@allmaps/id
Advanced tools
Comparing version 1.0.0-beta.16 to 1.0.0-beta.17
{ | ||
"name": "@allmaps/id", | ||
"version": "1.0.0-beta.16", | ||
"version": "1.0.0-beta.17", | ||
"description": "IDs for Allmaps", | ||
@@ -44,2 +44,3 @@ "type": "module", | ||
"format": "prettier --write src test", | ||
"prebuild": "npm run documentation", | ||
"documentation": "documentation readme ./dist/index.js --section=API" | ||
@@ -73,3 +74,3 @@ }, | ||
}, | ||
"gitHead": "45c0da2e8fa40e3d97a6a5d2f3531d6c03bd34aa" | ||
"gitHead": "7ce2bc3fe2133055b11e3034fcf0a386e903492e" | ||
} |
@@ -7,12 +7,12 @@ # @allmaps/id | ||
* Given the following manifest URL: https://polona.pl/iiif/item/NTU5NTE4OTg/manifest.json, | ||
* The output of the [`generateId`](#generateid) function will be: `4ac2770ae8624e38`, | ||
* We can use this ID to view the annotation for the georeferenced maps in the manifest in Allmaps: | ||
https://dev.annotations.allmaps.org/manifests/4ac2770ae8624e38. | ||
* Given the following manifest URL: https://digital.zlb.de/viewer/api/v1/records/34231682/manifest/, | ||
* The output of the [`generateId`](#generateid) function will be: `6f5a7b547c8f6fbe`, | ||
* We can use this ID to lookup the [Georeference Annotation](https://iiif.io/api/extension/georef/) for the georeferenced maps in this manifest using Allmaps API: | ||
https://annotations.allmaps.org/manifests/6f5a7b547c8f6fbe. | ||
To see @allmaps/id in action, view this [Observable notebook](https://observablehq.com/@bertspaan/ids-for-allmaps?collection=@bertspaan/allmaps). | ||
To see @allmaps/id in action, view this [Observable notebook](https://observablehq.com/@allmaps/the-allmaps-id-module). | ||
## Usage | ||
This is an ESM-only module that works in browsers or in Node.js. | ||
This is an ESM-only module that works in browsers and Node.js. | ||
@@ -25,6 +25,5 @@ Node.js: | ||
import { generateId } from '@allmaps/id' | ||
const url = | ||
'https://orka.bibliothek.uni-kassel.de/viewer/rest/iiif/manifests/1535113582549/manifest/' | ||
const url = 'https://digital.zlb.de/viewer/api/v1/records/34231682/manifest/' | ||
const id = await generateId(url) | ||
console.log(id) | ||
// id = '6f5a7b547c8f6fbe' | ||
``` | ||
@@ -47,2 +46,12 @@ | ||
## CLI | ||
Generating Allmaps IDs is also possible using the [Allmaps CLI](https://github.com/allmaps/allmaps/tree/main/apps/cli). | ||
For example: | ||
```sh | ||
echo https://digital.zlb.de/viewer/api/v1/records/34231682/manifest/ | allmaps id | ||
``` | ||
## API | ||
@@ -54,9 +63,21 @@ | ||
* [generateHash](#generatehash) | ||
* [Parameters](#parameters) | ||
* [generateId](#generateid) | ||
* [Parameters](#parameters) | ||
* [Parameters](#parameters-1) | ||
* [generateRandomId](#generaterandomid) | ||
* [Parameters](#parameters-1) | ||
* [Parameters](#parameters-2) | ||
* [generateChecksum](#generatechecksum) | ||
* [Parameters](#parameters-2) | ||
* [Parameters](#parameters-3) | ||
### generateHash | ||
Computes SHA-1 hash of input string. | ||
#### Parameters | ||
* `str` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Input string. | ||
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** SHA-1 hash of `str`. | ||
### generateId | ||
@@ -71,3 +92,3 @@ | ||
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** First `length` characters of the SHA-1 hash of `str`. | ||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** First `length` characters of the SHA-1 hash of `str`. | ||
@@ -82,3 +103,3 @@ ### generateRandomId | ||
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** First `length` characters of the SHA-1 hash of a random UUID. | ||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** First `length` characters of the SHA-1 hash of a random UUID. | ||
@@ -94,2 +115,2 @@ ### generateChecksum | ||
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** First `length` characters of the SHA-1 hash of sorted and serialized version of `obj`. | ||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** First `length` characters of the SHA-1 hash of sorted and serialized version of `obj`. |
15400
110