@api-client/core 0.17.5 → 0.17.7

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 (37) hide show
  1. package/build/src/modeling/Semantics.d.ts +8 -4
  2. package/build/src/modeling/Semantics.d.ts.map +1 -1
  3. package/build/src/modeling/Semantics.js +10 -5
  4. package/build/src/modeling/Semantics.js.map +1 -1
  5. package/build/src/modeling/definitions/Email.d.ts +2 -2
  6. package/build/src/modeling/definitions/Email.d.ts.map +1 -1
  7. package/build/src/modeling/definitions/Email.js.map +1 -1
  8. package/build/src/modeling/definitions/GeospatialCoordinates.d.ts +46 -1
  9. package/build/src/modeling/definitions/GeospatialCoordinates.d.ts.map +1 -1
  10. package/build/src/modeling/definitions/GeospatialCoordinates.js.map +1 -1
  11. package/build/src/modeling/definitions/Phone.d.ts +5 -7
  12. package/build/src/modeling/definitions/Phone.d.ts.map +1 -1
  13. package/build/src/modeling/definitions/Phone.js +2 -2
  14. package/build/src/modeling/definitions/Phone.js.map +1 -1
  15. package/build/src/modeling/definitions/PublicUniqueName.d.ts +1 -9
  16. package/build/src/modeling/definitions/PublicUniqueName.d.ts.map +1 -1
  17. package/build/src/modeling/definitions/PublicUniqueName.js +0 -1
  18. package/build/src/modeling/definitions/PublicUniqueName.js.map +1 -1
  19. package/build/src/modeling/definitions/SKU.d.ts +4 -1
  20. package/build/src/modeling/definitions/SKU.d.ts.map +1 -1
  21. package/build/src/modeling/definitions/SKU.js.map +1 -1
  22. package/build/src/modeling/definitions/URL.d.ts +1 -4
  23. package/build/src/modeling/definitions/URL.d.ts.map +1 -1
  24. package/build/src/modeling/definitions/URL.js +0 -1
  25. package/build/src/modeling/definitions/URL.js.map +1 -1
  26. package/build/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +2 -2
  28. package/src/modeling/Semantics.ts +10 -5
  29. package/src/modeling/definitions/Email.ts +2 -2
  30. package/src/modeling/definitions/GeospatialCoordinates.ts +46 -1
  31. package/src/modeling/definitions/Phone.ts +6 -8
  32. package/src/modeling/definitions/PublicUniqueName.ts +1 -10
  33. package/src/modeling/definitions/SKU.ts +4 -1
  34. package/src/modeling/definitions/URL.ts +1 -5
  35. package/tests/unit/modeling/definitions/derived.spec.ts +1 -2
  36. package/tests/unit/modeling/definitions/url.spec.ts +0 -1
  37. package/tests/unit/modeling/semantic-configs.spec.ts +1 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.17.5",
4
+ "version": "0.17.7",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -88,7 +88,7 @@
88
88
  "@esm-bundle/chai": "^4.3.4-fix.0",
89
89
  "@metrichor/jmespath": "^0.3.1",
90
90
  "@pawel-up/data-mock": "^0.4.0",
91
- "@pawel-up/jexl": "^3.0.0",
91
+ "@pawel-up/jexl": "^4.0.1",
92
92
  "@xmldom/xmldom": "^0.9.7",
93
93
  "amf-json-ld-lib": "^0.0.15",
94
94
  "chalk": "^5.4.1",
