mailschema 0.2.2 → 0.3.1
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 +27 -119
- package/bin/mailschema.js +42 -53
- package/dist/context.jsonld +50 -0
- package/dist/contract.schema.json +206 -0
- package/dist/core/artifacts.d.ts +11 -36
- package/dist/core/artifacts.js +21 -69
- package/dist/core/bundled.d.ts +4 -4
- package/dist/core/bundled.js +7 -7
- package/dist/core/contract.d.ts +59 -56
- package/dist/core/contract.js +224 -298
- package/dist/core/description.d.ts +45 -0
- package/dist/core/description.js +47 -0
- package/dist/core/implementation.d.ts +32 -0
- package/dist/core/implementation.js +25 -0
- package/dist/core/index.d.ts +7 -6
- package/dist/core/index.js +9 -9
- package/dist/core/json.d.ts +23 -0
- package/dist/core/{document.js → json.js} +61 -51
- package/dist/core/patterns.d.ts +12 -0
- package/dist/core/patterns.js +165 -0
- package/dist/core/sha256.d.ts +2 -0
- package/dist/core/sha256.js +59 -0
- package/dist/core.schema.json +210 -0
- package/dist/implementation.schema.json +173 -0
- package/dist/index.d.ts +4 -9
- package/dist/index.js +2 -14
- package/dist/profile.json +27 -0
- package/package.json +9 -10
- package/dist/contribution.schema.json +0 -874
- package/dist/core/binding.d.ts +0 -24
- package/dist/core/binding.js +0 -50
- package/dist/core/document.d.ts +0 -24
- package/dist/core/documents.d.ts +0 -68
- package/dist/core/documents.js +0 -145
- package/dist/core/limits.d.ts +0 -19
- package/dist/core/limits.js +0 -55
- package/dist/core/pointer.d.ts +0 -12
- package/dist/core/pointer.js +0 -48
- package/dist/core/schemas.d.ts +0 -21
- package/dist/core/schemas.js +0 -125
- package/dist/core/types.d.ts +0 -127
- package/dist/core/types.js +0 -2
- package/dist/forms-0.1.schema.json +0 -329
- package/dist/map-0.2.jsonld +0 -91
- package/dist/map-0.2.schema.json +0 -1033
- package/dist/map.d.ts +0 -8
- package/dist/map.js +0 -18
- package/dist/model.d.ts +0 -95
- package/dist/model.js +0 -5
- package/dist/type-contract-0.2.schema.json +0 -179
- package/dist/validation.d.ts +0 -15
- package/dist/validation.js +0 -64
package/README.md
CHANGED
|
@@ -1,138 +1,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mailschema
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
[](https://github.com/mailschema/javascript/actions/workflows/test.yml)
|
|
5
|
-
|
|
6
|
-
Mail Action Protocol 0.2 for JavaScript and TypeScript. The package parses, canonicalizes, digests and validates MAP documents, verifies the type contracts an implementation vendors, and builds results and problems. It also carries the MAP 0.2 core artifacts and validates MailSchema Registry contributions locally.
|
|
7
|
-
|
|
8
|
-
It does not establish endpoint trust, verify email authentication, grant authority or send email. Possession mode needs DKIM and DMARC checks on the raw message, which this package leaves to the client.
|
|
9
|
-
|
|
10
|
-
[Specification](https://mailschema.org/specification) · [Registry](https://mailschema.org/registry) · [Tools](https://mailschema.org/tools) · [Source](https://github.com/mailschema/javascript)
|
|
11
|
-
|
|
12
|
-
## Install
|
|
3
|
+
[Mail Action Protocol](https://mailschema.org) 0.3 for JavaScript. It parses and checks MAP descriptions, type contracts and Registry implementation records, and computes the RFC 8785 digests that identify contracts. The same code runs the MailSchema specification's own checks. It has no Node.js-only dependencies, so it also runs in browsers and workers.
|
|
13
4
|
|
|
14
5
|
```sh
|
|
15
|
-
npm install mailschema
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Node.js 22 or newer is required. The package is ESM and includes TypeScript declarations.
|
|
19
|
-
|
|
20
|
-
## A service
|
|
21
|
-
|
|
22
|
-
Vendor the exact contract and request schema your service implements, and pin the contract by the digest you reviewed. The package refuses any other contract.
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
import { readFileSync } from 'node:fs';
|
|
26
|
-
import { Contract, digest } from 'mailschema';
|
|
27
|
-
|
|
28
|
-
const read = (path: string) => JSON.parse(readFileSync(path, 'utf8'));
|
|
29
|
-
const contract = new Contract(
|
|
30
|
-
read('mailschema/content-review-0.3.json'),
|
|
31
|
-
read('mailschema/content-review-0.3.schema.json'),
|
|
32
|
-
{ digest: 'sha-256:…' },
|
|
33
|
-
);
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Before sending a description, check it against every rule of the core and the contract, and store its digest or keep it rebuildable from the interaction:
|
|
37
|
-
|
|
38
|
-
```ts
|
|
39
|
-
contract.descriptionErrors(description); // []
|
|
40
|
-
digest(description); // 'sha-256:…'
|
|
6
|
+
npm install mailschema@0.3.1
|
|
41
7
|
```
|
|
42
8
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { isJsonRequest, parse, problem, requestErrors, result, resultUrl } from 'mailschema';
|
|
47
|
-
import type { MapRequest } from 'mailschema';
|
|
48
|
-
|
|
49
|
-
// Answer 415 unless isJsonRequest(contentType). Under possession authority, answer an
|
|
50
|
-
// unknown capability with a plain 404 and a lapsed one with a plain 410 before reading
|
|
51
|
-
// the body; under credential authority, authenticate the principal.
|
|
52
|
-
const request = parse(body) as MapRequest; // throws InvalidDocument
|
|
53
|
-
requestErrors(request); // any errors: invalid-request
|
|
54
|
-
|
|
55
|
-
// Resolve the description you issued for request.interactionId. Refuse an unknown
|
|
56
|
-
// interaction, or a request whose descriptionDigest is not digest(description).
|
|
9
|
+
## Check a description against its contract
|
|
57
10
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// without requestId). Answer any change to the request, compared by digest, with
|
|
62
|
-
// idempotency-conflict. Otherwise settle the recorded result with settle() and return it,
|
|
63
|
-
// or expired-interaction once retainUntil() has passed. Nothing is applied again.
|
|
64
|
-
|
|
65
|
-
const refused = contract.requestProblem(description, request, { now: new Date() });
|
|
66
|
-
// refused.code is unsupported-type, unsupported-operation or expired-interaction, with the
|
|
67
|
-
// title and detail problem() takes. Then your own state: already-decided, or stale-target.
|
|
11
|
+
```js
|
|
12
|
+
import { readFile } from 'node:fs/promises';
|
|
13
|
+
import { Contract, parseDescription } from 'mailschema';
|
|
68
14
|
|
|
69
|
-
contract.
|
|
70
|
-
|
|
15
|
+
const contract = Contract.parse(await readFile('campaign-send-approval-0.1.json'));
|
|
16
|
+
const description = parseDescription(await readFile('description.json'));
|
|
17
|
+
const errors = contract.descriptionErrors(description);
|
|
18
|
+
if (errors.length) throw new Error(errors.join('\n'));
|
|
71
19
|
```
|
|
72
20
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
result(request, {
|
|
77
|
-
state: 'accepted',
|
|
78
|
-
target: description.target,
|
|
79
|
-
resultUrl: resultUrl(description, request.requestId),
|
|
80
|
-
recordedAt: new Date(),
|
|
81
|
-
output: { feedbackRecorded: true, feedbackId: 'fb-1' },
|
|
82
|
-
});
|
|
83
|
-
```
|
|
21
|
+
`parseDescription` reads the bytes as MAP JSON (strict I-JSON within 64 KiB) and checks the core rules, or throws `InvalidDocument` with every reason. Obtain contracts from a catalogue you configure and pin them by digest; a message never chooses one.
|
|
84
22
|
|
|
85
23
|
## API
|
|
86
24
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
| `new Contract(contract, requestSchema, { digest, dependencies })` | Checks the contract's format and profile, refuses any contract but the one pinned by `digest`, checks its pinned dependencies and request schema, and compiles every validator once, or throws `InvalidContract`; `dependencies` supplies, by URL, any pinned schema the package does not bundle |
|
|
94
|
-
| `contract.descriptionErrors(description)` | Checks a description against every rule of the core and the contract |
|
|
95
|
-
| `contract.requestProblem(description, request, { now })` | The exact type, an offered operation the authority permits, and expiry, as a problem code, title and detail, or undefined |
|
|
96
|
-
| `contract.inputErrors(description, request)` | Checks an operation's input and field bindings, with JSON Pointers into `input` |
|
|
97
|
-
| `contract.requestErrors(request)`, `contract.resultErrors(result)` | Check a request against the core and the request schema, and a result against the core, the declared output schema and the declared reason |
|
|
98
|
-
| `contract.typeReference`, `contract.operation(id)`, `contract.isDecision(id)` | The type reference descriptions and requests name, one of its operations, and whether completing it decides the interaction |
|
|
99
|
-
| `result`, `transition`, `problem` | Build results, state transitions and problems with their correlation members, or throw rather than return a document the core refuses. A problem stays within the core limits |
|
|
100
|
-
| `resultUrl`, `resultStatus`, `isRequestId` | The result resource of a request, a result's HTTP status, and whether a value is a request identifier, the only thing a result URL names |
|
|
101
|
-
| `isJsonRequest(contentType)` | Whether a `Content-Type` admits a request rather than a 415 |
|
|
102
|
-
| `DESCRIPTION_MEDIA_TYPE`, `isDescriptionPart(mediaType, profileParameter)` | The `Content-Type` of the part that carries a description, and whether a designated part is labelled with this profile |
|
|
103
|
-
| `retainUntil`, `settle`, `reached` | Result retention, the expiry of an undecided approval, and whether a deadline has passed |
|
|
104
|
-
| `capability(description)`, `writtenPath(url)` | The possession capability: the last segment of the execution URL's path as written |
|
|
105
|
-
|
|
106
|
-
Type rules a contract cannot express, such as a meeting slot being one of the slots offered, belong to each type's implementation. Validation uses Ajv with JSON Schema 2020-12. Lexical forms are core schema patterns, so `format` is never asserted, and references resolve only against pinned schemas, never over the network.
|
|
107
|
-
|
|
108
|
-
## MAP 0.2 core artifacts
|
|
109
|
-
|
|
110
|
-
```js
|
|
111
|
-
import { getContractFormatSchema, getFormsSchema, getMapContext, getMapSchema } from 'mailschema';
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Each is byte-identical to the file the [profile record](https://mailschema.org/profiles/map/0.2.json) binds by SHA-256, and is also exported raw as `mailschema/map-0.2.schema.json`, `mailschema/map-0.2.jsonld`, `mailschema/type-contract-0.2.schema.json` and `mailschema/forms-0.1.schema.json`. Type contracts are not bundled: an implementation vendors the contracts it supports, and `Contract` verifies them by digest.
|
|
115
|
-
|
|
116
|
-
## Registry data
|
|
117
|
-
|
|
118
|
-
```js
|
|
119
|
-
import { assertContribution, contributionErrors, referenceErrors } from 'mailschema';
|
|
120
|
-
|
|
121
|
-
const errors = contributionErrors(candidate);
|
|
122
|
-
if (errors.length) console.error(errors);
|
|
123
|
-
else assertContribution(candidate);
|
|
25
|
+
- `parse(input, maxBytes)`, `canonicalize(value)`, `digest(value)`: MAP JSON and RFC 8785 digests.
|
|
26
|
+
- `descriptionErrors(value)`, `parseDescription(input)`: the core description rules.
|
|
27
|
+
- `new Contract(value)`, `Contract.parse(input)`: a checked contract with `digest`, `operation(id)`, `detailsErrors(details)`, `inputErrors(operationId, input)` and `descriptionErrors(description)`.
|
|
28
|
+
- `contractErrors(value)`: why a value is not a contract, including schema keywords, formats and patterns every implementation can enforce alike.
|
|
29
|
+
- `implementationErrors(value)`, `parseImplementation(input)`: Registry implementation records.
|
|
30
|
+
- `PROFILE`, `CONTEXT`, `DESCRIPTION_MEDIA_TYPE`, `EFFECTS`, `CAPABILITY_KINDS` and the size limits.
|
|
124
31
|
|
|
125
|
-
|
|
126
|
-
```
|
|
32
|
+
The profile record, context and schemas are exported byte for byte: `mailschema/profile.json`, `mailschema/context.jsonld`, `mailschema/core.schema.json`, `mailschema/contract.schema.json` and `mailschema/implementation.schema.json`.
|
|
127
33
|
|
|
128
|
-
|
|
34
|
+
## Command line
|
|
129
35
|
|
|
130
36
|
```sh
|
|
131
|
-
npx mailschema
|
|
132
|
-
npx mailschema
|
|
133
|
-
npx mailschema
|
|
37
|
+
npx mailschema@0.3.1 contract campaign-send-approval-0.1.json
|
|
38
|
+
npx mailschema@0.3.1 description description.json --contract campaign-send-approval-0.1.json
|
|
39
|
+
npx mailschema@0.3.1 implementation record.json
|
|
134
40
|
```
|
|
135
41
|
|
|
136
|
-
|
|
42
|
+
Each command first prints a line naming what it checked. `contract` prints `Valid type contract <id> <version>` and, on the second line, the contract's digest. `description` prints `Valid MAP 0.3 description <@id>` and, on the second line, the description's digest; with `--contract`, it first checks that the description uses that contract as it allows. `implementation` prints `Valid implementation record for <service>`. A digest is `sha-256:` and the SHA-256 of the document's RFC 8785 canonical JSON, the value `digest()` returns; the description's digest is not the contract digest it names. An invalid file prints every reason on standard error and exits with status 1. Nothing is uploaded or changed.
|
|
43
|
+
|
|
44
|
+
Checking does not authenticate a message, establish a service's authority or perform an action. Those belong to the implementation, under the [specification](https://mailschema.org/specification/core).
|
|
137
45
|
|
|
138
|
-
|
|
46
|
+
Source: [mailschema/javascript](https://github.com/mailschema/javascript). License: MIT.
|
package/bin/mailschema.js
CHANGED
|
@@ -1,72 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
3
3
|
import { parseArgs } from 'node:util';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
getMapSchema,
|
|
12
|
-
getRecordSchema,
|
|
5
|
+
Contract,
|
|
6
|
+
CONTRACT_MAX_BYTES,
|
|
7
|
+
digest,
|
|
8
|
+
InvalidDocument,
|
|
9
|
+
parseDescription,
|
|
10
|
+
parseImplementation,
|
|
13
11
|
} from '../dist/index.js';
|
|
14
12
|
|
|
15
|
-
const help = `
|
|
13
|
+
const help = `Mail Action Protocol 0.3 checks
|
|
16
14
|
|
|
17
|
-
mailschema
|
|
18
|
-
mailschema
|
|
15
|
+
mailschema contract <contract.json>
|
|
16
|
+
mailschema description <description.json> [--contract <contract.json>]
|
|
17
|
+
mailschema implementation <record.json>
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
contract checks a type contract and prints its digest. description checks a
|
|
20
|
+
description and, with --contract, that it uses that contract as it allows,
|
|
21
|
+
then prints the description's digest. implementation checks a Registry
|
|
22
|
+
implementation record. A digest is the SHA-256 of the document's RFC 8785
|
|
23
|
+
canonical JSON. Nothing is uploaded or changed.`;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
async function read(path) {
|
|
26
|
+
const info = await stat(path);
|
|
27
|
+
if (!info.isFile() || info.size > CONTRACT_MAX_BYTES)
|
|
28
|
+
throw new Error(`Expected a JSON file of at most ${CONTRACT_MAX_BYTES} bytes.`);
|
|
29
|
+
return new Uint8Array(await readFile(path));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function report(errors) {
|
|
33
|
+
if (!errors.length) return;
|
|
34
|
+
throw new InvalidDocument('Not valid.', errors);
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
try {
|
|
33
38
|
const { values, positionals } = parseArgs({
|
|
34
39
|
allowPositionals: true,
|
|
35
|
-
options: {
|
|
36
|
-
...Object.fromEntries(Object.keys(schemas).map((name) => [name, { type: 'boolean' }])),
|
|
37
|
-
help: { type: 'boolean', short: 'h' },
|
|
38
|
-
},
|
|
40
|
+
options: { contract: { type: 'string' }, help: { type: 'boolean', short: 'h' } },
|
|
39
41
|
});
|
|
40
42
|
const [command, path, ...extra] = positionals;
|
|
41
|
-
const chosen = Object.keys(schemas).filter((name) => values[name]);
|
|
42
|
-
if (chosen.length > 1) throw new Error('Choose only one schema.');
|
|
43
43
|
if (values.help || !command) console.log(help);
|
|
44
|
-
else if (
|
|
45
|
-
|
|
46
|
-
else if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
throw new Error('Expected a JSON file no larger than 256 KiB.');
|
|
58
|
-
const bytes = Buffer.alloc(256 * 1024 + 1);
|
|
59
|
-
const { bytesRead } = await file.read(bytes, 0, bytes.length, 0);
|
|
60
|
-
if (bytesRead > 256 * 1024) throw new Error('JSON file exceeds 256 KiB.');
|
|
61
|
-
value = JSON.parse(bytes.subarray(0, bytesRead).toString('utf8'));
|
|
62
|
-
} finally {
|
|
63
|
-
await file.close();
|
|
64
|
-
}
|
|
65
|
-
if (values.record) assertTypeRecord(value);
|
|
66
|
-
else assertContribution(value);
|
|
67
|
-
console.log(`Valid MailSchema ${values.record ? 'type record' : 'contribution'}.`);
|
|
44
|
+
else if (!path || extra.length || (values.contract && command !== 'description'))
|
|
45
|
+
throw new Error(help);
|
|
46
|
+
else if (command === 'contract') {
|
|
47
|
+
const contract = Contract.parse(await read(path));
|
|
48
|
+
console.log(`Valid type contract ${contract.id} ${contract.version}\n${contract.digest}`);
|
|
49
|
+
} else if (command === 'description') {
|
|
50
|
+
const description = parseDescription(await read(path));
|
|
51
|
+
if (values.contract)
|
|
52
|
+
report(Contract.parse(await read(values.contract)).descriptionErrors(description));
|
|
53
|
+
console.log(`Valid MAP 0.3 description ${description['@id']}\n${digest(description)}`);
|
|
54
|
+
} else if (command === 'implementation') {
|
|
55
|
+
const record = parseImplementation(await read(path));
|
|
56
|
+
console.log(`Valid implementation record for ${record.service}`);
|
|
68
57
|
} else throw new Error(help);
|
|
69
58
|
} catch (error) {
|
|
70
|
-
console.error(error instanceof
|
|
59
|
+
console.error(error instanceof InvalidDocument ? error.errors.join('\n') : error.message);
|
|
71
60
|
process.exitCode = 1;
|
|
72
61
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": {
|
|
3
|
+
"@version": 1.1,
|
|
4
|
+
"@protected": true,
|
|
5
|
+
"@vocab": "https://mailschema.org/vocab/map/0.3#",
|
|
6
|
+
"MailAction": "https://mailschema.org/vocab/map/0.3#MailAction",
|
|
7
|
+
"profile": {
|
|
8
|
+
"@id": "profile",
|
|
9
|
+
"@type": "@id"
|
|
10
|
+
},
|
|
11
|
+
"type": {
|
|
12
|
+
"@id": "type",
|
|
13
|
+
"@type": "@json"
|
|
14
|
+
},
|
|
15
|
+
"service": {
|
|
16
|
+
"@id": "service",
|
|
17
|
+
"@type": "@json"
|
|
18
|
+
},
|
|
19
|
+
"subject": {
|
|
20
|
+
"@id": "subject",
|
|
21
|
+
"@type": "@json"
|
|
22
|
+
},
|
|
23
|
+
"terms": {
|
|
24
|
+
"@id": "terms",
|
|
25
|
+
"@type": "@json"
|
|
26
|
+
},
|
|
27
|
+
"details": {
|
|
28
|
+
"@id": "details",
|
|
29
|
+
"@type": "@json"
|
|
30
|
+
},
|
|
31
|
+
"operations": {
|
|
32
|
+
"@id": "operations",
|
|
33
|
+
"@type": "@json"
|
|
34
|
+
},
|
|
35
|
+
"human": {
|
|
36
|
+
"@id": "human",
|
|
37
|
+
"@type": "@json"
|
|
38
|
+
},
|
|
39
|
+
"recipient": "recipient",
|
|
40
|
+
"inLanguage": "inLanguage",
|
|
41
|
+
"issuedAt": {
|
|
42
|
+
"@id": "issuedAt",
|
|
43
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
44
|
+
},
|
|
45
|
+
"expiresAt": {
|
|
46
|
+
"@id": "expiresAt",
|
|
47
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://mailschema.org/artifacts/map-0.3/schemas/contract.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": [
|
|
7
|
+
"id",
|
|
8
|
+
"version",
|
|
9
|
+
"profile",
|
|
10
|
+
"name",
|
|
11
|
+
"summary",
|
|
12
|
+
"requirements",
|
|
13
|
+
"detailsSchema",
|
|
14
|
+
"operations"
|
|
15
|
+
],
|
|
16
|
+
"properties": {
|
|
17
|
+
"id": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"minLength": 1,
|
|
20
|
+
"format": "uri",
|
|
21
|
+
"pattern": "^https://",
|
|
22
|
+
"maxLength": 2048
|
|
23
|
+
},
|
|
24
|
+
"version": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"minLength": 1,
|
|
27
|
+
"maxLength": 64
|
|
28
|
+
},
|
|
29
|
+
"profile": {
|
|
30
|
+
"const": "https://mailschema.org/profiles/map/0.3"
|
|
31
|
+
},
|
|
32
|
+
"name": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"minLength": 1,
|
|
35
|
+
"maxLength": 2048
|
|
36
|
+
},
|
|
37
|
+
"summary": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"minLength": 1,
|
|
40
|
+
"maxLength": 2048
|
|
41
|
+
},
|
|
42
|
+
"requirements": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"items": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"minLength": 1,
|
|
47
|
+
"maxLength": 2048
|
|
48
|
+
},
|
|
49
|
+
"minItems": 1,
|
|
50
|
+
"maxItems": 64
|
|
51
|
+
},
|
|
52
|
+
"detailsSchema": {
|
|
53
|
+
"type": "object"
|
|
54
|
+
},
|
|
55
|
+
"operations": {
|
|
56
|
+
"type": "array",
|
|
57
|
+
"items": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"additionalProperties": false,
|
|
60
|
+
"required": [
|
|
61
|
+
"id",
|
|
62
|
+
"name",
|
|
63
|
+
"semantics",
|
|
64
|
+
"effects",
|
|
65
|
+
"bindings",
|
|
66
|
+
"actors",
|
|
67
|
+
"exactTerms",
|
|
68
|
+
"inputSchema",
|
|
69
|
+
"outcomes"
|
|
70
|
+
],
|
|
71
|
+
"properties": {
|
|
72
|
+
"id": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"minLength": 1,
|
|
75
|
+
"pattern": "^[a-z][a-z0-9-]{0,63}$"
|
|
76
|
+
},
|
|
77
|
+
"name": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"minLength": 1,
|
|
80
|
+
"maxLength": 2048
|
|
81
|
+
},
|
|
82
|
+
"semantics": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"minLength": 1,
|
|
85
|
+
"maxLength": 2048
|
|
86
|
+
},
|
|
87
|
+
"effects": {
|
|
88
|
+
"type": "array",
|
|
89
|
+
"items": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"minLength": 1,
|
|
92
|
+
"format": "uri",
|
|
93
|
+
"pattern": "^https://"
|
|
94
|
+
},
|
|
95
|
+
"minItems": 1,
|
|
96
|
+
"maxItems": 32,
|
|
97
|
+
"uniqueItems": true
|
|
98
|
+
},
|
|
99
|
+
"bindings": {
|
|
100
|
+
"type": "array",
|
|
101
|
+
"items": {
|
|
102
|
+
"enum": [
|
|
103
|
+
"credential",
|
|
104
|
+
"capability"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"minItems": 1,
|
|
108
|
+
"maxItems": 2,
|
|
109
|
+
"uniqueItems": true
|
|
110
|
+
},
|
|
111
|
+
"actors": {
|
|
112
|
+
"type": "array",
|
|
113
|
+
"items": {
|
|
114
|
+
"enum": [
|
|
115
|
+
"human",
|
|
116
|
+
"agent"
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
"minItems": 1,
|
|
120
|
+
"maxItems": 2,
|
|
121
|
+
"uniqueItems": true
|
|
122
|
+
},
|
|
123
|
+
"exactTerms": {
|
|
124
|
+
"type": "boolean"
|
|
125
|
+
},
|
|
126
|
+
"inputSchema": {
|
|
127
|
+
"type": [
|
|
128
|
+
"object",
|
|
129
|
+
"null"
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"outcomes": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"minProperties": 1,
|
|
135
|
+
"propertyNames": {
|
|
136
|
+
"pattern": "^[a-z][a-z0-9-]{0,63}$"
|
|
137
|
+
},
|
|
138
|
+
"additionalProperties": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"minLength": 1,
|
|
141
|
+
"maxLength": 2048
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"capability": {
|
|
145
|
+
"type": "object",
|
|
146
|
+
"additionalProperties": false,
|
|
147
|
+
"required": [
|
|
148
|
+
"kind",
|
|
149
|
+
"maxLifetimeSeconds"
|
|
150
|
+
],
|
|
151
|
+
"properties": {
|
|
152
|
+
"kind": {
|
|
153
|
+
"enum": [
|
|
154
|
+
"refusal",
|
|
155
|
+
"protective-report",
|
|
156
|
+
"address-confirmation"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"maxLifetimeSeconds": {
|
|
160
|
+
"type": "integer",
|
|
161
|
+
"minimum": 1,
|
|
162
|
+
"maximum": 604800
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"allOf": [
|
|
168
|
+
{
|
|
169
|
+
"if": {
|
|
170
|
+
"properties": {
|
|
171
|
+
"bindings": {
|
|
172
|
+
"contains": {
|
|
173
|
+
"const": "capability"
|
|
174
|
+
},
|
|
175
|
+
"type": "array"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"then": {
|
|
180
|
+
"required": [
|
|
181
|
+
"capability"
|
|
182
|
+
],
|
|
183
|
+
"properties": {
|
|
184
|
+
"inputSchema": {
|
|
185
|
+
"type": "null"
|
|
186
|
+
},
|
|
187
|
+
"exactTerms": {
|
|
188
|
+
"const": true
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"else": {
|
|
193
|
+
"not": {
|
|
194
|
+
"required": [
|
|
195
|
+
"capability"
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
"minItems": 1,
|
|
203
|
+
"maxItems": 32
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
package/dist/core/artifacts.d.ts
CHANGED
|
@@ -1,36 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare const definition: (schema: string, name: string) => ValidateFunction;
|
|
13
|
-
/** Errors as `pointer message` lines, as the other MailSchema packages report them. */
|
|
14
|
-
export declare function errorList(errors: ErrorObject[] | null | undefined, prefix?: string): string[];
|
|
15
|
-
/** Checks a type contract against the contract format. */
|
|
16
|
-
export declare const contractFormatErrors: (contract: unknown) => string[];
|
|
17
|
-
/** Checks any MAP 0.2 description, request, result or problem against the core schema. */
|
|
18
|
-
export declare const mapErrors: (document: unknown) => string[];
|
|
19
|
-
/**
|
|
20
|
-
* Checks a description against the core description definition only. A description of a
|
|
21
|
-
* type the caller has no contract for can be checked this far.
|
|
22
|
-
*/
|
|
23
|
-
export declare const descriptionErrors: (description: unknown) => string[];
|
|
24
|
-
/** Checks a request against the core request definition. Its identifier stays free if it fails. */
|
|
25
|
-
export declare const requestErrors: (request: unknown) => string[];
|
|
26
|
-
/** Checks a result against the core result definition only. */
|
|
27
|
-
export declare const resultErrors: (result: unknown) => string[];
|
|
28
|
-
/** Checks a problem against the core problem definition, including its type, status and code. */
|
|
29
|
-
export declare const problemErrors: (problem: unknown) => string[];
|
|
30
|
-
/** Whether a value is a request identifier: the core UUID URN form. Only one names a result resource. */
|
|
31
|
-
export declare const isRequestId: (value: unknown) => boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Whether a deadline, a core date-time plus `afterSeconds`, has been reached. Anything but
|
|
34
|
-
* a core date-time counts as reached, so a mistake fails closed.
|
|
35
|
-
*/
|
|
36
|
-
export declare const reached: (now: Date, deadline: string, afterSeconds?: number) => boolean;
|
|
1
|
+
export { coreSchema, contractSchema, implementationSchema } from './bundled.ts';
|
|
2
|
+
export declare const PROFILE = "https://mailschema.org/profiles/map/0.3";
|
|
3
|
+
export declare const CONTEXT = "https://mailschema.org/contexts/map-0.3.jsonld";
|
|
4
|
+
/** The Content-Type of the MIME part that carries a description. */
|
|
5
|
+
export declare const DESCRIPTION_MEDIA_TYPE = "application/ld+json; profile=\"https://mailschema.org/profiles/map/0.3\"";
|
|
6
|
+
export declare const DESCRIPTION_MAX_BYTES = 65536;
|
|
7
|
+
export declare const CONTRACT_MAX_BYTES = 262144;
|
|
8
|
+
/** The namespace of the initial effect vocabulary. */
|
|
9
|
+
export declare const EFFECTS = "https://mailschema.org/effects/";
|
|
10
|
+
/** The formats MAP schemas may assert. Every implementation checks exactly these. */
|
|
11
|
+
export declare const FORMATS: readonly ["date", "date-time", "email", "uri"];
|