@annotorious/core
Advanced tools
Comparing version 3.0.0-pre-alpha-51 to 3.0.0-pre-alpha-52
{ | ||
"name": "@annotorious/core", | ||
"version": "3.0.0-pre-alpha-51", | ||
"version": "3.0.0-pre-alpha-52", | ||
"description": "Annotorious core types and functions", | ||
@@ -5,0 +5,0 @@ "author": "Rainer Simon", |
@@ -47,3 +47,3 @@ import type { User } from './User'; | ||
value: string; | ||
value?: string; | ||
@@ -50,0 +50,0 @@ creator?: User; |
@@ -29,2 +29,4 @@ import type { AnnotationBody } from './Annotation'; | ||
source?: string; | ||
created?: Date; | ||
@@ -82,3 +84,7 @@ | ||
annotationId: string | ||
): AnnotationBody[] => (Array.isArray(body) ? body : [body]).map(b => ({ | ||
): AnnotationBody[] => (Array.isArray(body) ? body : [body]).map(body => { | ||
// Exctract properties that conform to the internal model, but keep custom props | ||
const { id, type, purpose, value, created, creator, ...rest} = body; | ||
// The internal model strictly requires IDs. (Because multi-user scenarios | ||
@@ -89,13 +95,16 @@ // will have problems without them.) In the W3C model, bodys *may* have IDs. | ||
// This will avoid unexpected results when checking for equality. | ||
id: b.id || hashCode(b), | ||
annotation: annotationId, | ||
type: b.type, | ||
purpose: b.purpose, | ||
value: b.value, | ||
created: b.created, | ||
creator: b.creator ? | ||
typeof b.creator === 'object' ? { ...b.creator }: b.creator : | ||
undefined | ||
})); | ||
return { | ||
id: id || hashCode(body), | ||
annotation: annotationId, | ||
type, | ||
purpose, | ||
value, | ||
created, | ||
creator: creator ? | ||
typeof creator === 'object' ? { ...creator }: creator : | ||
undefined, | ||
...rest | ||
} | ||
}); | ||
@@ -102,0 +111,0 @@ export const serializeW3CBodies = (bodies: AnnotationBody[]): W3CAnnotationBody[] => |
@@ -24,3 +24,3 @@ import { v4 as uuidv4 } from 'uuid'; | ||
annotation: Annotation, | ||
payload: { value: string, [key: string]: any }, | ||
payload: { [key: string]: any }, | ||
created?: Date, | ||
@@ -27,0 +27,0 @@ creator?: User |
47379
1181