@formspec/build 0.1.0-alpha.22 → 0.1.0-alpha.23
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 +9 -4
- package/dist/analyzer/class-analyzer.d.ts +1 -1
- package/dist/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/jsdoc-constraints.d.ts +1 -1
- package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/browser.cjs +5 -4
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +4 -3
- package/dist/browser.js.map +1 -1
- package/dist/build-alpha.d.ts +836 -0
- package/dist/build-beta.d.ts +836 -0
- package/dist/build-internal.d.ts +836 -0
- package/dist/build.d.ts +157 -538
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +2 -1
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -1
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts +1 -1
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -1
- package/dist/cli.cjs +82 -126
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +72 -116
- package/dist/cli.js.map +1 -1
- package/dist/generators/class-schema.d.ts +20 -3
- package/dist/generators/class-schema.d.ts.map +1 -1
- package/dist/generators/mixed-authoring.d.ts +3 -2
- package/dist/generators/mixed-authoring.d.ts.map +1 -1
- package/dist/index.cjs +79 -127
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -101
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +77 -15
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.d.ts +2 -1
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +69 -7
- package/dist/internals.js.map +1 -1
- package/dist/json-schema/generator.d.ts +8 -4
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/json-schema/ir-generator.d.ts +4 -4
- package/dist/json-schema/ir-generator.d.ts.map +1 -1
- package/dist/json-schema/schema.d.ts +2 -2
- package/dist/json-schema/types.d.ts +6 -6
- package/dist/ui-schema/ir-generator.d.ts +1 -1
- package/dist/ui-schema/ir-generator.d.ts.map +1 -1
- package/dist/ui-schema/schema.d.ts +28 -28
- package/dist/ui-schema/types.d.ts +152 -3
- package/dist/ui-schema/types.d.ts.map +1 -1
- package/dist/validate/constraint-validator.d.ts +1 -1
- package/dist/validate/constraint-validator.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/__tests__/alias-chain-propagation.test.d.ts +0 -9
- package/dist/__tests__/alias-chain-propagation.test.d.ts.map +0 -1
- package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts +0 -2
- package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts.map +0 -1
- package/dist/__tests__/class-schema.test.d.ts +0 -2
- package/dist/__tests__/class-schema.test.d.ts.map +0 -1
- package/dist/__tests__/cli.test.d.ts +0 -2
- package/dist/__tests__/cli.test.d.ts.map +0 -1
- package/dist/__tests__/constraint-validator.test.d.ts +0 -2
- package/dist/__tests__/constraint-validator.test.d.ts.map +0 -1
- package/dist/__tests__/date-extension.integration.test.d.ts +0 -2
- package/dist/__tests__/date-extension.integration.test.d.ts.map +0 -1
- package/dist/__tests__/edge-cases.test.d.ts +0 -7
- package/dist/__tests__/edge-cases.test.d.ts.map +0 -1
- package/dist/__tests__/extension-api.test.d.ts +0 -2
- package/dist/__tests__/extension-api.test.d.ts.map +0 -1
- package/dist/__tests__/extension-runtime.integration.test.d.ts +0 -2
- package/dist/__tests__/extension-runtime.integration.test.d.ts.map +0 -1
- package/dist/__tests__/fixtures/alias-chains.d.ts +0 -37
- package/dist/__tests__/fixtures/alias-chains.d.ts.map +0 -1
- package/dist/__tests__/fixtures/class-schema-regressions.d.ts +0 -86
- package/dist/__tests__/fixtures/class-schema-regressions.d.ts.map +0 -1
- package/dist/__tests__/fixtures/edge-cases.d.ts +0 -132
- package/dist/__tests__/fixtures/edge-cases.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-a-builtins.d.ts +0 -31
- package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-date-extension.d.ts +0 -12
- package/dist/__tests__/fixtures/example-date-extension.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-interface-types.d.ts +0 -107
- package/dist/__tests__/fixtures/example-interface-types.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-numeric-extension.d.ts +0 -20
- package/dist/__tests__/fixtures/example-numeric-extension.d.ts.map +0 -1
- package/dist/__tests__/fixtures/extension-forms.d.ts +0 -7
- package/dist/__tests__/fixtures/extension-forms.d.ts.map +0 -1
- package/dist/__tests__/fixtures/mixed-authoring-shipping-address.d.ts +0 -31
- package/dist/__tests__/fixtures/mixed-authoring-shipping-address.d.ts.map +0 -1
- package/dist/__tests__/fixtures/named-primitive-aliases.d.ts +0 -15
- package/dist/__tests__/fixtures/named-primitive-aliases.d.ts.map +0 -1
- package/dist/__tests__/fixtures/nested-array-path-constraints.d.ts +0 -14
- package/dist/__tests__/fixtures/nested-array-path-constraints.d.ts.map +0 -1
- package/dist/__tests__/fixtures/sample-forms.d.ts +0 -65
- package/dist/__tests__/fixtures/sample-forms.d.ts.map +0 -1
- package/dist/__tests__/generate-schemas.test.d.ts +0 -2
- package/dist/__tests__/generate-schemas.test.d.ts.map +0 -1
- package/dist/__tests__/generator.test.d.ts +0 -2
- package/dist/__tests__/generator.test.d.ts.map +0 -1
- package/dist/__tests__/guards.test.d.ts +0 -2
- package/dist/__tests__/guards.test.d.ts.map +0 -1
- package/dist/__tests__/integration.test.d.ts +0 -8
- package/dist/__tests__/integration.test.d.ts.map +0 -1
- package/dist/__tests__/ir-analyzer.test.d.ts +0 -11
- package/dist/__tests__/ir-analyzer.test.d.ts.map +0 -1
- package/dist/__tests__/ir-jsdoc-constraints.test.d.ts +0 -12
- package/dist/__tests__/ir-jsdoc-constraints.test.d.ts.map +0 -1
- package/dist/__tests__/ir-json-schema-generator.test.d.ts +0 -11
- package/dist/__tests__/ir-json-schema-generator.test.d.ts.map +0 -1
- package/dist/__tests__/ir-ui-schema-generator.test.d.ts +0 -2
- package/dist/__tests__/ir-ui-schema-generator.test.d.ts.map +0 -1
- package/dist/__tests__/mixed-authoring.test.d.ts +0 -2
- package/dist/__tests__/mixed-authoring.test.d.ts.map +0 -1
- package/dist/__tests__/numeric-extension.integration.test.d.ts +0 -2
- package/dist/__tests__/numeric-extension.integration.test.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts +0 -9
- package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts +0 -9
- package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts +0 -19
- package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts +0 -19
- package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts +0 -6
- package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts +0 -17
- package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts +0 -13
- package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts +0 -9
- package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts +0 -28
- package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts +0 -9
- package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts +0 -6
- package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts +0 -19
- package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts +0 -12
- package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts +0 -9
- package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts.map +0 -1
- package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts +0 -19
- package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts.map +0 -1
- package/dist/__tests__/parity/parity.test.d.ts +0 -18
- package/dist/__tests__/parity/parity.test.d.ts.map +0 -1
- package/dist/__tests__/parity/utils.d.ts +0 -152
- package/dist/__tests__/parity/utils.d.ts.map +0 -1
- package/dist/__tests__/path-target-parser.test.d.ts +0 -9
- package/dist/__tests__/path-target-parser.test.d.ts.map +0 -1
- package/dist/__tests__/write-schemas.test.d.ts +0 -2
- package/dist/__tests__/write-schemas.test.d.ts.map +0 -1
|
@@ -9,10 +9,11 @@ import type { UISchema } from "../ui-schema/types.js";
|
|
|
9
9
|
import { type IRClassAnalysis } from "../analyzer/class-analyzer.js";
|
|
10
10
|
import { type TSDocSource } from "../canonicalize/index.js";
|
|
11
11
|
import { type GenerateJsonSchemaFromIROptions, type JsonSchema2020 } from "../json-schema/ir-generator.js";
|
|
12
|
+
import type { ExtensionRegistry } from "../extensions/index.js";
|
|
12
13
|
/**
|
|
13
14
|
* Generated schemas for a class.
|
|
14
15
|
*
|
|
15
|
-
* @
|
|
16
|
+
* @beta
|
|
16
17
|
*/
|
|
17
18
|
export interface ClassSchemas {
|
|
18
19
|
/** JSON Schema 2020-12 for validation */
|
|
@@ -31,12 +32,28 @@ export interface ClassSchemas {
|
|
|
31
32
|
* @returns Generated JSON Schema and UI Schema
|
|
32
33
|
*/
|
|
33
34
|
export declare function generateClassSchemas(analysis: IRClassAnalysis, source?: TSDocSource, options?: GenerateJsonSchemaFromIROptions): ClassSchemas;
|
|
35
|
+
/**
|
|
36
|
+
* Shared options for schema generation flows that support custom extensions.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export interface StaticSchemaGenerationOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Registry used to resolve custom types, constraints, and annotations.
|
|
43
|
+
*/
|
|
44
|
+
readonly extensionRegistry?: ExtensionRegistry | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Vendor prefix for emitted extension keywords.
|
|
47
|
+
* @defaultValue "x-formspec"
|
|
48
|
+
*/
|
|
49
|
+
readonly vendorPrefix?: string | undefined;
|
|
50
|
+
}
|
|
34
51
|
/**
|
|
35
52
|
* Options for generating schemas from a decorated class.
|
|
36
53
|
*
|
|
37
54
|
* @public
|
|
38
55
|
*/
|
|
39
|
-
export interface GenerateFromClassOptions extends
|
|
56
|
+
export interface GenerateFromClassOptions extends StaticSchemaGenerationOptions {
|
|
40
57
|
/** Path to the TypeScript source file */
|
|
41
58
|
filePath: string;
|
|
42
59
|
/** Class name to analyze */
|
|
@@ -80,7 +97,7 @@ export declare function generateSchemasFromClass(options: GenerateFromClassOptio
|
|
|
80
97
|
*
|
|
81
98
|
* @public
|
|
82
99
|
*/
|
|
83
|
-
export interface GenerateSchemasOptions extends
|
|
100
|
+
export interface GenerateSchemasOptions extends StaticSchemaGenerationOptions {
|
|
84
101
|
/** Path to the TypeScript source file */
|
|
85
102
|
filePath: string;
|
|
86
103
|
/** Name of the exported class, interface, or type alias to analyze */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-schema.d.ts","sourceRoot":"","sources":["../../src/generators/class-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAMtD,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAEL,KAAK,+BAA+B,EACpC,KAAK,cAAc,EACpB,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"class-schema.d.ts","sourceRoot":"","sources":["../../src/generators/class-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAMtD,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAEL,KAAK,+BAA+B,EACpC,KAAK,cAAc,EACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,UAAU,EAAE,cAAc,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,EACzB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,+BAA+B,GACxC,YAAY,CAuBd;AAmBD;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3D;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5C;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAyB,SAAQ,6BAA6B;IAC7E,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,yCAAyC;IACzC,UAAU,EAAE,cAAc,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,wBAAwB,GAChC,uBAAuB,CAsBzB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAuB,SAAQ,6BAA6B;IAC3E,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,uBAAuB,CAOxF"}
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* dynamic enum or dynamic schema metadata.
|
|
8
8
|
*/
|
|
9
9
|
import type { FormElement, FormSpec } from "@formspec/core";
|
|
10
|
-
import type {
|
|
10
|
+
import type { JsonSchema2020 } from "../json-schema/ir-generator.js";
|
|
11
11
|
import type { UISchema } from "../ui-schema/types.js";
|
|
12
|
+
import type { StaticSchemaGenerationOptions } from "./class-schema.js";
|
|
12
13
|
/**
|
|
13
14
|
* Result of generating schemas from a mixed-authoring composition.
|
|
14
15
|
*
|
|
@@ -28,7 +29,7 @@ export interface MixedAuthoringSchemas {
|
|
|
28
29
|
*
|
|
29
30
|
* @public
|
|
30
31
|
*/
|
|
31
|
-
export interface BuildMixedAuthoringSchemasOptions extends
|
|
32
|
+
export interface BuildMixedAuthoringSchemasOptions extends StaticSchemaGenerationOptions {
|
|
32
33
|
/** Path to the TypeScript source file. */
|
|
33
34
|
readonly filePath: string;
|
|
34
35
|
/** Name of the class, interface, or type alias to analyze. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixed-authoring.d.ts","sourceRoot":"","sources":["../../src/generators/mixed-authoring.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mixed-authoring.d.ts","sourceRoot":"","sources":["../../src/generators/mixed-authoring.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iCAAkC,SAAQ,6BAA6B;IACtF,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2GAA2G;IAC3G,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,SAAS,WAAW,EAAE,CAAC,CAAC;CACrD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,iCAAiC,GACzC,qBAAqB,CAUvB"}
|
package/dist/index.cjs
CHANGED
|
@@ -32,36 +32,17 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
buildFormSchemas: () => buildFormSchemas,
|
|
34
34
|
buildMixedAuthoringSchemas: () => buildMixedAuthoringSchemas,
|
|
35
|
-
categorizationSchema: () => categorizationSchema,
|
|
36
|
-
categorySchema: () => categorySchema,
|
|
37
|
-
controlSchema: () => controlSchema,
|
|
38
35
|
createExtensionRegistry: () => createExtensionRegistry,
|
|
39
36
|
generateJsonSchema: () => generateJsonSchema,
|
|
40
|
-
generateJsonSchemaFromIR: () => generateJsonSchemaFromIR,
|
|
41
37
|
generateSchemas: () => generateSchemas,
|
|
42
38
|
generateSchemasFromClass: () => generateSchemasFromClass,
|
|
43
39
|
generateUiSchema: () => generateUiSchema,
|
|
44
|
-
getSchemaExtension: () => getSchemaExtension,
|
|
45
|
-
groupLayoutSchema: () => groupLayoutSchema,
|
|
46
|
-
horizontalLayoutSchema: () => horizontalLayoutSchema,
|
|
47
|
-
jsonSchema7Schema: () => jsonSchema7Schema,
|
|
48
|
-
jsonSchemaTypeSchema: () => jsonSchemaTypeSchema,
|
|
49
|
-
labelElementSchema: () => labelElementSchema,
|
|
50
|
-
ruleConditionSchema: () => ruleConditionSchema,
|
|
51
|
-
ruleEffectSchema: () => ruleEffectSchema,
|
|
52
|
-
ruleSchema: () => ruleSchema,
|
|
53
|
-
schemaBasedConditionSchema: () => schemaBasedConditionSchema,
|
|
54
|
-
setSchemaExtension: () => setSchemaExtension,
|
|
55
|
-
uiSchemaElementSchema: () => uiSchemaElementSchema,
|
|
56
|
-
uiSchemaElementTypeSchema: () => uiSchemaElementTypeSchema,
|
|
57
|
-
uiSchemaSchema: () => uiSchema,
|
|
58
|
-
verticalLayoutSchema: () => verticalLayoutSchema,
|
|
59
40
|
writeSchemas: () => writeSchemas
|
|
60
41
|
});
|
|
61
42
|
module.exports = __toCommonJS(index_exports);
|
|
62
43
|
|
|
63
44
|
// src/canonicalize/chain-dsl-canonicalizer.ts
|
|
64
|
-
var
|
|
45
|
+
var import_internals = require("@formspec/core/internals");
|
|
65
46
|
var CHAIN_DSL_PROVENANCE = {
|
|
66
47
|
surface: "chain-dsl",
|
|
67
48
|
file: "",
|
|
@@ -80,7 +61,7 @@ function isField(el) {
|
|
|
80
61
|
function canonicalizeChainDSL(form) {
|
|
81
62
|
return {
|
|
82
63
|
kind: "form-ir",
|
|
83
|
-
irVersion:
|
|
64
|
+
irVersion: import_internals.IR_VERSION,
|
|
84
65
|
elements: canonicalizeElements(form.elements),
|
|
85
66
|
rootAnnotations: [],
|
|
86
67
|
typeRegistry: {},
|
|
@@ -373,7 +354,7 @@ function buildObjectProperties(elements, insideConditional = false) {
|
|
|
373
354
|
}
|
|
374
355
|
|
|
375
356
|
// src/canonicalize/tsdoc-canonicalizer.ts
|
|
376
|
-
var
|
|
357
|
+
var import_internals2 = require("@formspec/core/internals");
|
|
377
358
|
function canonicalizeTSDoc(analysis, source) {
|
|
378
359
|
const file = source?.file ?? "";
|
|
379
360
|
const provenance = {
|
|
@@ -385,7 +366,7 @@ function canonicalizeTSDoc(analysis, source) {
|
|
|
385
366
|
const elements = assembleElements(analysis.fields, analysis.fieldLayouts, provenance);
|
|
386
367
|
return {
|
|
387
368
|
kind: "form-ir",
|
|
388
|
-
irVersion:
|
|
369
|
+
irVersion: import_internals2.IR_VERSION,
|
|
389
370
|
elements,
|
|
390
371
|
typeRegistry: analysis.typeRegistry,
|
|
391
372
|
...analysis.annotations !== void 0 && analysis.annotations.length > 0 && { rootAnnotations: analysis.annotations },
|
|
@@ -886,7 +867,8 @@ function assignVendorPrefixedExtensionKeywords(schema, extensionSchema, vendorPr
|
|
|
886
867
|
// src/json-schema/generator.ts
|
|
887
868
|
function generateJsonSchema(form, options) {
|
|
888
869
|
const ir = canonicalizeChainDSL(form);
|
|
889
|
-
|
|
870
|
+
const internalOptions = options?.vendorPrefix === void 0 ? void 0 : { vendorPrefix: options.vendorPrefix };
|
|
871
|
+
return generateJsonSchemaFromIR(ir, internalOptions);
|
|
890
872
|
}
|
|
891
873
|
|
|
892
874
|
// src/ui-schema/schema.ts
|
|
@@ -1122,14 +1104,6 @@ function generateUiSchema(form) {
|
|
|
1122
1104
|
var fs = __toESM(require("fs"), 1);
|
|
1123
1105
|
var path2 = __toESM(require("path"), 1);
|
|
1124
1106
|
|
|
1125
|
-
// src/json-schema/types.ts
|
|
1126
|
-
function setSchemaExtension(schema, key, value) {
|
|
1127
|
-
schema[key] = value;
|
|
1128
|
-
}
|
|
1129
|
-
function getSchemaExtension(schema, key) {
|
|
1130
|
-
return schema[key];
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
1107
|
// src/extensions/registry.ts
|
|
1134
1108
|
function createExtensionRegistry(extensions) {
|
|
1135
1109
|
const typeMap = /* @__PURE__ */ new Map();
|
|
@@ -1210,68 +1184,6 @@ function createExtensionRegistry(extensions) {
|
|
|
1210
1184
|
};
|
|
1211
1185
|
}
|
|
1212
1186
|
|
|
1213
|
-
// src/json-schema/schema.ts
|
|
1214
|
-
var import_zod3 = require("zod");
|
|
1215
|
-
var jsonSchemaTypeSchema = import_zod3.z.enum([
|
|
1216
|
-
"string",
|
|
1217
|
-
"number",
|
|
1218
|
-
"integer",
|
|
1219
|
-
"boolean",
|
|
1220
|
-
"object",
|
|
1221
|
-
"array",
|
|
1222
|
-
"null"
|
|
1223
|
-
]);
|
|
1224
|
-
var jsonSchema7Schema = import_zod3.z.lazy(
|
|
1225
|
-
() => import_zod3.z.object({
|
|
1226
|
-
$schema: import_zod3.z.string().optional(),
|
|
1227
|
-
$id: import_zod3.z.string().optional(),
|
|
1228
|
-
$ref: import_zod3.z.string().optional(),
|
|
1229
|
-
// Metadata
|
|
1230
|
-
title: import_zod3.z.string().optional(),
|
|
1231
|
-
description: import_zod3.z.string().optional(),
|
|
1232
|
-
deprecated: import_zod3.z.boolean().optional(),
|
|
1233
|
-
// Type
|
|
1234
|
-
type: import_zod3.z.union([jsonSchemaTypeSchema, import_zod3.z.array(jsonSchemaTypeSchema)]).optional(),
|
|
1235
|
-
// String validation
|
|
1236
|
-
minLength: import_zod3.z.number().optional(),
|
|
1237
|
-
maxLength: import_zod3.z.number().optional(),
|
|
1238
|
-
pattern: import_zod3.z.string().optional(),
|
|
1239
|
-
// Number validation
|
|
1240
|
-
minimum: import_zod3.z.number().optional(),
|
|
1241
|
-
maximum: import_zod3.z.number().optional(),
|
|
1242
|
-
exclusiveMinimum: import_zod3.z.number().optional(),
|
|
1243
|
-
exclusiveMaximum: import_zod3.z.number().optional(),
|
|
1244
|
-
// Enum
|
|
1245
|
-
enum: import_zod3.z.array(import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number(), import_zod3.z.boolean(), import_zod3.z.null()])).readonly().optional(),
|
|
1246
|
-
const: import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number(), import_zod3.z.boolean(), import_zod3.z.null()]).optional(),
|
|
1247
|
-
// Object
|
|
1248
|
-
properties: import_zod3.z.record(import_zod3.z.string(), jsonSchema7Schema).optional(),
|
|
1249
|
-
required: import_zod3.z.array(import_zod3.z.string()).optional(),
|
|
1250
|
-
additionalProperties: import_zod3.z.union([import_zod3.z.boolean(), jsonSchema7Schema]).optional(),
|
|
1251
|
-
// Array
|
|
1252
|
-
items: import_zod3.z.union([jsonSchema7Schema, import_zod3.z.array(jsonSchema7Schema)]).optional(),
|
|
1253
|
-
minItems: import_zod3.z.number().optional(),
|
|
1254
|
-
maxItems: import_zod3.z.number().optional(),
|
|
1255
|
-
// Composition
|
|
1256
|
-
allOf: import_zod3.z.array(jsonSchema7Schema).optional(),
|
|
1257
|
-
anyOf: import_zod3.z.array(jsonSchema7Schema).optional(),
|
|
1258
|
-
oneOf: import_zod3.z.array(jsonSchema7Schema).optional(),
|
|
1259
|
-
not: jsonSchema7Schema.optional(),
|
|
1260
|
-
// Conditional
|
|
1261
|
-
if: jsonSchema7Schema.optional(),
|
|
1262
|
-
then: jsonSchema7Schema.optional(),
|
|
1263
|
-
else: jsonSchema7Schema.optional(),
|
|
1264
|
-
// Format
|
|
1265
|
-
format: import_zod3.z.string().optional(),
|
|
1266
|
-
// Default
|
|
1267
|
-
default: import_zod3.z.unknown().optional(),
|
|
1268
|
-
// FormSpec extensions
|
|
1269
|
-
"x-formspec-source": import_zod3.z.string().optional(),
|
|
1270
|
-
"x-formspec-params": import_zod3.z.array(import_zod3.z.string()).readonly().optional(),
|
|
1271
|
-
"x-formspec-schemaSource": import_zod3.z.string().optional()
|
|
1272
|
-
}).passthrough()
|
|
1273
|
-
);
|
|
1274
|
-
|
|
1275
1187
|
// src/analyzer/program.ts
|
|
1276
1188
|
var ts4 = __toESM(require("typescript"), 1);
|
|
1277
1189
|
var path = __toESM(require("path"), 1);
|
|
@@ -1286,11 +1198,12 @@ var ts2 = __toESM(require("typescript"), 1);
|
|
|
1286
1198
|
var ts = __toESM(require("typescript"), 1);
|
|
1287
1199
|
var import_internal = require("@formspec/analysis/internal");
|
|
1288
1200
|
var import_tsdoc = require("@microsoft/tsdoc");
|
|
1289
|
-
var
|
|
1201
|
+
var import_internals3 = require("@formspec/core/internals");
|
|
1202
|
+
var import_internals4 = require("@formspec/core/internals");
|
|
1290
1203
|
var TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
|
|
1291
1204
|
function createFormSpecTSDocConfig(extensionTagNames = []) {
|
|
1292
1205
|
const config = new import_tsdoc.TSDocConfiguration();
|
|
1293
|
-
for (const tagName of Object.keys(
|
|
1206
|
+
for (const tagName of Object.keys(import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS)) {
|
|
1294
1207
|
config.addTagDefinition(
|
|
1295
1208
|
new import_tsdoc.TSDocTagDefinition({
|
|
1296
1209
|
tagName: "@" + tagName,
|
|
@@ -1333,10 +1246,71 @@ function sharedTagValueOptions(options) {
|
|
|
1333
1246
|
};
|
|
1334
1247
|
}
|
|
1335
1248
|
var SYNTHETIC_TYPE_FORMAT_FLAGS = ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
|
|
1249
|
+
function collectImportedNames(sourceFile) {
|
|
1250
|
+
const importedNames = /* @__PURE__ */ new Set();
|
|
1251
|
+
for (const statement of sourceFile.statements) {
|
|
1252
|
+
if (ts.isImportDeclaration(statement) && statement.importClause !== void 0) {
|
|
1253
|
+
const clause = statement.importClause;
|
|
1254
|
+
if (clause.name !== void 0) {
|
|
1255
|
+
importedNames.add(clause.name.text);
|
|
1256
|
+
}
|
|
1257
|
+
if (clause.namedBindings !== void 0) {
|
|
1258
|
+
if (ts.isNamedImports(clause.namedBindings)) {
|
|
1259
|
+
for (const specifier of clause.namedBindings.elements) {
|
|
1260
|
+
importedNames.add(specifier.name.text);
|
|
1261
|
+
}
|
|
1262
|
+
} else if (ts.isNamespaceImport(clause.namedBindings)) {
|
|
1263
|
+
importedNames.add(clause.namedBindings.name.text);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
continue;
|
|
1267
|
+
}
|
|
1268
|
+
if (ts.isImportEqualsDeclaration(statement)) {
|
|
1269
|
+
importedNames.add(statement.name.text);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
return importedNames;
|
|
1273
|
+
}
|
|
1274
|
+
function isNonReferenceIdentifier(node) {
|
|
1275
|
+
const parent = node.parent;
|
|
1276
|
+
if ((ts.isBindingElement(parent) || ts.isClassDeclaration(parent) || ts.isEnumDeclaration(parent) || ts.isEnumMember(parent) || ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) || ts.isImportSpecifier(parent) || ts.isInterfaceDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isMethodSignature(parent) || ts.isModuleDeclaration(parent) || ts.isNamespaceExport(parent) || ts.isNamespaceImport(parent) || ts.isParameter(parent) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent) || ts.isSetAccessorDeclaration(parent) || ts.isGetAccessorDeclaration(parent) || ts.isTypeAliasDeclaration(parent) || ts.isTypeParameterDeclaration(parent) || ts.isVariableDeclaration(parent)) && parent.name === node) {
|
|
1277
|
+
return true;
|
|
1278
|
+
}
|
|
1279
|
+
if ((ts.isPropertyAssignment(parent) || ts.isPropertyAccessExpression(parent)) && parent.name === node) {
|
|
1280
|
+
return true;
|
|
1281
|
+
}
|
|
1282
|
+
if (ts.isQualifiedName(parent) && parent.right === node) {
|
|
1283
|
+
return true;
|
|
1284
|
+
}
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
function statementReferencesImportedName(statement, importedNames) {
|
|
1288
|
+
let referencesImportedName = false;
|
|
1289
|
+
const visit = (node) => {
|
|
1290
|
+
if (referencesImportedName) {
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
if (ts.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
|
|
1294
|
+
referencesImportedName = true;
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
ts.forEachChild(node, visit);
|
|
1298
|
+
};
|
|
1299
|
+
visit(statement);
|
|
1300
|
+
return referencesImportedName;
|
|
1301
|
+
}
|
|
1336
1302
|
function buildSupportingDeclarations(sourceFile) {
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1303
|
+
const importedNames = collectImportedNames(sourceFile);
|
|
1304
|
+
return sourceFile.statements.filter((statement) => {
|
|
1305
|
+
if (ts.isImportDeclaration(statement)) return false;
|
|
1306
|
+
if (ts.isImportEqualsDeclaration(statement)) return false;
|
|
1307
|
+
if (ts.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0)
|
|
1308
|
+
return false;
|
|
1309
|
+
if (importedNames.size > 0 && statementReferencesImportedName(statement, importedNames)) {
|
|
1310
|
+
return false;
|
|
1311
|
+
}
|
|
1312
|
+
return true;
|
|
1313
|
+
}).map((statement) => statement.getText(sourceFile));
|
|
1340
1314
|
}
|
|
1341
1315
|
function renderSyntheticArgumentExpression(valueKind, argumentText) {
|
|
1342
1316
|
const trimmed = argumentText.trim();
|
|
@@ -1473,7 +1447,7 @@ function hasBuiltinConstraintBroadening(tagName, options) {
|
|
|
1473
1447
|
return broadenedTypeId !== void 0 && options?.extensionRegistry?.findBuiltinConstraintBroadening(broadenedTypeId, tagName) !== void 0;
|
|
1474
1448
|
}
|
|
1475
1449
|
function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, provenance, supportingDeclarations, options) {
|
|
1476
|
-
if (!(0,
|
|
1450
|
+
if (!(0, import_internals3.isBuiltinConstraintName)(tagName)) {
|
|
1477
1451
|
return [];
|
|
1478
1452
|
}
|
|
1479
1453
|
const checker = options?.checker;
|
|
@@ -1703,7 +1677,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1703
1677
|
}
|
|
1704
1678
|
}
|
|
1705
1679
|
for (const block of docComment.customBlocks) {
|
|
1706
|
-
const tagName = (0,
|
|
1680
|
+
const tagName = (0, import_internals3.normalizeConstraintTagName)(block.blockTag.tagName.substring(1));
|
|
1707
1681
|
const parsedTag = nextParsedTag(tagName);
|
|
1708
1682
|
if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
|
|
1709
1683
|
const text2 = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
|
|
@@ -1735,7 +1709,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1735
1709
|
}
|
|
1736
1710
|
if (TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
1737
1711
|
const text = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
|
|
1738
|
-
const expectedType = (0,
|
|
1712
|
+
const expectedType = (0, import_internals3.isBuiltinConstraintName)(tagName) ? import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
|
|
1739
1713
|
if (text === "" && expectedType !== "boolean") continue;
|
|
1740
1714
|
const provenance = parsedTag !== null ? provenanceForParsedTag(parsedTag, sourceFile, file) : provenanceForComment(range, sourceFile, file, tagName);
|
|
1741
1715
|
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
@@ -1963,7 +1937,7 @@ function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
|
|
|
1963
1937
|
function collectRawTextFallbacks(node, file) {
|
|
1964
1938
|
const fallbacks = /* @__PURE__ */ new Map();
|
|
1965
1939
|
for (const tag of ts.getJSDocTags(node)) {
|
|
1966
|
-
const tagName = (0,
|
|
1940
|
+
const tagName = (0, import_internals3.normalizeConstraintTagName)(tag.tagName.text);
|
|
1967
1941
|
if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
1968
1942
|
const commentText = getTagCommentText(tag)?.trim() ?? "";
|
|
1969
1943
|
if (commentText === "") continue;
|
|
@@ -3576,11 +3550,8 @@ function buildFormSchemas(form, options) {
|
|
|
3576
3550
|
};
|
|
3577
3551
|
}
|
|
3578
3552
|
function writeSchemas(form, options) {
|
|
3579
|
-
const { outDir, name = "schema", indent = 2,
|
|
3580
|
-
const buildOptions =
|
|
3581
|
-
extensionRegistry,
|
|
3582
|
-
vendorPrefix
|
|
3583
|
-
};
|
|
3553
|
+
const { outDir, name = "schema", indent = 2, vendorPrefix } = options;
|
|
3554
|
+
const buildOptions = vendorPrefix === void 0 ? void 0 : { vendorPrefix };
|
|
3584
3555
|
const { jsonSchema, uiSchema: uiSchema2 } = buildFormSchemas(form, buildOptions);
|
|
3585
3556
|
if (!fs.existsSync(outDir)) {
|
|
3586
3557
|
fs.mkdirSync(outDir, { recursive: true });
|
|
@@ -3595,30 +3566,11 @@ function writeSchemas(form, options) {
|
|
|
3595
3566
|
0 && (module.exports = {
|
|
3596
3567
|
buildFormSchemas,
|
|
3597
3568
|
buildMixedAuthoringSchemas,
|
|
3598
|
-
categorizationSchema,
|
|
3599
|
-
categorySchema,
|
|
3600
|
-
controlSchema,
|
|
3601
3569
|
createExtensionRegistry,
|
|
3602
3570
|
generateJsonSchema,
|
|
3603
|
-
generateJsonSchemaFromIR,
|
|
3604
3571
|
generateSchemas,
|
|
3605
3572
|
generateSchemasFromClass,
|
|
3606
3573
|
generateUiSchema,
|
|
3607
|
-
getSchemaExtension,
|
|
3608
|
-
groupLayoutSchema,
|
|
3609
|
-
horizontalLayoutSchema,
|
|
3610
|
-
jsonSchema7Schema,
|
|
3611
|
-
jsonSchemaTypeSchema,
|
|
3612
|
-
labelElementSchema,
|
|
3613
|
-
ruleConditionSchema,
|
|
3614
|
-
ruleEffectSchema,
|
|
3615
|
-
ruleSchema,
|
|
3616
|
-
schemaBasedConditionSchema,
|
|
3617
|
-
setSchemaExtension,
|
|
3618
|
-
uiSchemaElementSchema,
|
|
3619
|
-
uiSchemaElementTypeSchema,
|
|
3620
|
-
uiSchemaSchema,
|
|
3621
|
-
verticalLayoutSchema,
|
|
3622
3574
|
writeSchemas
|
|
3623
3575
|
});
|
|
3624
3576
|
//# sourceMappingURL=index.cjs.map
|