@powerlines/schema 0.11.71 → 0.11.73

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 (86) hide show
  1. package/dist/index.cjs +2111 -97
  2. package/dist/index.d.cts +1841 -11
  3. package/dist/index.d.cts.map +1 -1
  4. package/dist/index.d.mts +1841 -13
  5. package/dist/index.d.mts.map +1 -1
  6. package/dist/index.mjs +1999 -15
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +14 -14
  9. package/dist/_virtual/_rolldown/runtime.cjs +0 -37
  10. package/dist/bundle.cjs +0 -55
  11. package/dist/bundle.d.cts +0 -21
  12. package/dist/bundle.d.cts.map +0 -1
  13. package/dist/bundle.d.mts +0 -23
  14. package/dist/bundle.d.mts.map +0 -1
  15. package/dist/bundle.mjs +0 -54
  16. package/dist/bundle.mjs.map +0 -1
  17. package/dist/codegen.cjs +0 -81
  18. package/dist/codegen.d.cts +0 -26
  19. package/dist/codegen.d.cts.map +0 -1
  20. package/dist/codegen.d.mts +0 -28
  21. package/dist/codegen.d.mts.map +0 -1
  22. package/dist/codegen.mjs +0 -77
  23. package/dist/codegen.mjs.map +0 -1
  24. package/dist/constants.cjs +0 -69
  25. package/dist/constants.d.cts +0 -17
  26. package/dist/constants.d.cts.map +0 -1
  27. package/dist/constants.d.mts +0 -19
  28. package/dist/constants.d.mts.map +0 -1
  29. package/dist/constants.mjs +0 -65
  30. package/dist/constants.mjs.map +0 -1
  31. package/dist/extract.cjs +0 -490
  32. package/dist/extract.d.cts +0 -125
  33. package/dist/extract.d.cts.map +0 -1
  34. package/dist/extract.d.mts +0 -127
  35. package/dist/extract.d.mts.map +0 -1
  36. package/dist/extract.mjs +0 -480
  37. package/dist/extract.mjs.map +0 -1
  38. package/dist/helpers.cjs +0 -171
  39. package/dist/helpers.d.cts +0 -111
  40. package/dist/helpers.d.cts.map +0 -1
  41. package/dist/helpers.d.mts +0 -113
  42. package/dist/helpers.d.mts.map +0 -1
  43. package/dist/helpers.mjs +0 -164
  44. package/dist/helpers.mjs.map +0 -1
  45. package/dist/metadata.cjs +0 -61
  46. package/dist/metadata.d.cts +0 -31
  47. package/dist/metadata.d.cts.map +0 -1
  48. package/dist/metadata.d.mts +0 -33
  49. package/dist/metadata.d.mts.map +0 -1
  50. package/dist/metadata.mjs +0 -60
  51. package/dist/metadata.mjs.map +0 -1
  52. package/dist/persistence.cjs +0 -82
  53. package/dist/persistence.d.cts +0 -47
  54. package/dist/persistence.d.cts.map +0 -1
  55. package/dist/persistence.d.mts +0 -49
  56. package/dist/persistence.d.mts.map +0 -1
  57. package/dist/persistence.mjs +0 -79
  58. package/dist/persistence.mjs.map +0 -1
  59. package/dist/reflection.cjs +0 -434
  60. package/dist/reflection.d.cts +0 -11
  61. package/dist/reflection.d.cts.map +0 -1
  62. package/dist/reflection.d.mts +0 -13
  63. package/dist/reflection.d.mts.map +0 -1
  64. package/dist/reflection.mjs +0 -433
  65. package/dist/reflection.mjs.map +0 -1
  66. package/dist/resolve.cjs +0 -113
  67. package/dist/resolve.d.cts +0 -36
  68. package/dist/resolve.d.cts.map +0 -1
  69. package/dist/resolve.d.mts +0 -38
  70. package/dist/resolve.d.mts.map +0 -1
  71. package/dist/resolve.mjs +0 -110
  72. package/dist/resolve.mjs.map +0 -1
  73. package/dist/type-checks.cjs +0 -642
  74. package/dist/type-checks.d.cts +0 -316
  75. package/dist/type-checks.d.cts.map +0 -1
  76. package/dist/type-checks.d.mts +0 -318
  77. package/dist/type-checks.d.mts.map +0 -1
  78. package/dist/type-checks.mjs +0 -603
  79. package/dist/type-checks.mjs.map +0 -1
  80. package/dist/types.d.cts +0 -1152
  81. package/dist/types.d.cts.map +0 -1
  82. package/dist/types.d.mts +0 -1154
  83. package/dist/types.d.mts.map +0 -1
  84. package/dist/validate.cjs +0 -35
  85. package/dist/validate.mjs +0 -33
  86. package/dist/validate.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,20 +1,2004 @@
1
+ import { createUnpluginResolver } from "@powerlines/core/lib/unplugin";
2
+ import { resolveOptions } from "@powerlines/unplugin/esbuild";
3
+ import { omit } from "@stryke/helpers/omit";
4
+ import { findFileName } from "@stryke/path/file-path-fns";
5
+ import defu, { defu as defu$1 } from "defu";
6
+ import { build } from "esbuild";
7
+ import { createEsbuildPlugin } from "unplugin";
8
+ import { toBool } from "@stryke/convert/to-bool";
9
+ import { isBigInt, isBoolean, isFunction, isInteger, isNull, isNumber, isObject, isRegExp, isSetArray, isSetObject, isSetString, isString, isUndefined } from "@stryke/type-checks";
10
+ import { isBoolean as isBoolean$1 } from "@stryke/type-checks/is-boolean";
11
+ import { isNull as isNull$1 } from "@stryke/type-checks/is-null";
12
+ import { isNumber as isNumber$1 } from "@stryke/type-checks/is-number";
13
+ import { isSetString as isSetString$1 } from "@stryke/type-checks/is-set-string";
14
+ import { isUndefined as isUndefined$1 } from "@stryke/type-checks/is-undefined";
15
+ import standaloneCode from "ajv/dist/standalone/index.js";
16
+ import { getUnique } from "@stryke/helpers/get-unique";
17
+ import { findFileDotExtension, findFileExtensionSafe } from "@stryke/path/find";
18
+ import { isSetObject as isSetObject$1 } from "@stryke/type-checks/is-set-object";
19
+ import Ajv from "ajv";
20
+ import addFormats from "ajv-formats";
21
+ import { isFileReference } from "@powerlines/core";
22
+ import { esbuildPlugin } from "@powerlines/deepkit/esbuild-plugin";
23
+ import { ReflectionClass, ReflectionKind, TypeNumberBrand, deserializeType, isType, reflect, stringifyType as stringifyType$1 } from "@powerlines/deepkit/vendor/type";
24
+ import { extractFileReference } from "@stryke/convert/extract-file-reference";
25
+ import { murmurhash } from "@stryke/hash";
26
+ import { deepClone } from "@stryke/helpers/deep-clone";
27
+ import { isStandardJsonSchema } from "@stryke/json";
28
+ import { joinPaths } from "@stryke/path/join";
29
+ import { list } from "@stryke/string-format/list";
30
+ import { extractJsonSchema as extractJsonSchema$1, isZod3Type } from "@stryke/zod";
31
+ import { toJsonSchema } from "@valibot/to-json-schema";
32
+ import { parse } from "smol-toml";
33
+ import { parse as parse$1 } from "yaml";
1
34
 
