@decocms/bindings 0.2.4 → 1.0.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 (54) hide show
  1. package/README.md +3 -3
  2. package/package.json +9 -35
  3. package/src/core/binder.ts +241 -0
  4. package/src/core/client/README.md +3 -0
  5. package/{dist/core/client/http-client-transport.js → src/core/client/http-client-transport.ts} +24 -12
  6. package/src/core/client/index.ts +1 -0
  7. package/src/core/client/mcp-client.ts +149 -0
  8. package/src/core/client/mcp.ts +93 -0
  9. package/src/core/client/proxy.ts +151 -0
  10. package/src/core/connection.ts +38 -0
  11. package/src/core/subset.ts +514 -0
  12. package/src/index.ts +15 -0
  13. package/src/well-known/agent.ts +60 -0
  14. package/src/well-known/collections.ts +416 -0
  15. package/src/well-known/language-model.ts +383 -0
  16. package/test/index.test.ts +942 -0
  17. package/tsconfig.json +11 -0
  18. package/vitest.config.ts +8 -0
  19. package/dist/core/binder.d.ts +0 -3
  20. package/dist/core/binder.js +0 -77
  21. package/dist/core/binder.js.map +0 -1
  22. package/dist/core/client/http-client-transport.d.ts +0 -12
  23. package/dist/core/client/http-client-transport.js.map +0 -1
  24. package/dist/core/client/index.d.ts +0 -3
  25. package/dist/core/client/index.js +0 -5
  26. package/dist/core/client/index.js.map +0 -1
  27. package/dist/core/client/mcp-client.d.ts +0 -233
  28. package/dist/core/client/mcp-client.js +0 -99
  29. package/dist/core/client/mcp-client.js.map +0 -1
  30. package/dist/core/client/mcp.d.ts +0 -3
  31. package/dist/core/client/mcp.js +0 -29
  32. package/dist/core/client/mcp.js.map +0 -1
  33. package/dist/core/client/proxy.d.ts +0 -10
  34. package/dist/core/client/proxy.js +0 -104
  35. package/dist/core/client/proxy.js.map +0 -1
  36. package/dist/core/connection.d.ts +0 -30
  37. package/dist/core/connection.js +0 -1
  38. package/dist/core/connection.js.map +0 -1
  39. package/dist/core/subset.d.ts +0 -17
  40. package/dist/core/subset.js +0 -319
  41. package/dist/core/subset.js.map +0 -1
  42. package/dist/index-D0aUdNls.d.ts +0 -153
  43. package/dist/index.d.ts +0 -3
  44. package/dist/index.js +0 -7
  45. package/dist/index.js.map +0 -1
  46. package/dist/well-known/agent.d.ts +0 -903
  47. package/dist/well-known/agent.js +0 -27
  48. package/dist/well-known/agent.js.map +0 -1
  49. package/dist/well-known/collections.d.ts +0 -537
  50. package/dist/well-known/collections.js +0 -134
  51. package/dist/well-known/collections.js.map +0 -1
  52. package/dist/well-known/language-model.d.ts +0 -2836
  53. package/dist/well-known/language-model.js +0 -209
  54. package/dist/well-known/language-model.js.map +0 -1
