formspec 0.1.0-alpha.40 → 0.1.0-alpha.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formspec-alpha.d.ts +83 -0
- package/dist/formspec-beta.d.ts +83 -0
- package/dist/formspec-internal.d.ts +83 -0
- package/dist/formspec.d.ts +83 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/formspec-alpha.d.ts
CHANGED
|
@@ -368,6 +368,82 @@ export declare interface DynamicSchemaField<N extends string> {
|
|
|
368
368
|
readonly params?: readonly string[];
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Enum-member display names remain unset unless authored explicitly.
|
|
373
|
+
*
|
|
374
|
+
* @public
|
|
375
|
+
*/
|
|
376
|
+
export declare interface EnumMemberDisplayNameDisabledPolicyInput {
|
|
377
|
+
/** Leaves missing enum-member display names unresolved. */
|
|
378
|
+
readonly mode: "disabled";
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Missing enum-member display names may be inferred.
|
|
383
|
+
*
|
|
384
|
+
* @public
|
|
385
|
+
*/
|
|
386
|
+
export declare interface EnumMemberDisplayNameInferIfMissingPolicyInput {
|
|
387
|
+
/** Infers an enum-member display name when it is not authored explicitly. */
|
|
388
|
+
readonly mode: "infer-if-missing";
|
|
389
|
+
/** Callback used to infer the missing display name. */
|
|
390
|
+
readonly infer: EnumMemberMetadataInferenceFn;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Enum-member display-name policy input.
|
|
395
|
+
*
|
|
396
|
+
* @public
|
|
397
|
+
*/
|
|
398
|
+
export declare type EnumMemberDisplayNamePolicyInput = EnumMemberDisplayNameDisabledPolicyInput | EnumMemberDisplayNameRequireExplicitPolicyInput | EnumMemberDisplayNameInferIfMissingPolicyInput;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Enum members must declare display names explicitly.
|
|
402
|
+
*
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
export declare interface EnumMemberDisplayNameRequireExplicitPolicyInput {
|
|
406
|
+
/** Fails when an enum member has no authored display name. */
|
|
407
|
+
readonly mode: "require-explicit";
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Build-facing context passed to enum-member metadata inference callbacks.
|
|
412
|
+
*
|
|
413
|
+
* Enum members are resolved separately from declaration-level metadata so they
|
|
414
|
+
* do not participate in the shared declaration-kind model used by TSDoc and
|
|
415
|
+
* extension metadata slots.
|
|
416
|
+
*
|
|
417
|
+
* @public
|
|
418
|
+
*/
|
|
419
|
+
export declare interface EnumMemberMetadataInferenceContext {
|
|
420
|
+
/** Authoring surface the enum originated from. */
|
|
421
|
+
readonly surface: MetadataAuthoringSurface;
|
|
422
|
+
/** Logical member identifier used for policy inference. */
|
|
423
|
+
readonly logicalName: string;
|
|
424
|
+
/** Underlying enum value before stringification. */
|
|
425
|
+
readonly memberValue: string | number;
|
|
426
|
+
/** Optional build-only context supplied by the resolver. */
|
|
427
|
+
readonly buildContext?: unknown;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Callback used to infer enum-member display names.
|
|
432
|
+
*
|
|
433
|
+
* @public
|
|
434
|
+
*/
|
|
435
|
+
export declare type EnumMemberMetadataInferenceFn = (context: EnumMemberMetadataInferenceContext) => string;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* User-facing enum-member metadata policy input.
|
|
439
|
+
*
|
|
440
|
+
* @public
|
|
441
|
+
*/
|
|
442
|
+
export declare interface EnumMemberMetadataPolicyInput {
|
|
443
|
+
/** Policy for human-facing enum-member labels. */
|
|
444
|
+
readonly displayName?: EnumMemberDisplayNamePolicyInput | undefined;
|
|
445
|
+
}
|
|
446
|
+
|
|
371
447
|
/**
|
|
372
448
|
* An enum option with a separate ID and display label.
|
|
373
449
|
*
|
|
@@ -640,6 +716,11 @@ export declare interface GenerateJsonSchemaOptions {
|
|
|
640
716
|
* @defaultValue "x-formspec"
|
|
641
717
|
*/
|
|
642
718
|
readonly vendorPrefix?: string | undefined;
|
|
719
|
+
/**
|
|
720
|
+
* JSON Schema representation to use for static enums.
|
|
721
|
+
* @defaultValue "enum"
|
|
722
|
+
*/
|
|
723
|
+
readonly enumSerialization?: "enum" | "oneOf";
|
|
643
724
|
/** Metadata resolution policy for chain DSL generation. */
|
|
644
725
|
readonly metadata?: MetadataPolicyInput | undefined;
|
|
645
726
|
}
|
|
@@ -1036,6 +1117,8 @@ export declare interface MetadataPolicyInput {
|
|
|
1036
1117
|
readonly field?: DeclarationMetadataPolicyInput | undefined;
|
|
1037
1118
|
/** Policy applied to callable/method declarations. */
|
|
1038
1119
|
readonly method?: DeclarationMetadataPolicyInput | undefined;
|
|
1120
|
+
/** Policy applied to enum-member display names during build-time IR resolution. */
|
|
1121
|
+
readonly enumMember?: EnumMemberMetadataPolicyInput | undefined;
|
|
1039
1122
|
}
|
|
1040
1123
|
|
|
1041
1124
|
/**
|
package/dist/formspec-beta.d.ts
CHANGED
|
@@ -368,6 +368,82 @@ export declare interface DynamicSchemaField<N extends string> {
|
|
|
368
368
|
readonly params?: readonly string[];
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Enum-member display names remain unset unless authored explicitly.
|
|
373
|
+
*
|
|
374
|
+
* @public
|
|
375
|
+
*/
|
|
376
|
+
export declare interface EnumMemberDisplayNameDisabledPolicyInput {
|
|
377
|
+
/** Leaves missing enum-member display names unresolved. */
|
|
378
|
+
readonly mode: "disabled";
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Missing enum-member display names may be inferred.
|
|
383
|
+
*
|
|
384
|
+
* @public
|
|
385
|
+
*/
|
|
386
|
+
export declare interface EnumMemberDisplayNameInferIfMissingPolicyInput {
|
|
387
|
+
/** Infers an enum-member display name when it is not authored explicitly. */
|
|
388
|
+
readonly mode: "infer-if-missing";
|
|
389
|
+
/** Callback used to infer the missing display name. */
|
|
390
|
+
readonly infer: EnumMemberMetadataInferenceFn;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Enum-member display-name policy input.
|
|
395
|
+
*
|
|
396
|
+
* @public
|
|
397
|
+
*/
|
|
398
|
+
export declare type EnumMemberDisplayNamePolicyInput = EnumMemberDisplayNameDisabledPolicyInput | EnumMemberDisplayNameRequireExplicitPolicyInput | EnumMemberDisplayNameInferIfMissingPolicyInput;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Enum members must declare display names explicitly.
|
|
402
|
+
*
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
export declare interface EnumMemberDisplayNameRequireExplicitPolicyInput {
|
|
406
|
+
/** Fails when an enum member has no authored display name. */
|
|
407
|
+
readonly mode: "require-explicit";
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Build-facing context passed to enum-member metadata inference callbacks.
|
|
412
|
+
*
|
|
413
|
+
* Enum members are resolved separately from declaration-level metadata so they
|
|
414
|
+
* do not participate in the shared declaration-kind model used by TSDoc and
|
|
415
|
+
* extension metadata slots.
|
|
416
|
+
*
|
|
417
|
+
* @public
|
|
418
|
+
*/
|
|
419
|
+
export declare interface EnumMemberMetadataInferenceContext {
|
|
420
|
+
/** Authoring surface the enum originated from. */
|
|
421
|
+
readonly surface: MetadataAuthoringSurface;
|
|
422
|
+
/** Logical member identifier used for policy inference. */
|
|
423
|
+
readonly logicalName: string;
|
|
424
|
+
/** Underlying enum value before stringification. */
|
|
425
|
+
readonly memberValue: string | number;
|
|
426
|
+
/** Optional build-only context supplied by the resolver. */
|
|
427
|
+
readonly buildContext?: unknown;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Callback used to infer enum-member display names.
|
|
432
|
+
*
|
|
433
|
+
* @public
|
|
434
|
+
*/
|
|
435
|
+
export declare type EnumMemberMetadataInferenceFn = (context: EnumMemberMetadataInferenceContext) => string;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* User-facing enum-member metadata policy input.
|
|
439
|
+
*
|
|
440
|
+
* @public
|
|
441
|
+
*/
|
|
442
|
+
export declare interface EnumMemberMetadataPolicyInput {
|
|
443
|
+
/** Policy for human-facing enum-member labels. */
|
|
444
|
+
readonly displayName?: EnumMemberDisplayNamePolicyInput | undefined;
|
|
445
|
+
}
|
|
446
|
+
|
|
371
447
|
/**
|
|
372
448
|
* An enum option with a separate ID and display label.
|
|
373
449
|
*
|
|
@@ -640,6 +716,11 @@ export declare interface GenerateJsonSchemaOptions {
|
|
|
640
716
|
* @defaultValue "x-formspec"
|
|
641
717
|
*/
|
|
642
718
|
readonly vendorPrefix?: string | undefined;
|
|
719
|
+
/**
|
|
720
|
+
* JSON Schema representation to use for static enums.
|
|
721
|
+
* @defaultValue "enum"
|
|
722
|
+
*/
|
|
723
|
+
readonly enumSerialization?: "enum" | "oneOf";
|
|
643
724
|
/** Metadata resolution policy for chain DSL generation. */
|
|
644
725
|
readonly metadata?: MetadataPolicyInput | undefined;
|
|
645
726
|
}
|
|
@@ -1036,6 +1117,8 @@ export declare interface MetadataPolicyInput {
|
|
|
1036
1117
|
readonly field?: DeclarationMetadataPolicyInput | undefined;
|
|
1037
1118
|
/** Policy applied to callable/method declarations. */
|
|
1038
1119
|
readonly method?: DeclarationMetadataPolicyInput | undefined;
|
|
1120
|
+
/** Policy applied to enum-member display names during build-time IR resolution. */
|
|
1121
|
+
readonly enumMember?: EnumMemberMetadataPolicyInput | undefined;
|
|
1039
1122
|
}
|
|
1040
1123
|
|
|
1041
1124
|
/**
|
|
@@ -368,6 +368,82 @@ export declare interface DynamicSchemaField<N extends string> {
|
|
|
368
368
|
readonly params?: readonly string[];
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Enum-member display names remain unset unless authored explicitly.
|
|
373
|
+
*
|
|
374
|
+
* @public
|
|
375
|
+
*/
|
|
376
|
+
export declare interface EnumMemberDisplayNameDisabledPolicyInput {
|
|
377
|
+
/** Leaves missing enum-member display names unresolved. */
|
|
378
|
+
readonly mode: "disabled";
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Missing enum-member display names may be inferred.
|
|
383
|
+
*
|
|
384
|
+
* @public
|
|
385
|
+
*/
|
|
386
|
+
export declare interface EnumMemberDisplayNameInferIfMissingPolicyInput {
|
|
387
|
+
/** Infers an enum-member display name when it is not authored explicitly. */
|
|
388
|
+
readonly mode: "infer-if-missing";
|
|
389
|
+
/** Callback used to infer the missing display name. */
|
|
390
|
+
readonly infer: EnumMemberMetadataInferenceFn;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Enum-member display-name policy input.
|
|
395
|
+
*
|
|
396
|
+
* @public
|
|
397
|
+
*/
|
|
398
|
+
export declare type EnumMemberDisplayNamePolicyInput = EnumMemberDisplayNameDisabledPolicyInput | EnumMemberDisplayNameRequireExplicitPolicyInput | EnumMemberDisplayNameInferIfMissingPolicyInput;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Enum members must declare display names explicitly.
|
|
402
|
+
*
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
export declare interface EnumMemberDisplayNameRequireExplicitPolicyInput {
|
|
406
|
+
/** Fails when an enum member has no authored display name. */
|
|
407
|
+
readonly mode: "require-explicit";
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Build-facing context passed to enum-member metadata inference callbacks.
|
|
412
|
+
*
|
|
413
|
+
* Enum members are resolved separately from declaration-level metadata so they
|
|
414
|
+
* do not participate in the shared declaration-kind model used by TSDoc and
|
|
415
|
+
* extension metadata slots.
|
|
416
|
+
*
|
|
417
|
+
* @public
|
|
418
|
+
*/
|
|
419
|
+
export declare interface EnumMemberMetadataInferenceContext {
|
|
420
|
+
/** Authoring surface the enum originated from. */
|
|
421
|
+
readonly surface: MetadataAuthoringSurface;
|
|
422
|
+
/** Logical member identifier used for policy inference. */
|
|
423
|
+
readonly logicalName: string;
|
|
424
|
+
/** Underlying enum value before stringification. */
|
|
425
|
+
readonly memberValue: string | number;
|
|
426
|
+
/** Optional build-only context supplied by the resolver. */
|
|
427
|
+
readonly buildContext?: unknown;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Callback used to infer enum-member display names.
|
|
432
|
+
*
|
|
433
|
+
* @public
|
|
434
|
+
*/
|
|
435
|
+
export declare type EnumMemberMetadataInferenceFn = (context: EnumMemberMetadataInferenceContext) => string;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* User-facing enum-member metadata policy input.
|
|
439
|
+
*
|
|
440
|
+
* @public
|
|
441
|
+
*/
|
|
442
|
+
export declare interface EnumMemberMetadataPolicyInput {
|
|
443
|
+
/** Policy for human-facing enum-member labels. */
|
|
444
|
+
readonly displayName?: EnumMemberDisplayNamePolicyInput | undefined;
|
|
445
|
+
}
|
|
446
|
+
|
|
371
447
|
/**
|
|
372
448
|
* An enum option with a separate ID and display label.
|
|
373
449
|
*
|
|
@@ -640,6 +716,11 @@ export declare interface GenerateJsonSchemaOptions {
|
|
|
640
716
|
* @defaultValue "x-formspec"
|
|
641
717
|
*/
|
|
642
718
|
readonly vendorPrefix?: string | undefined;
|
|
719
|
+
/**
|
|
720
|
+
* JSON Schema representation to use for static enums.
|
|
721
|
+
* @defaultValue "enum"
|
|
722
|
+
*/
|
|
723
|
+
readonly enumSerialization?: "enum" | "oneOf";
|
|
643
724
|
/** Metadata resolution policy for chain DSL generation. */
|
|
644
725
|
readonly metadata?: MetadataPolicyInput | undefined;
|
|
645
726
|
}
|
|
@@ -1036,6 +1117,8 @@ export declare interface MetadataPolicyInput {
|
|
|
1036
1117
|
readonly field?: DeclarationMetadataPolicyInput | undefined;
|
|
1037
1118
|
/** Policy applied to callable/method declarations. */
|
|
1038
1119
|
readonly method?: DeclarationMetadataPolicyInput | undefined;
|
|
1120
|
+
/** Policy applied to enum-member display names during build-time IR resolution. */
|
|
1121
|
+
readonly enumMember?: EnumMemberMetadataPolicyInput | undefined;
|
|
1039
1122
|
}
|
|
1040
1123
|
|
|
1041
1124
|
/**
|
package/dist/formspec.d.ts
CHANGED
|
@@ -368,6 +368,82 @@ export declare interface DynamicSchemaField<N extends string> {
|
|
|
368
368
|
readonly params?: readonly string[];
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Enum-member display names remain unset unless authored explicitly.
|
|
373
|
+
*
|
|
374
|
+
* @public
|
|
375
|
+
*/
|
|
376
|
+
export declare interface EnumMemberDisplayNameDisabledPolicyInput {
|
|
377
|
+
/** Leaves missing enum-member display names unresolved. */
|
|
378
|
+
readonly mode: "disabled";
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Missing enum-member display names may be inferred.
|
|
383
|
+
*
|
|
384
|
+
* @public
|
|
385
|
+
*/
|
|
386
|
+
export declare interface EnumMemberDisplayNameInferIfMissingPolicyInput {
|
|
387
|
+
/** Infers an enum-member display name when it is not authored explicitly. */
|
|
388
|
+
readonly mode: "infer-if-missing";
|
|
389
|
+
/** Callback used to infer the missing display name. */
|
|
390
|
+
readonly infer: EnumMemberMetadataInferenceFn;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Enum-member display-name policy input.
|
|
395
|
+
*
|
|
396
|
+
* @public
|
|
397
|
+
*/
|
|
398
|
+
export declare type EnumMemberDisplayNamePolicyInput = EnumMemberDisplayNameDisabledPolicyInput | EnumMemberDisplayNameRequireExplicitPolicyInput | EnumMemberDisplayNameInferIfMissingPolicyInput;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Enum members must declare display names explicitly.
|
|
402
|
+
*
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
export declare interface EnumMemberDisplayNameRequireExplicitPolicyInput {
|
|
406
|
+
/** Fails when an enum member has no authored display name. */
|
|
407
|
+
readonly mode: "require-explicit";
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Build-facing context passed to enum-member metadata inference callbacks.
|
|
412
|
+
*
|
|
413
|
+
* Enum members are resolved separately from declaration-level metadata so they
|
|
414
|
+
* do not participate in the shared declaration-kind model used by TSDoc and
|
|
415
|
+
* extension metadata slots.
|
|
416
|
+
*
|
|
417
|
+
* @public
|
|
418
|
+
*/
|
|
419
|
+
export declare interface EnumMemberMetadataInferenceContext {
|
|
420
|
+
/** Authoring surface the enum originated from. */
|
|
421
|
+
readonly surface: MetadataAuthoringSurface;
|
|
422
|
+
/** Logical member identifier used for policy inference. */
|
|
423
|
+
readonly logicalName: string;
|
|
424
|
+
/** Underlying enum value before stringification. */
|
|
425
|
+
readonly memberValue: string | number;
|
|
426
|
+
/** Optional build-only context supplied by the resolver. */
|
|
427
|
+
readonly buildContext?: unknown;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Callback used to infer enum-member display names.
|
|
432
|
+
*
|
|
433
|
+
* @public
|
|
434
|
+
*/
|
|
435
|
+
export declare type EnumMemberMetadataInferenceFn = (context: EnumMemberMetadataInferenceContext) => string;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* User-facing enum-member metadata policy input.
|
|
439
|
+
*
|
|
440
|
+
* @public
|
|
441
|
+
*/
|
|
442
|
+
export declare interface EnumMemberMetadataPolicyInput {
|
|
443
|
+
/** Policy for human-facing enum-member labels. */
|
|
444
|
+
readonly displayName?: EnumMemberDisplayNamePolicyInput | undefined;
|
|
445
|
+
}
|
|
446
|
+
|
|
371
447
|
/**
|
|
372
448
|
* An enum option with a separate ID and display label.
|
|
373
449
|
*
|
|
@@ -640,6 +716,11 @@ export declare interface GenerateJsonSchemaOptions {
|
|
|
640
716
|
* @defaultValue "x-formspec"
|
|
641
717
|
*/
|
|
642
718
|
readonly vendorPrefix?: string | undefined;
|
|
719
|
+
/**
|
|
720
|
+
* JSON Schema representation to use for static enums.
|
|
721
|
+
* @defaultValue "enum"
|
|
722
|
+
*/
|
|
723
|
+
readonly enumSerialization?: "enum" | "oneOf";
|
|
643
724
|
/** Metadata resolution policy for chain DSL generation. */
|
|
644
725
|
readonly metadata?: MetadataPolicyInput | undefined;
|
|
645
726
|
}
|
|
@@ -1036,6 +1117,8 @@ export declare interface MetadataPolicyInput {
|
|
|
1036
1117
|
readonly field?: DeclarationMetadataPolicyInput | undefined;
|
|
1037
1118
|
/** Policy applied to callable/method declarations. */
|
|
1038
1119
|
readonly method?: DeclarationMetadataPolicyInput | undefined;
|
|
1120
|
+
/** Policy applied to enum-member display names during build-time IR resolution. */
|
|
1121
|
+
readonly enumMember?: EnumMemberMetadataPolicyInput | undefined;
|
|
1039
1122
|
}
|
|
1040
1123
|
|
|
1041
1124
|
/**
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * FormSpec - Type-safe form specifications\n *\n * This package re-exports everything from the FormSpec library for convenience.\n * You can import everything you need from a single package:\n *\n * @example\n * ```typescript\n * import {\n * // DSL functions\n * formspec, field, group, when, is,\n * // Type inference\n * type InferSchema,\n * // Schema generation\n * buildFormSchemas,\n * // Resolvers\n * defineResolvers,\n * // Core types\n * type FormSpec, type FormElement,\n * } from \"formspec\";\n *\n * // Define a form\n * const InvoiceForm = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.dynamicEnum(\"country\", \"fetch_countries\", { label: \"Country\" }),\n * ),\n * group(\"Details\",\n * field.number(\"amount\", { label: \"Amount\", min: 0 }),\n * field.enum(\"status\", [\"draft\", \"sent\", \"paid\"]),\n * when(is(\"status\", \"draft\"),\n * field.text(\"notes\", { label: \"Internal Notes\" }),\n * ),\n * ),\n * );\n *\n * // Infer the schema type\n * type Schema = InferSchema<typeof InvoiceForm.elements>;\n *\n * // Generate JSON Schema and UI Schema\n * const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);\n *\n * // Define resolvers for dynamic data\n * const resolvers = defineResolvers(InvoiceForm, {\n * fetch_countries: async () => ({\n * options: [{ value: \"us\", label: \"United States\" }],\n * validity: \"valid\",\n * }),\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// Core types\n// =============================================================================\n\nimport type {\n AnyField,\n ArrayField,\n BooleanField,\n Conditional,\n DataSourceValueType,\n DynamicEnumField,\n DynamicSchemaField,\n EnumOption,\n EnumOptionValue,\n EqualsPredicate,\n FormElement,\n FormSpec,\n Group,\n NumberField,\n ObjectField,\n Predicate,\n StaticEnumField,\n TextField,\n} from \"@formspec/core\";\n\nexport type {\n // Validity\n Validity,\n\n // Field state\n FieldState,\n\n // Form state\n FormState,\n\n // Data sources\n DataSourceRegistry,\n DataSourceOption,\n FetchOptionsResponse,\n DataSourceValueType,\n // Elements\n TextField,\n NumberField,\n BooleanField,\n EnumOption,\n EnumOptionValue,\n StaticEnumField,\n DynamicEnumField,\n DynamicSchemaField,\n MetadataPolicyInput,\n MetadataAuthoringSurface,\n MetadataDeclarationKind,\n MetadataInferenceContext,\n MetadataInferenceFn,\n MetadataPluralizationContext,\n MetadataPluralizationDisabledPolicyInput,\n MetadataPluralizationFn,\n MetadataPluralizationInferIfMissingPolicyInput,\n MetadataPluralizationPolicyInput,\n MetadataPluralizationRequireExplicitPolicyInput,\n MetadataResolutionMode,\n MetadataSource,\n MetadataValueDisabledPolicyInput,\n MetadataValueInferIfMissingPolicyInput,\n MetadataValuePolicyInput,\n MetadataValueRequireExplicitPolicyInput,\n ResolvedMetadata,\n ResolvedScalarMetadata,\n ArrayField,\n ObjectField,\n AnyField,\n Group,\n Conditional,\n DeclarationMetadataPolicyInput,\n FormElement,\n FormSpec,\n // Predicates\n EqualsPredicate,\n Predicate,\n} from \"@formspec/core\";\n\nexport { createInitialFieldState } from \"@formspec/core\";\n\n// Type guards\nexport {\n isField,\n isTextField,\n isNumberField,\n isBooleanField,\n isStaticEnumField,\n isDynamicEnumField,\n isDynamicSchemaField,\n isArrayField,\n isObjectField,\n isGroup,\n isConditional,\n} from \"@formspec/core\";\n\n// =============================================================================\n// DSL functions\n// =============================================================================\n\nexport { logValidationIssues } from \"@formspec/dsl\";\nimport {\n field as dslField,\n group as dslGroup,\n when as dslWhen,\n is as dslIs,\n formspec as dslFormspec,\n formspecWithValidation as dslFormspecWithValidation,\n validateForm as dslValidateForm,\n type FormSpecOptions,\n} from \"@formspec/dsl\";\nexport type {\n // Validation\n FormSpecOptions,\n ValidationSeverity,\n ValidationIssue,\n ValidationResult,\n} from \"@formspec/dsl\";\nimport type { ValidationResult } from \"@formspec/dsl\";\n\n/**\n * Field builder helpers re-exported by the top-level `formspec` package.\n *\n * @public\n */\nexport interface FormSpecFieldBuilder {\n /** Creates a text field. */\n text<const N extends string>(\n name: N,\n config?: Omit<TextField<N>, \"_type\" | \"_field\" | \"name\">\n ): TextField<N>;\n /** Creates a number field. */\n number<const N extends string>(\n name: N,\n config?: Omit<NumberField<N>, \"_type\" | \"_field\" | \"name\">\n ): NumberField<N>;\n /** Creates a boolean field. */\n boolean<const N extends string>(\n name: N,\n config?: Omit<BooleanField<N>, \"_type\" | \"_field\" | \"name\">\n ): BooleanField<N>;\n /** Creates a static enum field from a fixed options list. */\n enum<const N extends string, const O extends readonly EnumOptionValue[]>(\n name: N,\n options: O,\n config?: Omit<StaticEnumField<N, O>, \"_type\" | \"_field\" | \"name\" | \"options\">\n ): StaticEnumField<N, O>;\n /** Creates a dynamic enum field backed by an external option source. */\n dynamicEnum<const N extends string, const Source extends string>(\n name: N,\n source: Source,\n config?: Omit<DynamicEnumField<N, Source>, \"_type\" | \"_field\" | \"name\" | \"source\">\n ): DynamicEnumField<N, Source>;\n /** Creates a field whose schema is resolved from an external source at runtime. */\n dynamicSchema<const N extends string>(\n name: N,\n schemaSource: string,\n config?: Omit<DynamicSchemaField<N>, \"_type\" | \"_field\" | \"name\" | \"schemaSource\">\n ): DynamicSchemaField<N>;\n /** Creates an array field from a list of item elements. */\n array<const N extends string, const Items extends readonly FormElement[]>(\n name: N,\n ...items: Items\n ): ArrayField<N, Items>;\n /** Creates an array field with explicit configuration and item elements. */\n arrayWithConfig<const N extends string, const Items extends readonly FormElement[]>(\n name: N,\n config: Omit<ArrayField<N, Items>, \"_type\" | \"_field\" | \"name\" | \"items\">,\n ...items: Items\n ): ArrayField<N, Items>;\n /** Creates an object field from a list of property elements. */\n object<const N extends string, const Properties extends readonly FormElement[]>(\n name: N,\n ...properties: Properties\n ): ObjectField<N, Properties>;\n /** Creates an object field with explicit configuration and property elements. */\n objectWithConfig<const N extends string, const Properties extends readonly FormElement[]>(\n name: N,\n config: Omit<ObjectField<N, Properties>, \"_type\" | \"_field\" | \"name\" | \"properties\">,\n ...properties: Properties\n ): ObjectField<N, Properties>;\n}\n\n/**\n * Field builder helpers that preserve this package's exported type identities.\n *\n * @public\n */\nexport const field = dslField as unknown as FormSpecFieldBuilder;\n\n// =============================================================================\n// Build tools\n// =============================================================================\n\nimport {\n buildFormSchemas as buildFormSchemasInternal,\n generateJsonSchema as generateJsonSchemaInternal,\n generateUiSchema as generateUiSchemaInternal,\n writeSchemas as writeSchemasInternal,\n type BuildFormSchemasOptions,\n type BuildResult,\n type GenerateJsonSchemaOptions,\n type GenerateUiSchemaOptions,\n type JsonSchema2020,\n type UISchema,\n type WriteSchemasOptions,\n type WriteSchemasResult,\n} from \"@formspec/build\";\n\nexport type {\n BuildFormSchemasOptions,\n GenerateJsonSchemaOptions,\n GenerateUiSchemaOptions,\n JsonSchema2020,\n UISchema,\n UISchemaElement,\n ControlElement,\n VerticalLayout,\n HorizontalLayout,\n GroupLayout,\n Categorization,\n Category,\n LabelElement,\n Rule,\n RuleEffect,\n RuleConditionSchema,\n SchemaBasedCondition,\n BuildResult,\n WriteSchemasOptions,\n WriteSchemasResult,\n} from \"@formspec/build\";\n\n// =============================================================================\n// Runtime helpers\n// =============================================================================\n\nimport {\n defineResolvers as defineResolversInternal,\n type ResolverMap,\n type ResolverRegistry,\n type ResolverSourcesForForm,\n} from \"@formspec/runtime\";\n\nexport type {\n ExtractDynamicSources,\n ExtractDynamicSourcesFromArray,\n Resolver,\n ResolverMap,\n ResolverRegistry,\n ResolverSourcesForForm,\n} from \"@formspec/runtime\";\n\n// =============================================================================\n// Local DSL wrappers and inference helpers\n// =============================================================================\n\n/**\n * Creates a visual group of form elements.\n *\n * @public\n */\nexport function group<const Elements extends readonly FormElement[]>(\n label: string,\n ...elements: Elements\n): Group<Elements> {\n return dslGroup(label, ...elements);\n}\n\n/**\n * Creates a conditional wrapper that shows elements based on a predicate.\n *\n * @public\n */\nexport function when<\n const K extends string,\n const V,\n const Elements extends readonly FormElement[],\n>(predicate: Predicate<K, V>, ...elements: Elements): Conditional<K, V, Elements> {\n return dslWhen(predicate, ...elements);\n}\n\n/**\n * Creates an equality predicate that checks if a field equals a specific value.\n *\n * @public\n */\nexport function is<const K extends string, const V>(field: K, value: V): EqualsPredicate<K, V> {\n return dslIs(field, value);\n}\n\n/**\n * Creates a complete form specification.\n *\n * @public\n */\nexport function formspec<const Elements extends readonly FormElement[]>(\n ...elements: Elements\n): FormSpec<Elements> {\n return dslFormspec(...elements);\n}\n\n/**\n * Creates a complete form specification with validation options.\n *\n * @public\n */\nexport function formspecWithValidation<const Elements extends readonly FormElement[]>(\n options: FormSpecOptions,\n ...elements: Elements\n): FormSpec<Elements> {\n return dslFormspecWithValidation(options, ...elements);\n}\n\n/**\n * Infers the value type from a single field.\n *\n * @public\n */\nexport type InferFieldValue<F> =\n F extends TextField<string>\n ? string\n : F extends NumberField<string>\n ? number\n : F extends BooleanField<string>\n ? boolean\n : F extends StaticEnumField<string, infer O extends readonly EnumOptionValue[]>\n ? O extends readonly EnumOption[]\n ? O[number][\"id\"]\n : O extends readonly string[]\n ? O[number]\n : never\n : F extends DynamicEnumField<string, infer Source>\n ? DataSourceValueType<Source>\n : F extends DynamicSchemaField<string>\n ? Record<string, unknown>\n : F extends ArrayField<string, infer Items extends readonly FormElement[]>\n ? InferSchema<Items>[]\n : F extends ObjectField<string, infer Properties extends readonly FormElement[]>\n ? InferSchema<Properties>\n : never;\n\n/**\n * Extracts all fields from a single element.\n *\n * @public\n */\nexport type ExtractFields<E> = E extends AnyField\n ? E\n : E extends Group<infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : never;\n\n/**\n * Extracts fields from an array of elements.\n *\n * @public\n */\nexport type ExtractFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractFields<First> | ExtractFieldsFromArray<Rest>\n : never;\n\n/**\n * Extracts fields that are not inside conditionals.\n *\n * @public\n */\nexport type ExtractNonConditionalFields<E> = E extends AnyField\n ? E\n : E extends Group<infer Elements>\n ? ExtractNonConditionalFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer _Elements>\n ? never\n : never;\n\n/**\n * Extracts non-conditional fields from an array of elements.\n *\n * @public\n */\nexport type ExtractNonConditionalFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractNonConditionalFields<First> | ExtractNonConditionalFieldsFromArray<Rest>\n : never;\n\n/**\n * Extracts fields that are inside conditionals.\n *\n * @public\n */\nexport type ExtractConditionalFields<E> = E extends AnyField\n ? never\n : E extends Group<infer Elements>\n ? ExtractConditionalFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : never;\n\n/**\n * Extracts conditional fields from an array of elements.\n *\n * @public\n */\nexport type ExtractConditionalFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractConditionalFields<First> | ExtractConditionalFieldsFromArray<Rest>\n : never;\n\n/**\n * Builds a schema type from extracted fields.\n *\n * @public\n */\nexport type BuildSchema<Fields> = {\n [N in Fields extends { name: infer K extends string } ? K : never]: InferFieldValue<\n Extract<Fields, { name: N } & AnyField>\n >;\n};\n\n/**\n * Utility type that flattens intersection types.\n *\n * @public\n */\nexport type FlattenIntersection<T> = {\n [K in keyof T]: T[K];\n} & {};\n\n/**\n * Infers the schema type from an array of form elements.\n *\n * @public\n */\nexport type InferSchema<Elements extends readonly FormElement[]> = FlattenIntersection<\n BuildSchema<ExtractNonConditionalFieldsFromArray<Elements>> &\n Partial<BuildSchema<ExtractConditionalFieldsFromArray<Elements>>>\n>;\n\n/**\n * Infers the schema type from a FormSpec.\n *\n * @public\n */\nexport type InferFormSchema<F extends FormSpec<readonly FormElement[]>> =\n F extends FormSpec<infer Elements> ? InferSchema<Elements> : never;\n\n/**\n * Generates a JSON Schema 2020-12 from a FormSpec.\n *\n * @public\n */\nexport function generateJsonSchema<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: GenerateJsonSchemaOptions\n): JsonSchema2020 {\n return generateJsonSchemaInternal(form, options);\n}\n\n/**\n * Generates a UI schema from a FormSpec.\n *\n * @public\n */\nexport function generateUiSchema<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: GenerateUiSchemaOptions\n): UISchema {\n return generateUiSchemaInternal(form, options);\n}\n\n/**\n * Builds both JSON Schema and UI Schema from a FormSpec.\n *\n * @public\n */\nexport function buildFormSchemas<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: BuildFormSchemasOptions\n): BuildResult {\n return buildFormSchemasInternal(form, options);\n}\n\n/**\n * Builds and writes both JSON Schema and UI Schema files to disk.\n *\n * @public\n */\nexport function writeSchemas<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options: WriteSchemasOptions\n): WriteSchemasResult {\n return writeSchemasInternal(form, options);\n}\n\n/**\n * Defines resolvers for a form's dynamic data sources.\n *\n * @public\n */\nexport function defineResolvers<\n E extends readonly FormElement[],\n Sources extends string = ResolverSourcesForForm<E>,\n>(form: FormSpec<E>, resolvers: ResolverMap<Sources>): ResolverRegistry<Sources> {\n return defineResolversInternal(form, resolvers);\n}\n\n/**\n * Validates a list of form elements for duplicate names and structural issues.\n *\n * @public\n */\nexport function validateForm(elements: readonly FormElement[]): ValidationResult {\n return dslValidateForm(elements);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuIA,kBAAwC;AAGxC,IAAAA,eAYO;AAMP,iBAAoC;AACpC,IAAAC,cASO;AAoFP,mBAaO;AA6BP,qBAKO;AArDA,IAAM,QAAQ,YAAAC;AAyEd,SAAS,MACd,UACG,UACc;AACjB,aAAO,YAAAC,OAAS,OAAO,GAAG,QAAQ;AACpC;AAOO,SAAS,KAId,cAA+B,UAAiD;AAChF,aAAO,YAAAC,MAAQ,WAAW,GAAG,QAAQ;AACvC;AAOO,SAAS,GAAoCC,QAAU,OAAiC;AAC7F,aAAO,YAAAC,IAAMD,QAAO,KAAK;AAC3B;AAOO,SAAS,YACX,UACiB;AACpB,aAAO,YAAAE,UAAY,GAAG,QAAQ;AAChC;AAOO,SAAS,uBACd,YACG,UACiB;AACpB,aAAO,YAAAC,wBAA0B,SAAS,GAAG,QAAQ;AACvD;AAoJO,SAAS,mBACd,MACA,SACgB;AAChB,aAAO,aAAAC,oBAA2B,MAAM,OAAO;AACjD;AAOO,SAAS,iBACd,MACA,SACU;AACV,aAAO,aAAAC,kBAAyB,MAAM,OAAO;AAC/C;AAOO,SAAS,iBACd,MACA,SACa;AACb,aAAO,aAAAC,kBAAyB,MAAM,OAAO;AAC/C;AAOO,SAAS,aACd,MACA,SACoB;AACpB,aAAO,aAAAC,cAAqB,MAAM,OAAO;AAC3C;AAOO,SAAS,gBAGd,MAAmB,WAA4D;AAC/E,aAAO,eAAAC,iBAAwB,MAAM,SAAS;AAChD;AAOO,SAAS,aAAa,UAAoD;AAC/E,aAAO,YAAAC,cAAgB,QAAQ;AACjC;","names":["import_core","import_dsl","dslField","dslGroup","dslWhen","field","dslIs","dslFormspec","dslFormspecWithValidation","generateJsonSchemaInternal","generateUiSchemaInternal","buildFormSchemasInternal","writeSchemasInternal","defineResolversInternal","dslValidateForm"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * FormSpec - Type-safe form specifications\n *\n * This package re-exports everything from the FormSpec library for convenience.\n * You can import everything you need from a single package:\n *\n * @example\n * ```typescript\n * import {\n * // DSL functions\n * formspec, field, group, when, is,\n * // Type inference\n * type InferSchema,\n * // Schema generation\n * buildFormSchemas,\n * // Resolvers\n * defineResolvers,\n * // Core types\n * type FormSpec, type FormElement,\n * } from \"formspec\";\n *\n * // Define a form\n * const InvoiceForm = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.dynamicEnum(\"country\", \"fetch_countries\", { label: \"Country\" }),\n * ),\n * group(\"Details\",\n * field.number(\"amount\", { label: \"Amount\", min: 0 }),\n * field.enum(\"status\", [\"draft\", \"sent\", \"paid\"]),\n * when(is(\"status\", \"draft\"),\n * field.text(\"notes\", { label: \"Internal Notes\" }),\n * ),\n * ),\n * );\n *\n * // Infer the schema type\n * type Schema = InferSchema<typeof InvoiceForm.elements>;\n *\n * // Generate JSON Schema and UI Schema\n * const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);\n *\n * // Define resolvers for dynamic data\n * const resolvers = defineResolvers(InvoiceForm, {\n * fetch_countries: async () => ({\n * options: [{ value: \"us\", label: \"United States\" }],\n * validity: \"valid\",\n * }),\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// Core types\n// =============================================================================\n\nimport type {\n AnyField,\n ArrayField,\n BooleanField,\n Conditional,\n DataSourceValueType,\n DynamicEnumField,\n DynamicSchemaField,\n EnumOption,\n EnumOptionValue,\n EqualsPredicate,\n FormElement,\n FormSpec,\n Group,\n NumberField,\n ObjectField,\n Predicate,\n StaticEnumField,\n TextField,\n} from \"@formspec/core\";\n\nexport type {\n // Validity\n Validity,\n\n // Field state\n FieldState,\n\n // Form state\n FormState,\n\n // Data sources\n DataSourceRegistry,\n DataSourceOption,\n FetchOptionsResponse,\n DataSourceValueType,\n // Elements\n TextField,\n NumberField,\n BooleanField,\n EnumOption,\n EnumOptionValue,\n StaticEnumField,\n DynamicEnumField,\n DynamicSchemaField,\n MetadataPolicyInput,\n MetadataAuthoringSurface,\n MetadataDeclarationKind,\n MetadataInferenceContext,\n MetadataInferenceFn,\n EnumMemberMetadataInferenceContext,\n EnumMemberMetadataInferenceFn,\n MetadataPluralizationContext,\n MetadataPluralizationDisabledPolicyInput,\n MetadataPluralizationFn,\n MetadataPluralizationInferIfMissingPolicyInput,\n MetadataPluralizationPolicyInput,\n MetadataPluralizationRequireExplicitPolicyInput,\n MetadataResolutionMode,\n MetadataSource,\n MetadataValueDisabledPolicyInput,\n MetadataValueInferIfMissingPolicyInput,\n MetadataValuePolicyInput,\n MetadataValueRequireExplicitPolicyInput,\n EnumMemberDisplayNameDisabledPolicyInput,\n EnumMemberDisplayNameRequireExplicitPolicyInput,\n EnumMemberDisplayNameInferIfMissingPolicyInput,\n EnumMemberDisplayNamePolicyInput,\n EnumMemberMetadataPolicyInput,\n ResolvedMetadata,\n ResolvedScalarMetadata,\n ArrayField,\n ObjectField,\n AnyField,\n Group,\n Conditional,\n DeclarationMetadataPolicyInput,\n FormElement,\n FormSpec,\n // Predicates\n EqualsPredicate,\n Predicate,\n} from \"@formspec/core\";\n\nexport { createInitialFieldState } from \"@formspec/core\";\n\n// Type guards\nexport {\n isField,\n isTextField,\n isNumberField,\n isBooleanField,\n isStaticEnumField,\n isDynamicEnumField,\n isDynamicSchemaField,\n isArrayField,\n isObjectField,\n isGroup,\n isConditional,\n} from \"@formspec/core\";\n\n// =============================================================================\n// DSL functions\n// =============================================================================\n\nexport { logValidationIssues } from \"@formspec/dsl\";\nimport {\n field as dslField,\n group as dslGroup,\n when as dslWhen,\n is as dslIs,\n formspec as dslFormspec,\n formspecWithValidation as dslFormspecWithValidation,\n validateForm as dslValidateForm,\n type FormSpecOptions,\n} from \"@formspec/dsl\";\nexport type {\n // Validation\n FormSpecOptions,\n ValidationSeverity,\n ValidationIssue,\n ValidationResult,\n} from \"@formspec/dsl\";\nimport type { ValidationResult } from \"@formspec/dsl\";\n\n/**\n * Field builder helpers re-exported by the top-level `formspec` package.\n *\n * @public\n */\nexport interface FormSpecFieldBuilder {\n /** Creates a text field. */\n text<const N extends string>(\n name: N,\n config?: Omit<TextField<N>, \"_type\" | \"_field\" | \"name\">\n ): TextField<N>;\n /** Creates a number field. */\n number<const N extends string>(\n name: N,\n config?: Omit<NumberField<N>, \"_type\" | \"_field\" | \"name\">\n ): NumberField<N>;\n /** Creates a boolean field. */\n boolean<const N extends string>(\n name: N,\n config?: Omit<BooleanField<N>, \"_type\" | \"_field\" | \"name\">\n ): BooleanField<N>;\n /** Creates a static enum field from a fixed options list. */\n enum<const N extends string, const O extends readonly EnumOptionValue[]>(\n name: N,\n options: O,\n config?: Omit<StaticEnumField<N, O>, \"_type\" | \"_field\" | \"name\" | \"options\">\n ): StaticEnumField<N, O>;\n /** Creates a dynamic enum field backed by an external option source. */\n dynamicEnum<const N extends string, const Source extends string>(\n name: N,\n source: Source,\n config?: Omit<DynamicEnumField<N, Source>, \"_type\" | \"_field\" | \"name\" | \"source\">\n ): DynamicEnumField<N, Source>;\n /** Creates a field whose schema is resolved from an external source at runtime. */\n dynamicSchema<const N extends string>(\n name: N,\n schemaSource: string,\n config?: Omit<DynamicSchemaField<N>, \"_type\" | \"_field\" | \"name\" | \"schemaSource\">\n ): DynamicSchemaField<N>;\n /** Creates an array field from a list of item elements. */\n array<const N extends string, const Items extends readonly FormElement[]>(\n name: N,\n ...items: Items\n ): ArrayField<N, Items>;\n /** Creates an array field with explicit configuration and item elements. */\n arrayWithConfig<const N extends string, const Items extends readonly FormElement[]>(\n name: N,\n config: Omit<ArrayField<N, Items>, \"_type\" | \"_field\" | \"name\" | \"items\">,\n ...items: Items\n ): ArrayField<N, Items>;\n /** Creates an object field from a list of property elements. */\n object<const N extends string, const Properties extends readonly FormElement[]>(\n name: N,\n ...properties: Properties\n ): ObjectField<N, Properties>;\n /** Creates an object field with explicit configuration and property elements. */\n objectWithConfig<const N extends string, const Properties extends readonly FormElement[]>(\n name: N,\n config: Omit<ObjectField<N, Properties>, \"_type\" | \"_field\" | \"name\" | \"properties\">,\n ...properties: Properties\n ): ObjectField<N, Properties>;\n}\n\n/**\n * Field builder helpers that preserve this package's exported type identities.\n *\n * @public\n */\nexport const field = dslField as unknown as FormSpecFieldBuilder;\n\n// =============================================================================\n// Build tools\n// =============================================================================\n\nimport {\n buildFormSchemas as buildFormSchemasInternal,\n generateJsonSchema as generateJsonSchemaInternal,\n generateUiSchema as generateUiSchemaInternal,\n writeSchemas as writeSchemasInternal,\n type BuildFormSchemasOptions,\n type BuildResult,\n type GenerateJsonSchemaOptions,\n type GenerateUiSchemaOptions,\n type JsonSchema2020,\n type UISchema,\n type WriteSchemasOptions,\n type WriteSchemasResult,\n} from \"@formspec/build\";\n\nexport type {\n BuildFormSchemasOptions,\n GenerateJsonSchemaOptions,\n GenerateUiSchemaOptions,\n JsonSchema2020,\n UISchema,\n UISchemaElement,\n ControlElement,\n VerticalLayout,\n HorizontalLayout,\n GroupLayout,\n Categorization,\n Category,\n LabelElement,\n Rule,\n RuleEffect,\n RuleConditionSchema,\n SchemaBasedCondition,\n BuildResult,\n WriteSchemasOptions,\n WriteSchemasResult,\n} from \"@formspec/build\";\n\n// =============================================================================\n// Runtime helpers\n// =============================================================================\n\nimport {\n defineResolvers as defineResolversInternal,\n type ResolverMap,\n type ResolverRegistry,\n type ResolverSourcesForForm,\n} from \"@formspec/runtime\";\n\nexport type {\n ExtractDynamicSources,\n ExtractDynamicSourcesFromArray,\n Resolver,\n ResolverMap,\n ResolverRegistry,\n ResolverSourcesForForm,\n} from \"@formspec/runtime\";\n\n// =============================================================================\n// Local DSL wrappers and inference helpers\n// =============================================================================\n\n/**\n * Creates a visual group of form elements.\n *\n * @public\n */\nexport function group<const Elements extends readonly FormElement[]>(\n label: string,\n ...elements: Elements\n): Group<Elements> {\n return dslGroup(label, ...elements);\n}\n\n/**\n * Creates a conditional wrapper that shows elements based on a predicate.\n *\n * @public\n */\nexport function when<\n const K extends string,\n const V,\n const Elements extends readonly FormElement[],\n>(predicate: Predicate<K, V>, ...elements: Elements): Conditional<K, V, Elements> {\n return dslWhen(predicate, ...elements);\n}\n\n/**\n * Creates an equality predicate that checks if a field equals a specific value.\n *\n * @public\n */\nexport function is<const K extends string, const V>(field: K, value: V): EqualsPredicate<K, V> {\n return dslIs(field, value);\n}\n\n/**\n * Creates a complete form specification.\n *\n * @public\n */\nexport function formspec<const Elements extends readonly FormElement[]>(\n ...elements: Elements\n): FormSpec<Elements> {\n return dslFormspec(...elements);\n}\n\n/**\n * Creates a complete form specification with validation options.\n *\n * @public\n */\nexport function formspecWithValidation<const Elements extends readonly FormElement[]>(\n options: FormSpecOptions,\n ...elements: Elements\n): FormSpec<Elements> {\n return dslFormspecWithValidation(options, ...elements);\n}\n\n/**\n * Infers the value type from a single field.\n *\n * @public\n */\nexport type InferFieldValue<F> =\n F extends TextField<string>\n ? string\n : F extends NumberField<string>\n ? number\n : F extends BooleanField<string>\n ? boolean\n : F extends StaticEnumField<string, infer O extends readonly EnumOptionValue[]>\n ? O extends readonly EnumOption[]\n ? O[number][\"id\"]\n : O extends readonly string[]\n ? O[number]\n : never\n : F extends DynamicEnumField<string, infer Source>\n ? DataSourceValueType<Source>\n : F extends DynamicSchemaField<string>\n ? Record<string, unknown>\n : F extends ArrayField<string, infer Items extends readonly FormElement[]>\n ? InferSchema<Items>[]\n : F extends ObjectField<string, infer Properties extends readonly FormElement[]>\n ? InferSchema<Properties>\n : never;\n\n/**\n * Extracts all fields from a single element.\n *\n * @public\n */\nexport type ExtractFields<E> = E extends AnyField\n ? E\n : E extends Group<infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : never;\n\n/**\n * Extracts fields from an array of elements.\n *\n * @public\n */\nexport type ExtractFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractFields<First> | ExtractFieldsFromArray<Rest>\n : never;\n\n/**\n * Extracts fields that are not inside conditionals.\n *\n * @public\n */\nexport type ExtractNonConditionalFields<E> = E extends AnyField\n ? E\n : E extends Group<infer Elements>\n ? ExtractNonConditionalFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer _Elements>\n ? never\n : never;\n\n/**\n * Extracts non-conditional fields from an array of elements.\n *\n * @public\n */\nexport type ExtractNonConditionalFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractNonConditionalFields<First> | ExtractNonConditionalFieldsFromArray<Rest>\n : never;\n\n/**\n * Extracts fields that are inside conditionals.\n *\n * @public\n */\nexport type ExtractConditionalFields<E> = E extends AnyField\n ? never\n : E extends Group<infer Elements>\n ? ExtractConditionalFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : never;\n\n/**\n * Extracts conditional fields from an array of elements.\n *\n * @public\n */\nexport type ExtractConditionalFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractConditionalFields<First> | ExtractConditionalFieldsFromArray<Rest>\n : never;\n\n/**\n * Builds a schema type from extracted fields.\n *\n * @public\n */\nexport type BuildSchema<Fields> = {\n [N in Fields extends { name: infer K extends string } ? K : never]: InferFieldValue<\n Extract<Fields, { name: N } & AnyField>\n >;\n};\n\n/**\n * Utility type that flattens intersection types.\n *\n * @public\n */\nexport type FlattenIntersection<T> = {\n [K in keyof T]: T[K];\n} & {};\n\n/**\n * Infers the schema type from an array of form elements.\n *\n * @public\n */\nexport type InferSchema<Elements extends readonly FormElement[]> = FlattenIntersection<\n BuildSchema<ExtractNonConditionalFieldsFromArray<Elements>> &\n Partial<BuildSchema<ExtractConditionalFieldsFromArray<Elements>>>\n>;\n\n/**\n * Infers the schema type from a FormSpec.\n *\n * @public\n */\nexport type InferFormSchema<F extends FormSpec<readonly FormElement[]>> =\n F extends FormSpec<infer Elements> ? InferSchema<Elements> : never;\n\n/**\n * Generates a JSON Schema 2020-12 from a FormSpec.\n *\n * @public\n */\nexport function generateJsonSchema<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: GenerateJsonSchemaOptions\n): JsonSchema2020 {\n return generateJsonSchemaInternal(form, options);\n}\n\n/**\n * Generates a UI schema from a FormSpec.\n *\n * @public\n */\nexport function generateUiSchema<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: GenerateUiSchemaOptions\n): UISchema {\n return generateUiSchemaInternal(form, options);\n}\n\n/**\n * Builds both JSON Schema and UI Schema from a FormSpec.\n *\n * @public\n */\nexport function buildFormSchemas<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: BuildFormSchemasOptions\n): BuildResult {\n return buildFormSchemasInternal(form, options);\n}\n\n/**\n * Builds and writes both JSON Schema and UI Schema files to disk.\n *\n * @public\n */\nexport function writeSchemas<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options: WriteSchemasOptions\n): WriteSchemasResult {\n return writeSchemasInternal(form, options);\n}\n\n/**\n * Defines resolvers for a form's dynamic data sources.\n *\n * @public\n */\nexport function defineResolvers<\n E extends readonly FormElement[],\n Sources extends string = ResolverSourcesForForm<E>,\n>(form: FormSpec<E>, resolvers: ResolverMap<Sources>): ResolverRegistry<Sources> {\n return defineResolversInternal(form, resolvers);\n}\n\n/**\n * Validates a list of form elements for duplicate names and structural issues.\n *\n * @public\n */\nexport function validateForm(elements: readonly FormElement[]): ValidationResult {\n return dslValidateForm(elements);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8IA,kBAAwC;AAGxC,IAAAA,eAYO;AAMP,iBAAoC;AACpC,IAAAC,cASO;AAoFP,mBAaO;AA6BP,qBAKO;AArDA,IAAM,QAAQ,YAAAC;AAyEd,SAAS,MACd,UACG,UACc;AACjB,aAAO,YAAAC,OAAS,OAAO,GAAG,QAAQ;AACpC;AAOO,SAAS,KAId,cAA+B,UAAiD;AAChF,aAAO,YAAAC,MAAQ,WAAW,GAAG,QAAQ;AACvC;AAOO,SAAS,GAAoCC,QAAU,OAAiC;AAC7F,aAAO,YAAAC,IAAMD,QAAO,KAAK;AAC3B;AAOO,SAAS,YACX,UACiB;AACpB,aAAO,YAAAE,UAAY,GAAG,QAAQ;AAChC;AAOO,SAAS,uBACd,YACG,UACiB;AACpB,aAAO,YAAAC,wBAA0B,SAAS,GAAG,QAAQ;AACvD;AAoJO,SAAS,mBACd,MACA,SACgB;AAChB,aAAO,aAAAC,oBAA2B,MAAM,OAAO;AACjD;AAOO,SAAS,iBACd,MACA,SACU;AACV,aAAO,aAAAC,kBAAyB,MAAM,OAAO;AAC/C;AAOO,SAAS,iBACd,MACA,SACa;AACb,aAAO,aAAAC,kBAAyB,MAAM,OAAO;AAC/C;AAOO,SAAS,aACd,MACA,SACoB;AACpB,aAAO,aAAAC,cAAqB,MAAM,OAAO;AAC3C;AAOO,SAAS,gBAGd,MAAmB,WAA4D;AAC/E,aAAO,eAAAC,iBAAwB,MAAM,SAAS;AAChD;AAOO,SAAS,aAAa,UAAoD;AAC/E,aAAO,YAAAC,cAAgB,QAAQ;AACjC;","names":["import_core","import_dsl","dslField","dslGroup","dslWhen","field","dslIs","dslFormspec","dslFormspecWithValidation","generateJsonSchemaInternal","generateUiSchemaInternal","buildFormSchemasInternal","writeSchemasInternal","defineResolversInternal","dslValidateForm"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
* @packageDocumentation
|
|
53
53
|
*/
|
|
54
54
|
import type { AnyField, ArrayField, BooleanField, Conditional, DataSourceValueType, DynamicEnumField, DynamicSchemaField, EnumOption, EnumOptionValue, EqualsPredicate, FormElement, FormSpec, Group, NumberField, ObjectField, Predicate, StaticEnumField, TextField } from "@formspec/core";
|
|
55
|
-
export type { Validity, FieldState, FormState, DataSourceRegistry, DataSourceOption, FetchOptionsResponse, DataSourceValueType, TextField, NumberField, BooleanField, EnumOption, EnumOptionValue, StaticEnumField, DynamicEnumField, DynamicSchemaField, MetadataPolicyInput, MetadataAuthoringSurface, MetadataDeclarationKind, MetadataInferenceContext, MetadataInferenceFn, MetadataPluralizationContext, MetadataPluralizationDisabledPolicyInput, MetadataPluralizationFn, MetadataPluralizationInferIfMissingPolicyInput, MetadataPluralizationPolicyInput, MetadataPluralizationRequireExplicitPolicyInput, MetadataResolutionMode, MetadataSource, MetadataValueDisabledPolicyInput, MetadataValueInferIfMissingPolicyInput, MetadataValuePolicyInput, MetadataValueRequireExplicitPolicyInput, ResolvedMetadata, ResolvedScalarMetadata, ArrayField, ObjectField, AnyField, Group, Conditional, DeclarationMetadataPolicyInput, FormElement, FormSpec, EqualsPredicate, Predicate, } from "@formspec/core";
|
|
55
|
+
export type { Validity, FieldState, FormState, DataSourceRegistry, DataSourceOption, FetchOptionsResponse, DataSourceValueType, TextField, NumberField, BooleanField, EnumOption, EnumOptionValue, StaticEnumField, DynamicEnumField, DynamicSchemaField, MetadataPolicyInput, MetadataAuthoringSurface, MetadataDeclarationKind, MetadataInferenceContext, MetadataInferenceFn, EnumMemberMetadataInferenceContext, EnumMemberMetadataInferenceFn, MetadataPluralizationContext, MetadataPluralizationDisabledPolicyInput, MetadataPluralizationFn, MetadataPluralizationInferIfMissingPolicyInput, MetadataPluralizationPolicyInput, MetadataPluralizationRequireExplicitPolicyInput, MetadataResolutionMode, MetadataSource, MetadataValueDisabledPolicyInput, MetadataValueInferIfMissingPolicyInput, MetadataValuePolicyInput, MetadataValueRequireExplicitPolicyInput, EnumMemberDisplayNameDisabledPolicyInput, EnumMemberDisplayNameRequireExplicitPolicyInput, EnumMemberDisplayNameInferIfMissingPolicyInput, EnumMemberDisplayNamePolicyInput, EnumMemberMetadataPolicyInput, ResolvedMetadata, ResolvedScalarMetadata, ArrayField, ObjectField, AnyField, Group, Conditional, DeclarationMetadataPolicyInput, FormElement, FormSpec, EqualsPredicate, Predicate, } from "@formspec/core";
|
|
56
56
|
export { createInitialFieldState } from "@formspec/core";
|
|
57
57
|
export { isField, isTextField, isNumberField, isBooleanField, isStaticEnumField, isDynamicEnumField, isDynamicSchemaField, isArrayField, isObjectField, isGroup, isConditional, } from "@formspec/core";
|
|
58
58
|
export { logValidationIssues } from "@formspec/dsl";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAMH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,eAAe,EACf,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EACf,SAAS,EACV,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAEV,QAAQ,EAGR,UAAU,EAGV,SAAS,EAGT,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,E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AAQ,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,mBAAmB,GAC3B,kBAAkB,CAEpB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,CAAC,SAAS,SAAS,WAAW,EAAE,EAChC,OAAO,SAAS,MAAM,GAAG,sBAAsB,CAAC,CAAC,CAAC,EAClD,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAE/E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,gBAAgB,CAE/E"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * FormSpec - Type-safe form specifications\n *\n * This package re-exports everything from the FormSpec library for convenience.\n * You can import everything you need from a single package:\n *\n * @example\n * ```typescript\n * import {\n * // DSL functions\n * formspec, field, group, when, is,\n * // Type inference\n * type InferSchema,\n * // Schema generation\n * buildFormSchemas,\n * // Resolvers\n * defineResolvers,\n * // Core types\n * type FormSpec, type FormElement,\n * } from \"formspec\";\n *\n * // Define a form\n * const InvoiceForm = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.dynamicEnum(\"country\", \"fetch_countries\", { label: \"Country\" }),\n * ),\n * group(\"Details\",\n * field.number(\"amount\", { label: \"Amount\", min: 0 }),\n * field.enum(\"status\", [\"draft\", \"sent\", \"paid\"]),\n * when(is(\"status\", \"draft\"),\n * field.text(\"notes\", { label: \"Internal Notes\" }),\n * ),\n * ),\n * );\n *\n * // Infer the schema type\n * type Schema = InferSchema<typeof InvoiceForm.elements>;\n *\n * // Generate JSON Schema and UI Schema\n * const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);\n *\n * // Define resolvers for dynamic data\n * const resolvers = defineResolvers(InvoiceForm, {\n * fetch_countries: async () => ({\n * options: [{ value: \"us\", label: \"United States\" }],\n * validity: \"valid\",\n * }),\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// Core types\n// =============================================================================\n\nimport type {\n AnyField,\n ArrayField,\n BooleanField,\n Conditional,\n DataSourceValueType,\n DynamicEnumField,\n DynamicSchemaField,\n EnumOption,\n EnumOptionValue,\n EqualsPredicate,\n FormElement,\n FormSpec,\n Group,\n NumberField,\n ObjectField,\n Predicate,\n StaticEnumField,\n TextField,\n} from \"@formspec/core\";\n\nexport type {\n // Validity\n Validity,\n\n // Field state\n FieldState,\n\n // Form state\n FormState,\n\n // Data sources\n DataSourceRegistry,\n DataSourceOption,\n FetchOptionsResponse,\n DataSourceValueType,\n // Elements\n TextField,\n NumberField,\n BooleanField,\n EnumOption,\n EnumOptionValue,\n StaticEnumField,\n DynamicEnumField,\n DynamicSchemaField,\n MetadataPolicyInput,\n MetadataAuthoringSurface,\n MetadataDeclarationKind,\n MetadataInferenceContext,\n MetadataInferenceFn,\n MetadataPluralizationContext,\n MetadataPluralizationDisabledPolicyInput,\n MetadataPluralizationFn,\n MetadataPluralizationInferIfMissingPolicyInput,\n MetadataPluralizationPolicyInput,\n MetadataPluralizationRequireExplicitPolicyInput,\n MetadataResolutionMode,\n MetadataSource,\n MetadataValueDisabledPolicyInput,\n MetadataValueInferIfMissingPolicyInput,\n MetadataValuePolicyInput,\n MetadataValueRequireExplicitPolicyInput,\n ResolvedMetadata,\n ResolvedScalarMetadata,\n ArrayField,\n ObjectField,\n AnyField,\n Group,\n Conditional,\n DeclarationMetadataPolicyInput,\n FormElement,\n FormSpec,\n // Predicates\n EqualsPredicate,\n Predicate,\n} from \"@formspec/core\";\n\nexport { createInitialFieldState } from \"@formspec/core\";\n\n// Type guards\nexport {\n isField,\n isTextField,\n isNumberField,\n isBooleanField,\n isStaticEnumField,\n isDynamicEnumField,\n isDynamicSchemaField,\n isArrayField,\n isObjectField,\n isGroup,\n isConditional,\n} from \"@formspec/core\";\n\n// =============================================================================\n// DSL functions\n// =============================================================================\n\nexport { logValidationIssues } from \"@formspec/dsl\";\nimport {\n field as dslField,\n group as dslGroup,\n when as dslWhen,\n is as dslIs,\n formspec as dslFormspec,\n formspecWithValidation as dslFormspecWithValidation,\n validateForm as dslValidateForm,\n type FormSpecOptions,\n} from \"@formspec/dsl\";\nexport type {\n // Validation\n FormSpecOptions,\n ValidationSeverity,\n ValidationIssue,\n ValidationResult,\n} from \"@formspec/dsl\";\nimport type { ValidationResult } from \"@formspec/dsl\";\n\n/**\n * Field builder helpers re-exported by the top-level `formspec` package.\n *\n * @public\n */\nexport interface FormSpecFieldBuilder {\n /** Creates a text field. */\n text<const N extends string>(\n name: N,\n config?: Omit<TextField<N>, \"_type\" | \"_field\" | \"name\">\n ): TextField<N>;\n /** Creates a number field. */\n number<const N extends string>(\n name: N,\n config?: Omit<NumberField<N>, \"_type\" | \"_field\" | \"name\">\n ): NumberField<N>;\n /** Creates a boolean field. */\n boolean<const N extends string>(\n name: N,\n config?: Omit<BooleanField<N>, \"_type\" | \"_field\" | \"name\">\n ): BooleanField<N>;\n /** Creates a static enum field from a fixed options list. */\n enum<const N extends string, const O extends readonly EnumOptionValue[]>(\n name: N,\n options: O,\n config?: Omit<StaticEnumField<N, O>, \"_type\" | \"_field\" | \"name\" | \"options\">\n ): StaticEnumField<N, O>;\n /** Creates a dynamic enum field backed by an external option source. */\n dynamicEnum<const N extends string, const Source extends string>(\n name: N,\n source: Source,\n config?: Omit<DynamicEnumField<N, Source>, \"_type\" | \"_field\" | \"name\" | \"source\">\n ): DynamicEnumField<N, Source>;\n /** Creates a field whose schema is resolved from an external source at runtime. */\n dynamicSchema<const N extends string>(\n name: N,\n schemaSource: string,\n config?: Omit<DynamicSchemaField<N>, \"_type\" | \"_field\" | \"name\" | \"schemaSource\">\n ): DynamicSchemaField<N>;\n /** Creates an array field from a list of item elements. */\n array<const N extends string, const Items extends readonly FormElement[]>(\n name: N,\n ...items: Items\n ): ArrayField<N, Items>;\n /** Creates an array field with explicit configuration and item elements. */\n arrayWithConfig<const N extends string, const Items extends readonly FormElement[]>(\n name: N,\n config: Omit<ArrayField<N, Items>, \"_type\" | \"_field\" | \"name\" | \"items\">,\n ...items: Items\n ): ArrayField<N, Items>;\n /** Creates an object field from a list of property elements. */\n object<const N extends string, const Properties extends readonly FormElement[]>(\n name: N,\n ...properties: Properties\n ): ObjectField<N, Properties>;\n /** Creates an object field with explicit configuration and property elements. */\n objectWithConfig<const N extends string, const Properties extends readonly FormElement[]>(\n name: N,\n config: Omit<ObjectField<N, Properties>, \"_type\" | \"_field\" | \"name\" | \"properties\">,\n ...properties: Properties\n ): ObjectField<N, Properties>;\n}\n\n/**\n * Field builder helpers that preserve this package's exported type identities.\n *\n * @public\n */\nexport const field = dslField as unknown as FormSpecFieldBuilder;\n\n// =============================================================================\n// Build tools\n// =============================================================================\n\nimport {\n buildFormSchemas as buildFormSchemasInternal,\n generateJsonSchema as generateJsonSchemaInternal,\n generateUiSchema as generateUiSchemaInternal,\n writeSchemas as writeSchemasInternal,\n type BuildFormSchemasOptions,\n type BuildResult,\n type GenerateJsonSchemaOptions,\n type GenerateUiSchemaOptions,\n type JsonSchema2020,\n type UISchema,\n type WriteSchemasOptions,\n type WriteSchemasResult,\n} from \"@formspec/build\";\n\nexport type {\n BuildFormSchemasOptions,\n GenerateJsonSchemaOptions,\n GenerateUiSchemaOptions,\n JsonSchema2020,\n UISchema,\n UISchemaElement,\n ControlElement,\n VerticalLayout,\n HorizontalLayout,\n GroupLayout,\n Categorization,\n Category,\n LabelElement,\n Rule,\n RuleEffect,\n RuleConditionSchema,\n SchemaBasedCondition,\n BuildResult,\n WriteSchemasOptions,\n WriteSchemasResult,\n} from \"@formspec/build\";\n\n// =============================================================================\n// Runtime helpers\n// =============================================================================\n\nimport {\n defineResolvers as defineResolversInternal,\n type ResolverMap,\n type ResolverRegistry,\n type ResolverSourcesForForm,\n} from \"@formspec/runtime\";\n\nexport type {\n ExtractDynamicSources,\n ExtractDynamicSourcesFromArray,\n Resolver,\n ResolverMap,\n ResolverRegistry,\n ResolverSourcesForForm,\n} from \"@formspec/runtime\";\n\n// =============================================================================\n// Local DSL wrappers and inference helpers\n// =============================================================================\n\n/**\n * Creates a visual group of form elements.\n *\n * @public\n */\nexport function group<const Elements extends readonly FormElement[]>(\n label: string,\n ...elements: Elements\n): Group<Elements> {\n return dslGroup(label, ...elements);\n}\n\n/**\n * Creates a conditional wrapper that shows elements based on a predicate.\n *\n * @public\n */\nexport function when<\n const K extends string,\n const V,\n const Elements extends readonly FormElement[],\n>(predicate: Predicate<K, V>, ...elements: Elements): Conditional<K, V, Elements> {\n return dslWhen(predicate, ...elements);\n}\n\n/**\n * Creates an equality predicate that checks if a field equals a specific value.\n *\n * @public\n */\nexport function is<const K extends string, const V>(field: K, value: V): EqualsPredicate<K, V> {\n return dslIs(field, value);\n}\n\n/**\n * Creates a complete form specification.\n *\n * @public\n */\nexport function formspec<const Elements extends readonly FormElement[]>(\n ...elements: Elements\n): FormSpec<Elements> {\n return dslFormspec(...elements);\n}\n\n/**\n * Creates a complete form specification with validation options.\n *\n * @public\n */\nexport function formspecWithValidation<const Elements extends readonly FormElement[]>(\n options: FormSpecOptions,\n ...elements: Elements\n): FormSpec<Elements> {\n return dslFormspecWithValidation(options, ...elements);\n}\n\n/**\n * Infers the value type from a single field.\n *\n * @public\n */\nexport type InferFieldValue<F> =\n F extends TextField<string>\n ? string\n : F extends NumberField<string>\n ? number\n : F extends BooleanField<string>\n ? boolean\n : F extends StaticEnumField<string, infer O extends readonly EnumOptionValue[]>\n ? O extends readonly EnumOption[]\n ? O[number][\"id\"]\n : O extends readonly string[]\n ? O[number]\n : never\n : F extends DynamicEnumField<string, infer Source>\n ? DataSourceValueType<Source>\n : F extends DynamicSchemaField<string>\n ? Record<string, unknown>\n : F extends ArrayField<string, infer Items extends readonly FormElement[]>\n ? InferSchema<Items>[]\n : F extends ObjectField<string, infer Properties extends readonly FormElement[]>\n ? InferSchema<Properties>\n : never;\n\n/**\n * Extracts all fields from a single element.\n *\n * @public\n */\nexport type ExtractFields<E> = E extends AnyField\n ? E\n : E extends Group<infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : never;\n\n/**\n * Extracts fields from an array of elements.\n *\n * @public\n */\nexport type ExtractFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractFields<First> | ExtractFieldsFromArray<Rest>\n : never;\n\n/**\n * Extracts fields that are not inside conditionals.\n *\n * @public\n */\nexport type ExtractNonConditionalFields<E> = E extends AnyField\n ? E\n : E extends Group<infer Elements>\n ? ExtractNonConditionalFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer _Elements>\n ? never\n : never;\n\n/**\n * Extracts non-conditional fields from an array of elements.\n *\n * @public\n */\nexport type ExtractNonConditionalFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractNonConditionalFields<First> | ExtractNonConditionalFieldsFromArray<Rest>\n : never;\n\n/**\n * Extracts fields that are inside conditionals.\n *\n * @public\n */\nexport type ExtractConditionalFields<E> = E extends AnyField\n ? never\n : E extends Group<infer Elements>\n ? ExtractConditionalFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : never;\n\n/**\n * Extracts conditional fields from an array of elements.\n *\n * @public\n */\nexport type ExtractConditionalFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractConditionalFields<First> | ExtractConditionalFieldsFromArray<Rest>\n : never;\n\n/**\n * Builds a schema type from extracted fields.\n *\n * @public\n */\nexport type BuildSchema<Fields> = {\n [N in Fields extends { name: infer K extends string } ? K : never]: InferFieldValue<\n Extract<Fields, { name: N } & AnyField>\n >;\n};\n\n/**\n * Utility type that flattens intersection types.\n *\n * @public\n */\nexport type FlattenIntersection<T> = {\n [K in keyof T]: T[K];\n} & {};\n\n/**\n * Infers the schema type from an array of form elements.\n *\n * @public\n */\nexport type InferSchema<Elements extends readonly FormElement[]> = FlattenIntersection<\n BuildSchema<ExtractNonConditionalFieldsFromArray<Elements>> &\n Partial<BuildSchema<ExtractConditionalFieldsFromArray<Elements>>>\n>;\n\n/**\n * Infers the schema type from a FormSpec.\n *\n * @public\n */\nexport type InferFormSchema<F extends FormSpec<readonly FormElement[]>> =\n F extends FormSpec<infer Elements> ? InferSchema<Elements> : never;\n\n/**\n * Generates a JSON Schema 2020-12 from a FormSpec.\n *\n * @public\n */\nexport function generateJsonSchema<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: GenerateJsonSchemaOptions\n): JsonSchema2020 {\n return generateJsonSchemaInternal(form, options);\n}\n\n/**\n * Generates a UI schema from a FormSpec.\n *\n * @public\n */\nexport function generateUiSchema<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: GenerateUiSchemaOptions\n): UISchema {\n return generateUiSchemaInternal(form, options);\n}\n\n/**\n * Builds both JSON Schema and UI Schema from a FormSpec.\n *\n * @public\n */\nexport function buildFormSchemas<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: BuildFormSchemasOptions\n): BuildResult {\n return buildFormSchemasInternal(form, options);\n}\n\n/**\n * Builds and writes both JSON Schema and UI Schema files to disk.\n *\n * @public\n */\nexport function writeSchemas<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options: WriteSchemasOptions\n): WriteSchemasResult {\n return writeSchemasInternal(form, options);\n}\n\n/**\n * Defines resolvers for a form's dynamic data sources.\n *\n * @public\n */\nexport function defineResolvers<\n E extends readonly FormElement[],\n Sources extends string = ResolverSourcesForForm<E>,\n>(form: FormSpec<E>, resolvers: ResolverMap<Sources>): ResolverRegistry<Sources> {\n return defineResolversInternal(form, resolvers);\n}\n\n/**\n * Validates a list of form elements for duplicate names and structural issues.\n *\n * @public\n */\nexport function validateForm(elements: readonly FormElement[]): ValidationResult {\n return dslVal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E,SAAO,gBAAgB,QAAQ;AACjC;","names":["field"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * FormSpec - Type-safe form specifications\n *\n * This package re-exports everything from the FormSpec library for convenience.\n * You can import everything you need from a single package:\n *\n * @example\n * ```typescript\n * import {\n * // DSL functions\n * formspec, field, group, when, is,\n * // Type inference\n * type InferSchema,\n * // Schema generation\n * buildFormSchemas,\n * // Resolvers\n * defineResolvers,\n * // Core types\n * type FormSpec, type FormElement,\n * } from \"formspec\";\n *\n * // Define a form\n * const InvoiceForm = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.dynamicEnum(\"country\", \"fetch_countries\", { label: \"Country\" }),\n * ),\n * group(\"Details\",\n * field.number(\"amount\", { label: \"Amount\", min: 0 }),\n * field.enum(\"status\", [\"draft\", \"sent\", \"paid\"]),\n * when(is(\"status\", \"draft\"),\n * field.text(\"notes\", { label: \"Internal Notes\" }),\n * ),\n * ),\n * );\n *\n * // Infer the schema type\n * type Schema = InferSchema<typeof InvoiceForm.elements>;\n *\n * // Generate JSON Schema and UI Schema\n * const { jsonSchema, uiSchema } = buildFormSchemas(InvoiceForm);\n *\n * // Define resolvers for dynamic data\n * const resolvers = defineResolvers(InvoiceForm, {\n * fetch_countries: async () => ({\n * options: [{ value: \"us\", label: \"United States\" }],\n * validity: \"valid\",\n * }),\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// =============================================================================\n// Core types\n// =============================================================================\n\nimport type {\n AnyField,\n ArrayField,\n BooleanField,\n Conditional,\n DataSourceValueType,\n DynamicEnumField,\n DynamicSchemaField,\n EnumOption,\n EnumOptionValue,\n EqualsPredicate,\n FormElement,\n FormSpec,\n Group,\n NumberField,\n ObjectField,\n Predicate,\n StaticEnumField,\n TextField,\n} from \"@formspec/core\";\n\nexport type {\n // Validity\n Validity,\n\n // Field state\n FieldState,\n\n // Form state\n FormState,\n\n // Data sources\n DataSourceRegistry,\n DataSourceOption,\n FetchOptionsResponse,\n DataSourceValueType,\n // Elements\n TextField,\n NumberField,\n BooleanField,\n EnumOption,\n EnumOptionValue,\n StaticEnumField,\n DynamicEnumField,\n DynamicSchemaField,\n MetadataPolicyInput,\n MetadataAuthoringSurface,\n MetadataDeclarationKind,\n MetadataInferenceContext,\n MetadataInferenceFn,\n EnumMemberMetadataInferenceContext,\n EnumMemberMetadataInferenceFn,\n MetadataPluralizationContext,\n MetadataPluralizationDisabledPolicyInput,\n MetadataPluralizationFn,\n MetadataPluralizationInferIfMissingPolicyInput,\n MetadataPluralizationPolicyInput,\n MetadataPluralizationRequireExplicitPolicyInput,\n MetadataResolutionMode,\n MetadataSource,\n MetadataValueDisabledPolicyInput,\n MetadataValueInferIfMissingPolicyInput,\n MetadataValuePolicyInput,\n MetadataValueRequireExplicitPolicyInput,\n EnumMemberDisplayNameDisabledPolicyInput,\n EnumMemberDisplayNameRequireExplicitPolicyInput,\n EnumMemberDisplayNameInferIfMissingPolicyInput,\n EnumMemberDisplayNamePolicyInput,\n EnumMemberMetadataPolicyInput,\n ResolvedMetadata,\n ResolvedScalarMetadata,\n ArrayField,\n ObjectField,\n AnyField,\n Group,\n Conditional,\n DeclarationMetadataPolicyInput,\n FormElement,\n FormSpec,\n // Predicates\n EqualsPredicate,\n Predicate,\n} from \"@formspec/core\";\n\nexport { createInitialFieldState } from \"@formspec/core\";\n\n// Type guards\nexport {\n isField,\n isTextField,\n isNumberField,\n isBooleanField,\n isStaticEnumField,\n isDynamicEnumField,\n isDynamicSchemaField,\n isArrayField,\n isObjectField,\n isGroup,\n isConditional,\n} from \"@formspec/core\";\n\n// =============================================================================\n// DSL functions\n// =============================================================================\n\nexport { logValidationIssues } from \"@formspec/dsl\";\nimport {\n field as dslField,\n group as dslGroup,\n when as dslWhen,\n is as dslIs,\n formspec as dslFormspec,\n formspecWithValidation as dslFormspecWithValidation,\n validateForm as dslValidateForm,\n type FormSpecOptions,\n} from \"@formspec/dsl\";\nexport type {\n // Validation\n FormSpecOptions,\n ValidationSeverity,\n ValidationIssue,\n ValidationResult,\n} from \"@formspec/dsl\";\nimport type { ValidationResult } from \"@formspec/dsl\";\n\n/**\n * Field builder helpers re-exported by the top-level `formspec` package.\n *\n * @public\n */\nexport interface FormSpecFieldBuilder {\n /** Creates a text field. */\n text<const N extends string>(\n name: N,\n config?: Omit<TextField<N>, \"_type\" | \"_field\" | \"name\">\n ): TextField<N>;\n /** Creates a number field. */\n number<const N extends string>(\n name: N,\n config?: Omit<NumberField<N>, \"_type\" | \"_field\" | \"name\">\n ): NumberField<N>;\n /** Creates a boolean field. */\n boolean<const N extends string>(\n name: N,\n config?: Omit<BooleanField<N>, \"_type\" | \"_field\" | \"name\">\n ): BooleanField<N>;\n /** Creates a static enum field from a fixed options list. */\n enum<const N extends string, const O extends readonly EnumOptionValue[]>(\n name: N,\n options: O,\n config?: Omit<StaticEnumField<N, O>, \"_type\" | \"_field\" | \"name\" | \"options\">\n ): StaticEnumField<N, O>;\n /** Creates a dynamic enum field backed by an external option source. */\n dynamicEnum<const N extends string, const Source extends string>(\n name: N,\n source: Source,\n config?: Omit<DynamicEnumField<N, Source>, \"_type\" | \"_field\" | \"name\" | \"source\">\n ): DynamicEnumField<N, Source>;\n /** Creates a field whose schema is resolved from an external source at runtime. */\n dynamicSchema<const N extends string>(\n name: N,\n schemaSource: string,\n config?: Omit<DynamicSchemaField<N>, \"_type\" | \"_field\" | \"name\" | \"schemaSource\">\n ): DynamicSchemaField<N>;\n /** Creates an array field from a list of item elements. */\n array<const N extends string, const Items extends readonly FormElement[]>(\n name: N,\n ...items: Items\n ): ArrayField<N, Items>;\n /** Creates an array field with explicit configuration and item elements. */\n arrayWithConfig<const N extends string, const Items extends readonly FormElement[]>(\n name: N,\n config: Omit<ArrayField<N, Items>, \"_type\" | \"_field\" | \"name\" | \"items\">,\n ...items: Items\n ): ArrayField<N, Items>;\n /** Creates an object field from a list of property elements. */\n object<const N extends string, const Properties extends readonly FormElement[]>(\n name: N,\n ...properties: Properties\n ): ObjectField<N, Properties>;\n /** Creates an object field with explicit configuration and property elements. */\n objectWithConfig<const N extends string, const Properties extends readonly FormElement[]>(\n name: N,\n config: Omit<ObjectField<N, Properties>, \"_type\" | \"_field\" | \"name\" | \"properties\">,\n ...properties: Properties\n ): ObjectField<N, Properties>;\n}\n\n/**\n * Field builder helpers that preserve this package's exported type identities.\n *\n * @public\n */\nexport const field = dslField as unknown as FormSpecFieldBuilder;\n\n// =============================================================================\n// Build tools\n// =============================================================================\n\nimport {\n buildFormSchemas as buildFormSchemasInternal,\n generateJsonSchema as generateJsonSchemaInternal,\n generateUiSchema as generateUiSchemaInternal,\n writeSchemas as writeSchemasInternal,\n type BuildFormSchemasOptions,\n type BuildResult,\n type GenerateJsonSchemaOptions,\n type GenerateUiSchemaOptions,\n type JsonSchema2020,\n type UISchema,\n type WriteSchemasOptions,\n type WriteSchemasResult,\n} from \"@formspec/build\";\n\nexport type {\n BuildFormSchemasOptions,\n GenerateJsonSchemaOptions,\n GenerateUiSchemaOptions,\n JsonSchema2020,\n UISchema,\n UISchemaElement,\n ControlElement,\n VerticalLayout,\n HorizontalLayout,\n GroupLayout,\n Categorization,\n Category,\n LabelElement,\n Rule,\n RuleEffect,\n RuleConditionSchema,\n SchemaBasedCondition,\n BuildResult,\n WriteSchemasOptions,\n WriteSchemasResult,\n} from \"@formspec/build\";\n\n// =============================================================================\n// Runtime helpers\n// =============================================================================\n\nimport {\n defineResolvers as defineResolversInternal,\n type ResolverMap,\n type ResolverRegistry,\n type ResolverSourcesForForm,\n} from \"@formspec/runtime\";\n\nexport type {\n ExtractDynamicSources,\n ExtractDynamicSourcesFromArray,\n Resolver,\n ResolverMap,\n ResolverRegistry,\n ResolverSourcesForForm,\n} from \"@formspec/runtime\";\n\n// =============================================================================\n// Local DSL wrappers and inference helpers\n// =============================================================================\n\n/**\n * Creates a visual group of form elements.\n *\n * @public\n */\nexport function group<const Elements extends readonly FormElement[]>(\n label: string,\n ...elements: Elements\n): Group<Elements> {\n return dslGroup(label, ...elements);\n}\n\n/**\n * Creates a conditional wrapper that shows elements based on a predicate.\n *\n * @public\n */\nexport function when<\n const K extends string,\n const V,\n const Elements extends readonly FormElement[],\n>(predicate: Predicate<K, V>, ...elements: Elements): Conditional<K, V, Elements> {\n return dslWhen(predicate, ...elements);\n}\n\n/**\n * Creates an equality predicate that checks if a field equals a specific value.\n *\n * @public\n */\nexport function is<const K extends string, const V>(field: K, value: V): EqualsPredicate<K, V> {\n return dslIs(field, value);\n}\n\n/**\n * Creates a complete form specification.\n *\n * @public\n */\nexport function formspec<const Elements extends readonly FormElement[]>(\n ...elements: Elements\n): FormSpec<Elements> {\n return dslFormspec(...elements);\n}\n\n/**\n * Creates a complete form specification with validation options.\n *\n * @public\n */\nexport function formspecWithValidation<const Elements extends readonly FormElement[]>(\n options: FormSpecOptions,\n ...elements: Elements\n): FormSpec<Elements> {\n return dslFormspecWithValidation(options, ...elements);\n}\n\n/**\n * Infers the value type from a single field.\n *\n * @public\n */\nexport type InferFieldValue<F> =\n F extends TextField<string>\n ? string\n : F extends NumberField<string>\n ? number\n : F extends BooleanField<string>\n ? boolean\n : F extends StaticEnumField<string, infer O extends readonly EnumOptionValue[]>\n ? O extends readonly EnumOption[]\n ? O[number][\"id\"]\n : O extends readonly string[]\n ? O[number]\n : never\n : F extends DynamicEnumField<string, infer Source>\n ? DataSourceValueType<Source>\n : F extends DynamicSchemaField<string>\n ? Record<string, unknown>\n : F extends ArrayField<string, infer Items extends readonly FormElement[]>\n ? InferSchema<Items>[]\n : F extends ObjectField<string, infer Properties extends readonly FormElement[]>\n ? InferSchema<Properties>\n : never;\n\n/**\n * Extracts all fields from a single element.\n *\n * @public\n */\nexport type ExtractFields<E> = E extends AnyField\n ? E\n : E extends Group<infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : never;\n\n/**\n * Extracts fields from an array of elements.\n *\n * @public\n */\nexport type ExtractFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractFields<First> | ExtractFieldsFromArray<Rest>\n : never;\n\n/**\n * Extracts fields that are not inside conditionals.\n *\n * @public\n */\nexport type ExtractNonConditionalFields<E> = E extends AnyField\n ? E\n : E extends Group<infer Elements>\n ? ExtractNonConditionalFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer _Elements>\n ? never\n : never;\n\n/**\n * Extracts non-conditional fields from an array of elements.\n *\n * @public\n */\nexport type ExtractNonConditionalFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractNonConditionalFields<First> | ExtractNonConditionalFieldsFromArray<Rest>\n : never;\n\n/**\n * Extracts fields that are inside conditionals.\n *\n * @public\n */\nexport type ExtractConditionalFields<E> = E extends AnyField\n ? never\n : E extends Group<infer Elements>\n ? ExtractConditionalFieldsFromArray<Elements>\n : E extends Conditional<string, unknown, infer Elements>\n ? ExtractFieldsFromArray<Elements>\n : never;\n\n/**\n * Extracts conditional fields from an array of elements.\n *\n * @public\n */\nexport type ExtractConditionalFieldsFromArray<Elements> = Elements extends readonly [\n infer First,\n ...infer Rest,\n]\n ? ExtractConditionalFields<First> | ExtractConditionalFieldsFromArray<Rest>\n : never;\n\n/**\n * Builds a schema type from extracted fields.\n *\n * @public\n */\nexport type BuildSchema<Fields> = {\n [N in Fields extends { name: infer K extends string } ? K : never]: InferFieldValue<\n Extract<Fields, { name: N } & AnyField>\n >;\n};\n\n/**\n * Utility type that flattens intersection types.\n *\n * @public\n */\nexport type FlattenIntersection<T> = {\n [K in keyof T]: T[K];\n} & {};\n\n/**\n * Infers the schema type from an array of form elements.\n *\n * @public\n */\nexport type InferSchema<Elements extends readonly FormElement[]> = FlattenIntersection<\n BuildSchema<ExtractNonConditionalFieldsFromArray<Elements>> &\n Partial<BuildSchema<ExtractConditionalFieldsFromArray<Elements>>>\n>;\n\n/**\n * Infers the schema type from a FormSpec.\n *\n * @public\n */\nexport type InferFormSchema<F extends FormSpec<readonly FormElement[]>> =\n F extends FormSpec<infer Elements> ? InferSchema<Elements> : never;\n\n/**\n * Generates a JSON Schema 2020-12 from a FormSpec.\n *\n * @public\n */\nexport function generateJsonSchema<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: GenerateJsonSchemaOptions\n): JsonSchema2020 {\n return generateJsonSchemaInternal(form, options);\n}\n\n/**\n * Generates a UI schema from a FormSpec.\n *\n * @public\n */\nexport function generateUiSchema<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: GenerateUiSchemaOptions\n): UISchema {\n return generateUiSchemaInternal(form, options);\n}\n\n/**\n * Builds both JSON Schema and UI Schema from a FormSpec.\n *\n * @public\n */\nexport function buildFormSchemas<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options?: BuildFormSchemasOptions\n): BuildResult {\n return buildFormSchemasInternal(form, options);\n}\n\n/**\n * Builds and writes both JSON Schema and UI Schema files to disk.\n *\n * @public\n */\nexport function writeSchemas<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options: WriteSchemasOptions\n): WriteSchemasResult {\n return writeSchemasInternal(form, options);\n}\n\n/**\n * Defines resolvers for a form's dynamic data sources.\n *\n * @public\n */\nexport function defineResolvers<\n E extends readonly FormElement[],\n Sources extends string = ResolverSourcesForForm<E>,\n>(form: FormSpec<E>, resolvers: ResolverMap<Sources>): ResolverRegistry<Sources> {\n return defineResolversInternal(form, resolvers);\n}\n\n/**\n * Validates a list of form elements for duplicate names and structural issues.\n *\n * @public\n */\nexport function validateForm(elements: readonly FormElement[]): ValidationResult {\n return dslValidateForm(elements);\n}\n"],"mappings":";AA8IA,SAAS,+BAA+B;AAGxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,SAAS,2BAA2B;AACpC;AAAA,EACE,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,0BAA0B;AAAA,EAC1B,gBAAgB;AAAA,OAEX;AAoFP;AAAA,EACE,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,OASX;AA6BP;AAAA,EACE,mBAAmB;AAAA,OAId;AArDA,IAAM,QAAQ;AAyEd,SAAS,MACd,UACG,UACc;AACjB,SAAO,SAAS,OAAO,GAAG,QAAQ;AACpC;AAOO,SAAS,KAId,cAA+B,UAAiD;AAChF,SAAO,QAAQ,WAAW,GAAG,QAAQ;AACvC;AAOO,SAAS,GAAoCA,QAAU,OAAiC;AAC7F,SAAO,MAAMA,QAAO,KAAK;AAC3B;AAOO,SAAS,YACX,UACiB;AACpB,SAAO,YAAY,GAAG,QAAQ;AAChC;AAOO,SAAS,uBACd,YACG,UACiB;AACpB,SAAO,0BAA0B,SAAS,GAAG,QAAQ;AACvD;AAoJO,SAAS,mBACd,MACA,SACgB;AAChB,SAAO,2BAA2B,MAAM,OAAO;AACjD;AAOO,SAAS,iBACd,MACA,SACU;AACV,SAAO,yBAAyB,MAAM,OAAO;AAC/C;AAOO,SAAS,iBACd,MACA,SACa;AACb,SAAO,yBAAyB,MAAM,OAAO;AAC/C;AAOO,SAAS,aACd,MACA,SACoB;AACpB,SAAO,qBAAqB,MAAM,OAAO;AAC3C;AAOO,SAAS,gBAGd,MAAmB,WAA4D;AAC/E,SAAO,wBAAwB,MAAM,SAAS;AAChD;AAOO,SAAS,aAAa,UAAoD;AAC/E,SAAO,gBAAgB,QAAQ;AACjC;","names":["field"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formspec",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.42",
|
|
4
4
|
"description": "Type-safe form specifications that compile to JSON Schema and JSON Forms UI Schema",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@formspec/core": "0.1.0-alpha.
|
|
23
|
-
"@formspec/
|
|
24
|
-
"@formspec/
|
|
25
|
-
"@formspec/
|
|
22
|
+
"@formspec/core": "0.1.0-alpha.42",
|
|
23
|
+
"@formspec/dsl": "0.1.0-alpha.42",
|
|
24
|
+
"@formspec/build": "0.1.0-alpha.42",
|
|
25
|
+
"@formspec/runtime": "0.1.0-alpha.42"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|