@pdtf/schemas 3.5.1-9 → 3.6.0-2
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/.claude/settings.local.json +6 -1
- package/package.json +1 -1
- package/src/schemas/v3/combined.json +142 -0
- package/src/schemas/v3/compactSkeleton.txt +24 -1
- package/src/schemas/v3/pdtf-transaction.json +150 -0
- package/src/schemas/v3/skeleton.json +43 -2
- package/src/tests/v3/enquiries.test.js +1096 -0
- package/src/utils/extractOverlay.js +37 -13
|
@@ -29,16 +29,28 @@ const extractFields = [
|
|
|
29
29
|
|
|
30
30
|
const flattenSkeleton = (schema) => {
|
|
31
31
|
if (!schema) return undefined;
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
// Handle arrays - mark with special notation
|
|
34
34
|
if (schema.type === "array" && schema.items) {
|
|
35
35
|
const itemSchema = flattenSkeleton(schema.items);
|
|
36
36
|
// Use array notation to indicate this is an array
|
|
37
37
|
return [itemSchema];
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
// Handle patternProperties (dynamic keys like in offers and enquiries)
|
|
41
|
+
if (schema.type === "object" && schema.patternProperties) {
|
|
42
|
+
// Get the schema from the first pattern (usually ".*")
|
|
43
|
+
const patternKeys = Object.keys(schema.patternProperties);
|
|
44
|
+
if (patternKeys.length > 0) {
|
|
45
|
+
const patternSchema = schema.patternProperties[patternKeys[0]];
|
|
46
|
+
const itemSchema = flattenSkeleton(patternSchema);
|
|
47
|
+
// Use {*: schema} notation to indicate this is a keyed object
|
|
48
|
+
return { "*": itemSchema };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
// Handle primitives - return type indicator
|
|
41
|
-
if (schema.type && !schema.properties && !schema.oneOf && !schema.items) {
|
|
53
|
+
if (schema.type && !schema.properties && !schema.oneOf && !schema.items && !schema.patternProperties) {
|
|
42
54
|
// Return a type indicator for primitive types
|
|
43
55
|
if (schema.type === "string") return "string";
|
|
44
56
|
if (schema.type === "number") return "number";
|
|
@@ -46,16 +58,16 @@ const flattenSkeleton = (schema) => {
|
|
|
46
58
|
if (schema.type === "boolean") return "boolean";
|
|
47
59
|
if (schema.type === "null") return "null";
|
|
48
60
|
}
|
|
49
|
-
|
|
61
|
+
|
|
50
62
|
let returnStructure = {};
|
|
51
|
-
|
|
63
|
+
|
|
52
64
|
// Handle object properties
|
|
53
65
|
if (schema.properties) {
|
|
54
66
|
Object.keys(schema.properties).forEach((key) => {
|
|
55
67
|
returnStructure[key] = flattenSkeleton(schema.properties[key]);
|
|
56
68
|
});
|
|
57
69
|
}
|
|
58
|
-
|
|
70
|
+
|
|
59
71
|
// Handle oneOf - merge all possible properties
|
|
60
72
|
if (schema.oneOf) {
|
|
61
73
|
schema.oneOf.forEach((aOneOf) => {
|
|
@@ -78,7 +90,7 @@ const flattenSkeleton = (schema) => {
|
|
|
78
90
|
}
|
|
79
91
|
});
|
|
80
92
|
}
|
|
81
|
-
|
|
93
|
+
|
|
82
94
|
// Return empty object for objects without properties
|
|
83
95
|
return Object.keys(returnStructure).length > 0 ? returnStructure : {};
|
|
84
96
|
};
|
|
@@ -237,7 +249,7 @@ const toCompact = (obj, indent = "") => {
|
|
|
237
249
|
// Skip type indicators entirely
|
|
238
250
|
return "";
|
|
239
251
|
}
|
|
240
|
-
|
|
252
|
+
|
|
241
253
|
if (Array.isArray(obj)) {
|
|
242
254
|
if (obj.length === 0) return "[]";
|
|
243
255
|
// Array with content
|
|
@@ -247,16 +259,25 @@ const toCompact = (obj, indent = "") => {
|
|
|
247
259
|
}
|
|
248
260
|
return `[\n${inner}\n${indent}]`;
|
|
249
261
|
}
|
|
250
|
-
|
|
262
|
+
|
|
251
263
|
if (obj && typeof obj === "object") {
|
|
252
264
|
const keys = Object.keys(obj);
|
|
253
265
|
if (keys.length === 0) return "";
|
|
254
|
-
|
|
266
|
+
|
|
267
|
+
// Check if this is a keyed object (has "*" key)
|
|
268
|
+
if (keys.length === 1 && keys[0] === "*") {
|
|
269
|
+
const inner = toCompact(obj["*"], indent);
|
|
270
|
+
if (inner === "") {
|
|
271
|
+
return "{*}"; // Keyed object of primitives
|
|
272
|
+
}
|
|
273
|
+
return `{*}\n${inner}`;
|
|
274
|
+
}
|
|
275
|
+
|
|
255
276
|
// Process each key
|
|
256
277
|
const lines = [];
|
|
257
278
|
keys.forEach(k => {
|
|
258
279
|
const val = toCompact(obj[k], indent + " ");
|
|
259
|
-
|
|
280
|
+
|
|
260
281
|
if (val === "") {
|
|
261
282
|
// Leaf node - just show the property name
|
|
262
283
|
lines.push(`${indent} ${k}`);
|
|
@@ -266,16 +287,19 @@ const toCompact = (obj, indent = "") => {
|
|
|
266
287
|
} else if (val.startsWith("[")) {
|
|
267
288
|
// Array with nested content - simple concatenation
|
|
268
289
|
lines.push(`${indent} ${k}${val}`);
|
|
290
|
+
} else if (val.startsWith("{*}")) {
|
|
291
|
+
// Keyed object property - simple concatenation
|
|
292
|
+
lines.push(`${indent} ${k}${val}`);
|
|
269
293
|
} else {
|
|
270
294
|
// Object property - show name on its own line, content below
|
|
271
295
|
lines.push(`${indent} ${k}`);
|
|
272
296
|
lines.push(val);
|
|
273
297
|
}
|
|
274
298
|
});
|
|
275
|
-
|
|
299
|
+
|
|
276
300
|
return lines.length > 0 ? lines.join("\n") : "";
|
|
277
301
|
}
|
|
278
|
-
|
|
302
|
+
|
|
279
303
|
return "";
|
|
280
304
|
};
|
|
281
305
|
|