@api-client/core 0.17.4 → 0.17.6

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 (64) hide show
  1. package/build/src/modeling/Semantics.d.ts +9 -5
  2. package/build/src/modeling/Semantics.d.ts.map +1 -1
  3. package/build/src/modeling/Semantics.js +14 -10
  4. package/build/src/modeling/Semantics.js.map +1 -1
  5. package/build/src/modeling/definitions/{Price.d.ts → Currency.d.ts} +24 -24
  6. package/build/src/modeling/definitions/Currency.d.ts.map +1 -0
  7. package/build/src/modeling/definitions/{Price.js → Currency.js} +18 -18
  8. package/build/src/modeling/definitions/Currency.js.map +1 -0
  9. package/build/src/modeling/definitions/Email.d.ts +2 -2
  10. package/build/src/modeling/definitions/Email.d.ts.map +1 -1
  11. package/build/src/modeling/definitions/Email.js.map +1 -1
  12. package/build/src/modeling/definitions/GeospatialCoordinates.d.ts +46 -1
  13. package/build/src/modeling/definitions/GeospatialCoordinates.d.ts.map +1 -1
  14. package/build/src/modeling/definitions/GeospatialCoordinates.js.map +1 -1
  15. package/build/src/modeling/definitions/HTML.d.ts +17 -4
  16. package/build/src/modeling/definitions/HTML.d.ts.map +1 -1
  17. package/build/src/modeling/definitions/HTML.js +0 -1
  18. package/build/src/modeling/definitions/HTML.js.map +1 -1
  19. package/build/src/modeling/definitions/Markdown.d.ts +12 -4
  20. package/build/src/modeling/definitions/Markdown.d.ts.map +1 -1
  21. package/build/src/modeling/definitions/Markdown.js +0 -1
  22. package/build/src/modeling/definitions/Markdown.js.map +1 -1
  23. package/build/src/modeling/definitions/Phone.d.ts +5 -7
  24. package/build/src/modeling/definitions/Phone.d.ts.map +1 -1
  25. package/build/src/modeling/definitions/Phone.js +2 -2
  26. package/build/src/modeling/definitions/Phone.js.map +1 -1
  27. package/build/src/modeling/definitions/PublicUniqueName.d.ts +1 -9
  28. package/build/src/modeling/definitions/PublicUniqueName.d.ts.map +1 -1
  29. package/build/src/modeling/definitions/PublicUniqueName.js +0 -1
  30. package/build/src/modeling/definitions/PublicUniqueName.js.map +1 -1
  31. package/build/src/modeling/definitions/SKU.d.ts +4 -1
  32. package/build/src/modeling/definitions/SKU.d.ts.map +1 -1
  33. package/build/src/modeling/definitions/SKU.js.map +1 -1
  34. package/build/src/modeling/definitions/Status.d.ts +1 -1
  35. package/build/src/modeling/definitions/Status.d.ts.map +1 -1
  36. package/build/src/modeling/definitions/Status.js +1 -0
  37. package/build/src/modeling/definitions/Status.js.map +1 -1
  38. package/build/src/modeling/definitions/URL.d.ts +1 -4
  39. package/build/src/modeling/definitions/URL.d.ts.map +1 -1
  40. package/build/src/modeling/definitions/URL.js +0 -1
  41. package/build/src/modeling/definitions/URL.js.map +1 -1
  42. package/build/tsconfig.tsbuildinfo +1 -1
  43. package/data/models/example-generator-api.json +10 -10
  44. package/package.json +1 -1
  45. package/src/modeling/Semantics.ts +14 -10
  46. package/src/modeling/definitions/{Price.examples.md → Currency.examples.md} +12 -12
  47. package/src/modeling/definitions/{Price.ts → Currency.ts} +26 -26
  48. package/src/modeling/definitions/Email.ts +2 -2
  49. package/src/modeling/definitions/GeospatialCoordinates.ts +46 -1
  50. package/src/modeling/definitions/HTML.ts +17 -5
  51. package/src/modeling/definitions/Markdown.ts +12 -5
  52. package/src/modeling/definitions/Phone.ts +6 -8
  53. package/src/modeling/definitions/PublicUniqueName.ts +1 -10
  54. package/src/modeling/definitions/SKU.ts +4 -1
  55. package/src/modeling/definitions/Status.ts +2 -1
  56. package/src/modeling/definitions/URL.ts +1 -5
  57. package/tests/unit/modeling/definitions/{price.spec.ts → currency.spec.ts} +114 -114
  58. package/tests/unit/modeling/definitions/derived.spec.ts +1 -2
  59. package/tests/unit/modeling/definitions/description.spec.ts +0 -2
  60. package/tests/unit/modeling/definitions/url.spec.ts +0 -1
  61. package/tests/unit/modeling/semantic-configs.spec.ts +45 -46
  62. package/tests/unit/modeling/semantics.spec.ts +10 -1
  63. package/build/src/modeling/definitions/Price.d.ts.map +0 -1
  64. package/build/src/modeling/definitions/Price.js.map +0 -1
