mailschema 0.2.2 → 0.3.0

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 (52) hide show
  1. package/README.md +25 -119
  2. package/bin/mailschema.js +40 -53
  3. package/dist/context.jsonld +50 -0
  4. package/dist/contract.schema.json +206 -0
  5. package/dist/core/artifacts.d.ts +11 -36
  6. package/dist/core/artifacts.js +21 -69
  7. package/dist/core/bundled.d.ts +4 -4
  8. package/dist/core/bundled.js +7 -7
  9. package/dist/core/contract.d.ts +59 -56
  10. package/dist/core/contract.js +224 -298
  11. package/dist/core/description.d.ts +45 -0
  12. package/dist/core/description.js +47 -0
  13. package/dist/core/implementation.d.ts +32 -0
  14. package/dist/core/implementation.js +25 -0
  15. package/dist/core/index.d.ts +7 -6
  16. package/dist/core/index.js +9 -9
  17. package/dist/core/json.d.ts +23 -0
  18. package/dist/core/{document.js → json.js} +61 -51
  19. package/dist/core/patterns.d.ts +12 -0
  20. package/dist/core/patterns.js +165 -0
  21. package/dist/core/sha256.d.ts +2 -0
  22. package/dist/core/sha256.js +59 -0
  23. package/dist/core.schema.json +210 -0
  24. package/dist/implementation.schema.json +173 -0
  25. package/dist/index.d.ts +4 -9
  26. package/dist/index.js +2 -14
  27. package/dist/profile.json +27 -0
  28. package/package.json +9 -10
  29. package/dist/contribution.schema.json +0 -874
  30. package/dist/core/binding.d.ts +0 -24
  31. package/dist/core/binding.js +0 -50
  32. package/dist/core/document.d.ts +0 -24
  33. package/dist/core/documents.d.ts +0 -68
  34. package/dist/core/documents.js +0 -145
  35. package/dist/core/limits.d.ts +0 -19
  36. package/dist/core/limits.js +0 -55
  37. package/dist/core/pointer.d.ts +0 -12
  38. package/dist/core/pointer.js +0 -48
  39. package/dist/core/schemas.d.ts +0 -21
  40. package/dist/core/schemas.js +0 -125
  41. package/dist/core/types.d.ts +0 -127
  42. package/dist/core/types.js +0 -2
  43. package/dist/forms-0.1.schema.json +0 -329
  44. package/dist/map-0.2.jsonld +0 -91
  45. package/dist/map-0.2.schema.json +0 -1033
  46. package/dist/map.d.ts +0 -8
  47. package/dist/map.js +0 -18
  48. package/dist/model.d.ts +0 -95
  49. package/dist/model.js +0 -5
  50. package/dist/type-contract-0.2.schema.json +0 -179
  51. package/dist/validation.d.ts +0 -15
  52. package/dist/validation.js +0 -64
package/README.md CHANGED
@@ -1,138 +1,44 @@
1
- # MailSchema for JavaScript
1
+ # mailschema
2
2
 
