mailschema 0.1.3 → 0.1.4
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 +12 -1
- package/dist/content-review-0.1.contract.json +58 -0
- package/dist/content-review-0.1.schema.json +8 -6
- package/dist/content-review-0.2.contract.json +91 -0
- package/dist/content-review-0.2.schema.json +54 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/map-0.1.schema.json +155 -19
- package/dist/map.d.ts +5 -0
- package/dist/map.js +27 -5
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -18,11 +18,17 @@ Node.js 22 or newer is required. The package is ESM and includes TypeScript decl
|
|
|
18
18
|
## Validate MAP documents
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
assertMapDocument,
|
|
23
|
+
assertContentReviewRequest,
|
|
24
|
+
getContentReviewContract,
|
|
25
|
+
getMapSchema,
|
|
26
|
+
} from 'mailschema';
|
|
22
27
|
|
|
23
28
|
assertMapDocument(description);
|
|
24
29
|
assertContentReviewRequest(request);
|
|
25
30
|
const mapSchema = getMapSchema();
|
|
31
|
+
const contentReviewContract = getContentReviewContract();
|
|
26
32
|
```
|
|
27
33
|
|
|
28
34
|
The CLI performs the same checks against local JSON files:
|
|
@@ -56,8 +62,13 @@ Raw Draft 2020-12 schemas are exported as:
|
|
|
56
62
|
|
|
57
63
|
- `mailschema/map-0.1.schema.json`
|
|
58
64
|
- `mailschema/content-review-0.1.schema.json`
|
|
65
|
+
- `mailschema/content-review-0.1.contract.json`
|
|
66
|
+
- `mailschema/content-review-0.2.schema.json`
|
|
67
|
+
- `mailschema/content-review-0.2.contract.json`
|
|
59
68
|
- `mailschema/contribution.schema.json`
|
|
60
69
|
|
|
70
|
+
The unversioned Content Review helpers use 0.2. The `*ContentReview01*` helpers and 0.1 raw exports remain available for implementations pinned to the earlier draft.
|
|
71
|
+
|
|
61
72
|
## Trust boundary
|
|
62
73
|
|
|
63
74
|
A valid document is structured input. Validation does not authenticate a service, grant authority, approve an action or establish product conformance. Implementations must apply their own endpoint trust, credentials, permissions and policy before executing a request.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "MapTypeContract",
|
|
3
|
+
"id": "https://mailschema.org/types/content-review",
|
|
4
|
+
"version": "0.1",
|
|
5
|
+
"profile": "https://mailschema.org/profiles/map/0.1",
|
|
6
|
+
"target": "Service-owned content at the exact revision and digest named in the request.",
|
|
7
|
+
"requestSchema": {
|
|
8
|
+
"url": "https://mailschema.org/schemas/content-review-0.1.schema.json",
|
|
9
|
+
"canonicalDigest": "sha-256:cdad1149ab193d1bf71cb9463e3c4b7331ed56b0123e225adf68f70a2022b29d"
|
|
10
|
+
},
|
|
11
|
+
"operations": [
|
|
12
|
+
{
|
|
13
|
+
"id": "request-changes",
|
|
14
|
+
"effect": "Record review feedback on the named revision.",
|
|
15
|
+
"results": [
|
|
16
|
+
{
|
|
17
|
+
"state": "accepted",
|
|
18
|
+
"outputSchema": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"properties": {
|
|
22
|
+
"feedbackRecorded": { "const": true }
|
|
23
|
+
},
|
|
24
|
+
"required": ["feedbackRecorded"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "approve",
|
|
31
|
+
"effect": "Record approval of the named revision.",
|
|
32
|
+
"results": [
|
|
33
|
+
{
|
|
34
|
+
"state": "approval-required",
|
|
35
|
+
"outputSchema": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"additionalProperties": false,
|
|
38
|
+
"properties": {
|
|
39
|
+
"approvalUrl": { "type": "string", "format": "uri", "pattern": "^https://" }
|
|
40
|
+
},
|
|
41
|
+
"required": ["approvalUrl"]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"state": "completed",
|
|
46
|
+
"outputSchema": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"additionalProperties": false,
|
|
49
|
+
"properties": {
|
|
50
|
+
"decision": { "const": "approved" }
|
|
51
|
+
},
|
|
52
|
+
"required": ["decision"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://mailschema.org/schemas/content-review-0.1.schema.json",
|
|
4
|
-
"title": "Content Review 0.1 MAP request",
|
|
4
|
+
"title": "Content Review 0.1 MAP request binding",
|
|
5
5
|
"allOf": [
|
|
6
6
|
{ "$ref": "https://mailschema.org/schemas/map-0.1.schema.json#/$defs/request" },
|
|
7
7
|
{
|
|
@@ -11,10 +11,7 @@
|
|
|
11
11
|
"type": "object",
|
|
12
12
|
"properties": {
|
|
13
13
|
"id": { "const": "https://mailschema.org/types/content-review" },
|
|
14
|
-
"version": { "const": "0.1" }
|
|
15
|
-
"recordDigest": {
|
|
16
|
-
"const": "sha-256:0e6365df1bf904f2475f972ec66a5561edc0bfaae69fd7a1b41f53b40bf8ac1c"
|
|
17
|
-
}
|
|
14
|
+
"version": { "const": "0.1" }
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
17
|
}
|
|
@@ -29,7 +26,12 @@
|
|
|
29
26
|
"type": "object",
|
|
30
27
|
"additionalProperties": false,
|
|
31
28
|
"properties": {
|
|
32
|
-
"feedback": {
|
|
29
|
+
"feedback": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"minLength": 1,
|
|
32
|
+
"maxLength": 12000,
|
|
33
|
+
"pattern": "\\S"
|
|
34
|
+
}
|
|
33
35
|
},
|
|
34
36
|
"required": ["feedback"]
|
|
35
37
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "MapTypeContract",
|
|
3
|
+
"id": "https://mailschema.org/types/content-review",
|
|
4
|
+
"version": "0.2",
|
|
5
|
+
"profile": "https://mailschema.org/profiles/map/0.1",
|
|
6
|
+
"target": "Service-owned content at the exact revision and digest named in the request.",
|
|
7
|
+
"requestSchema": {
|
|
8
|
+
"url": "https://mailschema.org/schemas/content-review-0.2.schema.json",
|
|
9
|
+
"canonicalDigest": "sha-256:43a01e620e0730e47755694bdf5d086f8d0a1d3d8328fb0c7d2a4b70c6e62e25"
|
|
10
|
+
},
|
|
11
|
+
"operations": [
|
|
12
|
+
{
|
|
13
|
+
"id": "request-changes",
|
|
14
|
+
"effect": "Record review feedback on the named revision.",
|
|
15
|
+
"results": [
|
|
16
|
+
{
|
|
17
|
+
"state": "accepted",
|
|
18
|
+
"outputSchema": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"properties": {
|
|
22
|
+
"feedbackRecorded": {
|
|
23
|
+
"const": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"required": [
|
|
27
|
+
"feedbackRecorded"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "approve",
|
|
35
|
+
"effect": "Record approval of the named revision, or record why a proposed approval ended without approval.",
|
|
36
|
+
"results": [
|
|
37
|
+
{
|
|
38
|
+
"state": "approval-required",
|
|
39
|
+
"outputSchema": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"additionalProperties": false,
|
|
42
|
+
"properties": {
|
|
43
|
+
"approvalUrl": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"format": "uri",
|
|
46
|
+
"pattern": "^https://"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": [
|
|
50
|
+
"approvalUrl"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"state": "completed",
|
|
56
|
+
"outputSchema": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"additionalProperties": false,
|
|
59
|
+
"properties": {
|
|
60
|
+
"decision": {
|
|
61
|
+
"const": "approved"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": [
|
|
65
|
+
"decision"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"state": "failed",
|
|
71
|
+
"outputSchema": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"additionalProperties": false,
|
|
74
|
+
"properties": {
|
|
75
|
+
"reason": {
|
|
76
|
+
"enum": [
|
|
77
|
+
"declined",
|
|
78
|
+
"stale-target",
|
|
79
|
+
"expired"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"required": [
|
|
84
|
+
"reason"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://mailschema.org/schemas/content-review-0.2.schema.json",
|
|
4
|
+
"title": "Content Review 0.2 MAP request binding",
|
|
5
|
+
"allOf": [
|
|
6
|
+
{ "$ref": "https://mailschema.org/schemas/map-0.1.schema.json#/$defs/request" },
|
|
7
|
+
{
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"type": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"id": { "const": "https://mailschema.org/types/content-review" },
|
|
14
|
+
"version": { "const": "0.2" }
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"oneOf": [
|
|
21
|
+
{
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"operation": { "const": "request-changes" },
|
|
25
|
+
"input": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"additionalProperties": false,
|
|
28
|
+
"properties": {
|
|
29
|
+
"feedback": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"minLength": 1,
|
|
32
|
+
"maxLength": 12000,
|
|
33
|
+
"pattern": "\\S"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": ["feedback"]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "object",
|
|
42
|
+
"properties": {
|
|
43
|
+
"operation": { "const": "approve" },
|
|
44
|
+
"input": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"additionalProperties": false,
|
|
47
|
+
"maxProperties": 0
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { contributionErrors, assertContribution, assertTypeRecord, referenceErro
|
|
|
2
2
|
export type { CatalogView } from './validation.js';
|
|
3
3
|
export { typeStages } from './model.js';
|
|
4
4
|
export type { Party, TypeDefinition, TypeRecord, Contribution, Implementation } from './model.js';
|
|
5
|
-
export { mapErrors, assertMapDocument, contentReviewRequestErrors, assertContentReviewRequest, getMapSchema, getContentReviewSchema, } from './map.js';
|
|
5
|
+
export { mapErrors, assertMapDocument, contentReviewRequestErrors, assertContentReviewRequest, contentReview01RequestErrors, assertContentReview01Request, getMapSchema, getContentReviewSchema, getContentReviewContract, getContentReview01Schema, getContentReview01Contract, } from './map.js';
|
|
6
6
|
/** Return an independent copy of the contribution JSON Schema (Draft 2020-12). */
|
|
7
7
|
export declare function getContributionSchema(): Record<string, unknown>;
|
|
8
8
|
/** Return the schema for an expanded Registry record, including attribution and history. */
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import schema from './contribution.schema.json' with { type: 'json' };
|
|
3
3
|
export { contributionErrors, assertContribution, assertTypeRecord, referenceErrors, } from './validation.js';
|
|
4
4
|
export { typeStages } from './model.js';
|
|
5
|
-
export { mapErrors, assertMapDocument, contentReviewRequestErrors, assertContentReviewRequest, getMapSchema, getContentReviewSchema, } from './map.js';
|
|
5
|
+
export { mapErrors, assertMapDocument, contentReviewRequestErrors, assertContentReviewRequest, contentReview01RequestErrors, assertContentReview01Request, getMapSchema, getContentReviewSchema, getContentReviewContract, getContentReview01Schema, getContentReview01Contract, } from './map.js';
|
|
6
6
|
/** Return an independent copy of the contribution JSON Schema (Draft 2020-12). */
|
|
7
7
|
export function getContributionSchema() {
|
|
8
8
|
return structuredClone(schema);
|
package/dist/map-0.1.schema.json
CHANGED
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
"format": "uri",
|
|
19
19
|
"maxLength": 2048
|
|
20
20
|
},
|
|
21
|
+
"httpsIdentifier": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"format": "uri",
|
|
24
|
+
"pattern": "^https://",
|
|
25
|
+
"maxLength": 2048
|
|
26
|
+
},
|
|
21
27
|
"uuidUrn": {
|
|
22
28
|
"type": "string",
|
|
23
29
|
"pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
@@ -26,7 +32,7 @@
|
|
|
26
32
|
"type": "string",
|
|
27
33
|
"pattern": "^sha-256:[a-f0-9]{64}$"
|
|
28
34
|
},
|
|
29
|
-
"
|
|
35
|
+
"contractDigest": {
|
|
30
36
|
"type": "string",
|
|
31
37
|
"pattern": "^sha-256:[a-f0-9]{64}$"
|
|
32
38
|
},
|
|
@@ -40,9 +46,9 @@
|
|
|
40
46
|
"pattern": "^[0-9]+\\.[0-9]+(?:\\.[0-9]+)?(?:-[a-zA-Z0-9.-]+)?$",
|
|
41
47
|
"maxLength": 80
|
|
42
48
|
},
|
|
43
|
-
"
|
|
49
|
+
"contractDigest": { "$ref": "#/$defs/contractDigest" }
|
|
44
50
|
},
|
|
45
|
-
"required": ["id", "version", "
|
|
51
|
+
"required": ["id", "version", "contractDigest"]
|
|
46
52
|
},
|
|
47
53
|
"target": {
|
|
48
54
|
"type": "object",
|
|
@@ -93,7 +99,7 @@
|
|
|
93
99
|
"type": "object",
|
|
94
100
|
"additionalProperties": false,
|
|
95
101
|
"properties": {
|
|
96
|
-
"url": { "$ref": "#/$defs/
|
|
102
|
+
"url": { "$ref": "#/$defs/httpsIdentifier" },
|
|
97
103
|
"method": { "const": "POST" },
|
|
98
104
|
"requestMediaType": { "const": "application/json" },
|
|
99
105
|
"resultMediaType": { "const": "application/json" },
|
|
@@ -118,7 +124,7 @@
|
|
|
118
124
|
"resultRetentionSeconds"
|
|
119
125
|
]
|
|
120
126
|
},
|
|
121
|
-
"humanUrl": { "$ref": "#/$defs/
|
|
127
|
+
"humanUrl": { "$ref": "#/$defs/httpsIdentifier" },
|
|
122
128
|
"authorization": {
|
|
123
129
|
"type": "object",
|
|
124
130
|
"additionalProperties": false,
|
|
@@ -166,7 +172,6 @@
|
|
|
166
172
|
"profile": { "$ref": "#/$defs/profile" },
|
|
167
173
|
"requestId": { "$ref": "#/$defs/uuidUrn" },
|
|
168
174
|
"interactionId": { "$ref": "#/$defs/uuidUrn" },
|
|
169
|
-
"requestedAt": { "type": "string", "format": "date-time" },
|
|
170
175
|
"type": { "$ref": "#/$defs/typeReference" },
|
|
171
176
|
"operation": {
|
|
172
177
|
"type": "string",
|
|
@@ -181,7 +186,6 @@
|
|
|
181
186
|
"profile",
|
|
182
187
|
"requestId",
|
|
183
188
|
"interactionId",
|
|
184
|
-
"requestedAt",
|
|
185
189
|
"type",
|
|
186
190
|
"operation",
|
|
187
191
|
"target",
|
|
@@ -196,15 +200,18 @@
|
|
|
196
200
|
"profile": { "$ref": "#/$defs/profile" },
|
|
197
201
|
"requestId": { "$ref": "#/$defs/uuidUrn" },
|
|
198
202
|
"interactionId": { "$ref": "#/$defs/uuidUrn" },
|
|
203
|
+
"type": { "$ref": "#/$defs/typeReference" },
|
|
199
204
|
"operation": {
|
|
200
205
|
"type": "string",
|
|
201
206
|
"pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$",
|
|
202
207
|
"maxLength": 100
|
|
203
208
|
},
|
|
204
|
-
"state": {
|
|
209
|
+
"state": {
|
|
210
|
+
"enum": ["accepted", "completed", "failed", "pending", "approval-required"]
|
|
211
|
+
},
|
|
205
212
|
"target": { "$ref": "#/$defs/target" },
|
|
206
213
|
"recordedAt": { "type": "string", "format": "date-time" },
|
|
207
|
-
"resultUrl": { "$ref": "#/$defs/
|
|
214
|
+
"resultUrl": { "$ref": "#/$defs/httpsIdentifier" },
|
|
208
215
|
"output": { "type": "object", "maxProperties": 100 }
|
|
209
216
|
},
|
|
210
217
|
"required": [
|
|
@@ -212,6 +219,7 @@
|
|
|
212
219
|
"profile",
|
|
213
220
|
"requestId",
|
|
214
221
|
"interactionId",
|
|
222
|
+
"type",
|
|
215
223
|
"operation",
|
|
216
224
|
"state",
|
|
217
225
|
"target",
|
|
@@ -227,6 +235,8 @@
|
|
|
227
235
|
"type": {
|
|
228
236
|
"enum": [
|
|
229
237
|
"https://mailschema.org/problems/refused",
|
|
238
|
+
"https://mailschema.org/problems/authentication-required",
|
|
239
|
+
"https://mailschema.org/problems/result-not-found",
|
|
230
240
|
"https://mailschema.org/problems/stale-target",
|
|
231
241
|
"https://mailschema.org/problems/expired-interaction",
|
|
232
242
|
"https://mailschema.org/problems/invalid-request",
|
|
@@ -247,6 +257,8 @@
|
|
|
247
257
|
"code": {
|
|
248
258
|
"enum": [
|
|
249
259
|
"refused",
|
|
260
|
+
"authentication-required",
|
|
261
|
+
"result-not-found",
|
|
250
262
|
"stale-target",
|
|
251
263
|
"expired-interaction",
|
|
252
264
|
"invalid-request",
|
|
@@ -259,16 +271,140 @@
|
|
|
259
271
|
},
|
|
260
272
|
"target": { "$ref": "#/$defs/target" }
|
|
261
273
|
},
|
|
262
|
-
"required": [
|
|
263
|
-
|
|
264
|
-
"
|
|
265
|
-
"
|
|
266
|
-
"
|
|
267
|
-
"instance",
|
|
268
|
-
"profile",
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
274
|
+
"required": ["type", "title", "status", "detail"],
|
|
275
|
+
"dependentRequired": {
|
|
276
|
+
"instance": ["profile", "requestId", "code"],
|
|
277
|
+
"profile": ["instance", "requestId", "code"],
|
|
278
|
+
"requestId": ["instance", "profile", "code"],
|
|
279
|
+
"interactionId": ["instance", "profile", "requestId", "code"],
|
|
280
|
+
"code": ["instance", "profile", "requestId"]
|
|
281
|
+
},
|
|
282
|
+
"allOf": [
|
|
283
|
+
{
|
|
284
|
+
"if": {
|
|
285
|
+
"properties": { "code": { "not": { "const": "result-not-found" } } },
|
|
286
|
+
"required": ["code"]
|
|
287
|
+
},
|
|
288
|
+
"then": { "required": ["interactionId"] }
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"if": { "properties": { "code": { "const": "invalid-request" } }, "required": ["code"] },
|
|
292
|
+
"then": {
|
|
293
|
+
"properties": {
|
|
294
|
+
"type": { "const": "https://mailschema.org/problems/invalid-request" },
|
|
295
|
+
"status": { "const": 400 }
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"if": {
|
|
301
|
+
"properties": { "code": { "const": "authentication-required" } },
|
|
302
|
+
"required": ["code"]
|
|
303
|
+
},
|
|
304
|
+
"then": {
|
|
305
|
+
"properties": {
|
|
306
|
+
"type": { "const": "https://mailschema.org/problems/authentication-required" },
|
|
307
|
+
"status": { "const": 401 }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"if": { "properties": { "code": { "const": "refused" } }, "required": ["code"] },
|
|
313
|
+
"then": {
|
|
314
|
+
"properties": {
|
|
315
|
+
"type": { "const": "https://mailschema.org/problems/refused" },
|
|
316
|
+
"status": { "const": 403 }
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"if": { "properties": { "code": { "const": "result-not-found" } }, "required": ["code"] },
|
|
322
|
+
"then": {
|
|
323
|
+
"properties": {
|
|
324
|
+
"type": { "const": "https://mailschema.org/problems/result-not-found" },
|
|
325
|
+
"status": { "const": 404 }
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
"if": { "properties": { "code": { "const": "stale-target" } }, "required": ["code"] },
|
|
331
|
+
"then": {
|
|
332
|
+
"properties": {
|
|
333
|
+
"type": { "const": "https://mailschema.org/problems/stale-target" },
|
|
334
|
+
"status": { "const": 409 }
|
|
335
|
+
},
|
|
336
|
+
"required": ["target"]
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"if": {
|
|
341
|
+
"properties": { "code": { "const": "idempotency-conflict" } },
|
|
342
|
+
"required": ["code"]
|
|
343
|
+
},
|
|
344
|
+
"then": {
|
|
345
|
+
"properties": {
|
|
346
|
+
"type": { "const": "https://mailschema.org/problems/idempotency-conflict" },
|
|
347
|
+
"status": { "const": 409 }
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"if": {
|
|
353
|
+
"properties": { "code": { "const": "request-in-progress" } },
|
|
354
|
+
"required": ["code"]
|
|
355
|
+
},
|
|
356
|
+
"then": {
|
|
357
|
+
"properties": {
|
|
358
|
+
"type": { "const": "https://mailschema.org/problems/request-in-progress" },
|
|
359
|
+
"status": { "const": 409 }
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"if": {
|
|
365
|
+
"properties": { "code": { "const": "expired-interaction" } },
|
|
366
|
+
"required": ["code"]
|
|
367
|
+
},
|
|
368
|
+
"then": {
|
|
369
|
+
"properties": {
|
|
370
|
+
"type": { "const": "https://mailschema.org/problems/expired-interaction" },
|
|
371
|
+
"status": { "const": 410 }
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
"if": {
|
|
377
|
+
"properties": { "code": { "const": "unsupported-profile" } },
|
|
378
|
+
"required": ["code"]
|
|
379
|
+
},
|
|
380
|
+
"then": {
|
|
381
|
+
"properties": {
|
|
382
|
+
"type": { "const": "https://mailschema.org/problems/unsupported-profile" },
|
|
383
|
+
"status": { "const": 422 }
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"if": { "properties": { "code": { "const": "unsupported-type" } }, "required": ["code"] },
|
|
389
|
+
"then": {
|
|
390
|
+
"properties": {
|
|
391
|
+
"type": { "const": "https://mailschema.org/problems/unsupported-type" },
|
|
392
|
+
"status": { "const": 422 }
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
"if": {
|
|
398
|
+
"properties": { "code": { "const": "unsupported-operation" } },
|
|
399
|
+
"required": ["code"]
|
|
400
|
+
},
|
|
401
|
+
"then": {
|
|
402
|
+
"properties": {
|
|
403
|
+
"type": { "const": "https://mailschema.org/problems/unsupported-operation" },
|
|
404
|
+
"status": { "const": 422 }
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
272
408
|
]
|
|
273
409
|
}
|
|
274
410
|
}
|
package/dist/map.d.ts
CHANGED
|
@@ -2,5 +2,10 @@ export declare function mapErrors(value: unknown): string[];
|
|
|
2
2
|
export declare function assertMapDocument(value: unknown): void;
|
|
3
3
|
export declare function contentReviewRequestErrors(value: unknown): string[];
|
|
4
4
|
export declare function assertContentReviewRequest(value: unknown): void;
|
|
5
|
+
export declare function contentReview01RequestErrors(value: unknown): string[];
|
|
6
|
+
export declare function assertContentReview01Request(value: unknown): void;
|
|
5
7
|
export declare function getMapSchema(): Record<string, unknown>;
|
|
6
8
|
export declare function getContentReviewSchema(): Record<string, unknown>;
|
|
9
|
+
export declare function getContentReviewContract(): Record<string, unknown>;
|
|
10
|
+
export declare function getContentReview01Schema(): Record<string, unknown>;
|
|
11
|
+
export declare function getContentReview01Contract(): Record<string, unknown>;
|
package/dist/map.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import Ajv2020 from 'ajv/dist/2020.js';
|
|
2
2
|
import addFormats from 'ajv-formats';
|
|
3
3
|
import mapSchema from './map-0.1.schema.json' with { type: 'json' };
|
|
4
|
-
import
|
|
4
|
+
import contentReview01Schema from './content-review-0.1.schema.json' with { type: 'json' };
|
|
5
|
+
import contentReview01Contract from './content-review-0.1.contract.json' with { type: 'json' };
|
|
6
|
+
import contentReview02Schema from './content-review-0.2.schema.json' with { type: 'json' };
|
|
7
|
+
import contentReview02Contract from './content-review-0.2.contract.json' with { type: 'json' };
|
|
5
8
|
const ajv = new Ajv2020({ allErrors: true, strict: true, strictRequired: false });
|
|
6
9
|
addFormats(ajv);
|
|
7
|
-
|
|
8
|
-
const
|
|
10
|
+
ajv.addSchema(mapSchema);
|
|
11
|
+
const mapDocument = ajv.getSchema(mapSchema.$id);
|
|
12
|
+
const contentReview01Request = ajv.compile(contentReview01Schema);
|
|
13
|
+
const contentReview02Request = ajv.compile(contentReview02Schema);
|
|
9
14
|
function errors(validate, value) {
|
|
10
15
|
if (validate(value))
|
|
11
16
|
return [];
|
|
@@ -20,10 +25,18 @@ export function assertMapDocument(value) {
|
|
|
20
25
|
throw new Error(`Invalid MAP 0.1 document:\n${found.join('\n')}`);
|
|
21
26
|
}
|
|
22
27
|
export function contentReviewRequestErrors(value) {
|
|
23
|
-
return errors(
|
|
28
|
+
return errors(contentReview02Request, value);
|
|
24
29
|
}
|
|
25
30
|
export function assertContentReviewRequest(value) {
|
|
26
31
|
const found = contentReviewRequestErrors(value);
|
|
32
|
+
if (found.length)
|
|
33
|
+
throw new Error(`Invalid Content Review 0.2 request:\n${found.join('\n')}`);
|
|
34
|
+
}
|
|
35
|
+
export function contentReview01RequestErrors(value) {
|
|
36
|
+
return errors(contentReview01Request, value);
|
|
37
|
+
}
|
|
38
|
+
export function assertContentReview01Request(value) {
|
|
39
|
+
const found = contentReview01RequestErrors(value);
|
|
27
40
|
if (found.length)
|
|
28
41
|
throw new Error(`Invalid Content Review 0.1 request:\n${found.join('\n')}`);
|
|
29
42
|
}
|
|
@@ -31,5 +44,14 @@ export function getMapSchema() {
|
|
|
31
44
|
return structuredClone(mapSchema);
|
|
32
45
|
}
|
|
33
46
|
export function getContentReviewSchema() {
|
|
34
|
-
return structuredClone(
|
|
47
|
+
return structuredClone(contentReview02Schema);
|
|
48
|
+
}
|
|
49
|
+
export function getContentReviewContract() {
|
|
50
|
+
return structuredClone(contentReview02Contract);
|
|
51
|
+
}
|
|
52
|
+
export function getContentReview01Schema() {
|
|
53
|
+
return structuredClone(contentReview01Schema);
|
|
54
|
+
}
|
|
55
|
+
export function getContentReview01Contract() {
|
|
56
|
+
return structuredClone(contentReview01Contract);
|
|
35
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailschema",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Schemas and validation tools for Mail Action Protocol and the MailSchema Registry",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"./contribution.schema.json": "./dist/contribution.schema.json",
|
|
25
25
|
"./map-0.1.schema.json": "./dist/map-0.1.schema.json",
|
|
26
26
|
"./content-review-0.1.schema.json": "./dist/content-review-0.1.schema.json",
|
|
27
|
+
"./content-review-0.1.contract.json": "./dist/content-review-0.1.contract.json",
|
|
28
|
+
"./content-review-0.2.schema.json": "./dist/content-review-0.2.schema.json",
|
|
29
|
+
"./content-review-0.2.contract.json": "./dist/content-review-0.2.contract.json",
|
|
27
30
|
"./package.json": "./package.json"
|
|
28
31
|
},
|
|
29
32
|
"types": "./dist/index.d.ts",
|