mailschema 0.1.2 → 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 +46 -44
- package/dist/content-review-0.2.contract.json +91 -0
- package/dist/content-review-0.2.schema.json +54 -0
- package/dist/contribution.schema.json +846 -846
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/map-0.1.schema.json +388 -252
- package/dist/map.d.ts +5 -0
- package/dist/map.js +27 -5
- package/package.json +5 -2
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",
|
|
@@ -37,7 +40,7 @@
|
|
|
37
40
|
"LICENSE"
|
|
38
41
|
],
|
|
39
42
|
"scripts": {
|
|
40
|
-
"build": "
|
|
43
|
+
"build": "node build.mjs",
|
|
41
44
|
"test": "npm run build && node --test test/*.test.mjs"
|
|
42
45
|
},
|
|
43
46
|
"dependencies": {
|