@formspec/build 0.1.0-alpha.21 → 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
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* downstream phases (validation, JSON Schema generation, UI Schema generation)
|
|
8
8
|
* consume.
|
|
9
9
|
*/
|
|
10
|
-
import type { FormElement, FormSpec
|
|
10
|
+
import type { FormElement, FormSpec } from "@formspec/core";
|
|
11
|
+
import type { FormIR } from "@formspec/core/internals";
|
|
11
12
|
/**
|
|
12
13
|
* Translates a chain DSL `FormSpec` into the canonical `FormIR`.
|
|
13
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-dsl-canonicalizer.d.ts","sourceRoot":"","sources":["../../src/canonicalize/chain-dsl-canonicalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EASV,WAAW,EACX,QAAQ,
|
|
1
|
+
{"version":3,"file":"chain-dsl-canonicalizer.d.ts","sourceRoot":"","sources":["../../src/canonicalize/chain-dsl-canonicalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EASV,WAAW,EACX,QAAQ,EAMT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAYV,MAAM,EAYP,MAAM,0BAA0B,CAAC;AAqClC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,WAAW,EAAE,CAAC,GAAG,MAAM,CASnF"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* the layout metadata to wrap fields in `GroupLayoutNode` and
|
|
9
9
|
* `ConditionalLayoutNode` elements.
|
|
10
10
|
*/
|
|
11
|
-
import type { FormIR } from "@formspec/core";
|
|
11
|
+
import type { FormIR } from "@formspec/core/internals";
|
|
12
12
|
import type { IRClassAnalysis } from "../analyzer/class-analyzer.js";
|
|
13
13
|
/**
|
|
14
14
|
* Source-level metadata for provenance tracking.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdoc-canonicalizer.d.ts","sourceRoot":"","sources":["../../src/canonicalize/tsdoc-canonicalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,MAAM,EAMP,MAAM,
|
|
1
|
+
{"version":3,"file":"tsdoc-canonicalizer.d.ts","sourceRoot":"","sources":["../../src/canonicalize/tsdoc-canonicalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,MAAM,EAMP,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,eAAe,EAAuB,MAAM,+BAA+B,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAuBzF"}
|
package/dist/cli.cjs
CHANGED
|
@@ -43,7 +43,7 @@ function isField(el) {
|
|
|
43
43
|
function canonicalizeChainDSL(form) {
|
|
44
44
|
return {
|
|
45
45
|
kind: "form-ir",
|
|
46
|
-
irVersion:
|
|
46
|
+
irVersion: import_internals.IR_VERSION,
|
|
47
47
|
elements: canonicalizeElements(form.elements),
|
|
48
48
|
rootAnnotations: [],
|
|
49
49
|
typeRegistry: {},
|
|
@@ -334,11 +334,11 @@ function buildObjectProperties(elements, insideConditional = false) {
|
|
|
334
334
|
}
|
|
335
335
|
return properties;
|
|
336
336
|
}
|
|
337
|
-
var
|
|
337
|
+
var import_internals, CHAIN_DSL_PROVENANCE;
|
|
338
338
|
var init_chain_dsl_canonicalizer = __esm({
|
|
339
339
|
"src/canonicalize/chain-dsl-canonicalizer.ts"() {
|
|
340
340
|
"use strict";
|
|
341
|
-
|
|
341
|
+
import_internals = require("@formspec/core/internals");
|
|
342
342
|
CHAIN_DSL_PROVENANCE = {
|
|
343
343
|
surface: "chain-dsl",
|
|
344
344
|
file: "",
|
|
@@ -360,7 +360,7 @@ function canonicalizeTSDoc(analysis, source) {
|
|
|
360
360
|
const elements = assembleElements(analysis.fields, analysis.fieldLayouts, provenance);
|
|
361
361
|
return {
|
|
362
362
|
kind: "form-ir",
|
|
363
|
-
irVersion:
|
|
363
|
+
irVersion: import_internals2.IR_VERSION,
|
|
364
364
|
elements,
|
|
365
365
|
typeRegistry: analysis.typeRegistry,
|
|
366
366
|
...analysis.annotations !== void 0 && analysis.annotations.length > 0 && { rootAnnotations: analysis.annotations },
|
|
@@ -422,11 +422,11 @@ function wrapInConditional(field, layout, provenance) {
|
|
|
422
422
|
};
|
|
423
423
|
return conditional;
|
|
424
424
|
}
|
|
425
|
-
var
|
|
425
|
+
var import_internals2;
|
|
426
426
|
var init_tsdoc_canonicalizer = __esm({
|
|
427
427
|
"src/canonicalize/tsdoc-canonicalizer.ts"() {
|
|
428
428
|
"use strict";
|
|
429
|
-
|
|
429
|
+
import_internals2 = require("@formspec/core/internals");
|
|
430
430
|
}
|
|
431
431
|
});
|
|
432
432
|
|
|
@@ -882,7 +882,8 @@ var init_ir_generator = __esm({
|
|
|
882
882
|
// src/json-schema/generator.ts
|
|
883
883
|
function generateJsonSchema(form, options) {
|
|
884
884
|
const ir = canonicalizeChainDSL(form);
|
|
885
|
-
|
|
885
|
+
const internalOptions = options?.vendorPrefix === void 0 ? void 0 : { vendorPrefix: options.vendorPrefix };
|
|
886
|
+
return generateJsonSchemaFromIR(ir, internalOptions);
|
|
886
887
|
}
|
|
887
888
|
var init_generator = __esm({
|
|
888
889
|
"src/json-schema/generator.ts"() {
|
|
@@ -1141,19 +1142,6 @@ var init_generator2 = __esm({
|
|
|
1141
1142
|
}
|
|
1142
1143
|
});
|
|
1143
1144
|
|
|
1144
|
-
// src/json-schema/types.ts
|
|
1145
|
-
function setSchemaExtension(schema, key, value) {
|
|
1146
|
-
schema[key] = value;
|
|
1147
|
-
}
|
|
1148
|
-
function getSchemaExtension(schema, key) {
|
|
1149
|
-
return schema[key];
|
|
1150
|
-
}
|
|
1151
|
-
var init_types = __esm({
|
|
1152
|
-
"src/json-schema/types.ts"() {
|
|
1153
|
-
"use strict";
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
|
|
1157
1145
|
// src/extensions/registry.ts
|
|
1158
1146
|
function createExtensionRegistry(extensions) {
|
|
1159
1147
|
const typeMap = /* @__PURE__ */ new Map();
|
|
@@ -1247,78 +1235,10 @@ var init_extensions = __esm({
|
|
|
1247
1235
|
}
|
|
1248
1236
|
});
|
|
1249
1237
|
|
|
1250
|
-
// src/json-schema/schema.ts
|
|
1251
|
-
var import_zod3, jsonSchemaTypeSchema, jsonSchema7Schema;
|
|
1252
|
-
var init_schema2 = __esm({
|
|
1253
|
-
"src/json-schema/schema.ts"() {
|
|
1254
|
-
"use strict";
|
|
1255
|
-
import_zod3 = require("zod");
|
|
1256
|
-
jsonSchemaTypeSchema = import_zod3.z.enum([
|
|
1257
|
-
"string",
|
|
1258
|
-
"number",
|
|
1259
|
-
"integer",
|
|
1260
|
-
"boolean",
|
|
1261
|
-
"object",
|
|
1262
|
-
"array",
|
|
1263
|
-
"null"
|
|
1264
|
-
]);
|
|
1265
|
-
jsonSchema7Schema = import_zod3.z.lazy(
|
|
1266
|
-
() => import_zod3.z.object({
|
|
1267
|
-
$schema: import_zod3.z.string().optional(),
|
|
1268
|
-
$id: import_zod3.z.string().optional(),
|
|
1269
|
-
$ref: import_zod3.z.string().optional(),
|
|
1270
|
-
// Metadata
|
|
1271
|
-
title: import_zod3.z.string().optional(),
|
|
1272
|
-
description: import_zod3.z.string().optional(),
|
|
1273
|
-
deprecated: import_zod3.z.boolean().optional(),
|
|
1274
|
-
// Type
|
|
1275
|
-
type: import_zod3.z.union([jsonSchemaTypeSchema, import_zod3.z.array(jsonSchemaTypeSchema)]).optional(),
|
|
1276
|
-
// String validation
|
|
1277
|
-
minLength: import_zod3.z.number().optional(),
|
|
1278
|
-
maxLength: import_zod3.z.number().optional(),
|
|
1279
|
-
pattern: import_zod3.z.string().optional(),
|
|
1280
|
-
// Number validation
|
|
1281
|
-
minimum: import_zod3.z.number().optional(),
|
|
1282
|
-
maximum: import_zod3.z.number().optional(),
|
|
1283
|
-
exclusiveMinimum: import_zod3.z.number().optional(),
|
|
1284
|
-
exclusiveMaximum: import_zod3.z.number().optional(),
|
|
1285
|
-
// Enum
|
|
1286
|
-
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(),
|
|
1287
|
-
const: import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number(), import_zod3.z.boolean(), import_zod3.z.null()]).optional(),
|
|
1288
|
-
// Object
|
|
1289
|
-
properties: import_zod3.z.record(import_zod3.z.string(), jsonSchema7Schema).optional(),
|
|
1290
|
-
required: import_zod3.z.array(import_zod3.z.string()).optional(),
|
|
1291
|
-
additionalProperties: import_zod3.z.union([import_zod3.z.boolean(), jsonSchema7Schema]).optional(),
|
|
1292
|
-
// Array
|
|
1293
|
-
items: import_zod3.z.union([jsonSchema7Schema, import_zod3.z.array(jsonSchema7Schema)]).optional(),
|
|
1294
|
-
minItems: import_zod3.z.number().optional(),
|
|
1295
|
-
maxItems: import_zod3.z.number().optional(),
|
|
1296
|
-
// Composition
|
|
1297
|
-
allOf: import_zod3.z.array(jsonSchema7Schema).optional(),
|
|
1298
|
-
anyOf: import_zod3.z.array(jsonSchema7Schema).optional(),
|
|
1299
|
-
oneOf: import_zod3.z.array(jsonSchema7Schema).optional(),
|
|
1300
|
-
not: jsonSchema7Schema.optional(),
|
|
1301
|
-
// Conditional
|
|
1302
|
-
if: jsonSchema7Schema.optional(),
|
|
1303
|
-
then: jsonSchema7Schema.optional(),
|
|
1304
|
-
else: jsonSchema7Schema.optional(),
|
|
1305
|
-
// Format
|
|
1306
|
-
format: import_zod3.z.string().optional(),
|
|
1307
|
-
// Default
|
|
1308
|
-
default: import_zod3.z.unknown().optional(),
|
|
1309
|
-
// FormSpec extensions
|
|
1310
|
-
"x-formspec-source": import_zod3.z.string().optional(),
|
|
1311
|
-
"x-formspec-params": import_zod3.z.array(import_zod3.z.string()).readonly().optional(),
|
|
1312
|
-
"x-formspec-schemaSource": import_zod3.z.string().optional()
|
|
1313
|
-
}).passthrough()
|
|
1314
|
-
);
|
|
1315
|
-
}
|
|
1316
|
-
});
|
|
1317
|
-
|
|
1318
1238
|
// src/analyzer/tsdoc-parser.ts
|
|
1319
1239
|
function createFormSpecTSDocConfig(extensionTagNames = []) {
|
|
1320
1240
|
const config = new import_tsdoc.TSDocConfiguration();
|
|
1321
|
-
for (const tagName of Object.keys(
|
|
1241
|
+
for (const tagName of Object.keys(import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS)) {
|
|
1322
1242
|
config.addTagDefinition(
|
|
1323
1243
|
new import_tsdoc.TSDocTagDefinition({
|
|
1324
1244
|
tagName: "@" + tagName,
|
|
@@ -1360,10 +1280,71 @@ function sharedTagValueOptions(options) {
|
|
|
1360
1280
|
...options?.fieldType !== void 0 ? { fieldType: options.fieldType } : {}
|
|
1361
1281
|
};
|
|
1362
1282
|
}
|
|
1283
|
+
function collectImportedNames(sourceFile) {
|
|
1284
|
+
const importedNames = /* @__PURE__ */ new Set();
|
|
1285
|
+
for (const statement of sourceFile.statements) {
|
|
1286
|
+
if (ts.isImportDeclaration(statement) && statement.importClause !== void 0) {
|
|
1287
|
+
const clause = statement.importClause;
|
|
1288
|
+
if (clause.name !== void 0) {
|
|
1289
|
+
importedNames.add(clause.name.text);
|
|
1290
|
+
}
|
|
1291
|
+
if (clause.namedBindings !== void 0) {
|
|
1292
|
+
if (ts.isNamedImports(clause.namedBindings)) {
|
|
1293
|
+
for (const specifier of clause.namedBindings.elements) {
|
|
1294
|
+
importedNames.add(specifier.name.text);
|
|
1295
|
+
}
|
|
1296
|
+
} else if (ts.isNamespaceImport(clause.namedBindings)) {
|
|
1297
|
+
importedNames.add(clause.namedBindings.name.text);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
continue;
|
|
1301
|
+
}
|
|
1302
|
+
if (ts.isImportEqualsDeclaration(statement)) {
|
|
1303
|
+
importedNames.add(statement.name.text);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
return importedNames;
|
|
1307
|
+
}
|
|
1308
|
+
function isNonReferenceIdentifier(node) {
|
|
1309
|
+
const parent = node.parent;
|
|
1310
|
+
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) {
|
|
1311
|
+
return true;
|
|
1312
|
+
}
|
|
1313
|
+
if ((ts.isPropertyAssignment(parent) || ts.isPropertyAccessExpression(parent)) && parent.name === node) {
|
|
1314
|
+
return true;
|
|
1315
|
+
}
|
|
1316
|
+
if (ts.isQualifiedName(parent) && parent.right === node) {
|
|
1317
|
+
return true;
|
|
1318
|
+
}
|
|
1319
|
+
return false;
|
|
1320
|
+
}
|
|
1321
|
+
function statementReferencesImportedName(statement, importedNames) {
|
|
1322
|
+
let referencesImportedName = false;
|
|
1323
|
+
const visit = (node) => {
|
|
1324
|
+
if (referencesImportedName) {
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
if (ts.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
|
|
1328
|
+
referencesImportedName = true;
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
ts.forEachChild(node, visit);
|
|
1332
|
+
};
|
|
1333
|
+
visit(statement);
|
|
1334
|
+
return referencesImportedName;
|
|
1335
|
+
}
|
|
1363
1336
|
function buildSupportingDeclarations(sourceFile) {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1337
|
+
const importedNames = collectImportedNames(sourceFile);
|
|
1338
|
+
return sourceFile.statements.filter((statement) => {
|
|
1339
|
+
if (ts.isImportDeclaration(statement)) return false;
|
|
1340
|
+
if (ts.isImportEqualsDeclaration(statement)) return false;
|
|
1341
|
+
if (ts.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0)
|
|
1342
|
+
return false;
|
|
1343
|
+
if (importedNames.size > 0 && statementReferencesImportedName(statement, importedNames)) {
|
|
1344
|
+
return false;
|
|
1345
|
+
}
|
|
1346
|
+
return true;
|
|
1347
|
+
}).map((statement) => statement.getText(sourceFile));
|
|
1367
1348
|
}
|
|
1368
1349
|
function renderSyntheticArgumentExpression(valueKind, argumentText) {
|
|
1369
1350
|
const trimmed = argumentText.trim();
|
|
@@ -1500,7 +1481,7 @@ function hasBuiltinConstraintBroadening(tagName, options) {
|
|
|
1500
1481
|
return broadenedTypeId !== void 0 && options?.extensionRegistry?.findBuiltinConstraintBroadening(broadenedTypeId, tagName) !== void 0;
|
|
1501
1482
|
}
|
|
1502
1483
|
function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, provenance, supportingDeclarations, options) {
|
|
1503
|
-
if (!(0,
|
|
1484
|
+
if (!(0, import_internals3.isBuiltinConstraintName)(tagName)) {
|
|
1504
1485
|
return [];
|
|
1505
1486
|
}
|
|
1506
1487
|
const checker = options?.checker;
|
|
@@ -1728,7 +1709,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1728
1709
|
}
|
|
1729
1710
|
}
|
|
1730
1711
|
for (const block of docComment.customBlocks) {
|
|
1731
|
-
const tagName = (0,
|
|
1712
|
+
const tagName = (0, import_internals3.normalizeConstraintTagName)(block.blockTag.tagName.substring(1));
|
|
1732
1713
|
const parsedTag = nextParsedTag(tagName);
|
|
1733
1714
|
if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
|
|
1734
1715
|
const text2 = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
|
|
@@ -1760,7 +1741,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
1760
1741
|
}
|
|
1761
1742
|
if (TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
1762
1743
|
const text = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
|
|
1763
|
-
const expectedType = (0,
|
|
1744
|
+
const expectedType = (0, import_internals3.isBuiltinConstraintName)(tagName) ? import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
|
|
1764
1745
|
if (text === "" && expectedType !== "boolean") continue;
|
|
1765
1746
|
const provenance = parsedTag !== null ? provenanceForParsedTag(parsedTag, sourceFile, file) : provenanceForComment(range, sourceFile, file, tagName);
|
|
1766
1747
|
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
@@ -1988,7 +1969,7 @@ function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
|
|
|
1988
1969
|
function collectRawTextFallbacks(node, file) {
|
|
1989
1970
|
const fallbacks = /* @__PURE__ */ new Map();
|
|
1990
1971
|
for (const tag of ts.getJSDocTags(node)) {
|
|
1991
|
-
const tagName = (0,
|
|
1972
|
+
const tagName = (0, import_internals3.normalizeConstraintTagName)(tag.tagName.text);
|
|
1992
1973
|
if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
1993
1974
|
const commentText = getTagCommentText(tag)?.trim() ?? "";
|
|
1994
1975
|
if (commentText === "") continue;
|
|
@@ -2044,14 +2025,15 @@ function getTagCommentText(tag) {
|
|
|
2044
2025
|
}
|
|
2045
2026
|
return ts.getTextOfJSDocComment(tag.comment);
|
|
2046
2027
|
}
|
|
2047
|
-
var ts, import_internal, import_tsdoc,
|
|
2028
|
+
var ts, import_internal, import_tsdoc, import_internals3, import_internals4, TAGS_REQUIRING_RAW_TEXT, SYNTHETIC_TYPE_FORMAT_FLAGS, parserCache, parseResultCache;
|
|
2048
2029
|
var init_tsdoc_parser = __esm({
|
|
2049
2030
|
"src/analyzer/tsdoc-parser.ts"() {
|
|
2050
2031
|
"use strict";
|
|
2051
2032
|
ts = __toESM(require("typescript"), 1);
|
|
2052
2033
|
import_internal = require("@formspec/analysis/internal");
|
|
2053
2034
|
import_tsdoc = require("@microsoft/tsdoc");
|
|
2054
|
-
|
|
2035
|
+
import_internals3 = require("@formspec/core/internals");
|
|
2036
|
+
import_internals4 = require("@formspec/core/internals");
|
|
2055
2037
|
TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
|
|
2056
2038
|
SYNTHETIC_TYPE_FORMAT_FLAGS = ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
|
|
2057
2039
|
parserCache = /* @__PURE__ */ new Map();
|
|
@@ -3672,30 +3654,11 @@ var index_exports = {};
|
|
|
3672
3654
|
__export(index_exports, {
|
|
3673
3655
|
buildFormSchemas: () => buildFormSchemas,
|
|
3674
3656
|
buildMixedAuthoringSchemas: () => buildMixedAuthoringSchemas,
|
|
3675
|
-
categorizationSchema: () => categorizationSchema,
|
|
3676
|
-
categorySchema: () => categorySchema,
|
|
3677
|
-
controlSchema: () => controlSchema,
|
|
3678
3657
|
createExtensionRegistry: () => createExtensionRegistry,
|
|
3679
3658
|
generateJsonSchema: () => generateJsonSchema,
|
|
3680
|
-
generateJsonSchemaFromIR: () => generateJsonSchemaFromIR,
|
|
3681
3659
|
generateSchemas: () => generateSchemas,
|
|
3682
3660
|
generateSchemasFromClass: () => generateSchemasFromClass,
|
|
3683
3661
|
generateUiSchema: () => generateUiSchema,
|
|
3684
|
-
getSchemaExtension: () => getSchemaExtension,
|
|
3685
|
-
groupLayoutSchema: () => groupLayoutSchema,
|
|
3686
|
-
horizontalLayoutSchema: () => horizontalLayoutSchema,
|
|
3687
|
-
jsonSchema7Schema: () => jsonSchema7Schema,
|
|
3688
|
-
jsonSchemaTypeSchema: () => jsonSchemaTypeSchema,
|
|
3689
|
-
labelElementSchema: () => labelElementSchema,
|
|
3690
|
-
ruleConditionSchema: () => ruleConditionSchema,
|
|
3691
|
-
ruleEffectSchema: () => ruleEffectSchema,
|
|
3692
|
-
ruleSchema: () => ruleSchema,
|
|
3693
|
-
schemaBasedConditionSchema: () => schemaBasedConditionSchema,
|
|
3694
|
-
setSchemaExtension: () => setSchemaExtension,
|
|
3695
|
-
uiSchemaElementSchema: () => uiSchemaElementSchema,
|
|
3696
|
-
uiSchemaElementTypeSchema: () => uiSchemaElementTypeSchema,
|
|
3697
|
-
uiSchemaSchema: () => uiSchema,
|
|
3698
|
-
verticalLayoutSchema: () => verticalLayoutSchema,
|
|
3699
3662
|
writeSchemas: () => writeSchemas
|
|
3700
3663
|
});
|
|
3701
3664
|
function buildFormSchemas(form, options) {
|
|
@@ -3705,11 +3668,8 @@ function buildFormSchemas(form, options) {
|
|
|
3705
3668
|
};
|
|
3706
3669
|
}
|
|
3707
3670
|
function writeSchemas(form, options) {
|
|
3708
|
-
const { outDir, name = "schema", indent = 2,
|
|
3709
|
-
const buildOptions =
|
|
3710
|
-
extensionRegistry,
|
|
3711
|
-
vendorPrefix
|
|
3712
|
-
};
|
|
3671
|
+
const { outDir, name = "schema", indent = 2, vendorPrefix } = options;
|
|
3672
|
+
const buildOptions = vendorPrefix === void 0 ? void 0 : { vendorPrefix };
|
|
3713
3673
|
const { jsonSchema, uiSchema: uiSchema2 } = buildFormSchemas(form, buildOptions);
|
|
3714
3674
|
if (!fs.existsSync(outDir)) {
|
|
3715
3675
|
fs.mkdirSync(outDir, { recursive: true });
|
|
@@ -3729,12 +3689,8 @@ var init_index = __esm({
|
|
|
3729
3689
|
init_ir_generator();
|
|
3730
3690
|
fs = __toESM(require("fs"), 1);
|
|
3731
3691
|
path2 = __toESM(require("path"), 1);
|
|
3732
|
-
init_types();
|
|
3733
3692
|
init_extensions();
|
|
3734
|
-
init_schema();
|
|
3735
|
-
init_schema2();
|
|
3736
3693
|
init_generator();
|
|
3737
|
-
init_ir_generator();
|
|
3738
3694
|
init_generator2();
|
|
3739
3695
|
init_class_schema();
|
|
3740
3696
|
init_mixed_authoring();
|