@open-dpp/dto 2.9.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/aas/asset-administration-shell-json-schema.d.ts +560 -20
  2. package/dist/aas/asset-administration-shell-json-schema.d.ts.map +1 -1
  3. package/dist/aas/common/basic-json-schema.d.ts +56 -2
  4. package/dist/aas/common/basic-json-schema.d.ts.map +1 -1
  5. package/dist/aas/common/language-text-json-schema.d.ts +28 -1
  6. package/dist/aas/common/language-text-json-schema.d.ts.map +1 -1
  7. package/dist/aas/concept-description-json-schema.d.ts +56 -2
  8. package/dist/aas/concept-description-json-schema.d.ts.map +1 -1
  9. package/dist/aas/enums/language-enum.d.ts +58 -2
  10. package/dist/aas/enums/language-enum.d.ts.map +1 -1
  11. package/dist/aas/enums/language-enum.js +38 -3
  12. package/dist/aas/environment-json-schema.d.ts +28 -1
  13. package/dist/aas/environment-json-schema.d.ts.map +1 -1
  14. package/dist/aas/security/access-permission-rule.dto.d.ts +224 -8
  15. package/dist/aas/security/access-permission-rule.dto.d.ts.map +1 -1
  16. package/dist/aas/security/security.dto.d.ts +280 -10
  17. package/dist/aas/security/security.dto.d.ts.map +1 -1
  18. package/dist/aas/submodel-base/annotated-relationship-element-json-schema.d.ts +120 -12
  19. package/dist/aas/submodel-base/annotated-relationship-element-json-schema.d.ts.map +1 -1
  20. package/dist/aas/submodel-base/blob-json-schema.d.ts +56 -2
  21. package/dist/aas/submodel-base/blob-json-schema.d.ts.map +1 -1
  22. package/dist/aas/submodel-base/create-group-from-column-schema.d.ts +4 -4
  23. package/dist/aas/submodel-base/entity-type-json-schema.d.ts +120 -12
  24. package/dist/aas/submodel-base/entity-type-json-schema.d.ts.map +1 -1
  25. package/dist/aas/submodel-base/file-json-schema.d.ts +112 -4
  26. package/dist/aas/submodel-base/file-json-schema.d.ts.map +1 -1
  27. package/dist/aas/submodel-base/multi-language-property-json-schema.d.ts +84 -3
  28. package/dist/aas/submodel-base/multi-language-property-json-schema.d.ts.map +1 -1
  29. package/dist/aas/submodel-base/property-json-schema.d.ts +112 -4
  30. package/dist/aas/submodel-base/property-json-schema.d.ts.map +1 -1
  31. package/dist/aas/submodel-base/range-json-schema.d.ts +56 -2
  32. package/dist/aas/submodel-base/range-json-schema.d.ts.map +1 -1
  33. package/dist/aas/submodel-base/reference-element-json-schema.d.ts +112 -4
  34. package/dist/aas/submodel-base/reference-element-json-schema.d.ts.map +1 -1
  35. package/dist/aas/submodel-base/relationship-element-json-schema.d.ts +56 -2
  36. package/dist/aas/submodel-base/relationship-element-json-schema.d.ts.map +1 -1
  37. package/dist/aas/submodel-base/submodel-base-json-schema.d.ts +112 -4
  38. package/dist/aas/submodel-base/submodel-base-json-schema.d.ts.map +1 -1
  39. package/dist/aas/submodel-base/submodel-element-collection-json-schema.d.ts +232 -16
  40. package/dist/aas/submodel-base/submodel-element-collection-json-schema.d.ts.map +1 -1
  41. package/dist/aas/submodel-base/submodel-element-list-json-schema.d.ts +232 -16
  42. package/dist/aas/submodel-base/submodel-element-list-json-schema.d.ts.map +1 -1
  43. package/dist/aas/submodel-base/submodel-element-modification-schema.d.ts +56 -2
  44. package/dist/aas/submodel-base/submodel-element-modification-schema.d.ts.map +1 -1
  45. package/dist/aas/submodel-base/submodel-element-schema.d.ts +720 -45
  46. package/dist/aas/submodel-base/submodel-element-schema.d.ts.map +1 -1
  47. package/dist/aas/submodel-base/submodel-json-schema.d.ts +236 -20
  48. package/dist/aas/submodel-base/submodel-json-schema.d.ts.map +1 -1
  49. package/dist/activity-history/activity-history.dto.d.ts +28 -1
  50. package/dist/activity-history/activity-history.dto.d.ts.map +1 -1
  51. package/dist/digital-product-document/digital-product-document.schemas.d.ts +28 -1
  52. package/dist/digital-product-document/digital-product-document.schemas.d.ts.map +1 -1
  53. package/dist/index.d.ts +5 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +5 -0
  56. package/dist/passports/passport.dto.d.ts +112 -4
  57. package/dist/passports/passport.dto.d.ts.map +1 -1
  58. package/dist/permalinks/permalink.dto.d.ts +3718 -10
  59. package/dist/permalinks/permalink.dto.d.ts.map +1 -1
  60. package/dist/permalinks/permalink.dto.js +89 -6
  61. package/dist/shared/permalink-base-url.schema.d.ts +1 -0
  62. package/dist/shared/permalink-base-url.schema.d.ts.map +1 -1
  63. package/dist/shared/permalink-base-url.schema.js +9 -0
  64. package/dist/templates/template.dto.d.ts +112 -4
  65. package/dist/templates/template.dto.d.ts.map +1 -1
  66. package/dist/unique-product-identifiers/create-internal-unique-product-identifier.dto.d.ts +6 -0
  67. package/dist/unique-product-identifiers/create-internal-unique-product-identifier.dto.d.ts.map +1 -0
  68. package/dist/unique-product-identifiers/create-internal-unique-product-identifier.dto.js +9 -0
  69. package/dist/unique-product-identifiers/create-unique-product-identifier.dto.d.ts +9 -0
  70. package/dist/unique-product-identifiers/create-unique-product-identifier.dto.d.ts.map +1 -0
  71. package/dist/unique-product-identifiers/create-unique-product-identifier.dto.js +13 -0
  72. package/dist/unique-product-identifiers/gs1/gs1-ai-description.d.ts +6 -4
  73. package/dist/unique-product-identifiers/gs1/gs1-ai-description.d.ts.map +1 -1
  74. package/dist/unique-product-identifiers/gs1/gs1-ai-description.js +13 -3
  75. package/dist/unique-product-identifiers/gs1/gs1-digital-link.d.ts +10 -0
  76. package/dist/unique-product-identifiers/gs1/gs1-digital-link.d.ts.map +1 -1
  77. package/dist/unique-product-identifiers/gs1/gs1-digital-link.js +20 -6
  78. package/dist/unique-product-identifiers/unique-product-identifier-list-item.dto.d.ts +104 -0
  79. package/dist/unique-product-identifiers/unique-product-identifier-list-item.dto.d.ts.map +1 -0
  80. package/dist/unique-product-identifiers/unique-product-identifier-list-item.dto.js +42 -0
  81. package/dist/unique-product-identifiers/unique-product-identifier-type.d.ts +1 -1
  82. package/dist/unique-product-identifiers/update-unique-product-identifier.dto.d.ts +8 -0
  83. package/dist/unique-product-identifiers/update-unique-product-identifier.dto.d.ts.map +1 -0
  84. package/dist/unique-product-identifiers/update-unique-product-identifier.dto.js +12 -0
  85. package/dist/users/display-language.dto.d.ts +11 -0
  86. package/dist/users/display-language.dto.d.ts.map +1 -0
  87. package/dist/users/display-language.dto.js +9 -0
  88. package/dist/users/update-profile.dto.js +2 -2
  89. package/dist/users/user.dto.d.ts.map +1 -1
  90. package/dist/users/user.dto.js +2 -2
  91. package/package.json +1 -1
  92. package/src/aas/enums/language-enum.ts +41 -2
  93. package/src/index.ts +5 -0
  94. package/src/permalinks/permalink.dto.spec.ts +469 -0
  95. package/src/permalinks/permalink.dto.ts +103 -5
  96. package/src/shared/permalink-base-url.schema.spec.ts +17 -1
  97. package/src/shared/permalink-base-url.schema.ts +8 -0
  98. package/src/unique-product-identifiers/create-internal-unique-product-identifier.dto.ts +11 -0
  99. package/src/unique-product-identifiers/create-unique-product-identifier.dto.ts +15 -0
  100. package/src/unique-product-identifiers/gs1/gs1-ai-description.spec.ts +14 -0
  101. package/src/unique-product-identifiers/gs1/gs1-ai-description.ts +16 -5
  102. package/src/unique-product-identifiers/gs1/gs1-digital-link.spec.ts +16 -0
  103. package/src/unique-product-identifiers/gs1/gs1-digital-link.ts +22 -6
  104. package/src/unique-product-identifiers/unique-product-identifier-list-item.dto.ts +64 -0
  105. package/src/unique-product-identifiers/update-unique-product-identifier.dto.ts +14 -0
  106. package/src/users/display-language.dto.ts +9 -0
  107. package/src/users/update-profile.dto.spec.ts +1 -1
  108. package/src/users/update-profile.dto.ts +2 -2
  109. package/src/users/user.dto.ts +2 -2
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+
3
+ export const CreateInternalUniqueProductIdentifierRequestSchema = z
4
+ .object({
5
+ referenceId: z.uuid(),
6
+ })
7
+ .meta({ id: "CreateInternalUniqueProductIdentifierRequest" });
8
+
9
+ export type CreateInternalUniqueProductIdentifierRequest = z.infer<
10
+ typeof CreateInternalUniqueProductIdentifierRequestSchema
11
+ >;
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ import { Cset82ComponentInputSchema, GtinInputSchema } from "./gs1/gs1-digital-link";
3
+
4
+ export const CreateGs1UniqueProductIdentifierRequestSchema = z
5
+ .object({
6
+ referenceId: z.uuid(),
7
+ gtin: GtinInputSchema,
8
+ batch: Cset82ComponentInputSchema.optional(),
9
+ serial: Cset82ComponentInputSchema.optional(),
10
+ })
11
+ .meta({ id: "CreateGs1UniqueProductIdentifierRequest" });
12
+
13
+ export type CreateGs1UniqueProductIdentifierRequest = z.infer<
14
+ typeof CreateGs1UniqueProductIdentifierRequestSchema
15
+ >;
@@ -49,6 +49,20 @@ describe("getGs1AiDescription", () => {
49
49
  }
50
50
  });
