@powerlines/schema 0.11.28 → 0.11.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/bundle.cjs +34 -20
  2. package/dist/bundle.d.cts +3 -3
  3. package/dist/bundle.d.cts.map +1 -1
  4. package/dist/bundle.d.mts +3 -3
  5. package/dist/bundle.d.mts.map +1 -1
  6. package/dist/bundle.mjs +35 -21
  7. package/dist/bundle.mjs.map +1 -1
  8. package/dist/codegen.cjs +55 -8
  9. package/dist/codegen.d.cts +12 -6
  10. package/dist/codegen.d.cts.map +1 -1
  11. package/dist/codegen.d.mts +12 -6
  12. package/dist/codegen.d.mts.map +1 -1
  13. package/dist/codegen.mjs +52 -8
  14. package/dist/codegen.mjs.map +1 -1
  15. package/dist/constants.cjs +42 -0
  16. package/dist/constants.d.cts +15 -0
  17. package/dist/constants.d.cts.map +1 -0
  18. package/dist/constants.d.mts +15 -0
  19. package/dist/constants.d.mts.map +1 -0
  20. package/dist/constants.mjs +39 -0
  21. package/dist/constants.mjs.map +1 -0
  22. package/dist/extract.cjs +144 -95
  23. package/dist/extract.d.cts +34 -69
  24. package/dist/extract.d.cts.map +1 -1
  25. package/dist/extract.d.mts +34 -69
  26. package/dist/extract.d.mts.map +1 -1
  27. package/dist/extract.mjs +144 -95
  28. package/dist/extract.mjs.map +1 -1
  29. package/dist/helpers.cjs +87 -0
  30. package/dist/helpers.d.cts +48 -0
  31. package/dist/helpers.d.cts.map +1 -0
  32. package/dist/helpers.d.mts +48 -0
  33. package/dist/helpers.d.mts.map +1 -0
  34. package/dist/helpers.mjs +84 -0
  35. package/dist/helpers.mjs.map +1 -0
  36. package/dist/index.cjs +29 -5
  37. package/dist/index.d.cts +8 -5
  38. package/dist/index.d.mts +8 -5
  39. package/dist/index.mjs +7 -4
  40. package/dist/metadata.cjs +80 -0
  41. package/dist/metadata.d.cts +52 -0
  42. package/dist/metadata.d.cts.map +1 -0
  43. package/dist/metadata.d.mts +52 -0
  44. package/dist/metadata.d.mts.map +1 -0
  45. package/dist/metadata.mjs +76 -0
  46. package/dist/metadata.mjs.map +1 -0
  47. package/dist/persistence.cjs +75 -0
  48. package/dist/persistence.d.cts +47 -0
  49. package/dist/persistence.d.cts.map +1 -0
  50. package/dist/persistence.d.mts +47 -0
  51. package/dist/persistence.d.mts.map +1 -0
  52. package/dist/persistence.mjs +71 -0
  53. package/dist/persistence.mjs.map +1 -0
  54. package/dist/reflection.cjs +292 -299
  55. package/dist/reflection.d.cts +3 -16
  56. package/dist/reflection.d.cts.map +1 -1
  57. package/dist/reflection.d.mts +3 -16
  58. package/dist/reflection.d.mts.map +1 -1
  59. package/dist/reflection.mjs +291 -299
  60. package/dist/reflection.mjs.map +1 -1
  61. package/dist/resolve.cjs +7 -7
  62. package/dist/resolve.mjs +7 -7
  63. package/dist/resolve.mjs.map +1 -1
  64. package/dist/type-checks.cjs +126 -25
  65. package/dist/type-checks.d.cts +45 -23
  66. package/dist/type-checks.d.cts.map +1 -1
  67. package/dist/type-checks.d.mts +45 -23
  68. package/dist/type-checks.d.mts.map +1 -1
  69. package/dist/type-checks.mjs +125 -25
  70. package/dist/type-checks.mjs.map +1 -1
  71. package/dist/types.d.cts +237 -95
  72. package/dist/types.d.cts.map +1 -1
  73. package/dist/types.d.mts +237 -95
  74. package/dist/types.d.mts.map +1 -1
  75. package/package.json +24 -8
  76. package/dist/jtd.cjs +0 -385
  77. package/dist/jtd.d.cts +0 -15
  78. package/dist/jtd.d.cts.map +0 -1
  79. package/dist/jtd.d.mts +0 -15
  80. package/dist/jtd.d.mts.map +0 -1
  81. package/dist/jtd.mjs +0 -384
  82. 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 require_jtd = require('./jtd.cjs');
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 _powerlines_deepkit_esbuild_plugin = require("@powerlines/deepkit/esbuild-plugin");
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 _stryke_json = require("@stryke/json");
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. The function checks the type of the input and generates a hash based on its content. If the input is a Zod schema, it hashes the JSON representation of its internal definition. If the input is a Standard JSON Schema, it hashes the JSON representation of its internal standard schema. If the input is already a JSON Schema object, it hashes its JSON representation directly. If the input is a reflected Deepkit Type object, it hashes its JSON representation. The resulting hash string can be used for caching or comparison purposes.
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 ((0, _stryke_json.isJsonSchemaObjectType)(input)) return (0, _stryke_hash.murmurhash)({
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 @powerlines/deepkit/vendor/type#Type} into a JSON Schema (draft-07) representation.
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 Type Definition (RFC 8927) schema from a given schema definition, if possible.
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) || (0, _stryke_json.isJsonSchemaObjectType)(schema) || require_type_checks.isUntypedInput(schema) || require_type_checks.isUntypedSchema(schema))) {
71
- let jsonSchema;
72
- if ((0, _stryke_zod.isZod3Type)(schema)) jsonSchema = (0, _stryke_zod.extractJsonSchema)(schema);
73
- else if ((0, _stryke_json.isStandardJsonSchema)(schema)) jsonSchema = schema["~standard"].jsonSchema.input({ target: "draft-2020-12" });
74
- else if (require_type_checks.isUntypedInput(schema)) jsonSchema = schema.$schema;
75
- else jsonSchema = schema;
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.isJTDSchema(input)) return "jtd-schema";
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
- const jsonSchema = extractJsonSchema(input);
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, a JTD schema, an untyped schema, or a reflected Deepkit Type 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
- else if (variant === "jtd-schema") return {
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
- * 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.
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 extractSchema(context, "./schemas.ts#MySchema");
202
+ * const schema1 = await extract(context, "./schemas.ts#MySchema");
177
203
  * // Resolve a schema definition from a JSON Schema object
178
- * const schema2 = await extractSchema(context, schemaObject);
204
+ * const schema2 = await extract(context, schemaObject);
179
205
  * // Resolve a schema definition from a Zod schema
180
- * const schema3 = await extractSchema(context, zodSchema);
206
+ * const schema3 = await extract(context, zodSchema);
181
207
  * // Resolve a schema definition from a reflected Deepkit Type object
182
- * const schema4 = await extractSchema(context, reflectionType);
208
+ * const schema4 = await extract(context, reflectionType);
183
209
  * ```
184
210
  *
185
- * @param context - The plugin context used for resolving the schema definition input.
186
- * @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.
187
- * @param options - Optional overrides for the ESBuild configuration used during resolution.
188
- * @returns A promise that resolves to a {@link ExtractedSchema} containing the extracted JSON Schema and its variant, or the bytecode if JSON Schema extraction is not possible.
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("jtd-schema", input.schema),
196
- variant: "jtd-schema",
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, _powerlines_deepkit_esbuild_plugin.esbuildPlugin)(context, {
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", "jtd-schema", "standard-schema", "zod3", "untyped", or "reflection".`);
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: extractHash(variant, input)
253
+ hash
222
254
  };
