@powerlines/schema 0.11.0 → 0.11.2

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 (62) hide show
  1. package/README.md +36 -22
  2. package/dist/bundle.d.cts +2 -2
  3. package/dist/bundle.d.cts.map +1 -1
  4. package/dist/bundle.d.mts +2 -2
  5. package/dist/bundle.d.mts.map +1 -1
  6. package/dist/bundle.mjs.map +1 -1
  7. package/dist/codegen.cjs +27 -0
  8. package/dist/codegen.d.cts +15 -0
  9. package/dist/codegen.d.cts.map +1 -0
  10. package/dist/codegen.d.mts +15 -0
  11. package/dist/codegen.d.mts.map +1 -0
  12. package/dist/codegen.mjs +24 -0
  13. package/dist/codegen.mjs.map +1 -0
  14. package/dist/extract.cjs +201 -52
  15. package/dist/extract.d.cts +81 -16
  16. package/dist/extract.d.cts.map +1 -1
  17. package/dist/extract.d.mts +81 -16
  18. package/dist/extract.d.mts.map +1 -1
  19. package/dist/extract.mjs +199 -55
  20. package/dist/extract.mjs.map +1 -1
  21. package/dist/index.cjs +15 -3
  22. package/dist/index.d.cts +7 -5
  23. package/dist/index.d.mts +7 -5
  24. package/dist/index.mjs +6 -4
  25. package/dist/jtd.cjs +385 -0
  26. package/dist/jtd.d.cts +15 -0
  27. package/dist/jtd.d.cts.map +1 -0
  28. package/dist/jtd.d.mts +15 -0
  29. package/dist/jtd.d.mts.map +1 -0
  30. package/dist/jtd.mjs +384 -0
  31. package/dist/jtd.mjs.map +1 -0
  32. package/dist/reflection.cjs +321 -100
  33. package/dist/reflection.d.cts +16 -13
  34. package/dist/reflection.d.cts.map +1 -1
  35. package/dist/reflection.d.mts +16 -13
  36. package/dist/reflection.d.mts.map +1 -1
  37. package/dist/reflection.mjs +323 -101
  38. package/dist/reflection.mjs.map +1 -1
  39. package/dist/resolve.d.cts +5 -5
  40. package/dist/resolve.d.cts.map +1 -1
  41. package/dist/resolve.d.mts +5 -5
  42. package/dist/resolve.d.mts.map +1 -1
  43. package/dist/resolve.mjs.map +1 -1
  44. package/dist/type-checks.cjs +76 -0
  45. package/dist/type-checks.d.cts +43 -0
  46. package/dist/type-checks.d.cts.map +1 -0
  47. package/dist/type-checks.d.mts +43 -0
  48. package/dist/type-checks.d.mts.map +1 -0
  49. package/dist/type-checks.mjs +71 -0
  50. package/dist/type-checks.mjs.map +1 -0
  51. package/dist/types.d.cts +166 -24
  52. package/dist/types.d.cts.map +1 -1
  53. package/dist/types.d.mts +166 -24
  54. package/dist/types.d.mts.map +1 -1
  55. package/package.json +25 -19
  56. package/dist/is-schema-definition.cjs +0 -18
  57. package/dist/is-schema-definition.d.cts +0 -13
  58. package/dist/is-schema-definition.d.cts.map +0 -1
  59. package/dist/is-schema-definition.d.mts +0 -13
  60. package/dist/is-schema-definition.d.mts.map +0 -1
  61. package/dist/is-schema-definition.mjs +0 -17
  62. package/dist/is-schema-definition.mjs.map +0 -1
@@ -1,121 +1,236 @@
1
- import { ReflectionKind, TypeNumberBrand } from "@powerlines/deepkit/vendor/type";
1
+ import { ReflectionClass, ReflectionKind, TypeNumberBrand } from "@powerlines/deepkit/vendor/type";
2
+ import { isSetArray, isSetObject, isSetString } from "@stryke/type-checks";
2
3
 
3
4
  //#region src/reflection.ts
4
5
  /**
5
- * Converts a Deepkit type reflection into a JSON Schema representation.
6
+ * Maps a Deepkit numeric `brand` to the JTD numeric `type` keyword that best preserves the underlying width and signedness.
7
+ *
8
+ * @param brand - The Deepkit `TypeNumberBrand` of a numeric reflection, or `undefined` when no brand is set.
9
+ * @returns The JTD numeric `type` keyword to use.
10
+ */
11
+ function numberBrandToJtdType(brand) {
12
+ switch (brand) {
13
+ case TypeNumberBrand.integer: return "int32";
14
+ case TypeNumberBrand.int8: return "int8";
15
+ case TypeNumberBrand.uint8: return "uint8";
16
+ case TypeNumberBrand.int16: return "int16";
17
+ case TypeNumberBrand.uint16: return "uint16";
18
+ case TypeNumberBrand.int32: return "int32";
19
+ case TypeNumberBrand.uint32: return "uint32";
20
+ case TypeNumberBrand.float:
21
+ case TypeNumberBrand.float32: return "float32";
22
+ case TypeNumberBrand.float64: return "float64";
23
+ case void 0:
24
+ default: return "float64";
25
+ }
26
+ }
27
+ /**
28
+ * Converts a Deepkit type reflection into a JSON Type Definition (RFC 8927) form suitable for AJV's JTD validator.
29
+ *
30
+ * @remarks
31
+ * Some TypeScript constructs have no direct JTD equivalent and are handled with the closest available form:
32
+ *
33
+ * - `null` and `undefined` become the empty JTD form with `nullable: true`.
34
+ * - Unions of primitives that cannot be expressed as a JTD enum collapse to the empty form (which validates any value).
35
+ * - String/number/bigint literal unions are emitted as a JTD enum (non-string members are stringified, as JTD requires string enum members).
36
+ * - Tuples are emitted as a JTD elements form whose element schema is the single tuple member type, or the empty schema for mixed tuples.
37
+ * - `Date` is emitted as `{ type: "timestamp" }`.
38
+ * - Discriminated unions of object literals (a shared string-literal tag property) are emitted as a JTD discriminator form.
6
39
  *
7
40
  * @param reflection - The Deepkit type reflection to convert.
8
- * @returns The corresponding JSON Schema representation, or `undefined` if the type cannot be represented.
41
+ * @returns The corresponding JTD form, or `undefined` if the type cannot be represented.
9
42
  */
