@equinor/fusion-framework-cli-plugin-ai-index 3.0.6 → 3.0.7
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/CHANGELOG.md +32 -0
- package/dist/esm/bin/apply-metadata.js +13 -5
- package/dist/esm/bin/apply-metadata.js.map +1 -1
- package/dist/esm/bin/apply-schema.js +7 -1
- package/dist/esm/bin/apply-schema.js.map +1 -1
- package/dist/esm/bin/apply-schema.test.js +2 -1
- package/dist/esm/bin/apply-schema.test.js.map +1 -1
- package/dist/esm/bin/{delete-removed-files.js → create-delete-removed-files-stream.js} +12 -1
- package/dist/esm/bin/create-delete-removed-files-stream.js.map +1 -0
- package/dist/esm/bin/embed.js +260 -97
- package/dist/esm/bin/embed.js.map +1 -1
- package/dist/esm/bin/execute-pipeline.js +5 -0
- package/dist/esm/bin/execute-pipeline.js.map +1 -1
- package/dist/esm/bin/get-diff.js +6 -0
- package/dist/esm/bin/get-diff.js.map +1 -1
- package/dist/esm/{embeddings-command.options.js → command-options-schema.js} +1 -1
- package/dist/esm/command-options-schema.js.map +1 -0
- package/dist/esm/{embeddings-command.js → command.js} +4 -2
- package/dist/esm/command.js.map +1 -0
- package/dist/esm/{create-command.js → create-index-command.js} +13 -5
- package/dist/esm/create-index-command.js.map +1 -0
- package/dist/esm/{schema.js → define-index-schema.js} +1 -1
- package/dist/esm/define-index-schema.js.map +1 -0
- package/dist/esm/delete-command.js +11 -2
- package/dist/esm/delete-command.js.map +1 -1
- package/dist/esm/delete-index-command.js +4 -0
- package/dist/esm/delete-index-command.js.map +1 -1
- package/dist/esm/{delete-command.options.js → delete-options-schema.js} +1 -1
- package/dist/esm/delete-options-schema.js.map +1 -0
- package/dist/esm/embed-command.js +3 -4
- package/dist/esm/embed-command.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/search-command.js +20 -0
- package/dist/esm/search-command.js.map +1 -1
- package/dist/esm/utils/git/{metadata.js → extract-git-metadata.js} +4 -2
- package/dist/esm/utils/git/extract-git-metadata.js.map +1 -0
- package/dist/esm/utils/git/get-changed-files.js +87 -0
- package/dist/esm/utils/git/get-changed-files.js.map +1 -0
- package/dist/esm/utils/git/{file-changes.js → get-file-status.js} +9 -95
- package/dist/esm/utils/git/get-file-status.js.map +1 -0
- package/dist/esm/utils/git/{status.js → get-git-status.js} +5 -2
- package/dist/esm/utils/git/get-git-status.js.map +1 -0
- package/dist/esm/utils/git/get-git.js +30 -0
- package/dist/esm/utils/git/get-git.js.map +1 -0
- package/dist/esm/utils/git/index.js +7 -4
- package/dist/esm/utils/git/index.js.map +1 -1
- package/dist/esm/utils/git/is-file-changed.js +19 -0
- package/dist/esm/utils/git/is-file-changed.js.map +1 -0
- package/dist/esm/utils/git/resolve-project-root.js +22 -0
- package/dist/esm/utils/git/resolve-project-root.js.map +1 -0
- package/dist/esm/utils/markdown/index.js +3 -1
- package/dist/esm/utils/markdown/index.js.map +1 -1
- package/dist/esm/utils/markdown/is-markdown-file.js +10 -0
- package/dist/esm/utils/markdown/is-markdown-file.js.map +1 -0
- package/dist/esm/utils/markdown/parse-markdown-file.js +29 -0
- package/dist/esm/utils/markdown/parse-markdown-file.js.map +1 -0
- package/dist/esm/utils/markdown/{parser.js → parse-markdown.js} +8 -37
- package/dist/esm/utils/markdown/parse-markdown.js.map +1 -0
- package/dist/esm/utils/{embedding-dimensions.js → resolve-embedding-dimensions.js} +3 -1
- package/dist/esm/utils/resolve-embedding-dimensions.js.map +1 -0
- package/dist/esm/utils/{package-resolver.js → resolve-package.js} +4 -1
- package/dist/esm/utils/resolve-package.js.map +1 -0
- package/dist/esm/utils/ts-doc/create-typescript-document.js +27 -0
- package/dist/esm/utils/ts-doc/create-typescript-document.js.map +1 -0
- package/dist/esm/utils/ts-doc/extract-document-from-class-node.js +86 -0
- package/dist/esm/utils/ts-doc/extract-document-from-class-node.js.map +1 -0
- package/dist/esm/utils/ts-doc/extract-document-from-node.js +82 -0
- package/dist/esm/utils/ts-doc/extract-document-from-node.js.map +1 -0
- package/dist/esm/utils/ts-doc/index.js +3 -1
- package/dist/esm/utils/ts-doc/index.js.map +1 -1
- package/dist/esm/utils/ts-doc/is-typescript-file.js +10 -0
- package/dist/esm/utils/ts-doc/is-typescript-file.js.map +1 -0
- package/dist/esm/utils/ts-doc/{constants.js → node-kinds.js} +1 -1
- package/dist/esm/utils/ts-doc/node-kinds.js.map +1 -0
- package/dist/esm/utils/ts-doc/parse-ts-doc-from-file-sync.js +23 -0
- package/dist/esm/utils/ts-doc/parse-ts-doc-from-file-sync.js.map +1 -0
- package/dist/esm/utils/ts-doc/parse-ts-doc-sync.js +18 -0
- package/dist/esm/utils/ts-doc/parse-ts-doc-sync.js.map +1 -0
- package/dist/esm/utils/ts-doc/process-source-file.js +22 -0
- package/dist/esm/utils/ts-doc/process-source-file.js.map +1 -0
- package/dist/esm/utils/zod-to-azure-fields.js +7 -0
- package/dist/esm/utils/zod-to-azure-fields.js.map +1 -1
- package/dist/esm/utils/zod-to-azure-fields.test.js +8 -7
- package/dist/esm/utils/zod-to-azure-fields.test.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/bin/apply-schema.d.ts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/git/get-changed-files.d.ts +13 -0
- package/dist/types/utils/git/get-file-status.d.ts +13 -0
- package/dist/types/utils/git/{git-client.d.ts → get-git.d.ts} +0 -10
- package/dist/types/utils/git/index.d.ts +7 -4
- package/dist/types/utils/git/is-file-changed.d.ts +12 -0
- package/dist/types/utils/git/resolve-project-root.d.ts +10 -0
- package/dist/types/utils/markdown/index.d.ts +3 -1
- package/dist/types/utils/markdown/is-markdown-file.d.ts +7 -0
- package/dist/types/utils/markdown/parse-markdown-file.d.ts +14 -0
- package/dist/types/utils/markdown/parse-markdown.d.ts +14 -0
- package/dist/types/utils/ts-doc/create-typescript-document.d.ts +12 -0
- package/dist/types/utils/ts-doc/extract-document-from-class-node.d.ts +15 -0
- package/dist/types/utils/ts-doc/extract-document-from-node.d.ts +20 -0
- package/dist/types/utils/ts-doc/index.d.ts +3 -1
- package/dist/types/utils/ts-doc/is-typescript-file.d.ts +7 -0
- package/dist/types/utils/ts-doc/parse-ts-doc-from-file-sync.d.ts +14 -0
- package/dist/types/utils/ts-doc/parse-ts-doc-sync.d.ts +12 -0
- package/dist/types/utils/ts-doc/process-source-file.d.ts +11 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +8 -8
- package/src/bin/apply-metadata.ts +69 -57
- package/src/bin/apply-schema.test.ts +2 -1
- package/src/bin/apply-schema.ts +6 -1
- package/src/bin/{delete-removed-files.ts → create-delete-removed-files-stream.ts} +12 -1
- package/src/bin/embed.ts +389 -145
- package/src/bin/execute-pipeline.ts +5 -0
- package/src/bin/get-diff.ts +7 -1
- package/src/bin/types.ts +1 -1
- package/src/{embeddings-command.ts → command.ts} +3 -1
- package/src/config.ts +1 -1
- package/src/{create-command.ts → create-index-command.ts} +15 -5
- package/src/delete-command.ts +11 -2
- package/src/delete-index-command.ts +4 -0
- package/src/embed-command.ts +3 -6
- package/src/index.ts +3 -3
- package/src/search-command.ts +20 -0
- package/src/utils/git/{metadata.ts → extract-git-metadata.ts} +3 -1
- package/src/utils/git/get-changed-files.ts +93 -0
- package/src/utils/git/{file-changes.ts → get-file-status.ts} +9 -103
- package/src/utils/git/{status.ts → get-git-status.ts} +4 -1
- package/src/utils/git/{git-client.ts → get-git.ts} +4 -22
- package/src/utils/git/index.ts +7 -4
- package/src/utils/git/is-file-changed.ts +21 -0
- package/src/utils/git/resolve-project-root.ts +22 -0
- package/src/utils/markdown/index.ts +3 -1
- package/src/utils/markdown/is-markdown-file.ts +9 -0
- package/src/utils/markdown/parse-markdown-file.ts +36 -0
- package/src/utils/markdown/{parser.ts → parse-markdown.ts} +16 -51
- package/src/utils/{embedding-dimensions.ts → resolve-embedding-dimensions.ts} +2 -0
- package/src/utils/{package-resolver.ts → resolve-package.ts} +3 -0
- package/src/utils/ts-doc/create-typescript-document.ts +36 -0
- package/src/utils/ts-doc/extract-document-from-class-node.ts +106 -0
- package/src/utils/ts-doc/extract-document-from-node.ts +120 -0
- package/src/utils/ts-doc/index.ts +3 -1
- package/src/utils/ts-doc/is-typescript-file.ts +9 -0
- package/src/utils/ts-doc/parse-ts-doc-from-file-sync.ts +32 -0
- package/src/utils/ts-doc/parse-ts-doc-sync.ts +23 -0
- package/src/utils/ts-doc/process-source-file.ts +30 -0
- package/src/utils/zod-to-azure-fields.test.ts +10 -7
- package/src/utils/zod-to-azure-fields.ts +7 -0
- package/src/version.ts +1 -1
- package/dist/esm/bin/delete-removed-files.js.map +0 -1
- package/dist/esm/bin/file-stream.js +0 -22
- package/dist/esm/bin/file-stream.js.map +0 -1
- package/dist/esm/create-command.js.map +0 -1
- package/dist/esm/delete-command.options.js.map +0 -1
- package/dist/esm/embeddings-command.js.map +0 -1
- package/dist/esm/embeddings-command.options.js.map +0 -1
- package/dist/esm/schema.js.map +0 -1
- package/dist/esm/utils/embedding-dimensions.js.map +0 -1
- package/dist/esm/utils/git/file-changes.js.map +0 -1
- package/dist/esm/utils/git/git-client.js +0 -48
- package/dist/esm/utils/git/git-client.js.map +0 -1
- package/dist/esm/utils/git/metadata.js.map +0 -1
- package/dist/esm/utils/git/status.js.map +0 -1
- package/dist/esm/utils/markdown/parser.js.map +0 -1
- package/dist/esm/utils/package-resolver.js.map +0 -1
- package/dist/esm/utils/ts-doc/constants.js.map +0 -1
- package/dist/esm/utils/ts-doc/extractors.js +0 -189
- package/dist/esm/utils/ts-doc/extractors.js.map +0 -1
- package/dist/esm/utils/ts-doc/parser.js +0 -46
- package/dist/esm/utils/ts-doc/parser.js.map +0 -1
- package/dist/types/bin/file-stream.d.ts +0 -1
- package/dist/types/utils/git/file-changes.d.ts +0 -36
- package/dist/types/utils/markdown/parser.d.ts +0 -34
- package/dist/types/utils/ts-doc/extractors.d.ts +0 -42
- package/dist/types/utils/ts-doc/parser.d.ts +0 -32
- package/src/bin/file-stream.ts +0 -34
- package/src/utils/ts-doc/extractors.ts +0 -260
- package/src/utils/ts-doc/parser.ts +0 -60
- /package/dist/types/bin/{delete-removed-files.d.ts → create-delete-removed-files-stream.d.ts} +0 -0
- /package/dist/types/{embeddings-command.options.d.ts → command-options-schema.d.ts} +0 -0
- /package/dist/types/{embeddings-command.d.ts → command.d.ts} +0 -0
- /package/dist/types/{create-command.d.ts → create-index-command.d.ts} +0 -0
- /package/dist/types/{schema.d.ts → define-index-schema.d.ts} +0 -0
- /package/dist/types/{delete-command.options.d.ts → delete-options-schema.d.ts} +0 -0
- /package/dist/types/utils/git/{metadata.d.ts → extract-git-metadata.d.ts} +0 -0
- /package/dist/types/utils/git/{status.d.ts → get-git-status.d.ts} +0 -0
- /package/dist/types/utils/{embedding-dimensions.d.ts → resolve-embedding-dimensions.d.ts} +0 -0
- /package/dist/types/utils/{package-resolver.d.ts → resolve-package.d.ts} +0 -0
- /package/dist/types/utils/ts-doc/{constants.d.ts → node-kinds.d.ts} +0 -0
- /package/src/{embeddings-command.options.ts → command-options-schema.ts} +0 -0
- /package/src/{schema.ts → define-index-schema.ts} +0 -0
- /package/src/{delete-command.options.ts → delete-options-schema.ts} +0 -0
- /package/src/utils/ts-doc/{constants.ts → node-kinds.ts} +0 -0
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type SourceFile as ProjectSourceFile,
|
|
3
|
-
SyntaxKind,
|
|
4
|
-
Node,
|
|
5
|
-
type VariableStatement,
|
|
6
|
-
type ClassDeclaration,
|
|
7
|
-
type MethodDeclaration,
|
|
8
|
-
type PropertyDeclaration,
|
|
9
|
-
} from 'ts-morph';
|
|
10
|
-
|
|
11
|
-
import { generateChunkId } from '../generate-chunk-id.js';
|
|
12
|
-
import type { TypescriptDocument, ParseTsDocOptions } from './types.js';
|
|
13
|
-
import { nodeKinds } from './constants.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Creates a TypescriptDocument from the given parameters.
|
|
17
|
-
* @param sourceFile - The source file containing the node.
|
|
18
|
-
* @param pageContent - The content of the document.
|
|
19
|
-
* @param tsKind - The TypeScript node kind name.
|
|
20
|
-
* @param tsName - The name of the TypeScript node.
|
|
21
|
-
* @param options - Optional parsing configuration.
|
|
22
|
-
* @param sourceOverride - Optional source path override (for cases where source needs transformation).
|
|
23
|
-
* @returns A TypeScript document with metadata.
|
|
24
|
-
*/
|
|
25
|
-
const createTypescriptDocument = (
|
|
26
|
-
sourceFile: ProjectSourceFile,
|
|
27
|
-
pageContent: string,
|
|
28
|
-
tsKind: string,
|
|
29
|
-
tsName: string,
|
|
30
|
-
options?: ParseTsDocOptions,
|
|
31
|
-
): TypescriptDocument => {
|
|
32
|
-
const source = sourceFile.getFilePath().replace(/^\/+/, '');
|
|
33
|
-
return {
|
|
34
|
-
id: generateChunkId(source),
|
|
35
|
-
pageContent,
|
|
36
|
-
metadata: {
|
|
37
|
-
source,
|
|
38
|
-
...(options?.projectRoot && { rootPath: options.projectRoot }),
|
|
39
|
-
attributes: {
|
|
40
|
-
type: 'tsdoc',
|
|
41
|
-
ts_kind: tsKind,
|
|
42
|
-
ts_name: tsName,
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Extracts a vector-store document from a TypeScript class declaration.
|
|
50
|
-
*
|
|
51
|
-
* Collects the class-level TSDoc comment, constructor signature (if documented),
|
|
52
|
-
* and all public members with TSDoc into a single document whose `pageContent`
|
|
53
|
-
* mirrors a minimal class interface.
|
|
54
|
-
*
|
|
55
|
-
* @param classNode - The `ts-morph` {@link ClassDeclaration} node to inspect.
|
|
56
|
-
* @param sourceFile - The project source file that contains the class.
|
|
57
|
-
* @param _options - Optional parsing configuration.
|
|
58
|
-
* @returns A {@link TypescriptDocument}, or `null` when the class has no TSDoc.
|
|
59
|
-
*/
|
|
60
|
-
export const extractDocumentFromClassNode = (
|
|
61
|
-
classNode: ClassDeclaration,
|
|
62
|
-
sourceFile: ProjectSourceFile,
|
|
63
|
-
_options?: ParseTsDocOptions,
|
|
64
|
-
): TypescriptDocument | null => {
|
|
65
|
-
// Find TSDoc comment (/** ... */)
|
|
66
|
-
const docCommentRange = classNode
|
|
67
|
-
.getLeadingCommentRanges()
|
|
68
|
-
.find((range) => range.getText().startsWith('/**'));
|
|
69
|
-
|
|
70
|
-
if (!docCommentRange) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const docComment = docCommentRange.getText();
|
|
75
|
-
const className = classNode.getName() || 'AnonymousClass';
|
|
76
|
-
|
|
77
|
-
// Start with class TSDoc and declaration (without body)
|
|
78
|
-
const classSignature = `${classNode.getText({ includeJsDocComments: false }).split('{')[0].trim()} {`;
|
|
79
|
-
let pageContent = `${docComment}\n${classSignature}`;
|
|
80
|
-
|
|
81
|
-
// Add constructor with TSDoc if present
|
|
82
|
-
const constructorNode = classNode.getConstructors()[0]; // Get the first constructor (if any)
|
|
83
|
-
if (constructorNode) {
|
|
84
|
-
const constructorDocCommentRange = constructorNode
|
|
85
|
-
.getLeadingCommentRanges()
|
|
86
|
-
.find((range) => range.getText().startsWith('/**'));
|
|
87
|
-
if (constructorDocCommentRange) {
|
|
88
|
-
const constructorDocComment = constructorDocCommentRange.getText();
|
|
89
|
-
const constructorSignature = constructorNode
|
|
90
|
-
.getText({ includeJsDocComments: false })
|
|
91
|
-
.split('{')[0]
|
|
92
|
-
.trim();
|
|
93
|
-
pageContent += `\n ${constructorDocComment}\n ${constructorSignature}`;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Add public methods and properties with TSDoc
|
|
98
|
-
const publicMembers = [
|
|
99
|
-
...classNode.getMethods().filter((m) => m.hasModifier(SyntaxKind.PublicKeyword)),
|
|
100
|
-
...classNode.getProperties().filter((p) => p.hasModifier(SyntaxKind.PublicKeyword)),
|
|
101
|
-
];
|
|
102
|
-
|
|
103
|
-
publicMembers.forEach((member) => {
|
|
104
|
-
const memberDocCommentRange = member
|
|
105
|
-
.getLeadingCommentRanges()
|
|
106
|
-
.find((range) => range.getText().startsWith('/**'));
|
|
107
|
-
if (memberDocCommentRange) {
|
|
108
|
-
const memberDocComment = memberDocCommentRange.getText();
|
|
109
|
-
let memberSignature = '';
|
|
110
|
-
if (member.getKind() === SyntaxKind.MethodDeclaration) {
|
|
111
|
-
memberSignature = (member as MethodDeclaration)
|
|
112
|
-
.getText({ includeJsDocComments: false })
|
|
113
|
-
.split('{')[0]
|
|
114
|
-
.trim();
|
|
115
|
-
} else if (member.getKind() === SyntaxKind.PropertyDeclaration) {
|
|
116
|
-
memberSignature = (member as PropertyDeclaration)
|
|
117
|
-
.getText({ includeJsDocComments: false })
|
|
118
|
-
.trim();
|
|
119
|
-
}
|
|
120
|
-
pageContent += `\n ${memberDocComment}\n ${memberSignature}`;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
pageContent += '\n}';
|
|
125
|
-
|
|
126
|
-
return createTypescriptDocument(
|
|
127
|
-
sourceFile,
|
|
128
|
-
pageContent,
|
|
129
|
-
classNode.getKindName(),
|
|
130
|
-
className,
|
|
131
|
-
_options,
|
|
132
|
-
);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Extracts a vector-store document from a single TypeScript AST node.
|
|
137
|
-
*
|
|
138
|
-
* Handles function declarations, variable statements (arrow / function
|
|
139
|
-
* expressions), interfaces, type aliases, enums, and classes. Delegates
|
|
140
|
-
* to {@link extractDocumentFromClassNode} for class declarations.
|
|
141
|
-
*
|
|
142
|
-
* @param node - The `ts-morph` AST node to inspect.
|
|
143
|
-
* @param sourceFile - The project source file that contains the node.
|
|
144
|
-
* @param options - Optional parsing configuration.
|
|
145
|
-
* @param nodeOptions - Optional flags (e.g. `skipKindCheck`) to override default
|
|
146
|
-
* kind filtering.
|
|
147
|
-
* @returns A {@link TypescriptDocument}, or `null` when the node has no TSDoc or
|
|
148
|
-
* is not a supported kind.
|
|
149
|
-
*/
|
|
150
|
-
export const extractDocumentFromNode = (
|
|
151
|
-
node: Node,
|
|
152
|
-
sourceFile: ProjectSourceFile,
|
|
153
|
-
options?: ParseTsDocOptions,
|
|
154
|
-
nodeOptions?: { skipKindCheck?: boolean },
|
|
155
|
-
): TypescriptDocument | null => {
|
|
156
|
-
const kind = node.getKind();
|
|
157
|
-
|
|
158
|
-
// Skip if not in our target kinds unless skipKindCheck is true
|
|
159
|
-
if (!nodeOptions?.skipKindCheck && !nodeKinds.includes(kind)) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Handle ClassDeclaration separately
|
|
164
|
-
if (kind === SyntaxKind.ClassDeclaration) {
|
|
165
|
-
return extractDocumentFromClassNode(node as ClassDeclaration, sourceFile, options);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Handle VariableStatement (e.g., `export const bundleApp = ...`)
|
|
169
|
-
if (kind === SyntaxKind.VariableStatement) {
|
|
170
|
-
const declaration = (node as VariableStatement)
|
|
171
|
-
.getDeclarations()
|
|
172
|
-
.find((d) => d.getKind() === SyntaxKind.VariableDeclaration);
|
|
173
|
-
|
|
174
|
-
if (!declaration) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const initializer = declaration.getInitializer();
|
|
179
|
-
if (
|
|
180
|
-
!initializer ||
|
|
181
|
-
!(
|
|
182
|
-
initializer.getKind() === SyntaxKind.ArrowFunction ||
|
|
183
|
-
initializer.getKind() === SyntaxKind.FunctionExpression
|
|
184
|
-
)
|
|
185
|
-
) {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Get the TSDoc comment from the VariableStatement
|
|
190
|
-
const docCommentRange = node
|
|
191
|
-
.getLeadingCommentRanges()
|
|
192
|
-
.find((range) => range.getText().startsWith('/**'));
|
|
193
|
-
|
|
194
|
-
if (!docCommentRange) {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const nodeName = declaration.getName() || 'missing_name_of_node';
|
|
199
|
-
const docComment = docCommentRange.getText();
|
|
200
|
-
|
|
201
|
-
// Only include the TSDoc comment for functions/lambdas
|
|
202
|
-
return createTypescriptDocument(
|
|
203
|
-
sourceFile,
|
|
204
|
-
docComment,
|
|
205
|
-
initializer.getKindName(),
|
|
206
|
-
nodeName,
|
|
207
|
-
options,
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Get name if node has one
|
|
212
|
-
const nodeName = Node.hasName(node) ? node.getName() : 'missing_name_of_node';
|
|
213
|
-
|
|
214
|
-
// Find TSDoc comment (/** ... */)
|
|
215
|
-
const docCommentRange = node
|
|
216
|
-
.getLeadingCommentRanges()
|
|
217
|
-
.find((range) => range.getText().startsWith('/**'));
|
|
218
|
-
|
|
219
|
-
if (!docCommentRange) {
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const docComment = docCommentRange.getText();
|
|
224
|
-
let pageContent = docComment;
|
|
225
|
-
|
|
226
|
-
// For interfaces and type aliases, include the full code
|
|
227
|
-
if (kind === SyntaxKind.InterfaceDeclaration || kind === SyntaxKind.TypeAliasDeclaration) {
|
|
228
|
-
pageContent = `${docComment}\n${node.getText()}`;
|
|
229
|
-
}
|
|
230
|
-
// For other nodes (e.g., FunctionDeclaration), include only TSDoc
|
|
231
|
-
else if (kind !== SyntaxKind.FunctionDeclaration) {
|
|
232
|
-
return null; // Skip unsupported kinds
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return createTypescriptDocument(sourceFile, pageContent, node.getKindName(), nodeName, options);
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Walks a TypeScript source file and extracts a {@link TypescriptDocument}
|
|
240
|
-
* for every top-level declaration that carries a TSDoc comment.
|
|
241
|
-
*
|
|
242
|
-
* @param sourceFile - The `ts-morph` source file to traverse.
|
|
243
|
-
* @param options - Optional parsing configuration.
|
|
244
|
-
* @returns Array of extracted documents (one per documented declaration).
|
|
245
|
-
*/
|
|
246
|
-
export const processSourceFile = (
|
|
247
|
-
sourceFile: ProjectSourceFile,
|
|
248
|
-
options?: ParseTsDocOptions,
|
|
249
|
-
): TypescriptDocument[] => {
|
|
250
|
-
const documents: TypescriptDocument[] = [];
|
|
251
|
-
|
|
252
|
-
sourceFile.forEachDescendant((node) => {
|
|
253
|
-
const document = extractDocumentFromNode(node, sourceFile, options);
|
|
254
|
-
if (document) {
|
|
255
|
-
documents.push(document);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
return documents;
|
|
260
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { assert } from 'node:console';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { Project } from 'ts-morph';
|
|
4
|
-
|
|
5
|
-
import type { SourceFile } from '../types.js';
|
|
6
|
-
import type { TypescriptDocument, ParseTsDocOptions } from './types.js';
|
|
7
|
-
import { processSourceFile } from './extractors.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Checks whether a file path has a TypeScript (`.ts`) or TSX (`.tsx`) extension.
|
|
11
|
-
*
|
|
12
|
-
* @param filePath - Absolute or relative file path.
|
|
13
|
-
* @returns `true` if the file extension is `.ts` or `.tsx`.
|
|
14
|
-
*/
|
|
15
|
-
export const isTypescriptFile = (filePath: string): boolean => {
|
|
16
|
-
return filePath.endsWith('.ts') || filePath.endsWith('.tsx');
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Parses TSDoc comments from an in-memory TypeScript code string.
|
|
21
|
-
*
|
|
22
|
-
* Creates a temporary `ts-morph` project, analyses the source, and returns
|
|
23
|
-
* one {@link TypescriptDocument} per documented top-level declaration.
|
|
24
|
-
*
|
|
25
|
-
* @param content - TypeScript source code to parse.
|
|
26
|
-
* @param options - Optional parsing configuration.
|
|
27
|
-
* @returns Array of extracted TypeScript documents with TSDoc metadata.
|
|
28
|
-
*/
|
|
29
|
-
export const parseTsDocSync = (
|
|
30
|
-
content: string,
|
|
31
|
-
options?: ParseTsDocOptions,
|
|
32
|
-
): TypescriptDocument[] => {
|
|
33
|
-
const project = new Project({ useInMemoryFileSystem: true });
|
|
34
|
-
const sourceFile = project.createSourceFile('temp.ts', content);
|
|
35
|
-
return processSourceFile(sourceFile, options);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Parses TSDoc comments from a TypeScript file on disk.
|
|
40
|
-
*
|
|
41
|
-
* Reads the file synchronously, creates a `ts-morph` project, and returns
|
|
42
|
-
* one {@link TypescriptDocument} per documented top-level declaration.
|
|
43
|
-
*
|
|
44
|
-
* @param file - Source file descriptor with path and optional project root.
|
|
45
|
-
* @param options - Optional parsing configuration.
|
|
46
|
-
* @returns Array of extracted TypeScript documents.
|
|
47
|
-
* @throws {AssertionError} If the file does not have a `.ts` or `.tsx` extension.
|
|
48
|
-
*/
|
|
49
|
-
export const parseTsDocFromFileSync = (
|
|
50
|
-
file: SourceFile,
|
|
51
|
-
options?: ParseTsDocOptions,
|
|
52
|
-
): TypescriptDocument[] => {
|
|
53
|
-
assert(isTypescriptFile(file.path), `File ${file.path} is not a TypeScript file`);
|
|
54
|
-
const project = new Project({ useInMemoryFileSystem: true });
|
|
55
|
-
const sourceFile = project.createSourceFile(
|
|
56
|
-
file.relativePath ?? file.path,
|
|
57
|
-
readFileSync(file.path, 'utf8'),
|
|
58
|
-
);
|
|
59
|
-
return processSourceFile(sourceFile, options);
|
|
60
|
-
};
|
/package/dist/types/bin/{delete-removed-files.d.ts → create-delete-removed-files-stream.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|