@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.
Files changed (122) hide show
  1. package/README.md +65 -31
  2. package/dist/index.d.mts +2728 -0
  3. package/dist/index.d.ts +2728 -0
  4. package/dist/index.js +5463 -0
  5. package/dist/index.mjs +5433 -0
  6. package/package.json +44 -32
  7. package/dist/context.jsonld +0 -24
  8. package/dist/defs.jsonld +0 -949
  9. package/dist/schema.jsonld +0 -621
  10. package/dist/validate.js +0 -1
  11. package/lib/index.d.ts +0 -145
  12. package/lib/index.d.ts.map +0 -1
  13. package/lib/index.js +0 -13
  14. package/lib/index.js.map +0 -1
  15. package/lib/schema/config.d.ts +0 -4
  16. package/lib/schema/config.d.ts.map +0 -1
  17. package/lib/schema/config.js +0 -4
  18. package/lib/schema/config.js.map +0 -1
  19. package/lib/schema/context.d.ts +0 -25
  20. package/lib/schema/context.d.ts.map +0 -1
  21. package/lib/schema/context.js +0 -25
  22. package/lib/schema/context.js.map +0 -1
  23. package/lib/schema/definitions/agent.d.ts +0 -36
  24. package/lib/schema/definitions/agent.d.ts.map +0 -1
  25. package/lib/schema/definitions/agent.js +0 -82
  26. package/lib/schema/definitions/agent.js.map +0 -1
  27. package/lib/schema/definitions/body/citation.d.ts +0 -27
  28. package/lib/schema/definitions/body/citation.d.ts.map +0 -1
  29. package/lib/schema/definitions/body/citation.js +0 -53
  30. package/lib/schema/definitions/body/citation.js.map +0 -1
  31. package/lib/schema/definitions/body/common.d.ts +0 -17
  32. package/lib/schema/definitions/body/common.d.ts.map +0 -1
  33. package/lib/schema/definitions/body/common.js +0 -46
  34. package/lib/schema/definitions/body/common.js.map +0 -1
  35. package/lib/schema/definitions/body/conceptualObject.d.ts +0 -27
  36. package/lib/schema/definitions/body/conceptualObject.d.ts.map +0 -1
  37. package/lib/schema/definitions/body/conceptualObject.js +0 -61
  38. package/lib/schema/definitions/body/conceptualObject.js.map +0 -1
  39. package/lib/schema/definitions/body/correction.d.ts +0 -24
  40. package/lib/schema/definitions/body/correction.d.ts.map +0 -1
  41. package/lib/schema/definitions/body/correction.js +0 -54
  42. package/lib/schema/definitions/body/correction.js.map +0 -1
  43. package/lib/schema/definitions/body/date.d.ts +0 -30
  44. package/lib/schema/definitions/body/date.d.ts.map +0 -1
  45. package/lib/schema/definitions/body/date.js +0 -61
  46. package/lib/schema/definitions/body/date.js.map +0 -1
  47. package/lib/schema/definitions/body/index.d.ts +0 -37
  48. package/lib/schema/definitions/body/index.d.ts.map +0 -1
  49. package/lib/schema/definitions/body/index.js +0 -220
  50. package/lib/schema/definitions/body/index.js.map +0 -1
  51. package/lib/schema/definitions/body/keyword.d.ts +0 -48
  52. package/lib/schema/definitions/body/keyword.d.ts.map +0 -1
  53. package/lib/schema/definitions/body/keyword.js +0 -100
  54. package/lib/schema/definitions/body/keyword.js.map +0 -1
  55. package/lib/schema/definitions/body/link.d.ts +0 -21
  56. package/lib/schema/definitions/body/link.d.ts.map +0 -1
  57. package/lib/schema/definitions/body/link.js +0 -37
  58. package/lib/schema/definitions/body/link.js.map +0 -1
  59. package/lib/schema/definitions/body/note.d.ts +0 -27
  60. package/lib/schema/definitions/body/note.d.ts.map +0 -1
  61. package/lib/schema/definitions/body/note.js +0 -54
  62. package/lib/schema/definitions/body/note.js.map +0 -1
  63. package/lib/schema/definitions/body/organization.d.ts +0 -27
  64. package/lib/schema/definitions/body/organization.d.ts.map +0 -1
  65. package/lib/schema/definitions/body/organization.js +0 -65
  66. package/lib/schema/definitions/body/organization.js.map +0 -1
  67. package/lib/schema/definitions/body/person.d.ts +0 -27
  68. package/lib/schema/definitions/body/person.d.ts.map +0 -1
  69. package/lib/schema/definitions/body/person.js +0 -61
  70. package/lib/schema/definitions/body/person.js.map +0 -1
  71. package/lib/schema/definitions/body/physicalThing.d.ts +0 -27
  72. package/lib/schema/definitions/body/physicalThing.d.ts.map +0 -1
  73. package/lib/schema/definitions/body/physicalThing.js +0 -61
  74. package/lib/schema/definitions/body/physicalThing.js.map +0 -1
  75. package/lib/schema/definitions/body/place.d.ts +0 -30
  76. package/lib/schema/definitions/body/place.d.ts.map +0 -1
  77. package/lib/schema/definitions/body/place.js +0 -64
  78. package/lib/schema/definitions/body/place.js.map +0 -1
  79. package/lib/schema/definitions/body/work.d.ts +0 -27
  80. package/lib/schema/definitions/body/work.d.ts.map +0 -1
  81. package/lib/schema/definitions/body/work.js +0 -61
  82. package/lib/schema/definitions/body/work.js.map +0 -1
  83. package/lib/schema/definitions/index.d.ts +0 -22
  84. package/lib/schema/definitions/index.d.ts.map +0 -1
  85. package/lib/schema/definitions/index.js +0 -24
  86. package/lib/schema/definitions/index.js.map +0 -1
  87. package/lib/schema/definitions/target/index.d.ts +0 -710
  88. package/lib/schema/definitions/target/index.d.ts.map +0 -1
  89. package/lib/schema/definitions/target/index.js +0 -231
  90. package/lib/schema/definitions/target/index.js.map +0 -1
  91. package/lib/schema/definitions/target/selector/index.d.ts +0 -5
  92. package/lib/schema/definitions/target/selector/index.d.ts.map +0 -1
  93. package/lib/schema/definitions/target/selector/index.js +0 -5
  94. package/lib/schema/definitions/target/selector/index.js.map +0 -1
  95. package/lib/schema/definitions/target/selector/range.d.ts +0 -141
  96. package/lib/schema/definitions/target/selector/range.d.ts.map +0 -1
  97. package/lib/schema/definitions/target/selector/range.js +0 -44
  98. package/lib/schema/definitions/target/selector/range.js.map +0 -1
  99. package/lib/schema/definitions/target/selector/textPosition.d.ts +0 -21
  100. package/lib/schema/definitions/target/selector/textPosition.d.ts.map +0 -1
  101. package/lib/schema/definitions/target/selector/textPosition.js +0 -57
  102. package/lib/schema/definitions/target/selector/textPosition.js.map +0 -1
  103. package/lib/schema/definitions/target/selector/textQuote.d.ts +0 -297
  104. package/lib/schema/definitions/target/selector/textQuote.d.ts.map +0 -1
  105. package/lib/schema/definitions/target/selector/textQuote.js +0 -78
  106. package/lib/schema/definitions/target/selector/textQuote.js.map +0 -1
  107. package/lib/schema/definitions/target/selector/xpath.d.ts +0 -46
  108. package/lib/schema/definitions/target/selector/xpath.d.ts.map +0 -1
  109. package/lib/schema/definitions/target/selector/xpath.js +0 -51
  110. package/lib/schema/definitions/target/selector/xpath.js.map +0 -1
  111. package/lib/schema/index.d.ts +0 -5
  112. package/lib/schema/index.d.ts.map +0 -1
  113. package/lib/schema/index.js +0 -5
  114. package/lib/schema/index.js.map +0 -1
  115. package/lib/schema/root.d.ts +0 -1076
  116. package/lib/schema/root.d.ts.map +0 -1
  117. package/lib/schema/root.js +0 -408
  118. package/lib/schema/root.js.map +0 -1
  119. package/lib/validation.d.ts +0 -25
  120. package/lib/validation.d.ts.map +0 -1
  121. package/lib/validation.js +0 -35
  122. package/lib/validation.js.map +0 -1
