@bsv/create-dpp-app 0.0.0-stage → 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.
- package/LICENSE +203 -0
- package/NOTICE +2 -0
- package/PATENTS +12 -0
- package/README.md +93 -2
- package/dist/index.js +125 -0
- package/package.json +57 -4
- package/template/Dockerfile +37 -0
- package/template/README.md +389 -0
- package/template/_dockerignore +6 -0
- package/template/_env.example +122 -0
- package/template/_github/workflows/ci.yml +23 -0
- package/template/_gitignore +8 -0
- package/template/_prettierrc +6 -0
- package/template/apps/api/API.md +119 -0
- package/template/apps/api/package.json +39 -0
- package/template/apps/api/src/auth.ts +55 -0
- package/template/apps/api/src/bound-profiles.ts +590 -0
- package/template/apps/api/src/claims.ts +204 -0
- package/template/apps/api/src/cli.ts +99 -0
- package/template/apps/api/src/config.ts +180 -0
- package/template/apps/api/src/custody.ts +358 -0
- package/template/apps/api/src/dev-index.ts +120 -0
- package/template/apps/api/src/env-file.ts +55 -0
- package/template/apps/api/src/env.ts +14 -0
- package/template/apps/api/src/epcis/exchange.ts +434 -0
- package/template/apps/api/src/epcis/mongo-storage.ts +381 -0
- package/template/apps/api/src/epcis/routes.ts +364 -0
- package/template/apps/api/src/epcis/sources.ts +142 -0
- package/template/apps/api/src/go-live.ts +226 -0
- package/template/apps/api/src/http-error.ts +15 -0
- package/template/apps/api/src/identifiers.ts +57 -0
- package/template/apps/api/src/index-client.ts +261 -0
- package/template/apps/api/src/index-projects.ts +53 -0
- package/template/apps/api/src/lifecycle-authority.ts +49 -0
- package/template/apps/api/src/lifecycle.ts +485 -0
- package/template/apps/api/src/main.ts +58 -0
- package/template/apps/api/src/parties.ts +68 -0
- package/template/apps/api/src/platform.ts +176 -0
- package/template/apps/api/src/portability/commands.ts +224 -0
- package/template/apps/api/src/portability/export.ts +708 -0
- package/template/apps/api/src/portability/package.ts +270 -0
- package/template/apps/api/src/portability/restore.ts +863 -0
- package/template/apps/api/src/profiles.ts +125 -0
- package/template/apps/api/src/reader.ts +265 -0
- package/template/apps/api/src/resolver.ts +159 -0
- package/template/apps/api/src/sector-examples.ts +390 -0
- package/template/apps/api/src/server.ts +613 -0
- package/template/apps/api/src/store.ts +426 -0
- package/template/apps/api/src/validation-engine.ts +172 -0
- package/template/apps/api/src/wallet.ts +359 -0
- package/template/apps/api/src/worker.ts +113 -0
- package/template/apps/api/src/writer.ts +603 -0
- package/template/apps/api/test/bound-http.test.ts +496 -0
- package/template/apps/api/test/bound-profiles.test.ts +547 -0
- package/template/apps/api/test/config.test.ts +160 -0
- package/template/apps/api/test/custody-journal.test.ts +415 -0
- package/template/apps/api/test/custody-recovery-profile.test.ts +224 -0
- package/template/apps/api/test/custom-profile.test.ts +167 -0
- package/template/apps/api/test/env-file.test.ts +53 -0
- package/template/apps/api/test/epcis-fixtures.ts +270 -0
- package/template/apps/api/test/epcis-http.test.ts +1179 -0
- package/template/apps/api/test/epcis-mongo-storage.test.ts +313 -0
- package/template/apps/api/test/epcis-separation.test.ts +253 -0
- package/template/apps/api/test/epcis-web.test.ts +230 -0
- package/template/apps/api/test/exit-exercise.test.ts +1038 -0
- package/template/apps/api/test/external-index.test.ts +32 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/background.ttl +33 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/binding.json +141 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/context.jsonld +36 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/product.schema.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/shapes.ttl +112 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/conflicting-gtin.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/conflicting-serial.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/granularity-mismatch.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/item-gtin-13.json +43 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/item.json +42 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/missing-required-property.json +43 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/model-as-subject.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/no-passport-identifier.json +43 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/other-product.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/part-not-dishwasher-safe.json +45 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/altered-artefact.json +19 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/altered-background.ttl +33 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/conflicting-binding.json +141 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/conflicting-second-registration.json +19 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/untrusted-binding.json +13 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/unlisted-context.json +47 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/wrong-binding-digest.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/binding.json +88 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/product.schema.json +25 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/item.json +26 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/missing-required-property.json +27 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/no-passport-identifier.json +27 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/other-product.json +28 -0
- package/template/apps/api/test/go-live.test.ts +179 -0
- package/template/apps/api/test/gs1-global-setup.ts +33 -0
- package/template/apps/api/test/gs1-test-env.ts +5 -0
- package/template/apps/api/test/identifier-host.test.ts +256 -0
- package/template/apps/api/test/index-projects.test.ts +81 -0
- package/template/apps/api/test/lifecycle-claims.test.ts +546 -0
- package/template/apps/api/test/lifecycle-fixtures.ts +167 -0
- package/template/apps/api/test/lifecycle.test.ts +147 -0
- package/template/apps/api/test/manifest-notice.test.ts +36 -0
- package/template/apps/api/test/network-guard.ts +113 -0
- package/template/apps/api/test/portability.test.ts +655 -0
- package/template/apps/api/test/profile-bundle-resolver.test.ts +198 -0
- package/template/apps/api/test/retired-profiles.test.ts +216 -0
- package/template/apps/api/test/sector-cutover.test.ts +95 -0
- package/template/apps/api/test/sector-forms.test.ts +420 -0
- package/template/apps/api/test/unjoined-index.test.ts +62 -0
- package/template/apps/api/test/validation-engine.test.ts +328 -0
- package/template/apps/api/test/wallet-monitor.test.ts +38 -0
- package/template/apps/api/test/writer-journal.test.ts +327 -0
- package/template/apps/api/tsconfig.json +9 -0
- package/template/apps/api/vitest.config.ts +12 -0
- package/template/apps/web/components.json +21 -0
- package/template/apps/web/index.html +12 -0
- package/template/apps/web/package.json +33 -0
- package/template/apps/web/src/app.tsx +55 -0
- package/template/apps/web/src/components/bits.tsx +188 -0
- package/template/apps/web/src/components/bound/bound-passport-form.tsx +368 -0
- package/template/apps/web/src/components/bound/field-view.tsx +237 -0
- package/template/apps/web/src/components/bound/pieces.tsx +169 -0
- package/template/apps/web/src/components/bound/readings.tsx +152 -0
- package/template/apps/web/src/components/bound/structured-value.tsx +114 -0
- package/template/apps/web/src/components/claim-dialog.tsx +344 -0
- package/template/apps/web/src/components/epcis-events.tsx +119 -0
- package/template/apps/web/src/components/layout.tsx +135 -0
- package/template/apps/web/src/components/lifecycle-claims.tsx +199 -0
- package/template/apps/web/src/components/passport-form.tsx +244 -0
- package/template/apps/web/src/components/read-passport.tsx +49 -0
- package/template/apps/web/src/components/reading.tsx +150 -0
- package/template/apps/web/src/components/ui/alert.tsx +65 -0
- package/template/apps/web/src/components/ui/badge.tsx +47 -0
- package/template/apps/web/src/components/ui/button.tsx +63 -0
- package/template/apps/web/src/components/ui/card.tsx +91 -0
- package/template/apps/web/src/components/ui/dialog.tsx +156 -0
- package/template/apps/web/src/components/ui/input.tsx +20 -0
- package/template/apps/web/src/components/ui/label.tsx +21 -0
- package/template/apps/web/src/components/ui/select.tsx +189 -0
- package/template/apps/web/src/components/ui/separator.tsx +25 -0
- package/template/apps/web/src/components/ui/table.tsx +115 -0
- package/template/apps/web/src/components/ui/tabs.tsx +90 -0
- package/template/apps/web/src/components/ui/textarea.tsx +17 -0
- package/template/apps/web/src/index.css +81 -0
- package/template/apps/web/src/lib/api.ts +396 -0
- package/template/apps/web/src/lib/auth.ts +10 -0
- package/template/apps/web/src/lib/bound/battery-form.ts +269 -0
- package/template/apps/web/src/lib/bound/display.ts +122 -0
- package/template/apps/web/src/lib/bound/fields.ts +128 -0
- package/template/apps/web/src/lib/bound/form-model.ts +521 -0
- package/template/apps/web/src/lib/bound/forms.ts +15 -0
- package/template/apps/web/src/lib/bound/identity.ts +48 -0
- package/template/apps/web/src/lib/bound/textile-form.ts +236 -0
- package/template/apps/web/src/lib/bound/units.ts +37 -0
- package/template/apps/web/src/lib/epcis.ts +345 -0
- package/template/apps/web/src/lib/format.ts +87 -0
- package/template/apps/web/src/lib/lifecycle.ts +350 -0
- package/template/apps/web/src/lib/session.tsx +92 -0
- package/template/apps/web/src/lib/use-load.ts +46 -0
- package/template/apps/web/src/main.tsx +18 -0
- package/template/apps/web/src/pages/accept.tsx +113 -0
- package/template/apps/web/src/pages/brand.tsx +94 -0
- package/template/apps/web/src/pages/brands.tsx +104 -0
- package/template/apps/web/src/pages/events.tsx +388 -0
- package/template/apps/web/src/pages/home.tsx +51 -0
- package/template/apps/web/src/pages/new-passport.tsx +137 -0
- package/template/apps/web/src/pages/operations.tsx +169 -0
- package/template/apps/web/src/pages/passport.tsx +632 -0
- package/template/apps/web/src/pages/public-passport.tsx +64 -0
- package/template/apps/web/src/pages/sign-in.tsx +93 -0
- package/template/apps/web/src/pages/verify.tsx +30 -0
- package/template/apps/web/src/pages/wallet.tsx +141 -0
- package/template/apps/web/tsconfig.json +29 -0
- package/template/apps/web/vite.config.ts +23 -0
- package/template/deploy/compose.yml +38 -0
- package/template/package.json +48 -0
- package/template/tsconfig.base.json +13 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// The form for eu-battery@1: battery passport data for one serialised item.
|
|
2
|
+
// It follows the profile's own data model. Identifiers the manufacturer
|
|
3
|
+
// assigns, such as the model identifier and the location numbers, have
|
|
4
|
+
// fields of their own, apart from the names people read. Measurements are a
|
|
5
|
+
// value and a unit. Whether a property is public or restricted is not
|
|
6
|
+
// decided here: the page reads that from the binding's list.
|
|
7
|
+
import { address, certificate, code, contact, country, date, dateTime, decimal, entry, fixed, group, integer, langText, list, longText, measurement, operator, organisation, PASSPORT_STATUSES, quantity, reference, referencedFiles, text, url, warranty, yesNo } from './fields'
|
|
8
|
+
import type { GroupField, SectorForm } from './form-model'
|
|
9
|
+
import { ANY_UNIT } from './units'
|
|
10
|
+
|
|
11
|
+
const temperatureRange = (key: string, label: string): GroupField =>
|
|
12
|
+
group(key, label, 'eubat:TemperatureRange', [quantity('eubat:hasMinimumTemperature', 'Lowest', ['CEL']), quantity('eubat:hasMaximumTemperature', 'Highest', ['CEL'])])
|
|
13
|
+
|
|
14
|
+
const SHARE_HELP = 'A percentage of the metal in the battery.'
|
|
15
|
+
const metalShares = (metal: string, label: string) => [
|
|
16
|
+
decimal(`eubat:${metal}RecycledShare`, `${label}, recycled share`, { help: SHARE_HELP }),
|
|
17
|
+
decimal(`eubat:${metal}PreConsumerShare`, `${label}, from manufacturing waste`, { help: SHARE_HELP }),
|
|
18
|
+
decimal(`eubat:${metal}PostConsumerShare`, `${label}, from used products`, { help: SHARE_HELP }),
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
export const BATTERY_FORM: SectorForm = {
|
|
22
|
+
profile: 'eu-battery@1',
|
|
23
|
+
contexts: ['dpp-core-context.jsonld', 'battery-context.jsonld'],
|
|
24
|
+
type: ['gs1:Product', 'eubat:Battery'],
|
|
25
|
+
serialMembers: ['gs1:hasSerialNumber'],
|
|
26
|
+
sections: [
|
|
27
|
+
{
|
|
28
|
+
title: 'The battery',
|
|
29
|
+
description: 'The model identifier is the one the manufacturer assigned. The names beside it are for people to read and can be given in several languages.',
|
|
30
|
+
fields: [
|
|
31
|
+
text('eubat:batteryModelIdentifier', 'Model identifier', { required: true, help: 'Assigned by the manufacturer. Not the product name.' }),
|
|
32
|
+
list('gs1:productName', 'Product name', 'name', langText('', 'Name')),
|
|
33
|
+
langText('schema:model', 'Model name'),
|
|
34
|
+
list('gs1:productDescription', 'Description', 'description', langText('', 'Description')),
|
|
35
|
+
code('schema:category', 'Battery category', 'eubat:BatteryCategory'),
|
|
36
|
+
group('gs1:additionalProductClassification', 'Further classification', 'gs1:AdditionalProductClassificationDetails', [
|
|
37
|
+
text('gs1:additionalProductClassificationCode', 'Code', { help: 'A code from a classification you use, as that classification writes it.' }),
|
|
38
|
+
langText('gs1:additionalProductClassificationCodeDescription', 'What the code means'),
|
|
39
|
+
]),
|
|
40
|
+
code('schema:status', 'Battery status', 'eubat:BatteryStatus'),
|
|
41
|
+
code('eubat:hasCellType', 'Cell type', 'eubat:CellType'),
|
|
42
|
+
integer('eubat:numberOfCells', 'Number of cells'),
|
|
43
|
+
integer('eubat:numberOfModules', 'Number of modules'),
|
|
44
|
+
quantity('gs1:netWeight', 'Net weight', ['KGM', 'GRM']),
|
|
45
|
+
quantity('gs1:grossWeight', 'Gross weight', ['KGM', 'GRM']),
|
|
46
|
+
date('gs1:productionDate', 'Made on'),
|
|
47
|
+
date('eubat:puttingIntoService', 'Put into service on'),
|
|
48
|
+
country('gs1:countryOfOrigin', 'Country of origin'),
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
title: 'The passport',
|
|
53
|
+
fields: [
|
|
54
|
+
text('schema:schemaVersion', 'Version of the data model', { required: true, help: 'The version of the battery data model this document follows, as its publisher numbers it.' }),
|
|
55
|
+
code('oec:passportStatus', 'Passport status', PASSPORT_STATUSES, { as: 'text', required: true }),
|
|
56
|
+
code('oec:hasReportingGranularity', 'Reported per', 'oec:DPPGranularity', { required: true, help: 'Whether the data is reported per model, per batch or per item.' }),
|
|
57
|
+
dateTime('oec:lastUpdated', 'Last updated', { required: true }),
|
|
58
|
+
url('oec:passportIdentifier', 'Passport identifier of the model', { help: 'Optional. A link for the same product at model level. It must not name another product.' }),
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title: 'Manufacturer, operator and site',
|
|
63
|
+
description: 'Each party is identified by a location number. A name is a label, and does not identify anything on its own.',
|
|
64
|
+
fields: [
|
|
65
|
+
organisation('gs1:manufacturer', 'Manufacturer'),
|
|
66
|
+
text('eubat:manufacturerIdentifier', 'Manufacturer identifier', { help: 'The identifier of the manufacturer, such as its location number.' }),
|
|
67
|
+
operator('eubat:hasOperatorInformation', 'eubat:hasOperatorRole'),
|
|
68
|
+
text('eubat:operatorIdentifier', 'Operator identifier', { help: 'The identifier of the economic operator, such as its location number.' }),
|
|
69
|
+
group('eubat:hasManufacturingPlace', 'Manufacturing site', 'gs1:Place', [
|
|
70
|
+
url('id', 'Identifier of the site', { help: 'Optional. A web address that identifies the site, if it has one.' }),
|
|
71
|
+
text('gs1:globalLocationNumber', 'Location number (GLN)', { help: 'A Global Location Number: 13 digits.' }),
|
|
72
|
+
address(),
|
|
73
|
+
]),
|
|
74
|
+
text('eubat:facilityIdentifier', 'Site identifier', { help: 'The identifier of the manufacturing site, such as its location number.' }),
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
title: 'Chemistry and ratings',
|
|
79
|
+
fields: [
|
|
80
|
+
group('eubat:hasBatteryChemistry', 'Chemistry', 'eubat:BatteryChemistry', [
|
|
81
|
+
langText('schema:name', 'Name'),
|
|
82
|
+
text('schema:alternateName', 'Short name'),
|
|
83
|
+
text('eubat:cathodeActiveMaterial', 'Cathode material'),
|
|
84
|
+
text('eubat:anodeActiveMaterial', 'Anode material'),
|
|
85
|
+
langText('eubat:electrolyteType', 'Electrolyte'),
|
|
86
|
+
]),
|
|
87
|
+
group('eubat:hasTechnicalSpecifications', 'Ratings', 'eubat:TechnicalSpecification', [
|
|
88
|
+
quantity('eubat:hasRatedCapacity', 'Rated capacity', ['AMH']),
|
|
89
|
+
quantity('eubat:hasRatedEnergy', 'Rated energy', ['KWH']),
|
|
90
|
+
quantity('eubat:hasNominalVoltage', 'Nominal voltage', ['VLT']),
|
|
91
|
+
quantity('eubat:hasMinimumVoltage', 'Minimum voltage', ['VLT']),
|
|
92
|
+
quantity('eubat:hasMaximumVoltage', 'Maximum voltage', ['VLT']),
|
|
93
|
+
quantity('eubat:hasRatedMaximumPower', 'Rated maximum power', ['KWT']),
|
|
94
|
+
quantity('eubat:hasMaximumChargingPower', 'Maximum charging power', ['KWT', 'WTT']),
|
|
95
|
+
quantity('eubat:hasMaximumDischargingPower', 'Maximum discharging power', ['KWT', 'WTT']),
|
|
96
|
+
quantity('eubat:hasMaximumChargingCurrent', 'Maximum charging current', ['AMP']),
|
|
97
|
+
quantity('eubat:hasMaximumDischargingCurrent', 'Maximum discharging current', ['AMP']),
|
|
98
|
+
quantity('eubat:hasExpectedLifetime', 'Expected lifetime', ['ANN', 'MON']),
|
|
99
|
+
decimal('eubat:powerCapabilityRatio', 'Power to energy ratio'),
|
|
100
|
+
decimal('eubat:cRate', 'C-rate'),
|
|
101
|
+
temperatureRange('eubat:hasTemperatureRangeStorage', 'Temperature range, storage'),
|
|
102
|
+
temperatureRange('eubat:hasTemperatureRangeCharging', 'Temperature range, charging'),
|
|
103
|
+
temperatureRange('eubat:hasTemperatureRangeDischarging', 'Temperature range, discharging'),
|
|
104
|
+
temperatureRange('eubat:hasTemperatureRangeIdleState', 'Temperature range, idle'),
|
|
105
|
+
]),
|
|
106
|
+
group('eubat:hasBatteryState', 'State of this battery', 'eubat:BatteryStateAssessment', [
|
|
107
|
+
list('oea:hasResult', 'Measured values', 'measured value', measurement('', '', 'eubat:')),
|
|
108
|
+
list(
|
|
109
|
+
'oea:hasSubAssessment',
|
|
110
|
+
'Values measured under a condition',
|
|
111
|
+
'measurement',
|
|
112
|
+
entry('oea:TestExecution', [
|
|
113
|
+
group('oea:hasCondition', 'Condition', 'oea:AssessmentCondition', [code('oea:hasConditionType', 'Kind of condition', 'oea:ConditionType'), quantity('oea:hasConditionValue', 'At', ANY_UNIT)]),
|
|
114
|
+
measurement('oea:hasResult', 'Result', 'eubat:'),
|
|
115
|
+
]),
|
|
116
|
+
{ help: 'For example the power the battery can deliver at a given state of charge.' }
|
|
117
|
+
),
|
|
118
|
+
]),
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
title: 'Materials and substances',
|
|
123
|
+
fields: [
|
|
124
|
+
list(
|
|
125
|
+
'eubat:hasMaterialComposition',
|
|
126
|
+
'Materials',
|
|
127
|
+
'material',
|
|
128
|
+
entry('eubat:BatteryMaterial', [
|
|
129
|
+
langText('schema:name', 'Name', { required: true }),
|
|
130
|
+
text('oec:casNumber', 'CAS number'),
|
|
131
|
+
text('oec:ecNumber', 'EC number'),
|
|
132
|
+
code('eubat:hasComponentLocation', 'Where in the battery', 'eubat:ComponentLocation'),
|
|
133
|
+
code('schema:category', 'Kind of material', 'eubat:MaterialCategory'),
|
|
134
|
+
decimal('schema:weightPercentage', 'Share of the weight', { help: 'A percentage.' }),
|
|
135
|
+
yesNo('eubat:isCriticalRawMaterial', 'A critical raw material'),
|
|
136
|
+
yesNo('eubat:isSubstanceOfConcern', 'A substance of concern'),
|
|
137
|
+
decimal('eubat:renewableContentShare', 'Renewable share', { help: 'A percentage.' }),
|
|
138
|
+
country('oec:hasMaterialOrigin', 'Country it comes from'),
|
|
139
|
+
])
|
|
140
|
+
),
|
|
141
|
+
list(
|
|
142
|
+
'eubat:hasHazardousSubstances',
|
|
143
|
+
'Hazardous substances',
|
|
144
|
+
'substance',
|
|
145
|
+
entry('eubat:HazardousSubstance', [
|
|
146
|
+
langText('schema:name', 'Name', { required: true }),
|
|
147
|
+
text('oec:casNumber', 'CAS number'),
|
|
148
|
+
text('oec:ecNumber', 'EC number'),
|
|
149
|
+
code('eubat:hasHazardClass', 'Hazard class', 'eubat:HazardClass'),
|
|
150
|
+
decimal('eubat:concentration', 'Concentration', { help: 'A percentage of the weight.' }),
|
|
151
|
+
langText('eubat:hazardImpact', 'What it does'),
|
|
152
|
+
code('eubat:hasSubstanceLocation', 'Where in the battery', 'eubat:ComponentLocation'),
|
|
153
|
+
])
|
|
154
|
+
),
|
|
155
|
+
group('eubat:hasRecycledContent', 'Recycled content', 'eubat:RecycledContent', [...metalShares('lithium', 'Lithium'), ...metalShares('cobalt', 'Cobalt'), ...metalShares('nickel', 'Nickel'), ...metalShares('lead', 'Lead')]),
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
title: 'Carbon footprint',
|
|
160
|
+
fields: [
|
|
161
|
+
group('eubat:hasCarbonFootprintDeclaration', 'Carbon footprint declaration', 'eubat:CarbonFootprintDeclaration', [
|
|
162
|
+
quantity('eubat:hasCarbonFootprintTotal', 'Total', ['KGM'], { required: true, help: 'Kilograms of carbon dioxide equivalent for the unit named below.' }),
|
|
163
|
+
quantity('eubat:hasCarbonFootprintRawMaterialExtraction', 'Raw materials', ['KGM']),
|
|
164
|
+
quantity('eubat:hasCarbonFootprintProduction', 'Production', ['KGM']),
|
|
165
|
+
quantity('eubat:hasCarbonFootprintDistribution', 'Distribution', ['KGM']),
|
|
166
|
+
quantity('eubat:hasCarbonFootprintRecycling', 'End of life and recycling', ['KGM']),
|
|
167
|
+
url('eubat:carbonFootprintStudyUrl', 'Study', { required: true, help: 'The web address of the study behind the figures.' }),
|
|
168
|
+
text('eubat:functionalUnit', 'Unit the figures are for'),
|
|
169
|
+
text('eubat:calculationStandard', 'Calculation standard'),
|
|
170
|
+
text('eubat:carbonFootprintDeclarationId', 'Declaration number'),
|
|
171
|
+
text('eubat:carbonFootprintGeographicScope', 'Geographic scope'),
|
|
172
|
+
group('eubat:hasThirdPartyVerification', 'Verification', 'eubat:ThirdPartyVerification', [
|
|
173
|
+
text('eubat:verificationBodyName', 'Verified by'),
|
|
174
|
+
date('eubat:verificationDate', 'Verified on'),
|
|
175
|
+
url('eubat:verificationCertificateUrl', 'Certificate'),
|
|
176
|
+
text('eubat:verificationStandard', 'Standard'),
|
|
177
|
+
]),
|
|
178
|
+
group('oea:hasIndicator', 'Performance class', 'oea:Indicator', [fixed('oea:hasIndicatorKind', reference('eubat:CarbonFootprintPerformanceClass')), code('oea:hasCategoricalValue', 'Class', 'eubat:CarbonFootprintClass')], {
|
|
179
|
+
required: true,
|
|
180
|
+
}),
|
|
181
|
+
]),
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
title: 'Conformity and labels',
|
|
186
|
+
fields: [
|
|
187
|
+
yesNo('eubat:ceMarkingIndicator', 'CE marked'),
|
|
188
|
+
code('eubat:hasComplianceStatus', 'Compliance status', 'eubat:ComplianceStatus'),
|
|
189
|
+
group('eubat:hasEuDeclarationOfConformity', 'EU declaration of conformity', 'cccev:Evidence', [
|
|
190
|
+
text('eubat:euDeclarationOfConformityId', 'Declaration number'),
|
|
191
|
+
url('eubat:declarationOfConformity', 'Document'),
|
|
192
|
+
group('eubat:hasNotifiedBody', 'Notified body', 'cv:PublicOrganisation', [text('eubat:notifiedBodyNumber', 'Number'), text('eubat:notifiedBodyName', 'Name')]),
|
|
193
|
+
]),
|
|
194
|
+
list('gs1:certification', 'Certificates', 'certificate', certificate()),
|
|
195
|
+
url('eubat:resultOfTestReport', 'Test report'),
|
|
196
|
+
text('eubat:testReportNumber', 'Test report number'),
|
|
197
|
+
url('eubat:separateCollectionSymbolUrl', 'Separate collection symbol'),
|
|
198
|
+
yesNo('eubat:cadmiumSymbolRequired', 'Cadmium symbol required'),
|
|
199
|
+
yesNo('eubat:leadSymbolRequired', 'Lead symbol required'),
|
|
200
|
+
list(
|
|
201
|
+
'eubat:hasLabels',
|
|
202
|
+
'Labels',
|
|
203
|
+
'label',
|
|
204
|
+
entry('eubat:Label', [code('eubat:hasLabelSubject', 'What the label is about', 'eubat:LabelSubject'), url('eubat:labelSymbol', 'Symbol'), langText('eubat:labelMeaning', 'What it means')])
|
|
205
|
+
),
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
title: 'Warranty, transport and service',
|
|
210
|
+
fields: [
|
|
211
|
+
warranty(),
|
|
212
|
+
url('eubat:warrantyConditions', 'Warranty conditions'),
|
|
213
|
+
yesNo('eubat:extendedWarrantyAvailable', 'Extended warranty available'),
|
|
214
|
+
contact('schema:contactPoint', 'Service contact'),
|
|
215
|
+
url('eubat:authorizedServiceCenters', 'Authorised service centres'),
|
|
216
|
+
text('eubat:transportationSafetyClass', 'Transport class', { help: 'The UN number, for example UN3480.' }),
|
|
217
|
+
langText('eubat:shippingName', 'Proper shipping name'),
|
|
218
|
+
langText('eubat:dangerousGoodsPackingInstructions', 'Packing instructions'),
|
|
219
|
+
langText('eubat:repurposingPotential', 'Suitability for a second use'),
|
|
220
|
+
url('eubat:repurposingGuidelines', 'Guidelines for a second use'),
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
title: 'End of life and due diligence',
|
|
225
|
+
fields: [
|
|
226
|
+
group('eubat:hasEndOfLifeInfo', 'End of life', 'eubat:EndOfLifeInfo', [
|
|
227
|
+
decimal('eubat:recyclabilityRate', 'Recyclable share', { help: 'A percentage.' }),
|
|
228
|
+
list('eubat:hasMaterialRecoveryTargets', 'Recovery targets', 'target', entry('eubat:MaterialRecoveryTarget', [text('eubat:recoveryMaterial', 'Material'), decimal('eubat:recoveryRate', 'Share recovered', { help: 'A percentage.' })])),
|
|
229
|
+
group('eubat:hasSafetyMeasures', 'Safety measures', 'oec:DocumentReference', [url('oec:documentUrl', 'Document')]),
|
|
230
|
+
quantity('eubat:hasDismantlingTime', 'Time to dismantle', ['MIN', 'HUR']),
|
|
231
|
+
langText('eubat:extinguishingAgent', 'Extinguishing agent'),
|
|
232
|
+
url('eubat:wastePrevention', 'Waste prevention'),
|
|
233
|
+
url('eubat:separateCollection', 'Separate collection'),
|
|
234
|
+
url('eubat:informationOnCollection', 'Collection points'),
|
|
235
|
+
url('eubat:safetyInstructions', 'Safety instructions'),
|
|
236
|
+
decimal('eubat:renewableContent', 'Renewable content', { help: 'A percentage.' }),
|
|
237
|
+
]),
|
|
238
|
+
list(
|
|
239
|
+
'eubat:hasDismantlingAndRemovalInformation',
|
|
240
|
+
'Dismantling documents',
|
|
241
|
+
'document',
|
|
242
|
+
entry('eubat:DismantlingDocument', [code('eubat:hasDocumentType', 'Kind of document', 'eubat:DismantlingDocumentType'), url('eubat:documentUrl', 'Document'), text('eubat:mimeType', 'File type'), text('eubat:languageCode', 'Language code')])
|
|
243
|
+
),
|
|
244
|
+
group('eubat:hasSupplyChainDueDiligence', 'Supply chain due diligence', 'eubat:SupplyChainDueDiligence', [
|
|
245
|
+
url('eubat:dueDiligenceReportUrl', 'Report', { required: true }),
|
|
246
|
+
url('eubat:dueDiligencePolicyUrl', 'Policy'),
|
|
247
|
+
url('eubat:thirdPartyAssurancesUrl', 'Third-party assurance'),
|
|
248
|
+
langText('eubat:riskAssessmentSummary', 'Summary of the risks'),
|
|
249
|
+
yesNo('eubat:supplyChainMappingAvailable', 'Supply chain is mapped'),
|
|
250
|
+
yesNo('eubat:conflictMineralFree', 'Free of conflict minerals'),
|
|
251
|
+
code('eubat:hasResponsibleSourcingStandard', 'Sourcing standard', 'eubat:ResponsibleSourcingStandard'),
|
|
252
|
+
date('schema:auditDate', 'Audited on'),
|
|
253
|
+
text('eubat:auditBody', 'Audited by'),
|
|
254
|
+
decimal('eubat:supplyChainIndex', 'Supply chain index'),
|
|
255
|
+
]),
|
|
256
|
+
list(
|
|
257
|
+
'eubat:hasSparePartSources',
|
|
258
|
+
'Where spare parts come from',
|
|
259
|
+
'source',
|
|
260
|
+
entry('gs1:Organization', [text('gs1:organizationName', 'Name'), langText('eubat:spareParts', 'Parts'), address(), contact('eubat:hasSupplierContact', 'Contact')])
|
|
261
|
+
),
|
|
262
|
+
referencedFiles(),
|
|
263
|
+
langText('eubat:criticalRawMaterialsStatement', 'Statement on critical raw materials'),
|
|
264
|
+
longText('eubat:dataProviderCertification', 'Certification of the data provider'),
|
|
265
|
+
text('eubat:dataQualityAssessment', 'Data quality rating'),
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// How a reader's page shows a product document: as the structure it has.
|
|
2
|
+
// A measurement is a value with its unit, text keeps its language, a coded
|
|
3
|
+
// value is shown as a code, a list stays a list and a nested object stays
|
|
4
|
+
// nested. Nothing is left out: a property the page has no label for is
|
|
5
|
+
// shown under the name the document gives it.
|
|
6
|
+
import { isObject, type Json } from './form-model'
|
|
7
|
+
import { unitName } from './units'
|
|
8
|
+
|
|
9
|
+
export type Shown =
|
|
10
|
+
| { kind: 'empty' }
|
|
11
|
+
| { kind: 'text'; text: string }
|
|
12
|
+
| { kind: 'link'; href: string }
|
|
13
|
+
| { kind: 'date'; text: string }
|
|
14
|
+
| { kind: 'number'; text: string }
|
|
15
|
+
| { kind: 'boolean'; value: boolean }
|
|
16
|
+
/** Text in a language. */
|
|
17
|
+
| { kind: 'langText'; text: string; language: string }
|
|
18
|
+
/** A literal with a data type written beside it. `type` is as the document writes it. */
|
|
19
|
+
| { kind: 'typed'; text: string; type: string }
|
|
20
|
+
/** A measurement: the value exactly as written, the unit code and its name. */
|
|
21
|
+
| { kind: 'quantity'; value: string; unitCode: string; unitName: string }
|
|
22
|
+
/** A coded value or a link to another thing, by its identifier. */
|
|
23
|
+
| { kind: 'reference'; id: string; label: string }
|
|
24
|
+
| { kind: 'list'; items: Shown[] }
|
|
25
|
+
| { kind: 'object'; type?: string; id?: string; entries: Array<{ key: string; label: string; value: Shown }> }
|
|
26
|
+
|
|
27
|
+
const hasOnly = (value: Json, names: string[]): boolean => Object.keys(value).every((name) => names.includes(name))
|
|
28
|
+
|
|
29
|
+
/** `eubat:hasBatteryState` becomes `Battery state`; `gs1:TargetConsumerGenderCode-UNISEX` becomes `Unisex`. */
|
|
30
|
+
export function humaniseName(name: string): string {
|
|
31
|
+
const local = name.slice(name.lastIndexOf(':') + 1)
|
|
32
|
+
const tail = local.includes('-') ? local.slice(local.lastIndexOf('-') + 1) : local
|
|
33
|
+
const words = tail
|
|
34
|
+
.replace(/^(has|is)(?=[A-Z])/, '')
|
|
35
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
36
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
|
|
37
|
+
.replace(/[_-]+/g, ' ')
|
|
38
|
+
.trim()
|
|
39
|
+
if (words === '') return name
|
|
40
|
+
const lower = /^[A-Z0-9 ]+$/.test(words) && local.includes('-') ? words.toLowerCase() : words.replace(/\b([A-Z])([a-z])/g, (_, first: string, rest: string) => first.toLowerCase() + rest)
|
|
41
|
+
return lower[0].toUpperCase() + lower.slice(1)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One value of a product document, as the structure the page draws. `labels` gives a property its label where the form knows one. */
|
|
45
|
+
export function describeValue(value: unknown, labels: Map<string, string> = new Map()): Shown {
|
|
46
|
+
if (value === null || value === undefined || value === '') return { kind: 'empty' }
|
|
47
|
+
if (typeof value === 'boolean') return { kind: 'boolean', value }
|
|
48
|
+
if (typeof value === 'number') return { kind: 'number', text: String(value) }
|
|
49
|
+
if (typeof value === 'string') {
|
|
50
|
+
if (/^https?:\/\//.test(value)) return { kind: 'link', href: value }
|
|
51
|
+
if (/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/.test(value)) return { kind: 'date', text: value }
|
|
52
|
+
return { kind: 'text', text: value }
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(value)) return { kind: 'list', items: value.map((item) => describeValue(item, labels)) }
|
|
55
|
+
if (!isObject(value)) return { kind: 'text', text: String(value) }
|
|
56
|
+
|
|
57
|
+
if (Object.hasOwn(value, '@value')) {
|
|
58
|
+
const text = String(value['@value'])
|
|
59
|
+
if (typeof value['@language'] === 'string' && hasOnly(value, ['@value', '@language'])) return { kind: 'langText', text, language: value['@language'] }
|
|
60
|
+
if (typeof value['@type'] === 'string' && hasOnly(value, ['@value', '@type'])) return { kind: 'typed', text, type: value['@type'] }
|
|
61
|
+
}
|
|
62
|
+
const id = [value['@id'], value.id].find((candidate): candidate is string => typeof candidate === 'string')
|
|
63
|
+
if (id != null && Object.keys(value).length === 1) return /^https?:\/\//.test(id) ? { kind: 'link', href: id } : { kind: 'reference', id, label: humaniseName(id) }
|
|
64
|
+
const unit = value['gs1:unitCode']
|
|
65
|
+
const amount = value['gs1:value']
|
|
66
|
+
if (typeof unit === 'string' && (typeof amount === 'string' || typeof amount === 'number') && hasOnly(value, ['type', '@type', 'gs1:value', 'gs1:unitCode'])) {
|
|
67
|
+
return { kind: 'quantity', value: String(amount), unitCode: unit, unitName: unitName(unit) }
|
|
68
|
+
}
|
|
69
|
+
const type = [value.type, value['@type']].find((candidate) => typeof candidate === 'string' || Array.isArray(candidate))
|
|
70
|
+
return {
|
|
71
|
+
kind: 'object',
|
|
72
|
+
...(type == null ? {} : { type: Array.isArray(type) ? type.join(', ') : (type as string) }),
|
|
73
|
+
...(id == null ? {} : { id }),
|
|
74
|
+
entries: Object.entries(value)
|
|
75
|
+
.filter(([key]) => !['type', '@type', 'id', '@id'].includes(key))
|
|
76
|
+
.map(([key, member]) => ({ key, label: labels.get(key) ?? humaniseName(key), value: describeValue(member, labels) })),
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Labels for the members every product document has, whatever its profile. */
|
|
81
|
+
const COMMON_LABELS: Record<string, string> = {
|
|
82
|
+
'@context': 'Contexts',
|
|
83
|
+
id: 'Identifier',
|
|
84
|
+
'@id': 'Identifier',
|
|
85
|
+
type: 'Type',
|
|
86
|
+
'@type': 'Type',
|
|
87
|
+
'gs1:gtin': 'GTIN',
|
|
88
|
+
'gs1:hasSerialNumber': 'Serial',
|
|
89
|
+
'schema:serialNumber': 'Serial',
|
|
90
|
+
'oec:granularityLevel': 'Granularity',
|
|
91
|
+
}
|
|
92
|
+
const labelFor = (labels: Map<string, string>, key: string): string => COMMON_LABELS[key] ?? labels.get(key) ?? humaniseName(key)
|
|
93
|
+
|
|
94
|
+
export interface ShownProperty {
|
|
95
|
+
key: string
|
|
96
|
+
label: string
|
|
97
|
+
/** Where the property was read from: the public payload on chain, or the restricted part the holder opened. */
|
|
98
|
+
tier: 'public' | 'restricted'
|
|
99
|
+
/** The property is in the public payload although the binding does not list it as public. The validation reports the same as a disclosure. */
|
|
100
|
+
disclosed?: boolean
|
|
101
|
+
value: Shown
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The top-level properties of a product document for a reader's page, each
|
|
106
|
+
* with its tier. A property read from the public payload is public, because
|
|
107
|
+
* it is on chain for anyone. A property read from the restricted part is
|
|
108
|
+
* restricted. Every property of both parts is listed.
|
|
109
|
+
*/
|
|
110
|
+
export function describeProduct(parts: { publicProduct: Json; restrictedProduct?: Json; access?: { public: string[] } }, labels: Map<string, string> = new Map()): ShownProperty[] {
|
|
111
|
+
const shown: ShownProperty[] = []
|
|
112
|
+
for (const [key, value] of Object.entries(parts.publicProduct)) {
|
|
113
|
+
const disclosed = parts.access != null && !parts.access.public.includes(key)
|
|
114
|
+
shown.push({ key, label: labelFor(labels, key), tier: 'public', ...(disclosed ? { disclosed } : {}), value: describeValue(value, labels) })
|
|
115
|
+
}
|
|
116
|
+
for (const [key, value] of Object.entries(parts.restrictedProduct ?? {})) {
|
|
117
|
+
// The restricted part repeats the product's identifier so the two can be rejoined; it is already shown.
|
|
118
|
+
if (Object.hasOwn(parts.publicProduct, key)) continue
|
|
119
|
+
shown.push({ key, label: labelFor(labels, key), tier: 'restricted', value: describeValue(value, labels) })
|
|
120
|
+
}
|
|
121
|
+
return shown
|
|
122
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Short ways to write a form's fields, and the groups both sector forms
|
|
2
|
+
// share: an address, a contact, a measurement, a certificate.
|
|
3
|
+
import type { CodeSource, Field, FixedField, GroupField, ListField, ScalarField } from './form-model'
|
|
4
|
+
import { ANY_UNIT } from './units'
|
|
5
|
+
|
|
6
|
+
interface Extra {
|
|
7
|
+
help?: string
|
|
8
|
+
required?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Simple = 'text' | 'longText' | 'date' | 'dateTime' | 'integer' | 'boolean'
|
|
12
|
+
const simple =
|
|
13
|
+
(kind: Simple) =>
|
|
14
|
+
(key: string, label: string, extra: Extra = {}): ScalarField => ({ kind, key, label, ...extra })
|
|
15
|
+
|
|
16
|
+
export const text = simple('text')
|
|
17
|
+
export const longText = simple('longText')
|
|
18
|
+
export const url = (key: string, label: string, extra: Extra = {}): ScalarField => ({ kind: 'url', key, label, ...extra })
|
|
19
|
+
/** A web address written as a link to the thing at that address. */
|
|
20
|
+
export const link = (key: string, label: string, extra: Extra = {}): ScalarField => ({ kind: 'url', key, label, as: 'reference', ...extra })
|
|
21
|
+
export const date = simple('date')
|
|
22
|
+
export const dateTime = simple('dateTime')
|
|
23
|
+
export const integer = simple('integer')
|
|
24
|
+
export const yesNo = simple('boolean')
|
|
25
|
+
export const decimal = (key: string, label: string, extra: Extra & { typed?: boolean } = {}): ScalarField => ({ kind: 'decimal', key, label, ...extra })
|
|
26
|
+
export const langText = (key: string, label: string, extra: Extra = {}): ScalarField => ({ kind: 'langText', key, label, ...extra })
|
|
27
|
+
export const quantity = (key: string, label: string, units: string[], extra: Extra = {}): ScalarField => ({ kind: 'quantity', key, label, units, ...extra })
|
|
28
|
+
/** A coded value from a class of the profile's vocabulary, or from the list given. */
|
|
29
|
+
export const code = (key: string, label: string, codes: string | CodeSource, extra: Extra & { as?: 'text' } = {}): ScalarField => ({ kind: 'code', key, label, codes: typeof codes === 'string' ? { class: codes } : codes, ...extra })
|
|
30
|
+
export const country = (key: string, label: string, extra: Extra & { as?: 'text' } = {}): ScalarField => ({ kind: 'country', key, label, ...extra })
|
|
31
|
+
export const fixed = (key: string, value: unknown): FixedField => ({ kind: 'fixed', key, value })
|
|
32
|
+
export const reference = (id: string): { '@id': string } => ({ '@id': id })
|
|
33
|
+
export const group = (key: string, label: string, type: string | undefined, fields: Array<Field | FixedField>, extra: Extra = {}): GroupField => ({ kind: 'group', key, label, ...(type == null ? {} : { type }), fields, ...extra })
|
|
34
|
+
export const list = (key: string, label: string, itemLabel: string, item: ScalarField | GroupField, extra: Extra = {}): ListField => ({ kind: 'list', key, label, itemLabel, item, ...extra })
|
|
35
|
+
/** One entry of a list: a group with no property of its own, since the list names it. */
|
|
36
|
+
export const entry = (type: string | undefined, fields: Array<Field | FixedField>): GroupField => group('', '', type, fields)
|
|
37
|
+
|
|
38
|
+
const GLN_HELP = 'A Global Location Number: 13 digits.'
|
|
39
|
+
|
|
40
|
+
export const address = (): GroupField =>
|
|
41
|
+
group('gs1:address', 'Address', 'gs1:PostalAddress', [text('gs1:streetAddress', 'Street'), text('gs1:addressLocality', 'Town or city'), text('gs1:postalCode', 'Postcode'), country('gs1:addressCountry', 'Country')])
|
|
42
|
+
|
|
43
|
+
export const contact = (key = 'gs1:contactPoint', label = 'Contact'): GroupField => group(key, label, 'gs1:ContactPoint', [text('gs1:email', 'Email'), text('gs1:telephone', 'Telephone'), link('schema:url', 'Web page')])
|
|
44
|
+
|
|
45
|
+
/** An organisation: its name as people read it, kept apart from the number that identifies it. */
|
|
46
|
+
export const organisation = (key: string, label: string, extra: Extra = {}): GroupField =>
|
|
47
|
+
group(
|
|
48
|
+
key,
|
|
49
|
+
label,
|
|
50
|
+
'gs1:Organization',
|
|
51
|
+
[
|
|
52
|
+
url('id', 'Identifier of the organisation', { help: 'Optional. A web address that identifies the organisation, if it has one. Leave it empty otherwise.' }),
|
|
53
|
+
text('gs1:organizationName', 'Name'),
|
|
54
|
+
text('gs1:globalLocationNumber', 'Location number (GLN)', { help: GLN_HELP }),
|
|
55
|
+
address(),
|
|
56
|
+
contact(),
|
|
57
|
+
],
|
|
58
|
+
extra
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
/** The economic operator behind the product. `roleKey` is the property the profile writes the role under. */
|
|
62
|
+
export const operator = (key: string, roleKey: string, extra: Extra = {}): GroupField =>
|
|
63
|
+
group(
|
|
64
|
+
key,
|
|
65
|
+
'Economic operator',
|
|
66
|
+
'oec:OperatorInformation',
|
|
67
|
+
[
|
|
68
|
+
url('id', 'Identifier of the operator', { help: 'Optional. A web address that identifies the operator, if it has one.' }),
|
|
69
|
+
text('gs1:globalLocationNumber', 'Location number (GLN)', { help: GLN_HELP, required: true }),
|
|
70
|
+
text('gs1:organizationName', 'Name'),
|
|
71
|
+
code(roleKey, 'Role', 'oec:OperatorRole', { required: true, help: 'The role the operator has for this product.' }),
|
|
72
|
+
text('oec:eoriNumber', 'EORI number'),
|
|
73
|
+
text('schema:vatID', 'VAT number'),
|
|
74
|
+
address(),
|
|
75
|
+
contact(),
|
|
76
|
+
],
|
|
77
|
+
extra
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
/** A site: its location number and name, with the certificates it holds. */
|
|
81
|
+
export const facility = (key: string, label: string): GroupField =>
|
|
82
|
+
group(key, label, 'oec:FacilityInformation', [
|
|
83
|
+
url('id', 'Identifier of the site', { help: 'Optional. A web address that identifies the site, if it has one.' }),
|
|
84
|
+
text('gs1:globalLocationNumber', 'Location number (GLN)', { help: GLN_HELP, required: true }),
|
|
85
|
+
text('schema:name', 'Name', { required: true }),
|
|
86
|
+
text('oec:facilityType', 'Kind of site'),
|
|
87
|
+
address(),
|
|
88
|
+
list('oec:hasFacilityCertifications', 'Certificates of the site', 'certificate', entry('gs1:CertificationDetails', [text('gs1:certificationStandard', 'Standard'), text('gs1:certificationIdentification', 'Certificate number')])),
|
|
89
|
+
])
|
|
90
|
+
|
|
91
|
+
/** One measured value: what was measured, how much, in which unit. `prefix` keeps the choices to the sector's own parameters. */
|
|
92
|
+
export const measurement = (key: string, label: string, prefix: string): GroupField =>
|
|
93
|
+
group(key, label, 'oea:MeasurementResult', [
|
|
94
|
+
code('oea:hasObservedParameter', 'What was measured', { class: 'oea:PerformanceParameter', prefix }, { required: true }),
|
|
95
|
+
quantity('oea:hasMeasuredValue', 'Measured value', ANY_UNIT, { required: true, help: 'Use the unit "one" for a count or a grade on a scale.' }),
|
|
96
|
+
])
|
|
97
|
+
|
|
98
|
+
export const certificate = (): GroupField =>
|
|
99
|
+
entry('gs1:CertificationDetails', [
|
|
100
|
+
text('gs1:certificationAgency', 'Issued by'),
|
|
101
|
+
text('gs1:certificationStandard', 'Standard'),
|
|
102
|
+
text('gs1:certificationIdentification', 'Certificate number'),
|
|
103
|
+
text('gs1:certificationValue', 'Certificate value'),
|
|
104
|
+
url('gs1:certificationURI', 'Web address'),
|
|
105
|
+
date('gs1:certificationStartDate', 'Valid from'),
|
|
106
|
+
date('gs1:certificationEndDate', 'Valid to'),
|
|
107
|
+
])
|
|
108
|
+
|
|
109
|
+
export const warranty = (): GroupField =>
|
|
110
|
+
group('gs1:manufacturersWarranty', 'Warranty', 'gs1:WarrantyPromise', [quantity('gs1:durationOfWarranty', 'Length', ['ANN', 'MON', 'DAY']), text('gs1:warrantyScopeDescription', 'What it covers')])
|
|
111
|
+
|
|
112
|
+
/** A file about the product: its address is its identifier. */
|
|
113
|
+
export const referencedFiles = (): ListField =>
|
|
114
|
+
list(
|
|
115
|
+
'gs1:referencedFile',
|
|
116
|
+
'Files',
|
|
117
|
+
'file',
|
|
118
|
+
entry('gs1:ReferencedFileDetails', [
|
|
119
|
+
url('id', 'Web address of the file', { required: true }),
|
|
120
|
+
code('gs1:referencedFileType', 'Kind of file', { options: ['PRODUCT_IMAGE', 'DOCUMENT', 'CERTIFICATION', 'IFU', 'SAFETY_DATA_SHEET', 'WARRANTY_INFORMATION', 'VIDEO', 'WEBSITE'].map((value) => ({ value: `gs1:ReferencedFileTypeCode-${value}`, label: value[0] + value.slice(1).toLowerCase().replace(/_/g, ' ') })) }),
|
|
121
|
+
text('schema:encodingFormat', 'File type'),
|
|
122
|
+
text('schema:description', 'Description'),
|
|
123
|
+
text('gs1:fileLanguageCode', 'Language code'),
|
|
124
|
+
])
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
/** The passport statuses the profiles' rules accept. */
|
|
128
|
+
export const PASSPORT_STATUSES: CodeSource = { options: ['active', 'inactive', 'archived', 'invalid', 'draft', 'withdrawn', 'suspended'].map((value) => ({ value, label: value[0].toUpperCase() + value.slice(1) })) }
|