aiiinotate 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/docs/db.md +21 -1
- package/docs/endpoints.md +2 -2
- package/package.json +3 -2
- package/docs/progress.md +0 -38
- package/docs/todo.md +0 -19
package/README.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
aiiinotate is a fast and lightweight annotation server for IIIF. It relies on `nodejs/fastify` and `mongodb` and provides an API to read/write/update/delete IIIF annotations and index manifests.
|
|
4
4
|
|
|
5
|
+
NOTE: currently, only annotations following the IIIF presentation API 2.0 and 2.1 are supported.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## API
|
|
10
|
+
|
|
11
|
+
See the [docs on the aiiinotate API](https://github.com/Aikon-platform/aiiinotate/blob/dev/docs/endpoints.md).
|
|
12
|
+
|
|
5
13
|
---
|
|
6
14
|
|
|
7
15
|
## PROD USAGE
|
|
@@ -138,9 +146,6 @@ Remember to have your `mongodb` service running: `sudo systemctl start mongod` !
|
|
|
138
146
|
```bash
|
|
139
147
|
# reload enabled
|
|
140
148
|
npm run dev
|
|
141
|
-
|
|
142
|
-
# reload disabled
|
|
143
|
-
npm run prod
|
|
144
149
|
```
|
|
145
150
|
|
|
146
151
|
- **Test the app**. NOTE: the tests will probably fail if you set the env variable `AIIINOTATE_STRICT_MODE` to `true`.
|
|
@@ -153,7 +158,7 @@ npm run test
|
|
|
153
158
|
|
|
154
159
|
|
|
155
160
|
```bash
|
|
156
|
-
npm cli
|
|
161
|
+
npm run cli
|
|
157
162
|
```
|
|
158
163
|
|
|
159
164
|
- **Process migrations**. (see [the CLI docs](https://github.com/Aikon-platform/aiiinotate/blob/dev/docs/cli.md) for more info)
|
package/docs/db.md
CHANGED
|
@@ -4,15 +4,35 @@
|
|
|
4
4
|
|
|
5
5
|
## Collections
|
|
6
6
|
|
|
7
|
+
- `annotations2`: a collection of annotations following the IIIF Presentation API 2.x (OpenAnnotation specification)
|
|
8
|
+
- `annotations3`: a collection of annotations following the IIIF Presentation API 3.x (WebAnnotation specification)
|
|
9
|
+
- `manifests2`: an index of manifests (manifest ID and array of canvas IDs of the manifest) following the IIIF Presentation API 2.x (OpenAnnotation specification)
|
|
10
|
+
- `manifests3`: an index of manifests (manifest ID and array of canvas IDs of the manifest) following the IIIF Presentation API 3.x (WebAnnotation specification)
|
|
11
|
+
|
|
12
|
+
Conversion between IIIF Presentation APIs 2 and 3 is not implemented.
|
|
13
|
+
|
|
7
14
|
---
|
|
8
15
|
|
|
9
16
|
## Validation rules
|
|
10
17
|
|
|
18
|
+
Two levels of validation rules are implemented:
|
|
19
|
+
- route-level validation
|
|
20
|
+
- database-level validation
|
|
21
|
+
|
|
22
|
+
At route-level, we ensure that the data has the absolutely necessary data to work with annotations.
|
|
23
|
+
|
|
24
|
+
At database-level (see [`src/schema`](https://github.com/Aikon-platform/aiiinotate/blob/main/src/schemas/) module, we define a complete model (in JSONSchema) to describe annotations.
|
|
25
|
+
|
|
26
|
+
**TLDR**: when inserting annotations (i.e., from an AnnotationList)
|
|
27
|
+
1. at [route-level](https://github.com/Aikon-platform/aiiinotate/blob/main/src/data/annotations/routes.js), we ensure that the AnnotationList is generally valid (contains a `resource` with annotations, each annotations contains a `on`...)
|
|
28
|
+
2. in the [`Annotations2`](https://github.com/Aikon-platform/aiiinotate/blob/main/src/data/annotations/annotations2.js) module, we do some extra checks and extra minimal reformatting to ensure that our annotations all have the same structure (i.e., convert `annotation.on` values to an array of `SpecificResources`). After finishing the cleanup, we are certain that an annotation can be inserted
|
|
29
|
+
3. when inserting an annotation in the MongDB `annotations2`, MongoDB uses the `annotation` schema defined in [`src/schemas/schemasPresentation2`](https://github.com/Aikon-platform/aiiinotate/blob/main/src/schemas/schemasPresentation2.js) to validate annotations before inserting.
|
|
30
|
+
|
|
11
31
|
---
|
|
12
32
|
|
|
13
33
|
## Migrations
|
|
14
34
|
|
|
15
|
-
Migrations are used to specify changes to the database's structure (creation and deletion of collections and indexes, changes to collection options such as validation rules etc.). Migration is done using [`migrate-mongo`](https://github.com/seppevs/migrate-mongo), a command-line interface for npm.
|
|
35
|
+
Migrations are used to specify changes to the database's structure (creation and deletion of collections and indexes, changes to collection options such as validation rules etc.). Migration is done using [`migrate-mongo`](https://github.com/seppevs/migrate-mongo), a command-line interface for npm.
|
|
16
36
|
|
|
17
37
|
*Note that here, migrations only concern changes to the structure, not changes to the data.*
|
|
18
38
|
|
package/docs/endpoints.md
CHANGED
|
@@ -13,10 +13,9 @@ In the docs below,
|
|
|
13
13
|
|
|
14
14
|
**aiiinotate** is meant to be able to handle both IIIF presentation APIs: the most common [2.x](https://iiif.io/api/presentation/2.1) and the more recent [3.x](https://iiif.io/api/presentation/3.0). Both APIs define a data structure for manifests, annotations, lists of annotations and collections of manifests.
|
|
15
15
|
|
|
16
|
-
**HOWEVER, in aiiinotate,
|
|
16
|
+
**HOWEVER, in aiiinotate, v2 and v3 data are isolated**: they form two separate collections, and no conversion is done between IIIF 2.x and 3.x data. This means that:
|
|
17
17
|
- **when communicating with aiiinotate**, you must specify a **IIIF presentation version in the query URL**. In the docs, this is described by the `iiif_version` keyword.
|
|
18
18
|
- **when inserting/updating data**, the data structure you provide must match the URL's `iiif_version`: you can't insert an annotation in v3 if your `iiif_version` is `2`.
|
|
19
|
-
- **when searching for data**, if you inserted an annotation in v3, you must search for it with `iiif_version = 3`.
|
|
20
19
|
- **TLDR**:
|
|
21
20
|
- your data must match the `iiif_version` argument
|
|
22
21
|
- if you insert an Annotation following the API v3.x, you can't search for it using `iiif_version=2`.
|
|
@@ -289,6 +288,7 @@ Batch insert multiple annotations.
|
|
|
289
288
|
|
|
290
289
|
#### Notes
|
|
291
290
|
|
|
291
|
+
- Calling this route using parallel processes (i.e., `Promise.all`) can cause data races which will cause inserts to fail
|
|
292
292
|
- Be wary of maximum body size, especially when sending AnnotationLists in your body. If possible, using `{ uri: string }` is better.
|
|
293
293
|
- All annotations within a single AnnotationList/Page may have different target canvases or manifests.
|
|
294
294
|
- See **Create/update an annotation**.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiiinotate",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "a fast IIIF-compliant annotation server",
|
|
5
5
|
"main": "./cli/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"lint": "npx eslint --fix",
|
|
19
19
|
"migrate": "npm run cli -- migrate",
|
|
20
20
|
"update_version": "python3 scripts/update_version.py",
|
|
21
|
-
"get_version": "python3 scripts/get_version.py"
|
|
21
|
+
"get_version": "python3 scripts/get_version.py",
|
|
22
|
+
"ttt": "echo 'HELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLO'"
|
|
22
23
|
},
|
|
23
24
|
"pre-commit": [
|
|
24
25
|
"lint"
|
package/docs/progress.md
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Dev progress
|
|
2
|
-
|
|
3
|
-
We mostly talk about which routes are done here
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Done
|
|
8
|
-
|
|
9
|
-
### Routes
|
|
10
|
-
|
|
11
|
-
Routes are only implemented with IIIF Presentation API 2.x, not with the 3.0 version.
|
|
12
|
-
|
|
13
|
-
#### Generic routes
|
|
14
|
-
|
|
15
|
-
- `GET /search-api/:iiifSearchVersion/manifests/:manifestShortId/search`: search API
|
|
16
|
-
|
|
17
|
-
#### Annotations routes
|
|
18
|
-
|
|
19
|
-
- `GET /annotations/:iiifPresentationVersion/search`: get all annotations for a canvas URI
|
|
20
|
-
- `POST /annotations/:iiifPresentationVersion/create`: create 1 annotation
|
|
21
|
-
- `POST /annotations/:iiifPresentationVersion/createMany`: create several annotations
|
|
22
|
-
- `POST /annotations/:iiifPresentationVersion/update`: update 1 annotation
|
|
23
|
-
- `DELETE /annotations/:iiifPresentationVersion/delete`: delete annotations, either by their `@id`, trget canvas URI (`on.full`), or their `on.manifestShortId`
|
|
24
|
-
|
|
25
|
-
=> all create/update/delete annotation routes are done !
|
|
26
|
-
|
|
27
|
-
#### Manifests routes
|
|
28
|
-
|
|
29
|
-
- `POST /manifests/:iiifPresentationVersion/create`: create a single manifest, either by including the manifest in the body or its URI
|
|
30
|
-
- `DELETE /manifests/:iiifPresentationVersion/delete`: delete a single manifest
|
|
31
|
-
- `GET /manifests/:iiifPresentationVersion`: return an index of all manifests as a collection
|
|
32
|
-
|
|
33
|
-
### Non-routes
|
|
34
|
-
|
|
35
|
-
- `manifests2`: `insert`, `insertMany` internal behaviours
|
|
36
|
-
- fetching and inserting manifests related to an annotation when using inserting annotations.
|
|
37
|
-
|
|
38
|
-
---
|
package/docs/todo.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# TODO
|
|
2
|
-
|
|
3
|
-
## Short term
|
|
4
|
-
|
|
5
|
-
- **pagination**
|
|
6
|
-
- add pagination to responses (`next` field in AnnotationLists)
|
|
7
|
-
- add `pageNumber` and `limit` parameters to routes to be able to specify page numbers and number of items in page from GET queries
|
|
8
|
-
- **update Mongo indexes**
|
|
9
|
-
- to reflect database changes (`annotation.on` is now an array)
|
|
10
|
-
- on frequently queried fields (`annotation.on.canvasIdx`, `annotation.on.manifestShortId`... => see what else is used in GET routes)
|
|
11
|
-
- **sort annotations collections**
|
|
12
|
-
- by `canvasIdx`
|
|
13
|
-
- by position on the page (y-offset then x-offset, see `xywh`)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Mid term
|
|
17
|
-
|
|
18
|
-
- **aiiinotate CLI** to import and export data easily
|
|
19
|
-
- **IIIF presentation 3**
|