package/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # LINCS Web Annotation Schema
2
2
 
3
- ![NPM](https://img.shields.io/npm/l/@cwrc/leafwriter-validator)
4
- ![npm type definitions](https://img.shields.io/npm/types/@cwrc/leafwriter-validator)
3
+ ![npm (scoped)](https://img.shields.io/npm/v/%40lincs.project/webannotation-schema)
4
+ ![npm(scoped)](https://img.shields.io/npm/l/%40lincs.project/webannotation-schema)
5
+ ![npm (scoped) type definitions](https://img.shields.io/npm/types/%40lincs.project/webannotation-schema)
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 the discussion in this [document](https://docs.google.com/document/d/1SkrZTbHMDxupDmsmBsjTTdu7Inlny-eecg369zVaJNM/edit#heading=h.4pfo79y7up7t). Subsequent versions may introduce changes and improve upon this document.
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
- - [Typings](#typings)
22
+ - [Typing](#typing)
22
23
  - [import types](#import-types)
23
24
  - [Development](#development)
24
- - [Testing](#testing)
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: true,
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 | 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) |
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* | string | Information about the error |
95
- | path* | string | Error location |
96
- | context* | object | Specific information about the error |
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 ([Typings](#typings)).
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
- ## Typings
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 { Body, Creator, Motivation, Software, Status, Target, User, WebAnnotation } from '@lincs.project/webannotation-schema';
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 { Body, Creator, Motivation, Software, Status, Target, User, WebAnnotation } from '@lincs.project/webannotation-schema';
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
- ### Testing
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
- We use jest for testing.
171
+ The linter always runs before any commit. But you can also run it at any time to check the code.
150
172
 
151
- `npm test`
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 [link](link). 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.
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.