@geekmidas/schema 0.1.0 → 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.
- package/CHANGELOG.md +7 -0
- package/dist/conversion-BJGLAqtd.mjs.map +1 -1
- package/dist/conversion-CFlFrSru.cjs.map +1 -1
- package/dist/conversion-CH_EmflL.d.cts.map +1 -0
- package/dist/conversion-DUyZYTWO.d.mts.map +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/{openapi-DR4_PG-e.d.cts → openapi-Aeb_1e9T.d.cts} +3 -1
- package/dist/openapi-Aeb_1e9T.d.cts.map +1 -0
- package/dist/openapi-DH5yCqKh.mjs.map +1 -1
- package/dist/openapi-DVvLYx-8.cjs.map +1 -1
- package/dist/{openapi-j01kFjpI.d.mts → openapi-Dxc4FuMP.d.mts} +3 -1
- package/dist/openapi-Dxc4FuMP.d.mts.map +1 -0
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/parser.cjs.map +1 -1
- package/dist/parser.d.cts +3 -1
- package/dist/parser.d.cts.map +1 -0
- package/dist/parser.d.mts +3 -1
- package/dist/parser.d.mts.map +1 -0
- package/dist/parser.mjs.map +1 -1
- package/dist/{types-ByLHeRGs.d.mts → types-D7ZRea_7.d.cts} +3 -1
- package/dist/types-D7ZRea_7.d.cts.map +1 -0
- package/dist/{types-DfcgE7cO.d.cts → types-o4dOkvCd.d.mts} +3 -1
- package/dist/types-o4dOkvCd.d.mts.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +1 -1
- package/src/__benchmarks__/conversion.bench.ts +67 -67
- package/src/__tests__/conversion.spec.ts +440 -257
- package/src/__tests__/openapi.spec.ts +390 -390
- package/src/__tests__/parser.spec.ts +202 -202
- package/src/conversion.ts +154 -154
- package/src/index.ts +8 -9
- package/src/openapi.ts +49 -49
- package/src/parser.ts +11 -11
- package/src/types.ts +16 -16
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +1 -1
package/CHANGELOG.md
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-BJGLAqtd.mjs","names":["vendor?: string","StandardSchemaJsonSchema: VendorConvertors","jsonSchema: any","componentCollector?: {\n
|
|
1
|
+
{"version":3,"file":"conversion-BJGLAqtd.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\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":";AAEA,IAAY,wDAAL;AACN;AACA;;AACA;AAKD,SAAS,eAAeA,QAAyC;AAChE,MAAK,OACJ,QAAO;AAGR,QAAO,OAAO,OAAO,aAAa,CAAC,SAAS,OAAuB;AACnE;AAED,MAAaC,2BAA6C;CACzD,KAAK,OAAO,WAAyB;AACpC,MAAI;GACH,MAAM,EAAE,GAAG,GAAG,MAAM,OAAO,UAAU,MAAM,OAAO,EAAE,GAAG,CAAE,EAAE,GAAE;AAE7D,OAAI,kBAAkB,YAAY,EAAE,iBAAiB,WACpD,QAAO,EAAE,aAAa,OAAO;GAE9B,MAAM,EAAE,iBAAiB,GAAG,MAAM,OAAO;GAEzC,MAAM,SAAS,gBAAgB,QAAQ,EACtC,0BAA0B,SAC1B,EAAC;AAEF,UAAO;EACP,QAAO;AAEP,UAAO,EAAE,MAAM,SAAU;EACzB;CACD;CACD,SAAS,OAAO,WAAyB;EACxC,MAAM,EAAE,cAAc,GAAG,MAAM,OAAO;AACtC,SAAO,aAAa,OAAc;CAClC;AACD;AAED,SAAS,sBACRC,YACAC,oBAIM;AACN,MAAK,qBAAqB,eAAe,SACxC,QAAO;CAIR,MAAM,gBAAgB,CAACC,WAAqB;AAC3C,OAAK,iBAAiB,WAAW,SAChC,QAAO;AAIR,MAAI,OAAO,eAAe,OAAO,SAAS,UAAU;AAEnD,OAAI,OAAO,KAAK,WAAW,WAAW,EAAE;IACvC,MAAM,UAAU,OAAO,KAAK,QAAQ,YAAY,GAAG;AACnD,WAAO,qBACJ,mBAAmB,aAAa,QAAQ,GACxC;GACH;AACD,UAAO;EACP;AAGD,MAAI,MAAM,QAAQ,OAAO,CACxB,Q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iB,GAAG;AAEnC,qBAAmB,UAAU,UAAU,gBAAgB;AACvD,SAAO,mBAAmB,aAAa,SAAS;CAChD;AAED,QAAO;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-CFlFrSru.cjs","names":["vendor?: string","StandardSchemaJsonSchema: VendorConvertors","jsonSchema: any","componentCollector?: {\n
|
|
1
|
+
{"version":3,"file":"conversion-CFlFrSru.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\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":";;AAEA,IAAY,wDAAL;AACN;AACA;;AACA;AAKD,SAAS,eAAeA,QAAyC;AAChE,MAAK,OACJ,QAAO;AAGR,QAAO,OAAO,OAAO,aAAa,CAAC,SAAS,OAAuB;AACnE;AAED,MAAaC,2BAA6C;CACzD,KAAK,OAAO,WAAyB;AACpC,MAAI;GACH,MAAM,EAAE,GAAG,GAAG,MAAM,OAAO,UAAU,MAAM,OAAO,EAAE,GAAG,CAAE,EAAE,GAAE;AAE7D,OAAI,kBAAkB,YAAY,EAAE,iBAAiB,WACpD,QAAO,EAAE,aAAa,OAAO;GAE9B,MAAM,EAAE,iBAAiB,GAAG,MAAM,OAAO;GAEzC,MAAM,SAAS,gBAAgB,QAAQ,EACtC,0BAA0B,SAC1B,EAAC;AAEF,UAAO;EACP,QAAO;AAEP,UAAO,EAAE,MAAM,SAAU;EACzB;CACD;CACD,SAAS,OAAO,WAAyB;EACxC,MAAM,EAAE,cAAc,GAAG,MAAM,OAAO;AACtC,SAAO,aAAa,OAAc;CAClC;AACD;AAED,SAAS,sBACRC,YACAC,oBAIM;AACN,MAAK,qBAAqB,eAAe,SACxC,QAAO;CAIR,MAAM,gBAAgB,CAACC,WAAqB;AAC3C,OAAK,iBAAiB,WAAW,SAChC,QAAO;AAIR,MAAI,OAAO,eAAe,OAAO,SAAS,UAAU;AAEnD,OAAI,OAAO,KAAK,WAAW,WAAW,EAAE;IACvC,MAAM,UAAU,OAAO,KAAK,QAAQ,YAAY,GAAG;AACnD,WAAO,qBACJ,mBAAmB,aAAa,QAAQ,GACxC;GACH;AACD,UAAO;EACP;A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AAA,MAAA,CAAA,EAAA;IAAO,IAAA,EAAA,MAAA;EAUY,CAAA;CAAiB,CAAA,EAsBpC,OAtBoC,CAAA,GAAA,CAAA"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { convertSchemaWithComponents, convertStandardSchemaToJsonSchema } from "./conversion-CH_EmflL.cjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector } from "./openapi-Aeb_1e9T.cjs";
|
|
3
|
+
import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "./types-D7ZRea_7.cjs";
|
|
4
4
|
export { ComponentCollector, ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema, OpenApiSchemaOptions, buildOpenApiSchema, convertSchemaWithComponents, convertStandardSchemaToJsonSchema, createComponentCollector };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { convertSchemaWithComponents, convertStandardSchemaToJsonSchema } from "./conversion-DUyZYTWO.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector } from "./openapi-Dxc4FuMP.mjs";
|
|
3
|
+
import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "./types-o4dOkvCd.mjs";
|
|
4
4
|
export { ComponentCollector, ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema, OpenApiSchemaOptions, buildOpenApiSchema, convertSchemaWithComponents, convertStandardSchemaToJsonSchema, createComponentCollector };
|
|
@@ -21,6 +21,8 @@ declare function createComponentCollector(): ComponentCollector;
|
|
|
21
21
|
declare function buildOpenApiSchema(endpoints: Array<{
|
|
22
22
|
toOpenApi3Route(collector?: ComponentCollector): Promise<any>;
|
|
23
23
|
}>, options?: OpenApiSchemaOptions): Promise<OpenAPIV3_1.Document>;
|
|
24
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
25
|
+
|
|
24
26
|
//#endregion
|
|
25
27
|
export { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector };
|
|
26
|
-
//# sourceMappingURL=openapi-
|
|
28
|
+
//# sourceMappingURL=openapi-Aeb_1e9T.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-DH5yCqKh.mjs","names":["schemas: Record<string, OpenAPIV3_1.SchemaObject>","id: string","schema: OpenAPIV3_1.SchemaObject","endpoints: Array<{\n
|
|
1
|
+
{"version":3,"file":"openapi-DH5yCqKh.mjs","names":["schemas: Record<string, OpenAPIV3_1.SchemaObject>","id: string","schema: OpenAPIV3_1.SchemaObject","endpoints: Array<{\n\t\ttoOpenApi3Route(collector?: ComponentCollector): Promise<any>;\n\t}>","options: OpenApiSchemaOptions","paths: OpenAPIV3_1.PathsObject","doc: OpenAPIV3_1.Document"],"sources":["../src/openapi.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from 'openapi-types';\n\nexport interface OpenApiSchemaOptions {\n\ttitle?: string;\n\tversion?: string;\n\tdescription?: string;\n}\n\nexport interface ComponentCollector {\n\tschemas: Record<string, OpenAPIV3_1.SchemaObject>;\n\taddSchema(id: string, schema: OpenAPIV3_1.SchemaObject): void;\n\tgetReference(id: string): OpenAPIV3_1.ReferenceObject;\n}\n\nexport function createComponentCollector(): ComponentCollector {\n\tconst schemas: Record<string, OpenAPIV3_1.SchemaObject> = {};\n\n\treturn {\n\t\tschemas,\n\t\taddSchema(id: string, schema: OpenAPIV3_1.SchemaObject) {\n\t\t\tschemas[id] = schema;\n\t\t},\n\t\tgetReference(id: string): OpenAPIV3_1.ReferenceObject {\n\t\t\treturn { $ref: `#/components/schemas/${id}` };\n\t\t},\n\t};\n}\n\n/**\n * Builds OpenAPI 3.1 schema from an array of endpoints.\n *\n * Note: This function requires endpoints with toOpenApi3Route method.\n * The actual implementation is in @geekmidas/constructs to avoid circular dependencies.\n */\nexport async function buildOpenApiSchema(\n\tendpoints: Array<{\n\t\ttoOpenApi3Route(collector?: ComponentCollector): Promise<any>;\n\t}>,\n\toptions: OpenApiSchemaOptions = {},\n): Promise<OpenAPIV3_1.Document> {\n\tconst { title = 'API', version = '1.0.0', description } = options;\n\tconst paths: OpenAPIV3_1.PathsObject = {};\n\tconst componentCollector = createComponentCollector();\n\n\tfor (const endpoint of endpoints) {\n\t\tconst route = await endpoint.toOpenApi3Route(componentCollector);\n\n\t\t// Merge the route into the paths object\n\t\tfor (const [path, methods] of Object.entries(route)) {\n\t\t\tif (!paths[path]) {\n\t\t\t\tpaths[path] = {};\n\t\t\t}\n\t\t\tObject.assign(paths[path], methods);\n\t\t}\n\t}\n\n\tconst doc: OpenAPIV3_1.Document = {\n\t\topenapi: '3.0.0',\n\t\tinfo: {\n\t\t\ttitle,\n\t\t\tversion,\n\t\t\t...(description && { description }),\n\t\t},\n\t\tpaths,\n\t};\n\n\t// Add components if any schemas were collected\n\tif (Object.keys(componentCollector.schemas).length > 0) {\n\t\tdoc.components = {\n\t\t\tschemas: componentCollector.schemas,\n\t\t};\n\t}\n\n\treturn doc;\n}\n"],"mappings":";AAcA,SAAgB,2BAA+C;CAC9D,MAAMA,UAAoD,CAAE;AAE5D,QAAO;EACN;EACA,UAAUC,IAAYC,QAAkC;AACvD,WAAQ,MAAM;EACd;EACD,aAAaD,IAAyC;AACrD,UAAO,EAAE,OAAO,uBAAuB,GAAG,EAAG;EAC7C;CACD;AACD;;;;;;;AAQD,eAAsB,mBACrBE,WAGAC,UAAgC,CAAE,GACF;CAChC,MAAM,EAAE,QAAQ,OAAO,UAAU,SAAS,aAAa,GAAG;CAC1D,MAAMC,QAAiC,CAAE;CACzC,MAAM,qBAAqB,0BAA0B;AAErD,MAAK,MAAM,YAAY,WAAW;EACjC,MAAM,QAAQ,MAAM,SAAS,gBAAgB,mBAAmB;AAGhE,OAAK,MAAM,CAAC,MAAM,QAAQ,IAAI,OAAO,QAAQ,MAAM,EAAE;AACpD,QAAK,MAAM,MACV,OAAM,QAAQ,CAAE;AAEjB,UAAO,OAAO,MAAM,OAAO,QAAQ;EACnC;CACD;CAED,MAAMC,MAA4B;EACjC,SAAS;EACT,MAAM;GACL;GACA;GACA,GAAI,eAAe,EAAE,YAAa;EAClC;EACD;CACA;AAGD,KAAI,OAAO,KAAK,mBAAmB,QAAQ,CAAC,SAAS,EACpD,KAAI,aAAa,EAChB,SAAS,mBAAmB,QAC5B;AAGF,QAAO;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-DVvLYx-8.cjs","names":["schemas: Record<string, OpenAPIV3_1.SchemaObject>","id: string","schema: OpenAPIV3_1.SchemaObject","endpoints: Array<{\n
|
|
1
|
+
{"version":3,"file":"openapi-DVvLYx-8.cjs","names":["schemas: Record<string, OpenAPIV3_1.SchemaObject>","id: string","schema: OpenAPIV3_1.SchemaObject","endpoints: Array<{\n\t\ttoOpenApi3Route(collector?: ComponentCollector): Promise<any>;\n\t}>","options: OpenApiSchemaOptions","paths: OpenAPIV3_1.PathsObject","doc: OpenAPIV3_1.Document"],"sources":["../src/openapi.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from 'openapi-types';\n\nexport interface OpenApiSchemaOptions {\n\ttitle?: string;\n\tversion?: string;\n\tdescription?: string;\n}\n\nexport interface ComponentCollector {\n\tschemas: Record<string, OpenAPIV3_1.SchemaObject>;\n\taddSchema(id: string, schema: OpenAPIV3_1.SchemaObject): void;\n\tgetReference(id: string): OpenAPIV3_1.ReferenceObject;\n}\n\nexport function createComponentCollector(): ComponentCollector {\n\tconst schemas: Record<string, OpenAPIV3_1.SchemaObject> = {};\n\n\treturn {\n\t\tschemas,\n\t\taddSchema(id: string, schema: OpenAPIV3_1.SchemaObject) {\n\t\t\tschemas[id] = schema;\n\t\t},\n\t\tgetReference(id: string): OpenAPIV3_1.ReferenceObject {\n\t\t\treturn { $ref: `#/components/schemas/${id}` };\n\t\t},\n\t};\n}\n\n/**\n * Builds OpenAPI 3.1 schema from an array of endpoints.\n *\n * Note: This function requires endpoints with toOpenApi3Route method.\n * The actual implementation is in @geekmidas/constructs to avoid circular dependencies.\n */\nexport async function buildOpenApiSchema(\n\tendpoints: Array<{\n\t\ttoOpenApi3Route(collector?: ComponentCollector): Promise<any>;\n\t}>,\n\toptions: OpenApiSchemaOptions = {},\n): Promise<OpenAPIV3_1.Document> {\n\tconst { title = 'API', version = '1.0.0', description } = options;\n\tconst paths: OpenAPIV3_1.PathsObject = {};\n\tconst componentCollector = createComponentCollector();\n\n\tfor (const endpoint of endpoints) {\n\t\tconst route = await endpoint.toOpenApi3Route(componentCollector);\n\n\t\t// Merge the route into the paths object\n\t\tfor (const [path, methods] of Object.entries(route)) {\n\t\t\tif (!paths[path]) {\n\t\t\t\tpaths[path] = {};\n\t\t\t}\n\t\t\tObject.assign(paths[path], methods);\n\t\t}\n\t}\n\n\tconst doc: OpenAPIV3_1.Document = {\n\t\topenapi: '3.0.0',\n\t\tinfo: {\n\t\t\ttitle,\n\t\t\tversion,\n\t\t\t...(description && { description }),\n\t\t},\n\t\tpaths,\n\t};\n\n\t// Add components if any schemas were collected\n\tif (Object.keys(componentCollector.schemas).length > 0) {\n\t\tdoc.components = {\n\t\t\tschemas: componentCollector.schemas,\n\t\t};\n\t}\n\n\treturn doc;\n}\n"],"mappings":";;AAcA,SAAgB,2BAA+C;CAC9D,MAAMA,UAAoD,CAAE;AAE5D,QAAO;EACN;EACA,UAAUC,IAAYC,QAAkC;AACvD,WAAQ,MAAM;EACd;EACD,aAAaD,IAAyC;AACrD,UAAO,EAAE,OAAO,uBAAuB,GAAG,EAAG;EAC7C;CACD;AACD;;;;;;;AAQD,eAAsB,mBACrBE,WAGAC,UAAgC,CAAE,GACF;CAChC,MAAM,EAAE,QAAQ,OAAO,UAAU,SAAS,aAAa,GAAG;CAC1D,MAAMC,QAAiC,CAAE;CACzC,MAAM,qBAAqB,0BAA0B;AAErD,MAAK,MAAM,YAAY,WAAW;EACjC,MAAM,QAAQ,MAAM,SAAS,gBAAgB,mBAAmB;AAGhE,OAAK,MAAM,CAAC,MAAM,QAAQ,IAAI,OAAO,QAAQ,MAAM,EAAE;AACpD,QAAK,MAAM,MACV,OAAM,QAAQ,CAAE;AAEjB,UAAO,OAAO,MAAM,OAAO,QAAQ;EACnC;CACD;CAED,MAAMC,MAA4B;EACjC,SAAS;EACT,MAAM;GACL;GACA;GACA,GAAI,eAAe,EAAE,YAAa;EAClC;EACD;CACA;AAGD,KAAI,OAAO,KAAK,mBAAmB,QAAQ,CAAC,SAAS,EACpD,KAAI,aAAa,EAChB,SAAS,mBAAmB,QAC5B;AAGF,QAAO;AACP"}
|
|
@@ -21,6 +21,8 @@ declare function createComponentCollector(): ComponentCollector;
|
|
|
21
21
|
declare function buildOpenApiSchema(endpoints: Array<{
|
|
22
22
|
toOpenApi3Route(collector?: ComponentCollector): Promise<any>;
|
|
23
23
|
}>, options?: OpenApiSchemaOptions): Promise<OpenAPIV3_1.Document>;
|
|
24
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
25
|
+
|
|
24
26
|
//#endregion
|
|
25
27
|
export { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector };
|
|
26
|
-
//# sourceMappingURL=openapi-
|
|
28
|
+
//# sourceMappingURL=openapi-Dxc4FuMP.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-Dxc4FuMP.d.mts","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"}
|
package/dist/openapi.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector } from "./openapi-
|
|
1
|
+
import { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector } from "./openapi-Aeb_1e9T.cjs";
|
|
2
2
|
export { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector };
|
package/dist/openapi.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector } from "./openapi-
|
|
1
|
+
import { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector } from "./openapi-Dxc4FuMP.mjs";
|
|
2
2
|
export { ComponentCollector, OpenApiSchemaOptions, buildOpenApiSchema, createComponentCollector };
|
package/dist/parser.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.cjs","names":["schema: T","data: unknown"],"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
|
|
1
|
+
{"version":3,"file":"parser.cjs","names":["schema: T","data: unknown"],"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,SAAqCA,QAAWC,MAAe;AAC9E,QAAO,OAAO,aAAa,SAAS,KAAK;AACzC;AAED,eAAsB,YACrBD,QACAC,MACkC;AAClC,MAAK,OACJ;CAGD,MAAM,SAAS,MAAM,SAAS,QAAuC,KAAK;AAE1E,KAAI,OAAO,OACV,OAAM,OAAO;AAGd,QAAO,OAAO;AACd"}
|
package/dist/parser.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InferStandardSchema } from "./types-
|
|
1
|
+
import { InferStandardSchema } from "./types-D7ZRea_7.cjs";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
3
|
|
|
4
4
|
//#region src/parser.d.ts
|
|
@@ -12,6 +12,8 @@ import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
|
12
12
|
*/
|
|
13
13
|
declare function validate<T extends StandardSchemaV1>(schema: T, data: unknown): StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>;
|
|
14
14
|
declare function parseSchema<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<InferStandardSchema<T>>;
|
|
15
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
16
|
+
|
|
15
17
|
//#endregion
|
|
16
18
|
export { parseSchema, validate };
|
|
17
19
|
//# sourceMappingURL=parser.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.cts","names":[],"sources":["../src/parser.ts"],"sourcesContent":[],"mappings":";;;;;;;AAUA;;;;;AAA6E,iBAA7D,QAA6D,CAAA,UAA1C,gBAA0C,CAAA,CAAA,MAAA,EAAhB,CAAgB,EAAA,IAAA,EAAA,OAAA,CAAA,EAAA,gBAAA,CAAA,MAAA,CAAA,OAAA,CAAA,GAAA,OAAA,CAAA,gBAAA,CAAA,MAAA,CAAA,OAAA,CAAA,CAAA;AAAA,iBAIvD,WAJuD,CAAA,UAIjC,gBAJiC,CAAA,CAAA,MAAA,EAKpE,CALoE,EAAA,IAAA,EAAA,OAAA,CAAA,EAO1E,OAP0E,CAOlE,mBAPkE,CAO9C,CAP8C,CAAA,CAAA;AAAA"}
|
package/dist/parser.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InferStandardSchema } from "./types-
|
|
1
|
+
import { InferStandardSchema } from "./types-o4dOkvCd.mjs";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
3
|
|
|
4
4
|
//#region src/parser.d.ts
|
|
@@ -12,6 +12,8 @@ import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
|
12
12
|
*/
|
|
13
13
|
declare function validate<T extends StandardSchemaV1>(schema: T, data: unknown): StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>;
|
|
14
14
|
declare function parseSchema<T extends StandardSchemaV1>(schema: T, data: unknown): Promise<InferStandardSchema<T>>;
|
|
15
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
16
|
+
|
|
15
17
|
//#endregion
|
|
16
18
|
export { parseSchema, validate };
|
|
17
19
|
//# sourceMappingURL=parser.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.mts","names":[],"sources":["../src/parser.ts"],"sourcesContent":[],"mappings":";;;;;;;AAUA;;;;;AAA6E,iBAA7D,QAA6D,CAAA,UAA1C,gBAA0C,CAAA,CAAA,MAAA,EAAhB,CAAgB,EAAA,IAAA,EAAA,OAAA,CAAA,EAAA,gBAAA,CAAA,MAAA,CAAA,OAAA,CAAA,GAAA,OAAA,CAAA,gBAAA,CAAA,MAAA,CAAA,OAAA,CAAA,CAAA;AAAA,iBAIvD,WAJuD,CAAA,UAIjC,gBAJiC,CAAA,CAAA,MAAA,EAKpE,CALoE,EAAA,IAAA,EAAA,OAAA,CAAA,EAO1E,OAP0E,CAOlE,mBAPkE,CAO9C,CAP8C,CAAA,CAAA;AAAA"}
|
package/dist/parser.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.mjs","names":["schema: T","data: unknown"],"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
|
|
1
|
+
{"version":3,"file":"parser.mjs","names":["schema: T","data: unknown"],"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,SAAqCA,QAAWC,MAAe;AAC9E,QAAO,OAAO,aAAa,SAAS,KAAK;AACzC;AAED,eAAsB,YACrBD,QACAC,MACkC;AAClC,MAAK,OACJ;CAGD,MAAM,SAAS,MAAM,SAAS,QAAuC,KAAK;AAE1E,KAAI,OAAO,OACV,OAAM,OAAO;AAGd,QAAO,OAAO;AACd"}
|
|
@@ -8,6 +8,8 @@ type ComposableStandardSchema = StandardSchemaV1 | {
|
|
|
8
8
|
type InferComposableStandardSchema<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T> : T extends {
|
|
9
9
|
[key: string]: StandardSchemaV1 | undefined;
|
|
10
10
|
} ? { [K in keyof T as T[K] extends StandardSchemaV1 ? K : never]: T[K] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T[K]> : never } : {};
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
12
|
+
|
|
11
13
|
//#endregion
|
|
12
14
|
export { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema };
|
|
13
|
-
//# sourceMappingURL=types-
|
|
15
|
+
//# sourceMappingURL=types-D7ZRea_7.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-D7ZRea_7.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;KAEY,yBAAyB,UAAU,mBAC5C,gBAAA,CAAiB,YAAY;KAGpB,wBAAA,GACT;EALS,CAAA,GAAA,EAAA,MAAA,CAAA,EAOM,gBAPa,GAAA,SAAA;CAAA;AAAM,KAUzB,6BAVyB,CAAA,CAAA,CAAA,GAUU,CAVV,SAUoB,gBAVpB,GAWlC,gBAAA,CAAiB,WAXiB,CAWL,CAXK,CAAA,GAYlC,CAZkC,SAAA;EAAC,CAAA,GAAS,EAAA,MAAA,CAAA,EAYjB,gBAZiB,GAAA,SAAA;CAAgB,GAAA,QAC5D,MAaa,CAbb,IAakB,CAblB,CAaoB,CAbH,CAAA,SAac,gBAbd,GAcb,CAda,GAAA,KAAA,GAeL,CAfK,CAeH,CAfG,CAAA,SAeQ,gBAfR,GAgBb,gBAAA,CAAiB,WAhBJ,CAgBgB,CAhBhB,CAgBkB,CAhBlB,CAAA,CAAA,GAAA,KAAA,EAAW,GAAA,CAAA,CAAA;AAG/B"}
|
|
@@ -8,6 +8,8 @@ type ComposableStandardSchema = StandardSchemaV1 | {
|
|
|
8
8
|
type InferComposableStandardSchema<T> = T extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T> : T extends {
|
|
9
9
|
[key: string]: StandardSchemaV1 | undefined;
|
|
10
10
|
} ? { [K in keyof T as T[K] extends StandardSchemaV1 ? K : never]: T[K] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<T[K]> : never } : {};
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
12
|
+
|
|
11
13
|
//#endregion
|
|
12
14
|
export { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema };
|
|
13
|
-
//# sourceMappingURL=types-
|
|
15
|
+
//# sourceMappingURL=types-o4dOkvCd.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-o4dOkvCd.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;KAEY,yBAAyB,UAAU,mBAC5C,gBAAA,CAAiB,YAAY;KAGpB,wBAAA,GACT;EALS,CAAA,GAAA,EAAA,MAAA,CAAA,EAOM,gBAPa,GAAA,SAAA;CAAA;AAAM,KAUzB,6BAVyB,CAAA,CAAA,CAAA,GAUU,CAVV,SAUoB,gBAVpB,GAWlC,gBAAA,CAAiB,WAXiB,CAWL,CAXK,CAAA,GAYlC,CAZkC,SAAA;EAAC,CAAA,GAAS,EAAA,MAAA,CAAA,EAYjB,gBAZiB,GAAA,SAAA;CAAgB,GAAA,QAC5D,MAaa,CAbb,IAakB,CAblB,CAaoB,CAbH,CAAA,SAac,gBAbd,GAcb,CAda,GAAA,KAAA,GAeL,CAfK,CAeH,CAfG,CAAA,SAeQ,gBAfR,GAgBb,gBAAA,CAAiB,WAhBJ,CAgBgB,CAhBhB,CAgBkB,CAhBlB,CAAA,CAAA,GAAA,KAAA,EAAW,GAAA,CAAA,CAAA;AAG/B"}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "./types-
|
|
1
|
+
import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "./types-D7ZRea_7.cjs";
|
|
2
2
|
export { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "./types-
|
|
1
|
+
import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "./types-o4dOkvCd.mjs";
|
|
2
2
|
export { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema };
|
package/package.json
CHANGED
|
@@ -3,86 +3,86 @@ import { z } from 'zod';
|
|
|
3
3
|
import { convertStandardSchemaToJsonSchema } from '../conversion';
|
|
4
4
|
|
|
5
5
|
describe('Schema Conversion - Simple', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const simpleSchema = z.object({
|
|
7
|
+
id: z.string(),
|
|
8
|
+
name: z.string(),
|
|
9
|
+
email: z.string().email(),
|
|
10
|
+
});
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
bench('simple object schema', async () => {
|
|
13
|
+
await convertStandardSchemaToJsonSchema(simpleSchema);
|
|
14
|
+
});
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const primitiveSchema = z.string();
|
|
17
|
+
bench('primitive string schema', async () => {
|
|
18
|
+
await convertStandardSchemaToJsonSchema(primitiveSchema);
|
|
19
|
+
});
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const arraySchema = z.array(z.string());
|
|
22
|
+
bench('array of strings schema', async () => {
|
|
23
|
+
await convertStandardSchemaToJsonSchema(arraySchema);
|
|
24
|
+
});
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
describe('Schema Conversion - Complex', () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
28
|
+
const nestedSchema = z.object({
|
|
29
|
+
user: z.object({
|
|
30
|
+
profile: z.object({
|
|
31
|
+
name: z.string(),
|
|
32
|
+
bio: z.string().optional(),
|
|
33
|
+
settings: z.record(z.string(), z.unknown()),
|
|
34
|
+
}),
|
|
35
|
+
contacts: z.array(
|
|
36
|
+
z.object({
|
|
37
|
+
type: z.enum(['email', 'phone']),
|
|
38
|
+
value: z.string(),
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
}),
|
|
42
|
+
metadata: z.object({
|
|
43
|
+
createdAt: z.string(),
|
|
44
|
+
updatedAt: z.string(),
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
bench('deeply nested schema', async () => {
|
|
49
|
+
await convertStandardSchemaToJsonSchema(nestedSchema);
|
|
50
|
+
});
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
const unionSchema = z.discriminatedUnion('type', [
|
|
53
|
+
z.object({ type: z.literal('text'), content: z.string() }),
|
|
54
|
+
z.object({ type: z.literal('image'), url: z.string() }),
|
|
55
|
+
z.object({
|
|
56
|
+
type: z.literal('video'),
|
|
57
|
+
url: z.string(),
|
|
58
|
+
duration: z.number(),
|
|
59
|
+
}),
|
|
60
|
+
]);
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
bench('discriminated union schema', async () => {
|
|
63
|
+
await convertStandardSchemaToJsonSchema(unionSchema);
|
|
64
|
+
});
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
const largeSchema = z.object(
|
|
67
|
+
Object.fromEntries(
|
|
68
|
+
Array.from({ length: 50 }, (_, i) => [`field${i}`, z.string()]),
|
|
69
|
+
),
|
|
70
|
+
);
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
bench('large object (50 fields)', async () => {
|
|
73
|
+
await convertStandardSchemaToJsonSchema(largeSchema);
|
|
74
|
+
});
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
describe('Schema Conversion - With Refinements', () => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
const refinedSchema = z.object({
|
|
79
|
+
age: z.number().min(0).max(150),
|
|
80
|
+
email: z.string().email(),
|
|
81
|
+
url: z.string().url(),
|
|
82
|
+
uuid: z.string().uuid(),
|
|
83
|
+
});
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
bench('schema with refinements', async () => {
|
|
86
|
+
await convertStandardSchemaToJsonSchema(refinedSchema);
|
|
87
|
+
});
|
|
88
88
|
});
|