@formspec/build 0.1.0-alpha.5 → 0.1.0-alpha.50

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 (119) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +238 -93
  3. package/dist/analyzer/class-analyzer.d.ts +135 -0
  4. package/dist/analyzer/class-analyzer.d.ts.map +1 -0
  5. package/dist/analyzer/jsdoc-constraints.d.ts +53 -0
  6. package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -0
  7. package/dist/analyzer/program.d.ts +97 -0
  8. package/dist/analyzer/program.d.ts.map +1 -0
  9. package/dist/analyzer/tsdoc-parser.d.ts +124 -0
  10. package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
  11. package/dist/browser.cjs +2212 -0
  12. package/dist/browser.cjs.map +1 -0
  13. package/dist/browser.d.ts +74 -0
  14. package/dist/browser.d.ts.map +1 -0
  15. package/dist/browser.js +2167 -0
  16. package/dist/browser.js.map +1 -0
  17. package/dist/build-alpha.d.ts +2408 -0
  18. package/dist/build-beta.d.ts +2408 -0
  19. package/dist/build-internal.d.ts +2408 -0
  20. package/dist/build.d.ts +2209 -151
  21. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +22 -0
  22. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -0
  23. package/dist/canonicalize/index.d.ts +8 -0
  24. package/dist/canonicalize/index.d.ts.map +1 -0
  25. package/dist/canonicalize/tsdoc-canonicalizer.d.ts +38 -0
  26. package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
  27. package/dist/cli.cjs +7111 -0
  28. package/dist/cli.cjs.map +1 -0
  29. package/dist/cli.js +7070 -103
  30. package/dist/cli.js.map +1 -1
  31. package/dist/extensions/index.d.ts +8 -0
  32. package/dist/extensions/index.d.ts.map +1 -0
  33. package/dist/extensions/registry.d.ts +142 -0
  34. package/dist/extensions/registry.d.ts.map +1 -0
  35. package/dist/extensions/resolve-custom-type.d.ts +37 -0
  36. package/dist/extensions/resolve-custom-type.d.ts.map +1 -0
  37. package/dist/extensions/symbol-registry.d.ts +33 -0
  38. package/dist/extensions/symbol-registry.d.ts.map +1 -0
  39. package/dist/extensions/ts-type-utils.d.ts +40 -0
  40. package/dist/extensions/ts-type-utils.d.ts.map +1 -0
  41. package/dist/generators/class-schema.d.ts +392 -0
  42. package/dist/generators/class-schema.d.ts.map +1 -0
  43. package/dist/generators/discovered-schema.d.ts +152 -0
  44. package/dist/generators/discovered-schema.d.ts.map +1 -0
  45. package/dist/generators/method-schema.d.ts +72 -0
  46. package/dist/generators/method-schema.d.ts.map +1 -0
  47. package/dist/generators/mixed-authoring.d.ts +52 -0
  48. package/dist/generators/mixed-authoring.d.ts.map +1 -0
  49. package/dist/index.cjs +6786 -0
  50. package/dist/index.cjs.map +1 -0
  51. package/dist/index.d.ts +51 -8
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +6751 -107
  54. package/dist/index.js.map +1 -1
  55. package/dist/internals.cjs +5736 -0
  56. package/dist/internals.cjs.map +1 -0
  57. package/dist/internals.d.ts +32 -0
  58. package/dist/internals.d.ts.map +1 -0
  59. package/dist/internals.js +5706 -0
  60. package/dist/internals.js.map +1 -0
  61. package/dist/json-schema/generator.d.ts +32 -6
  62. package/dist/json-schema/generator.d.ts.map +1 -1
  63. package/dist/json-schema/ir-generator.d.ts +149 -0
  64. package/dist/json-schema/ir-generator.d.ts.map +1 -0
  65. package/dist/json-schema/schema.d.ts +23 -0
  66. package/dist/json-schema/schema.d.ts.map +1 -0
  67. package/dist/json-schema/types.d.ts +76 -2
  68. package/dist/json-schema/types.d.ts.map +1 -1
  69. package/dist/metadata/collision-guards.d.ts +3 -0
  70. package/dist/metadata/collision-guards.d.ts.map +1 -0
  71. package/dist/metadata/index.d.ts +7 -0
  72. package/dist/metadata/index.d.ts.map +1 -0
  73. package/dist/metadata/policy.d.ts +12 -0
  74. package/dist/metadata/policy.d.ts.map +1 -0
  75. package/dist/metadata/resolve.d.ts +21 -0
  76. package/dist/metadata/resolve.d.ts.map +1 -0
  77. package/dist/static-build.d.ts +61 -0
  78. package/dist/static-build.d.ts.map +1 -0
  79. package/dist/ui-schema/generator.d.ts +18 -2
  80. package/dist/ui-schema/generator.d.ts.map +1 -1
  81. package/dist/ui-schema/ir-generator.d.ts +54 -0
  82. package/dist/ui-schema/ir-generator.d.ts.map +1 -0
  83. package/dist/ui-schema/schema.d.ts +429 -0
  84. package/dist/ui-schema/schema.d.ts.map +1 -0
  85. package/dist/ui-schema/types.d.ts +179 -35
  86. package/dist/ui-schema/types.d.ts.map +1 -1
  87. package/dist/validate/constraint-validator.d.ts +85 -0
  88. package/dist/validate/constraint-validator.d.ts.map +1 -0
  89. package/dist/validate/index.d.ts +9 -0
  90. package/dist/validate/index.d.ts.map +1 -0
  91. package/package.json +30 -11
  92. package/dist/__tests__/cli.test.d.ts +0 -2
  93. package/dist/__tests__/cli.test.d.ts.map +0 -1
  94. package/dist/__tests__/cli.test.js +0 -178
  95. package/dist/__tests__/cli.test.js.map +0 -1
  96. package/dist/__tests__/edge-cases.test.d.ts +0 -7
  97. package/dist/__tests__/edge-cases.test.d.ts.map +0 -1
  98. package/dist/__tests__/edge-cases.test.js +0 -217
  99. package/dist/__tests__/edge-cases.test.js.map +0 -1
  100. package/dist/__tests__/generator.test.d.ts +0 -2
  101. package/dist/__tests__/generator.test.d.ts.map +0 -1
  102. package/dist/__tests__/generator.test.js +0 -234
  103. package/dist/__tests__/generator.test.js.map +0 -1
  104. package/dist/__tests__/integration.test.d.ts +0 -8
  105. package/dist/__tests__/integration.test.d.ts.map +0 -1
  106. package/dist/__tests__/integration.test.js +0 -163
  107. package/dist/__tests__/integration.test.js.map +0 -1
  108. package/dist/__tests__/write-schemas.test.d.ts +0 -2
  109. package/dist/__tests__/write-schemas.test.d.ts.map +0 -1
  110. package/dist/__tests__/write-schemas.test.js +0 -196
  111. package/dist/__tests__/write-schemas.test.js.map +0 -1
  112. package/dist/json-schema/generator.js +0 -167
  113. package/dist/json-schema/generator.js.map +0 -1
  114. package/dist/json-schema/types.js +0 -7
  115. package/dist/json-schema/types.js.map +0 -1
  116. package/dist/ui-schema/generator.js +0 -150
  117. package/dist/ui-schema/generator.js.map +0 -1
  118. package/dist/ui-schema/types.js +0 -8
  119. package/dist/ui-schema/types.js.map +0 -1
