@powerlines/schema 0.11.28 → 0.11.37
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/bundle.cjs +34 -20
- package/dist/bundle.d.cts +3 -3
- package/dist/bundle.d.cts.map +1 -1
- package/dist/bundle.d.mts +3 -3
- package/dist/bundle.d.mts.map +1 -1
- package/dist/bundle.mjs +35 -21
- package/dist/bundle.mjs.map +1 -1
- package/dist/codegen.cjs +55 -8
- package/dist/codegen.d.cts +12 -6
- package/dist/codegen.d.cts.map +1 -1
- package/dist/codegen.d.mts +12 -6
- package/dist/codegen.d.mts.map +1 -1
- package/dist/codegen.mjs +52 -8
- package/dist/codegen.mjs.map +1 -1
- package/dist/constants.cjs +42 -0
- package/dist/constants.d.cts +15 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +15 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +39 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/extract.cjs +144 -95
- package/dist/extract.d.cts +34 -69
- package/dist/extract.d.cts.map +1 -1
- package/dist/extract.d.mts +34 -69
- package/dist/extract.d.mts.map +1 -1
- package/dist/extract.mjs +144 -95
- package/dist/extract.mjs.map +1 -1
- package/dist/helpers.cjs +87 -0
- package/dist/helpers.d.cts +48 -0
- package/dist/helpers.d.cts.map +1 -0
- package/dist/helpers.d.mts +48 -0
- package/dist/helpers.d.mts.map +1 -0
- package/dist/helpers.mjs +84 -0
- package/dist/helpers.mjs.map +1 -0
- package/dist/index.cjs +29 -5
- package/dist/index.d.cts +8 -5
- package/dist/index.d.mts +8 -5
- package/dist/index.mjs +7 -4
- package/dist/metadata.cjs +80 -0
- package/dist/metadata.d.cts +52 -0
- package/dist/metadata.d.cts.map +1 -0
- package/dist/metadata.d.mts +52 -0
- package/dist/metadata.d.mts.map +1 -0
- package/dist/metadata.mjs +76 -0
- package/dist/metadata.mjs.map +1 -0
- package/dist/persistence.cjs +75 -0
- package/dist/persistence.d.cts +47 -0
- package/dist/persistence.d.cts.map +1 -0
- package/dist/persistence.d.mts +47 -0
- package/dist/persistence.d.mts.map +1 -0
- package/dist/persistence.mjs +71 -0
- package/dist/persistence.mjs.map +1 -0
- package/dist/reflection.cjs +292 -299
- package/dist/reflection.d.cts +3 -16
- package/dist/reflection.d.cts.map +1 -1
- package/dist/reflection.d.mts +3 -16
- package/dist/reflection.d.mts.map +1 -1
- package/dist/reflection.mjs +291 -299
- package/dist/reflection.mjs.map +1 -1
- package/dist/resolve.cjs +7 -7
- package/dist/resolve.mjs +7 -7
- package/dist/resolve.mjs.map +1 -1
- package/dist/type-checks.cjs +126 -25
- package/dist/type-checks.d.cts +45 -23
- package/dist/type-checks.d.cts.map +1 -1
- package/dist/type-checks.d.mts +45 -23
- package/dist/type-checks.d.mts.map +1 -1
- package/dist/type-checks.mjs +125 -25
- package/dist/type-checks.mjs.map +1 -1
- package/dist/types.d.cts +237 -95
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +237 -95
- package/dist/types.d.mts.map +1 -1
- package/package.json +24 -8
- package/dist/jtd.cjs +0 -385
- package/dist/jtd.d.cts +0 -15
- package/dist/jtd.d.cts.map +0 -1
- package/dist/jtd.d.mts +0 -15
- package/dist/jtd.d.mts.map +0 -1
- package/dist/jtd.mjs +0 -384
- package/dist/jtd.mjs.map +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
const JsonSchemaTypes = {
|
|
3
|
+
STRING: "string",
|
|
4
|
+
NUMBER: "number",
|
|
5
|
+
INTEGER: "integer",
|
|
6
|
+
BOOLEAN: "boolean",
|
|
7
|
+
NULL: "null",
|
|
8
|
+
OBJECT: "object",
|
|
9
|
+
ARRAY: "array"
|
|
10
|
+
};
|
|
11
|
+
const JSON_SCHEMA_DATA_TYPES = [
|
|
12
|
+
JsonSchemaTypes.STRING,
|
|
13
|
+
JsonSchemaTypes.NUMBER,
|
|
14
|
+
JsonSchemaTypes.INTEGER,
|
|
15
|
+
JsonSchemaTypes.BOOLEAN,
|
|
16
|
+
JsonSchemaTypes.ARRAY,
|
|
17
|
+
JsonSchemaTypes.OBJECT,
|
|
18
|
+
JsonSchemaTypes.NULL
|
|
19
|
+
];
|
|
20
|
+
const JSON_SCHEMA_METADATA_KEYS = [
|
|
21
|
+
"docs",
|
|
22
|
+
"deprecated",
|
|
23
|
+
"title",
|
|
24
|
+
"description",
|
|
25
|
+
"examples",
|
|
26
|
+
"visibility",
|
|
27
|
+
"hidden",
|
|
28
|
+
"ignore",
|
|
29
|
+
"internal",
|
|
30
|
+
"runtime",
|
|
31
|
+
"readOnly",
|
|
32
|
+
"writeOnly",
|
|
33
|
+
"alias",
|
|
34
|
+
"tags"
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { JSON_SCHEMA_DATA_TYPES, JSON_SCHEMA_METADATA_KEYS, JsonSchemaTypes };
|
|
39
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { SchemaMetadata } from \"./types\";\n\nexport const JsonSchemaTypes = {\n STRING: \"string\",\n NUMBER: \"number\",\n INTEGER: \"integer\",\n BOOLEAN: \"boolean\",\n NULL: \"null\",\n OBJECT: \"object\",\n ARRAY: \"array\"\n} as const;\n\nexport const JSON_SCHEMA_DATA_TYPES = [\n JsonSchemaTypes.STRING,\n JsonSchemaTypes.NUMBER,\n JsonSchemaTypes.INTEGER,\n JsonSchemaTypes.BOOLEAN,\n JsonSchemaTypes.ARRAY,\n JsonSchemaTypes.OBJECT,\n JsonSchemaTypes.NULL\n] as const;\n\nexport const JSON_SCHEMA_METADATA_KEYS = [\n \"docs\",\n \"deprecated\",\n \"title\",\n \"description\",\n \"examples\",\n \"visibility\",\n \"hidden\",\n \"ignore\",\n \"internal\",\n \"runtime\",\n \"readOnly\",\n \"writeOnly\",\n \"alias\",\n \"tags\"\n] satisfies ReadonlyArray<keyof SchemaMetadata>;\n"],"mappings":";AAoBA,MAAa,kBAAkB;CAC7B,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,MAAM;CACN,QAAQ;CACR,OAAO;AACT;AAEA,MAAa,yBAAyB;CACpC,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;AAClB;AAEA,MAAa,4BAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
package/dist/extract.cjs
CHANGED
|
@@ -1,23 +1,94 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_type_checks = require('./type-checks.cjs');
|
|
4
|
+
const require_persistence = require('./persistence.cjs');
|
|
4
5
|
const require_reflection = require('./reflection.cjs');
|
|
5
6
|
const require_resolve = require('./resolve.cjs');
|
|
6
|
-
const require_type_checks = require('./type-checks.cjs');
|
|
7
7
|
let defu = require("defu");
|
|
8
8
|
defu = require_runtime.__toESM(defu, 1);
|
|
9
|
+
let _stryke_type_checks = require("@stryke/type-checks");
|
|
10
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
11
|
+
let _stryke_json = require("@stryke/json");
|
|
9
12
|
let _powerlines_core = require("@powerlines/core");
|
|
10
|
-
let
|
|
13
|
+
let _powerlines_deepkit_rolldown_plugin = require("@powerlines/deepkit/rolldown-plugin");
|
|
11
14
|
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
12
15
|
let _stryke_hash = require("@stryke/hash");
|
|
13
|
-
let
|
|
14
|
-
let _stryke_type_checks = require("@stryke/type-checks");
|
|
15
|
-
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
16
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
16
17
|
let _stryke_zod = require("@stryke/zod");
|
|
17
18
|
|
|
18
19
|
//#region src/extract.ts
|
|
20
|
+
function convertNestedUntypedSchema(value) {
|
|
21
|
+
if (require_type_checks.isUntypedSchema(value)) return convertUntypedSchemaToJsonSchema(value);
|
|
22
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(value)) {
|
|
23
|
+
if (require_type_checks.isUntypedInput(value)) return convertUntypedInputToJsonSchema(value);
|
|
24
|
+
const nested = value;
|
|
25
|
+
if ("$schema" in nested && require_type_checks.isUntypedSchema(nested.$schema)) return convertUntypedSchemaToJsonSchema(nested.$schema);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
function convertNestedUntypedSchemaArray(value) {
|
|
30
|
+
if (!Array.isArray(value)) return value;
|
|
31
|
+
return value.map((item) => convertNestedUntypedSchema(item));
|
|
32
|
+
}
|
|
33
|
+
function convertUntypedSchemaToJsonSchema(schema) {
|
|
34
|
+
const source = schema;
|
|
35
|
+
const jsonSchema = {};
|
|
36
|
+
for (const [key, value] of Object.entries(source)) {
|
|
37
|
+
if (key === "tsType" || key === "markdownType" || key === "tags" || key === "args" || key === "resolve") continue;
|
|
38
|
+
if (key === "id" && (0, _stryke_type_checks.isSetString)(value)) {
|
|
39
|
+
jsonSchema.$id = value;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (key === "properties" || key === "patternProperties" || key === "dependentSchemas" || key === "$defs" || key === "definitions") {
|
|
43
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(value)) {
|
|
44
|
+
jsonSchema[key] = value;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
jsonSchema[key] = Object.fromEntries(Object.entries(value).map(([propertyKey, propertyValue]) => [propertyKey, convertNestedUntypedSchema(propertyValue)]));
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (key === "items" || key === "contains" || key === "if" || key === "then" || key === "else" || key === "not" || key === "propertyNames" || key === "additionalProperties" || key === "unevaluatedProperties") {
|
|
51
|
+
jsonSchema[key] = convertNestedUntypedSchema(value);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (key === "oneOf" || key === "anyOf" || key === "allOf") {
|
|
55
|
+
jsonSchema[key] = convertNestedUntypedSchemaArray(value);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
jsonSchema[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return jsonSchema;
|
|
61
|
+
}
|
|
62
|
+
function convertUntypedInputToJsonSchema(input) {
|
|
63
|
+
const inputObject = input;
|
|
64
|
+
const base = require_type_checks.isUntypedSchema(inputObject.$schema) ? convertUntypedSchemaToJsonSchema(inputObject.$schema) : {};
|
|
65
|
+
const properties = {};
|
|
66
|
+
for (const [key, value] of Object.entries(inputObject)) {
|
|
67
|
+
if (key.startsWith("$")) continue;
|
|
68
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(value)) continue;
|
|
69
|
+
if (require_type_checks.isUntypedInput(value)) {
|
|
70
|
+
properties[key] = convertUntypedInputToJsonSchema(value);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const nested = value;
|
|
74
|
+
if ("$schema" in nested && require_type_checks.isUntypedSchema(nested.$schema)) {
|
|
75
|
+
properties[key] = convertUntypedSchemaToJsonSchema(nested.$schema);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (require_type_checks.isUntypedSchema(value)) properties[key] = convertUntypedSchemaToJsonSchema(value);
|
|
79
|
+
}
|
|
80
|
+
const mergedProperties = {
|
|
81
|
+
...(0, _stryke_type_checks_is_set_object.isSetObject)(base.properties) ? base.properties : {},
|
|
82
|
+
...properties
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
...base,
|
|
86
|
+
type: base.type ?? "object",
|
|
87
|
+
...Object.keys(mergedProperties).length > 0 ? { properties: mergedProperties } : {}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
19
90
|
/**
|
|
20
|
-
* Creates a hash string for a given schema definition input.
|
|
91
|
+
* Creates a hash string for a given schema definition input.
|
|
21
92
|
*/
|
|
22
93
|
function extractHash(variant, input) {
|
|
23
94
|
if ((0, _stryke_type_checks.isSetString)(input)) return (0, _stryke_hash.murmurhash)({
|
|
@@ -33,10 +104,18 @@ function extractHash(variant, input) {
|
|
|
33
104
|
variant,
|
|
34
105
|
input: input["~standard"]
|
|
35
106
|
});
|
|
36
|
-
else if (
|
|
107
|
+
else if (require_type_checks.isJsonSchema(input)) return (0, _stryke_hash.murmurhash)({
|
|
37
108
|
variant,
|
|
38
109
|
input
|
|
39
110
|
});
|
|
111
|
+
else if (require_type_checks.isUntypedInput(input)) return (0, _stryke_hash.murmurhash)({
|
|
112
|
+
variant,
|
|
113
|
+
input: convertUntypedInputToJsonSchema(input)
|
|
114
|
+
});
|
|
115
|
+
else if (require_type_checks.isUntypedSchema(input)) return (0, _stryke_hash.murmurhash)({
|
|
116
|
+
variant,
|
|
117
|
+
input: convertUntypedSchemaToJsonSchema(input)
|
|
118
|
+
});
|
|
40
119
|
else if ((0, _powerlines_deepkit_vendor_type.isType)(input)) return (0, _stryke_hash.murmurhash)({
|
|
41
120
|
variant,
|
|
42
121
|
input: (0, _powerlines_deepkit_vendor_type.stringifyType)(input)
|
|
@@ -45,95 +124,47 @@ function extractHash(variant, input) {
|
|
|
45
124
|
throw new Error(`Failed to create an input hash for the provided schema definition input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, or a reflected Deepkit Type object.`);
|
|
46
125
|
}
|
|
47
126
|
/**
|
|
48
|
-
* Converts a reflected Deepkit {@link
|
|
49
|
-
*
|
|
50
|
-
* @remarks
|
|
51
|
-
* This function delegates to an internal recursive walker that handles the full set of Deepkit reflection kinds.
|
|
52
|
-
*
|
|
53
|
-
* @param reflection - The reflected Deepkit Type to convert.
|
|
54
|
-
* @returns A JSON Schema (draft-07) fragment representing the type, or `undefined` when no schema could be produced.
|
|
127
|
+
* Converts a reflected Deepkit {@link Type} into a JSON Schema (draft-07) representation.
|
|
55
128
|
*/
|
|
56
129
|
function extractReflection(reflection) {
|
|
57
130
|
if (!(0, _powerlines_deepkit_vendor_type.isType)(reflection)) return;
|
|
58
131
|
return require_reflection.reflectionToJsonSchema(reflection);
|
|
59
132
|
}
|
|
60
133
|
/**
|
|
61
|
-
* Extracts a JSON
|
|
62
|
-
*
|
|
63
|
-
* @remarks
|
|
64
|
-
* This function checks if the provided input is a Zod schema, a Standard JSON Schema, or already a JSON Schema object, extracts a JSON Schema fragment via the appropriate adapter (Zod and Standard Schema produce draft-07 fragments), and then converts that fragment into a valid JTD form suitable for AJV's JTD validator.
|
|
65
|
-
*
|
|
66
|
-
* @param schema - The schema definition to extract from. This can be a Zod schema, a Standard JSON Schema, or a JSON Schema object.
|
|
67
|
-
* @returns The extracted JTD schema if successful, otherwise undefined.
|
|
134
|
+
* Extracts a JSON Schema from Zod, Standard Schema, untyped, or JSON Schema inputs.
|
|
68
135
|
*/
|
|
69
136
|
function extractJsonSchema(schema) {
|
|
70
|
-
if ((0, _stryke_type_checks_is_set_object.isSetObject)(schema) && ((0, _stryke_zod.isZod3Type)(schema) || (0, _stryke_json.isStandardJsonSchema)(schema) ||
|
|
71
|
-
|
|
72
|
-
if ((0,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const jtd = require_jtd.jsonSchemaToJtd(jsonSchema);
|
|
77
|
-
if (jtd) return jtd;
|
|
137
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(schema) && ((0, _stryke_zod.isZod3Type)(schema) || (0, _stryke_json.isStandardJsonSchema)(schema) || require_type_checks.isJsonSchema(schema) || require_type_checks.isUntypedInput(schema) || require_type_checks.isUntypedSchema(schema))) {
|
|
138
|
+
if ((0, _stryke_zod.isZod3Type)(schema)) return (0, _stryke_zod.extractJsonSchema)(schema);
|
|
139
|
+
if ((0, _stryke_json.isStandardJsonSchema)(schema)) return schema["~standard"].jsonSchema.input({ target: "draft-2020-12" });
|
|
140
|
+
if (require_type_checks.isUntypedInput(schema)) return convertUntypedInputToJsonSchema(schema);
|
|
141
|
+
if (require_type_checks.isUntypedSchema(schema)) return convertUntypedSchemaToJsonSchema(schema);
|
|
142
|
+
return schema;
|
|
78
143
|
}
|
|
79
144
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Extracts a schema definition from a given input object, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, or a reflected Deepkit Type object. The function checks the type of the input and attempts to extract the corresponding schema based on its variant. If the input is a Zod schema, it extracts the JSON Schema using the `extractJsonSchema` function. If the input is a Standard JSON Schema, it retrieves the JSON Schema targeting draft-07. If the input is already a JSON Schema object, it uses it directly. If the input is a reflected Deepkit Type object, it extracts the schema using the `extractReflection` function. The function returns a `Schema` containing the extracted schema and its variant if successful; otherwise, it throws an error.
|
|
82
|
-
*
|
|
83
|
-
* @param input - The input object to extract the schema definition from.
|
|
84
|
-
* @returns A `Schema` containing the extracted schema and its variant if successful.
|
|
85
|
-
* @throws An error if the input does not contain a valid schema definition.
|
|
86
|
-
*/
|
|
87
145
|
function extractResolvedVariant(input) {
|
|
88
146
|
if ((0, _stryke_type_checks_is_set_object.isSetObject)(input)) {
|
|
89
147
|
if ((0, _stryke_zod.isZod3Type)(input)) return "zod3";
|
|
90
148
|
else if ((0, _stryke_json.isStandardJsonSchema)(input)) return "standard-schema";
|
|
91
|
-
else if (require_type_checks.
|
|
92
|
-
else if ((0, _stryke_json.isJsonSchemaObjectType)(input)) return "json-schema";
|
|
149
|
+
else if (require_type_checks.isJsonSchema(input)) return "json-schema";
|
|
93
150
|
else if ((0, _powerlines_deepkit_vendor_type.isType)(input)) return "reflection";
|
|
94
151
|
else if (require_type_checks.isUntypedInput(input) || require_type_checks.isUntypedSchema(input)) return "untyped";
|
|
95
152
|
}
|
|
96
153
|
throw new Error(`Failed to determine the variant of the provided schema definition input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a reflected Deepkit Type object, or an Untyped schema.`);
|
|
97
154
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Extracts a schema definition from a given input object, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, a reflected Deepkit Type object, or an Untyped schema. The function checks the type of the input and attempts to extract the corresponding schema based on its variant. If the input is a Zod schema, it extracts the JSON Schema using the `extractJsonSchema` function. If the input is a Standard JSON Schema, it retrieves the JSON Schema targeting draft-07. If the input is already a JSON Schema object, it uses it directly. If the input is a reflected Deepkit Type object, it extracts the schema using the `extractReflection` function. The function returns a `Schema` containing the extracted schema and its variant if successful; otherwise, it throws an error.
|
|
100
|
-
*
|
|
101
|
-
* @param input - The input object to extract the schema definition from.
|
|
102
|
-
* @returns A `Schema` containing the extracted schema and its variant if successful.
|
|
103
|
-
* @throws An error if the input does not contain a valid schema definition.
|
|
104
|
-
*/
|
|
105
155
|
function extractVariant(input) {
|
|
106
156
|
if ((0, _stryke_type_checks.isSetString)(input) || (0, _powerlines_core.isTypeDefinition)(input)) return "type-definition";
|
|
107
157
|
return extractResolvedVariant(input);
|
|
108
158
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Extracts a JSON Schema object from a given schema definition input. The input can be a Zod schema, a Standard JSON Schema, a JSON Schema object, or a reflected Deepkit Type object. The function checks the type of the input and attempts to extract the corresponding JSON Schema based on its variant. If the input is a Zod schema, it extracts the JSON Schema using the `extractJsonSchema` function. If the input is a Standard JSON Schema, it retrieves the JSON Schema targeting draft-07. If the input is already a JSON Schema object, it uses it directly. If the input is a reflected Deepkit Type object, it extracts the schema using the `extractReflection` function. The function returns the extracted JSON Schema if successful; otherwise, it throws an error.
|
|
111
|
-
*
|
|
112
|
-
* @param input - The schema definition input to extract the JSON Schema from. This can be a Zod schema, a Standard JSON Schema, a JSON Schema object, or a TypeScript type definition.
|
|
113
|
-
* @param variant - The variant of the schema definition to extract.
|
|
114
|
-
* @returns The extracted JSON Schema if successful.
|
|
115
|
-
* @throws An error if the input does not contain a valid schema definition.
|
|
116
|
-
*/
|
|
117
159
|
async function extractSchemaSchema(input, variant) {
|
|
118
160
|
if (require_type_checks.isExtractedSchema(input)) return input.schema;
|
|
119
161
|
const resolvedVariant = variant ?? extractResolvedVariant(input);
|
|
120
162
|
let schema;
|
|
121
|
-
if (resolvedVariant === "zod3" || resolvedVariant === "json-schema" || resolvedVariant === "standard-schema" || resolvedVariant === "untyped")
|
|
122
|
-
|
|
123
|
-
if (jsonSchema) schema = require_jtd.jsonSchemaToJtd(jsonSchema);
|
|
124
|
-
} else if (resolvedVariant === "reflection") schema = extractReflection(input);
|
|
125
|
-
else if (resolvedVariant === "jtd-schema") schema = input;
|
|
163
|
+
if (resolvedVariant === "zod3" || resolvedVariant === "json-schema" || resolvedVariant === "standard-schema" || resolvedVariant === "untyped") schema = extractJsonSchema(input);
|
|
164
|
+
else if (resolvedVariant === "reflection") schema = extractReflection(input);
|
|
126
165
|
if (schema) return schema;
|
|
127
|
-
throw new Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object,
|
|
166
|
+
throw new Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`);
|
|
128
167
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Extracts a schema definition from a given input object, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, a JTD schema, an untyped schema, or a reflected Deepkit Type object. The function checks the type of the input and attempts to extract the corresponding schema based on its variant. If the input is a Zod schema, it extracts the JSON Schema using the `extractJsonSchema` function. If the input is a Standard JSON Schema, it retrieves the JSON Schema targeting draft-07. If the input is already a JSON Schema object, it uses it directly. If the input is a reflected Deepkit Type object, it extracts the schema using the `extractReflection` function. The function returns a `Schema` containing the extracted schema and its variant if successful; otherwise, it throws an error.
|
|
131
|
-
*
|
|
132
|
-
* @param variant - The variant of the schema definition to extract.
|
|
133
|
-
* @param input - The input object to extract the schema definition from.
|
|
134
|
-
* @returns A `Schema` containing the extracted schema and its variant if successful.
|
|
135
|
-
* @throws An error if the input does not contain a valid schema definition.
|
|
136
|
-
*/
|
|
137
168
|
function extractSource(variant, input) {
|
|
138
169
|
if (variant === "zod3") return {
|
|
139
170
|
hash: extractHash(variant, input),
|
|
@@ -160,69 +191,70 @@ function extractSource(variant, input) {
|
|
|
160
191
|
variant: "reflection",
|
|
161
192
|
schema: input
|
|
162
193
|
};
|
|
163
|
-
|
|
164
|
-
hash: extractHash(variant, input),
|
|
165
|
-
variant: "jtd-schema",
|
|
166
|
-
schema: input
|
|
167
|
-
};
|
|
168
|
-
throw new Error(`Failed to extract source information from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, a JTD schema, an untyped schema, or a reflected Deepkit Type object.`);
|
|
194
|
+
throw new Error(`Failed to extract source information from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`);
|
|
169
195
|
}
|
|
170
196
|
/**
|
|
171
|
-
*
|
|
197
|
+
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object. If the input is a type definition reference (e.g. a file path with an export), it will be resolved and bundled using ESBuild to obtain the actual schema definition before extraction.
|
|
172
198
|
*
|
|
173
199
|
* @example
|
|
174
200
|
* ```ts
|
|
175
201
|
* // Resolve a schema definition from a file path
|
|
176
|
-
* const schema1 = await
|
|
202
|
+
* const schema1 = await extract(context, "./schemas.ts#MySchema");
|
|
177
203
|
* // Resolve a schema definition from a JSON Schema object
|
|
178
|
-
* const schema2 = await
|
|
204
|
+
* const schema2 = await extract(context, schemaObject);
|
|
179
205
|
* // Resolve a schema definition from a Zod schema
|
|
180
|
-
* const schema3 = await
|
|
206
|
+
* const schema3 = await extract(context, zodSchema);
|
|
181
207
|
* // Resolve a schema definition from a reflected Deepkit Type object
|
|
182
|
-
* const schema4 = await
|
|
208
|
+
* const schema4 = await extract(context, reflectionType);
|
|
183
209
|
* ```
|
|
184
210
|
*
|
|
185
|
-
* @
|
|
186
|
-
* @
|
|
187
|
-
* @
|
|
188
|
-
* @
|
|
211
|
+
* @see https://github.com/colinhacks/zod
|
|
212
|
+
* @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
|
|
213
|
+
* @see https://json-schema.org/
|
|
214
|
+
* @see https://ajv.js.org/json-type-definition.html
|
|
215
|
+
* @see https://deepkit.io/en/documentation/runtime-types/reflection
|
|
216
|
+
*
|
|
217
|
+
* @param context - The context object providing access to the file system and cache path.
|
|
218
|
+
* @param input - The schema definition input to extract, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object. If the input is a string or a type definition reference, it will be resolved and bundled to obtain the actual schema definition before extraction.
|
|
219
|
+
* @param options - Optional overrides for the ESBuild configuration used during extraction. This can include custom plugins, loaders, or other build options to control how the schema definition is resolved and bundled when the input is a type definition reference.
|
|
220
|
+
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object. The function will attempt to extract a valid JSON Schema from the provided input, and if successful, it will return the schema. If the extraction process fails or if the input is not a valid schema definition, it will throw an error indicating the failure.
|
|
189
221
|
*/
|
|
190
222
|
async function extractSchema(context, input, options = {}) {
|
|
191
223
|
if (require_type_checks.isExtractedSchema(input)) return input;
|
|
192
224
|
if (require_type_checks.isSchema(input)) return {
|
|
193
225
|
...input,
|
|
194
226
|
source: {
|
|
195
|
-
hash: extractHash("
|
|
196
|
-
variant: "
|
|
227
|
+
hash: extractHash("json-schema", input.schema),
|
|
228
|
+
variant: "json-schema",
|
|
197
229
|
schema: input.schema
|
|
198
230
|
}
|
|
199
231
|
};
|
|
200
232
|
let source;
|
|
201
233
|
const variant = extractVariant(input);
|
|
234
|
+
const hash = extractHash(variant, input);
|
|
202
235
|
if (variant === "type-definition") {
|
|
203
|
-
const resolved = await require_resolve.resolve(context, input, (0, defu.default)(options, { plugins: [(0,
|
|
236
|
+
const resolved = await require_resolve.resolve(context, input, (0, defu.default)(options, { plugins: [(0, _powerlines_deepkit_rolldown_plugin.rolldownPlugin)(context, {
|
|
204
237
|
reflection: "default",
|
|
205
238
|
level: "all"
|
|
206
239
|
})] }));
|
|
207
240
|
source = extractSource(extractResolvedVariant(resolved), resolved);
|
|
208
241
|
} else if ([
|
|
209
242
|
"json-schema",
|
|
210
|
-
"jtd-schema",
|
|
211
243
|
"standard-schema",
|
|
212
244
|
"zod3",
|
|
213
245
|
"untyped",
|
|
214
246
|
"reflection"
|
|
215
247
|
].includes(variant)) source = extractSource(variant, input);
|
|
216
|
-
else throw new Error(`Invalid schema definition input "${variant}". The variant must be one of "type-definition", "json-schema", "
|
|
248
|
+
else throw new Error(`Invalid schema definition input "${variant}". The variant must be one of "type-definition", "json-schema", "standard-schema", "zod3", "untyped", or "reflection".`);
|
|
217
249
|
return {
|
|
218
250
|
variant,
|
|
219
251
|
source,
|
|
220
252
|
schema: await extractSchemaSchema(source.schema, source.variant),
|
|
221
|
-
hash
|
|
253
|
+
hash
|
|
222
254
|
};
|
|
223
255
|
}
|
|
224
256
|
/**
|
|
225
|
-
*
|
|
257
|
+
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object. If the input is a type definition reference (e.g. a file path with an export), it will be resolved and bundled using ESBuild to obtain the actual schema definition before extraction.
|
|
226
258
|
*
|
|
227
259
|
* @example
|
|
228
260
|
* ```ts
|
|
@@ -244,13 +276,30 @@ async function extractSchema(context, input, options = {}) {
|
|
|
244
276
|
* @see https://github.com/unjs/untyped
|
|
245
277
|
* @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
|
|
246
278
|
*
|
|
247
|
-
* @param context - The
|
|
248
|
-
* @param input - The
|
|
249
|
-
* @param options - Optional overrides for the
|
|
250
|
-
* @returns A promise that resolves to
|
|
279
|
+
* @param context - The context object providing access to the file system and cache path.
|
|
280
|
+
* @param input - The schema definition input to extract, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object.
|
|
281
|
+
* @param options - Optional overrides for the ESBuild configuration used during extraction.
|
|
282
|
+
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object.
|
|
283
|
+
* @throws Will throw an error if the input is not a valid schema definition or if the extraction process fails to produce a valid schema.
|
|
251
284
|
*/
|
|
252
285
|
async function extract(context, input, options = {}) {
|
|
253
|
-
|
|
286
|
+
if (require_type_checks.isExtractedSchema(input) || require_type_checks.isSchema(input)) return input;
|
|
287
|
+
let result;
|
|
288
|
+
const variant = extractVariant(input);
|
|
289
|
+
const hash = extractHash(variant, input);
|
|
290
|
+
const cacheFilePath = (0, _stryke_path_join.joinPaths)(require_persistence.getCacheDirectory(context), `${hash}.json`);
|
|
291
|
+
if (context.config.skipCache !== true && context.fs.existsSync(cacheFilePath)) {
|
|
292
|
+
const schema = await context.fs.read(cacheFilePath);
|
|
293
|
+
if (schema) result = {
|
|
294
|
+
variant,
|
|
295
|
+
hash,
|
|
296
|
+
schema: JSON.parse(schema)
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
result ??= await extractSchema(context, input, options);
|
|
300
|
+
if (!result?.schema) throw new Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`);
|
|
301
|
+
if (context.config.skipCache !== true) await require_persistence.writeSchema(context, result);
|
|
302
|
+
return result;
|
|
254
303
|
}
|
|
255
304
|
|
|
256
305
|
//#endregion
|
package/dist/extract.d.cts
CHANGED
|
@@ -1,90 +1,54 @@
|
|
|
1
|
-
import { ExtractedSchema,
|
|
1
|
+
import { ExtractedSchema, JsonSchema, Schema, SchemaInput, SchemaInputVariant, SchemaSource, SchemaSourceInput, SchemaSourceVariant } from "./types.cjs";
|
|
2
2
|
import { Context } from "@powerlines/core";
|
|
3
|
-
import { BuildOptions } from "
|
|
3
|
+
import { BuildOptions } from "rolldown";
|
|
4
4
|
import { Type } from "@powerlines/deepkit/vendor/type";
|
|
5
5
|
|
|
6
6
|
//#region src/extract.d.ts
|
|
7
7
|
/**
|
|
8
|
-
* Creates a hash string for a given schema definition input.
|
|
8
|
+
* Creates a hash string for a given schema definition input.
|
|
9
9
|
*/
|
|
10
|
-
declare function extractHash(variant: SchemaInputVariant, input: SchemaInput): string;
|
|
10
|
+
declare function extractHash<T = unknown>(variant: SchemaInputVariant, input: SchemaInput<T>): string;
|
|
11
11
|
/**
|
|
12
|
-
* Converts a reflected Deepkit {@link
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* This function delegates to an internal recursive walker that handles the full set of Deepkit reflection kinds.
|
|
16
|
-
*
|
|
17
|
-
* @param reflection - The reflected Deepkit Type to convert.
|
|
18
|
-
* @returns A JSON Schema (draft-07) fragment representing the type, or `undefined` when no schema could be produced.
|
|
12
|
+
* Converts a reflected Deepkit {@link Type} into a JSON Schema (draft-07) representation.
|
|
19
13
|
*/
|
|
20
|
-
declare function extractReflection<
|
|
14
|
+
declare function extractReflection<T = unknown>(reflection: Type): JsonSchema<T> | undefined;
|
|
21
15
|
/**
|
|
22
|
-
* Extracts a JSON
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* This function checks if the provided input is a Zod schema, a Standard JSON Schema, or already a JSON Schema object, extracts a JSON Schema fragment via the appropriate adapter (Zod and Standard Schema produce draft-07 fragments), and then converts that fragment into a valid JTD form suitable for AJV's JTD validator.
|
|
26
|
-
*
|
|
27
|
-
* @param schema - The schema definition to extract from. This can be a Zod schema, a Standard JSON Schema, or a JSON Schema object.
|
|
28
|
-
* @returns The extracted JTD schema if successful, otherwise undefined.
|
|
29
|
-
*/
|
|
30
|
-
declare function extractJsonSchema<TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>>(schema: unknown): JTDSchemaType<TMetadata> | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* Extracts a schema definition from a given input object, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, or a reflected Deepkit Type object. The function checks the type of the input and attempts to extract the corresponding schema based on its variant. If the input is a Zod schema, it extracts the JSON Schema using the `extractJsonSchema` function. If the input is a Standard JSON Schema, it retrieves the JSON Schema targeting draft-07. If the input is already a JSON Schema object, it uses it directly. If the input is a reflected Deepkit Type object, it extracts the schema using the `extractReflection` function. The function returns a `Schema` containing the extracted schema and its variant if successful; otherwise, it throws an error.
|
|
33
|
-
*
|
|
34
|
-
* @param input - The input object to extract the schema definition from.
|
|
35
|
-
* @returns A `Schema` containing the extracted schema and its variant if successful.
|
|
36
|
-
* @throws An error if the input does not contain a valid schema definition.
|
|
16
|
+
* Extracts a JSON Schema from Zod, Standard Schema, untyped, or JSON Schema inputs.
|
|
37
17
|
*/
|
|
18
|
+
declare function extractJsonSchema<T = unknown>(schema: unknown): JsonSchema<T> | undefined;
|
|
38
19
|
declare function extractResolvedVariant(input: SchemaSourceInput): SchemaSourceVariant;
|
|
20
|
+
declare function extractVariant<T = unknown>(input: SchemaInput<T>): SchemaInputVariant;
|
|
21
|
+
declare function extractSchemaSchema<T = unknown>(input: SchemaSourceInput, variant?: SchemaInputVariant): Promise<JsonSchema<T>>;
|
|
22
|
+
declare function extractSource(variant: SchemaSourceVariant, input: SchemaSourceInput): SchemaSource;
|
|
39
23
|
/**
|
|
40
|
-
* Extracts a
|
|
41
|
-
*
|
|
42
|
-
* @param input - The input object to extract the schema definition from.
|
|
43
|
-
* @returns A `Schema` containing the extracted schema and its variant if successful.
|
|
44
|
-
* @throws An error if the input does not contain a valid schema definition.
|
|
45
|
-
*/
|
|
46
|
-
declare function extractVariant(input: SchemaInput): SchemaInputVariant;
|
|
47
|
-
/**
|
|
48
|
-
* Extracts a JSON Schema object from a given schema definition input. The input can be a Zod schema, a Standard JSON Schema, a JSON Schema object, or a reflected Deepkit Type object. The function checks the type of the input and attempts to extract the corresponding JSON Schema based on its variant. If the input is a Zod schema, it extracts the JSON Schema using the `extractJsonSchema` function. If the input is a Standard JSON Schema, it retrieves the JSON Schema targeting draft-07. If the input is already a JSON Schema object, it uses it directly. If the input is a reflected Deepkit Type object, it extracts the schema using the `extractReflection` function. The function returns the extracted JSON Schema if successful; otherwise, it throws an error.
|
|
49
|
-
*
|
|
50
|
-
* @param input - The schema definition input to extract the JSON Schema from. This can be a Zod schema, a Standard JSON Schema, a JSON Schema object, or a TypeScript type definition.
|
|
51
|
-
* @param variant - The variant of the schema definition to extract.
|
|
52
|
-
* @returns The extracted JSON Schema if successful.
|
|
53
|
-
* @throws An error if the input does not contain a valid schema definition.
|
|
54
|
-
*/
|
|
55
|
-
declare function extractSchemaSchema<TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>>(input: SchemaSourceInput, variant?: SchemaInputVariant): Promise<JTDSchemaType<TMetadata>>;
|
|
56
|
-
/**
|
|
57
|
-
* Extracts a schema definition from a given input object, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, a JTD schema, an untyped schema, or a reflected Deepkit Type object. The function checks the type of the input and attempts to extract the corresponding schema based on its variant. If the input is a Zod schema, it extracts the JSON Schema using the `extractJsonSchema` function. If the input is a Standard JSON Schema, it retrieves the JSON Schema targeting draft-07. If the input is already a JSON Schema object, it uses it directly. If the input is a reflected Deepkit Type object, it extracts the schema using the `extractReflection` function. The function returns a `Schema` containing the extracted schema and its variant if successful; otherwise, it throws an error.
|
|
58
|
-
*
|
|
59
|
-
* @param variant - The variant of the schema definition to extract.
|
|
60
|
-
* @param input - The input object to extract the schema definition from.
|
|
61
|
-
* @returns A `Schema` containing the extracted schema and its variant if successful.
|
|
62
|
-
* @throws An error if the input does not contain a valid schema definition.
|
|
63
|
-
*/
|
|
64
|
-
declare function extractSource<TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>>(variant: SchemaSourceVariant, input: SchemaSourceInput): SchemaSource;
|
|
65
|
-
/**
|
|
66
|
-
* Resolves the provided entry points to their corresponding type definitions. The function accepts an array of entry points, which can be strings (file paths) or type definition objects. It processes each entry point, resolving file paths and glob patterns to find matching files. For each resolved file, it creates a type definition object and resolves it using the `resolveInput` function. The function returns an array of resolved entry type definitions.
|
|
24
|
+
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object. If the input is a type definition reference (e.g. a file path with an export), it will be resolved and bundled using ESBuild to obtain the actual schema definition before extraction.
|
|
67
25
|
*
|
|
68
26
|
* @example
|
|
69
27
|
* ```ts
|
|
70
28
|
* // Resolve a schema definition from a file path
|
|
71
|
-
* const schema1 = await
|
|
29
|
+
* const schema1 = await extract(context, "./schemas.ts#MySchema");
|
|
72
30
|
* // Resolve a schema definition from a JSON Schema object
|
|
73
|
-
* const schema2 = await
|
|
31
|
+
* const schema2 = await extract(context, schemaObject);
|
|
74
32
|
* // Resolve a schema definition from a Zod schema
|
|
75
|
-
* const schema3 = await
|
|
33
|
+
* const schema3 = await extract(context, zodSchema);
|
|
76
34
|
* // Resolve a schema definition from a reflected Deepkit Type object
|
|
77
|
-
* const schema4 = await
|
|
35
|
+
* const schema4 = await extract(context, reflectionType);
|
|
78
36
|
* ```
|
|
79
37
|
*
|
|
80
|
-
* @
|
|
81
|
-
* @
|
|
82
|
-
* @
|
|
83
|
-
* @
|
|
38
|
+
* @see https://github.com/colinhacks/zod
|
|
39
|
+
* @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
|
|
40
|
+
* @see https://json-schema.org/
|
|
41
|
+
* @see https://ajv.js.org/json-type-definition.html
|
|
42
|
+
* @see https://deepkit.io/en/documentation/runtime-types/reflection
|
|
43
|
+
*
|
|
44
|
+
* @param context - The context object providing access to the file system and cache path.
|
|
45
|
+
* @param input - The schema definition input to extract, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object. If the input is a string or a type definition reference, it will be resolved and bundled to obtain the actual schema definition before extraction.
|
|
46
|
+
* @param options - Optional overrides for the ESBuild configuration used during extraction. This can include custom plugins, loaders, or other build options to control how the schema definition is resolved and bundled when the input is a type definition reference.
|
|
47
|
+
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object. The function will attempt to extract a valid JSON Schema from the provided input, and if successful, it will return the schema. If the extraction process fails or if the input is not a valid schema definition, it will throw an error indicating the failure.
|
|
84
48
|
*/
|
|
85
|
-
declare function extractSchema<
|
|
49
|
+
declare function extractSchema<T = unknown>(context: Context, input: SchemaInput, options?: Partial<BuildOptions>): Promise<ExtractedSchema<T>>;
|
|
86
50
|
/**
|
|
87
|
-
*
|
|
51
|
+
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object. If the input is a type definition reference (e.g. a file path with an export), it will be resolved and bundled using ESBuild to obtain the actual schema definition before extraction.
|
|
88
52
|
*
|
|
89
53
|
* @example
|
|
90
54
|
* ```ts
|
|
@@ -106,12 +70,13 @@ declare function extractSchema<TMetadata extends Partial<SchemaMetadata> = Parti
|
|
|
106
70
|
* @see https://github.com/unjs/untyped
|
|
107
71
|
* @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
|
|
108
72
|
*
|
|
109
|
-
* @param context - The
|
|
110
|
-
* @param input - The
|
|
111
|
-
* @param options - Optional overrides for the
|
|
112
|
-
* @returns A promise that resolves to
|
|
73
|
+
* @param context - The context object providing access to the file system and cache path.
|
|
74
|
+
* @param input - The schema definition input to extract, which can be a Zod schema, a Standard JSON Schema, a JSON Schema object, an untyped schema, or a reflected Deepkit Type object.
|
|
75
|
+
* @param options - Optional overrides for the ESBuild configuration used during extraction.
|
|
76
|
+
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object.
|
|
77
|
+
* @throws Will throw an error if the input is not a valid schema definition or if the extraction process fails to produce a valid schema.
|
|
113
78
|
*/
|
|
114
|
-
declare function extract<
|
|
79
|
+
declare function extract<T = unknown>(context: Context, input: SchemaInput, options?: Partial<BuildOptions>): Promise<Schema<T>>;
|
|
115
80
|
//#endregion
|
|
116
81
|
export { extract, extractHash, extractJsonSchema, extractReflection, extractResolvedVariant, extractSchema, extractSchemaSchema, extractSource, extractVariant };
|
|
117
82
|
//# sourceMappingURL=extract.d.cts.map
|
package/dist/extract.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.cts","names":[],"sources":["../src/extract.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"extract.d.cts","names":[],"sources":["../src/extract.ts"],"mappings":";;;;;;;;AAiNA;iBAAgB,WAAA,aAAA,CACd,OAAA,EAAS,kBAAA,EACT,KAAA,EAAO,WAAA,CAAY,CAAA;;;;iBAkCL,iBAAA,aAAA,CACd,UAAA,EAAY,IAAA,GACX,UAAA,CAAW,CAAA;;;;iBAWE,iBAAA,aAAA,CACd,MAAA,YACC,UAAU,CAAC,CAAA;AAAA,iBA6BE,sBAAA,CACd,KAAA,EAAO,iBAAA,GACN,mBAAmB;AAAA,iBAoBN,cAAA,aAAA,CACd,KAAA,EAAO,WAAA,CAAY,CAAA,IAClB,kBAAA;AAAA,iBAQmB,mBAAA,aAAA,CACpB,KAAA,EAAO,iBAAA,EACP,OAAA,GAAU,kBAAA,GACT,OAAA,CAAQ,UAAA,CAAW,CAAA;AAAA,iBA4BN,aAAA,CACd,OAAA,EAAS,mBAAA,EACT,KAAA,EAAO,iBAAA,GACN,YAAA;;AAhJoB;AAkCvB;;;;;;;;;;;;;;AAEe;AAWf;;;;;;;;;iBAiKsB,aAAA,aAAA,CACpB,OAAA,EAAS,OAAA,EACT,KAAA,EAAO,WAAA,EACP,OAAA,GAAS,OAAA,CAAQ,YAAA,IAChB,OAAA,CAAQ,eAAA,CAAgB,CAAA;AAtI3B;;;;;;;;AAEsB;AAoBtB;;;;;;;;;;;;;;AAEqB;AAQrB;;;;;AAhCA,iBAiOsB,OAAA,aAAA,CACpB,OAAA,EAAS,OAAA,EACT,KAAA,EAAO,WAAA,EACP,OAAA,GAAS,OAAA,CAAQ,YAAA,IAChB,OAAA,CAAQ,MAAA,CAAO,CAAA"}
|