223
255
  }
224
256
  /**
225
- * 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.
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 {@link Context | context} used for resolving the {@link Schema | schema} definition input.
248
- * @param input - The input object or string to extract the {@link Schema | schema} from. This can be {@link TypeDefinitionReference | a string that references a Typescript module}, a [Zod v3 schema](https://github.com/colinhacks/zod), any type that adheres to [the Standard JSON Schema specification](https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec), a [JSON Schema object](https://json-schema.org/), a [JTD schema object](https://ajv.js.org/json-type-definition.html), an [untyped schema](https://github.com/unjs/untyped), or a [TypeScript type reflection](https://deepkit.io/en/documentation/runtime-types/reflection).
249
- * @param options - Optional overrides for the [ESBuild configuration](https://esbuild.github.io/api/#general-options) used during resolution.
250
- * @returns A promise that resolves to a {@link Schema | schema} object parsed from the input.
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
- return await extractSchema(context, input, options);
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
@@ -1,90 +1,54 @@
1
- import { ExtractedSchema, JTDSchemaType, Schema, SchemaInput, SchemaInputVariant, SchemaMetadata, SchemaSource, SchemaSourceInput, SchemaSourceVariant } from "./types.cjs";
1
+ import { ExtractedSchema, JsonSchema, Schema, SchemaInput, SchemaInputVariant, SchemaSource, SchemaSourceInput, SchemaSourceVariant } from "./types.cjs";
2
2
  import { Context } from "@powerlines/core";
3
- import { BuildOptions } from "esbuild";
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. The function checks the type of the input and generates a hash based on its content. If the input is a Zod schema, it hashes the JSON representation of its internal definition. If the input is a Standard JSON Schema, it hashes the JSON representation of its internal standard schema. If the input is already a JSON Schema object, it hashes its JSON representation directly. If the input is a reflected Deepkit Type object, it hashes its JSON representation. The resulting hash string can be used for caching or comparison purposes.
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 @powerlines/deepkit/vendor/type#Type} into a JSON Schema (draft-07) representation.
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<TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>>(reflection: Type): JTDSchemaType<TMetadata> | undefined;
14
+ declare function extractReflection<T = unknown>(reflection: Type): JsonSchema<T> | undefined;
21
15
  /**
22
- * Extracts a JSON Type Definition (RFC 8927) schema from a given schema definition, if possible.
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 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.
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 extractSchema(context, "./schemas.ts#MySchema");
29
+ * const schema1 = await extract(context, "./schemas.ts#MySchema");
72
30
  * // Resolve a schema definition from a JSON Schema object
73
- * const schema2 = await extractSchema(context, schemaObject);
31
+ * const schema2 = await extract(context, schemaObject);
74
32
  * // Resolve a schema definition from a Zod schema
75
- * const schema3 = await extractSchema(context, zodSchema);
33
+ * const schema3 = await extract(context, zodSchema);
76
34
  * // Resolve a schema definition from a reflected Deepkit Type object
77
- * const schema4 = await extractSchema(context, reflectionType);
35
+ * const schema4 = await extract(context, reflectionType);
78
36
  * ```
79
37
  *
80
- * @param context - The plugin context used for resolving the schema definition input.
81
- * @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.
82
- * @param options - Optional overrides for the ESBuild configuration used during resolution.
83
- * @returns A promise that resolves to a {@link ExtractedSchema} containing the extracted JSON Schema and its variant, or the bytecode if JSON Schema extraction is not possible.
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<TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>, TContext extends Context = Context>(context: TContext, input: SchemaInput, options?: Partial<BuildOptions>): Promise<ExtractedSchema<TMetadata>>;
49
+ declare function extractSchema<T = unknown>(context: Context, input: SchemaInput, options?: Partial<BuildOptions>): Promise<ExtractedSchema<T>>;
86
50
  /**
87
- * 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.
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 {@link Context | context} used for resolving the {@link Schema | schema} definition input.
110
- * @param input - The input object or string to extract the {@link Schema | schema} from. This can be {@link TypeDefinitionReference | a string that references a Typescript module}, a [Zod v3 schema](https://github.com/colinhacks/zod), any type that adheres to [the Standard JSON Schema specification](https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec), a [JSON Schema object](https://json-schema.org/), a [JTD schema object](https://ajv.js.org/json-type-definition.html), an [untyped schema](https://github.com/unjs/untyped), or a [TypeScript type reflection](https://deepkit.io/en/documentation/runtime-types/reflection).
111
- * @param options - Optional overrides for the [ESBuild configuration](https://esbuild.github.io/api/#general-options) used during resolution.
112
- * @returns A promise that resolves to a {@link Schema | schema} object parsed from the input.
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<TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>, TContext extends Context = Context>(context: TContext, input: SchemaInput, options?: Partial<BuildOptions>): Promise<Schema<TMetadata>>;
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
@@ -1 +1 @@
1
- {"version":3,"file":"extract.d.cts","names":[],"sources":["../src/extract.ts"],"mappings":";;;;;;;;AAmEA;iBAAgB,WAAA,CACd,OAAA,EAAS,kBAAA,EACT,KAAA,EAAO,WAAA;;;;;;;;;AA8BT;iBAAgB,iBAAA,mBACI,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,cAAA,EAAA,CACpD,UAAA,EAAY,IAAA,GAAO,aAAA,CAAc,SAAA;;;;;;;;;;iBAiBnB,iBAAA,mBACI,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,cAAA,EAAA,CACpD,MAAA,YAAkB,aAAA,CAAc,SAAA;;;;;;;;iBAsClB,sBAAA,CACd,KAAA,EAAO,iBAAA,GACN,mBAAA;;;;AA1CH;;;;iBAuEgB,cAAA,CAAe,KAAA,EAAO,WAAA,GAAc,kBAAA;;;;;;;;;iBAgB9B,mBAAA,mBACF,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,cAAA,EAAA,CAEpD,KAAA,EAAO,iBAAA,EACP,OAAA,GAAU,kBAAA,GACT,OAAA,CAAQ,aAAA,CAAc,SAAA;;;;;;;;AApDzB;iBA6FgB,aAAA,mBACI,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,cAAA,EAAA,CACpD,OAAA,EAAS,mBAAA,EAAqB,KAAA,EAAO,iBAAA,GAAoB,YAAA;;;;;;;;AAhE3D;;;;;;;;;AAgBA;;;;iBAgHsB,aAAA,mBACF,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,cAAA,oBACnC,OAAA,GAAU,OAAA,CAAA,CAE3B,OAAA,EAAS,QAAA,EACT,KAAA,EAAO,WAAA,EACP,OAAA,GAAS,OAAA,CAAQ,YAAA,IAChB,OAAA,CAAQ,eAAA,CAAgB,SAAA;;;;;;;;;;;;;;;;;;;;;;;;AAzE3B;;;;;iBAkKsB,OAAA,mBACF,OAAA,CAAQ,cAAA,IAAkB,OAAA,CAAQ,cAAA,oBACnC,OAAA,GAAU,OAAA,CAAA,CAE3B,OAAA,EAAS,QAAA,EACT,KAAA,EAAO,WAAA,EACP,OAAA,GAAS,OAAA,CAAQ,YAAA,IAChB,OAAA,CAAQ,MAAA,CAAO,SAAA"}
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"}