@power-plant/schema 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,28 +1,31 @@
1
- import { a as SCHEMA_ARRAY_CONCAT_KEYWORDS, i as JsonSchemaTypeNames, n as JSON_SCHEMA_PRIMITIVE_TYPES, o as SCHEMA_RECORD_KEYWORDS, r as JSON_SCHEMA_TYPES, s as SCHEMA_SINGLE_KEYWORDS, t as JSON_SCHEMA_METADATA_KEYS } from "./constants-COGt3eeW.mjs";
2
- import { $ as isUntypedConfigStrict, A as isJsonSchemaNever, B as isJsonSchemaString, C as isJsonSchemaDecimal, D as isJsonSchemaLiteral, E as isJsonSchemaKeywords, F as isJsonSchemaPrimitiveType, G as isJsonSchemaUnknown, H as isJsonSchemaType, I as isJsonSchemaPrimitiveUnion, J as isSchemaObject, K as isNullOnlyJsonSchema, L as isJsonSchemaRecord, M as isJsonSchemaNullable, N as isJsonSchemaNumber, O as isJsonSchemaMap, P as isJsonSchemaObject, Q as isUntypedConfig, R as isJsonSchemaRef, S as isJsonSchemaDate, T as isJsonSchemaInteger, U as isJsonSchemaUndefined, V as isJsonSchemaTuple, W as isJsonSchemaUnion, X as isSchemaWithSource, Y as isSchemaOf, Z as isStandardSchema, _ as isJsonSchemaAny, a as getPropertiesList, at as applyJsonSchemaMetadata, b as isJsonSchemaBigint, c as isSchemaNullable, d as merge, et as isUntypedInput, f as mergeMetadata, g as isJsonSchemaAllOf, h as isJsonSchema, i as getProperties, it as isValibotSchema, j as isJsonSchemaNull, k as isJsonSchemaNativeEnum, l as isValidSchemaConfigFile, m as isFileReference, n as getJsonSchema, nt as isUntypedSchema, o as getProperty, ot as getPrimarySchemaType, p as traverseSchema, q as isSchema, r as getJsonSchemaObject, rt as isUntypedSchemaStrict, s as isPropertyOptional, st as readSchemaTypes, t as addProperty, tt as isUntypedInputStrict, u as isValidSchemaInputFile, v as isJsonSchemaAnyOf, w as isJsonSchemaEnum, x as isJsonSchemaBoolean, y as isJsonSchemaArray, z as isJsonSchemaSet } from "./helpers-dvxktFml.mjs";
1
+ import { a as JsonSchemaTypeNames, c as SCHEMA_SINGLE_KEYWORDS, i as JSON_SCHEMA_TYPES, n as JSON_SCHEMA_METADATA_KEYS, o as SCHEMA_ARRAY_CONCAT_KEYWORDS, r as JSON_SCHEMA_PRIMITIVE_TYPES, s as SCHEMA_RECORD_KEYWORDS, t as JSON_SCHEMA_CONSTRUCTOR_KEY } from "./constants-BlppSDwG.mjs";
2
+ import { $ as isUntypedConfig, A as isJsonSchemaNativeEnum, B as isJsonSchemaSet, C as isJsonSchemaDate, D as isJsonSchemaKeywords, E as isJsonSchemaInteger, F as isJsonSchemaObject, G as isJsonSchemaUnion, H as isJsonSchemaTuple, I as isJsonSchemaPrimitiveType, J as isSchema, K as isJsonSchemaUnknown, L as isJsonSchemaPrimitiveUnion, M as isJsonSchemaNull, N as isJsonSchemaNullable, O as isJsonSchemaLiteral, P as isJsonSchemaNumber, Q as isStandardSchema, R as isJsonSchemaRecord, S as isJsonSchemaBoolean, T as isJsonSchemaEnum, U as isJsonSchemaType, V as isJsonSchemaString, W as isJsonSchemaUndefined, X as isSchemaOf, Y as isSchemaObject, Z as isSchemaWithSource, _ as isJsonSchemaAllOf, a as getPropertiesList, at as isValibotSchema, b as isJsonSchemaArray, c as isSchemaNullable, ct as readSchemaTypes, d as merge, et as isUntypedConfigStrict, f as mergeMetadata, g as isJsonSchema, h as isFileReference, i as getProperties, it as isUntypedSchemaStrict, j as isJsonSchemaNever, k as isJsonSchemaMap, l as isValidSchemaConfigFile, m as hasJsonSchemaConstructorFlag, n as getJsonSchema, nt as isUntypedInputStrict, o as getProperty, ot as applyJsonSchemaMetadata, p as traverseSchema, q as isNullOnlyJsonSchema, r as getJsonSchemaObject, rt as isUntypedSchema, s as isPropertyOptional, st as getPrimarySchemaType, t as addProperty, tt as isUntypedInput, u as isValidSchemaInputFile, v as isJsonSchemaAny, w as isJsonSchemaDecimal, x as isJsonSchemaBigint, y as isJsonSchemaAnyOf, z as isJsonSchemaRef } from "./helpers-_8ADIMSN.mjs";
3
+ import { getJsonSchemaType } from "./codegen.mjs";
3
4
  import { n as createStoragePromises, r as normalizeKey, t as mapStorageToFileSystem } from "./storage-C3BT2Xh-.mjs";
4
5
  import { isSetObject } from "@stryke/type-checks/is-set-object";
5
6
  import { isSetString } from "@stryke/type-checks/is-set-string";
6
- import { isSetString as isSetString$1 } from "@stryke/type-checks";
7
+ import { isBigInt, isBoolean, isInteger, isNull, isNumber, isRegExp, isSetArray, isSetObject as isSetObject$1, isSetString as isSetString$1, isString, isUndefined } from "@stryke/type-checks";
8
+ import { ReflectionClass, ReflectionKind, TypeNumberBrand, isType, reflect, stringifyType } from "@deepkit/type";
9
+ import { Cache, DeclarationTransformer, ReflectionTransformer } from "@deepkit/type-compiler";
7
10
  import { extractFileReference } from "@stryke/convert/extract-file-reference";
8
11
  import { resolveSafe } from "@stryke/fs/resolve";
9
12
  import { murmurhash } from "@stryke/hash";
10
13
  import { deepClone } from "@stryke/helpers/deep-clone";
14
+ import { omit } from "@stryke/helpers/omit";
11
15
  import { isStandardJsonSchema } from "@stryke/json";
