@twin.org/standards-vda 0.0.2-next.8 → 0.0.3-next.1

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 (34) hide show
  1. package/dist/es/identifiers/vdaIdentifiers.js +28 -0
  2. package/dist/es/identifiers/vdaIdentifiers.js.map +1 -0
  3. package/dist/es/index.js +14 -0
  4. package/dist/es/index.js.map +1 -0
  5. package/dist/es/models/IVdaBizLocation.js +2 -0
  6. package/dist/es/models/IVdaBizLocation.js.map +1 -0
  7. package/dist/es/models/IVdaCommon.js +2 -0
  8. package/dist/es/models/IVdaCommon.js.map +1 -0
  9. package/dist/es/models/IVdaObjectIdentifier.js +2 -0
  10. package/dist/es/models/IVdaObjectIdentifier.js.map +1 -0
  11. package/dist/es/models/IVdaReadPoint.js +2 -0
  12. package/dist/es/models/IVdaReadPoint.js.map +1 -0
  13. package/dist/es/models/IVdaUriPlates.js +2 -0
  14. package/dist/es/models/IVdaUriPlates.js.map +1 -0
  15. package/dist/es/models/vdaIdTypes.js +17 -0
  16. package/dist/es/models/vdaIdTypes.js.map +1 -0
  17. package/dist/es/models/vdaIdentifierTypes.js +21 -0
  18. package/dist/es/models/vdaIdentifierTypes.js.map +1 -0
  19. package/dist/es/models/vdaUriIdentifiers.js +53 -0
  20. package/dist/es/models/vdaUriIdentifiers.js.map +1 -0
  21. package/dist/es/models/vdaUriPackages.js +29 -0
  22. package/dist/es/models/vdaUriPackages.js.map +1 -0
  23. package/dist/{esm/index.mjs → es/utils/vdaIdentifiersValidation.js} +7 -153
  24. package/dist/es/utils/vdaIdentifiersValidation.js.map +1 -0
  25. package/dist/types/index.d.ts +11 -11
  26. package/dist/types/models/IVdaBizLocation.d.ts +1 -1
  27. package/dist/types/models/IVdaObjectIdentifier.d.ts +1 -1
  28. package/dist/types/models/IVdaReadPoint.d.ts +1 -1
  29. package/dist/types/utils/vdaIdentifiersValidation.d.ts +4 -4
  30. package/docs/changelog.md +68 -0
  31. package/docs/reference/classes/VdaIdentifiersValidation.md +8 -8
  32. package/locales/en.json +9 -1
  33. package/package.json +20 -8
  34. package/dist/cjs/index.cjs +0 -334
