baml-sap-ts 0.1.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.
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +355 -0
- package/dist/index.d.ts +180 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +274 -0
- package/dist/index.js.map +1 -0
- package/dist/json-extractor.d.ts +57 -0
- package/dist/json-extractor.d.ts.map +1 -0
- package/dist/json-extractor.js +382 -0
- package/dist/json-extractor.js.map +1 -0
- package/dist/schema-renderer.d.ts +34 -0
- package/dist/schema-renderer.d.ts.map +1 -0
- package/dist/schema-renderer.js +329 -0
- package/dist/schema-renderer.js.map +1 -0
- package/dist/type-coercer.d.ts +59 -0
- package/dist/type-coercer.d.ts.map +1 -0
- package/dist/type-coercer.js +589 -0
- package/dist/type-coercer.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type Coercer - Validates and coerces parsed data to TypeBox schemas
|
|
4
|
+
*
|
|
5
|
+
* This module takes extracted JSON and validates/coerces it against
|
|
6
|
+
* TypeBox schemas, handling:
|
|
7
|
+
* - Union type matching
|
|
8
|
+
* - Optional fields
|
|
9
|
+
* - Default values
|
|
10
|
+
* - Type conversions
|
|
11
|
+
* - Array/object coercion
|
|
12
|
+
*
|
|
13
|
+
* Based on BAML's deserializer/coercer
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.coerceValue = coerceValue;
|
|
17
|
+
exports.validateValue = validateValue;
|
|
18
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
19
|
+
const value_1 = require("@sinclair/typebox/value");
|
|
20
|
+
const defaultOptions = {
|
|
21
|
+
allowPartials: false,
|
|
22
|
+
useDefaults: true,
|
|
23
|
+
strict: false,
|
|
24
|
+
maxDepth: 50,
|
|
25
|
+
trackCoercions: false,
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Coerce a value to match a TypeBox schema
|
|
29
|
+
*/
|
|
30
|
+
function coerceValue(value, schema, options = {}, path = "") {
|
|
31
|
+
const opts = { ...defaultOptions, ...options };
|
|
32
|
+
const errors = [];
|
|
33
|
+
const coercions = [];
|
|
34
|
+
function addCoercion(message) {
|
|
35
|
+
if (opts.trackCoercions) {
|
|
36
|
+
coercions.push(message);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function addError(message, expected, received) {
|
|
40
|
+
errors.push({
|
|
41
|
+
path,
|
|
42
|
+
message,
|
|
43
|
+
expected,
|
|
44
|
+
received: received ?? String(value),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const result = coerceInternal(value, schema, opts, path, 0, addCoercion, addError);
|
|
48
|
+
return {
|
|
49
|
+
value: result,
|
|
50
|
+
success: errors.length === 0,
|
|
51
|
+
errors,
|
|
52
|
+
coercions: opts.trackCoercions ? coercions : undefined,
|
|
53
|
+
isPartial: opts.allowPartials && !isComplete(value, schema),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Internal coercion function
|
|
58
|
+
*/
|
|
59
|
+
function coerceInternal(value, schema, options, path, depth, addCoercion, addError) {
|
|
60
|
+
// Depth limit
|
|
61
|
+
if (depth > options.maxDepth) {
|
|
62
|
+
addError("Maximum depth exceeded");
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
// Handle null/undefined
|
|
66
|
+
if (value === null || value === undefined) {
|
|
67
|
+
return coerceNull(value, schema, options, path, addCoercion, addError);
|
|
68
|
+
}
|
|
69
|
+
// Handle schema references
|
|
70
|
+
if (schema.$ref) {
|
|
71
|
+
// References would need to be resolved from a schema registry
|
|
72
|
+
// For now, we treat them as 'any'
|
|
73
|
+
addCoercion(`unresolved reference: ${schema.$ref}`);
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
// Handle different schema kinds
|
|
77
|
+
switch (schema[typebox_1.Kind]) {
|
|
78
|
+
case "Object":
|
|
79
|
+
return coerceObject(value, schema, options, path, depth, addCoercion, addError);
|
|
80
|
+
case "Array":
|
|
81
|
+
return coerceArray(value, schema, options, path, depth, addCoercion, addError);
|
|
82
|
+
case "Union":
|
|
83
|
+
return coerceUnion(value, schema, options, path, depth, addCoercion, addError);
|
|
84
|
+
case "Intersect":
|
|
85
|
+
return coerceIntersect(value, schema, options, path, depth, addCoercion, addError);
|
|
86
|
+
case "Optional":
|
|
87
|
+
return coerceOptional(value, schema, options, path, depth, addCoercion, addError);
|
|
88
|
+
case "Literal":
|
|
89
|
+
return coerceLiteral(value, schema, path, addError);
|
|
90
|
+
case "Enum":
|
|
91
|
+
return coerceEnum(value, schema, path, addCoercion, addError);
|
|
92
|
+
case "String":
|
|
93
|
+
return coerceString(value, schema, path, addCoercion, addError);
|
|
94
|
+
case "Number":
|
|
95
|
+
case "Integer":
|
|
96
|
+
return coerceNumber(value, schema, path, addCoercion, addError);
|
|
97
|
+
case "Boolean":
|
|
98
|
+
return coerceBoolean(value, path, addCoercion, addError);
|
|
99
|
+
case "Null":
|
|
100
|
+
return coerceNull(value, schema, options, path, addCoercion, addError);
|
|
101
|
+
case "Any":
|
|
102
|
+
case "Unknown":
|
|
103
|
+
return value;
|
|
104
|
+
case "Record":
|
|
105
|
+
return coerceRecord(value, schema, options, path, depth, addCoercion, addError);
|
|
106
|
+
case "Tuple":
|
|
107
|
+
return coerceTuple(value, schema, options, path, depth, addCoercion, addError);
|
|
108
|
+
case "Ref":
|
|
109
|
+
// References should be resolved
|
|
110
|
+
addCoercion(`reference coercion: ${schema.$ref}`);
|
|
111
|
+
return value;
|
|
112
|
+
default:
|
|
113
|
+
// Try JSON Schema type coercion
|
|
114
|
+
if (schema.type) {
|
|
115
|
+
return coerceJsonSchemaType(value, schema, options, path, depth, addCoercion, addError);
|
|
116
|
+
}
|
|
117
|
+
// Default: try TypeBox validation
|
|
118
|
+
try {
|
|
119
|
+
return value_1.Value.Decode(schema, value);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
addError(`Unable to coerce to ${schema[typebox_1.Kind] || "unknown type"}`);
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function coerceObject(value, schema, options, path, depth, addCoercion, addError) {
|
|
128
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
129
|
+
// Try to convert array to object with index keys
|
|
130
|
+
if (Array.isArray(value)) {
|
|
131
|
+
addCoercion(`converted array to object with index keys at ${path}`);
|
|
132
|
+
const obj = {};
|
|
133
|
+
value.forEach((item, index) => {
|
|
134
|
+
obj[String(index)] = item;
|
|
135
|
+
});
|
|
136
|
+
return coerceObject(obj, schema, options, path, depth, addCoercion, addError);
|
|
137
|
+
}
|
|
138
|
+
// Try to convert string to object (JSON parsing)
|
|
139
|
+
if (typeof value === "string") {
|
|
140
|
+
try {
|
|
141
|
+
const parsed = JSON.parse(value);
|
|
142
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
143
|
+
addCoercion(`parsed string to object at ${path}`);
|
|
144
|
+
return coerceObject(parsed, schema, options, path, depth, addCoercion, addError);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// Not valid JSON
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
addError(`Expected object, got ${typeof value}`, "object", typeof value);
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
const properties = schema.properties;
|
|
155
|
+
if (!properties) {
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
// Get required fields from the schema (TypeBox uses this for optional fields)
|
|
159
|
+
const required = schema.required || [];
|
|
160
|
+
const result = {};
|
|
161
|
+
const valueObj = value;
|
|
162
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
163
|
+
const fieldPath = path ? `${path}.${key}` : key;
|
|
164
|
+
const fieldValue = valueObj[key];
|
|
165
|
+
const isRequired = required.includes(key);
|
|
166
|
+
if (fieldValue === undefined) {
|
|
167
|
+
// Check for default
|
|
168
|
+
if (options.useDefaults && propSchema.default !== undefined) {
|
|
169
|
+
result[key] = propSchema.default;
|
|
170
|
+
addCoercion(`used default for ${fieldPath}`);
|
|
171
|
+
}
|
|
172
|
+
else if (!isRequired || isOptionalProperty(propSchema)) {
|
|
173
|
+
// Optional field, skip
|
|
174
|
+
}
|
|
175
|
+
else if (options.allowPartials) {
|
|
176
|
+
// Partial mode - leave undefined
|
|
177
|
+
result[key] = undefined;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
addError(`Missing required field: ${key}`, undefined, "undefined");
|
|
181
|
+
result[key] = undefined;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
result[key] = coerceInternal(fieldValue, propSchema, options, fieldPath, depth + 1, addCoercion, addError);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Handle additional properties
|
|
189
|
+
const additionalProps = schema.additionalProperties;
|
|
190
|
+
for (const [key, fieldValue] of Object.entries(valueObj)) {
|
|
191
|
+
if (!(key in properties)) {
|
|
192
|
+
if (additionalProps === true || additionalProps === undefined) {
|
|
193
|
+
// Allow any additional properties
|
|
194
|
+
result[key] = fieldValue;
|
|
195
|
+
}
|
|
196
|
+
else if (additionalProps !== false) {
|
|
197
|
+
// Validate against schema
|
|
198
|
+
const fieldPath = path ? `${path}.${key}` : key;
|
|
199
|
+
result[key] = coerceInternal(fieldValue, additionalProps, options, fieldPath, depth + 1, addCoercion, addError);
|
|
200
|
+
}
|
|
201
|
+
// If false, ignore the property
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
function coerceArray(value, schema, options, path, depth, addCoercion, addError) {
|
|
207
|
+
// Handle single value -> array
|
|
208
|
+
if (!Array.isArray(value)) {
|
|
209
|
+
addCoercion(`wrapped single value in array at ${path}`);
|
|
210
|
+
const items = schema.items;
|
|
211
|
+
return [coerceInternal(value, items, options, `${path}[0]`, depth + 1, addCoercion, addError)];
|
|
212
|
+
}
|
|
213
|
+
const items = schema.items;
|
|
214
|
+
const result = [];
|
|
215
|
+
for (let i = 0; i < value.length; i++) {
|
|
216
|
+
const itemPath = `${path}[${i}]`;
|
|
217
|
+
result.push(coerceInternal(value[i], items, options, itemPath, depth + 1, addCoercion, addError));
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
function coerceUnion(value, schema, options, path, depth, addCoercion, addError) {
|
|
222
|
+
const variants = schema.anyOf;
|
|
223
|
+
// Try each variant and pick the one with fewest errors
|
|
224
|
+
let bestResult = null;
|
|
225
|
+
for (const variant of variants) {
|
|
226
|
+
// Check if this variant can handle the value
|
|
227
|
+
if (canHandleValue(value, variant)) {
|
|
228
|
+
// Create temporary error trackers
|
|
229
|
+
const variantErrors = [];
|
|
230
|
+
const variantCoercions = [];
|
|
231
|
+
const result = coerceInternal(value, variant, options, path, depth, (msg) => variantCoercions.push(msg), (msg, exp, rec) => variantErrors.push({ path, message: msg, expected: exp, received: rec }));
|
|
232
|
+
if (variantErrors.length === 0) {
|
|
233
|
+
// Perfect match
|
|
234
|
+
for (const c of variantCoercions) {
|
|
235
|
+
addCoercion(c);
|
|
236
|
+
}
|
|
237
|
+
return result;
|
|
238
|
+
}
|
|
239
|
+
if (!bestResult || variantErrors.length < bestResult.errors) {
|
|
240
|
+
bestResult = {
|
|
241
|
+
value: result,
|
|
242
|
+
errors: variantErrors.length,
|
|
243
|
+
coercions: variantCoercions.length,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Return the best match even if it had errors
|
|
249
|
+
if (bestResult) {
|
|
250
|
+
addCoercion(`selected union variant with ${bestResult.errors} errors at ${path}`);
|
|
251
|
+
return bestResult.value;
|
|
252
|
+
}
|
|
253
|
+
// Last resort: try each variant anyway
|
|
254
|
+
for (const variant of variants) {
|
|
255
|
+
try {
|
|
256
|
+
const result = coerceInternal(value, variant, options, path, depth, addCoercion, addError);
|
|
257
|
+
addCoercion(`forced union variant at ${path}`);
|
|
258
|
+
return result;
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
// Try next
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
addError(`No matching variant in union`);
|
|
265
|
+
return value;
|
|
266
|
+
}
|
|
267
|
+
function coerceIntersect(value, schema, options, path, depth, addCoercion, addError) {
|
|
268
|
+
const allOf = schema.allOf;
|
|
269
|
+
if (!allOf || allOf.length === 0) {
|
|
270
|
+
return value;
|
|
271
|
+
}
|
|
272
|
+
// Merge all object schemas and coerce
|
|
273
|
+
const merged = {};
|
|
274
|
+
for (const subSchema of allOf) {
|
|
275
|
+
if (subSchema[typebox_1.Kind] === "Object") {
|
|
276
|
+
const props = subSchema.properties;
|
|
277
|
+
Object.assign(merged, props);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const mergedSchema = typebox_1.Type.Object(merged);
|
|
281
|
+
return coerceObject(value, mergedSchema, options, path, depth, addCoercion, addError);
|
|
282
|
+
}
|
|
283
|
+
function coerceOptional(value, schema, options, _path, depth, addCoercion, _addError) {
|
|
284
|
+
const inner = schema.item;
|
|
285
|
+
if (value === null || value === undefined) {
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
return coerceInternal(value, inner, options, _path, depth, addCoercion, _addError);
|
|
289
|
+
}
|
|
290
|
+
function coerceLiteral(value, schema, _path, addError) {
|
|
291
|
+
const expected = schema.const;
|
|
292
|
+
if (value === expected) {
|
|
293
|
+
return value;
|
|
294
|
+
}
|
|
295
|
+
// Try string comparison
|
|
296
|
+
if (String(value) === String(expected)) {
|
|
297
|
+
return expected;
|
|
298
|
+
}
|
|
299
|
+
addError(`Expected literal ${JSON.stringify(expected)}`, JSON.stringify(expected), String(value));
|
|
300
|
+
return value;
|
|
301
|
+
}
|
|
302
|
+
function coerceEnum(value, schema, path, addCoercion, addError) {
|
|
303
|
+
const allowed = schema.enum;
|
|
304
|
+
if (allowed.includes(value)) {
|
|
305
|
+
return value;
|
|
306
|
+
}
|
|
307
|
+
// Try case-insensitive string matching
|
|
308
|
+
if (typeof value === "string") {
|
|
309
|
+
const match = allowed.find((v) => typeof v === "string" && v.toLowerCase() === value.toLowerCase());
|
|
310
|
+
if (match !== undefined) {
|
|
311
|
+
addCoercion(`case-insensitive enum match at ${path}: ${value} -> ${match}`);
|
|
312
|
+
return match;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
addError(`Expected one of ${allowed.map((v) => JSON.stringify(v)).join(", ")}`, "enum", String(value));
|
|
316
|
+
return value;
|
|
317
|
+
}
|
|
318
|
+
function coerceString(value, schema, path, addCoercion, addError) {
|
|
319
|
+
if (typeof value === "string") {
|
|
320
|
+
// Validate constraints
|
|
321
|
+
if (schema.minLength !== undefined && value.length < schema.minLength) {
|
|
322
|
+
addError(`String too short (min ${schema.minLength})`, `minLength ${schema.minLength}`, String(value.length));
|
|
323
|
+
}
|
|
324
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength) {
|
|
325
|
+
addError(`String too long (max ${schema.maxLength})`, `maxLength ${schema.maxLength}`, String(value.length));
|
|
326
|
+
}
|
|
327
|
+
if (schema.pattern && !new RegExp(schema.pattern).test(value)) {
|
|
328
|
+
addError(`String does not match pattern /${schema.pattern}/`, `pattern ${schema.pattern}`, value);
|
|
329
|
+
}
|
|
330
|
+
return value;
|
|
331
|
+
}
|
|
332
|
+
// Coerce to string
|
|
333
|
+
addCoercion(`coerced ${typeof value} to string at ${path}`);
|
|
334
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
335
|
+
return String(value);
|
|
336
|
+
}
|
|
337
|
+
if (value === null) {
|
|
338
|
+
return "null";
|
|
339
|
+
}
|
|
340
|
+
if (typeof value === "object") {
|
|
341
|
+
return JSON.stringify(value);
|
|
342
|
+
}
|
|
343
|
+
return String(value);
|
|
344
|
+
}
|
|
345
|
+
function coerceNumber(value, schema, path, addCoercion, addError) {
|
|
346
|
+
const isInt = schema[typebox_1.Kind] === "Integer" || schema.type === "integer";
|
|
347
|
+
if (typeof value === "number") {
|
|
348
|
+
let num = value;
|
|
349
|
+
if (isInt && !Number.isInteger(num)) {
|
|
350
|
+
addCoercion(`truncated float to integer at ${path}`);
|
|
351
|
+
num = Math.trunc(num);
|
|
352
|
+
}
|
|
353
|
+
return validateNumber(num, schema, path, addError);
|
|
354
|
+
}
|
|
355
|
+
if (typeof value === "string") {
|
|
356
|
+
const parsed = isInt ? parseInt(value, 10) : parseFloat(value);
|
|
357
|
+
if (!Number.isNaN(parsed)) {
|
|
358
|
+
addCoercion(`parsed string to number at ${path}`);
|
|
359
|
+
return validateNumber(parsed, schema, path, addError);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (typeof value === "boolean") {
|
|
363
|
+
addCoercion(`converted boolean to number at ${path}`);
|
|
364
|
+
return validateNumber(value ? 1 : 0, schema, path, addError);
|
|
365
|
+
}
|
|
366
|
+
addError(`Cannot coerce to ${isInt ? "integer" : "number"}`, isInt ? "integer" : "number", String(value));
|
|
367
|
+
return value;
|
|
368
|
+
}
|
|
369
|
+
function validateNumber(num, schema, _path, addError) {
|
|
370
|
+
if (schema.minimum !== undefined && num < schema.minimum) {
|
|
371
|
+
addError(`Number below minimum (${schema.minimum})`, `>= ${schema.minimum}`, String(num));
|
|
372
|
+
}
|
|
373
|
+
if (schema.maximum !== undefined && num > schema.maximum) {
|
|
374
|
+
addError(`Number above maximum (${schema.maximum})`, `<= ${schema.maximum}`, String(num));
|
|
375
|
+
}
|
|
376
|
+
if (schema.exclusiveMinimum !== undefined && num <= schema.exclusiveMinimum) {
|
|
377
|
+
addError(`Number not above exclusive minimum (${schema.exclusiveMinimum})`, `> ${schema.exclusiveMinimum}`, String(num));
|
|
378
|
+
}
|
|
379
|
+
if (schema.exclusiveMaximum !== undefined && num >= schema.exclusiveMaximum) {
|
|
380
|
+
addError(`Number not below exclusive maximum (${schema.exclusiveMaximum})`, `< ${schema.exclusiveMaximum}`, String(num));
|
|
381
|
+
}
|
|
382
|
+
if (schema.multipleOf !== undefined && num % schema.multipleOf !== 0) {
|
|
383
|
+
addError(`Number not multiple of ${schema.multipleOf}`, `multiple of ${schema.multipleOf}`, String(num));
|
|
384
|
+
}
|
|
385
|
+
return num;
|
|
386
|
+
}
|
|
387
|
+
function coerceBoolean(value, _path, _addCoercion, addError) {
|
|
388
|
+
if (typeof value === "boolean") {
|
|
389
|
+
return value;
|
|
390
|
+
}
|
|
391
|
+
if (typeof value === "string") {
|
|
392
|
+
const lower = value.toLowerCase();
|
|
393
|
+
if (lower === "true" || lower === "1" || lower === "yes") {
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
if (lower === "false" || lower === "0" || lower === "no" || lower === "") {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (typeof value === "number") {
|
|
401
|
+
return value !== 0;
|
|
402
|
+
}
|
|
403
|
+
addError(`Cannot coerce to boolean`, "boolean", String(value));
|
|
404
|
+
return value;
|
|
405
|
+
}
|
|
406
|
+
function coerceNull(value, _schema, options, path, addCoercion, _addError) {
|
|
407
|
+
if (value === null || value === undefined) {
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
// Check if this is part of an optional/union with null
|
|
411
|
+
if (options.allowPartials) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
addCoercion(`coerced ${typeof value} to null at ${path}`);
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
function coerceRecord(value, schema, options, path, depth, addCoercion, addError) {
|
|
418
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
419
|
+
addError(`Expected record object, got ${typeof value}`, "record", typeof value);
|
|
420
|
+
return value;
|
|
421
|
+
}
|
|
422
|
+
const patternProps = schema.patternProperties;
|
|
423
|
+
const additional = schema.additionalProperties;
|
|
424
|
+
let valueSchema;
|
|
425
|
+
if (patternProps && Object.keys(patternProps).length > 0) {
|
|
426
|
+
valueSchema = Object.values(patternProps)[0];
|
|
427
|
+
}
|
|
428
|
+
else if (additional && typeof additional !== "boolean") {
|
|
429
|
+
valueSchema = additional;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
valueSchema = typebox_1.Type.Any();
|
|
433
|
+
}
|
|
434
|
+
const result = {};
|
|
435
|
+
for (const [key, val] of Object.entries(value)) {
|
|
436
|
+
const keyPath = `${path}[${key}]`;
|
|
437
|
+
result[key] = coerceInternal(val, valueSchema, options, keyPath, depth + 1, addCoercion, addError);
|
|
438
|
+
}
|
|
439
|
+
return result;
|
|
440
|
+
}
|
|
441
|
+
function coerceTuple(value, schema, options, path, depth, addCoercion, addError) {
|
|
442
|
+
if (!Array.isArray(value)) {
|
|
443
|
+
addError(`Expected tuple array, got ${typeof value}`, "tuple", typeof value);
|
|
444
|
+
return value;
|
|
445
|
+
}
|
|
446
|
+
const items = schema.items;
|
|
447
|
+
const result = [];
|
|
448
|
+
for (let i = 0; i < items.length; i++) {
|
|
449
|
+
const itemPath = `${path}[${i}]`;
|
|
450
|
+
if (i < value.length) {
|
|
451
|
+
result.push(coerceInternal(value[i], items[i], options, itemPath, depth + 1, addCoercion, addError));
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
// Missing element - use default or undefined
|
|
455
|
+
if (items[i].default !== undefined) {
|
|
456
|
+
result.push(items[i].default);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
addError(`Missing tuple element at index ${i}`);
|
|
460
|
+
result.push(undefined);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
// Handle extra elements if additionalItems is allowed
|
|
465
|
+
const additionalItems = schema.additionalItems;
|
|
466
|
+
if (additionalItems !== false) {
|
|
467
|
+
for (let i = items.length; i < value.length; i++) {
|
|
468
|
+
result.push(value[i]);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return result;
|
|
472
|
+
}
|
|
473
|
+
function coerceJsonSchemaType(value, schema, options, path, depth, addCoercion, addError) {
|
|
474
|
+
const type = schema.type;
|
|
475
|
+
switch (type) {
|
|
476
|
+
case "string":
|
|
477
|
+
return coerceString(value, schema, path, addCoercion, addError);
|
|
478
|
+
case "number":
|
|
479
|
+
return coerceNumber(value, schema, path, addCoercion, addError);
|
|
480
|
+
case "integer":
|
|
481
|
+
return coerceNumber(value, schema, path, addCoercion, addError);
|
|
482
|
+
case "boolean":
|
|
483
|
+
return coerceBoolean(value, path, addCoercion, addError);
|
|
484
|
+
case "null":
|
|
485
|
+
return coerceNull(value, schema, options, path, addCoercion, addError);
|
|
486
|
+
case "array":
|
|
487
|
+
if (schema.items) {
|
|
488
|
+
return coerceArray(value, schema, options, path, depth, addCoercion, addError);
|
|
489
|
+
}
|
|
490
|
+
return Array.isArray(value) ? value : [value];
|
|
491
|
+
case "object":
|
|
492
|
+
if (schema.properties) {
|
|
493
|
+
return coerceObject(value, schema, options, path, depth, addCoercion, addError);
|
|
494
|
+
}
|
|
495
|
+
return typeof value === "object" ? value : {};
|
|
496
|
+
default:
|
|
497
|
+
return value;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Check if a value can potentially be handled by a schema
|
|
502
|
+
*/
|
|
503
|
+
function canHandleValue(value, schema) {
|
|
504
|
+
if (schema[typebox_1.Kind] === "Any" || schema[typebox_1.Kind] === "Unknown") {
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
if (value === null || value === undefined) {
|
|
508
|
+
return schema[typebox_1.Kind] === "Null" || schema[typebox_1.Kind] === "Optional" || isNullable(schema);
|
|
509
|
+
}
|
|
510
|
+
switch (schema[typebox_1.Kind]) {
|
|
511
|
+
case "String":
|
|
512
|
+
return typeof value === "string";
|
|
513
|
+
case "Number":
|
|
514
|
+
return typeof value === "number";
|
|
515
|
+
case "Integer":
|
|
516
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
517
|
+
case "Boolean":
|
|
518
|
+
return typeof value === "boolean";
|
|
519
|
+
case "Object":
|
|
520
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
521
|
+
case "Array":
|
|
522
|
+
return Array.isArray(value);
|
|
523
|
+
case "Literal":
|
|
524
|
+
return value === schema.const;
|
|
525
|
+
case "Enum":
|
|
526
|
+
return schema.enum.includes(value);
|
|
527
|
+
case "Union":
|
|
528
|
+
return schema.anyOf.some((s) => canHandleValue(value, s));
|
|
529
|
+
default:
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
function isNullable(schema) {
|
|
534
|
+
if (schema.anyOf) {
|
|
535
|
+
return schema.anyOf.some((s) => s[typebox_1.Kind] === "Null" || s.type === "null");
|
|
536
|
+
}
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
function isOptionalProperty(schema) {
|
|
540
|
+
if (schema[typebox_1.Kind] === "Optional") {
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
if (schema.anyOf) {
|
|
544
|
+
return schema.anyOf.some((s) => s[typebox_1.Kind] === "Null" || s.type === "null" || s.type === "undefined");
|
|
545
|
+
}
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
function isComplete(value, schema) {
|
|
549
|
+
if (schema[typebox_1.Kind] === "Object") {
|
|
550
|
+
if (typeof value !== "object" || value === null) {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
const properties = schema.properties;
|
|
554
|
+
const required = schema.required || [];
|
|
555
|
+
for (const key of Object.keys(properties)) {
|
|
556
|
+
if (required.includes(key)) {
|
|
557
|
+
if (!(key in value)) {
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (schema[typebox_1.Kind] === "Array") {
|
|
564
|
+
if (!Array.isArray(value)) {
|
|
565
|
+
return false;
|
|
566
|
+
}
|
|
567
|
+
// Arrays are considered complete if they have elements
|
|
568
|
+
return value.length > 0;
|
|
569
|
+
}
|
|
570
|
+
return value !== undefined && value !== null;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Validate a value against a schema without coercion
|
|
574
|
+
*/
|
|
575
|
+
function validateValue(value, schema) {
|
|
576
|
+
const errors = [];
|
|
577
|
+
function addError(path, message, expected, received) {
|
|
578
|
+
errors.push({ path, message, expected, received });
|
|
579
|
+
}
|
|
580
|
+
const valid = value_1.Value.Check(schema, value);
|
|
581
|
+
if (!valid) {
|
|
582
|
+
const iterator = value_1.Value.Errors(schema, value);
|
|
583
|
+
for (const error of iterator) {
|
|
584
|
+
addError(error.path, error.message, undefined, String(error.value));
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return { valid, errors };
|
|
588
|
+
}
|
|
589
|
+
//# sourceMappingURL=type-coercer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-coercer.js","sourceRoot":"","sources":["../src/type-coercer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAqEH,kCAkCC;AAkvBD,sCAoBC;AA32BD,+CAiB2B;AAC3B,mDAAgE;AAehE,MAAM,cAAc,GAAoB;IACvC,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,EAAE;IACZ,cAAc,EAAE,KAAK;CACrB,CAAC;AAyBF;;GAEG;AACH,SAAgB,WAAW,CAC1B,KAAc,EACd,MAAS,EACT,UAA2B,EAAE,EAC7B,OAAe,EAAE;IAEjB,MAAM,IAAI,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC;IAC/C,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,MAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,SAAS,WAAW,CAAC,OAAe;QACnC,IAAI,IAAI,CAAC,cAAc,EAAE,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