@formspec/build 0.1.0-alpha.30 → 0.1.0-alpha.32
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 +82 -5
- package/dist/analyzer/class-analyzer.d.ts +6 -0
- package/dist/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/browser.cjs +166 -24
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +166 -24
- package/dist/browser.js.map +1 -1
- package/dist/build-alpha.d.ts +180 -0
- package/dist/build-beta.d.ts +180 -0
- package/dist/build-internal.d.ts +180 -0
- package/dist/build.d.ts +180 -0
- package/dist/cli.cjs +584 -33
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +582 -33
- package/dist/cli.js.map +1 -1
- package/dist/generators/discovered-schema.d.ts +112 -0
- package/dist/generators/discovered-schema.d.ts.map +1 -0
- package/dist/index.cjs +573 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +565 -33
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +197 -33
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +197 -33
- package/dist/internals.js.map +1 -1
- package/dist/static-build.d.ts +61 -0
- package/dist/static-build.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import type { UISchema } from "../ui-schema/types.js";
|
|
3
|
+
import type { StaticBuildContext } from "../static-build.js";
|
|
4
|
+
import { type StaticSchemaGenerationOptions } from "./class-schema.js";
|
|
5
|
+
import { type JsonSchema2020 } from "../json-schema/ir-generator.js";
|
|
6
|
+
/**
|
|
7
|
+
* Generated schemas for a discovered declaration or signature type.
|
|
8
|
+
*
|
|
9
|
+
* `uiSchema` is `null` when the discovered type does not have an object-shaped
|
|
10
|
+
* root that can be represented as a JSON Forms layout.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export interface DiscoveredTypeSchemas {
|
|
15
|
+
/** JSON Schema 2020-12 for the resolved type. */
|
|
16
|
+
readonly jsonSchema: JsonSchema2020;
|
|
17
|
+
/** UI Schema for object-shaped roots, or `null` when not applicable. */
|
|
18
|
+
readonly uiSchema: UISchema | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Supported declaration kinds for declaration-driven schema generation.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export type SchemaSourceDeclaration = ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration;
|
|
26
|
+
/**
|
|
27
|
+
* Options for generating schemas from a resolved declaration.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export interface GenerateSchemasFromDeclarationOptions extends StaticSchemaGenerationOptions {
|
|
32
|
+
/** Supported build context used for checker access and related analysis. */
|
|
33
|
+
readonly context: StaticBuildContext;
|
|
34
|
+
/** Declaration to turn into schemas. */
|
|
35
|
+
readonly declaration: SchemaSourceDeclaration;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Options for generating schemas from a resolved TypeScript type.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export interface GenerateSchemasFromTypeOptions extends StaticSchemaGenerationOptions {
|
|
43
|
+
/** Supported build context used for checker access and related analysis. */
|
|
44
|
+
readonly context: StaticBuildContext;
|
|
45
|
+
/** TypeScript type to turn into schemas. */
|
|
46
|
+
readonly type: ts.Type;
|
|
47
|
+
/**
|
|
48
|
+
* Optional source node associated with the type.
|
|
49
|
+
*
|
|
50
|
+
* When provided, FormSpec uses it as the source location for provenance and
|
|
51
|
+
* inline-type analysis.
|
|
52
|
+
*/
|
|
53
|
+
readonly sourceNode?: ts.Node | undefined;
|
|
54
|
+
/** Optional logical name used for anonymous roots. */
|
|
55
|
+
readonly name?: string | undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Options for generating schemas from a method or function parameter type.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export interface GenerateSchemasFromParameterOptions extends StaticSchemaGenerationOptions {
|
|
63
|
+
/** Supported build context used for checker access and related analysis. */
|
|
64
|
+
readonly context: StaticBuildContext;
|
|
65
|
+
/** Parameter declaration whose type should be converted into schemas. */
|
|
66
|
+
readonly parameter: ts.ParameterDeclaration;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Options for generating schemas from a method or function return type.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export interface GenerateSchemasFromReturnTypeOptions extends StaticSchemaGenerationOptions {
|
|
74
|
+
/** Supported build context used for checker access and related analysis. */
|
|
75
|
+
readonly context: StaticBuildContext;
|
|
76
|
+
/** Signature declaration whose return type should be converted into schemas. */
|
|
77
|
+
readonly declaration: ts.SignatureDeclaration;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Generates schemas from a resolved declaration using the supported public
|
|
81
|
+
* static-build workflow.
|
|
82
|
+
*
|
|
83
|
+
* Named declarations reuse the same analyzer semantics as FormSpec's existing
|
|
84
|
+
* top-level generation APIs. Non-object type aliases fall back to the generic
|
|
85
|
+
* resolved-type entry point.
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
export declare function generateSchemasFromDeclaration(options: GenerateSchemasFromDeclarationOptions): DiscoveredTypeSchemas;
|
|
90
|
+
/**
|
|
91
|
+
* Generates schemas from a resolved TypeScript type.
|
|
92
|
+
*
|
|
93
|
+
* This is the advanced public entry point for build tooling that already uses
|
|
94
|
+
* the TypeScript compiler API to discover types before handing them to
|
|
95
|
+
* FormSpec.
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export declare function generateSchemasFromType(options: GenerateSchemasFromTypeOptions): DiscoveredTypeSchemas;
|
|
100
|
+
/**
|
|
101
|
+
* Generates schemas for a method or function parameter type.
|
|
102
|
+
*
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare function generateSchemasFromParameter(options: GenerateSchemasFromParameterOptions): DiscoveredTypeSchemas;
|
|
106
|
+
/**
|
|
107
|
+
* Generates schemas for a method or function return type.
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
|
|
112
|
+
//# sourceMappingURL=discovered-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovered-schema.d.ts","sourceRoot":"","sources":["../../src/generators/discovered-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAQjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAS7D,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAK/F;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,iDAAiD;IACjD,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAC/B,EAAE,CAAC,gBAAgB,GACnB,EAAE,CAAC,oBAAoB,GACvB,EAAE,CAAC,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,WAAW,qCAAsC,SAAQ,6BAA6B;IAC1F,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,wCAAwC;IACxC,QAAQ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