mailschema 0.1.1 → 0.1.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 +42 -18
- package/dist/content-review-0.1.schema.json +45 -45
- package/dist/contribution.schema.json +846 -846
- package/dist/map-0.1.schema.json +261 -261
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -1,41 +1,65 @@
|
|
|
1
|
-
# MailSchema
|
|
1
|
+
# MailSchema for JavaScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/mailschema)
|
|
4
|
+
[](https://github.com/mailschema/javascript/actions/workflows/test.yml)
|
|
4
5
|
|
|
5
|
-
Validate
|
|
6
|
+
Validate Mail Action Protocol documents and MailSchema Registry contributions without making a network request.
|
|
7
|
+
|
|
8
|
+
[Specification](https://mailschema.org/specification/) · [Registry](https://mailschema.org/registry/) · [Tools](https://mailschema.org/tools/) · [Source](https://github.com/mailschema/javascript)
|
|
9
|
+
|
|
10
|
+
## Install
|
|
6
11
|
|
|
7
12
|
```sh
|
|
8
13
|
npm install mailschema
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Node.js 22 or newer is required. The package is ESM and includes TypeScript declarations.
|
|
17
|
+
|
|
18
|
+
## Validate MAP documents
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import { assertMapDocument, assertContentReviewRequest, getMapSchema } from 'mailschema';
|
|
22
|
+
|
|
23
|
+
assertMapDocument(description);
|
|
24
|
+
assertContentReviewRequest(request);
|
|
25
|
+
const mapSchema = getMapSchema();
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The CLI performs the same checks against local JSON files:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
11
31
|
npx mailschema check description.json --map
|
|
12
32
|
npx mailschema check request.json --content-review
|
|
13
33
|
```
|
|
14
34
|
|
|
15
|
-
|
|
35
|
+
## Work with Registry data
|
|
16
36
|
|
|
17
37
|
```js
|
|
18
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
assertContribution,
|
|
40
|
+
contributionErrors,
|
|
41
|
+
getContributionSchema,
|
|
42
|
+
referenceErrors,
|
|
43
|
+
} from 'mailschema';
|
|
19
44
|
|
|
20
45
|
const errors = contributionErrors(candidate);
|
|
21
46
|
if (errors.length) console.error(errors);
|
|
22
47
|
else assertContribution(candidate);
|
|
23
48
|
|
|
24
|
-
const schema = getContributionSchema();
|
|
49
|
+
const schema = getContributionSchema();
|
|
50
|
+
const referenceProblems = referenceErrors(candidate, catalog);
|
|
25
51
|
```
|
|
26
52
|
|
|
27
|
-
|
|
28
|
-
import { assertMapDocument, assertContentReviewRequest, getMapSchema } from 'mailschema';
|
|
53
|
+
`assertTypeRecord`, `getRecordSchema` and `mailschema check record.json --record` handle expanded Registry records. Reference checks use a catalogue supplied by the caller; the package never fetches one automatically.
|
|
29
54
|
|
|
30
|
-
|
|
31
|
-
assertContentReviewRequest(request);
|
|
32
|
-
const mapSchema = getMapSchema();
|
|
33
|
-
```
|
|
55
|
+
Raw Draft 2020-12 schemas are exported as:
|
|
34
56
|
|
|
35
|
-
|
|
57
|
+
- `mailschema/map-0.1.schema.json`
|
|
58
|
+
- `mailschema/content-review-0.1.schema.json`
|
|
59
|
+
- `mailschema/contribution.schema.json`
|
|
36
60
|
|
|
37
|
-
|
|
61
|
+
## Trust boundary
|
|
38
62
|
|
|
39
|
-
|
|
63
|
+
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.
|
|
40
64
|
|
|
41
|
-
|
|
65
|
+
The CLI reads one local file of at most 256 KiB and does not upload or modify it. Package versions and MAP profile versions advance independently. MIT licensed.
|
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.1" },
|
|
15
|
-
"recordDigest": {
|
|
16
|
-
"const": "sha-256:0e6365df1bf904f2475f972ec66a5561edc0bfaae69fd7a1b41f53b40bf8ac1c"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"oneOf": [
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://mailschema.org/schemas/content-review-0.1.schema.json",
|
|
4
|
+
"title": "Content Review 0.1 MAP request",
|
|
5
|
+
"allOf": [
|
|
6
|
+
{ "$ref": "https://mailschema.org/schemas/map-0.1.schema.json#/$defs/request" },
|
|
24
7
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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.1" },
|
|
15
|
+
"recordDigest": {
|
|
16
|
+
"const": "sha-256:0e6365df1bf904f2475f972ec66a5561edc0bfaae69fd7a1b41f53b40bf8ac1c"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
35
20
|
}
|
|
36
|
-
}
|
|
37
21
|
},
|
|
38
22
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
"oneOf": [
|
|
24
|
+
{
|
|
25
|
+
"type": "object",
|
|
26
|
+
"properties": {
|
|
27
|
+
"operation": { "const": "request-changes" },
|
|
28
|
+
"input": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"additionalProperties": false,
|
|
31
|
+
"properties": {
|
|
32
|
+
"feedback": { "type": "string", "minLength": 1, "maxLength": 12000 }
|
|
33
|
+
},
|
|
34
|
+
"required": ["feedback"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {
|
|
41
|
+
"operation": { "const": "approve" },
|
|
42
|
+
"input": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"additionalProperties": false,
|
|
45
|
+
"maxProperties": 0
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
]
|
|
51
|
+
]
|
|
52
52
|
}
|