3
- [![npm](https://img.shields.io/npm/v/mailschema)](https://www.npmjs.com/package/mailschema)
4
- [![CI](https://github.com/mailschema/javascript/actions/workflows/test.yml/badge.svg)](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.0
41
7
  ```
42
8
 
43
- When a request arrives, check it in this order. No step applies an effect for a problem, and a refusal before the description is resolved and its digest matched leaves the request identifier unclaimed:
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
- // Request identifiers are claimed within your tenant: the account, or the capability.
59
- // If request.requestId is already claimed there, refuse another principal, and a principal
60
- // whose permission has been revoked, with an uncorrelated refused problem (problem()
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.inputErrors(description, request);
70
- // [{ detail: '…', pointer: '/feedback' }], a claimed invalid-request
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
- Then apply the approval lifecycle or the effect, and record the result:
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
- | Call | Does |
88
- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
89
- | `parse(text \| bytes)` | Parses a MAP document as I-JSON within the core limits, or throws `InvalidDocument` |
90
- | `canonicalize(value)`, `digest(value)` | RFC 8785 canonical JSON, and `sha-256:` over it |
91
- | `mapErrors(document)` | Checks a description, request, result or problem against the core schema |
92
- | `descriptionErrors`, `requestErrors`, `resultErrors`, `problemErrors` | Check one document against its core definition only |
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 |
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.
105
31
 
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);
124
-
125
- const referenceProblems = referenceErrors(candidate, catalog);
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
- `assertTypeRecord` and `getRecordSchema` handle expanded Registry records. Reference checks use a catalogue supplied by the caller; the package never fetches one.
34
+ ## Command line
129
35
 
130
36
  ```sh
131
- npx mailschema check contribution.json
132
- npx mailschema check record.json --record
133
- npx mailschema schema --map
37
+ npx mailschema@0.3.0 contract campaign-send-approval-0.1.json
38
+ npx mailschema@0.3.0 description description.json --contract campaign-send-approval-0.1.json
39
+ npx mailschema@0.3.0 implementation record.json
134
40
  ```
135
41
 
136
- ## Trust boundary
42
+ 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
43
 
138
- A valid document is structured input. Validation does not authenticate a service, grant authority or establish product conformance. 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.
44
+ Source: [mailschema/javascript](https://github.com/mailschema/javascript). License: MIT.
package/bin/mailschema.js CHANGED
@@ -1,72 +1,59 @@
1
1
  #!/usr/bin/env node
2
- import { open } from 'node:fs/promises';
2
+ import { readFile, stat } from 'node:fs/promises';
3
3
  import { parseArgs } from 'node:util';
4
4
  import {
5
- assertContribution,
6
- assertTypeRecord,
7
- getContractFormatSchema,
8
- getContributionSchema,
9
- getFormsSchema,
10
- getMapContext,
11
- getMapSchema,
12
- getRecordSchema,
5
+ Contract,
6
+ CONTRACT_MAX_BYTES,
7
+ InvalidDocument,
8
+ parseDescription,
9
+ parseImplementation,
13
10
  } from '../dist/index.js';
14
11
 
15
- const help = `MailSchema Registry tools
12
+ const help = `Mail Action Protocol 0.3 checks
16
13
 
17
- mailschema check <file.json> [--record]
18
- mailschema schema [--record | --map | --context | --contract-format | --forms]
14
+ mailschema contract <contract.json>
15
+ mailschema description <description.json> [--contract <contract.json>]
16
+ mailschema implementation <record.json>
19
17
 
20
- check validates a Registry contribution, or with --record an expanded record,
21
- locally. schema prints a bundled schema: the contribution schema by default, or
22
- a MAP 0.2 core artifact. No files are uploaded or changed.`;
18
+ contract checks a type contract and prints its digest. description checks a
19
+ description and, with --contract, that it uses that contract as it allows.
20
+ implementation checks a Registry implementation record. Nothing is uploaded
21
+ or changed.`;
23
22
 
24
- const schemas = {
25
- record: getRecordSchema,
26
- map: getMapSchema,
27
- context: getMapContext,
28
- 'contract-format': getContractFormatSchema,
29
- forms: getFormsSchema,
30
- };
23
+ async function read(path) {
24
+ const info = await stat(path);
25
+ if (!info.isFile() || info.size > CONTRACT_MAX_BYTES)
26
+ throw new Error(`Expected a JSON file of at most ${CONTRACT_MAX_BYTES} bytes.`);
27
+ return new Uint8Array(await readFile(path));
28
+ }
29
+
30
+ function report(errors) {
31
+ if (!errors.length) return;
32
+ throw new InvalidDocument('Not valid.', errors);
33
+ }
31
34
 
32
35
  try {
33
36
  const { values, positionals } = parseArgs({
34
37
  allowPositionals: true,
35
- options: {
36
- ...Object.fromEntries(Object.keys(schemas).map((name) => [name, { type: 'boolean' }])),
37
- help: { type: 'boolean', short: 'h' },
38
- },
38
+ options: { contract: { type: 'string' }, help: { type: 'boolean', short: 'h' } },
39
39
  });
40
40
  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
41
  if (values.help || !command) console.log(help);
44
- else if (command === 'schema' && !path && !extra.length)
45
- console.log(JSON.stringify((schemas[chosen[0]] ?? getContributionSchema)(), null, 2));
46
- else if (
47
- command === 'check' &&
48
- path &&
49
- !extra.length &&
50
- chosen.every((name) => name === 'record')
51
- ) {
52
- const file = await open(path, 'r');
53
- let value;
54
- try {
55
- const info = await file.stat();
56
- if (!info.isFile() || info.size > 256 * 1024)
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'}.`);
42
+ else if (!path || extra.length || (values.contract && command !== 'description'))
43
+ throw new Error(help);
44
+ else if (command === 'contract') {
45
+ const contract = Contract.parse(await read(path));
46
+ console.log(`Valid type contract ${contract.id} ${contract.version}\n${contract.digest}`);
47
+ } else if (command === 'description') {
48
+ const description = parseDescription(await read(path));
49
+ if (values.contract)
50
+ report(Contract.parse(await read(values.contract)).descriptionErrors(description));
51
+ console.log(`Valid MAP 0.3 description ${description['@id']}`);
52
+ } else if (command === 'implementation') {
53
+ const record = parseImplementation(await read(path));
54
+ console.log(`Valid implementation record for ${record.service}`);
68
55
  } else throw new Error(help);
69
56
  } catch (error) {
70
- console.error(error instanceof Error ? error.message : String(error));
57
+ console.error(error instanceof InvalidDocument ? error.errors.join('\n') : error.message);
71
58
  process.exitCode = 1;
72
59
  }
@@ -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
+ }
@@ -1,36 +1,11 @@
1
- import { type ErrorObject, type ValidateFunction } from 'ajv/dist/2020.js';
2
- import type { JsonObject } from './types.ts';
3
- export declare const MAP_PROFILE = "https://mailschema.org/profiles/map/0.2";
4
- export declare const CORE_SCHEMA = "https://mailschema.org/schemas/map-0.2.schema.json";
5
- export declare const FORMS_SCHEMA = "https://mailschema.org/schemas/forms-0.1.schema.json";
6
- export declare const CONTRACT_FORMAT = "https://mailschema.org/schemas/type-contract-0.2.schema.json";
7
- export declare const CONTEXT = "https://mailschema.org/contexts/map-0.2.jsonld";
8
- export declare const JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";
9
- /** The schemas a contract may depend on without supplying them itself. */
10
- export declare const BUNDLED: ReadonlyMap<string, JsonObject>;
11
- /** A core or form fields definition by name, for the shared lexical vectors. */
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"];