@@ -0,0 +1,2212 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/browser.ts
21
+ var browser_exports = {};
22
+ __export(browser_exports, {
23
+ buildFormSchemas: () => buildFormSchemas,
24
+ canonicalizeChainDSL: () => canonicalizeChainDSL,
25
+ categorizationSchema: () => categorizationSchema,
26
+ categorySchema: () => categorySchema,
27
+ controlSchema: () => controlSchema,
28
+ createExtensionRegistry: () => createExtensionRegistry,
29
+ generateJsonSchema: () => generateJsonSchema,
30
+ generateJsonSchemaFromIR: () => generateJsonSchemaFromIR,
31
+ generateUiSchema: () => generateUiSchema,
32
+ getSchemaExtension: () => getSchemaExtension,
33
+ groupLayoutSchema: () => groupLayoutSchema,
34
+ horizontalLayoutSchema: () => horizontalLayoutSchema,
35
+ jsonSchema7Schema: () => jsonSchema7Schema,
36
+ jsonSchemaTypeSchema: () => jsonSchemaTypeSchema,
37
+ labelElementSchema: () => labelElementSchema,
38
+ ruleConditionSchema: () => ruleConditionSchema,
39
+ ruleEffectSchema: () => ruleEffectSchema,
40
+ ruleSchema: () => ruleSchema,
41
+ schemaBasedConditionSchema: () => schemaBasedConditionSchema,
42
+ setSchemaExtension: () => setSchemaExtension,
43
+ uiSchemaElementSchema: () => uiSchemaElementSchema,
44
+ uiSchemaElementTypeSchema: () => uiSchemaElementTypeSchema,
45
+ uiSchemaSchema: () => uiSchema,
46
+ validateIR: () => validateIR,
47
+ verticalLayoutSchema: () => verticalLayoutSchema
48
+ });
49
+ module.exports = __toCommonJS(browser_exports);
50
+
51
+ // src/canonicalize/chain-dsl-canonicalizer.ts
52
+ var import_internals = require("@formspec/core/internals");
53
+
54
+ // src/metadata/policy.ts
55
+ var NOOP_INFLECT = () => "";
56
+ function normalizePluralization(input) {
57
+ if (input?.mode === "infer-if-missing") {
58
+ return {
59
+ mode: "infer-if-missing",
60
+ infer: () => "",
61
+ inflect: input.inflect
62
+ };
63
+ }
64
+ if (input?.mode === "require-explicit") {
65
+ return {
66
+ mode: "require-explicit",
67
+ infer: () => "",
68
+ inflect: NOOP_INFLECT
69
+ };
70
+ }
71
+ return {
72
+ mode: "disabled",
73
+ infer: () => "",
74
+ inflect: NOOP_INFLECT
75
+ };
76
+ }
77
+ function normalizeScalarPolicy(input) {
78
+ if (input?.mode === "infer-if-missing") {
79
+ return {
80
+ mode: "infer-if-missing",
81
+ infer: input.infer,
82
+ pluralization: normalizePluralization(input.pluralization)
83
+ };
84
+ }
85
+ if (input?.mode === "require-explicit") {
86
+ return {
87
+ mode: "require-explicit",
88
+ infer: () => "",
89
+ pluralization: normalizePluralization(input.pluralization)
90
+ };
91
+ }
92
+ return {
93
+ mode: "disabled",
94
+ infer: () => "",
95
+ pluralization: normalizePluralization(input?.pluralization)
96
+ };
97
+ }
98
+ function normalizeDeclarationPolicy(input) {
99
+ return {
100
+ apiName: normalizeScalarPolicy(input?.apiName),
101
+ displayName: normalizeScalarPolicy(input?.displayName)
102
+ };
103
+ }
104
+ function normalizeEnumMemberDisplayNamePolicy(input) {
105
+ if (input?.mode === "infer-if-missing") {
106
+ return {
107
+ mode: "infer-if-missing",
108
+ infer: input.infer
109
+ };
110
+ }
111
+ if (input?.mode === "require-explicit") {
112
+ return {
113
+ mode: "require-explicit",
114
+ infer: () => ""
115
+ };
116
+ }
117
+ return {
118
+ mode: "disabled",
119
+ infer: () => ""
120
+ };
121
+ }
122
+ function normalizeEnumMemberPolicy(input) {
123
+ return {
124
+ displayName: normalizeEnumMemberDisplayNamePolicy(input?.displayName)
125
+ };
126
+ }
127
+ function normalizeMetadataPolicy(input) {
128
+ return {
129
+ type: normalizeDeclarationPolicy(input?.type),
130
+ field: normalizeDeclarationPolicy(input?.field),
131
+ method: normalizeDeclarationPolicy(input?.method),
132
+ enumMember: normalizeEnumMemberPolicy(input?.enumMember)
133
+ };
134
+ }
135
+ function getDeclarationMetadataPolicy(policy, declarationKind) {
136
+ return policy[declarationKind];
137
+ }
138
+ function makeMetadataContext(surface, declarationKind, logicalName, buildContext) {
139
+ return {
140
+ surface,
141
+ declarationKind,
142
+ logicalName,
143
+ ...buildContext !== void 0 && { buildContext }
144
+ };
145
+ }
146
+
147
+ // src/metadata/resolve.ts
148
+ function toExplicitScalar(value) {
149
+ return value !== void 0 && value.trim() !== "" ? { value, source: "explicit" } : void 0;
150
+ }
151
+ function toExplicitResolvedMetadata(explicit) {
152
+ if (explicit === void 0) {
153
+ return void 0;
154
+ }
155
+ const apiName = toExplicitScalar(explicit.apiName);
156
+ const displayName = toExplicitScalar(explicit.displayName);
157
+ const apiNamePlural = toExplicitScalar(explicit.apiNamePlural);
158
+ const displayNamePlural = toExplicitScalar(explicit.displayNamePlural);
159
+ const metadata = {
160
+ ...apiName !== void 0 && { apiName },
161
+ ...displayName !== void 0 && { displayName },
162
+ ...apiNamePlural !== void 0 && { apiNamePlural },
163
+ ...displayNamePlural !== void 0 && { displayNamePlural }
164
+ };
165
+ return Object.keys(metadata).length > 0 ? metadata : void 0;
166
+ }
167
+ function resolveScalar(current, policy, context, metadataLabel) {
168
+ if (current !== void 0) {
169
+ return current;
170
+ }
171
+ if (policy.mode === "require-explicit") {
172
+ throw new Error(
173
+ `Metadata policy requires explicit ${metadataLabel} for ${context.declarationKind} "${context.logicalName}" on the ${context.surface} surface.`
174
+ );
175
+ }
176
+ if (policy.mode !== "infer-if-missing") {
177
+ return void 0;
178
+ }
179
+ const inferredValue = policy.infer(context);
180
+ return inferredValue.trim() !== "" ? { value: inferredValue, source: "inferred" } : void 0;
181
+ }
182
+ function resolvePlural(current, singular, policy, context, metadataLabel) {
183
+ if (current !== void 0) {
184
+ return current;
185
+ }
186
+ if (policy.mode === "require-explicit") {
187
+ throw new Error(
188
+ `Metadata policy requires explicit ${metadataLabel} for ${context.declarationKind} "${context.logicalName}" on the ${context.surface} surface.`
189
+ );
190
+ }
191
+ if (singular === void 0 || policy.mode !== "infer-if-missing") {
192
+ return void 0;
193
+ }
194
+ const pluralValue = policy.inflect({ ...context, singular: singular.value });
195
+ return pluralValue.trim() !== "" ? { value: pluralValue, source: "inferred" } : void 0;
196
+ }
197
+ function resolveResolvedMetadata(current, policy, context) {
198
+ const apiName = resolveScalar(current?.apiName, policy.apiName, context, "apiName");
199
+ const displayName = resolveScalar(
200
+ current?.displayName,
201
+ policy.displayName,
202
+ context,
203
+ "displayName"
204
+ );
205
+ const apiNamePlural = resolvePlural(
206
+ current?.apiNamePlural,
207
+ apiName,
208
+ policy.apiName.pluralization,
209
+ context,
210
+ "apiNamePlural"
211
+ );
212
+ const displayNamePlural = resolvePlural(
213
+ current?.displayNamePlural,
214
+ displayName,
215
+ policy.displayName.pluralization,
216
+ context,
217
+ "displayNamePlural"
218
+ );
219
+ if (apiName === void 0 && displayName === void 0 && apiNamePlural === void 0 && displayNamePlural === void 0) {
220
+ return void 0;
221
+ }
222
+ return {
223
+ ...apiName !== void 0 && { apiName },
224
+ ...displayName !== void 0 && { displayName },
225
+ ...apiNamePlural !== void 0 && { apiNamePlural },
226
+ ...displayNamePlural !== void 0 && { displayNamePlural }
227
+ };
228
+ }
229
+ function resolveEnumMemberDisplayName(current, policy, context) {
230
+ if (current !== void 0) {
231
+ return current;
232
+ }
233
+ if (policy.mode === "require-explicit") {
234
+ throw new Error(
235
+ `Metadata policy requires explicit displayName for enum member "${context.logicalName}" on the ${context.surface} surface.`
236
+ );
237
+ }
238
+ if (policy.mode !== "infer-if-missing") {
239
+ return void 0;
240
+ }
241
+ const inferredValue = policy.infer(context).trim();
242
+ return inferredValue !== "" ? inferredValue : void 0;
243
+ }
244
+ function resolveEnumTypeMetadata(type, options) {
245
+ const members = type.members.map((member) => {
246
+ const displayName = resolveEnumMemberDisplayName(
247
+ member.displayName,
248
+ options.policy.enumMember.displayName,
249
+ {
250
+ surface: options.surface,
251
+ logicalName: String(member.value),
252
+ memberValue: member.value,
253
+ ...options.buildContext !== void 0 && { buildContext: options.buildContext }
254
+ }
255
+ );
256
+ if (displayName === member.displayName) {
257
+ return member;
258
+ }
259
+ return displayName === void 0 ? { value: member.value } : { value: member.value, displayName };
260
+ });
261
+ return members.some((member, index) => member !== type.members[index]) ? { ...type, members } : type;
262
+ }
263
+ function resolveTypeNodeMetadata(type, options) {
264
+ switch (type.kind) {
265
+ case "array":
266
+ return {
267
+ ...type,
268
+ items: resolveTypeNodeMetadata(type.items, options)
269
+ };
270
+ case "object":
271
+ return {
272
+ ...type,
273
+ properties: type.properties.map(
274
+ (property) => resolveObjectPropertyMetadata(property, options)
275
+ )
276
+ };
277
+ case "record":
278
+ return {
279
+ ...type,
280
+ valueType: resolveTypeNodeMetadata(type.valueType, options)
281
+ };
282
+ case "union":
283
+ return {
284
+ ...type,
285
+ members: type.members.map((member) => resolveTypeNodeMetadata(member, options))
286
+ };
287
+ case "enum":
288
+ return resolveEnumTypeMetadata(type, options);
289
+ case "reference":
290
+ case "primitive":
291
+ case "dynamic":
292
+ case "custom":
293
+ return type;
294
+ default: {
295
+ const _exhaustive = type;
296
+ return _exhaustive;
297
+ }
298
+ }
299
+ }
300
+ function resolveObjectPropertyMetadata(property, options) {
301
+ const metadata = resolveResolvedMetadata(property.metadata, options.policy.field, {
302
+ surface: options.surface,
303
+ declarationKind: "field",
304
+ logicalName: property.name,
305
+ ...options.buildContext !== void 0 && { buildContext: options.buildContext }
306
+ });
307
+ return {
308
+ ...property,
309
+ ...metadata !== void 0 && { metadata },
310
+ type: resolveTypeNodeMetadata(property.type, options)
311
+ };
312
+ }
313
+ function resolveFieldMetadataNode(field, options) {
314
+ const metadata = resolveResolvedMetadata(field.metadata, options.policy.field, {
315
+ surface: options.surface,
316
+ declarationKind: "field",
317
+ logicalName: field.name,
318
+ ...options.buildContext !== void 0 && { buildContext: options.buildContext }
319
+ });
320
+ return {
321
+ ...field,
322
+ ...metadata !== void 0 && { metadata },
323
+ type: resolveTypeNodeMetadata(field.type, options)
324
+ };
325
+ }
326
+ function resolveFormElementMetadata(element, options) {
327
+ switch (element.kind) {
328
+ case "field":
329
+ return resolveFieldMetadataNode(element, options);
330
+ case "group":
331
+ return {
332
+ ...element,
333
+ elements: element.elements.map((child) => resolveFormElementMetadata(child, options))
334
+ };
335
+ case "conditional":
336
+ return {
337
+ ...element,
338
+ elements: element.elements.map((child) => resolveFormElementMetadata(child, options))
339
+ };
340
+ default: {
341
+ const _exhaustive = element;
342
+ return _exhaustive;
343
+ }
344
+ }
345
+ }
346
+ function resolveTypeDefinitionMetadata(typeDefinition, options) {
347
+ const metadata = resolveResolvedMetadata(typeDefinition.metadata, options.policy.type, {
348
+ surface: options.surface,
349
+ declarationKind: "type",
350
+ logicalName: typeDefinition.name,
351
+ ...options.buildContext !== void 0 && { buildContext: options.buildContext }
352
+ });
353
+ return {
354
+ ...typeDefinition,
355
+ ...metadata !== void 0 && { metadata },
356
+ type: resolveTypeNodeMetadata(typeDefinition.type, options)
357
+ };
358
+ }
359
+ function resolveMetadata(explicit, policy, context) {
360
+ return resolveResolvedMetadata(toExplicitResolvedMetadata(explicit), policy, context);
361
+ }
362
+ function getSerializedName(logicalName, metadata) {
363
+ return metadata?.apiName?.value ?? logicalName;
364
+ }
365
+ function getDisplayName(metadata) {
366
+ return metadata?.displayName?.value;
367
+ }
368
+ function resolveFormIRMetadata(ir, options) {
369
+ const metadata = options.resolveRootTypeMetadata === false ? ir.metadata : resolveResolvedMetadata(ir.metadata, options.policy.type, {
370
+ surface: options.surface,
371
+ declarationKind: "type",
372
+ logicalName: options.rootLogicalName ?? ir.name ?? "FormSpec",
373
+ ...options.buildContext !== void 0 && { buildContext: options.buildContext }
374
+ });
375
+ return {
376
+ ...ir,
377
+ ...metadata !== void 0 && { metadata },
378
+ elements: ir.elements.map((element) => resolveFormElementMetadata(element, options)),
379
+ typeRegistry: Object.fromEntries(
380
+ Object.entries(ir.typeRegistry).map(([name, definition]) => [
381
+ name,
382
+ resolveTypeDefinitionMetadata(definition, options)
383
+ ])
384
+ )
385
+ };
386
+ }
387
+
388
+ // src/canonicalize/chain-dsl-canonicalizer.ts
389
+ var CHAIN_DSL_PROVENANCE = {
390
+ surface: "chain-dsl",
391
+ file: "",
392
+ line: 0,
393
+ column: 0
394
+ };
395
+ function isGroup(el) {
396
+ return el._type === "group";
397
+ }
398
+ function isConditional(el) {
399
+ return el._type === "conditional";
400
+ }
401
+ function isField(el) {
402
+ return el._type === "field";
403
+ }
404
+ function canonicalizeChainDSL(form, options) {
405
+ const metadataPolicy = normalizeMetadataPolicy(
406
+ options?.metadata ?? (0, import_internals._getFormSpecMetadataPolicy)(form)
407
+ );
408
+ const ir = {
409
+ kind: "form-ir",
410
+ irVersion: import_internals.IR_VERSION,
411
+ elements: canonicalizeElements(form.elements, metadataPolicy),
412
+ rootAnnotations: [],
413
+ typeRegistry: {},
414
+ provenance: CHAIN_DSL_PROVENANCE
415
+ };
416
+ return resolveFormIRMetadata(ir, {
417
+ policy: metadataPolicy,
418
+ surface: "chain-dsl",
419
+ // Chain DSL has no root/type-metadata authoring surface, so only resolve
420
+ // field/type-registry metadata and enum-member labels here.
421
+ resolveRootTypeMetadata: false
422
+ });
423
+ }
424
+ function canonicalizeElements(elements, metadataPolicy) {
425
+ return elements.map((element) => canonicalizeElement(element, metadataPolicy));
426
+ }
427
+ function canonicalizeElement(element, metadataPolicy) {
428
+ if (isField(element)) {
429
+ return canonicalizeField(element, metadataPolicy);
430
+ }
431
+ if (isGroup(element)) {
432
+ return canonicalizeGroup(element, metadataPolicy);
433
+ }
434
+ if (isConditional(element)) {
435
+ return canonicalizeConditional(element, metadataPolicy);
436
+ }
437
+ const _exhaustive = element;
438
+ throw new Error(`Unknown element type: ${JSON.stringify(_exhaustive)}`);
439
+ }
440
+ function canonicalizeField(field, metadataPolicy) {
441
+ switch (field._field) {
442
+ case "text":
443
+ return canonicalizeTextField(field, metadataPolicy);
444
+ case "number":
445
+ return canonicalizeNumberField(field, metadataPolicy);
446
+ case "boolean":
447
+ return canonicalizeBooleanField(field, metadataPolicy);
448
+ case "enum":
449
+ return canonicalizeStaticEnumField(field, metadataPolicy);
450
+ case "dynamic_enum":
451
+ return canonicalizeDynamicEnumField(field, metadataPolicy);
452
+ case "dynamic_schema":
453
+ return canonicalizeDynamicSchemaField(field, metadataPolicy);
454
+ case "array":
455
+ return canonicalizeArrayField(field, metadataPolicy);
456
+ case "object":
457
+ return canonicalizeObjectField(field, metadataPolicy);
458
+ default: {
459
+ const _exhaustive = field;
460
+ throw new Error(`Unknown field type: ${JSON.stringify(_exhaustive)}`);
461
+ }
462
+ }
463
+ }
464
+ function canonicalizeTextField(field, metadataPolicy) {
465
+ const type = { kind: "primitive", primitiveKind: "string" };
466
+ const constraints = [];
467
+ if (field.minLength !== void 0) {
468
+ const c = {
469
+ kind: "constraint",
470
+ constraintKind: "minLength",
471
+ value: field.minLength,
472
+ provenance: CHAIN_DSL_PROVENANCE
473
+ };
474
+ constraints.push(c);
475
+ }
476
+ if (field.maxLength !== void 0) {
477
+ const c = {
478
+ kind: "constraint",
479
+ constraintKind: "maxLength",
480
+ value: field.maxLength,
481
+ provenance: CHAIN_DSL_PROVENANCE
482
+ };
483
+ constraints.push(c);
484
+ }
485
+ if (field.pattern !== void 0) {
486
+ const c = {
487
+ kind: "constraint",
488
+ constraintKind: "pattern",
489
+ pattern: field.pattern,
490
+ provenance: CHAIN_DSL_PROVENANCE
491
+ };
492
+ constraints.push(c);
493
+ }
494
+ return buildFieldNode(
495
+ field.name,
496
+ resolveFieldMetadata(field.name, field, metadataPolicy),
497
+ type,
498
+ field.required,
499
+ buildAnnotations(getExplicitDisplayName(field), field.placeholder),
500
+ constraints
501
+ );
502
+ }
503
+ function canonicalizeNumberField(field, metadataPolicy) {
504
+ const type = { kind: "primitive", primitiveKind: "number" };
505
+ const constraints = [];
506
+ if (field.min !== void 0) {
507
+ const c = {
508
+ kind: "constraint",
509
+ constraintKind: "minimum",
510
+ value: field.min,
511
+ provenance: CHAIN_DSL_PROVENANCE
512
+ };
513
+ constraints.push(c);
514
+ }
515
+ if (field.max !== void 0) {
516
+ const c = {
517
+ kind: "constraint",
518
+ constraintKind: "maximum",
519
+ value: field.max,
520
+ provenance: CHAIN_DSL_PROVENANCE
521
+ };
522
+ constraints.push(c);
523
+ }
524
+ if (field.multipleOf !== void 0) {
525
+ const c = {
526
+ kind: "constraint",
527
+ constraintKind: "multipleOf",
528
+ value: field.multipleOf,
529
+ provenance: CHAIN_DSL_PROVENANCE
530
+ };
531
+ constraints.push(c);
532
+ }
533
+ return buildFieldNode(
534
+ field.name,
535
+ resolveFieldMetadata(field.name, field, metadataPolicy),
536
+ type,
537
+ field.required,
538
+ buildAnnotations(getExplicitDisplayName(field)),
539
+ constraints
540
+ );
541
+ }
542
+ function canonicalizeBooleanField(field, metadataPolicy) {
543
+ const type = { kind: "primitive", primitiveKind: "boolean" };
544
+ return buildFieldNode(
545
+ field.name,
546
+ resolveFieldMetadata(field.name, field, metadataPolicy),
547
+ type,
548
+ field.required,
549
+ buildAnnotations(getExplicitDisplayName(field))
550
+ );
551
+ }
552
+ function canonicalizeStaticEnumField(field, metadataPolicy) {
553
+ const members = field.options.map((opt) => {
554
+ if (typeof opt === "string") {
555
+ return { value: opt };
556
+ }
557
+ return { value: opt.id, displayName: opt.label };
558
+ });
559
+ const type = { kind: "enum", members };
560
+ return buildFieldNode(
561
+ field.name,
562
+ resolveFieldMetadata(field.name, field, metadataPolicy),
563
+ type,
564
+ field.required,
565
+ buildAnnotations(getExplicitDisplayName(field))
566
+ );
567
+ }
568
+ function canonicalizeDynamicEnumField(field, metadataPolicy) {
569
+ const type = {
570
+ kind: "dynamic",
571
+ dynamicKind: "enum",
572
+ sourceKey: field.source,
573
+ parameterFields: field.params ? [...field.params] : []
574
+ };
575
+ return buildFieldNode(
576
+ field.name,
577
+ resolveFieldMetadata(field.name, field, metadataPolicy),
578
+ type,
579
+ field.required,
580
+ buildAnnotations(getExplicitDisplayName(field))
581
+ );
582
+ }
583
+ function canonicalizeDynamicSchemaField(field, metadataPolicy) {
584
+ const type = {
585
+ kind: "dynamic",
586
+ dynamicKind: "schema",
587
+ sourceKey: field.schemaSource,
588
+ parameterFields: []
589
+ };
590
+ return buildFieldNode(
591
+ field.name,
592
+ resolveFieldMetadata(field.name, field, metadataPolicy),
593
+ type,
594
+ field.required,
595
+ buildAnnotations(getExplicitDisplayName(field))
596
+ );
597
+ }
598
+ function canonicalizeArrayField(field, metadataPolicy) {
599
+ const itemProperties = buildObjectProperties(field.items, metadataPolicy);
600
+ const itemsType = {
601
+ kind: "object",
602
+ properties: itemProperties,
603
+ additionalProperties: true
604
+ };
605
+ const type = { kind: "array", items: itemsType };
606
+ const constraints = [];
607
+ if (field.minItems !== void 0) {
608
+ const c = {
609
+ kind: "constraint",
610
+ constraintKind: "minItems",
611
+ value: field.minItems,
612
+ provenance: CHAIN_DSL_PROVENANCE
613
+ };
614
+ constraints.push(c);
615
+ }
616
+ if (field.maxItems !== void 0) {
617
+ const c = {
618
+ kind: "constraint",
619
+ constraintKind: "maxItems",
620
+ value: field.maxItems,
621
+ provenance: CHAIN_DSL_PROVENANCE
622
+ };
623
+ constraints.push(c);
624
+ }
625
+ return buildFieldNode(
626
+ field.name,
627
+ resolveFieldMetadata(field.name, field, metadataPolicy),
628
+ type,
629
+ field.required,
630
+ buildAnnotations(getExplicitDisplayName(field)),
631
+ constraints
632
+ );
633
+ }
634
+ function canonicalizeObjectField(field, metadataPolicy) {
635
+ const properties = buildObjectProperties(field.properties, metadataPolicy);
636
+ const type = {
637
+ kind: "object",
638
+ properties,
639
+ additionalProperties: true
640
+ };
641
+ return buildFieldNode(
642
+ field.name,
643
+ resolveFieldMetadata(field.name, field, metadataPolicy),
644
+ type,
645
+ field.required,
646
+ buildAnnotations(getExplicitDisplayName(field))
647
+ );
648
+ }
649
+ function canonicalizeGroup(g, metadataPolicy) {
650
+ return {
651
+ kind: "group",
652
+ label: g.label,
653
+ elements: canonicalizeElements(g.elements, metadataPolicy),
654
+ provenance: CHAIN_DSL_PROVENANCE
655
+ };
656
+ }
657
+ function canonicalizeConditional(c, metadataPolicy) {
658
+ return {
659
+ kind: "conditional",
660
+ fieldName: c.field,
661
+ // Conditional values from the chain DSL are JSON-serializable primitives
662
+ // (strings, numbers, booleans) produced by the `is()` predicate helper.
663
+ value: assertJsonValue(c.value),
664
+ elements: canonicalizeElements(c.elements, metadataPolicy),
665
+ provenance: CHAIN_DSL_PROVENANCE
666
+ };
667
+ }
668
+ function assertJsonValue(v) {
669
+ if (v === null || typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
670
+ return v;
671
+ }
672
+ if (Array.isArray(v)) {
673
+ return v.map(assertJsonValue);
674
+ }
675
+ if (typeof v === "object") {
676
+ const result = {};
677
+ for (const [key, val] of Object.entries(v)) {
678
+ result[key] = assertJsonValue(val);
679
+ }
680
+ return result;
681
+ }
682
+ throw new TypeError(`Conditional value is not a valid JsonValue: ${typeof v}`);
683
+ }
684
+ function buildFieldNode(name, metadata, type, required, annotations, constraints = []) {
685
+ return {
686
+ kind: "field",
687
+ name,
688
+ ...metadata !== void 0 && { metadata },
689
+ type,
690
+ required: required === true,
691
+ constraints,
692
+ annotations,
693
+ provenance: CHAIN_DSL_PROVENANCE
694
+ };
695
+ }
696
+ function buildAnnotations(label, placeholder) {
697
+ const annotations = [];
698
+ if (label !== void 0) {
699
+ const a = {
700
+ kind: "annotation",
701
+ annotationKind: "displayName",
702
+ value: label,
703
+ provenance: CHAIN_DSL_PROVENANCE
704
+ };
705
+ annotations.push(a);
706
+ }
707
+ if (placeholder !== void 0) {
708
+ const a = {
709
+ kind: "annotation",
710
+ annotationKind: "placeholder",
711
+ value: placeholder,
712
+ provenance: CHAIN_DSL_PROVENANCE
713
+ };
714
+ annotations.push(a);
715
+ }
716
+ return annotations;
717
+ }
718
+ function buildObjectProperties(elements, metadataPolicy, insideConditional = false) {
719
+ const properties = [];
720
+ for (const el of elements) {
721
+ if (isField(el)) {
722
+ const fieldNode = canonicalizeField(el, metadataPolicy);
723
+ properties.push({
724
+ name: fieldNode.name,
725
+ ...fieldNode.metadata !== void 0 && { metadata: fieldNode.metadata },
726
+ type: fieldNode.type,
727
+ // Fields inside a conditional branch are always optional in the
728
+ // data schema, regardless of their `required` flag — the condition
729
+ // may not be met, so the field may be absent.
730
+ optional: insideConditional || !fieldNode.required,
731
+ constraints: fieldNode.constraints,
732
+ annotations: fieldNode.annotations,
733
+ provenance: CHAIN_DSL_PROVENANCE
734
+ });
735
+ } else if (isGroup(el)) {
736
+ properties.push(...buildObjectProperties(el.elements, metadataPolicy, insideConditional));
737
+ } else if (isConditional(el)) {
738
+ properties.push(...buildObjectProperties(el.elements, metadataPolicy, true));
739
+ }
740
+ }
741
+ return properties;
742
+ }
743
+ function getExplicitDisplayName(field) {
744
+ if (field.label !== void 0 && field.displayName !== void 0) {
745
+ throw new Error('Chain DSL fields cannot specify both "label" and "displayName".');
746
+ }
747
+ return field.displayName ?? field.label;
748
+ }
749
+ function resolveFieldMetadata(logicalName, field, metadataPolicy) {
750
+ const displayName = getExplicitDisplayName(field);
751
+ return resolveMetadata(
752
+ {
753
+ ...field.apiName !== void 0 && { apiName: field.apiName },
754
+ ...displayName !== void 0 && { displayName }
755
+ },
756
+ getDeclarationMetadataPolicy(metadataPolicy, "field"),
757
+ makeMetadataContext("chain-dsl", "field", logicalName)
758
+ );
759
+ }
760
+
761
+ // src/canonicalize/tsdoc-canonicalizer.ts
762
+ var import_internals2 = require("@formspec/core/internals");
763
+
764
+ // src/metadata/collision-guards.ts
765
+ function assertUniqueSerializedNames(entries, scope) {
766
+ const seen = /* @__PURE__ */ new Map();
767
+ for (const entry of entries) {
768
+ const previous = seen.get(entry.serializedName);
769
+ if (previous !== void 0) {
770
+ if (previous.logicalName === entry.logicalName && previous.category === entry.category) {
771
+ continue;
772
+ }
773
+ throw new Error(
774
+ `Serialized name collision in ${scope}: ${previous.category} "${previous.logicalName}" and ${entry.category} "${entry.logicalName}" both resolve to "${entry.serializedName}".`
775
+ );
776
+ }
777
+ seen.set(entry.serializedName, entry);
778
+ }
779
+ }
780
+ function collectFlattenedFields(elements) {
781
+ const fields = [];
782
+ for (const element of elements) {
783
+ switch (element.kind) {
784
+ case "field":
785
+ fields.push(element);
786
+ break;
787
+ case "group":
788
+ case "conditional":
789
+ fields.push(...collectFlattenedFields(element.elements));
790
+ break;
791
+ default: {
792
+ const exhaustive = element;
793
+ void exhaustive;
794
+ }
795
+ }
796
+ }
797
+ return fields;
798
+ }
799
+ function validateObjectProperties(properties, scope) {
800
+ assertUniqueSerializedNames(
801
+ properties.map((property) => ({
802
+ logicalName: property.name,
803
+ serializedName: getSerializedName(property.name, property.metadata),
804
+ category: "object property"
805
+ })),
806
+ scope
807
+ );
808
+ for (const property of properties) {
809
+ validateTypeNode(
810
+ property.type,
811
+ `${scope}.${getSerializedName(property.name, property.metadata)}`
812
+ );
813
+ }
814
+ }
815
+ function validateTypeNode(type, scope) {
816
+ switch (type.kind) {
817
+ case "array":
818
+ validateTypeNode(type.items, `${scope}[]`);
819
+ break;
820
+ case "object":
821
+ validateObjectProperties(type.properties, scope);
822
+ break;
823
+ case "record":
824
+ validateTypeNode(type.valueType, `${scope}.*`);
825
+ break;
826
+ case "union":
827
+ type.members.forEach((member, index) => {
828
+ validateTypeNode(member, `${scope}|${String(index)}`);
829
+ });
830
+ break;
831
+ case "reference":
832
+ case "primitive":
833
+ case "enum":
834
+ case "dynamic":
835
+ case "custom":
836
+ break;
837
+ default: {
838
+ const exhaustive = type;
839
+ void exhaustive;
840
+ }
841
+ }
842
+ }
843
+ function validateTypeDefinitions(typeRegistry) {
844
+ const definitions = Object.values(typeRegistry);
845
+ assertUniqueSerializedNames(
846
+ definitions.map((definition) => ({
847
+ logicalName: definition.name,
848
+ serializedName: getSerializedName(definition.name, definition.metadata),
849
+ category: "type definition"
850
+ })),
851
+ "$defs"
852
+ );
853
+ for (const definition of definitions) {
854
+ validateTypeDefinition(definition);
855
+ }
856
+ }
857
+ function validateTypeDefinition(definition) {
858
+ validateTypeNode(
859
+ definition.type,
860
+ `type "${getSerializedName(definition.name, definition.metadata)}"`
861
+ );
862
+ }
863
+ function assertNoSerializedNameCollisions(ir) {
864
+ assertUniqueSerializedNames(
865
+ collectFlattenedFields(ir.elements).map((field) => ({
866
+ logicalName: field.name,
867
+ serializedName: getSerializedName(field.name, field.metadata),
868
+ category: "field"
869
+ })),
870
+ "form root"
871
+ );
872
+ for (const field of collectFlattenedFields(ir.elements)) {
873
+ validateTypeNode(field.type, `field "${getSerializedName(field.name, field.metadata)}"`);
874
+ }
875
+ validateTypeDefinitions(ir.typeRegistry);
876
+ }
877
+
878
+ // src/json-schema/ir-generator.ts
879
+ function makeContext(options) {
880
+ const vendorPrefix = options?.vendorPrefix ?? "x-formspec";
881
+ const rawEnumSerialization = options?.enumSerialization;
882
+ if (!vendorPrefix.startsWith("x-")) {
883
+ throw new Error(
884
+ `Invalid vendorPrefix "${vendorPrefix}". Extension JSON Schema keywords must start with "x-".`
885
+ );
886
+ }
887
+ if (rawEnumSerialization !== void 0 && rawEnumSerialization !== "enum" && rawEnumSerialization !== "oneOf") {
888
+ throw new Error(
889
+ `Invalid enumSerialization "${rawEnumSerialization}". Expected "enum" or "oneOf".`
890
+ );
891
+ }
892
+ const enumSerialization = rawEnumSerialization ?? "enum";
893
+ return {
894
+ defs: {},
895
+ typeNameMap: {},
896
+ typeRegistry: {},
897
+ extensionRegistry: options?.extensionRegistry,
898
+ vendorPrefix,
899
+ enumSerialization
900
+ };
901
+ }
902
+ function generateJsonSchemaFromIR(ir, options) {
903
+ assertNoSerializedNameCollisions(ir);
904
+ const ctx = {
905
+ ...makeContext(options),
906
+ typeRegistry: ir.typeRegistry,
907
+ typeNameMap: Object.fromEntries(
908
+ Object.entries(ir.typeRegistry).map(([name, typeDef]) => [
909
+ name,
910
+ getSerializedName(name, typeDef.metadata)
911
+ ])
912
+ )
913
+ };
914
+ for (const [name, typeDef] of Object.entries(ir.typeRegistry)) {
915
+ const schemaName = ctx.typeNameMap[name] ?? name;
916
+ ctx.defs[schemaName] = generateTypeNode(typeDef.type, ctx);
917
+ applyResolvedMetadata(ctx.defs[schemaName], typeDef.metadata);
918
+ if (typeDef.constraints && typeDef.constraints.length > 0) {
919
+ applyConstraints(ctx.defs[schemaName], typeDef.constraints, ctx);
920
+ }
921
+ if (typeDef.annotations && typeDef.annotations.length > 0) {
922
+ applyAnnotations(ctx.defs[schemaName], typeDef.annotations, ctx);
923
+ }
924
+ }
925
+ const properties = {};
926
+ const required = [];
927
+ collectFields(ir.elements, properties, required, ctx);
928
+ const uniqueRequired = [...new Set(required)];
929
+ const result = {
930
+ $schema: "https://json-schema.org/draft/2020-12/schema",
931
+ type: "object",
932
+ properties,
933
+ ...uniqueRequired.length > 0 && { required: uniqueRequired }
934
+ };
935
+ applyResolvedMetadata(result, ir.metadata);
936
+ if (ir.annotations && ir.annotations.length > 0) {
937
+ applyAnnotations(result, ir.annotations, ctx);
938
+ }
939
+ if (Object.keys(ctx.defs).length > 0) {
940
+ result.$defs = ctx.defs;
941
+ }
942
+ return result;
943
+ }
944
+ function collectFields(elements, properties, required, ctx) {
945
+ for (const element of elements) {
946
+ switch (element.kind) {
947
+ case "field":
948
+ properties[getSerializedFieldName(element)] = generateFieldSchema(element, ctx);
949
+ if (element.required) {
950
+ required.push(getSerializedFieldName(element));
951
+ }
952
+ break;
953
+ case "group":
954
+ collectFields(element.elements, properties, required, ctx);
955
+ break;
956
+ case "conditional":
957
+ collectFields(element.elements, properties, required, ctx);
958
+ break;
959
+ default: {
960
+ const _exhaustive = element;
961
+ void _exhaustive;
962
+ }
963
+ }
964
+ }
965
+ }
966
+ function generateFieldSchema(field, ctx) {
967
+ const schema = generateTypeNode(field.type, ctx);
968
+ const itemStringSchema = schema.type === "array" && schema.items?.type === "string" ? schema.items : void 0;
969
+ const directConstraints = [];
970
+ const itemConstraints = [];
971
+ const pathConstraints = [];
972
+ for (const c of field.constraints) {
973
+ if (c.path) {
974
+ pathConstraints.push(c);
975
+ } else if (itemStringSchema !== void 0 && isStringItemConstraint(c)) {
976
+ itemConstraints.push(c);
977
+ } else {
978
+ directConstraints.push(c);
979
+ }
980
+ }
981
+ applyConstraints(schema, directConstraints, ctx);
982
+ if (itemStringSchema !== void 0) {
983
+ applyConstraints(itemStringSchema, itemConstraints, ctx);
984
+ }
985
+ const rootAnnotations = [];
986
+ const itemAnnotations = [];
987
+ for (const annotation of field.annotations) {
988
+ if (itemStringSchema !== void 0 && annotation.annotationKind === "format") {
989
+ itemAnnotations.push(annotation);
990
+ } else {
991
+ rootAnnotations.push(annotation);
992
+ }
993
+ }
994
+ applyResolvedMetadata(schema, field.metadata);
995
+ applyAnnotations(schema, rootAnnotations, ctx);
996
+ if (itemStringSchema !== void 0) {
997
+ applyAnnotations(itemStringSchema, itemAnnotations, ctx);
998
+ }
999
+ if (pathConstraints.length === 0) {
1000
+ return schema;
1001
+ }
1002
+ return applyPathTargetedConstraints(schema, pathConstraints, ctx, field.type);
1003
+ }
1004
+ function isStringItemConstraint(constraint) {
1005
+ switch (constraint.constraintKind) {
1006
+ case "minLength":
1007
+ case "maxLength":
1008
+ case "pattern":
1009
+ return true;
1010
+ default:
1011
+ return false;
1012
+ }
1013
+ }
1014
+ function applyPathTargetedConstraints(schema, pathConstraints, ctx, typeNode) {
1015
+ if (schema.type === "array" && schema.items) {
1016
+ const referencedType = typeNode?.kind === "reference" ? resolveReferencedType(typeNode, ctx) : void 0;
1017
+ const nestedType = typeNode?.kind === "array" ? typeNode.items : referencedType?.kind === "array" ? referencedType.items : void 0;
1018
+ schema.items = applyPathTargetedConstraints(schema.items, pathConstraints, ctx, nestedType);
1019
+ return schema;
1020
+ }
1021
+ const propertyOverrides = buildPropertyOverrides(pathConstraints, typeNode, ctx);
1022
+ const nullableValueBranch = getNullableUnionValueSchema(schema);
1023
+ if (nullableValueBranch !== void 0) {
1024
+ const updatedNullableValueBranch = applyPathTargetedConstraints(
1025
+ nullableValueBranch,
1026
+ pathConstraints,
1027
+ ctx,
1028
+ resolveTraversableTypeNode(typeNode, ctx)
1029
+ );
1030
+ if (schema.oneOf !== void 0) {
1031
+ schema.oneOf = schema.oneOf.map(
1032
+ (branch) => branch === nullableValueBranch ? updatedNullableValueBranch : branch
1033
+ );
1034
+ }
1035
+ return schema;
1036
+ }
1037
+ if (schema.$ref) {
1038
+ const { $ref, ...rest } = schema;
1039
+ const refPart = { $ref };
1040
+ const overridePart = {
1041
+ properties: propertyOverrides,
1042
+ ...rest
1043
+ };
1044
+ return { allOf: [refPart, overridePart] };
1045
+ }
1046
+ if (schema.type === "object" && schema.properties) {
1047
+ const missingOverrides = {};
1048
+ for (const [target, overrideSchema] of Object.entries(propertyOverrides)) {
1049
+ if (schema.properties[target]) {
1050
+ mergeSchemaOverride(schema.properties[target], overrideSchema);
1051
+ } else {
1052
+ missingOverrides[target] = overrideSchema;
1053
+ }
1054
+ }
1055
+ if (Object.keys(missingOverrides).length === 0) {
1056
+ return schema;
1057
+ }
1058
+ return {
1059
+ allOf: [schema, { properties: missingOverrides }]
1060
+ };
1061
+ }
1062
+ if (schema.allOf) {
1063
+ schema.allOf = [...schema.allOf, { properties: propertyOverrides }];
1064
+ return schema;
1065
+ }
1066
+ return schema;
1067
+ }
1068
+ function generateTypeNode(type, ctx) {
1069
+ switch (type.kind) {
1070
+ case "primitive":
1071
+ return generatePrimitiveType(type);
1072
+ case "enum":
1073
+ return generateEnumType(type, ctx);
1074
+ case "array":
1075
+ return generateArrayType(type, ctx);
1076
+ case "object":
1077
+ return generateObjectType(type, ctx);
1078
+ case "record":
1079
+ return generateRecordType(type, ctx);
1080
+ case "union":
1081
+ return generateUnionType(type, ctx);
1082
+ case "reference":
1083
+ return generateReferenceType(type, ctx);
1084
+ case "dynamic":
1085
+ return generateDynamicType(type);
1086
+ case "custom":
1087
+ return generateCustomType(type, ctx);
1088
+ default: {
1089
+ const _exhaustive = type;
1090
+ return _exhaustive;
1091
+ }
1092
+ }
1093
+ }
1094
+ function generatePrimitiveType(type) {
1095
+ return {
1096
+ type: type.primitiveKind === "integer" || type.primitiveKind === "bigint" ? "integer" : type.primitiveKind
1097
+ };
1098
+ }
1099
+ function generateEnumType(type, ctx) {
1100
+ if (ctx.enumSerialization === "oneOf") {
1101
+ return {
1102
+ oneOf: type.members.map((m) => ({
1103
+ const: m.value,
1104
+ title: m.displayName ?? String(m.value)
1105
+ }))
1106
+ };
1107
+ }
1108
+ const schema = { enum: type.members.map((m) => m.value) };
1109
+ const displayNames = buildEnumDisplayNameExtension(type);
1110
+ if (displayNames !== void 0) {
1111
+ schema[`${ctx.vendorPrefix}-display-names`] = displayNames;
1112
+ }
1113
+ return schema;
1114
+ }
1115
+ function buildEnumDisplayNameExtension(type) {
1116
+ if (!type.members.some((member) => member.displayName !== void 0)) {
1117
+ return void 0;
1118
+ }
1119
+ const displayNames = /* @__PURE__ */ Object.create(null);
1120
+ for (const member of type.members) {
1121
+ const key = String(member.value);
1122
+ if (Object.hasOwn(displayNames, key)) {
1123
+ throw new Error(
1124
+ `Enum display-name key "${key}" is ambiguous after stringification. Use oneOf serialization for mixed string/number enum values that collide.`
1125
+ );
1126
+ }
1127
+ displayNames[key] = member.displayName ?? key;
1128
+ }
1129
+ return displayNames;
1130
+ }
1131
+ function generateArrayType(type, ctx) {
1132
+ return {
1133
+ type: "array",
1134
+ items: generateTypeNode(type.items, ctx)
1135
+ };
1136
+ }
1137
+ function generateObjectType(type, ctx) {
1138
+ const properties = {};
1139
+ const required = [];
1140
+ for (const prop of type.properties) {
1141
+ const propertyName = getSerializedObjectPropertyName(prop);
1142
+ properties[propertyName] = generatePropertySchema(prop, ctx);
1143
+ if (!prop.optional) {
1144
+ required.push(propertyName);
1145
+ }
1146
+ }
1147
+ const schema = { type: "object", properties };
1148
+ if (required.length > 0) {
1149
+ schema.required = required;
1150
+ }
1151
+ if (!type.additionalProperties) {
1152
+ schema.additionalProperties = false;
1153
+ }
1154
+ return schema;
1155
+ }
1156
+ function generateRecordType(type, ctx) {
1157
+ return {
1158
+ type: "object",
1159
+ additionalProperties: generateTypeNode(type.valueType, ctx)
1160
+ };
1161
+ }
1162
+ function generatePropertySchema(prop, ctx) {
1163
+ const schema = generateTypeNode(prop.type, ctx);
1164
+ applyConstraints(schema, prop.constraints, ctx);
1165
+ applyResolvedMetadata(schema, prop.metadata);
1166
+ applyAnnotations(schema, prop.annotations, ctx);
1167
+ return schema;
1168
+ }
1169
+ function generateUnionType(type, ctx) {
1170
+ if (isBooleanUnion(type)) {
1171
+ return { type: "boolean" };
1172
+ }
1173
+ if (isNullableUnion(type)) {
1174
+ return {
1175
+ oneOf: type.members.map((m) => generateTypeNode(m, ctx))
1176
+ };
1177
+ }
1178
+ return {
1179
+ anyOf: type.members.map((m) => generateTypeNode(m, ctx))
1180
+ };
1181
+ }
1182
+ function isBooleanUnion(type) {
1183
+ if (type.members.length !== 2) return false;
1184
+ const kinds = type.members.map((m) => m.kind);
1185
+ return kinds.every((k) => k === "primitive") && type.members.every((m) => m.kind === "primitive" && m.primitiveKind === "boolean");
1186
+ }
1187
+ function isNullableUnion(type) {
1188
+ if (type.members.length !== 2) return false;
1189
+ const nullCount = type.members.filter(
1190
+ (m) => m.kind === "primitive" && m.primitiveKind === "null"
1191
+ ).length;
1192
+ return nullCount === 1;
1193
+ }
1194
+ function generateReferenceType(type, ctx) {
1195
+ return { $ref: `#/$defs/${getSerializedTypeName(type.name, ctx)}` };
1196
+ }
1197
+ function getSerializedFieldName(field) {
1198
+ return getSerializedName(field.name, field.metadata);
1199
+ }
1200
+ function getSerializedObjectPropertyName(property) {
1201
+ return getSerializedName(property.name, property.metadata);
1202
+ }
1203
+ function getSerializedTypeName(logicalName, ctx) {
1204
+ return ctx.typeNameMap[logicalName] ?? logicalName;
1205
+ }
1206
+ function applyResolvedMetadata(schema, metadata) {
1207
+ const displayName = getDisplayName(metadata);
1208
+ if (displayName !== void 0) {
1209
+ schema.title = displayName;
1210
+ }
1211
+ }
1212
+ function resolveReferencedType(type, ctx) {
1213
+ return ctx.typeRegistry[type.name]?.type;
1214
+ }
1215
+ function dereferenceTypeNode(typeNode, ctx) {
1216
+ if (typeNode?.kind !== "reference") {
1217
+ return typeNode;
1218
+ }
1219
+ return resolveReferencedType(typeNode, ctx);
1220
+ }
1221
+ function unwrapNullableTypeNode(typeNode) {
1222
+ if (typeNode?.kind !== "union" || !isNullableUnion(typeNode)) {
1223
+ return typeNode;
1224
+ }
1225
+ return typeNode.members.find(
1226
+ (member) => !(member.kind === "primitive" && member.primitiveKind === "null")
1227
+ );
1228
+ }
1229
+ function resolveTraversableTypeNode(typeNode, ctx) {
1230
+ const dereferenced = dereferenceTypeNode(typeNode, ctx);
1231
+ const unwrapped = unwrapNullableTypeNode(dereferenced);
1232
+ if (unwrapped !== dereferenced) {
1233
+ return resolveTraversableTypeNode(unwrapped, ctx);
1234
+ }
1235
+ return dereferenced;
1236
+ }
1237
+ function resolveSerializedPropertyName(logicalName, typeNode, ctx) {
1238
+ const effectiveType = resolveTraversableTypeNode(typeNode, ctx);
1239
+ if (effectiveType?.kind === "array") {
1240
+ return resolveSerializedPropertyName(logicalName, effectiveType.items, ctx);
1241
+ }
1242
+ if (effectiveType?.kind === "object") {
1243
+ const property = effectiveType.properties.find((candidate) => candidate.name === logicalName);
1244
+ return property === void 0 ? logicalName : getSerializedObjectPropertyName(property);
1245
+ }
1246
+ return logicalName;
1247
+ }
1248
+ function resolveTargetTypeNode(logicalName, typeNode, ctx) {
1249
+ const effectiveType = resolveTraversableTypeNode(typeNode, ctx);
1250
+ if (effectiveType?.kind === "array") {
1251
+ return resolveTargetTypeNode(logicalName, effectiveType.items, ctx);
1252
+ }
1253
+ if (effectiveType?.kind !== "object") {
1254
+ return void 0;
1255
+ }
1256
+ return effectiveType.properties.find((candidate) => candidate.name === logicalName)?.type;
1257
+ }
1258
+ function buildPropertyOverrides(pathConstraints, typeNode, ctx) {
1259
+ const byTarget = /* @__PURE__ */ new Map();
1260
+ for (const constraint of pathConstraints) {
1261
+ const target = constraint.path?.segments[0];
1262
+ if (!target) {
1263
+ continue;
1264
+ }
1265
+ const grouped = byTarget.get(target) ?? [];
1266
+ grouped.push(constraint);
1267
+ byTarget.set(target, grouped);
1268
+ }
1269
+ const overrides = {};
1270
+ for (const [target, constraints] of byTarget) {
1271
+ overrides[resolveSerializedPropertyName(target, typeNode, ctx)] = buildPathOverrideSchema(
1272
+ constraints.map(stripLeadingPathSegment),
1273
+ resolveTargetTypeNode(target, typeNode, ctx),
1274
+ ctx
1275
+ );
1276
+ }
1277
+ return overrides;
1278
+ }
1279
+ function buildPathOverrideSchema(constraints, typeNode, ctx) {
1280
+ const schema = {};
1281
+ const directConstraints = [];
1282
+ const nestedConstraints = [];
1283
+ for (const constraint of constraints) {
1284
+ if (constraint.path === void 0 || constraint.path.segments.length === 0) {
1285
+ directConstraints.push(constraint);
1286
+ } else {
1287
+ nestedConstraints.push(constraint);
1288
+ }
1289
+ }
1290
+ applyConstraints(schema, directConstraints, ctx);
1291
+ if (nestedConstraints.length === 0) {
1292
+ return schema;
1293
+ }
1294
+ const effectiveType = resolveTraversableTypeNode(typeNode, ctx);
1295
+ if (effectiveType?.kind === "array") {
1296
+ schema.items = buildPathOverrideSchema(nestedConstraints, effectiveType.items, ctx);
1297
+ return schema;
1298
+ }
1299
+ schema.properties = buildPropertyOverrides(nestedConstraints, effectiveType, ctx);
1300
+ return schema;
1301
+ }
1302
+ function mergeSchemaOverride(target, override) {
1303
+ const nullableValueBranch = getNullableUnionValueSchema(target);
1304
+ if (nullableValueBranch !== void 0) {
1305
+ mergeSchemaOverride(nullableValueBranch, override);
1306
+ return;
1307
+ }
1308
+ if (override.properties !== void 0) {
1309
+ const mergedProperties = target.properties ?? {};
1310
+ for (const [name, propertyOverride] of Object.entries(override.properties)) {
1311
+ const existing = mergedProperties[name];
1312
+ if (existing === void 0) {
1313
+ mergedProperties[name] = propertyOverride;
1314
+ } else {
1315
+ mergeSchemaOverride(existing, propertyOverride);
1316
+ }
1317
+ }
1318
+ target.properties = mergedProperties;
1319
+ }
1320
+ if (override.items !== void 0) {
1321
+ if (target.items === void 0) {
1322
+ target.items = override.items;
1323
+ } else {
1324
+ mergeSchemaOverride(target.items, override.items);
1325
+ }
1326
+ }
1327
+ for (const [key, value] of Object.entries(override)) {
1328
+ if (key === "properties" || key === "items") {
1329
+ continue;
1330
+ }
1331
+ target[key] = value;
1332
+ }
1333
+ }
1334
+ function stripLeadingPathSegment(constraint) {
1335
+ const segments = constraint.path?.segments;
1336
+ if (segments === void 0 || segments.length === 0) {
1337
+ return constraint;
1338
+ }
1339
+ const [, ...rest] = segments;
1340
+ if (rest.length === 0) {
1341
+ const { path: _path, ...stripped } = constraint;
1342
+ return stripped;
1343
+ }
1344
+ return {
1345
+ ...constraint,
1346
+ path: { segments: rest }
1347
+ };
1348
+ }
1349
+ function getNullableUnionValueSchema(schema) {
1350
+ if (schema.oneOf?.length !== 2) {
1351
+ return void 0;
1352
+ }
1353
+ const valueSchema = schema.oneOf.find((branch) => branch.type !== "null");
1354
+ const nullSchema = schema.oneOf.find((branch) => branch.type === "null");
1355
+ return valueSchema !== void 0 && nullSchema !== void 0 ? valueSchema : void 0;
1356
+ }
1357
+ function generateDynamicType(type) {
1358
+ if (type.dynamicKind === "enum") {
1359
+ const schema = {
1360
+ type: "string",
1361
+ "x-formspec-source": type.sourceKey
1362
+ };
1363
+ if (type.parameterFields.length > 0) {
1364
+ schema["x-formspec-params"] = [...type.parameterFields];
1365
+ }
1366
+ return schema;
1367
+ }
1368
+ return {
1369
+ type: "object",
1370
+ additionalProperties: true,
1371
+ "x-formspec-schemaSource": type.sourceKey
1372
+ };
1373
+ }
1374
+ function applyConstraints(schema, constraints, ctx) {
1375
+ for (const constraint of constraints) {
1376
+ switch (constraint.constraintKind) {
1377
+ case "minimum":
1378
+ schema.minimum = constraint.value;
1379
+ break;
1380
+ case "maximum":
1381
+ schema.maximum = constraint.value;
1382
+ break;
1383
+ case "exclusiveMinimum":
1384
+ schema.exclusiveMinimum = constraint.value;
1385
+ break;
1386
+ case "exclusiveMaximum":
1387
+ schema.exclusiveMaximum = constraint.value;
1388
+ break;
1389
+ case "multipleOf": {
1390
+ const { value } = constraint;
1391
+ if (value === 1 && schema.type === "number") {
1392
+ schema.type = "integer";
1393
+ } else {
1394
+ schema.multipleOf = value;
1395
+ }
1396
+ break;
1397
+ }
1398
+ case "minLength":
1399
+ schema.minLength = constraint.value;
1400
+ break;
1401
+ case "maxLength":
1402
+ schema.maxLength = constraint.value;
1403
+ break;
1404
+ case "minItems":
1405
+ schema.minItems = constraint.value;
1406
+ break;
1407
+ case "maxItems":
1408
+ schema.maxItems = constraint.value;
1409
+ break;
1410
+ case "pattern":
1411
+ schema.pattern = constraint.pattern;
1412
+ break;
1413
+ case "uniqueItems":
1414
+ schema.uniqueItems = constraint.value;
1415
+ break;
1416
+ case "const":
1417
+ schema.const = constraint.value;
1418
+ break;
1419
+ case "allowedMembers":
1420
+ break;
1421
+ case "custom":
1422
+ applyCustomConstraint(schema, constraint, ctx);
1423
+ break;
1424
+ default: {
1425
+ const _exhaustive = constraint;
1426
+ void _exhaustive;
1427
+ }
1428
+ }
1429
+ }
1430
+ }
1431
+ function applyAnnotations(schema, annotations, ctx) {
1432
+ for (const annotation of annotations) {
1433
+ switch (annotation.annotationKind) {
1434
+ case "displayName":
1435
+ schema.title ??= annotation.value;
1436
+ break;
1437
+ case "description":
1438
+ schema.description = annotation.value;
1439
+ break;
1440
+ case "remarks":
1441
+ schema[`${ctx.vendorPrefix}-remarks`] = annotation.value;
1442
+ break;
1443
+ case "defaultValue":
1444
+ schema.default = annotation.value;
1445
+ break;
1446
+ case "format":
1447
+ schema.format = annotation.value;
1448
+ break;
1449
+ case "deprecated":
1450
+ schema.deprecated = true;
1451
+ if (annotation.message !== void 0 && annotation.message !== "") {
1452
+ schema[`${ctx.vendorPrefix}-deprecation-description`] = annotation.message;
1453
+ }
1454
+ break;
1455
+ case "placeholder":
1456
+ break;
1457
+ case "formatHint":
1458
+ break;
1459
+ case "custom":
1460
+ applyCustomAnnotation(schema, annotation, ctx);
1461
+ break;
1462
+ default: {
1463
+ const _exhaustive = annotation;
1464
+ void _exhaustive;
1465
+ }
1466
+ }
1467
+ }
1468
+ }
1469
+ function generateCustomType(type, ctx) {
1470
+ const registration = ctx.extensionRegistry?.findType(type.typeId);
1471
+ if (registration === void 0) {
1472
+ throw new Error(
1473
+ `Cannot generate JSON Schema for custom type "${type.typeId}" without a matching extension registration`
1474
+ );
1475
+ }
1476
+ return registration.toJsonSchema(type.payload, ctx.vendorPrefix);
1477
+ }
1478
+ var VOCABULARY_MODE_BLOCKED_KEYWORDS = /* @__PURE__ */ new Set([
1479
+ "$schema",
1480
+ "$ref",
1481
+ "$defs",
1482
+ "$id",
1483
+ "$anchor",
1484
+ "$dynamicRef",
1485
+ "$dynamicAnchor",
1486
+ "$vocabulary",
1487
+ "$comment",
1488
+ "type",
1489
+ "enum",
1490
+ "const",
1491
+ "properties",
1492
+ "patternProperties",
1493
+ "additionalProperties",
1494
+ "required",
1495
+ "items",
1496
+ "prefixItems",
1497
+ "additionalItems",
1498
+ "contains",
1499
+ "allOf",
1500
+ "oneOf",
1501
+ "anyOf",
1502
+ "not",
1503
+ "if",
1504
+ "then",
1505
+ "else",
1506
+ "minimum",
1507
+ "maximum",
1508
+ "exclusiveMinimum",
1509
+ "exclusiveMaximum",
1510
+ "multipleOf",
1511
+ "minLength",
1512
+ "maxLength",
1513
+ "pattern",
1514
+ "minItems",
1515
+ "maxItems",
1516
+ "uniqueItems",
1517
+ "minProperties",
1518
+ "maxProperties",
1519
+ "minContains",
1520
+ "maxContains",
1521
+ "format",
1522
+ "title",
1523
+ "description",
1524
+ "default",
1525
+ "deprecated",
1526
+ "readOnly",
1527
+ "writeOnly",
1528
+ "examples",
1529
+ "dependentRequired",
1530
+ "dependentSchemas",
1531
+ "propertyNames",
1532
+ "unevaluatedItems",
1533
+ "unevaluatedProperties",
1534
+ "contentEncoding",
1535
+ "contentMediaType",
1536
+ "contentSchema"
1537
+ ]);
1538
+ function applyCustomConstraint(schema, constraint, ctx) {
1539
+ const registration = ctx.extensionRegistry?.findConstraint(constraint.constraintId);
1540
+ if (registration === void 0) {
1541
+ throw new Error(
1542
+ `Cannot generate JSON Schema for custom constraint "${constraint.constraintId}" without a matching extension registration`
1543
+ );
1544
+ }
1545
+ const extensionSchema = registration.toJsonSchema(constraint.payload, ctx.vendorPrefix);
1546
+ if (registration.emitsVocabularyKeywords) {
1547
+ const target = schema;
1548
+ for (const [key, value] of Object.entries(extensionSchema)) {
1549
+ if (VOCABULARY_MODE_BLOCKED_KEYWORDS.has(key)) {
1550
+ throw new Error(
1551
+ `Custom constraint "${constraint.constraintId}" with emitsVocabularyKeywords must not overwrite standard JSON Schema keyword "${key}"`
1552
+ );
1553
+ }
1554
+ target[key] = value;
1555
+ }
1556
+ } else {
1557
+ assignVendorPrefixedExtensionKeywords(
1558
+ schema,
1559
+ extensionSchema,
1560
+ ctx.vendorPrefix,
1561
+ `custom constraint "${constraint.constraintId}"`
1562
+ );
1563
+ }
1564
+ }
1565
+ function applyCustomAnnotation(schema, annotation, ctx) {
1566
+ const registration = ctx.extensionRegistry?.findAnnotation(annotation.annotationId);
1567
+ if (registration === void 0) {
1568
+ throw new Error(
1569
+ `Cannot generate JSON Schema for custom annotation "${annotation.annotationId}" without a matching extension registration`
1570
+ );
1571
+ }
1572
+ if (registration.toJsonSchema === void 0) {
1573
+ return;
1574
+ }
1575
+ assignVendorPrefixedExtensionKeywords(
1576
+ schema,
1577
+ registration.toJsonSchema(annotation.value, ctx.vendorPrefix),
1578
+ ctx.vendorPrefix,
1579
+ `custom annotation "${annotation.annotationId}"`
1580
+ );
1581
+ }
1582
+ function assignVendorPrefixedExtensionKeywords(schema, extensionSchema, vendorPrefix, source) {
1583
+ for (const [key, value] of Object.entries(extensionSchema)) {
1584
+ if (!key.startsWith(`${vendorPrefix}-`)) {
1585
+ throw new Error(
1586
+ `Cannot apply ${source}: extension hooks may only emit "${vendorPrefix}-*" JSON Schema keywords`
1587
+ );
1588
+ }
1589
+ schema[key] = value;
1590
+ }
1591
+ }
1592
+
1593
+ // src/json-schema/generator.ts
1594
+ function generateJsonSchema(form, options) {
1595
+ const metadata = options?.metadata;
1596
+ const vendorPrefix = options?.vendorPrefix;
1597
+ const enumSerialization = options?.enumSerialization;
1598
+ const ir = canonicalizeChainDSL(form, metadata !== void 0 ? { metadata } : void 0);
1599
+ const internalOptions = vendorPrefix === void 0 && enumSerialization === void 0 ? void 0 : {
1600
+ ...vendorPrefix !== void 0 && { vendorPrefix },
1601
+ ...enumSerialization !== void 0 && { enumSerialization }
1602
+ };
1603
+ return generateJsonSchemaFromIR(ir, internalOptions);
1604
+ }
1605
+
1606
+ // src/ui-schema/schema.ts
1607
+ var import_zod = require("zod");
1608
+ var jsonPointerSchema = import_zod.z.string();
1609
+ var ruleEffectSchema = import_zod.z.enum(["SHOW", "HIDE", "ENABLE", "DISABLE"]);
1610
+ var uiSchemaElementTypeSchema = import_zod.z.enum([
1611
+ "Control",
1612
+ "VerticalLayout",
1613
+ "HorizontalLayout",
1614
+ "Group",
1615
+ "Categorization",
1616
+ "Category",
1617
+ "Label"
1618
+ ]);
1619
+ var ruleConditionSchema = import_zod.z.lazy(
1620
+ () => import_zod.z.object({
1621
+ const: import_zod.z.unknown().optional(),
1622
+ enum: import_zod.z.array(import_zod.z.unknown()).readonly().optional(),
1623
+ type: import_zod.z.string().optional(),
1624
+ not: ruleConditionSchema.optional(),
1625
+ minimum: import_zod.z.number().optional(),
1626
+ maximum: import_zod.z.number().optional(),
1627
+ exclusiveMinimum: import_zod.z.number().optional(),
1628
+ exclusiveMaximum: import_zod.z.number().optional(),
1629
+ minLength: import_zod.z.number().optional(),
1630
+ properties: import_zod.z.record(import_zod.z.string(), ruleConditionSchema).optional(),
1631
+ required: import_zod.z.array(import_zod.z.string()).optional(),
1632
+ allOf: import_zod.z.array(ruleConditionSchema).optional()
1633
+ }).strict()
1634
+ );
1635
+ var schemaBasedConditionSchema = import_zod.z.object({
1636
+ scope: jsonPointerSchema,
1637
+ schema: ruleConditionSchema
1638
+ }).strict();
1639
+ var ruleSchema = import_zod.z.object({
1640
+ effect: ruleEffectSchema,
1641
+ condition: schemaBasedConditionSchema
1642
+ }).strict();
1643
+ var uiSchemaElementSchema = import_zod.z.lazy(
1644
+ () => import_zod.z.union([
1645
+ controlSchema,
1646
+ verticalLayoutSchema,
1647
+ horizontalLayoutSchema,
1648
+ groupLayoutSchema,
1649
+ categorizationSchema,
1650
+ categorySchema,
1651
+ labelElementSchema
1652
+ ])
1653
+ );
1654
+ var controlSchema = import_zod.z.object({
1655
+ type: import_zod.z.literal("Control"),
1656
+ scope: jsonPointerSchema,
1657
+ label: import_zod.z.union([import_zod.z.string(), import_zod.z.literal(false)]).optional(),
1658
+ rule: ruleSchema.optional(),
1659
+ options: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
1660
+ }).passthrough();
1661
+ var verticalLayoutSchema = import_zod.z.lazy(
1662
+ () => import_zod.z.object({
1663
+ type: import_zod.z.literal("VerticalLayout"),
1664
+ elements: import_zod.z.array(uiSchemaElementSchema),
1665
+ rule: ruleSchema.optional(),
1666
+ options: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
1667
+ }).passthrough()
1668
+ );
1669
+ var horizontalLayoutSchema = import_zod.z.lazy(
1670
+ () => import_zod.z.object({
1671
+ type: import_zod.z.literal("HorizontalLayout"),
1672
+ elements: import_zod.z.array(uiSchemaElementSchema),
1673
+ rule: ruleSchema.optional(),
1674
+ options: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
1675
+ }).passthrough()
1676
+ );
1677
+ var groupLayoutSchema = import_zod.z.lazy(
1678
+ () => import_zod.z.object({
1679
+ type: import_zod.z.literal("Group"),
1680
+ label: import_zod.z.string(),
1681
+ elements: import_zod.z.array(uiSchemaElementSchema),
1682
+ rule: ruleSchema.optional(),
1683
+ options: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
1684
+ }).passthrough()
1685
+ );
1686
+ var categorySchema = import_zod.z.lazy(
1687
+ () => import_zod.z.object({
1688
+ type: import_zod.z.literal("Category"),
1689
+ label: import_zod.z.string(),
1690
+ elements: import_zod.z.array(uiSchemaElementSchema),
1691
+ rule: ruleSchema.optional(),
1692
+ options: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
1693
+ }).passthrough()
1694
+ );
1695
+ var categorizationSchema = import_zod.z.lazy(
1696
+ () => import_zod.z.object({
1697
+ type: import_zod.z.literal("Categorization"),
1698
+ elements: import_zod.z.array(categorySchema),
1699
+ label: import_zod.z.string().optional(),
1700
+ rule: ruleSchema.optional(),
1701
+ options: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
1702
+ }).passthrough()
1703
+ );
1704
+ var labelElementSchema = import_zod.z.object({
1705
+ type: import_zod.z.literal("Label"),
1706
+ text: import_zod.z.string(),
1707
+ rule: ruleSchema.optional(),
1708
+ options: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
1709
+ }).passthrough();
1710
+ var uiSchema = import_zod.z.lazy(
1711
+ () => import_zod.z.union([verticalLayoutSchema, horizontalLayoutSchema, groupLayoutSchema, categorizationSchema])
1712
+ );
1713
+
1714
+ // src/ui-schema/ir-generator.ts
1715
+ var import_zod2 = require("zod");
1716
+ function parseOrThrow(schema, value, label) {
1717
+ try {
1718
+ return schema.parse(value);
1719
+ } catch (error) {
1720
+ if (error instanceof import_zod2.z.ZodError) {
1721
+ throw new Error(
1722
+ `Generated ${label} failed validation:
1723
+ ${error.issues.map((i) => ` ${i.path.join(".")}: ${i.message}`).join("\n")}`
1724
+ );
1725
+ }
1726
+ throw error;
1727
+ }
1728
+ }
1729
+ function fieldToScope(fieldName) {
1730
+ return `#/properties/${fieldName}`;
1731
+ }
1732
+ function createShowRule(fieldName, value) {
1733
+ return {
1734
+ effect: "SHOW",
1735
+ condition: {
1736
+ scope: fieldToScope(fieldName),
1737
+ schema: { const: value }
1738
+ }
1739
+ };
1740
+ }
1741
+ function flattenConditionSchema(scope, schema) {
1742
+ if (schema.allOf === void 0) {
1743
+ if (scope === "#") {
1744
+ return [schema];
1745
+ }
1746
+ const fieldName = scope.replace("#/properties/", "");
1747
+ return [
1748
+ {
1749
+ properties: {
1750
+ [fieldName]: schema
1751
+ }
1752
+ }
1753
+ ];
1754
+ }
1755
+ return schema.allOf.flatMap((member) => flattenConditionSchema(scope, member));
1756
+ }
1757
+ function combineRules(parentRule, childRule) {
1758
+ return {
1759
+ effect: "SHOW",
1760
+ condition: {
1761
+ scope: "#",
1762
+ schema: {
1763
+ allOf: [
1764
+ ...flattenConditionSchema(parentRule.condition.scope, parentRule.condition.schema),
1765
+ ...flattenConditionSchema(childRule.condition.scope, childRule.condition.schema)
1766
+ ]
1767
+ }
1768
+ }
1769
+ };
1770
+ }
1771
+ function getFieldDisplayName(field) {
1772
+ const resolvedDisplayName = getDisplayName(field.metadata);
1773
+ if (resolvedDisplayName !== void 0) {
1774
+ return resolvedDisplayName;
1775
+ }
1776
+ return field.annotations.find((annotation) => annotation.annotationKind === "displayName")?.value;
1777
+ }
1778
+ function fieldNodeToControl(field, fieldNameMap, parentRule) {
1779
+ const placeholderAnnotation = field.annotations.find((a) => a.annotationKind === "placeholder");
1780
+ const serializedName = fieldNameMap.get(field.name) ?? getSerializedName(field.name, field.metadata);
1781
+ const displayName = getFieldDisplayName(field);
1782
+ const control = {
1783
+ type: "Control",
1784
+ scope: fieldToScope(serializedName),
1785
+ ...displayName !== void 0 && { label: displayName },
1786
+ ...placeholderAnnotation !== void 0 && {
1787
+ options: { placeholder: placeholderAnnotation.value }
1788
+ },
1789
+ ...parentRule !== void 0 && { rule: parentRule }
1790
+ };
1791
+ return control;
1792
+ }
1793
+ function groupNodeToLayout(group, fieldNameMap, parentRule) {
1794
+ return {
1795
+ type: "Group",
1796
+ label: group.label,
1797
+ elements: irElementsToUiSchema(group.elements, fieldNameMap, parentRule),
1798
+ ...parentRule !== void 0 && { rule: parentRule }
1799
+ };
1800
+ }
1801
+ function irElementsToUiSchema(elements, fieldNameMap, parentRule) {
1802
+ const result = [];
1803
+ for (const element of elements) {
1804
+ switch (element.kind) {
1805
+ case "field": {
1806
+ result.push(fieldNodeToControl(element, fieldNameMap, parentRule));
1807
+ break;
1808
+ }
1809
+ case "group": {
1810
+ result.push(groupNodeToLayout(element, fieldNameMap, parentRule));
1811
+ break;
1812
+ }
1813
+ case "conditional": {
1814
+ const newRule = createShowRule(
1815
+ fieldNameMap.get(element.fieldName) ?? element.fieldName,
1816
+ element.value
1817
+ );
1818
+ const combinedRule = parentRule !== void 0 ? combineRules(parentRule, newRule) : newRule;
1819
+ const childElements = irElementsToUiSchema(element.elements, fieldNameMap, combinedRule);
1820
+ result.push(...childElements);
1821
+ break;
1822
+ }
1823
+ default: {
1824
+ const _exhaustive = element;
1825
+ void _exhaustive;
1826
+ throw new Error("Unhandled IR element kind");
1827
+ }
1828
+ }
1829
+ }
1830
+ return result;
1831
+ }
1832
+ function generateUiSchemaFromIR(ir) {
1833
+ assertNoSerializedNameCollisions(ir);
1834
+ const fieldNameMap = collectFieldNameMap(ir.elements);
1835
+ const result = {
1836
+ type: "VerticalLayout",
1837
+ elements: irElementsToUiSchema(ir.elements, fieldNameMap)
1838
+ };
1839
+ return parseOrThrow(uiSchema, result, "UI Schema");
1840
+ }
1841
+ function collectFieldNameMap(elements) {
1842
+ const map = /* @__PURE__ */ new Map();
1843
+ for (const element of elements) {
1844
+ switch (element.kind) {
1845
+ case "field":
1846
+ map.set(element.name, getSerializedName(element.name, element.metadata));
1847
+ break;
1848
+ case "group":
1849
+ case "conditional":
1850
+ for (const [key, value] of collectFieldNameMap(element.elements)) {
1851
+ map.set(key, value);
1852
+ }
1853
+ break;
1854
+ default: {
1855
+ const _exhaustive = element;
1856
+ void _exhaustive;
1857
+ }
1858
+ }
1859
+ }
1860
+ return map;
1861
+ }
1862
+
1863
+ // src/ui-schema/generator.ts
1864
+ function generateUiSchema(form, options) {
1865
+ const ir = canonicalizeChainDSL(
1866
+ form,
1867
+ options?.metadata !== void 0 ? { metadata: options.metadata } : void 0
1868
+ );
1869
+ return generateUiSchemaFromIR(ir);
1870
+ }
1871
+
1872
+ // src/json-schema/types.ts
1873
+ function setSchemaExtension(schema, key, value) {
1874
+ schema[key] = value;
1875
+ }
1876
+ function getSchemaExtension(schema, key) {
1877
+ return schema[key];
1878
+ }
1879
+
1880
+ // src/extensions/registry.ts
1881
+ var import_internals3 = require("@formspec/core/internals");
1882
+ var import_internal = require("@formspec/analysis/internal");
1883
+ var BUILTIN_METADATA_TAGS = /* @__PURE__ */ new Set(["apiName", "displayName"]);
1884
+ function buildConstraintTagSources(extensions) {
1885
+ return extensions.map((extension) => ({
1886
+ extensionId: extension.extensionId,
1887
+ ...extension.constraintTags !== void 0 ? {
1888
+ constraintTags: extension.constraintTags.map((tag) => ({
1889
+ tagName: (0, import_internal.normalizeFormSpecTagName)(tag.tagName)
1890
+ }))
1891
+ } : {}
1892
+ }));
1893
+ }
1894
+ function createExtensionRegistry(extensions) {
1895
+ const reservedTagSources = buildConstraintTagSources(extensions);
1896
+ let symbolMap = /* @__PURE__ */ new Map();
1897
+ const typeMap = /* @__PURE__ */ new Map();
1898
+ const typeNameMap = /* @__PURE__ */ new Map();
1899
+ const brandMap = /* @__PURE__ */ new Map();
1900
+ const constraintMap = /* @__PURE__ */ new Map();
1901
+ const constraintTagMap = /* @__PURE__ */ new Map();
1902
+ const builtinBroadeningMap = /* @__PURE__ */ new Map();
1903
+ const annotationMap = /* @__PURE__ */ new Map();
1904
+ const metadataSlotMap = /* @__PURE__ */ new Map();
1905
+ const metadataTagMap = /* @__PURE__ */ new Map();
1906
+ for (const ext of extensions) {
1907
+ if (ext.types !== void 0) {
1908
+ for (const type of ext.types) {
1909
+ const qualifiedId = `${ext.extensionId}/${type.typeName}`;
1910
+ if (typeMap.has(qualifiedId)) {
1911
+ throw new Error(`Duplicate custom type ID: "${qualifiedId}"`);
1912
+ }
1913
+ typeMap.set(qualifiedId, type);
1914
+ for (const sourceTypeName of type.tsTypeNames ?? [type.typeName]) {
1915
+ if (typeNameMap.has(sourceTypeName)) {
1916
+ throw new Error(`Duplicate custom type source name: "${sourceTypeName}"`);
1917
+ }
1918
+ typeNameMap.set(sourceTypeName, {
1919
+ extensionId: ext.extensionId,
1920
+ registration: type
1921
+ });
1922
+ }
1923
+ if (type.brand !== void 0) {
1924
+ if (type.brand === "__integerBrand") {
1925
+ throw new Error(
1926
+ `Brand "__integerBrand" is reserved for the builtin Integer type and cannot be registered by extensions`
1927
+ );
1928
+ }
1929
+ if (brandMap.has(type.brand)) {
1930
+ throw new Error(`Duplicate custom type brand: "${type.brand}"`);
1931
+ }
1932
+ brandMap.set(type.brand, {
1933
+ extensionId: ext.extensionId,
1934
+ registration: type
1935
+ });
1936
+ }
1937
+ if (type.builtinConstraintBroadenings !== void 0) {
1938
+ for (const broadening of type.builtinConstraintBroadenings) {
1939
+ const key = `${qualifiedId}:${broadening.tagName}`;
1940
+ if (builtinBroadeningMap.has(key)) {
1941
+ throw new Error(`Duplicate built-in constraint broadening: "${key}"`);
1942
+ }
1943
+ builtinBroadeningMap.set(key, {
1944
+ extensionId: ext.extensionId,
1945
+ registration: broadening
1946
+ });
1947
+ }
1948
+ }
1949
+ }
1950
+ }
1951
+ if (ext.constraints !== void 0) {
1952
+ for (const constraint of ext.constraints) {
1953
+ const qualifiedId = `${ext.extensionId}/${constraint.constraintName}`;
1954
+ if (constraintMap.has(qualifiedId)) {
1955
+ throw new Error(`Duplicate custom constraint ID: "${qualifiedId}"`);
1956
+ }
1957
+ constraintMap.set(qualifiedId, constraint);
1958
+ }
1959
+ }
1960
+ if (ext.constraintTags !== void 0) {
1961
+ for (const tag of ext.constraintTags) {
1962
+ const canonicalTagName = (0, import_internal.normalizeFormSpecTagName)(tag.tagName);
1963
+ if (constraintTagMap.has(canonicalTagName)) {
1964
+ throw new Error(`Duplicate custom constraint tag: "@${canonicalTagName}"`);
1965
+ }
1966
+ constraintTagMap.set(canonicalTagName, {
1967
+ extensionId: ext.extensionId,
1968
+ registration: tag
1969
+ });
1970
+ }
1971
+ }
1972
+ if (ext.annotations !== void 0) {
1973
+ for (const annotation of ext.annotations) {
1974
+ const qualifiedId = `${ext.extensionId}/${annotation.annotationName}`;
1975
+ if (annotationMap.has(qualifiedId)) {
1976
+ throw new Error(`Duplicate custom annotation ID: "${qualifiedId}"`);
1977
+ }
1978
+ annotationMap.set(qualifiedId, annotation);
1979
+ }
1980
+ }
1981
+ if (ext.metadataSlots !== void 0) {
1982
+ for (const slot of ext.metadataSlots) {
1983
+ if (metadataSlotMap.has(slot.slotId)) {
1984
+ throw new Error(`Duplicate metadata slot ID: "${slot.slotId}"`);
1985
+ }
1986
+ metadataSlotMap.set(slot.slotId, true);
1987
+ const canonicalTagName = (0, import_internal.normalizeFormSpecTagName)(slot.tagName);
1988
+ if (slot.allowBare === false && (slot.qualifiers?.length ?? 0) === 0) {
1989
+ throw new Error(
1990
+ `Metadata tag "@${canonicalTagName}" must allow bare usage or declare at least one qualifier.`
1991
+ );
1992
+ }
1993
+ if (metadataTagMap.has(canonicalTagName)) {
1994
+ throw new Error(`Duplicate metadata tag: "@${canonicalTagName}"`);
1995
+ }
1996
+ if (BUILTIN_METADATA_TAGS.has(canonicalTagName)) {
1997
+ throw new Error(
1998
+ `Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
1999
+ );
2000
+ }
2001
+ if (constraintTagMap.has(canonicalTagName)) {
2002
+ throw new Error(
2003
+ `Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${canonicalTagName}".`
2004
+ );
2005
+ }
2006
+ if (Object.hasOwn(
2007
+ import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS,
2008
+ (0, import_internals3.normalizeConstraintTagName)(canonicalTagName)
2009
+ )) {
2010
+ throw new Error(
2011
+ `Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${(0, import_internals3.normalizeConstraintTagName)(canonicalTagName)}".`
2012
+ );
2013
+ }
2014
+ const existingTag = (0, import_internal.getTagDefinition)(canonicalTagName, reservedTagSources);
2015
+ if (existingTag !== null) {
2016
+ throw BUILTIN_METADATA_TAGS.has(existingTag.canonicalName) ? new Error(
2017
+ `Metadata tag "@${canonicalTagName}" conflicts with built-in metadata tags.`
2018
+ ) : new Error(
2019
+ `Metadata tag "@${canonicalTagName}" conflicts with existing FormSpec tag "@${existingTag.canonicalName}".`
2020
+ );
2021
+ }
2022
+ metadataTagMap.set(canonicalTagName, true);
2023
+ }
2024
+ }
2025
+ }
2026
+ return {
2027
+ extensions,
2028
+ findType: (typeId) => typeMap.get(typeId),
2029
+ findTypeByName: (typeName) => typeNameMap.get(typeName),
2030
+ findTypeByBrand: (brand) => brandMap.get(brand),
2031
+ findTypeBySymbol: (symbol) => symbolMap.get(symbol),
2032
+ setSymbolMap: (map) => {
2033
+ symbolMap = map;
2034
+ },
2035
+ findConstraint: (constraintId) => constraintMap.get(constraintId),
2036
+ findConstraintTag: (tagName) => constraintTagMap.get((0, import_internal.normalizeFormSpecTagName)(tagName)),
2037
+ findBuiltinConstraintBroadening: (typeId, tagName) => builtinBroadeningMap.get(`${typeId}:${tagName}`),
2038
+ findAnnotation: (annotationId) => annotationMap.get(annotationId)
2039
+ };
2040
+ }
2041
+
2042
+ // src/json-schema/schema.ts
2043
+ var import_zod3 = require("zod");
2044
+ var jsonSchemaTypeSchema = import_zod3.z.enum([
2045
+ "string",
2046
+ "number",
2047
+ "integer",
2048
+ "boolean",
2049
+ "object",
2050
+ "array",
2051
+ "null"
2052
+ ]);
2053
+ var jsonSchema7Schema = import_zod3.z.lazy(
2054
+ () => import_zod3.z.object({
2055
+ $schema: import_zod3.z.string().optional(),
2056
+ $id: import_zod3.z.string().optional(),
2057
+ $ref: import_zod3.z.string().optional(),
2058
+ // Metadata
2059
+ title: import_zod3.z.string().optional(),
2060
+ description: import_zod3.z.string().optional(),
2061
+ deprecated: import_zod3.z.boolean().optional(),
2062
+ // Type
2063
+ type: import_zod3.z.union([jsonSchemaTypeSchema, import_zod3.z.array(jsonSchemaTypeSchema)]).optional(),
2064
+ // String validation
2065
+ minLength: import_zod3.z.number().optional(),
2066
+ maxLength: import_zod3.z.number().optional(),
2067
+ pattern: import_zod3.z.string().optional(),
2068
+ // Number validation
2069
+ minimum: import_zod3.z.number().optional(),
2070
+ maximum: import_zod3.z.number().optional(),
2071
+ exclusiveMinimum: import_zod3.z.number().optional(),
2072
+ exclusiveMaximum: import_zod3.z.number().optional(),
2073
+ // Enum
2074
+ enum: import_zod3.z.array(import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number(), import_zod3.z.boolean(), import_zod3.z.null()])).readonly().optional(),
2075
+ const: import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number(), import_zod3.z.boolean(), import_zod3.z.null()]).optional(),
2076
+ // Object
2077
+ properties: import_zod3.z.record(import_zod3.z.string(), jsonSchema7Schema).optional(),
2078
+ required: import_zod3.z.array(import_zod3.z.string()).optional(),
2079
+ additionalProperties: import_zod3.z.union([import_zod3.z.boolean(), jsonSchema7Schema]).optional(),
2080
+ // Array
2081
+ items: import_zod3.z.union([jsonSchema7Schema, import_zod3.z.array(jsonSchema7Schema)]).optional(),
2082
+ minItems: import_zod3.z.number().optional(),
2083
+ maxItems: import_zod3.z.number().optional(),
2084
+ // Composition
2085
+ allOf: import_zod3.z.array(jsonSchema7Schema).optional(),
2086
+ anyOf: import_zod3.z.array(jsonSchema7Schema).optional(),
2087
+ oneOf: import_zod3.z.array(jsonSchema7Schema).optional(),
2088
+ not: jsonSchema7Schema.optional(),
2089
+ // Conditional
2090
+ if: jsonSchema7Schema.optional(),
2091
+ then: jsonSchema7Schema.optional(),
2092
+ else: jsonSchema7Schema.optional(),
2093
+ // Format
2094
+ format: import_zod3.z.string().optional(),
2095
+ // Default
2096
+ default: import_zod3.z.unknown().optional(),
2097
+ // FormSpec extensions
2098
+ "x-formspec-source": import_zod3.z.string().optional(),
2099
+ "x-formspec-params": import_zod3.z.array(import_zod3.z.string()).readonly().optional(),
2100
+ "x-formspec-schemaSource": import_zod3.z.string().optional()
2101
+ }).passthrough()
2102
+ );
2103
+
2104
+ // src/validate/constraint-validator.ts
2105
+ var import_internal2 = require("@formspec/analysis/internal");
2106
+ function validateFieldNode(ctx, field) {
2107
+ const analysis = (0, import_internal2.analyzeConstraintTargets)(
2108
+ field.name,
2109
+ field.type,
2110
+ field.constraints,
2111
+ ctx.typeRegistry,
2112
+ ctx.extensionRegistry === void 0 ? void 0 : {
2113
+ extensionRegistry: ctx.extensionRegistry
2114
+ }
2115
+ );
2116
+ ctx.diagnostics.push(...analysis.diagnostics);
2117
+ if (field.type.kind === "object") {
2118
+ for (const property of field.type.properties) {
2119
+ validateObjectProperty(ctx, field.name, property);
2120
+ }
2121
+ }
2122
+ }
2123
+ function validateObjectProperty(ctx, parentName, property) {
2124
+ const qualifiedName = `${parentName}.${property.name}`;
2125
+ const analysis = (0, import_internal2.analyzeConstraintTargets)(
2126
+ qualifiedName,
2127
+ property.type,
2128
+ property.constraints,
2129
+ ctx.typeRegistry,
2130
+ ctx.extensionRegistry === void 0 ? void 0 : {
2131
+ extensionRegistry: ctx.extensionRegistry
2132
+ }
2133
+ );
2134
+ ctx.diagnostics.push(...analysis.diagnostics);
2135
+ if (property.type.kind === "object") {
2136
+ for (const nestedProperty of property.type.properties) {
2137
+ validateObjectProperty(ctx, qualifiedName, nestedProperty);
2138
+ }
2139
+ }
2140
+ }
2141
+ function validateElement(ctx, element) {
2142
+ switch (element.kind) {
2143
+ case "field":
2144
+ validateFieldNode(ctx, element);
2145
+ break;
2146
+ case "group":
2147
+ for (const child of element.elements) {
2148
+ validateElement(ctx, child);
2149
+ }
2150
+ break;
2151
+ case "conditional":
2152
+ for (const child of element.elements) {
2153
+ validateElement(ctx, child);
2154
+ }
2155
+ break;
2156
+ default: {
2157
+ const exhaustive = element;
2158
+ throw new Error(`Unhandled element kind: ${String(exhaustive)}`);
2159
+ }
2160
+ }
2161
+ }
2162
+ function validateIR(ir, options) {
2163
+ const ctx = {
2164
+ diagnostics: [],
2165
+ extensionRegistry: options?.extensionRegistry,
2166
+ typeRegistry: ir.typeRegistry
2167
+ };
2168
+ for (const element of ir.elements) {
2169
+ validateElement(ctx, element);
2170
+ }
2171
+ return {
2172
+ diagnostics: ctx.diagnostics,
2173
+ valid: ctx.diagnostics.every((diagnostic) => diagnostic.severity !== "error")
2174
+ };
2175
+ }
2176
+
2177
+ // src/browser.ts
2178
+ function buildFormSchemas(form, options) {
2179
+ return {
2180
+ jsonSchema: generateJsonSchema(form, options),
2181
+ uiSchema: generateUiSchema(form, options)
2182
+ };
2183
+ }
2184
+ // Annotate the CommonJS export names for ESM import in node:
2185
+ 0 && (module.exports = {
2186
+ buildFormSchemas,
2187
+ canonicalizeChainDSL,
2188
+ categorizationSchema,
2189
+ categorySchema,
2190
+ controlSchema,
2191
+ createExtensionRegistry,
2192
+ generateJsonSchema,
2193
+ generateJsonSchemaFromIR,
2194
+ generateUiSchema,
2195
+ getSchemaExtension,
2196
+ groupLayoutSchema,
2197
+ horizontalLayoutSchema,
2198
+ jsonSchema7Schema,
2199
+ jsonSchemaTypeSchema,
2200
+ labelElementSchema,
2201
+ ruleConditionSchema,
2202
+ ruleEffectSchema,
2203
+ ruleSchema,
2204
+ schemaBasedConditionSchema,
2205
+ setSchemaExtension,
2206
+ uiSchemaElementSchema,
2207
+ uiSchemaElementTypeSchema,
2208
+ uiSchemaSchema,
2209
+ validateIR,
2210
+ verticalLayoutSchema
2211
+ });
2212
+ //# sourceMappingURL=browser.cjs.map