@formspec/build 0.1.0-alpha.54 → 0.1.0-alpha.57

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.
@@ -469,46 +469,6 @@ declare interface CustomTypeRegistration_2 {
469
469
  * Note: `"__integerBrand"` is reserved for the builtin Integer type.
470
470
  */
471
471
  readonly brand?: string;
472
- /**
473
- * Optional callback to extract a payload from the TypeScript type at
474
- * analysis time. The returned value is stored on the custom type node
475
- * and later passed to `toJsonSchema`.
476
- *
477
- * Use this to carry type-level information (e.g., a generic argument's
478
- * resolved literal value) through the IR into schema generation.
479
- *
480
- * **Parameters:** typed as `unknown` because `@formspec/core` does not
481
- * depend on the TypeScript compiler API. Implementations should cast to
482
- * `ts.Type` and `ts.TypeChecker`. Both parameters originate from the
483
- * host program's type checker — extensions may rely on host-program
484
- * symbol identity.
485
- *
486
- * **Contract:**
487
- * - Must be a pure function of `(type, checker)` — no I/O or shared state.
488
- * - May be invoked multiple times for the same type (no memoization is provided).
489
- * - Must return a JSON-serializable `ExtensionPayloadValue`. Returning live
490
- * compiler objects (e.g., `ts.Type`) will corrupt any IR caching.
491
- * - Errors thrown by the callback are attributed to the extension and
492
- * reported as build diagnostics.
493
- * - Returning `undefined` is coerced to `null` at the call site.
494
- *
495
- * @param type - The resolved TypeScript type (cast to `ts.Type`).
496
- * @param checker - The TypeScript type checker (cast to `ts.TypeChecker`).
497
- * @returns A JSON-serializable payload, or `null` if no payload can be extracted.
498
- *
499
- * @example
500
- * ```typescript
501
- * extractPayload: (type: unknown, checker: unknown) => {
502
- * const tsType = type as ts.Type;
503
- * const tsChecker = checker as ts.TypeChecker;
504
- * const prop = tsType.getProperty('target');
505
- * if (!prop) return null;
506
- * const propType = tsChecker.getTypeOfSymbol(prop);
507
- * return propType.isStringLiteral() ? propType.value : null;
508
- * }
509
- * ```
510
- */
511
- readonly extractPayload?: (type: unknown, checker: unknown) => ExtensionPayloadValue;
512
472
  /**
513
473
  * Converts the custom type's payload into a JSON Schema fragment.
514
474
  *
@@ -945,11 +905,12 @@ export declare interface FormSpecConfig {
945
905
  readonly vendorPrefix?: string;
946
906
  /**
947
907
  * JSON Schema representation for static enums.
948
- * - "enum": flat { "enum": ["a", "b"] }
949
- * - "oneOf": { "oneOf": [{ "const": "a" }, ...] }
908
+ * - "enum": compact `enum` output, plus a display-name extension when labels exist
909
+ * - "oneOf": per-member `const` output, with `title` only for distinct labels
910
+ * - "smart-size": uses `enum` unless a distinct display label would be lost
950
911
  * @defaultValue "enum"
951
912
  */
952
- readonly enumSerialization?: "enum" | "oneOf";
913
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
953
914
  /**
954
915
  * Per-package configuration overrides for monorepos.
955
916
  * Keys are glob patterns matched against file paths relative to
@@ -968,7 +929,7 @@ declare interface FormSpecPackageOverride {
968
929
  /** Override constraint surface for this package. */
969
930
  readonly constraints?: ConstraintConfig;
970
931
  /** Override enum serialization for this package. */
971
- readonly enumSerialization?: "enum" | "oneOf";
932
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
972
933
  /** Override metadata policy for this package. */
973
934
  readonly metadata?: MetadataPolicyInput_2;
974
935
  }
