@api-client/core 0.15.1 → 0.16.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 (126) hide show
  1. package/TESTING_READY.md +114 -0
  2. package/TESTING_SETUP.md +198 -0
  3. package/build/src/modeling/Semantics.d.ts +126 -2
  4. package/build/src/modeling/Semantics.d.ts.map +1 -1
  5. package/build/src/modeling/Semantics.js +281 -13
  6. package/build/src/modeling/Semantics.js.map +1 -1
  7. package/build/src/modeling/definitions/Calculated.d.ts +54 -0
  8. package/build/src/modeling/definitions/Calculated.d.ts.map +1 -0
  9. package/build/src/modeling/definitions/Calculated.js +31 -0
  10. package/build/src/modeling/definitions/Calculated.js.map +1 -0
  11. package/build/src/modeling/definitions/Categories.d.ts +60 -0
  12. package/build/src/modeling/definitions/Categories.d.ts.map +1 -0
  13. package/build/src/modeling/definitions/Categories.js +33 -0
  14. package/build/src/modeling/definitions/Categories.js.map +1 -0
  15. package/build/src/modeling/definitions/Derived.d.ts +54 -0
  16. package/build/src/modeling/definitions/Derived.d.ts.map +1 -0
  17. package/build/src/modeling/definitions/Derived.js +31 -0
  18. package/build/src/modeling/definitions/Derived.js.map +1 -0
  19. package/build/src/modeling/definitions/Description.d.ts +36 -0
  20. package/build/src/modeling/definitions/Description.d.ts.map +1 -0
  21. package/build/src/modeling/definitions/Description.js +28 -0
  22. package/build/src/modeling/definitions/Description.js.map +1 -0
  23. package/build/src/modeling/definitions/Email.d.ts +66 -0
  24. package/build/src/modeling/definitions/Email.d.ts.map +1 -0
  25. package/build/src/modeling/definitions/Email.js +33 -0
  26. package/build/src/modeling/definitions/Email.js.map +1 -0
  27. package/build/src/modeling/definitions/GeospatialCoordinates.d.ts +212 -0
  28. package/build/src/modeling/definitions/GeospatialCoordinates.d.ts.map +1 -0
  29. package/build/src/modeling/definitions/GeospatialCoordinates.js +129 -0
  30. package/build/src/modeling/definitions/GeospatialCoordinates.js.map +1 -0
  31. package/build/src/modeling/definitions/HTML.d.ts +88 -0
  32. package/build/src/modeling/definitions/HTML.d.ts.map +1 -0
  33. package/build/src/modeling/definitions/HTML.js +42 -0
  34. package/build/src/modeling/definitions/HTML.js.map +1 -0
  35. package/build/src/modeling/definitions/Markdown.d.ts +84 -0
  36. package/build/src/modeling/definitions/Markdown.d.ts.map +1 -0
  37. package/build/src/modeling/definitions/Markdown.js +41 -0
  38. package/build/src/modeling/definitions/Markdown.js.map +1 -0
  39. package/build/src/modeling/definitions/Password.d.ts +112 -0
  40. package/build/src/modeling/definitions/Password.d.ts.map +1 -0
  41. package/build/src/modeling/definitions/Password.js +57 -0
  42. package/build/src/modeling/definitions/Password.js.map +1 -0
  43. package/build/src/modeling/definitions/Phone.d.ts +83 -0
  44. package/build/src/modeling/definitions/Phone.d.ts.map +1 -0
  45. package/build/src/modeling/definitions/Phone.js +39 -0
  46. package/build/src/modeling/definitions/Phone.js.map +1 -0
  47. package/build/src/modeling/definitions/Price.d.ts +102 -0
  48. package/build/src/modeling/definitions/Price.d.ts.map +1 -0
  49. package/build/src/modeling/definitions/Price.js +99 -0
  50. package/build/src/modeling/definitions/Price.js.map +1 -0
  51. package/build/src/modeling/definitions/PublicUniqueName.d.ts +69 -0
  52. package/build/src/modeling/definitions/PublicUniqueName.d.ts.map +1 -0
  53. package/build/src/modeling/definitions/PublicUniqueName.js +34 -0
  54. package/build/src/modeling/definitions/PublicUniqueName.js.map +1 -0
  55. package/build/src/modeling/definitions/SKU.d.ts +127 -0
  56. package/build/src/modeling/definitions/SKU.d.ts.map +1 -0
  57. package/build/src/modeling/definitions/SKU.js +142 -0
  58. package/build/src/modeling/definitions/SKU.js.map +1 -0
  59. package/build/src/modeling/definitions/Status.d.ts +150 -0
  60. package/build/src/modeling/definitions/Status.d.ts.map +1 -0
  61. package/build/src/modeling/definitions/Status.js +60 -0
  62. package/build/src/modeling/definitions/Status.js.map +1 -0
  63. package/build/src/modeling/definitions/Summary.d.ts +53 -0
  64. package/build/src/modeling/definitions/Summary.d.ts.map +1 -0
  65. package/build/src/modeling/definitions/Summary.js +50 -0
  66. package/build/src/modeling/definitions/Summary.js.map +1 -0
  67. package/build/src/modeling/definitions/Tags.d.ts +52 -0
  68. package/build/src/modeling/definitions/Tags.d.ts.map +1 -0
  69. package/build/src/modeling/definitions/Tags.js +32 -0
  70. package/build/src/modeling/definitions/Tags.js.map +1 -0
  71. package/build/src/modeling/definitions/URL.d.ts +68 -0
  72. package/build/src/modeling/definitions/URL.d.ts.map +1 -0
  73. package/build/src/modeling/definitions/URL.js +37 -0
  74. package/build/src/modeling/definitions/URL.js.map +1 -0
  75. package/build/src/modeling/validation/semantic_validation.d.ts +4 -0
  76. package/build/src/modeling/validation/semantic_validation.d.ts.map +1 -1
  77. package/build/src/modeling/validation/semantic_validation.js +32 -1
  78. package/build/src/modeling/validation/semantic_validation.js.map +1 -1
  79. package/build/tsconfig.tsbuildinfo +1 -1
  80. package/data/models/example-generator-api.json +11 -11
  81. package/package.json +1 -1
  82. package/src/modeling/Semantics.ts +297 -14
  83. package/src/modeling/definitions/Calculated.ts +76 -0
  84. package/src/modeling/definitions/Categories.ts +84 -0
  85. package/src/modeling/definitions/Derived.ts +76 -0
  86. package/src/modeling/definitions/Description.ts +55 -0
  87. package/src/modeling/definitions/Email.ts +90 -0
  88. package/src/modeling/definitions/GeospatialCoordinates.ts +274 -0
  89. package/src/modeling/definitions/HTML.ts +121 -0
  90. package/src/modeling/definitions/Markdown.ts +116 -0
  91. package/src/modeling/definitions/Password.ts +156 -0
  92. package/src/modeling/definitions/Phone.ts +116 -0
  93. package/src/modeling/definitions/Price.examples.md +158 -0
  94. package/src/modeling/definitions/Price.ts +180 -0
  95. package/src/modeling/definitions/PublicUniqueName.ts +98 -0
  96. package/src/modeling/definitions/SKU.examples.md +230 -0
  97. package/src/modeling/definitions/SKU.ts +254 -0
  98. package/src/modeling/definitions/Status.ts +227 -0
  99. package/src/modeling/definitions/Summary.ts +73 -0
  100. package/src/modeling/definitions/Tags.ts +75 -0
  101. package/src/modeling/definitions/URL.ts +96 -0
  102. package/src/modeling/validation/semantic_validation.ts +35 -1
  103. package/tests/example-test-setup.ts +133 -0
  104. package/tests/template-node.spec.ts +75 -0
  105. package/tests/test-utils.ts +293 -0
  106. package/tests/unit/modeling/definitions/calculated.spec.ts +33 -0
  107. package/tests/unit/modeling/definitions/categories.spec.ts +38 -0
  108. package/tests/unit/modeling/definitions/derived.spec.ts +34 -0
  109. package/tests/unit/modeling/definitions/description.spec.ts +38 -0
  110. package/tests/unit/modeling/definitions/email.spec.ts +38 -0
  111. package/tests/unit/modeling/definitions/geospatial-coordinates.spec.ts +41 -0
  112. package/tests/unit/modeling/definitions/html.spec.ts +38 -0
  113. package/tests/unit/modeling/definitions/markdown.spec.ts +38 -0
  114. package/tests/unit/modeling/definitions/password.spec.ts +347 -0
  115. package/tests/unit/modeling/definitions/phone.spec.ts +38 -0
  116. package/tests/unit/modeling/definitions/price.spec.ts +465 -0
  117. package/tests/unit/modeling/definitions/public-unique-name.spec.ts +38 -0
  118. package/tests/unit/modeling/definitions/sku.spec.ts +240 -0
  119. package/tests/unit/modeling/definitions/status.spec.ts +37 -0
  120. package/tests/unit/modeling/definitions/summary.spec.ts +36 -0
  121. package/tests/unit/modeling/definitions/tags.spec.ts +38 -0
  122. package/tests/unit/modeling/definitions/url.spec.ts +38 -0
  123. package/tests/unit/modeling/domain_property.spec.ts +106 -0
  124. package/tests/unit/modeling/domain_validation.spec.ts +5 -5
  125. package/tests/unit/modeling/semantic-configs.spec.ts +569 -0
  126. package/tests/unit/modeling/semantics.spec.ts +52 -0