@@ -1,104 +0,0 @@
1
- import { convertJsonSchemaToZod } from "zod-from-json-schema";
2
- import { createServerClient } from "./mcp-client";
3
- const safeParse = (content) => {
4
- try {
5
- return JSON.parse(content);
6
- } catch {
7
- return content;
8
- }
9
- };
10
- const toolsMap = /* @__PURE__ */ new Map();
11
- function createMCPClientProxy(options) {
12
- return new Proxy({}, {
13
- get(_, name) {
14
- if (name === "toJSON") {
15
- return null;
16
- }
17
- if (typeof name !== "string") {
18
- throw new Error("Name must be a string");
19
- }
20
- async function callToolFn(args) {
21
- const debugId = options?.debugId?.();
22
- const extraHeaders = debugId ? { "x-trace-debug-id": debugId } : void 0;
23
- const { client, callStreamableTool } = await createServerClient(
24
- { connection: options.connection },
25
- void 0,
26
- extraHeaders
27
- );
28
- if (options?.streamable?.[String(name)]) {
29
- return callStreamableTool(String(name), args);
30
- }
31
- const { structuredContent, isError, content } = await client.callTool(
32
- {
33
- name: String(name),
34
- arguments: args
35
- },
36
- void 0,
37
- {
38
- timeout: 3e6
39
- }
40
- );
41
- if (isError) {
42
- const maybeErrorMessage = content?.[0]?.text;
43
- const error = typeof maybeErrorMessage === "string" ? safeParse(maybeErrorMessage) : null;
44
- const throwableError = error?.code && typeof options?.getErrorByStatusCode === "function" ? options.getErrorByStatusCode(
45
- error.code,
46
- error.message,
47
- error.traceId
48
- ) : null;
49
- if (throwableError) {
50
- throw throwableError;
51
- }
52
- throw new Error(
53
- `Tool ${String(name)} returned an error: ${JSON.stringify(
54
- structuredContent ?? content
55
- )}`
56
- );
57
- }
58
- return structuredContent;
59
- }
60
- const listToolsFn = async () => {
61
- const { client } = await createServerClient({
62
- connection: options.connection
63
- });
64
- const { tools } = await client.listTools();
65
- return tools;
66
- };
67
- async function listToolsOnce() {
68
- const conn = options.connection;
69
- const key = JSON.stringify(conn);
70
- try {
71
- if (!toolsMap.has(key)) {
72
- toolsMap.set(key, listToolsFn());
73
- }
74
- return await toolsMap.get(key);
75
- } catch (error) {
76
- console.error("Failed to list tools", error);
77
- toolsMap.delete(key);
78
- return;
79
- }
80
- }
81
- callToolFn.asTool = async () => {
82
- const tools = await listToolsOnce() ?? [];
83
- const tool = tools.find((t) => t.name === name);
84
- if (!tool) {
85
- throw new Error(`Tool ${name} not found`);
86
- }
87
- return {
88
- ...tool,
89
- id: tool.name,
90
- inputSchema: tool.inputSchema ? convertJsonSchemaToZod(tool.inputSchema) : void 0,
91
- outputSchema: tool.outputSchema ? convertJsonSchemaToZod(tool.outputSchema) : void 0,
92
- execute: (input) => {
93
- return callToolFn(input.context);
94
- }
95
- };
96
- };
97
- return callToolFn;
98
- }
99
- });
100
- }
101
- export {
102
- createMCPClientProxy
103
- };
104
- //# sourceMappingURL=proxy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/core/client/proxy.ts"],"sourcesContent":["/* oxlint-disable no-explicit-any */\nimport { convertJsonSchemaToZod } from \"zod-from-json-schema\";\nimport type { CreateStubAPIOptions } from \"./mcp\";\nimport { createServerClient } from \"./mcp-client\";\n\nconst safeParse = (content: string) => {\n try {\n return JSON.parse(content as string);\n } catch {\n return content;\n }\n};\n\nconst toolsMap = new Map<\n string,\n Promise<\n Array<{\n name: string;\n inputSchema: any;\n outputSchema?: any;\n description: string;\n }>\n >\n>();\n\n/**\n * The base fetcher used to fetch the MCP from API.\n */\nexport function createMCPClientProxy<T extends Record<string, unknown>>(\n options: CreateStubAPIOptions,\n): T {\n return new Proxy<T>({} as T, {\n get(_, name) {\n if (name === \"toJSON\") {\n return null;\n }\n if (typeof name !== \"string\") {\n throw new Error(\"Name must be a string\");\n }\n async function callToolFn(args: unknown) {\n const debugId = options?.debugId?.();\n const extraHeaders = debugId\n ? { \"x-trace-debug-id\": debugId }\n : undefined;\n\n const { client, callStreamableTool } = await createServerClient(\n { connection: options.connection },\n undefined,\n extraHeaders,\n );\n\n if (options?.streamable?.[String(name)]) {\n return callStreamableTool(String(name), args);\n }\n\n const { structuredContent, isError, content } = await client.callTool(\n {\n name: String(name),\n arguments: args as Record<string, unknown>,\n },\n undefined,\n {\n timeout: 3000000,\n },\n );\n\n if (isError) {\n const maybeErrorMessage = (content as { text: string }[])?.[0]?.text;\n const error =\n typeof maybeErrorMessage === \"string\"\n ? safeParse(maybeErrorMessage)\n : null;\n\n const throwableError =\n error?.code && typeof options?.getErrorByStatusCode === \"function\"\n ? options.getErrorByStatusCode(\n error.code,\n error.message,\n error.traceId,\n )\n : null;\n\n if (throwableError) {\n throw throwableError;\n }\n\n throw new Error(\n `Tool ${String(name)} returned an error: ${JSON.stringify(\n structuredContent ?? content,\n )}`,\n );\n }\n return structuredContent;\n }\n\n const listToolsFn = async () => {\n const { client } = await createServerClient({\n connection: options.connection,\n });\n const { tools } = await client.listTools();\n\n return tools as {\n name: string;\n inputSchema: any;\n outputSchema?: any;\n description: string;\n }[];\n };\n\n async function listToolsOnce() {\n const conn = options.connection;\n const key = JSON.stringify(conn);\n\n try {\n if (!toolsMap.has(key)) {\n toolsMap.set(key, listToolsFn());\n }\n\n return await toolsMap.get(key)!;\n } catch (error) {\n console.error(\"Failed to list tools\", error);\n\n toolsMap.delete(key);\n return;\n }\n }\n callToolFn.asTool = async () => {\n const tools = (await listToolsOnce()) ?? [];\n const tool = tools.find((t) => t.name === name);\n if (!tool) {\n throw new Error(`Tool ${name} not found`);\n }\n\n return {\n ...tool,\n id: tool.name,\n inputSchema: tool.inputSchema\n ? convertJsonSchemaToZod(tool.inputSchema)\n : undefined,\n outputSchema: tool.outputSchema\n ? convertJsonSchemaToZod(tool.outputSchema)\n : undefined,\n execute: (input: any) => {\n return callToolFn(input.context);\n },\n };\n };\n return callToolFn;\n },\n });\n}\n"],"mappings":"AACA,SAAS,8BAA8B;AAEvC,SAAS,0BAA0B;AAEnC,MAAM,YAAY,CAAC,YAAoB;AACrC,MAAI;AACF,WAAO,KAAK,MAAM,OAAiB;AAAA,EACrC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,MAAM,WAAW,oBAAI,IAUnB;AAKK,SAAS,qBACd,SACG;AACH,SAAO,IAAI,MAAS,CAAC,GAAQ;AAAA,IAC3B,IAAI,GAAG,MAAM;AACX,UAAI,SAAS,UAAU;AACrB,eAAO;AAAA,MACT;AACA,UAAI,OAAO,SAAS,UAAU;AAC5B,cAAM,IAAI,MAAM,uBAAuB;AAAA,MACzC;AACA,qBAAe,WAAW,MAAe;AACvC,cAAM,UAAU,SAAS,UAAU;AACnC,cAAM,eAAe,UACjB,EAAE,oBAAoB,QAAQ,IAC9B;AAEJ,cAAM,EAAE,QAAQ,mBAAmB,IAAI,MAAM;AAAA,UAC3C,EAAE,YAAY,QAAQ,WAAW;AAAA,UACjC;AAAA,UACA;AAAA,QACF;AAEA,YAAI,SAAS,aAAa,OAAO,IAAI,CAAC,GAAG;AACvC,iBAAO,mBAAmB,OAAO,IAAI,GAAG,IAAI;AAAA,QAC9C;AAEA,cAAM,EAAE,mBAAmB,SAAS,QAAQ,IAAI,MAAM,OAAO;AAAA,UAC3D;AAAA,YACE,MAAM,OAAO,IAAI;AAAA,YACjB,WAAW;AAAA,UACb;AAAA,UACA;AAAA,UACA;AAAA,YACE,SAAS;AAAA,UACX;AAAA,QACF;AAEA,YAAI,SAAS;AACX,gBAAM,oBAAqB,UAAiC,CAAC,GAAG;AAChE,gBAAM,QACJ,OAAO,sBAAsB,WACzB,UAAU,iBAAiB,IAC3B;AAEN,gBAAM,iBACJ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,UAAe;AACvB,mBAAO,WAAW,MAAM,OAAO;AAAA,UACjC;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,30 +0,0 @@
1
- type SSEConnection = {
2
- type: "SSE";
3
- url: string;
4
- token?: string;
5
- headers?: Record<string, string>;
6
- };
7
- type WebsocketConnection = {
8
- type: "Websocket";
9
- url: string;
10
- token?: string;
11
- };
12
- type DecoConnection = {
13
- type: "Deco";
14
- tenant: string;
15
- token?: string;
16
- };
17
- type InnateConnection = {
18
- type: "INNATE";
19
- name: string;
20
- workspace?: string;
21
- };
22
- type HTTPConnection = {
23
- type: "HTTP";
24
- url: string;
25
- headers?: Record<string, string>;
26
- token?: string;
27
- };
28
- type MCPConnection = SSEConnection | WebsocketConnection | InnateConnection | DecoConnection | HTTPConnection;
29
-
30
- export type { DecoConnection, HTTPConnection, InnateConnection, MCPConnection, SSEConnection, WebsocketConnection };
@@ -1 +0,0 @@
1
- //# sourceMappingURL=connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,17 +0,0 @@
1
- /**
2
- * Structural JSON Schema Subset Check
3
- *
4
- * This module implements an algorithm to determine if one JSON Schema (A)
5
- * is a subset of another (B). A ⊆ B means every value valid under A is also
6
- * valid under B (A is more restrictive or equally restrictive).
7
- *
8
- * Core Axiom: A ⊆ B ⟺ Constraints(A) ⊇ Constraints(B)
9
- */
10
- type JSONSchema = Record<string, any>;
11
- /**
12
- * Main subset check: isSubset(A, B)
13
- * Returns true if A ⊆ B (every value valid under A is valid under B)
14
- */
15
- declare function isSubset(schemaA: JSONSchema | boolean, schemaB: JSONSchema | boolean): boolean;
16
-
17
- export { isSubset };
@@ -1,319 +0,0 @@
1
- function deepEqual(x, y) {
2
- if (x === y) return true;
3
- if (typeof x !== typeof y) return false;
4
- if (x === null || y === null) return x === y;
5
- if (typeof x !== "object") return false;
6
- if (Array.isArray(x)) {
7
- if (!Array.isArray(y)) return false;
8
- if (x.length !== y.length) return false;
9
- for (let i = 0; i < x.length; i++) {
10
- if (!deepEqual(x[i], y[i])) return false;
11
- }
12
- return true;
13
- }
14
- if (Array.isArray(y)) return false;
15
- const xObj = x;
16
- const yObj = y;
17
- const xKeys = Object.keys(xObj);
18
- const yKeys = Object.keys(yObj);
19
- if (xKeys.length !== yKeys.length) return false;
20
- for (const key of xKeys) {
21
- if (!Object.prototype.hasOwnProperty.call(yObj, key)) return false;
22
- if (!deepEqual(xObj[key], yObj[key])) return false;
23
- }
24
- return true;
25
- }
26
- function normalize(schema) {
27
- if (schema === true) return {};
28
- if (schema === false) return { not: {} };
29
- const s = { ...schema };
30
- if (Array.isArray(s.type)) {
31
- const types = s.type;
32
- if (types.length === 1) {
33
- s.type = types[0];
34
- } else {
35
- const { type: _type, ...rest } = s;
36
- return {
37
- anyOf: types.map((t) => normalize({ ...rest, type: t }))
38
- };
39
- }
40
- }
41
- if (s.type === "integer") {
42
- s.type = "number";
43
- if (s.multipleOf === void 0) {
44
- s.multipleOf = 1;
45
- }
46
- }
47
- return s;
48
- }
49
- function isSetSubset(a, b) {
50
- const setB = new Set(b);
51
- return a.every((item) => setB.has(item));
52
- }
53
- function getEffectiveMin(schema) {
54
- const min = schema.minimum ?? -Infinity;
55
- const exMin = schema.exclusiveMinimum;
56
- if (typeof exMin === "number") {
57
- return Math.max(min, exMin);
58
- }
59
- if (exMin === true && typeof schema.minimum === "number") {
60
- return schema.minimum;
61
- }
62
- return min;
63
- }
64
- function getEffectiveMax(schema) {
65
- const max = schema.maximum ?? Infinity;
66
- const exMax = schema.exclusiveMaximum;
67
- if (typeof exMax === "number") {
68
- return Math.min(max, exMax);
69
- }
70
- if (exMax === true && typeof schema.maximum === "number") {
71
- return schema.maximum;
72
- }
73
- return max;
74
- }
75
- function isMultipleOf(a, b) {
76
- if (b === 0) return false;
77
- const ratio = a / b;
78
- return Math.abs(ratio - Math.round(ratio)) < 1e-10;
79
- }
80
- function isEnumSubset(enumA, schemaB) {
81
- if (schemaB.enum) {
82
- return enumA.every(
83
- (val) => schemaB.enum.some((bVal) => deepEqual(val, bVal))
84
- );
85
- }
86
- if (schemaB.const !== void 0) {
87
- return enumA.length === 1 && deepEqual(enumA[0], schemaB.const);
88
- }
89
- return true;
90
- }
91
- function isSubset(schemaA, schemaB) {
92
- const a = normalize(schemaA);
93
- const b = normalize(schemaB);
94
- if (Object.keys(b).length === 0) return true;
95
- if (a.not && Object.keys(a.not).length === 0) return true;
96
- if (deepEqual(a, b)) return true;
97
- if (a.anyOf) {
98
- return a.anyOf.every((optA) => isSubset(optA, b));
99
- }
100
- if (a.oneOf) {
101
- return a.oneOf.every((optA) => isSubset(optA, b));
102
- }
103
- if (b.anyOf) {
104
- return b.anyOf.some((optB) => isSubset(a, optB));
105
- }
106
- if (b.oneOf) {
107
- return b.oneOf.some((optB) => isSubset(a, optB));
108
- }
109
- if (b.allOf) {
110
- return b.allOf.every((optB) => isSubset(a, optB));
111
- }
112
- if (a.allOf) {
113
- return a.allOf.some((optA) => isSubset(optA, b));
114
- }
115
- if (a.const !== void 0) {
116
- if (b.const !== void 0) {
117
- return deepEqual(a.const, b.const);
118
- }
119
- if (b.enum) {
120
- return b.enum.some((v) => deepEqual(a.const, v));
121
- }
122
- return isValueValidForType(a.const, b);
123
- }
124
- if (a.enum) {
125
- return isEnumSubset(a.enum, b);
126
- }
127
- if (a.type && b.type && a.type !== b.type) {
128
- return false;
129
- }
130
- if (b.type && !a.type) {
131
- if (!a.enum && a.const === void 0) {
132
- return false;
133
- }
134
- }
135
- const type = a.type || b.type;
136
- switch (type) {
137
- case "object":
138
- return isObjectSubset(a, b);
139
- case "array":
140
- return isArraySubset(a, b);
141
- case "number":
142
- return isNumberSubset(a, b);
143
- case "string":
144
- return isStringSubset(a, b);
145
- case "boolean":
146
- case "null":
147
- return true;
148
- default:
149
- return true;
150
- }
151
- }
152
- function isValueValidForType(value, schema) {
153
- if (!schema.type) return true;
154
- const valueType = typeof value;
155
- switch (schema.type) {
156
- case "string":
157
- return valueType === "string";
158
- case "number":
159
- return valueType === "number";
160
- case "boolean":
161
- return valueType === "boolean";
162
- case "null":
163
- return value === null;
164
- case "object":
165
- return valueType === "object" && value !== null && !Array.isArray(value);
166
- case "array":
167
- return Array.isArray(value);
168
- default:
169
- return true;
170
- }
171
- }
172
- function isObjectSubset(a, b) {
173
- const aRequired = a.required || [];
174
- const bRequired = b.required || [];
175
- if (!isSetSubset(bRequired, aRequired)) {
176
- return false;
177
- }
178
- const aProps = a.properties || {};
179
- const bProps = b.properties || {};
180
- for (const key of Object.keys(bProps)) {
181
- if (key in aProps) {
182
- if (!isSubset(aProps[key], bProps[key])) {
183
- return false;
184
- }
185
- } else {
186
- if (a.additionalProperties === false) {
187
- if (bRequired.includes(key)) {
188
- return false;
189
- }
190
- } else {
191
- const aAdditional = a.additionalProperties;
192
- if (aAdditional && typeof aAdditional === "object") {
193
- if (!isSubset(aAdditional, bProps[key])) {
194
- return false;
195
- }
196
- }
197
- }
198
- }
199
- }
200
- for (const key of aRequired) {
201
- if (key in aProps && !(key in bProps)) {
202
- if (b.additionalProperties === false) {
203
- return false;
204
- } else if (b.additionalProperties && typeof b.additionalProperties === "object") {
205
- if (!isSubset(aProps[key], b.additionalProperties)) {
206
- return false;
207
- }
208
- }
209
- }
210
- }
211
- if (b.additionalProperties === false) {
212
- const aHasExtraProps = Object.keys(aProps).some((key) => !(key in bProps));
213
- if (aHasExtraProps) {
214
- return false;
215
- }
216
- if (a.additionalProperties !== false) {
217
- return false;
218
- }
219
- } else if (b.additionalProperties && typeof b.additionalProperties === "object") {
220
- const aAdditional = a.additionalProperties;
221
- if (aAdditional && typeof aAdditional === "object") {
222
- if (!isSubset(aAdditional, b.additionalProperties)) {
223
- return false;
224
- }
225
- }
226
- }
227
- return true;
228
- }
229
- function isArraySubset(a, b) {
230
- if (a.items && b.items) {
231
- if (Array.isArray(a.items) && Array.isArray(b.items)) {
232
- if (a.items.length !== b.items.length) {
233
- return false;
234
- }
235
- for (let i = 0; i < a.items.length; i++) {
236
- if (!isSubset(a.items[i], b.items[i])) {
237
- return false;
238
- }
239
- }
240
- } else if (Array.isArray(a.items) && !Array.isArray(b.items)) {
241
- for (const itemSchema of a.items) {
242
- if (!isSubset(itemSchema, b.items)) {
243
- return false;
244
- }
245
- }
246
- } else if (!Array.isArray(a.items) && Array.isArray(b.items)) {
247
- return false;
248
- } else {
249
- if (!isSubset(a.items, b.items)) {
250
- return false;
251
- }
252
- }
253
- } else if (b.items && !a.items) {
254
- return false;
255
- }
256
- const aMinItems = a.minItems ?? 0;
257
- const bMinItems = b.minItems ?? 0;
258
- if (aMinItems < bMinItems) {
259
- return false;
260
- }
261
- const aMaxItems = a.maxItems ?? Infinity;
262
- const bMaxItems = b.maxItems ?? Infinity;
263
- if (aMaxItems > bMaxItems) {
264
- return false;
265
- }
266
- if (b.uniqueItems && !a.uniqueItems) {
267
- return false;
268
- }
269
- return true;
270
- }
271
- function isNumberSubset(a, b) {
272
- const aMin = getEffectiveMin(a);
273
- const bMin = getEffectiveMin(b);
274
- if (aMin < bMin) {
275
- return false;
276
- }
277
- const aMax = getEffectiveMax(a);
278
- const bMax = getEffectiveMax(b);
279
- if (aMax > bMax) {
280
- return false;
281
- }
282
- if (b.multipleOf !== void 0) {
283
- if (a.multipleOf === void 0) {
284
- return false;
285
- }
286
- if (!isMultipleOf(a.multipleOf, b.multipleOf)) {
287
- return false;
288
- }
289
- }
290
- return true;
291
- }
292
- function isStringSubset(a, b) {
293
- const aMinLength = a.minLength ?? 0;
294
- const bMinLength = b.minLength ?? 0;
295
- if (aMinLength < bMinLength) {
296
- return false;
297
- }
298
- const aMaxLength = a.maxLength ?? Infinity;
299
- const bMaxLength = b.maxLength ?? Infinity;
300
- if (aMaxLength > bMaxLength) {
301
- return false;
302
- }
303
- if (b.pattern) {
304
- if (!a.pattern) {
305
- return false;
306
- }
307
- if (a.pattern !== b.pattern) {
308
- return false;
309
- }
310
- }
311
- if (b.format && a.format !== b.format) {
312
- return false;
313
- }
314
- return true;
315
- }
316
- export {
317
- isSubset
318
- };
319
- //# sourceMappingURL=subset.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/subset.ts"],"sourcesContent":["/**\n * Structural JSON Schema Subset Check\n *\n * This module implements an algorithm to determine if one JSON Schema (A)\n * is a subset of another (B). A ⊆ B means every value valid under A is also\n * valid under B (A is more restrictive or equally restrictive).\n *\n * Core Axiom: A ⊆ B ⟺ Constraints(A) ⊇ Constraints(B)\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype JSONSchema = Record<string, any>;\n\n/**\n * Deep equality check for JSON values (for const/enum comparison)\n */\nfunction deepEqual(x: unknown, y: unknown): boolean {\n if (x === y) return true;\n if (typeof x !== typeof y) return false;\n if (x === null || y === null) return x === y;\n if (typeof x !== \"object\") return false;\n\n if (Array.isArray(x)) {\n if (!Array.isArray(y)) return false;\n if (x.length !== y.length) return false;\n for (let i = 0; i < x.length; i++) {\n if (!deepEqual(x[i], y[i])) return false;\n }\n return true;\n }\n\n if (Array.isArray(y)) return false;\n\n const xObj = x as Record<string, unknown>;\n const yObj = y as Record<string, unknown>;\n const xKeys = Object.keys(xObj);\n const yKeys = Object.keys(yObj);\n\n if (xKeys.length !== yKeys.length) return false;\n\n for (const key of xKeys) {\n if (!Object.prototype.hasOwnProperty.call(yObj, key)) return false;\n if (!deepEqual(xObj[key], yObj[key])) return false;\n }\n\n return true;\n}\n\n/**\n * Phase 1: Normalization\n * Convert syntactic sugar to canonical form\n */\nfunction normalize(schema: JSONSchema | boolean): JSONSchema {\n // Boolean schemas\n if (schema === true) return {};\n if (schema === false) return { not: {} };\n\n // Already an object\n const s = { ...schema };\n\n // Type arrays -> anyOf\n if (Array.isArray(s.type)) {\n const types = s.type as string[];\n if (types.length === 1) {\n s.type = types[0];\n } else {\n const { type: _type, ...rest } = s;\n return {\n anyOf: types.map((t) => normalize({ ...rest, type: t })),\n };\n }\n }\n\n // Integer is number with multipleOf: 1\n if (s.type === \"integer\") {\n s.type = \"number\";\n if (s.multipleOf === undefined) {\n s.multipleOf = 1;\n }\n }\n\n return s;\n}\n\n/**\n * Check if set A is a subset of set B (for required fields)\n */\nfunction isSetSubset(a: string[], b: string[]): boolean {\n const setB = new Set(b);\n return a.every((item) => setB.has(item));\n}\n\n/**\n * Get effective minimum value from schema\n */\nfunction getEffectiveMin(schema: JSONSchema): number {\n const min = schema.minimum ?? -Infinity;\n const exMin = schema.exclusiveMinimum;\n\n if (typeof exMin === \"number\") {\n return Math.max(min, exMin);\n }\n if (exMin === true && typeof schema.minimum === \"number\") {\n return schema.minimum;\n }\n return min;\n}\n\n/**\n * Get effective maximum value from schema\n */\nfunction getEffectiveMax(schema: JSONSchema): number {\n const max = schema.maximum ?? Infinity;\n const exMax = schema.exclusiveMaximum;\n\n if (typeof exMax === \"number\") {\n return Math.min(max, exMax);\n }\n if (exMax === true && typeof schema.maximum === \"number\") {\n return schema.maximum;\n }\n return max;\n}\n\n/**\n * Check if multipleOfA is a multiple of multipleOfB\n * (i.e., A's constraint is tighter)\n */\nfunction isMultipleOf(a: number, b: number): boolean {\n if (b === 0) return false;\n // Handle floating point precision\n const ratio = a / b;\n return Math.abs(ratio - Math.round(ratio)) < 1e-10;\n}\n\n/**\n * Check if A's enum values are all valid in B\n */\nfunction isEnumSubset(enumA: unknown[], schemaB: JSONSchema): boolean {\n // If B has enum, check set inclusion\n if (schemaB.enum) {\n return enumA.every((val) =>\n schemaB.enum.some((bVal: unknown) => deepEqual(val, bVal)),\n );\n }\n\n // If B has const, check if A's enum only contains that value\n if (schemaB.const !== undefined) {\n return enumA.length === 1 && deepEqual(enumA[0], schemaB.const);\n }\n\n // Otherwise, enum values must match B's type constraints\n // This is a simplified check - full validation would require more\n return true;\n}\n\n/**\n * Main subset check: isSubset(A, B)\n * Returns true if A ⊆ B (every value valid under A is valid under B)\n */\nexport function isSubset(\n schemaA: JSONSchema | boolean,\n schemaB: JSONSchema | boolean,\n): boolean {\n // Phase 1: Normalize\n const a = normalize(schemaA);\n const b = normalize(schemaB);\n\n // Phase 2: Meta Logic - Universal Terminators\n\n // If B is {} (Any), everything is a subset\n if (Object.keys(b).length === 0) return true;\n\n // If A is false (Never), empty set is subset of everything\n if (a.not && Object.keys(a.not).length === 0) return true;\n\n // Deep equality check\n if (deepEqual(a, b)) return true;\n\n // Phase 2: Unions and Intersections\n\n // Left-side union (anyOf in A): all options must fit in B\n if (a.anyOf) {\n return (a.anyOf as JSONSchema[]).every((optA) => isSubset(optA, b));\n }\n\n // Left-side union (oneOf in A): all options must fit in B\n if (a.oneOf) {\n return (a.oneOf as JSONSchema[]).every((optA) => isSubset(optA, b));\n }\n\n // Right-side union (anyOf in B): A must fit in at least one option\n if (b.anyOf) {\n return (b.anyOf as JSONSchema[]).some((optB) => isSubset(a, optB));\n }\n\n // Right-side union (oneOf in B): A must fit in at least one option\n if (b.oneOf) {\n return (b.oneOf as JSONSchema[]).some((optB) => isSubset(a, optB));\n }\n\n // Right-side intersection (allOf in B): A must satisfy all\n if (b.allOf) {\n return (b.allOf as JSONSchema[]).every((optB) => isSubset(a, optB));\n }\n\n // Left-side intersection (allOf in A): merge and compare\n if (a.allOf) {\n // Simplified: check if any single branch satisfies B\n return (a.allOf as JSONSchema[]).some((optA) => isSubset(optA, b));\n }\n\n // Phase 3: Type-specific logic\n\n // Handle const in A\n if (a.const !== undefined) {\n if (b.const !== undefined) {\n return deepEqual(a.const, b.const);\n }\n if (b.enum) {\n return b.enum.some((v: unknown) => deepEqual(a.const, v));\n }\n // const must match B's type constraints\n return isValueValidForType(a.const, b);\n }\n\n // Handle enum in A\n if (a.enum) {\n return isEnumSubset(a.enum, b);\n }\n\n // Type mismatch check\n if (a.type && b.type && a.type !== b.type) {\n return false;\n }\n\n // If B has a type but A doesn't, A might allow more types\n if (b.type && !a.type) {\n // A is more permissive (no type restriction) so it's not a subset\n // unless A has other constraints that limit it\n if (!a.enum && a.const === undefined) {\n return false;\n }\n }\n\n const type = a.type || b.type;\n\n switch (type) {\n case \"object\":\n return isObjectSubset(a, b);\n case \"array\":\n return isArraySubset(a, b);\n case \"number\":\n return isNumberSubset(a, b);\n case \"string\":\n return isStringSubset(a, b);\n case \"boolean\":\n case \"null\":\n // These types have no additional constraints\n return true;\n default:\n // Unknown type or no type specified\n return true;\n }\n}\n\n/**\n * Check if a value would be valid for a schema's type\n */\nfunction isValueValidForType(value: unknown, schema: JSONSchema): boolean {\n if (!schema.type) return true;\n\n const valueType = typeof value;\n switch (schema.type) {\n case \"string\":\n return valueType === \"string\";\n case \"number\":\n return valueType === \"number\";\n case \"boolean\":\n return valueType === \"boolean\";\n case \"null\":\n return value === null;\n case \"object\":\n return valueType === \"object\" && value !== null && !Array.isArray(value);\n case \"array\":\n return Array.isArray(value);\n default:\n return true;\n }\n}\n\n/**\n * Object subset check\n */\nfunction isObjectSubset(a: JSONSchema, b: JSONSchema): boolean {\n // Required keys: A must require at least everything B requires\n const aRequired = (a.required as string[]) || [];\n const bRequired = (b.required as string[]) || [];\n\n if (!isSetSubset(bRequired, aRequired)) {\n return false;\n }\n\n // Property compatibility\n const aProps = (a.properties as Record<string, JSONSchema>) || {};\n const bProps = (b.properties as Record<string, JSONSchema>) || {};\n\n // Check all properties defined in B\n for (const key of Object.keys(bProps)) {\n if (key in aProps) {\n // Both have the property, check recursively\n if (!isSubset(aProps[key], bProps[key])) {\n return false;\n }\n } else {\n // Property missing in A\n // If A is closed (additionalProperties: false), A won't produce this key\n // which means A values won't have this property, potentially violating B if B requires it\n if (a.additionalProperties === false) {\n // A is closed and doesn't have this property\n // If B requires this property, A can't satisfy it\n if (bRequired.includes(key)) {\n return false;\n }\n // Otherwise, A just won't have this optional property, which is fine\n } else {\n // A is open, check if additionalProperties schema satisfies B's property\n const aAdditional = a.additionalProperties;\n if (aAdditional && typeof aAdditional === \"object\") {\n if (!isSubset(aAdditional, bProps[key])) {\n return false;\n }\n }\n // If additionalProperties is true or undefined, any value is allowed\n // which might not satisfy B's property schema\n }\n }\n }\n\n // Check all properties defined in A (that A requires)\n // If A requires a property, B must also define it (or have compatible additionalProperties)\n for (const key of aRequired) {\n if (key in aProps && !(key in bProps)) {\n // A requires and defines this property, but B doesn't define it\n // B must have additionalProperties that accepts A's property schema\n if (b.additionalProperties === false) {\n // B doesn't allow additional properties, so A's required property would be rejected\n return false;\n } else if (\n b.additionalProperties &&\n typeof b.additionalProperties === \"object\"\n ) {\n // B has a schema for additional properties, check compatibility\n if (!isSubset(aProps[key], b.additionalProperties)) {\n return false;\n }\n }\n // If B's additionalProperties is true or undefined, any value is allowed\n }\n }\n\n // Additional properties constraint\n if (b.additionalProperties === false) {\n // B is closed, A must also be closed or not have extra properties\n const aHasExtraProps = Object.keys(aProps).some((key) => !(key in bProps));\n if (aHasExtraProps) {\n return false;\n }\n // If A is open and B is closed, A could produce extra properties\n if (a.additionalProperties !== false) {\n return false;\n }\n } else if (\n b.additionalProperties &&\n typeof b.additionalProperties === \"object\"\n ) {\n // B has a schema for additional properties\n const aAdditional = a.additionalProperties;\n if (aAdditional && typeof aAdditional === \"object\") {\n if (!isSubset(aAdditional, b.additionalProperties)) {\n return false;\n }\n }\n }\n\n return true;\n}\n\n/**\n * Array subset check\n */\nfunction isArraySubset(a: JSONSchema, b: JSONSchema): boolean {\n // Items schema\n if (a.items && b.items) {\n if (Array.isArray(a.items) && Array.isArray(b.items)) {\n // Both are tuples\n if (a.items.length !== b.items.length) {\n return false;\n }\n for (let i = 0; i < a.items.length; i++) {\n if (!isSubset(a.items[i], b.items[i])) {\n return false;\n }\n }\n } else if (Array.isArray(a.items) && !Array.isArray(b.items)) {\n // A is tuple, B is list\n for (const itemSchema of a.items) {\n if (!isSubset(itemSchema, b.items)) {\n return false;\n }\n }\n } else if (!Array.isArray(a.items) && Array.isArray(b.items)) {\n // A is list, B is tuple - A is more permissive\n return false;\n } else {\n // Both are lists\n if (!isSubset(a.items, b.items)) {\n return false;\n }\n }\n } else if (b.items && !a.items) {\n // B has items constraint but A doesn't\n return false;\n }\n\n // Length constraints\n const aMinItems = a.minItems ?? 0;\n const bMinItems = b.minItems ?? 0;\n if (aMinItems < bMinItems) {\n return false;\n }\n\n const aMaxItems = a.maxItems ?? Infinity;\n const bMaxItems = b.maxItems ?? Infinity;\n if (aMaxItems > bMaxItems) {\n return false;\n }\n\n // Uniqueness\n if (b.uniqueItems && !a.uniqueItems) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Number subset check\n */\nfunction isNumberSubset(a: JSONSchema, b: JSONSchema): boolean {\n // Minimum\n const aMin = getEffectiveMin(a);\n const bMin = getEffectiveMin(b);\n if (aMin < bMin) {\n return false;\n }\n\n // Maximum\n const aMax = getEffectiveMax(a);\n const bMax = getEffectiveMax(b);\n if (aMax > bMax) {\n return false;\n }\n\n // MultipleOf\n if (b.multipleOf !== undefined) {\n if (a.multipleOf === undefined) {\n // A doesn't have multipleOf constraint, so it's more permissive\n return false;\n }\n if (!isMultipleOf(a.multipleOf, b.multipleOf)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * String subset check\n */\nfunction isStringSubset(a: JSONSchema, b: JSONSchema): boolean {\n // Length constraints\n const aMinLength = a.minLength ?? 0;\n const bMinLength = b.minLength ?? 0;\n if (aMinLength < bMinLength) {\n return false;\n }\n\n const aMaxLength = a.maxLength ?? Infinity;\n const bMaxLength = b.maxLength ?? Infinity;\n if (aMaxLength > bMaxLength) {\n return false;\n }\n\n // Pattern (regex)\n if (b.pattern) {\n if (!a.pattern) {\n // A has no pattern constraint, more permissive\n return false;\n }\n // Exact match only (full regex subset check is computationally expensive)\n if (a.pattern !== b.pattern) {\n return false;\n }\n }\n\n // Format (treat as informational, exact match required)\n if (b.format && a.format !== b.format) {\n return false;\n }\n\n return true;\n}\n"],"mappings":"AAgBA,SAAS,UAAU,GAAY,GAAqB;AAClD,MAAI,MAAM,EAAG,QAAO;AACpB,MAAI,OAAO,MAAM,OAAO,EAAG,QAAO;AAClC,MAAI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