35
+ //#region src/bundle.ts
36
+ /**
37
+ * Bundle a type definition to a module.
38
+ *
39
+ * @param context - The context object containing the environment paths.
40
+ * @param file - The file path to bundle.
41
+ * @param options - Optional overrides for the ESBuild configuration.
42
+ * @returns A promise that resolves to the bundled module.
43
+ */
44
+ async function bundle(context, file, options = {}) {
45
+ const path = await context.fs.resolve(file);
46
+ if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
47
+ const result = await build(defu({
48
+ entryPoints: [path],
49
+ write: false,
50
+ sourcemap: false,
51
+ splitting: false,
52
+ treeShaking: true,
53
+ bundle: true,
54
+ packages: "bundle",
55
+ platform: "node",
56
+ logLevel: "silent",
57
+ ...omit(options, ["name", "resolve"])
58
+ }, resolveOptions(context), { plugins: [createEsbuildPlugin(createUnpluginResolver(context, {
59
+ name: options.name ?? `${findFileName(file)} Bundler`,
60
+ prefix: false,
61
+ overrides: defu(options.resolve ?? {}, { skipNodeModulesBundle: false }, context.config.resolve),
62
+ silenceHookLogging: true
63
+ }))()] }));
64
+ if (result.errors.length > 0) throw new Error(`Failed to bundle ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
65
+ if (result.warnings.length > 0) context.warn(`Warnings while bundling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
66
+ if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
67
+ return result.outputFiles.filter(Boolean)[0];
68
+ }
2
69
 
3
- import __tsdown_shims_path from 'node:path'
4
- import __tsdown_shims_url from 'node:url'
70
+ //#endregion
71
+ //#region src/constants.ts
72
+ const VALID_SOURCE_FILE_EXTENSIONS = [
73
+ "ts",
74
+ "cts",
75
+ "mts",
76
+ "tsx",
77
+ "js",
78
+ "cjs",
79
+ "mjs",
80
+ "jsx",
81
+ "json",
82
+ "jsonc",
83
+ "json5",
84
+ "yaml",
85
+ "yml",
86
+ "toml"
87
+ ];
88
+ const JsonSchemaTypeNames = {
89
+ STRING: "string",
90
+ NUMBER: "number",
91
+ INTEGER: "integer",
92
+ BOOLEAN: "boolean",
93
+ NULL: "null",
94
+ OBJECT: "object",
95
+ ARRAY: "array"
96
+ };
97
+ const JSON_SCHEMA_PRIMITIVE_TYPES = [
98
+ JsonSchemaTypeNames.STRING,
99
+ JsonSchemaTypeNames.NUMBER,
100
+ JsonSchemaTypeNames.INTEGER,
101
+ JsonSchemaTypeNames.BOOLEAN,
102
+ JsonSchemaTypeNames.NULL
103
+ ];
104
+ const JSON_SCHEMA_TYPES = [
105
+ ...JSON_SCHEMA_PRIMITIVE_TYPES,
106
+ JsonSchemaTypeNames.ARRAY,
107
+ JsonSchemaTypeNames.OBJECT
108
+ ];
109
+ const JSON_SCHEMA_METADATA_KEYS = [
110
+ "docs",
111
+ "deprecated",
112
+ "title",
113
+ "description",
114
+ "examples",
115
+ "hidden",
116
+ "ignore",
117
+ "internal",
118
+ "runtime",
119
+ "readOnly",
120
+ "writeOnly",
121
+ "alias",
122
+ "tags"
123
+ ];
5
124
 
6
- const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
- const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
125
+ //#endregion
126
+ //#region src/metadata.ts
127
+ /**
128
+ * Applies Powerlines schema metadata onto a JSON Schema fragment.
129
+ *
130
+ * @param schema - The JSON Schema fragment to apply metadata to.
131
+ * @param metadata - The Powerlines schema metadata to apply.
132
+ * @returns A new JSON Schema fragment with the metadata applied.
133
+ */
134
+ function applyJsonSchemaMetadata(schema, metadata) {
135
+ if (!metadata || !isSetObject$1(schema)) return schema;
136
+ const result = { ...schema };
137
+ const mutableResult = result;
138
+ for (const key of JSON_SCHEMA_METADATA_KEYS) {
139
+ const value = metadata[key];
140
+ if (value !== void 0 && value !== null) mutableResult[key] = value;
141
+ }
142
+ return result;
143
+ }
144
+ /**
145
+ * Normalizes the JSON Schema `type` keyword to a string array.
146
+ *
147
+ * @remarks
148
+ * This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
149
+ *
150
+ * @param schema - The JSON Schema fragment to read types from.
151
+ * @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
152
+ */
153
+ function readSchemaTypes(schema) {
154
+ if (!isSetObject$1(schema)) return [];
155
+ const objectSchema = schema;
156
+ if (Array.isArray(objectSchema.type)) return objectSchema.type.filter((type) => isSetString(type));
157
+ if (isSetString(objectSchema.type) && objectSchema.type !== "object" && objectSchema.type !== "array") return [objectSchema.type];
158
+ return [];
159
+ }
160
+ /**
161
+ * Returns the primary non-null JSON Schema type name for a fragment.
162
+ *
163
+ * @param schema - The JSON Schema fragment to check.
164
+ * @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
165
+ */
166
+ function getPrimarySchemaType(schema) {
167
+ if (!isSetObject$1(schema)) return;
168
+ return readSchemaTypes(schema).find((type) => type !== "null");
169
+ }
8
170
 
9
- import { bundle } from "./bundle.mjs";
10
- import { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames, VALID_SOURCE_FILE_EXTENSIONS } from "./constants.mjs";
11
- import { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes } from "./metadata.mjs";
12
- import { isJsonSchema, isJsonSchemaAllOf, isJsonSchemaAny, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaDecimal, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaKeywords, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNullable, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaPrimitiveType, isJsonSchemaPrimitiveUnion, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaType, isJsonSchemaUndefined, isJsonSchemaUnion, isJsonSchemaUnknown, isNullOnlyJsonSchema, isSchema, isSchemaObject, isSchemaWithSource, isStandardSchema, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema } from "./type-checks.mjs";
13
- import { addProperty, getJsonSchema, getJsonSchemaObject, getProperties, getPropertiesList, isPropertyOptional, isSchemaNullable, isValidSchemaInputFile, merge } from "./helpers.mjs";
14
- import { generateCode, getJsonSchemaType, stringifyType, stringifyValue } from "./codegen.mjs";
15
- import { getCacheDirectory, getCacheFilePath, readSchema, readSchemaSafe, writeSchema } from "./persistence.mjs";
16
- import { reflectionToJsonSchema } from "./reflection.mjs";
17
- import { resolve, resolveModule, resolveReflection } from "./resolve.mjs";
18
- import { bundleReferences, extract, extractHash, extractJsonSchema, extractReflection, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractVariant } from "./extract.mjs";
171
+ //#endregion
172
+ //#region src/type-checks.ts
173
+ const isSetNumber = (value) => typeof value === "number" && Number.isFinite(value);
174
+ const isSetBoolean = (value) => typeof value === "boolean";
175
+ const isSchemaLikeValue = (value) => isSetObject(value) || isSetBoolean(value);
176
+ const isRecordOfSchemaLike = (value) => isSetObject(value) && Object.values(value).every((item) => isSchemaLikeValue(item));
177
+ const isVocabularyMap = (value) => isSetObject(value) && Object.values(value).every((item) => isSetBoolean(item));
178
+ const isStringArray = (value) => Array.isArray(value) && value.every((item) => isSetString(item));
179
+ const isRecordOfStringArrays = (value) => isSetObject(value) && Object.values(value).every((item) => isStringArray(item));
180
+ const JSON_SCHEMA_PRIMITIVE_TYPE_SET = new Set(JSON_SCHEMA_PRIMITIVE_TYPES);
181
+ const JSON_SCHEMA_TYPE_SET = new Set(JSON_SCHEMA_TYPES);
182
+ /**
183
+ * A helper type guard to check if a value is a JSON Schema primitive type.
184
+ *
185
+ * @param value - The value to check.
186
+ * @returns True if the value is a JSON Schema primitive type, false otherwise.
187
+ */
188
+ function isJsonSchemaPrimitiveType(value) {
189
+ return isSetString(value) && JSON_SCHEMA_PRIMITIVE_TYPE_SET.has(value);
190
+ }
191
+ /**
192
+ * A helper type guard to check if a value is a JSON Schema type.
193
+ *
194
+ * @param value - The value to check.
195
+ * @returns True if the value is a JSON Schema type, false otherwise.
196
+ */
197
+ function isJsonSchemaType(value) {
198
+ return isSetString(value) && JSON_SCHEMA_TYPE_SET.has(value);
199
+ }
200
+ const DATE_FORMAT_SET = new Set([
201
+ "date",
202
+ "time",
203
+ "date-time",
204
+ "iso-time",
205
+ "iso-date-time",
206
+ "unix-time"
207
+ ]);
208
+ const isSetBigint = (value) => typeof value === "bigint";
209
+ const UNTYPED_TYPE_NAME_SET = new Set([
210
+ "string",
211
+ "number",
212
+ "bigint",
213
+ "boolean",
214
+ "symbol",
215
+ "function",
216
+ "object",
217
+ "any",
218
+ "array"
219
+ ]);
220
+ const isUntypedJSType = (value) => isSetString(value) && UNTYPED_TYPE_NAME_SET.has(value);
221
+ const isUntypedTypeDescriptor = (value) => {
222
+ if (!isSetObject(value)) return false;
223
+ const descriptor = value;
224
+ if (descriptor.type !== void 0 && !(isSetString(descriptor.type) && isUntypedJSType(descriptor.type) || Array.isArray(descriptor.type) && descriptor.type.every((item) => isUntypedJSType(item)))) return false;
225
+ if (descriptor.tsType !== void 0 && !isSetString(descriptor.tsType)) return false;
226
+ if (descriptor.markdownType !== void 0 && !isSetString(descriptor.markdownType)) return false;
227
+ if (descriptor.items !== void 0 && !(isUntypedTypeDescriptor(descriptor.items) || Array.isArray(descriptor.items) && descriptor.items.every((item) => isUntypedTypeDescriptor(item)))) return false;
228
+ return true;
229
+ };
230
+ const isUntypedFunctionArg = (value) => {
231
+ if (!isUntypedTypeDescriptor(value)) return false;
232
+ const arg = value;
233
+ if (arg.name !== void 0 && !isSetString(arg.name)) return false;
234
+ return arg.optional === void 0 || typeof arg.optional === "boolean";
235
+ };
236
+ const isRecordOfUntypedSchema = (value) => isSetObject(value) && Object.values(value).every((item) => isUntypedSchema(item));
237
+ const isArrayOf = (value, predicate) => Array.isArray(value) && value.every((item) => predicate(item));
238
+ const isTupleOfTwo = (value, aPredicate, bPredicate) => Array.isArray(value) && value.length === 2 && aPredicate(value[0]) && bPredicate(value[1]);
239
+ const isOptionalString = (value) => value === void 0 || isSetString(value);
240
+ const isOptionalBoolean = (value) => value === void 0 || isSetBoolean(value);
241
+ const isOptionalNumber = (value) => value === void 0 || isSetNumber(value);
242
+ const isOptionalBigint = (value) => value === void 0 || isSetBigint(value);
243
+ const isOptionalJsonSchema = (value) => value === void 0 || isJsonSchema(value);
244
+ const isOptionalJsonSchemaArray = (value) => value === void 0 || isArrayOf(value, isJsonSchema);
245
+ const isOptionalPrimitiveTypeArray = (value) => value === void 0 || Array.isArray(value) && value.every((item) => isSetString(item) && JSON_SCHEMA_PRIMITIVE_TYPE_SET.has(item));
246
+ const isOptionalJsonSchemaTypeArray = (value) => value === void 0 || Array.isArray(value) && value.every((item) => isSetString(item) && JSON_SCHEMA_TYPE_SET.has(item));
247
+ const hasValidJsonSchemaKeywords = (schema) => {
248
+ if (!isOptionalString(schema.$id)) return false;
249
+ if (!isOptionalString(schema.$schema)) return false;
250
+ if (schema.$vocabulary !== void 0 && !isVocabularyMap(schema.$vocabulary)) return false;
251
+ if (!isOptionalString(schema.$comment)) return false;
252
+ if (!isOptionalString(schema.$anchor)) return false;
253
+ if (schema.$defs !== void 0 && !isRecordOfSchemaLike(schema.$defs)) return false;
254
+ if (!isOptionalString(schema.$dynamicRef)) return false;
255
+ if (!isOptionalString(schema.$dynamicAnchor)) return false;
256
+ if (!isOptionalString(schema.name)) return false;
257
+ if (!isOptionalString(schema.title)) return false;
258
+ if (!isOptionalString(schema.description)) return false;
259
+ if (!isOptionalString(schema.docs)) return false;
260
+ if (schema.examples !== void 0 && !Array.isArray(schema.examples)) return false;
261
+ if (schema.alias !== void 0 && !isStringArray(schema.alias)) return false;
262
+ if (schema.tags !== void 0 && !isStringArray(schema.tags)) return false;
263
+ if (!isOptionalBoolean(schema.deprecated)) return false;
264
+ if (!isOptionalBoolean(schema.hidden)) return false;
265
+ if (!isOptionalBoolean(schema.ignore)) return false;
266
+ if (!isOptionalBoolean(schema.internal)) return false;
267
+ if (!isOptionalBoolean(schema.runtime)) return false;
268
+ if (!isOptionalBoolean(schema.readOnly)) return false;
269
+ if (!isOptionalBoolean(schema.writeOnly)) return false;
270
+ if (!isOptionalJsonSchemaArray(schema.allOf)) return false;
271
+ if (!isOptionalJsonSchemaArray(schema.anyOf)) return false;
272
+ if (!isOptionalJsonSchemaArray(schema.oneOf)) return false;
273
+ if (!isOptionalJsonSchema(schema.not)) return false;
274
+ if (!isOptionalJsonSchema(schema.if)) return false;
275
+ if (!isOptionalJsonSchema(schema.then)) return false;
276
+ if (!isOptionalJsonSchema(schema.else)) return false;
277
+ return true;
278
+ };
279
+ /**
280
+ * Type guard for shared JSON Schema keyword groups.
281
+ *
282
+ * @param input - The value to check.
283
+ * @returns True if the input is a JSON Schema keyword group, false otherwise.
284
+ */
285
+ function isJsonSchemaKeywords(input) {
286
+ if (!isSetObject(input)) return false;
287
+ return hasValidJsonSchemaKeywords(input);
288
+ }
289
+ /**
290
+ * Type guard for generic JSON Schema objects with optional `$ref`.
291
+ *
292
+ * @param input - The value to check.
293
+ * @returns True if the input is a generic JSON Schema object, false otherwise.
294
+ */
295
+ function isJsonSchemaAny(input) {
296
+ if (!isSetObject(input)) return false;
297
+ const schema = input;
298
+ return hasValidJsonSchemaKeywords(schema) && isOptionalString(schema.$ref);
299
+ }
300
+ /**
301
+ * Type guard for JSON Schema array types.
302
+ *
303
+ * @param input - The value to check.
304
+ * @returns True if the input is a JSON Schema array schema, false otherwise.
305
+ */
306
+ function isJsonSchemaArray(input) {
307
+ if (!isSetObject(input)) return false;
308
+ const schema = input;
309
+ if (!hasValidJsonSchemaKeywords(schema) || schema.type !== "array") return false;
310
+ return isOptionalJsonSchemaArray(schema.prefixItems) && isOptionalJsonSchema(schema.items) && isOptionalJsonSchema(schema.contains) && isOptionalNumber(schema.minItems) && isOptionalNumber(schema.maxItems) && isOptionalBoolean(schema.uniqueItems) && isOptionalNumber(schema.minContains) && isOptionalNumber(schema.maxContains) && (schema.unevaluatedItems === void 0 || isSetBoolean(schema.unevaluatedItems) || isJsonSchema(schema.unevaluatedItems));
311
+ }
312
+ /**
313
+ * Type guard for bigint-backed integer schemas.
314
+ *
315
+ * @param input - The value to check.
316
+ * @returns True if the input is a bigint-backed integer schema, false otherwise.
317
+ */
318
+ function isJsonSchemaBigint(input) {
319
+ if (!isSetObject(input)) return false;
320
+ const schema = input;
321
+ if (!hasValidJsonSchemaKeywords(schema) || schema.type !== "integer" || schema.format !== "int64") return false;
322
+ return isOptionalBigint(schema.minimum) && isOptionalBigint(schema.exclusiveMinimum) && isOptionalBigint(schema.maximum) && isOptionalBigint(schema.exclusiveMaximum) && isOptionalBigint(schema.multipleOf) && isOptionalBigint(schema.default) && (schema.enum === void 0 || isArrayOf(schema.enum, isSetBigint));
323
+ }
324
+ /**
325
+ * Type guard for boolean schemas.
326
+ *
327
+ * @param input - The value to check.
328
+ * @returns True if the input is a boolean schema, false otherwise.
329
+ */
330
+ function isJsonSchemaBoolean(input) {
331
+ if (!isSetObject(input)) return false;
332
+ const schema = input;
333
+ return hasValidJsonSchemaKeywords(schema) && schema.type === "boolean" && isOptionalBoolean(schema.default);
334
+ }
335
+ /**
336
+ * Type guard for date/time schemas.
337
+ *
338
+ * @param input - The value to check.
339
+ * @returns True if the input is a date or time schema, false otherwise.
340
+ */
341
+ function isJsonSchemaDate(input) {
342
+ if (!isSetObject(input)) return false;
343
+ const schema = input;
344
+ if (!hasValidJsonSchemaKeywords(schema)) return false;
345
+ if (schema.anyOf !== void 0) return isArrayOf(schema.anyOf, isJsonSchemaDate);
346
+ if (schema.type !== "integer" && schema.type !== "string") return false;
347
+ if (!isSetString(schema.format) || !DATE_FORMAT_SET.has(schema.format)) return false;
348
+ return isOptionalNumber(schema.minimum) && isOptionalNumber(schema.maximum) && (schema.default === void 0 || isSetString(schema.default) || isSetNumber(schema.default));
349
+ }
350
+ /**
351
+ * Type guard for enum-constrained schemas.
352
+ *
353
+ * @param input - The value to check.
354
+ * @returns True if the input is an enum-constrained schema, false otherwise.
355
+ */
356
+ function isJsonSchemaEnum(input) {
357
+ if (!isSetObject(input)) return false;
358
+ const schema = input;
359
+ if (!hasValidJsonSchemaKeywords(schema) || !isSetString(schema.type) || !JSON_SCHEMA_PRIMITIVE_TYPE_SET.has(schema.type) || !Array.isArray(schema.enum)) return false;
360
+ const typeName = schema.type;
361
+ const enumValues = schema.enum;
362
+ const defaultValue = schema.default;
363
+ if (typeName === "string") return enumValues.every((value) => isSetString(value)) && (defaultValue === void 0 || isSetString(defaultValue));
364
+ if (typeName === "number" || typeName === "integer") return enumValues.every((value) => isSetNumber(value)) && (defaultValue === void 0 || isSetNumber(defaultValue));
365
+ if (typeName === "boolean") return enumValues.every((value) => isSetBoolean(value)) && (defaultValue === void 0 || isSetBoolean(defaultValue));
366
+ return typeName === "null" && enumValues.every((value) => value === null) && (defaultValue === void 0 || defaultValue === null);
367
+ }
368
+ /**
369
+ * Type guard for `allOf` composition schemas.
370
+ *
371
+ * @param input - The value to check.
372
+ * @returns True if the input is an `allOf` schema, false otherwise.
373
+ */
374
+ function isJsonSchemaAllOf(input) {
375
+ if (!isSetObject(input)) return false;
376
+ const schema = input;
377
+ if (!hasValidJsonSchemaKeywords(schema) || !isArrayOf(schema.allOf, isJsonSchema)) return false;
378
+ return schema.unevaluatedProperties === void 0 || isSetBoolean(schema.unevaluatedProperties) || isJsonSchema(schema.unevaluatedProperties);
379
+ }
380
+ /**
381
+ * Type guard for literal-value schemas.
382
+ *
383
+ * @param input - The value to check.
384
+ * @returns True if the input is a literal-value schema, false otherwise.
385
+ */
386
+ function isJsonSchemaLiteral(input) {
387
+ if (!isSetObject(input)) return false;
388
+ const schema = input;
389
+ if (!hasValidJsonSchemaKeywords(schema) || !("const" in schema)) return false;
390
+ return schema.type === void 0 || isSetString(schema.type) && isJsonSchemaType(schema.type) || isOptionalJsonSchemaTypeArray(schema.type);
391
+ }
392
+ /**
393
+ * Type guard for map tuple-array schemas.
394
+ *
395
+ * @param input - The value to check.
396
+ * @returns True if the input is a map tuple-array schema, false otherwise.
397
+ */
398
+ function isJsonSchemaMap(input) {
399
+ if (!isSetObject(input)) return false;
400
+ const schema = input;
401
+ if (!hasValidJsonSchemaKeywords(schema) || schema.type !== "array" || schema.maxItems !== 125 || !isSetObject(schema.items)) return false;
402
+ const items = schema.items;
403
+ return items.type === "array" && isTupleOfTwo(items.prefixItems, isJsonSchema, isJsonSchema) && (items.items === void 0 || items.items === false) && items.minItems === 2 && items.maxItems === 2;
404
+ }
405
+ /**
406
+ * Type guard for native enum schemas.
407
+ *
408
+ * @param input - The value to check.
409
+ * @returns True if the input is a native enum schema, false otherwise.
410
+ */
411
+ function isJsonSchemaNativeEnum(input) {
412
+ if (!isSetObject(input)) return false;
413
+ const schema = input;
414
+ const isValidType = schema.type === "string" || schema.type === "number" || Array.isArray(schema.type) && schema.type.length === 2 && schema.type[0] === "string" && schema.type[1] === "number";
415
+ return hasValidJsonSchemaKeywords(schema) && isValidType && Array.isArray(schema.enum) && schema.enum.every((value) => isSetString(value) || isSetNumber(value));
416
+ }
417
+ /**
418
+ * Type guard for impossible/never schemas.
419
+ *
420
+ * @param input - The value to check.
421
+ * @returns True if the input is a never schema, false otherwise.
422
+ */
423
+ function isJsonSchemaNever(input) {
424
+ if (!isSetObject(input)) return false;
425
+ const schema = input;
426
+ return hasValidJsonSchemaKeywords(schema) && isJsonSchemaAny(schema.not);
427
+ }
428
+ /**
429
+ * Type guard for `null` schemas.
430
+ *
431
+ * @param input - The value to check.
432
+ * @returns True if the input is a null schema, false otherwise.
433
+ */
434
+ function isJsonSchemaNull(input) {
435
+ if (!isSetObject(input)) return false;
436
+ const schema = input;
437
+ return hasValidJsonSchemaKeywords(schema) && schema.type === "null" && (schema.const === void 0 || schema.const === null) && (schema.enum === void 0 || Array.isArray(schema.enum) && schema.enum.every((v) => v === null)) && (schema.default === void 0 || schema.default === null);
438
+ }
439
+ /**
440
+ * Type guard for nullable schema unions.
441
+ *
442
+ * @param input - The value to check.
443
+ * @returns True if the input is a nullable schema union, false otherwise.
444
+ */
445
+ function isJsonSchemaNullable(input) {
446
+ if (!isSetObject(input)) return false;
447
+ const schema = input;
448
+ if (!hasValidJsonSchemaKeywords(schema)) return false;
449
+ const anyOfBranch = schema.anyOf !== void 0 && Array.isArray(schema.anyOf) && schema.anyOf.length === 2 && isJsonSchema(schema.anyOf[0]) && isJsonSchemaNull(schema.anyOf[1]);
450
+ const typeBranch = Array.isArray(schema.type) && schema.type.length === 2 && (schema.type[0] === "null" && isSetString(schema.type[1]) && schema.type[1] !== "null" && JSON_SCHEMA_TYPE_SET.has(schema.type[1]) || schema.type[1] === "null" && isSetString(schema.type[0]) && schema.type[0] !== "null" && JSON_SCHEMA_TYPE_SET.has(schema.type[0]));
451
+ return anyOfBranch || typeBranch;
452
+ }
453
+ /**
454
+ * Type guard for numeric schemas.
455
+ *
456
+ * @param input - The value to check.
457
+ * @returns True if the input is a numeric schema, false otherwise.
458
+ */
459
+ function isJsonSchemaNumber(input) {
460
+ if (!isSetObject(input)) return false;
461
+ const schema = input;
462
+ if (!hasValidJsonSchemaKeywords(schema) || schema.type !== "number" && schema.type !== "integer") return false;
463
+ return isOptionalString(schema.format) && isOptionalNumber(schema.minimum) && isOptionalNumber(schema.exclusiveMinimum) && isOptionalNumber(schema.maximum) && isOptionalNumber(schema.exclusiveMaximum) && isOptionalNumber(schema.multipleOf) && isOptionalNumber(schema.default) && (schema.enum === void 0 || isArrayOf(schema.enum, isSetNumber));
464
+ }
465
+ /**
466
+ * Type guard for integer schemas.
467
+ *
468
+ * @param input - The value to check.
469
+ * @returns True if the input is an integer schema, false otherwise.
470
+ */
471
+ function isJsonSchemaInteger(input) {
472
+ return isJsonSchemaNumber(input) && input.type === "integer";
473
+ }
474
+ /**
475
+ * Type guard for decimal schemas.
476
+ *
477
+ * @param input - The value to check.
478
+ * @returns True if the input is a decimal schema, false otherwise.
479
+ */
480
+ function isJsonSchemaDecimal(input) {
481
+ return isJsonSchemaNumber(input) && input.type === "number";
482
+ }
483
+ /**
484
+ * Type guard for object schemas.
485
+ *
486
+ * @param input - The value to check.
487
+ * @returns True if the input is an object schema, false otherwise.
488
+ */
489
+ function isJsonSchemaObject(input) {
490
+ if (!isSetObject(input)) return false;
491
+ const schema = input;
492
+ return hasValidJsonSchemaKeywords(schema) && schema.type === "object" && (schema.properties === void 0 || isRecordOfSchemaLike(schema.properties)) && (schema.patternProperties === void 0 || isRecordOfSchemaLike(schema.patternProperties)) && (schema.additionalProperties === void 0 || isSetBoolean(schema.additionalProperties) || isJsonSchema(schema.additionalProperties)) && (schema.required === void 0 || isStringArray(schema.required)) && (schema.unevaluatedProperties === void 0 || isSetBoolean(schema.unevaluatedProperties) || isJsonSchema(schema.unevaluatedProperties)) && (schema.dependencies === void 0 || isSetObject(schema.dependencies) && Object.values(schema.dependencies).every((item) => isStringArray(item) || isJsonSchema(item))) && (schema.dependentRequired === void 0 || isRecordOfStringArrays(schema.dependentRequired)) && (schema.dependentSchemas === void 0 || isRecordOfSchemaLike(schema.dependentSchemas)) && isOptionalNumber(schema.minProperties) && isOptionalNumber(schema.maxProperties) && (schema.primaryKey === void 0 || isStringArray(schema.primaryKey)) && isOptionalString(schema.databaseSchema);
493
+ }
494
+ /**
495
+ * Type guard for string schemas.
496
+ *
497
+ * @param input - The value to check.
498
+ * @returns True if the input is a string schema, false otherwise.
499
+ */
500
+ function isJsonSchemaString(input) {
501
+ if (!isSetObject(input)) return false;
502
+ const schema = input;
503
+ return hasValidJsonSchemaKeywords(schema) && schema.type === "string" && isOptionalNumber(schema.minLength) && isOptionalNumber(schema.maxLength) && isOptionalString(schema.pattern) && isOptionalString(schema.format) && isOptionalString(schema.default) && (schema.enum === void 0 || isArrayOf(schema.enum, isSetString)) && isOptionalString(schema.contentMediaType) && isOptionalString(schema.contentEncoding) && isOptionalString(schema.contentSchema);
504
+ }
505
+ /**
506
+ * Type guard for set-like array schemas.
507
+ *
508
+ * @param input - The value to check.
509
+ * @returns True if the input is a set-like array schema, false otherwise.
510
+ */
511
+ function isJsonSchemaSet(input) {
512
+ if (!isSetObject(input)) return false;
513
+ const schema = input;
514
+ return hasValidJsonSchemaKeywords(schema) && schema.type === "array" && schema.uniqueItems === true && isOptionalJsonSchemaArray(schema.prefixItems) && isOptionalJsonSchema(schema.items) && isOptionalJsonSchema(schema.contains) && isOptionalNumber(schema.minItems) && isOptionalNumber(schema.maxItems) && isOptionalNumber(schema.minContains) && isOptionalNumber(schema.maxContains) && (schema.unevaluatedItems === void 0 || isSetBoolean(schema.unevaluatedItems) || isJsonSchema(schema.unevaluatedItems));
515
+ }
516
+ /**
517
+ * Type guard for record schemas.
518
+ *
519
+ * @param input - The value to check.
520
+ * @returns True if the input is a record schema, false otherwise.
521
+ */
522
+ function isJsonSchemaRecord(input) {
523
+ if (!isSetObject(input)) return false;
524
+ const schema = input;
525
+ return hasValidJsonSchemaKeywords(schema) && schema.type === "object" && (schema.patternProperties === void 0 || isRecordOfSchemaLike(schema.patternProperties)) && (schema.additionalProperties === void 0 || isSetBoolean(schema.additionalProperties) || isJsonSchema(schema.additionalProperties)) && isOptionalJsonSchema(schema.propertyNames);
526
+ }
527
+ /**
528
+ * Type guard for tuple schemas.
529
+ *
530
+ * @param input - The value to check.
531
+ * @returns True if the input is a tuple schema, false otherwise.
532
+ */
533
+ function isJsonSchemaTuple(input) {
534
+ if (!isSetObject(input)) return false;
535
+ const schema = input;
536
+ return hasValidJsonSchemaKeywords(schema) && schema.type === "array" && isArrayOf(schema.prefixItems, isJsonSchema) && isOptionalNumber(schema.minItems) && isOptionalNumber(schema.maxItems) && isOptionalJsonSchema(schema.items) && isOptionalJsonSchema(schema.contains) && isOptionalBoolean(schema.uniqueItems) && isOptionalNumber(schema.minContains) && isOptionalNumber(schema.maxContains) && (schema.unevaluatedItems === void 0 || isSetBoolean(schema.unevaluatedItems) || isJsonSchema(schema.unevaluatedItems));
537
+ }
538
+ /**
539
+ * Type guard for undefined-representing schemas.
540
+ *
541
+ * @param input - The value to check.
542
+ * @returns True if the input is an undefined-representing schema, false otherwise.
543
+ */
544
+ function isJsonSchemaUndefined(input) {
545
+ if (!isSetObject(input)) return false;
546
+ const schema = input;
547
+ return hasValidJsonSchemaKeywords(schema) && isJsonSchemaAny(schema.not) && (schema.default === void 0 || schema.default === void 0);
548
+ }
549
+ /**
550
+ * Type guard for primitive-union schema variants.
551
+ *
552
+ * @param input - The value to check.
553
+ * @returns True if the input is a primitive-union schema variant, false otherwise.
554
+ */
555
+ function isJsonSchemaPrimitiveUnion(input) {
556
+ if (!isSetObject(input)) return false;
557
+ const schema = input;
558
+ if (!hasValidJsonSchemaKeywords(schema)) return false;
559
+ if (isSetString(schema.type) && JSON_SCHEMA_PRIMITIVE_TYPE_SET.has(schema.type)) {
560
+ if (schema.enum === void 0) return true;
561
+ if (!Array.isArray(schema.enum)) return false;
562
+ if (schema.type === "string") return schema.enum.every((value) => isSetString(value)) && (schema.default === void 0 || isSetString(schema.default));
563
+ if (schema.type === "number") return schema.enum.every((value) => isSetNumber(value)) && (schema.default === void 0 || isSetNumber(schema.default));
564
+ if (schema.type === "boolean") return schema.enum.every((value) => isSetBoolean(value)) && (schema.default === void 0 || isSetBoolean(schema.default));
565
+ if (schema.type === "integer") {
566
+ if (schema.format !== "int64") return false;
567
+ return schema.enum.every((value) => isSetBigint(value)) && (schema.default === void 0 || isSetBigint(schema.default));
568
+ }
569
+ return schema.type === "null" && schema.enum.every((value) => value === null) && (schema.default === void 0 || schema.default === null);
570
+ }
571
+ return isOptionalPrimitiveTypeArray(schema.type) && schema.type !== void 0;
572
+ }
573
+ /**
574
+ * Type guard for union schemas.
575
+ *
576
+ * @param input - The value to check.
577
+ * @returns True if the input is a union schema, false otherwise.
578
+ */
579
+ function isJsonSchemaUnion(input) {
580
+ if (!isSetObject(input)) return false;
581
+ const schema = input;
582
+ return hasValidJsonSchemaKeywords(schema) && (isJsonSchemaPrimitiveUnion(schema) || isJsonSchemaAnyOf(schema));
583
+ }
584
+ /**
585
+ * Type guard for permissive unknown schemas.
586
+ *
587
+ * @param input - The value to check.
588
+ * @returns True if the input is a permissive unknown schema, false otherwise.
589
+ */
590
+ function isJsonSchemaUnknown(input) {
591
+ return isJsonSchemaAny(input);
592
+ }
593
+ /**
594
+ * Type guard for `anyOf` composition schemas.
595
+ *
596
+ * @param input - The value to check.
597
+ * @returns True if the input is an `anyOf` schema, false otherwise.
598
+ */
599
+ function isJsonSchemaAnyOf(input) {
600
+ if (!isSetObject(input)) return false;
601
+ const schema = input;
602
+ return hasValidJsonSchemaKeywords(schema) && isArrayOf(schema.anyOf, isJsonSchema);
603
+ }
604
+ /**
605
+ * Type guard for reference schemas.
606
+ *
607
+ * @param input - The value to check.
608
+ * @returns True if the input is a reference schema, false otherwise.
609
+ */
610
+ function isJsonSchemaRef(input) {
611
+ if (!isSetObject(input)) return false;
612
+ const schema = input;
613
+ return hasValidJsonSchemaKeywords(schema) && isSetString(schema.$ref);
614
+ }
615
+ /**
616
+ * Type guard for Standard Schema V1 objects.
617
+ *
618
+ * @param input - The value to check.
619
+ * @returns True if the input is a Standard Schema V1 object, false otherwise.
620
+ */
621
+ function isStandardSchema(input) {
622
+ if (!isSetObject(input)) return false;
623
+ const schema = input;
624
+ if (!isSetObject(schema["~standard"])) return false;
625
+ const standard = schema["~standard"];
626
+ return standard.version === 1 && isFunction(standard.validate);
627
+ }
628
+ /**
629
+ * Type guard for Valibot BaseSchema objects.
630
+ *
631
+ * @param input - The value to check.
632
+ * @returns True if the input is a Valibot BaseSchema, false otherwise.
633
+ */
634
+ function isValibotSchema(input) {
635
+ if (!isSetObject(input) || !isStandardSchema(input)) return false;
636
+ const schema = input;
637
+ return schema.kind === "schema" && isSetString(schema.type) && isSetBoolean(schema.async) && isFunction(schema.reference) && isSetString(schema.expects) && isFunction(schema["~run"]);
638
+ }
639
+ /**
640
+ * Type guard for JSON Schema types.
641
+ *
642
+ * @remarks
643
+ * This function checks if the input is a JSON Schema type, which is defined as having a `type` property or a `$ref` property. This is used to determine if a given input conforms to the structure of a JSON Schema definition that includes type information.
644
+ *
645
+ * @param input - The value to check.
646
+ * @returns True if the input is a JSON Schema type, false otherwise.
647
+ */
648
+ function isJsonSchema(input) {
649
+ return isJsonSchemaString(input) || isJsonSchemaInteger(input) || isJsonSchemaDecimal(input) || isJsonSchemaBigint(input) || isJsonSchemaBoolean(input) || isJsonSchemaDate(input) || isJsonSchemaEnum(input) || isJsonSchemaLiteral(input) || isJsonSchemaNativeEnum(input) || isJsonSchemaNull(input) || isJsonSchemaArray(input) || isJsonSchemaObject(input) || isJsonSchemaRecord(input) || isJsonSchemaTuple(input) || isJsonSchemaUnion(input) || isJsonSchemaUndefined(input) || isJsonSchemaRef(input) || isJsonSchemaNever(input) || isJsonSchemaMap(input) || isJsonSchemaAny(input) || isJsonSchemaNullable(input) || isJsonSchemaAllOf(input) || isJsonSchemaUnknown(input) || isJsonSchemaSet(input);
650
+ }
651
+ /**
652
+ * Type guard for JSON Schemas that only accept `null`.
653
+ *
654
+ * @remarks
655
+ * This function checks if the input is a JSON Schema that exclusively accepts the `null` type. It verifies that the input is a valid JSON Schema and that its `type` property is set to "null". This is useful for identifying schemas that are specifically designed to allow only `null` values.
656
+ *
657
+ * @param input - The value to check.
658
+ * @returns True if the input is a JSON Schema that only accepts `null`, false otherwise.
659
+ */
660
+ function isNullOnlyJsonSchema(input) {
661
+ return isJsonSchemaNull(input);
662
+ }
663
+ /**
664
+ * Type guard for untyped schema objects.
665
+ *
666
+ * @remarks
667
+ * This function checks if the input is an untyped schema object, which is defined as having certain properties that are commonly found in untyped schema definitions. This includes properties such as `id`, `title`, `description`, `$schema`, `tsType`, `markdownType`, `type`, `required`, `tags`, `args`, `properties`, and `resolve`. The function verifies that these properties, if present, conform to the expected types (e.g., strings for certain properties, arrays for others). This type guard is used to determine if a given input can be treated as an untyped schema object within the context of the Powerlines schema system.
668
+ *
669
+ * @param input - The value to check.
670
+ * @returns True if the input is an untyped schema object, false otherwise.
671
+ */
672
+ function isUntypedSchema(input) {
673
+ if (!isSetObject(input)) return false;
674
+ const schema = input;
675
+ if (!isUntypedTypeDescriptor(schema)) return false;
676
+ if ("id" in schema && !isSetString(schema.id)) return false;
677
+ if ("resolve" in schema && !isFunction(schema.resolve)) return false;
678
+ if ("properties" in schema && !isRecordOfUntypedSchema(schema.properties)) return false;
679
+ if ("required" in schema && !isStringArray(schema.required)) return false;
680
+ if ("title" in schema && !isSetString(schema.title)) return false;
681
+ if ("description" in schema && !isSetString(schema.description)) return false;
682
+ if ("$schema" in schema && !isSetString(schema.$schema)) return false;
683
+ if ("tags" in schema && !isStringArray(schema.tags)) return false;
684
+ if ("args" in schema && (!Array.isArray(schema.args) || !schema.args.every((item) => isUntypedFunctionArg(item)))) return false;
685
+ if ("returns" in schema && !isUntypedTypeDescriptor(schema.returns)) return false;
686
+ return true;
687
+ }
688
+ /**
689
+ * Strict type guard for untyped schema objects.
690
+ *
691
+ * @remarks
692
+ * This guard narrows values to the Untyped schema model while explicitly
693
+ * rejecting values that are also valid JSON Schema instances.
694
+ *
695
+ * @param input - The value to check.
696
+ * @returns True if the input is an untyped schema and not a JSON Schema.
697
+ */
698
+ function isUntypedSchemaStrict(input) {
699
+ return isUntypedSchema(input) && !isJsonSchema(input);
700
+ }
701
+ /**
702
+ * Type guard for untyped input objects.
703
+ *
704
+ * @remarks
705
+ * This function checks if the input is an untyped input object, which is defined as having certain properties that are commonly found in untyped input definitions. This includes properties such as `$schema` and `$resolve`. The function verifies that these properties, if present, conform to the expected types (e.g., objects for `$schema`, functions for `$resolve`). This type guard is used to determine if a given input can be treated as an untyped input object within the context of the Powerlines schema system.
706
+ *
707
+ * @param input - The value to check.
708
+ * @returns True if the input is an untyped input object, false otherwise.
709
+ */
710
+ function isUntypedInput(input) {
711
+ if (!isSetObject(input)) return false;
712
+ const inputObject = input;
713
+ if ("$schema" in inputObject && !isUntypedSchema(inputObject.$schema)) return false;
714
+ if ("$resolve" in inputObject && !isFunction(inputObject.$resolve)) return false;
715
+ return true;
716
+ }
717
+ /**
718
+ * Strict type guard for untyped input objects.
719
+ *
720
+ * @remarks
721
+ * This guard narrows values to the Untyped input-object model while
722
+ * explicitly rejecting values that are valid JSON Schema objects.
723
+ *
724
+ * @param input - The value to check.
725
+ * @returns True if the input is an untyped input object and not JSON Schema.
726
+ */
727
+ function isUntypedInputStrict(input) {
728
+ if (!isUntypedInput(input) || isJsonSchema(input)) return false;
729
+ const inputObject = input;
730
+ if ("$schema" in inputObject && inputObject.$schema !== void 0 && !isUntypedSchemaStrict(inputObject.$schema)) return false;
731
+ return true;
732
+ }
733
+ /**
734
+ * Type guard for Powerlines Schema objects.
735
+ *
736
+ * @param input - The value to check.
737
+ * @returns True if the input is a Powerlines Schema object, false otherwise.
738
+ */
739
+ function isSchema(input) {
740
+ return isSetObject(input) && "schema" in input && isJsonSchema(input.schema) && "variant" in input && isSetString(input.variant) && "hash" in input && isSetString(input.hash);
741
+ }
742
+ /**
743
+ * Type guard for extracted schema objects that include source information.
744
+ *
745
+ * @param input - The value to check.
746
+ * @returns True if the input is a SchemaWithSource object, false otherwise.
747
+ */
748
+ function isSchemaWithSource(input) {
749
+ return isSchema(input) && "source" in input && isSetObject(input.source) && "schema" in input.source && "variant" in input.source && isSetString(input.source.variant);
750
+ }
751
+ /**
752
+ * Type guard for Powerlines Schemas that are in Object form.
753
+ *
754
+ * @param input - The value to check.
755
+ * @returns True if the input is a Powerlines Schema object in Object form, false otherwise.
756
+ */
757
+ function isSchemaObject(input) {
758
+ return isSchema(input) && isJsonSchemaObject(input.schema);
759
+ }
19
760
 
20
- export { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames, VALID_SOURCE_FILE_EXTENSIONS, addProperty, applyJsonSchemaMetadata, bundle, bundleReferences, extract, extractHash, extractJsonSchema, extractReflection, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractVariant, generateCode, getCacheDirectory, getCacheFilePath, getJsonSchema, getJsonSchemaObject, getJsonSchemaType, getPrimarySchemaType, getProperties, getPropertiesList, isJsonSchema, isJsonSchemaAllOf, isJsonSchemaAny, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaDecimal, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaKeywords, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNullable, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaPrimitiveType, isJsonSchemaPrimitiveUnion, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaType, isJsonSchemaUndefined, isJsonSchemaUnion, isJsonSchemaUnknown, isNullOnlyJsonSchema, isPropertyOptional, isSchema, isSchemaNullable, isSchemaObject, isSchemaWithSource, isStandardSchema, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaInputFile, merge, readSchema, readSchemaSafe, readSchemaTypes, reflectionToJsonSchema, resolve, resolveModule, resolveReflection, stringifyType, stringifyValue, writeSchema };
761
+ //#endregion
762
+ //#region src/helpers.ts
763
+ /**
764
+ * Retrieves the JSON Schema from a Schema wrapper or returns the input if it's already a JSON Schema.
765
+ *
766
+ * @remarks
767
+ * This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.
768
+ *
769
+ * @param input - The input which can be either a Schema wrapper or a JSON Schema object.
770
+ * @returns The JSON Schema object.
771
+ * @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.
772
+ */
773
+ function getJsonSchema(input) {
774
+ const schema = isSchema(input) ? input.schema : input;
775
+ if (!isJsonSchema(schema)) throw new TypeError(`The provided input is not a valid JSON Schema: ${JSON.stringify(schema, null, 2)}`);
776
+ return schema;
777
+ }
778
+ /**
779
+ * Retrieves the JSON Schema in Object form from a Schema wrapper or returns the input if it's already a JSON Schema.
780
+ *
781
+ * @remarks
782
+ * This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema object, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.
783
+ *
784
+ * @param input - The input which can be either a Schema wrapper or a JSON Schema object.
785
+ * @returns The JSON Schema object.
786
+ * @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.
787
+ */
788
+ function getJsonSchemaObject(input) {
789
+ const schema = getJsonSchema(input);
790
+ if (!isJsonSchemaObject(schema)) throw new TypeError(`The provided input is not a valid JSON Schema object: ${JSON.stringify(schema, null, 2)}`);
791
+ return schema;
792
+ }
793
+ /**
794
+ * Extracts object properties from a JSON Schema object form.
795
+ *
796
+ * @remarks
797
+ * This function returns an empty object if the schema is not an object form or if it has no properties.
798
+ *
799
+ * @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
800
+ * @returns An object mapping property names to their corresponding JSON Schema fragments, including metadata.
801
+ */
802
+ function getProperties(obj) {
803
+ const properties = {};
804
+ const schema = getJsonSchemaObject(obj);
805
+ if (!isSetObject(schema.properties)) return properties;
806
+ for (const [key, value] of Object.entries(schema.properties)) {
807
+ const propertySchema = {};
808
+ if (typeof value !== "boolean") Object.assign(propertySchema, value);
809
+ properties[key] = {
810
+ ...propertySchema,
811
+ name: key,
812
+ required: !isPropertyOptional(schema, key),
813
+ default: schema.default?.[key] ?? propertySchema.default
814
+ };
815
+ }
816
+ return properties;
817
+ }
818
+ /**
819
+ * Returns object properties as an array.
820
+ *
821
+ * @remarks
822
+ * This is a convenience function that extracts properties using `getProperties` and returns them as an array.
823
+ *
824
+ * @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
825
+ * @returns An array of JSON Schema fragments representing the properties, each including metadata.
826
+ */
827
+ function getPropertiesList(obj) {
828
+ return Object.values(getProperties(obj));
829
+ }
830
+ /**
831
+ * Adds a property to a JSON Schema object form.
832
+ *
833
+ * @remarks
834
+ * This function modifies the provided schema in place by adding a new property with the specified name and schema. It also updates the `required` array based on the `optional` flag of the property. If the property is marked as optional, it will be removed from the `required` array; otherwise, it will be added to it.
835
+ *
836
+ * @param obj - The JSON Schema object form or a Schema wrapper to which the property should be added.
837
+ * @param name - The name of the property to add.
838
+ * @param property - The JSON Schema fragment representing the property's schema, including metadata.
839
+ * @throws Will throw an error if the provided schema is not an object form.
840
+ */
841
+ function addProperty(obj, name, property) {
842
+ const schema = getJsonSchemaObject(obj);
843
+ schema.properties ??= {};
844
+ schema.required ??= [];
845
+ schema.properties[name] = {
846
+ ...property,
847
+ name
848
+ };
849
+ if (!schema.required.includes(name)) schema.required.push(name);
850
+ if (schema.required.length === 0) delete schema.required;
851
+ }
852
+ /**
853
+ * Merges multiple JSON Schemas into one.
854
+ *
855
+ * @remarks
856
+ * This function takes multiple JSON Schemas or Schema wrappers and merges them into a single JSON Schema object. The merging process combines properties and metadata from all provided schemas, with later schemas in the arguments list taking precedence over earlier ones in case of conflicts. The resulting schema will include all unique properties and metadata from the input schemas.
857
+ *
858
+ * @param schemas - An array of JSON Schemas or Schema wrappers to merge.
859
+ * @returns A new JSON Schema that is the result of merging all input schemas.
860
+ */
861
+ function merge(...schemas) {
862
+ let result = {};
863
+ for (const schema of schemas.reverse()) if (!result.type || result.type === schema.type) {
864
+ result = defu$1(result, getJsonSchema(schema));
865
+ if (isJsonSchemaObject(result)) result.required = getUnique(result.required ?? []);
866
+ }
867
+ return result;
868
+ }
869
+ /**
870
+ * Returns whether a JSON Schema fragment accepts `null`.
871
+ *
872
+ * @remarks
873
+ * This is true if the schema has `nullable: true` or if its `type` includes `"null"`.
874
+ *
875
+ * @param schema - The JSON Schema fragment to check.
876
+ * @returns `true` if the schema accepts `null`, otherwise `false`.
877
+ */
878
+ function isSchemaNullable(schema) {
879
+ if (!isSetObject(schema)) return false;
880
+ if (schema.nullable === true) return true;
881
+ return readSchemaTypes(schema).includes("null");
882
+ }
883
+ /**
884
+ * Returns whether an object property is optional (not listed in `required`).
885
+ *
886
+ * @remarks
887
+ * In JSON Schema, object properties are optional by default unless they are listed in the `required` array of the parent schema. This function checks whether a given property name is not included in the `required` array of its parent schema, indicating that it is optional.
888
+ *
889
+ * @param parent - The parent JSON Schema object containing the property.
890
+ * @param propertyName - The name of the property to check for optionality.
891
+ * @returns `true` if the property is optional, otherwise `false`.
892
+ */
893
+ function isPropertyOptional(parent, propertyName) {
894
+ if (!parent.properties?.[propertyName]) throw new Error(`The property "${propertyName}" does not exist in the parent schema.`);
895
+ return !(parent.required ?? []).includes(propertyName);
896
+ }
897
+ /**
898
+ * Checks if a given file name has a valid schema input file extension.
899
+ *
900
+ * @param fileName - The file name to check for a valid schema input extension.
901
+ * @returns `true` if the file name has a valid schema input extension, otherwise `false`.
902
+ */
903
+ function isValidSchemaInputFile(fileName) {
904
+ return VALID_SOURCE_FILE_EXTENSIONS.includes(findFileExtensionSafe(fileName));
905
+ }
906
+
907
+ //#endregion
908
+ //#region src/validate.ts
909
+ /**
910
+ * Gets an Ajv validator instance for a given JSON Schema.
911
+ *
912
+ * @param schema - The JSON Schema to create a validator for.
913
+ * @returns An Ajv instance with the schema added.
914
+ */
915
+ function getValidator(schema) {
916
+ const ajv = new Ajv({
917
+ schemas: [schema],
918
+ code: {
919
+ source: true,
920
+ esm: true
921
+ }
922
+ });
923
+ addFormats(ajv);
924
+ return ajv;
925
+ }
926
+
927
+ //#endregion
928
+ //#region src/codegen.ts
929
+ /**
930
+ * Stringifies a value for generated TypeScript code.
931
+ */
932
+ function stringifyValue(value, type) {
933
+ return isUndefined$1(value) ? "undefined" : isNull$1(value) ? "null" : type === "boolean" || isBoolean$1(value) ? String(toBool(value)) : type === "number" || isNumber$1(value) ? Number.parseFloat(String(value)).toLocaleString(void 0, { maximumFractionDigits: 20 }) : type === "integer" ? Number.parseInt(String(value)).toLocaleString() : type === "string" || type === "object" || type === "array" ? JSON.stringify(value) : String(value);
934
+ }
935
+ /**
936
+ * Stringifies a JSON Schema fragment into a TypeScript-like type string.
937
+ */
938
+ function stringifyType(schema) {
939
+ if (!schema) return "unknown";
940
+ if (typeof schema === "boolean") return schema ? "unknown" : "never";
941
+ const objectSchema = schema;
942
+ if (isSetString$1(objectSchema.$ref)) return /^#\/(?:definitions|\$defs)\/(.+)$/.exec(objectSchema.$ref)?.[1] ?? objectSchema.$ref;
943
+ const primaryType = getPrimarySchemaType(schema);
944
+ if (primaryType) {
945
+ if (primaryType === "integer" || primaryType === "number") return "number";
946
+ return primaryType;
947
+ }
948
+ if (objectSchema.type === "array" && Array.isArray(objectSchema.enum)) return objectSchema.enum.map((value) => JSON.stringify(value)).join(" | ");
949
+ if (objectSchema.const !== void 0) return JSON.stringify(objectSchema.const);
950
+ if (objectSchema.type === "array" || objectSchema.items) return `${stringifyType(objectSchema.items)}[]`;
951
+ if (objectSchema.type === "object" || objectSchema.properties || objectSchema.additionalProperties) {
952
+ if (isJsonSchema(objectSchema.additionalProperties)) return `{ [key: string]: ${stringifyType(objectSchema.additionalProperties)} }`;
953
+ if (isJsonSchemaObject(objectSchema)) {
954
+ const required = objectSchema.required ?? [];
955
+ return `{ ${getPropertiesList(objectSchema).map((property) => {
956
+ const suffix = !required.includes(property.name) || isSchemaNullable(property) ? `${!required.includes(property.name) ? "?" : ""}${isSchemaNullable(property) ? " | null" : ""}` : "";
957
+ return `${property.name}${suffix}: ${stringifyType(property)}`;
958
+ }).join(";\n")} }`;
959
+ }
960
+ }
961
+ if (objectSchema.oneOf || objectSchema.anyOf) return (objectSchema.oneOf ?? objectSchema.anyOf ?? []).map((branch) => stringifyType(branch)).join(" | ");
962
+ if (objectSchema.allOf) return "object";
963
+ return "unknown";
964
+ }
965
+ /**
966
+ * Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.
967
+ *
968
+ * @param value - The value whose type is to be represented as a string.
969
+ * @returns A string representation of the value's type, which may be influenced by the provided JSON Schema primitive type hint. The function handles various JavaScript types and formats them accordingly, including special handling for `undefined`, `null`, booleans, numbers (with formatting), strings, objects, and arrays. If a specific type hint is provided, it will take precedence in determining the string representation of the value.
970
+ */
971
+ function getJsonSchemaType(value) {
972
+ return isNull$1(value) ? "null" : isBoolean$1(value) ? "boolean" : isInteger(value) ? "integer" : isNumber$1(value) ? "number" : isString(value) ? "string" : isObject(value) ? "object" : Array.isArray(value) ? "array" : void 0;
973
+ }
974
+ /**
975
+ * Generates standalone JSON Schema validation code using Ajv.
976
+ */
977
+ async function generateCode(schemas, refsOrFuncts) {
978
+ return standaloneCode(getValidator(schemas), refsOrFuncts);
979
+ }
980
+
981
+ //#endregion
982
+ //#region src/persistence.ts
983
+ /**
984
+ * A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
985
+ *
986
+ * @param context - The context object providing access to the cache path.
987
+ * @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
988
+ */
989
+ function getCacheDirectory(context) {
990
+ return joinPaths(context.cachePath, "schemas");
991
+ }
992
+ /**
993
+ * A helper function to get the file path for a cached schema based on the provided context and schema input. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file by joining the cache directory path (obtained from the `getCacheDirectory` function) with a filename derived from the extracted hash. The resulting file path points to where the cached schema should be stored or retrieved from in the file system. This function is essential for ensuring that all operations related to caching schemas use a consistent method for determining the correct file path based on the schema's unique identifier (hash).
994
+ *
995
+ * @param context - The context object providing access to the cache path.
996
+ * @param input - The input schema from which to extract the variant and hash for constructing the cache file path.
997
+ * @returns The file path to the cached schema JSON file, constructed by joining the cache directory path with a filename derived from the extracted hash of the schema input.
998
+ */
999
+ function getCacheFilePath(context, input) {
1000
+ const hash = extractHash(extractVariant(input), input);
1001
+ return joinPaths(getCacheDirectory(context), `${hash}.json`);
1002
+ }
1003
+ /**
1004
+ * Writes a given schema to the file system using the provided context. This function first checks if the input is a valid schema using the `isSchema` type guard. If the input is not a valid schema, it throws an error indicating that the provided input is invalid. If the input is valid, it proceeds to write the schema to a JSON file in the cache directory specified by the context. The file is named using the hash of the schema to ensure uniqueness and easy retrieval in future operations. The schema is serialized to JSON format before being written to the file system. This function is asynchronous and returns a promise that resolves once the writing operation is complete.
1005
+ *
1006
+ * @param context - The context object providing access to the file system and cache path.
1007
+ * @param schema - The schema to be written to the file system, which must be a valid schema object containing a `variant`, `schema`, and `hash` property.
1008
+ * @throws Will throw an error if the provided input is not a valid schema.
1009
+ */
1010
+ async function writeSchema(context, schema) {
1011
+ if (!isSchema(schema)) throw new Error(`The provided input is not a valid schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);
1012
+ await context.fs.write(getCacheFilePath(context, schema), JSON.stringify(schema.schema));
1013
+ }
1014
+ /**
1015
+ * A helper function to read a schema from the file system using the provided context. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file based on the cache path provided in the context and the extracted hash. The function checks if the file exists in the cache; if it does not exist, it returns `undefined`. If the file exists, it reads the contents of the file, parses it as JSON, and returns the resulting object. This function is asynchronous and returns a promise that resolves to either the parsed schema object or `undefined` if the schema is not found in the cache.
1016
+ *
1017
+ * @param context - The context object providing access to the file system and cache path.
1018
+ * @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
1019
+ * @returns A promise that resolves to the parsed schema object if found in the cache, or `undefined` if the schema does not exist in the cache.
1020
+ */
1021
+ async function readSchemaSafe(context, input) {
1022
+ const cacheFilePath = getCacheFilePath(context, input);
1023
+ if (!await context.fs.exists(cacheFilePath)) return;
1024
+ const data = await context.fs.read(cacheFilePath);
1025
+ if (!data) return;
1026
+ return JSON.parse(data);
1027
+ }
1028
+ /**
1029
+ * Reads a schema from the file system using the provided context and input. This function first attempts to read the schema using the `readSchemaSafe` helper function, which returns `undefined` if the schema is not found in the cache. If the schema is not found, this function throws an error indicating that the schema with the specified variant and hash does not exist in the cache. The error message suggests that this may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. It advises ensuring that the schema is properly written to the cache before attempting to read it. If the schema is successfully read from the cache, it is returned as a parsed object. This function is asynchronous and returns a promise that resolves to the parsed schema object if found, or throws an error if the schema is not found in the cache.
1030
+ *
1031
+ * @param context - The context object providing access to the file system and cache path.
1032
+ * @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
1033
+ * @returns A promise that resolves to the parsed schema object if found in the cache, or throws an error if the schema does not exist in the cache.
1034
+ * @throws Will throw an error if the schema with the specified variant and hash does not exist in the cache.
1035
+ */
1036
+ async function readSchema(context, input) {
1037
+ const schema = await readSchemaSafe(context, input);
1038
+ if (!schema) {
1039
+ const variant = extractVariant(input);
1040
+ const hash = extractHash(variant, input);
1041
+ throw new Error(`The ${variant} schema with hash "${hash}" does not exist in the cache. This may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. Please ensure that the schema is properly written to the cache before attempting to read it.`);
1042
+ }
1043
+ return schema;
1044
+ }
1045
+
1046
+ //#endregion
1047
+ //#region src/reflection.ts
1048
+ /**
1049
+ * Maps a Deepkit numeric `brand` to JSON Schema `type` and `format`.
1050
+ *
1051
+ * @remarks
1052
+ * This function takes a `TypeNumberBrand` (which represents specific numeric types in Deepkit, such as `integer`, `float`, `int8`, etc.) and returns a corresponding JSON Schema fragment that includes the appropriate `type`, `format`, and any relevant keywords (like `multipleOf` for integers). If the brand is not recognized, it defaults to a generic JSON Schema for numbers.
1053
+ *
1054
+ * @param brand - The Deepkit numeric brand to convert.
1055
+ * @return A JSON Schema fragment representing the numeric type corresponding to the provided brand.
1056
+ */
1057
+ function numberBrandToJsonSchema(brand) {
1058
+ switch (brand) {
1059
+ case TypeNumberBrand.integer: return {
1060
+ type: "integer",
1061
+ format: "int32",
1062
+ multipleOf: 1
1063
+ };
1064
+ case TypeNumberBrand.int8: return {
1065
+ type: "integer",
1066
+ format: "int8",
1067
+ multipleOf: 1
1068
+ };
1069
+ case TypeNumberBrand.uint8: return {
1070
+ type: "integer",
1071
+ format: "uint8",
1072
+ multipleOf: 1
1073
+ };
1074
+ case TypeNumberBrand.int16: return {
1075
+ type: "integer",
1076
+ format: "int16",
1077
+ multipleOf: 1
1078
+ };
1079
+ case TypeNumberBrand.uint16: return {
1080
+ type: "integer",
1081
+ format: "uint16",
1082
+ multipleOf: 1
1083
+ };
1084
+ case TypeNumberBrand.int32: return {
1085
+ type: "integer",
1086
+ format: "int32",
1087
+ multipleOf: 1
1088
+ };
1089
+ case TypeNumberBrand.uint32: return {
1090
+ type: "integer",
1091
+ format: "uint32",
1092
+ multipleOf: 1
1093
+ };
1094
+ case TypeNumberBrand.float:
1095
+ case TypeNumberBrand.float32: return {
1096
+ type: "number",
1097
+ format: "float"
1098
+ };
1099
+ case TypeNumberBrand.float64: return {
1100
+ type: "number",
1101
+ format: "double"
1102
+ };
1103
+ case void 0:
1104
+ default: return { type: "number" };
1105
+ }
1106
+ }
1107
+ function withReflectionTags(reflection, schema) {
1108
+ if (!isSetObject(schema) || !isSetObject(reflection?.tags)) return schema;
1109
+ const updatedSchema = { ...schema };
1110
+ const tags = reflection.tags;
1111
+ if (isSetString(tags.title)) updatedSchema.title = tags.title;
1112
+ if (isSetArray(tags.alias)) updatedSchema.alias = tags.alias;
1113
+ if (!isUndefined(tags.hidden)) updatedSchema.hidden = tags.hidden;
1114
+ if (!isUndefined(tags.ignore)) updatedSchema.ignore = tags.ignore;
1115
+ if (!isUndefined(tags.internal)) updatedSchema.internal = tags.internal;
1116
+ if (!isUndefined(tags.runtime)) updatedSchema.runtime = tags.runtime;
1117
+ if (!isUndefined(tags.readonly)) updatedSchema.readOnly = tags.readonly;
1118
+ return updatedSchema;
1119
+ }
1120
+ function withNullable(schema) {
1121
+ if (!isSetObject(schema)) return { anyOf: [schema, {
1122
+ type: "null",
1123
+ default: null
1124
+ }] };
1125
+ const rawType = schema.type;
1126
+ const types = Array.isArray(rawType) ? [...rawType] : rawType ? [rawType] : [];
1127
+ if (!types.includes("null")) types.push("null");
1128
+ return {
1129
+ ...schema,
1130
+ type: types.length === 1 ? types[0] : types
1131
+ };
1132
+ }
1133
+ /**
1134
+ * Converts a Deepkit type reflection into a JSON Schema (draft-07) fragment.
1135
+ */
1136
+ function reflectionToJsonSchema(reflection) {
1137
+ return reflectionToJsonSchemaInner(reflection);
1138
+ }
1139
+ function reflectionToJsonSchemaInner(reflection) {
1140
+ switch (reflection.kind) {
1141
+ case ReflectionKind.any:
1142
+ case ReflectionKind.unknown:
1143
+ case ReflectionKind.void:
1144
+ case ReflectionKind.object: return withReflectionTags(reflection, { name: reflection.typeName });
1145
+ case ReflectionKind.never: return;
1146
+ case ReflectionKind.undefined:
1147
+ case ReflectionKind.null: return withReflectionTags(reflection, {
1148
+ type: "null",
1149
+ name: reflection.typeName,
1150
+ default: null
1151
+ });
1152
+ case ReflectionKind.string: return withReflectionTags(reflection, {
1153
+ type: "string",
1154
+ name: reflection.typeName
1155
+ });
1156
+ case ReflectionKind.boolean: return withReflectionTags(reflection, {
1157
+ type: "boolean",
1158
+ name: reflection.typeName
1159
+ });
1160
+ case ReflectionKind.number: return withReflectionTags(reflection, numberBrandToJsonSchema(reflection.brand));
1161
+ case ReflectionKind.bigint: return withReflectionTags(reflection, {
1162
+ type: "integer",
1163
+ name: reflection.typeName,
1164
+ format: "int64"
1165
+ });
1166
+ case ReflectionKind.regexp: return withReflectionTags(reflection, {
1167
+ type: "string",
1168
+ name: reflection.typeName,
1169
+ format: "regex",
1170
+ contentMediaType: "text/regex"
1171
+ });
1172
+ case ReflectionKind.literal: {
1173
+ const { literal } = reflection;
1174
+ if (isBigInt(literal)) return withReflectionTags(reflection, {
1175
+ type: "integer",
1176
+ name: reflection.typeName,
1177
+ format: "int64",
1178
+ const: literal
1179
+ });
1180
+ if (isRegExp(literal)) return withReflectionTags(reflection, {
1181
+ type: "string",
1182
+ name: reflection.typeName,
1183
+ format: "regex",
1184
+ const: literal.source
1185
+ });
1186
+ return withReflectionTags(reflection, {
1187
+ type: getJsonSchemaType(literal),
1188
+ name: reflection.typeName,
1189
+ const: literal
1190
+ });
1191
+ }
1192
+ case ReflectionKind.templateLiteral: return withReflectionTags(reflection, { type: "string" });
1193
+ case ReflectionKind.enum: {
1194
+ const values = reflection.values.filter((value) => isString(value) || isInteger(value) || isBigInt(value) || isNumber(value) || isBoolean(value) || isNull(value));
1195
+ if (values.length === 0) return withReflectionTags(reflection, {
1196
+ name: reflection.typeName,
1197
+ description: reflection.description,
1198
+ enum: []
1199
+ });
1200
+ return withReflectionTags(reflection, {
1201
+ type: values.every((value) => isString(value)) ? "string" : values.every((value) => isInteger(value) || isBigInt(value)) ? "integer" : values.every((value) => isNumber(value)) ? "number" : values.every((value) => isBoolean(value)) ? "boolean" : values.every((value) => isNull(value)) ? "null" : values.reduce((ret, value) => {
1202
+ const type = getJsonSchemaType(value);
1203
+ if (isJsonSchemaPrimitiveType(type) && !ret.includes(type)) ret.push(type);
1204
+ return ret;
1205
+ }, []),
1206
+ name: reflection.typeName,
1207
+ description: reflection.description,
1208
+ enum: values,
1209
+ default: values.length === 1 ? values[0] : void 0
1210
+ });
1211
+ }
1212
+ case ReflectionKind.array: {
1213
+ const items = reflectionToJsonSchemaInner(reflection.type);
1214
+ return withReflectionTags(reflection, {
1215
+ type: "array",
1216
+ name: reflection.typeName,
1217
+ items: items ?? {}
1218
+ });
1219
+ }
1220
+ case ReflectionKind.tuple: {
1221
+ const items = reflection.types.map((member) => reflectionToJsonSchemaInner(member.type)).filter((item) => item !== void 0);
1222
+ if (items.length <= 1) return withReflectionTags(reflection, {
1223
+ type: "array",
1224
+ name: reflection.typeName,
1225
+ items: items.length === 1 ? items[0] : {}
1226
+ });
1227
+ return withReflectionTags(reflection, {
1228
+ type: "array",
1229
+ name: reflection.typeName,
1230
+ prefixItems: items,
1231
+ minItems: items.length,
1232
+ maxItems: items.length
1233
+ });
1234
+ }
1235
+ case ReflectionKind.union: {
1236
+ const branches = reflection.types.map((inner) => reflectionToJsonSchemaInner(inner)).filter((branch) => branch !== void 0);
1237
+ if (!reflection.types.some((inner) => inner.kind === ReflectionKind.null || inner.kind === ReflectionKind.undefined)) return withReflectionTags(reflection, {
1238
+ name: reflection.typeName,
1239
+ anyOf: branches
1240
+ });
1241
+ const nonNull = branches.filter((branch) => !isNullOnlyJsonSchema(branch));
1242
+ if (nonNull.length === 0) return withReflectionTags(reflection, {
1243
+ type: "null",
1244
+ default: null
1245
+ });
1246
+ if (nonNull.length === 1) {
1247
+ const first = nonNull[0];
1248
+ if (!isSetObject(first)) return withNullable(withReflectionTags(reflection, {
1249
+ name: reflection.typeName,
1250
+ anyOf: [first]
1251
+ }));
1252
+ return withNullable(withReflectionTags(reflection, {
1253
+ name: reflection.typeName,
1254
+ ...first
1255
+ }));
1256
+ }
1257
+ const enumValues = nonNull.map((branch) => isSetObject(branch) ? branch.const : void 0).filter((value) => value === null || typeof value === "string" || typeof value === "number" || typeof value === "bigint" || typeof value === "boolean");
1258
+ if (enumValues.length === nonNull.length) return withNullable(withReflectionTags(reflection, {
1259
+ name: reflection.typeName,
1260
+ enum: enumValues
1261
+ }));
1262
+ const discriminator = tryReflectionDiscriminator(reflection.types);
1263
+ if (discriminator && isSetObject(discriminator)) return withNullable(withReflectionTags(reflection, {
1264
+ name: reflection.typeName,
1265
+ ...discriminator
1266
+ }));
1267
+ return withNullable(withReflectionTags(reflection, {
1268
+ name: reflection.typeName,
1269
+ anyOf: nonNull
1270
+ }));
1271
+ }
1272
+ case ReflectionKind.intersection: {
1273
+ const members = reflection.types.map((inner) => reflectionToJsonSchemaInner(inner)).filter((item) => item !== void 0);
1274
+ if (members.length === 0) return;
1275
+ if (members.length === 1) {
1276
+ if (!isSetObject(members[0])) return members[0];
1277
+ return withReflectionTags(reflection, {
1278
+ name: reflection.typeName,
1279
+ ...members[0]
1280
+ });
1281
+ }
1282
+ if (members.every(isJsonSchemaObject)) return withReflectionTags(reflection, {
1283
+ name: reflection.typeName,
1284
+ ...mergeObjectSchemas(members)
1285
+ });
1286
+ return withReflectionTags(reflection, {
1287
+ name: reflection.typeName,
1288
+ allOf: members
1289
+ });
1290
+ }
1291
+ case ReflectionKind.promise: return reflectionToJsonSchemaInner(reflection.type);
1292
+ case ReflectionKind.objectLiteral: return objectReflectionToJsonSchema(reflection);
1293
+ case ReflectionKind.class: switch (reflection.classType?.name) {
1294
+ case "Date": return withReflectionTags(reflection, {
1295
+ type: "string",
1296
+ format: "date-time"
1297
+ });
1298
+ case "RegExp": return withReflectionTags(reflection, {
1299
+ type: "string",
1300
+ format: "regex"
1301
+ });
1302
+ case "URL": return withReflectionTags(reflection, {
1303
+ type: "string",
1304
+ format: "uri"
1305
+ });
1306
+ case "Set": {
1307
+ const itemType = reflection.arguments?.[0];
1308
+ return withReflectionTags(reflection, {
1309
+ type: "array",
1310
+ items: (itemType ? reflectionToJsonSchemaInner(itemType) : void 0) ?? {},
1311
+ uniqueItems: true
1312
+ });
1313
+ }
1314
+ case "Map": {
1315
+ const valueType = reflection.arguments?.[1];
1316
+ return withReflectionTags(reflection, {
1317
+ type: "object",
1318
+ additionalProperties: (valueType ? reflectionToJsonSchemaInner(valueType) : void 0) ?? true
1319
+ });
1320
+ }
1321
+ case "Uint8Array":
1322
+ case "Uint8ClampedArray":
1323
+ case "Uint16Array":
1324
+ case "Uint32Array":
1325
+ case "Int8Array":
1326
+ case "Int16Array":
1327
+ case "Int32Array":
1328
+ case "Float32Array":
1329
+ case "Float64Array":
1330
+ case "BigInt64Array":
1331
+ case "BigUint64Array": return withReflectionTags(reflection, {
1332
+ type: "string",
1333
+ format: "byte",
1334
+ contentEncoding: "base64"
1335
+ });
1336
+ case void 0:
1337
+ default: return withReflectionTags(reflection, {
1338
+ name: reflection.typeName,
1339
+ description: reflection.description,
1340
+ ...objectReflectionToJsonSchema(reflection)
1341
+ });
1342
+ }
1343
+ case ReflectionKind.symbol:
1344
+ case ReflectionKind.property:
1345
+ case ReflectionKind.method:
1346
+ case ReflectionKind.function:
1347
+ case ReflectionKind.parameter:
1348
+ case ReflectionKind.typeParameter:
1349
+ case ReflectionKind.tupleMember:
1350
+ case ReflectionKind.enumMember:
1351
+ case ReflectionKind.rest:
1352
+ case ReflectionKind.indexSignature:
1353
+ case ReflectionKind.propertySignature:
1354
+ case ReflectionKind.methodSignature:
1355
+ case ReflectionKind.infer:
1356
+ case ReflectionKind.callSignature:
1357
+ default: return;
1358
+ }
1359
+ }
1360
+ function mergeObjectSchemas(schemas) {
1361
+ const merged = {
1362
+ type: "object",
1363
+ properties: {},
1364
+ required: []
1365
+ };
1366
+ for (const schema of schemas) {
1367
+ if (schema.properties) merged.properties = defu(merged.properties, schema.properties);
1368
+ if (schema.required) merged.required = Array.from(new Set([...merged.required ?? [], ...schema.required]));
1369
+ if (schema.additionalProperties !== void 0) merged.additionalProperties = schema.additionalProperties;
1370
+ }
1371
+ if ((merged.required?.length ?? 0) === 0) delete merged.required;
1372
+ return merged;
1373
+ }
1374
+ function tryReflectionDiscriminator(types) {
1375
+ const nonNullTypes = types.filter((t) => t.kind !== ReflectionKind.null && t.kind !== ReflectionKind.undefined);
1376
+ const objectBranches = nonNullTypes.filter((t) => t.kind === ReflectionKind.objectLiteral || t.kind === ReflectionKind.class);
1377
+ if (objectBranches.length < 2 || objectBranches.length !== nonNullTypes.length) return;
1378
+ let tagKey;
1379
+ const branches = [];
1380
+ for (const branch of objectBranches) {
1381
+ const literalProps = [];
1382
+ for (const member of branch.types) if ((member.kind === ReflectionKind.property || member.kind === ReflectionKind.propertySignature) && typeof member.name === "string" && member.type.kind === ReflectionKind.literal && typeof member.type.literal === "string") literalProps.push({
1383
+ name: member.name,
1384
+ literal: member.type.literal
1385
+ });
1386
+ if (literalProps.length === 0) return;
1387
+ const first = literalProps[0];
1388
+ if (!tagKey) tagKey = first.name;
1389
+ else if (tagKey !== first.name) return;
1390
+ const body = objectReflectionToJsonSchema({
1391
+ ...branch,
1392
+ types: branch.types.filter((member) => !((member.kind === ReflectionKind.property || member.kind === ReflectionKind.propertySignature) && member.name === tagKey))
1393
+ });
1394
+ if (!body || !isJsonSchemaObject(body)) return;
1395
+ branches.push({
1396
+ type: "object",
1397
+ properties: {
1398
+ [tagKey]: { const: first.literal },
1399
+ ...body.properties ?? {}
1400
+ },
1401
+ required: [tagKey, ...body.required ?? []],
1402
+ additionalProperties: body.additionalProperties ?? false
1403
+ });
1404
+ }
1405
+ if (!tagKey) return;
1406
+ return {
1407
+ oneOf: branches,
1408
+ discriminator: { propertyName: tagKey }
1409
+ };
1410
+ }
1411
+ function objectReflectionToJsonSchema(type) {
1412
+ const reflection = ReflectionClass.from(type);
1413
+ const schema = {
1414
+ type: "object",
1415
+ name: reflection.getName(),
1416
+ description: reflection.getDescription(),
1417
+ properties: {},
1418
+ required: [],
1419
+ readOnly: reflection.isReadonly(),
1420
+ ignore: reflection.isIgnored(),
1421
+ internal: reflection.isInternal(),
1422
+ runtime: reflection.isRuntime(),
1423
+ hidden: reflection.isHidden(),
1424
+ primaryKey: reflection.getPrimaries().map((primary) => primary.getNameAsString()),
1425
+ ...isSetString(reflection.databaseSchemaName) ? { databaseSchemaName: reflection.databaseSchemaName } : {},
1426
+ ...isSetString(reflection.getName()) ? { name: reflection.getName() } : {},
1427
+ ...isSetString(reflection.getDescription()) ? { description: reflection.getDescription() } : {},
1428
+ ...isSetArray(reflection.getAlias()) ? { alias: reflection.getAlias() } : {},
1429
+ ...isSetString(reflection.getTitle()) ? { title: reflection.getTitle() } : {}
1430
+ };
1431
+ for (const propertyReflection of reflection.getProperties()) {
1432
+ if (propertyReflection.getKind() === ReflectionKind.indexSignature) {
1433
+ schema.additionalProperties = reflectionToJsonSchemaInner(propertyReflection.type) ?? true;
1434
+ continue;
1435
+ }
1436
+ let property = reflectionToJsonSchemaInner(propertyReflection.type);
1437
+ if (!property) continue;
1438
+ property = {
1439
+ ...isSetObject(property) ? property : {},
1440
+ name: propertyReflection.getNameAsString(),
1441
+ description: propertyReflection.getDescription(),
1442
+ readOnly: propertyReflection.isReadonly(),
1443
+ ignore: propertyReflection.isIgnored(),
1444
+ internal: propertyReflection.isInternal(),
1445
+ runtime: propertyReflection.isRuntime(),
1446
+ hidden: propertyReflection.isHidden(),
1447
+ ...propertyReflection.hasDefault() ? { default: propertyReflection.getDefaultValue() } : {},
1448
+ ...isSetArray(propertyReflection.getGroups()) ? { tags: propertyReflection.getGroups() } : {},
1449
+ ...isSetArray(propertyReflection.getAlias()) ? { alias: propertyReflection.getAlias() } : {},
1450
+ ...isSetString(propertyReflection.getTitle()) ? { title: propertyReflection.getTitle() } : {}
1451
+ };
1452
+ if (propertyReflection.isNullable()) property = withNullable(property);
1453
+ schema.properties ??= {};
1454
+ schema.properties[propertyReflection.name] = property;
1455
+ if (!propertyReflection.isOptional()) {
1456
+ schema.required ??= [];
1457
+ schema.required.push(propertyReflection.name);
1458
+ }
1459
+ }
1460
+ return schema;
1461
+ }
1462
+
1463
+ //#endregion
1464
+ //#region src/resolve.ts
1465
+ /**
1466
+ * Compiles a type definition to a module and returns the module.
1467
+ *
1468
+ * @param context - The context object containing the environment paths.
1469
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
1470
+ * @param overrides - Optional overrides for the ESBuild configuration.
1471
+ * @returns A promise that resolves to the compiled module.
1472
+ */
1473
+ async function resolveModule(context, input, overrides) {
1474
+ const fileReference = extractFileReference(input);
1475
+ if (!fileReference) throw new Error(`Failed to extract a file reference from the provided input ${JSON.stringify(input)}. The input must be a string or an object with a "file" property that specifies the file path and optional export name.`);
1476
+ const result = await bundle(context, fileReference.file, overrides);
1477
+ let resolved;
1478
+ try {
1479
+ resolved = await context.resolver.evalModule(result.text, {
1480
+ filename: result.path,
1481
+ ext: findFileDotExtension(result.path)
1482
+ });
1483
+ } catch (error) {
1484
+ if (isSetString$1(error.message) && new RegExp(`Cannot find module '${context.config.framework?.name || "powerlines"}:.*'`).test(error.message)) {
1485
+ const moduleName = error.message.match(new RegExp(`Cannot find module '(${context.config.framework?.name || "powerlines"}:.*)'`))?.[1];
1486
+ throw new Error(`The module "${moduleName}" could not be resolved while evaluating "${fileReference.file}". It is possible the required built-in modules have not yet been generated. Please check the order of your plugins. ${context.config.logLevel.general === "debug" || context.config.logLevel.general === "trace" ? `
1487
+
1488
+ Bundle output for module:
1489
+ ${result.text}` : ""}`);
1490
+ }
1491
+ throw new Error(`Failed to evaluate the bundled module for "${fileReference.file}". Error: ${error.message}${context.config.logLevel.general === "debug" || context.config.logLevel.general === "trace" ? `
1492
+
1493
+ Bundle output for module:
1494
+ ${result.text}` : ""}`);
1495
+ }
1496
+ return resolved;
1497
+ }
1498
+ /**
1499
+ * Compiles a type definition to a module and returns the specified export from the module.
1500
+ *
1501
+ * @param context - The context object containing the environment paths.
1502
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
1503
+ * @param options - Optional overrides for the ESBuild configuration.
1504
+ * @returns A promise that resolves to the compiled module.
1505
+ */
1506
+ async function resolve(context, input, options) {
1507
+ const fileReference = extractFileReference(input);
1508
+ if (!fileReference) throw new Error(`Failed to extract a file reference from the provided input. The input must be a string or an object with a "file" property that specifies the file path and optional export name.`);
1509
+ const extension = findFileExtensionSafe(fileReference.file);
1510
+ if (extension.startsWith("json")) try {
1511
+ const json = await context.fs.read(fileReference.file);
1512
+ if (!isSetString$1(json)) throw new Error(`The file at "${fileReference.file}" could not be read as a string. Please ensure the file exists and contains valid JSON.`);
1513
+ return JSON.parse(json);
1514
+ } catch (error) {
1515
+ throw new Error(`Failed to read or parse the JSON file at "${fileReference.file}". Please ensure the file exists and contains valid JSON. Error: ${error.message}`);
1516
+ }
1517
+ else if (extension === "yaml" || extension === "yml") try {
1518
+ const yaml = await context.fs.read(fileReference.file);
1519
+ if (!isSetString$1(yaml)) throw new Error(`The file at "${fileReference.file}" could not be read as a string. Please ensure the file exists and contains valid YAML.`);
1520
+ return parse$1(yaml);
1521
+ } catch (error) {
1522
+ throw new Error(`Failed to read or parse the YAML file at "${fileReference.file}". Please ensure the file exists and contains valid YAML. Error: ${error.message}`);
1523
+ }
1524
+ else if (extension === "toml") try {
1525
+ const toml = await context.fs.read(fileReference.file);
1526
+ if (!isSetString$1(toml)) throw new Error(`The file at "${fileReference.file}" could not be read as a string. Please ensure the file exists and contains valid TOML.`);
1527
+ return parse(toml);
1528
+ } catch (error) {
1529
+ throw new Error(`Failed to read or parse the TOML file at "${fileReference.file}". Please ensure the file exists and contains valid TOML. Error: ${error.message}`);
1530
+ }
1531
+ const resolved = await resolveModule(context, fileReference, options);
1532
+ let exportName = fileReference.export;
1533
+ if (!exportName) exportName = "default";
1534
+ const resolvedExport = resolved[exportName] ?? resolved[`__Ω${exportName}`];
1535
+ if (resolvedExport === void 0) throw new Error(`The export "${exportName}" could not be resolved in the "${fileReference.file}" module. ${Object.keys(resolved).length === 0 ? `After bundling, no exports were found in the module. Please ensure that the "${fileReference.file}" module has a "${exportName}" export with the desired value.` : `After bundling, the available exports were: ${Object.keys(resolved).join(", ")}. Please ensure that the export exists and is correctly named.`}`);
1536
+ return resolvedExport;
1537
+ }
1538
+ /**
1539
+ * Resolves a type definition to a Deepkit Type reflection. This function compiles the provided type definition to a module, evaluates the module to get the specified export, and then reflects the export to get its Deepkit Type reflection.
1540
+ *
1541
+ * @param context - The context object containing the environment paths.
1542
+ * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
1543
+ * @param options - Optional overrides for the ESBuild configuration.
1544
+ * @returns A promise that resolves to the Deepkit Type reflection.
1545
+ */
1546
+ async function resolveReflection(context, input, options) {
1547
+ return reflect(await resolve(context, input, defu(options, { plugins: [esbuildPlugin(context, {
1548
+ reflection: "default",
1549
+ level: "all"
1550
+ })] })));
1551
+ }
1552
+
1553
+ //#endregion
1554
+ //#region src/extract.ts
1555
+ const SCHEMA_BUNDLE_BASE_URI = "https://powerlines.invalid/";
1556
+ function normalizeUri(uri) {
1557
+ return uri.endsWith("#") ? uri.slice(0, -1) : uri;
1558
+ }
1559
+ function stripUriFragment(uri) {
1560
+ const hashIndex = uri.indexOf("#");
1561
+ return hashIndex >= 0 ? uri.slice(0, hashIndex) : uri;
1562
+ }
1563
+ function escapeJsonPointerToken(token) {
1564
+ return token.replaceAll("~", "~0").replaceAll("/", "~1");
1565
+ }
1566
+ function toJsonPointer(path) {
1567
+ if (path.length === 0) return "";
1568
+ return `/${path.map((segment) => escapeJsonPointerToken(segment)).join("/")}`;
1569
+ }
1570
+ function resolveUri(reference, baseUri) {
1571
+ try {
1572
+ return normalizeUri(new URL(reference, baseUri).toString());
1573
+ } catch {
1574
+ return normalizeUri(reference);
1575
+ }
1576
+ }
1577
+ function collectReferenceTargets(value, path, baseUri, uriToPointer, dynamicUriToFragment) {
1578
+ if (!isSetObject$1(value)) return;
1579
+ const schema = value;
1580
+ const pointer = toJsonPointer(path);
1581
+ const currentBaseUri = isSetString(schema.$id) ? resolveUri(schema.$id, baseUri) : baseUri;
1582
+ const currentDocumentUri = stripUriFragment(currentBaseUri);
1583
+ uriToPointer.set(currentBaseUri, pointer);
1584
+ uriToPointer.set(currentDocumentUri, pointer);
1585
+ if (isSetString(schema.$anchor)) uriToPointer.set(`${currentDocumentUri}#${schema.$anchor}`, pointer);
1586
+ if (isSetString(schema.$dynamicAnchor)) {
1587
+ const dynamicTarget = `${currentDocumentUri}#${schema.$dynamicAnchor}`;
1588
+ uriToPointer.set(dynamicTarget, pointer);
1589
+ dynamicUriToFragment.set(dynamicTarget, `#${schema.$dynamicAnchor}`);
1590
+ }
1591
+ for (const [key, child] of Object.entries(schema)) {
1592
+ if (Array.isArray(child)) {
1593
+ child.forEach((entry, index) => {
1594
+ collectReferenceTargets(entry, [
1595
+ ...path,
1596
+ key,
1597
+ String(index)
1598
+ ], currentBaseUri, uriToPointer, dynamicUriToFragment);
1599
+ });
1600
+ continue;
1601
+ }
1602
+ collectReferenceTargets(child, [...path, key], currentBaseUri, uriToPointer, dynamicUriToFragment);
1603
+ }
1604
+ }
1605
+ function rewriteReferenceTargets(value, path, baseUri, uriToPointer, dynamicUriToFragment) {
1606
+ if (!isSetObject$1(value)) return;
1607
+ const schema = value;
1608
+ const currentBaseUri = isSetString(schema.$id) ? resolveUri(schema.$id, baseUri) : baseUri;
1609
+ if (isSetString(schema.$ref)) {
1610
+ const resolvedRefUri = resolveUri(schema.$ref, currentBaseUri);
1611
+ const pointer = uriToPointer.get(resolvedRefUri) ?? uriToPointer.get(stripUriFragment(resolvedRefUri));
1612
+ if (pointer !== void 0) schema.$ref = pointer.length > 0 ? `#${pointer}` : "#";
1613
+ }
1614
+ if (isSetString(schema.$dynamicRef)) {
1615
+ const resolvedDynamicRefUri = resolveUri(schema.$dynamicRef, currentBaseUri);
1616
+ const dynamicFragment = dynamicUriToFragment.get(resolvedDynamicRefUri);
1617
+ if (dynamicFragment) schema.$dynamicRef = dynamicFragment;
1618
+ else {
1619
+ const pointer = uriToPointer.get(resolvedDynamicRefUri) ?? uriToPointer.get(stripUriFragment(resolvedDynamicRefUri));
1620
+ if (pointer !== void 0) schema.$dynamicRef = pointer.length > 0 ? `#${pointer}` : "#";
1621
+ }
1622
+ }
1623
+ for (const [key, child] of Object.entries(schema)) {
1624
+ if (Array.isArray(child)) {
1625
+ child.forEach((entry, index) => {
1626
+ rewriteReferenceTargets(entry, [
1627
+ ...path,
1628
+ key,
1629
+ String(index)
1630
+ ], currentBaseUri, uriToPointer, dynamicUriToFragment);
1631
+ });
1632
+ continue;
1633
+ }
1634
+ rewriteReferenceTargets(child, [...path, key], currentBaseUri, uriToPointer, dynamicUriToFragment);
1635
+ }
1636
+ }
1637
+ /**
1638
+ * Bundles all external references in a JSON Schema into a single schema document by collecting all reference targets and rewriting the references to point to the bundled definitions. This ensures that the resulting schema is self-contained and can be used independently without relying on external documents.
1639
+ *
1640
+ * @param schema - The JSON Schema to bundle references for.
1641
+ * @returns A new JSON Schema with all references bundled and rewritten to point to the bundled definitions.
1642
+ */
1643
+ function bundleReferences(schema) {
1644
+ if (!isSetObject$1(schema)) return schema;
1645
+ const bundledSchema = deepClone(schema);
1646
+ const baseUri = isSetString(bundledSchema.$id) ? resolveUri(bundledSchema.$id, SCHEMA_BUNDLE_BASE_URI) : SCHEMA_BUNDLE_BASE_URI;
1647
+ const uriToPointer = /* @__PURE__ */ new Map();
1648
+ const dynamicUriToFragment = /* @__PURE__ */ new Map();
1649
+ collectReferenceTargets(bundledSchema, [], baseUri, uriToPointer, dynamicUriToFragment);
1650
+ rewriteReferenceTargets(bundledSchema, [], baseUri, uriToPointer, dynamicUriToFragment);
1651
+ return bundledSchema;
1652
+ }
1653
+ function convertNestedUntypedSchema(value) {
1654
+ if (isUntypedSchema(value)) return convertUntypedSchemaToJsonSchema(value);
1655
+ if (isSetObject$1(value)) {
1656
+ if (isUntypedInput(value)) return convertUntypedInputToJsonSchema(value);
1657
+ const nested = value;
1658
+ if ("$schema" in nested && isUntypedSchema(nested.$schema)) return convertUntypedSchemaToJsonSchema(nested.$schema);
1659
+ }
1660
+ return value;
1661
+ }
1662
+ function convertNestedUntypedSchemaArray(value) {
1663
+ if (!Array.isArray(value)) return value;
1664
+ return value.map((item) => convertNestedUntypedSchema(item));
1665
+ }
1666
+ function convertValibotSchemaToJsonSchema(schema) {
1667
+ return toJsonSchema(schema, { target: "draft-2020-12" });
1668
+ }
1669
+ function convertUntypedSchemaToJsonSchema(schema) {
1670
+ const source = schema;
1671
+ const jsonSchema = {};
1672
+ for (const [key, value] of Object.entries(source)) {
1673
+ if (key === "tsType" || key === "markdownType" || key === "tags" || key === "args" || key === "resolve") continue;
1674
+ if (key === "id" && isSetString(value)) {
1675
+ jsonSchema.$id = value;
1676
+ continue;
1677
+ }
1678
+ if (key === "properties" || key === "patternProperties" || key === "dependentSchemas" || key === "$defs" || key === "definitions") {
1679
+ if (!isSetObject$1(value)) {
1680
+ jsonSchema[key] = value;
1681
+ continue;
1682
+ }
1683
+ jsonSchema[key] = Object.fromEntries(Object.entries(value).map(([propertyKey, propertyValue]) => [propertyKey, convertNestedUntypedSchema(propertyValue)]));
1684
+ continue;
1685
+ }
1686
+ if (key === "items" || key === "contains" || key === "if" || key === "then" || key === "else" || key === "not" || key === "propertyNames" || key === "additionalProperties" || key === "unevaluatedProperties") {
1687
+ jsonSchema[key] = convertNestedUntypedSchema(value);
1688
+ continue;
1689
+ }
1690
+ if (key === "oneOf" || key === "anyOf" || key === "allOf") {
1691
+ jsonSchema[key] = convertNestedUntypedSchemaArray(value);
1692
+ continue;
1693
+ }
1694
+ jsonSchema[key] = value;
1695
+ }
1696
+ return jsonSchema;
1697
+ }
1698
+ function convertUntypedInputToJsonSchema(input) {
1699
+ const inputObject = input;
1700
+ const base = isUntypedSchema(inputObject.$schema) ? convertUntypedSchemaToJsonSchema(inputObject.$schema) : {};
1701
+ const properties = {};
1702
+ for (const [key, value] of Object.entries(inputObject)) {
1703
+ if (key.startsWith("$")) continue;
1704
+ if (!isSetObject$1(value)) continue;
1705
+ if (isUntypedInput(value)) {
1706
+ properties[key] = convertUntypedInputToJsonSchema(value);
1707
+ continue;
1708
+ }
1709
+ const nested = value;
1710
+ if ("$schema" in nested && isUntypedSchema(nested.$schema)) {
1711
+ properties[key] = convertUntypedSchemaToJsonSchema(nested.$schema);
1712
+ continue;
1713
+ }
1714
+ if (isUntypedSchema(value)) properties[key] = convertUntypedSchemaToJsonSchema(value);
1715
+ }
1716
+ if (!isJsonSchemaObject(base)) throw new Error(`Failed to convert untyped input to JSON Schema. The base schema must be a valid JSON Schema object.`);
1717
+ const mergedProperties = {
1718
+ ...isSetObject$1(base.properties) ? base.properties : {},
1719
+ ...properties
1720
+ };
1721
+ return {
1722
+ ...base,
1723
+ type: base.type ?? "object",
1724
+ ...Object.keys(mergedProperties).length > 0 ? { properties: mergedProperties } : {}
1725
+ };
1726
+ }
1727
+ /**
1728
+ * Creates a hash string for a given schema definition input.
1729
+ */
1730
+ function extractHash(variant, input) {
1731
+ if (isSetString(input)) return murmurhash({
1732
+ variant,
1733
+ input
1734
+ });
1735
+ else if (typeof input === "boolean") return murmurhash({
1736
+ variant,
1737
+ input
1738
+ });
1739
+ else if (isSetObject$1(input)) {
1740
+ if (isZod3Type(input)) return murmurhash({
1741
+ variant,
1742
+ input: input._def
1743
+ });
1744
+ else if (isType(input)) return murmurhash({
1745
+ variant,
1746
+ input: stringifyType$1(input)
1747
+ });
1748
+ else if (isStandardJsonSchema(input)) return murmurhash({
1749
+ variant,
1750
+ input: input["~standard"]
1751
+ });
1752
+ else if (isJsonSchema(input)) return murmurhash({
1753
+ variant,
1754
+ input
1755
+ });
1756
+ else if (isValibotSchema(input)) return murmurhash({
1757
+ variant,
1758
+ input: convertValibotSchemaToJsonSchema(input)
1759
+ });
1760
+ else if (isUntypedInput(input)) return murmurhash({
1761
+ variant,
1762
+ input: convertUntypedInputToJsonSchema(input)
1763
+ });
1764
+ else if (isUntypedSchema(input)) return murmurhash({
1765
+ variant,
1766
+ input: convertUntypedSchemaToJsonSchema(input)
1767
+ });
1768
+ }
1769
+ 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, a Valibot BaseSchema, or a reflected Deepkit Type object.`);
1770
+ }
1771
+ /**
1772
+ * Converts a reflected Deepkit {@link Type} into a JSON Schema (draft-2020-12) representation.
1773
+ */
1774
+ function extractReflection(reflection) {
1775
+ if (!isType(reflection)) return;
1776
+ return reflectionToJsonSchema(reflection);
1777
+ }
1778
+ /**
1779
+ * Extracts a JSON Schema from Zod, Standard Schema, Valibot, untyped, or JSON Schema inputs.
1780
+ *
1781
+ * @param schema - The schema input to extract a JSON Schema from.
1782
+ * @returns The extracted JSON Schema, or `undefined` if the input is not a supported schema type.
1783
+ */
1784
+ function extractJsonSchema(schema) {
1785
+ if (isSetObject$1(schema)) {
1786
+ if (isZod3Type(schema)) return extractJsonSchema$1(schema, { target: "draft-2020-12" });
1787
+ if (isUntypedInputStrict(schema)) return convertUntypedInputToJsonSchema(schema);
1788
+ if (isUntypedSchemaStrict(schema)) return convertUntypedSchemaToJsonSchema(schema);
1789
+ if (isStandardJsonSchema(schema)) return schema["~standard"].jsonSchema.input({ target: "draft-2020-12" });
1790
+ if (isValibotSchema(schema)) return convertValibotSchemaToJsonSchema(schema);
1791
+ if (isJsonSchema(schema)) return schema;
1792
+ }
1793
+ }
1794
+ /**
1795
+ * Resolves the concrete source variant for a schema source input.
1796
+ *
1797
+ * @param input - The schema source input to inspect.
1798
+ * @returns The resolved schema source variant.
1799
+ * @throws Will throw an error when the input cannot be mapped to a supported source variant.
1800
+ */
1801
+ function extractResolvedVariant(input) {
1802
+ if (isSetObject$1(input)) {
1803
+ if (isZod3Type(input)) return "zod3";
1804
+ else if (isType(input)) return "reflection";
1805
+ else if (isUntypedInputStrict(input) || isUntypedSchemaStrict(input)) return "untyped";
1806
+ else if (isStandardJsonSchema(input)) return "standard-schema";
1807
+ else if (isJsonSchema(input)) return "json-schema";
1808
+ else if (isValibotSchema(input)) return "valibot";
1809
+ }
1810
+ 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 Valibot BaseSchema, a reflected Deepkit Type object, or an Untyped schema.`);
1811
+ }
1812
+ /**
1813
+ * Determines the top-level input variant for schema extraction.
1814
+ *
1815
+ * @param input - The schema input to classify.
1816
+ * @returns The resolved schema input variant.
1817
+ */
1818
+ function extractVariant(input) {
1819
+ if (isSetString(input) || isFileReference(input)) return "file-reference";
1820
+ return extractResolvedVariant(input);
1821
+ }
1822
+ /**
1823
+ * Extracts and normalizes a JSON Schema from a concrete schema source input.
1824
+ *
1825
+ * @param input - The schema source input to extract from.
1826
+ * @param variant - Optional source variant override. When omitted, the variant is inferred from the input.
1827
+ * @returns A promise that resolves to a bundled JSON Schema.
1828
+ * @throws Will throw an error if no valid JSON Schema can be extracted from the input.
1829
+ */
1830
+ async function extractSchema(input, variant) {
1831
+ if (isSchemaWithSource(input)) return input.schema;
1832
+ const resolvedVariant = variant ?? extractResolvedVariant(input);
1833
+ let schema;
1834
+ if (resolvedVariant === "zod3" || resolvedVariant === "json-schema" || resolvedVariant === "standard-schema" || resolvedVariant === "untyped" || resolvedVariant === "valibot") schema = extractJsonSchema(input);
1835
+ else if (resolvedVariant === "reflection") schema = extractReflection(input);
1836
+ if (schema) return bundleReferences(schema);
1837
+ 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 Valibot BaseSchema, an untyped schema, or a reflected Deepkit Type object.`);
1838
+ }
1839
+ /**
1840
+ * Builds source metadata for a schema input using a known source variant.
1841
+ *
1842
+ * @param variant - The schema source variant associated with the input.
1843
+ * @param input - The schema source input to wrap.
1844
+ * @returns The normalized schema source payload, including the source hash and variant.
1845
+ * @throws Will throw an error if the provided variant is unsupported.
1846
+ */
1847
+ function extractSource(variant, input) {
1848
+ if (variant === "zod3") return {
1849
+ hash: extractHash(variant, input),
1850
+ variant: "zod3",
1851
+ schema: input
1852
+ };
1853
+ else if (variant === "untyped") return {
1854
+ hash: extractHash(variant, input),
1855
+ variant: "untyped",
1856
+ schema: input
1857
+ };
1858
+ else if (variant === "standard-schema") return {
1859
+ hash: extractHash(variant, input),
1860
+ variant: "standard-schema",
1861
+ schema: input
1862
+ };
1863
+ else if (variant === "json-schema") return {
1864
+ hash: extractHash(variant, input),
1865
+ variant: "json-schema",
1866
+ schema: input
1867
+ };
1868
+ else if (variant === "valibot") return {
1869
+ hash: extractHash(variant, input),
1870
+ variant: "valibot",
1871
+ schema: input
1872
+ };
1873
+ else if (variant === "reflection") return {
1874
+ hash: extractHash(variant, input),
1875
+ variant: "reflection",
1876
+ schema: input
1877
+ };
1878
+ 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.`);
1879
+ }
1880
+ /**
1881
+ * Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a 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 Rolldown to obtain the actual schema definition before extraction.
1882
+ *
1883
+ * @example
1884
+ * ```ts
1885
+ * // Resolve a schema definition from a file path
1886
+ * const schema1 = await extract(context, "./schemas.ts#MySchema");
1887
+ * // Resolve a schema definition from a JSON Schema object
1888
+ * const schema2 = await extract(context, schemaObject);
1889
+ * // Resolve a schema definition from a Zod schema
1890
+ * const schema3 = await extract(context, zodSchema);
1891
+ * // Resolve a schema definition from a reflected Deepkit Type object
1892
+ * const schema4 = await extract(context, reflectionType);
1893
+ * ```
1894
+ *
1895
+ * @see https://zod.dev/
1896
+ * @see https://valibot.dev/
1897
+ * @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
1898
+ * @see https://json-schema.org/
1899
+ * @see https://ajv.js.org/json-type-definition.html
1900
+ * @see https://deepkit.io/en/documentation/runtime-types/reflection
1901
+ *
1902
+ * @param context - The context object providing access to the file system and cache path.
1903
+ * @param input - The schema definition input to extract, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain 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.
1904
+ * @param options - Optional overrides for the Rolldown 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.
1905
+ * @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.
1906
+ */
1907
+ async function extractSchemaWithSource(context, input, options = {}) {
1908
+ if (isSchemaWithSource(input)) return input;
1909
+ if (isSchema(input)) return {
1910
+ ...input,
1911
+ source: {
1912
+ hash: extractHash("json-schema", input.schema),
1913
+ variant: "json-schema",
1914
+ schema: input.schema
1915
+ }
1916
+ };
1917
+ let source;
1918
+ const variant = extractVariant(input);
1919
+ const hash = extractHash(variant, input);
1920
+ if (variant === "file-reference") {
1921
+ const fileReference = extractFileReference(input);
1922
+ if (!fileReference) throw new Error(`Failed to extract a valid file reference from the provided input "${JSON.stringify(input)}". Please ensure that the input is correctly formatted as a file reference (e.g. "./schema.ts#MySchema") and that the file exists at the specified path.`);
1923
+ const extension = findFileExtensionSafe(fileReference.file);
1924
+ if (extension && !VALID_SOURCE_FILE_EXTENSIONS.includes(extension)) throw new Error(`The provided schema file input "${fileReference.file}" has an invalid file extension (.${extension}). Please ensure that the file has one of the following extensions: ${list(VALID_SOURCE_FILE_EXTENSIONS, { conjunction: "or" })}.`);
1925
+ let resolved = await resolve(context, input, defu(options, { plugins: [esbuildPlugin(context, {
1926
+ reflection: "default",
1927
+ level: "all"
1928
+ })] }));
1929
+ try {
1930
+ const type = deserializeType(resolved);
1931
+ if (isType(type)) resolved = type;
1932
+ } catch {}
1933
+ source = extractSource(extractResolvedVariant(resolved), resolved);
1934
+ } else if ([
1935
+ "json-schema",
1936
+ "standard-schema",
1937
+ "zod3",
1938
+ "untyped",
1939
+ "valibot",
1940
+ "reflection"
1941
+ ].includes(variant)) source = extractSource(variant, input);
1942
+ else throw new Error(`Invalid schema definition input "${variant}". The variant must be one of "file-reference", "json-schema", "standard-schema", "zod3", "valibot", "untyped", or "reflection".`);
1943
+ return {
1944
+ variant,
1945
+ source,
1946
+ schema: await extractSchema(source.schema, source.variant),
1947
+ hash
1948
+ };
1949
+ }
1950
+ /**
1951
+ * Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a 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 Rolldown to obtain the actual schema definition before extraction.
1952
+ *
1953
+ * @example
1954
+ * ```ts
1955
+ * // Resolve a schema definition from a file path
1956
+ * const schema1 = await extract(context, "./schemas.ts#MySchema");
1957
+ * // Resolve a schema definition from a JSON Schema object
1958
+ * const schema2 = await extract(context, schemaObject);
1959
+ * // Resolve a schema definition from a Zod schema
1960
+ * const schema3 = await extract(context, zodSchema);
1961
+ * // Resolve a schema definition from a Valibot schema
1962
+ * const schema4 = await extract(context, valibotSchema);
1963
+ * // Resolve a schema definition from a reflected Deepkit Type object
1964
+ * const schema5 = await extract(context, reflectionType);
1965
+ * ```
1966
+ *
1967
+ * @see https://zod.dev/
1968
+ * @see https://valibot.dev/
1969
+ * @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
1970
+ * @see https://json-schema.org/
1971
+ * @see https://ajv.js.org/json-type-definition.html
1972
+ * @see https://deepkit.io/en/documentation/runtime-types/reflection
1973
+ * @see https://github.com/unjs/untyped
1974
+ * @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
1975
+ *
1976
+ * @param context - The context object providing access to the file system and cache path.
1977
+ * @param input - The schema definition input to extract, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a reflected Deepkit Type object.
1978
+ * @param options - Optional overrides for the Rolldown configuration used during extraction.
1979
+ * @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object.
1980
+ * @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.
1981
+ */
1982
+ async function extract(context, input, options = {}) {
1983
+ if (isSchemaWithSource(input) || isSchema(input)) return input;
1984
+ let result;
1985
+ const variant = extractVariant(input);
1986
+ const hash = extractHash(variant, input);
1987
+ const cacheFilePath = joinPaths(getCacheDirectory(context), `${hash}.json`);
1988
+ if (context.config.skipCache !== true && context.fs.existsSync(cacheFilePath)) {
1989
+ const schema = await context.fs.read(cacheFilePath);
1990
+ if (schema) result = {
1991
+ variant,
1992
+ hash,
1993
+ schema: JSON.parse(schema)
1994
+ };
1995
+ }
1996
+ result ??= await extractSchemaWithSource(context, input, options);
1997
+ if (!result?.schema) throw new Error(`Failed to extract a valid schema from the provided input. The input must be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a reflected Deepkit Type object.`);
1998
+ if (context.config.skipCache !== true) await writeSchema(context, result);
1999
+ return result;
2000
+ }
2001
+
2002
+ //#endregion
2003
+ export { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames, VALID_SOURCE_FILE_EXTENSIONS, addProperty, applyJsonSchemaMetadata, bundle, bundleReferences, extract, extractHash, extractJsonSchema, extractReflection, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractVariant, generateCode, getCacheDirectory, getCacheFilePath, getJsonSchema, getJsonSchemaObject, getJsonSchemaType, getPrimarySchemaType, getProperties, getPropertiesList, isJsonSchema, isJsonSchemaAllOf, isJsonSchemaAny, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaDecimal, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaKeywords, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNullable, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaPrimitiveType, isJsonSchemaPrimitiveUnion, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaType, isJsonSchemaUndefined, isJsonSchemaUnion, isJsonSchemaUnknown, isNullOnlyJsonSchema, isPropertyOptional, isSchema, isSchemaNullable, isSchemaObject, isSchemaWithSource, isStandardSchema, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaInputFile, merge, readSchema, readSchemaSafe, readSchemaTypes, reflectionToJsonSchema, resolve, resolveModule, resolveReflection, stringifyType, stringifyValue, writeSchema };
2004
+ //# sourceMappingURL=index.mjs.map