@ng-forge/dynamic-form-mcp 0.5.1
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 +221 -0
- package/bin/ng-forge-mcp.d.ts +8 -0
- package/bin/ng-forge-mcp.d.ts.map +1 -0
- package/bin/ng-forge-mcp.js +10202 -0
- package/package.json +61 -0
- package/src/index.d.ts +14 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +10265 -0
- package/src/registry/api-reference.json +510 -0
- package/src/registry/docs.json +230 -0
- package/src/registry/examples.json +629 -0
- package/src/registry/field-types.json +490 -0
- package/src/registry/index.d.ts +110 -0
- package/src/registry/index.d.ts.map +1 -0
- package/src/registry/instructions.d.ts +8 -0
- package/src/registry/instructions.d.ts.map +1 -0
- package/src/registry/ui-adapters.json +225 -0
- package/src/registry/validators.json +158 -0
- package/src/resources/documentation.resource.d.ts +8 -0
- package/src/resources/documentation.resource.d.ts.map +1 -0
- package/src/resources/examples.resource.d.ts +8 -0
- package/src/resources/examples.resource.d.ts.map +1 -0
- package/src/resources/field-types.resource.d.ts +8 -0
- package/src/resources/field-types.resource.d.ts.map +1 -0
- package/src/resources/index.d.ts +11 -0
- package/src/resources/index.d.ts.map +1 -0
- package/src/resources/instructions.resource.d.ts +8 -0
- package/src/resources/instructions.resource.d.ts.map +1 -0
- package/src/resources/schemas.resource.d.ts +9 -0
- package/src/resources/schemas.resource.d.ts.map +1 -0
- package/src/resources/ui-adapters.resource.d.ts +8 -0
- package/src/resources/ui-adapters.resource.d.ts.map +1 -0
- package/src/resources/validators.resource.d.ts +8 -0
- package/src/resources/validators.resource.d.ts.map +1 -0
- package/src/server.d.ts +22 -0
- package/src/server.d.ts.map +1 -0
- package/src/tools/data/lookup-topics.d.ts +18 -0
- package/src/tools/data/lookup-topics.d.ts.map +1 -0
- package/src/tools/examples.tool.d.ts +12 -0
- package/src/tools/examples.tool.d.ts.map +1 -0
- package/src/tools/index.d.ts +33 -0
- package/src/tools/index.d.ts.map +1 -0
- package/src/tools/lookup.tool.d.ts +15 -0
- package/src/tools/lookup.tool.d.ts.map +1 -0
- package/src/tools/scaffold.tool.d.ts +11 -0
- package/src/tools/scaffold.tool.d.ts.map +1 -0
- package/src/tools/validate.tool.d.ts +14 -0
- package/src/tools/validate.tool.d.ts.map +1 -0
- package/src/utils/ast-extractor.d.ts +88 -0
- package/src/utils/ast-extractor.d.ts.map +1 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Extractor Utility
|
|
3
|
+
*
|
|
4
|
+
* Uses ts-morph for robust TypeScript parsing to extract FormConfig objects.
|
|
5
|
+
* Handles complex patterns that regex + new Function() cannot:
|
|
6
|
+
* - new Date() constructors
|
|
7
|
+
* - Function references and arrow functions
|
|
8
|
+
* - Regex literals
|
|
9
|
+
* - External variable references
|
|
10
|
+
* - Method calls like Math.floor()
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Placeholder date used when encountering `new Date()` expressions.
|
|
14
|
+
* Since dates are runtime values, we substitute a fixed ISO string for validation.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DATE_PLACEHOLDER = "2024-01-01T00:00:00.000Z";
|
|
17
|
+
/**
|
|
18
|
+
* Maximum length for source text before truncation in warnings.
|
|
19
|
+
* Keeps warning messages readable while preserving context.
|
|
20
|
+
*/
|
|
21
|
+
export declare const MAX_SOURCE_TEXT_LENGTH = 50;
|
|
22
|
+
import { SourceFile, Node, ObjectLiteralExpression } from 'ts-morph';
|
|
23
|
+
/**
|
|
24
|
+
* A candidate FormConfig object found in the source file.
|
|
25
|
+
*/
|
|
26
|
+
export interface FormConfigCandidate {
|
|
27
|
+
/** Variable or property name */
|
|
28
|
+
name: string;
|
|
29
|
+
/** Line number where the declaration starts */
|
|
30
|
+
startLine: number;
|
|
31
|
+
/** The AST node for the object literal */
|
|
32
|
+
objectLiteral: ObjectLiteralExpression;
|
|
33
|
+
/** How this candidate was detected */
|
|
34
|
+
matchReason: 'type-annotation' | 'satisfies' | 'as-cast' | 'structural';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Warning about a non-serializable value that was replaced with a placeholder.
|
|
38
|
+
*/
|
|
39
|
+
export interface ExtractionWarning {
|
|
40
|
+
/** Path to the property, e.g., "fields[0].props.maxDate" */
|
|
41
|
+
path: string;
|
|
42
|
+
/** Description of the issue */
|
|
43
|
+
issue: string;
|
|
44
|
+
/** Original source text */
|
|
45
|
+
originalText: string;
|
|
46
|
+
/** What was substituted */
|
|
47
|
+
placeholder: string | number | boolean | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Error that occurred during extraction.
|
|
51
|
+
*/
|
|
52
|
+
export interface ExtractionError {
|
|
53
|
+
/** Path to the property */
|
|
54
|
+
path: string;
|
|
55
|
+
/** Error message */
|
|
56
|
+
message: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Result of extracting an AST node to JSON.
|
|
60
|
+
*/
|
|
61
|
+
export interface ExtractionResult {
|
|
62
|
+
/** The extracted JSON-safe object */
|
|
63
|
+
value: unknown;
|
|
64
|
+
/** Non-fatal issues (runtime values replaced with placeholders) */
|
|
65
|
+
warnings: ExtractionWarning[];
|
|
66
|
+
/** Fatal issues (couldn't extract) */
|
|
67
|
+
errors: ExtractionError[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a ts-morph Project and parse source code.
|
|
71
|
+
*/
|
|
72
|
+
export declare function createSourceFile(source: string, fileName?: string): SourceFile;
|
|
73
|
+
/**
|
|
74
|
+
* Find all potential FormConfig objects in a source file.
|
|
75
|
+
*
|
|
76
|
+
* Uses multiple detection strategies (in order of precedence):
|
|
77
|
+
* 1. Type annotation: `const x: FormConfig = {...}` or `const x: SomeFormConfig = {...}`
|
|
78
|
+
* 2. Satisfies: `const x = {...} satisfies FormConfig` or `{...} as const satisfies SomeConfig`
|
|
79
|
+
* 3. As cast: `const x = {...} as FormConfig`
|
|
80
|
+
* 4. Structural: Any object with `fields` array containing form-like objects
|
|
81
|
+
*/
|
|
82
|
+
export declare function findFormConfigCandidates(sourceFile: SourceFile): FormConfigCandidate[];
|
|
83
|
+
/**
|
|
84
|
+
* Extract an AST node to a JSON-safe object.
|
|
85
|
+
* Handles non-serializable values gracefully with placeholders and warnings.
|
|
86
|
+
*/
|
|
87
|
+
export declare function extractToJson(node: Node, path?: string): ExtractionResult;
|
|
88
|
+
//# sourceMappingURL=ast-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-extractor.d.ts","sourceRoot":"","sources":["../../../../../packages/dynamic-form-mcp/src/utils/ast-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,OAAO,EAEL,UAAU,EACV,IAAI,EACJ,uBAAuB,EAKxB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,aAAa,EAAE,uBAAuB,CAAC;IACvC,sCAAsC;IACtC,WAAW,EAAE,iBAAiB,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,CAAC;CACzE;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC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