@@ -50,11 +50,12 @@ export enum SemanticType {
50
50
  */
51
51
  DeletedFlag = 'Semantic#DeletedFlag',
52
52
  /**
53
- * Designates a Data Property as a unique public identifier for a resource (the slug).
53
+ * Designates a Data Property as a public identifier for a resource (the slug).
54
54
  * This is often used in URLs to provide a user-friendly way to access the resource.
55
55
  * For example, a blog post might have a public unique name like "my-first-post".
56
- * A URL-friendly text field. The runtime automatically generates a unique, URL-safe string from another field (like a title or name). The user needs to specify which field is used to generate
57
- * the slug.
56
+ * The runtime automatically generates a URL-safe string from another field (like a title).
57
+ * By default, slugs are generated to be unique, but the configuration allows for duplicates
58
+ * in scenarios where uniqueness is handled by a combination of fields (e.g., year and slug).
58
59
  */
59
60
  PublicUniqueName = 'Semantic#PublicUniqueName',
60
61
  /**
@@ -149,7 +150,10 @@ export enum SemanticType {
149
150
  /**
150
151
  * Annotates a field as a monetary value with currency support and precision control.
151
152
  * Can store simple decimal amounts or complex objects with amount and currency.
152
- * Enforces proper decimal handling to avoid floating-point errors.
153
+ *
154
+ * As a semantic, it provides flexibility by annotating a base `number` or `string` type,
155
+ * allowing for different storage strategies (e.g., decimal, integer cents, or a JSON object)
156
+ * while maintaining a consistent API for currency operations.
153
157
  */
154
158
  Currency = 'Semantic#Currency',
155
159
  /**
@@ -623,13 +627,14 @@ export const DataSemantics: Record<SemanticType, DataSemantic> = {
623
627
  // Computed Values
624
628
  //
625
629
 
630
+ // Calculated field can be added to any data type as we can compute any value.
626
631
  [SemanticType.Calculated]: {
627
632
  id: SemanticType.Calculated,
628
633
  displayName: 'Calculated',
629
634
  scope: SemanticScope.Property,
630
635
  description: 'Auto-calculated field value',
631
636
  category: SemanticCategory.Computed,
632
- applicableDataTypes: ['string'],
637
+ applicableDataTypes: ['string', 'number', 'boolean', 'date', 'datetime', 'time', 'binary'],
633
638
  hasConfig: true,
634
639
  },
635
640
  [SemanticType.Derived]: {
@@ -15,9 +15,9 @@ export interface EmailConfig {
15
15
  */
16
16
  requireVerification?: boolean
17
17
  /**
18
- * Method to use for verification: 'email', 'sms', or 'none'.
18
+ * Method to use for verification: 'email' or 'sms'.
19
19
  */
20
- verificationMethod?: 'email' | 'sms' | 'none'
20
+ verificationMethod?: 'email' | 'sms'
21
21
  /**
22
22
  * Whether to allow subaddressing (user+tag@domain.com).
23
23
  */
@@ -97,12 +97,16 @@ export interface GeospatialCoordinatesConfig {
97
97
  /**
98
98
  * The spatial reference system (SRS) for the coordinates.
99
99
  * Defaults to WGS84 (EPSG:4326) if not specified.
100
+ *
101
+ * Note: If `format` is set to `GeoJSON`, this value is automatically locked to `WGS84`
102
+ * as per the GeoJSON specification (RFC 7946).
100
103
  */
101
104
  spatialReferenceSystem?: GeospatialSpatialReferenceSystem
102
105
 
103
106
  /**
104
107
  * The default distance unit for spatial queries.
105
108
  * Defaults to 'meters' if not specified.
109
+ * Only applicable when `enableDistanceQueries` is true.
106
110
  */
107
111
  defaultDistanceUnit?: GeospatialDistanceUnit
108
112
 
@@ -120,7 +124,8 @@ export interface GeospatialCoordinatesConfig {
120
124
 
121
125
  /**
122
126
  * Custom validation rules for coordinate bounds.
123
- * If not specified, uses standard latitude (-90 to 90) and longitude (-180 to 180) bounds.
127
+ * Values are in decimal degrees.
128
+ * If not specified, uses standard latitude (-90.0 to 90.0) and longitude (-180.0 to 180.0) bounds.
124
129
  */
125
130
  validationBounds?: {
126
131
  /**
@@ -144,35 +149,55 @@ export interface GeospatialCoordinatesConfig {
144
149
  /**
145
150
  * Whether to enable automatic PostGIS integration when using PostgreSQL.
146
151
  * Defaults to true if not specified.
152
+ *
153
+ * This is an advanced setting. For UIs targeting non-technical users,
154
+ * it is safe to hide this option and keep it enabled. The backend should
155
+ * gracefully handle cases where the database is not PostgreSQL.
147
156
  */
148
157
  enablePostGISIntegration?: boolean
149
158
 
150
159
  /**
151
160
  * The PostGIS geometry type to use for storage.
152
161
  * Defaults to 'POINT' if not specified.
162
+ * This choice fundamentally defines the shape of the data and the types of queries that can be performed.
163
+ *
164
+ * - **POINT**: For single locations (e.g., a store, a user's location).
165
+ * - **LINESTRING**: For paths or routes (e.g., a delivery route, a hiking trail).
166
+ * - **POLYGON**: For defined areas (e.g., a delivery zone, a sales territory, a city boundary).
167
+ * - **MULTI***: For collections of the above types (e.g., all stores in a chain as a MULTIPOINT).
153
168
  */
154
169
  postGISGeometryType?: 'POINT' | 'LINESTRING' | 'POLYGON' | 'MULTIPOINT' | 'MULTILINESTRING' | 'MULTIPOLYGON'
155
170
 
156
171
  /**
157
172
  * Whether to enable distance-based query endpoints.
173
+ * This is not mutually exclusive with other query types and is useful for all geometry types.
158
174
  * Defaults to true if not specified.
175
+ *
176
+ * - For **POINT**: Finds points within a certain radius.
177
+ * - For **POLYGON**: Finds polygons that are within a certain distance of a point
178
+ * (e.g., "find all parks within 5 miles").
179
+ * - For **LINESTRING**: Finds paths/routes within a certain distance of a point
180
+ * (e.g., "find all subway lines near me").
159
181
  */
160
182
  enableDistanceQueries?: boolean
161
183
 
162
184
  /**
163
185
  * Maximum distance allowed in distance queries (in the default distance unit).
164
186
  * Defaults to 100000 (100km) if not specified.
187
+ * Only applicable when `enableDistanceQueries` is true.
165
188
  */
166
189
  maxQueryDistance?: number
167
190
 
168
191
  /**
169
192
  * Whether to enable bounding box query endpoints.
193
+ * This is not mutually exclusive with other query types.
170
194
  * Defaults to true if not specified.
171
195
  */
172
196
  enableBoundingBoxQueries?: boolean
173
197
 
174
198
  /**
175
199
  * Whether to enable polygon intersection query endpoints.
200
+ * This is not mutually exclusive with other query types.
176
201
  * Defaults to false if not specified.
177
202
  */
178
203
  enablePolygonQueries?: boolean
@@ -180,12 +205,26 @@ export interface GeospatialCoordinatesConfig {
180
205
  /**
181
206
  * Custom API endpoint prefix for geospatial queries.
182
207
  * Defaults to '/nearby' if not specified.
208
+ * Only applicable if `enableDistanceQueries`, `enableBoundingBoxQueries`,
209
+ * or `enablePolygonQueries` is true.
210
+ *
211
+ * The generated endpoints would be:
212
+ * - **Distance Query**: `GET {apiEndpointPrefix}`
213
+ * - **Bounding Box Query**: `GET {apiEndpointPrefix}/bbox`
214
+ * - **Polygon Query**: `POST {apiEndpointPrefix}/polygon`
183
215
  */
184
216
  apiEndpointPrefix?: string
185
217
 
186
218
  /**
187
219
  * Whether to include elevation data in coordinates (3D coordinates).
188
220
  * Defaults to false if not specified.
221
+ * When true, a third value for elevation is expected in the coordinate data.
222
+ *
223
+ * - **LatLon**: `"40.7128,-74.0060,10"` (latitude, longitude, elevation)
224
+ * - **PostGIS/WKT**: `"POINT Z (-74.0060 40.7128 10)"`
225
+ * - **GeoJSON**: `{"type": "Point", "coordinates": [-74.0060, 40.7128, 10]}`
226
+ *
227
+ * The unit for elevation is determined by `defaultDistanceUnit`.
189
228
  */
190
229
  includeElevation?: boolean
191
230
 
@@ -198,6 +237,12 @@ export interface GeospatialCoordinatesConfig {
198
237
  /**
199
238
  * Whether to enable reverse geocoding capabilities.
200
239
  * Defaults to false if not specified.
240
+ *
241
+ * When enabled, the system can convert geographic coordinates (e.g., `40.7128, -74.0060`)
242
+ * into a human-readable address (e.g., "New York, NY, USA").
243
+ *
244
+ * This often requires integration with an external geocoding service and may have
245
+ * associated costs or usage limits.
201
246
  */
202
247
  enableReverseGeocoding?: boolean
203
248
 
@@ -15,18 +15,17 @@ export interface PhoneConfig {
15
15
 
16
16
  /**
17
17
  * Whether the phone number must include a country code.
18
- * Defaults to true for E.164 format.
18
+ * Defaults to true for international format.
19
19
  */
20
20
  requireCountryCode?: boolean
21
21
 
22
22
  /**
23
23
  * Format for phone number validation and display.
24
- * - 'E.164': International format with + prefix (e.g., +1234567890)
25
24
  * - 'national': Country-specific format without country code
26
- * - 'international': International format with country code
25
+ * - 'international': E.164 international format with + prefix (e.g., +1234567890)
27
26
  * - 'custom': Use customFormat pattern
28
27
  */
29
- format?: 'E.164' | 'national' | 'international' | 'custom'
28
+ format?: 'national' | 'international' | 'custom'
30
29
 
31
30
  /**
32
31
  * Custom format pattern for phone number validation.
@@ -51,9 +50,8 @@ export interface PhoneConfig {
51
50
  * Method to use for phone verification.
52
51
  * - 'sms': Send verification code via SMS
53
52
  * - 'call': Make verification call
54
- * - 'none': No verification required
55
53
  */
56
- verificationMethod?: 'sms' | 'call' | 'none'
54
+ verificationMethod?: 'sms' | 'call'
57
55
 
58
56
  /**
59
57
  * Custom metadata for the phone field.
@@ -105,11 +103,11 @@ export const createPhoneSemantic = (config: PhoneConfig = {}): AppliedPhoneSeman
105
103
 
106
104
  /**
107
105
  * Default configuration for Phone semantic.
108
- * Uses E.164 format with country code required and SMS verification.
106
+ * Uses international format with country code required and SMS verification.
109
107
  */
110
108
  export const DEFAULT_PHONE_CONFIG: PhoneConfig = {
111
109
  requireCountryCode: true,
112
- format: 'E.164',
110
+ format: 'international',
113
111
  allowExtension: false,
114
112
  requireVerification: false,
115
113
  verificationMethod: 'sms',
@@ -7,7 +7,7 @@ import { SemanticType } from '../Semantics.js'
7
7
  */
8
8
  export interface PublicUniqueNameConfig {
9
9
  /**
10
- * The source field to generate the slug from (e.g., 'title').
10
+ * The key of the source field to generate the slug from.
11
11
  * Default to the field that is annotated with the Title semantic.
12
12
  */
13
13
  sourceField?: string
@@ -15,10 +15,6 @@ export interface PublicUniqueNameConfig {
15
15
  * Separator character to use in the slug (default: '-').
16
16
  */
17
17
  separator?: string
18
- /**
19
- * Maximum length of the slug (default: 64).
20
- */
21
- maxLength?: number
22
18
  /**
23
19
  * Whether the slug is case sensitive (default: false).
24
20
  */
@@ -27,10 +23,6 @@ export interface PublicUniqueNameConfig {
27
23
  * Whether to allow Unicode characters in the slug (default: false).
28
24
  */
29
25
  allowUnicode?: boolean
30
- /**
31
- * Name of a custom generator function to use for slug creation.
32
- */
33
- customGenerator?: string
34
26
  /**
35
27
  * Whether to allow duplicate slugs (default: false).
36
28
  */
@@ -91,7 +83,6 @@ export const createPublicUniqueNameSemantic = (
91
83
  */
92
84
  export const DEFAULT_PUBLIC_UNIQUE_NAME_CONFIG: PublicUniqueNameConfig = {
93
85
  separator: '-',
94
- maxLength: 64,
95
86
  caseSensitive: false,
96
87
  allowUnicode: false,
97
88
  allowDuplicates: false,
@@ -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
 
@@ -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,
@@ -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,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
  }
@@ -287,7 +287,7 @@ test.group('Semantic Configurations', () => {
287
287
  test('Phone: should create semantic with custom config', ({ assert }) => {
288
288
  const config: PhoneConfig = {
289
289
  allowedCountries: ['US', 'CA'],
290
- format: 'E.164',
290
+ format: 'international',
291
291
  requireVerification: true,
292
292
  }
293
293
  const semantic = createPhoneSemantic(config)
@@ -308,7 +308,6 @@ test.group('Semantic Configurations', () => {
308
308
 
309
309
  test('URL: should create semantic with custom config', ({ assert }) => {
310
310
  const config: URLConfig = {
311
- allowedProtocols: ['https'],
312
311
  allowedDomains: ['example.com'],
313
312
  requireHTTPS: true,
314
313
  }