@@ -0,0 +1,83 @@
1
+ import type { AppliedDataSemantic } from '../Semantics.js';
2
+ import { SemanticType } from '../Semantics.js';
3
+ /**
4
+ * Configuration options for the Phone semantic.
5
+ * Controls validation, formatting, and verification of phone numbers.
6
+ */
7
+ export interface PhoneConfig {
8
+ /**
9
+ * List of allowed country codes (ISO 3166-1 alpha-2 format).
10
+ * If not specified, all countries are allowed.
11
+ * Examples: ['US', 'CA', 'GB', 'DE']
12
+ */
13
+ allowedCountries?: string[];
14
+ /**
15
+ * Whether the phone number must include a country code.
16
+ * Defaults to true for E.164 format.
17
+ */
18
+ requireCountryCode?: boolean;
19
+ /**
20
+ * Format for phone number validation and display.
21
+ * - 'E.164': International format with + prefix (e.g., +1234567890)
22
+ * - 'national': Country-specific format without country code
23
+ * - 'international': International format with country code
24
+ * - 'custom': Use customFormat pattern
25
+ */
26
+ format?: 'E.164' | 'national' | 'international' | 'custom';
27
+ /**
28
+ * Custom format pattern for phone number validation.
29
+ * Only used when format is set to 'custom'.
30
+ * Examples: '###-###-####', '(###) ###-####'
31
+ */
32
+ customFormat?: string;
33
+ /**
34
+ * Whether to allow phone extensions (e.g., +1234567890 ext 123).
35
+ * Defaults to false.
36
+ */
37
+ allowExtension?: boolean;
38
+ /**
39
+ * Whether phone number verification is required.
40
+ * Defaults to false.
41
+ */
42
+ requireVerification?: boolean;
43
+ /**
44
+ * Method to use for phone verification.
45
+ * - 'sms': Send verification code via SMS
46
+ * - 'call': Make verification call
47
+ * - 'none': No verification required
48
+ */
49
+ verificationMethod?: 'sms' | 'call' | 'none';
50
+ /**
51
+ * Custom metadata for the phone field.
52
+ */
53
+ metadata?: Record<string, unknown>;
54
+ /**
55
+ * Index signature to allow additional properties.
56
+ */
57
+ [key: string]: unknown;
58
+ }
59
+ /**
60
+ * Type-safe configuration for Phone semantic.
61
+ */
62
+ export interface AppliedPhoneSemantic extends AppliedDataSemantic {
63
+ id: SemanticType.Phone;
64
+ config?: PhoneConfig;
65
+ }
66
+ /**
67
+ * Type guard to check if a semantic is a Phone semantic.
68
+ * @param semantic - The semantic to check
69
+ * @returns True if the semantic is a Phone semantic
70
+ */
71
+ export declare const isPhoneSemantic: (semantic: AppliedDataSemantic) => semantic is AppliedPhoneSemantic;
72
+ /**
73
+ * Helper function to create a Phone semantic with configuration.
74
+ * @param config - Configuration options for the phone semantic
75
+ * @returns AppliedPhoneSemantic with the specified configuration
76
+ */
77
+ export declare const createPhoneSemantic: (config?: PhoneConfig) => AppliedPhoneSemantic;
78
+ /**
79
+ * Default configuration for Phone semantic.
80
+ * Uses E.164 format with country code required and SMS verification.
81
+ */
82
+ export declare const DEFAULT_PHONE_CONFIG: PhoneConfig;
83
+ //# sourceMappingURL=Phone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Phone.d.ts","sourceRoot":"","sources":["../../../../src/modeling/definitions/Phone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE3B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAE5B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,eAAe,GAAG,QAAQ,CAAA;IAE1D;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IAExB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAE7B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;IAE5C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAElC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,EAAE,EAAE,YAAY,CAAC,KAAK,CAAA;IACtB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,mBAAmB,KAAG,QAAQ,IAAI,oBAE3E,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAQ,WAAgB,KAAG,oBAa9D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAMlC,CAAA"}
@@ -0,0 +1,39 @@
1
+ import { SemanticType } from '../Semantics.js';
2
+ /**
3
+ * Type guard to check if a semantic is a Phone semantic.
4
+ * @param semantic - The semantic to check
5
+ * @returns True if the semantic is a Phone semantic
6
+ */
7
+ export const isPhoneSemantic = (semantic) => {
8
+ return semantic.id === SemanticType.Phone;
9
+ };
10
+ /**
11
+ * Helper function to create a Phone semantic with configuration.
12
+ * @param config - Configuration options for the phone semantic
13
+ * @returns AppliedPhoneSemantic with the specified configuration
14
+ */
15
+ export const createPhoneSemantic = (config = {}) => {
16
+ const mergedConfig = {
17
+ ...DEFAULT_PHONE_CONFIG,
18
+ ...config,
19
+ };
20
+ if (config.metadata) {
21
+ mergedConfig.metadata = { ...config.metadata };
22
+ }
23
+ return {
24
+ id: SemanticType.Phone,
25
+ config: mergedConfig,
26
+ };
27
+ };
28
+ /**
29
+ * Default configuration for Phone semantic.
30
+ * Uses E.164 format with country code required and SMS verification.
31
+ */
32
+ export const DEFAULT_PHONE_CONFIG = {
33
+ requireCountryCode: true,
34
+ format: 'E.164',
35
+ allowExtension: false,
36
+ requireVerification: false,
37
+ verificationMethod: 'sms',
38
+ };
39
+ //# sourceMappingURL=Phone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Phone.js","sourceRoot":"","sources":["../../../../src/modeling/definitions/Phone.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AA2E9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAA6B,EAAoC,EAAE;IACjG,OAAO,QAAQ,CAAC,EAAE,KAAK,YAAY,CAAC,KAAK,CAAA;AAC3C,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAsB,EAAE,EAAwB,EAAE;IACpF,MAAM,YAAY,GAAG;QACnB,GAAG,oBAAoB;QACvB,GAAG,MAAM;KACV,CAAA;IACD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,YAAY,CAAC,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAChD,CAAC;IAED,OAAO;QACL,EAAE,EAAE,YAAY,CAAC,KAAK;QACtB,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,kBAAkB,EAAE,IAAI;IACxB,MAAM,EAAE,OAAO;IACf,cAAc,EAAE,KAAK;IACrB,mBAAmB,EAAE,KAAK;IAC1B,kBAAkB,EAAE,KAAK;CAC1B,CAAA","sourcesContent":["import type { AppliedDataSemantic } from '../Semantics.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Configuration options for the Phone semantic.\n * Controls validation, formatting, and verification of phone numbers.\n */\nexport interface PhoneConfig {\n /**\n * List of allowed country codes (ISO 3166-1 alpha-2 format).\n * If not specified, all countries are allowed.\n * Examples: ['US', 'CA', 'GB', 'DE']\n */\n allowedCountries?: string[]\n\n /**\n * Whether the phone number must include a country code.\n * Defaults to true for E.164 format.\n */\n requireCountryCode?: boolean\n\n /**\n * Format for phone number validation and display.\n * - 'E.164': International format with + prefix (e.g., +1234567890)\n * - 'national': Country-specific format without country code\n * - 'international': International format with country code\n * - 'custom': Use customFormat pattern\n */\n format?: 'E.164' | 'national' | 'international' | 'custom'\n\n /**\n * Custom format pattern for phone number validation.\n * Only used when format is set to 'custom'.\n * Examples: '###-###-####', '(###) ###-####'\n */\n customFormat?: string\n\n /**\n * Whether to allow phone extensions (e.g., +1234567890 ext 123).\n * Defaults to false.\n */\n allowExtension?: boolean\n\n /**\n * Whether phone number verification is required.\n * Defaults to false.\n */\n requireVerification?: boolean\n\n /**\n * Method to use for phone verification.\n * - 'sms': Send verification code via SMS\n * - 'call': Make verification call\n * - 'none': No verification required\n */\n verificationMethod?: 'sms' | 'call' | 'none'\n\n /**\n * Custom metadata for the phone field.\n */\n metadata?: Record<string, unknown>\n\n /**\n * Index signature to allow additional properties.\n */\n [key: string]: unknown\n}\n\n/**\n * Type-safe configuration for Phone semantic.\n */\nexport interface AppliedPhoneSemantic extends AppliedDataSemantic {\n id: SemanticType.Phone\n config?: PhoneConfig\n}\n\n/**\n * Type guard to check if a semantic is a Phone semantic.\n * @param semantic - The semantic to check\n * @returns True if the semantic is a Phone semantic\n */\nexport const isPhoneSemantic = (semantic: AppliedDataSemantic): semantic is AppliedPhoneSemantic => {\n return semantic.id === SemanticType.Phone\n}\n\n/**\n * Helper function to create a Phone semantic with configuration.\n * @param config - Configuration options for the phone semantic\n * @returns AppliedPhoneSemantic with the specified configuration\n */\nexport const createPhoneSemantic = (config: PhoneConfig = {}): AppliedPhoneSemantic => {\n const mergedConfig = {\n ...DEFAULT_PHONE_CONFIG,\n ...config,\n }\n if (config.metadata) {\n mergedConfig.metadata = { ...config.metadata }\n }\n\n return {\n id: SemanticType.Phone,\n config: mergedConfig,\n }\n}\n\n/**\n * Default configuration for Phone semantic.\n * Uses E.164 format with country code required and SMS verification.\n */\nexport const DEFAULT_PHONE_CONFIG: PhoneConfig = {\n requireCountryCode: true,\n format: 'E.164',\n allowExtension: false,\n requireVerification: false,\n verificationMethod: 'sms',\n}\n"]}
@@ -0,0 +1,102 @@
1
+ import type { AppliedDataSemantic } from '../Semantics.js';
2
+ import { SemanticType } from '../Semantics.js';
3
+ /**
4
+ * Supported storage formats for monetary values.
5
+ */
6
+ export type PriceStorageFormat = 'decimal' | 'integer_cents' | 'complex_object';
7
+ /**
8
+ * Configuration options for the Price semantic.
9
+ * Controls monetary value storage, validation, currency handling, and precision.
10
+ */
11
+ export interface PriceConfig {
12
+ /**
13
+ * How the monetary value is stored in the database.
14
+ *
15
+ * - 'decimal': Store as DECIMAL/NUMERIC type (e.g., 19.99)
16
+ * - 'integer_cents': Store as INTEGER in smallest currency unit (e.g., 1999 for $19.99)
17
+ * - 'complex_object': Store as JSON/JSONB with amount and currency (e.g., {"amount": 1999, "currency": "USD"})
18
+ */
19
+ storageFormat?: PriceStorageFormat;
20
+ /**
21
+ * Default currency code (ISO 4217) when not specified.
22
+ * Required when using 'decimal' or 'integer_cents' format.
23
+ */
24
+ defaultCurrency?: string;
25
+ /**
26
+ * List of allowed currency codes (ISO 4217).
27
+ * If not specified, all valid ISO 4217 currencies are allowed.
28
+ */
29
+ allowedCurrencies?: string[];
30
+ /**
31
+ * Number of decimal places for precision.
32
+ * Default: 2 (for most currencies like USD, EUR)
33
+ * Some currencies may need 0 (JPY, KRW) or 3 (BHD, KWD)
34
+ */
35
+ decimalPlaces?: number;
36
+ /**
37
+ * Whether negative values are allowed (for refunds, discounts, etc.).
38
+ */
39
+ allowNegative?: boolean;
40
+ /**
41
+ * Whether to automatically validate currency codes against ISO 4217.
42
+ */
43
+ validateCurrencyCode?: boolean;
44
+ /**
45
+ * Custom metadata for the price field.
46
+ */
47
+ metadata?: Record<string, unknown>;
48
+ /**
49
+ * Index signature to allow additional properties.
50
+ */
51
+ [key: string]: unknown;
52
+ }
53
+ /**
54
+ * Type-safe configuration for Price semantic.
55
+ */
56
+ export interface AppliedPriceSemantic extends AppliedDataSemantic {
57
+ id: SemanticType.Price;
58
+ config?: PriceConfig;
59
+ }
60
+ /**
61
+ * Type guard to check if a semantic is a Price semantic.
62
+ */
63
+ export declare const isPriceSemantic: (semantic: AppliedDataSemantic) => semantic is AppliedPriceSemantic;
64
+ /**
65
+ * Helper function to create a Price semantic with configuration.
66
+ */
67
+ export declare const createPriceSemantic: (config?: PriceConfig) => AppliedPriceSemantic;
68
+ /**
69
+ * Default configuration for Price semantic.
70
+ * Optimized for common e-commerce use cases with USD currency.
71
+ */
72
+ export declare const DEFAULT_PRICE_CONFIG: PriceConfig;
73
+ /**
74
+ * Predefined configurations for common use cases.
75
+ */
76
+ export declare const PRICE_PRESETS: {
77
+ /**
78
+ * Simple USD decimal storage - good for most e-commerce sites.
79
+ */
80
+ readonly USD_DECIMAL: AppliedPriceSemantic;
81
+ /**
82
+ * Integer cents storage - avoids floating point issues, good for financial calculations.
83
+ */
84
+ readonly USD_CENTS: AppliedPriceSemantic;
85
+ /**
86
+ * Multi-currency support with complex object storage.
87
+ */
88
+ readonly MULTI_CURRENCY: AppliedPriceSemantic;
89
+ /**
90
+ * Configuration that allows negative values for refunds, discounts, etc.
91
+ */
92
+ readonly WITH_NEGATIVES: AppliedPriceSemantic;
93
+ /**
94
+ * High-precision configuration for cryptocurrency or precious metals.
95
+ */
96
+ readonly HIGH_PRECISION: AppliedPriceSemantic;
97
+ };
98
+ /**
99
+ * Helper function to validate a price configuration.
100
+ */
101
+ export declare const validatePriceConfig: (config: PriceConfig) => string[];
102
+ //# sourceMappingURL=Price.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Price.d.ts","sourceRoot":"","sources":["../../../../src/modeling/definitions/Price.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,eAAe,GAAG,gBAAgB,CAAA;AAE/E;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAA;IAElC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IAEvB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAE9B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAElC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,EAAE,EAAE,YAAY,CAAC,KAAK,CAAA;IACtB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,mBAAmB,KAAG,QAAQ,IAAI,oBAE3E,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAQ,WAAgB,KAAG,oBAe9D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAMlC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;;IAQH;;OAEG;;IAQH;;OAEG;;IAQH;;OAEG;;IAQH;;OAEG;;CAOK,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,WAAW,KAAG,MAAM,EAY/D,CAAA"}
@@ -0,0 +1,99 @@
1
+ import { SemanticType } from '../Semantics.js';
2
+ /**
3
+ * Type guard to check if a semantic is a Price semantic.
4
+ */
5
+ export const isPriceSemantic = (semantic) => {
6
+ return semantic.id === SemanticType.Price;
7
+ };
8
+ /**
9
+ * Helper function to create a Price semantic with configuration.
10
+ */
11
+ export const createPriceSemantic = (config = {}) => {
12
+ const mergedConfig = {
13
+ ...DEFAULT_PRICE_CONFIG,
14
+ ...config,
15
+ };
16
+ // Merge metadata separately
17
+ if (config.metadata) {
18
+ mergedConfig.metadata = { ...config.metadata };
19
+ }
20
+ return {
21
+ id: SemanticType.Price,
22
+ config: mergedConfig,
23
+ };
24
+ };
25
+ /**
26
+ * Default configuration for Price semantic.
27
+ * Optimized for common e-commerce use cases with USD currency.
28
+ */
29
+ export const DEFAULT_PRICE_CONFIG = {
30
+ storageFormat: 'decimal',
31
+ defaultCurrency: 'USD',
32
+ decimalPlaces: 2,
33
+ allowNegative: false,
34
+ validateCurrencyCode: true,
35
+ };
36
+ /**
37
+ * Predefined configurations for common use cases.
38
+ */
39
+ export const PRICE_PRESETS = {
40
+ /**
41
+ * Simple USD decimal storage - good for most e-commerce sites.
42
+ */
43
+ USD_DECIMAL: createPriceSemantic({
44
+ storageFormat: 'decimal',
45
+ defaultCurrency: 'USD',
46
+ decimalPlaces: 2,
47
+ allowNegative: false,
48
+ }),
49
+ /**
50
+ * Integer cents storage - avoids floating point issues, good for financial calculations.
51
+ */
52
+ USD_CENTS: createPriceSemantic({
53
+ storageFormat: 'integer_cents',
54
+ defaultCurrency: 'USD',
55
+ decimalPlaces: 2,
56
+ allowNegative: false,
57
+ }),
58
+ /**
59
+ * Multi-currency support with complex object storage.
60
+ */
61
+ MULTI_CURRENCY: createPriceSemantic({
62
+ storageFormat: 'complex_object',
63
+ allowedCurrencies: ['USD', 'EUR', 'GBP', 'JPY', 'CAD'],
64
+ decimalPlaces: 2,
65
+ allowNegative: false,
66
+ }),
67
+ /**
68
+ * Configuration that allows negative values for refunds, discounts, etc.
69
+ */
70
+ WITH_NEGATIVES: createPriceSemantic({
71
+ storageFormat: 'decimal',
72
+ defaultCurrency: 'USD',
73
+ decimalPlaces: 2,
74
+ allowNegative: true,
75
+ }),
76
+ /**
77
+ * High-precision configuration for cryptocurrency or precious metals.
78
+ */
79
+ HIGH_PRECISION: createPriceSemantic({
80
+ storageFormat: 'decimal',
81
+ defaultCurrency: 'BTC',
82
+ decimalPlaces: 8,
83
+ allowNegative: false,
84
+ }),
85
+ };
86
+ /**
87
+ * Helper function to validate a price configuration.
88
+ */
89
+ export const validatePriceConfig = (config) => {
90
+ const errors = [];
91
+ if (config.storageFormat !== 'complex_object' && !config.defaultCurrency) {
92
+ errors.push('defaultCurrency is required when storageFormat is not complex_object');
93
+ }
94
+ if (config.decimalPlaces !== undefined && config.decimalPlaces < 0) {
95
+ errors.push('decimalPlaces must be non-negative');
96
+ }
97
+ return errors;
98
+ };
99
+ //# sourceMappingURL=Price.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Price.js","sourceRoot":"","sources":["../../../../src/modeling/definitions/Price.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAqE9C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAA6B,EAAoC,EAAE;IACjG,OAAO,QAAQ,CAAC,EAAE,KAAK,YAAY,CAAC,KAAK,CAAA;AAC3C,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAsB,EAAE,EAAwB,EAAE;IACpF,MAAM,YAAY,GAAG;QACnB,GAAG,oBAAoB;QACvB,GAAG,MAAM;KACV,CAAA;IAED,4BAA4B;IAC5B,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,YAAY,CAAC,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAChD,CAAC;IAED,OAAO;QACL,EAAE,EAAE,YAAY,CAAC,KAAK;QACtB,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,KAAK;IACtB,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,KAAK;IACpB,oBAAoB,EAAE,IAAI;CAC3B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;;OAEG;IACH,WAAW,EAAE,mBAAmB,CAAC;QAC/B,aAAa,EAAE,SAAS;QACxB,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,KAAK;KACrB,CAAC;IAEF;;OAEG;IACH,SAAS,EAAE,mBAAmB,CAAC;QAC7B,aAAa,EAAE,eAAe;QAC9B,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,KAAK;KACrB,CAAC;IAEF;;OAEG;IACH,cAAc,EAAE,mBAAmB,CAAC;QAClC,aAAa,EAAE,gBAAgB;QAC/B,iBAAiB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;QACtD,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,KAAK;KACrB,CAAC;IAEF;;OAEG;IACH,cAAc,EAAE,mBAAmB,CAAC;QAClC,aAAa,EAAE,SAAS;QACxB,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,IAAI;KACpB,CAAC;IAEF;;OAEG;IACH,cAAc,EAAE,mBAAmB,CAAC;QAClC,aAAa,EAAE,SAAS;QACxB,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,KAAK;KACrB,CAAC;CACM,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAmB,EAAY,EAAE;IACnE,MAAM,MAAM,GAAa,EAAE,CAAA;IAE3B,IAAI,MAAM,CAAC,aAAa,KAAK,gBAAgB,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAA;IACrF,CAAC;IAED,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,IAAI,MAAM,CAAC,aAAa,GAAG,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAA;IACnD,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import type { AppliedDataSemantic } from '../Semantics.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Supported storage formats for monetary values.\n */\nexport type PriceStorageFormat = 'decimal' | 'integer_cents' | 'complex_object'\n\n/**\n * Configuration options for the Price semantic.\n * Controls monetary value storage, validation, currency handling, and precision.\n */\nexport interface PriceConfig {\n /**\n * How the monetary value is stored in the database.\n *\n * - 'decimal': Store as DECIMAL/NUMERIC type (e.g., 19.99)\n * - 'integer_cents': Store as INTEGER in smallest currency unit (e.g., 1999 for $19.99)\n * - 'complex_object': Store as JSON/JSONB with amount and currency (e.g., {\"amount\": 1999, \"currency\": \"USD\"})\n */\n storageFormat?: PriceStorageFormat\n\n /**\n * Default currency code (ISO 4217) when not specified.\n * Required when using 'decimal' or 'integer_cents' format.\n */\n defaultCurrency?: string\n\n /**\n * List of allowed currency codes (ISO 4217).\n * If not specified, all valid ISO 4217 currencies are allowed.\n */\n allowedCurrencies?: string[]\n\n /**\n * Number of decimal places for precision.\n * Default: 2 (for most currencies like USD, EUR)\n * Some currencies may need 0 (JPY, KRW) or 3 (BHD, KWD)\n */\n decimalPlaces?: number\n\n /**\n * Whether negative values are allowed (for refunds, discounts, etc.).\n */\n allowNegative?: boolean\n\n /**\n * Whether to automatically validate currency codes against ISO 4217.\n */\n validateCurrencyCode?: boolean\n\n /**\n * Custom metadata for the price field.\n */\n metadata?: Record<string, unknown>\n\n /**\n * Index signature to allow additional properties.\n */\n [key: string]: unknown\n}\n\n/**\n * Type-safe configuration for Price semantic.\n */\nexport interface AppliedPriceSemantic extends AppliedDataSemantic {\n id: SemanticType.Price\n config?: PriceConfig\n}\n\n/**\n * Type guard to check if a semantic is a Price semantic.\n */\nexport const isPriceSemantic = (semantic: AppliedDataSemantic): semantic is AppliedPriceSemantic => {\n return semantic.id === SemanticType.Price\n}\n\n/**\n * Helper function to create a Price semantic with configuration.\n */\nexport const createPriceSemantic = (config: PriceConfig = {}): AppliedPriceSemantic => {\n const mergedConfig = {\n ...DEFAULT_PRICE_CONFIG,\n ...config,\n }\n\n // Merge metadata separately\n if (config.metadata) {\n mergedConfig.metadata = { ...config.metadata }\n }\n\n return {\n id: SemanticType.Price,\n config: mergedConfig,\n }\n}\n\n/**\n * Default configuration for Price semantic.\n * Optimized for common e-commerce use cases with USD currency.\n */\nexport const DEFAULT_PRICE_CONFIG: PriceConfig = {\n storageFormat: 'decimal',\n defaultCurrency: 'USD',\n decimalPlaces: 2,\n allowNegative: false,\n validateCurrencyCode: true,\n}\n\n/**\n * Predefined configurations for common use cases.\n */\nexport const PRICE_PRESETS = {\n /**\n * Simple USD decimal storage - good for most e-commerce sites.\n */\n USD_DECIMAL: createPriceSemantic({\n storageFormat: 'decimal',\n defaultCurrency: 'USD',\n decimalPlaces: 2,\n allowNegative: false,\n }),\n\n /**\n * Integer cents storage - avoids floating point issues, good for financial calculations.\n */\n USD_CENTS: createPriceSemantic({\n storageFormat: 'integer_cents',\n defaultCurrency: 'USD',\n decimalPlaces: 2,\n allowNegative: false,\n }),\n\n /**\n * Multi-currency support with complex object storage.\n */\n MULTI_CURRENCY: createPriceSemantic({\n storageFormat: 'complex_object',\n allowedCurrencies: ['USD', 'EUR', 'GBP', 'JPY', 'CAD'],\n decimalPlaces: 2,\n allowNegative: false,\n }),\n\n /**\n * Configuration that allows negative values for refunds, discounts, etc.\n */\n WITH_NEGATIVES: createPriceSemantic({\n storageFormat: 'decimal',\n defaultCurrency: 'USD',\n decimalPlaces: 2,\n allowNegative: true,\n }),\n\n /**\n * High-precision configuration for cryptocurrency or precious metals.\n */\n HIGH_PRECISION: createPriceSemantic({\n storageFormat: 'decimal',\n defaultCurrency: 'BTC',\n decimalPlaces: 8,\n allowNegative: false,\n }),\n} as const\n\n/**\n * Helper function to validate a price configuration.\n */\nexport const validatePriceConfig = (config: PriceConfig): string[] => {\n const errors: string[] = []\n\n if (config.storageFormat !== 'complex_object' && !config.defaultCurrency) {\n errors.push('defaultCurrency is required when storageFormat is not complex_object')\n }\n\n if (config.decimalPlaces !== undefined && config.decimalPlaces < 0) {\n errors.push('decimalPlaces must be non-negative')\n }\n\n return errors\n}\n"]}
@@ -0,0 +1,69 @@
1
+ import type { AppliedDataSemantic } from '../Semantics.js';
2
+ import { SemanticType } from '../Semantics.js';
3
+ /**
4
+ * Configuration options for the PublicUniqueName (slug) semantic.
5
+ * Controls how slugs are generated and validated.
6
+ */
7
+ export interface PublicUniqueNameConfig {
8
+ /**
9
+ * The source field to generate the slug from (e.g., 'title').
10
+ * Default to the field that is annotated with the Title semantic.
11
+ */
12
+ sourceField?: string;
13
+ /**
14
+ * Separator character to use in the slug (default: '-').
15
+ */
16
+ separator?: string;
17
+ /**
18
+ * Maximum length of the slug (default: 64).
19
+ */
20
+ maxLength?: number;
21
+ /**
22
+ * Whether the slug is case sensitive (default: false).
23
+ */
24
+ caseSensitive?: boolean;
25
+ /**
26
+ * Whether to allow Unicode characters in the slug (default: false).
27
+ */
28
+ allowUnicode?: boolean;
29
+ /**
30
+ * Name of a custom generator function to use for slug creation.
31
+ */
32
+ customGenerator?: string;
33
+ /**
34
+ * Whether to allow duplicate slugs (default: false).
35
+ */
36
+ allowDuplicates?: boolean;
37
+ /**
38
+ * Fallback field to use if the source field is empty or invalid.
39
+ */
40
+ fallbackField?: string;
41
+ /**
42
+ * Custom metadata for the slug field.
43
+ */
44
+ metadata?: Record<string, unknown>;
45
+ /**
46
+ * Index signature to allow additional properties.
47
+ */
48
+ [key: string]: unknown;
49
+ }
50
+ /**
51
+ * Type-safe configuration for PublicUniqueName semantic.
52
+ */
53
+ export interface AppliedPublicUniqueNameSemantic extends AppliedDataSemantic {
54
+ id: SemanticType.PublicUniqueName;
55
+ config?: PublicUniqueNameConfig;
56
+ }
57
+ /**
58
+ * Type guard to check if a semantic is a PublicUniqueName semantic.
59
+ */
60
+ export declare const isPublicUniqueNameSemantic: (semantic: AppliedDataSemantic) => semantic is AppliedPublicUniqueNameSemantic;
61
+ /**
62
+ * Helper function to create a PublicUniqueName semantic with configuration.
63
+ */
64
+ export declare const createPublicUniqueNameSemantic: (config?: PublicUniqueNameConfig) => AppliedPublicUniqueNameSemantic;
65
+ /**
66
+ * Default configuration for PublicUniqueName semantic.
67
+ */
68
+ export declare const DEFAULT_PUBLIC_UNIQUE_NAME_CONFIG: PublicUniqueNameConfig;
69
+ //# sourceMappingURL=PublicUniqueName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PublicUniqueName.d.ts","sourceRoot":"","sources":["../../../../src/modeling/definitions/PublicUniqueName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,+BAAgC,SAAQ,mBAAmB;IAC1E,EAAE,EAAE,YAAY,CAAC,gBAAgB,CAAA;IACjC,MAAM,CAAC,EAAE,sBAAsB,CAAA;CAChC;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B,GACrC,UAAU,mBAAmB,KAC5B,QAAQ,IAAI,+BAEd,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,8BAA8B,GACzC,SAAQ,sBAA2B,KAClC,+BAaF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,iCAAiC,EAAE,sBAM/C,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { SemanticType } from '../Semantics.js';
2
+ /**
3
+ * Type guard to check if a semantic is a PublicUniqueName semantic.
4
+ */
5
+ export const isPublicUniqueNameSemantic = (semantic) => {
6
+ return semantic.id === SemanticType.PublicUniqueName;
7
+ };
8
+ /**
9
+ * Helper function to create a PublicUniqueName semantic with configuration.
10
+ */
11
+ export const createPublicUniqueNameSemantic = (config = {}) => {
12
+ const mergedConfig = {
13
+ ...DEFAULT_PUBLIC_UNIQUE_NAME_CONFIG,
14
+ ...config,
15
+ };
16
+ if (config.metadata) {
17
+ mergedConfig.metadata = { ...config.metadata };
18
+ }
19
+ return {
20
+ id: SemanticType.PublicUniqueName,
21
+ config: mergedConfig,
22
+ };
23
+ };
24
+ /**
25
+ * Default configuration for PublicUniqueName semantic.
26
+ */
27
+ export const DEFAULT_PUBLIC_UNIQUE_NAME_CONFIG = {
28
+ separator: '-',
29
+ maxLength: 64,
30
+ caseSensitive: false,
31
+ allowUnicode: false,
32
+ allowDuplicates: false,
33
+ };
34
+ //# sourceMappingURL=PublicUniqueName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PublicUniqueName.js","sourceRoot":"","sources":["../../../../src/modeling/definitions/PublicUniqueName.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AA0D9C;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,QAA6B,EACgB,EAAE;IAC/C,OAAO,QAAQ,CAAC,EAAE,KAAK,YAAY,CAAC,gBAAgB,CAAA;AACtD,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,SAAiC,EAAE,EACF,EAAE;IACnC,MAAM,YAAY,GAAG;QACnB,GAAG,iCAAiC;QACpC,GAAG,MAAM;KACV,CAAA;IACD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,YAAY,CAAC,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAChD,CAAC;IAED,OAAO;QACL,EAAE,EAAE,YAAY,CAAC,gBAAgB;QACjC,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAA2B;IACvE,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,KAAK;IACpB,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;CACvB,CAAA","sourcesContent":["import type { AppliedDataSemantic } from '../Semantics.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Configuration options for the PublicUniqueName (slug) semantic.\n * Controls how slugs are generated and validated.\n */\nexport interface PublicUniqueNameConfig {\n /**\n * The source field to generate the slug from (e.g., 'title').\n * Default to the field that is annotated with the Title semantic.\n */\n sourceField?: string\n /**\n * Separator character to use in the slug (default: '-').\n */\n separator?: string\n /**\n * Maximum length of the slug (default: 64).\n */\n maxLength?: number\n /**\n * Whether the slug is case sensitive (default: false).\n */\n caseSensitive?: boolean\n /**\n * Whether to allow Unicode characters in the slug (default: false).\n */\n allowUnicode?: boolean\n /**\n * Name of a custom generator function to use for slug creation.\n */\n customGenerator?: string\n /**\n * Whether to allow duplicate slugs (default: false).\n */\n allowDuplicates?: boolean\n /**\n * Fallback field to use if the source field is empty or invalid.\n */\n fallbackField?: string\n /**\n * Custom metadata for the slug field.\n */\n metadata?: Record<string, unknown>\n /**\n * Index signature to allow additional properties.\n */\n [key: string]: unknown\n}\n\n/**\n * Type-safe configuration for PublicUniqueName semantic.\n */\nexport interface AppliedPublicUniqueNameSemantic extends AppliedDataSemantic {\n id: SemanticType.PublicUniqueName\n config?: PublicUniqueNameConfig\n}\n\n/**\n * Type guard to check if a semantic is a PublicUniqueName semantic.\n */\nexport const isPublicUniqueNameSemantic = (\n semantic: AppliedDataSemantic\n): semantic is AppliedPublicUniqueNameSemantic => {\n return semantic.id === SemanticType.PublicUniqueName\n}\n\n/**\n * Helper function to create a PublicUniqueName semantic with configuration.\n */\nexport const createPublicUniqueNameSemantic = (\n config: PublicUniqueNameConfig = {}\n): AppliedPublicUniqueNameSemantic => {\n const mergedConfig = {\n ...DEFAULT_PUBLIC_UNIQUE_NAME_CONFIG,\n ...config,\n }\n if (config.metadata) {\n mergedConfig.metadata = { ...config.metadata }\n }\n\n return {\n id: SemanticType.PublicUniqueName,\n config: mergedConfig,\n }\n}\n\n/**\n * Default configuration for PublicUniqueName semantic.\n */\nexport const DEFAULT_PUBLIC_UNIQUE_NAME_CONFIG: PublicUniqueNameConfig = {\n separator: '-',\n maxLength: 64,\n caseSensitive: false,\n allowUnicode: false,\n allowDuplicates: false,\n}\n"]}
@@ -0,0 +1,127 @@
1
+ import type { AppliedDataSemantic } from '../Semantics.js';
2
+ import { SemanticType } from '../Semantics.js';
3
+ /**
4
+ * Supported SKU validation modes.
5
+ */
6
+ export type SKUValidationMode = 'strict' | 'lenient' | 'custom';
7
+ /**
8
+ * Supported SKU case transformation modes.
9
+ */
10
+ export type SKUCaseMode = 'uppercase' | 'lowercase' | 'preserve';
11
+ /**
12
+ * Configuration options for the SKU semantic.
13
+ * Controls SKU validation, formatting, uniqueness enforcement, and pattern matching.
14
+ */
15
+ export interface SKUConfig {
16
+ /**
17
+ * The validation mode for SKU format.
18
+ *
19
+ * - 'strict': Enforces alphanumeric characters with optional hyphens/underscores
20
+ * - 'lenient': Allows more special characters but still validates basic format
21
+ * - 'custom': Uses custom regex pattern defined in `customPattern`
22
+ */
23
+ validationMode?: SKUValidationMode;
24
+ /**
25
+ * Custom regex pattern for SKU validation when using 'custom' validation mode.
26
+ * Only used when validationMode is 'custom'.
27
+ */
28
+ customPattern?: string;
29
+ /**
30
+ * Case transformation to apply to SKUs.
31
+ * - 'uppercase': Convert to uppercase (recommended for consistency)
32
+ * - 'lowercase': Convert to lowercase
33
+ * - 'preserve': Keep original case
34
+ */
35
+ caseMode?: SKUCaseMode;
36
+ /**
37
+ * Prefix to automatically add to SKUs if not present.
38
+ * Useful for organizing SKUs by category (e.g., 'PROD-', 'SKU-').
39
+ */
40
+ prefix?: string;
41
+ /**
42
+ * Whether to enforce global uniqueness across all entities.
43
+ * When true, creates unique database constraints.
44
+ * Default: true
45
+ */
46
+ enforceUniqueness?: boolean;
47
+ /**
48
+ * Whether to auto-generate SKUs when not provided.
49
+ * When true, generates SKUs based on other fields or random values.
50
+ * Default: false
51
+ */
52
+ autoGenerate?: boolean;
53
+ /**
54
+ * Field name to use as source for auto-generation.
55
+ * Only used when autoGenerate is true.
56
+ * If not specified, uses random generation.
57
+ */
58
+ autoGenerateSource?: string;
59
+ /**
60
+ * Whether to validate that SKU doesn't conflict with reserved words or patterns.
61
+ * Default: true
62
+ */
63
+ validateReservedWords?: boolean;
64
+ /**
65
+ * List of reserved SKU values that cannot be used.
66
+ * Common examples: 'ADMIN', 'TEST', 'NULL', 'DEFAULT'
67
+ */
68
+ reservedValues?: string[];
69
+ /**
70
+ * Custom metadata for the SKU field.
71
+ */
72
+ metadata?: Record<string, unknown>;
73
+ /**
74
+ * Index signature to allow additional properties.
75
+ */
76
+ [key: string]: unknown;
77
+ }
78
+ /**
79
+ * Type-safe configuration for SKU semantic.
80
+ */
81
+ export interface AppliedSKUSemantic extends AppliedDataSemantic {
82
+ id: SemanticType.SKU;
83
+ config?: SKUConfig;
84
+ }
85
+ /**
86
+ * Type guard to check if a semantic is a SKU semantic.
87
+ */
88
+ export declare const isSKUSemantic: (semantic: AppliedDataSemantic) => semantic is AppliedSKUSemantic;
89
+ /**
90
+ * Helper function to create a SKU semantic with configuration.
91
+ */
92
+ export declare const createSKUSemantic: (config?: SKUConfig) => AppliedSKUSemantic;
93
+ /**
94
+ * Default configuration for SKU semantic.
95
+ * Optimized for common product catalog use cases.
96
+ */
97
+ export declare const DEFAULT_SKU_CONFIG: SKUConfig;
98
+ /**
99
+ * Predefined configurations for common use cases.
100
+ */
101
+ export declare const SKU_PRESETS: {
102
+ /**
103
+ * Standard product SKU with strict validation and uppercase formatting.
104
+ */
105
+ readonly PRODUCT_STANDARD: AppliedSKUSemantic;
106
+ /**
107
+ * Simple SKU configuration for basic catalogs.
108
+ */
109
+ readonly SIMPLE: AppliedSKUSemantic;
110
+ /**
111
+ * Auto-generating SKU from product name.
112
+ */
113
+ readonly AUTO_GENERATE: AppliedSKUSemantic;
114
+ /**
115
+ * Flexible SKU for variable product types.
116
+ */
117
+ readonly FLEXIBLE: AppliedSKUSemantic;
118
+ };
119
+ /**
120
+ * Helper function to validate a SKU configuration.
121
+ */
122
+ export declare const validateSKUConfig: (config: SKUConfig) => string[];
123
+ /**
124
+ * Helper function to validate SKU value against configuration.
125
+ */
126
+ export declare const validateSKUValue: (value: string, config?: SKUConfig) => string[];
127
+ //# sourceMappingURL=SKU.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SKU.d.ts","sourceRoot":"","sources":["../../../../src/modeling/definitions/SKU.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,CAAA;AAEhE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,iBAAiB,CAAA;IAElC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAA;IAEtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IAEtB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAE/B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAElC;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,EAAE,EAAE,YAAY,CAAC,GAAG,CAAA;IACpB,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,mBAAmB,KAAG,QAAQ,IAAI,kBAEzE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAQ,SAAc,KAAG,kBAe1D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAOhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;;IAQH;;OAEG;;IAOH;;OAEG;;IASH;;OAEG;;CAOK,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,SAAS,KAAG,MAAM,EAwB3D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,EAAE,SAAQ,SAA8B,KAAG,MAAM,EAqC9F,CAAA"}