@@ -1051,7 +1012,7 @@ export declare interface GenerateJsonSchemaOptions {
1051
1012
  * JSON Schema representation to use for static enums.
1052
1013
  * @defaultValue "enum"
1053
1014
  */
1054
- readonly enumSerialization?: "enum" | "oneOf";
1015
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
1055
1016
  /** Metadata resolution policy for chain DSL generation. */
1056
1017
  readonly metadata?: MetadataPolicyInput | undefined;
1057
1018
  /**
@@ -2213,7 +2174,7 @@ export declare interface StaticSchemaGenerationOptions {
2213
2174
  * @defaultValue "enum"
2214
2175
  * @deprecated Provide a `FormSpecConfig` via the `config` option instead.
2215
2176
  */
2216
- readonly enumSerialization?: "enum" | "oneOf";
2177
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
2217
2178
  /**
2218
2179
  * Metadata resolution policy for static schema generation.
2219
2180
  * @deprecated Provide a `FormSpecConfig` via the `config` option instead.
@@ -469,46 +469,6 @@ declare interface CustomTypeRegistration_2 {
469
469
  * Note: `"__integerBrand"` is reserved for the builtin Integer type.
470
470
  */
471
471
  readonly brand?: string;
472
- /**
473
- * Optional callback to extract a payload from the TypeScript type at
474
- * analysis time. The returned value is stored on the custom type node
475
- * and later passed to `toJsonSchema`.
476
- *
477
- * Use this to carry type-level information (e.g., a generic argument's
478
- * resolved literal value) through the IR into schema generation.
479
- *
480
- * **Parameters:** typed as `unknown` because `@formspec/core` does not
481
- * depend on the TypeScript compiler API. Implementations should cast to
482
- * `ts.Type` and `ts.TypeChecker`. Both parameters originate from the
483
- * host program's type checker — extensions may rely on host-program
484
- * symbol identity.
485
- *
486
- * **Contract:**
487
- * - Must be a pure function of `(type, checker)` — no I/O or shared state.
488
- * - May be invoked multiple times for the same type (no memoization is provided).
489
- * - Must return a JSON-serializable `ExtensionPayloadValue`. Returning live
490
- * compiler objects (e.g., `ts.Type`) will corrupt any IR caching.
491
- * - Errors thrown by the callback are attributed to the extension and
492
- * reported as build diagnostics.
493
- * - Returning `undefined` is coerced to `null` at the call site.
494
- *
495
- * @param type - The resolved TypeScript type (cast to `ts.Type`).
496
- * @param checker - The TypeScript type checker (cast to `ts.TypeChecker`).
497
- * @returns A JSON-serializable payload, or `null` if no payload can be extracted.
498
- *
499
- * @example
500
- * ```typescript
501
- * extractPayload: (type: unknown, checker: unknown) => {
502
- * const tsType = type as ts.Type;
503
- * const tsChecker = checker as ts.TypeChecker;
504
- * const prop = tsType.getProperty('target');
505
- * if (!prop) return null;
506
- * const propType = tsChecker.getTypeOfSymbol(prop);
507
- * return propType.isStringLiteral() ? propType.value : null;
508
- * }
509
- * ```
510
- */
511
- readonly extractPayload?: (type: unknown, checker: unknown) => ExtensionPayloadValue;
512
472
  /**
513
473
  * Converts the custom type's payload into a JSON Schema fragment.
514
474
  *
@@ -945,11 +905,12 @@ export declare interface FormSpecConfig {
945
905
  readonly vendorPrefix?: string;
946
906
  /**
947
907
  * JSON Schema representation for static enums.
948
- * - "enum": flat { "enum": ["a", "b"] }
949
- * - "oneOf": { "oneOf": [{ "const": "a" }, ...] }
908
+ * - "enum": compact `enum` output, plus a display-name extension when labels exist
909
+ * - "oneOf": per-member `const` output, with `title` only for distinct labels
910
+ * - "smart-size": uses `enum` unless a distinct display label would be lost
950
911
  * @defaultValue "enum"
951
912
  */
952
- readonly enumSerialization?: "enum" | "oneOf";
913
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
953
914
  /**
954
915
  * Per-package configuration overrides for monorepos.
955
916
  * Keys are glob patterns matched against file paths relative to
@@ -968,7 +929,7 @@ declare interface FormSpecPackageOverride {
968
929
  /** Override constraint surface for this package. */
969
930
  readonly constraints?: ConstraintConfig;
970
931
  /** Override enum serialization for this package. */
971
- readonly enumSerialization?: "enum" | "oneOf";
932
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
972
933
  /** Override metadata policy for this package. */
973
934
  readonly metadata?: MetadataPolicyInput_2;
974
935
  }
