@tracepass/dpp-schemas 1.29.7 → 1.31.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.
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
12
12
  [![npm](https://img.shields.io/npm/v/@tracepass/dpp-schemas.svg)](https://www.npmjs.com/package/@tracepass/dpp-schemas)
13
- [![Fields](https://img.shields.io/badge/fields-1010-informational)](#whats-in-here)
13
+ [![Fields](https://img.shields.io/badge/fields-1016-informational)](#whats-in-here)
14
14
  [![Categories](https://img.shields.io/badge/categories-13-informational)](#whats-in-here)
15
15
  [![Dependencies](https://img.shields.io/badge/dependencies-none-success)](#no-build-step)
16
16
  [![Schema](https://img.shields.io/badge/JSON%20Schema-2020--12-orange)](./schema.json)
@@ -39,14 +39,14 @@ this repository contains.
39
39
 
40
40
  ## What's in here
41
41
 
42
- Thirteen JSON files, one per product category. **1,010 fields in total. 66 are required by
42
+ Thirteen JSON files, one per product category. **1,016 fields in total. 67 are required by
43
43
  a law that creates a passport; 176 are anticipated under a rule that does not apply yet.**
44
44
  Every other legal duty (on the product, the label, a safety data sheet, a document) is
45
45
  recorded per field in `regulationRef.obligations` instead of being marked required.
46
46
 
47
47
  | Category | Fields | Required | Instrument |
48
48
  |---|---:|---:|---|
49
- | `battery` | 136 | 40 | Regulation (EU) 2023/1542 |
49
+ | `battery` | 142 | 41 | Regulation (EU) 2023/1542 |
50
50
  | `construction` | 54 | 0 | CPR (EU) 2024/3110 |
51
51
  | `detergents` | 77 | 12 | Regulation (EU) 2026/405 |
52
52
  | `electronics` | 160 | 0 | ESPR (EU) 2024/1781 |
@@ -390,6 +390,53 @@ runs it on every push:
390
390
  [`audit/README.md`](./audit/README.md).
391
391
  - **Planned acts** (`scripts/check-planned-acts.mjs`): every `plannedActs` entry names
392
392
  an instrument it is adopted under, and its planned date matches its source's precision.
393
+ - **Data-model versions** (`scripts/check-model-versions.mjs`): every template's
394
+ `modelVersion` matches its hash in `model-versions.json`. See below.
395
+
396
+ ## Data-model versions
397
+
398
+ Each template carries `modelVersion`, a SemVer name for its **data model**: the parts
399
+ that decide whether a passport is valid and who may see each field. These are field
400
+ keys, data types, units, allowed values, validation, access levels, the citations and
401
+ the regulation dates. Labels, descriptions, translations and editorial notes are not
402
+ part of the model. [`model-subset.json`](./model-subset.json) lists which keys are in
403
+ and which are out.
404
+
405
+ [`model-versions.json`](./model-versions.json) pairs every released version with a
406
+ hash of the model, so a version number can always be checked:
407
+
408
+ - **The hash** is `sha256:` over the [RFC 8785](https://www.rfc-editor.org/rfc/rfc8785)
409
+ (JCS) canonical form of the template projected onto `model-subset.json`
410
+ ([`scripts/model-hash.mjs`](./scripts/model-hash.mjs)). In the projection:
411
+ - `fields` is keyed by field key;
412
+ - enum values and obligations are sorted;
413
+ - `null`, `[]` and `{}` count as absent.
414
+ - **The gate** (`npm run check:model`, part of `npm run check`) fails two cases: a model
415
+ that changed without a new version, and a template key that `model-subset.json` does
416
+ not classify.
417
+
418
+ The version number moves like this:
419
+
420
+ | Level | When |
421
+ |---|---|
422
+ | MAJOR | A passport that met the old model can fail the new one, or data a reader relies on disappears or changes meaning. This covers a field added as required, made required, removed or renamed; a type or unit changed; an allowed value removed; validation tightened; a date moved earlier; an access level tightened. |
423
+ | MINOR | Compatible additions and relaxations. This covers an optional field added, an allowed value added, validation relaxed, a field no longer required, a date moved later, an access level loosened. |
424
+ | PATCH | A model change with no effect on any outcome, such as a corrected citation. |
425
+
426
+ To bump a version after editing a template:
427
+
428
+ ```bash
429
+ npm run bump:model -- battery minor # --dry-run to preview
430
+ ```
431
+
432
+ The bump command:
433
+
434
+ 1. finds the recorded model in git history;
435
+ 2. lists what changed;
436
+ 3. works out the smallest allowed level and refuses anything below it;
437
+ 4. sets `modelVersion` and appends the new entry to the ledger.
438
+
439
+ The integer `version` is a legacy label and is not enforced.
393
440
 
394
441
  ## Recent changes
395
442
 
@@ -439,6 +439,12 @@
439
439
  71
440
440
  ],
441
441
  "why": "periodically recorded state of charge, Annex XIII 4(d)"
442
+ },
443
+ "notInUseTemperatureRangeTest": {
444
+ "dp": [
445
+ 34
446
+ ],
447
+ "why": "reference test of the idle temperature range, Annex XIII 1(l)"
442
448
  }
443
449
  },
444
450
  "primaryTextOnly": {}
package/index.json CHANGED
@@ -7,8 +7,8 @@
7
7
  },
8
8
  "totals": {
9
9
  "categories": 13,
10
- "fields": 1010,
11
- "requiredFields": 66,
10
+ "fields": 1016,
11
+ "requiredFields": 67,
12
12
  "anticipatedFields": 176
13
13
  },
14
14
  "categories": [
@@ -16,9 +16,10 @@
16
16
  "category": "battery",
17
17
  "label": "Battery",
18
18
  "file": "templates/battery.json",
19
- "version": 6,
20
- "fieldCount": 136,
21
- "requiredFieldCount": 40,
19
+ "version": 7,
20
+ "modelVersion": "7.0.0",
21
+ "fieldCount": 142,
22
+ "requiredFieldCount": 41,
22
23
  "anticipatedFieldCount": 15,
23
24
  "regulation": {
24
25
  "name": "EU Battery Regulation",
@@ -33,6 +34,7 @@
33
34
  "label": "Construction Materials",
34
35
  "file": "templates/construction.json",
35
36
  "version": 2,
37
+ "modelVersion": "2.0.0",
36
38
  "fieldCount": 54,
37
39
  "requiredFieldCount": 0,
38
40
  "anticipatedFieldCount": 0,
@@ -51,6 +53,7 @@
51
53
  "label": "Detergents & Surfactants",
52
54
  "file": "templates/detergents.json",
53
55
  "version": 1,
56
+ "modelVersion": "1.0.0",
54
57
  "fieldCount": 77,
55
58
  "requiredFieldCount": 12,
56
59
  "anticipatedFieldCount": 4,
@@ -67,6 +70,7 @@
67
70
  "label": "Electronics",
68
71
  "file": "templates/electronics.json",
69
72
  "version": 2,
73
+ "modelVersion": "2.0.0",
70
74
  "fieldCount": 160,
71
75
  "requiredFieldCount": 0,
72
76
  "anticipatedFieldCount": 13,
@@ -85,6 +89,7 @@
85
89
  "label": "FMCG",
86
90
  "file": "templates/fmcg.json",
87
91
  "version": 2,
92
+ "modelVersion": "2.0.0",
88
93
  "fieldCount": 42,
89
94
  "requiredFieldCount": 0,
90
95
  "anticipatedFieldCount": 3,
@@ -101,6 +106,7 @@
101
106
  "label": "Furniture & Mattresses",
102
107
  "file": "templates/furniture.json",
103
108
  "version": 2,
109
+ "modelVersion": "2.0.0",
104
110
  "fieldCount": 79,
105
111
  "requiredFieldCount": 0,
106
112
  "anticipatedFieldCount": 26,
@@ -119,6 +125,7 @@
119
125
  "label": "Jewelry & Precious Metals",
120
126
  "file": "templates/jewelry.json",
121
127
  "version": 2,
128
+ "modelVersion": "2.0.0",
122
129
  "fieldCount": 54,
123
130
  "requiredFieldCount": 0,
124
131
  "anticipatedFieldCount": 0,
@@ -135,6 +142,7 @@
135
142
  "label": "Packaging",
136
143
  "file": "templates/packaging.json",
137
144
  "version": 2,
145
+ "modelVersion": "2.0.0",
138
146
  "fieldCount": 64,
139
147
  "requiredFieldCount": 0,
140
148
  "anticipatedFieldCount": 28,
@@ -151,6 +159,7 @@
151
159
  "label": "Paints & Coatings",
152
160
  "file": "templates/paints-coatings.json",
153
161
  "version": 1,
162
+ "modelVersion": "1.0.0",
154
163
  "fieldCount": 65,
155
164
  "requiredFieldCount": 0,
156
165
  "anticipatedFieldCount": 0,
@@ -167,6 +176,7 @@
167
176
  "label": "Iron, Steel & Aluminium",
168
177
  "file": "templates/steel.json",
169
178
  "version": 2,
179
+ "modelVersion": "2.0.0",
170
180
  "fieldCount": 84,
171
181
  "requiredFieldCount": 0,
172
182
  "anticipatedFieldCount": 26,
@@ -185,6 +195,7 @@
185
195
  "label": "Textile",
186
196
  "file": "templates/textile.json",
187
197
  "version": 2,
198
+ "modelVersion": "2.0.0",
188
199
  "fieldCount": 60,
189
200
  "requiredFieldCount": 0,
190
201
  "anticipatedFieldCount": 35,
@@ -203,6 +214,7 @@
203
214
  "label": "Toys",
204
215
  "file": "templates/toys.json",
205
216
  "version": 2,
217
+ "modelVersion": "2.0.0",
206
218
  "fieldCount": 42,
207
219
  "requiredFieldCount": 14,
208
220
  "anticipatedFieldCount": 0,
@@ -219,6 +231,7 @@
219
231
  "label": "Tyres",
220
232
  "file": "templates/tyres.json",
221
233
  "version": 2,
234
+ "modelVersion": "2.0.0",
222
235
  "fieldCount": 93,
223
236
  "requiredFieldCount": 0,
224
237
  "anticipatedFieldCount": 26,
@@ -0,0 +1,35 @@
1
+ {
2
+ "$comment": "Which template keys make up a category's data model: the parts that decide whether a passport is valid and who may see what. scripts/model-hash.mjs projects a template onto the 'include' keys and hashes the result (SHA-256 over RFC 8785 JCS); labels, descriptions, translations and editorial notes are 'exclude' and never change the hash. Every key found in a template must be listed in one of the two, so a new key fails `npm run check:model` until it is placed. The platform mirrors this file and must hash the same way.",
3
+ "template": {
4
+ "include": ["category", "regulation", "fields"],
5
+ "exclude": ["categoryLabel", "version", "modelVersion", "isLatest", "fieldCount", "requiredFieldCount", "categories", "createdBy", "changelog", "_note"]
6
+ },
7
+ "regulation": {
8
+ "include": ["number", "effectiveDate", "mandatoryDate", "dateBasis", "datePrecision", "mandatoryDatePrecision"],
9
+ "exclude": ["name"]
10
+ },
11
+ "field": {
12
+ "include": ["key", "dataType", "unit", "translatable", "enumOptions", "validation", "defaultAccessLevel", "regulationRef", "entryProperties"],
13
+ "exclude": ["label", "description", "category", "categoryLabel", "sortOrder", "aiHints", "defaultValue"]
14
+ },
15
+ "validation": {
16
+ "include": ["required", "min", "max", "minLength", "maxLength", "pattern", "anticipated", "anticipatedUnder", "requiredBy"],
17
+ "exclude": ["anticipatedNote"]
18
+ },
19
+ "enumOption": {
20
+ "include": ["value"],
21
+ "exclude": ["label"]
22
+ },
23
+ "entryProperty": {
24
+ "include": ["type", "required", "format", "enum"],
25
+ "exclude": ["description"]
26
+ },
27
+ "regulationRef": {
28
+ "include": ["instrument", "provision", "kind", "obligations"],
29
+ "exclude": ["article", "annex", "description", "standards", "source", "verifiedAgainstPrimaryText"]
30
+ },
31
+ "obligation": {
32
+ "include": ["instrument", "provision", "carrier", "condition"],
33
+ "exclude": ["quote"]
34
+ }
35
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "$comment": "Every released data-model version per category, oldest first: the SemVer `modelVersion` and the SHA-256 hash of the template's model-bearing subset (model-subset.json, scripts/model-hash.mjs). Append-only: written by `npm run bump:model`, checked by `npm run check:model`. Bump rules: README § Data-model versions.",
3
+ "battery": [
4
+ {
5
+ "modelVersion": "7.0.0",
6
+ "hash": "sha256:ef8e6aca08374637d5af750453201363dc884713b84a8d719a322741e8e8731c"
7
+ }
8
+ ],
9
+ "construction": [
10
+ {
11
+ "modelVersion": "2.0.0",
12
+ "hash": "sha256:44d80921f85e5321780f441b08b3c7a4a53637bdab452102718f26bb18474110"
13
+ }
14
+ ],
15
+ "detergents": [
16
+ {
17
+ "modelVersion": "1.0.0",
18
+ "hash": "sha256:c5549127a7f42b4e4cb4055385333a72480cdbc8a5e9033d17d6519b4559fef7"
19
+ }
20
+ ],
21
+ "electronics": [
22
+ {
23
+ "modelVersion": "2.0.0",
24
+ "hash": "sha256:e5417e6a028e6b075d762c11aea6ca8b9cc38903bb3ba05eef73999b663130dc"
25
+ }
26
+ ],
27
+ "fmcg": [
28
+ {
29
+ "modelVersion": "2.0.0",
30
+ "hash": "sha256:e4823795088f3ce435baf40fb8eef8385710163677a6fba25e80ae01aada2d8e"
31
+ }
32
+ ],
33
+ "furniture": [
34
+ {
35
+ "modelVersion": "2.0.0",
36
+ "hash": "sha256:d0192751eab541c295dda13d9c058ae99de3807bb380ab09664baf5d319c159e"
37
+ }
38
+ ],
39
+ "jewelry": [
40
+ {
41
+ "modelVersion": "2.0.0",
42
+ "hash": "sha256:f7a25b15c0b6b9da8c35a60bb45c097273971f77efdce0be4fd1a5bb7ecc8d77"
43
+ }
44
+ ],
45
+ "packaging": [
46
+ {
47
+ "modelVersion": "2.0.0",
48
+ "hash": "sha256:9d1132587dce4099c35ceb3b8c846091f16a7d510e68d091a138c73fab1096b0"
49
+ }
50
+ ],
51
+ "paints-coatings": [
52
+ {
53
+ "modelVersion": "1.0.0",
54
+ "hash": "sha256:7a221ba90143665a59b256948b5819290c1ea76156ce23b9b7b80d60e7de8716"
55
+ }
56
+ ],
57
+ "steel": [
58
+ {
59
+ "modelVersion": "2.0.0",
60
+ "hash": "sha256:28a8bf4c26be983b962fe5fe32c8378bc8f0affd6cf36cdd76d44b601e807860"
61
+ }
62
+ ],
63
+ "textile": [
64
+ {
65
+ "modelVersion": "2.0.0",
66
+ "hash": "sha256:b7b769aa3fe145b51875005fc407ffa9adeb02bf5162cc7da5ccf2c1335adf29"
67
+ }
68
+ ],
69
+ "toys": [
70
+ {
71
+ "modelVersion": "2.0.0",
72
+ "hash": "sha256:38b301f68fa8c66d2dc2616eec8e0765a63a9a533df25d9a655ddcd48a3e52bf"
73
+ }
74
+ ],
75
+ "tyres": [
76
+ {
77
+ "modelVersion": "2.0.0",
78
+ "hash": "sha256:1a6afc60b278d79751be19ce467851dad3dda831f9d79350e6008ca34acb9874"
79
+ }
80
+ ]
81
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tracepass/dpp-schemas",
3
- "version": "1.29.7",
4
- "description": "Machine-readable field specifications for EU Digital Product Passports (ESPR) — 13 product categories, 1010 fields, each traced to the article of EU law that mandates it. Pure JSON, no dependencies.",
3
+ "version": "1.31.0",
4
+ "description": "Machine-readable field specifications for EU Digital Product Passports (ESPR) — 13 product categories, 1016 fields, each traced to the article of EU law that mandates it. Pure JSON, no dependencies.",
5
5
  "keywords": [
6
6
  "digital-product-passport",
7
7
  "dpp",
@@ -35,6 +35,8 @@
35
35
  "instruments.json",
36
36
  "standards.json",
37
37
  "units.json",
38
+ "model-subset.json",
39
+ "model-versions.json",
38
40
  "guidance",
39
41
  "README.md",
40
42
  "LICENSE"
@@ -48,12 +50,15 @@
48
50
  "validate": "python3 -c \"import json,glob,sys;from jsonschema import Draft202012Validator as V;v=V(json.load(open('schema.json')));bad=0\nfor p in sorted(glob.glob('templates/*.json')):\n e=list(v.iter_errors(json.load(open(p))));bad+=bool(e);print(('FAIL' if e else 'ok '),p)\n [print(' ',str(x.absolute_path),x.message[:120]) for x in e[:3]]\nsys.exit(1 if bad else 0)\"",
49
51
  "build:index": "node scripts/build-index.mjs",
50
52
  "check:index": "node scripts/build-index.mjs --check",
51
- "check": "npm run validate && npm run check:index && npm run check:standards && npm run check:locales && npm run check:audit && npm run test:audit && npm run check:planned && npm run test:planned",
53
+ "check": "npm run validate && npm run check:index && npm run check:standards && npm run check:locales && npm run check:audit && npm run test:audit && npm run check:planned && npm run test:planned && npm run check:model && npm run test:model",
52
54
  "check:standards": "node scripts/check-standards.mjs",
53
55
  "check:locales": "node scripts/check-locales.mjs",
54
56
  "check:audit": "node audit/audit.mjs",
55
57
  "test:audit": "node --test audit/self-test.mjs",
56
58
  "check:planned": "node scripts/check-planned-acts.mjs",
57
- "test:planned": "node --test scripts/check-planned-acts.test.mjs"
59
+ "test:planned": "node --test scripts/check-planned-acts.test.mjs",
60
+ "check:model": "node scripts/check-model-versions.mjs",
61
+ "test:model": "node --test scripts/model-hash.test.mjs",
62
+ "bump:model": "node scripts/bump-model.mjs"
58
63
  }
59
64
  }
package/schema.json CHANGED
@@ -8,6 +8,7 @@
8
8
  "category",
9
9
  "categoryLabel",
10
10
  "version",
11
+ "modelVersion",
11
12
  "isLatest",
12
13
  "regulation",
13
14
  "fields",
@@ -34,7 +35,12 @@
34
35
  "version": {
35
36
  "type": "integer",
36
37
  "minimum": 1,
37
- "description": "Template version. Increments when fields are added, removed, or their validation changes."
38
+ "description": "Legacy integer label, kept because the v1 API returns it. Nothing enforces a bump; the data-model version is modelVersion."
39
+ },
40
+ "modelVersion": {
41
+ "type": "string",
42
+ "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$",
43
+ "description": "SemVer name of the category data model: the template keys listed in model-subset.json. MAJOR when a passport that met the old model can fail the new one or data a reader relies on goes away; MINOR for compatible additions and relaxations; PATCH for model changes that change no outcome (a corrected citation). model-versions.json pairs every released version with its SHA-256 model hash, and npm run check:model fails a model change without a bump."
38
44
  },
39
45
  "isLatest": {
40
46
  "type": "boolean",