@annotorious/core 3.0.0-pre-alpha-51 → 3.0.0-pre-alpha-52
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
package/src/model/Annotation.ts
CHANGED
|
@@ -26,6 +26,8 @@ export interface W3CAnnotationBody {
|
|
|
26
26
|
|
|
27
27
|
value?: string;
|
|
28
28
|
|
|
29
|
+
source?: string;
|
|
30
|
+
|
|
29
31
|
created?: Date;
|
|
30
32
|
|
|
31
33
|
creator?: {
|
|
@@ -78,23 +80,30 @@ const hashCode = (obj: Object): string => {
|
|
|
78
80
|
export const parseW3CBodies = (
|
|
79
81
|
body: W3CAnnotationBody | W3CAnnotationBody[],
|
|
80
82
|
annotationId: string
|
|
81
|
-
): AnnotationBody[] => (Array.isArray(body) ? body : [body]).map(
|
|
83
|
+
): AnnotationBody[] => (Array.isArray(body) ? body : [body]).map(body => {
|
|
84
|
+
|
|
85
|
+
// Exctract properties that conform to the internal model, but keep custom props
|
|
86
|
+
const { id, type, purpose, value, created, creator, ...rest} = body;
|
|
87
|
+
|
|
82
88
|
// The internal model strictly requires IDs. (Because multi-user scenarios
|
|
83
89
|
// will have problems without them.) In the W3C model, bodys *may* have IDs.
|
|
84
90
|
// We'll create ad-hoc IDs for bodies without IDs, but want to make sure that
|
|
85
91
|
// generating the ID is idempotent: the same body should always get the same ID.
|
|
86
92
|
// This will avoid unexpected results when checking for equality.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
return {
|
|
94
|
+
id: id || hashCode(body),
|
|
95
|
+
annotation: annotationId,
|
|
96
|
+
type,
|
|
97
|
+
purpose,
|
|
98
|
+
value,
|
|
99
|
+
created,
|
|
100
|
+
creator: creator ?
|
|
101
|
+
typeof creator === 'object' ? { ...creator }: creator :
|
|
102
|
+
undefined,
|
|
103
|
+
...rest
|
|
104
|
+
}
|
|
97
105
|
|
|
106
|
+
});
|
|
98
107
|
|
|
99
108
|
export const serializeW3CBodies = (bodies: AnnotationBody[]): W3CAnnotationBody[] =>
|
|
100
109
|
bodies.map(b => {
|
|
@@ -21,7 +21,7 @@ export const getContributors = (annotation: Annotation): User[] => {
|
|
|
21
21
|
|
|
22
22
|
export const createBody = (
|
|
23
23
|
annotation: Annotation,
|
|
24
|
-
payload: {
|
|
24
|
+
payload: { [key: string]: any },
|
|
25
25
|
created?: Date,
|
|
26
26
|
creator?: User
|
|
27
27
|
): AnnotationBody => ({
|