@@ -1051,7 +1012,7 @@ export declare interface GenerateJsonSchemaOptions {
1051
1012
  * JSON Schema representation to use for static enums.
1052
1013
  * @defaultValue "enum"
1053
1014
  */
1054
- readonly enumSerialization?: "enum" | "oneOf";
1015
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
1055
1016
  /** Metadata resolution policy for chain DSL generation. */
1056
1017
  readonly metadata?: MetadataPolicyInput | undefined;
1057
1018
  /**
@@ -2213,7 +2174,7 @@ export declare interface StaticSchemaGenerationOptions {
2213
2174
  * @defaultValue "enum"
2214
2175
  * @deprecated Provide a `FormSpecConfig` via the `config` option instead.
2215
2176
  */
2216
- readonly enumSerialization?: "enum" | "oneOf";
2177
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
2217
2178
  /**
2218
2179
  * Metadata resolution policy for static schema generation.
2219
2180
  * @deprecated Provide a `FormSpecConfig` via the `config` option instead.
@@ -469,46 +469,6 @@ declare interface CustomTypeRegistration_2 {
469
469
  * Note: `"__integerBrand"` is reserved for the builtin Integer type.
470
470
  */
471
471
  readonly brand?: string;
472
- /**
473
- * Optional callback to extract a payload from the TypeScript type at
474
- * analysis time. The returned value is stored on the custom type node
475
- * and later passed to `toJsonSchema`.
476
- *
477
- * Use this to carry type-level information (e.g., a generic argument's
478
- * resolved literal value) through the IR into schema generation.
479
- *
480
- * **Parameters:** typed as `unknown` because `@formspec/core` does not
481
- * depend on the TypeScript compiler API. Implementations should cast to
482
- * `ts.Type` and `ts.TypeChecker`. Both parameters originate from the
483
- * host program's type checker — extensions may rely on host-program
484
- * symbol identity.
485
- *
486
- * **Contract:**
487
- * - Must be a pure function of `(type, checker)` — no I/O or shared state.
488
- * - May be invoked multiple times for the same type (no memoization is provided).
489
- * - Must return a JSON-serializable `ExtensionPayloadValue`. Returning live
490
- * compiler objects (e.g., `ts.Type`) will corrupt any IR caching.
491
- * - Errors thrown by the callback are attributed to the extension and
492
- * reported as build diagnostics.
493
- * - Returning `undefined` is coerced to `null` at the call site.
494
- *
495
- * @param type - The resolved TypeScript type (cast to `ts.Type`).
496
- * @param checker - The TypeScript type checker (cast to `ts.TypeChecker`).
497
- * @returns A JSON-serializable payload, or `null` if no payload can be extracted.
498
- *
499
- * @example
500
- * ```typescript
501
- * extractPayload: (type: unknown, checker: unknown) => {
502
- * const tsType = type as ts.Type;
503
- * const tsChecker = checker as ts.TypeChecker;
504
- * const prop = tsType.getProperty('target');
505
- * if (!prop) return null;
506
- * const propType = tsChecker.getTypeOfSymbol(prop);
507
- * return propType.isStringLiteral() ? propType.value : null;
508
- * }
509
- * ```
510
- */
511
- readonly extractPayload?: (type: unknown, checker: unknown) => ExtensionPayloadValue;
512
472
  /**
513
473
  * Converts the custom type's payload into a JSON Schema fragment.
514
474
  *
@@ -945,11 +905,12 @@ export declare interface FormSpecConfig {
945
905
  readonly vendorPrefix?: string;
946
906
  /**
947
907
  * JSON Schema representation for static enums.
948
- * - "enum": flat { "enum": ["a", "b"] }
949
- * - "oneOf": { "oneOf": [{ "const": "a" }, ...] }
908
+ * - "enum": compact `enum` output, plus a display-name extension when labels exist
909
+ * - "oneOf": per-member `const` output, with `title` only for distinct labels
910
+ * - "smart-size": uses `enum` unless a distinct display label would be lost
950
911
  * @defaultValue "enum"
951
912
  */
952
- readonly enumSerialization?: "enum" | "oneOf";
913
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
953
914
  /**
954
915
  * Per-package configuration overrides for monorepos.
955
916
  * Keys are glob patterns matched against file paths relative to
@@ -968,7 +929,7 @@ declare interface FormSpecPackageOverride {
968
929
  /** Override constraint surface for this package. */
969
930
  readonly constraints?: ConstraintConfig;
970
931
  /** Override enum serialization for this package. */
971
- readonly enumSerialization?: "enum" | "oneOf";
932
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
972
933
  /** Override metadata policy for this package. */
973
934
  readonly metadata?: MetadataPolicyInput_2;
974
935
  }