12
16
  import { appendPath } from "@stryke/path/append";
13
- import { findFileExtensionSafe, findFilePath } from "@stryke/path/find";
17
+ import { findFileDotExtensionSafe, findFileExtensionSafe, findFilePath } from "@stryke/path/find";
14
18
  import { joinPaths } from "@stryke/path/join";
15
- import { plugin } from "@stryke/resolve/bundle";
16
19
  import { VALID_OBJECT_SOURCE_EXTENSIONS } from "@stryke/resolve/constants";
17
20
  import { loadSafe } from "@stryke/resolve/load";
18
- import { resolve } from "@stryke/resolve/resolve";
19
21
  import { list } from "@stryke/string-format/list";
20
22
  import { extractJsonSchema as extractJsonSchema$1, isZod3Type } from "@stryke/zod";
21
23
  import { toJsonSchema } from "@valibot/to-json-schema";
22
24
  import { build } from "esbuild";
23
- import { createGenerator } from "ts-json-schema-generator/dist/factory/generator.js";
24
- import { DEFAULT_CONFIG } from "ts-json-schema-generator/dist/src/Config.js";
25
- import ts from "typescript";
25
+ import { createJiti } from "jiti";
26
+ import { readFile } from "node:fs/promises";
27
+ import ts, { DiagnosticCategory } from "typescript";
28
+ import defu from "defu";
26
29
 
27
30
  //#region src/compatibility.ts
