@formspec/build 0.1.0-alpha.13 → 0.1.0-alpha.15
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 +20 -20
- package/dist/__tests__/alias-chain-propagation.test.d.ts +9 -0
- package/dist/__tests__/alias-chain-propagation.test.d.ts.map +1 -0
- package/dist/__tests__/extension-runtime.integration.test.d.ts +2 -0
- package/dist/__tests__/extension-runtime.integration.test.d.ts.map +1 -0
- package/dist/__tests__/fixtures/alias-chains.d.ts +37 -0
- package/dist/__tests__/fixtures/alias-chains.d.ts.map +1 -0
- package/dist/__tests__/fixtures/edge-cases.d.ts +11 -0
- package/dist/__tests__/fixtures/edge-cases.d.ts.map +1 -1
- package/dist/__tests__/fixtures/example-a-builtins.d.ts +13 -13
- package/dist/__tests__/fixtures/example-interface-types.d.ts +33 -33
- package/dist/__tests__/fixtures/example-interface-types.d.ts.map +1 -1
- package/dist/__tests__/jsdoc-constraints.test.d.ts +4 -5
- package/dist/__tests__/jsdoc-constraints.test.d.ts.map +1 -1
- package/dist/__tests__/json-utils.test.d.ts +5 -0
- package/dist/__tests__/json-utils.test.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts +19 -0
- package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts +6 -0
- package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts +17 -0
- package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts +9 -0
- package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts +6 -0
- package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts +19 -0
- package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts.map +1 -0
- package/dist/__tests__/parity/utils.d.ts +6 -1
- package/dist/__tests__/parity/utils.d.ts.map +1 -1
- package/dist/__tests__/path-target-parser.test.d.ts +9 -0
- package/dist/__tests__/path-target-parser.test.d.ts.map +1 -0
- 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 +8 -52
- package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -1
- package/dist/analyzer/json-utils.d.ts +22 -0
- package/dist/analyzer/json-utils.d.ts.map +1 -0
- package/dist/analyzer/tsdoc-parser.d.ts +24 -12
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
- package/dist/browser.cjs +452 -94
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +15 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +450 -94
- package/dist/browser.js.map +1 -1
- package/dist/build.d.ts +132 -5
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts +3 -3
- package/dist/cli.cjs +406 -104
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +407 -104
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +386 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +386 -104
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +597 -172
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.js +597 -172
- package/dist/internals.js.map +1 -1
- package/dist/json-schema/generator.d.ts +8 -2
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/json-schema/ir-generator.d.ts +25 -2
- package/dist/json-schema/ir-generator.d.ts.map +1 -1
- package/dist/json-schema/types.d.ts +1 -1
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/validate/constraint-validator.d.ts +3 -7
- package/dist/validate/constraint-validator.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -3,37 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Extracts constraints and annotation tags from JSDoc comments on
|
|
5
5
|
* class/interface fields and returns canonical IR nodes directly:
|
|
6
|
-
* - {@link ConstraintNode} for set-influencing tags (@
|
|
7
|
-
* - {@link AnnotationNode} for value-influencing tags (@
|
|
6
|
+
* - {@link ConstraintNode} for set-influencing tags (@minimum, @pattern, etc.)
|
|
7
|
+
* - {@link AnnotationNode} for value-influencing tags (@displayName, etc.)
|
|
8
8
|
*
|
|
9
9
|
* The IR extraction path uses the official `@microsoft/tsdoc` parser for
|
|
10
|
-
*
|
|
11
|
-
* compiler JSDoc API for annotation tags (which contain underscores, e.g.
|
|
12
|
-
* `@Field_displayName`).
|
|
10
|
+
* all canonical tags.
|
|
13
11
|
*
|
|
14
|
-
* Supported constraints correspond to
|
|
15
|
-
*
|
|
12
|
+
* Supported constraints correspond to the built-in FormSpec constraint tags
|
|
13
|
+
* (e.g., `@minimum`, `@maximum`, `@pattern`).
|
|
16
14
|
*/
|
|
17
15
|
import * as ts from "typescript";
|
|
18
|
-
import {
|
|
19
|
-
/**
|
|
20
|
-
* A constraint argument value.
|
|
21
|
-
*/
|
|
22
|
-
export type ConstraintArg = string | number | boolean | null | ConstraintArg[] | {
|
|
23
|
-
[key: string]: ConstraintArg;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Extracted constraint information from a JSDoc tag.
|
|
27
|
-
* @deprecated Use {@link ConstraintNode} from the IR path instead.
|
|
28
|
-
*/
|
|
29
|
-
export interface ConstraintInfo {
|
|
30
|
-
/** Constraint name (e.g., "Minimum", "Pattern", "Field") */
|
|
31
|
-
name: string;
|
|
32
|
-
/** Constraint arguments as literal values */
|
|
33
|
-
args: ConstraintArg[];
|
|
34
|
-
/** Raw AST node (undefined for synthetic JSDoc constraint entries) */
|
|
35
|
-
node: ts.Decorator | undefined;
|
|
36
|
-
}
|
|
16
|
+
import type { ConstraintNode, AnnotationNode } from "@formspec/core";
|
|
37
17
|
/**
|
|
38
18
|
* Extracts constraints from JSDoc comments on a TypeScript AST node and returns
|
|
39
19
|
* canonical {@link ConstraintNode} objects.
|
|
@@ -47,14 +27,8 @@ export interface ConstraintInfo {
|
|
|
47
27
|
*/
|
|
48
28
|
export declare function extractJSDocConstraintNodes(node: ts.Node, file?: string): ConstraintNode[];
|
|
49
29
|
/**
|
|
50
|
-
* Extracts
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* Uses a hybrid approach:
|
|
54
|
-
* - `@deprecated` is extracted via the TSDoc parser (standard tag).
|
|
55
|
-
* - `@Field_displayName` and `@Field_description` are extracted via the
|
|
56
|
-
* TypeScript compiler JSDoc API because they contain underscores which
|
|
57
|
-
* are invalid in TSDoc tag names.
|
|
30
|
+
* Extracts canonical annotation tags from a node and returns
|
|
31
|
+
* {@link AnnotationNode} objects.
|
|
58
32
|
*
|
|
59
33
|
* @param node - The AST node to inspect for annotation tags
|
|
60
34
|
* @param file - Absolute path to the source file for provenance
|
|
@@ -74,22 +48,4 @@ export declare function hasDeprecatedTag(node: ts.Node): boolean;
|
|
|
74
48
|
* Only extracts literal values (strings, numbers, booleans, null).
|
|
75
49
|
*/
|
|
76
50
|
export declare function extractDefaultValueAnnotation(initializer: ts.Expression | undefined, file?: string): AnnotationNode | null;
|
|
77
|
-
/**
|
|
78
|
-
* Extracts JSDoc constraint tags and returns synthetic {@link ConstraintInfo}
|
|
79
|
-
* objects for backward compatibility with the decorator-based pipeline.
|
|
80
|
-
*
|
|
81
|
-
* Uses the TypeScript compiler JSDoc API (not TSDoc parser) to maintain
|
|
82
|
-
* identical behavior with the legacy pipeline.
|
|
83
|
-
*
|
|
84
|
-
* @deprecated Use {@link extractJSDocConstraintNodes} for IR output.
|
|
85
|
-
*/
|
|
86
|
-
export declare function extractJSDocConstraints(node: ts.Node): ConstraintInfo[];
|
|
87
|
-
/**
|
|
88
|
-
* Extracts `@Field_displayName` and `@Field_description` TSDoc tags
|
|
89
|
-
* and returns a synthetic `Field` {@link ConstraintInfo} for backward
|
|
90
|
-
* compatibility with the decorator-based pipeline.
|
|
91
|
-
*
|
|
92
|
-
* @deprecated Use {@link extractJSDocAnnotationNodes} for IR output.
|
|
93
|
-
*/
|
|
94
|
-
export declare function extractJSDocFieldMetadata(node: ts.Node): ConstraintInfo | null;
|
|
95
51
|
//# sourceMappingURL=jsdoc-constraints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsdoc-constraints.d.ts","sourceRoot":"","sources":["../../src/analyzer/jsdoc-constraints.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"jsdoc-constraints.d.ts","sourceRoot":"","sources":["../../src/analyzer/jsdoc-constraints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAOhF;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,SAAK,GAAG,cAAc,EAAE,CAGtF;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,SAAK,GAAG,cAAc,EAAE,CAGtF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAEvD;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,EAAE,CAAC,UAAU,GAAG,SAAS,EACtC,IAAI,SAAK,GACR,cAAc,GAAG,IAAI,CAwCvB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared JSON parsing utilities for the analyzer pipeline.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Attempts to parse `text` as JSON.
|
|
6
|
+
*
|
|
7
|
+
* Returns the parsed value on success, or `null` if the input is not valid
|
|
8
|
+
* JSON. This is the canonical "try-parse" wrapper used by the constraint tag
|
|
9
|
+
* parsers so that every `JSON.parse` call in this package is consistent and
|
|
10
|
+
* centrally tested.
|
|
11
|
+
*
|
|
12
|
+
* Note: when the input is the literal string `"null"`, the return value is
|
|
13
|
+
* also `null` (valid JSON). This helper therefore cannot distinguish parse
|
|
14
|
+
* failure from a successfully-parsed JSON `null`. Callers that need to
|
|
15
|
+
* distinguish these cases should use a different API (for example, a wrapper
|
|
16
|
+
* that returns a discriminated result such as `{ ok: boolean, value?: unknown }`).
|
|
17
|
+
*
|
|
18
|
+
* @param text - Raw string to parse
|
|
19
|
+
* @returns The parsed value, or `null` on parse failure
|
|
20
|
+
*/
|
|
21
|
+
export declare function tryParseJson(text: string): unknown;
|
|
22
|
+
//# sourceMappingURL=json-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-utils.d.ts","sourceRoot":"","sources":["../../src/analyzer/json-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMlD"}
|
|
@@ -8,14 +8,15 @@
|
|
|
8
8
|
* The parser recognises two categories of tags:
|
|
9
9
|
*
|
|
10
10
|
* 1. **Constraint tags** (all alphanumeric, TSDoc-compliant):
|
|
11
|
-
* `@
|
|
12
|
-
* `@
|
|
11
|
+
* `@minimum`, `@maximum`, `@exclusiveMinimum`, `@exclusiveMaximum`,
|
|
12
|
+
* `@multipleOf`, `@minLength`, `@maxLength`, `@minItems`, `@maxItems`,
|
|
13
|
+
* `@pattern`, `@enumOptions`
|
|
13
14
|
* — Parsed via TSDocParser as custom block tags.
|
|
15
|
+
* Both camelCase and PascalCase forms are accepted (e.g., `@Minimum`).
|
|
14
16
|
*
|
|
15
|
-
* 2. **Annotation tags** (`@
|
|
16
|
-
* These
|
|
17
|
-
*
|
|
18
|
-
* until a future migration to underscore-free tag names.
|
|
17
|
+
* 2. **Annotation tags** (`@displayName`, `@description`):
|
|
18
|
+
* These are parsed as structured custom block tags and mapped directly
|
|
19
|
+
* onto annotation IR nodes.
|
|
19
20
|
*
|
|
20
21
|
* The `@deprecated` tag is a standard TSDoc block tag, parsed structurally.
|
|
21
22
|
*
|
|
@@ -27,14 +28,14 @@
|
|
|
27
28
|
* verbatim.
|
|
28
29
|
*/
|
|
29
30
|
import * as ts from "typescript";
|
|
30
|
-
import { type ConstraintNode, type AnnotationNode } from "@formspec/core";
|
|
31
|
+
import { type ConstraintNode, type AnnotationNode, type PathTarget } from "@formspec/core";
|
|
31
32
|
/**
|
|
32
33
|
* Result of parsing a single JSDoc comment attached to a TS AST node.
|
|
33
34
|
*/
|
|
34
35
|
export interface TSDocParseResult {
|
|
35
36
|
/** Constraint IR nodes extracted from custom block tags. */
|
|
36
37
|
readonly constraints: readonly ConstraintNode[];
|
|
37
|
-
/** Annotation IR nodes extracted from
|
|
38
|
+
/** Annotation IR nodes extracted from canonical TSDoc block tags. */
|
|
38
39
|
readonly annotations: readonly AnnotationNode[];
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
@@ -42,10 +43,9 @@ export interface TSDocParseResult {
|
|
|
42
43
|
* official TSDoc parser and returns canonical IR constraint and annotation
|
|
43
44
|
* nodes.
|
|
44
45
|
*
|
|
45
|
-
* For constraint tags (`@
|
|
46
|
-
* the structured TSDoc parser is used.
|
|
47
|
-
*
|
|
48
|
-
* compiler JSDoc API is used as a fallback.
|
|
46
|
+
* For constraint tags (`@minimum`, `@pattern`, `@enumOptions`, etc.),
|
|
47
|
+
* the structured TSDoc parser is used. Canonical annotation tags
|
|
48
|
+
* (`@displayName`, `@description`) are also parsed structurally.
|
|
49
49
|
*
|
|
50
50
|
* @param node - The TS AST node to inspect (PropertyDeclaration, PropertySignature, etc.)
|
|
51
51
|
* @param file - Absolute source file path for provenance
|
|
@@ -58,4 +58,16 @@ export declare function parseTSDocTags(node: ts.Node, file?: string): TSDocParse
|
|
|
58
58
|
* Falls back to the TS compiler API for nodes without doc comments.
|
|
59
59
|
*/
|
|
60
60
|
export declare function hasDeprecatedTagTSDoc(node: ts.Node): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Extracts a path-target prefix (`:fieldName`) from constraint tag text.
|
|
63
|
+
* Returns the parsed PathTarget and remaining text, or null if no path target.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* extractPathTarget(":value 0") // → { path: { segments: ["value"] }, remainingText: "0" }
|
|
67
|
+
* extractPathTarget("42") // → null
|
|
68
|
+
*/
|
|
69
|
+
export declare function extractPathTarget(text: string): {
|
|
70
|
+
path: PathTarget;
|
|
71
|
+
remainingText: string;
|
|
72
|
+
} | null;
|
|
61
73
|
//# sourceMappingURL=tsdoc-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdoc-parser.d.ts","sourceRoot":"","sources":["../../src/analyzer/tsdoc-parser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tsdoc-parser.d.ts","sourceRoot":"","sources":["../../src/analyzer/tsdoc-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAYjC,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,cAAc,EAInB,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAwFxB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;CACjD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,SAAK,GAAG,gBAAgB,CAkGzE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAsB5D;AAMD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQpD"}
|