@telorun/sdk 0.75.0 → 0.77.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-schema-ref.d.ts","sourceRoot":"","sources":["../src/type-schema-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElF;AAED;;;;;;wBAMwB;AACxB,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,OAAO,GACX;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAKjD;
|
|
1
|
+
{"version":3,"file":"type-schema-ref.d.ts","sourceRoot":"","sources":["../src/type-schema-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElF;AAED;;;;;;wBAMwB;AACxB,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,OAAO,GACX;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAKjD;AAyBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6CzB;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAKjE"}
|
package/dist/type-schema-ref.js
CHANGED
|
@@ -55,6 +55,14 @@ const STRUCTURAL_KEYS = new Set([
|
|
|
55
55
|
"properties",
|
|
56
56
|
"required",
|
|
57
57
|
"additionalProperties",
|
|
58
|
+
// `$defs` is a NAMESPACE, not a value: last-wins would drop every definition
|
|
59
|
+
// the other side declared, and a `$ref` pointing at one would then resolve to
|
|
60
|
+
// nothing. That is not hypothetical — a schema-valued slot is localized to
|
|
61
|
+
// `#/$defs/telo:<Fragment>` and hoisted here, so a child declaring any `$defs`
|
|
62
|
+
// of its own would erase the parent's hoisted entry and leave the parent's
|
|
63
|
+
// slots pointing at a definition that no longer exists.
|
|
64
|
+
"$defs",
|
|
65
|
+
"definitions",
|
|
58
66
|
"allOf",
|
|
59
67
|
"oneOf",
|
|
60
68
|
"anyOf",
|
|
@@ -85,6 +93,7 @@ const STRUCTURAL_KEYS = new Set([
|
|
|
85
93
|
export function mergeTypeSchemas(schemas) {
|
|
86
94
|
const out = {};
|
|
87
95
|
const properties = {};
|
|
96
|
+
const defs = { $defs: {}, definitions: {} };
|
|
88
97
|
const required = new Set();
|
|
89
98
|
let additionalProperties;
|
|
90
99
|
let hasAdditionalProperties = false;
|
|
@@ -101,6 +110,11 @@ export function mergeTypeSchemas(schemas) {
|
|
|
101
110
|
const props = schema.properties;
|
|
102
111
|
if (props && typeof props === "object")
|
|
103
112
|
Object.assign(properties, props);
|
|
113
|
+
for (const key of ["$defs", "definitions"]) {
|
|
114
|
+
const declared = schema[key];
|
|
115
|
+
if (declared && typeof declared === "object")
|
|
116
|
+
Object.assign(defs[key], declared);
|
|
117
|
+
}
|
|
104
118
|
const req = schema.required;
|
|
105
119
|
if (Array.isArray(req))
|
|
106
120
|
for (const name of req)
|
|
@@ -121,6 +135,10 @@ export function mergeTypeSchemas(schemas) {
|
|
|
121
135
|
}
|
|
122
136
|
if (Object.keys(properties).length > 0)
|
|
123
137
|
out.properties = properties;
|
|
138
|
+
for (const key of ["$defs", "definitions"]) {
|
|
139
|
+
if (Object.keys(defs[key]).length > 0)
|
|
140
|
+
out[key] = defs[key];
|
|
141
|
+
}
|
|
124
142
|
if (required.size > 0)
|
|
125
143
|
out.required = [...required];
|
|
126
144
|
if (hasAdditionalProperties)
|
package/package.json
CHANGED
package/src/type-schema-ref.ts
CHANGED
|
@@ -59,6 +59,14 @@ const STRUCTURAL_KEYS = new Set([
|
|
|
59
59
|
"properties",
|
|
60
60
|
"required",
|
|
61
61
|
"additionalProperties",
|
|
62
|
+
// `$defs` is a NAMESPACE, not a value: last-wins would drop every definition
|
|
63
|
+
// the other side declared, and a `$ref` pointing at one would then resolve to
|
|
64
|
+
// nothing. That is not hypothetical — a schema-valued slot is localized to
|
|
65
|
+
// `#/$defs/telo:<Fragment>` and hoisted here, so a child declaring any `$defs`
|
|
66
|
+
// of its own would erase the parent's hoisted entry and leave the parent's
|
|
67
|
+
// slots pointing at a definition that no longer exists.
|
|
68
|
+
"$defs",
|
|
69
|
+
"definitions",
|
|
62
70
|
"allOf",
|
|
63
71
|
"oneOf",
|
|
64
72
|
"anyOf",
|
|
@@ -92,6 +100,7 @@ export function mergeTypeSchemas(
|
|
|
92
100
|
): Record<string, unknown> {
|
|
93
101
|
const out: Record<string, unknown> = {};
|
|
94
102
|
const properties: Record<string, unknown> = {};
|
|
103
|
+
const defs: Record<string, Record<string, unknown>> = { $defs: {}, definitions: {} };
|
|
95
104
|
const required = new Set<string>();
|
|
96
105
|
let additionalProperties: unknown;
|
|
97
106
|
let hasAdditionalProperties = false;
|
|
@@ -106,6 +115,10 @@ export function mergeTypeSchemas(
|
|
|
106
115
|
}
|
|
107
116
|
const props = (schema as { properties?: unknown }).properties;
|
|
108
117
|
if (props && typeof props === "object") Object.assign(properties, props);
|
|
118
|
+
for (const key of ["$defs", "definitions"] as const) {
|
|
119
|
+
const declared = (schema as Record<string, unknown>)[key];
|
|
120
|
+
if (declared && typeof declared === "object") Object.assign(defs[key], declared);
|
|
121
|
+
}
|
|
109
122
|
const req = (schema as { required?: unknown }).required;
|
|
110
123
|
if (Array.isArray(req)) for (const name of req) required.add(name as string);
|
|
111
124
|
if ("additionalProperties" in schema) {
|
|
@@ -121,6 +134,9 @@ export function mergeTypeSchemas(
|
|
|
121
134
|
}
|
|
122
135
|
|
|
123
136
|
if (Object.keys(properties).length > 0) out.properties = properties;
|
|
137
|
+
for (const key of ["$defs", "definitions"] as const) {
|
|
138
|
+
if (Object.keys(defs[key]).length > 0) out[key] = defs[key];
|
|
139
|
+
}
|
|
124
140
|
if (required.size > 0) out.required = [...required];
|
|
125
141
|
if (hasAdditionalProperties) out.additionalProperties = additionalProperties;
|
|
126
142
|
if (composition.length > 0) out.allOf = composition;
|