@@ -1051,7 +1012,7 @@ export declare interface GenerateJsonSchemaOptions {
1051
1012
  * JSON Schema representation to use for static enums.
1052
1013
  * @defaultValue "enum"
1053
1014
  */
1054
- readonly enumSerialization?: "enum" | "oneOf";
1015
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
1055
1016
  /** Metadata resolution policy for chain DSL generation. */
1056
1017
  readonly metadata?: MetadataPolicyInput | undefined;
1057
1018
  /**
@@ -2213,7 +2174,7 @@ export declare interface StaticSchemaGenerationOptions {
2213
2174
  * @defaultValue "enum"
2214
2175
  * @deprecated Provide a `FormSpecConfig` via the `config` option instead.
2215
2176
  */
2216
- readonly enumSerialization?: "enum" | "oneOf";
2177
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
2217
2178
  /**
2218
2179
  * Metadata resolution policy for static schema generation.
2219
2180
  * @deprecated Provide a `FormSpecConfig` via the `config` option instead.
package/dist/build.d.ts CHANGED
@@ -469,46 +469,6 @@ declare interface CustomTypeRegistration_2 {
469
469
  * Note: `"__integerBrand"` is reserved for the builtin Integer type.
470
470
  */
471
471
  readonly brand?: string;
472
- /**
473
- * Optional callback to extract a payload from the TypeScript type at
474
- * analysis time. The returned value is stored on the custom type node
475
- * and later passed to `toJsonSchema`.
476
- *
477
- * Use this to carry type-level information (e.g., a generic argument's
478
- * resolved literal value) through the IR into schema generation.
479
- *
480
- * **Parameters:** typed as `unknown` because `@formspec/core` does not
481
- * depend on the TypeScript compiler API. Implementations should cast to
482
- * `ts.Type` and `ts.TypeChecker`. Both parameters originate from the
483
- * host program's type checker — extensions may rely on host-program
484
- * symbol identity.
485
- *
486
- * **Contract:**
487
- * - Must be a pure function of `(type, checker)` — no I/O or shared state.
488
- * - May be invoked multiple times for the same type (no memoization is provided).
489
- * - Must return a JSON-serializable `ExtensionPayloadValue`. Returning live
490
- * compiler objects (e.g., `ts.Type`) will corrupt any IR caching.
491
- * - Errors thrown by the callback are attributed to the extension and
492
- * reported as build diagnostics.
493
- * - Returning `undefined` is coerced to `null` at the call site.
494
- *
495
- * @param type - The resolved TypeScript type (cast to `ts.Type`).
496
- * @param checker - The TypeScript type checker (cast to `ts.TypeChecker`).
497
- * @returns A JSON-serializable payload, or `null` if no payload can be extracted.
498
- *
499
- * @example
500
- * ```typescript
501
- * extractPayload: (type: unknown, checker: unknown) => {
502
- * const tsType = type as ts.Type;
503
- * const tsChecker = checker as ts.TypeChecker;
504
- * const prop = tsType.getProperty('target');
505
- * if (!prop) return null;
506
- * const propType = tsChecker.getTypeOfSymbol(prop);
507
- * return propType.isStringLiteral() ? propType.value : null;
508
- * }
509
- * ```
510
- */
511
- readonly extractPayload?: (type: unknown, checker: unknown) => ExtensionPayloadValue;
512
472
  /**
513
473
  * Converts the custom type's payload into a JSON Schema fragment.
514
474
  *
@@ -945,11 +905,12 @@ export declare interface FormSpecConfig {
945
905
  readonly vendorPrefix?: string;
946
906
  /**
947
907
  * JSON Schema representation for static enums.
948
- * - "enum": flat { "enum": ["a", "b"] }
949
- * - "oneOf": { "oneOf": [{ "const": "a" }, ...] }
908
+ * - "enum": compact `enum` output, plus a display-name extension when labels exist
909
+ * - "oneOf": per-member `const` output, with `title` only for distinct labels
910
+ * - "smart-size": uses `enum` unless a distinct display label would be lost
950
911
  * @defaultValue "enum"
951
912
  */
952
- readonly enumSerialization?: "enum" | "oneOf";
913
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
953
914
  /**
954
915
  * Per-package configuration overrides for monorepos.
955
916
  * Keys are glob patterns matched against file paths relative to
@@ -968,7 +929,7 @@ declare interface FormSpecPackageOverride {
968
929
  /** Override constraint surface for this package. */
969
930
  readonly constraints?: ConstraintConfig;
970
931
  /** Override enum serialization for this package. */
971
- readonly enumSerialization?: "enum" | "oneOf";
932
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
972
933
  /** Override metadata policy for this package. */
973
934
  readonly metadata?: MetadataPolicyInput_2;
974
935
  }
@@ -1051,7 +1012,7 @@ export declare interface GenerateJsonSchemaOptions {
1051
1012
  * JSON Schema representation to use for static enums.
1052
1013
  * @defaultValue "enum"
1053
1014
  */
1054
- readonly enumSerialization?: "enum" | "oneOf";
1015
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
1055
1016
  /** Metadata resolution policy for chain DSL generation. */
1056
1017
  readonly metadata?: MetadataPolicyInput | undefined;
1057
1018
  /**
@@ -2213,7 +2174,7 @@ export declare interface StaticSchemaGenerationOptions {
2213
2174
  * @defaultValue "enum"
2214
2175
  * @deprecated Provide a `FormSpecConfig` via the `config` option instead.
2215
2176
  */
2216
- readonly enumSerialization?: "enum" | "oneOf";
2177
+ readonly enumSerialization?: "enum" | "oneOf" | "smart-size";
2217
2178
  /**
2218
2179
  * Metadata resolution policy for static schema generation.
2219
2180
  * @deprecated Provide a `FormSpecConfig` via the `config` option instead.