51
51
 
52
+ it("accepts BCP 47 tags and casing variants (primary subtag wins)", () => {
53
+ expect(getGs1AiDescription("17", "de-DE")).toBe("Verfallsdatum (JJMMTT)");
54
+ expect(getGs1AiDescription("17", "DE")).toBe("Verfallsdatum (JJMMTT)");
55
+ expect(getGs1AiDescription("17", "de-CH")).toBe("Verfallsdatum (JJMMTT)");
56
+ });
57
+
58
+ it("falls back to English for languages not vendored", () => {
59
+ expect(getGs1AiDescription("17", "fr")).toBe("Expiration date (YYMMDD)");
60
+ expect(getGs1AiDescription("17", "fr-FR")).toBe("Expiration date (YYMMDD)");
61
+ expect(getGs1AiDescription("17", "")).toBe("Expiration date (YYMMDD)");
62
+ // Prototype names must not leak object internals as a "translation".
63
+ expect(getGs1AiDescription("17", "constructor")).toBe("Expiration date (YYMMDD)");
64
+ });
65
+
52
66
  it("returns undefined for unknown or non-AI input", () => {
53
67
  expect(getGs1AiDescription("0000", "en")).toBeUndefined();
54
68
  expect(getGs1AiDescription("", "en")).toBeUndefined();
@@ -1,4 +1,4 @@
1
- import { GS1_AI_I18N, type Gs1AiI18nLang } from "./gs1-ai-i18n";
1
+ import { GS1_AI_I18N, type Gs1AiI18nEntry } from "./gs1-ai-i18n";
2
2
 
3
3
  /** A syntactically valid GS1 Application Identifier: 2-4 digits. */
4
4
  const AI_SHAPE = /^\d{2,4}$/;
@@ -21,26 +21,37 @@ function candidateKeys(ai: string): string[] {
21
21
  return keys;
22
22
  }
23
23
 
24
+ /** Resolve a language cell by BCP 47 primary subtag, falling back to English. */
25
+ function pickLanguageCell(entry: Gs1AiI18nEntry, lang: string): string {
26
+ const primary = lang.split("-")[0]?.toLowerCase() ?? "";
27
+ // Own enumerable entries only — a tag like "constructor" must not reach the prototype.
28
+ const cell: string | undefined = Object.entries(entry).find(([key]) => key === primary)?.[1];
29
+ return cell ?? entry.en;
30
+ }
31
+
24
32
  /**
25
33
  * Resolve the translated description for a GS1 Application Identifier.
26
34
  *
27
35
  * Lookup chain: exact AI key -> family key ("n"/"s" collapse) -> "91-99"
28
- * range key; within the found row, the requested language falls back to
29
- * English (every vendored row carries English text).
36
+ * range key. `lang` accepts any BCP 47-ish tag ("de", "de-DE", "DE"); its
37
+ * primary subtag selects the vendored translation, and languages GS1 data
38
+ * doesn't carry fall back to English (every vendored row has English text).
39
+ * Which languages are vendored is an internal detail of this module — app
40
+ * display languages grow independently.
30
41
  *
31
42
  * Returns `undefined` for unknown AIs and non-AI input — callers fall back to
32
43
  * the English `title` from GS1_AI_TABLE as the last resort.
33
44
  *
34
45
  * Pure function, no I/O, no mutation.
35
46
  */
36
- export function getGs1AiDescription(ai: string, lang: Gs1AiI18nLang): string | undefined {
47
+ export function getGs1AiDescription(ai: string, lang: string): string | undefined {
37
48
  if (!AI_SHAPE.test(ai)) {
38
49
  return undefined;
39
50
  }
40
51
  for (const key of candidateKeys(ai)) {
41
52
  const entry = GS1_AI_I18N[key];
42
53
  if (entry !== undefined) {
43
- return entry[lang] ?? entry.en;
54
+ return pickLanguageCell(entry, lang);
44
55
  }
45
56
  }
46
57
  return undefined;
@@ -3,6 +3,7 @@ import { GS1_AI_TABLE, type Gs1AiTableEntry } from "./gs1-ai-table";
3
3
  import {
4
4
  buildGs1DataAttributeQuery,
5
5
  buildGs1DigitalLink,
6
+ buildGs1DigitalLinkPath,
6
7
  Cset82ComponentInputSchema,
7
8
  Cset82ComponentSchema,
8
9
  GS1_DATA_ATTRIBUTE_MAX_LENGTH,
@@ -113,6 +114,21 @@ describe("RFC 3986 canonical encoding", () => {
113
114
  });
114
115
  });
115
116
 
117
+ describe("buildGs1DigitalLinkPath", () => {
118
+ it("builds the base-less canonical path with normalization and encoding", () => {
119
+ expect(buildGs1DigitalLinkPath({ gtin: "4006381333931", batch: "LOT/1", serial: "SN-1" })).toBe(
120
+ "01/04006381333931/10/LOT%2F1/21/SN-1",
121
+ );
122
+ });
123
+
124
+ it("matches the path portion of buildGs1DigitalLink", () => {
125
+ const parts = { gtin: "04006381333931", batch: "B(1)", serial: "S:1" };
126
+ expect(buildGs1DigitalLink("https://r.example", parts)).toBe(
127
+ `https://r.example/${buildGs1DigitalLinkPath(parts)}`,
128
+ );
129
+ });
130
+ });
131
+
116
132
  describe("non-string input guards (plain-JS callers)", () => {
117
133
  it("isGs1DataAttributeAi rejects non-string AI keys", () => {
118
134
  expect(isGs1DataAttributeAi(17 as unknown as string)).toBe(false);
@@ -324,20 +324,36 @@ function normalizeOptionalComponent(
324
324
  * length / the dot-segment rule.
325
325
  */
326
326
  export function buildGs1DigitalLink(resolverBase: string, parts: Gs1DigitalLinkParts): string {
327
+ const base = canonicaliseBaseUrl(resolverBase);
328
+ let url = `${base}/${buildGs1DigitalLinkPath(parts)}`;
329
+ url += buildGs1DataAttributeQuery(parts.dataAttributes);
330
+ return url;
331
+ }
332
+
333
+ /**
334
+ * Build the base-less canonical GS1 Digital Link path
335
+ * `01/{gtin14}[/10/{batch}][/21/{serial}]` (no leading slash, no query string).
336
+ * Same normalization, validation, and percent-encoding as `buildGs1DigitalLink`;
337
+ * usable as an exact-match canonical value for a GS1 identity.
338
+ *
339
+ * @throws Error when the GTIN is invalid or a batch/serial violates CSET-82 /
340
+ * length / the dot-segment rule.
341
+ */
342
+ export function buildGs1DigitalLinkPath(
343
+ parts: Omit<Gs1DigitalLinkParts, "dataAttributes">,
344
+ ): string {
327
345
  const gtin14 = normalizeToGtin14(parts.gtin);
328
346
  const batch = normalizeOptionalComponent(parts.batch, "Batch");
329
347
  const serial = normalizeOptionalComponent(parts.serial, "Serial");
330
- const base = canonicaliseBaseUrl(resolverBase);
331
348
 
332
- let url = `${base}/${GS1_AI_GTIN}/${gtin14}`;
349
+ let path = `${GS1_AI_GTIN}/${gtin14}`;
333
350
  if (batch !== undefined) {
334
- url += `/${GS1_AI_BATCH}/${encodeRfc3986(batch)}`;
351
+ path += `/${GS1_AI_BATCH}/${encodeRfc3986(batch)}`;
335
352
  }
336
353
  if (serial !== undefined) {
337
- url += `/${GS1_AI_SERIAL}/${encodeRfc3986(serial)}`;
354
+ path += `/${GS1_AI_SERIAL}/${encodeRfc3986(serial)}`;
338
355
  }
339
- url += buildGs1DataAttributeQuery(parts.dataAttributes);
340
- return url;
356
+ return path;
341
357
  }
342
358
 
343
359
  /**
@@ -0,0 +1,64 @@
1
+ import { z } from "zod";
2
+ import {
3
+ Gs1GranularitySchema,
4
+ UniqueProductIdentifierTypeSchema,
5
+ } from "./unique-product-identifier-type";
6
+ import { Cset82ComponentSchema, Gtin14Schema } from "./gs1/gs1-digital-link";
7
+ import { PermalinkKindSchema } from "../permalinks/permalink.dto";
8
+ import { PagingMetadataDtoSchema } from "../shared/pagination.dto";
9
+
10
+ export const UniqueProductIdentifierPermalinkSummaryDtoSchema = z
11
+ .object({
12
+ id: z.uuid(),
13
+ kind: PermalinkKindSchema,
14
+ publicUrl: z.string().url(),
15
+ })
16
+ .meta({ id: "UniqueProductIdentifierPermalinkSummary" });
17
+
18
+ export type UniqueProductIdentifierPermalinkSummaryDto = z.infer<
19
+ typeof UniqueProductIdentifierPermalinkSummaryDtoSchema
20
+ >;
21
+
22
+ export const UniqueProductIdentifierListItemDtoSchema = z
23
+ .object({
24
+ uuid: z.uuid(),
25
+ referenceId: z.uuid(),
26
+ type: UniqueProductIdentifierTypeSchema,
27
+ gtin: Gtin14Schema.nullable(),
28
+ batch: Cset82ComponentSchema.nullish().overwrite((v) => v ?? null),
29
+ serial: Cset82ComponentSchema.nullable()
30
+ .nullish()
31
+ .overwrite((v) => v ?? null),
32
+ granularity: Gs1GranularitySchema.nullable(),
33
+ digitalLink: z
34
+ .string()
35
+ .url()
36
+ .nullish()
37
+ .overwrite((v) => v ?? null),
38
+ passportPublished: z.boolean(),
39
+ permalink: UniqueProductIdentifierPermalinkSummaryDtoSchema.nullish().overwrite(
40
+ (v) => v ?? null,
41
+ ),
42
+ })
43
+ .meta({ id: "UniqueProductIdentifierListItem" });
44
+
45
+ export type UniqueProductIdentifierListItemDto = z.infer<
46
+ typeof UniqueProductIdentifierListItemDtoSchema
47
+ >;
48
+
49
+ export const UniqueProductIdentifierListDtoSchema = z.array(
50
+ UniqueProductIdentifierListItemDtoSchema,
51
+ );
52
+
53
+ export type UniqueProductIdentifierListDto = z.infer<typeof UniqueProductIdentifierListDtoSchema>;
54
+
55
+ export const UniqueProductIdentifierPaginationDtoSchema = z
56
+ .object({
57
+ ...PagingMetadataDtoSchema.shape,
58
+ result: UniqueProductIdentifierListItemDtoSchema.array(),
59
+ })
60
+ .meta({ id: "UniqueProductIdentifiers" });
61
+
62
+ export type UniqueProductIdentifierPaginationDto = z.infer<
63
+ typeof UniqueProductIdentifierPaginationDtoSchema
64
+ >;
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import { Cset82ComponentInputSchema, GtinInputSchema } from "./gs1/gs1-digital-link";
3
+
4
+ export const UpdateGs1UniqueProductIdentifierRequestSchema = z
5
+ .object({
6
+ gtin: GtinInputSchema,
7
+ batch: Cset82ComponentInputSchema.optional(),
8
+ serial: Cset82ComponentInputSchema.optional(),
9
+ })
10
+ .meta({ id: "UpdateGs1UniqueProductIdentifierRequest" });
11
+
12
+ export type UpdateGs1UniqueProductIdentifierRequest = z.infer<
13
+ typeof UpdateGs1UniqueProductIdentifierRequestSchema
14
+ >;
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+
3
+ export const DisplayLanguage = {
4
+ en: "en",
5
+ de: "de",
6
+ } as const;
7
+
8
+ export const DisplayLanguageEnum = z.enum(DisplayLanguage);
9
+ export type DisplayLanguageType = z.infer<typeof DisplayLanguageEnum>;
@@ -58,7 +58,7 @@ describe("updateProfileDto", () => {
58
58
  });
59
59
 
60
60
  it("rejects an unsupported preferredLanguage", () => {
61
- const result = UpdateProfileDtoSchema.safeParse({ preferredLanguage: "fr" });
61
+ const result = UpdateProfileDtoSchema.safeParse({ preferredLanguage: "kl" });
62
62
  expect(result.success).toBe(false);
63
63
  });
64
64
 
@@ -1,12 +1,12 @@
1
1
  import { z } from "zod";
2
- import { LanguageEnum } from "../aas/enums/language-enum";
2
+ import { DisplayLanguageEnum } from "./display-language.dto";
3
3
 
4
4
  export const UpdateProfileDtoSchema = z.object({
5
5
  // Empty string is a valid "cleared name" — admin-invited users have firstName: "".
6
6
  // No .min(1): it would lock empty-name users out of saving any profile change.
7
7
  firstName: z.string().trim().max(100).optional(),
8
8
  lastName: z.string().trim().max(100).optional(),
9
- preferredLanguage: LanguageEnum.optional(),
9
+ preferredLanguage: DisplayLanguageEnum.optional(),
10
10
  });
11
11
 
12
12
  export type UpdateProfileDto = z.infer<typeof UpdateProfileDtoSchema>;
@@ -1,5 +1,5 @@
1
- import { LanguageEnum } from "../aas/enums/language-enum";
2
1
  import { z } from "zod";
2
+ import { DisplayLanguageEnum } from "./display-language.dto";
3
3
 
4
4
  export const UserDtoSchema = z.object({
5
5
  id: z.string(),
@@ -9,7 +9,7 @@ export const UserDtoSchema = z.object({
9
9
  name: z.string().nullable(),
10
10
  image: z.string().nullable(),
11
11
  emailVerified: z.boolean(),
12
- preferredLanguage: LanguageEnum,
12
+ preferredLanguage: DisplayLanguageEnum,
13
13
  createdAt: z.coerce.date(),
14
14
  updatedAt: z.coerce.date(),
15
15
  });