{"id":27288095,"url":"https://github.com/jptmoore/maniiifest","last_synced_at":"2025-04-11T20:28:06.706Z","repository":{"id":251342967,"uuid":"836747854","full_name":"jptmoore/maniiifest","owner":"jptmoore","description":"Typesafe IIIF presentation v3 parsing without external dependencies","archived":false,"fork":false,"pushed_at":"2025-03-31T10:47:30.000Z","size":749,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T11:33:18.082Z","etag":null,"topics":["iiif","iiif-presentation-3","manifest","parser"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jptmoore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-01T13:27:52.000Z","updated_at":"2025-03-31T10:47:26.000Z","dependencies_parsed_at":"2024-08-28T15:29:45.046Z","dependency_job_id":"4f280542-d6b6-425a-bb43-4cdc64b6576e","html_url":"https://github.com/jptmoore/maniiifest","commit_stats":null,"previous_names":["jptmoore/maniiifest"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jptmoore%2Fmaniiifest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jptmoore%2Fmaniiifest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jptmoore%2Fmaniiifest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jptmoore%2Fmaniiifest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jptmoore","download_url":"https://codeload.github.com/jptmoore/maniiifest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248475325,"owners_count":21110068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iiif","iiif-presentation-3","manifest","parser"],"created_at":"2025-04-11T20:28:05.930Z","updated_at":"2025-04-11T20:28:06.699Z","avatar_url":"https://github.com/jptmoore.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Maniiifest\n\n## Description\n\nManiiifest provides methods to parse and manipulate [IIIF Presentation API 3.0](https://iiif.io/api/presentation/3.0/) specification and [W3C web annotations](https://www.w3.org/TR/annotation-model/). It ensures type safety and offers utility functions for working with IIIF data. Maniiifest takes a parser generator approach to generating TypeScript type definitions using a domain-specific language (DSL). The current specification is available [here](https://raw.githubusercontent.com/jptmoore/maniiifest/main/src/specification.atd).\n\nA typechecker/validator built using maniiifest is available online [here](https://maniiifest.onrender.com/).\n\n## Installation\n\nInstall the package using npm:\n\n```sh\nnpm install maniiifest --save-dev\n```\n\n## Usage\n\nImport and use the functions in your TypeScript project:\n\n  ```typescript\nimport { Maniiifest } from 'maniiifest';\n\nconst manifest = {\n    \"id\": \"https://iiif.io/api/cookbook/recipe/0032-collection/manifest-02.json\",\n    \"type\": \"Manifest\",\n    \"label\": { \"en\": [\"Northeaster\"] }\n}\n\nconst parser = new Maniiifest(manifest);\nconst label = parser.getManifestLabelByLanguage('en');\nconsole.log(label?.['en']);\n  ```\n\nTo parse web annotations you need to provide the type of annotation to the constructor. For example:\n\n```typescript\nconst annotationParser = new Maniiifest(annotation, \"Annotation\");\nconst annotationPageParser = new Maniiifest(annotation_page, \"AnnotationPage\");\nconst annotationCollectionParser = new Maniiifest(annotation_collection, \"AnnotationCollection\");\n```\nThe aim is to support the most relevant subset of the W3C standard as used within IIIF manifests.\n\n## Documentation\n\nDocumentation for the current supported get methods and generators available [here](https://jptmoore.github.io/maniiifest/classes/Maniiifest.html). If you would like to see other methods added please raise an issue.\n\n\n## Tutorial\n\nIn this example we will use generators to work with a complex collection that nests manifests within it.\n\n```typescript\nimport { Maniiifest } from 'maniiifest';\n\nasync function main() {\n    const response = await fetch('https://iiif.wellcomecollection.org/presentation/b19974760');\n    const jsonData = await response.json();\n    const parser = new Maniiifest(jsonData);\n    const manifests = parser.iterateCollectionManifest();\n    let count = 0;\n    for (const item of manifests) {\n        if (count \u003e= 25) break;\n        const manifestRef = new Maniiifest(item);\n        const metadata = manifestRef.iterateManifestMetadata();\n        for (const item of metadata) {\n            console.log(item);\n        }\n        count++;\n    }\n}\n\nmain()\n```\nThe output will be the metadata from the first 25 manifests:\n\n```sh\n❯ ts-node tutorial.ts\n{ label: { en: [ 'Volume' ] }, value: { none: [ '1' ] } }\n{ label: { en: [ 'Year' ] }, value: { none: [ '1859' ] } }\n{ label: { en: [ 'Month' ] }, value: { en: [ 'September' ] } }\n{\n  label: { en: [ 'DisplayDate' ] },\n  value: { en: [ '15. September 1859' ] }\n}\n{ label: { en: [ 'Volume' ] }, value: { none: [ '1' ] } }\n{ label: { en: [ 'Year' ] }, value: { none: [ '1859' ] } }\n{ label: { en: [ 'Month' ] }, value: { en: [ 'October' ] } }\n.....\n```\n\nIn this example we will work with externally referenced W3C annotations. \n```typescript\nimport { Maniiifest } from 'maniiifest';\n\nasync function main() {\n    const response = await fetch('https://iiif.io/api/cookbook/recipe/0269-embedded-or-referenced-annotations/manifest.json');\n    const jsonData = await response.json();\n    const parser = new Maniiifest(jsonData);\n    const annotationPages = parser.iterateManifestCanvasW3cAnnotationPage();\n    for (const annotationPage of annotationPages) {\n        const response = await fetch(annotationPage.id);\n        const jsonData = await response.json();\n        const parser = new Maniiifest(jsonData, \"AnnotationPage\");\n        const annotations = parser.iterateAnnotationPageAnnotation();\n        for (const annotation of annotations) {\n            console.log(annotation.body?.value);\n        }\n    }\n}\n\nmain()\n```\nThe output will the commenting value from the single annotation:\n```\nGöttinger Marktplatz mit Gänseliesel Brunnen\n```\n\nIn this example we will work with an annotation that uses the [georeference](https://iiif.io/api/extension/georef/) extension.\n\n```typescript\nimport { Maniiifest } from 'maniiifest';\n\nasync function main() {\n    const response = await fetch('https://annotations.allmaps.org/maps/cde9210870a2652a');\n    const jsonData = await response.json();\n    const annotation = new Maniiifest(jsonData, \"Annotation\");\n    const points = Array.from(annotation.iterateAnnotationGeometryPointCoordinates());\n    for (let i = 0; i \u003c points.length; i += 2) {\n        console.log(`x: ${points[i]}, y: ${points[i + 1]}`);\n    } \n}\n\nmain()\n```\nThe output will be all the point coordinates:\n```\nx: -70.9375518, y: 42.4811769\nx: -70.9398138, y: 42.4825027\nx: -70.9403993, y: 42.4821228\nx: -70.9434097, y: 42.480079\nx: -70.9373183, y: 42.4793787\nx: -70.9454651, y: 42.4765122\nx: -70.9364491, y: 42.4804618\nx: -70.9377961, y: 42.4788144\nx: -70.935966, y: 42.4809988\nx: -70.9390062, y: 42.4772977\nx: -70.9398389, y: 42.4815905\nx: -70.9369067, y: 42.4798999\n```\n\nMore examples of parsing complex manifests and collections can be found [here](https://github.com/jptmoore/maniiitest).\n\n## Scripts\n\n- `npm run build`: Compile the TypeScript code.\n- `npm run test`: Run the tests using Jest.\n- `npm start`: Run the example script.\n- `npm run generate-docs`: Generate documentation using TypeDoc.\n\n## License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjptmoore%2Fmaniiifest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjptmoore%2Fmaniiifest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjptmoore%2Fmaniiifest/lists"}