@api-client/core 0.15.1 → 0.16.1
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.
- package/TESTING_READY.md +114 -0
- package/TESTING_SETUP.md +198 -0
- package/build/src/modeling/Semantics.d.ts +126 -2
- package/build/src/modeling/Semantics.d.ts.map +1 -1
- package/build/src/modeling/Semantics.js +281 -13
- package/build/src/modeling/Semantics.js.map +1 -1
- package/build/src/modeling/definitions/Calculated.d.ts +54 -0
- package/build/src/modeling/definitions/Calculated.d.ts.map +1 -0
- package/build/src/modeling/definitions/Calculated.js +31 -0
- package/build/src/modeling/definitions/Calculated.js.map +1 -0
- package/build/src/modeling/definitions/Categories.d.ts +60 -0
- package/build/src/modeling/definitions/Categories.d.ts.map +1 -0
- package/build/src/modeling/definitions/Categories.js +33 -0
- package/build/src/modeling/definitions/Categories.js.map +1 -0
- package/build/src/modeling/definitions/Derived.d.ts +54 -0
- package/build/src/modeling/definitions/Derived.d.ts.map +1 -0
- package/build/src/modeling/definitions/Derived.js +31 -0
- package/build/src/modeling/definitions/Derived.js.map +1 -0
- package/build/src/modeling/definitions/Description.d.ts +36 -0
- package/build/src/modeling/definitions/Description.d.ts.map +1 -0
- package/build/src/modeling/definitions/Description.js +28 -0
- package/build/src/modeling/definitions/Description.js.map +1 -0
- package/build/src/modeling/definitions/Email.d.ts +66 -0
- package/build/src/modeling/definitions/Email.d.ts.map +1 -0
- package/build/src/modeling/definitions/Email.js +33 -0
- package/build/src/modeling/definitions/Email.js.map +1 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.d.ts +212 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.d.ts.map +1 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.js +129 -0
- package/build/src/modeling/definitions/GeospatialCoordinates.js.map +1 -0
- package/build/src/modeling/definitions/HTML.d.ts +88 -0
- package/build/src/modeling/definitions/HTML.d.ts.map +1 -0
- package/build/src/modeling/definitions/HTML.js +42 -0
- package/build/src/modeling/definitions/HTML.js.map +1 -0
- package/build/src/modeling/definitions/Markdown.d.ts +84 -0
- package/build/src/modeling/definitions/Markdown.d.ts.map +1 -0
- package/build/src/modeling/definitions/Markdown.js +41 -0
- package/build/src/modeling/definitions/Markdown.js.map +1 -0
- package/build/src/modeling/definitions/Password.d.ts +112 -0
- package/build/src/modeling/definitions/Password.d.ts.map +1 -0
- package/build/src/modeling/definitions/Password.js +57 -0
- package/build/src/modeling/definitions/Password.js.map +1 -0
- package/build/src/modeling/definitions/Phone.d.ts +83 -0
- package/build/src/modeling/definitions/Phone.d.ts.map +1 -0
- package/build/src/modeling/definitions/Phone.js +39 -0
- package/build/src/modeling/definitions/Phone.js.map +1 -0
- package/build/src/modeling/definitions/Price.d.ts +102 -0
- package/build/src/modeling/definitions/Price.d.ts.map +1 -0
- package/build/src/modeling/definitions/Price.js +99 -0
- package/build/src/modeling/definitions/Price.js.map +1 -0
- package/build/src/modeling/definitions/PublicUniqueName.d.ts +69 -0
- package/build/src/modeling/definitions/PublicUniqueName.d.ts.map +1 -0
- package/build/src/modeling/definitions/PublicUniqueName.js +34 -0
- package/build/src/modeling/definitions/PublicUniqueName.js.map +1 -0
- package/build/src/modeling/definitions/SKU.d.ts +127 -0
- package/build/src/modeling/definitions/SKU.d.ts.map +1 -0
- package/build/src/modeling/definitions/SKU.js +142 -0
- package/build/src/modeling/definitions/SKU.js.map +1 -0
- package/build/src/modeling/definitions/Status.d.ts +150 -0
- package/build/src/modeling/definitions/Status.d.ts.map +1 -0
- package/build/src/modeling/definitions/Status.js +60 -0
- package/build/src/modeling/definitions/Status.js.map +1 -0
- package/build/src/modeling/definitions/Summary.d.ts +53 -0
- package/build/src/modeling/definitions/Summary.d.ts.map +1 -0
- package/build/src/modeling/definitions/Summary.js +50 -0
- package/build/src/modeling/definitions/Summary.js.map +1 -0
- package/build/src/modeling/definitions/Tags.d.ts +52 -0
- package/build/src/modeling/definitions/Tags.d.ts.map +1 -0
- package/build/src/modeling/definitions/Tags.js +32 -0
- package/build/src/modeling/definitions/Tags.js.map +1 -0
- package/build/src/modeling/definitions/URL.d.ts +68 -0
- package/build/src/modeling/definitions/URL.d.ts.map +1 -0
- package/build/src/modeling/definitions/URL.js +37 -0
- package/build/src/modeling/definitions/URL.js.map +1 -0
- package/build/src/modeling/validation/semantic_validation.d.ts +4 -0
- package/build/src/modeling/validation/semantic_validation.d.ts.map +1 -1
- package/build/src/modeling/validation/semantic_validation.js +32 -1
- package/build/src/modeling/validation/semantic_validation.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modeling/Semantics.ts +297 -14
- package/src/modeling/definitions/Calculated.ts +76 -0
- package/src/modeling/definitions/Categories.ts +84 -0
- package/src/modeling/definitions/Derived.ts +76 -0
- package/src/modeling/definitions/Description.ts +55 -0
- package/src/modeling/definitions/Email.ts +90 -0
- package/src/modeling/definitions/GeospatialCoordinates.ts +274 -0
- package/src/modeling/definitions/HTML.ts +121 -0
- package/src/modeling/definitions/Markdown.ts +116 -0
- package/src/modeling/definitions/Password.ts +156 -0
- package/src/modeling/definitions/Phone.ts +116 -0
- package/src/modeling/definitions/Price.examples.md +158 -0
- package/src/modeling/definitions/Price.ts +180 -0
- package/src/modeling/definitions/PublicUniqueName.ts +98 -0
- package/src/modeling/definitions/SKU.examples.md +230 -0
- package/src/modeling/definitions/SKU.ts +254 -0
- package/src/modeling/definitions/Status.ts +227 -0
- package/src/modeling/definitions/Summary.ts +73 -0
- package/src/modeling/definitions/Tags.ts +75 -0
- package/src/modeling/definitions/URL.ts +96 -0
- package/src/modeling/validation/semantic_validation.ts +35 -1
- package/tests/example-test-setup.ts +133 -0
- package/tests/template-node.spec.ts +75 -0
- package/tests/test-utils.ts +293 -0
- package/tests/unit/modeling/definitions/calculated.spec.ts +33 -0
- package/tests/unit/modeling/definitions/categories.spec.ts +38 -0
- package/tests/unit/modeling/definitions/derived.spec.ts +34 -0
- package/tests/unit/modeling/definitions/description.spec.ts +38 -0
- package/tests/unit/modeling/definitions/email.spec.ts +38 -0
- package/tests/unit/modeling/definitions/geospatial-coordinates.spec.ts +41 -0
- package/tests/unit/modeling/definitions/html.spec.ts +38 -0
- package/tests/unit/modeling/definitions/markdown.spec.ts +38 -0
- package/tests/unit/modeling/definitions/password.spec.ts +347 -0
- package/tests/unit/modeling/definitions/phone.spec.ts +38 -0
- package/tests/unit/modeling/definitions/price.spec.ts +465 -0
- package/tests/unit/modeling/definitions/public-unique-name.spec.ts +38 -0
- package/tests/unit/modeling/definitions/sku.spec.ts +240 -0
- package/tests/unit/modeling/definitions/status.spec.ts +37 -0
- package/tests/unit/modeling/definitions/summary.spec.ts +36 -0
- package/tests/unit/modeling/definitions/tags.spec.ts +38 -0
- package/tests/unit/modeling/definitions/url.spec.ts +38 -0
- package/tests/unit/modeling/domain_property.spec.ts +106 -0
- package/tests/unit/modeling/domain_validation.spec.ts +5 -5
- package/tests/unit/modeling/semantic-configs.spec.ts +569 -0
- package/tests/unit/modeling/semantics.spec.ts +52 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { AppliedDataSemantic } from '../Semantics.js'
|
|
2
|
+
import { SemanticType } from '../Semantics.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for the Markdown semantic.
|
|
6
|
+
* Controls rendering, sanitization, and allowed features.
|
|
7
|
+
*/
|
|
8
|
+
export interface MarkdownConfig {
|
|
9
|
+
/**
|
|
10
|
+
* List of allowed HTML tags in the rendered output.
|
|
11
|
+
*/
|
|
12
|
+
allowedTags?: string[]
|
|
13
|
+
/**
|
|
14
|
+
* Maximum length of the markdown 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 markdown.
|
|
27
|
+
*/
|
|
28
|
+
allowImages?: boolean
|
|
29
|
+
/**
|
|
30
|
+
* Whether to allow links in markdown.
|
|
31
|
+
*/
|
|
32
|
+
allowLinks?: boolean
|
|
33
|
+
/**
|
|
34
|
+
* Whether to allow tables in markdown.
|
|
35
|
+
*/
|
|
36
|
+
allowTables?: boolean
|
|
37
|
+
/**
|
|
38
|
+
* Whether to allow raw HTML in markdown.
|
|
39
|
+
*/
|
|
40
|
+
allowHtml?: boolean
|
|
41
|
+
/**
|
|
42
|
+
* Whether to allow footnotes in markdown.
|
|
43
|
+
*/
|
|
44
|
+
allowFootnotes?: boolean
|
|
45
|
+
/**
|
|
46
|
+
* Whether to allow GitHub-style task lists.
|
|
47
|
+
*/
|
|
48
|
+
allowTaskLists?: boolean
|
|
49
|
+
/**
|
|
50
|
+
* Whether to allow strikethrough formatting.
|
|
51
|
+
*/
|
|
52
|
+
allowStrikethrough?: boolean
|
|
53
|
+
/**
|
|
54
|
+
* Whether to allow math expressions (e.g., LaTeX).
|
|
55
|
+
*/
|
|
56
|
+
allowMath?: boolean
|
|
57
|
+
/**
|
|
58
|
+
* Custom metadata for the markdown field.
|
|
59
|
+
*/
|
|
60
|
+
metadata?: Record<string, unknown>
|
|
61
|
+
/**
|
|
62
|
+
* Index signature to allow additional properties.
|
|
63
|
+
*/
|
|
64
|
+
[key: string]: unknown
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Type-safe configuration for Markdown semantic.
|
|
69
|
+
*/
|
|
70
|
+
export interface AppliedMarkdownSemantic extends AppliedDataSemantic {
|
|
71
|
+
id: SemanticType.Markdown
|
|
72
|
+
config?: MarkdownConfig
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Type guard to check if a semantic is a Markdown semantic.
|
|
77
|
+
*/
|
|
78
|
+
export const isMarkdownSemantic = (semantic: AppliedDataSemantic): semantic is AppliedMarkdownSemantic => {
|
|
79
|
+
return semantic.id === SemanticType.Markdown
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Helper function to create a Markdown semantic with configuration.
|
|
84
|
+
*/
|
|
85
|
+
export const createMarkdownSemantic = (config: MarkdownConfig = {}): AppliedMarkdownSemantic => {
|
|
86
|
+
const mergedConfig = {
|
|
87
|
+
...DEFAULT_MARKDOWN_CONFIG,
|
|
88
|
+
...config,
|
|
89
|
+
}
|
|
90
|
+
if (config.metadata) {
|
|
91
|
+
mergedConfig.metadata = { ...config.metadata }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
id: SemanticType.Markdown,
|
|
96
|
+
config: mergedConfig,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Default configuration for Markdown semantic.
|
|
102
|
+
*/
|
|
103
|
+
export const DEFAULT_MARKDOWN_CONFIG: MarkdownConfig = {
|
|
104
|
+
allowedTags: ['b', 'i', 'em', 'strong', 'a', 'ul', 'ol', 'li', 'p', 'br', 'pre', 'code'],
|
|
105
|
+
maxLength: 10000,
|
|
106
|
+
renderMode: 'html',
|
|
107
|
+
sanitizeLevel: 'strict',
|
|
108
|
+
allowImages: true,
|
|
109
|
+
allowLinks: true,
|
|
110
|
+
allowTables: true,
|
|
111
|
+
allowHtml: false,
|
|
112
|
+
allowFootnotes: false,
|
|
113
|
+
allowTaskLists: false,
|
|
114
|
+
allowStrikethrough: true,
|
|
115
|
+
allowMath: false,
|
|
116
|
+
}
|