@lincs.project/webannotation-schema 1.0.0 → 1.0.2
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 +65 -31
- package/dist/index.d.mts +2728 -0
- package/dist/index.d.ts +2728 -0
- package/dist/index.js +5463 -0
- package/dist/index.mjs +5433 -0
- package/package.json +44 -32
- package/dist/context.jsonld +0 -24
- package/dist/defs.jsonld +0 -949
- package/dist/schema.jsonld +0 -621
- package/dist/validate.js +0 -1
- package/lib/index.d.ts +0 -145
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -13
- package/lib/index.js.map +0 -1
- package/lib/schema/config.d.ts +0 -4
- package/lib/schema/config.d.ts.map +0 -1
- package/lib/schema/config.js +0 -4
- package/lib/schema/config.js.map +0 -1
- package/lib/schema/context.d.ts +0 -25
- package/lib/schema/context.d.ts.map +0 -1
- package/lib/schema/context.js +0 -25
- package/lib/schema/context.js.map +0 -1
- package/lib/schema/definitions/agent.d.ts +0 -36
- package/lib/schema/definitions/agent.d.ts.map +0 -1
- package/lib/schema/definitions/agent.js +0 -82
- package/lib/schema/definitions/agent.js.map +0 -1
- package/lib/schema/definitions/body/citation.d.ts +0 -27
- package/lib/schema/definitions/body/citation.d.ts.map +0 -1
- package/lib/schema/definitions/body/citation.js +0 -53
- package/lib/schema/definitions/body/citation.js.map +0 -1
- package/lib/schema/definitions/body/common.d.ts +0 -17
- package/lib/schema/definitions/body/common.d.ts.map +0 -1
- package/lib/schema/definitions/body/common.js +0 -46
- package/lib/schema/definitions/body/common.js.map +0 -1
- package/lib/schema/definitions/body/conceptualObject.d.ts +0 -27
- package/lib/schema/definitions/body/conceptualObject.d.ts.map +0 -1
- package/lib/schema/definitions/body/conceptualObject.js +0 -61
- package/lib/schema/definitions/body/conceptualObject.js.map +0 -1
- package/lib/schema/definitions/body/correction.d.ts +0 -24
- package/lib/schema/definitions/body/correction.d.ts.map +0 -1
- package/lib/schema/definitions/body/correction.js +0 -54
- package/lib/schema/definitions/body/correction.js.map +0 -1
- package/lib/schema/definitions/body/date.d.ts +0 -30
- package/lib/schema/definitions/body/date.d.ts.map +0 -1
- package/lib/schema/definitions/body/date.js +0 -61
- package/lib/schema/definitions/body/date.js.map +0 -1
- package/lib/schema/definitions/body/index.d.ts +0 -37
- package/lib/schema/definitions/body/index.d.ts.map +0 -1
- package/lib/schema/definitions/body/index.js +0 -220
- package/lib/schema/definitions/body/index.js.map +0 -1
- package/lib/schema/definitions/body/keyword.d.ts +0 -48
- package/lib/schema/definitions/body/keyword.d.ts.map +0 -1
- package/lib/schema/definitions/body/keyword.js +0 -100
- package/lib/schema/definitions/body/keyword.js.map +0 -1
- package/lib/schema/definitions/body/link.d.ts +0 -21
- package/lib/schema/definitions/body/link.d.ts.map +0 -1
- package/lib/schema/definitions/body/link.js +0 -37
- package/lib/schema/definitions/body/link.js.map +0 -1
- package/lib/schema/definitions/body/note.d.ts +0 -27
- package/lib/schema/definitions/body/note.d.ts.map +0 -1
- package/lib/schema/definitions/body/note.js +0 -54
- package/lib/schema/definitions/body/note.js.map +0 -1
- package/lib/schema/definitions/body/organization.d.ts +0 -27
- package/lib/schema/definitions/body/organization.d.ts.map +0 -1
- package/lib/schema/definitions/body/organization.js +0 -65
- package/lib/schema/definitions/body/organization.js.map +0 -1
- package/lib/schema/definitions/body/person.d.ts +0 -27
- package/lib/schema/definitions/body/person.d.ts.map +0 -1
- package/lib/schema/definitions/body/person.js +0 -61
- package/lib/schema/definitions/body/person.js.map +0 -1
- package/lib/schema/definitions/body/physicalThing.d.ts +0 -27
- package/lib/schema/definitions/body/physicalThing.d.ts.map +0 -1
- package/lib/schema/definitions/body/physicalThing.js +0 -61
- package/lib/schema/definitions/body/physicalThing.js.map +0 -1
- package/lib/schema/definitions/body/place.d.ts +0 -30
- package/lib/schema/definitions/body/place.d.ts.map +0 -1
- package/lib/schema/definitions/body/place.js +0 -64
- package/lib/schema/definitions/body/place.js.map +0 -1
- package/lib/schema/definitions/body/work.d.ts +0 -27
- package/lib/schema/definitions/body/work.d.ts.map +0 -1
- package/lib/schema/definitions/body/work.js +0 -61
- package/lib/schema/definitions/body/work.js.map +0 -1
- package/lib/schema/definitions/index.d.ts +0 -22
- package/lib/schema/definitions/index.d.ts.map +0 -1
- package/lib/schema/definitions/index.js +0 -24
- package/lib/schema/definitions/index.js.map +0 -1
- package/lib/schema/definitions/target/index.d.ts +0 -710
- package/lib/schema/definitions/target/index.d.ts.map +0 -1
- package/lib/schema/definitions/target/index.js +0 -231
- package/lib/schema/definitions/target/index.js.map +0 -1
- package/lib/schema/definitions/target/selector/index.d.ts +0 -5
- package/lib/schema/definitions/target/selector/index.d.ts.map +0 -1
- package/lib/schema/definitions/target/selector/index.js +0 -5
- package/lib/schema/definitions/target/selector/index.js.map +0 -1
- package/lib/schema/definitions/target/selector/range.d.ts +0 -141
- package/lib/schema/definitions/target/selector/range.d.ts.map +0 -1
- package/lib/schema/definitions/target/selector/range.js +0 -44
- package/lib/schema/definitions/target/selector/range.js.map +0 -1
- package/lib/schema/definitions/target/selector/textPosition.d.ts +0 -21
- package/lib/schema/definitions/target/selector/textPosition.d.ts.map +0 -1
- package/lib/schema/definitions/target/selector/textPosition.js +0 -57
- package/lib/schema/definitions/target/selector/textPosition.js.map +0 -1
- package/lib/schema/definitions/target/selector/textQuote.d.ts +0 -297
- package/lib/schema/definitions/target/selector/textQuote.d.ts.map +0 -1
- package/lib/schema/definitions/target/selector/textQuote.js +0 -78
- package/lib/schema/definitions/target/selector/textQuote.js.map +0 -1
- package/lib/schema/definitions/target/selector/xpath.d.ts +0 -46
- package/lib/schema/definitions/target/selector/xpath.d.ts.map +0 -1
- package/lib/schema/definitions/target/selector/xpath.js +0 -51
- package/lib/schema/definitions/target/selector/xpath.js.map +0 -1
- package/lib/schema/index.d.ts +0 -5
- package/lib/schema/index.d.ts.map +0 -1
- package/lib/schema/index.js +0 -5
- package/lib/schema/index.js.map +0 -1
- package/lib/schema/root.d.ts +0 -1076
- package/lib/schema/root.d.ts.map +0 -1
- package/lib/schema/root.js +0 -408
- package/lib/schema/root.js.map +0 -1
- package/lib/validation.d.ts +0 -25
- package/lib/validation.d.ts.map +0 -1
- package/lib/validation.js +0 -35
- package/lib/validation.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# LINCS Web Annotation Schema
|
|
2
2
|
|
|
3
|
-

