@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
package/dist/internals.cjs
CHANGED
|
@@ -50,7 +50,7 @@ __export(internals_exports, {
|
|
|
50
50
|
module.exports = __toCommonJS(internals_exports);
|
|
51
51
|
|
|
52
52
|
// src/canonicalize/chain-dsl-canonicalizer.ts
|
|
53
|
-
var
|
|
53
|
+
var import_internals = require("@formspec/core/internals");
|
|
54
54
|
var CHAIN_DSL_PROVENANCE = {
|
|
55
55
|
surface: "chain-dsl",
|
|
56
56
|
file: "",
|
|
@@ -69,7 +69,7 @@ function isField(el) {
|
|
|
69
69
|
function canonicalizeChainDSL(form) {
|
|
70
70
|
return {
|
|
71
71
|
kind: "form-ir",
|
|
72
|
-
irVersion:
|
|
72
|
+
irVersion: import_internals.IR_VERSION,
|
|
73
73
|
elements: canonicalizeElements(form.elements),
|
|
74
74
|
rootAnnotations: [],
|
|
75
75
|
typeRegistry: {},
|
|
@@ -362,7 +362,7 @@ function buildObjectProperties(elements, insideConditional = false) {
|
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
// src/canonicalize/tsdoc-canonicalizer.ts
|
|
365
|
-
var
|
|
365
|
+
var import_internals2 = require("@formspec/core/internals");
|
|
366
366
|
function canonicalizeTSDoc(analysis, source) {
|
|
367
367
|
const file = source?.file ?? "";
|
|
368
368
|
const provenance = {
|
|
@@ -374,7 +374,7 @@ function canonicalizeTSDoc(analysis, source) {
|
|
|
374
374
|
const elements = assembleElements(analysis.fields, analysis.fieldLayouts, provenance);
|
|
375
375
|
return {
|
|
376
376
|
kind: "form-ir",
|
|
377
|
-
irVersion:
|
|
377
|
+
irVersion: import_internals2.IR_VERSION,
|
|
378
378
|
elements,
|
|
379
379
|
typeRegistry: analysis.typeRegistry,
|
|
380
380
|
...analysis.annotations !== void 0 && analysis.annotations.length > 0 && { rootAnnotations: analysis.annotations },
|
|
@@ -451,11 +451,12 @@ var ts2 = __toESM(require("typescript"), 1);
|
|
|
451
451
|
var ts = __toESM(require("typescript"), 1);
|
|
452
452
|
var import_internal = require("@formspec/analysis/internal");
|
|
453
453
|
var import_tsdoc = require("@microsoft/tsdoc");
|
|
454
|
-
var
|
|
454
|
+
var import_internals3 = require("@formspec/core/internals");
|
|
455
|
+
var import_internals4 = require("@formspec/core/internals");
|
|
455
456
|
var TAGS_REQUIRING_RAW_TEXT = /* @__PURE__ */ new Set(["pattern", "enumOptions", "defaultValue"]);
|
|
456
457
|
function createFormSpecTSDocConfig(extensionTagNames = []) {
|
|
457
458
|
const config = new import_tsdoc.TSDocConfiguration();
|
|
458
|
-
for (const tagName of Object.keys(
|
|
459
|
+
for (const tagName of Object.keys(import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS)) {
|
|
459
460
|
config.addTagDefinition(
|
|
460
461
|
new import_tsdoc.TSDocTagDefinition({
|
|
461
462
|
tagName: "@" + tagName,
|
|
@@ -498,10 +499,71 @@ function sharedTagValueOptions(options) {
|
|
|
498
499
|
};
|
|
499
500
|
}
|
|
500
501
|
var SYNTHETIC_TYPE_FORMAT_FLAGS = ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
|
|
502
|
+
function collectImportedNames(sourceFile) {
|
|
503
|
+
const importedNames = /* @__PURE__ */ new Set();
|
|
504
|
+
for (const statement of sourceFile.statements) {
|
|
505
|
+
if (ts.isImportDeclaration(statement) && statement.importClause !== void 0) {
|
|
506
|
+
const clause = statement.importClause;
|
|
507
|
+
if (clause.name !== void 0) {
|
|
508
|
+
importedNames.add(clause.name.text);
|
|
509
|
+
}
|
|
510
|
+
if (clause.namedBindings !== void 0) {
|
|
511
|
+
if (ts.isNamedImports(clause.namedBindings)) {
|
|
512
|
+
for (const specifier of clause.namedBindings.elements) {
|
|
513
|
+
importedNames.add(specifier.name.text);
|
|
514
|
+
}
|
|
515
|
+
} else if (ts.isNamespaceImport(clause.namedBindings)) {
|
|
516
|
+
importedNames.add(clause.namedBindings.name.text);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
if (ts.isImportEqualsDeclaration(statement)) {
|
|
522
|
+
importedNames.add(statement.name.text);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return importedNames;
|
|
526
|
+
}
|
|
527
|
+
function isNonReferenceIdentifier(node) {
|
|
528
|
+
const parent = node.parent;
|
|
529
|
+
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) {
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
if ((ts.isPropertyAssignment(parent) || ts.isPropertyAccessExpression(parent)) && parent.name === node) {
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
535
|
+
if (ts.isQualifiedName(parent) && parent.right === node) {
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
function statementReferencesImportedName(statement, importedNames) {
|
|
541
|
+
let referencesImportedName = false;
|
|
542
|
+
const visit = (node) => {
|
|
543
|
+
if (referencesImportedName) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
if (ts.isIdentifier(node) && importedNames.has(node.text) && !isNonReferenceIdentifier(node)) {
|
|
547
|
+
referencesImportedName = true;
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
ts.forEachChild(node, visit);
|
|
551
|
+
};
|
|
552
|
+
visit(statement);
|
|
553
|
+
return referencesImportedName;
|
|
554
|
+
}
|
|
501
555
|
function buildSupportingDeclarations(sourceFile) {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
556
|
+
const importedNames = collectImportedNames(sourceFile);
|
|
557
|
+
return sourceFile.statements.filter((statement) => {
|
|
558
|
+
if (ts.isImportDeclaration(statement)) return false;
|
|
559
|
+
if (ts.isImportEqualsDeclaration(statement)) return false;
|
|
560
|
+
if (ts.isExportDeclaration(statement) && statement.moduleSpecifier !== void 0)
|
|
561
|
+
return false;
|
|
562
|
+
if (importedNames.size > 0 && statementReferencesImportedName(statement, importedNames)) {
|
|
563
|
+
return false;
|
|
564
|
+
}
|
|
565
|
+
return true;
|
|
566
|
+
}).map((statement) => statement.getText(sourceFile));
|
|
505
567
|
}
|
|
506
568
|
function renderSyntheticArgumentExpression(valueKind, argumentText) {
|
|
507
569
|
const trimmed = argumentText.trim();
|
|
@@ -638,7 +700,7 @@ function hasBuiltinConstraintBroadening(tagName, options) {
|
|
|
638
700
|
return broadenedTypeId !== void 0 && options?.extensionRegistry?.findBuiltinConstraintBroadening(broadenedTypeId, tagName) !== void 0;
|
|
639
701
|
}
|
|
640
702
|
function buildCompilerBackedConstraintDiagnostics(node, sourceFile, tagName, parsedTag, provenance, supportingDeclarations, options) {
|
|
641
|
-
if (!(0,
|
|
703
|
+
if (!(0, import_internals3.isBuiltinConstraintName)(tagName)) {
|
|
642
704
|
return [];
|
|
643
705
|
}
|
|
644
706
|
const checker = options?.checker;
|
|
@@ -868,7 +930,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
868
930
|
}
|
|
869
931
|
}
|
|
870
932
|
for (const block of docComment.customBlocks) {
|
|
871
|
-
const tagName = (0,
|
|
933
|
+
const tagName = (0, import_internals3.normalizeConstraintTagName)(block.blockTag.tagName.substring(1));
|
|
872
934
|
const parsedTag = nextParsedTag(tagName);
|
|
873
935
|
if (tagName === "displayName" || tagName === "format" || tagName === "placeholder") {
|
|
874
936
|
const text2 = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
|
|
@@ -900,7 +962,7 @@ function parseTSDocTags(node, file = "", options) {
|
|
|
900
962
|
}
|
|
901
963
|
if (TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
902
964
|
const text = getBestBlockPayloadText(parsedTag, commentText, range.pos, block);
|
|
903
|
-
const expectedType = (0,
|
|
965
|
+
const expectedType = (0, import_internals3.isBuiltinConstraintName)(tagName) ? import_internals3.BUILTIN_CONSTRAINT_DEFINITIONS[tagName] : void 0;
|
|
904
966
|
if (text === "" && expectedType !== "boolean") continue;
|
|
905
967
|
const provenance = parsedTag !== null ? provenanceForParsedTag(parsedTag, sourceFile, file) : provenanceForComment(range, sourceFile, file, tagName);
|
|
906
968
|
const compilerDiagnostics = buildCompilerBackedConstraintDiagnostics(
|
|
@@ -1128,7 +1190,7 @@ function getBestBlockPayloadText(tag, commentText, commentOffset, block) {
|
|
|
1128
1190
|
function collectRawTextFallbacks(node, file) {
|
|
1129
1191
|
const fallbacks = /* @__PURE__ */ new Map();
|
|
1130
1192
|
for (const tag of ts.getJSDocTags(node)) {
|
|
1131
|
-
const tagName = (0,
|
|
1193
|
+
const tagName = (0, import_internals3.normalizeConstraintTagName)(tag.tagName.text);
|
|
1132
1194
|
if (!TAGS_REQUIRING_RAW_TEXT.has(tagName)) continue;
|
|
1133
1195
|
const commentText = getTagCommentText(tag)?.trim() ?? "";
|
|
1134
1196
|
if (commentText === "") continue;
|
|
@@ -3245,7 +3307,7 @@ function createExtensionRegistry(extensions) {
|
|
|
3245
3307
|
}
|
|
3246
3308
|
|
|
3247
3309
|
// src/generators/method-schema.ts
|
|
3248
|
-
var
|
|
3310
|
+
var import_internals5 = require("@formspec/core/internals");
|
|
3249
3311
|
function typeToJsonSchema(type, checker) {
|
|
3250
3312
|
const typeRegistry = {};
|
|
3251
3313
|
const visiting = /* @__PURE__ */ new Set();
|
|
@@ -3253,7 +3315,7 @@ function typeToJsonSchema(type, checker) {
|
|
|
3253
3315
|
const fieldProvenance = { surface: "tsdoc", file: "", line: 0, column: 0 };
|
|
3254
3316
|
const ir = {
|
|
3255
3317
|
kind: "form-ir",
|
|
3256
|
-
irVersion:
|
|
3318
|
+
irVersion: import_internals5.IR_VERSION,
|
|
3257
3319
|
elements: [
|
|
3258
3320
|
{
|
|
3259
3321
|
kind: "field",
|