mailschema 0.1.1 → 0.1.3

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 (2) hide show
  1. package/README.md +42 -18
  2. package/package.json +10 -3
package/README.md CHANGED
@@ -1,41 +1,65 @@
1
- # MailSchema
1
+ # MailSchema for JavaScript
2
2
 
3
- JSON Schemas and validation tools for Mail Action Protocol 0.1 and the MailSchema Registry.
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)
4
5
 
5
- Validate MAP descriptions, requests, results and problems, or prepare a Registry contribution. The package is local and performs no network requests.
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
- npx mailschema check contribution.json
10
- npx mailschema schema > contribution.schema.json
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
- Node.js 22 or newer. The JavaScript API is ESM; the CLI reads a local JSON file of at most 256 KiB and does not upload or modify it.
35
+ ## Work with Registry data
16
36
 
17
37
  ```js
18
- import { assertContribution, contributionErrors, getContributionSchema } from 'mailschema';
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(); // Independent copy, JSON Schema Draft 2020-12.
49
+ const schema = getContributionSchema();
50
+ const referenceProblems = referenceErrors(candidate, catalog);
25
51
  ```
26
52
 
27
- ```js
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
- assertMapDocument(description);
31
- assertContentReviewRequest(request);
32
- const mapSchema = getMapSchema();
33
- ```
55
+ Raw Draft 2020-12 schemas are exported as:
34
56
 
35
- Use `assertTypeRecord(value)` or `mailschema check record.json --record` for expanded Registry records. `getRecordSchema()` returns the equivalent schema. The raw contribution schema is also exported as `mailschema/contribution.schema.json`.
57
+ - `mailschema/map-0.1.schema.json`
58
+ - `mailschema/content-review-0.1.schema.json`
59
+ - `mailschema/contribution.schema.json`
36
60
 
37
- For a structurally valid contribution, `referenceErrors(contribution, catalog)` checks references against a supplied catalogue: current amendment bases, existing type names, exact implementation records, versions, profiles and operations. The catalogue contains `types` and `snapshots` arrays of `{ record, digest }` entries. It is never fetched automatically.
61
+ ## Trust boundary
38
62
 
39
- `Contribution`, `TypeRecord`, `TypeDefinition`, `Implementation`, `Party` and `CatalogView` are exported TypeScript types. Successful validation does not verify a contributor's identity, establish product compatibility or accept a submission. Full repository review also checks competing amendments and contribution identifiers.
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
- Raw schemas are exported as `mailschema/map-0.1.schema.json`, `mailschema/content-review-0.1.schema.json` and `mailschema/contribution.schema.json`. Package version `0.2.0` is independent of the MAP profile version. MIT licensed.
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailschema",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Schemas and validation tools for Mail Action Protocol and the MailSchema Registry",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,10 +8,10 @@
8
8
  "homepage": "https://mailschema.org/tools/",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/mailschema/mailschema.git"
11
+ "url": "git+https://github.com/mailschema/javascript.git"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/mailschema/mailschema/issues"
14
+ "url": "https://github.com/mailschema/javascript/issues"
15
15
  },
16
16
  "engines": {
17
17
  "node": ">=22"
@@ -36,10 +36,17 @@
36
36
  "README.md",
37
37
  "LICENSE"
38
38
  ],
39
+ "scripts": {
40
+ "build": "node build.mjs",
41
+ "test": "npm run build && node --test test/*.test.mjs"
42
+ },
39
43
  "dependencies": {
40
44
  "ajv": "8.20.0",
41
45
  "ajv-formats": "3.0.1"
42
46
  },
47
+ "devDependencies": {
48
+ "typescript": "5.9.3"
49
+ },
43
50
  "keywords": [
44
51
  "email",
45
52
  "schema",