|
|
4
|
+

|
|
5
|
+

|
|
5
6
|
|
|
6
7
|
LINCS Web Annotation Schema is a Typescript JSON Schema generator and validator for the browser and NodeJS. It extends the [Web Annotation Model](https://www.w3.org/TR/annotation-model/) and provides the means to validate Web Annotations that follow this schema. The schema is defined by a JSON-LD object constructed using a combination of Typescript objects based on [Zod](https://zod.dev/) and [Ajv](https://ajv.js.org/).
|
|
7
8
|
|
|
8
|
-
The first version of the schema follows
|
|
9
|
+
The first version of the schema follows this [Table Alignment](https://gitlab.com/calincs/conversion/lincs-webannotation/-/blob/main/LINCS%20Web%20Annotation%20Schema%20Alignment.md). Subsequent versions may introduce changes and improve upon this document.
|
|
9
10
|
|
|
10
11
|
You can check the modules and type definitions [Type Docs](https://gitlab.com/calincs/conversion/lincs-webannotation/-/tree/main/packages/schema/docs). Check also the [examples](https://gitlab.com/calincs/conversion/lincs-webannotation/-/tree/main/packages/schema/examples) folder to see how to produce valid LINCS Web Annotations.
|
|
11
12
|
|
|
@@ -18,10 +19,11 @@ You can check the modules and type definitions [Type Docs](https://gitlab.com/ca
|
|
|
18
19
|
- [ValidationError](#validationerror)
|
|
19
20
|
- [Assets](#assets)
|
|
20
21
|
- [Ajv Schema Object](#ajv-schema-object)
|
|
21
|
-
- [
|
|
22
|
+
- [Typing](#typing)
|
|
22
23
|
- [import types](#import-types)
|
|
23
24
|
- [Development](#development)
|
|
24
|
-
- [
|
|
25
|
+
- [Linter](#linter)
|
|
26
|
+
- [Tests](#tests)
|
|
25
27
|
- [Versioning](#versioning)
|
|
26
28
|
|
|
27
29
|
## Install
|
|
@@ -40,17 +42,15 @@ const validAnnotation = {...};
|
|
|
40
42
|
const resultValid = validate(validAnnotation);
|
|
41
43
|
console.log(resultValid);
|
|
42
44
|
/*
|
|
43
|
-
{
|
|
44
|
-
valid: true
|
|
45
|
-
}
|
|
45
|
+
{ valid: true }
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
48
|
const invalidAnnotation = {...};
|
|
49
49
|
const resultInvalid = validate(invalidAnnotation);
|
|
50
50
|
console.log(resultInvalid);
|
|
51
|
-
/*
|
|
51
|
+
/*
|
|
52
52
|
{
|
|
53
|
-
valid:
|
|
53
|
+
valid: false,
|
|
54
54
|
error: [
|
|
55
55
|
{
|
|
56
56
|
"message": "property 'type' must not have fewer than 2 items",
|
|
@@ -82,32 +82,32 @@ console.log(resultInvalid);
|
|
|
82
82
|
|
|
83
83
|
#### ValidateResult
|
|
84
84
|
|
|
85
|
-
| Name
|
|
86
|
-
|
|
|
87
|
-
| valid
|
|
88
|
-
| Error
|
|
85
|
+
| Name | Type | Description |
|
|
86
|
+
| ------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
87
|
+
| valid\* | boolean | If the Annotation is valid or not |
|
|
88
|
+
| Error | [ValidationError](#validationerror)[] | Collection of error ValidationError from [better-ajv-errors](https://github.com/apideck-libraries/better-ajv-errors) |
|
|
89
89
|
|
|
90
90
|
#### ValidationError
|
|
91
91
|
|
|
92
|
-
| Name | Type | Description
|
|
93
|
-
| ---------- | ------ |
|
|
94
|
-
| message
|
|
95
|
-
| path
|
|
96
|
-
| context
|
|
92
|
+
| Name | Type | Description |
|
|
93
|
+
| ---------- | ------ | ------------------------------------ |
|
|
94
|
+
| message\* | string | Information about the error |
|
|
95
|
+
| path\* | string | Error location |
|
|
96
|
+
| context\* | object | Specific information about the error |
|
|
97
97
|
| suggestion | string | Suggestion of correction |
|
|
98
98
|
|
|
99
99
|
## Assets
|
|
100
100
|
|
|
101
|
-
Beyond the `validate` function, this module export multiple assets that can be used to build a custom validator ([Ajv Schema Object](#ajv-schema-object)) or assist the developer in building Web Annotations using Typescript ([
|
|
101
|
+
Beyond the `validate` function, this module export multiple assets that can be used to build a custom validator ([Ajv Schema Object](#ajv-schema-object)) or assist the developer in building Web Annotations using Typescript ([Typing](#typing)).
|
|
102
102
|
|
|
103
103
|
### Ajv Schema Object
|
|
104
104
|
|
|
105
105
|
It can be used to combine a custom validator.
|
|
106
106
|
|
|
107
107
|
- JSONSchemaType
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
```ts
|
|
110
|
-
import {definitionSchema, webAnnotationSchema } from '@lincs.project/webannotation-schema';
|
|
110
|
+
import { definitionSchema, webAnnotationSchema } from '@lincs.project/webannotation-schema';
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
- Schema Ids (string)
|
|
@@ -119,37 +119,71 @@ import { defsId, schemaId } from '@lincs.project/webannotation-schema';
|
|
|
119
119
|
- Schema Context (JSON)
|
|
120
120
|
|
|
121
121
|
```ts
|
|
122
|
-
import {schemaContext} from '@lincs.project/webannotation-schema';
|
|
122
|
+
import { schemaContext } from '@lincs.project/webannotation-schema';
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
##
|
|
125
|
+
## Typing
|
|
126
126
|
|
|
127
127
|
This module exports types. Check the available types in the documentation [here](?).
|
|
128
128
|
|
|
129
129
|
### import types
|
|
130
130
|
|
|
131
131
|
```ts
|
|
132
|
-
import type {
|
|
132
|
+
import type {
|
|
133
|
+
Body,
|
|
134
|
+
Creator,
|
|
135
|
+
Motivation,
|
|
136
|
+
Software,
|
|
137
|
+
Status,
|
|
138
|
+
Target,
|
|
139
|
+
User,
|
|
140
|
+
WebAnnotation,
|
|
141
|
+
} from '@lincs.project/webannotation-schema';
|
|
133
142
|
```
|
|
134
143
|
|
|
135
144
|
It is also possible to import Zod Schema.
|
|
136
145
|
|
|
137
146
|
```ts
|
|
138
|
-
import {
|
|
147
|
+
import {
|
|
148
|
+
Body,
|
|
149
|
+
Creator,
|
|
150
|
+
Motivation,
|
|
151
|
+
Software,
|
|
152
|
+
Status,
|
|
153
|
+
Target,
|
|
154
|
+
User,
|
|
155
|
+
WebAnnotation,
|
|
156
|
+
} from '@lincs.project/webannotation-schema';
|
|
139
157
|
```
|
|
140
158
|
|
|
141
159
|
## Development
|
|
142
160
|
|
|
143
161
|
Generate a new version of the schema with valid examples.
|
|
144
162
|
|
|
145
|
-
`npm run generate`
|
|
163
|
+
`npm run generate-auxiliar-files`
|
|
164
|
+
|
|
165
|
+
### Linter
|
|
166
|
+
|
|
167
|
+
**Attention!**
|
|
146
168
|
|
|
147
|
-
|
|
169
|
+
The linter is partily setup ath the monorepo level (check the root of this project). We have configured a tight linter with strict Typescript and format (prettier) rules. Some of these rules can be relaxed if needed. Check eslint config: `.eslintrc.js`.
|
|
148
170
|
|
|
149
|
-
|
|
171
|
+
The linter always runs before any commit. But you can also run it at any time to check the code.
|
|
150
172
|
|
|
151
|
-
|
|
173
|
+
```node
|
|
174
|
+
npm run lint
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Tests
|
|
178
|
+
|
|
179
|
+
This project use jest and mock tests to check the request and response from each endpoint. These tests will run before each commit.
|
|
180
|
+
|
|
181
|
+
You can also run them manually.
|
|
182
|
+
|
|
183
|
+
```node
|
|
184
|
+
npm test
|
|
185
|
+
```
|
|
152
186
|
|
|
153
187
|
### Versioning
|
|
154
188
|
|
|
155
|
-
We follow Semantic Versioning. But it is important to note that the context and the schema are made public available on the web. They are also used in our web service for validation
|
|
189
|
+
We follow Semantic Versioning. But it is important to note that the context and the schema are made public available on the web. They are also used in our [web service](<(https://gitlab.com/calincs/conversion/lincs-webannotation/-/tree/main/apps/api/examples)>) for validation . Thus, when introducing changes, especially if there are **breaking changes**, it is important to update the schema IDs and introduce the new version in the web service.
|