28
31
  const METADATA_KEYS = /* @__PURE__ */ new Set([
@@ -126,12 +129,415 @@ function assertSchemasDoNotContradict(base, override, label = "schema") {
126
129
  if (issues.length > 0) throw new Error(`The ${label} schema contradicts the generator schema:\n${issues.map((issue) => `- ${issue}`).join("\n")}`);
127
130
  }
128
131
 
132
+ //#endregion
133
+ //#region src/reflection.ts
134
+ /**
135
+ * Maps a Deepkit numeric `brand` to JSON Schema `type` and `format`.
136
+ *
137
+ * @remarks
138
+ * 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.
139
+ *
140
+ * @param brand - The Deepkit numeric brand to convert.
141
+ * @return A JSON Schema fragment representing the numeric type corresponding to the provided brand.
142
+ */
143
+ function numberBrandToJsonSchema(brand) {
144
+ switch (brand) {
145
+ case TypeNumberBrand.integer: return {
146
+ type: "integer",
147
+ format: "int32",
148
+ multipleOf: 1
149
+ };
150
+ case TypeNumberBrand.int8: return {
151
+ type: "integer",
152
+ format: "int8",
153
+ multipleOf: 1
154
+ };
155
+ case TypeNumberBrand.uint8: return {
156
+ type: "integer",
157
+ format: "uint8",
158
+ multipleOf: 1
159
+ };
160
+ case TypeNumberBrand.int16: return {
161
+ type: "integer",
162
+ format: "int16",
163
+ multipleOf: 1
164
+ };
165
+ case TypeNumberBrand.uint16: return {
166
+ type: "integer",
167
+ format: "uint16",
168
+ multipleOf: 1
169
+ };
170
+ case TypeNumberBrand.int32: return {
171
+ type: "integer",
172
+ format: "int32",
173
+ multipleOf: 1
174
+ };
175
+ case TypeNumberBrand.uint32: return {
176
+ type: "integer",
177
+ format: "uint32",
178
+ multipleOf: 1
179
+ };
180
+ case TypeNumberBrand.float:
181
+ case TypeNumberBrand.float32: return {
182
+ type: "number",
183
+ format: "float"
184
+ };
185
+ case TypeNumberBrand.float64: return {
186
+ type: "number",
187
+ format: "double"
188
+ };
189
+ case void 0:
190
+ default: return { type: "number" };
191
+ }
192
+ }
193
+ function withReflectionTags(reflection, schema) {
194
+ if (!isSetObject$1(schema) || !isSetObject$1(reflection?.tags)) return schema;
195
+ const updatedSchema = { ...schema };
196
+ const tags = reflection.tags;
197
+ if (isSetString$1(tags.title)) updatedSchema.title = tags.title;
198
+ if (isSetArray(tags.alias)) updatedSchema.alias = tags.alias;
199
+ if (!isUndefined(tags.hidden)) updatedSchema.hidden = tags.hidden;
200
+ if (!isUndefined(tags.ignore)) updatedSchema.ignore = tags.ignore;
201
+ if (!isUndefined(tags.internal)) updatedSchema.internal = tags.internal;
202
+ if (!isUndefined(tags.runtime)) updatedSchema.runtime = tags.runtime;
203
+ if (!isUndefined(tags.readonly)) updatedSchema.readOnly = tags.readonly;
204
+ return updatedSchema;
205
+ }
206
+ function withNullable(schema) {
207
+ if (!isSetObject$1(schema)) return { anyOf: [schema, {
208
+ type: "null",
209
+ default: null
210
+ }] };
211
+ const rawType = schema.type;
212
+ const types = Array.isArray(rawType) ? [...rawType] : rawType ? [rawType] : [];
213
+ if (!types.includes("null")) types.push("null");
214
+ return {
215
+ ...schema,
216
+ type: types.length === 1 ? types[0] : types
217
+ };
218
+ }
219
+ /**
220
+ * Converts a Deepkit type reflection into a JSON Schema (draft-07) fragment.
221
+ */
222
+ function reflectionToJsonSchema(reflection) {
223
+ return reflectionToJsonSchemaInner(reflection);
224
+ }
225
+ function reflectionToJsonSchemaInner(reflection) {
226
+ switch (reflection.kind) {
227
+ case ReflectionKind.any:
228
+ case ReflectionKind.unknown:
229
+ case ReflectionKind.void:
230
+ case ReflectionKind.object: return withReflectionTags(reflection, { name: reflection.typeName });
231
+ case ReflectionKind.never: return;
232
+ case ReflectionKind.undefined:
233
+ case ReflectionKind.null: return withReflectionTags(reflection, {
234
+ type: "null",
235
+ name: reflection.typeName,
236
+ default: null
237
+ });
238
+ case ReflectionKind.string: return withReflectionTags(reflection, {
239
+ type: "string",
240
+ name: reflection.typeName
241
+ });
242
+ case ReflectionKind.boolean: return withReflectionTags(reflection, {
243
+ type: "boolean",
244
+ name: reflection.typeName
245
+ });
246
+ case ReflectionKind.number: return withReflectionTags(reflection, numberBrandToJsonSchema(reflection.brand));
247
+ case ReflectionKind.bigint: return withReflectionTags(reflection, {
248
+ type: "integer",
249
+ name: reflection.typeName,
250
+ format: "int64"
251
+ });
252
+ case ReflectionKind.regexp: return withReflectionTags(reflection, {
253
+ type: "string",
254
+ name: reflection.typeName,
255
+ format: "regex",
256
+ contentMediaType: "text/regex"
257
+ });
258
+ case ReflectionKind.literal: {
259
+ const { literal } = reflection;
260
+ if (isBigInt(literal)) return withReflectionTags(reflection, {
261
+ type: "integer",
262
+ name: reflection.typeName,
263
+ format: "int64",
264
+ const: literal
265
+ });
266
+ if (isRegExp(literal)) return withReflectionTags(reflection, {
267
+ type: "string",
268
+ name: reflection.typeName,
269
+ format: "regex",
270
+ const: literal.source
271
+ });
272
+ return withReflectionTags(reflection, {
273
+ type: getJsonSchemaType(literal),
274
+ name: reflection.typeName,
275
+ const: literal
276
+ });
277
+ }
278
+ case ReflectionKind.templateLiteral: return withReflectionTags(reflection, { type: "string" });
279
+ case ReflectionKind.enum: {
280
+ const values = reflection.values.filter((value) => isString(value) || isInteger(value) || isBigInt(value) || isNumber(value) || isBoolean(value) || isNull(value));
281
+ if (values.length === 0) return withReflectionTags(reflection, {
282
+ name: reflection.typeName,
283
+ description: reflection.description,
284
+ enum: []
285
+ });
286
+ return withReflectionTags(reflection, {
287
+ 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) => {
288
+ const type = getJsonSchemaType(value);
289
+ if (isJsonSchemaPrimitiveType(type) && !ret.includes(type)) ret.push(type);
290
+ return ret;
291
+ }, []),
292
+ name: reflection.typeName,
293
+ description: reflection.description,
294
+ enum: values,
295
+ default: values.length === 1 ? values[0] : void 0
296
+ });
297
+ }
298
+ case ReflectionKind.array: {
299
+ const items = reflectionToJsonSchemaInner(reflection.type);
300
+ return withReflectionTags(reflection, {
301
+ type: "array",
302
+ name: reflection.typeName,
303
+ items: items ?? {}
304
+ });
305
+ }
306
+ case ReflectionKind.tuple: {
307
+ const items = reflection.types.map((member) => reflectionToJsonSchemaInner(member.type)).filter((item) => item !== void 0);
308
+ if (items.length <= 1) return withReflectionTags(reflection, {
309
+ type: "array",
310
+ name: reflection.typeName,
311
+ items: items.length === 1 ? items[0] : {}
312
+ });
313
+ return withReflectionTags(reflection, {
314
+ type: "array",
315
+ name: reflection.typeName,
316
+ prefixItems: items,
317
+ minItems: items.length,
318
+ maxItems: items.length
319
+ });
320
+ }
321
+ case ReflectionKind.union: {
322
+ const branches = reflection.types.map((inner) => reflectionToJsonSchemaInner(inner)).filter((branch) => branch !== void 0);
323
+ if (!reflection.types.some((inner) => inner.kind === ReflectionKind.null || inner.kind === ReflectionKind.undefined)) return withReflectionTags(reflection, {
324
+ name: reflection.typeName,
325
+ anyOf: branches
326
+ });
327
+ const nonNull = branches.filter((branch) => !isNullOnlyJsonSchema(branch));
328
+ if (nonNull.length === 0) return withReflectionTags(reflection, {
329
+ type: "null",
330
+ default: null
331
+ });
332
+ if (nonNull.length === 1) {
333
+ const first = nonNull[0];
334
+ if (!isSetObject$1(first)) return withNullable(withReflectionTags(reflection, {
335
+ name: reflection.typeName,
336
+ anyOf: [first]
337
+ }));
338
+ return withNullable(withReflectionTags(reflection, {
339
+ name: reflection.typeName,
340
+ ...first
341
+ }));
342
+ }
343
+ const enumValues = nonNull.map((branch) => isSetObject$1(branch) ? branch.const : void 0).filter((value) => value === null || typeof value === "string" || typeof value === "number" || typeof value === "bigint" || typeof value === "boolean");
344
+ if (enumValues.length === nonNull.length) return withNullable(withReflectionTags(reflection, {
345
+ name: reflection.typeName,
346
+ enum: enumValues
347
+ }));
348
+ const discriminator = tryReflectionDiscriminator(reflection.types);
349
+ if (discriminator && isSetObject$1(discriminator)) return withNullable(withReflectionTags(reflection, {
350
+ name: reflection.typeName,
351
+ ...discriminator
352
+ }));
353
+ return withNullable(withReflectionTags(reflection, {
354
+ name: reflection.typeName,
355
+ anyOf: nonNull
356
+ }));
357
+ }
358
+ case ReflectionKind.intersection: {
359
+ const members = reflection.types.map((inner) => reflectionToJsonSchemaInner(inner)).filter((item) => item !== void 0);
360
+ if (members.length === 0) return;
361
+ if (members.length === 1) {
362
+ if (!isSetObject$1(members[0])) return members[0];
363
+ return withReflectionTags(reflection, {
364
+ name: reflection.typeName,
365
+ ...members[0]
366
+ });
367
+ }
368
+ if (members.every(isJsonSchemaObject)) return withReflectionTags(reflection, {
369
+ name: reflection.typeName,
370
+ ...mergeObjectSchemas(members)
371
+ });
372
+ return withReflectionTags(reflection, {
373
+ name: reflection.typeName,
374
+ allOf: members
375
+ });
376
+ }
377
+ case ReflectionKind.promise: return reflectionToJsonSchemaInner(reflection.type);
378
+ case ReflectionKind.objectLiteral: return objectReflectionToJsonSchema(reflection);
379
+ case ReflectionKind.class: switch (reflection.classType?.name) {
380
+ case "Date": return withReflectionTags(reflection, {
381
+ type: "string",
382
+ format: "date-time"
383
+ });
384
+ case "RegExp": return withReflectionTags(reflection, {
385
+ type: "string",
386
+ format: "regex"
387
+ });
388
+ case "URL": return withReflectionTags(reflection, {
389
+ type: "string",
390
+ format: "uri"
391
+ });
392
+ case "Set": {
393
+ const itemType = reflection.arguments?.[0];
394
+ return withReflectionTags(reflection, {
395
+ type: "array",
396
+ items: (itemType ? reflectionToJsonSchemaInner(itemType) : void 0) ?? {},
397
+ uniqueItems: true
398
+ });
399
+ }
400
+ case "Map": {
401
+ const valueType = reflection.arguments?.[1];
402
+ return withReflectionTags(reflection, {
403
+ type: "object",
404
+ additionalProperties: (valueType ? reflectionToJsonSchemaInner(valueType) : void 0) ?? true
405
+ });
406
+ }
407
+ case "Uint8Array":
408
+ case "Uint8ClampedArray":
409
+ case "Uint16Array":
410
+ case "Uint32Array":
411
+ case "Int8Array":
412
+ case "Int16Array":
413
+ case "Int32Array":
414
+ case "Float32Array":
415
+ case "Float64Array":
416
+ case "BigInt64Array":
417
+ case "BigUint64Array": return withReflectionTags(reflection, {
418
+ type: "string",
419
+ format: "byte",
420
+ contentEncoding: "base64"
421
+ });
422
+ case void 0:
423
+ default: return withReflectionTags(reflection, {
424
+ name: reflection.typeName,
425
+ description: reflection.description,
426
+ ...objectReflectionToJsonSchema(reflection)
427
+ });
428
+ }
429
+ case ReflectionKind.symbol:
430
+ case ReflectionKind.property:
431
+ case ReflectionKind.method:
432
+ case ReflectionKind.function:
433
+ case ReflectionKind.parameter:
434
+ case ReflectionKind.typeParameter:
435
+ case ReflectionKind.tupleMember:
436
+ case ReflectionKind.enumMember:
437
+ case ReflectionKind.rest:
438
+ case ReflectionKind.indexSignature:
439
+ case ReflectionKind.propertySignature:
440
+ case ReflectionKind.methodSignature:
441
+ case ReflectionKind.infer:
442
+ case ReflectionKind.callSignature:
443
+ default: return;
444
+ }
445
+ }
446
+ function mergeObjectSchemas(schemas) {
447
+ const merged = {
448
+ type: "object",
449
+ properties: {},
450
+ required: []
451
+ };
452
+ for (const schema of schemas) {
453
+ if (schema.properties) merged.properties = defu(merged.properties, schema.properties);
454
+ if (schema.required) merged.required = Array.from(/* @__PURE__ */ new Set([...merged.required ?? [], ...schema.required]));
455
+ if (schema.additionalProperties !== void 0) merged.additionalProperties = schema.additionalProperties;
456
+ }
457
+ if ((merged.required?.length ?? 0) === 0) delete merged.required;
458
+ return merged;
459
+ }
460
+ function tryReflectionDiscriminator(types) {
461
+ const nonNullTypes = types.filter((t) => t.kind !== ReflectionKind.null && t.kind !== ReflectionKind.undefined);
462
+ const objectBranches = nonNullTypes.filter((t) => t.kind === ReflectionKind.objectLiteral || t.kind === ReflectionKind.class);
463
+ if (objectBranches.length < 2 || objectBranches.length !== nonNullTypes.length) return;
464
+ let tagKey;
465
+ const branches = [];
466
+ for (const branch of objectBranches) {
467
+ const literalProps = [];
468
+ 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({
469
+ name: member.name,
470
+ literal: member.type.literal
471
+ });
472
+ if (literalProps.length === 0) return;
473
+ const first = literalProps[0];
474
+ if (!tagKey) tagKey = first.name;
475
+ else if (tagKey !== first.name) return;
476
+ const body = objectReflectionToJsonSchema({
477
+ ...branch,
478
+ types: branch.types.filter((member) => !((member.kind === ReflectionKind.property || member.kind === ReflectionKind.propertySignature) && member.name === tagKey))
479
+ });
480
+ if (!body || !isJsonSchemaObject(body)) return;
481
+ branches.push({
482
+ type: "object",
483
+ properties: {
484
+ [tagKey]: { const: first.literal },
485
+ ...body.properties ?? {}
486
+ },
487
+ required: [tagKey, ...body.required ?? []],
488
+ additionalProperties: body.additionalProperties ?? false
489
+ });
490
+ }
491
+ if (!tagKey) return;
492
+ return {
493
+ oneOf: branches,
494
+ discriminator: { propertyName: tagKey }
495
+ };
496
+ }
497
+ function objectReflectionToJsonSchema(type) {
498
+ const reflection = ReflectionClass.from(type);
499
+ const schema = {
500
+ type: "object",
501
+ name: reflection.getName(),
502
+ description: reflection.getDescription(),
503
+ properties: {},
504
+ required: [],
505
+ primaryKey: reflection.getPrimaries().map((primary) => primary.getNameAsString()),
506
+ ...isSetString$1(reflection.databaseSchemaName) ? { databaseSchemaName: reflection.databaseSchemaName } : {},
507
+ ...isSetString$1(reflection.getName()) ? { name: reflection.getName() } : {},
508
+ ...isSetString$1(reflection.getDescription()) ? { description: reflection.getDescription() } : {}
509
+ };
510
+ for (const propertyReflection of reflection.getProperties()) {
511
+ if (propertyReflection.getKind() === ReflectionKind.indexSignature) {
512
+ schema.additionalProperties = reflectionToJsonSchemaInner(propertyReflection.type) ?? true;
513
+ continue;
514
+ }
515
+ let property = reflectionToJsonSchemaInner(propertyReflection.type);
516
+ if (!property) continue;
517
+ const propertySchema = isSetObject$1(property) ? property : {};
518
+ const groups = propertyReflection.getGroups();
519
+ property = {
520
+ ...propertySchema,
521
+ name: propertyReflection.getNameAsString(),
522
+ description: propertyReflection.getDescription(),
523
+ readOnly: propertyReflection.isReadonly(),
524
+ ...propertyReflection.hasDefault() ? { default: propertyReflection.getDefaultValue() } : {},
525
+ ...isSetArray(groups) ? { tags: groups } : {}
526
+ };
527
+ if (propertyReflection.isNullable()) property = withNullable(property);
528
+ schema.properties ??= {};
529
+ schema.properties[propertyReflection.name] = property;
530
+ if (!propertyReflection.isOptional()) {
531
+ schema.required ??= [];
532
+ schema.required.push(propertyReflection.name);
533
+ }
534
+ }
535
+ return schema;
536
+ }
537
+
129
538
  //#endregion
