@bsv/create-dpp-app 0.1.0-beta.1 → 0.1.0-beta.2

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 (143) hide show
  1. package/NOTICE +2 -0
  2. package/PATENTS +12 -0
  3. package/README.md +26 -6
  4. package/dist/index.js +36 -8
  5. package/package.json +9 -5
  6. package/template/Dockerfile +4 -2
  7. package/template/README.md +297 -42
  8. package/template/_env.example +82 -13
  9. package/template/_github/workflows/ci.yml +3 -3
  10. package/template/apps/api/API.md +86 -16
  11. package/template/apps/api/package.json +9 -4
  12. package/template/apps/api/src/bound-profiles.ts +590 -0
  13. package/template/apps/api/src/claims.ts +175 -56
  14. package/template/apps/api/src/cli.ts +64 -7
  15. package/template/apps/api/src/config.ts +124 -10
  16. package/template/apps/api/src/custody.ts +241 -69
  17. package/template/apps/api/src/dev-index.ts +58 -9
  18. package/template/apps/api/src/env-file.ts +55 -0
  19. package/template/apps/api/src/epcis/exchange.ts +434 -0
  20. package/template/apps/api/src/epcis/mongo-storage.ts +381 -0
  21. package/template/apps/api/src/epcis/routes.ts +364 -0
  22. package/template/apps/api/src/epcis/sources.ts +142 -0
  23. package/template/apps/api/src/go-live.ts +226 -0
  24. package/template/apps/api/src/http-error.ts +15 -0
  25. package/template/apps/api/src/identifiers.ts +1 -1
  26. package/template/apps/api/src/index-client.ts +131 -6
  27. package/template/apps/api/src/index-projects.ts +53 -0
  28. package/template/apps/api/src/lifecycle-authority.ts +49 -0
  29. package/template/apps/api/src/lifecycle.ts +485 -0
  30. package/template/apps/api/src/main.ts +10 -2
  31. package/template/apps/api/src/parties.ts +2 -2
  32. package/template/apps/api/src/platform.ts +72 -17
  33. package/template/apps/api/src/portability/commands.ts +224 -0
  34. package/template/apps/api/src/portability/export.ts +708 -0
  35. package/template/apps/api/src/portability/package.ts +270 -0
  36. package/template/apps/api/src/portability/restore.ts +863 -0
  37. package/template/apps/api/src/profiles.ts +38 -13
  38. package/template/apps/api/src/reader.ts +172 -3
  39. package/template/apps/api/src/resolver.ts +159 -0
  40. package/template/apps/api/src/sector-examples.ts +390 -0
  41. package/template/apps/api/src/server.ts +253 -60
  42. package/template/apps/api/src/store.ts +198 -21
  43. package/template/apps/api/src/validation-engine.ts +172 -0
  44. package/template/apps/api/src/wallet.ts +30 -17
  45. package/template/apps/api/src/worker.ts +20 -13
  46. package/template/apps/api/src/writer.ts +383 -131
  47. package/template/apps/api/test/bound-http.test.ts +496 -0
  48. package/template/apps/api/test/bound-profiles.test.ts +547 -0
  49. package/template/apps/api/test/config.test.ts +148 -3
  50. package/template/apps/api/test/custody-journal.test.ts +415 -0
  51. package/template/apps/api/test/custody-recovery-profile.test.ts +224 -0
  52. package/template/apps/api/test/custom-profile.test.ts +167 -0
  53. package/template/apps/api/test/env-file.test.ts +53 -0
  54. package/template/apps/api/test/epcis-fixtures.ts +270 -0
  55. package/template/apps/api/test/epcis-http.test.ts +1179 -0
  56. package/template/apps/api/test/epcis-mongo-storage.test.ts +313 -0
  57. package/template/apps/api/test/epcis-separation.test.ts +253 -0
  58. package/template/apps/api/test/epcis-web.test.ts +230 -0
  59. package/template/apps/api/test/exit-exercise.test.ts +1038 -0
  60. package/template/apps/api/test/external-index.test.ts +3 -2
  61. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/background.ttl +33 -0
  62. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/binding.json +141 -0
  63. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/context.jsonld +36 -0
  64. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/product.schema.json +44 -0
  65. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/shapes.ttl +112 -0
  66. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/conflicting-gtin.json +44 -0
  67. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/conflicting-serial.json +44 -0
  68. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/granularity-mismatch.json +44 -0
  69. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/item-gtin-13.json +43 -0
  70. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/item.json +42 -0
  71. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/missing-required-property.json +43 -0
  72. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/model-as-subject.json +44 -0
  73. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/no-passport-identifier.json +43 -0
  74. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/other-product.json +44 -0
  75. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/part-not-dishwasher-safe.json +45 -0
  76. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/altered-artefact.json +19 -0
  77. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/altered-background.ttl +33 -0
  78. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/conflicting-binding.json +141 -0
  79. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/conflicting-second-registration.json +19 -0
  80. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/untrusted-binding.json +13 -0
  81. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/unlisted-context.json +47 -0
  82. package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/wrong-binding-digest.json +44 -0
  83. package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/binding.json +88 -0
  84. package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/product.schema.json +25 -0
  85. package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/item.json +26 -0
  86. package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/missing-required-property.json +27 -0
  87. package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/no-passport-identifier.json +27 -0
  88. package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/other-product.json +28 -0
  89. package/template/apps/api/test/go-live.test.ts +179 -0
  90. package/template/apps/api/test/gs1-global-setup.ts +33 -0
  91. package/template/apps/api/test/gs1-test-env.ts +5 -0
  92. package/template/apps/api/test/identifier-host.test.ts +256 -0
  93. package/template/apps/api/test/index-projects.test.ts +81 -0
  94. package/template/apps/api/test/lifecycle-claims.test.ts +546 -0
  95. package/template/apps/api/test/lifecycle-fixtures.ts +167 -0
  96. package/template/apps/api/test/lifecycle.test.ts +17 -6
  97. package/template/apps/api/test/manifest-notice.test.ts +36 -0
  98. package/template/apps/api/test/network-guard.ts +113 -0
  99. package/template/apps/api/test/portability.test.ts +655 -0
  100. package/template/apps/api/test/profile-bundle-resolver.test.ts +198 -0
  101. package/template/apps/api/test/retired-profiles.test.ts +216 -0
  102. package/template/apps/api/test/sector-cutover.test.ts +95 -0
  103. package/template/apps/api/test/sector-forms.test.ts +420 -0
  104. package/template/apps/api/test/unjoined-index.test.ts +62 -0
  105. package/template/apps/api/test/validation-engine.test.ts +328 -0
  106. package/template/apps/api/test/wallet-monitor.test.ts +38 -0
  107. package/template/apps/api/test/writer-journal.test.ts +327 -0
  108. package/template/apps/api/vitest.config.ts +3 -0
  109. package/template/apps/web/src/app.tsx +8 -4
  110. package/template/apps/web/src/components/bound/bound-passport-form.tsx +368 -0
  111. package/template/apps/web/src/components/bound/field-view.tsx +237 -0
  112. package/template/apps/web/src/components/bound/pieces.tsx +169 -0
  113. package/template/apps/web/src/components/bound/readings.tsx +152 -0
  114. package/template/apps/web/src/components/bound/structured-value.tsx +114 -0
  115. package/template/apps/web/src/components/claim-dialog.tsx +344 -0
  116. package/template/apps/web/src/components/epcis-events.tsx +119 -0
  117. package/template/apps/web/src/components/layout.tsx +17 -0
  118. package/template/apps/web/src/components/lifecycle-claims.tsx +199 -0
  119. package/template/apps/web/src/components/passport-form.tsx +2 -2
  120. package/template/apps/web/src/components/read-passport.tsx +4 -3
  121. package/template/apps/web/src/components/reading.tsx +32 -39
  122. package/template/apps/web/src/lib/api.ts +136 -26
  123. package/template/apps/web/src/lib/bound/battery-form.ts +269 -0
  124. package/template/apps/web/src/lib/bound/display.ts +122 -0
  125. package/template/apps/web/src/lib/bound/fields.ts +128 -0
  126. package/template/apps/web/src/lib/bound/form-model.ts +521 -0
  127. package/template/apps/web/src/lib/bound/forms.ts +15 -0
  128. package/template/apps/web/src/lib/bound/identity.ts +48 -0
  129. package/template/apps/web/src/lib/bound/textile-form.ts +236 -0
  130. package/template/apps/web/src/lib/bound/units.ts +37 -0
  131. package/template/apps/web/src/lib/epcis.ts +345 -0
  132. package/template/apps/web/src/lib/format.ts +27 -4
  133. package/template/apps/web/src/lib/lifecycle.ts +350 -0
  134. package/template/apps/web/src/pages/accept.tsx +8 -3
  135. package/template/apps/web/src/pages/events.tsx +388 -0
  136. package/template/apps/web/src/pages/new-passport.tsx +25 -2
  137. package/template/apps/web/src/pages/operations.tsx +22 -3
  138. package/template/apps/web/src/pages/passport.tsx +226 -162
  139. package/template/apps/web/src/pages/public-passport.tsx +50 -10
  140. package/template/apps/web/src/pages/wallet.tsx +1 -1
  141. package/template/apps/web/vite.config.ts +12 -4
  142. package/template/deploy/compose.yml +14 -2
  143. package/template/package.json +9 -3
