Skip to content

Commit 9f46292

Browse files
authored
Merge pull request #66 from IIIF-Commons/feature/missing-auth2-services
Fixed missing Auth2 services
2 parents bc661d6 + 52b1313 commit 9f46292

4 files changed

Lines changed: 20 additions & 15 deletions

File tree

‎src/presentation-3/normalize.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {
1010
ResourceProvider,
1111
Selector,
1212
Service,
13+
Services,
1314
SpecificResource,
1415
} from "./types";
1516
import type {
@@ -85,13 +86,13 @@ function mapToEntities(entities: Record<string, Record<string, NormalizedEntity>
8586
if (resource && resource.id && type) {
8687
storeType[resource.id] = storeType[resource.id]
8788
? (mergeEntities(storeType[resource.id]!, resource, {
88-
parent: context.parent,
89-
isTopLevel: topLevel.id === resource.id,
90-
}) as any)
89+
parent: context.parent,
90+
isTopLevel: topLevel.id === resource.id,
91+
}) as any)
9192
: mergeEntities({ id: resource.id, type: resource.type } as any, resource, {
92-
parent: context.parent,
93-
isTopLevel: topLevel.id === resource.id,
94-
});
93+
parent: context.parent,
94+
isTopLevel: topLevel.id === resource.id,
95+
});
9596
return {
9697
id: resource.id,
9798
type: type === "ContentResource" ? type : resource.type,
@@ -257,8 +258,7 @@ export function mergeEntities(
257258
}
258259

259260
throw new Error(
260-
`Can only merge entities with identical identifiers and type! ${incoming.type}(${incoming.id}) => ${
261-
(existing as any).type
261+
`Can only merge entities with identical identifiers and type! ${incoming.type}(${incoming.id}) => ${(existing as any).type
262262
}(${(existing as any).id})`
263263
);
264264
}
@@ -308,7 +308,7 @@ function normalizeService(_service: any): any {
308308
}
309309

310310
function recordServiceForLoading(store: CompatibleStore["entities"]) {
311-
return (resource: Service) => {
311+
return (resource: Service | Services) => {
312312
store.Service = store.Service ? store.Service : {};
313313
const id: string = (resource as any).id || (resource as any)["@id"];
314314
const normalizedResource = normalizeService(resource);

‎src/presentation-3/traverse.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
SpecificResource,
1919
ResourceProvider,
2020
StructuralProperties,
21+
Services,
2122
} from "./types";
2223
import type { GeoJSON } from "../shared/geojson";
2324
import { isSpecificResource } from "../shared/is-specific-resource";
@@ -50,6 +51,7 @@ export type Presentation3Resource =
5051
| ChoiceBody
5152
| Range
5253
| Service
54+
| Services
5355
| ResourceProvider
5456
| SpecificResource
5557
| GeoJSON;
@@ -73,7 +75,7 @@ export type TraversalMap = {
7375
contentResource?: Array<Traversal<ContentResource>>;
7476
choice?: Array<Traversal<ChoiceTarget | ChoiceBody>>;
7577
range?: Array<Traversal<Range>>;
76-
service?: Array<Traversal<Service>>;
78+
service?: Array<Traversal<Services>>;
7779
agent?: Array<Traversal<ResourceProvider>>;
7880
specificResource?: Array<Traversal<SpecificResource>>;
7981
geoJson?: Array<Traversal<GeoJSON>>;
@@ -512,13 +514,14 @@ export class Traverse {
512514
}, object);
513515
}
514516

517+
traverseService<S extends Service | Services>(service: S, parent?: Presentation3Resource): S;
515518
traverseService(service: Service, parent?: Presentation3Resource): Service;
516-
traverseService(service: Service, parent?: any): Service {
519+
traverseService<S extends Service | Services>(service: S, parent?: any): S {
517520
const _service: any = Object.assign({}, service);
518521
if (_service && _service.service) {
519522
_service.service = ensureArray(_service.service).map((innerService: any) => this.traverseService(innerService));
520523
}
521-
return this.traverseType<Service>(_service, { parent }, this.traversals.service);
524+
return this.traverseType<S>(_service, { parent }, this.traversals.service);
522525
}
523526

524527
traverseUnknown(

‎src/presentation-3/types/legacy/src/iiif/linking.d.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ContentResource } from "../resources/contentResource";
2-
import { Service } from "../resources/service";
2+
import { Service, Services } from "../resources/service";
33
import { Canvas } from "../resources/canvas";
44
import { AnnotationCollection } from "../resources/annotationCollection";
55
import { Reference } from "../reference";
@@ -71,7 +71,7 @@ export type LinkingProperties = {
7171
* A Manifest may have the services property.
7272
* Clients should process services on a Manifest.
7373
*/
74-
services: Service[];
74+
services: Services[];
7575

7676
/**
7777
* A resource that is an alternative, non-IIIF representation of the resource that has the rendering property. Such
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { AuthProbeService2 } from "../services/auth-2";
1+
import { AuthAccessService2, AuthProbeService2 } from "../services/auth-2";
22
import { AuthService } from "../services/auth-service";
33
import { GeoJsonService } from "../services/geo-json";
44
import { ImageService } from "../services/image-service";
55
import { SearchService } from "../services/search";
66
import { Search2Service } from "../services/search-2";
77

88
export type Service = AuthService | GeoJsonService | ImageService | SearchService | AuthProbeService2 | Search2Service;
9+
10+
export type Services = Service | AuthAccessService2;

0 commit comments

Comments
 (0)