@@ -0,0 +1,28 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { IdentifierHandlerFactory } from "@twin.org/data-core";
4
+ import { VdaIdentifierTypes } from "../models/vdaIdentifierTypes.js";
5
+ import { VdaIdentifiersValidation } from "../utils/vdaIdentifiersValidation.js";
6
+ /**
7
+ * Handle all identifier types for VDA.
8
+ */
9
+ export class VdaIdentifiers {
10
+ /**
11
+ * Register all the identifiers.
12
+ */
13
+ static registerIdentifiers() {
14
+ IdentifierHandlerFactory.register(VdaIdentifierTypes.JaifId, () => ({
15
+ namespace: VdaIdentifierTypes.JaifId,
16
+ validate: (propertyName, value, failures) => VdaIdentifiersValidation.jaifId(propertyName, value, failures)
17
+ }));
18
+ IdentifierHandlerFactory.register(VdaIdentifierTypes.JaifLocation, () => ({
19
+ namespace: VdaIdentifierTypes.JaifLocation,
20
+ validate: (propertyName, value, failures) => VdaIdentifiersValidation.jaifIdLocation(propertyName, value, failures)
21
+ }));
22
+ IdentifierHandlerFactory.register(VdaIdentifierTypes.JaifItem, () => ({
23
+ namespace: VdaIdentifierTypes.JaifItem,
24
+ validate: (propertyName, value, failures) => VdaIdentifiersValidation.jaifIdItem(propertyName, value, failures)
25
+ }));
26
+ }
27
+ }
28
+ //# sourceMappingURL=vdaIdentifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vdaIdentifiers.js","sourceRoot":"","sources":["../../../src/identifiers/vdaIdentifiers.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF;;GAEG;AACH,MAAM,OAAO,cAAc;IAC1B;;OAEG;IACI,MAAM,CAAC,mBAAmB;QAChC,wBAAwB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;YACnE,SAAS,EAAE,kBAAkB,CAAC,MAAM;YACpC,QAAQ,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAW,EAAE,CACpD,wBAAwB,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC;SAC/D,CAAC,CAAC,CAAC;QAEJ,wBAAwB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC;YACzE,SAAS,EAAE,kBAAkB,CAAC,YAAY;YAC1C,QAAQ,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAW,EAAE,CACpD,wBAAwB,CAAC,cAAc,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC;SACvE,CAAC,CAAC,CAAC;QAEJ,wBAAwB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;YACrE,SAAS,EAAE,kBAAkB,CAAC,QAAQ;YACtC,QAAQ,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAW,EAAE,CACpD,wBAAwB,CAAC,UAAU,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC;SACnE,CAAC,CAAC,CAAC;IACL,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { IdentifierHandlerFactory } from \"@twin.org/data-core\";\nimport { VdaIdentifierTypes } from \"../models/vdaIdentifierTypes.js\";\nimport { VdaIdentifiersValidation } from \"../utils/vdaIdentifiersValidation.js\";\n\n/**\n * Handle all identifier types for VDA.\n */\nexport class VdaIdentifiers {\n\t/**\n\t * Register all the identifiers.\n\t */\n\tpublic static registerIdentifiers(): void {\n\t\tIdentifierHandlerFactory.register(VdaIdentifierTypes.JaifId, () => ({\n\t\t\tnamespace: VdaIdentifierTypes.JaifId,\n\t\t\tvalidate: (propertyName, value, failures): boolean =>\n\t\t\t\tVdaIdentifiersValidation.jaifId(propertyName, value, failures)\n\t\t}));\n\n\t\tIdentifierHandlerFactory.register(VdaIdentifierTypes.JaifLocation, () => ({\n\t\t\tnamespace: VdaIdentifierTypes.JaifLocation,\n\t\t\tvalidate: (propertyName, value, failures): boolean =>\n\t\t\t\tVdaIdentifiersValidation.jaifIdLocation(propertyName, value, failures)\n\t\t}));\n\n\t\tIdentifierHandlerFactory.register(VdaIdentifierTypes.JaifItem, () => ({\n\t\t\tnamespace: VdaIdentifierTypes.JaifItem,\n\t\t\tvalidate: (propertyName, value, failures): boolean =>\n\t\t\t\tVdaIdentifiersValidation.jaifIdItem(propertyName, value, failures)\n\t\t}));\n\t}\n}\n"]}
@@ -0,0 +1,14 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./identifiers/vdaIdentifiers.js";
4
+ export * from "./models/IVdaBizLocation.js";
5
+ export * from "./models/IVdaCommon.js";
6
+ export * from "./models/IVdaObjectIdentifier.js";
7
+ export * from "./models/IVdaReadPoint.js";
8
+ export * from "./models/IVdaUriPlates.js";
9
+ export * from "./models/vdaIdentifierTypes.js";
10
+ export * from "./models/vdaIdTypes.js";
11
+ export * from "./models/vdaUriIdentifiers.js";
12
+ export * from "./models/vdaUriPackages.js";
13
+ export * from "./utils/vdaIdentifiersValidation.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./identifiers/vdaIdentifiers.js\";\nexport * from \"./models/IVdaBizLocation.js\";\nexport * from \"./models/IVdaCommon.js\";\nexport * from \"./models/IVdaObjectIdentifier.js\";\nexport * from \"./models/IVdaReadPoint.js\";\nexport * from \"./models/IVdaUriPlates.js\";\nexport * from \"./models/vdaIdentifierTypes.js\";\nexport * from \"./models/vdaIdTypes.js\";\nexport * from \"./models/vdaUriIdentifiers.js\";\nexport * from \"./models/vdaUriPackages.js\";\nexport * from \"./utils/vdaIdentifiersValidation.js\";\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IVdaBizLocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IVdaBizLocation.js","sourceRoot":"","sources":["../../../src/models/IVdaBizLocation.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IVdaCommon } from \"./IVdaCommon.js\";\n\n/**\n * Interface for a VDA Biz Location.\n */\nexport interface IVdaBizLocation extends IVdaCommon {\n\t/**\n\t * DUNS Number.\n\t */\n\tdunsNumber: string;\n\n\t/**\n\t * Plant Building Floor and Room.\n\t */\n\tplantBuildingFloorRoom: string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IVdaCommon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IVdaCommon.js","sourceRoot":"","sources":["../../../src/models/IVdaCommon.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/**\n * Common VDA interface.\n */\nexport interface IVdaCommon {\n\t/**\n\t * Data Identifier (DI).\n\t */\n\tdataIdentifier: string;\n\n\t/**\n\t * Issuing Agency Code (IAC).\n\t */\n\tissuingAgencyCode: string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IVdaObjectIdentifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IVdaObjectIdentifier.js","sourceRoot":"","sources":["../../../src/models/IVdaObjectIdentifier.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IVdaCommon } from \"./IVdaCommon.js\";\n\n/**\n * Interface for VDA object identifier.\n */\nexport interface IVdaObjectIdentifier extends IVdaCommon {\n\t/**\n\t * The company identification number.\n\t */\n\tcompanyIdNumber: string;\n\n\t/**\n\t * The part number.\n\t */\n\tpartNumber: string;\n\n\t/**\n\t * The part serial number.\n\t */\n\tpartSerialNumber: string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IVdaReadPoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IVdaReadPoint.js","sourceRoot":"","sources":["../../../src/models/IVdaReadPoint.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IVdaCommon } from \"./IVdaCommon.js\";\n\n/**\n * Interface for VDA read point.\n */\nexport interface IVdaReadPoint extends IVdaCommon {\n\t/**\n\t * DUNS Number.\n\t */\n\tdunsNumber: string;\n\n\t/**\n\t * Plant.\n\t */\n\tplant: string;\n\n\t/**\n\t * Cost Center.\n\t */\n\tcostCenter: string;\n\n\t/**\n\t * Device Name/Serial Number.\n\t */\n\tserialNumber: string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IVdaUriPlates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IVdaUriPlates.js","sourceRoot":"","sources":["../../../src/models/IVdaUriPlates.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/**\n * Interface for VDA URI plates.\n */\nexport interface IVdaUriPlates {\n\t/**\n\t * Application family identifier A2 or A5.\n\t */\n\tapplicationFamilyIdentifier: string;\n\n\t/**\n\t * The type of package 2. Alphanumeric characters.\n\t */\n\ttypeOfPackage: string;\n\n\t/**\n\t * The issuing agency. 2 alphanumeric characters.\n\t */\n\tissuingAgencyCode: string;\n\n\t/**\n\t * The company identification number.\n\t */\n\tcompanyIdentificationNumber: string;\n\n\t/**\n\t * The serial number of the package.\n\t */\n\tpackageSerialNumber: string;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ /**
4
+ * VDA identifiers.
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ export const VdaIdTypes = {
8
+ /**
9
+ * Object.
10
+ */
11
+ Obj: "obj",
12
+ /**
13
+ * Location.
14
+ */
15
+ Loc: "loc"
16
+ };
17
+ //# sourceMappingURL=vdaIdTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vdaIdTypes.js","sourceRoot":"","sources":["../../../src/models/vdaIdTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB;;OAEG;IACH,GAAG,EAAE,KAAK;IAEV;;OAEG;IACH,GAAG,EAAE,KAAK;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/**\n * VDA identifiers.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const VdaIdTypes = {\n\t/**\n\t * Object.\n\t */\n\tObj: \"obj\",\n\n\t/**\n\t * Location.\n\t */\n\tLoc: \"loc\"\n} as const;\n\n/**\n * VDA identifiers.\n */\nexport type VdaIdTypes = (typeof VdaIdTypes)[keyof typeof VdaIdTypes];\n"]}
@@ -0,0 +1,21 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ /**
4
+ * The types of VDA Identifier data.
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ export const VdaIdentifierTypes = {
8
+ /**
9
+ * Identifier Joint Automotive Industry Format namespace.
10
+ */
11
+ JaifId: "jaif:id",
12
+ /**
13
+ * Specific extended namespace for location validation.
14
+ */
15
+ JaifLocation: "jaif:id@location",
16
+ /**
17
+ * Specific extended namespace for item validation.
18
+ */
19
+ JaifItem: "jaif:id@item"
20
+ };
21
+ //# sourceMappingURL=vdaIdentifierTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vdaIdentifierTypes.js","sourceRoot":"","sources":["../../../src/models/vdaIdentifierTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC;;OAEG;IACH,MAAM,EAAE,SAAS;IAEjB;;OAEG;IACH,YAAY,EAAE,kBAAkB;IAEhC;;OAEG;IACH,QAAQ,EAAE,cAAc;CACf,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The types of VDA Identifier data.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const VdaIdentifierTypes = {\n\t/**\n\t * Identifier Joint Automotive Industry Format namespace.\n\t */\n\tJaifId: \"jaif:id\",\n\n\t/**\n\t * Specific extended namespace for location validation.\n\t */\n\tJaifLocation: \"jaif:id@location\",\n\n\t/**\n\t * Specific extended namespace for item validation.\n\t */\n\tJaifItem: \"jaif:id@item\"\n} as const;\n\n/**\n * The types of VDA Identifier data.\n */\nexport type VdaIdentifierTypes = (typeof VdaIdentifierTypes)[keyof typeof VdaIdentifierTypes];\n"]}
@@ -0,0 +1,53 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ /**
4
+ * VDA URI Packages License Plates identifiers.
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ export const VdaUriIdentifiers = {
8
+ /**
9
+ * ISO 17367 Supply chain applications for RFID - Product tagging.
10
+ */
11
+ RfidProductTagging: "A1",
12
+ /**
13
+ * ISO 17365 Supply chain applications for RFID - Transport unit.
14
+ */
15
+ RfidTransportUnit: "A2",
16
+ /**
17
+ * ISO 17364 Supply chain applications for RFID - Returnable transport item.
18
+ */
19
+ RfidReturnableTransportItem: "A3",
20
+ /**
21
+ * ISO 17367 Supply chain applications for RFID - Product tagging (HazMat).
22
+ */
23
+ RfidProductTaggingHazmat: "A4",
24
+ /**
25
+ * ISO 17366 Supply chain applications for RFID - Product packaging.
26
+ */
27
+ RfidProductPackaging: "A5",
28
+ /**
29
+ * ISO 17366 Supply chain applications for RFID - Product packaging (HazMat).
30
+ */
31
+ RfidProductPackagingHazmat: "A6",
32
+ /**
33
+ * ISO 17365 Supply chain applications for RFID - Transport unit (HazMat).
34
+ */
35
+ RfidTransportUnitHazmat: "A7",
36
+ /**
37
+ * ISO 17364 Supply chain applications for RFID - Returnable transport item (Hazmat).
38
+ */
39
+ RfidReturnableTransportItemHazmat: "A8",
40
+ /**
41
+ * ISO 17363 Supply chain applications for RFID - Freight container.
42
+ */
43
+ RfidFreightContainer: "A9",
44
+ /**
45
+ * ISO 17363 Supply chain applications for RFID - Freight container (HazMat).
46
+ */
47
+ RfidFreightContainerHazmat: "AA",
48
+ /**
49
+ * Vehicle identified with the Vehicle Identification Number (VIN) as defined in ISO 3779.
50
+ */
51
+ VehicleIdentificationNumber: "90"
52
+ };
53
+ //# sourceMappingURL=vdaUriIdentifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vdaUriIdentifiers.js","sourceRoot":"","sources":["../../../src/models/vdaUriIdentifiers.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC;;OAEG;IACH,kBAAkB,EAAE,IAAI;IAExB;;OAEG;IACH,iBAAiB,EAAE,IAAI;IAEvB;;OAEG;IACH,2BAA2B,EAAE,IAAI;IAEjC;;OAEG;IACH,wBAAwB,EAAE,IAAI;IAE9B;;OAEG;IACH,oBAAoB,EAAE,IAAI;IAE1B;;OAEG;IACH,0BAA0B,EAAE,IAAI;IAEhC;;OAEG;IACH,uBAAuB,EAAE,IAAI;IAE7B;;OAEG;IACH,iCAAiC,EAAE,IAAI;IAEvC;;OAEG;IACH,oBAAoB,EAAE,IAAI;IAE1B;;OAEG;IACH,0BAA0B,EAAE,IAAI;IAEhC;;OAEG;IACH,2BAA2B,EAAE,IAAI;CACxB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * VDA URI Packages License Plates identifiers.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const VdaUriIdentifiers = {\n\t/**\n\t * ISO 17367 Supply chain applications for RFID - Product tagging.\n\t */\n\tRfidProductTagging: \"A1\",\n\n\t/**\n\t * ISO 17365 Supply chain applications for RFID - Transport unit.\n\t */\n\tRfidTransportUnit: \"A2\",\n\n\t/**\n\t * ISO 17364 Supply chain applications for RFID - Returnable transport item.\n\t */\n\tRfidReturnableTransportItem: \"A3\",\n\n\t/**\n\t * ISO 17367 Supply chain applications for RFID - Product tagging (HazMat).\n\t */\n\tRfidProductTaggingHazmat: \"A4\",\n\n\t/**\n\t * ISO 17366 Supply chain applications for RFID - Product packaging.\n\t */\n\tRfidProductPackaging: \"A5\",\n\n\t/**\n\t * ISO 17366 Supply chain applications for RFID - Product packaging (HazMat).\n\t */\n\tRfidProductPackagingHazmat: \"A6\",\n\n\t/**\n\t * ISO 17365 Supply chain applications for RFID - Transport unit (HazMat).\n\t */\n\tRfidTransportUnitHazmat: \"A7\",\n\n\t/**\n\t * ISO 17364 Supply chain applications for RFID - Returnable transport item (Hazmat).\n\t */\n\tRfidReturnableTransportItemHazmat: \"A8\",\n\n\t/**\n\t * ISO 17363 Supply chain applications for RFID - Freight container.\n\t */\n\tRfidFreightContainer: \"A9\",\n\n\t/**\n\t * ISO 17363 Supply chain applications for RFID - Freight container (HazMat).\n\t */\n\tRfidFreightContainerHazmat: \"AA\",\n\n\t/**\n\t * Vehicle identified with the Vehicle Identification Number (VIN) as defined in ISO 3779.\n\t */\n\tVehicleIdentificationNumber: \"90\"\n} as const;\n\n/**\n * VDA URI Packages License Plates identifiers.\n */\nexport type VdaUriIdentifiers = (typeof VdaUriIdentifiers)[keyof typeof VdaUriIdentifiers];\n"]}
@@ -0,0 +1,29 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ /**
4
+ * VDA URI Packages License Plates identifiers.
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ export const VdaUriPackages = {
8
+ /**
9
+ * Unique package ID of inner packaging (Single Label).
10
+ */
11
+ Package1J: "1J",
12
+ /**
13
+ * Unique package ID of JIS loading unit with compartments.
14
+ */
15
+ Package3J: "3J",
16
+ /**
17
+ * Unique package ID of JIS loading unit with 1...n JIS packages.
18
+ */
19
+ Package4J: "4J",
20
+ /**
21
+ * Unique package ID of mixed loading unit with intermediate packaging level (mixed master).
22
+ */
23
+ Package5J: "5J",
24
+ /**
25
+ * Unique package ID of loading unit or intermediate packaging containing identical parts.
26
+ */
27
+ Package67: "6J"
28
+ };
29
+ //# sourceMappingURL=vdaUriPackages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vdaUriPackages.js","sourceRoot":"","sources":["../../../src/models/vdaUriPackages.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B;;OAEG;IACH,SAAS,EAAE,IAAI;IAEf;;OAEG;IACH,SAAS,EAAE,IAAI;IAEf;;OAEG;IACH,SAAS,EAAE,IAAI;IAEf;;OAEG;IACH,SAAS,EAAE,IAAI;IAEf;;OAEG;IACH,SAAS,EAAE,IAAI;CACN,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/**\n * VDA URI Packages License Plates identifiers.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const VdaUriPackages = {\n\t/**\n\t * Unique package ID of inner packaging (Single Label).\n\t */\n\tPackage1J: \"1J\",\n\n\t/**\n\t * Unique package ID of JIS loading unit with compartments.\n\t */\n\tPackage3J: \"3J\",\n\n\t/**\n\t * Unique package ID of JIS loading unit with 1...n JIS packages.\n\t */\n\tPackage4J: \"4J\",\n\n\t/**\n\t * Unique package ID of mixed loading unit with intermediate packaging level (mixed master).\n\t */\n\tPackage5J: \"5J\",\n\n\t/**\n\t * Unique package ID of loading unit or intermediate packaging containing identical parts.\n\t */\n\tPackage67: \"6J\"\n} as const;\n\n/**\n * VDA URI Packages License Plates identifiers.\n */\nexport type VdaUriPackages = (typeof VdaUriPackages)[keyof typeof VdaUriPackages];\n"]}
@@ -1,115 +1,12 @@
1
- import { IdentifierHandlerFactory } from '@twin.org/data-core';
2
- import { Urn, Is } from '@twin.org/core';
3
-
4
- // Copyright 2024 IOTA Stiftung.
5
- // SPDX-License-Identifier: Apache-2.0.
6
- /**
7
- * The types of VDA Identifier data.
8
- */
9
- // eslint-disable-next-line @typescript-eslint/naming-convention
10
- const VdaIdentifierTypes = {
11
- /**
12
- * Identifier Joint Automotive Industry Format namespace.
13
- */
14
- JaifId: "jaif:id",
15
- /**
16
- * Specific extended namespace for location validation.
17
- */
18
- JaifLocation: "jaif:id@location",
19
- /**
20
- * Specific extended namespace for item validation.
21
- */
22
- JaifItem: "jaif:id@item"
23
- };
24
-
25
- // Copyright 2024 IOTA Stiftung.
26
- // SPDX-License-Identifier: Apache-2.0.
27
- /**
28
- * VDA URI Packages License Plates identifiers.
29
- */
30
- // eslint-disable-next-line @typescript-eslint/naming-convention
31
- const VdaUriIdentifiers = {
32
- /**
33
- * ISO 17367 Supply chain applications for RFID - Product tagging.
34
- */
35
- RfidProductTagging: "A1",
36
- /**
37
- * ISO 17365 Supply chain applications for RFID - Transport unit.
38
- */
39
- RfidTransportUnit: "A2",
40
- /**
41
- * ISO 17364 Supply chain applications for RFID - Returnable transport item.
42
- */
43
- RfidReturnableTransportItem: "A3",
44
- /**
45
- * ISO 17367 Supply chain applications for RFID - Product tagging (HazMat).
46
- */
47
- RfidProductTaggingHazmat: "A4",
48
- /**
49
- * ISO 17366 Supply chain applications for RFID - Product packaging.
50
- */
51
- RfidProductPackaging: "A5",
52
- /**
53
- * ISO 17366 Supply chain applications for RFID - Product packaging (HazMat).
54
- */
55
- RfidProductPackagingHazmat: "A6",
56
- /**
57
- * ISO 17365 Supply chain applications for RFID - Transport unit (HazMat).
58
- */
59
- RfidTransportUnitHazmat: "A7",
60
- /**
61
- * ISO 17364 Supply chain applications for RFID - Returnable transport item (Hazmat).
62
- */
63
- RfidReturnableTransportItemHazmat: "A8",
64
- /**
65
- * ISO 17363 Supply chain applications for RFID - Freight container.
66
- */
67
- RfidFreightContainer: "A9",
68
- /**
69
- * ISO 17363 Supply chain applications for RFID - Freight container (HazMat).
70
- */
71
- RfidFreightContainerHazmat: "AA",
72
- /**
73
- * Vehicle identified with the Vehicle Identification Number (VIN) as defined in ISO 3779.
74
- */
75
- VehicleIdentificationNumber: "90"
76
- };
77
-
78
- // Copyright 2024 IOTA Stiftung.
79
- // SPDX-License-Identifier: Apache-2.0.
80
- /**
81
- * VDA URI Packages License Plates identifiers.
82
- */
83
- // eslint-disable-next-line @typescript-eslint/naming-convention
84
- const VdaUriPackages = {
85
- /**
86
- * Unique package ID of inner packaging (Single Label).
87
- */
88
- Package1J: "1J",
89
- /**
90
- * Unique package ID of JIS loading unit with compartments.
91
- */
92
- Package3J: "3J",
93
- /**
94
- * Unique package ID of JIS loading unit with 1...n JIS packages.
95
- */
96
- Package4J: "4J",
97
- /**
98
- * Unique package ID of mixed loading unit with intermediate packaging level (mixed master).
99
- */
100
- Package5J: "5J",
101
- /**
102
- * Unique package ID of loading unit or intermediate packaging containing identical parts.
103
- */
104
- Package67: "6J"
105
- };
106
-
107
1
  // Copyright 2024 IOTA Stiftung.
108
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ import { Is, Urn } from "@twin.org/core";
4
+ import { VdaUriIdentifiers } from "../models/vdaUriIdentifiers.js";
5
+ import { VdaUriPackages } from "../models/vdaUriPackages.js";
109
6
  /**
110
7
  * Validation for identifier types for VDA.
111
8
  */
112
- class VdaIdentifiersValidation {
9
+ export class VdaIdentifiersValidation {
113
10
  /**
114
11
  * Validate if the property is a valid epc.
115
12
  * @param propertyName The name of the property being validated.
@@ -239,7 +136,7 @@ class VdaIdentifiersValidation {
239
136
  */
240
137
  static extractUriPlp(id) {
241
138
  const parts = /^urn:jaif:id:([\dA-Z]{2}):([\dA-Z]{2})([\dA-Z]{2})([\dA-Z]{9})(\d{9})/.exec(id);
242
- if (parts && parts.length === 6 && id.split(":")[4].length === 22) {
139
+ if (parts?.length === 6 && id.split(":")[4].length === 22) {
243
140
  const data = {
244
141
  applicationFamilyIdentifier: parts[1],
245
142
  typeOfPackage: parts[2],
@@ -267,7 +164,7 @@ class VdaIdentifiersValidation {
267
164
  const split = epc.split(":");
268
165
  if (split.length === 5) {
269
166
  const parts = /([\dA-Z]{3})([\dA-Z]{2})(\d+){1,9}(([\dA-Z]+)\+([\dA-Z]+))/.exec(split[4]);
270
- if (parts && parts.length === 7) {
167
+ if (parts?.length === 7) {
271
168
  return {
272
169
  dataIdentifier: parts[1],
273
170
  issuingAgencyCode: parts[2],
@@ -281,47 +178,4 @@ class VdaIdentifiersValidation {
281
178
  }
282
179
  }
283
180
  }
284
-
285
- // Copyright 2024 IOTA Stiftung.
286
- // SPDX-License-Identifier: Apache-2.0.
287
- /**
288
- * Handle all identifier types for VDA.
289
- */
290
- class VdaIdentifiers {
291
- /**
292
- * Register all the identifiers.
293
- */
294
- static registerIdentifiers() {
295
- IdentifierHandlerFactory.register(VdaIdentifierTypes.JaifId, () => ({
296
- namespace: VdaIdentifierTypes.JaifId,
297
- validate: (propertyName, value, failures) => VdaIdentifiersValidation.jaifId(propertyName, value, failures)
298
- }));
299
- IdentifierHandlerFactory.register(VdaIdentifierTypes.JaifLocation, () => ({
300
- namespace: VdaIdentifierTypes.JaifLocation,
301
- validate: (propertyName, value, failures) => VdaIdentifiersValidation.jaifIdLocation(propertyName, value, failures)
302
- }));
303
- IdentifierHandlerFactory.register(VdaIdentifierTypes.JaifItem, () => ({
304
- namespace: VdaIdentifierTypes.JaifItem,
305
- validate: (propertyName, value, failures) => VdaIdentifiersValidation.jaifIdItem(propertyName, value, failures)
306
- }));
307
- }
308
- }
309
-
310
- // Copyright 2024 IOTA Stiftung.
311
- // SPDX-License-Identifier: Apache-2.0.
312
- /**
313
- * VDA identifiers.
314
- */
315
- // eslint-disable-next-line @typescript-eslint/naming-convention
316
- const VdaIdTypes = {
317
- /**
318
- * Object.
319
- */
320
- Obj: "obj",
321
- /**
322
- * Location.
323
- */
324
- Loc: "loc"
325
- };
326
-
327
- export { VdaIdTypes, VdaIdentifierTypes, VdaIdentifiers, VdaIdentifiersValidation, VdaUriIdentifiers, VdaUriPackages };
181
+ //# sourceMappingURL=vdaIdentifiersValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vdaIdentifiersValidation.js","sourceRoot":"","sources":["../../../src/utils/vdaIdentifiersValidation.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAA2B,GAAG,EAAE,MAAM,gBAAgB,CAAC;AA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identifier: Apache-2.0.\nimport { Is, type IValidationFailure, Urn } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IVdaBizLocation } from \"../models/IVdaBizLocation.js\";\nimport type { IVdaObjectIdentifier } from \"../models/IVdaObjectIdentifier.js\";\nimport type { IVdaReadPoint } from \"../models/IVdaReadPoint.js\";\nimport type { IVdaUriPlates } from \"../models/IVdaUriPlates.js\";\nimport { VdaUriIdentifiers } from \"../models/vdaUriIdentifiers.js\";\nimport { VdaUriPackages } from \"../models/vdaUriPackages.js\";\n\n/**\n * Validation for identifier types for VDA.\n */\nexport class VdaIdentifiersValidation {\n\t/**\n\t * Validate if the property is a valid epc.\n\t * @param propertyName The name of the property being validated.\n\t * @param value The value to test.\n\t * @param failures The list of failures to add to.\n\t * @returns True if the value is valid epc.\n\t */\n\tpublic static jaifId(\n\t\tpropertyName: string,\n\t\tvalue: unknown,\n\t\tfailures: IValidationFailure[]\n\t): value is string {\n\t\tconst is = Urn.validate(nameof(value), value, failures);\n\n\t\tif (is) {\n\t\t\tconst urn = Urn.fromValidString(value);\n\t\t\tconst specificParts = urn.namespaceSpecific().split(\":\");\n\n\t\t\tif (specificParts[0] !== \"id\") {\n\t\t\t\tfailures.push({\n\t\t\t\t\tproperty: propertyName,\n\t\t\t\t\treason: \"validation.vdaEpcNoId\"\n\t\t\t\t});\n\t\t\t} else if (specificParts.length < 2) {\n\t\t\t\tfailures.push({\n\t\t\t\t\tproperty: propertyName,\n\t\t\t\t\treason: \"validation.vdaIncorrectSegmentCount\"\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn is;\n\t}\n\n\t/**\n\t * Validate if the property is a valid epc vda id location.\n\t * @param propertyName The name of the property being validated.\n\t * @param value The value to test.\n\t * @param failures The list of failures to add to.\n\t * @returns True if the value is valid epc.\n\t */\n\tpublic static jaifIdLocation(\n\t\tpropertyName: string,\n\t\tvalue: unknown,\n\t\tfailures: IValidationFailure[]\n\t): value is string {\n\t\tconst is = Urn.validate(nameof(value), value, failures);\n\n\t\tif (\n\t\t\tis &&\n\t\t\tIs.undefined(VdaIdentifiersValidation.extractBizLocation(value)) &&\n\t\t\tIs.undefined(VdaIdentifiersValidation.extractReadPoint(value))\n\t\t) {\n\t\t\tfailures.push({\n\t\t\t\tproperty: propertyName,\n\t\t\t\treason: \"validation.vdaValueIncorrect\"\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\n\t\treturn is;\n\t}\n\n\t/**\n\t * Validate if the property is a valid epc vda id item.\n\t * @param propertyName The name of the property being validated.\n\t * @param value The value to test.\n\t * @param failures The list of failures to add to.\n\t * @returns True if the value is valid epc.\n\t */\n\tpublic static jaifIdItem(\n\t\tpropertyName: string,\n\t\tvalue: unknown,\n\t\tfailures: IValidationFailure[]\n\t): value is string {\n\t\tconst is = Urn.validate(nameof(value), value, failures);\n\n\t\tif (\n\t\t\tis &&\n\t\t\tIs.undefined(VdaIdentifiersValidation.extractUriPlp(value)) &&\n\t\t\tIs.undefined(VdaIdentifiersValidation.extractIdentifier(value))\n\t\t) {\n\t\t\tfailures.push({\n\t\t\t\tproperty: propertyName,\n\t\t\t\treason: \"validation.vdaValueIncorrect\"\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\n\t\treturn is;\n\t}\n\n\t/**\n\t * Validate if the property is a valid epc id gtin.\n\t * @param propertyName The name of the property being validated.\n\t * @param value The value to test.\n\t * @param failures The list of failures to add to.\n\t * @returns True if the value is valid epc.\n\t */\n\tpublic static uriPlp(\n\t\tpropertyName: string,\n\t\tvalue: unknown,\n\t\tfailures: IValidationFailure[]\n\t): value is string {\n\t\tconst is = Urn.validate(nameof(value), value, failures);\n\n\t\tif (is) {\n\t\t\tconst plp = VdaIdentifiersValidation.extractUriPlp(value);\n\n\t\t\tif (Is.undefined(plp)) {\n\t\t\t\tfailures.push({\n\t\t\t\t\tproperty: propertyName,\n\t\t\t\t\treason: \"validation.vdaValueIncorrect\"\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn is;\n\t}\n\n\t/**\n\t * Function to validate and extract RFID read points URNs.\n\t * @param urn The URN to validate.\n\t * @returns The extracted read point object or undefined.\n\t */\n\tpublic static extractReadPoint(urn: string): IVdaReadPoint | undefined {\n\t\tconst parts =\n\t\t\t/^urn:jaif:id:obj:([\\dA-Za-z]{3})([\\dA-Za-z]{2})(\\d{9})([\\dA-Za-z]{2})(\\d{5})([\\dA-Za-z]*)/.exec(\n\t\t\t\turn\n\t\t\t);\n\t\tif (parts) {\n\t\t\treturn {\n\t\t\t\tdataIdentifier: parts[1],\n\t\t\t\tissuingAgencyCode: parts[2],\n\t\t\t\tdunsNumber: parts[3],\n\t\t\t\tplant: parts[4],\n\t\t\t\tcostCenter: parts[5],\n\t\t\t\tserialNumber: parts[6]\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Function to validate and extract Biz Location URN.\n\t * @param urn The URN to validate.\n\t * @returns The extracted biz location object or undefined.\n\t */\n\tpublic static extractBizLocation(urn: string): IVdaBizLocation | undefined {\n\t\tconst parts = /^urn:jaif:id:obj:([\\dA-Za-z]{3})([\\dA-Za-z]{2})(\\d{9})([\\dA-Za-z]*)/.exec(urn);\n\t\tif (parts) {\n\t\t\treturn {\n\t\t\t\tdataIdentifier: parts[1],\n\t\t\t\tissuingAgencyCode: parts[2],\n\t\t\t\tdunsNumber: parts[3],\n\t\t\t\tplantBuildingFloorRoom: parts[4]\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Function to validate VDA URI Packages License Plates.\n\t * @param id The VDA URI to validate.\n\t * @returns The VDA URI object or undefined.\n\t */\n\tpublic static extractUriPlp(id: string): IVdaUriPlates | undefined {\n\t\tconst parts = /^urn:jaif:id:([\\dA-Z]{2}):([\\dA-Z]{2})([\\dA-Z]{2})([\\dA-Z]{9})(\\d{9})/.exec(id);\n\t\tif (parts?.length === 6 && id.split(\":\")[4].length === 22) {\n\t\t\tconst data = {\n\t\t\t\tapplicationFamilyIdentifier: parts[1],\n\t\t\t\ttypeOfPackage: parts[2],\n\t\t\t\tissuingAgencyCode: parts[3],\n\t\t\t\tcompanyIdentificationNumber: parts[4],\n\t\t\t\tpackageSerialNumber: parts[5]\n\t\t\t};\n\n\t\t\tif (!Is.arrayOneOf(data.applicationFamilyIdentifier, Object.values(VdaUriIdentifiers))) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!Is.arrayOneOf(data.typeOfPackage, Object.values(VdaUriPackages))) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn data;\n\t\t}\n\t}\n\n\t/**\n\t * VDA object identifier verifier function.\n\t * @param epc The epc to validate.\n\t * @returns The VDA object or undefined.\n\t */\n\tpublic static extractIdentifier(epc: string): IVdaObjectIdentifier | undefined {\n\t\tif (\n\t\t\t(epc.startsWith(\"urn:jaif:id:obj:\") || epc.startsWith(\"urn:jaif:id:A1:\")) &&\n\t\t\tepc.length <= 56\n\t\t) {\n\t\t\tconst split = epc.split(\":\");\n\t\t\tif (split.length === 5) {\n\t\t\t\tconst parts = /([\\dA-Z]{3})([\\dA-Z]{2})(\\d+){1,9}(([\\dA-Z]+)\\+([\\dA-Z]+))/.exec(split[4]);\n\t\t\t\tif (parts?.length === 7) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdataIdentifier: parts[1],\n\t\t\t\t\t\tissuingAgencyCode: parts[2],\n\t\t\t\t\t\tcompanyIdNumber: parts[3],\n\t\t\t\t\t\t// skipped part[4] since it is a concatenation of part[5] + part[6]\n\t\t\t\t\t\tpartNumber: parts[5],\n\t\t\t\t\t\tpartSerialNumber: parts[6]\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -1,11 +1,11 @@
1
- export * from "./identifiers/vdaIdentifiers";
2
- export * from "./models/IVdaBizLocation";
3
- export * from "./models/IVdaCommon";
4
- export * from "./models/IVdaObjectIdentifier";
5
- export * from "./models/IVdaReadPoint";
6
- export * from "./models/IVdaUriPlates";
7
- export * from "./models/vdaIdentifierTypes";
8
- export * from "./models/vdaIdTypes";
9
- export * from "./models/vdaUriIdentifiers";
10
- export * from "./models/vdaUriPackages";
11
- export * from "./utils/vdaIdentifiersValidation";
1
+ export * from "./identifiers/vdaIdentifiers.js";
2
+ export * from "./models/IVdaBizLocation.js";
3
+ export * from "./models/IVdaCommon.js";
4
+ export * from "./models/IVdaObjectIdentifier.js";
5
+ export * from "./models/IVdaReadPoint.js";
6
+ export * from "./models/IVdaUriPlates.js";
7
+ export * from "./models/vdaIdentifierTypes.js";
8
+ export * from "./models/vdaIdTypes.js";
9
+ export * from "./models/vdaUriIdentifiers.js";
10
+ export * from "./models/vdaUriPackages.js";
11
+ export * from "./utils/vdaIdentifiersValidation.js";
@@ -1,4 +1,4 @@
1
- import type { IVdaCommon } from "./IVdaCommon";
1
+ import type { IVdaCommon } from "./IVdaCommon.js";
2
2
  /**
3
3
  * Interface for a VDA Biz Location.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IVdaCommon } from "./IVdaCommon";
1
+ import type { IVdaCommon } from "./IVdaCommon.js";
2
2
  /**
3
3
  * Interface for VDA object identifier.
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { IVdaCommon } from "./IVdaCommon";
1
+ import type { IVdaCommon } from "./IVdaCommon.js";
2
2
  /**
3
3
  * Interface for VDA read point.
4
4
  */
@@ -1,8 +1,8 @@
1
1
  import { type IValidationFailure } from "@twin.org/core";
2
- import type { IVdaBizLocation } from "../models/IVdaBizLocation";
3
- import type { IVdaObjectIdentifier } from "../models/IVdaObjectIdentifier";
4
- import type { IVdaReadPoint } from "../models/IVdaReadPoint";
5
- import type { IVdaUriPlates } from "../models/IVdaUriPlates";
2
+ import type { IVdaBizLocation } from "../models/IVdaBizLocation.js";
3
+ import type { IVdaObjectIdentifier } from "../models/IVdaObjectIdentifier.js";
4
+ import type { IVdaReadPoint } from "../models/IVdaReadPoint.js";
5
+ import type { IVdaUriPlates } from "../models/IVdaUriPlates.js";
6
6
  /**
7
7
  * Validation for identifier types for VDA.
8
8
  */
package/docs/changelog.md CHANGED
@@ -1,5 +1,73 @@
1
1
  # @twin.org/standards-vda - Changelog
2
2
 
3
+ ## [0.0.3-next.1](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.3-next.0...standards-vda-v0.0.3-next.1) (2025-11-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#64](https://github.com/twinfoundation/standards/issues/64)) ([e68bb87](https://github.com/twinfoundation/standards/commit/e68bb87a215f3c3956cfd6400a5e1e2a16256085))
9
+ * add validate-locales ([838389c](https://github.com/twinfoundation/standards/commit/838389c1daf62ed42397d5758d267c3d1a37fa4d))
10
+ * eslint migration to flat config ([648c1a1](https://github.com/twinfoundation/standards/commit/648c1a1e69d99b6b0cf69358ec6bdeecdbe3a5ea))
11
+ * update framework core ([58c0c3d](https://github.com/twinfoundation/standards/commit/58c0c3dd6cea0e4c2393dc0e3e1eb33a6d06f617))
12
+ * update to latest JSON schema spec ([7a23930](https://github.com/twinfoundation/standards/commit/7a2393032d7f48bfb20d3a484f981fb6dd83a92c))
13
+ * use shared store mechanism ([#11](https://github.com/twinfoundation/standards/issues/11)) ([96fa237](https://github.com/twinfoundation/standards/commit/96fa23735f69c1fc7e3d0019b527634fa0a042d9))
14
+
15
+ ## [0.0.2-next.16](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.2-next.15...standards-vda-v0.0.2-next.16) (2025-10-09)
16
+
17
+
18
+ ### Miscellaneous Chores
19
+
20
+ * **standards-vda:** Synchronize repo versions
21
+
22
+ ## [0.0.2-next.15](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.2-next.14...standards-vda-v0.0.2-next.15) (2025-10-09)
23
+
24
+
25
+ ### Features
26
+
27
+ * add validate-locales ([838389c](https://github.com/twinfoundation/standards/commit/838389c1daf62ed42397d5758d267c3d1a37fa4d))
28
+
29
+ ## [0.0.2-next.14](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.2-next.13...standards-vda-v0.0.2-next.14) (2025-10-02)
30
+
31
+
32
+ ### Miscellaneous Chores
33
+
34
+ * **standards-vda:** Synchronize repo versions
35
+
36
+ ## [0.0.2-next.13](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.2-next.12...standards-vda-v0.0.2-next.13) (2025-09-22)
37
+
38
+
39
+ ### Miscellaneous Chores
40
+
41
+ * **standards-vda:** Synchronize repo versions
42
+
43
+ ## [0.0.2-next.12](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.2-next.11...standards-vda-v0.0.2-next.12) (2025-09-16)
44
+
45
+
46
+ ### Miscellaneous Chores
47
+
48
+ * **standards-vda:** Synchronize repo versions
49
+
50
+ ## [0.0.2-next.11](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.2-next.10...standards-vda-v0.0.2-next.11) (2025-09-16)
51
+
52
+
53
+ ### Miscellaneous Chores
54
+
55
+ * **standards-vda:** Synchronize repo versions
56
+
57
+ ## [0.0.2-next.10](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.2-next.9...standards-vda-v0.0.2-next.10) (2025-09-16)
58
+
59
+
60
+ ### Miscellaneous Chores
61
+
62
+ * **standards-vda:** Synchronize repo versions
63
+
64
+ ## [0.0.2-next.9](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.2-next.8...standards-vda-v0.0.2-next.9) (2025-09-15)
65
+
66
+
67
+ ### Miscellaneous Chores
68
+
69
+ * **standards-vda:** Synchronize repo versions
70
+
3
71
  ## [0.0.2-next.8](https://github.com/twinfoundation/standards/compare/standards-vda-v0.0.2-next.7...standards-vda-v0.0.2-next.8) (2025-09-15)
4
72
 
5
73
 
@@ -152,7 +152,7 @@ True if the value is valid epc.
152
152
 
153
153
  ### extractReadPoint()
154
154
 
155
- > `static` **extractReadPoint**(`urn`): `undefined` \| [`IVdaReadPoint`](../interfaces/IVdaReadPoint.md)
155
+ > `static` **extractReadPoint**(`urn`): [`IVdaReadPoint`](../interfaces/IVdaReadPoint.md) \| `undefined`
156
156
 
157
157
  Function to validate and extract RFID read points URNs.
158
158
 
@@ -166,7 +166,7 @@ The URN to validate.
166
166
 
167
167
  #### Returns
168
168
 
169
- `undefined` \| [`IVdaReadPoint`](../interfaces/IVdaReadPoint.md)
169
+ [`IVdaReadPoint`](../interfaces/IVdaReadPoint.md) \| `undefined`
170
170
 
171
171
  The extracted read point object or undefined.
172
172
 
@@ -174,7 +174,7 @@ The extracted read point object or undefined.
174
174
 
175
175
  ### extractBizLocation()
176
176
 
177
- > `static` **extractBizLocation**(`urn`): `undefined` \| [`IVdaBizLocation`](../interfaces/IVdaBizLocation.md)
177
+ > `static` **extractBizLocation**(`urn`): [`IVdaBizLocation`](../interfaces/IVdaBizLocation.md) \| `undefined`
178
178
 
179
179
  Function to validate and extract Biz Location URN.
180
180
 
@@ -188,7 +188,7 @@ The URN to validate.
188
188
 
189
189
  #### Returns
190
190
 
191
- `undefined` \| [`IVdaBizLocation`](../interfaces/IVdaBizLocation.md)
191
+ [`IVdaBizLocation`](../interfaces/IVdaBizLocation.md) \| `undefined`
192
192
 
193
193
  The extracted biz location object or undefined.
194
194
 
@@ -196,7 +196,7 @@ The extracted biz location object or undefined.
196
196
 
197
197
  ### extractUriPlp()
198
198
 
199
- > `static` **extractUriPlp**(`id`): `undefined` \| [`IVdaUriPlates`](../interfaces/IVdaUriPlates.md)
199
+ > `static` **extractUriPlp**(`id`): [`IVdaUriPlates`](../interfaces/IVdaUriPlates.md) \| `undefined`
200
200
 
201
201
  Function to validate VDA URI Packages License Plates.
202
202
 
@@ -210,7 +210,7 @@ The VDA URI to validate.
210
210
 
211
211
  #### Returns
212
212
 
213
- `undefined` \| [`IVdaUriPlates`](../interfaces/IVdaUriPlates.md)
213
+ [`IVdaUriPlates`](../interfaces/IVdaUriPlates.md) \| `undefined`
214
214
 
215
215
  The VDA URI object or undefined.
216
216
 
@@ -218,7 +218,7 @@ The VDA URI object or undefined.
218
218
 
219
219
  ### extractIdentifier()
220
220
 
221
- > `static` **extractIdentifier**(`epc`): `undefined` \| [`IVdaObjectIdentifier`](../interfaces/IVdaObjectIdentifier.md)
221
+ > `static` **extractIdentifier**(`epc`): [`IVdaObjectIdentifier`](../interfaces/IVdaObjectIdentifier.md) \| `undefined`
222
222
 
223
223
  VDA object identifier verifier function.
224
224
 
@@ -232,6 +232,6 @@ The epc to validate.
232
232
 
233
233
  #### Returns
234
234
 
235
- `undefined` \| [`IVdaObjectIdentifier`](../interfaces/IVdaObjectIdentifier.md)
235
+ [`IVdaObjectIdentifier`](../interfaces/IVdaObjectIdentifier.md) \| `undefined`
236
236
 
237
237
  The VDA object or undefined.
package/locales/en.json CHANGED
@@ -1 +1,9 @@
1
- {}
1
+ {
2
+ "error": {
3
+ "validation": {
4
+ "vdaEpcNoId": "VDA EPC does not contain an identifier.",
5
+ "vdaIncorrectSegmentCount": "VDA EPC has an incorrect number of segments.",
6
+ "vdaValueIncorrect": "VDA EPC value is incorrect."
7
+ }
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/standards-vda",
3
- "version": "0.0.2-next.8",
3
+ "version": "0.0.3-next.1",
4
4
  "description": "Models which define the structure of VDA JAIF Standard",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,22 +20,34 @@
20
20
  "@twin.org/entity": "next",
21
21
  "@twin.org/nameof": "next"
22
22
  },
23
- "main": "./dist/cjs/index.cjs",
24
- "module": "./dist/esm/index.mjs",
23
+ "main": "./dist/es/index.js",
25
24
  "types": "./dist/types/index.d.ts",
26
25
  "exports": {
27
26
  ".": {
28
27
  "types": "./dist/types/index.d.ts",
29
- "require": "./dist/cjs/index.cjs",
30
- "import": "./dist/esm/index.mjs"
28
+ "import": "./dist/es/index.js",
29
+ "default": "./dist/es/index.js"
31
30
  },
32
31
  "./locales/*.json": "./locales/*.json"
33
32
  },
34
33
  "files": [
35
- "dist/cjs",
36
- "dist/esm",
34
+ "dist/es",
37
35
  "dist/types",
38
36
  "locales",
39
37
  "docs"
40
- ]
38
+ ],
39
+ "keywords": [
40
+ "twin",
41
+ "trade",
42
+ "iota",
43
+ "framework",
44
+ "blockchain",
45
+ "standards",
46
+ "schema",
47
+ "specification"
48
+ ],
49
+ "bugs": {
50
+ "url": "git+https://github.com/twinfoundation/standards/issues"
51
+ },
52
+ "homepage": "https://twindev.org"
41
53
  }
@@ -1,334 +0,0 @@
1
- 'use strict';
2
-
3
- var dataCore = require('@twin.org/data-core');
4
- var core = require('@twin.org/core');
5
-
6
- // Copyright 2024 IOTA Stiftung.
7
- // SPDX-License-Identifier: Apache-2.0.
8
- /**
9
- * The types of VDA Identifier data.
10
- */
11
- // eslint-disable-next-line @typescript-eslint/naming-convention
12
- const VdaIdentifierTypes = {
13
- /**
14
- * Identifier Joint Automotive Industry Format namespace.
15
- */
16
- JaifId: "jaif:id",
17
- /**
18
- * Specific extended namespace for location validation.
19
- */
20
- JaifLocation: "jaif:id@location",
21
- /**
22
- * Specific extended namespace for item validation.
23
- */
24
- JaifItem: "jaif:id@item"
25
- };
26
-
27
- // Copyright 2024 IOTA Stiftung.
28
- // SPDX-License-Identifier: Apache-2.0.
29
- /**
30
- * VDA URI Packages License Plates identifiers.
31
- */
32
- // eslint-disable-next-line @typescript-eslint/naming-convention
33
- const VdaUriIdentifiers = {
34
- /**
35
- * ISO 17367 Supply chain applications for RFID - Product tagging.
36
- */
37
- RfidProductTagging: "A1",
38
- /**
39
- * ISO 17365 Supply chain applications for RFID - Transport unit.
40
- */
41
- RfidTransportUnit: "A2",
42
- /**
43
- * ISO 17364 Supply chain applications for RFID - Returnable transport item.
44
- */
45
- RfidReturnableTransportItem: "A3",
46
- /**
47
- * ISO 17367 Supply chain applications for RFID - Product tagging (HazMat).
48
- */
49
- RfidProductTaggingHazmat: "A4",
50
- /**
51
- * ISO 17366 Supply chain applications for RFID - Product packaging.
52
- */
53
- RfidProductPackaging: "A5",
54
- /**
55
- * ISO 17366 Supply chain applications for RFID - Product packaging (HazMat).
56
- */
57
- RfidProductPackagingHazmat: "A6",
58
- /**
59
- * ISO 17365 Supply chain applications for RFID - Transport unit (HazMat).
60
- */
61
- RfidTransportUnitHazmat: "A7",
62
- /**
63
- * ISO 17364 Supply chain applications for RFID - Returnable transport item (Hazmat).
64
- */
65
- RfidReturnableTransportItemHazmat: "A8",
66
- /**
67
- * ISO 17363 Supply chain applications for RFID - Freight container.
68
- */
69
- RfidFreightContainer: "A9",
70
- /**
71
- * ISO 17363 Supply chain applications for RFID - Freight container (HazMat).
72
- */
73
- RfidFreightContainerHazmat: "AA",
74
- /**
75
- * Vehicle identified with the Vehicle Identification Number (VIN) as defined in ISO 3779.
76
- */
77
- VehicleIdentificationNumber: "90"
78
- };
79
-
80
- // Copyright 2024 IOTA Stiftung.
81
- // SPDX-License-Identifier: Apache-2.0.
82
- /**
83
- * VDA URI Packages License Plates identifiers.
84
- */
85
- // eslint-disable-next-line @typescript-eslint/naming-convention
86
- const VdaUriPackages = {
87
- /**
88
- * Unique package ID of inner packaging (Single Label).
89
- */
90
- Package1J: "1J",
91
- /**
92
- * Unique package ID of JIS loading unit with compartments.
93
- */
94
- Package3J: "3J",
95
- /**
96
- * Unique package ID of JIS loading unit with 1...n JIS packages.
97
- */
98
- Package4J: "4J",
99
- /**
100
- * Unique package ID of mixed loading unit with intermediate packaging level (mixed master).
101
- */
102
- Package5J: "5J",
103
- /**
104
- * Unique package ID of loading unit or intermediate packaging containing identical parts.
105
- */
106
- Package67: "6J"
107
- };
108
-
109
- // Copyright 2024 IOTA Stiftung.
110
- // SPDX-License-Identifier: Apache-2.0.
111
- /**
112
- * Validation for identifier types for VDA.
113
- */
114
- class VdaIdentifiersValidation {
115
- /**
116
- * Validate if the property is a valid epc.
117
- * @param propertyName The name of the property being validated.
118
- * @param value The value to test.
119
- * @param failures The list of failures to add to.
120
- * @returns True if the value is valid epc.
121
- */
122
- static jaifId(propertyName, value, failures) {
123
- const is = core.Urn.validate("value", value, failures);
124
- if (is) {
125
- const urn = core.Urn.fromValidString(value);
126
- const specificParts = urn.namespaceSpecific().split(":");
127
- if (specificParts[0] !== "id") {
128
- failures.push({
129
- property: propertyName,
130
- reason: "validation.vdaEpcNoId"
131
- });
132
- }
133
- else if (specificParts.length < 2) {
134
- failures.push({
135
- property: propertyName,
136
- reason: "validation.vdaIncorrectSegmentCount"
137
- });
138
- }
139
- }
140
- return is;
141
- }
142
- /**
143
- * Validate if the property is a valid epc vda id location.
144
- * @param propertyName The name of the property being validated.
145
- * @param value The value to test.
146
- * @param failures The list of failures to add to.
147
- * @returns True if the value is valid epc.
148
- */
149
- static jaifIdLocation(propertyName, value, failures) {
150
- const is = core.Urn.validate("value", value, failures);
151
- if (is &&
152
- core.Is.undefined(VdaIdentifiersValidation.extractBizLocation(value)) &&
153
- core.Is.undefined(VdaIdentifiersValidation.extractReadPoint(value))) {
154
- failures.push({
155
- property: propertyName,
156
- reason: "validation.vdaValueIncorrect"
157
- });
158
- return false;
159
- }
160
- return is;
161
- }
162
- /**
163
- * Validate if the property is a valid epc vda id item.
164
- * @param propertyName The name of the property being validated.
165
- * @param value The value to test.
166
- * @param failures The list of failures to add to.
167
- * @returns True if the value is valid epc.
168
- */
169
- static jaifIdItem(propertyName, value, failures) {
170
- const is = core.Urn.validate("value", value, failures);
171
- if (is &&
172
- core.Is.undefined(VdaIdentifiersValidation.extractUriPlp(value)) &&
173
- core.Is.undefined(VdaIdentifiersValidation.extractIdentifier(value))) {
174
- failures.push({
175
- property: propertyName,
176
- reason: "validation.vdaValueIncorrect"
177
- });
178
- return false;
179
- }
180
- return is;
181
- }
182
- /**
183
- * Validate if the property is a valid epc id gtin.
184
- * @param propertyName The name of the property being validated.
185
- * @param value The value to test.
186
- * @param failures The list of failures to add to.
187
- * @returns True if the value is valid epc.
188
- */
189
- static uriPlp(propertyName, value, failures) {
190
- const is = core.Urn.validate("value", value, failures);
191
- if (is) {
192
- const plp = VdaIdentifiersValidation.extractUriPlp(value);
193
- if (core.Is.undefined(plp)) {
194
- failures.push({
195
- property: propertyName,
196
- reason: "validation.vdaValueIncorrect"
197
- });
198
- return false;
199
- }
200
- }
201
- return is;
202
- }
203
- /**
204
- * Function to validate and extract RFID read points URNs.
205
- * @param urn The URN to validate.
206
- * @returns The extracted read point object or undefined.
207
- */
208
- static extractReadPoint(urn) {
209
- const parts = /^urn:jaif:id:obj:([\dA-Za-z]{3})([\dA-Za-z]{2})(\d{9})([\dA-Za-z]{2})(\d{5})([\dA-Za-z]*)/.exec(urn);
210
- if (parts) {
211
- return {
212
- dataIdentifier: parts[1],
213
- issuingAgencyCode: parts[2],
214
- dunsNumber: parts[3],
215
- plant: parts[4],
216
- costCenter: parts[5],
217
- serialNumber: parts[6]
218
- };
219
- }
220
- }
221
- /**
222
- * Function to validate and extract Biz Location URN.
223
- * @param urn The URN to validate.
224
- * @returns The extracted biz location object or undefined.
225
- */
226
- static extractBizLocation(urn) {
227
- const parts = /^urn:jaif:id:obj:([\dA-Za-z]{3})([\dA-Za-z]{2})(\d{9})([\dA-Za-z]*)/.exec(urn);
228
- if (parts) {
229
- return {
230
- dataIdentifier: parts[1],
231
- issuingAgencyCode: parts[2],
232
- dunsNumber: parts[3],
233
- plantBuildingFloorRoom: parts[4]
234
- };
235
- }
236
- }
237
- /**
238
- * Function to validate VDA URI Packages License Plates.
239
- * @param id The VDA URI to validate.
240
- * @returns The VDA URI object or undefined.
241
- */
242
- static extractUriPlp(id) {
243
- const parts = /^urn:jaif:id:([\dA-Z]{2}):([\dA-Z]{2})([\dA-Z]{2})([\dA-Z]{9})(\d{9})/.exec(id);
244
- if (parts && parts.length === 6 && id.split(":")[4].length === 22) {
245
- const data = {
246
- applicationFamilyIdentifier: parts[1],
247
- typeOfPackage: parts[2],
248
- issuingAgencyCode: parts[3],
249
- companyIdentificationNumber: parts[4],
250
- packageSerialNumber: parts[5]
251
- };
252
- if (!core.Is.arrayOneOf(data.applicationFamilyIdentifier, Object.values(VdaUriIdentifiers))) {
253
- return;
254
- }
255
- if (!core.Is.arrayOneOf(data.typeOfPackage, Object.values(VdaUriPackages))) {
256
- return;
257
- }
258
- return data;
259
- }
260
- }
261
- /**
262
- * VDA object identifier verifier function.
263
- * @param epc The epc to validate.
264
- * @returns The VDA object or undefined.
265
- */
266
- static extractIdentifier(epc) {
267
- if ((epc.startsWith("urn:jaif:id:obj:") || epc.startsWith("urn:jaif:id:A1:")) &&
268
- epc.length <= 56) {
269
- const split = epc.split(":");
270
- if (split.length === 5) {
271
- const parts = /([\dA-Z]{3})([\dA-Z]{2})(\d+){1,9}(([\dA-Z]+)\+([\dA-Z]+))/.exec(split[4]);
272
- if (parts && parts.length === 7) {
273
- return {
274
- dataIdentifier: parts[1],
275
- issuingAgencyCode: parts[2],
276
- companyIdNumber: parts[3],
277
- // skipped part[4] since it is a concatenation of part[5] + part[6]
278
- partNumber: parts[5],
279
- partSerialNumber: parts[6]
280
- };
281
- }
282
- }
283
- }
284
- }
285
- }
286
-
287
- // Copyright 2024 IOTA Stiftung.
288
- // SPDX-License-Identifier: Apache-2.0.
289
- /**
290
- * Handle all identifier types for VDA.
291
- */
292
- class VdaIdentifiers {
293
- /**
294
- * Register all the identifiers.
295
- */
296
- static registerIdentifiers() {
297
- dataCore.IdentifierHandlerFactory.register(VdaIdentifierTypes.JaifId, () => ({
298
- namespace: VdaIdentifierTypes.JaifId,
299
- validate: (propertyName, value, failures) => VdaIdentifiersValidation.jaifId(propertyName, value, failures)
300
- }));
301
- dataCore.IdentifierHandlerFactory.register(VdaIdentifierTypes.JaifLocation, () => ({
302
- namespace: VdaIdentifierTypes.JaifLocation,
303
- validate: (propertyName, value, failures) => VdaIdentifiersValidation.jaifIdLocation(propertyName, value, failures)
304
- }));
305
- dataCore.IdentifierHandlerFactory.register(VdaIdentifierTypes.JaifItem, () => ({
306
- namespace: VdaIdentifierTypes.JaifItem,
307
- validate: (propertyName, value, failures) => VdaIdentifiersValidation.jaifIdItem(propertyName, value, failures)
308
- }));
309
- }
310
- }
311
-
312
- // Copyright 2024 IOTA Stiftung.
313
- // SPDX-License-Identifier: Apache-2.0.
314
- /**
315
- * VDA identifiers.
316
- */
317
- // eslint-disable-next-line @typescript-eslint/naming-convention
318
- const VdaIdTypes = {
319
- /**
320
- * Object.
321
- */
322
- Obj: "obj",
323
- /**
324
- * Location.
325
- */
326
- Loc: "loc"
327
- };
328
-
329
- exports.VdaIdTypes = VdaIdTypes;
330
- exports.VdaIdentifierTypes = VdaIdentifierTypes;
331
- exports.VdaIdentifiers = VdaIdentifiers;
332
- exports.VdaIdentifiersValidation = VdaIdentifiersValidation;
333
- exports.VdaUriIdentifiers = VdaUriIdentifiers;
334
- exports.VdaUriPackages = VdaUriPackages;