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

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.
@@ -40,6 +40,7 @@ import { ExtensionDefinition } from '@formspec/core';
40
40
  import { FormElement } from '@formspec/core';
41
41
  import { FormSpec } from '@formspec/core';
42
42
  import { Group } from '@formspec/core';
43
+ import type { LoggerLike } from '@formspec/core';
43
44
  import type { MetadataPolicyInput } from '@formspec/core';
44
45
  import { NumberField } from '@formspec/core';
45
46
  import { ObjectField } from '@formspec/core';
@@ -95,6 +96,11 @@ export declare function buildFormSchemas<E extends readonly FormElement[]>(form:
95
96
  * @public
96
97
  */
97
98
  export declare interface BuildFormSchemasOptions extends GenerateJsonSchemaOptions, GenerateUiSchemaOptions {
99
+ /**
100
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
101
+ * existing callers produce no output.
102
+ */
103
+ readonly logger?: LoggerLike | undefined;
98
104
  }
99
105
 
100
106
  /**
@@ -463,6 +469,46 @@ declare interface CustomTypeRegistration_2 {
463
469
  * Note: `"__integerBrand"` is reserved for the builtin Integer type.
464
470
  */
465
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;
466
512
  /**
467
513
  * Converts the custom type's payload into a JSON Schema fragment.
468
514
  *
@@ -1008,6 +1054,11 @@ export declare interface GenerateJsonSchemaOptions {
1008
1054
  readonly enumSerialization?: "enum" | "oneOf";
1009
1055
  /** Metadata resolution policy for chain DSL generation. */
1010
1056
  readonly metadata?: MetadataPolicyInput | undefined;
1057
+ /**
1058
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
1059
+ * existing callers produce no output.
1060
+ */
1061
+ readonly logger?: LoggerLike | undefined;
1011
1062
  }
1012
1063
 
1013
1064
  /**
@@ -1390,6 +1441,11 @@ export declare function generateUiSchema<E extends readonly FormElement[]>(form:
1390
1441
  export declare interface GenerateUiSchemaOptions {
1391
1442
  /** Metadata resolution policy for chain DSL UI generation. */
1392
1443
  readonly metadata?: MetadataPolicyInput | undefined;
1444
+ /**
1445
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
1446
+ * existing callers produce no output.
1447
+ */
1448
+ readonly logger?: LoggerLike | undefined;
1393
1449
  }
1394
1450
 
1395
1451
  export { Group }
@@ -2391,6 +2447,11 @@ export declare interface WriteSchemasOptions extends GenerateJsonSchemaOptions {
2391
2447
  readonly name?: string;
2392
2448
  /** Number of spaces for JSON indentation. Defaults to 2 */
2393
2449
  readonly indent?: number;
2450
+ /**
2451
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
2452
+ * existing callers produce no output.
2453
+ */
2454
+ readonly logger?: LoggerLike | undefined;
2394
2455
  }
2395
2456
 
2396
2457
  /**
@@ -40,6 +40,7 @@ import { ExtensionDefinition } from '@formspec/core';
40
40
  import { FormElement } from '@formspec/core';
41
41
  import { FormSpec } from '@formspec/core';
42
42
  import { Group } from '@formspec/core';
43
+ import type { LoggerLike } from '@formspec/core';
43
44
  import type { MetadataPolicyInput } from '@formspec/core';
44
45
  import { NumberField } from '@formspec/core';
45
46
  import { ObjectField } from '@formspec/core';
@@ -95,6 +96,11 @@ export declare function buildFormSchemas<E extends readonly FormElement[]>(form:
95
96
  * @public
96
97
  */
97
98
  export declare interface BuildFormSchemasOptions extends GenerateJsonSchemaOptions, GenerateUiSchemaOptions {
99
+ /**
100
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
101
+ * existing callers produce no output.
102
+ */
103
+ readonly logger?: LoggerLike | undefined;
98
104
  }
99
105
 
100
106
  /**
@@ -463,6 +469,46 @@ declare interface CustomTypeRegistration_2 {
463
469
  * Note: `"__integerBrand"` is reserved for the builtin Integer type.
464
470
  */
465
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;
466
512
  /**
467
513
  * Converts the custom type's payload into a JSON Schema fragment.
468
514
  *
@@ -1008,6 +1054,11 @@ export declare interface GenerateJsonSchemaOptions {
1008
1054
  readonly enumSerialization?: "enum" | "oneOf";
1009
1055
  /** Metadata resolution policy for chain DSL generation. */
