@formspec/build 0.1.0-alpha.2 → 0.1.0-alpha.20

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.
Files changed (177) hide show
  1. package/README.md +120 -0
  2. package/dist/__tests__/alias-chain-propagation.test.d.ts +9 -0
  3. package/dist/__tests__/alias-chain-propagation.test.d.ts.map +1 -0
  4. package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts +2 -0
  5. package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts.map +1 -0
  6. package/dist/__tests__/class-schema.test.d.ts +2 -0
  7. package/dist/__tests__/class-schema.test.d.ts.map +1 -0
  8. package/dist/__tests__/constraint-validator.test.d.ts +2 -0
  9. package/dist/__tests__/constraint-validator.test.d.ts.map +1 -0
  10. package/dist/__tests__/date-extension.integration.test.d.ts +2 -0
  11. package/dist/__tests__/date-extension.integration.test.d.ts.map +1 -0
  12. package/dist/__tests__/extension-api.test.d.ts +2 -0
  13. package/dist/__tests__/extension-api.test.d.ts.map +1 -0
  14. package/dist/__tests__/extension-runtime.integration.test.d.ts +2 -0
  15. package/dist/__tests__/extension-runtime.integration.test.d.ts.map +1 -0
  16. package/dist/__tests__/fixtures/alias-chains.d.ts +37 -0
  17. package/dist/__tests__/fixtures/alias-chains.d.ts.map +1 -0
  18. package/dist/__tests__/fixtures/class-schema-regressions.d.ts +87 -0
  19. package/dist/__tests__/fixtures/class-schema-regressions.d.ts.map +1 -0
  20. package/dist/__tests__/fixtures/edge-cases.d.ts +132 -0
  21. package/dist/__tests__/fixtures/edge-cases.d.ts.map +1 -0
  22. package/dist/__tests__/fixtures/example-a-builtins.d.ts +30 -0
  23. package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +1 -0
  24. package/dist/__tests__/fixtures/example-date-extension.d.ts +12 -0
  25. package/dist/__tests__/fixtures/example-date-extension.d.ts.map +1 -0
  26. package/dist/__tests__/fixtures/example-interface-types.d.ts +102 -0
  27. package/dist/__tests__/fixtures/example-interface-types.d.ts.map +1 -0
  28. package/dist/__tests__/fixtures/example-numeric-extension.d.ts +20 -0
  29. package/dist/__tests__/fixtures/example-numeric-extension.d.ts.map +1 -0
  30. package/dist/__tests__/fixtures/extension-forms.d.ts +7 -0
  31. package/dist/__tests__/fixtures/extension-forms.d.ts.map +1 -0
  32. package/dist/__tests__/fixtures/mixed-authoring-shipping-address.d.ts +31 -0
  33. package/dist/__tests__/fixtures/mixed-authoring-shipping-address.d.ts.map +1 -0
  34. package/dist/__tests__/fixtures/named-primitive-aliases.d.ts +15 -0
  35. package/dist/__tests__/fixtures/named-primitive-aliases.d.ts.map +1 -0
  36. package/dist/__tests__/fixtures/nested-array-path-constraints.d.ts +14 -0
  37. package/dist/__tests__/fixtures/nested-array-path-constraints.d.ts.map +1 -0
  38. package/dist/__tests__/fixtures/sample-forms.d.ts +65 -0
  39. package/dist/__tests__/fixtures/sample-forms.d.ts.map +1 -0
  40. package/dist/__tests__/generate-schemas.test.d.ts +2 -0
  41. package/dist/__tests__/generate-schemas.test.d.ts.map +1 -0
  42. package/dist/__tests__/guards.test.d.ts +2 -0
  43. package/dist/__tests__/guards.test.d.ts.map +1 -0
  44. package/dist/__tests__/ir-analyzer.test.d.ts +11 -0
  45. package/dist/__tests__/ir-analyzer.test.d.ts.map +1 -0
  46. package/dist/__tests__/ir-jsdoc-constraints.test.d.ts +12 -0
  47. package/dist/__tests__/ir-jsdoc-constraints.test.d.ts.map +1 -0
  48. package/dist/__tests__/ir-json-schema-generator.test.d.ts +11 -0
  49. package/dist/__tests__/ir-json-schema-generator.test.d.ts.map +1 -0
  50. package/dist/__tests__/ir-ui-schema-generator.test.d.ts +2 -0
  51. package/dist/__tests__/ir-ui-schema-generator.test.d.ts.map +1 -0
  52. package/dist/__tests__/mixed-authoring.test.d.ts +2 -0
  53. package/dist/__tests__/mixed-authoring.test.d.ts.map +1 -0
  54. package/dist/__tests__/numeric-extension.integration.test.d.ts +2 -0
  55. package/dist/__tests__/numeric-extension.integration.test.d.ts.map +1 -0
  56. package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts +9 -0
  57. package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts.map +1 -0
  58. package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts +9 -0
  59. package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts.map +1 -0
  60. package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts +19 -0
  61. package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts.map +1 -0
  62. package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts +19 -0
  63. package/dist/__tests__/parity/fixtures/plan-status/chain-dsl.d.ts.map +1 -0
  64. package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts +6 -0
  65. package/dist/__tests__/parity/fixtures/plan-status/expected-ir.d.ts.map +1 -0
  66. package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts +17 -0
  67. package/dist/__tests__/parity/fixtures/plan-status/tsdoc.d.ts.map +1 -0
  68. package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts +13 -0
  69. package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts.map +1 -0
  70. package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts +9 -0
  71. package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts.map +1 -0
  72. package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts +28 -0
  73. package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts.map +1 -0
  74. package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts +9 -0
  75. package/dist/__tests__/parity/fixtures/usd-cents/chain-dsl.d.ts.map +1 -0
  76. package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts +6 -0
  77. package/dist/__tests__/parity/fixtures/usd-cents/expected-ir.d.ts.map +1 -0
  78. package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts +19 -0
  79. package/dist/__tests__/parity/fixtures/usd-cents/tsdoc.d.ts.map +1 -0
  80. package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts +12 -0
  81. package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts.map +1 -0
  82. package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts +9 -0
  83. package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts.map +1 -0
  84. package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts +19 -0
  85. package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts.map +1 -0
  86. package/dist/__tests__/parity/parity.test.d.ts +18 -0
  87. package/dist/__tests__/parity/parity.test.d.ts.map +1 -0
  88. package/dist/__tests__/parity/utils.d.ts +151 -0
  89. package/dist/__tests__/parity/utils.d.ts.map +1 -0
  90. package/dist/__tests__/path-target-parser.test.d.ts +9 -0
  91. package/dist/__tests__/path-target-parser.test.d.ts.map +1 -0
  92. package/dist/analyzer/class-analyzer.d.ts +100 -0
  93. package/dist/analyzer/class-analyzer.d.ts.map +1 -0
  94. package/dist/analyzer/jsdoc-constraints.d.ts +53 -0
  95. package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -0
  96. package/dist/analyzer/program.d.ts +68 -0
  97. package/dist/analyzer/program.d.ts.map +1 -0
  98. package/dist/analyzer/tsdoc-parser.d.ts +122 -0
  99. package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
  100. package/dist/browser.cjs +1291 -0
  101. package/dist/browser.cjs.map +1 -0
  102. package/dist/browser.d.ts +73 -0
  103. package/dist/browser.d.ts.map +1 -0
  104. package/dist/browser.js +1242 -0
  105. package/dist/browser.js.map +1 -0
  106. package/dist/build.d.ts +996 -0
  107. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +18 -0
  108. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -0
  109. package/dist/canonicalize/index.d.ts +8 -0
  110. package/dist/canonicalize/index.d.ts.map +1 -0
  111. package/dist/canonicalize/tsdoc-canonicalizer.d.ts +34 -0
  112. package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
  113. package/dist/cli.cjs +3862 -0
  114. package/dist/cli.cjs.map +1 -0
  115. package/dist/cli.js +3826 -103
  116. package/dist/cli.js.map +1 -1
  117. package/dist/extensions/index.d.ts +8 -0
  118. package/dist/extensions/index.d.ts.map +1 -0
  119. package/dist/extensions/registry.d.ts +79 -0
  120. package/dist/extensions/registry.d.ts.map +1 -0
  121. package/dist/generators/class-schema.d.ts +99 -0
  122. package/dist/generators/class-schema.d.ts.map +1 -0
  123. package/dist/generators/method-schema.d.ts +65 -0
  124. package/dist/generators/method-schema.d.ts.map +1 -0
  125. package/dist/generators/mixed-authoring.d.ts +45 -0
  126. package/dist/generators/mixed-authoring.d.ts.map +1 -0
  127. package/dist/index.cjs +3627 -0
  128. package/dist/index.cjs.map +1 -0
  129. package/dist/index.d.ts +33 -8
  130. package/dist/index.d.ts.map +1 -1
  131. package/dist/index.js +3587 -106
  132. package/dist/index.js.map +1 -1
  133. package/dist/internals.cjs +3371 -0
  134. package/dist/internals.cjs.map +1 -0
  135. package/dist/internals.d.ts +30 -0
  136. package/dist/internals.d.ts.map +1 -0
  137. package/dist/internals.js +3345 -0
  138. package/dist/internals.js.map +1 -0
  139. package/dist/json-schema/generator.d.ts +16 -5
  140. package/dist/json-schema/generator.d.ts.map +1 -1
  141. package/dist/json-schema/ir-generator.d.ts +108 -0
  142. package/dist/json-schema/ir-generator.d.ts.map +1 -0
  143. package/dist/json-schema/schema.d.ts +16 -0
  144. package/dist/json-schema/schema.d.ts.map +1 -0
  145. package/dist/json-schema/types.d.ts +29 -2
  146. package/dist/json-schema/types.d.ts.map +1 -1
  147. package/dist/ui-schema/generator.d.ts +5 -0
  148. package/dist/ui-schema/generator.d.ts.map +1 -1
  149. package/dist/ui-schema/ir-generator.d.ts +53 -0
  150. package/dist/ui-schema/ir-generator.d.ts.map +1 -0
  151. package/dist/ui-schema/schema.d.ts +357 -0
  152. package/dist/ui-schema/schema.d.ts.map +1 -0
  153. package/dist/ui-schema/types.d.ts +8 -73
  154. package/dist/ui-schema/types.d.ts.map +1 -1
  155. package/dist/validate/constraint-validator.d.ts +23 -0
  156. package/dist/validate/constraint-validator.d.ts.map +1 -0
  157. package/dist/validate/index.d.ts +9 -0
  158. package/dist/validate/index.d.ts.map +1 -0
  159. package/package.json +27 -7
  160. package/dist/__tests__/cli.test.js +0 -178
  161. package/dist/__tests__/cli.test.js.map +0 -1
  162. package/dist/__tests__/edge-cases.test.js +0 -217
  163. package/dist/__tests__/edge-cases.test.js.map +0 -1
  164. package/dist/__tests__/generator.test.js +0 -225
  165. package/dist/__tests__/generator.test.js.map +0 -1
  166. package/dist/__tests__/integration.test.js +0 -163
  167. package/dist/__tests__/integration.test.js.map +0 -1
  168. package/dist/__tests__/write-schemas.test.js +0 -196
  169. package/dist/__tests__/write-schemas.test.js.map +0 -1
  170. package/dist/json-schema/generator.js +0 -161
  171. package/dist/json-schema/generator.js.map +0 -1
  172. package/dist/json-schema/types.js +0 -7
  173. package/dist/json-schema/types.js.map +0 -1
  174. package/dist/ui-schema/generator.js +0 -150
  175. package/dist/ui-schema/generator.js.map +0 -1
  176. package/dist/ui-schema/types.js +0 -8
  177. package/dist/ui-schema/types.js.map +0 -1
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Parity testing utilities.
3
+ *
4
+ * Provides:
5
+ * - `ProvenanceFree<T>` — type-level mapper that strips `provenance` fields from IR nodes
6
+ * - `stripProvenance(ir)` — runtime equivalent for `FormIR`
7
+ * - `compareIR(a, b)` — structured IR comparison after stripping provenance
8
+ * - narrow parity normalization for TSDoc-only helper types the chain DSL
9
+ * cannot express directly
10
+ *
11
+ * `ProvenanceFree<T>` is implemented as explicit per-type mapped interfaces
12
+ * rather than a generic deep-recursive mapped type. This keeps the type
13
+ * system's structural guarantees intact: if an IR node gains or loses a
14
+ * field, the provenance-free variants here will fail to compile, catching
15
+ * shape regressions at type-check time.
16
+ */
17
+ import type { FormIR, FormIRElement, PrimitiveTypeNode, EnumMember, DynamicTypeNode, CustomTypeNode, NumericConstraintNode, LengthConstraintNode, PatternConstraintNode, ArrayCardinalityConstraintNode, EnumMemberConstraintNode, ConstConstraintNode, CustomConstraintNode, DisplayNameAnnotationNode, DescriptionAnnotationNode, FormatAnnotationNode, PlaceholderAnnotationNode, DefaultValueAnnotationNode, DeprecatedAnnotationNode, FormatHintAnnotationNode, CustomAnnotationNode, JsonValue } from "@formspec/core";
18
+ /** Primitive type node has no `provenance` field — pass through unchanged. */
19
+ export type ProvenanceFreePrimitiveTypeNode = PrimitiveTypeNode;
20
+ /** Enum member has no `provenance` field. */
21
+ export type ProvenanceFreeEnumMember = EnumMember;
22
+ /** Enum type node has no `provenance` field. */
23
+ export interface ProvenanceFreeEnumTypeNode {
24
+ readonly kind: "enum";
25
+ readonly members: readonly ProvenanceFreeEnumMember[];
26
+ }
27
+ /** Array type node — items type is recursively provenance-free. */
28
+ export interface ProvenanceFreeArrayTypeNode {
29
+ readonly kind: "array";
30
+ readonly items: ProvenanceFreeTypeNode;
31
+ }
32
+ /** Object property with `provenance` stripped and nested types recursively mapped. */
33
+ export interface ProvenanceFreeObjectProperty {
34
+ readonly name: string;
35
+ readonly type: ProvenanceFreeTypeNode;
36
+ readonly optional: boolean;
37
+ readonly constraints: readonly ProvenanceFreeConstraintNode[];
38
+ readonly annotations: readonly ProvenanceFreeAnnotationNode[];
39
+ }
40
+ /** Object type node — properties are recursively provenance-free. */
41
+ export interface ProvenanceFreeObjectTypeNode {
42
+ readonly kind: "object";
43
+ readonly properties: readonly ProvenanceFreeObjectProperty[];
44
+ readonly additionalProperties: boolean;
45
+ }
46
+ /** Record type node — valueType is recursively provenance-free. */
47
+ export interface ProvenanceFreeRecordTypeNode {
48
+ readonly kind: "record";
49
+ readonly valueType: ProvenanceFreeTypeNode;
50
+ }
51
+ /** Union type node — members are recursively provenance-free. */
52
+ export interface ProvenanceFreeUnionTypeNode {
53
+ readonly kind: "union";
54
+ readonly members: readonly ProvenanceFreeTypeNode[];
55
+ }
56
+ /** Reference type node — type arguments are recursively provenance-free. */
57
+ export interface ProvenanceFreeReferenceTypeNode {
58
+ readonly kind: "reference";
59
+ readonly name: string;
60
+ readonly typeArguments: readonly ProvenanceFreeTypeNode[];
61
+ }
62
+ /** Dynamic type node has no `provenance` field — pass through unchanged. */
63
+ export type ProvenanceFreeDynamicTypeNode = DynamicTypeNode;
64
+ /** Custom type node has no `provenance` field — pass through unchanged. */
65
+ export type ProvenanceFreeCustomTypeNode = CustomTypeNode;
66
+ /** Union of all provenance-free type node variants. */
67
+ export type ProvenanceFreeTypeNode = ProvenanceFreePrimitiveTypeNode | ProvenanceFreeEnumTypeNode | ProvenanceFreeArrayTypeNode | ProvenanceFreeObjectTypeNode | ProvenanceFreeRecordTypeNode | ProvenanceFreeUnionTypeNode | ProvenanceFreeReferenceTypeNode | ProvenanceFreeDynamicTypeNode | ProvenanceFreeCustomTypeNode;
68
+ export type ProvenanceFreeNumericConstraintNode = Omit<NumericConstraintNode, "provenance">;
69
+ export type ProvenanceFreeLengthConstraintNode = Omit<LengthConstraintNode, "provenance">;
70
+ export type ProvenanceFreePatternConstraintNode = Omit<PatternConstraintNode, "provenance">;
71
+ export type ProvenanceFreeArrayCardinalityConstraintNode = Omit<ArrayCardinalityConstraintNode, "provenance">;
72
+ export type ProvenanceFreeEnumMemberConstraintNode = Omit<EnumMemberConstraintNode, "provenance">;
73
+ export type ProvenanceFreeConstConstraintNode = Omit<ConstConstraintNode, "provenance">;
74
+ export type ProvenanceFreeCustomConstraintNode = Omit<CustomConstraintNode, "provenance">;
75
+ export type ProvenanceFreeConstraintNode = ProvenanceFreeNumericConstraintNode | ProvenanceFreeLengthConstraintNode | ProvenanceFreePatternConstraintNode | ProvenanceFreeArrayCardinalityConstraintNode | ProvenanceFreeEnumMemberConstraintNode | ProvenanceFreeConstConstraintNode | ProvenanceFreeCustomConstraintNode;
76
+ export type ProvenanceFreeDisplayNameAnnotationNode = Omit<DisplayNameAnnotationNode, "provenance">;
77
+ export type ProvenanceFreeDescriptionAnnotationNode = Omit<DescriptionAnnotationNode, "provenance">;
78
+ export type ProvenanceFreeFormatAnnotationNode = Omit<FormatAnnotationNode, "provenance">;
79
+ export type ProvenanceFreePlaceholderAnnotationNode = Omit<PlaceholderAnnotationNode, "provenance">;
80
+ export type ProvenanceFreeDefaultValueAnnotationNode = Omit<DefaultValueAnnotationNode, "provenance">;
81
+ export type ProvenanceFreeDeprecatedAnnotationNode = Omit<DeprecatedAnnotationNode, "provenance">;
82
+ export type ProvenanceFreeFormatHintAnnotationNode = Omit<FormatHintAnnotationNode, "provenance">;
83
+ export type ProvenanceFreeCustomAnnotationNode = Omit<CustomAnnotationNode, "provenance">;
84
+ export type ProvenanceFreeAnnotationNode = ProvenanceFreeDisplayNameAnnotationNode | ProvenanceFreeDescriptionAnnotationNode | ProvenanceFreeFormatAnnotationNode | ProvenanceFreePlaceholderAnnotationNode | ProvenanceFreeDefaultValueAnnotationNode | ProvenanceFreeDeprecatedAnnotationNode | ProvenanceFreeFormatHintAnnotationNode | ProvenanceFreeCustomAnnotationNode;
85
+ /** Field node with `provenance` and `mergeHistory` stripped; nested structures recursively mapped. */
86
+ export interface ProvenanceFreeFieldNode {
87
+ readonly kind: "field";
88
+ readonly name: string;
89
+ readonly type: ProvenanceFreeTypeNode;
90
+ readonly required: boolean;
91
+ readonly constraints: readonly ProvenanceFreeConstraintNode[];
92
+ readonly annotations: readonly ProvenanceFreeAnnotationNode[];
93
+ }
94
+ /** Group layout node with `provenance` stripped; elements are recursively mapped. */
95
+ export interface ProvenanceFreeGroupLayoutNode {
96
+ readonly kind: "group";
97
+ readonly label: string;
98
+ readonly elements: readonly ProvenanceFreeFormIRElement[];
99
+ }
100
+ /** Conditional layout node with `provenance` stripped. */
101
+ export interface ProvenanceFreeConditionalLayoutNode {
102
+ readonly kind: "conditional";
103
+ readonly fieldName: string;
104
+ readonly value: JsonValue;
105
+ readonly elements: readonly ProvenanceFreeFormIRElement[];
106
+ }
107
+ /** Union of all provenance-free IR element types. */
108
+ export type ProvenanceFreeFormIRElement = ProvenanceFreeFieldNode | ProvenanceFreeGroupLayoutNode | ProvenanceFreeConditionalLayoutNode;
109
+ /** TypeDefinition with `provenance` stripped. */
110
+ export interface ProvenanceFreeTypeDefinition {
111
+ readonly name: string;
112
+ readonly type: ProvenanceFreeTypeNode;
113
+ readonly constraints?: readonly ProvenanceFreeConstraintNode[];
114
+ readonly annotations?: readonly ProvenanceFreeAnnotationNode[];
115
+ }
116
+ /** The top-level `FormIR` with all `provenance` fields stripped. */
117
+ export interface ProvenanceFreeFormIR {
118
+ readonly kind: "form-ir";
119
+ readonly irVersion: string;
120
+ readonly elements: readonly ProvenanceFreeFormIRElement[];
121
+ readonly typeRegistry: Record<string, ProvenanceFreeTypeDefinition>;
122
+ }
123
+ /**
124
+ * A structured description of a single difference between two IR trees.
125
+ * Path uses dot notation for object properties and `[n]` for array indices.
126
+ */
127
+ export interface IRDifference {
128
+ /** JSONPath-like string describing where the difference is located. */
129
+ readonly path: string;
130
+ readonly expected: unknown;
131
+ readonly actual: unknown;
132
+ }
133
+ /**
134
+ * Strips all `provenance` (and `mergeHistory`) fields from a `FormIRElement`,
135
+ * returning a `ProvenanceFreeFormIRElement`.
136
+ */
137
+ export declare function stripProvenanceFromElement(element: FormIRElement): ProvenanceFreeFormIRElement;
138
+ /**
139
+ * Strips all `provenance` and `mergeHistory` fields from a complete `FormIR`,
140
+ * returning a `ProvenanceFreeFormIR` suitable for structural comparison.
141
+ */
142
+ export declare function stripProvenance(ir: FormIR): ProvenanceFreeFormIR;
143
+ /**
144
+ * Compares two `FormIR` objects structurally after stripping provenance.
145
+ *
146
+ * Returns an empty array when the IRs are identical modulo provenance.
147
+ * Returns one `IRDifference` per divergence found, with a JSONPath-like
148
+ * path string indicating where the difference occurs.
149
+ */
150
+ export declare function compareIR(a: FormIR, b: FormIR): IRDifference[];
151
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 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,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;CAErE;AAMD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAMD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,aAAa,GAAG,2BAA2B,CAS9F;AAyID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,oBAAoB,CAwBhE;AAgFD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,EAAE,CAQ9D"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Unit tests for path-target extraction in TSDoc constraint tags.
3
+ *
4
+ * Covers both the low-level `extractPathTarget` helper and integration
5
+ * via `parseTSDocTags` to confirm that ConstraintNode objects carry the
6
+ * parsed `path` field when a `:identifier` prefix is present.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=path-target-parser.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-target-parser.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/path-target-parser.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Class analyzer for extracting fields, types, and JSDoc constraints.
3
+ *
4
+ * Produces `IRClassAnalysis` containing `FieldNode[]` and `typeRegistry`
5
+ * directly from class, interface, or type alias declarations.
6
+ * All downstream generation routes through the canonical FormIR.
7
+ */
8
+ import * as ts from "typescript";
9
+ import type { ConstraintSemanticDiagnostic } from "@formspec/analysis";
10
+ import type { FieldNode, TypeNode, AnnotationNode, TypeDefinition, JsonValue } from "@formspec/core";
11
+ import type { ExtensionRegistry } from "../extensions/index.js";
12
+ /**
13
+ * Layout metadata extracted from `@Group` and `@ShowWhen` TSDoc tags.
14
+ * One entry per field, in the same order as `fields`.
15
+ */
16
+ export interface FieldLayoutMetadata {
17
+ /** Group label from `@Group("label")`, or undefined if ungrouped. */
18
+ readonly groupLabel?: string;
19
+ /** ShowWhen condition from `@ShowWhen({ field, value })`, or undefined if always visible. */
20
+ readonly showWhen?: {
21
+ readonly field: string;
22
+ readonly value: JsonValue;
23
+ };
24
+ }
25
+ /**
26
+ * Result of analyzing a class/interface/type alias into canonical IR.
27
+ */
28
+ export interface IRClassAnalysis {
29
+ /** Type name */
30
+ readonly name: string;
31
+ /** Analyzed fields as canonical IR FieldNodes */
32
+ readonly fields: readonly FieldNode[];
33
+ /** Layout metadata per field (same order/length as `fields`). */
34
+ readonly fieldLayouts: readonly FieldLayoutMetadata[];
35
+ /** Named type definitions referenced by fields */
36
+ readonly typeRegistry: Record<string, TypeDefinition>;
37
+ /** Root-level metadata for the analyzed declaration. */
38
+ readonly annotations?: readonly AnnotationNode[];
39
+ /** Extraction-time diagnostics surfaced before IR validation. */
40
+ readonly diagnostics?: readonly ConstraintSemanticDiagnostic[];
41
+ /** Instance methods (retained for downstream method-schema generation) */
42
+ readonly instanceMethods: readonly MethodInfo[];
43
+ /** Static methods */
44
+ readonly staticMethods: readonly MethodInfo[];
45
+ }
46
+ /**
47
+ * Result of analyzing a type alias into IR — either success or error.
48
+ */
49
+ export type AnalyzeTypeAliasToIRResult = {
50
+ readonly ok: true;
51
+ readonly analysis: IRClassAnalysis;
52
+ } | {
53
+ readonly ok: false;
54
+ readonly error: string;
55
+ };
56
+ /**
57
+ * Analyzes a class declaration and produces canonical IR FieldNodes.
58
+ */
59
+ export declare function analyzeClassToIR(classDecl: ts.ClassDeclaration, checker: ts.TypeChecker, file?: string, extensionRegistry?: ExtensionRegistry): IRClassAnalysis;
60
+ /**
61
+ * Analyzes an interface declaration and produces canonical IR FieldNodes.
62
+ */
63
+ export declare function analyzeInterfaceToIR(interfaceDecl: ts.InterfaceDeclaration, checker: ts.TypeChecker, file?: string, extensionRegistry?: ExtensionRegistry): IRClassAnalysis;
64
+ /**
65
+ * Analyzes a type alias declaration and produces canonical IR FieldNodes.
66
+ */
67
+ export declare function analyzeTypeAliasToIR(typeAlias: ts.TypeAliasDeclaration, checker: ts.TypeChecker, file?: string, extensionRegistry?: ExtensionRegistry): AnalyzeTypeAliasToIRResult;
68
+ /**
69
+ * Resolves a TypeScript type to a canonical IR TypeNode.
70
+ */
71
+ export declare function resolveTypeNode(type: ts.Type, checker: ts.TypeChecker, file: string, typeRegistry: Record<string, TypeDefinition>, visiting: Set<ts.Type>, sourceNode?: ts.Node, extensionRegistry?: ExtensionRegistry, diagnostics?: ConstraintSemanticDiagnostic[]): TypeNode;
72
+ /**
73
+ * Analyzed method information.
74
+ */
75
+ export interface MethodInfo {
76
+ /** Method name */
77
+ name: string;
78
+ /** Method parameters */
79
+ parameters: ParameterInfo[];
80
+ /** Return type node */
81
+ returnTypeNode: ts.TypeNode | undefined;
82
+ /** Resolved return type */
83
+ returnType: ts.Type;
84
+ }
85
+ /**
86
+ * Analyzed parameter information.
87
+ */
88
+ export interface ParameterInfo {
89
+ /** Parameter name */
90
+ name: string;
91
+ /** TypeScript type node */
92
+ typeNode: ts.TypeNode | undefined;
93
+ /** Resolved type */
94
+ type: ts.Type;
95
+ /** If this is InferSchema<typeof X>, the export name X */
96
+ formSpecExportName: string | null;
97
+ /** Whether the parameter is optional (has ? or default value) */
98
+ optional: boolean;
99
+ }
100
+ //# sourceMappingURL=class-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-analyzer.d.ts","sourceRoot":"","sources":["../../src/analyzer/class-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EACV,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;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;IAClC,oBAAoB;IACpB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,0DAA0D;IAC1D,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iEAAiE;IACjE,QAAQ,EAAE,OAAO,CAAC;CACnB"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * JSDoc constraint and annotation extractor.
3
+ *
4
+ * Extracts constraints and annotation tags from JSDoc comments on
5
+ * class/interface fields and returns canonical IR nodes directly:
6
+ * - {@link ConstraintNode} for set-influencing tags (@minimum, @pattern, etc.)
7
+ * - {@link AnnotationNode} for value-influencing tags (@displayName, etc.)
8
+ *
9
+ * The IR extraction path uses the official `@microsoft/tsdoc` parser for
10
+ * all canonical tags.
11
+ *
12
+ * Supported constraints correspond to the built-in FormSpec constraint tags
13
+ * (e.g., `@minimum`, `@maximum`, `@pattern`).
14
+ */
15
+ import * as ts from "typescript";
16
+ import type { ConstraintNode, AnnotationNode } from "@formspec/core";
17
+ import { type ParseTSDocOptions, type TSDocParseResult } from "./tsdoc-parser.js";
18
+ export declare function extractJSDocParseResult(node: ts.Node, file?: string, options?: ParseTSDocOptions): TSDocParseResult;
19
+ /**
20
+ * Extracts constraints from JSDoc comments on a TypeScript AST node and returns
21
+ * canonical {@link ConstraintNode} objects.
22
+ *
23
+ * Uses the official `@microsoft/tsdoc` parser for structured tag extraction.
24
+ * Constraints are registered as custom block tags in the TSDoc configuration.
25
+ *
26
+ * @param node - The AST node to inspect for JSDoc tags
27
+ * @param file - Absolute path to the source file for provenance
28
+ * @returns Canonical constraint nodes for each valid constraint tag
29
+ */
30
+ export declare function extractJSDocConstraintNodes(node: ts.Node, file?: string, options?: ParseTSDocOptions): ConstraintNode[];
31
+ /**
32
+ * Extracts canonical annotation tags from a node and returns
33
+ * {@link AnnotationNode} objects.
34
+ *
35
+ * @param node - The AST node to inspect for annotation tags
36
+ * @param file - Absolute path to the source file for provenance
37
+ * @returns Canonical annotation nodes
38
+ */
39
+ export declare function extractJSDocAnnotationNodes(node: ts.Node, file?: string, options?: ParseTSDocOptions): AnnotationNode[];
40
+ /**
41
+ * Checks if a node has a TSDoc `@deprecated` tag.
42
+ *
43
+ * Uses the TSDoc parser for structured detection.
44
+ */
45
+ export declare function hasDeprecatedTag(node: ts.Node): boolean;
46
+ /**
47
+ * Extracts a default value from a property initializer and returns a
48
+ * {@link DefaultValueAnnotationNode} if present.
49
+ *
50
+ * Only extracts literal values (strings, numbers, booleans, null).
51
+ */
52
+ export declare function extractDefaultValueAnnotation(initializer: ts.Expression | undefined, file?: string): AnnotationNode | null;
53
+ //# sourceMappingURL=jsdoc-constraints.d.ts.map
@@ -0,0 +1 @@
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;AAChF,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAM3B,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,IAAI,SAAK,EACT,OAAO,CAAC,EAAE,iBAAiB,GAC1B,gBAAgB,CAElB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,IAAI,SAAK,EACT,OAAO,CAAC,EAAE,iBAAiB,GAC1B,cAAc,EAAE,CAGlB;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,IAAI,SAAK,EACT,OAAO,CAAC,EAAE,iBAAiB,GAC1B,cAAc,EAAE,CAGlB;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,68 @@
1
+ /**
2
+ * TypeScript program setup for static analysis.
3
+ *
4
+ * Creates a TypeScript program with type checker from a source file,
5
+ * using the project's tsconfig.json for compiler options.
6
+ */
7
+ import * as ts from "typescript";
8
+ import { type IRClassAnalysis } from "./class-analyzer.js";
9
+ import type { ExtensionRegistry } from "../extensions/index.js";
10
+ /**
11
+ * Result of creating a TypeScript program for analysis.
12
+ */
13
+ export interface ProgramContext {
14
+ /** The TypeScript program */
15
+ program: ts.Program;
16
+ /** Type checker for resolving types */
17
+ checker: ts.TypeChecker;
18
+ /** The source file being analyzed */
19
+ sourceFile: ts.SourceFile;
20
+ }
21
+ /**
22
+ * Creates a TypeScript program for analyzing a source file.
23
+ *
24
+ * Looks for tsconfig.json in the file's directory or parent directories.
25
+ * Falls back to default compiler options if no config is found.
26
+ *
27
+ * @param filePath - Absolute path to the TypeScript source file
28
+ * @returns Program context with checker and source file
29
+ */
30
+ export declare function createProgramContext(filePath: string): ProgramContext;
31
+ /**
32
+ * Finds a class declaration by name in a source file.
33
+ *
34
+ * @param sourceFile - The source file to search
35
+ * @param className - Name of the class to find
36
+ * @returns The class declaration node, or null if not found
37
+ */
38
+ export declare function findClassByName(sourceFile: ts.SourceFile, className: string): ts.ClassDeclaration | null;
39
+ /**
40
+ * Finds an interface declaration by name in a source file.
41
+ *
42
+ * @param sourceFile - The source file to search
43
+ * @param interfaceName - Name of the interface to find
44
+ * @returns The interface declaration node, or null if not found
45
+ */
46
+ export declare function findInterfaceByName(sourceFile: ts.SourceFile, interfaceName: string): ts.InterfaceDeclaration | null;
47
+ /**
48
+ * Finds a type alias declaration by name in a source file.
49
+ *
50
+ * @param sourceFile - The source file to search
51
+ * @param aliasName - Name of the type alias to find
52
+ * @returns The type alias declaration node, or null if not found
53
+ */
54
+ export declare function findTypeAliasByName(sourceFile: ts.SourceFile, aliasName: string): ts.TypeAliasDeclaration | null;
55
+ /**
56
+ * Analyzes a named type (class, interface, or type alias) from a TypeScript
57
+ * source file and returns an `IRClassAnalysis`.
58
+ *
59
+ * Tries each declaration kind in order: class → interface → type alias.
60
+ * Throws if the name is not found or if the type alias analysis fails.
61
+ *
62
+ * @param filePath - Absolute or relative path to the TypeScript source file (resolved internally)
63
+ * @param typeName - Name of the class, interface, or type alias to analyze
64
+ * @param extensionRegistry - Optional extension registry for custom type handling
65
+ * @returns IR analysis result
66
+ */
67
+ export declare function analyzeNamedTypeToIR(filePath: string, typeName: string, extensionRegistry?: ExtensionRegistry): IRClassAnalysis;
68
+ //# sourceMappingURL=program.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/analyzer/program.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IACpB,uCAAuC;IACvC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;IACxB,qCAAqC;IACrC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CA6DrE;AA6BD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,MAAM,GAChB,EAAE,CAAC,gBAAgB,GAAG,IAAI,CAE5B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,aAAa,EAAE,MAAM,GACpB,EAAE,CAAC,oBAAoB,GAAG,IAAI,CAEhC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,MAAM,GAChB,EAAE,CAAC,oBAAoB,GAAG,IAAI,CAEhC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,eAAe,CAyBjB"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * TSDoc-based structured tag parser.
3
+ *
4
+ * Bridges the TypeScript compiler AST with the official `@microsoft/tsdoc`
5
+ * parser to extract constraint and annotation tags from JSDoc comments
6
+ * on class/interface/type-alias properties.
7
+ *
8
+ * The parser recognises two categories of tags:
9
+ *
10
+ * 1. **Constraint tags** (all alphanumeric, TSDoc-compliant):
11
+ * `@minimum`, `@maximum`, `@exclusiveMinimum`, `@exclusiveMaximum`,
12
+ * `@multipleOf`, `@minLength`, `@maxLength`, `@minItems`, `@maxItems`,
13
+ * `@uniqueItems`, `@pattern`, `@enumOptions`, `@const`
14
+ * — Parsed via TSDocParser as custom block tags.
15
+ * Both camelCase and PascalCase forms are accepted (e.g., `@Minimum`).
16
+ *
17
+ * 2. **Annotation tags** (`@displayName`, `@description`, `@format`, `@placeholder`):
18
+ * These are parsed as structured custom block tags and mapped directly
19
+ * onto annotation IR nodes.
20
+ *
21
+ * The `@deprecated` tag is a standard TSDoc block tag, parsed structurally.
22
+ *
23
+ * Description precedence is:
24
+ * 1. Explicit `@description`
25
+ * 2. Explicit `@remarks`
26
+ * 3. Implicit summary text (free text in the comment block)
27
+ *
28
+ * **Fallback strategy**: TSDoc treats `{` / `}` as inline tag delimiters and
29
+ * `@` as a tag prefix, so content containing these characters (e.g. JSON
30
+ * objects in `@EnumOptions`, regex patterns with `@` in `@Pattern`) gets
31
+ * mangled by the TSDoc parser. The shared comment syntax parser is the
32
+ * primary source for these payloads; the TS compiler's `ts.getJSDocTags()`
33
+ * API remains as a fallback when a raw payload cannot be recovered from the
34
+ * shared parse.
35
+ */
36
+ import * as ts from "typescript";
37
+ import { type ConstraintSemanticDiagnostic } from "@formspec/analysis";
38
+ import { type ConstraintNode, type AnnotationNode, type PathTarget, type TypeNode } from "@formspec/core";
39
+ import type { ExtensionRegistry } from "../extensions/index.js";
40
+ /**
41
+ * Result of parsing a single JSDoc comment attached to a TS AST node.
42
+ */
43
+ export interface TSDocParseResult {
44
+ /** Constraint IR nodes extracted from custom block tags. */
45
+ readonly constraints: readonly ConstraintNode[];
46
+ /** Annotation IR nodes extracted from canonical TSDoc block tags. */
47
+ readonly annotations: readonly AnnotationNode[];
48
+ /** Compiler-backed extraction diagnostics for invalid tag applications. */
49
+ readonly diagnostics: readonly ConstraintSemanticDiagnostic[];
50
+ }
51
+ /**
52
+ * Optional extension-aware parsing inputs for TSDoc extraction.
53
+ */
54
+ export interface ParseTSDocOptions {
55
+ /**
56
+ * Extension registry used to resolve custom tags and custom-type-specific
57
+ * broadening of built-in constraint tags.
58
+ */
59
+ readonly extensionRegistry?: ExtensionRegistry;
60
+ /**
61
+ * Effective field/type node for the declaration being parsed. Required when
62
+ * built-in tags may broaden onto a custom type.
63
+ */
64
+ readonly fieldType?: TypeNode;
65
+ /** Type checker used for compiler-backed placement and type validation. */
66
+ readonly checker?: ts.TypeChecker;
67
+ /** The declaration type that the parsed tag applies to. */
68
+ readonly subjectType?: ts.Type;
69
+ /** Optional enclosing host type for future cross-field signature checks. */
70
+ readonly hostType?: ts.Type;
71
+ }
72
+ /**
73
+ * Display-name metadata extracted from a node's JSDoc tags.
74
+ *
75
+ * The root display name is returned separately from member-target labels so
76
+ * callers can apply the former to the enclosing type/form and the latter to
77
+ * enum members.
78
+ */
79
+ export interface DisplayNameMetadata {
80
+ readonly displayName?: string;
81
+ readonly memberDisplayNames: ReadonlyMap<string, string>;
82
+ }
83
+ /**
84
+ * Parses the JSDoc comment attached to a TypeScript AST node using the
85
+ * official TSDoc parser and returns canonical IR constraint and annotation
86
+ * nodes.
87
+ *
88
+ * For constraint tags (`@minimum`, `@pattern`, `@enumOptions`, etc.),
89
+ * the structured TSDoc parser is used. Canonical annotation tags
90
+ * (`@displayName`, `@description`) are also parsed structurally.
91
+ *
92
+ * @param node - The TS AST node to inspect (PropertyDeclaration, PropertySignature, etc.)
93
+ * @param file - Absolute source file path for provenance
94
+ * @returns Parsed constraint and annotation nodes
95
+ */
96
+ export declare function parseTSDocTags(node: ts.Node, file?: string, options?: ParseTSDocOptions): TSDocParseResult;
97
+ /**
98
+ * Checks if a TS AST node has a `@deprecated` tag using the TSDoc parser.
99
+ *
100
+ * Falls back to the TS compiler API for nodes without doc comments.
101
+ */
102
+ export declare function hasDeprecatedTagTSDoc(node: ts.Node): boolean;
103
+ /**
104
+ * Extracts root and member-target display-name metadata from a node's JSDoc tags.
105
+ *
106
+ * Member-target display-name tags use the syntax `@displayName :member Label`.
107
+ * The first non-target `@displayName` is returned as the root display name.
108
+ */
109
+ export declare function extractDisplayNameMetadata(node: ts.Node): DisplayNameMetadata;
110
+ /**
111
+ * Extracts a path-target prefix (`:fieldName`) from constraint tag text.
112
+ * Returns the parsed PathTarget and remaining text, or null if no path target.
113
+ *
114
+ * @example
115
+ * extractPathTarget(":value 0") // → { path: { segments: ["value"] }, remainingText: "0" }
116
+ * extractPathTarget("42") // → null
117
+ */
118
+ export declare function extractPathTarget(text: string): {
119
+ path: PathTarget;
120
+ remainingText: string;
121
+ } | null;
122
+ //# sourceMappingURL=tsdoc-parser.d.ts.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