130
539
  //#region src/extract.ts
131
540
  const SCHEMA_BUNDLE_BASE_URI = "https://power-plant.invalid/";
132
- function normalizePath(filePath) {
133
- return filePath.replaceAll("\\", "/");
134
- }
135
541
  function isWrappedSchemaConfig(input) {
136
542
  if (!isSetObject(input) || !("schema" in input)) return false;
137
543
  if ("hash" in input || "variant" in input || "source" in input) return false;
@@ -334,6 +740,10 @@ function extractHash(variant, input) {
334
740
  variant,
335
741
  input: unwrappedConfig._def
336
742
  });
743
+ else if (isType(unwrappedConfig)) return murmurhash({
744
+ variant,
745
+ input: stringifyType(unwrappedConfig)
746
+ });
337
747
  else if (isStandardJsonSchema(unwrappedConfig)) return murmurhash({
338
748
  variant,
339
749
  input: unwrappedConfig["~standard"]
@@ -358,6 +768,13 @@ function extractHash(variant, input) {
358
768
  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.`);
359
769
  }
360
770
  /**
771
+ * Converts a reflected Deepkit {@link Type} into a JSON Schema (draft-2020-12) representation.
772
+ */
773
+ function extractReflection(reflection) {
774
+ if (!isType(reflection)) return;
775
+ return reflectionToJsonSchema(reflection);
776
+ }
777
+ /**
361
778
  * Extracts a JSON Schema from Zod, Standard Schema, Valibot, untyped, or JSON Schema inputs.
362
779
  *
363
780
  * @param schema - The schema input to extract a JSON Schema from.
@@ -383,6 +800,7 @@ function extractJsonSchema(schema) {
383
800
  function extractResolvedVariant(input) {
384
801
  if (isSetObject(input)) {
385
802
  if (isZod3Type(input)) return "zod3";
803
+ else if (isType(input)) return "reflection";
386
804
  else if (isUntypedConfigStrict(input) || isUntypedSchemaStrict(input)) return "untyped";
387
805
  else if (isStandardJsonSchema(input)) return "standard-schema";
388
806
  else if (isJsonSchema(input)) return "json-schema";
@@ -415,6 +833,7 @@ async function extractSchema(input, variant) {
415
833
  const resolvedVariant = variant ?? extractResolvedVariant(input);
416
834
  let schema;
417
835
  if (resolvedVariant === "zod3" || resolvedVariant === "json-schema" || resolvedVariant === "standard-schema" || resolvedVariant === "untyped" || resolvedVariant === "valibot") schema = extractJsonSchema(input);
836
+ else if (resolvedVariant === "reflection") schema = extractReflection(input);
418
837
  if (schema) return bundleReferences(schema);
419
838
  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.`);
420
839
  }
@@ -452,191 +871,166 @@ function extractSource(variant, input) {
452
871
  variant: "valibot",
453
872
  schema: input
454
873
  };
874
+ else if (variant === "reflection") return {
875
+ hash: extractHash(variant, input),
876
+ variant: "reflection",
877
+ schema: input
878
+ };
455
879
  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.`);
456
880
  }
457
- function getTsCompilerOptions(config) {
458
- if (config.tsconfig) {
459
- const raw = ts.sys.readFile(config.tsconfig);
460
- if (!raw) throw new Error(`Cannot read config file "${config.tsconfig}"`);
461
- const parsedConfig = ts.parseConfigFileTextToJson(config.tsconfig, raw);
462
- if (parsedConfig.error) throw new Error(parsedConfig.error.messageText.toString());
463
- if (!parsedConfig.config) throw new Error(`Invalid parsed config file "${config.tsconfig}"`);
464
- const parseResult = ts.parseJsonConfigFileContent(parsedConfig.config, ts.sys, findFilePath(config.tsconfig), {}, config.tsconfig);
465
- parseResult.options.noEmit = true;
466
- delete parseResult.options.out;
467
- delete parseResult.options.outDir;
468
- delete parseResult.options.outFile;
469
- delete parseResult.options.declaration;
470
- delete parseResult.options.declarationDir;
471
- delete parseResult.options.declarationMap;
472
- return parseResult.options;
473
- }
881
+ const deepkitCache = new Cache();
882
+ function rewriteTypeOnlyImports(source) {
883
+ return source.replaceAll(/\bimport\s+type\s+/g, "import ").replaceAll(/\bexport\s+type\s+\*\s+from/g, "export * from").replaceAll(/\bexport\s+type\s+\{/g, "export {");
884
+ }
885
+ function resolveReflectionConfig(options) {
886
+ return {
887
+ reflection: options.reflection ?? "default",
888
+ exclude: options.exclude
889
+ };
890
+ }
891
+ function getCompilerOptions(options) {
892
+ const cwd = options.cwd || process.cwd();
893
+ const tsconfigPath = options.tsconfig ? appendPath(options.tsconfig, cwd) : joinPaths(cwd, "tsconfig.json");
894
+ try {
895
+ const raw = ts.sys.readFile(tsconfigPath);
896
+ if (raw) {
897
+ const parsed = ts.parseConfigFileTextToJson(tsconfigPath, raw);
898
+ if (parsed.config) return {
899
+ ...ts.parseJsonConfigFileContent(parsed.config, ts.sys, findFilePath(tsconfigPath) || cwd, {}, tsconfigPath).options,
900
+ noEmit: true,
901
+ experimentalDecorators: true,
902
+ emitDecoratorMetadata: true
903
+ };
904
+ }
905
+ } catch {}
474
906
  return {
475
- noEmit: true,
476
- emitDecoratorMetadata: true,
477
- experimentalDecorators: true,
478
907
  target: ts.ScriptTarget.ES2022,
479
908
  module: ts.ModuleKind.ESNext,
480
909
  moduleResolution: ts.ModuleResolutionKind.Bundler,
481
- strictNullChecks: false,
910
+ strictNullChecks: true,
911
+ experimentalDecorators: true,
912
+ emitDecoratorMetadata: true,
482
913
  skipLibCheck: true,
483
- skipDefaultLibCheck: true,
484
914
  esModuleInterop: true,
485
- types: ["node"]
915
+ noEmit: true
486
916
  };
487
917
  }
488
- /**
489
- * Rewrites type-only imports/exports so esbuild still walks them while
490
- * collecting the original TypeScript sources for schema generation.
491
- */
492
- function rewriteTypeOnlyImports(source) {
493
- return source.replace(/\bimport\s+type\s+/g, "import ").replace(/\bexport\s+type\s+\*\s+from/g, "export * from").replace(/\bexport\s+type\s+\{/g, "export {");
494
- }
495
- function getScriptKind(fileName) {
496
- switch (findFileExtensionSafe(fileName)?.toLowerCase()) {
497
- case "tsx": return ts.ScriptKind.TSX;
498
- case "jsx": return ts.ScriptKind.JSX;
499
- case "js":
500
- case "cjs":
501
- case "mjs": return ts.ScriptKind.JS;
502
- default: return ts.ScriptKind.TS;
503
- }
504
- }
505
- /**
506
- * Uses esbuild (with `@stryke/resolve` path resolution) to walk the module
507
- * graph, capturing original TypeScript sources before types are erased.
508
- */
509
- async function bundleTypeScriptSources(filePath, options) {
510
- const cwd = options.cwd || process.cwd();
511
- const sources = /* @__PURE__ */ new Map();
512
- const result = await build({
513
- absWorkingDir: cwd,
514
- entryPoints: [filePath],
515
- bundle: true,
516
- write: false,
517
- platform: "node",
518
- format: "esm",
519
- logLevel: "silent",
520
- packages: "external",
521
- plugins: [{
522
- name: "power-plant-capture-ts-sources",
523
- setup(buildApi) {
524
- buildApi.onLoad({ filter: /.*/ }, async (args) => {
525
- if (/[/\\]node_modules[/\\]/.test(args.path)) return null;
526
- try {
527
- const original = await resolve(args.path, {
528
- skipBundle: true,
529
- cwd,
530
- fs: options.fs
531
- });
532
- sources.set(normalizePath(args.path), original);
533
- const extension = findFileExtensionSafe(args.path);
534
- const loader = extension === "tsx" || extension === "jsx" ? extension : extension === "js" || extension === "cjs" || extension === "mjs" ? "js" : "ts";
535
- return {
536
- contents: rewriteTypeOnlyImports(original),
537
- loader
538
- };
539
- } catch {
540
- return null;
541
- }
542
- });
543
- }
544
- }, plugin({
545
- originalInput: filePath,
546
- cwd,
547
- fs: options.fs ?? {}
548
- })]
918
+ function transpileWithDeepkit(code, fileName, options) {
919
+ const reflectionConfig = resolveReflectionConfig(options);
920
+ deepkitCache.tick();
921
+ return ts.transpileModule(code, {
922
+ compilerOptions: getCompilerOptions(options),
923
+ fileName,
924
+ transformers: {
925
+ before: [(context) => new ReflectionTransformer(context, deepkitCache).withReflection(reflectionConfig)],
926
+ after: [(context) => new DeclarationTransformer(context, deepkitCache).withReflection(reflectionConfig)]
927
+ }
549
928
  });
550
- if (result.errors.length > 0) throw new Error(`Failed to bundle TypeScript sources for "${filePath}": ${result.errors.map((error) => error.text).join(", ")}`);
551
- if (sources.size === 0) {
552
- const fallback = await resolve(filePath, {
553
- skipBundle: true,
554
- cwd,
555
- fs: options.fs
556
- });
557
- sources.set(normalizePath(filePath), fallback);
929
+ }
930
+ async function readSourceFile(path, fs) {
931
+ try {
932
+ if (fs?.promises?.readFile) return await fs.promises.readFile(path, "utf8");
933
+ return await readFile(path, "utf8");
934
+ } catch {
935
+ return;
558
936
  }
559
- return {
560
- entryFileName: filePath,
561
- sources
562
- };
563
937
  }
564
- /**
565
- * Builds a TypeScript program from original sources collected during the
566
- * esbuild graph walk so type information remains intact for schema generation.
567
- */
568
- function createProgramFromSources(entryFileName, sources, config) {
569
- const compilerOptions = getTsCompilerOptions(config);
570
- const host = ts.createCompilerHost(compilerOptions, true);
571
- const normalizedSources = new Map([...sources.entries()].map(([key, value]) => [normalizePath(key), value]));
572
- const getContent = (name) => normalizedSources.get(normalizePath(name)) ?? normalizedSources.get(name);
573
- const baseFileExists = host.fileExists.bind(host);
574
- const baseReadFile = host.readFile.bind(host);
575
- const baseGetSourceFile = host.getSourceFile.bind(host);
576
- host.fileExists = (name) => getContent(name) !== void 0 || baseFileExists(name);
577
- host.readFile = (name) => getContent(name) ?? baseReadFile(name);
578
- host.getSourceFile = (name, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
579
- const content = getContent(name);
580
- if (content !== void 0) {
581
- const scriptTarget = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions.languageVersion : languageVersionOrOptions;
582
- return ts.createSourceFile(name, content, scriptTarget ?? compilerOptions.target ?? ts.ScriptTarget.ES2022, true, getScriptKind(name));
938
+ function createDeepkitPlugin(options) {
939
+ return {
940
+ name: "power-plant:deepkit",
941
+ setup(pluginBuild) {
942
+ pluginBuild.onLoad({ filter: /\.(m|c)?tsx?$/ }, async (args) => {
943
+ if (args.pluginData?.isReflected) {
944
+ const contents = await readSourceFile(args.path, options.fs);
945
+ if (!contents) return null;
946
+ return {
947
+ contents,
948
+ loader: "ts",
949
+ pluginData: { isReflected: true }
950
+ };
951
+ }
952
+ const raw = await readSourceFile(args.path, options.fs);
953
+ if (!raw) return null;
954
+ const result = transpileWithDeepkit(rewriteTypeOnlyImports(raw), args.path, options);
955
+ if (result.diagnostics?.length) {
956
+ const errors = result.diagnostics.filter((diagnostic) => diagnostic.category === DiagnosticCategory.Error);
957
+ if (errors.length > 0) {
958
+ const errorMessage = `Deepkit Type reflection transpilation errors: ${args.path} \n ${errors.map((diagnostic) => `-${diagnostic.file ? `${diagnostic.file.fileName}:` : ""} ${typeof diagnostic.messageText === "string" ? diagnostic.messageText : diagnostic.messageText.messageText} (at ${diagnostic.start}:${diagnostic.length})`).join("\n")}`;
959
+ options.logger?.error?.(errorMessage);
960
+ throw new Error(errorMessage);
961
+ }
962
+ }
963
+ return {
964
+ contents: result.outputText,
965
+ loader: "ts",
966
+ pluginData: { isReflected: true }
967
+ };
968
+ });
583
969
  }
584
- return baseGetSourceFile(name, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
585
970
  };
586
- const program = ts.createProgram([entryFileName], compilerOptions, host);
587
- if (!config.skipTypeCheck) {
588
- const diagnostics = ts.getPreEmitDiagnostics(program);
589
- if (diagnostics.length) throw new Error(`Type check error: ${diagnostics.map((diagnostic) => diagnostic.messageText.toString()).join("\n")}`);
590
- }
591
- return program;
592
971
  }
593
972
  /**
594
- * Resolves a type definition to a JSON Schema. First bundles the TypeScript
595
- * module graph for {@link FileReference.file} with esbuild (preserving original
596
- * sources), then feeds that program to
597
- * [ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator)
598
- * using the referenced export name as the target type when one is provided.
973
+ * Resolves a type definition to a JSON Schema. Bundles the TypeScript module
974
+ * graph with esbuild using `@deepkit/type-compiler` reflection transformers,
975
+ * then converts the reflected Deepkit {@link Type} via {@link reflectionToJsonSchema}.
599
976
  *
600
977
  * @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
601
- * @param options - Optional overrides reserved for API compatibility.
978
+ * @param options - Optional overrides for reflection and file resolution.
602
979
  * @returns A promise that resolves to the generated JSON Schema.
980
+ * @see https://deepkit.io/en/documentation/runtime-types/reflection
603
981
  */
604
982
  async function extractTSType(input, options = {}) {
605
983
  const fileReference = extractFileReference(input);
606
984
  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.`);
