@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,76 @@
1
+ import type { AppliedDataSemantic } from '../Semantics.js'
2
+ import { SemanticType } from '../Semantics.js'
3
+
4
+ /**
5
+ * Configuration options for the Derived semantic.
6
+ * Controls source fields, transformation, and recalculation behavior.
7
+ *
8
+ * Use Derived when you need to combine, format, or transform existing field values
9
+ */
10
+ export interface DerivedConfig {
11
+ /**
12
+ * List of source field names this value is derived from.
13
+ */
14
+ sourceFields: string[]
15
+ /**
16
+ * Name of a transformation function to apply to the source fields.
17
+ */
18
+ transformation?: string
19
+ /**
20
+ * Whether to recalculate the value on update (default: true).
21
+ */
22
+ recalculateOnUpdate?: boolean
23
+ /**
24
+ * Whether to allow manual override of the derived value.
25
+ */
26
+ allowManualOverride?: boolean
27
+ /**
28
+ * Custom metadata for the derived field.
29
+ */
30
+ metadata?: Record<string, unknown>
31
+ /**
32
+ * Index signature to allow additional properties.
33
+ */
34
+ [key: string]: unknown
35
+ }
36
+
37
+ /**
38
+ * Type-safe configuration for Derived semantic.
39
+ */
40
+ export interface AppliedDerivedSemantic extends AppliedDataSemantic {
41
+ id: SemanticType.Derived
42
+ config?: DerivedConfig
43
+ }
44
+
45
+ /**
46
+ * Type guard to check if a semantic is a Derived semantic.
47
+ */
48
+ export const isDerivedSemantic = (semantic: AppliedDataSemantic): semantic is AppliedDerivedSemantic => {
49
+ return semantic.id === SemanticType.Derived
50
+ }
51
+
52
+ /**
53
+ * Helper function to create a Derived semantic with configuration.
54
+ */
55
+ export const createDerivedSemantic = (config: DerivedConfig): AppliedDerivedSemantic => {
56
+ const mergedConfig = {
57
+ ...DEFAULT_DERIVED_CONFIG,
58
+ ...config,
59
+ }
60
+ if (config.metadata) {
61
+ mergedConfig.metadata = { ...config.metadata }
62
+ }
63
+
64
+ return {
65
+ id: SemanticType.Derived,
66
+ config: mergedConfig,
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Default configuration for Derived semantic.
72
+ */
73
+ export const DEFAULT_DERIVED_CONFIG: Partial<DerivedConfig> = {
74
+ recalculateOnUpdate: true,
75
+ allowManualOverride: false,
76
+ }
@@ -0,0 +1,55 @@
1
+ import type { AppliedDataSemantic } from '../Semantics.js'
2
+ import { SemanticType } from '../Semantics.js'
3
+
4
+ /**
5
+ * Configuration options for the Description semantic.
6
+ * Controls length, formatting, and markdown support.
7
+ */
8
+ export interface DescriptionConfig {
9
+ /**
10
+ * Custom metadata for the description field.
11
+ */
12
+ metadata?: Record<string, unknown>
13
+ /**
14
+ * Index signature to allow additional properties.
15
+ */
16
+ [key: string]: unknown
17
+ }
18
+
19
+ /**
20
+ * Type-safe configuration for Description semantic.
21
+ */
22
+ export interface AppliedDescriptionSemantic extends AppliedDataSemantic {
23
+ id: SemanticType.Description
24
+ config?: DescriptionConfig
25
+ }
26
+
27
+ /**
28
+ * Type guard to check if a semantic is a Description semantic.
29
+ */
30
+ export const isDescriptionSemantic = (semantic: AppliedDataSemantic): semantic is AppliedDescriptionSemantic => {
31
+ return semantic.id === SemanticType.Description
32
+ }
33
+
34
+ /**
35
+ * Helper function to create a Description semantic with configuration.
36
+ */
37
+ export const createDescriptionSemantic = (config: DescriptionConfig = {}): AppliedDescriptionSemantic => {
38
+ const mergedConfig = {
39
+ ...DEFAULT_DESCRIPTION_CONFIG,
40
+ ...config,
41
+ }
42
+ if (config.metadata) {
43
+ mergedConfig.metadata = { ...config.metadata }
44
+ }
45
+
46
+ return {
47
+ id: SemanticType.Description,
48
+ config: mergedConfig,
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Default configuration for Description semantic.
54
+ */
55
+ export const DEFAULT_DESCRIPTION_CONFIG: DescriptionConfig = {}
@@ -0,0 +1,90 @@
1
+ import type { AppliedDataSemantic } from '../Semantics.js'
2
+ import { SemanticType } from '../Semantics.js'
3
+
4
+ /**
5
+ * Configuration options for the Email semantic.
6
+ * Controls validation, allowed domains, and verification.
7
+ */
8
+ export interface EmailConfig {
9
+ /**
10
+ * List of allowed email domains (e.g., ['example.com']).
11
+ */
12
+ allowedDomains?: string[]
13
+ /**
14
+ * Whether email verification is required.
15
+ */
16
+ requireVerification?: boolean
17
+ /**
18
+ * Method to use for verification: 'email', 'sms', or 'none'.
19
+ */
20
+ verificationMethod?: 'email' | 'sms' | 'none'
21
+ /**
22
+ * Whether to allow subaddressing (user+tag@domain.com).
23
+ */
24
+ allowSubaddressing?: boolean
25
+ /**
26
+ * Whether to allow internationalized email addresses.
27
+ *
28
+ * - When true (default): Allows email addresses with non-ASCII characters in the domain part,
29
+ * like user@münchen.de or user@café.com
30
+ * - When false: Only allows ASCII characters in the domain part, like user@example.com
31
+ *
32
+ * Why it exists:
33
+ * - Internationalization: Many countries have domain names with native characters (like German umlauts,
34
+ * French accents, etc.)
35
+ * - RFC 6531: The standard for internationalized email addresses
36
+ * - Validation flexibility: Some systems may need to restrict to ASCII-only domains for compatibility reasons
37
+ */
38
+ allowInternational?: boolean
39
+ /**
40
+ * Custom metadata for the email field.
41
+ */
42
+ metadata?: Record<string, unknown>
43
+ /**
44
+ * Index signature to allow additional properties.
45
+ */
46
+ [key: string]: unknown
47
+ }
48
+
49
+ /**
50
+ * Type-safe configuration for Email semantic.
51
+ */
52
+ export interface AppliedEmailSemantic extends AppliedDataSemantic {
53
+ id: SemanticType.Email
54
+ config?: EmailConfig
55
+ }
56
+
57
+ /**
58
+ * Type guard to check if a semantic is an Email semantic.
59
+ */
60
+ export const isEmailSemantic = (semantic: AppliedDataSemantic): semantic is AppliedEmailSemantic => {
61
+ return semantic.id === SemanticType.Email
62
+ }
63
+
64
+ /**
65
+ * Helper function to create an Email semantic with configuration.
66
+ */
67
+ export const createEmailSemantic = (config: EmailConfig = {}): AppliedEmailSemantic => {
68
+ const mergedConfig = {
69
+ ...DEFAULT_EMAIL_CONFIG,
70
+ ...config,
71
+ }
72
+ if (config.metadata) {
73
+ mergedConfig.metadata = { ...config.metadata }
74
+ }
75
+
76
+ return {
77
+ id: SemanticType.Email,
78
+ config: mergedConfig,
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Default configuration for Email semantic.
84
+ */
85
+ export const DEFAULT_EMAIL_CONFIG: EmailConfig = {
86
+ requireVerification: false,
87
+ verificationMethod: 'email',
88
+ allowSubaddressing: true,
89
+ allowInternational: true,
90
+ }
@@ -0,0 +1,274 @@
1
+ import type { AppliedDataSemantic } from '../Semantics.js'
2
+ import { SemanticType } from '../Semantics.js'
3
+
4
+ /**
5
+ * Supported coordinate formats for geospatial data.
6
+ */
7
+ export enum GeospatialCoordinateFormat {
8
+ /**
9
+ * Latitude, Longitude format: "40.7128,-74.0060"
10
+ */
11
+ LatLon = 'lat,lon',
12
+ /**
13
+ * Longitude, Latitude format: "-74.0060,40.7128"
14
+ */
15
+ LonLat = 'lon,lat',
16
+ /**
17
+ * PostGIS POINT format: "POINT(-74.0060 40.7128)"
18
+ */
19
+ PostGIS = 'postgis',
20
+ /**
21
+ * Degree format with cardinal directions: "40.7128°N, 74.0060°W"
22
+ */
23
+ Degree = 'degree',
24
+ /**
25
+ * Well-Known Text (WKT) format: "POINT(-74.0060 40.7128)"
26
+ */
27
+ WKT = 'wkt',
28
+ /**
29
+ * GeoJSON format: {"type": "Point", "coordinates": [-74.0060, 40.7128]}
30
+ */
31
+ GeoJSON = 'geojson',
32
+ }
33
+
34
+ /**
35
+ * Supported distance units for spatial queries.
36
+ */
37
+ export enum GeospatialDistanceUnit {
38
+ /**
39
+ * Meters (SI unit)
40
+ */
41
+ Meters = 'meters',
42
+ /**
43
+ * Kilometers
44
+ */
45
+ Kilometers = 'kilometers',
46
+ /**
47
+ * Miles (imperial)
48
+ */
49
+ Miles = 'miles',
50
+ /**
51
+ * Feet (imperial)
52
+ */
53
+ Feet = 'feet',
54
+ /**
55
+ * Yards (imperial)
56
+ */
57
+ Yards = 'yards',
58
+ /**
59
+ * Nautical miles
60
+ */
61
+ NauticalMiles = 'nautical_miles',
62
+ }
63
+
64
+ /**
65
+ * Supported spatial reference systems.
66
+ */
67
+ export enum GeospatialSpatialReferenceSystem {
68
+ /**
69
+ * WGS84 (World Geodetic System 1984) - Most common for GPS coordinates
70
+ */
71
+ WGS84 = 'EPSG:4326',
72
+ /**
73
+ * Web Mercator - Common for web mapping
74
+ */
75
+ WebMercator = 'EPSG:3857',
76
+ /**
77
+ * NAD83 (North American Datum 1983)
78
+ */
79
+ NAD83 = 'EPSG:4269',
80
+ /**
81
+ * NAD27 (North American Datum 1927)
82
+ */
83
+ NAD27 = 'EPSG:4267',
84
+ }
85
+
86
+ /**
87
+ * Configuration options for the GeospatialCoordinates semantic.
88
+ * These options control how the runtime handles geospatial data and queries.
89
+ */
90
+ export interface GeospatialCoordinatesConfig {
91
+ /**
92
+ * The coordinate format expected for input/output.
93
+ * Defaults to 'lat,lon' if not specified.
94
+ */
95
+ format?: GeospatialCoordinateFormat
96
+
97
+ /**
98
+ * The spatial reference system (SRS) for the coordinates.
99
+ * Defaults to WGS84 (EPSG:4326) if not specified.
100
+ */
101
+ spatialReferenceSystem?: GeospatialSpatialReferenceSystem
102
+
103
+ /**
104
+ * The default distance unit for spatial queries.
105
+ * Defaults to 'meters' if not specified.
106
+ */
107
+ defaultDistanceUnit?: GeospatialDistanceUnit
108
+
109
+ /**
110
+ * Whether to enable automatic spatial indexing.
111
+ * Defaults to true if not specified.
112
+ */
113
+ enableSpatialIndexing?: boolean
114
+
115
+ /**
116
+ * Whether to enable automatic coordinate validation.
117
+ * Defaults to true if not specified.
118
+ */
119
+ enableValidation?: boolean
120
+
121
+ /**
122
+ * Custom validation rules for coordinate bounds.
123
+ * If not specified, uses standard latitude (-90 to 90) and longitude (-180 to 180) bounds.
124
+ */
125
+ validationBounds?: {
126
+ /**
127
+ * Minimum latitude value
128
+ */
129
+ minLatitude?: number
130
+ /**
131
+ * Maximum latitude value
132
+ */
133
+ maxLatitude?: number
134
+ /**
135
+ * Minimum longitude value
136
+ */
137
+ minLongitude?: number
138
+ /**
139
+ * Maximum longitude value
140
+ */
141
+ maxLongitude?: number
142
+ }
143
+
144
+ /**
145
+ * Whether to enable automatic PostGIS integration when using PostgreSQL.
146
+ * Defaults to true if not specified.
147
+ */
148
+ enablePostGISIntegration?: boolean
149
+
150
+ /**
151
+ * The PostGIS geometry type to use for storage.
152
+ * Defaults to 'POINT' if not specified.
153
+ */
154
+ postGISGeometryType?: 'POINT' | 'LINESTRING' | 'POLYGON' | 'MULTIPOINT' | 'MULTILINESTRING' | 'MULTIPOLYGON'
155
+
156
+ /**
157
+ * Whether to enable distance-based query endpoints.
158
+ * Defaults to true if not specified.
159
+ */
160
+ enableDistanceQueries?: boolean
161
+
162
+ /**
163
+ * Maximum distance allowed in distance queries (in the default distance unit).
164
+ * Defaults to 100000 (100km) if not specified.
165
+ */
166
+ maxQueryDistance?: number
167
+
168
+ /**
169
+ * Whether to enable bounding box query endpoints.
170
+ * Defaults to true if not specified.
171
+ */
172
+ enableBoundingBoxQueries?: boolean
173
+
174
+ /**
175
+ * Whether to enable polygon intersection query endpoints.
176
+ * Defaults to false if not specified.
177
+ */
178
+ enablePolygonQueries?: boolean
179
+
180
+ /**
181
+ * Custom API endpoint prefix for geospatial queries.
182
+ * Defaults to '/nearby' if not specified.
183
+ */
184
+ apiEndpointPrefix?: string
185
+
186
+ /**
187
+ * Whether to include elevation data in coordinates (3D coordinates).
188
+ * Defaults to false if not specified.
189
+ */
190
+ includeElevation?: boolean
191
+
192
+ /**
193
+ * Precision for coordinate storage (number of decimal places).
194
+ * Defaults to 6 if not specified.
195
+ */
196
+ coordinatePrecision?: number
197
+
198
+ /**
199
+ * Whether to enable reverse geocoding capabilities.
200
+ * Defaults to false if not specified.
201
+ */
202
+ enableReverseGeocoding?: boolean
203
+
204
+ /**
205
+ * Custom metadata for the geospatial field.
206
+ */
207
+ metadata?: Record<string, unknown>
208
+
209
+ /**
210
+ * Index signature to allow additional properties.
211
+ */
212
+ [key: string]: unknown
213
+ }
214
+
215
+ /**
216
+ * Type-safe configuration for GeospatialCoordinates semantic.
217
+ */
218
+ export interface AppliedGeospatialCoordinatesSemantic extends AppliedDataSemantic {
219
+ id: SemanticType.GeospatialCoordinates
220
+ config?: GeospatialCoordinatesConfig
221
+ }
222
+
223
+ /**
224
+ * Type guard to check if a semantic is a GeospatialCoordinates semantic.
225
+ */
226
+ export const isGeospatialCoordinatesSemantic = (
227
+ semantic: AppliedDataSemantic
228
+ ): semantic is AppliedGeospatialCoordinatesSemantic => {
229
+ return semantic.id === SemanticType.GeospatialCoordinates
230
+ }
231
+
232
+ /**
233
+ * Helper function to create a GeospatialCoordinates semantic with configuration.
234
+ */
235
+ export const createGeospatialCoordinatesSemantic = (
236
+ config: GeospatialCoordinatesConfig = {}
237
+ ): AppliedGeospatialCoordinatesSemantic => {
238
+ const mergedConfig = {
239
+ ...DEFAULT_GEOSPATIAL_CONFIG,
240
+ ...config,
241
+ }
242
+ if (config.metadata) {
243
+ mergedConfig.metadata = { ...config.metadata }
244
+ }
245
+ if (config.validationBounds) {
246
+ mergedConfig.validationBounds = { ...config.validationBounds }
247
+ }
248
+
249
+ return {
250
+ id: SemanticType.GeospatialCoordinates,
251
+ config: mergedConfig,
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Default configuration for GeospatialCoordinates semantic.
257
+ */
258
+ export const DEFAULT_GEOSPATIAL_CONFIG: GeospatialCoordinatesConfig = {
259
+ format: GeospatialCoordinateFormat.LatLon,
260
+ spatialReferenceSystem: GeospatialSpatialReferenceSystem.WGS84,
261
+ defaultDistanceUnit: GeospatialDistanceUnit.Meters,
262
+ enableSpatialIndexing: true,
263
+ enableValidation: true,
264
+ enablePostGISIntegration: true,
265
+ postGISGeometryType: 'POINT',
266
+ enableDistanceQueries: true,
267
+ maxQueryDistance: 100000,
268
+ enableBoundingBoxQueries: true,
269
+ enablePolygonQueries: false,
270
+ apiEndpointPrefix: '/nearby',
271
+ includeElevation: false,
272
+ coordinatePrecision: 6,
273
+ enableReverseGeocoding: false,
274
+ }
@@ -0,0 +1,121 @@
1
+ import type { AppliedDataSemantic } from '../Semantics.js'
2
+ import { SemanticType } from '../Semantics.js'
3
+
4
+ /**
5
+ * Configuration options for the HTML semantic.
6
+ * Controls rendering, sanitization, and allowed HTML features.
7
+ */
8
+ export interface HTMLConfig {
9
+ /**
10
+ * List of allowed HTML tags in the content.
11
+ */
12
+ allowedTags?: string[]
13
+ /**
14
+ * Maximum length of the HTML content.
15
+ */
16
+ maxLength?: number
17
+ /**
18
+ * Render mode: 'html', 'text', or 'both'.
19
+ */
20
+ renderMode?: 'html' | 'text' | 'both'
21
+ /**
22
+ * Sanitization level: 'strict', 'moderate', or 'none'.
23
+ */
24
+ sanitizeLevel?: 'strict' | 'moderate' | 'none'
25
+ /**
26
+ * Whether to allow images in HTML.
27
+ */
28
+ allowImages?: boolean
29
+ /**
30
+ * Whether to allow links in HTML.
31
+ */
32
+ allowLinks?: boolean
33
+ /**
34
+ * Whether to allow tables in HTML.
35
+ */
36
+ allowTables?: boolean
37
+ /**
38
+ * Whether to allow forms in HTML.
39
+ */
40
+ allowForms?: boolean
41
+ /**
42
+ * Whether to allow scripts in HTML.
43
+ */
44
+ allowScripts?: boolean
45
+ /**
46
+ * Whether to allow iframes in HTML.
47
+ */
48
+ allowIframes?: boolean
49
+ /**
50
+ * Whether to allow embedded content (video, audio, etc.).
51
+ */
52
+ allowEmbedded?: boolean
53
+ /**
54
+ * Whether to allow CSS styles in HTML.
55
+ */
56
+ allowStyles?: boolean
57
+ /**
58
+ * Whether to allow data attributes in HTML.
59
+ */
60
+ allowDataAttributes?: boolean
61
+ /**
62
+ * Custom metadata for the HTML field.
63
+ */
64
+ metadata?: Record<string, unknown>
65
+ /**
66
+ * Index signature to allow additional properties.
67
+ */
68
+ [key: string]: unknown
69
+ }
70
+
71
+ /**
72
+ * Type-safe configuration for HTML semantic.
73
+ */
74
+ export interface AppliedHTMLSemantic extends AppliedDataSemantic {
75
+ id: SemanticType.HTML
76
+ config?: HTMLConfig
77
+ }
78
+
79
+ /**
80
+ * Type guard to check if a semantic is an HTML semantic.
81
+ */
82
+ export const isHTMLSemantic = (semantic: AppliedDataSemantic): semantic is AppliedHTMLSemantic => {
83
+ return semantic.id === SemanticType.HTML
84
+ }
85
+
86
+ /**
87
+ * Helper function to create an HTML semantic with configuration.
88
+ */
89
+ export const createHTMLSemantic = (config: HTMLConfig = {}): AppliedHTMLSemantic => {
90
+ const mergedConfig = {
91
+ ...DEFAULT_HTML_CONFIG,
92
+ ...config,
93
+ }
94
+ if (config.metadata) {
95
+ mergedConfig.metadata = { ...config.metadata }
96
+ }
97
+
98
+ return {
99
+ id: SemanticType.HTML,
100
+ config: mergedConfig,
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Default configuration for HTML semantic.
106
+ */
107
+ export const DEFAULT_HTML_CONFIG: HTMLConfig = {
108
+ allowedTags: ['b', 'i', 'em', 'strong', 'a', 'ul', 'ol', 'li', 'p', 'br', 'pre', 'code', 'div', 'span'],
109
+ maxLength: 10000,
110
+ renderMode: 'html',
111
+ sanitizeLevel: 'strict',
112
+ allowImages: true,
113
+ allowLinks: true,
114
+ allowTables: true,
115
+ allowForms: false,
116
+ allowScripts: false,
117
+ allowIframes: false,
118
+ allowEmbedded: false,
119
+ allowStyles: false,
120
+ allowDataAttributes: false,
121
+ }