aiiinotate 0.9.0 → 0.9.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiiinotate",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "a fast IIIF-compliant annotation server",
5
5
  "main": "./cli/index.js",
6
6
  "type": "module",
@@ -391,12 +391,18 @@ class Annotations2 extends CollectionAbstract {
391
391
  * TODO: handle side effects when changing `annotation.on`: changes that can affect `manifestShortId`, `manifestUri` and `canvasIdx`
392
392
  * (for example, updating `annotation.on.full` would ask to change `canvasIdx`).
393
393
  * @param {object} annotation
394
- * @param {boolean} throwOnXywhError
394
+ * @param {boolean?} throwOnCanvasIndexError
395
+ * @param {boolean?} throwOnXywhError
395
396
  * @returns {Promise<UpdateResponseType>}
396
397
  */
397
- async updateAnnotation(annotation, throwOnXywhError=STRICT_MODE) {
398
+ async updateAnnotation(annotation, throwOnCanvasIndexError=STRICT_MODE, throwOnXywhError=STRICT_MODE) {
398
399
  // necessary: on insert, the `@id` received is modified by `this.#cleanAnnotationList`.
399
400
  annotation = await this.#cleanAnnotation({ annotation, update: true, throwOnXywhError });
401
+ // necessary:
402
+ // 1. handle changes to target canvas' manifest
403
+ // 2. when updating an annotation in MAE, the non-standard fields in the annotation are lost:
404
+ // `canvasIdx`, `manifestUri`, `manifestShortId` are not serialized/deserialized in MAE.
405
+ annotation = await this.#insertManifestsAndGetCanvasIdx(annotation, throwOnCanvasIndexError);
400
406
  const
401
407
  query = { "@id": annotation["@id"] },
402
408
  update = { $set: annotation };
@@ -410,8 +416,13 @@ class Annotations2 extends CollectionAbstract {
410
416
  * when inserting, aiiinotate attempts to fetch the target manifest of an annotation and to add the canvas number of the annotation to `annotation.on`.
411
417
  * this may fail for a number of reasons (manifest URL and JSON structure, server storing the manifest is inaccessible...). if `throwOnCanvasIndexError`, it will raise.
412
418
  *
419
+ * about `throwOnXywhError`:
420
+ * we try to calculate the bounding box of an annotation. this is only supported for FragmentSelectors and SvgSelectors, and will fail otherwise
421
+ * => if `throwOnXywhError`, throw if there is an error calculating the bounding box.
422
+ *
413
423
  * @param {object} annotationList
414
424
  * @param {boolean?} throwOnCanvasIndexError
425
+ * @param {boolean?} throwOnXywhError
415
426
  * @returns {Promise<InsertResponseType>}
416
427
  */
417
428
  async insertAnnotationList(annotationList, throwOnCanvasIndexError=STRICT_MODE, throwOnXywhError=STRICT_MODE) {
@@ -240,7 +240,7 @@ function annotationsRoutes(fastify, options, done) {
240
240
  if ( iiifPresentationVersion === 2 ) {
241
241
  return action==="create"
242
242
  ? await annotations2.insertAnnotation(annotation, throwOnCanvasIndexError, throwOnXywhError)
243
- : await annotations2.updateAnnotation(annotation, throwOnXywhError);
243
+ : await annotations2.updateAnnotation(annotation, throwOnCanvasIndexError, throwOnXywhError);
244
244
  } else {
245
245
  annotations3.notImplementedError();
246
246
  }