@reqlan/analytical 0.9.1 → 0.10.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 +19 -2
- package/README.template.md +1 -1
- package/out/core/barrel-page.d.ts +2 -1
- package/out/core/barrel-page.js +18 -83
- package/out/core/barrel-page.js.map +1 -1
- package/out/core/base-discovery.d.ts +6 -0
- package/out/core/base-discovery.js +47 -2
- package/out/core/base-discovery.js.map +1 -1
- package/out/core/create-base.js +10 -14
- package/out/core/create-base.js.map +1 -1
- package/out/core/file-reference-resolve.js +3 -1
- package/out/core/file-reference-resolve.js.map +1 -1
- package/out/core/index-error.d.ts +3 -3
- package/out/core/index-error.js.map +1 -1
- package/out/core/index-state-types.d.ts +47 -0
- package/out/core/index-state-types.js +11 -0
- package/out/core/index-state-types.js.map +1 -0
- package/out/core/path-relative.d.ts +15 -0
- package/out/core/path-relative.js +84 -0
- package/out/core/path-relative.js.map +1 -0
- package/out/core/rqignore.js +62 -62
- package/out/core/rqignore.js.map +1 -1
- package/out/core/types.d.ts +4 -3
- package/out/core/types.js +4 -1
- package/out/core/types.js.map +1 -1
- package/out/core/workspace-paths.d.ts +1 -2
- package/out/core/workspace-paths.js +6 -46
- package/out/core/workspace-paths.js.map +1 -1
- package/out/export/build-export-snapshot.js +1 -1
- package/out/export/build-export-snapshot.js.map +1 -1
- package/out/export/export-utils.d.ts +5 -0
- package/out/export/export-utils.js +38 -0
- package/out/export/export-utils.js.map +1 -0
- package/out/export/write-csv-export.js +1 -1
- package/out/export/write-csv-export.js.map +1 -1
- package/out/export/write-markdown-export.js +1 -1
- package/out/export/write-markdown-export.js.map +1 -1
- package/out/index-store/base-registry.d.ts +2 -3
- package/out/index-store/base-registry.js +8 -4
- package/out/index-store/base-registry.js.map +1 -1
- package/out/index-store/fuzzy-search-hit.d.ts +10 -0
- package/out/index-store/fuzzy-search-hit.js +2 -0
- package/out/index-store/fuzzy-search-hit.js.map +1 -0
- package/out/index-store/index-diagnostics-store.d.ts +4 -0
- package/out/index-store/index-diagnostics-store.js +44 -88
- package/out/index-store/index-diagnostics-store.js.map +1 -1
- package/out/index-store/index-file-error.d.ts +1 -1
- package/out/index-store/index-parse-issues.d.ts +4 -3
- package/out/index-store/index-parse-issues.js +0 -38
- package/out/index-store/index-parse-issues.js.map +1 -1
- package/out/index-store/index-status.d.ts +1 -1
- package/out/index-store/sqlite-store.d.ts +6 -2
- package/out/index-store/sqlite-store.js +70 -613
- package/out/index-store/sqlite-store.js.map +1 -1
- package/out/index-store/webview-graph-queries.d.ts +5 -0
- package/out/index-store/webview-graph-queries.js.map +1 -1
- package/out/index-store/workspace-index-file.d.ts +3 -14
- package/out/index-store/workspace-index-file.js +1 -114
- package/out/index-store/workspace-index-file.js.map +1 -1
- package/out/index-store/workspace-index-sync.d.ts +4 -17
- package/out/index-store/workspace-index-sync.js +29 -11
- package/out/index-store/workspace-index-sync.js.map +1 -1
- package/out/index-store/workspace-index.d.ts +36 -9
- package/out/index-store/workspace-index.js +223 -120
- package/out/index-store/workspace-index.js.map +1 -1
- package/out/index.d.ts +16 -43
- package/out/index.js +9 -25
- package/out/index.js.map +1 -1
- package/out/native/generated.d.ts +102 -0
- package/out/native/generated.js +4 -0
- package/out/native/generated.js.map +1 -0
- package/out/native/index.d.ts +17 -0
- package/out/native/index.js +12 -0
- package/out/native/index.js.map +1 -0
- package/out/native/load-native.d.ts +50 -0
- package/out/native/load-native.js +186 -0
- package/out/native/load-native.js.map +1 -0
- package/out/{analysis-api.d.ts → native/native-analysis-api.d.ts} +19 -19
- package/out/native/native-analysis-api.js +212 -0
- package/out/native/native-analysis-api.js.map +1 -0
- package/out/native/native-index-store.d.ts +5 -0
- package/out/native/native-index-store.js +6 -0
- package/out/native/native-index-store.js.map +1 -0
- package/out/native/native-sql-db.d.ts +135 -0
- package/out/native/native-sql-db.js +217 -0
- package/out/native/native-sql-db.js.map +1 -0
- package/out/native/native-workspace-index.d.ts +164 -0
- package/out/native/native-workspace-index.js +283 -0
- package/out/native/native-workspace-index.js.map +1 -0
- package/out/native/open-analysis-api.d.ts +16 -0
- package/out/native/open-analysis-api.js +21 -0
- package/out/native/open-analysis-api.js.map +1 -0
- package/out/native/parse-source.d.ts +24 -0
- package/out/native/parse-source.js +26 -0
- package/out/native/parse-source.js.map +1 -0
- package/package.json +18 -30
- package/out/analysis/analyser-registry.d.ts +0 -21
- package/out/analysis/analyser-registry.js +0 -33
- package/out/analysis/analyser-registry.js.map +0 -1
- package/out/analysis/completion-tracking-analyser.d.ts +0 -3
- package/out/analysis/completion-tracking-analyser.js +0 -37
- package/out/analysis/completion-tracking-analyser.js.map +0 -1
- package/out/analysis/contextual-search.d.ts +0 -26
- package/out/analysis/contextual-search.js +0 -94
- package/out/analysis/contextual-search.js.map +0 -1
- package/out/analysis/deprecation-impact-analyser.d.ts +0 -3
- package/out/analysis/deprecation-impact-analyser.js +0 -21
- package/out/analysis/deprecation-impact-analyser.js.map +0 -1
- package/out/analysis/file-related-analyser.d.ts +0 -5
- package/out/analysis/file-related-analyser.js +0 -41
- package/out/analysis/file-related-analyser.js.map +0 -1
- package/out/analysis/fuzzy-search-analyser.d.ts +0 -17
- package/out/analysis/fuzzy-search-analyser.js +0 -25
- package/out/analysis/fuzzy-search-analyser.js.map +0 -1
- package/out/analysis/fuzzy-search-worker-client.d.ts +0 -39
- package/out/analysis/fuzzy-search-worker-client.js +0 -178
- package/out/analysis/fuzzy-search-worker-client.js.map +0 -1
- package/out/analysis/fuzzy-search-worker.d.ts +0 -32
- package/out/analysis/fuzzy-search-worker.js +0 -81
- package/out/analysis/fuzzy-search-worker.js.map +0 -1
- package/out/analysis/fuzzy-search.d.ts +0 -62
- package/out/analysis/fuzzy-search.js +0 -471
- package/out/analysis/fuzzy-search.js.map +0 -1
- package/out/analysis/git-dates-analyser.d.ts +0 -12
- package/out/analysis/git-dates-analyser.js +0 -96
- package/out/analysis/git-dates-analyser.js.map +0 -1
- package/out/analysis/list-ideas-analyser.d.ts +0 -3
- package/out/analysis/list-ideas-analyser.js +0 -7
- package/out/analysis/list-ideas-analyser.js.map +0 -1
- package/out/analysis/local-graph-analyser.d.ts +0 -6
- package/out/analysis/local-graph-analyser.js +0 -42
- package/out/analysis/local-graph-analyser.js.map +0 -1
- package/out/analysis/semantic-search-analyser.d.ts +0 -8
- package/out/analysis/semantic-search-analyser.js +0 -51
- package/out/analysis/semantic-search-analyser.js.map +0 -1
- package/out/analysis-api.js +0 -199
- package/out/analysis-api.js.map +0 -1
- package/out/core/analytical-store.d.ts +0 -85
- package/out/core/analytical-store.js +0 -143
- package/out/core/analytical-store.js.map +0 -1
- package/out/core/context-model.d.ts +0 -204
- package/out/core/context-model.js +0 -36
- package/out/core/context-model.js.map +0 -1
- package/out/core/context-signals.d.ts +0 -154
- package/out/core/context-signals.js +0 -406
- package/out/core/context-signals.js.map +0 -1
- package/out/create-runtime.d.ts +0 -47
- package/out/create-runtime.js +0 -79
- package/out/create-runtime.js.map +0 -1
- package/out/export/export-html.d.ts +0 -4
- package/out/export/export-html.js +0 -12
- package/out/export/export-html.js.map +0 -1
- package/out/export/html-export-assets.d.ts +0 -3
- package/out/export/html-export-assets.js +0 -2294
- package/out/export/html-export-assets.js.map +0 -1
- package/out/export/html-export-template.d.ts +0 -18
- package/out/export/html-export-template.js +0 -1154
- package/out/export/html-export-template.js.map +0 -1
- package/out/export/html-export-utils.d.ts +0 -86
- package/out/export/html-export-utils.js +0 -485
- package/out/export/html-export-utils.js.map +0 -1
- package/out/export/write-html-export.d.ts +0 -2
- package/out/export/write-html-export.js +0 -181
- package/out/export/write-html-export.js.map +0 -1
- package/out/graph/physics-core-source.d.ts +0 -5
- package/out/graph/physics-core-source.js +0 -8
- package/out/graph/physics-core-source.js.map +0 -1
- package/out/graph/physics-core.d.ts +0 -141
- package/out/graph/physics-core.js +0 -237
- package/out/graph/physics-core.js.map +0 -1
- package/out/index-store/file-treatment.d.ts +0 -40
- package/out/index-store/file-treatment.js +0 -144
- package/out/index-store/file-treatment.js.map +0 -1
- package/out/index-store/idea-extractor.d.ts +0 -11
- package/out/index-store/idea-extractor.js +0 -351
- package/out/index-store/idea-extractor.js.map +0 -1
- package/out/index-store/overview-coverage.d.ts +0 -23
- package/out/index-store/overview-coverage.js +0 -254
- package/out/index-store/overview-coverage.js.map +0 -1
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* AnalysisApi-compatible facade over the core Rust engine.
|
|
3
|
+
* rq:["../../../reqlan rq/core_analysis/rust_port.rq".native_bridge]
|
|
4
|
+
* rq:["../../../reqlan rq/core_analysis/rust_port.rq".ts_interface]
|
|
5
|
+
*/
|
|
6
|
+
import type { CompletionSummary, DeprecationImpact, FileRelatedRequirements, GraphSlice, IdeaSummary } from '../core/types.js';
|
|
7
|
+
import type { ExportProgressCallback, ExportRequest, ExportResult } from '../export/types.js';
|
|
8
|
+
export interface AnalysisRuntimeOptions {
|
|
9
|
+
workspaceRoot: string;
|
|
10
|
+
storagePath?: string;
|
|
11
|
+
}
|
|
4
12
|
export interface RequirementMatch {
|
|
5
13
|
idea: IdeaSummary;
|
|
6
14
|
score?: number;
|
|
@@ -15,9 +23,9 @@ export interface InteractionDescriptor {
|
|
|
15
23
|
description: string;
|
|
16
24
|
parameters: Record<string, string>;
|
|
17
25
|
}
|
|
18
|
-
export declare class
|
|
19
|
-
private readonly
|
|
20
|
-
constructor(
|
|
26
|
+
export declare class NativeAnalysisApi {
|
|
27
|
+
private readonly native;
|
|
28
|
+
constructor(options: AnalysisRuntimeOptions);
|
|
21
29
|
ensureReady(): Promise<void>;
|
|
22
30
|
searchRequirements(query: string, limit?: number, options?: SearchRequirementsOptions): Promise<RequirementMatch[]>;
|
|
23
31
|
listRequirements(limit?: number): Promise<IdeaSummary[]>;
|
|
@@ -26,27 +34,18 @@ export declare class AnalysisApi {
|
|
|
26
34
|
summarizeSubtree(requirementName: string, depth?: number): Promise<GraphSlice | undefined>;
|
|
27
35
|
getCompletionStatus(): Promise<CompletionSummary>;
|
|
28
36
|
getDeprecationImpact(): Promise<DeprecationImpact[]>;
|
|
29
|
-
/**
|
|
30
|
-
* Export the indexed requirement graph as a multi-file static HTML site.
|
|
31
|
-
* Headless entry point shared by CLI and site build.
|
|
32
|
-
*/
|
|
33
37
|
exportHtml(request: Omit<ExportRequest, 'workspaceRoot'> & {
|
|
34
38
|
workspaceRoot?: string;
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* Export the indexed requirement graph as markdown (README + optional idea pages).
|
|
38
|
-
*/
|
|
39
|
+
}, _onProgress?: ExportProgressCallback): Promise<ExportResult>;
|
|
39
40
|
exportMarkdown(request: Omit<ExportRequest, 'workspaceRoot'> & {
|
|
40
41
|
workspaceRoot?: string;
|
|
41
|
-
},
|
|
42
|
-
/** Export structured JSON for tooling and AI consumption. */
|
|
42
|
+
}, _onProgress?: ExportProgressCallback): Promise<ExportResult>;
|
|
43
43
|
exportJson(request: Omit<ExportRequest, 'workspaceRoot'> & {
|
|
44
44
|
workspaceRoot?: string;
|
|
45
|
-
},
|
|
46
|
-
/** Export ideas/references as CSV with flattened tags and attributes. */
|
|
45
|
+
}, _onProgress?: ExportProgressCallback): Promise<ExportResult>;
|
|
47
46
|
exportCsv(request: Omit<ExportRequest, 'workspaceRoot'> & {
|
|
48
47
|
workspaceRoot?: string;
|
|
49
|
-
},
|
|
48
|
+
}, _onProgress?: ExportProgressCallback): Promise<ExportResult>;
|
|
50
49
|
resolveRequirementReference(name?: string): Promise<IdeaSummary[]>;
|
|
51
50
|
resolveFileReference(pathPrefix?: string): Promise<Array<{
|
|
52
51
|
path: string;
|
|
@@ -54,4 +53,5 @@ export declare class AnalysisApi {
|
|
|
54
53
|
}>>;
|
|
55
54
|
listInteractions(): InteractionDescriptor[];
|
|
56
55
|
formatIdea(idea: IdeaSummary): string;
|
|
56
|
+
private exportFormat;
|
|
57
57
|
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { loadNativeEngine } from './load-native.js';
|
|
2
|
+
export class NativeAnalysisApi {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
const engine = loadNativeEngine();
|
|
5
|
+
this.native = engine.NativeAnalysisRuntime.open(options.workspaceRoot, options.storagePath);
|
|
6
|
+
}
|
|
7
|
+
async ensureReady() {
|
|
8
|
+
this.native.ensureReady();
|
|
9
|
+
}
|
|
10
|
+
async searchRequirements(query, limit = 8, options) {
|
|
11
|
+
const matches = this.native.searchRequirements(query, limit, options?.context);
|
|
12
|
+
return matches.map(match => ({
|
|
13
|
+
idea: toIdea(match.idea),
|
|
14
|
+
score: match.score ?? undefined,
|
|
15
|
+
reasons: match.reasons ?? undefined
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
async listRequirements(limit = 50) {
|
|
19
|
+
return this.native.listRequirements(limit).map(toIdea);
|
|
20
|
+
}
|
|
21
|
+
async getFileContext(filePath) {
|
|
22
|
+
const related = this.native.getFileContext(filePath);
|
|
23
|
+
return {
|
|
24
|
+
fileUri: related.fileUri,
|
|
25
|
+
ideasInFile: related.ideasInFile.map(toIdea),
|
|
26
|
+
referencingIdeas: related.referencingIdeas.map(toIdea),
|
|
27
|
+
commentLinkedIdeas: related.commentLinkedIdeas.map(toIdea),
|
|
28
|
+
folderReferencingIdeas: related.folderReferencingIdeas.map(toIdea)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async getLocalGraph(filePath, depth = 1) {
|
|
32
|
+
const graph = this.native.getLocalGraph(filePath, depth);
|
|
33
|
+
return graph ? toGraph(graph) : undefined;
|
|
34
|
+
}
|
|
35
|
+
async summarizeSubtree(requirementName, depth = 2) {
|
|
36
|
+
const graph = this.native.summarizeSubtree(requirementName, depth);
|
|
37
|
+
return graph ? toGraph(graph) : undefined;
|
|
38
|
+
}
|
|
39
|
+
async getCompletionStatus() {
|
|
40
|
+
const summary = this.native.getCompletionStatus();
|
|
41
|
+
return {
|
|
42
|
+
total: summary.total,
|
|
43
|
+
byStatus: toCountRecord(summary.byStatus),
|
|
44
|
+
byTag: toCountRecord(summary.byTag),
|
|
45
|
+
outstanding: summary.outstanding.map(toIdea),
|
|
46
|
+
deprecated: summary.deprecated.map(toIdea)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async getDeprecationImpact() {
|
|
50
|
+
const impacts = this.native.getDeprecationImpact();
|
|
51
|
+
return impacts.map(impact => ({
|
|
52
|
+
deprecated: toIdea(impact.deprecated),
|
|
53
|
+
dependents: impact.dependents.map(toIdea)
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
async exportHtml(request, _onProgress) {
|
|
57
|
+
return this.exportFormat('html', request);
|
|
58
|
+
}
|
|
59
|
+
async exportMarkdown(request, _onProgress) {
|
|
60
|
+
return this.exportFormat('markdown', request);
|
|
61
|
+
}
|
|
62
|
+
async exportJson(request, _onProgress) {
|
|
63
|
+
return this.exportFormat('json', request);
|
|
64
|
+
}
|
|
65
|
+
async exportCsv(request, _onProgress) {
|
|
66
|
+
return this.exportFormat('csv', request);
|
|
67
|
+
}
|
|
68
|
+
async resolveRequirementReference(name) {
|
|
69
|
+
return this.native.resolveRequirementReference(name).map(toIdea);
|
|
70
|
+
}
|
|
71
|
+
async resolveFileReference(pathPrefix) {
|
|
72
|
+
return this.native.resolveFileReference(pathPrefix);
|
|
73
|
+
}
|
|
74
|
+
listInteractions() {
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
name: 'search_requirements',
|
|
78
|
+
description: 'Search requirements by keyword across names, summaries, tags, and references.',
|
|
79
|
+
parameters: { query: 'Search text', limit: 'Optional maximum number of matches' }
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'list_requirements',
|
|
83
|
+
description: 'List indexed requirements in the workspace.',
|
|
84
|
+
parameters: { limit: 'Optional maximum number of requirements' }
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'file_context',
|
|
88
|
+
description: 'Get requirements in, referencing, or comment-linked to a file.',
|
|
89
|
+
parameters: { filePath: 'Relative or absolute path to a .rq file' }
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'local_graph',
|
|
93
|
+
description: 'Get the local requirement graph around the first requirement in a file.',
|
|
94
|
+
parameters: { filePath: 'Relative or absolute path to a .rq file', depth: 'Optional hop depth' }
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'summarize_subtree',
|
|
98
|
+
description: 'Summarise a requirement subtree rooted at a named requirement.',
|
|
99
|
+
parameters: { requirementName: 'Requirement name or search text', depth: 'Optional hop depth' }
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'requirement_reference',
|
|
103
|
+
description: 'Resolve a requirement by name for compact chat or MCP context.',
|
|
104
|
+
parameters: { name: 'Optional requirement name or search text' }
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'file_reference',
|
|
108
|
+
description: 'Resolve requirements indexed in matching .rq files.',
|
|
109
|
+
parameters: { path: 'Optional path fragment filter' }
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'completion_status',
|
|
113
|
+
description: 'Summarise completion and deprecation status across the workspace graph.',
|
|
114
|
+
parameters: {}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'export_html',
|
|
118
|
+
description: 'Export the requirement graph as a multi-file static HTML site.',
|
|
119
|
+
parameters: {
|
|
120
|
+
outputDir: 'Parent directory for the export folder',
|
|
121
|
+
exportName: 'Export folder name',
|
|
122
|
+
excludeSecretFiles: 'Optional: omit *.secret.rq files',
|
|
123
|
+
excludeIgnoredFiles: 'Optional: omit .rqignore-matched files'
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'list_interactions',
|
|
128
|
+
description: 'Discover available requirement graph interactions and parameters.',
|
|
129
|
+
parameters: {}
|
|
130
|
+
}
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
formatIdea(idea) {
|
|
134
|
+
const location = `${idea.fileUri}:${idea.lineStart + 1}`;
|
|
135
|
+
const tags = idea.tags.length > 0 ? `\nTags: ${idea.tags.join(', ')}` : '';
|
|
136
|
+
const status = idea.status ? `\nStatus: ${idea.status}` : '';
|
|
137
|
+
return `### ${idea.name} (${location})\n${idea.summary || '(no summary)'}${status}${tags}`;
|
|
138
|
+
}
|
|
139
|
+
exportFormat(format, request) {
|
|
140
|
+
const dto = {
|
|
141
|
+
format,
|
|
142
|
+
outputDir: request.outputDir,
|
|
143
|
+
exportName: request.exportName,
|
|
144
|
+
workspaceRoot: request.workspaceRoot,
|
|
145
|
+
templateId: request.templateId,
|
|
146
|
+
scope: request.scope,
|
|
147
|
+
sourceFileUri: request.sourceFileUri,
|
|
148
|
+
includeRequirementsPage: request.includeRequirementsPage ?? false,
|
|
149
|
+
includeGraphPage: request.includeGraphPage ?? false,
|
|
150
|
+
printEntryFileName: request.printEntryFileName,
|
|
151
|
+
excludeSecretFiles: request.excludeSecretFiles ?? false,
|
|
152
|
+
excludeIgnoredFiles: request.excludeIgnoredFiles ?? false,
|
|
153
|
+
runtimeMode: request.runtimeMode,
|
|
154
|
+
clusterStrategy: request.clusterStrategy,
|
|
155
|
+
includeIdeaPages: request.includeIdeaPages ?? true,
|
|
156
|
+
includeFilePages: request.includeFilePages ?? true,
|
|
157
|
+
includeCodeFilePages: request.includeCodeFilePages ?? true,
|
|
158
|
+
includeClusterPages: request.includeClusterPages ?? true,
|
|
159
|
+
includeAttributePages: request.includeAttributePages ?? true,
|
|
160
|
+
includePrintPages: request.includePrintPages ?? true,
|
|
161
|
+
maxGraphNodes: request.maxGraphNodes,
|
|
162
|
+
urlBase: request.urlBase,
|
|
163
|
+
headerLink: request.headerLink
|
|
164
|
+
};
|
|
165
|
+
const result = this.native.exportGraph(dto);
|
|
166
|
+
return {
|
|
167
|
+
outputDir: result.outputDir,
|
|
168
|
+
indexFilePath: result.indexFilePath,
|
|
169
|
+
printFilePath: result.printFilePath,
|
|
170
|
+
dataFilePath: result.dataFilePath
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function toCountRecord(counts) {
|
|
175
|
+
const result = {};
|
|
176
|
+
for (const [key, value] of Object.entries(counts ?? {})) {
|
|
177
|
+
if (typeof value === 'number') {
|
|
178
|
+
result[key] = value;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
function toIdea(idea) {
|
|
184
|
+
return {
|
|
185
|
+
id: idea.id,
|
|
186
|
+
name: idea.name,
|
|
187
|
+
kind: idea.kind,
|
|
188
|
+
fileUri: idea.fileUri,
|
|
189
|
+
lineStart: idea.lineStart,
|
|
190
|
+
summary: idea.summary,
|
|
191
|
+
status: idea.status ?? undefined,
|
|
192
|
+
statusKey: idea.statusKey,
|
|
193
|
+
tags: idea.tags,
|
|
194
|
+
tagsKeys: idea.tagsKeys
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function toGraph(graph) {
|
|
198
|
+
return {
|
|
199
|
+
centerId: graph.centerId,
|
|
200
|
+
depth: graph.depth,
|
|
201
|
+
nodes: graph.nodes.map(toIdea),
|
|
202
|
+
edges: graph.edges.map(edge => ({
|
|
203
|
+
id: edge.id,
|
|
204
|
+
sourceId: edge.sourceId,
|
|
205
|
+
targetId: edge.targetId ?? undefined,
|
|
206
|
+
targetFile: edge.targetFile ?? undefined,
|
|
207
|
+
kind: edge.kind,
|
|
208
|
+
label: edge.label ?? undefined
|
|
209
|
+
}))
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=native-analysis-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-analysis-api.js","sourceRoot":"","sources":["../../src/native/native-analysis-api.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAoC,MAAM,kBAAkB,CAAC;AAkCtF,MAAM,OAAO,iBAAiB;IAG1B,YAAY,OAA+B;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CAAC,KAAuB;IACpC,OAAO;QACH,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;QAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,SAAS;YACpC,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;YACxC,IAAI,EAAE,IAAI,CAAC,IAA2C;YACtD,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;SACjC,CAAC,CAAC;KACN,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native-backed index store facade (SqliteIndexStore over rusqlite via napi).
|
|
3
|
+
* rq:["../../../reqlan rq/core_analysis/rust_port.rq".native_bridge]
|
|
4
|
+
*/
|
|
5
|
+
export { SqliteIndexStore as NativeIndexStore } from '../index-store/sqlite-store.js';
|
|
6
|
+
//# sourceMappingURL=native-index-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-index-store.js","sourceRoot":"","sources":["../../src/native/native-index-store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { NativeWorkspaceIndex } from './native-workspace-index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Typed webview table/graph query surface implemented natively (reqlan-index queries.rs).
|
|
4
|
+
* Returns raw SQL rows; TS presentation mappers shape them into view rows.
|
|
5
|
+
*/
|
|
6
|
+
/** Outbound + inbound raw reference rows for a single idea (both joined to ideas). */
|
|
7
|
+
export interface NativeReferenceBundle {
|
|
8
|
+
outbound: Record<string, unknown>[];
|
|
9
|
+
inbound: Record<string, unknown>[];
|
|
10
|
+
}
|
|
11
|
+
export interface NativeQuerySurface {
|
|
12
|
+
countIdeas(query: unknown): number;
|
|
13
|
+
listIdeasPageRows(query: unknown): Record<string, unknown>[];
|
|
14
|
+
listReferenceChipRows(ideaIds: string[]): Record<string, unknown>[];
|
|
15
|
+
countIdeasets(query: unknown): number;
|
|
16
|
+
listIdeasetsPageRows(query: unknown): Record<string, unknown>[];
|
|
17
|
+
listIdeasetMemberRows(ideasetId: string, kind: string, fileUri: string): Record<string, unknown>[];
|
|
18
|
+
countReferences(query: unknown): number;
|
|
19
|
+
listReferencesPageRows(query: unknown): Record<string, unknown>[];
|
|
20
|
+
listTodoIdeaRows(): Record<string, unknown>[];
|
|
21
|
+
listIdeasForGraphQuery(query: unknown, limit: number): {
|
|
22
|
+
rows: Record<string, unknown>[];
|
|
23
|
+
totalMatching: number;
|
|
24
|
+
};
|
|
25
|
+
listRecentGitIdeaRows(limit: number): Record<string, unknown>[];
|
|
26
|
+
listIdeaIdsMissingGitDates(limit: number, fileUri?: string, preferFileUri?: string): string[];
|
|
27
|
+
listAttributeIdeaRows(): Record<string, unknown>[];
|
|
28
|
+
migrateIdeasSchema(): void;
|
|
29
|
+
getDocumentHash(fileUri: string): string | null;
|
|
30
|
+
getDocumentMtimeMs(fileUri: string): number | null;
|
|
31
|
+
listDocumentMtimeRows(): Record<string, unknown>[];
|
|
32
|
+
listDocumentUris(): string[];
|
|
33
|
+
listAllIdeaRows(): Record<string, unknown>[];
|
|
34
|
+
getIdeaRow(id: string): Record<string, unknown> | null;
|
|
35
|
+
getIdeasInFileRows(fileUri: string): Record<string, unknown>[];
|
|
36
|
+
getIdeaAtLineRow(fileUri: string, line: number): Record<string, unknown> | null;
|
|
37
|
+
getIdeasetAtLineRow(fileUri: string, line: number): Record<string, unknown> | null;
|
|
38
|
+
listIdeasInFileWithRangeRows(fileUri: string): Record<string, unknown>[];
|
|
39
|
+
listIdeasetsInFileWithRangeRows(fileUri: string): Record<string, unknown>[];
|
|
40
|
+
getIdeasByIdsRows(ids: string[]): Record<string, unknown>[];
|
|
41
|
+
searchIdeaRows(search: string): Record<string, unknown>[];
|
|
42
|
+
listReferencesForIdea(ideaId: string): NativeReferenceBundle;
|
|
43
|
+
countUnresolvedForIdea(ideaId: string): number;
|
|
44
|
+
countEdgesFromFile(fileUri: string): number;
|
|
45
|
+
getEdgesFromRows(sourceId: string): Record<string, unknown>[];
|
|
46
|
+
getEdgesToRows(targetId: string): Record<string, unknown>[];
|
|
47
|
+
getEdgesForNodesRows(nodeIds: string[]): Record<string, unknown>[];
|
|
48
|
+
getEdgesReferencingFileRows(filePath: string): Record<string, unknown>[];
|
|
49
|
+
getAllEdgeRows(): Record<string, unknown>[];
|
|
50
|
+
listFileReferenceTargetRows(): Record<string, unknown>[];
|
|
51
|
+
allIdeaRawRows(): Record<string, unknown>[];
|
|
52
|
+
counts(): {
|
|
53
|
+
ideas: number;
|
|
54
|
+
edges: number;
|
|
55
|
+
};
|
|
56
|
+
updateDocumentMtime(fileUri: string, mtimeMs: number): void;
|
|
57
|
+
updateGitDates(id: string, createdAt?: string, modifiedAt?: string, changeCount?: number): void;
|
|
58
|
+
clearAll(): void;
|
|
59
|
+
removeDocuments(fileUris: string[]): void;
|
|
60
|
+
upsertDocument(fileUri: string, contentHash: string, ideas: unknown, edges: unknown, mtimeMs?: number): void;
|
|
61
|
+
}
|
|
62
|
+
export interface NativeSqlDbHandle extends NativeQuerySurface {
|
|
63
|
+
query(sql: string, params?: unknown[]): Record<string, unknown>[];
|
|
64
|
+
execute(sql: string, params?: unknown[]): number;
|
|
65
|
+
executeBatch(sql: string): void;
|
|
66
|
+
lastInsertRowid(): number;
|
|
67
|
+
close(): void;
|
|
68
|
+
}
|
|
69
|
+
export declare class NativeSqlConnection {
|
|
70
|
+
private readonly handle;
|
|
71
|
+
readonly dbPath: string;
|
|
72
|
+
private readonly ownsHandle;
|
|
73
|
+
private constructor();
|
|
74
|
+
static open(dbPath: string): Promise<NativeSqlConnection>;
|
|
75
|
+
/** Share the ideas DB connection owned by a NativeWorkspaceIndex (single writer). */
|
|
76
|
+
static fromWorkspaceIdeas(native: NativeWorkspaceIndex, dbPath: string): NativeSqlConnection;
|
|
77
|
+
/** Share the diagnostics DB connection owned by a NativeWorkspaceIndex. */
|
|
78
|
+
static fromWorkspaceDiagnostics(native: NativeWorkspaceIndex, dbPath: string): NativeSqlConnection;
|
|
79
|
+
run(sql: string, ...params: unknown[]): void;
|
|
80
|
+
exec(sql: string): void;
|
|
81
|
+
all<T extends Record<string, unknown> = Record<string, unknown>>(sql: string, ...params: unknown[]): T[];
|
|
82
|
+
get<T extends Record<string, unknown> = Record<string, unknown>>(sql: string, ...params: unknown[]): T | undefined;
|
|
83
|
+
lastInsertRowid(): number;
|
|
84
|
+
countIdeas(query: unknown): number;
|
|
85
|
+
listIdeasPageRows(query: unknown): Record<string, unknown>[];
|
|
86
|
+
listReferenceChipRows(ideaIds: string[]): Record<string, unknown>[];
|
|
87
|
+
countIdeasets(query: unknown): number;
|
|
88
|
+
listIdeasetsPageRows(query: unknown): Record<string, unknown>[];
|
|
89
|
+
listIdeasetMemberRows(ideasetId: string, kind: string, fileUri: string): Record<string, unknown>[];
|
|
90
|
+
countReferences(query: unknown): number;
|
|
91
|
+
listReferencesPageRows(query: unknown): Record<string, unknown>[];
|
|
92
|
+
listTodoIdeaRows(): Record<string, unknown>[];
|
|
93
|
+
listIdeasForGraphQuery(query: unknown, limit: number): {
|
|
94
|
+
rows: Record<string, unknown>[];
|
|
95
|
+
totalMatching: number;
|
|
96
|
+
};
|
|
97
|
+
listRecentGitIdeaRows(limit: number): Record<string, unknown>[];
|
|
98
|
+
listIdeaIdsMissingGitDates(limit: number, fileUri?: string, preferFileUri?: string): string[];
|
|
99
|
+
listAttributeIdeaRows(): Record<string, unknown>[];
|
|
100
|
+
migrateIdeasSchema(): void;
|
|
101
|
+
getDocumentHash(fileUri: string): string | null;
|
|
102
|
+
getDocumentMtimeMs(fileUri: string): number | null;
|
|
103
|
+
listDocumentMtimeRows(): Record<string, unknown>[];
|
|
104
|
+
listDocumentUris(): string[];
|
|
105
|
+
listAllIdeaRows(): Record<string, unknown>[];
|
|
106
|
+
getIdeaRow(id: string): Record<string, unknown> | null;
|
|
107
|
+
getIdeasInFileRows(fileUri: string): Record<string, unknown>[];
|
|
108
|
+
getIdeaAtLineRow(fileUri: string, line: number): Record<string, unknown> | null;
|
|
109
|
+
getIdeasetAtLineRow(fileUri: string, line: number): Record<string, unknown> | null;
|
|
110
|
+
listIdeasInFileWithRangeRows(fileUri: string): Record<string, unknown>[];
|
|
111
|
+
listIdeasetsInFileWithRangeRows(fileUri: string): Record<string, unknown>[];
|
|
112
|
+
getIdeasByIdsRows(ids: string[]): Record<string, unknown>[];
|
|
113
|
+
searchIdeaRows(search: string): Record<string, unknown>[];
|
|
114
|
+
listReferencesForIdea(ideaId: string): NativeReferenceBundle;
|
|
115
|
+
countUnresolvedForIdea(ideaId: string): number;
|
|
116
|
+
countEdgesFromFile(fileUri: string): number;
|
|
117
|
+
getEdgesFromRows(sourceId: string): Record<string, unknown>[];
|
|
118
|
+
getEdgesToRows(targetId: string): Record<string, unknown>[];
|
|
119
|
+
getEdgesForNodesRows(nodeIds: string[]): Record<string, unknown>[];
|
|
120
|
+
getEdgesReferencingFileRows(filePath: string): Record<string, unknown>[];
|
|
121
|
+
getAllEdgeRows(): Record<string, unknown>[];
|
|
122
|
+
listFileReferenceTargetRows(): Record<string, unknown>[];
|
|
123
|
+
allIdeaRawRows(): Record<string, unknown>[];
|
|
124
|
+
counts(): {
|
|
125
|
+
ideas: number;
|
|
126
|
+
edges: number;
|
|
127
|
+
};
|
|
128
|
+
updateDocumentMtime(fileUri: string, mtimeMs: number): void;
|
|
129
|
+
updateGitDates(id: string, createdAt?: string, modifiedAt?: string, changeCount?: number): void;
|
|
130
|
+
clearAll(): void;
|
|
131
|
+
removeDocuments(fileUris: string[]): void;
|
|
132
|
+
upsertDocument(fileUri: string, contentHash: string, ideas: unknown, edges: unknown, mtimeMs?: number): void;
|
|
133
|
+
assertHealthy(): void;
|
|
134
|
+
close(): void;
|
|
135
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin TS wrapper around napi SQL surfaces (NativeSqlDb or NativeWorkspaceIndex).
|
|
3
|
+
* rq:["../../../reqlan rq/core_analysis/rust_port.rq".native_bridge]
|
|
4
|
+
*/
|
|
5
|
+
import { mkdir } from 'node:fs/promises';
|
|
6
|
+
import { statSync } from 'node:fs';
|
|
7
|
+
import { dirname } from 'node:path';
|
|
8
|
+
import { loadNativeEngine } from './load-native.js';
|
|
9
|
+
function toJsonParams(params) {
|
|
10
|
+
return params.map(value => (value === undefined ? null : value));
|
|
11
|
+
}
|
|
12
|
+
export class NativeSqlConnection {
|
|
13
|
+
constructor(handle, dbPath, ownsHandle) {
|
|
14
|
+
this.handle = handle;
|
|
15
|
+
this.dbPath = dbPath;
|
|
16
|
+
this.ownsHandle = ownsHandle;
|
|
17
|
+
}
|
|
18
|
+
static async open(dbPath) {
|
|
19
|
+
await mkdir(dirname(dbPath), { recursive: true });
|
|
20
|
+
const engine = loadNativeEngine();
|
|
21
|
+
if (!engine.NativeSqlDb) {
|
|
22
|
+
throw new Error('NativeSqlDb is missing from the native engine; rebuild reqlan-napi.');
|
|
23
|
+
}
|
|
24
|
+
const conn = new NativeSqlConnection(engine.NativeSqlDb.open(dbPath), dbPath, true);
|
|
25
|
+
conn.assertHealthy();
|
|
26
|
+
return conn;
|
|
27
|
+
}
|
|
28
|
+
/** Share the ideas DB connection owned by a NativeWorkspaceIndex (single writer). */
|
|
29
|
+
static fromWorkspaceIdeas(native, dbPath) {
|
|
30
|
+
return new NativeSqlConnection(native.ideasSqlHandle(), dbPath, false);
|
|
31
|
+
}
|
|
32
|
+
/** Share the diagnostics DB connection owned by a NativeWorkspaceIndex. */
|
|
33
|
+
static fromWorkspaceDiagnostics(native, dbPath) {
|
|
34
|
+
return new NativeSqlConnection(native.diagnosticsSqlHandle(), dbPath, false);
|
|
35
|
+
}
|
|
36
|
+
run(sql, ...params) {
|
|
37
|
+
this.handle.execute(sql, toJsonParams(params));
|
|
38
|
+
}
|
|
39
|
+
exec(sql) {
|
|
40
|
+
this.handle.executeBatch(sql);
|
|
41
|
+
}
|
|
42
|
+
all(sql, ...params) {
|
|
43
|
+
return this.handle.query(sql, toJsonParams(params));
|
|
44
|
+
}
|
|
45
|
+
get(sql, ...params) {
|
|
46
|
+
return this.all(sql, ...params)[0];
|
|
47
|
+
}
|
|
48
|
+
lastInsertRowid() {
|
|
49
|
+
return this.handle.lastInsertRowid();
|
|
50
|
+
}
|
|
51
|
+
// ---- typed webview table/graph query surface (native SQL builders) ----------
|
|
52
|
+
countIdeas(query) {
|
|
53
|
+
return this.handle.countIdeas(query);
|
|
54
|
+
}
|
|
55
|
+
listIdeasPageRows(query) {
|
|
56
|
+
return this.handle.listIdeasPageRows(query);
|
|
57
|
+
}
|
|
58
|
+
listReferenceChipRows(ideaIds) {
|
|
59
|
+
return this.handle.listReferenceChipRows(ideaIds);
|
|
60
|
+
}
|
|
61
|
+
countIdeasets(query) {
|
|
62
|
+
return this.handle.countIdeasets(query);
|
|
63
|
+
}
|
|
64
|
+
listIdeasetsPageRows(query) {
|
|
65
|
+
return this.handle.listIdeasetsPageRows(query);
|
|
66
|
+
}
|
|
67
|
+
listIdeasetMemberRows(ideasetId, kind, fileUri) {
|
|
68
|
+
return this.handle.listIdeasetMemberRows(ideasetId, kind, fileUri);
|
|
69
|
+
}
|
|
70
|
+
countReferences(query) {
|
|
71
|
+
return this.handle.countReferences(query);
|
|
72
|
+
}
|
|
73
|
+
listReferencesPageRows(query) {
|
|
74
|
+
return this.handle.listReferencesPageRows(query);
|
|
75
|
+
}
|
|
76
|
+
listTodoIdeaRows() {
|
|
77
|
+
return this.handle.listTodoIdeaRows();
|
|
78
|
+
}
|
|
79
|
+
listIdeasForGraphQuery(query, limit) {
|
|
80
|
+
return this.handle.listIdeasForGraphQuery(query, limit);
|
|
81
|
+
}
|
|
82
|
+
listRecentGitIdeaRows(limit) {
|
|
83
|
+
return this.handle.listRecentGitIdeaRows(limit);
|
|
84
|
+
}
|
|
85
|
+
listIdeaIdsMissingGitDates(limit, fileUri, preferFileUri) {
|
|
86
|
+
return this.handle.listIdeaIdsMissingGitDates(limit, fileUri, preferFileUri);
|
|
87
|
+
}
|
|
88
|
+
listAttributeIdeaRows() {
|
|
89
|
+
return this.handle.listAttributeIdeaRows();
|
|
90
|
+
}
|
|
91
|
+
// ---- typed domain read/write surface (native SQL) ---------------------------
|
|
92
|
+
migrateIdeasSchema() {
|
|
93
|
+
this.handle.migrateIdeasSchema();
|
|
94
|
+
}
|
|
95
|
+
getDocumentHash(fileUri) {
|
|
96
|
+
return this.handle.getDocumentHash(fileUri);
|
|
97
|
+
}
|
|
98
|
+
getDocumentMtimeMs(fileUri) {
|
|
99
|
+
return this.handle.getDocumentMtimeMs(fileUri);
|
|
100
|
+
}
|
|
101
|
+
listDocumentMtimeRows() {
|
|
102
|
+
return this.handle.listDocumentMtimeRows();
|
|
103
|
+
}
|
|
104
|
+
listDocumentUris() {
|
|
105
|
+
return this.handle.listDocumentUris();
|
|
106
|
+
}
|
|
107
|
+
listAllIdeaRows() {
|
|
108
|
+
return this.handle.listAllIdeaRows();
|
|
109
|
+
}
|
|
110
|
+
getIdeaRow(id) {
|
|
111
|
+
return this.handle.getIdeaRow(id);
|
|
112
|
+
}
|
|
113
|
+
getIdeasInFileRows(fileUri) {
|
|
114
|
+
return this.handle.getIdeasInFileRows(fileUri);
|
|
115
|
+
}
|
|
116
|
+
getIdeaAtLineRow(fileUri, line) {
|
|
117
|
+
return this.handle.getIdeaAtLineRow(fileUri, line);
|
|
118
|
+
}
|
|
119
|
+
getIdeasetAtLineRow(fileUri, line) {
|
|
120
|
+
return this.handle.getIdeasetAtLineRow(fileUri, line);
|
|
121
|
+
}
|
|
122
|
+
listIdeasInFileWithRangeRows(fileUri) {
|
|
123
|
+
return this.handle.listIdeasInFileWithRangeRows(fileUri);
|
|
124
|
+
}
|
|
125
|
+
listIdeasetsInFileWithRangeRows(fileUri) {
|
|
126
|
+
return this.handle.listIdeasetsInFileWithRangeRows(fileUri);
|
|
127
|
+
}
|
|
128
|
+
getIdeasByIdsRows(ids) {
|
|
129
|
+
return this.handle.getIdeasByIdsRows(ids);
|
|
130
|
+
}
|
|
131
|
+
searchIdeaRows(search) {
|
|
132
|
+
return this.handle.searchIdeaRows(search);
|
|
133
|
+
}
|
|
134
|
+
listReferencesForIdea(ideaId) {
|
|
135
|
+
return this.handle.listReferencesForIdea(ideaId);
|
|
136
|
+
}
|
|
137
|
+
countUnresolvedForIdea(ideaId) {
|
|
138
|
+
return this.handle.countUnresolvedForIdea(ideaId);
|
|
139
|
+
}
|
|
140
|
+
countEdgesFromFile(fileUri) {
|
|
141
|
+
return this.handle.countEdgesFromFile(fileUri);
|
|
142
|
+
}
|
|
143
|
+
getEdgesFromRows(sourceId) {
|
|
144
|
+
return this.handle.getEdgesFromRows(sourceId);
|
|
145
|
+
}
|
|
146
|
+
getEdgesToRows(targetId) {
|
|
147
|
+
return this.handle.getEdgesToRows(targetId);
|
|
148
|
+
}
|
|
149
|
+
getEdgesForNodesRows(nodeIds) {
|
|
150
|
+
return this.handle.getEdgesForNodesRows(nodeIds);
|
|
151
|
+
}
|
|
152
|
+
getEdgesReferencingFileRows(filePath) {
|
|
153
|
+
return this.handle.getEdgesReferencingFileRows(filePath);
|
|
154
|
+
}
|
|
155
|
+
getAllEdgeRows() {
|
|
156
|
+
return this.handle.getAllEdgeRows();
|
|
157
|
+
}
|
|
158
|
+
listFileReferenceTargetRows() {
|
|
159
|
+
return this.handle.listFileReferenceTargetRows();
|
|
160
|
+
}
|
|
161
|
+
allIdeaRawRows() {
|
|
162
|
+
return this.handle.allIdeaRawRows();
|
|
163
|
+
}
|
|
164
|
+
counts() {
|
|
165
|
+
return this.handle.counts();
|
|
166
|
+
}
|
|
167
|
+
updateDocumentMtime(fileUri, mtimeMs) {
|
|
168
|
+
this.handle.updateDocumentMtime(fileUri, mtimeMs);
|
|
169
|
+
}
|
|
170
|
+
updateGitDates(id, createdAt, modifiedAt, changeCount) {
|
|
171
|
+
this.handle.updateGitDates(id, createdAt, modifiedAt, changeCount);
|
|
172
|
+
}
|
|
173
|
+
clearAll() {
|
|
174
|
+
this.handle.clearAll();
|
|
175
|
+
}
|
|
176
|
+
removeDocuments(fileUris) {
|
|
177
|
+
this.handle.removeDocuments(fileUris);
|
|
178
|
+
}
|
|
179
|
+
upsertDocument(fileUri, contentHash, ideas, edges, mtimeMs) {
|
|
180
|
+
this.handle.upsertDocument(fileUri, contentHash, ideas, edges, mtimeMs);
|
|
181
|
+
}
|
|
182
|
+
assertHealthy() {
|
|
183
|
+
const rows = this.all('PRAGMA integrity_check');
|
|
184
|
+
if (rows.length === 0) {
|
|
185
|
+
throw new Error('database disk image is malformed: integrity_check returned no rows');
|
|
186
|
+
}
|
|
187
|
+
for (const row of rows) {
|
|
188
|
+
const result = String(row.integrity_check ?? row.quick_check ?? Object.values(row)[0] ?? '');
|
|
189
|
+
if (result && result.toLowerCase() !== 'ok') {
|
|
190
|
+
throw new Error(`database disk image is malformed: ${result}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const pageCountRow = this.get('PRAGMA page_count');
|
|
194
|
+
const pageSizeRow = this.get('PRAGMA page_size');
|
|
195
|
+
const pageCount = Number(pageCountRow?.page_count ?? Object.values(pageCountRow ?? {})[0] ?? 0);
|
|
196
|
+
const pageSize = Number(pageSizeRow?.page_size ?? Object.values(pageSizeRow ?? {})[0] ?? 0);
|
|
197
|
+
if (pageCount > 0 && pageSize > 0) {
|
|
198
|
+
try {
|
|
199
|
+
const size = statSync(this.dbPath).size;
|
|
200
|
+
if (size < pageCount * pageSize) {
|
|
201
|
+
throw new Error(`database disk image is malformed: file truncated (${size} bytes, expected ${pageCount * pageSize})`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
if (error instanceof Error && /malformed/i.test(error.message)) {
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
close() {
|
|
212
|
+
if (this.ownsHandle) {
|
|
213
|
+
this.handle.close();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=native-sql-db.js.map
|