607
- const exportName = fileReference.export ?? "*";
985
+ const exportName = fileReference.export ?? "default";
608
986
  const resolvedPath = await resolveSafe(fileReference.file, { fs: options.fs });
609
987
  const filePath = resolvedPath || fileReference.file;
988
+ const cwd = options.cwd || process.cwd();
610
989
  try {
611
- const tsconfig = options.tsconfig ? appendPath(options.tsconfig, options.cwd || process.cwd()) : joinPaths(options.cwd || process.cwd(), "tsconfig.json");
612
- const { entryFileName, sources } = await bundleTypeScriptSources(filePath, {
613
- cwd: options.cwd || process.cwd(),
614
- fs: options.fs
990
+ options.logger?.debug?.(`Generating JSON schema for bundled "${filePath}" using the type "${exportName}"`);
991
+ const result = await build({
992
+ platform: "node",
993
+ format: "esm",
994
+ logLevel: "silent",
995
+ entryPoints: [filePath],
996
+ write: false,
997
+ sourcemap: false,
998
+ splitting: false,
999
+ treeShaking: true,
1000
+ bundle: true,
1001
+ packages: "bundle",
1002
+ keepNames: true,
1003
+ metafile: false,
1004
+ absWorkingDir: cwd,
1005
+ plugins: [createDeepkitPlugin(options)]
615
1006
  });
616
- const config = {
617
- ...DEFAULT_CONFIG,
618
- expose: "all",
619
- jsDoc: "extended",
620
- markdownDescription: true,
621
- fullDescription: true,
622
- ...options,
623
- tsconfig,
624
- path: entryFileName,
625
- type: exportName,
626
- skipTypeCheck: true
627
- };
628
- const tsProgram = createProgramFromSources(entryFileName, sources, config);
629
- options.logger?.debug?.(`Generating JSON schema for bundled "${filePath}" using the type "${exportName}" (${sources.size} source file(s))`);
630
- return createGenerator({
631
- ...config,
632
- tsProgram
633
- }).createSchema(exportName);
1007
+ if (result.errors.length > 0) throw new Error(result.errors.map((error) => error.text).join(", "));
1008
+ const bundled = result.outputFiles?.filter(Boolean)[0]?.text;
1009
+ if (!isSetString$1(bundled)) throw new Error(`No output files generated for "${filePath}". Please check the configuration and try again.`);
1010
+ const evaluated = await createJiti(cwd).evalModule(bundled, {
1011
+ filename: filePath,
1012
+ ext: findFileDotExtensionSafe(filePath) || ".ts"
1013
+ });
1014
+ let resolved = evaluated[exportName] ?? evaluated[`__Ω${exportName}`];
1015
+ if (resolved === void 0) throw new Error(`The export "${exportName}" could not be resolved in the "${filePath}" module. ${Object.keys(evaluated).length === 0 ? `After bundling, no exports were found in the module.` : `After bundling, the available exports were: ${Object.keys(evaluated).join(", ")}.`}`);
1016
+ try {
1017
+ const type = reflect(resolved);
1018
+ if (isType(type)) resolved = type;
1019
+ } catch {}
1020
+ if (isType(resolved)) {
1021
+ const schema = extractReflection(resolved);
1022
+ if (!schema) throw new Error(`Failed to convert the reflected Deepkit type for "${exportName}" to JSON Schema.`);
1023
+ return schema;
1024
+ }
1025
+ const schema = extractJsonSchema(resolved);
1026
+ if (!schema) throw new Error(`The export "${exportName}" could not be converted to a JSON Schema.`);
1027
+ return schema;
634
1028
  } catch (error) {
635
1029
  throw new Error(`Failed to generate a JSON schema for "${fileReference.file}"${resolvedPath && resolvedPath !== fileReference.file ? ` (resolved: ${resolvedPath})` : ""} using the type "${exportName}". Error: ${error.message}`);
636
1030
  }
637
1031
  }
638
1032
  /**
639
- * 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 {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options. If the input is a {@link FileReferenceInput} (e.g. a file path with an export), the source code will be bundled with [esbuild](esbuild.github.io) using [ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator) to obtain the actual schema definition before extraction.
1033
+ * 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, a Deepkit Type object, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options. If the input is a {@link FileReferenceInput} (e.g. a file path with an export), the source code will be bundled with [esbuild](https://esbuild.github.io) using [@deepkit/type-compiler](https://deepkit.io/en/documentation/runtime-types/getting-started) reflection to obtain the actual schema definition before extraction.
640
1034
  *
641
1035
  * @example
642
1036
  * ```ts
@@ -650,8 +1044,8 @@ async function extractTSType(input, options = {}) {
650
1044
  * const schema4 = await extract(context, zodSchema);
651
1045
  * // Resolve a schema definition from a Valibot schema
652
1046
  * const schema5 = await extract(context, valibotSchema);
653
- * // Resolve a schema definition from an untyped schema
654
- * const schema6 = await extract(context, untypedSchema);
1047
+ * // Resolve a schema definition from a reflected Deepkit Type object
1048
+ * const schema6 = await extract(context, reflectionType);
655
1049
  * ```
656
1050
  *
657
1051
  * @see https://zod.dev/
@@ -659,7 +1053,7 @@ async function extractTSType(input, options = {}) {
659
1053
  * @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
660
1054
  * @see https://json-schema.org/
661
1055
  * @see https://ajv.js.org/json-type-definition.html
662
- * @see https://github.com/vega/ts-json-schema-generator
1056
+ * @see https://deepkit.io/en/documentation/runtime-types/reflection
663
1057
  * @see https://github.com/unjs/untyped
664
1058
  * @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
665
1059
  *
@@ -690,13 +1084,22 @@ async function extractSchemaWithSource(input, options = {}) {
690
1084
  let fs;
691
1085
  if (options.storage) fs = mapStorageToFileSystem(options.storage);
692
1086
  let resolved = await loadSafe(unwrappedConfig, {
693
- ...options,
694
- fs
1087
+ ...omit(options, [
1088
+ "storage",
1089
+ "logger",
1090
+ "tsconfig"
1091
+ ]),
1092
+ fs,
1093
+ cwd: options.cwd ?? void 0
695
1094
  });
696
1095
  resolved ??= await extractTSType(unwrappedConfig, {
697
1096
  ...options,
698
1097
  fs
699
1098
  });
1099
+ try {
1100
+ const type = reflect(resolved);
1101
+ if (isType(type)) resolved = type;
1102
+ } catch {}
700
1103
  const resolvedConfig = unwrapSchemaConfig(resolved);
701
1104
  if (isSchemaWithSource(resolvedConfig)) source = resolvedConfig.source;
702
1105
  else if (isSchema(resolvedConfig)) source = {
@@ -722,7 +1125,7 @@ async function extractSchemaWithSource(input, options = {}) {
722
1125
  };
723
1126
  }
724
1127
  /**
725
- * 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 {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options. If the input is a {@link FileReferenceInput} (e.g. a file path with an export), the source code will be bundled with [esbuild](esbuild.github.io) using [ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator) to obtain the actual schema definition before extraction.
1128
+ * 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, a Deepkit Type object, or a {@link FileReferenceInput} to an exported TypeScript type definition or any of the previous options. If the input is a {@link FileReferenceInput} (e.g. a file path with an export), the source code will be bundled with [esbuild](https://esbuild.github.io) using [@deepkit/type-compiler](https://deepkit.io/en/documentation/runtime-types/getting-started) reflection to obtain the actual schema definition before extraction.
726
1129
  *
727
1130
  * @example
728
1131
  * ```ts
@@ -736,8 +1139,8 @@ async function extractSchemaWithSource(input, options = {}) {
736
1139
  * const schema4 = await extract(context, zodSchema);
737
1140
  * // Resolve a schema definition from a Valibot schema
738
1141
  * const schema5 = await extract(context, valibotSchema);
739
- * // Resolve a schema definition from an untyped schema
740
- * const schema6 = await extract(context, untypedSchema);
1142
+ * // Resolve a schema definition from a reflected Deepkit Type object
1143
+ * const schema6 = await extract(context, reflectionType);
741
1144
  * ```
742
1145
  *
743
1146
  * @see https://zod.dev/
@@ -745,7 +1148,7 @@ async function extractSchemaWithSource(input, options = {}) {
745
1148
  * @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
746
1149
  * @see https://json-schema.org/
747
1150
  * @see https://ajv.js.org/json-type-definition.html
748
- * @see https://github.com/vega/ts-json-schema-generator
1151
+ * @see https://deepkit.io/en/documentation/runtime-types/reflection
749
1152
  * @see https://github.com/unjs/untyped
750
1153
  * @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
751
1154
  *
@@ -763,5 +1166,5 @@ async function extract(input, options = {}) {
763
1166
  }
764
1167
 
765
1168
  //#endregion
766
- export { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames, SCHEMA_ARRAY_CONCAT_KEYWORDS, SCHEMA_RECORD_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, addProperty, applyJsonSchemaMetadata, assertSchemasDoNotContradict, bundleReferences, createStoragePromises, extract, extractHash, extractJsonSchema, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractTSType, extractVariant, findSchemaContradictions, getJsonSchema, getJsonSchemaObject, getPrimarySchemaType, getProperties, getPropertiesList, getProperty, isFileReference, 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, isSchemaOf, isSchemaWithSource, isStandardSchema, isUntypedConfig, isUntypedConfigStrict, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaConfigFile, isValidSchemaInputFile, mapStorageToFileSystem, merge, mergeMetadata, normalizeKey, readSchemaTypes, traverseSchema };
1169
+ export { JSON_SCHEMA_CONSTRUCTOR_KEY, JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames, SCHEMA_ARRAY_CONCAT_KEYWORDS, SCHEMA_RECORD_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, addProperty, applyJsonSchemaMetadata, assertSchemasDoNotContradict, bundleReferences, createStoragePromises, extract, extractHash, extractJsonSchema, extractReflection, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractTSType, extractVariant, findSchemaContradictions, getJsonSchema, getJsonSchemaObject, getPrimarySchemaType, getProperties, getPropertiesList, getProperty, hasJsonSchemaConstructorFlag, isFileReference, 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, isSchemaOf, isSchemaWithSource, isStandardSchema, isUntypedConfig, isUntypedConfigStrict, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema, isValidSchemaConfigFile, isValidSchemaInputFile, mapStorageToFileSystem, merge, mergeMetadata, normalizeKey, readSchemaTypes, traverseSchema };
767
1170
  //# sourceMappingURL=index.mjs.map