@@ -60,9 +60,12 @@ export interface SKUConfig {
60
60
  autoGenerate?: boolean
61
61
 
62
62
  /**
63
- * Field name to use as source for auto-generation.
63
+ * Field key to use as source for auto-generation.
64
64
  * Only used when autoGenerate is true.
65
65
  * If not specified, uses random generation.
66
+ *
67
+ * The kay can be any field that provides a meaningful value for the SKU. It can also be a key of
68
+ * a property in one of the parent entities.
66
69
  */
67
70
  autoGenerateSource?: string
68
71
 
@@ -17,7 +17,7 @@ export interface StatusConfig {
17
17
  * Default state when creating new records.
18
18
  * Must be one of the allowedStates (if specified) or enum values from the schema.
19
19
  */
20
- defaultState: string
20
+ defaultState?: string
21
21
 
22
22
  /**
23
23
  * State transitions configuration.
@@ -200,6 +200,7 @@ export const createStatusSemantic = (config: Partial<StatusConfig> = {}): Applie
200
200
  * Default configuration for Status semantic.
201
201
  */
202
202
  export const DEFAULT_STATUS_CONFIG: StatusConfig = {
203
+ allowedStates: ['draft', 'published', 'archived'],
203
204
  defaultState: 'draft',
204
205
  stateBehaviors: {
205
206
  draft: {
@@ -6,12 +6,9 @@ import { SemanticType } from '../Semantics.js'
6
6
  * Controls validation, allowed protocols, and formatting.
7
7
  */
8
8
  export interface URLConfig {
9
- /**
10
- * List of allowed protocols (e.g., ['http', 'https']).
11
- */
12
- allowedProtocols?: string[]
13
9
  /**
14
10
  * Whether to require HTTPS protocol (default: false).
11
+ * When not set, both HTTP and HTTPS are allowed.
15
12
  */
16
13
  requireHttps?: boolean
17
14
  /**
@@ -85,7 +82,6 @@ export const createURLSemantic = (config: URLConfig = {}): AppliedURLSemantic =>
85
82
  * Default configuration for URL semantic.
86
83
  */
87
84
  export const DEFAULT_URL_CONFIG: URLConfig = {
88
- allowedProtocols: ['http', 'https'],
89
85
  requireHttps: false,
90
86
  allowQueryParams: true,
91
87
  allowFragments: true,
@@ -1,183 +1,183 @@
1
1
  import { test } from '@japa/runner'
2
2
  import {
3
- createPriceSemantic,
4
- isPriceSemantic,
5
- validatePriceConfig,
6
- DEFAULT_PRICE_CONFIG,
7
- PRICE_PRESETS,
8
- type PriceConfig,
9
- } from '../../../../src/modeling/definitions/Price.js'
3
+ createCurrencySemantic,
4
+ isCurrencySemantic,
5
+ validateCurrencyConfig,
6
+ DEFAULT_CURRENCY_CONFIG,
7
+ CURRENCY_PRESETS,
8
+ type CurrencyConfig,
9
+ } from '../../../../src/modeling/definitions/Currency.js'
10
10
  import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'
11
11
 
12
- test.group('Price Semantic Configuration', () => {
12
+ test.group('Currency Semantic Configuration', () => {
13
13
  test('should create semantic with default config', ({ assert }) => {
14
- const semantic = createPriceSemantic()
15
- assert.equal(semantic.id, SemanticType.Price)
16
- assert.deepEqual(semantic.config, DEFAULT_PRICE_CONFIG)
14
+ const semantic = createCurrencySemantic()
15
+ assert.equal(semantic.id, SemanticType.Currency)
16
+ assert.deepEqual(semantic.config, DEFAULT_CURRENCY_CONFIG)
17
17
  })
18
18
 
19
19
  test('should create semantic with custom config', ({ assert }) => {
20
- const config: PriceConfig = {
20
+ const config: CurrencyConfig = {
21
21
  storageFormat: 'complex_object',
22
22
  allowedCurrencies: ['USD', 'EUR'],
23
23
  decimalPlaces: 4,
24
24
  allowNegative: true,
25
25
  validateCurrencyCode: false,
26
26
  }
27
- const semantic = createPriceSemantic(config)
28
- assert.equal(semantic.id, SemanticType.Price)
29
- assert.deepEqual(semantic.config, { ...DEFAULT_PRICE_CONFIG, ...config })
27
+ const semantic = createCurrencySemantic(config)
28
+ assert.equal(semantic.id, SemanticType.Currency)
29
+ assert.deepEqual(semantic.config, { ...DEFAULT_CURRENCY_CONFIG, ...config })
30
30
  })
31
31
 
32
32
  test('should merge metadata properly', ({ assert }) => {
33
- const config: PriceConfig = {
33
+ const config: CurrencyConfig = {
34
34
  metadata: {
35
35
  customField: 'value',
36
36
  anotherField: 123,
37
37
  },
38
38
  }
39
- const semantic = createPriceSemantic(config)
40
- assert.equal(semantic.id, SemanticType.Price)
39
+ const semantic = createCurrencySemantic(config)
40
+ assert.equal(semantic.id, SemanticType.Currency)
41
41
  assert.deepEqual(semantic.config?.metadata, config.metadata)
42
42
  })
43
43
 
44
- test('should identify price semantic', ({ assert }) => {
45
- const semantic = createPriceSemantic()
46
- assert.isTrue(isPriceSemantic(semantic))
44
+ test('should identify currency semantic', ({ assert }) => {
45
+ const semantic = createCurrencySemantic()
46
+ assert.isTrue(isCurrencySemantic(semantic))
47
47
  })
48
48
 
49
- test('should not identify non-price semantic', ({ assert }) => {
49
+ test('should not identify non-currency semantic', ({ assert }) => {
50
50
  const fakeSemantic: AppliedDataSemantic = {
51
51
  id: SemanticType.Email,
52
52
  config: {},
53
53
  }
54
- assert.isFalse(isPriceSemantic(fakeSemantic))
54
+ assert.isFalse(isCurrencySemantic(fakeSemantic))
55
55
  })
56
56
 
57
- test('DEFAULT_PRICE_CONFIG should have correct values', ({ assert }) => {
58
- assert.equal(DEFAULT_PRICE_CONFIG.storageFormat, 'decimal')
59
- assert.equal(DEFAULT_PRICE_CONFIG.defaultCurrency, 'USD')
60
- assert.equal(DEFAULT_PRICE_CONFIG.decimalPlaces, 2)
61
- assert.equal(DEFAULT_PRICE_CONFIG.allowNegative, false)
62
- assert.equal(DEFAULT_PRICE_CONFIG.validateCurrencyCode, true)
57
+ test('DEFAULT_CURRENCY_CONFIG should have correct values', ({ assert }) => {
58
+ assert.equal(DEFAULT_CURRENCY_CONFIG.storageFormat, 'decimal')
59
+ assert.equal(DEFAULT_CURRENCY_CONFIG.defaultCurrency, 'USD')
60
+ assert.equal(DEFAULT_CURRENCY_CONFIG.decimalPlaces, 2)
61
+ assert.equal(DEFAULT_CURRENCY_CONFIG.allowNegative, false)
62
+ assert.equal(DEFAULT_CURRENCY_CONFIG.validateCurrencyCode, true)
63
63
  })
64
64
  })
65
65
 
66
- test.group('Price Storage Formats', () => {
66
+ test.group('Currency Storage Formats', () => {
67
67
  test('should support decimal storage format', ({ assert }) => {
68
- const config: PriceConfig = {
68
+ const config: CurrencyConfig = {
69
69
  storageFormat: 'decimal',
70
70
  defaultCurrency: 'USD',
71
71
  decimalPlaces: 2,
72
72
  }
73
- const semantic = createPriceSemantic(config)
73
+ const semantic = createCurrencySemantic(config)
74
74
  assert.equal(semantic.config?.storageFormat, 'decimal')
75
75
  assert.equal(semantic.config?.defaultCurrency, 'USD')
76
76
  assert.equal(semantic.config?.decimalPlaces, 2)
77
77
  })
78
78
 
79
79
  test('should support integer_cents storage format', ({ assert }) => {
80
- const config: PriceConfig = {
80
+ const config: CurrencyConfig = {
81
81
  storageFormat: 'integer_cents',
82
82
  defaultCurrency: 'EUR',
83
83
  decimalPlaces: 2,
84
84
  }
85
- const semantic = createPriceSemantic(config)
85
+ const semantic = createCurrencySemantic(config)
86
86
  assert.equal(semantic.config?.storageFormat, 'integer_cents')
87
87
  assert.equal(semantic.config?.defaultCurrency, 'EUR')
88
88
  })
89
89
 
90
90
  test('should support complex_object storage format', ({ assert }) => {
91
- const config: PriceConfig = {
91
+ const config: CurrencyConfig = {
92
92
  storageFormat: 'complex_object',
93
93
  allowedCurrencies: ['USD', 'EUR', 'GBP'],
94
94
  decimalPlaces: 2,
95
95
  }
96
- const semantic = createPriceSemantic(config)
96
+ const semantic = createCurrencySemantic(config)
97
97
  assert.equal(semantic.config?.storageFormat, 'complex_object')
98
98
  assert.deepEqual(semantic.config?.allowedCurrencies, ['USD', 'EUR', 'GBP'])
99
99
  })
100
100
  })
101
101
 
102
- test.group('Price Configuration Validation', () => {
102
+ test.group('Currency Configuration Validation', () => {
103
103
  test('should validate that defaultCurrency is required for decimal format', ({ assert }) => {
104
- const config: PriceConfig = {
104
+ const config: CurrencyConfig = {
105
105
  storageFormat: 'decimal',
106
106
  // Missing defaultCurrency
107
107
  decimalPlaces: 2,
108
108
  }
109
- const errors = validatePriceConfig(config)
109
+ const errors = validateCurrencyConfig(config)
110
110
  assert.include(errors, 'defaultCurrency is required when storageFormat is not complex_object')
111
111
  })
112
112
 
113
113
  test('should validate that defaultCurrency is required for integer_cents format', ({ assert }) => {
114
- const config: PriceConfig = {
114
+ const config: CurrencyConfig = {
115
115
  storageFormat: 'integer_cents',
116
116
  // Missing defaultCurrency
117
117
  decimalPlaces: 2,
118
118
  }
119
- const errors = validatePriceConfig(config)
119
+ const errors = validateCurrencyConfig(config)
120
120
  assert.include(errors, 'defaultCurrency is required when storageFormat is not complex_object')
121
121
  })
122
122
 
123
123
  test('should not require defaultCurrency for complex_object format', ({ assert }) => {
124
- const config: PriceConfig = {
124
+ const config: CurrencyConfig = {
125
125
  storageFormat: 'complex_object',
126
126
  // No defaultCurrency needed
127
127
  allowedCurrencies: ['USD', 'EUR'],
128
128
  }
129
- const errors = validatePriceConfig(config)
129
+ const errors = validateCurrencyConfig(config)
130
130
  assert.notInclude(errors, 'defaultCurrency is required when storageFormat is not complex_object')
131
131
  })
132
132
 
133
133
  test('should validate that decimalPlaces is non-negative', ({ assert }) => {
134
- const config: PriceConfig = {
134
+ const config: CurrencyConfig = {
135
135
  storageFormat: 'decimal',
136
136
  defaultCurrency: 'USD',
137
137
  decimalPlaces: -1,
138
138
  }
139
- const errors = validatePriceConfig(config)
139
+ const errors = validateCurrencyConfig(config)
140
140
  assert.include(errors, 'decimalPlaces must be non-negative')
141
141
  })
142
142
 
143
143
  test('should accept zero decimal places', ({ assert }) => {
144
- const config: PriceConfig = {
144
+ const config: CurrencyConfig = {
145
145
  storageFormat: 'decimal',
146
146
  defaultCurrency: 'JPY',
147
147
  decimalPlaces: 0,
148
148
  }
149
- const errors = validatePriceConfig(config)
149
+ const errors = validateCurrencyConfig(config)
150
150
  assert.notInclude(errors, 'decimalPlaces must be non-negative')
151
151
  })
152
152
 
153
153
  test('should return empty array for valid config', ({ assert }) => {
154
- const config: PriceConfig = {
154
+ const config: CurrencyConfig = {
155
155
  storageFormat: 'decimal',
156
156
  defaultCurrency: 'USD',
157
157
  decimalPlaces: 2,
158
158
  allowNegative: false,
159
159
  }
160
- const errors = validatePriceConfig(config)
160
+ const errors = validateCurrencyConfig(config)
161
161
  assert.lengthOf(errors, 0)
162
162
  })
163
163
 
164
164
  test('should accumulate multiple validation errors', ({ assert }) => {
165
- const config: PriceConfig = {
165
+ const config: CurrencyConfig = {
166
166
  storageFormat: 'decimal',
167
167
  // Missing defaultCurrency
168
168
  decimalPlaces: -2, // Invalid decimal places
169
169
  }
170
- const errors = validatePriceConfig(config)
170
+ const errors = validateCurrencyConfig(config)
171
171
  assert.lengthOf(errors, 2)
172
172
  assert.include(errors, 'defaultCurrency is required when storageFormat is not complex_object')
173
173
  assert.include(errors, 'decimalPlaces must be non-negative')
174
174
  })
175
175
  })
176
176
 
177
- test.group('Price Presets', () => {
177
+ test.group('Currency Presets', () => {
178
178
  test('USD_DECIMAL preset should have correct configuration', ({ assert }) => {
179
- const preset = PRICE_PRESETS.USD_DECIMAL
180
- assert.equal(preset.id, SemanticType.Price)
179
+ const preset = CURRENCY_PRESETS.USD_DECIMAL
180
+ assert.equal(preset.id, SemanticType.Currency)
181
181
  assert.equal(preset.config?.storageFormat, 'decimal')
182
182
  assert.equal(preset.config?.defaultCurrency, 'USD')
183
183
  assert.equal(preset.config?.decimalPlaces, 2)
@@ -185,8 +185,8 @@ test.group('Price Presets', () => {
185
185
  })
186
186
 
187
187
  test('USD_CENTS preset should have correct configuration', ({ assert }) => {
188
- const preset = PRICE_PRESETS.USD_CENTS
189
- assert.equal(preset.id, SemanticType.Price)
188
+ const preset = CURRENCY_PRESETS.USD_CENTS
189
+ assert.equal(preset.id, SemanticType.Currency)
190
190
  assert.equal(preset.config?.storageFormat, 'integer_cents')
191
191
  assert.equal(preset.config?.defaultCurrency, 'USD')
192
192
  assert.equal(preset.config?.decimalPlaces, 2)
@@ -194,8 +194,8 @@ test.group('Price Presets', () => {
194
194
  })
195
195
 
196
196
  test('MULTI_CURRENCY preset should have correct configuration', ({ assert }) => {
197
- const preset = PRICE_PRESETS.MULTI_CURRENCY
198
- assert.equal(preset.id, SemanticType.Price)
197
+ const preset = CURRENCY_PRESETS.MULTI_CURRENCY
198
+ assert.equal(preset.id, SemanticType.Currency)
199
199
  assert.equal(preset.config?.storageFormat, 'complex_object')
200
200
  assert.deepEqual(preset.config?.allowedCurrencies, ['USD', 'EUR', 'GBP', 'JPY', 'CAD'])
201
201
  assert.equal(preset.config?.decimalPlaces, 2)
@@ -203,8 +203,8 @@ test.group('Price Presets', () => {
203
203
  })
204
204
 
205
205
  test('WITH_NEGATIVES preset should have correct configuration', ({ assert }) => {
206
- const preset = PRICE_PRESETS.WITH_NEGATIVES
207
- assert.equal(preset.id, SemanticType.Price)
206
+ const preset = CURRENCY_PRESETS.WITH_NEGATIVES
207
+ assert.equal(preset.id, SemanticType.Currency)
208
208
  assert.equal(preset.config?.storageFormat, 'decimal')
209
209
  assert.equal(preset.config?.defaultCurrency, 'USD')
210
210
  assert.equal(preset.config?.decimalPlaces, 2)
@@ -212,134 +212,134 @@ test.group('Price Presets', () => {
212
212
  })
213
213
 
214
214
  test('HIGH_PRECISION preset should have correct configuration', ({ assert }) => {
215
- const preset = PRICE_PRESETS.HIGH_PRECISION
216
- assert.equal(preset.id, SemanticType.Price)
215
+ const preset = CURRENCY_PRESETS.HIGH_PRECISION
216
+ assert.equal(preset.id, SemanticType.Currency)
217
217
  assert.equal(preset.config?.storageFormat, 'decimal')
218
218
  assert.equal(preset.config?.defaultCurrency, 'BTC')
219
219
  assert.equal(preset.config?.decimalPlaces, 8)
220
220
  assert.equal(preset.config?.allowNegative, false)
221
221
  })
222
222
 
223
- test('all presets should be valid price semantics', ({ assert }) => {
224
- Object.values(PRICE_PRESETS).forEach((preset) => {
225
- assert.isTrue(isPriceSemantic(preset))
223
+ test('all presets should be valid currency semantics', ({ assert }) => {
224
+ Object.values(CURRENCY_PRESETS).forEach((preset) => {
225
+ assert.isTrue(isCurrencySemantic(preset))
226
226
  // Validate each preset config
227
227
  if (preset.config) {
228
- const errors = validatePriceConfig(preset.config)
228
+ const errors = validateCurrencyConfig(preset.config)
229
229
  assert.lengthOf(errors, 0, `Preset ${preset.config.storageFormat} should have valid config`)
230
230
  }
231
231
  })
232
232
  })
233
233
  })
234
234
 
235
- test.group('Price Currency Configuration', () => {
235
+ test.group('Currency Currency Configuration', () => {
236
236
  test('should support single currency with defaultCurrency', ({ assert }) => {
237
- const config: PriceConfig = {
237
+ const config: CurrencyConfig = {
238
238
  storageFormat: 'decimal',
239
239
  defaultCurrency: 'EUR',
240
240
  decimalPlaces: 2,
241
241
  }
242
- const semantic = createPriceSemantic(config)
242
+ const semantic = createCurrencySemantic(config)
243
243
  assert.equal(semantic.config?.defaultCurrency, 'EUR')
244
244
  assert.isUndefined(semantic.config?.allowedCurrencies)
245
245
  })
246
246
 
247
247
  test('should support multiple currencies with allowedCurrencies', ({ assert }) => {
248
248
  const currencies = ['USD', 'EUR', 'GBP', 'JPY', 'CAD', 'AUD']
249
- const config: PriceConfig = {
249
+ const config: CurrencyConfig = {
250
250
  storageFormat: 'complex_object',
251
251
  allowedCurrencies: currencies,
252
252
  decimalPlaces: 2,
253
253
  }
254
- const semantic = createPriceSemantic(config)
254
+ const semantic = createCurrencySemantic(config)
255
255
  assert.deepEqual(semantic.config?.allowedCurrencies, currencies)
256
256
  })
257
257
 
258
258
  test('should support currency validation toggle', ({ assert }) => {
259
- const configWithValidation: PriceConfig = {
259
+ const configWithValidation: CurrencyConfig = {
260
260
  storageFormat: 'decimal',
261
261
  defaultCurrency: 'USD',
262
262
  validateCurrencyCode: true,
263
263
  }
264
- const configWithoutValidation: PriceConfig = {
264
+ const configWithoutValidation: CurrencyConfig = {
265
265
  storageFormat: 'decimal',
266
266
  defaultCurrency: 'USD',
267
267
  validateCurrencyCode: false,
268
268
  }
269
269
 
270
- const semanticWithValidation = createPriceSemantic(configWithValidation)
271
- const semanticWithoutValidation = createPriceSemantic(configWithoutValidation)
270
+ const semanticWithValidation = createCurrencySemantic(configWithValidation)
271
+ const semanticWithoutValidation = createCurrencySemantic(configWithoutValidation)
272
272
 
273
273
  assert.isTrue(semanticWithValidation.config?.validateCurrencyCode)
274
274
  assert.isFalse(semanticWithoutValidation.config?.validateCurrencyCode)
275
275
  })
276
276
  })
277
277
 
278
- test.group('Price Precision Configuration', () => {
278
+ test.group('Currency Precision Configuration', () => {
279
279
  test('should support standard 2 decimal places (USD, EUR)', ({ assert }) => {
280
- const config: PriceConfig = {
280
+ const config: CurrencyConfig = {
281
281
  storageFormat: 'decimal',
282
282
  defaultCurrency: 'USD',
283
283
  decimalPlaces: 2,
284
284
  }
285
- const semantic = createPriceSemantic(config)
285
+ const semantic = createCurrencySemantic(config)
286
286
  assert.equal(semantic.config?.decimalPlaces, 2)
287
287
  })
288
288
 
289
289
  test('should support zero decimal places (JPY, KRW)', ({ assert }) => {
290
- const config: PriceConfig = {
290
+ const config: CurrencyConfig = {
291
291
  storageFormat: 'decimal',
292
292
  defaultCurrency: 'JPY',
293
293
  decimalPlaces: 0,
294
294
  }
295
- const semantic = createPriceSemantic(config)
295
+ const semantic = createCurrencySemantic(config)
296
296
  assert.equal(semantic.config?.decimalPlaces, 0)
297
297
  })
298
298
 
299
299
  test('should support high precision (3 decimal places for BHD, KWD)', ({ assert }) => {
300
- const config: PriceConfig = {
300
+ const config: CurrencyConfig = {
301
301
  storageFormat: 'decimal',
302
302
  defaultCurrency: 'BHD',
303
303
  decimalPlaces: 3,
304
304
  }
305
- const semantic = createPriceSemantic(config)
305
+ const semantic = createCurrencySemantic(config)
306
306
  assert.equal(semantic.config?.decimalPlaces, 3)
307
307
  })
308
308
 
309
309
  test('should support very high precision (cryptocurrencies)', ({ assert }) => {
310
- const config: PriceConfig = {
310
+ const config: CurrencyConfig = {
311
311
  storageFormat: 'decimal',
312
312
  defaultCurrency: 'BTC',
313
313
  decimalPlaces: 8,
314
314
  }
315
- const semantic = createPriceSemantic(config)
315
+ const semantic = createCurrencySemantic(config)
316
316
  assert.equal(semantic.config?.decimalPlaces, 8)
317
317
  })
318
318
  })
319
319
 
320
- test.group('Price Negative Values Configuration', () => {
320
+ test.group('Currency Negative Values Configuration', () => {
321
321
  test('should support disallowing negative values (default)', ({ assert }) => {
322
- const config: PriceConfig = {
322
+ const config: CurrencyConfig = {
323
323
  storageFormat: 'decimal',
324
324
  defaultCurrency: 'USD',
325
325
  allowNegative: false,
326
326
  }
327
- const semantic = createPriceSemantic(config)
327
+ const semantic = createCurrencySemantic(config)
328
328
  assert.isFalse(semantic.config?.allowNegative)
329
329
  })
330
330
 
331
331
  test('should support allowing negative values (refunds, discounts)', ({ assert }) => {
332
- const config: PriceConfig = {
332
+ const config: CurrencyConfig = {
333
333
  storageFormat: 'decimal',
334
334
  defaultCurrency: 'USD',
335
335
  allowNegative: true,
336
336
  }
337
- const semantic = createPriceSemantic(config)
337
+ const semantic = createCurrencySemantic(config)
338
338
  assert.isTrue(semantic.config?.allowNegative)
339
339
  })
340
340
  })
341
341
 
342
- test.group('Price Metadata Configuration', () => {
342
+ test.group('Currency Metadata Configuration', () => {
343
343
  test('should support custom metadata', ({ assert }) => {
344
344
  const metadata = {
345
345
  displayFormat: 'currency',
@@ -347,17 +347,17 @@ test.group('Price Metadata Configuration', () => {
347
347
  rounding: 'standard',
348
348
  customField: 'value',
349
349
  }
350
- const config: PriceConfig = {
350
+ const config: CurrencyConfig = {
351
351
  storageFormat: 'decimal',
352
352
  defaultCurrency: 'USD',
353
353
  metadata,
354
354
  }
355
- const semantic = createPriceSemantic(config)
355
+ const semantic = createCurrencySemantic(config)
356
356
  assert.deepEqual(semantic.config?.metadata, metadata)
357
357
  })
358
358
 
359
359
  test('should merge metadata with other config', ({ assert }) => {
360
- const config: PriceConfig = {
360
+ const config: CurrencyConfig = {
361
361
  storageFormat: 'complex_object',
362
362
  allowedCurrencies: ['USD', 'EUR'],
363
363
  decimalPlaces: 2,
@@ -366,7 +366,7 @@ test.group('Price Metadata Configuration', () => {
366
366
  lastUpdated: '2023-01-01',
367
367
  },
368
368
  }
369
- const semantic = createPriceSemantic(config)
369
+ const semantic = createCurrencySemantic(config)
370
370
  assert.equal(semantic.config?.storageFormat, 'complex_object')
371
371
  assert.deepEqual(semantic.config?.allowedCurrencies, ['USD', 'EUR'])
372
372
  assert.equal(semantic.config?.decimalPlaces, 2)
@@ -377,34 +377,34 @@ test.group('Price Metadata Configuration', () => {
377
377
  })
378
378
  })
379
379
 
380
- test.group('Price Cross-semantic Type Guards', () => {
380
+ test.group('Currency Cross-semantic Type Guards', () => {
381
381
  test('should correctly identify different semantic types', ({ assert }) => {
382
- const priceSemantic = createPriceSemantic()
382
+ const currencySemantic = createCurrencySemantic()
383
383
 
384
384
  // Mock other semantics for comparison
385
385
  const emailSemantic: AppliedDataSemantic = { id: SemanticType.Email }
386
386
  const statusSemantic: AppliedDataSemantic = { id: SemanticType.Status }
387
387
  const userSemantic: AppliedDataSemantic = { id: SemanticType.User }
388
388
 
389
- // Price semantic should only be identified as Price
390
- assert.isTrue(isPriceSemantic(priceSemantic))
391
- assert.isFalse(isPriceSemantic(emailSemantic))
392
- assert.isFalse(isPriceSemantic(statusSemantic))
393
- assert.isFalse(isPriceSemantic(userSemantic))
389
+ // Currency semantic should only be identified as Currency
390
+ assert.isTrue(isCurrencySemantic(currencySemantic))
391
+ assert.isFalse(isCurrencySemantic(emailSemantic))
392
+ assert.isFalse(isCurrencySemantic(statusSemantic))
393
+ assert.isFalse(isCurrencySemantic(userSemantic))
394
394
  })
395
395
  })
396
396
 
397
- test.group('Price Real-world Use Cases', () => {
397
+ test.group('Currency Real-world Use Cases', () => {
398
398
  test('should configure for simple e-commerce store', ({ assert }) => {
399
- const config: PriceConfig = {
399
+ const config: CurrencyConfig = {
400
400
  storageFormat: 'decimal',
401
401
  defaultCurrency: 'USD',
402
402
  decimalPlaces: 2,
403
403
  allowNegative: false,
404
404
  validateCurrencyCode: true,
405
405
  }
406
- const semantic = createPriceSemantic(config)
407
- const errors = validatePriceConfig(config)
406
+ const semantic = createCurrencySemantic(config)
407
+ const errors = validateCurrencyConfig(config)
408
408
 
409
409
  assert.lengthOf(errors, 0)
410
410
  assert.equal(semantic.config?.storageFormat, 'decimal')
@@ -413,15 +413,15 @@ test.group('Price Real-world Use Cases', () => {
413
413
  })
414
414
 
415
415
  test('should configure for international marketplace', ({ assert }) => {
416
- const config: PriceConfig = {
416
+ const config: CurrencyConfig = {
417
417
  storageFormat: 'complex_object',
418
418
  allowedCurrencies: ['USD', 'EUR', 'GBP', 'JPY', 'CAD', 'AUD'],
419
419
  decimalPlaces: 2,
420
420
  allowNegative: false,
421
421
  validateCurrencyCode: true,
422
422
  }
423
- const semantic = createPriceSemantic(config)
424
- const errors = validatePriceConfig(config)
423
+ const semantic = createCurrencySemantic(config)
424
+ const errors = validateCurrencyConfig(config)
425
425
 
426
426
  assert.lengthOf(errors, 0)
427
427
  assert.equal(semantic.config?.storageFormat, 'complex_object')
@@ -430,15 +430,15 @@ test.group('Price Real-world Use Cases', () => {
430
430
  })
431
431
 
432
432
  test('should configure for financial system with precision', ({ assert }) => {
433
- const config: PriceConfig = {
433
+ const config: CurrencyConfig = {
434
434
  storageFormat: 'integer_cents',
435
435
  defaultCurrency: 'USD',
436
436
  decimalPlaces: 4,
437
437
  allowNegative: true,
438
438
  validateCurrencyCode: true,
439
439
  }
440
- const semantic = createPriceSemantic(config)
441
- const errors = validatePriceConfig(config)
440
+ const semantic = createCurrencySemantic(config)
441
+ const errors = validateCurrencyConfig(config)
442
442
 
443
443
  assert.lengthOf(errors, 0)
444
444
  assert.equal(semantic.config?.storageFormat, 'integer_cents')
@@ -447,15 +447,15 @@ test.group('Price Real-world Use Cases', () => {
447
447
  })
448
448
 
449
449
  test('should configure for cryptocurrency trading', ({ assert }) => {
450
- const config: PriceConfig = {
450
+ const config: CurrencyConfig = {
451
451
  storageFormat: 'decimal',
452
452
  defaultCurrency: 'BTC',
453
453
  decimalPlaces: 8,
454
454
  allowNegative: false,
455
455
  validateCurrencyCode: false, // Custom crypto currency
456
456
  }
457
- const semantic = createPriceSemantic(config)
458
- const errors = validatePriceConfig(config)
457
+ const semantic = createCurrencySemantic(config)
458
+ const errors = validateCurrencyConfig(config)
459
459
 
460
460
  assert.lengthOf(errors, 0)
461
461
  assert.equal(semantic.config?.defaultCurrency, 'BTC')
@@ -10,8 +10,7 @@ test.group('Derived Semantic Configuration', () => {
10
10
  test('should create semantic with custom config', ({ assert }) => {
11
11
  const config: DerivedConfig = {
12
12
  sourceFields: ['firstName', 'lastName'],
13
- derivationRule: 'concat',
14
- updateOnChange: true,
13
+ transformation: 'concat',
15
14
  allowManualOverride: true,
16
15
  recalculateOnUpdate: false,
17
16
  }
@@ -16,8 +16,6 @@ test.group('Description Semantic Configuration', () => {
16
16
 
17
17
  test('should create semantic with custom config', ({ assert }) => {
18
18
  const config: DescriptionConfig = {
19
- minLength: 10,
20
- maxLength: 1000,
21
19
  allowMarkdown: true,
22
20
  }
23
21
  const semantic = createDescriptionSemantic(config)
@@ -16,7 +16,6 @@ test.group('URL Semantic Configuration', () => {
16
16
 
17
17
  test('should create semantic with custom config', ({ assert }) => {
18
18
  const config: URLConfig = {
19
- allowedProtocols: ['https'],
20
19
  allowedDomains: ['example.com'],
21
20
  requireHTTPS: true,
22
21
  }