1010
1056
  readonly metadata?: MetadataPolicyInput | undefined;
1057
+ /**
1058
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
1059
+ * existing callers produce no output.
1060
+ */
1061
+ readonly logger?: LoggerLike | undefined;
1011
1062
  }
1012
1063
 
1013
1064
  /**
@@ -1390,6 +1441,11 @@ export declare function generateUiSchema<E extends readonly FormElement[]>(form:
1390
1441
  export declare interface GenerateUiSchemaOptions {
1391
1442
  /** Metadata resolution policy for chain DSL UI generation. */
1392
1443
  readonly metadata?: MetadataPolicyInput | undefined;
1444
+ /**
1445
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
1446
+ * existing callers produce no output.
1447
+ */
1448
+ readonly logger?: LoggerLike | undefined;
1393
1449
  }
1394
1450
 
1395
1451
  export { Group }
@@ -2391,6 +2447,11 @@ export declare interface WriteSchemasOptions extends GenerateJsonSchemaOptions {
2391
2447
  readonly name?: string;
2392
2448
  /** Number of spaces for JSON indentation. Defaults to 2 */
2393
2449
  readonly indent?: number;
2450
+ /**
2451
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
2452
+ * existing callers produce no output.
2453
+ */
2454
+ readonly logger?: LoggerLike | undefined;
2394
2455
  }
2395
2456
 
2396
2457
  /**
@@ -40,6 +40,7 @@ import { ExtensionDefinition } from '@formspec/core';
40
40
  import { FormElement } from '@formspec/core';
41
41
  import { FormSpec } from '@formspec/core';
42
42
  import { Group } from '@formspec/core';
43
+ import type { LoggerLike } from '@formspec/core';
43
44
  import type { MetadataPolicyInput } from '@formspec/core';
44
45
  import { NumberField } from '@formspec/core';
45
46
  import { ObjectField } from '@formspec/core';
@@ -95,6 +96,11 @@ export declare function buildFormSchemas<E extends readonly FormElement[]>(form:
95
96
  * @public
96
97
  */
97
98
  export declare interface BuildFormSchemasOptions extends GenerateJsonSchemaOptions, GenerateUiSchemaOptions {
99
+ /**
100
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
101
+ * existing callers produce no output.
102
+ */
103
+ readonly logger?: LoggerLike | undefined;
98
104
  }
99
105
 
100
106
  /**
@@ -463,6 +469,46 @@ declare interface CustomTypeRegistration_2 {
463
469
  * Note: `"__integerBrand"` is reserved for the builtin Integer type.
464
470
  */
465
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;
466
512
  /**
467
513
  * Converts the custom type's payload into a JSON Schema fragment.
468
514
  *
@@ -1008,6 +1054,11 @@ export declare interface GenerateJsonSchemaOptions {
1008
1054
  readonly enumSerialization?: "enum" | "oneOf";
1009
1055
  /** Metadata resolution policy for chain DSL generation. */
1010
1056
  readonly metadata?: MetadataPolicyInput | undefined;
1057
+ /**
1058
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
1059
+ * existing callers produce no output.
1060
+ */
1061
+ readonly logger?: LoggerLike | undefined;
1011
1062
  }
1012
1063
 
1013
1064
  /**
@@ -1390,6 +1441,11 @@ export declare function generateUiSchema<E extends readonly FormElement[]>(form:
1390
1441
  export declare interface GenerateUiSchemaOptions {
1391
1442
  /** Metadata resolution policy for chain DSL UI generation. */
1392
1443
  readonly metadata?: MetadataPolicyInput | undefined;
1444
+ /**
1445
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
1446
+ * existing callers produce no output.
1447
+ */
1448
+ readonly logger?: LoggerLike | undefined;
1393
1449
  }
1394
1450
 
1395
1451
  export { Group }
@@ -2391,6 +2447,11 @@ export declare interface WriteSchemasOptions extends GenerateJsonSchemaOptions {
2391
2447
  readonly name?: string;
2392
2448
  /** Number of spaces for JSON indentation. Defaults to 2 */
2393
2449
  readonly indent?: number;
2450
+ /**
2451
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
2452
+ * existing callers produce no output.
2453
+ */
2454
+ readonly logger?: LoggerLike | undefined;
2394
2455
  }
