@formspec/build 0.1.0-alpha.37 → 0.1.0-alpha.39
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/README.md +74 -0
- package/dist/analyzer/program.d.ts +13 -0
- package/dist/analyzer/program.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/build-alpha.d.ts +268 -5
- package/dist/build-beta.d.ts +268 -5
- package/dist/build-internal.d.ts +268 -5
- package/dist/build.d.ts +268 -5
- package/dist/cli.cjs +302 -48
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +302 -48
- package/dist/cli.js.map +1 -1
- package/dist/generators/class-schema.d.ts +184 -5
- package/dist/generators/class-schema.d.ts.map +1 -1
- package/dist/generators/discovered-schema.d.ts +9 -0
- package/dist/generators/discovered-schema.d.ts.map +1 -1
- package/dist/index.cjs +303 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +299 -48
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +157 -34
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.d.ts +4 -3
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +155 -34
- package/dist/internals.js.map +1 -1
- package/dist/validate/constraint-validator.d.ts +64 -2
- package/dist/validate/constraint-validator.d.ts.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/build-alpha.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ import { Group } from '@formspec/core';
|
|
|
43
43
|
import type { MetadataPolicyInput } from '@formspec/core';
|
|
44
44
|
import { NumberField } from '@formspec/core';
|
|
45
45
|
import { ObjectField } from '@formspec/core';
|
|
46
|
+
import type { ResolvedMetadata } from '@formspec/core';
|
|
46
47
|
import { StaticEnumField } from '@formspec/core';
|
|
47
48
|
import { TextField } from '@formspec/core';
|
|
48
49
|
import * as ts from 'typescript';
|
|
@@ -246,6 +247,34 @@ export { CustomConstraintRegistration }
|
|
|
246
247
|
|
|
247
248
|
export { CustomTypeRegistration }
|
|
248
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Non-throwing schema generation result with structured diagnostics.
|
|
252
|
+
*
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
export declare interface DetailedClassSchemasResult {
|
|
256
|
+
/** Whether schema generation completed without error-severity diagnostics. */
|
|
257
|
+
readonly ok: boolean;
|
|
258
|
+
/** Collected analysis and validation diagnostics for this target. */
|
|
259
|
+
readonly diagnostics: readonly ValidationDiagnostic[];
|
|
260
|
+
/** JSON Schema 2020-12 for validation, when generation succeeds. */
|
|
261
|
+
readonly jsonSchema?: JsonSchema2020 | undefined;
|
|
262
|
+
/** JSON Forms UI Schema for rendering, when generation succeeds. */
|
|
263
|
+
readonly uiSchema?: UISchema | undefined;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Result for a single target in a batch generation request.
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
export declare interface DetailedSchemaGenerationTargetResult extends DetailedClassSchemasResult {
|
|
272
|
+
/** Path to the TypeScript source file. */
|
|
273
|
+
readonly filePath: string;
|
|
274
|
+
/** Name of the exported class, interface, or type alias that was analyzed. */
|
|
275
|
+
readonly typeName: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
249
278
|
/**
|
|
250
279
|
* Generated schemas for a discovered declaration or signature type.
|
|
251
280
|
*
|
|
@@ -259,6 +288,14 @@ export declare interface DiscoveredTypeSchemas {
|
|
|
259
288
|
readonly jsonSchema: JsonSchema2020;
|
|
260
289
|
/** UI Schema for object-shaped roots, or `null` when not applicable. */
|
|
261
290
|
readonly uiSchema: UISchema | null;
|
|
291
|
+
/**
|
|
292
|
+
* Resolved type-level metadata used during generation, when available.
|
|
293
|
+
*
|
|
294
|
+
* This preserves explicit and inferred naming metadata such as singular and
|
|
295
|
+
* plural API/display names for consumers that need the resolved values in
|
|
296
|
+
* addition to the emitted schema artifacts.
|
|
297
|
+
*/
|
|
298
|
+
readonly resolvedMetadata?: ResolvedMetadata | undefined;
|
|
262
299
|
}
|
|
263
300
|
|
|
264
301
|
/**
|
|
@@ -447,15 +484,99 @@ export declare interface GenerateJsonSchemaOptions {
|
|
|
447
484
|
* const result = generateSchemas({
|
|
448
485
|
* filePath: "./src/config.ts",
|
|
449
486
|
* typeName: "DiscountConfig",
|
|
487
|
+
* errorReporting: "throw",
|
|
450
488
|
* });
|
|
451
489
|
* ```
|
|
490
|
+
*/
|
|
491
|
+
/**
|
|
492
|
+
* Generates JSON Schema and UI Schema from a named type and throws when
|
|
493
|
+
* generation reports error-severity diagnostics.
|
|
494
|
+
*
|
|
495
|
+
* @param options - File path, type name, and explicit throw-on-error reporting
|
|
496
|
+
* @returns Generated JSON Schema and UI Schema
|
|
497
|
+
*
|
|
498
|
+
* @public
|
|
499
|
+
*/
|
|
500
|
+
export declare function generateSchemas(options: GenerateSchemasOptions & {
|
|
501
|
+
readonly errorReporting: "throw";
|
|
502
|
+
}): GenerateFromClassResult;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Generates JSON Schema and UI Schema from a named type and returns structured
|
|
506
|
+
* diagnostics instead of throwing on validation or analysis failures.
|
|
452
507
|
*
|
|
508
|
+
* @param options - File path, type name, and explicit diagnostics reporting
|
|
509
|
+
* @returns Structured generation result with diagnostics
|
|
510
|
+
*
|
|
511
|
+
* @public
|
|
512
|
+
*/
|
|
513
|
+
export declare function generateSchemas(options: GenerateSchemasOptions & {
|
|
514
|
+
readonly errorReporting: "diagnostics";
|
|
515
|
+
}): DetailedClassSchemasResult;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Generates JSON Schema and UI Schema from a named type.
|
|
519
|
+
*
|
|
520
|
+
* @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
|
|
453
521
|
* @param options - File path and type name
|
|
454
522
|
* @returns Generated JSON Schema and UI Schema
|
|
455
523
|
*
|
|
456
524
|
* @public
|
|
457
525
|
*/
|
|
458
|
-
export declare function generateSchemas(options:
|
|
526
|
+
export declare function generateSchemas(options: StaticSchemaGenerationOptions & {
|
|
527
|
+
readonly filePath: string;
|
|
528
|
+
readonly typeName: string;
|
|
529
|
+
}): GenerateFromClassResult;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Generates schemas for many targets and returns per-target diagnostics instead
|
|
533
|
+
* of failing on the first problem.
|
|
534
|
+
*
|
|
535
|
+
* @public
|
|
536
|
+
*/
|
|
537
|
+
export declare function generateSchemasBatch(options: GenerateSchemasBatchOptions): readonly DetailedSchemaGenerationTargetResult[];
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Generates schemas for many targets from an existing TypeScript program and
|
|
541
|
+
* returns per-target diagnostics instead of failing on the first problem.
|
|
542
|
+
*
|
|
543
|
+
* @public
|
|
544
|
+
*/
|
|
545
|
+
export declare function generateSchemasBatchFromProgram(options: GenerateSchemasBatchFromProgramOptions): readonly DetailedSchemaGenerationTargetResult[];
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Batch options for non-throwing schema generation using an existing program.
|
|
549
|
+
*
|
|
550
|
+
* @public
|
|
551
|
+
*/
|
|
552
|
+
export declare interface GenerateSchemasBatchFromProgramOptions extends StaticSchemaGenerationOptions {
|
|
553
|
+
/** Existing TypeScript program supplied by the caller. */
|
|
554
|
+
readonly program: ts.Program;
|
|
555
|
+
/** Targets to analyze and generate. */
|
|
556
|
+
readonly targets: readonly SchemaGenerationTarget[];
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Batch options for non-throwing schema generation.
|
|
561
|
+
*
|
|
562
|
+
* @public
|
|
563
|
+
*/
|
|
564
|
+
export declare interface GenerateSchemasBatchOptions extends StaticSchemaGenerationOptions {
|
|
565
|
+
/** Targets to analyze and generate. */
|
|
566
|
+
readonly targets: readonly SchemaGenerationTarget[];
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Generates JSON Schema and UI Schema from a named type and returns structured
|
|
571
|
+
* diagnostics instead of throwing on validation or analysis failures.
|
|
572
|
+
* @deprecated Use `generateSchemas({ ...options, errorReporting: "diagnostics" })` instead.
|
|
573
|
+
*
|
|
574
|
+
* @public
|
|
575
|
+
*/
|
|
576
|
+
export declare function generateSchemasDetailed(options: StaticSchemaGenerationOptions & {
|
|
577
|
+
readonly filePath: string;
|
|
578
|
+
readonly typeName: string;
|
|
579
|
+
}): DetailedClassSchemasResult;
|
|
459
580
|
|
|
460
581
|
/**
|
|
461
582
|
* Generates JSON Schema and UI Schema from a decorated TypeScript class.
|
|
@@ -529,13 +650,63 @@ export declare interface GenerateSchemasFromParameterOptions extends StaticSchem
|
|
|
529
650
|
*
|
|
530
651
|
* This low-level entry point lets downstream tooling reuse a host-owned
|
|
531
652
|
* `Program` for both FormSpec extraction and other TypeScript analysis.
|
|
653
|
+
*/
|
|
654
|
+
/**
|
|
655
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
656
|
+
* TypeScript program and throws when generation reports error-severity diagnostics.
|
|
657
|
+
*
|
|
658
|
+
* @param options - Host program, file path, type name, and explicit throw-on-error reporting
|
|
659
|
+
* @returns Generated JSON Schema and UI Schema
|
|
532
660
|
*
|
|
533
|
-
* @
|
|
661
|
+
* @public
|
|
662
|
+
*/
|
|
663
|
+
export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
|
|
664
|
+
readonly errorReporting: "throw";
|
|
665
|
+
}): GenerateFromClassResult;
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
669
|
+
* TypeScript program and returns structured diagnostics instead of throwing on
|
|
670
|
+
* validation or analysis failures.
|
|
671
|
+
*
|
|
672
|
+
* @param options - Host program, file path, type name, and explicit diagnostics reporting
|
|
673
|
+
* @returns Structured generation result with diagnostics
|
|
674
|
+
*
|
|
675
|
+
* @public
|
|
676
|
+
*/
|
|
677
|
+
export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
|
|
678
|
+
readonly errorReporting: "diagnostics";
|
|
679
|
+
}): DetailedClassSchemasResult;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
683
|
+
* TypeScript program.
|
|
684
|
+
*
|
|
685
|
+
* @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
|
|
686
|
+
* @param options - Host program, file path, and type name
|
|
534
687
|
* @returns Generated JSON Schema and UI Schema
|
|
535
688
|
*
|
|
536
689
|
* @public
|
|
537
690
|
*/
|
|
538
|
-
export declare function generateSchemasFromProgram(options:
|
|
691
|
+
export declare function generateSchemasFromProgram(options: StaticSchemaGenerationOptions & {
|
|
692
|
+
readonly program: ts.Program;
|
|
693
|
+
readonly filePath: string;
|
|
694
|
+
readonly typeName: string;
|
|
695
|
+
}): GenerateFromClassResult;
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
699
|
+
* TypeScript program and returns structured diagnostics instead of throwing on
|
|
700
|
+
* validation or analysis failures.
|
|
701
|
+
* @deprecated Use `generateSchemasFromProgram({ ...options, errorReporting: "diagnostics" })` instead.
|
|
702
|
+
*
|
|
703
|
+
* @public
|
|
704
|
+
*/
|
|
705
|
+
export declare function generateSchemasFromProgramDetailed(options: StaticSchemaGenerationOptions & {
|
|
706
|
+
readonly program: ts.Program;
|
|
707
|
+
readonly filePath: string;
|
|
708
|
+
readonly typeName: string;
|
|
709
|
+
}): DetailedClassSchemasResult;
|
|
539
710
|
|
|
540
711
|
/**
|
|
541
712
|
* Options for generating schemas from a named type inside an existing TypeScript program.
|
|
@@ -549,6 +720,10 @@ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaG
|
|
|
549
720
|
readonly filePath: string;
|
|
550
721
|
/** Name of the exported class, interface, or type alias to analyze */
|
|
551
722
|
readonly typeName: string;
|
|
723
|
+
/**
|
|
724
|
+
* Controls whether error-severity diagnostics throw or are returned in the result.
|
|
725
|
+
*/
|
|
726
|
+
readonly errorReporting: "throw" | "diagnostics";
|
|
552
727
|
}
|
|
553
728
|
|
|
554
729
|
/**
|
|
@@ -611,9 +786,13 @@ export declare interface GenerateSchemasFromTypeOptions extends StaticSchemaGene
|
|
|
611
786
|
*/
|
|
612
787
|
export declare interface GenerateSchemasOptions extends StaticSchemaGenerationOptions {
|
|
613
788
|
/** Path to the TypeScript source file */
|
|
614
|
-
filePath: string;
|
|
789
|
+
readonly filePath: string;
|
|
615
790
|
/** Name of the exported class, interface, or type alias to analyze */
|
|
616
|
-
typeName: string;
|
|
791
|
+
readonly typeName: string;
|
|
792
|
+
/**
|
|
793
|
+
* Controls whether error-severity diagnostics throw or are returned in the result.
|
|
794
|
+
*/
|
|
795
|
+
readonly errorReporting: "throw" | "diagnostics";
|
|
617
796
|
}
|
|
618
797
|
|
|
619
798
|
/**
|
|
@@ -1019,6 +1198,18 @@ export declare interface SchemaBasedCondition {
|
|
|
1019
1198
|
readonly schema: RuleConditionSchema;
|
|
1020
1199
|
}
|
|
1021
1200
|
|
|
1201
|
+
/**
|
|
1202
|
+
* A batch target for non-throwing schema generation.
|
|
1203
|
+
*
|
|
1204
|
+
* @public
|
|
1205
|
+
*/
|
|
1206
|
+
export declare interface SchemaGenerationTarget {
|
|
1207
|
+
/** Path to the TypeScript source file. */
|
|
1208
|
+
readonly filePath: string;
|
|
1209
|
+
/** Name of the exported class, interface, or type alias to analyze. */
|
|
1210
|
+
readonly typeName: string;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1022
1213
|
/**
|
|
1023
1214
|
* Supported declaration kinds for declaration-driven schema generation.
|
|
1024
1215
|
*
|
|
@@ -1116,6 +1307,78 @@ export declare type UISchemaElementType = "Control" | "VerticalLayout" | "Horizo
|
|
|
1116
1307
|
*/
|
|
1117
1308
|
export declare const uiSchemaSchema: z.ZodType<UISchema>;
|
|
1118
1309
|
|
|
1310
|
+
/**
|
|
1311
|
+
* Options for validating canonical FormIR.
|
|
1312
|
+
*
|
|
1313
|
+
* @public
|
|
1314
|
+
*/
|
|
1315
|
+
export declare interface ValidateIROptions {
|
|
1316
|
+
/** Vendor prefix used when resolving extension-backed keywords. */
|
|
1317
|
+
readonly vendorPrefix?: string;
|
|
1318
|
+
/** Extension registry used to resolve custom constraints and types. */
|
|
1319
|
+
readonly extensionRegistry?: ExtensionRegistry;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* A machine-readable validation diagnostic returned by static schema analysis.
|
|
1324
|
+
*
|
|
1325
|
+
* @public
|
|
1326
|
+
*/
|
|
1327
|
+
export declare interface ValidationDiagnostic {
|
|
1328
|
+
/** Stable machine-readable diagnostic code. */
|
|
1329
|
+
readonly code: string;
|
|
1330
|
+
/** Human-readable explanation of the validation problem. */
|
|
1331
|
+
readonly message: string;
|
|
1332
|
+
/** Severity of the reported validation problem. */
|
|
1333
|
+
readonly severity: ValidationDiagnosticSeverity;
|
|
1334
|
+
/** Primary source location associated with the diagnostic. */
|
|
1335
|
+
readonly primaryLocation: ValidationDiagnosticLocation;
|
|
1336
|
+
/** Related source locations that add context to the diagnostic. */
|
|
1337
|
+
readonly relatedLocations: readonly ValidationDiagnosticLocation[];
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Public source-location shape attached to validation diagnostics.
|
|
1342
|
+
*
|
|
1343
|
+
* This mirrors the provenance information surfaced by the shared analysis
|
|
1344
|
+
* layer without exposing `@formspec/core/internals` through the public API.
|
|
1345
|
+
*
|
|
1346
|
+
* @public
|
|
1347
|
+
*/
|
|
1348
|
+
export declare interface ValidationDiagnosticLocation {
|
|
1349
|
+
/** Authoring surface that produced the diagnostic location. */
|
|
1350
|
+
readonly surface: "tsdoc" | "chain-dsl" | "extension" | "inferred";
|
|
1351
|
+
/** Absolute path to the source file. */
|
|
1352
|
+
readonly file: string;
|
|
1353
|
+
/** 1-based line number in the source file. */
|
|
1354
|
+
readonly line: number;
|
|
1355
|
+
/** 0-based column number in the source file. */
|
|
1356
|
+
readonly column: number;
|
|
1357
|
+
/** Optional span length in characters. */
|
|
1358
|
+
readonly length?: number;
|
|
1359
|
+
/** Optional tag or construct associated with the location. */
|
|
1360
|
+
readonly tagName?: string;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* Supported severity levels returned by static build validation.
|
|
1365
|
+
*
|
|
1366
|
+
* @public
|
|
1367
|
+
*/
|
|
1368
|
+
export declare type ValidationDiagnosticSeverity = "error" | "warning";
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* Result of validating canonical FormIR before schema emission.
|
|
1372
|
+
*
|
|
1373
|
+
* @public
|
|
1374
|
+
*/
|
|
1375
|
+
export declare interface ValidationResult {
|
|
1376
|
+
/** Diagnostics produced during validation. */
|
|
1377
|
+
readonly diagnostics: readonly ValidationDiagnostic[];
|
|
1378
|
+
/** Whether any error-severity diagnostics were produced. */
|
|
1379
|
+
readonly valid: boolean;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1119
1382
|
/**
|
|
1120
1383
|
* A vertical layout element.
|
|
1121
1384
|
*
|
package/dist/build-beta.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ import { Group } from '@formspec/core';
|
|
|
43
43
|
import type { MetadataPolicyInput } from '@formspec/core';
|
|
44
44
|
import { NumberField } from '@formspec/core';
|
|
45
45
|
import { ObjectField } from '@formspec/core';
|
|
46
|
+
import type { ResolvedMetadata } from '@formspec/core';
|
|
46
47
|
import { StaticEnumField } from '@formspec/core';
|
|
47
48
|
import { TextField } from '@formspec/core';
|
|
48
49
|
import * as ts from 'typescript';
|
|
@@ -246,6 +247,34 @@ export { CustomConstraintRegistration }
|
|
|
246
247
|
|
|
247
248
|
export { CustomTypeRegistration }
|
|
248
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Non-throwing schema generation result with structured diagnostics.
|
|
252
|
+
*
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
export declare interface DetailedClassSchemasResult {
|
|
256
|
+
/** Whether schema generation completed without error-severity diagnostics. */
|
|
257
|
+
readonly ok: boolean;
|
|
258
|
+
/** Collected analysis and validation diagnostics for this target. */
|
|
259
|
+
readonly diagnostics: readonly ValidationDiagnostic[];
|
|
260
|
+
/** JSON Schema 2020-12 for validation, when generation succeeds. */
|
|
261
|
+
readonly jsonSchema?: JsonSchema2020 | undefined;
|
|
262
|
+
/** JSON Forms UI Schema for rendering, when generation succeeds. */
|
|
263
|
+
readonly uiSchema?: UISchema | undefined;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Result for a single target in a batch generation request.
|
|
268
|
+
*
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
export declare interface DetailedSchemaGenerationTargetResult extends DetailedClassSchemasResult {
|
|
272
|
+
/** Path to the TypeScript source file. */
|
|
273
|
+
readonly filePath: string;
|
|
274
|
+
/** Name of the exported class, interface, or type alias that was analyzed. */
|
|
275
|
+
readonly typeName: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
249
278
|
/**
|
|
250
279
|
* Generated schemas for a discovered declaration or signature type.
|
|
251
280
|
*
|
|
@@ -259,6 +288,14 @@ export declare interface DiscoveredTypeSchemas {
|
|
|
259
288
|
readonly jsonSchema: JsonSchema2020;
|
|
260
289
|
/** UI Schema for object-shaped roots, or `null` when not applicable. */
|
|
261
290
|
readonly uiSchema: UISchema | null;
|
|
291
|
+
/**
|
|
292
|
+
* Resolved type-level metadata used during generation, when available.
|
|
293
|
+
*
|
|
294
|
+
* This preserves explicit and inferred naming metadata such as singular and
|
|
295
|
+
* plural API/display names for consumers that need the resolved values in
|
|
296
|
+
* addition to the emitted schema artifacts.
|
|
297
|
+
*/
|
|
298
|
+
readonly resolvedMetadata?: ResolvedMetadata | undefined;
|
|
262
299
|
}
|
|
263
300
|
|
|
264
301
|
/**
|
|
@@ -447,15 +484,99 @@ export declare interface GenerateJsonSchemaOptions {
|
|
|
447
484
|
* const result = generateSchemas({
|
|
448
485
|
* filePath: "./src/config.ts",
|
|
449
486
|
* typeName: "DiscountConfig",
|
|
487
|
+
* errorReporting: "throw",
|
|
450
488
|
* });
|
|
451
489
|
* ```
|
|
490
|
+
*/
|
|
491
|
+
/**
|
|
492
|
+
* Generates JSON Schema and UI Schema from a named type and throws when
|
|
493
|
+
* generation reports error-severity diagnostics.
|
|
494
|
+
*
|
|
495
|
+
* @param options - File path, type name, and explicit throw-on-error reporting
|
|
496
|
+
* @returns Generated JSON Schema and UI Schema
|
|
497
|
+
*
|
|
498
|
+
* @public
|
|
499
|
+
*/
|
|
500
|
+
export declare function generateSchemas(options: GenerateSchemasOptions & {
|
|
501
|
+
readonly errorReporting: "throw";
|
|
502
|
+
}): GenerateFromClassResult;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Generates JSON Schema and UI Schema from a named type and returns structured
|
|
506
|
+
* diagnostics instead of throwing on validation or analysis failures.
|
|
452
507
|
*
|
|
508
|
+
* @param options - File path, type name, and explicit diagnostics reporting
|
|
509
|
+
* @returns Structured generation result with diagnostics
|
|
510
|
+
*
|
|
511
|
+
* @public
|
|
512
|
+
*/
|
|
513
|
+
export declare function generateSchemas(options: GenerateSchemasOptions & {
|
|
514
|
+
readonly errorReporting: "diagnostics";
|
|
515
|
+
}): DetailedClassSchemasResult;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Generates JSON Schema and UI Schema from a named type.
|
|
519
|
+
*
|
|
520
|
+
* @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
|
|
453
521
|
* @param options - File path and type name
|
|
454
522
|
* @returns Generated JSON Schema and UI Schema
|
|
455
523
|
*
|
|
456
524
|
* @public
|
|
457
525
|
*/
|
|
458
|
-
export declare function generateSchemas(options:
|
|
526
|
+
export declare function generateSchemas(options: StaticSchemaGenerationOptions & {
|
|
527
|
+
readonly filePath: string;
|
|
528
|
+
readonly typeName: string;
|
|
529
|
+
}): GenerateFromClassResult;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Generates schemas for many targets and returns per-target diagnostics instead
|
|
533
|
+
* of failing on the first problem.
|
|
534
|
+
*
|
|
535
|
+
* @public
|
|
536
|
+
*/
|
|
537
|
+
export declare function generateSchemasBatch(options: GenerateSchemasBatchOptions): readonly DetailedSchemaGenerationTargetResult[];
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Generates schemas for many targets from an existing TypeScript program and
|
|
541
|
+
* returns per-target diagnostics instead of failing on the first problem.
|
|
542
|
+
*
|
|
543
|
+
* @public
|
|
544
|
+
*/
|
|
545
|
+
export declare function generateSchemasBatchFromProgram(options: GenerateSchemasBatchFromProgramOptions): readonly DetailedSchemaGenerationTargetResult[];
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Batch options for non-throwing schema generation using an existing program.
|
|
549
|
+
*
|
|
550
|
+
* @public
|
|
551
|
+
*/
|
|
552
|
+
export declare interface GenerateSchemasBatchFromProgramOptions extends StaticSchemaGenerationOptions {
|
|
553
|
+
/** Existing TypeScript program supplied by the caller. */
|
|
554
|
+
readonly program: ts.Program;
|
|
555
|
+
/** Targets to analyze and generate. */
|
|
556
|
+
readonly targets: readonly SchemaGenerationTarget[];
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Batch options for non-throwing schema generation.
|
|
561
|
+
*
|
|
562
|
+
* @public
|
|
563
|
+
*/
|
|
564
|
+
export declare interface GenerateSchemasBatchOptions extends StaticSchemaGenerationOptions {
|
|
565
|
+
/** Targets to analyze and generate. */
|
|
566
|
+
readonly targets: readonly SchemaGenerationTarget[];
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Generates JSON Schema and UI Schema from a named type and returns structured
|
|
571
|
+
* diagnostics instead of throwing on validation or analysis failures.
|
|
572
|
+
* @deprecated Use `generateSchemas({ ...options, errorReporting: "diagnostics" })` instead.
|
|
573
|
+
*
|
|
574
|
+
* @public
|
|
575
|
+
*/
|
|
576
|
+
export declare function generateSchemasDetailed(options: StaticSchemaGenerationOptions & {
|
|
577
|
+
readonly filePath: string;
|
|
578
|
+
readonly typeName: string;
|
|
579
|
+
}): DetailedClassSchemasResult;
|
|
459
580
|
|
|
460
581
|
/**
|
|
461
582
|
* Generates JSON Schema and UI Schema from a decorated TypeScript class.
|
|
@@ -529,13 +650,63 @@ export declare interface GenerateSchemasFromParameterOptions extends StaticSchem
|
|
|
529
650
|
*
|
|
530
651
|
* This low-level entry point lets downstream tooling reuse a host-owned
|
|
531
652
|
* `Program` for both FormSpec extraction and other TypeScript analysis.
|
|
653
|
+
*/
|
|
654
|
+
/**
|
|
655
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
656
|
+
* TypeScript program and throws when generation reports error-severity diagnostics.
|
|
657
|
+
*
|
|
658
|
+
* @param options - Host program, file path, type name, and explicit throw-on-error reporting
|
|
659
|
+
* @returns Generated JSON Schema and UI Schema
|
|
532
660
|
*
|
|
533
|
-
* @
|
|
661
|
+
* @public
|
|
662
|
+
*/
|
|
663
|
+
export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
|
|
664
|
+
readonly errorReporting: "throw";
|
|
665
|
+
}): GenerateFromClassResult;
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
669
|
+
* TypeScript program and returns structured diagnostics instead of throwing on
|
|
670
|
+
* validation or analysis failures.
|
|
671
|
+
*
|
|
672
|
+
* @param options - Host program, file path, type name, and explicit diagnostics reporting
|
|
673
|
+
* @returns Structured generation result with diagnostics
|
|
674
|
+
*
|
|
675
|
+
* @public
|
|
676
|
+
*/
|
|
677
|
+
export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
|
|
678
|
+
readonly errorReporting: "diagnostics";
|
|
679
|
+
}): DetailedClassSchemasResult;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
683
|
+
* TypeScript program.
|
|
684
|
+
*
|
|
685
|
+
* @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
|
|
686
|
+
* @param options - Host program, file path, and type name
|
|
534
687
|
* @returns Generated JSON Schema and UI Schema
|
|
535
688
|
*
|
|
536
689
|
* @public
|
|
537
690
|
*/
|
|
538
|
-
export declare function generateSchemasFromProgram(options:
|
|
691
|
+
export declare function generateSchemasFromProgram(options: StaticSchemaGenerationOptions & {
|
|
692
|
+
readonly program: ts.Program;
|
|
693
|
+
readonly filePath: string;
|
|
694
|
+
readonly typeName: string;
|
|
695
|
+
}): GenerateFromClassResult;
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Generates JSON Schema and UI Schema from a named type within an existing
|
|
699
|
+
* TypeScript program and returns structured diagnostics instead of throwing on
|
|
700
|
+
* validation or analysis failures.
|
|
701
|
+
* @deprecated Use `generateSchemasFromProgram({ ...options, errorReporting: "diagnostics" })` instead.
|
|
702
|
+
*
|
|
703
|
+
* @public
|
|
704
|
+
*/
|
|
705
|
+
export declare function generateSchemasFromProgramDetailed(options: StaticSchemaGenerationOptions & {
|
|
706
|
+
readonly program: ts.Program;
|
|
707
|
+
readonly filePath: string;
|
|
708
|
+
readonly typeName: string;
|
|
709
|
+
}): DetailedClassSchemasResult;
|
|
539
710
|
|
|
540
711
|
/**
|
|
541
712
|
* Options for generating schemas from a named type inside an existing TypeScript program.
|
|
@@ -549,6 +720,10 @@ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaG
|
|
|
549
720
|
readonly filePath: string;
|
|
550
721
|
/** Name of the exported class, interface, or type alias to analyze */
|
|
551
722
|
readonly typeName: string;
|
|
723
|
+
/**
|
|
724
|
+
* Controls whether error-severity diagnostics throw or are returned in the result.
|
|
725
|
+
*/
|
|
726
|
+
readonly errorReporting: "throw" | "diagnostics";
|
|
552
727
|
}
|
|
553
728
|
|
|
554
729
|
/**
|
|
@@ -611,9 +786,13 @@ export declare interface GenerateSchemasFromTypeOptions extends StaticSchemaGene
|
|
|
611
786
|
*/
|
|
612
787
|
export declare interface GenerateSchemasOptions extends StaticSchemaGenerationOptions {
|
|
613
788
|
/** Path to the TypeScript source file */
|
|
614
|
-
filePath: string;
|
|
789
|
+
readonly filePath: string;
|
|
615
790
|
/** Name of the exported class, interface, or type alias to analyze */
|
|
616
|
-
typeName: string;
|
|
791
|
+
readonly typeName: string;
|
|
792
|
+
/**
|
|
793
|
+
* Controls whether error-severity diagnostics throw or are returned in the result.
|
|
794
|
+
*/
|
|
795
|
+
readonly errorReporting: "throw" | "diagnostics";
|
|
617
796
|
}
|
|
618
797
|
|
|
619
798
|
/**
|
|
@@ -1019,6 +1198,18 @@ export declare interface SchemaBasedCondition {
|
|
|
1019
1198
|
readonly schema: RuleConditionSchema;
|
|
1020
1199
|
}
|
|
1021
1200
|
|
|
1201
|
+
/**
|
|
1202
|
+
* A batch target for non-throwing schema generation.
|
|
1203
|
+
*
|
|
1204
|
+
* @public
|
|
1205
|
+
*/
|
|
1206
|
+
export declare interface SchemaGenerationTarget {
|
|
1207
|
+
/** Path to the TypeScript source file. */
|
|
1208
|
+
readonly filePath: string;
|
|
1209
|
+
/** Name of the exported class, interface, or type alias to analyze. */
|
|
1210
|
+
readonly typeName: string;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1022
1213
|
/**
|
|
1023
1214
|
* Supported declaration kinds for declaration-driven schema generation.
|
|
1024
1215
|
*
|
|
@@ -1116,6 +1307,78 @@ export declare type UISchemaElementType = "Control" | "VerticalLayout" | "Horizo
|
|
|
1116
1307
|
*/
|
|
1117
1308
|
export declare const uiSchemaSchema: z.ZodType<UISchema>;
|
|
1118
1309
|
|
|
1310
|
+
/**
|
|
1311
|
+
* Options for validating canonical FormIR.
|
|
1312
|
+
*
|
|
1313
|
+
* @public
|
|
1314
|
+
*/
|
|
1315
|
+
export declare interface ValidateIROptions {
|
|
1316
|
+
/** Vendor prefix used when resolving extension-backed keywords. */
|
|
1317
|
+
readonly vendorPrefix?: string;
|
|
1318
|
+
/** Extension registry used to resolve custom constraints and types. */
|
|
1319
|
+
readonly extensionRegistry?: ExtensionRegistry;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* A machine-readable validation diagnostic returned by static schema analysis.
|
|
1324
|
+
*
|
|
1325
|
+
* @public
|
|
1326
|
+
*/
|
|
1327
|
+
export declare interface ValidationDiagnostic {
|
|
1328
|
+
/** Stable machine-readable diagnostic code. */
|
|
1329
|
+
readonly code: string;
|
|
1330
|
+
/** Human-readable explanation of the validation problem. */
|
|
1331
|
+
readonly message: string;
|
|
1332
|
+
/** Severity of the reported validation problem. */
|
|
1333
|
+
readonly severity: ValidationDiagnosticSeverity;
|
|
1334
|
+
/** Primary source location associated with the diagnostic. */
|
|
1335
|
+
readonly primaryLocation: ValidationDiagnosticLocation;
|
|
1336
|
+
/** Related source locations that add context to the diagnostic. */
|
|
1337
|
+
readonly relatedLocations: readonly ValidationDiagnosticLocation[];
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Public source-location shape attached to validation diagnostics.
|
|
1342
|
+
*
|
|
1343
|
+
* This mirrors the provenance information surfaced by the shared analysis
|
|
1344
|
+
* layer without exposing `@formspec/core/internals` through the public API.
|
|
1345
|
+
*
|
|
1346
|
+
* @public
|
|
1347
|
+
*/
|
|
1348
|
+
export declare interface ValidationDiagnosticLocation {
|
|
1349
|
+
/** Authoring surface that produced the diagnostic location. */
|
|
1350
|
+
readonly surface: "tsdoc" | "chain-dsl" | "extension" | "inferred";
|
|
1351
|
+
/** Absolute path to the source file. */
|
|
1352
|
+
readonly file: string;
|
|
1353
|
+
/** 1-based line number in the source file. */
|
|
1354
|
+
readonly line: number;
|
|
1355
|
+
/** 0-based column number in the source file. */
|
|
1356
|
+
readonly column: number;
|
|
1357
|
+
/** Optional span length in characters. */
|
|
1358
|
+
readonly length?: number;
|
|
1359
|
+
/** Optional tag or construct associated with the location. */
|
|
1360
|
+
readonly tagName?: string;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* Supported severity levels returned by static build validation.
|
|
1365
|
+
*
|
|
1366
|
+
* @public
|
|
1367
|
+
*/
|
|
1368
|
+
export declare type ValidationDiagnosticSeverity = "error" | "warning";
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* Result of validating canonical FormIR before schema emission.
|
|
1372
|
+
*
|
|
1373
|
+
* @public
|
|
1374
|
+
*/
|
|
1375
|
+
export declare interface ValidationResult {
|
|
1376
|
+
/** Diagnostics produced during validation. */
|
|
1377
|
+
readonly diagnostics: readonly ValidationDiagnostic[];
|
|
1378
|
+
/** Whether any error-severity diagnostics were produced. */
|
|
1379
|
+
readonly valid: boolean;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1119
1382
|
/**
|
|
1120
1383
|
* A vertical layout element.
|
|
1121
1384
|
*
|