From 52b1313839333b2a65f7455f2c197cec6167a463 Mon Sep 17 00:00:00 2001 From: Stephen Fraser Date: Tue, 15 Sep 2026 16:41:58 +0100 Subject: [PATCH] Fixed missing Auth2 services --- src/presentation-3/normalize.ts | 18 +++++++++--------- src/presentation-3/traverse.ts | 9 ++++++--- .../types/legacy/src/iiif/linking.d.ts | 4 ++-- .../types/legacy/src/resources/service.d.ts | 4 +++- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/presentation-3/normalize.ts b/src/presentation-3/normalize.ts index 03e7cb0..2782f99 100644 --- a/src/presentation-3/normalize.ts +++ b/src/presentation-3/normalize.ts @@ -10,6 +10,7 @@ import type { ResourceProvider, Selector, Service, + Services, SpecificResource, } from "./types"; import type { @@ -85,13 +86,13 @@ function mapToEntities(entities: Record if (resource && resource.id && type) { storeType[resource.id] = storeType[resource.id] ? (mergeEntities(storeType[resource.id]!, resource, { - parent: context.parent, - isTopLevel: topLevel.id === resource.id, - }) as any) + parent: context.parent, + isTopLevel: topLevel.id === resource.id, + }) as any) : mergeEntities({ id: resource.id, type: resource.type } as any, resource, { - parent: context.parent, - isTopLevel: topLevel.id === resource.id, - }); + parent: context.parent, + isTopLevel: topLevel.id === resource.id, + }); return { id: resource.id, type: type === "ContentResource" ? type : resource.type, @@ -257,8 +258,7 @@ export function mergeEntities( } throw new Error( - `Can only merge entities with identical identifiers and type! ${incoming.type}(${incoming.id}) => ${ - (existing as any).type + `Can only merge entities with identical identifiers and type! ${incoming.type}(${incoming.id}) => ${(existing as any).type }(${(existing as any).id})` ); } @@ -308,7 +308,7 @@ function normalizeService(_service: any): any { } function recordServiceForLoading(store: CompatibleStore["entities"]) { - return (resource: Service) => { + return (resource: Service | Services) => { store.Service = store.Service ? store.Service : {}; const id: string = (resource as any).id || (resource as any)["@id"]; const normalizedResource = normalizeService(resource); diff --git a/src/presentation-3/traverse.ts b/src/presentation-3/traverse.ts index c3038f7..994c2b4 100644 --- a/src/presentation-3/traverse.ts +++ b/src/presentation-3/traverse.ts @@ -18,6 +18,7 @@ import type { SpecificResource, ResourceProvider, StructuralProperties, + Services, } from "./types"; import type { GeoJSON } from "../shared/geojson"; import { isSpecificResource } from "../shared/is-specific-resource"; @@ -50,6 +51,7 @@ export type Presentation3Resource = | ChoiceBody | Range | Service + | Services | ResourceProvider | SpecificResource | GeoJSON; @@ -73,7 +75,7 @@ export type TraversalMap = { contentResource?: Array>; choice?: Array>; range?: Array>; - service?: Array>; + service?: Array>; agent?: Array>; specificResource?: Array>; geoJson?: Array>; @@ -512,13 +514,14 @@ export class Traverse { }, object); } + traverseService(service: S, parent?: Presentation3Resource): S; traverseService(service: Service, parent?: Presentation3Resource): Service; - traverseService(service: Service, parent?: any): Service { + traverseService(service: S, parent?: any): S { const _service: any = Object.assign({}, service); if (_service && _service.service) { _service.service = ensureArray(_service.service).map((innerService: any) => this.traverseService(innerService)); } - return this.traverseType(_service, { parent }, this.traversals.service); + return this.traverseType(_service, { parent }, this.traversals.service); } traverseUnknown( diff --git a/src/presentation-3/types/legacy/src/iiif/linking.d.ts b/src/presentation-3/types/legacy/src/iiif/linking.d.ts index 1ad7097..e353977 100644 --- a/src/presentation-3/types/legacy/src/iiif/linking.d.ts +++ b/src/presentation-3/types/legacy/src/iiif/linking.d.ts @@ -1,5 +1,5 @@ import { ContentResource } from "../resources/contentResource"; -import { Service } from "../resources/service"; +import { Service, Services } from "../resources/service"; import { Canvas } from "../resources/canvas"; import { AnnotationCollection } from "../resources/annotationCollection"; import { Reference } from "../reference"; @@ -71,7 +71,7 @@ export type LinkingProperties = { * A Manifest may have the services property. * Clients should process services on a Manifest. */ - services: Service[]; + services: Services[]; /** * A resource that is an alternative, non-IIIF representation of the resource that has the rendering property. Such diff --git a/src/presentation-3/types/legacy/src/resources/service.d.ts b/src/presentation-3/types/legacy/src/resources/service.d.ts index 7d92c7b..2341f94 100644 --- a/src/presentation-3/types/legacy/src/resources/service.d.ts +++ b/src/presentation-3/types/legacy/src/resources/service.d.ts @@ -1,4 +1,4 @@ -import { AuthProbeService2 } from "../services/auth-2"; +import { AuthAccessService2, AuthProbeService2 } from "../services/auth-2"; import { AuthService } from "../services/auth-service"; import { GeoJsonService } from "../services/geo-json"; import { ImageService } from "../services/image-service"; @@ -6,3 +6,5 @@ import { SearchService } from "../services/search"; import { Search2Service } from "../services/search-2"; export type Service = AuthService | GeoJsonService | ImageService | SearchService | AuthProbeService2 | Search2Service; + +export type Services = Service | AuthAccessService2;