@@ -0,0 +1,390 @@
1
+ // Example product documents for the battery and textile sector bindings.
2
+ // Both versions use the same product vocabulary. They were written for this
3
+ // starter: every organisation, product and number in them is invented, and
4
+ // every identifier is under GS1's demonstration prefix 952, which is
5
+ // licensed to nobody. They exist so a form can start from a document that
6
+ // already has the profile's nested shape. Replace every value with the
7
+ // product's own data before writing a real passport.
8
+ //
9
+ // An example is completed for this deployment when it is served: the
10
+ // product's identifier, GTIN and serial are minted under the configured
11
+ // host and prefix, and the contexts are named by the addresses the
12
+ // registered binding lists.
13
+ import type { BindingProfile } from '@bsv/dpp-profiles'
14
+ import { mintGtin, mintPassportId, type IdentifierPolicy } from './identifiers.js'
15
+
16
+ type Json = Record<string, unknown>
17
+
18
+ interface SectorExample {
19
+ title: string
20
+ /** Digits for the item reference; cut to the length the configured prefix leaves. */
21
+ itemDigits: string
22
+ serial: string
23
+ /** The contexts the document names, by the file name the binding gives each. */
24
+ contexts: string[]
25
+ type: string[]
26
+ /** The members that state the serial, as the profile's documents write them. */
27
+ serialMembers: string[]
28
+ body: Json
29
+ }
30
+
31
+ const text = (value: string, language = 'en'): Json => ({ '@value': value, '@language': language })
32
+ const code = (id: string): Json => ({ '@id': id })
33
+ const quantity = (value: string, unitCode: string): Json => ({ type: 'gs1:QuantitativeValue', 'gs1:value': value, 'gs1:unitCode': unitCode })
34
+ const country = (countryCode: string): Json => ({ type: 'gs1:Country', 'gs1:countryCode': countryCode })
35
+ const address = (parts: { street?: string; locality: string; postalCode?: string; country: string }): Json => ({
36
+ type: 'gs1:PostalAddress',
37
+ ...(parts.street == null ? {} : { 'gs1:streetAddress': parts.street }),
38
+ 'gs1:addressLocality': parts.locality,
39
+ ...(parts.postalCode == null ? {} : { 'gs1:postalCode': parts.postalCode }),
40
+ 'gs1:addressCountry': country(parts.country),
41
+ })
42
+ const measurement = (parameter: string, value: string, unitCode: string): Json => ({ type: 'oea:MeasurementResult', 'oea:hasObservedParameter': code(parameter), 'oea:hasMeasuredValue': quantity(value, unitCode) })
43
+
44
+ const BATTERY: SectorExample = {
45
+ title: 'Stationary storage module (invented data)',
46
+ itemDigits: '100200300400',
47
+ serial: 'HC48-2026-000117',
48
+ contexts: ['dpp-core-context.jsonld', 'battery-context.jsonld'],
49
+ type: ['gs1:Product', 'eubat:Battery'],
50
+ serialMembers: ['gs1:hasSerialNumber'],
51
+ body: {
52
+ 'eubat:batteryModelIdentifier': 'HC-LFP-48-100',
53
+ 'gs1:productName': [text('Harbour 48 V storage module')],
54
+ 'schema:model': text('Harbour 48-100'),
55
+ 'gs1:productDescription': [text('Lithium iron phosphate module for stationary storage. Example data: nothing here describes a real product.')],
56
+ 'schema:schemaVersion': '1.3',
57
+ 'oec:passportStatus': 'active',
58
+ 'oec:hasReportingGranularity': code('oec:ItemLevel'),
59
+ 'oec:lastUpdated': '2026-11-02T09:30:00Z',
60
+ 'schema:category': code('eubat:StationaryBattery'),
61
+ 'schema:status': code('eubat:Original'),
62
+ 'eubat:puttingIntoService': '2026-10-12',
63
+ 'gs1:productionDate': '2026-09-18',
64
+ 'gs1:countryOfOrigin': country('AU'),
65
+ 'eubat:hasCellType': code('eubat:PrismaticCell'),
66
+ 'eubat:numberOfCells': 16,
67
+ 'eubat:numberOfModules': 1,
68
+ 'gs1:netWeight': quantity('41.5', 'KGM'),
69
+ 'gs1:grossWeight': quantity('44.0', 'KGM'),
70
+ 'gs1:manufacturer': {
71
+ type: 'gs1:Organization',
72
+ 'gs1:organizationName': 'Harbour Cells Pty Ltd',
73
+ 'gs1:globalLocationNumber': '9520000000011',
74
+ 'gs1:address': address({ street: '1 Example Wharf Road', locality: 'Newcastle', postalCode: '2300', country: 'AU' }),
75
+ 'gs1:contactPoint': { type: 'gs1:ContactPoint', 'gs1:email': 'info@harbour-cells.example' },
76
+ },
77
+ 'eubat:manufacturerIdentifier': '9520000000011',
78
+ 'eubat:operatorIdentifier': '9520000000028',
79
+ 'eubat:facilityIdentifier': '9520000000035',
80
+ 'eubat:hasOperatorInformation': {
81
+ type: 'oec:OperatorInformation',
82
+ 'gs1:globalLocationNumber': '9520000000028',
83
+ 'gs1:organizationName': 'Harbour Energy Imports B.V.',
84
+ 'eubat:hasOperatorRole': code('oec:Importer'),
85
+ 'gs1:address': address({ street: 'Voorbeeldkade 12', locality: 'Rotterdam', postalCode: '3011 AA', country: 'NL' }),
86
+ 'gs1:contactPoint': { type: 'gs1:ContactPoint', 'gs1:email': 'compliance@harbour-energy.example', 'gs1:telephone': '+31-10-555-0100' },
87
+ },
88
+ 'eubat:hasManufacturingPlace': { type: 'gs1:Place', 'gs1:globalLocationNumber': '9520000000035', 'gs1:address': address({ locality: 'Newcastle', country: 'AU' }) },
89
+ 'eubat:hasBatteryChemistry': {
90
+ type: 'eubat:BatteryChemistry',
91
+ 'schema:name': text('Lithium iron phosphate'),
92
+ 'schema:alternateName': 'LFP',
93
+ 'eubat:cathodeActiveMaterial': 'LiFePO4',
94
+ 'eubat:anodeActiveMaterial': 'Graphite',
95
+ 'eubat:electrolyteType': text('Liquid, organic carbonate based'),
96
+ },
97
+ 'eubat:hasTechnicalSpecifications': {
98
+ type: 'eubat:TechnicalSpecification',
99
+ 'eubat:hasRatedCapacity': quantity('100', 'AMH'),
100
+ 'eubat:hasRatedEnergy': quantity('5.12', 'KWH'),
101
+ 'eubat:hasNominalVoltage': quantity('51.2', 'VLT'),
102
+ 'eubat:hasMinimumVoltage': quantity('44.8', 'VLT'),
103
+ 'eubat:hasMaximumVoltage': quantity('58.4', 'VLT'),
104
+ 'eubat:hasRatedMaximumPower': quantity('5.0', 'KWT'),
105
+ 'eubat:hasMaximumChargingCurrent': quantity('100', 'AMP'),
106
+ 'eubat:hasMaximumDischargingCurrent': quantity('100', 'AMP'),
107
+ 'eubat:hasExpectedLifetime': quantity('15', 'ANN'),
108
+ 'eubat:cRate': '0.5',
109
+ 'eubat:hasTemperatureRangeCharging': { type: 'eubat:TemperatureRange', 'eubat:hasMinimumTemperature': quantity('0', 'CEL'), 'eubat:hasMaximumTemperature': quantity('45', 'CEL') },
110
+ 'eubat:hasTemperatureRangeDischarging': { type: 'eubat:TemperatureRange', 'eubat:hasMinimumTemperature': quantity('-20', 'CEL'), 'eubat:hasMaximumTemperature': quantity('55', 'CEL') },
111
+ },
112
+ 'eubat:hasBatteryState': {
113
+ type: 'eubat:BatteryStateAssessment',
114
+ 'oea:hasResult': [measurement('eubat:StateOfHealth', '98.50', 'P1'), measurement('eubat:FullCycleCount', '42', 'C62'), measurement('eubat:RemainingCapacity', '98.5', 'AMH')],
115
+ },
116
+ 'eubat:hasMaterialComposition': [
117
+ {
118
+ type: 'eubat:BatteryMaterial',
119
+ 'schema:name': text('Lithium'),
120
+ 'oec:casNumber': '7439-93-2',
121
+ 'oec:ecNumber': '231-102-5',
122
+ 'eubat:hasComponentLocation': code('eubat:Cathode'),
123
+ 'schema:category': code('eubat:ActiveMaterial'),
124
+ 'schema:weightPercentage': '4.1',
125
+ 'eubat:isCriticalRawMaterial': true,
126
+ 'eubat:isSubstanceOfConcern': false,
127
+ 'oec:hasMaterialOrigin': country('AU'),
128
+ },
129
+ {
130
+ type: 'eubat:BatteryMaterial',
131
+ 'schema:name': text('Graphite'),
132
+ 'oec:casNumber': '7782-42-5',
133
+ 'oec:ecNumber': '231-955-3',
134
+ 'eubat:hasComponentLocation': code('eubat:Anode'),
135
+ 'schema:category': code('eubat:ActiveMaterial'),
136
+ 'schema:weightPercentage': '17.9',
137
+ 'eubat:isCriticalRawMaterial': true,
138
+ 'eubat:isSubstanceOfConcern': false,
139
+ },
140
+ ],
141
+ 'eubat:hasHazardousSubstances': [
142
+ {
143
+ type: 'eubat:HazardousSubstance',
144
+ 'schema:name': text('Lithium hexafluorophosphate'),
145
+ 'oec:casNumber': '21324-40-3',
146
+ 'oec:ecNumber': '244-334-7',
147
+ 'eubat:hasHazardClass': code('eubat:AcuteToxicity'),
148
+ 'eubat:concentration': '11.8',
149
+ 'eubat:hazardImpact': text('Toxic if swallowed. Causes severe skin burns and eye damage.'),
150
+ 'eubat:hasSubstanceLocation': code('eubat:Electrolyte'),
151
+ },
152
+ ],
153
+ 'eubat:hasRecycledContent': {
154
+ type: 'eubat:RecycledContent',
155
+ 'eubat:lithiumRecycledShare': '6',
156
+ 'eubat:lithiumPreConsumerShare': '4',
157
+ 'eubat:lithiumPostConsumerShare': '2',
158
+ 'eubat:cobaltRecycledShare': '0',
159
+ 'eubat:nickelRecycledShare': '0',
160
+ 'eubat:leadRecycledShare': '0',
161
+ },
162
+ 'eubat:hasCarbonFootprintDeclaration': {
163
+ type: 'eubat:CarbonFootprintDeclaration',
164
+ 'eubat:hasCarbonFootprintTotal': quantity('61.4', 'KGM'),
165
+ 'eubat:hasCarbonFootprintProduction': quantity('22.0', 'KGM'),
166
+ 'eubat:carbonFootprintStudyUrl': 'https://harbour-cells.example/docs/carbon-footprint-study.pdf',
167
+ 'eubat:functionalUnit': '1 kWh of total energy provided over the service life',
168
+ 'eubat:calculationStandard': 'ISO 14067:2018',
169
+ 'oea:hasIndicator': { type: 'oea:Indicator', 'oea:hasIndicatorKind': code('eubat:CarbonFootprintPerformanceClass'), 'oea:hasCategoricalValue': code('eubat:CFClassC') },
170
+ },
171
+ 'gs1:manufacturersWarranty': { type: 'gs1:WarrantyPromise', 'gs1:durationOfWarranty': quantity('10', 'ANN'), 'gs1:warrantyScopeDescription': 'Covers manufacturing defects.' },
172
+ 'eubat:ceMarkingIndicator': true,
173
+ 'eubat:hasComplianceStatus': code('eubat:Compliant'),
174
+ 'eubat:hasLabels': [
175
+ {
176
+ type: 'eubat:Label',
177
+ 'eubat:hasLabelSubject': code('eubat:SeparateCollection'),
178
+ 'eubat:labelSymbol': 'https://harbour-cells.example/symbols/separate-collection.svg',
179
+ 'eubat:labelMeaning': text('Do not dispose of with household waste. Return to a collection point.'),
180
+ },
181
+ ],
182
+ 'eubat:hasEndOfLifeInfo': {
183
+ type: 'eubat:EndOfLifeInfo',
184
+ 'eubat:recyclabilityRate': '92',
185
+ 'eubat:hasMaterialRecoveryTargets': [{ type: 'eubat:MaterialRecoveryTarget', 'eubat:recoveryMaterial': 'Lithium', 'eubat:recoveryRate': '70' }],
186
+ 'eubat:hasDismantlingTime': quantity('40', 'MIN'),
187
+ 'eubat:extinguishingAgent': text('Class D extinguisher or dry sand'),
188
+ 'eubat:safetyInstructions': 'https://harbour-cells.example/docs/safety-instructions.pdf',
189
+ },
190
+ 'eubat:hasSupplyChainDueDiligence': {
191
+ type: 'eubat:SupplyChainDueDiligence',
192
+ 'eubat:dueDiligenceReportUrl': 'https://harbour-cells.example/docs/due-diligence-report.pdf',
193
+ 'eubat:supplyChainMappingAvailable': true,
194
+ 'schema:auditDate': '2026-06-30',
195
+ 'eubat:auditBody': 'Example Assurance Ltd',
196
+ },
197
+ },
198
+ }
199
+
200
+ const TEXTILE: SectorExample = {
201
+ title: 'Rain jacket (invented data)',
202
+ itemDigits: '100200400500',
203
+ serial: 'TL-RS-2026-000408',
204
+ contexts: ['dpp-core-context.jsonld', 'textile-context.jsonld'],
205
+ type: ['gs1:Clothing', 'eutex:TextileApparel'],
206
+ serialMembers: ['schema:serialNumber'],
207
+ body: {
208
+ 'gs1:productName': [text('Tideline rain shell, slate')],
209
+ 'gs1:productDescription': [text('Waterproof shell jacket with a recycled polyester face. Example data: nothing here describes a real product.')],
210
+ 'oec:passportStatus': 'active',
211
+ 'oec:passportVersion': '1.0',
212
+ 'oec:passportIssueDate': '2026-10-20',
213
+ 'oec:lastUpdated': '2026-11-02T09:30:00Z',
214
+ 'oec:hasProductCategory': code('oec:Textiles'),
215
+ 'schema:category': code('eutex:Apparel'),
216
+ 'eutex:hasApparelSubcategory': code('eutex:JacketsCoats'),
217
+ 'eutex:garmentType': 'Rain jacket',
218
+ 'eutex:hasFabricType': code('eutex:WovenNonDenim'),
219
+ 'gs1:targetConsumerGender': code('gs1:TargetConsumerGenderCode-UNISEX'),
220
+ 'eutex:sizeRange': 'XS-XXL',
221
+ 'eutex:seasonCollection': 'AW2026',
222
+ 'gs1:countryOfOrigin': country('PT'),
223
+ 'gs1:productionDate': '2026-09-05',
224
+ 'gs1:netWeight': quantity('0.42', 'KGM'),
225
+ 'gs1:manufacturer': {
226
+ type: 'gs1:Organization',
227
+ 'gs1:organizationName': 'Tideline Outdoor Lda',
228
+ 'gs1:globalLocationNumber': '9520000000042',
229
+ 'gs1:address': address({ street: 'Rua do Exemplo 8', locality: 'Porto', postalCode: '4000-001', country: 'PT' }),
230
+ 'gs1:contactPoint': { type: 'gs1:ContactPoint', 'gs1:email': 'hello@tideline.example' },
231
+ },
232
+ 'oec:hasOperatorInformation': {
233
+ type: 'oec:OperatorInformation',
234
+ 'gs1:globalLocationNumber': '9520000000042',
235
+ 'gs1:organizationName': 'Tideline Outdoor Lda',
236
+ 'oec:hasOperatorRole': code('oec:Manufacturer'),
237
+ 'gs1:address': address({ street: 'Rua do Exemplo 8', locality: 'Porto', postalCode: '4000-001', country: 'PT' }),
238
+ 'gs1:contactPoint': { type: 'gs1:ContactPoint', 'gs1:email': 'compliance@tideline.example', 'gs1:telephone': '+351-22-555-0100' },
239
+ },
240
+ 'gs1:textileMaterial': [
241
+ {
242
+ type: 'gs1:TextileMaterialDetails',
243
+ 'gs1:textileMaterialPercentage': { '@value': '88', '@type': 'xsd:decimal' },
244
+ 'gs1:textileMaterialDescription': text('Recycled polyester (shell)'),
245
+ 'eutex:fiberOrigin': 'TW',
246
+ 'eutex:isRecycledFiber': true,
247
+ 'eutex:recycledContentSource': 'Post-consumer bottles',
248
+ 'eutex:hasFiberCertification': { type: 'gs1:CertificationDetails', 'gs1:certificationAgency': 'Example Certification Body', 'gs1:certificationStandard': 'Global Recycled Standard', 'gs1:certificationValue': 'DEMO-GRS-0001' },
249
+ },
250
+ {
251
+ type: 'gs1:TextileMaterialDetails',
252
+ 'gs1:textileMaterialPercentage': { '@value': '12', '@type': 'xsd:decimal' },
253
+ 'gs1:textileMaterialDescription': text('Polyamide (lining)'),
254
+ 'eutex:fiberOrigin': 'IT',
255
+ 'eutex:isRecycledFiber': false,
256
+ },
257
+ ],
258
+ 'eutex:hasCareInstructions': {
259
+ type: 'eutex:CareInstruction',
260
+ 'eutex:hasWashingSymbol': code('eutex:Wash30'),
261
+ 'eutex:hasBleachingSymbol': code('eutex:DoNotBleach'),
262
+ 'eutex:hasDryingSymbol': code('eutex:DripDry'),
263
+ 'eutex:hasIroningSymbol': code('eutex:DoNotIron'),
264
+ 'eutex:hasDryCleaningSymbol': code('eutex:DoNotDryClean'),
265
+ 'eutex:additionalCareInstructions': text('Close all zips before washing. Reproof after ten washes.'),
266
+ },
267
+ 'eutex:hasDurabilityInfo': {
268
+ type: 'eutex:DurabilityInfo',
269
+ 'oea:hasSubAssessment': [
270
+ { type: 'oea:TestExecution', 'oea:hasMethod': code('eutex:MartindaleAbrasionTest'), 'oea:hasResult': measurement('eutex:AbrasionResistance', '30000', 'C62') },
271
+ { type: 'oea:TestExecution', 'oea:hasMethod': code('eutex:PillingTest'), 'oea:hasResult': measurement('eutex:PillingResistance', '4', 'C62') },
272
+ { type: 'oea:TestExecution', 'oea:hasMethod': code('eutex:TearStrengthTest'), 'oea:hasResult': measurement('eutex:TearStrength', '32.5', 'NEW') },
273
+ ],
274
+ 'oea:hasIndicator': [{ type: 'oea:Indicator', 'oea:hasIndicatorKind': code('eutex:DurabilityRating'), 'oea:hasCategoricalValue': code('eutex:DurabilityB') }],
275
+ },
276
+ 'eutex:hasMicroplasticInfo': {
277
+ type: 'eutex:MicroplasticInfo',
278
+ 'eutex:syntheticFiberContent': '100',
279
+ 'eutex:microplasticMitigationMeasures': text('Tightly woven face fabric. Wash in a fibre-catching laundry bag.'),
280
+ },
281
+ 'oec:hasRecycledContentDetails': { type: 'oec:RecycledContent', 'oec:recycledContent': '0.88', 'oec:postConsumerRecycledContent': '0.88' },
282
+ 'eutex:hasRecycledContentDeclaration': [
283
+ {
284
+ type: 'eutex:RecycledContentDeclaration',
285
+ 'eutex:secondaryMaterialFraction': '88',
286
+ 'eutex:hasWasteOriginType': code('eutex:PostConsumer'),
287
+ 'eutex:hasRecycledSourceType': code('eutex:OpenLoop'),
288
+ 'eutex:hasChainOfCustodyMethod': code('eutex:Certified'),
289
+ 'eutex:meetsTargetThreshold': true,
290
+ },
291
+ ],
292
+ 'oec:carbonFootprintTotal': '9.6',
293
+ 'oec:declaredUnit': 'kg CO2e per garment',
294
+ 'eutex:hasWaterUsage': quantity('1400', 'LTR'),
295
+ 'eutex:hasEnergyUsage': quantity('21.5', 'KWH'),
296
+ 'eutex:productionWastePercentage': '6.5',
297
+ 'eutex:pfasFree': true,
298
+ 'eutex:biodegradable': false,
299
+ 'eutex:hasSubstancesOfConcern': [
300
+ {
301
+ type: 'eutex:SubstanceOfConcern',
302
+ 'eutex:hasSocType': code('eutex:SoCTypeB'),
303
+ 'schema:name': 'Formaldehyde',
304
+ 'oec:casNumber': '50-00-0',
305
+ 'oec:ecNumber': '200-001-8',
306
+ 'eutex:substanceConcentration': '0.002',
307
+ 'eutex:hasClpHazardCategory': code('eutex:CMR'),
308
+ 'oec:substanceLocation': 'Seam tape adhesive',
309
+ 'eutex:safeUseInstructions': 'Wash before first wear.',
310
+ },
311
+ ],
312
+ 'eutex:takeBackProgramAvailable': true,
313
+ 'eutex:hasTakeBackProgram': {
314
+ type: 'eutex:TakeBackProgram',
315
+ 'eutex:takeBackUrl': 'https://tideline.example/take-back',
316
+ 'eutex:takeBackIncentive': text('A repair voucher for each returned jacket.'),
317
+ 'eutex:endOfLifeDestination': text('Resale when sound, fibre recycling when not.'),
318
+ },
319
+ 'gs1:consumerRecyclingInstructions': [text('Return the jacket to a Tideline shop. Do not put it in household waste.')],
320
+ 'eutex:isRepairable': true,
321
+ 'eutex:repairGuideUrl': 'https://tideline.example/repair',
322
+ 'eutex:hasRepairServices': [
323
+ {
324
+ type: 'gs1:Organization',
325
+ 'gs1:organizationName': 'Tideline Repairs',
326
+ 'gs1:address': address({ locality: 'Porto', country: 'PT' }),
327
+ 'gs1:contactPoint': { type: 'gs1:ContactPoint', 'gs1:email': 'repairs@tideline.example' },
328
+ },
329
+ ],
330
+ 'gs1:certification': [
331
+ {
332
+ type: 'gs1:CertificationDetails',
333
+ 'gs1:certificationAgency': 'Example Certification Body',
334
+ 'gs1:certificationStandard': 'Global Recycled Standard',
335
+ 'gs1:certificationIdentification': 'DEMO-GRS-0001',
336
+ 'gs1:certificationStartDate': '2026-01-01',
337
+ 'gs1:certificationEndDate': '2026-12-31',
338
+ },
339
+ ],
340
+ 'eutex:hasCutAndSewFacility': {
341
+ type: 'oec:FacilityInformation',
342
+ 'gs1:globalLocationNumber': '9520000000059',
343
+ 'schema:name': 'Porto sewing unit',
344
+ 'oec:facilityType': 'Cut and sew',
345
+ 'gs1:address': address({ locality: 'Porto', country: 'PT' }),
346
+ 'oec:hasFacilityCertifications': [{ type: 'gs1:CertificationDetails', 'gs1:certificationStandard': 'ISO 14001:2015', 'gs1:certificationIdentification': 'DEMO-EMS-0007' }],
347
+ },
348
+ 'gs1:manufacturersWarranty': { type: 'gs1:WarrantyPromise', 'gs1:durationOfWarranty': quantity('2', 'ANN'), 'gs1:warrantyScopeDescription': 'Covers manufacturing defects, not wear.' },
349
+ },
350
+ }
351
+
352
+ const EXAMPLES: Record<string, SectorExample[]> = {
353
+ 'eu-battery@1': [BATTERY],
354
+ 'eu-battery@2': [BATTERY],
355
+ 'eu-textile@1': [TEXTILE],
356
+ 'eu-textile@2': [TEXTILE],
357
+ }
358
+
359
+ /**
360
+ * The examples for a registered profile, each a complete product document
361
+ * for this deployment, with the item reference and serial its identifier
362
+ * was minted from. A profile with no example answers with an empty list.
363
+ */
364
+ export function sectorExamples(profile: BindingProfile, policy: IdentifierPolicy): Array<{ title: string; itemReference: string; serial: string; passportId: string; product: Json }> {
365
+ const contexts = new Map(profile.artefacts.filter((a) => a.artefact.role === 'context').map((a) => [a.artefact.path, a.artefact.uri!]))
366
+ return (EXAMPLES[profile.profile] ?? []).flatMap((example) => {
367
+ const itemReference = example.itemDigits.slice(0, Math.max(0, 12 - policy.prefix.length))
368
+ let passportId: string
369
+ let gtin: string
370
+ try {
371
+ passportId = mintPassportId(policy, itemReference, example.serial)
372
+ gtin = mintGtin(policy.prefix, itemReference)
373
+ } catch {
374
+ // A prefix the example's digits cannot fill has no example; the form still works without one.
375
+ return []
376
+ }
377
+ const named = example.contexts.map((path) => contexts.get(path))
378
+ if (named.some((uri) => uri == null)) return []
379
+ const product: Json = {
380
+ '@context': named,
381
+ id: passportId,
382
+ type: example.type,
383
+ 'oec:granularityLevel': 'item',
384
+ 'gs1:gtin': gtin,
385
+ ...Object.fromEntries(example.serialMembers.map((member) => [member, example.serial])),
386
+ ...structuredClone(example.body),
387
+ }
388
+ return [{ title: example.title, itemReference, serial: example.serial, passportId, product }]
389
+ })
390
+ }