10
43
  function reflectionToJsonSchema(reflection) {
44
+ return reflectionToJtd(reflection);
45
+ }
46
+ /**
47
+ * Internal worker that performs the recursive Deepkit reflection → JTD conversion.
48
+ *
49
+ * @param reflection - The Deepkit type reflection to convert.
50
+ * @returns The corresponding JTD form, or `undefined` if the type cannot be represented.
51
+ */
52
+ function reflectionToJtd(reflection) {
53
+ const schema = {};
54
+ if (isSetObject(reflection?.tags)) {
55
+ const tags = reflection.tags;
56
+ schema.metadata = schema.metadata ?? {};
57
+ if (tags.readonly === true) schema.metadata.isReadonly = true;
58
+ if (tags.ignore === true) schema.metadata.isIgnored = true;
59
+ if (tags.internal === true) schema.metadata.isInternal = true;
60
+ if (tags.runtime === true) schema.metadata.isRuntime = true;
61
+ if (tags.hidden === true) schema.metadata.isHidden = true;
62
+ if (isSetArray(tags.alias)) schema.metadata.alias = tags.alias;
63
+ if (isSetString(tags.title)) schema.metadata.title = tags.title;
64
+ }
11
65
  switch (reflection.kind) {
12
66
  case ReflectionKind.any:
13
67
  case ReflectionKind.unknown:
14
68
  case ReflectionKind.void:
15
69
  case ReflectionKind.object: return {};
16
- case ReflectionKind.never:
17
- case ReflectionKind.undefined: return { not: {} };
18
- case ReflectionKind.null: return { type: "null" };
19
- case ReflectionKind.string: return { type: "string" };
20
- case ReflectionKind.boolean: return { type: "boolean" };
21
- case ReflectionKind.number: {
22
- const brand = reflection.brand;
23
- return { type: brand !== void 0 && brand >= TypeNumberBrand.integer && brand <= TypeNumberBrand.uint32 ? "integer" : "number" };
24
- }
70
+ case ReflectionKind.never: return;
71
+ case ReflectionKind.undefined:
72
+ case ReflectionKind.null: return { nullable: true };
73
+ case ReflectionKind.string: return {
74
+ ...schema,
75
+ type: "string"
76
+ };
77
+ case ReflectionKind.boolean: return {
78
+ ...schema,
79
+ type: "boolean"
80
+ };
81
+ case ReflectionKind.number: return {
82
+ ...schema,
83
+ type: numberBrandToJtdType(reflection.brand)
84
+ };
25
85
  case ReflectionKind.bigint: return {
26
- type: "integer",
27
- format: "int64"
86
+ ...schema,
87
+ type: "float64"
88
+ };
89
+ case ReflectionKind.regexp: return {
90
+ ...schema,
91
+ type: "string"
28
92
  };
29
- case ReflectionKind.regexp: return { type: "string" };
30
93
  case ReflectionKind.literal: {
31
94
  const { literal } = reflection;
32
95
  if (typeof literal === "string") return {
33
- type: "string",
34
- const: literal
96
+ ...schema,
97
+ enum: [literal]
35
98
  };
36
- if (typeof literal === "number") return {
37
- type: Number.isInteger(literal) ? "integer" : "number",
38
- const: literal
99
+ if (typeof literal === "number" || typeof literal === "bigint") return {
100
+ ...schema,
101
+ enum: [String(literal)]
39
102
  };
40
103
  if (typeof literal === "boolean") return {
41
- type: "boolean",
42
- const: literal
43
- };
44
- if (typeof literal === "bigint") return {
45
- type: "integer",
46
- format: "int64"
104
+ ...schema,
105
+ type: "boolean"
47
106
  };
48
107
  if (literal instanceof RegExp) return {
49
- type: "string",
50
- pattern: literal.source
108
+ ...schema,
109
+ type: "string"
51
110
  };
52
- return {};
111
+ return schema;
53
112
  }
54
- case ReflectionKind.templateLiteral: return { type: "string" };
113
+ case ReflectionKind.templateLiteral: return {
114
+ ...schema,
115
+ type: "string"
116
+ };
55
117
  case ReflectionKind.enum: {
56
- const values = reflection.values.filter((value) => typeof value === "string" || typeof value === "number");
57
- const allStrings = values.every((value) => typeof value === "string");
58
- const allNumbers = values.every((value) => typeof value === "number");
118
+ const values = reflection.values.filter((value) => typeof value === "string" || typeof value === "number").map((value) => String(value));
119
+ const unique = Array.from(new Set(values));
120
+ if (unique.length === 0) return schema;
59
121
  return {
60
- type: allStrings ? "string" : allNumbers ? "number" : ["string", "number"],
61
- enum: values
122
+ ...schema,
123
+ enum: unique
62
124
  };
63
125
  }
64
126
  case ReflectionKind.array: {
65
- const items = reflectionToJsonSchema(reflection.type);
66
- return items ? {
67
- type: "array",
68
- items
69
- } : { type: "array" };
127
+ const items = reflectionToJtd(reflection.type);
128
+ return {
129
+ ...schema,
130
+ elements: items ?? {}
131
+ };
132
+ }
133
+ case ReflectionKind.tuple: {
134
+ const items = reflection.types.map((member) => reflectionToJtd(member.type)).filter((item) => item !== void 0);
135
+ if (items.length === 0) return {
136
+ ...schema,
137
+ elements: {}
138
+ };
139
+ if (items.length === 1) return {
140
+ ...schema,
141
+ elements: items[0]
142
+ };
143
+ return {
144
+ ...schema,
145
+ elements: {}
146
+ };
70
147
  }
71
- case ReflectionKind.tuple: return {
72
- type: "array",
73
- items: reflection.types.map((member) => reflectionToJsonSchema(member.type)).filter((item) => item !== void 0),
74
- minItems: reflection.types.filter((member) => !member.optional).length,
75
- maxItems: reflection.types.length
76
- };
77
148
  case ReflectionKind.union: {
78
- const anyOf = reflection.types.map((inner) => reflectionToJsonSchema(inner)).filter((item) => item !== void 0);
79
- if (anyOf.length === 0) return;
80
- if (anyOf.length === 1) return anyOf[0];
81
- return { anyOf };
149
+ const branches = reflection.types.map((inner) => reflectionToJtd(inner)).filter((item) => item !== void 0);
150
+ const nullable = reflection.types.some((inner) => inner.kind === ReflectionKind.null || inner.kind === ReflectionKind.undefined);
151
+ const nonNull = branches.filter((b) => !isPureNullable(b));
152
+ if (nonNull.length === 0) return {
153
+ ...schema,
154
+ nullable: true
155
+ };
156
+ if (nonNull.length === 1) {
157
+ const only = nonNull[0];
158
+ if (nullable) only.nullable = true;
159
+ return {
160
+ ...schema,
161
+ ...only
162
+ };
163
+ }
164
+ if (nonNull.every(isEnumForm)) {
165
+ const merged = Array.from(new Set(nonNull.flatMap((b) => b.enum)));
166
+ const form = {
167
+ ...schema,
168
+ enum: merged
169
+ };
170
+ if (nullable) form.nullable = true;
171
+ return {
172
+ ...schema,
173
+ ...form
174
+ };
175
+ }
176
+ const discriminator = tryReflectionDiscriminator(reflection.types);
177
+ if (discriminator) {
178
+ if (nullable) discriminator.nullable = true;
179
+ return {
180
+ ...schema,
181
+ ...discriminator
182
+ };
183
+ }
184
+ const fallback = {};
185
+ if (nullable) fallback.nullable = true;
186
+ return {
187
+ ...schema,
188
+ ...fallback
189
+ };
82
190
  }
83
191
  case ReflectionKind.intersection: {
84
- const allOf = reflection.types.map((inner) => reflectionToJsonSchema(inner)).filter((item) => item !== void 0);
85
- if (allOf.length === 0) return;
86
- if (allOf.length === 1) return allOf[0];
87
- return { allOf };
192
+ const members = reflection.types.map((inner) => reflectionToJtd(inner)).filter((item) => item !== void 0);
193
+ if (members.length === 0) return;
194
+ if (members.length === 1) return {
195
+ ...schema,
196
+ ...members[0]
197
+ };
198
+ if (members.every((member) => member && isPropertiesForm(member))) return mergePropertiesForms(members);
199
+ return {
200
+ ...schema,
201
+ ...members[0]
202
+ };
88
203
  }
89
- case ReflectionKind.promise: return reflectionToJsonSchema(reflection.type);
90
- case ReflectionKind.objectLiteral: return objectReflectionToJsonSchema(reflection);
204
+ case ReflectionKind.promise: return reflectionToJtd(reflection.type);
205
+ case ReflectionKind.objectLiteral: return objectReflectionToJtd(reflection);
91
206
  case ReflectionKind.class: switch (reflection.classType?.name) {
92
207
  case "Date": return {
93
- type: "string",
94
- format: "date-time"
208
+ ...schema,
209
+ type: "timestamp"
210
+ };
211
+ case "RegExp": return {
212
+ ...schema,
213
+ type: "string"
95
214
  };
96
- case "RegExp": return { type: "string" };
97
215
  case "URL": return {
98
- type: "string",
99
- format: "uri"
216
+ ...schema,
217
+ type: "string"
100
218
  };
101
219
  case "Set": {
102
220
  const itemType = reflection.arguments?.[0];
103
- const items = itemType ? reflectionToJsonSchema(itemType) : void 0;
104
- return items ? {
105
- type: "array",
106
- uniqueItems: true,
107
- items
108
- } : {
109
- type: "array",
110
- uniqueItems: true
221
+ const items = itemType ? reflectionToJtd(itemType) : void 0;
222
+ return {
223
+ ...schema,
224
+ elements: items ?? {}
111
225
  };
112
226
  }
113
227
  case "Map": {
114
228
  const valueType = reflection.arguments?.[1];
115
- const additionalProperties = valueType ? reflectionToJsonSchema(valueType) : void 0;
116
- const schema = { type: "object" };
117
- if (additionalProperties) schema.additionalProperties = additionalProperties;
118
- return schema;
229
+ const values = valueType ? reflectionToJtd(valueType) : void 0;
230
+ return {
231
+ ...schema,
232
+ values: values ?? {}
233
+ };
119
234
  }
120
235
  case "Uint8Array":
121
236
  case "Uint8ClampedArray":
@@ -128,11 +243,11 @@ function reflectionToJsonSchema(reflection) {
128
243
  case "Float64Array":
129
244
  case "BigInt64Array":
130
245
  case "BigUint64Array": return {
131
- type: "string",
132
- contentEncoding: "base64"
246
+ ...schema,
247
+ type: "string"
133
248
  };
134
249
  case void 0:
135
- default: return objectReflectionToJsonSchema(reflection);
250
+ default: return objectReflectionToJtd(reflection);
136
251
  }
137
252
  case ReflectionKind.symbol:
138
253
  case ReflectionKind.property:
@@ -152,38 +267,145 @@ function reflectionToJsonSchema(reflection) {
152
267
  }
153
268
  }
154
269
  /**
155
- * Builds a JSON Schema object representation from a Deepkit class or object literal type.
270
+ * Tests whether a JTD form is an enum form.
271
+ *
272
+ * @param form - The JTD form to inspect.
273
+ * @returns `true` if the form is a JTD enum form.
274
+ */
275
+ function isEnumForm(form) {
276
+ return Array.isArray(form.enum);
277
+ }
278
+ /**
279
+ * Tests whether a JTD form is a properties form (object).
280
+ *
281
+ * @param form - The JTD form to inspect.
282
+ * @returns `true` if the form is a JTD properties form.
283
+ */
284
+ function isPropertiesForm(form) {
285
+ return "properties" in form || "optionalProperties" in form;
286
+ }
287
+ /**
288
+ * Tests whether a JTD form is the empty `{ nullable: true }` placeholder.
289
+ *
290
+ * @param form - The JTD form to inspect.
291
+ * @returns `true` if the form has no shape constraints beyond `nullable`.
292
+ */
293
+ function isPureNullable(form) {
294
+ return Object.keys(form).filter((k) => k !== "nullable" && k !== "metadata").length === 0 && form.nullable === true;
295
+ }
296
+ /**
297
+ * Shallow-merges two JTD properties forms, unioning their `properties` and `optionalProperties` maps.
298
+ *
299
+ * @param forms - The JTD properties forms to merge.
300
+ * @returns The merged JTD properties form.
301
+ */
302
+ function mergePropertiesForms(forms) {
303
+ const merged = {
304
+ properties: {},
305
+ optionalProperties: {}
306
+ };
307
+ for (const form of forms) {
308
+ const p = form.properties;
309
+ const o = form.optionalProperties;
310
+ if (p) Object.assign(merged.properties, p);
311
+ if (o) Object.assign(merged.optionalProperties, o);
312
+ if (form.additionalProperties) merged.additionalProperties = true;
313
+ }
314
+ const hasProperties = Object.keys(merged.properties).length > 0;
315
+ const hasOptional = Object.keys(merged.optionalProperties).length > 0;
316
+ const result = {};
317
+ if (hasProperties) result.properties = merged.properties;
318
+ else if (!hasOptional) result.properties = {};
319
+ if (hasOptional) result.optionalProperties = merged.optionalProperties;
320
+ if (merged.additionalProperties) result.additionalProperties = true;
321
+ return result;
322
+ }
323
+ /**
324
+ * Detects whether a Deepkit union represents a tagged union and, when so, emits the corresponding JTD discriminator form.
325
+ *
326
+ * @param types - The Deepkit reflection types that make up the union branches.
327
+ * @returns A JTD discriminator form if every non-null branch is an object literal that shares a string-literal tag property, otherwise `undefined`.
328
+ */
329
+ function tryReflectionDiscriminator(types) {
330
+ const nonNullTypes = types.filter((t) => t.kind !== ReflectionKind.null && t.kind !== ReflectionKind.undefined);
331
+ const objectBranches = nonNullTypes.filter((t) => t.kind === ReflectionKind.objectLiteral || t.kind === ReflectionKind.class);
332
+ if (objectBranches.length < 2 || objectBranches.length !== nonNullTypes.length) return;
333
+ let tagKey;
334
+ const mapping = {};
335
+ for (const branch of objectBranches) {
336
+ const literalProps = [];
337
+ 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({
338
+ name: member.name,
339
+ literal: member.type.literal
340
+ });
341
+ if (literalProps.length === 0) return;
342
+ const first = literalProps[0];
343
+ if (!tagKey) tagKey = first.name;
344
+ else if (tagKey !== first.name) return;
345
+ const body = objectReflectionToJtd({
346
+ ...branch,
347
+ types: branch.types.filter((member) => !((member.kind === ReflectionKind.property || member.kind === ReflectionKind.propertySignature) && member.name === tagKey))
348
+ });
349
+ if (!body || !isPropertiesForm(body)) return;
350
+ mapping[first.literal] = body;
351
+ }
352
+ if (!tagKey) return;
353
+ return {
354
+ discriminator: tagKey,
355
+ mapping
356
+ };
357
+ }
358
+ /**
359
+ * Internal worker that produces a JTD properties form (or `values` form for index signatures alone) from a Deepkit object-like type.
156
360
  *
157
361
  * @param type - The class or object literal type whose members should be serialized.
158
- * @returns A JSON Schema object describing the type's properties.
362
+ * @returns A JTD properties or values form describing the type's members.
159
363
  */
160
- function objectReflectionToJsonSchema(type) {
364
+ function objectReflectionToJtd(type) {
365
+ const reflection = ReflectionClass.from(type);
366
+ const schema = {};
367
+ schema.metadata = schema.metadata ?? {};
368
+ schema.metadata.isReadonly = reflection.isReadonly();
369
+ schema.metadata.isIgnored = reflection.isIgnored();
370
+ schema.metadata.isInternal = reflection.isInternal();
371
+ schema.metadata.isRuntime = reflection.isRuntime();
372
+ schema.metadata.isHidden = reflection.isHidden();
373
+ if (isSetString(reflection.databaseSchemaName)) schema.metadata.table = reflection.databaseSchemaName;
374
+ if (isSetString(reflection.getDescription())) schema.metadata.description = reflection.getDescription();
375
+ if (isSetArray(reflection.getAlias())) schema.metadata.alias = reflection.getAlias();
376
+ if (isSetString(reflection.getTitle())) schema.metadata.title = reflection.getTitle();
161
377
  const properties = {};
162
- const required = [];
163
- let additionalProperties;
164
- const description = "description" in type && typeof type.description === "string" ? type.description : void 0;
165
- for (const member of type.types) if (member.kind === ReflectionKind.property || member.kind === ReflectionKind.propertySignature) {
166
- const property = member;
167
- if (typeof property.name !== "string") continue;
168
- const propertySchema = reflectionToJsonSchema(property.type);
169
- if (!propertySchema) continue;
170
- if (typeof property.description === "string") propertySchema.description = property.description;
171
- properties[property.name] = propertySchema;
172
- if (!property.optional) required.push(property.name);
173
- } else if (member.kind === ReflectionKind.indexSignature) {
174
- const valueSchema = reflectionToJsonSchema(member.type);
175
- if (valueSchema) additionalProperties = valueSchema;
378
+ const optionalProperties = {};
379
+ for (const propertyReflection of reflection.getProperties()) if (propertyReflection.getKind() === ReflectionKind.indexSignature) {
380
+ const valueSchema = reflectionToJtd(propertyReflection.type);
381
+ if (valueSchema) return {
382
+ ...schema,
383
+ values: valueSchema,
384
+ additionalProperties: true
385
+ };
386
+ } else {
387
+ const property = reflectionToJtd(propertyReflection.type);
388
+ if (!property) continue;
389
+ property.metadata = property.metadata ?? {};
390
+ property.metadata.isReadonly = propertyReflection.isReadonly();
391
+ property.metadata.isIgnored = propertyReflection.isIgnored();
392
+ property.metadata.isInternal = propertyReflection.isInternal();
393
+ property.metadata.isRuntime = propertyReflection.isRuntime();
394
+ property.metadata.isPrimaryKey = propertyReflection.isPrimaryKey();
395
+ property.metadata.isHidden = propertyReflection.isHidden();
396
+ if (propertyReflection.hasDefault()) property.metadata.default = propertyReflection.getDefaultValue();
397
+ if (isSetString(propertyReflection.getDescription())) property.metadata.description = propertyReflection.getDescription();
398
+ if (isSetArray(propertyReflection.getAlias())) property.metadata.alias = propertyReflection.getAlias();
399
+ if (isSetString(propertyReflection.getTitle())) property.metadata.title = propertyReflection.getTitle();
400
+ if (propertyReflection.isOptional()) optionalProperties[propertyReflection.name] = property;
401
+ else properties[propertyReflection.name] = property;
176
402
  }
177
- const schema = {
178
- type: "object",
179
- properties
180
- };
181
- if (required.length > 0) schema.required = required;
182
- if (additionalProperties !== void 0) schema.additionalProperties = additionalProperties;
183
- if (description) schema.description = description;
403
+ if (Object.keys(properties).length > 0) schema.properties = properties;
404
+ else if (Object.keys(optionalProperties).length > 0) schema.optionalProperties = optionalProperties;
405
+ else schema.properties = {};
184
406
  return schema;
185
407
  }
186
408
 
187
409
  //#endregion
188
- export { objectReflectionToJsonSchema, reflectionToJsonSchema };
410
+ export { reflectionToJsonSchema };
189
411
  //# sourceMappingURL=reflection.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"reflection.mjs","names":["indexSignature"],"sources":["../src/reflection.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Type, TypeClass } from \"@powerlines/deepkit/vendor/type\";\nimport {\n ReflectionKind,\n TypeNumberBrand,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { JsonSchema7Type } from \"@stryke/json/types\";\n\n/**\n * Converts a Deepkit type reflection into a JSON Schema representation.\n *\n * @param reflection - The Deepkit type reflection to convert.\n * @returns The corresponding JSON Schema representation, or `undefined` if the type cannot be represented.\n */\nexport function reflectionToJsonSchema(\n reflection: Type\n): JsonSchema7Type | undefined {\n switch (reflection.kind) {\n case ReflectionKind.any:\n case ReflectionKind.unknown:\n case ReflectionKind.void:\n case ReflectionKind.object:\n return {};\n case ReflectionKind.never:\n case ReflectionKind.undefined:\n return { not: {} };\n case ReflectionKind.null:\n return { type: \"null\" };\n case ReflectionKind.string:\n return { type: \"string\" };\n case ReflectionKind.boolean:\n return { type: \"boolean\" };\n case ReflectionKind.number: {\n const brand = reflection.brand;\n const isInteger =\n brand !== undefined &&\n brand >= TypeNumberBrand.integer &&\n brand <= TypeNumberBrand.uint32;\n\n return { type: isInteger ? \"integer\" : \"number\" };\n }\n case ReflectionKind.bigint:\n return { type: \"integer\", format: \"int64\" };\n case ReflectionKind.regexp:\n return { type: \"string\" };\n case ReflectionKind.literal: {\n const { literal } = reflection;\n if (typeof literal === \"string\") {\n return { type: \"string\", const: literal };\n }\n if (typeof literal === \"number\") {\n return {\n type: Number.isInteger(literal) ? \"integer\" : \"number\",\n const: literal\n };\n }\n if (typeof literal === \"boolean\") {\n return { type: \"boolean\", const: literal };\n }\n if (typeof literal === \"bigint\") {\n return { type: \"integer\", format: \"int64\" };\n }\n if (literal instanceof RegExp) {\n return { type: \"string\", pattern: literal.source };\n }\n return {};\n }\n case ReflectionKind.templateLiteral:\n return { type: \"string\" };\n case ReflectionKind.enum: {\n const values = reflection.values.filter(\n (value): value is string | number =>\n typeof value === \"string\" || typeof value === \"number\"\n );\n const allStrings = values.every(value => typeof value === \"string\");\n const allNumbers = values.every(value => typeof value === \"number\");\n\n return {\n type: allStrings\n ? \"string\"\n : allNumbers\n ? \"number\"\n : [\"string\", \"number\"],\n enum: values\n };\n }\n case ReflectionKind.array: {\n const items = reflectionToJsonSchema(reflection.type);\n\n return items ? { type: \"array\", items } : { type: \"array\" };\n }\n case ReflectionKind.tuple: {\n const items = reflection.types\n .map(member => reflectionToJsonSchema(member.type))\n .filter((item): item is JsonSchema7Type => item !== undefined);\n const required = reflection.types.filter(\n member => !member.optional\n ).length;\n\n return {\n type: \"array\",\n items,\n minItems: required,\n maxItems: reflection.types.length\n };\n }\n case ReflectionKind.union: {\n const anyOf = reflection.types\n .map(inner => reflectionToJsonSchema(inner))\n .filter((item): item is JsonSchema7Type => item !== undefined);\n if (anyOf.length === 0) {\n return undefined;\n }\n if (anyOf.length === 1) {\n return anyOf[0];\n }\n return { anyOf };\n }\n case ReflectionKind.intersection: {\n const allOf = reflection.types\n .map(inner => reflectionToJsonSchema(inner))\n .filter((item): item is JsonSchema7Type => item !== undefined);\n if (allOf.length === 0) {\n return undefined;\n }\n if (allOf.length === 1) {\n return allOf[0];\n }\n return { allOf };\n }\n case ReflectionKind.promise:\n return reflectionToJsonSchema(reflection.type);\n case ReflectionKind.objectLiteral:\n return objectReflectionToJsonSchema(reflection);\n case ReflectionKind.class: {\n const classType = reflection.classType as { name?: string } | undefined;\n const className = classType?.name;\n switch (className) {\n case \"Date\":\n return { type: \"string\", format: \"date-time\" };\n case \"RegExp\":\n return { type: \"string\" };\n case \"URL\":\n return { type: \"string\", format: \"uri\" };\n case \"Set\": {\n const itemType = reflection.arguments?.[0];\n const items = itemType ? reflectionToJsonSchema(itemType) : undefined;\n\n return items\n ? { type: \"array\", uniqueItems: true, items }\n : { type: \"array\", uniqueItems: true };\n }\n case \"Map\": {\n const valueType = reflection.arguments?.[1];\n const additionalProperties = valueType\n ? reflectionToJsonSchema(valueType)\n : undefined;\n const schema = { type: \"object\" } as JsonSchema7Type;\n if (additionalProperties) {\n (\n schema as { additionalProperties?: JsonSchema7Type }\n ).additionalProperties = additionalProperties;\n }\n return schema;\n }\n case \"Uint8Array\":\n case \"Uint8ClampedArray\":\n case \"Uint16Array\":\n case \"Uint32Array\":\n case \"Int8Array\":\n case \"Int16Array\":\n case \"Int32Array\":\n case \"Float32Array\":\n case \"Float64Array\":\n case \"BigInt64Array\":\n case \"BigUint64Array\":\n return { type: \"string\", contentEncoding: \"base64\" };\n case undefined:\n default:\n return objectReflectionToJsonSchema(reflection);\n }\n }\n\n case ReflectionKind.symbol:\n case ReflectionKind.property:\n case ReflectionKind.method:\n case ReflectionKind.function:\n case ReflectionKind.parameter:\n case ReflectionKind.typeParameter:\n case ReflectionKind.tupleMember:\n case ReflectionKind.enumMember:\n case ReflectionKind.rest:\n case ReflectionKind.indexSignature:\n case ReflectionKind.propertySignature:\n case ReflectionKind.methodSignature:\n case ReflectionKind.infer:\n case ReflectionKind.callSignature:\n default:\n return undefined;\n }\n}\n\n/**\n * Builds a JSON Schema object representation from a Deepkit class or object literal type.\n *\n * @param type - The class or object literal type whose members should be serialized.\n * @returns A JSON Schema object describing the type's properties.\n */\nexport function objectReflectionToJsonSchema(\n type: TypeObjectLiteral | TypeClass\n): JsonSchema7Type {\n const properties: Record<string, JsonSchema7Type> = {};\n const required: string[] = [];\n let additionalProperties: JsonSchema7Type | boolean | undefined;\n const description =\n \"description\" in type && typeof type.description === \"string\"\n ? type.description\n : undefined;\n\n for (const member of type.types) {\n if (\n member.kind === ReflectionKind.property ||\n member.kind === ReflectionKind.propertySignature\n ) {\n const property = member;\n if (typeof property.name !== \"string\") {\n continue;\n }\n const propertySchema = reflectionToJsonSchema(property.type);\n if (!propertySchema) {\n continue;\n }\n if (typeof property.description === \"string\") {\n (propertySchema as { description?: string }).description =\n property.description;\n }\n properties[property.name] = propertySchema;\n if (!property.optional) {\n required.push(property.name);\n }\n } else if (member.kind === ReflectionKind.indexSignature) {\n const indexSignature = member;\n const valueSchema = reflectionToJsonSchema(indexSignature.type);\n if (valueSchema) {\n additionalProperties = valueSchema;\n }\n }\n }\n\n const schema = {\n type: \"object\",\n properties\n } as JsonSchema7Type;\n\n if (required.length > 0) {\n (schema as { required?: string[] }).required = required;\n }\n if (additionalProperties !== undefined) {\n (\n schema as { additionalProperties?: JsonSchema7Type | boolean }\n ).additionalProperties = additionalProperties;\n }\n if (description) {\n (schema as { description?: string }).description = description;\n }\n\n return schema;\n}\n"],"mappings":";;;;;;;;;AAgCA,SAAgB,uBACd,YAC6B;AAC7B,SAAQ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,gBAAgB,SAClC,CAAC,eAA4C,cAC3C,SAAS;AAEb,aAAW,SAAS,QAAQ;AAC5B,MAAI,CAAC,SAAS,SACZ,UAAS,KAAK,SAAS,KAAK;YAErB,OAAO,SAAS,eAAe,gBAAgB;EAExD,MAAM,cAAc,uBAAuBA,OAAe,KAAK;AAC/D,MAAI,YACF,wBAAuB;;CAK7B,MAAM,SAAS;EACb,MAAM;EACN;EACD;AAED,KAAI,SAAS,SAAS,EACpB,CAAC,OAAmC,WAAW;AAEjD,KAAI,yBAAyB,OAC3B,CACE,OACA,uBAAuB;AAE3B,KAAI,YACF,CAAC,OAAoC,cAAc;AAGrD,QAAO"}
1
+ {"version":3,"file":"reflection.mjs","names":[],"sources":["../src/reflection.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n TagsReflection,\n Type,\n TypeClass\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n ReflectionClass,\n ReflectionKind,\n TypeNumberBrand,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isSetArray, isSetObject, isSetString } from \"@stryke/type-checks\";\nimport { JTDSchemaType, SchemaMetadata } from \"./types\";\n\n/**\n * Maps a Deepkit numeric `brand` to the JTD numeric `type` keyword that best preserves the underlying width and signedness.\n *\n * @param brand - The Deepkit `TypeNumberBrand` of a numeric reflection, or `undefined` when no brand is set.\n * @returns The JTD numeric `type` keyword to use.\n */\nfunction numberBrandToJtdType(\n brand: TypeNumberBrand | undefined\n):\n | \"int8\"\n | \"uint8\"\n | \"int16\"\n | \"uint16\"\n | \"int32\"\n | \"uint32\"\n | \"float32\"\n | \"float64\" {\n switch (brand) {\n case TypeNumberBrand.integer:\n return \"int32\";\n case TypeNumberBrand.int8:\n return \"int8\";\n case TypeNumberBrand.uint8:\n return \"uint8\";\n case TypeNumberBrand.int16:\n return \"int16\";\n case TypeNumberBrand.uint16:\n return \"uint16\";\n case TypeNumberBrand.int32:\n return \"int32\";\n case TypeNumberBrand.uint32:\n return \"uint32\";\n case TypeNumberBrand.float:\n case TypeNumberBrand.float32:\n return \"float32\";\n case TypeNumberBrand.float64:\n return \"float64\";\n case undefined:\n default:\n return \"float64\";\n }\n}\n\n/**\n * Converts a Deepkit type reflection into a JSON Type Definition (RFC 8927) form suitable for AJV's JTD validator.\n *\n * @remarks\n * Some TypeScript constructs have no direct JTD equivalent and are handled with the closest available form:\n *\n * - `null` and `undefined` become the empty JTD form with `nullable: true`.\n * - Unions of primitives that cannot be expressed as a JTD enum collapse to the empty form (which validates any value).\n * - String/number/bigint literal unions are emitted as a JTD enum (non-string members are stringified, as JTD requires string enum members).\n * - Tuples are emitted as a JTD elements form whose element schema is the single tuple member type, or the empty schema for mixed tuples.\n * - `Date` is emitted as `{ type: \"timestamp\" }`.\n * - Discriminated unions of object literals (a shared string-literal tag property) are emitted as a JTD discriminator form.\n *\n * @param reflection - The Deepkit type reflection to convert.\n * @returns The corresponding JTD form, or `undefined` if the type cannot be represented.\n */\nexport function reflectionToJsonSchema<\n TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>\n>(reflection: Type): JTDSchemaType<TMetadata> | undefined {\n const result = reflectionToJtd<TMetadata>(reflection);\n\n return result;\n}\n\n/**\n * Internal worker that performs the recursive Deepkit reflection → JTD conversion.\n *\n * @param reflection - The Deepkit type reflection to convert.\n * @returns The corresponding JTD form, or `undefined` if the type cannot be represented.\n */\nfunction reflectionToJtd<\n TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>\n>(reflection: Type): JTDSchemaType<TMetadata> | undefined {\n const schema = {} as JTDSchemaType<TMetadata>;\n\n if (isSetObject((reflection as { tags?: TagsReflection })?.tags)) {\n const tags = (reflection as { tags: TagsReflection }).tags;\n\n schema.metadata = (schema.metadata ?? {}) as TMetadata;\n if (tags.readonly === true) {\n schema.metadata.isReadonly = true;\n }\n if (tags.ignore === true) {\n schema.metadata.isIgnored = true;\n }\n if (tags.internal === true) {\n schema.metadata.isInternal = true;\n }\n if (tags.runtime === true) {\n schema.metadata.isRuntime = true;\n }\n if (tags.hidden === true) {\n schema.metadata.isHidden = true;\n }\n if (isSetArray(tags.alias)) {\n schema.metadata.alias = tags.alias;\n }\n if (isSetString(tags.title)) {\n schema.metadata.title = tags.title;\n }\n }\n\n switch (reflection.kind) {\n case ReflectionKind.any:\n case ReflectionKind.unknown:\n case ReflectionKind.void:\n case ReflectionKind.object:\n return {};\n case ReflectionKind.never:\n return undefined;\n case ReflectionKind.undefined:\n case ReflectionKind.null:\n return { nullable: true };\n case ReflectionKind.string:\n return { ...schema, type: \"string\" };\n case ReflectionKind.boolean:\n return { ...schema, type: \"boolean\" };\n case ReflectionKind.number:\n return {\n ...schema,\n type: numberBrandToJtdType(reflection.brand)\n };\n case ReflectionKind.bigint:\n // JTD has no native 64-bit integer type — float64 is the widest numeric form.\n return { ...schema, type: \"float64\" };\n case ReflectionKind.regexp:\n return { ...schema, type: \"string\" };\n case ReflectionKind.literal: {\n const { literal } = reflection;\n if (typeof literal === \"string\") {\n return { ...schema, enum: [literal] };\n }\n\n if (typeof literal === \"number\" || typeof literal === \"bigint\") {\n return {\n ...schema,\n enum: [String(literal)]\n };\n }\n\n if (typeof literal === \"boolean\") {\n // JTD has no boolean literal — emit the type form.\n return { ...schema, type: \"boolean\" };\n }\n\n if (literal instanceof RegExp) {\n return { ...schema, type: \"string\" };\n }\n\n return schema;\n }\n case ReflectionKind.templateLiteral:\n return { ...schema, type: \"string\" };\n case ReflectionKind.enum: {\n const values = reflection.values\n .filter(\n (value): value is string | number =>\n typeof value === \"string\" || typeof value === \"number\"\n )\n .map(value => String(value));\n\n const unique = Array.from(new Set(values));\n if (unique.length === 0) {\n return schema;\n }\n\n return { ...schema, enum: unique };\n }\n case ReflectionKind.array: {\n const items = reflectionToJtd<TMetadata>(reflection.type);\n\n return { ...schema, elements: items ?? {} };\n }\n case ReflectionKind.tuple: {\n const items = reflection.types\n .map(member => reflectionToJtd<TMetadata>(member.type))\n .filter((item): item is JTDSchemaType<TMetadata> => item !== undefined);\n if (items.length === 0) {\n return { ...schema, elements: {} };\n }\n\n if (items.length === 1) {\n return { ...schema, elements: items[0]! };\n }\n\n // JTD has no tuple form — accept any element shape.\n return { ...schema, elements: {} };\n }\n case ReflectionKind.union: {\n const branches = reflection.types\n .map(inner => reflectionToJtd<TMetadata>(inner))\n .filter((item): item is JTDSchemaType<TMetadata> => item !== undefined);\n\n const nullable = reflection.types.some(\n inner =>\n inner.kind === ReflectionKind.null ||\n inner.kind === ReflectionKind.undefined\n );\n const nonNull = branches.filter(b => !isPureNullable(b));\n\n if (nonNull.length === 0) {\n return { ...schema, nullable: true };\n }\n\n if (nonNull.length === 1) {\n const only = nonNull[0]!;\n if (nullable) {\n (only as { nullable?: boolean }).nullable = true;\n }\n\n return { ...schema, ...only };\n }\n\n // String-enum union: combine all enum branches into one JTD enum.\n if (nonNull.every(isEnumForm)) {\n const merged = Array.from(\n new Set(nonNull.flatMap(b => (b as { enum: string[] }).enum))\n );\n const form: JTDSchemaType<TMetadata> = { ...schema, enum: merged };\n\n if (nullable) {\n (form as { nullable?: boolean }).nullable = true;\n }\n\n return { ...schema, ...form };\n }\n\n // Discriminated union of object literals: detect a shared string-literal tag.\n const discriminator = tryReflectionDiscriminator<TMetadata>(\n reflection.types\n );\n if (discriminator) {\n if (nullable) {\n (discriminator as { nullable?: boolean }).nullable = true;\n }\n\n return { ...schema, ...discriminator };\n }\n\n // Fallback — JTD has no general union; allow any value.\n const fallback: JTDSchemaType<TMetadata> = {};\n if (nullable) {\n (fallback as { nullable?: boolean }).nullable = true;\n }\n\n return { ...schema, ...fallback };\n }\n case ReflectionKind.intersection: {\n const members = reflection.types\n .map(inner => reflectionToJtd<TMetadata>(inner))\n .filter(\n (item): item is JTDSchemaType<TMetadata> | undefined =>\n item !== undefined\n );\n if (members.length === 0) {\n return undefined as JTDSchemaType<TMetadata> | undefined;\n }\n\n if (members.length === 1) {\n return { ...schema, ...members[0] };\n }\n\n if (\n members.every(member => member && isPropertiesForm<TMetadata>(member))\n ) {\n return mergePropertiesForms<TMetadata>(\n members as JTDSchemaType<TMetadata>[]\n );\n }\n\n return { ...schema, ...members[0] };\n }\n case ReflectionKind.promise:\n return reflectionToJtd<TMetadata>(reflection.type);\n case ReflectionKind.objectLiteral:\n return objectReflectionToJtd<TMetadata>(reflection);\n case ReflectionKind.class: {\n const classType = reflection.classType as { name?: string } | undefined;\n const className = classType?.name;\n switch (className) {\n case \"Date\":\n return { ...schema, type: \"timestamp\" };\n case \"RegExp\":\n return { ...schema, type: \"string\" };\n case \"URL\":\n return { ...schema, type: \"string\" };\n case \"Set\": {\n const itemType = reflection.arguments?.[0];\n const items = itemType\n ? reflectionToJtd<TMetadata>(itemType)\n : undefined;\n\n return { ...schema, elements: items ?? {} };\n }\n case \"Map\": {\n const valueType = reflection.arguments?.[1];\n const values = valueType\n ? reflectionToJtd<TMetadata>(valueType)\n : undefined;\n\n return { ...schema, values: values ?? {} };\n }\n case \"Uint8Array\":\n case \"Uint8ClampedArray\":\n case \"Uint16Array\":\n case \"Uint32Array\":\n case \"Int8Array\":\n case \"Int16Array\":\n case \"Int32Array\":\n case \"Float32Array\":\n case \"Float64Array\":\n case \"BigInt64Array\":\n case \"BigUint64Array\":\n // Base64-encoded binary payload — represented as a plain string in JTD.\n return { ...schema, type: \"string\" };\n case undefined:\n default:\n return objectReflectionToJtd<TMetadata>(reflection);\n }\n }\n case ReflectionKind.symbol:\n case ReflectionKind.property:\n case ReflectionKind.method:\n case ReflectionKind.function:\n case ReflectionKind.parameter:\n case ReflectionKind.typeParameter:\n case ReflectionKind.tupleMember:\n case ReflectionKind.enumMember:\n case ReflectionKind.rest:\n case ReflectionKind.indexSignature:\n case ReflectionKind.propertySignature:\n case ReflectionKind.methodSignature:\n case ReflectionKind.infer:\n case ReflectionKind.callSignature:\n default:\n return undefined;\n }\n}\n\n/**\n * Tests whether a JTD form is an enum form.\n *\n * @param form - The JTD form to inspect.\n * @returns `true` if the form is a JTD enum form.\n */\nfunction isEnumForm<\n TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>\n>(\n form: JTDSchemaType<TMetadata>\n): form is { enum: string[]; nullable?: boolean; metadata?: TMetadata } {\n return Array.isArray((form as { enum?: unknown[] }).enum);\n}\n\n/**\n * Tests whether a JTD form is a properties form (object).\n *\n * @param form - The JTD form to inspect.\n * @returns `true` if the form is a JTD properties form.\n */\nfunction isPropertiesForm<\n TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>\n>(\n form: JTDSchemaType<TMetadata>\n): form is {\n properties: Record<string, JTDSchemaType<TMetadata>>;\n optionalProperties?: Record<string, JTDSchemaType<TMetadata>>;\n nullable?: boolean;\n metadata?: TMetadata;\n} {\n return (\n \"properties\" in (form as object) || \"optionalProperties\" in (form as object)\n );\n}\n\n/**\n * Tests whether a JTD form is the empty `{ nullable: true }` placeholder.\n *\n * @param form - The JTD form to inspect.\n * @returns `true` if the form has no shape constraints beyond `nullable`.\n */\nfunction isPureNullable<\n TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>\n>(form: JTDSchemaType<TMetadata>): boolean {\n const keys = Object.keys(form as object).filter(\n k => k !== \"nullable\" && k !== \"metadata\"\n );\n\n return (\n keys.length === 0 && (form as { nullable?: boolean }).nullable === true\n );\n}\n\n/**\n * Shallow-merges two JTD properties forms, unioning their `properties` and `optionalProperties` maps.\n *\n * @param forms - The JTD properties forms to merge.\n * @returns The merged JTD properties form.\n */\nfunction mergePropertiesForms<\n TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>\n>(forms: JTDSchemaType<TMetadata>[]): JTDSchemaType<TMetadata> {\n const merged: {\n properties: Record<string, JTDSchemaType<TMetadata>>;\n optionalProperties: Record<string, JTDSchemaType<TMetadata>>;\n additionalProperties?: boolean;\n } = {\n properties: {},\n optionalProperties: {}\n };\n\n for (const form of forms) {\n const p = (\n form as { properties?: Record<string, JTDSchemaType<TMetadata>> }\n ).properties;\n const o = (\n form as { optionalProperties?: Record<string, JTDSchemaType<TMetadata>> }\n ).optionalProperties;\n if (p) {\n Object.assign(merged.properties, p);\n }\n if (o) {\n Object.assign(merged.optionalProperties, o);\n }\n if ((form as { additionalProperties?: boolean }).additionalProperties) {\n merged.additionalProperties = true;\n }\n }\n\n const hasProperties = Object.keys(merged.properties).length > 0;\n const hasOptional = Object.keys(merged.optionalProperties).length > 0;\n const result: JTDSchemaType<TMetadata> = {};\n\n if (hasProperties) {\n (\n result as { properties: Record<string, JTDSchemaType<TMetadata>> }\n ).properties = merged.properties;\n } else if (!hasOptional) {\n (\n result as { properties: Record<string, JTDSchemaType<TMetadata>> }\n ).properties = {};\n }\n\n if (hasOptional) {\n (\n result as { optionalProperties: Record<string, JTDSchemaType<TMetadata>> }\n ).optionalProperties = merged.optionalProperties;\n }\n\n if (merged.additionalProperties) {\n (result as { additionalProperties: boolean }).additionalProperties = true;\n }\n\n return result;\n}\n\n/**\n * Detects whether a Deepkit union represents a tagged union and, when so, emits the corresponding JTD discriminator form.\n *\n * @param types - The Deepkit reflection types that make up the union branches.\n * @returns A JTD discriminator form if every non-null branch is an object literal that shares a string-literal tag property, otherwise `undefined`.\n */\nfunction tryReflectionDiscriminator<\n TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>\n>(types: readonly Type[]): JTDSchemaType<TMetadata> | undefined {\n const nonNullTypes = types.filter(\n t => t.kind !== ReflectionKind.null && t.kind !== ReflectionKind.undefined\n );\n const objectBranches: Array<TypeObjectLiteral | TypeClass> =\n nonNullTypes.filter(\n t =>\n t.kind === ReflectionKind.objectLiteral ||\n t.kind === ReflectionKind.class\n );\n\n if (\n objectBranches.length < 2 ||\n objectBranches.length !== nonNullTypes.length\n ) {\n return undefined;\n }\n\n let tagKey: string | undefined;\n const mapping: Record<string, JTDSchemaType<TMetadata>> = {};\n\n for (const branch of objectBranches) {\n const literalProps: Array<{ name: string; literal: string }> = [];\n for (const member of branch.types) {\n if (\n (member.kind === ReflectionKind.property ||\n member.kind === ReflectionKind.propertySignature) &&\n typeof member.name === \"string\" &&\n member.type.kind === ReflectionKind.literal &&\n typeof (member.type as { literal?: unknown }).literal === \"string\"\n ) {\n literalProps.push({\n name: member.name,\n literal: (member.type as { literal: string }).literal\n });\n }\n }\n\n if (literalProps.length === 0) {\n return undefined;\n }\n\n const first = literalProps[0]!;\n if (!tagKey) {\n tagKey = first.name;\n } else if (tagKey !== first.name) {\n return undefined;\n }\n\n // Build the branch body excluding the discriminator property.\n const filteredBranch = {\n ...branch,\n types: branch.types.filter(\n member =>\n !(\n (member.kind === ReflectionKind.property ||\n member.kind === ReflectionKind.propertySignature) &&\n member.name === tagKey\n )\n )\n } as TypeObjectLiteral | TypeClass;\n\n const body = objectReflectionToJtd<TMetadata>(filteredBranch);\n if (!body || !isPropertiesForm<TMetadata>(body)) {\n return undefined;\n }\n\n mapping[first.literal] = body;\n }\n\n if (!tagKey) {\n return undefined;\n }\n\n return { discriminator: tagKey, mapping };\n}\n\n/**\n * Internal worker that produces a JTD properties form (or `values` form for index signatures alone) from a Deepkit object-like type.\n *\n * @param type - The class or object literal type whose members should be serialized.\n * @returns A JTD properties or values form describing the type's members.\n */\nfunction objectReflectionToJtd<\n TMetadata extends Partial<SchemaMetadata> = Partial<SchemaMetadata>\n>(type: TypeObjectLiteral | TypeClass): JTDSchemaType<TMetadata> {\n const reflection = ReflectionClass.from(type);\n\n const schema = {} as {\n properties?: Record<string, JTDSchemaType<TMetadata>>;\n optionalProperties?: Record<string, JTDSchemaType<TMetadata>>;\n additionalProperties?: boolean;\n metadata?: TMetadata;\n };\n\n schema.metadata = (schema.metadata ?? {}) as TMetadata;\n schema.metadata.isReadonly = reflection.isReadonly();\n schema.metadata.isIgnored = reflection.isIgnored();\n schema.metadata.isInternal = reflection.isInternal();\n schema.metadata.isRuntime = reflection.isRuntime();\n schema.metadata.isHidden = reflection.isHidden();\n\n if (isSetString(reflection.databaseSchemaName)) {\n schema.metadata.table = reflection.databaseSchemaName;\n }\n if (isSetString(reflection.getDescription())) {\n schema.metadata.description = reflection.getDescription();\n }\n if (isSetArray(reflection.getAlias())) {\n schema.metadata.alias = reflection.getAlias();\n }\n if (isSetString(reflection.getTitle())) {\n schema.metadata.title = reflection.getTitle();\n }\n\n const properties: Record<string, JTDSchemaType<TMetadata>> = {};\n const optionalProperties: Record<string, JTDSchemaType<TMetadata>> = {};\n\n for (const propertyReflection of reflection.getProperties()) {\n if (propertyReflection.getKind() === ReflectionKind.indexSignature) {\n const valueSchema = reflectionToJtd<TMetadata>(propertyReflection.type);\n if (valueSchema) {\n return {\n ...schema,\n values: valueSchema,\n additionalProperties: true\n };\n }\n } else {\n const property = reflectionToJtd<TMetadata>(propertyReflection.type);\n if (!property) {\n continue;\n }\n\n property.metadata = (property.metadata ?? {}) as TMetadata;\n property.metadata.isReadonly = propertyReflection.isReadonly();\n property.metadata.isIgnored = propertyReflection.isIgnored();\n property.metadata.isInternal = propertyReflection.isInternal();\n property.metadata.isRuntime = propertyReflection.isRuntime();\n property.metadata.isPrimaryKey = propertyReflection.isPrimaryKey();\n property.metadata.isHidden = propertyReflection.isHidden();\n\n if (propertyReflection.hasDefault()) {\n property.metadata.default = propertyReflection.getDefaultValue();\n }\n if (isSetString(propertyReflection.getDescription())) {\n property.metadata.description = propertyReflection.getDescription();\n }\n if (isSetArray(propertyReflection.getAlias())) {\n property.metadata.alias = propertyReflection.getAlias();\n }\n if (isSetString(propertyReflection.getTitle())) {\n property.metadata.title = propertyReflection.getTitle();\n }\n\n if (propertyReflection.isOptional()) {\n optionalProperties[propertyReflection.name] = property;\n } else {\n properties[propertyReflection.name] = property;\n }\n }\n }\n\n if (Object.keys(properties).length > 0) {\n schema.properties = properties;\n } else if (Object.keys(optionalProperties).length > 0) {\n schema.optionalProperties = optionalProperties;\n } else {\n schema.properties = {};\n }\n\n return schema;\n}\n"],"mappings":";;;;;;;;;;AAsCA,SAAS,qBACP,OASY;AACZ,SAAQ,OAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB,KACnB,QAAO;EACT,KAAK,gBAAgB,MACnB,QAAO;EACT,KAAK,gBAAgB,MACnB,QAAO;EACT,KAAK,gBAAgB,OACnB,QAAO;EACT,KAAK,gBAAgB,MACnB,QAAO;EACT,KAAK,gBAAgB,OACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK;EACL,QACE,QAAO;;;;;;;;;;;;;;;;;;;AAoBb,SAAgB,uBAEd,YAAwD;AAGxD,QAFe,gBAA2B,WAE7B;;;;;;;;AASf,SAAS,gBAEP,YAAwD;CACxD,MAAM,SAAS,EAAE;AAEjB,KAAI,YAAa,YAA0C,KAAK,EAAE;EAChE,MAAM,OAAQ,WAAwC;AAEtD,SAAO,WAAY,OAAO,YAAY,EAAE;AACxC,MAAI,KAAK,aAAa,KACpB,QAAO,SAAS,aAAa;AAE/B,MAAI,KAAK,WAAW,KAClB,QAAO,SAAS,YAAY;AAE9B,MAAI,KAAK,aAAa,KACpB,QAAO,SAAS,aAAa;AAE/B,MAAI,KAAK,YAAY,KACnB,QAAO,SAAS,YAAY;AAE9B,MAAI,KAAK,WAAW,KAClB,QAAO,SAAS,WAAW;AAE7B,MAAI,WAAW,KAAK,MAAM,CACxB,QAAO,SAAS,QAAQ,KAAK;AAE/B,MAAI,YAAY,KAAK,MAAM,CACzB,QAAO,SAAS,QAAQ,KAAK;;AAIjC,SAAQ,WAAW,MAAnB;EACE,KAAK,eA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AAmB,UAAU,CAAC,CAC3C,UAAS,SAAS,QAAQ,mBAAmB,UAAU;AAEzD,MAAI,YAAY,mBAAmB,UAAU,CAAC,CAC5C,UAAS,SAAS,QAAQ,mBAAmB,UAAU;AAGzD,MAAI,mBAAmB,YAAY,CACjC,oBAAmB,mBAAmB,QAAQ;MAE9C,YAAW,mBAAmB,QAAQ;;AAK5C,KAAI,OAAO,KAAK,WAAW,CAAC,SAAS,EACnC,QAAO,aAAa;UACX,OAAO,KAAK,mBAAmB,CAAC,SAAS,EAClD,QAAO,qBAAqB;KAE5B,QAAO,aAAa,EAAE;AAGxB,QAAO"}
@@ -1,7 +1,7 @@
1
1
  import { BundleOptions } from "./bundle.cjs";
2
- import { PluginContext } from "@powerlines/core";
2
+ import { TypeDefinitionReference } from "./types.cjs";
3
+ import { PluginContext, UnresolvedContext } from "@powerlines/core";
3
4
  import { Type } from "@powerlines/deepkit/vendor/type";
4
- import { TypeDefinitionParameter } from "@stryke/types/configuration";
5
5
 
6
6
  //#region src/resolve.d.ts
7
7
  /**
@@ -12,7 +12,7 @@ import { TypeDefinitionParameter } from "@stryke/types/configuration";
12
12
  * @param overrides - Optional overrides for the ESBuild configuration.
13
13
  * @returns A promise that resolves to the compiled module.
14
14
  */
15
- declare function resolveModule<TResult, TContext extends PluginContext = PluginContext>(context: TContext, type: TypeDefinitionParameter, overrides?: BundleOptions): Promise<TResult>;
15
+ declare function resolveModule<TResult, TContext extends UnresolvedContext = UnresolvedContext>(context: TContext, type: TypeDefinitionReference, overrides?: BundleOptions): Promise<TResult>;
16
16
  /**
17
17
  * Compiles a type definition to a module and returns the specified export from the module.
18
18
  *
@@ -21,7 +21,7 @@ declare function resolveModule<TResult, TContext extends PluginContext = PluginC
21
21
  * @param options - Optional overrides for the ESBuild configuration.
22
22
  * @returns A promise that resolves to the compiled module.
23
23
  */
24
- declare function resolve<TResult, TContext extends PluginContext = PluginContext>(context: TContext, input: TypeDefinitionParameter, options?: BundleOptions): Promise<TResult>;
24
+ declare function resolve<TResult, TContext extends UnresolvedContext = UnresolvedContext>(context: TContext, input: TypeDefinitionReference, options?: BundleOptions): Promise<TResult>;
25
25
  /**
26
26
  * 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.
27
27
  *
@@ -30,7 +30,7 @@ declare function resolve<TResult, TContext extends PluginContext = PluginContext
30
30
  * @param options - Optional overrides for the ESBuild configuration.
31
31
  * @returns A promise that resolves to the Deepkit Type reflection.
32
32
  */
33
- declare function resolveReflection<TContext extends PluginContext = PluginContext>(context: TContext, input: TypeDefinitionParameter, options?: BundleOptions): Promise<Type>;
33
+ declare function resolveReflection<TContext extends PluginContext = PluginContext>(context: TContext, input: TypeDefinitionReference, options?: BundleOptions): Promise<Type>;
34
34
  //#endregion
35
35
  export { resolve, resolveModule, resolveReflection };
36
36
  //# sourceMappingURL=resolve.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.cts","names":[],"sources":["../src/resolve.ts"],"mappings":";;;;;;;;AAuCA;;;;;;iBAAsB,aAAA,2BAEH,aAAA,GAAgB,aAAA,CAAA,CAEjC,OAAA,EAAS,QAAA,EACT,IAAA,EAAM,uBAAA,EACN,SAAA,GAAY,aAAA,GACX,OAAA,CAAQ,OAAA;;;;;;;;;iBAyEW,OAAA,2BAEH,aAAA,GAAgB,aAAA,CAAA,CAEjC,OAAA,EAAS,QAAA,EACT,KAAA,EAAO,uBAAA,EACP,OAAA,GAAU,aAAA,GACT,OAAA,CAAQ,OAAA;;;;;;;;;iBAiDW,iBAAA,kBACH,aAAA,GAAgB,aAAA,CAAA,CAEjC,OAAA,EAAS,QAAA,EACT,KAAA,EAAO,uBAAA,EACP,OAAA,GAAU,aAAA,GACT,OAAA,CAAQ,IAAA"}
1
+ {"version":3,"file":"resolve.d.cts","names":[],"sources":["../src/resolve.ts"],"mappings":";;;;;;;;AAqCA;;;;;;iBAAsB,aAAA,2BAEH,iBAAA,GAAoB,iBAAA,CAAA,CAErC,OAAA,EAAS,QAAA,EACT,IAAA,EAAM,uBAAA,EACN,SAAA,GAAY,aAAA,GACX,OAAA,CAAQ,OAAA;;;;;;;;;iBAyEW,OAAA,2BAEH,iBAAA,GAAoB,iBAAA,CAAA,CAErC,OAAA,EAAS,QAAA,EACT,KAAA,EAAO,uBAAA,EACP,OAAA,GAAU,aAAA,GACT,OAAA,CAAQ,OAAA;;;;;;;;;iBAiDW,iBAAA,kBACH,aAAA,GAAgB,aAAA,CAAA,CAEjC,OAAA,EAAS,QAAA,EACT,KAAA,EAAO,uBAAA,EACP,OAAA,GAAU,aAAA,GACT,OAAA,CAAQ,IAAA"}