@geekmidas/schema 10.0.0-alpha.2 → 10.0.0-alpha.21
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/dist/conversion.cjs +106 -8
- package/dist/conversion.cjs.map +1 -0
- package/dist/conversion.d.cts +37 -2
- package/dist/conversion.d.cts.map +1 -0
- package/dist/conversion.d.mts +37 -2
- package/dist/conversion.d.mts.map +1 -0
- package/dist/conversion.mjs +99 -2
- package/dist/conversion.mjs.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -4
- package/dist/openapi.cjs +56 -3
- package/dist/openapi.cjs.map +1 -0
- package/dist/openapi.d.cts +27 -2
- package/dist/openapi.d.cts.map +1 -0
- package/dist/openapi.d.mts +27 -2
- package/dist/openapi.d.mts.map +1 -0
- package/dist/openapi.mjs +54 -2
- package/dist/openapi.mjs.map +1 -0
- package/dist/parser.cjs +3 -3
- package/dist/parser.cjs.map +1 -1
- package/dist/parser.d.cts +3 -8
- package/dist/parser.d.cts.map +1 -1
- package/dist/parser.d.mts +3 -8
- package/dist/parser.d.mts.map +1 -1
- package/dist/parser.mjs +2 -2
- package/dist/parser.mjs.map +1 -1
- package/dist/types.d.cts +22 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +22 -2
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +1 -0
- package/package.json +10 -7
- package/dist/conversion-CIBtqJkS.mjs +0 -106
- package/dist/conversion-CIBtqJkS.mjs.map +0 -1
- package/dist/conversion-Cf9R-jGc.cjs +0 -148
- package/dist/conversion-Cf9R-jGc.cjs.map +0 -1
- package/dist/conversion-JY1Wixil.d.cts +0 -39
- package/dist/conversion-JY1Wixil.d.cts.map +0 -1
- package/dist/conversion-e4k9rTxy.d.mts +0 -39
- package/dist/conversion-e4k9rTxy.d.mts.map +0 -1
- package/dist/openapi-Aeb_1e9T.d.cts +0 -28
- package/dist/openapi-Aeb_1e9T.d.cts.map +0 -1
- package/dist/openapi-DH5yCqKh.mjs +0 -46
- package/dist/openapi-DH5yCqKh.mjs.map +0 -1
- package/dist/openapi-DVvLYx-8.cjs +0 -58
- package/dist/openapi-DVvLYx-8.cjs.map +0 -1
- package/dist/openapi-Dxc4FuMP.d.mts +0 -28
- package/dist/openapi-Dxc4FuMP.d.mts.map +0 -1
- package/dist/types-Bm3VhqVE.d.cts +0 -26
- package/dist/types-Bm3VhqVE.d.cts.map +0 -1
- package/dist/types-xm7EGhin.d.mts +0 -26
- package/dist/types-xm7EGhin.d.mts.map +0 -1
package/dist/parser.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.cjs","names":[
|
|
1
|
+
{"version":3,"file":"parser.cjs","names":[],"sources":["../src/parser.ts"],"sourcesContent":["import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { InferStandardSchema } from './types';\n\n/**\n * Validates data against a StandardSchema.\n *\n * @param schema - The StandardSchema to validate against\n * @param data - The data to validate\n * @returns Validation result with value or issues\n */\nexport function validate<T extends StandardSchemaV1>(schema: T, data: unknown) {\n\treturn schema['~standard'].validate(data);\n}\n\nexport async function parseSchema<T extends StandardSchemaV1>(\n\tschema: T,\n\tdata: unknown,\n): Promise<InferStandardSchema<T>> {\n\tif (!schema) {\n\t\treturn undefined as InferStandardSchema<T>;\n\t}\n\n\tconst parsed = await validate(schema as unknown as StandardSchemaV1, data);\n\n\tif (parsed.issues) {\n\t\tthrow parsed.issues;\n\t}\n\n\treturn parsed.value as InferStandardSchema<T>;\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,SAAqC,QAAW,MAAe;CAC9E,OAAO,OAAO,YAAY,CAAC,SAAS,IAAI;AACzC;AAEA,eAAsB,YACrB,QACA,MACkC;CAClC,IAAI,CAAC,QACJ;CAGD,MAAM,SAAS,MAAM,SAAS,QAAuC,IAAI;CAEzE,IAAI,OAAO,QACV,MAAM,OAAO;CAGd,OAAO,OAAO;AACf"}
|
package/dist/parser.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { InferStandardSchema } from "./types
|
|
1
|
+
import { InferStandardSchema } from "./types.cjs";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
|
|
4
3
|
//#region src/parser.d.ts
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* Validates data against a StandardSchema.
|
|
8
6
|
*
|
|
@@ -10,10 +8,7 @@ import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
|
10
8
|
* @param data - The data to validate
|
|
11
9
|
* @returns Validation result with value or issues
|
|
12
10
|
*/
|
|
13
|
-
declare function validate<T extends StandardSchemaV1>(schema: T, data: unknown): StandardSchemaV1.Result<unknown
|
|
14
|
-
declare function parseSchema<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<InferStandardSchema<T>>;
|
|
15
|
-
//# sourceMappingURL=parser.d.ts.map
|
|
16
|
-
|
|
11
|
+
export declare function validate<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<StandardSchemaV1.Result<unknown>> | StandardSchemaV1.Result<unknown>;
|
|
12
|
+
export declare function parseSchema<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<InferStandardSchema<T>>;
|
|
17
13
|
//#endregion
|
|
18
|
-
export { parseSchema, validate };
|
|
19
14
|
//# sourceMappingURL=parser.d.cts.map
|
package/dist/parser.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.cts","names":[],"sources":["../src/parser.ts"],"
|
|
1
|
+
{"version":3,"file":"parser.d.cts","names":[],"sources":["../src/parser.ts"],"mappings":";;;;;;;;;;wBAUgB,SAAS,UAAU,kBAAkB,QAAQ,GAAG,gBAAa,QAAA,iBAAA,mBAAA,iBAAA;wBAIvD,YAAY,UAAU,kBAC3C,QAAQ,GACR,gBACE,QAAQ,oBAAoB"}
|
package/dist/parser.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { InferStandardSchema } from "./types
|
|
1
|
+
import { InferStandardSchema } from "./types.mjs";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
|
|
4
3
|
//#region src/parser.d.ts
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* Validates data against a StandardSchema.
|
|
8
6
|
*
|
|
@@ -10,10 +8,7 @@ import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
|
10
8
|
* @param data - The data to validate
|
|
11
9
|
* @returns Validation result with value or issues
|
|
12
10
|
*/
|
|
13
|
-
declare function validate<T extends StandardSchemaV1>(schema: T, data: unknown): StandardSchemaV1.Result<unknown
|
|
14
|
-
declare function parseSchema<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<InferStandardSchema<T>>;
|
|
15
|
-
//# sourceMappingURL=parser.d.ts.map
|
|
16
|
-
|
|
11
|
+
export declare function validate<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<StandardSchemaV1.Result<unknown>> | StandardSchemaV1.Result<unknown>;
|
|
12
|
+
export declare function parseSchema<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<InferStandardSchema<T>>;
|
|
17
13
|
//#endregion
|
|
18
|
-
export { parseSchema, validate };
|
|
19
14
|
//# sourceMappingURL=parser.d.mts.map
|
package/dist/parser.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.mts","names":[],"sources":["../src/parser.ts"],"
|
|
1
|
+
{"version":3,"file":"parser.d.mts","names":[],"sources":["../src/parser.ts"],"mappings":";;;;;;;;;;wBAUgB,SAAS,UAAU,kBAAkB,QAAQ,GAAG,gBAAa,QAAA,iBAAA,mBAAA,iBAAA;wBAIvD,YAAY,UAAU,kBAC3C,QAAQ,GACR,gBACE,QAAQ,oBAAoB"}
|
package/dist/parser.mjs
CHANGED
|
@@ -10,12 +10,12 @@ function validate(schema, data) {
|
|
|
10
10
|
return schema["~standard"].validate(data);
|
|
11
11
|
}
|
|
12
12
|
async function parseSchema(schema, data) {
|
|
13
|
-
if (!schema) return
|
|
13
|
+
if (!schema) return;
|
|
14
14
|
const parsed = await validate(schema, data);
|
|
15
15
|
if (parsed.issues) throw parsed.issues;
|
|
16
16
|
return parsed.value;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
18
|
//#endregion
|
|
20
19
|
export { parseSchema, validate };
|
|
20
|
+
|
|
21
21
|
//# sourceMappingURL=parser.mjs.map
|
package/dist/parser.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.mjs","names":[
|
|
1
|
+
{"version":3,"file":"parser.mjs","names":[],"sources":["../src/parser.ts"],"sourcesContent":["import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { InferStandardSchema } from './types';\n\n/**\n * Validates data against a StandardSchema.\n *\n * @param schema - The StandardSchema to validate against\n * @param data - The data to validate\n * @returns Validation result with value or issues\n */\nexport function validate<T extends StandardSchemaV1>(schema: T, data: unknown) {\n\treturn schema['~standard'].validate(data);\n}\n\nexport async function parseSchema<T extends StandardSchemaV1>(\n\tschema: T,\n\tdata: unknown,\n): Promise<InferStandardSchema<T>> {\n\tif (!schema) {\n\t\treturn undefined as InferStandardSchema<T>;\n\t}\n\n\tconst parsed = await validate(schema as unknown as StandardSchemaV1, data);\n\n\tif (parsed.issues) {\n\t\tthrow parsed.issues;\n\t}\n\n\treturn parsed.value as InferStandardSchema<T>;\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,SAAqC,QAAW,MAAe;CAC9E,OAAO,OAAO,YAAY,CAAC,SAAS,IAAI;AACzC;AAEA,eAAsB,YACrB,QACA,MACkC;CAClC,IAAI,CAAC,QACJ;CAGD,MAAM,SAAS,MAAM,SAAS,QAAuC,IAAI;CAEzE,IAAI,OAAO,QACV,MAAM,OAAO;CAGd,OAAO,OAAO;AACf"}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
export type InferStandardSchema<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T> : never;
|
|
4
|
+
/**
|
|
5
|
+
* The *input* type a Standard Schema accepts (before any transform/coercion),
|
|
6
|
+
* as opposed to {@link InferStandardSchema} which is the output type.
|
|
7
|
+
*
|
|
8
|
+
* Use this for the value a producer must HAND TO the schema (e.g. an endpoint
|
|
9
|
+
* handler's return that will be parsed by its output schema): the schema may
|
|
10
|
+
* coerce it (a `Date` → an ISO `string`, a default applied, etc.), so the
|
|
11
|
+
* producer should be allowed to supply the looser input type while consumers
|
|
12
|
+
* still see the narrower output type.
|
|
13
|
+
*/
|
|
14
|
+
export type InferStandardSchemaInput<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferInput<T> : never;
|
|
15
|
+
export type ComposableStandardSchema = StandardSchemaV1 | {
|
|
16
|
+
[key: string]: StandardSchemaV1 | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type InferComposableStandardSchema<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T> : T extends {
|
|
19
|
+
[key: string]: StandardSchemaV1 | undefined;
|
|
20
|
+
} ? { [K in keyof T as T[K] extends StandardSchemaV1 ? K : never]: T[K] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T[K]> : never; } : {};
|
|
21
|
+
//#endregion
|
|
22
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;YAEY,oBAAoB,KAAK,UAAU,mBAC5C,iBAAiB,YAAY;;;;;;;;;;;YAapB,yBAAyB,KAAK,UAAU,mBACjD,iBAAiB,WAAW;YAGnB,2BACT;GAEC,cAAc;;YAGN,8BAA8B,KAAK,UAAU,mBACtD,iBAAiB,YAAY,KAC7B;GAAa,cAAc;OAEzB,WAAW,KAAK,EAAE,WAAW,mBAC3B,YACQ,EAAE,WAAW,mBACrB,iBAAiB,YAAY,EAAE"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
export type InferStandardSchema<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T> : never;
|
|
4
|
+
/**
|
|
5
|
+
* The *input* type a Standard Schema accepts (before any transform/coercion),
|
|
6
|
+
* as opposed to {@link InferStandardSchema} which is the output type.
|
|
7
|
+
*
|
|
8
|
+
* Use this for the value a producer must HAND TO the schema (e.g. an endpoint
|
|
9
|
+
* handler's return that will be parsed by its output schema): the schema may
|
|
10
|
+
* coerce it (a `Date` → an ISO `string`, a default applied, etc.), so the
|
|
11
|
+
* producer should be allowed to supply the looser input type while consumers
|
|
12
|
+
* still see the narrower output type.
|
|
13
|
+
*/
|
|
14
|
+
export type InferStandardSchemaInput<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferInput<T> : never;
|
|
15
|
+
export type ComposableStandardSchema = StandardSchemaV1 | {
|
|
16
|
+
[key: string]: StandardSchemaV1 | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type InferComposableStandardSchema<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T> : T extends {
|
|
19
|
+
[key: string]: StandardSchemaV1 | undefined;
|
|
20
|
+
} ? { [K in keyof T as T[K] extends StandardSchemaV1 ? K : never]: T[K] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T[K]> : never; } : {};
|
|
21
|
+
//#endregion
|
|
22
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;YAEY,oBAAoB,KAAK,UAAU,mBAC5C,iBAAiB,YAAY;;;;;;;;;;;YAapB,yBAAyB,KAAK,UAAU,mBACjD,iBAAiB,WAAW;YAGnB,2BACT;GAEC,cAAc;;YAGN,8BAA8B,KAAK,UAAU,mBACtD,iBAAiB,YAAY,KAC7B;GAAa,cAAc;OAEzB,WAAW,KAAK,EAAE,WAAW,mBAC3B,YACQ,EAAE,WAAW,mBACrB,iBAAiB,YAAY,EAAE"}
|
package/dist/types.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/schema",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
3
|
+
"version": "10.0.0-alpha.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -56,14 +56,17 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"
|
|
60
|
-
"
|
|
59
|
+
"@standard-schema/spec": "~1.1.0",
|
|
60
|
+
"openapi-types": "~12.1.3"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@valibot/to-json-schema": "~1.8.0",
|
|
64
|
+
"valibot": "~1.5.0"
|
|
61
65
|
},
|
|
62
|
-
"devDependencies": {},
|
|
63
66
|
"peerDependencies": {
|
|
64
|
-
"@valibot/to-json-schema": ">=1.
|
|
65
|
-
"zod
|
|
66
|
-
"zod": "
|
|
67
|
+
"@valibot/to-json-schema": ">=1.8.0",
|
|
68
|
+
"zod": ">=4.6.5",
|
|
69
|
+
"zod-to-json-schema": ">=3.25.2"
|
|
67
70
|
},
|
|
68
71
|
"scripts": {
|
|
69
72
|
"ts": "tsc --noEmit --skipLibCheck src/**/*.ts"
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
//#region src/conversion.ts
|
|
2
|
-
let SchemaVendor = /* @__PURE__ */ function(SchemaVendor$1) {
|
|
3
|
-
SchemaVendor$1["zod"] = "zod";
|
|
4
|
-
SchemaVendor$1["valibot"] = "valibot";
|
|
5
|
-
return SchemaVendor$1;
|
|
6
|
-
}({});
|
|
7
|
-
function isSchemaVendor(vendor) {
|
|
8
|
-
if (!vendor) return false;
|
|
9
|
-
return Object.values(SchemaVendor).includes(vendor);
|
|
10
|
-
}
|
|
11
|
-
const StandardSchemaJsonSchema = {
|
|
12
|
-
zod: async (schema) => {
|
|
13
|
-
try {
|
|
14
|
-
const { z } = await import("zod/v4").catch(() => ({ z: {} }));
|
|
15
|
-
if ("toJSONSchema" in z && typeof z.toJSONSchema === "function") return z.toJSONSchema(schema);
|
|
16
|
-
const { zodToJsonSchema } = await import("zod-to-json-schema");
|
|
17
|
-
const result = zodToJsonSchema(schema, { removeAdditionalStrategy: "strict" });
|
|
18
|
-
return result;
|
|
19
|
-
} catch {
|
|
20
|
-
return { type: "object" };
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
valibot: async (schema) => {
|
|
24
|
-
const { toJsonSchema } = await import("@valibot/to-json-schema");
|
|
25
|
-
return toJsonSchema(schema);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
function extractAndConvertDefs(jsonSchema, componentCollector) {
|
|
29
|
-
if (!jsonSchema || typeof jsonSchema !== "object") return jsonSchema;
|
|
30
|
-
const processSchema = (schema) => {
|
|
31
|
-
if (!schema || typeof schema !== "object") return schema;
|
|
32
|
-
if (schema.$ref && typeof schema.$ref === "string") {
|
|
33
|
-
if (schema.$ref.startsWith("#/$defs/")) {
|
|
34
|
-
const refName = schema.$ref.replace("#/$defs/", "");
|
|
35
|
-
return componentCollector ? componentCollector.getReference(refName) : schema;
|
|
36
|
-
}
|
|
37
|
-
return schema;
|
|
38
|
-
}
|
|
39
|
-
if (Array.isArray(schema)) return schema.map(processSchema);
|
|
40
|
-
const processed = {};
|
|
41
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
42
|
-
if (key === "$defs") continue;
|
|
43
|
-
processed[key] = processSchema(value);
|
|
44
|
-
}
|
|
45
|
-
return processed;
|
|
46
|
-
};
|
|
47
|
-
if (jsonSchema.$defs && componentCollector) for (const [defName, defSchema] of Object.entries(jsonSchema.$defs)) {
|
|
48
|
-
const processedDefSchema = processSchema(defSchema);
|
|
49
|
-
componentCollector.addSchema(defName, processedDefSchema);
|
|
50
|
-
}
|
|
51
|
-
const { $defs,...schemaWithoutDefs } = jsonSchema;
|
|
52
|
-
return processSchema(schemaWithoutDefs);
|
|
53
|
-
}
|
|
54
|
-
async function convertStandardSchemaToJsonSchema(schema, componentCollector) {
|
|
55
|
-
if (!schema) return void 0;
|
|
56
|
-
const vendor = schema["~standard"]?.vendor;
|
|
57
|
-
if (!isSchemaVendor(vendor)) throw new Error(`Unsupported or missing vendor "${vendor}" for Standard Schema. Supported vendors are: ${Object.keys(StandardSchemaJsonSchema).join(", ")}`);
|
|
58
|
-
const toJSONSchema = StandardSchemaJsonSchema[vendor];
|
|
59
|
-
const jsonSchema = await toJSONSchema(schema);
|
|
60
|
-
return extractAndConvertDefs(jsonSchema, componentCollector);
|
|
61
|
-
}
|
|
62
|
-
async function getZodMetadata(schema) {
|
|
63
|
-
const { ZodObject } = await import("zod/v4");
|
|
64
|
-
if (schema instanceof ZodObject) return schema.meta();
|
|
65
|
-
return void 0;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Return JSON Schema for every schema registered in zod v4's global registry
|
|
69
|
-
* via `.meta({ id })`. Returns an empty object when zod v4 is unavailable or
|
|
70
|
-
* no schemas are registered.
|
|
71
|
-
*
|
|
72
|
-
* `unrepresentable: 'any'` keeps a single unrepresentable schema from
|
|
73
|
-
* collapsing the whole result.
|
|
74
|
-
*/
|
|
75
|
-
async function getRegisteredZodJsonSchemas() {
|
|
76
|
-
try {
|
|
77
|
-
const { z } = await import("zod/v4").catch(() => ({ z: null }));
|
|
78
|
-
if (!z?.toJSONSchema || !z.globalRegistry) return {};
|
|
79
|
-
const result = z.toJSONSchema(z.globalRegistry, { unrepresentable: "any" });
|
|
80
|
-
return result?.schemas ?? {};
|
|
81
|
-
} catch {
|
|
82
|
-
return {};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
async function getSchemaMetadata(schema) {
|
|
86
|
-
const vendor = schema["~standard"]?.vendor;
|
|
87
|
-
if (vendor === "zod") return getZodMetadata(schema);
|
|
88
|
-
return void 0;
|
|
89
|
-
}
|
|
90
|
-
async function convertSchemaWithComponents(schema, componentCollector) {
|
|
91
|
-
if (!schema) return void 0;
|
|
92
|
-
const jsonSchema = await convertStandardSchemaToJsonSchema(schema, componentCollector);
|
|
93
|
-
if (!componentCollector) return jsonSchema;
|
|
94
|
-
const metadata = await getSchemaMetadata(schema);
|
|
95
|
-
const schemaId = metadata?.id || jsonSchema?.id;
|
|
96
|
-
if (schemaId) {
|
|
97
|
-
const { id,...schemaWithoutId } = jsonSchema;
|
|
98
|
-
componentCollector.addSchema(schemaId, schemaWithoutId);
|
|
99
|
-
return componentCollector.getReference(schemaId);
|
|
100
|
-
}
|
|
101
|
-
return jsonSchema;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//#endregion
|
|
105
|
-
export { SchemaVendor, StandardSchemaJsonSchema, convertSchemaWithComponents, convertStandardSchemaToJsonSchema, getRegisteredZodJsonSchemas, getSchemaMetadata, getZodMetadata };
|
|
106
|
-
//# sourceMappingURL=conversion-CIBtqJkS.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-CIBtqJkS.mjs","names":["vendor?: string","StandardSchemaJsonSchema: VendorConvertors","jsonSchema: any","componentCollector?: {\n\t\taddSchema(id: string, schema: any): void;\n\t\tgetReference(id: string): { $ref: string };\n\t}","schema: any","processed: any","schema?: StandardSchemaV1","schema: StandardSchemaV1","schema: StandardSchemaV1 | undefined"],"sources":["../src/conversion.ts"],"sourcesContent":["import type { StandardSchemaV1 } from '@standard-schema/spec';\n\nexport enum SchemaVendor {\n\tzod = 'zod',\n\tvalibot = 'valibot',\n}\n\nexport type VendorConvertor = (schema: any) => Promise<any>;\nexport type VendorConvertors = Record<SchemaVendor, VendorConvertor>;\n\nfunction isSchemaVendor(vendor?: string): vendor is SchemaVendor {\n\tif (!vendor) {\n\t\treturn false;\n\t}\n\n\treturn Object.values(SchemaVendor).includes(vendor as SchemaVendor);\n}\n\nexport const StandardSchemaJsonSchema: VendorConvertors = {\n\tzod: async (schema): Promise<any> => {\n\t\ttry {\n\t\t\tconst { z } = await import('zod/v4').catch(() => ({ z: {} }));\n\n\t\t\tif ('toJSONSchema' in z && typeof z.toJSONSchema === 'function') {\n\t\t\t\treturn z.toJSONSchema(schema);\n\t\t\t}\n\t\t\tconst { zodToJsonSchema } = await import('zod-to-json-schema');\n\n\t\t\tconst result = zodToJsonSchema(schema, {\n\t\t\t\tremoveAdditionalStrategy: 'strict',\n\t\t\t});\n\n\t\t\treturn result;\n\t\t} catch {\n\t\t\t// Fallback to basic conversion if zod-to-json-schema is not available\n\t\t\treturn { type: 'object' };\n\t\t}\n\t},\n\tvalibot: async (schema): Promise<any> => {\n\t\tconst { toJsonSchema } = await import('@valibot/to-json-schema');\n\t\treturn toJsonSchema(schema as any);\n\t},\n};\n\nfunction extractAndConvertDefs(\n\tjsonSchema: any,\n\tcomponentCollector?: {\n\t\taddSchema(id: string, schema: any): void;\n\t\tgetReference(id: string): { $ref: string };\n\t},\n): any {\n\tif (!jsonSchema || typeof jsonSchema !== 'object') {\n\t\treturn jsonSchema;\n\t}\n\n\t// Process the schema recursively to update references\n\tconst processSchema = (schema: any): any => {\n\t\tif (!schema || typeof schema !== 'object') {\n\t\t\treturn schema;\n\t\t}\n\n\t\t// Handle $ref\n\t\tif (schema.$ref && typeof schema.$ref === 'string') {\n\t\t\t// Convert #/$defs/X to #/components/schemas/X\n\t\t\tif (schema.$ref.startsWith('#/$defs/')) {\n\t\t\t\tconst refName = schema.$ref.replace('#/$defs/', '');\n\t\t\t\treturn componentCollector\n\t\t\t\t\t? componentCollector.getReference(refName)\n\t\t\t\t\t: schema;\n\t\t\t}\n\t\t\treturn schema;\n\t\t}\n\n\t\t// Handle arrays\n\t\tif (Array.isArray(schema)) {\n\t\t\treturn schema.map(processSchema);\n\t\t}\n\n\t\t// Process all properties recursively\n\t\tconst processed: any = {};\n\t\tfor (const [key, value] of Object.entries(schema)) {\n\t\t\tif (key === '$defs') {\n\t\t\t\t// Skip $defs as they've been extracted\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tprocessed[key] = processSchema(value);\n\t\t}\n\t\treturn processed;\n\t};\n\n\t// Extract $defs if present\n\tif (jsonSchema.$defs && componentCollector) {\n\t\tfor (const [defName, defSchema] of Object.entries(jsonSchema.$defs)) {\n\t\t\t// Process the definition recursively to handle nested $refs\n\t\t\tconst processedDefSchema = processSchema(defSchema);\n\t\t\t// Add each definition to the component collector\n\t\t\tcomponentCollector.addSchema(defName, processedDefSchema);\n\t\t}\n\t}\n\n\t// Process the schema and remove $defs\n\tconst { $defs, ...schemaWithoutDefs } = jsonSchema;\n\treturn processSchema(schemaWithoutDefs);\n}\n\nexport async function convertStandardSchemaToJsonSchema(\n\tschema?: StandardSchemaV1,\n\tcomponentCollector?: {\n\t\taddSchema(id: string, schema: any): void;\n\t\tgetReference(id: string): { $ref: string };\n\t},\n): Promise<any> {\n\tif (!schema) {\n\t\treturn undefined;\n\t}\n\n\tconst vendor = schema['~standard']?.vendor;\n\tif (!isSchemaVendor(vendor)) {\n\t\tthrow new Error(\n\t\t\t`Unsupported or missing vendor \"${vendor}\" for Standard Schema. Supported vendors are: ${Object.keys(StandardSchemaJsonSchema).join(', ')}`,\n\t\t);\n\t}\n\n\tconst toJSONSchema = StandardSchemaJsonSchema[vendor];\n\tconst jsonSchema = await toJSONSchema(schema);\n\n\t// Extract and convert $defs to components\n\treturn extractAndConvertDefs(jsonSchema, componentCollector);\n}\n\nexport async function getZodMetadata(\n\tschema: StandardSchemaV1,\n): Promise<SchemaMeta | undefined> {\n\tconst { ZodObject } = await import('zod/v4');\n\n\tif (schema instanceof ZodObject) {\n\t\treturn schema.meta();\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Return JSON Schema for every schema registered in zod v4's global registry\n * via `.meta({ id })`. Returns an empty object when zod v4 is unavailable or\n * no schemas are registered.\n *\n * `unrepresentable: 'any'` keeps a single unrepresentable schema from\n * collapsing the whole result.\n */\nexport async function getRegisteredZodJsonSchemas(): Promise<\n\tRecord<string, any>\n> {\n\ttry {\n\t\tconst { z } = await import('zod/v4').catch(() => ({ z: null as any }));\n\t\tif (!z?.toJSONSchema || !z.globalRegistry) {\n\t\t\treturn {};\n\t\t}\n\t\tconst result = z.toJSONSchema(z.globalRegistry, {\n\t\t\tunrepresentable: 'any',\n\t\t});\n\t\treturn (result?.schemas ?? {}) as Record<string, any>;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport async function getSchemaMetadata(\n\tschema: StandardSchemaV1,\n): Promise<SchemaMeta | undefined> {\n\tconst vendor = schema['~standard']?.vendor;\n\n\tif (vendor === 'zod') {\n\t\treturn getZodMetadata(schema);\n\t}\n\n\treturn undefined;\n}\n\ninterface SchemaMeta {\n\tid?: string;\n}\n\nexport async function convertSchemaWithComponents(\n\tschema: StandardSchemaV1 | undefined,\n\tcomponentCollector?: {\n\t\taddSchema(id: string, schema: any): void;\n\t\tgetReference(id: string): { $ref: string };\n\t},\n): Promise<any> {\n\tif (!schema) {\n\t\treturn undefined;\n\t}\n\n\t// Convert to JSON Schema with component collector to handle $defs\n\tconst jsonSchema = await convertStandardSchemaToJsonSchema(\n\t\tschema,\n\t\tcomponentCollector,\n\t);\n\n\tif (!componentCollector) {\n\t\treturn jsonSchema;\n\t}\n\n\t// Check if this schema has metadata with an ID\n\tconst metadata = await getSchemaMetadata(schema);\n\n\t// Also check if the JSON Schema itself has an id field (from Zod's meta)\n\tconst schemaId = metadata?.id || jsonSchema?.id;\n\n\tif (schemaId) {\n\t\t// Remove the id from the schema before adding to components\n\t\tconst { id, ...schemaWithoutId } = jsonSchema;\n\t\t// Add this schema to components and return a reference\n\t\tcomponentCollector.addSchema(schemaId, schemaWithoutId);\n\t\treturn componentCollector.getReference(schemaId);\n\t}\n\n\treturn jsonSchema;\n}\n"],"mappings":"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"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/conversion.ts
|
|
3
|
-
let SchemaVendor = /* @__PURE__ */ function(SchemaVendor$1) {
|
|
4
|
-
SchemaVendor$1["zod"] = "zod";
|
|
5
|
-
SchemaVendor$1["valibot"] = "valibot";
|
|
6
|
-
return SchemaVendor$1;
|
|
7
|
-
}({});
|
|
8
|
-
function isSchemaVendor(vendor) {
|
|
9
|
-
if (!vendor) return false;
|
|
10
|
-
return Object.values(SchemaVendor).includes(vendor);
|
|
11
|
-
}
|
|
12
|
-
const StandardSchemaJsonSchema = {
|
|
13
|
-
zod: async (schema) => {
|
|
14
|
-
try {
|
|
15
|
-
const { z } = await import("zod/v4").catch(() => ({ z: {} }));
|
|
16
|
-
if ("toJSONSchema" in z && typeof z.toJSONSchema === "function") return z.toJSONSchema(schema);
|
|
17
|
-
const { zodToJsonSchema } = await import("zod-to-json-schema");
|
|
18
|
-
const result = zodToJsonSchema(schema, { removeAdditionalStrategy: "strict" });
|
|
19
|
-
return result;
|
|
20
|
-
} catch {
|
|
21
|
-
return { type: "object" };
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
valibot: async (schema) => {
|
|
25
|
-
const { toJsonSchema } = await import("@valibot/to-json-schema");
|
|
26
|
-
return toJsonSchema(schema);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
function extractAndConvertDefs(jsonSchema, componentCollector) {
|
|
30
|
-
if (!jsonSchema || typeof jsonSchema !== "object") return jsonSchema;
|
|
31
|
-
const processSchema = (schema) => {
|
|
32
|
-
if (!schema || typeof schema !== "object") return schema;
|
|
33
|
-
if (schema.$ref && typeof schema.$ref === "string") {
|
|
34
|
-
if (schema.$ref.startsWith("#/$defs/")) {
|
|
35
|
-
const refName = schema.$ref.replace("#/$defs/", "");
|
|
36
|
-
return componentCollector ? componentCollector.getReference(refName) : schema;
|
|
37
|
-
}
|
|
38
|
-
return schema;
|
|
39
|
-
}
|
|
40
|
-
if (Array.isArray(schema)) return schema.map(processSchema);
|
|
41
|
-
const processed = {};
|
|
42
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
43
|
-
if (key === "$defs") continue;
|
|
44
|
-
processed[key] = processSchema(value);
|
|
45
|
-
}
|
|
46
|
-
return processed;
|
|
47
|
-
};
|
|
48
|
-
if (jsonSchema.$defs && componentCollector) for (const [defName, defSchema] of Object.entries(jsonSchema.$defs)) {
|
|
49
|
-
const processedDefSchema = processSchema(defSchema);
|
|
50
|
-
componentCollector.addSchema(defName, processedDefSchema);
|
|
51
|
-
}
|
|
52
|
-
const { $defs,...schemaWithoutDefs } = jsonSchema;
|
|
53
|
-
return processSchema(schemaWithoutDefs);
|
|
54
|
-
}
|
|
55
|
-
async function convertStandardSchemaToJsonSchema(schema, componentCollector) {
|
|
56
|
-
if (!schema) return void 0;
|
|
57
|
-
const vendor = schema["~standard"]?.vendor;
|
|
58
|
-
if (!isSchemaVendor(vendor)) throw new Error(`Unsupported or missing vendor "${vendor}" for Standard Schema. Supported vendors are: ${Object.keys(StandardSchemaJsonSchema).join(", ")}`);
|
|
59
|
-
const toJSONSchema = StandardSchemaJsonSchema[vendor];
|
|
60
|
-
const jsonSchema = await toJSONSchema(schema);
|
|
61
|
-
return extractAndConvertDefs(jsonSchema, componentCollector);
|
|
62
|
-
}
|
|
63
|
-
async function getZodMetadata(schema) {
|
|
64
|
-
const { ZodObject } = await import("zod/v4");
|
|
65
|
-
if (schema instanceof ZodObject) return schema.meta();
|
|
66
|
-
return void 0;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Return JSON Schema for every schema registered in zod v4's global registry
|
|
70
|
-
* via `.meta({ id })`. Returns an empty object when zod v4 is unavailable or
|
|
71
|
-
* no schemas are registered.
|
|
72
|
-
*
|
|
73
|
-
* `unrepresentable: 'any'` keeps a single unrepresentable schema from
|
|
74
|
-
* collapsing the whole result.
|
|
75
|
-
*/
|
|
76
|
-
async function getRegisteredZodJsonSchemas() {
|
|
77
|
-
try {
|
|
78
|
-
const { z } = await import("zod/v4").catch(() => ({ z: null }));
|
|
79
|
-
if (!z?.toJSONSchema || !z.globalRegistry) return {};
|
|
80
|
-
const result = z.toJSONSchema(z.globalRegistry, { unrepresentable: "any" });
|
|
81
|
-
return result?.schemas ?? {};
|
|
82
|
-
} catch {
|
|
83
|
-
return {};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async function getSchemaMetadata(schema) {
|
|
87
|
-
const vendor = schema["~standard"]?.vendor;
|
|
88
|
-
if (vendor === "zod") return getZodMetadata(schema);
|
|
89
|
-
return void 0;
|
|
90
|
-
}
|
|
91
|
-
async function convertSchemaWithComponents(schema, componentCollector) {
|
|
92
|
-
if (!schema) return void 0;
|
|
93
|
-
const jsonSchema = await convertStandardSchemaToJsonSchema(schema, componentCollector);
|
|
94
|
-
if (!componentCollector) return jsonSchema;
|
|
95
|
-
const metadata = await getSchemaMetadata(schema);
|
|
96
|
-
const schemaId = metadata?.id || jsonSchema?.id;
|
|
97
|
-
if (schemaId) {
|
|
98
|
-
const { id,...schemaWithoutId } = jsonSchema;
|
|
99
|
-
componentCollector.addSchema(schemaId, schemaWithoutId);
|
|
100
|
-
return componentCollector.getReference(schemaId);
|
|
101
|
-
}
|
|
102
|
-
return jsonSchema;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
//#endregion
|
|
106
|
-
Object.defineProperty(exports, 'SchemaVendor', {
|
|
107
|
-
enumerable: true,
|
|
108
|
-
get: function () {
|
|
109
|
-
return SchemaVendor;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
Object.defineProperty(exports, 'StandardSchemaJsonSchema', {
|
|
113
|
-
enumerable: true,
|
|
114
|
-
get: function () {
|
|
115
|
-
return StandardSchemaJsonSchema;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
Object.defineProperty(exports, 'convertSchemaWithComponents', {
|
|
119
|
-
enumerable: true,
|
|
120
|
-
get: function () {
|
|
121
|
-
return convertSchemaWithComponents;
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
Object.defineProperty(exports, 'convertStandardSchemaToJsonSchema', {
|
|
125
|
-
enumerable: true,
|
|
126
|
-
get: function () {
|
|
127
|
-
return convertStandardSchemaToJsonSchema;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
Object.defineProperty(exports, 'getRegisteredZodJsonSchemas', {
|
|
131
|
-
enumerable: true,
|
|
132
|
-
get: function () {
|
|
133
|
-
return getRegisteredZodJsonSchemas;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
Object.defineProperty(exports, 'getSchemaMetadata', {
|
|
137
|
-
enumerable: true,
|
|
138
|
-
get: function () {
|
|
139
|
-
return getSchemaMetadata;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
Object.defineProperty(exports, 'getZodMetadata', {
|
|
143
|
-
enumerable: true,
|
|
144
|
-
get: function () {
|
|
145
|
-
return getZodMetadata;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
//# sourceMappingURL=conversion-Cf9R-jGc.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-Cf9R-jGc.cjs","names":["vendor?: string","StandardSchemaJsonSchema: VendorConvertors","jsonSchema: any","componentCollector?: {\n\t\taddSchema(id: string, schema: any): void;\n\t\tgetReference(id: string): { $ref: string };\n\t}","schema: any","processed: any","schema?: StandardSchemaV1","schema: StandardSchemaV1","schema: StandardSchemaV1 | undefined"],"sources":["../src/conversion.ts"],"sourcesContent":["import type { StandardSchemaV1 } from '@standard-schema/spec';\n\nexport enum SchemaVendor {\n\tzod = 'zod',\n\tvalibot = 'valibot',\n}\n\nexport type VendorConvertor = (schema: any) => Promise<any>;\nexport type VendorConvertors = Record<SchemaVendor, VendorConvertor>;\n\nfunction isSchemaVendor(vendor?: string): vendor is SchemaVendor {\n\tif (!vendor) {\n\t\treturn false;\n\t}\n\n\treturn Object.values(SchemaVendor).includes(vendor as SchemaVendor);\n}\n\nexport const StandardSchemaJsonSchema: VendorConvertors = {\n\tzod: async (schema): Promise<any> => {\n\t\ttry {\n\t\t\tconst { z } = await import('zod/v4').catch(() => ({ z: {} }));\n\n\t\t\tif ('toJSONSchema' in z && typeof z.toJSONSchema === 'function') {\n\t\t\t\treturn z.toJSONSchema(schema);\n\t\t\t}\n\t\t\tconst { zodToJsonSchema } = await import('zod-to-json-schema');\n\n\t\t\tconst result = zodToJsonSchema(schema, {\n\t\t\t\tremoveAdditionalStrategy: 'strict',\n\t\t\t});\n\n\t\t\treturn result;\n\t\t} catch {\n\t\t\t// Fallback to basic conversion if zod-to-json-schema is not available\n\t\t\treturn { type: 'object' };\n\t\t}\n\t},\n\tvalibot: async (schema): Promise<any> => {\n\t\tconst { toJsonSchema } = await import('@valibot/to-json-schema');\n\t\treturn toJsonSchema(schema as any);\n\t},\n};\n\nfunction extractAndConvertDefs(\n\tjsonSchema: any,\n\tcomponentCollector?: {\n\t\taddSchema(id: string, schema: any): void;\n\t\tgetReference(id: string): { $ref: string };\n\t},\n): any {\n\tif (!jsonSchema || typeof jsonSchema !== 'object') {\n\t\treturn jsonSchema;\n\t}\n\n\t// Process the schema recursively to update references\n\tconst processSchema = (schema: any): any => {\n\t\tif (!schema || typeof schema !== 'object') {\n\t\t\treturn schema;\n\t\t}\n\n\t\t// Handle $ref\n\t\tif (schema.$ref && typeof schema.$ref === 'string') {\n\t\t\t// Convert #/$defs/X to #/components/schemas/X\n\t\t\tif (schema.$ref.startsWith('#/$defs/')) {\n\t\t\t\tconst refName = schema.$ref.replace('#/$defs/', '');\n\t\t\t\treturn componentCollector\n\t\t\t\t\t? componentCollector.getReference(refName)\n\t\t\t\t\t: schema;\n\t\t\t}\n\t\t\treturn schema;\n\t\t}\n\n\t\t// Handle arrays\n\t\tif (Array.isArray(schema)) {\n\t\t\treturn schema.map(processSchema);\n\t\t}\n\n\t\t// Process all properties recursively\n\t\tconst processed: any = {};\n\t\tfor (const [key, value] of Object.entries(schema)) {\n\t\t\tif (key === '$defs') {\n\t\t\t\t// Skip $defs as they've been extracted\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tprocessed[key] = processSchema(value);\n\t\t}\n\t\treturn processed;\n\t};\n\n\t// Extract $defs if present\n\tif (jsonSchema.$defs && componentCollector) {\n\t\tfor (const [defName, defSchema] of Object.entries(jsonSchema.$defs)) {\n\t\t\t// Process the definition recursively to handle nested $refs\n\t\t\tconst processedDefSchema = processSchema(defSchema);\n\t\t\t// Add each definition to the component collector\n\t\t\tcomponentCollector.addSchema(defName, processedDefSchema);\n\t\t}\n\t}\n\n\t// Process the schema and remove $defs\n\tconst { $defs, ...schemaWithoutDefs } = jsonSchema;\n\treturn processSchema(schemaWithoutDefs);\n}\n\nexport async function convertStandardSchemaToJsonSchema(\n\tschema?: StandardSchemaV1,\n\tcomponentCollector?: {\n\t\taddSchema(id: string, schema: any): void;\n\t\tgetReference(id: string): { $ref: string };\n\t},\n): Promise<any> {\n\tif (!schema) {\n\t\treturn undefined;\n\t}\n\n\tconst vendor = schema['~standard']?.vendor;\n\tif (!isSchemaVendor(vendor)) {\n\t\tthrow new Error(\n\t\t\t`Unsupported or missing vendor \"${vendor}\" for Standard Schema. Supported vendors are: ${Object.keys(StandardSchemaJsonSchema).join(', ')}`,\n\t\t);\n\t}\n\n\tconst toJSONSchema = StandardSchemaJsonSchema[vendor];\n\tconst jsonSchema = await toJSONSchema(schema);\n\n\t// Extract and convert $defs to components\n\treturn extractAndConvertDefs(jsonSchema, componentCollector);\n}\n\nexport async function getZodMetadata(\n\tschema: StandardSchemaV1,\n): Promise<SchemaMeta | undefined> {\n\tconst { ZodObject } = await import('zod/v4');\n\n\tif (schema instanceof ZodObject) {\n\t\treturn schema.meta();\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Return JSON Schema for every schema registered in zod v4's global registry\n * via `.meta({ id })`. Returns an empty object when zod v4 is unavailable or\n * no schemas are registered.\n *\n * `unrepresentable: 'any'` keeps a single unrepresentable schema from\n * collapsing the whole result.\n */\nexport async function getRegisteredZodJsonSchemas(): Promise<\n\tRecord<string, any>\n> {\n\ttry {\n\t\tconst { z } = await import('zod/v4').catch(() => ({ z: null as any }));\n\t\tif (!z?.toJSONSchema || !z.globalRegistry) {\n\t\t\treturn {};\n\t\t}\n\t\tconst result = z.toJSONSchema(z.globalRegistry, {\n\t\t\tunrepresentable: 'any',\n\t\t});\n\t\treturn (result?.schemas ?? {}) as Record<string, any>;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport async function getSchemaMetadata(\n\tschema: StandardSchemaV1,\n): Promise<SchemaMeta | undefined> {\n\tconst vendor = schema['~standard']?.vendor;\n\n\tif (vendor === 'zod') {\n\t\treturn getZodMetadata(schema);\n\t}\n\n\treturn undefined;\n}\n\ninterface SchemaMeta {\n\tid?: string;\n}\n\nexport async function convertSchemaWithComponents(\n\tschema: StandardSchemaV1 | undefined,\n\tcomponentCollector?: {\n\t\taddSchema(id: string, schema: any): void;\n\t\tgetReference(id: string): { $ref: string };\n\t},\n): Promise<any> {\n\tif (!schema) {\n\t\treturn undefined;\n\t}\n\n\t// Convert to JSON Schema with component collector to handle $defs\n\tconst jsonSchema = await convertStandardSchemaToJsonSchema(\n\t\tschema,\n\t\tcomponentCollector,\n\t);\n\n\tif (!componentCollector) {\n\t\treturn jsonSchema;\n\t}\n\n\t// Check if this schema has metadata with an ID\n\tconst metadata = await getSchemaMetadata(schema);\n\n\t// Also check if the JSON Schema itself has an id field (from Zod's meta)\n\tconst schemaId = metadata?.id || jsonSchema?.id;\n\n\tif (schemaId) {\n\t\t// Remove the id from the schema before adding to components\n\t\tconst { id, ...schemaWithoutId } = jsonSchema;\n\t\t// Add this schema to components and return a reference\n\t\tcomponentCollector.addSchema(schemaId, schemaWithoutId);\n\t\treturn componentCollector.getReference(schemaId);\n\t}\n\n\treturn jsonSchema;\n}\n"],"mappings":"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"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
-
|
|
3
|
-
//#region src/conversion.d.ts
|
|
4
|
-
declare enum SchemaVendor {
|
|
5
|
-
zod = "zod",
|
|
6
|
-
valibot = "valibot",
|
|
7
|
-
}
|
|
8
|
-
type VendorConvertor = (schema: any) => Promise<any>;
|
|
9
|
-
type VendorConvertors = Record<SchemaVendor, VendorConvertor>;
|
|
10
|
-
declare const StandardSchemaJsonSchema: VendorConvertors;
|
|
11
|
-
declare function convertStandardSchemaToJsonSchema(schema?: StandardSchemaV1, componentCollector?: {
|
|
12
|
-
addSchema(id: string, schema: any): void;
|
|
13
|
-
getReference(id: string): {
|
|
14
|
-
$ref: string;
|
|
15
|
-
};
|
|
16
|
-
}): Promise<any>;
|
|
17
|
-
declare function getZodMetadata(schema: StandardSchemaV1): Promise<SchemaMeta | undefined>;
|
|
18
|
-
/**
|
|
19
|
-
* Return JSON Schema for every schema registered in zod v4's global registry
|
|
20
|
-
* via `.meta({ id })`. Returns an empty object when zod v4 is unavailable or
|
|
21
|
-
* no schemas are registered.
|
|
22
|
-
*
|
|
23
|
-
* `unrepresentable: 'any'` keeps a single unrepresentable schema from
|
|
24
|
-
* collapsing the whole result.
|
|
25
|
-
*/
|
|
26
|
-
declare function getRegisteredZodJsonSchemas(): Promise<Record<string, any>>;
|
|
27
|
-
declare function getSchemaMetadata(schema: StandardSchemaV1): Promise<SchemaMeta | undefined>;
|
|
28
|
-
interface SchemaMeta {
|
|
29
|
-
id?: string;
|
|
30
|
-
}
|
|
31
|
-
declare function convertSchemaWithComponents(schema: StandardSchemaV1 | undefined, componentCollector?: {
|
|
32
|
-
addSchema(id: string, schema: any): void;
|
|
33
|
-
getReference(id: string): {
|
|
34
|
-
$ref: string;
|
|
35
|
-
};
|
|
36
|
-
}): Promise<any>;
|
|
37
|
-
//#endregion
|
|
38
|
-
export { SchemaVendor, StandardSchemaJsonSchema, VendorConvertor, VendorConvertors, convertSchemaWithComponents, convertStandardSchemaToJsonSchema, getRegisteredZodJsonSchemas, getSchemaMetadata, getZodMetadata };
|
|
39
|
-
//# sourceMappingURL=conversion-JY1Wixil.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-JY1Wixil.d.cts","names":[],"sources":["../src/conversion.ts"],"sourcesContent":[],"mappings":";;;aAEY,YAAA;;EAAA,OAAA,GAAA,SAAY;AAKxB;AACY,KADA,eAAA,GACgB,CAAA,MAAA,EAAA,GAAA,EAAA,GADmB,OACnB,CAAA,GAAA,CAAA;AAAA,KAAhB,gBAAA,GAAmB,MAAH,CAAU,YAAV,EAAwB,eAAxB,CAAA;AAAU,cAUzB,wBAVyB,EAUC,gBAVD;AAAc,iBAiG9B,iCAAA,CAjG8B,MAAA,CAAA,EAkG1C,gBAlG0C,EAAA,kBAiGG,CAjGH,EAAA;EAAe,SAApC,CAAA,EAAA,EAAA,MAAA,EAAA,MAAA,EAAA,GAAA,CAAA,EAAA,IAAA;EAAM,YAAA,CAAA,EAAA,EAAA,MAAA,CAAA,EAAA;IAUxB,IAAA,EAAA,MAAA;EAuFS,CAAA;CAAiC,CAAA,EAMpD,OANoD,CAAA,GAAA,CAAA;AAC7C,iBAwBY,cAAA,CAxBZ,MAAA,EAyBD,gBAzBC,CAAA,EA0BP,OA1BO,CA0BC,UA1BD,GAAA,SAAA,CAAA;;AAKA;AAmBV;;;;;AAEU;AAkBY,iBAAA,2BAAA,CAAA,CAA2B,EAAI,OAAJ,CAChD,MADgD,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA;AAAA,iBAiB3B,iBAAA,CAjB2B,MAAA,EAkBxC,gBAlBwC,CAAA,EAmB9C,OAnB8C,CAmBtC,UAnBsC,GAAA,SAAA,CAAA;UA6BvC,UAAA,CA5BT;EAAM,EAAA,CAD8C,EAAA,MAAA;AAAO;AAiBtC,iBAgBA,2BAAA,CAhBiB,MAAA,EAiB9B,gBAjB8B,GAAA,SAAA,EAAA,kBAE7B,CAF6B,EAAA;EAAA,SAAA,CAAA,EAAA,EAAA,MAAA,EAAA,MAAA,EAAA,GAAA,CAAA,EAAA,IAAA;EAAA,YAC9B,CAAA,EAAA,EAAA,MAAA,CAAA,EAAA;IACE,IAAA,EAAA,MAAA;EAAU,CAAA;AAAX,CAAA,CAAA,EAoBP,OApBO,CAAA,GAAA,CAAA"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
-
|
|
3
|
-
//#region src/conversion.d.ts
|
|
4
|
-
declare enum SchemaVendor {
|
|
5
|
-
zod = "zod",
|
|
6
|
-
valibot = "valibot",
|
|
7
|
-
}
|
|
8
|
-
type VendorConvertor = (schema: any) => Promise<any>;
|
|
9
|
-
type VendorConvertors = Record<SchemaVendor, VendorConvertor>;
|
|
10
|
-
declare const StandardSchemaJsonSchema: VendorConvertors;
|
|
11
|
-
declare function convertStandardSchemaToJsonSchema(schema?: StandardSchemaV1, componentCollector?: {
|
|
12
|
-
addSchema(id: string, schema: any): void;
|
|
13
|
-
getReference(id: string): {
|
|
14
|
-
$ref: string;
|
|
15
|
-
};
|
|
16
|
-
}): Promise<any>;
|
|
17
|
-
declare function getZodMetadata(schema: StandardSchemaV1): Promise<SchemaMeta | undefined>;
|
|
18
|
-
/**
|
|
19
|
-
* Return JSON Schema for every schema registered in zod v4's global registry
|
|
20
|
-
* via `.meta({ id })`. Returns an empty object when zod v4 is unavailable or
|
|
21
|
-
* no schemas are registered.
|
|
22
|
-
*
|
|
23
|
-
* `unrepresentable: 'any'` keeps a single unrepresentable schema from
|
|
24
|
-
* collapsing the whole result.
|
|
25
|
-
*/
|
|
26
|
-
declare function getRegisteredZodJsonSchemas(): Promise<Record<string, any>>;
|
|
27
|
-
declare function getSchemaMetadata(schema: StandardSchemaV1): Promise<SchemaMeta | undefined>;
|
|
28
|
-
interface SchemaMeta {
|
|
29
|
-
id?: string;
|
|
30
|
-
}
|
|
31
|
-
declare function convertSchemaWithComponents(schema: StandardSchemaV1 | undefined, componentCollector?: {
|
|
32
|
-
addSchema(id: string, schema: any): void;
|
|
33
|
-
getReference(id: string): {
|
|
34
|
-
$ref: string;
|
|
35
|
-
};
|
|
36
|
-
}): Promise<any>;
|
|
37
|
-
//#endregion
|
|
38
|
-
export { SchemaVendor, StandardSchemaJsonSchema, VendorConvertor, VendorConvertors, convertSchemaWithComponents, convertStandardSchemaToJsonSchema, getRegisteredZodJsonSchemas, getSchemaMetadata, getZodMetadata };
|
|
39
|
-
//# sourceMappingURL=conversion-e4k9rTxy.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-e4k9rTxy.d.mts","names":[],"sources":["../src/conversion.ts"],"sourcesContent":[],"mappings":";;;aAEY,YAAA;;EAAA,OAAA,GAAA,SAAY;AAKxB;AACY,KADA,eAAA,GACgB,CAAA,MAAA,EAAA,GAAA,EAAA,GADmB,OACnB,CAAA,GAAA,CAAA;AAAA,KAAhB,gBAAA,GAAmB,MAAH,CAAU,YAAV,EAAwB,eAAxB,CAAA;AAAU,cAUzB,wBAVyB,EAUC,gBAVD;AAAc,iBAiG9B,iCAAA,CAjG8B,MAAA,CAAA,EAkG1C,gBAlG0C,EAAA,kBAiGG,CAjGH,EAAA;EAAe,SAApC,CAAA,EAAA,EAAA,MAAA,EAAA,MAAA,EAAA,GAAA,CAAA,EAAA,IAAA;EAAM,YAAA,CAAA,EAAA,EAAA,MAAA,CAAA,EAAA;IAUxB,IAAA,EAAA,MAAA;EAuFS,CAAA;CAAiC,CAAA,EAMpD,OANoD,CAAA,GAAA,CAAA;AAC7C,iBAwBY,cAAA,CAxBZ,MAAA,EAyBD,gBAzBC,CAAA,EA0BP,OA1BO,CA0BC,UA1BD,GAAA,SAAA,CAAA;;AAKA;AAmBV;;;;;AAEU;AAkBY,iBAAA,2BAAA,CAAA,CAA2B,EAAI,OAAJ,CAChD,MADgD,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA;AAAA,iBAiB3B,iBAAA,CAjB2B,MAAA,EAkBxC,gBAlBwC,CAAA,EAmB9C,OAnB8C,CAmBtC,UAnBsC,GAAA,SAAA,CAAA;UA6BvC,UAAA,CA5BT;EAAM,EAAA,CAD8C,EAAA,MAAA;AAAO;AAiBtC,iBAgBA,2BAAA,CAhBiB,MAAA,EAiB9B,gBAjB8B,GAAA,SAAA,EAAA,kBAE7B,CAF6B,EAAA;EAAA,SAAA,CAAA,EAAA,EAAA,MAAA,EAAA,MAAA,EAAA,GAAA,CAAA,EAAA,IAAA;EAAA,YAC9B,CAAA,EAAA,EAAA,MAAA,CAAA,EAAA;IACE,IAAA,EAAA,MAAA;EAAU,CAAA;AAAX,CAAA,CAAA,EAoBP,OApBO,CAAA,GAAA,CAAA"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { OpenAPIV3_1 } from "openapi-types";
|
|
2
|
-
|
|
3
|
-
//#region src/openapi.d.ts
|
|
4
|
-
interface OpenApiSchemaOptions {
|
|
5
|
-
title?: string;
|
|
6
|
-
version?: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
}
|
|
9
|
-
interface ComponentCollector {
|
|
10
|
-
schemas: Record<string, OpenAPIV3_1.SchemaObject>;
|
|
11
|
-
addSchema(id: string, schema: OpenAPIV3_1.SchemaObject): void;
|
|
12
|
-
getReference(id: string): OpenAPIV3_1.ReferenceObject;
|
|
13
|
-
}
|
|
14
|
-
declare function createComponentCollector(): ComponentCollector;
|
|
15
|
-
/**
|
|
16
|
-
* Builds OpenAPI 3.1 schema from an array of endpoints.
|
|
17
|
-
*
|
|
18
|
-
* Note: This function requires endpoints with toOpenApi3Route method.
|
|
19
|
-
* The actual implementation is in @geekmidas/constructs to avoid circular dependencies.
|
|
20
|
-
*/
|
|
21
|
-
declare function buildOpenApiSchema(endpoints: Array<{
|
|
22
|
-
toOpenApi3Route(collector?: ComponentCollector): Promise<any>;
|
|
23
|
-
}>, options?: OpenApiSchemaOptions): Promise<OpenAPIV3_1.Document>;
|
|
24
|
-
//# sourceMappingURL=openapi.d.ts.map
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
export { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector };
|
|
28
|
-
//# sourceMappingURL=openapi-Aeb_1e9T.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-Aeb_1e9T.d.cts","names":[],"sources":["../src/openapi.ts"],"sourcesContent":[],"mappings":";;;UAEiB,oBAAA;;EAAA,OAAA,CAAA,EAAA,MAAA;EAMA,WAAA,CAAA,EAAA,MAAA;;AACQ,UADR,kBAAA,CACoB;EAAY,OAAvC,EAAA,MAAA,CAAA,MAAA,EAAe,WAAA,CAAY,YAA3B,CAAA;EAAM,SACe,CAAA,EAAA,EAAA,MAAY,EAAA,MAAA,EAAZ,WAAA,CAAY,YAAA,CAAA,EAAA,IAAA;EAAY,YAC5B,CAAA,EAAY,EAAA,MAAA,CAAA,EAAZ,WAAA,CAAY,eAAA;AAAe;AAGtC,iBAAA,wBAAA,CAAA,CAA4B,EAAA,kBAAkB;AAoB9D;;;;;;AAKW,iBALW,kBAAA,CAKC,SAAA,EAJX,KAIW,CAAA;EAAQ,eAA5B,CAAA,SAAA,CAAA,EAH2B,kBAG3B,CAAA,EAHgD,OAGhD,CAAA,GAAA,CAAA;AAAO,CAAA,CAAA,EAAA,OAAA,CAAA,EADA,oBACA,CAAA,EAAP,OAAO,CAAC,WAAA,CAAY,QAAb,CAAA"}
|