UNPKG

@allmaps/iiif-parser

Version:

Allmaps IIIF parser

71 lines (70 loc) 3.62 kB
import { z } from 'zod'; import { CollectionSchema } from '../schemas/iiif.js'; import { EmbeddedCollection2Schema } from '../schemas/presentation.2.js'; import { EmbeddedCollection3Schema } from '../schemas/presentation.3.js'; import { EmbeddedManifest, Manifest } from './manifest.js'; import type { Image, EmbeddedImage } from './image.js'; import type { Canvas } from './canvas.js'; import type { LanguageString, MajorVersion, FetchNextItemOptions, FetchNextItemResults, Metadata, NavDate, NavPlace, Thumbnail, SeeAlso, Summary, RequiredStatement, Annotations, Homepage, Rendering, ParseOptions, ConstructorOptions } from '../lib/types.js'; type CollectionType = z.infer<typeof CollectionSchema>; type EmbeddedCollectionType = z.infer<typeof EmbeddedCollection2Schema> | z.infer<typeof EmbeddedCollection3Schema>; declare const CollectionTypeString = "collection"; export declare class EmbeddedCollection { uri: string; type: typeof CollectionTypeString; majorVersion: MajorVersion; label?: LanguageString; description?: LanguageString; metadata?: Metadata; navDate?: NavDate; navPlace?: NavPlace; thumbnail?: Thumbnail; embedded: boolean; constructor(parsedCollection: CollectionType | EmbeddedCollectionType); /** * Parses a IIIF Collection and returns a [Collection](#collection) containing the parsed version * @param iiifCollection - Source data of IIIF Collection * @param majorVersion - IIIF API version of Collection. If not provided, it will be determined automatically * @returns Parsed IIIF Collection * @static */ static parse(iiifCollection: unknown, options?: Partial<ParseOptions>): Collection; } /** * Parsed IIIF Collection * * @property uri - URI of Collection * @property label - Label of Collection * @property items - Items in Collection * @property majorVersion - IIIF API version of Collection * @property type - Resource type, equals 'collection' */ export declare class Collection extends EmbeddedCollection { #private; source?: unknown; items: (Collection | EmbeddedCollection | Manifest | EmbeddedManifest)[]; embedded: boolean; homepage?: Homepage; rendering?: Rendering; seeAlso?: SeeAlso; summary?: Summary; requiredStatement?: RequiredStatement; annotations?: Annotations; constructor(parsedCollection: CollectionType, options?: Partial<ConstructorOptions>); /** * Parses a IIIF Collection and returns a [Collection](#collection) containing the parsed version * @param iiifCollection - Source data of IIIF Collection * @param majorVersion - IIIF API version of Collection. If not provided, it will be determined automatically * @returns Parsed IIIF Collection */ static parse(iiifCollection: unknown, options?: Partial<ParseOptions>): Collection; get canvases(): Canvas[]; get images(): (Image | EmbeddedImage)[]; fetchItemWithIndex(index: number, fetchFn?: typeof fetch): Promise<EmbeddedCollection | Collection | Manifest | EmbeddedManifest>; fetchItemWithId(id: string, fetchFn?: typeof fetch): Promise<EmbeddedCollection | EmbeddedManifest | undefined>; getItemAtPath(path: number[]): EmbeddedCollection | EmbeddedManifest | Canvas | undefined; fetchUntilPath(path: number[]): Promise<void>; fetchAllItems(options?: Partial<FetchNextItemOptions>): Promise<FetchNextItemResults<Collection | Manifest | Image>[]>; fetchNextItem(options?: Partial<FetchNextItemOptions>, depth?: number): AsyncGenerator<FetchNextItemResults<Collection | Manifest | Image>, void, void>; } export {};