2395
2456
 
2396
2457
  /**
package/dist/build.d.ts CHANGED
@@ -40,6 +40,7 @@ import { ExtensionDefinition } from '@formspec/core';
40
40
  import { FormElement } from '@formspec/core';
41
41
  import { FormSpec } from '@formspec/core';
42
42
  import { Group } from '@formspec/core';
43
+ import type { LoggerLike } from '@formspec/core';
43
44
  import type { MetadataPolicyInput } from '@formspec/core';
44
45
  import { NumberField } from '@formspec/core';
45
46
  import { ObjectField } from '@formspec/core';
@@ -95,6 +96,11 @@ export declare function buildFormSchemas<E extends readonly FormElement[]>(form:
95
96
  * @public
96
97
  */
97
98
  export declare interface BuildFormSchemasOptions extends GenerateJsonSchemaOptions, GenerateUiSchemaOptions {
99
+ /**
100
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
101
+ * existing callers produce no output.
102
+ */
103
+ readonly logger?: LoggerLike | undefined;
98
104
  }
99
105
 
100
106
  /**
@@ -463,6 +469,46 @@ declare interface CustomTypeRegistration_2 {
463
469
  * Note: `"__integerBrand"` is reserved for the builtin Integer type.
464
470
  */
465
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;
466
512
  /**
467
513
  * Converts the custom type's payload into a JSON Schema fragment.
468
514
  *
@@ -1008,6 +1054,11 @@ export declare interface GenerateJsonSchemaOptions {
1008
1054
  readonly enumSerialization?: "enum" | "oneOf";
1009
1055
  /** Metadata resolution policy for chain DSL generation. */
1010
1056
  readonly metadata?: MetadataPolicyInput | undefined;
1057
+ /**
1058
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
1059
+ * existing callers produce no output.
1060
+ */
1061
+ readonly logger?: LoggerLike | undefined;
1011
1062
  }
1012
1063
 
1013
1064
  /**
@@ -1390,6 +1441,11 @@ export declare function generateUiSchema<E extends readonly FormElement[]>(form:
1390
1441
  export declare interface GenerateUiSchemaOptions {
1391
1442
  /** Metadata resolution policy for chain DSL UI generation. */
1392
1443
  readonly metadata?: MetadataPolicyInput | undefined;
1444
+ /**
1445
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
1446
+ * existing callers produce no output.
1447
+ */
1448
+ readonly logger?: LoggerLike | undefined;
1393
1449
  }
1394
1450
 
1395
1451
  export { Group }
@@ -2391,6 +2447,11 @@ export declare interface WriteSchemasOptions extends GenerateJsonSchemaOptions {
2391
2447
  readonly name?: string;
2392
2448
  /** Number of spaces for JSON indentation. Defaults to 2 */
2393
2449
  readonly indent?: number;
2450
+ /**
2451
+ * Optional logger for diagnostic output. Defaults to a no-op logger so
2452
+ * existing callers produce no output.
2453
+ */
2454
+ readonly logger?: LoggerLike | undefined;
2394
2455
  }
2395
2456
 
2396
2457
  /**
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Pino-based logger factory for the @formspec/build CLI.
3
+ *
4
+ * Reads `process.env.DEBUG` to determine which namespaces are enabled using
5
+ * the shared matcher in `@formspec/core` — same semantics as the `debug` npm
6
+ * package (comma-separated patterns, `*` wildcard, `-` prefix for negation,
7
+ * negations always win).
8
+ */
9
+ import type { LoggerLike } from "@formspec/core";
10
+ /**
11
+ * Creates a logger for the given namespace.
12
+ *
13
+ * When the namespace is enabled by `DEBUG`, writes structured JSON to stderr
14
+ * (with pino-pretty formatting when stderr is a TTY). Otherwise returns the
15
+ * silent `noopLogger` from `@formspec/core`.
16
+ *
17
+ * pino and pino-pretty are loaded lazily via `require()` so that the CLI
18
+ * pays no load-time cost when logging is disabled, and so the dependencies
19
+ * can be declared as `optionalDependencies` of `@formspec/build`.
20
+ */
21
+ export declare function createLogger(namespace: string): LoggerLike;
22
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/cli/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAwB1D"}