@dikolab/kbdb 0.2.1 → 0.3.0
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 +59 -24
- package/dist/cli.cjs +462 -73
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.mjs +454 -65
- package/dist/cli.mjs.map +4 -4
- package/dist/kbdb-worker.cjs +395 -60
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +18 -1
- package/dist/mod.cjs.map +2 -2
- package/dist/mod.mjs +18 -1
- package/dist/mod.mjs.map +2 -2
- package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +3 -1
- package/dist/src/shared/cli/functions/install-default-skills.function.d.ts +12 -0
- package/dist/src/shared/cli/functions/run-check.function.d.ts +47 -5
- package/dist/src/shared/cli/functions/run-export.function.d.ts +34 -0
- package/dist/src/shared/cli/functions/run-gc.function.d.ts +6 -0
- package/dist/src/shared/cli/functions/run-learn.function.d.ts +35 -6
- package/dist/src/shared/cli/functions/run-recall.function.d.ts +45 -0
- package/dist/src/shared/cli/functions/run-search.function.d.ts +52 -15
- package/dist/src/shared/cli/index.d.ts +4 -0
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +13 -0
- package/dist/src/shared/cli/typings/learn-result.model.d.ts +19 -0
- package/dist/src/shared/cli/typings/search-display.model.d.ts +18 -0
- package/dist/src/shared/mcp/classes/mcp-server.class.d.ts +8 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +43 -0
- package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
- package/dist/src/shared/wasm-codec/functions/decode-add-section-result.function.d.ts +48 -0
- package/dist/src/shared/wasm-codec/functions/decode-scored-results.function.d.ts +58 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +33 -0
- package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +52 -0
- package/dist/src/shared/wasm-codec/index.d.ts +2 -0
- package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +16 -0
- package/dist/src/shared/worker-client/index.d.ts +1 -1
- package/dist/src/shared/worker-client/typings/add-section-result.model.d.ts +29 -15
- package/dist/src/shared/worker-client/typings/export-result.model.d.ts +14 -0
- package/dist/src/shared/worker-client/typings/gc-result.model.d.ts +6 -0
- package/dist/src/shared/worker-client/typings/search-result.model.d.ts +12 -0
- package/dist/src/shared/worker-client/typings/section.model.d.ts +16 -0
- package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +35 -0
- package/dist/wasm/fs-database/kbdb_fs_database.d.ts +22 -1
- package/dist/wasm/fs-database/kbdb_fs_database.js +28 -1
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +1 -0
- package/dist/wasm/kb-worker/kbdb_worker.d.ts +48 -1
- package/dist/wasm/kb-worker/kbdb_worker.js +60 -1
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +2 -0
- package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
- package/dist/worker.mjs +396 -60
- package/dist/worker.mjs.map +4 -4
- package/docs/details/cli.md +102 -15
- package/docs/details/library-api.md +55 -6
- package/docs/details/mcp-server.md +8 -4
- package/docs/details/search-and-ranking.md +63 -5
- package/docs/details/storage.md +2 -0
- package/docs/goals/cli.md +255 -14
- package/docs/goals/database.md +244 -17
- package/docs/goals/document.md +1 -1
- package/docs/goals/mcp.md +83 -14
- package/docs/goals/query-parser.md +98 -4
- package/docs/goals/query-result.md +177 -10
- package/docs/goals/skills.md +72 -0
- package/docs/goals/worker-daemon.md +54 -7
- package/docs/modules/rust/fs-database/functions/integrity.md +11 -0
- package/docs/modules/rust/fs-database/functions/section.md +23 -6
- package/docs/modules/rust/fs-database/module.md +1 -0
- package/docs/modules/rust/fs-database/types/section.md +27 -1
- package/docs/modules/rust/overview.md +2 -1
- package/docs/modules/rust/query-parser/functions/module.md +2 -2
- package/docs/modules/rust/query-parser/functions/pipeline.md +44 -6
- package/docs/modules/rust/query-parser/module.md +5 -4
- package/docs/modules/rust/query-parser/types/keyphrase.md +11 -0
- package/docs/modules/rust/query-parser/types/module.md +3 -3
- package/docs/modules/typescript/shared/cli/functions.md +68 -3
- package/package.json +1 -1
- package/src/shared/cli/functions/dispatch-command.function.ts +53 -1
- package/src/shared/cli/functions/format-output.function.ts +36 -12
- package/src/shared/cli/functions/generate-help.function.ts +56 -1
- package/src/shared/cli/functions/install-default-skills.function.ts +296 -0
- package/src/shared/cli/functions/parse-args.function.ts +13 -0
- package/src/shared/cli/functions/run-check.function.ts +87 -6
- package/src/shared/cli/functions/run-export.function.ts +40 -0
- package/src/shared/cli/functions/run-gc.function.ts +6 -0
- package/src/shared/cli/functions/run-init.function.ts +2 -0
- package/src/shared/cli/functions/run-learn.function.ts +68 -16
- package/src/shared/cli/functions/run-recall.function.ts +66 -0
- package/src/shared/cli/functions/run-search.function.ts +58 -15
- package/src/shared/cli/index.ts +4 -0
- package/src/shared/cli/typings/cli-options.interface.ts +13 -0
- package/src/shared/cli/typings/learn-result.model.ts +16 -0
- package/src/shared/cli/typings/search-display.model.ts +18 -0
- package/src/shared/mcp/classes/mcp-server.class.ts +30 -1
- package/src/shared/mcp/functions/create-tool-definitions.function.ts +46 -5
- package/src/shared/mcp/functions/handle-tool-call.function.ts +70 -2
- package/src/shared/mcp/typings/mcp-client.interface.ts +45 -0
- package/src/shared/version/constants/version.constant.ts +1 -1
- package/src/shared/wasm-codec/functions/decode-add-section-result.function.ts +112 -0
- package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +86 -0
- package/src/shared/wasm-codec/functions/decode-section-records.function.ts +87 -0
- package/src/shared/wasm-codec/functions/encode-add-section-params.function.ts +68 -0
- package/src/shared/wasm-codec/index.ts +5 -0
- package/src/shared/worker-client/classes/worker-client.class.ts +19 -0
- package/src/shared/worker-client/index.ts +4 -1
- package/src/shared/worker-client/typings/add-section-result.model.ts +30 -15
- package/src/shared/worker-client/typings/export-result.model.ts +14 -0
- package/src/shared/worker-client/typings/gc-result.model.ts +6 -0
- package/src/shared/worker-client/typings/search-result.model.ts +12 -0
- package/src/shared/worker-client/typings/section.model.ts +16 -0
- package/src/shared/worker-daemon/classes/worker-daemon.class.ts +315 -46
- package/src/shared/worker-daemon/functions/create-host-imports.function.ts +19 -4
- package/src/shared/worker-daemon/functions/create-ipc-server.function.ts +5 -1
- package/src/wasm/fs-database/kbdb_fs_database.d.ts +22 -1
- package/src/wasm/fs-database/kbdb_fs_database.js +28 -1
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +1 -0
- package/src/wasm/kb-worker/kbdb_worker.d.ts +48 -1
- package/src/wasm/kb-worker/kbdb_worker.js +60 -1
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +2 -0
- package/src/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
|
@@ -12,7 +12,7 @@ export type { Section, AddSectionParams, } from './typings/section.model.ts';
|
|
|
12
12
|
export type { StatusResult } from './typings/status-result.model.ts';
|
|
13
13
|
export type { WorkerClientError } from './typings/worker-client-error.interface.ts';
|
|
14
14
|
export type { DaemonInfo } from './typings/daemon-info.model.ts';
|
|
15
|
-
export type { AddSectionResult } from './typings/add-section-result.model.ts';
|
|
15
|
+
export type { AddSectionResult, NearDuplicateEntry, } from './typings/add-section-result.model.ts';
|
|
16
16
|
export type { RemoveSectionResult } from './typings/remove-section-result.model.ts';
|
|
17
17
|
export type { ContentResult } from './typings/content-result.model.ts';
|
|
18
18
|
export type { IntegrityCheckResult, IntegrityError, } from './typings/integrity-check-result.model.ts';
|
|
@@ -1,22 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A near-duplicate section reported after adding a new section.
|
|
3
|
+
*/
|
|
4
|
+
export interface NearDuplicateEntry {
|
|
5
|
+
/** Knowledge-base identifier of the near-duplicate section. */
|
|
6
|
+
readonly kbid: string;
|
|
7
|
+
/** Jaccard similarity score (0.0--1.0). */
|
|
8
|
+
readonly similarity: number;
|
|
9
|
+
}
|
|
1
10
|
/** Result returned by the daemon after adding a new section. */
|
|
2
11
|
export interface AddSectionResult {
|
|
3
12
|
/** Knowledge-base identifier assigned to the section. */
|
|
4
13
|
readonly kbid: string;
|
|
5
|
-
/** MIME type of the stored section. */
|
|
6
|
-
readonly type: string;
|
|
7
|
-
/** Section title, if provided. */
|
|
8
|
-
readonly title?: string;
|
|
9
|
-
/** Section description, if provided. */
|
|
10
|
-
readonly description?: string;
|
|
11
|
-
/** Total token count for the section. */
|
|
12
|
-
readonly token_count: number;
|
|
13
|
-
/** Number of unique terms indexed for this section. */
|
|
14
|
-
readonly indexed_terms_count: number;
|
|
15
|
-
/** Time taken to process and store the section, in milliseconds. */
|
|
16
|
-
readonly elapsed_ms: number;
|
|
17
14
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* Number of unique terms indexed for the section.
|
|
16
|
+
* Present in the current binary-decoded response format.
|
|
17
|
+
*/
|
|
18
|
+
readonly indexed_terms_count?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Wall-clock time the add operation took, in milliseconds.
|
|
21
|
+
* Present in the current binary-decoded response format.
|
|
22
|
+
*/
|
|
23
|
+
readonly elapsed_ms?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Knowledge-base identifier of the section that was superseded,
|
|
26
|
+
* or `null` if no supersession occurred.
|
|
27
|
+
*/
|
|
28
|
+
readonly superseded?: string | null;
|
|
29
|
+
/** Advisory warnings emitted during indexing. */
|
|
30
|
+
readonly warnings?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Near-duplicate sections detected above the similarity threshold
|
|
33
|
+
* (Jaccard >= 0.85).
|
|
20
34
|
*/
|
|
21
|
-
readonly
|
|
35
|
+
readonly near_duplicates?: NearDuplicateEntry[];
|
|
22
36
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report returned by the daemon after exporting the database to a
|
|
3
|
+
* target directory.
|
|
4
|
+
*/
|
|
5
|
+
export interface ExportResult {
|
|
6
|
+
/** Absolute path to the directory where files were written. */
|
|
7
|
+
readonly path: string;
|
|
8
|
+
/** Number of section files copied to the export directory. */
|
|
9
|
+
readonly sections_exported: number;
|
|
10
|
+
/** Number of document manifest files copied. */
|
|
11
|
+
readonly documents_exported: number;
|
|
12
|
+
/** Wall-clock time the export operation took, in milliseconds. */
|
|
13
|
+
readonly elapsed_ms: number;
|
|
14
|
+
}
|
|
@@ -9,4 +9,10 @@ export interface GcResult {
|
|
|
9
9
|
readonly removed_bytes: number;
|
|
10
10
|
/** Time taken to complete garbage collection, in milliseconds. */
|
|
11
11
|
readonly elapsed_ms: number;
|
|
12
|
+
/**
|
|
13
|
+
* Number of sections whose source_path file no longer contains
|
|
14
|
+
* their heading text. Advisory; not auto-removed by gc.
|
|
15
|
+
* Absent on older daemon versions.
|
|
16
|
+
*/
|
|
17
|
+
readonly stale_sources?: number;
|
|
12
18
|
}
|
|
@@ -14,6 +14,18 @@ export interface SearchResult {
|
|
|
14
14
|
readonly snippet: string;
|
|
15
15
|
/** Query terms that matched within this section. */
|
|
16
16
|
readonly matched_terms: readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* Fields that contained at least one match
|
|
19
|
+
* (e.g. `'heading'`, `'body'`).
|
|
20
|
+
*/
|
|
21
|
+
readonly matched_fields?: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* Normalised confidence score (0.0-1.0) relative to the top result.
|
|
24
|
+
* May be absent from older daemon versions.
|
|
25
|
+
*/
|
|
26
|
+
readonly confidence?: number;
|
|
27
|
+
/** ISO 8601 creation timestamp of the section. */
|
|
28
|
+
readonly created_at?: string;
|
|
17
29
|
}
|
|
18
30
|
/** Paginated search result envelope. */
|
|
19
31
|
export interface PagedSearchResult {
|
|
@@ -23,4 +23,20 @@ export interface AddSectionParams {
|
|
|
23
23
|
readonly content: string;
|
|
24
24
|
/** Parent document identifier to associate the section with. */
|
|
25
25
|
readonly docid?: string;
|
|
26
|
+
/** Human-readable heading for the section. */
|
|
27
|
+
readonly title?: string;
|
|
28
|
+
/** Short summary or description of the section. */
|
|
29
|
+
readonly description?: string;
|
|
30
|
+
/** Application-defined tags for scoping and filtering. */
|
|
31
|
+
readonly tags?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* When `true`, supersedes an existing section with the same
|
|
34
|
+
* source key (derived from `sourcePath` and `title`).
|
|
35
|
+
*/
|
|
36
|
+
readonly replace?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Absolute path to the source file. Required for supersession
|
|
39
|
+
* via source key when `replace` is `true`.
|
|
40
|
+
*/
|
|
41
|
+
readonly sourcePath?: string;
|
|
26
42
|
}
|
|
@@ -25,6 +25,14 @@ export declare class WorkerDaemon {
|
|
|
25
25
|
private _idleTimer;
|
|
26
26
|
private _server;
|
|
27
27
|
private readonly _wasmDir;
|
|
28
|
+
/** Queue of waiters for the single-writer lock. */
|
|
29
|
+
private _writeQueue;
|
|
30
|
+
/** Whether the write lock is currently held. */
|
|
31
|
+
private _writeLocked;
|
|
32
|
+
/** Whether the startup integrity check passed. */
|
|
33
|
+
private _integrityOk;
|
|
34
|
+
/** Integrity errors found at startup, if any. */
|
|
35
|
+
private _integrityErrors;
|
|
28
36
|
/**
|
|
29
37
|
* @param ctx - context ID (16-hex characters), the first 16 of
|
|
30
38
|
* the SHA-256 hash of `targetDir`
|
|
@@ -133,7 +141,34 @@ export declare class WorkerDaemon {
|
|
|
133
141
|
private handleIntegrityCheck;
|
|
134
142
|
private handleGc;
|
|
135
143
|
private handleRebuild;
|
|
144
|
+
private handleExport;
|
|
145
|
+
private scanNearDuplicates;
|
|
146
|
+
private extractTermSet;
|
|
147
|
+
/**
|
|
148
|
+
* Acquires the write lock.
|
|
149
|
+
*
|
|
150
|
+
* If the lock is free it is granted immediately. If it is held the
|
|
151
|
+
* caller is queued and its promise resolves once the lock is
|
|
152
|
+
* released by the current holder.
|
|
153
|
+
*/
|
|
154
|
+
private acquireWriteLock;
|
|
155
|
+
/**
|
|
156
|
+
* Releases the write lock.
|
|
157
|
+
*
|
|
158
|
+
* If waiters are queued the next one is granted the lock
|
|
159
|
+
* immediately. Otherwise the lock is marked free.
|
|
160
|
+
*/
|
|
161
|
+
private releaseWriteLock;
|
|
136
162
|
private initWorkerContext;
|
|
163
|
+
/**
|
|
164
|
+
* Runs a database integrity check immediately after context
|
|
165
|
+
* initialisation.
|
|
166
|
+
*
|
|
167
|
+
* Stores the result in `_integrityOk` and `_integrityErrors`.
|
|
168
|
+
* Logs a warning to stderr when issues are found so operators
|
|
169
|
+
* are alerted without aborting the daemon.
|
|
170
|
+
*/
|
|
171
|
+
private runStartupIntegrityCheck;
|
|
137
172
|
private getExport;
|
|
138
173
|
private wasmAlloc;
|
|
139
174
|
private wasmFree;
|
|
@@ -5,7 +5,10 @@ declare namespace wasm_bindgen {
|
|
|
5
5
|
/**
|
|
6
6
|
* Adds a section. `ptr`/`len` point to an encoded `AddSectionParams`.
|
|
7
7
|
*
|
|
8
|
-
* On success: writes encoded
|
|
8
|
+
* On success: writes an encoded `AddSectionResult` to the return slot and
|
|
9
|
+
* returns 0. When `params.replace` is true and a section with the same
|
|
10
|
+
* `source_key` exists, the superseded section's index entries are removed
|
|
11
|
+
* and the returned `AddSectionResult.superseded` is set to its kbid.
|
|
9
12
|
* On error: writes error message to return slot, returns -1.
|
|
10
13
|
*/
|
|
11
14
|
export function db_add_section(ptr: number, len: number): number;
|
|
@@ -42,6 +45,23 @@ declare namespace wasm_bindgen {
|
|
|
42
45
|
*/
|
|
43
46
|
export function db_check_version(ptr: number, len: number): number;
|
|
44
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Exports the database to a target directory.
|
|
50
|
+
*
|
|
51
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
52
|
+
*
|
|
53
|
+
* Copies `sections/`, `documents/`, and `catalog.toml` to the target.
|
|
54
|
+
* Indexes are not copied because they can be rebuilt from the data.
|
|
55
|
+
*
|
|
56
|
+
* The target path may be absolute or relative. It is an external output
|
|
57
|
+
* destination, not a database-internal path, so no path validation is
|
|
58
|
+
* applied to it.
|
|
59
|
+
*
|
|
60
|
+
* On success a summary string is placed in the return slot:
|
|
61
|
+
* `path={target}\nsections_exported={N}\ndocuments_exported={M}`
|
|
62
|
+
*/
|
|
63
|
+
export function db_export(ptr: number, len: number): number;
|
|
64
|
+
|
|
45
65
|
/**
|
|
46
66
|
* Runs garbage collection. Returns 0 on success.
|
|
47
67
|
* On success a summary string is placed in the return slot.
|
|
@@ -200,6 +220,7 @@ declare interface InitOutput {
|
|
|
200
220
|
readonly db_add_to_index: (a: number, b: number) => number;
|
|
201
221
|
readonly db_check_integrity: (a: number, b: number) => number;
|
|
202
222
|
readonly db_check_version: (a: number, b: number) => number;
|
|
223
|
+
readonly db_export: (a: number, b: number) => number;
|
|
203
224
|
readonly db_gc: (a: number, b: number) => number;
|
|
204
225
|
readonly db_get_back_refs: (a: number, b: number) => number;
|
|
205
226
|
readonly db_get_forward_refs: (a: number, b: number) => number;
|
|
@@ -7,7 +7,10 @@ let wasm_bindgen = (function(exports) {
|
|
|
7
7
|
/**
|
|
8
8
|
* Adds a section. `ptr`/`len` point to an encoded `AddSectionParams`.
|
|
9
9
|
*
|
|
10
|
-
* On success: writes encoded
|
|
10
|
+
* On success: writes an encoded `AddSectionResult` to the return slot and
|
|
11
|
+
* returns 0. When `params.replace` is true and a section with the same
|
|
12
|
+
* `source_key` exists, the superseded section's index entries are removed
|
|
13
|
+
* and the returned `AddSectionResult.superseded` is set to its kbid.
|
|
11
14
|
* On error: writes error message to return slot, returns -1.
|
|
12
15
|
* @param {number} ptr
|
|
13
16
|
* @param {number} len
|
|
@@ -72,6 +75,30 @@ let wasm_bindgen = (function(exports) {
|
|
|
72
75
|
}
|
|
73
76
|
exports.db_check_version = db_check_version;
|
|
74
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Exports the database to a target directory.
|
|
80
|
+
*
|
|
81
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
82
|
+
*
|
|
83
|
+
* Copies `sections/`, `documents/`, and `catalog.toml` to the target.
|
|
84
|
+
* Indexes are not copied because they can be rebuilt from the data.
|
|
85
|
+
*
|
|
86
|
+
* The target path may be absolute or relative. It is an external output
|
|
87
|
+
* destination, not a database-internal path, so no path validation is
|
|
88
|
+
* applied to it.
|
|
89
|
+
*
|
|
90
|
+
* On success a summary string is placed in the return slot:
|
|
91
|
+
* `path={target}\nsections_exported={N}\ndocuments_exported={M}`
|
|
92
|
+
* @param {number} ptr
|
|
93
|
+
* @param {number} len
|
|
94
|
+
* @returns {number}
|
|
95
|
+
*/
|
|
96
|
+
function db_export(ptr, len) {
|
|
97
|
+
const ret = wasm.db_export(ptr, len);
|
|
98
|
+
return ret;
|
|
99
|
+
}
|
|
100
|
+
exports.db_export = db_export;
|
|
101
|
+
|
|
75
102
|
/**
|
|
76
103
|
* Runs garbage collection. Returns 0 on success.
|
|
77
104
|
* On success a summary string is placed in the return slot.
|
|
Binary file
|
|
@@ -7,6 +7,7 @@ export const db_add_section: (a: number, b: number) => number;
|
|
|
7
7
|
export const db_add_to_index: (a: number, b: number) => number;
|
|
8
8
|
export const db_check_integrity: (a: number, b: number) => number;
|
|
9
9
|
export const db_check_version: (a: number, b: number) => number;
|
|
10
|
+
export const db_export: (a: number, b: number) => number;
|
|
10
11
|
export const db_gc: (a: number, b: number) => number;
|
|
11
12
|
export const db_get_back_refs: (a: number, b: number) => number;
|
|
12
13
|
export const db_get_forward_refs: (a: number, b: number) => number;
|
|
@@ -5,7 +5,10 @@ declare namespace wasm_bindgen {
|
|
|
5
5
|
/**
|
|
6
6
|
* Adds a section. `ptr`/`len` point to an encoded `AddSectionParams`.
|
|
7
7
|
*
|
|
8
|
-
* On success: writes encoded
|
|
8
|
+
* On success: writes an encoded `AddSectionResult` to the return slot and
|
|
9
|
+
* returns 0. When `params.replace` is true and a section with the same
|
|
10
|
+
* `source_key` exists, the superseded section's index entries are removed
|
|
11
|
+
* and the returned `AddSectionResult.superseded` is set to its kbid.
|
|
9
12
|
* On error: writes error message to return slot, returns -1.
|
|
10
13
|
*/
|
|
11
14
|
export function db_add_section(ptr: number, len: number): number;
|
|
@@ -42,6 +45,23 @@ declare namespace wasm_bindgen {
|
|
|
42
45
|
*/
|
|
43
46
|
export function db_check_version(ptr: number, len: number): number;
|
|
44
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Exports the database to a target directory.
|
|
50
|
+
*
|
|
51
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
52
|
+
*
|
|
53
|
+
* Copies `sections/`, `documents/`, and `catalog.toml` to the target.
|
|
54
|
+
* Indexes are not copied because they can be rebuilt from the data.
|
|
55
|
+
*
|
|
56
|
+
* The target path may be absolute or relative. It is an external output
|
|
57
|
+
* destination, not a database-internal path, so no path validation is
|
|
58
|
+
* applied to it.
|
|
59
|
+
*
|
|
60
|
+
* On success a summary string is placed in the return slot:
|
|
61
|
+
* `path={target}\nsections_exported={N}\ndocuments_exported={M}`
|
|
62
|
+
*/
|
|
63
|
+
export function db_export(ptr: number, len: number): number;
|
|
64
|
+
|
|
45
65
|
/**
|
|
46
66
|
* Runs garbage collection. Returns 0 on success.
|
|
47
67
|
* On success a summary string is placed in the return slot.
|
|
@@ -344,6 +364,10 @@ declare namespace wasm_bindgen {
|
|
|
344
364
|
|
|
345
365
|
/**
|
|
346
366
|
* Adds a section. Returns 0 on success, -1 on error.
|
|
367
|
+
*
|
|
368
|
+
* On success the return slot holds the binary-encoded `AddSectionResult`
|
|
369
|
+
* (kbid + indexed_terms_count + elapsed_ms + superseded + warnings +
|
|
370
|
+
* near_duplicates) using the `Encode` trait wire format.
|
|
347
371
|
*/
|
|
348
372
|
export function worker_add_section(ptr: number, len: number): number;
|
|
349
373
|
|
|
@@ -365,6 +389,19 @@ declare namespace wasm_bindgen {
|
|
|
365
389
|
*/
|
|
366
390
|
export function worker_compose(ptr: number, len: number): number;
|
|
367
391
|
|
|
392
|
+
/**
|
|
393
|
+
* Exports the database to a target directory.
|
|
394
|
+
*
|
|
395
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
396
|
+
*
|
|
397
|
+
* Delegates directly to `db_export` in `kbdb-fs-database`. Does not require
|
|
398
|
+
* the worker to have been initialised because the target path is given
|
|
399
|
+
* explicitly by the caller.
|
|
400
|
+
*
|
|
401
|
+
* Returns 0 on success, -1 on error (message in return slot).
|
|
402
|
+
*/
|
|
403
|
+
export function worker_export(ptr: number, len: number): number;
|
|
404
|
+
|
|
368
405
|
/**
|
|
369
406
|
* Runs garbage collection and invalidates all cache entries.
|
|
370
407
|
*
|
|
@@ -444,6 +481,14 @@ declare namespace wasm_bindgen {
|
|
|
444
481
|
|
|
445
482
|
/**
|
|
446
483
|
* Rebuilds all database indexes.
|
|
484
|
+
*
|
|
485
|
+
* First clears the existing inverted, positional, and reference indexes via
|
|
486
|
+
* `db_rebuild_index`. Then re-tokenizes every stored section and re-populates
|
|
487
|
+
* the indexes via `rebuild_all_section_indexes`.
|
|
488
|
+
*
|
|
489
|
+
* On success the return slot holds the number of reindexed sections as a
|
|
490
|
+
* little-endian `u32`, and 0 is returned. On error -1 is returned and an
|
|
491
|
+
* error message is in the return slot.
|
|
447
492
|
*/
|
|
448
493
|
export function worker_rebuild_indexes(): number;
|
|
449
494
|
|
|
@@ -525,6 +570,7 @@ declare interface InitOutput {
|
|
|
525
570
|
readonly worker_add_section: (a: number, b: number) => number;
|
|
526
571
|
readonly worker_check_integrity: () => number;
|
|
527
572
|
readonly worker_compose: (a: number, b: number) => number;
|
|
573
|
+
readonly worker_export: (a: number, b: number) => number;
|
|
528
574
|
readonly worker_garbage_collect: () => number;
|
|
529
575
|
readonly worker_get_result: (a: number) => number;
|
|
530
576
|
readonly worker_group_sections: (a: number, b: number) => number;
|
|
@@ -565,6 +611,7 @@ declare interface InitOutput {
|
|
|
565
611
|
readonly db_add_to_index: (a: number, b: number) => number;
|
|
566
612
|
readonly db_check_integrity: (a: number, b: number) => number;
|
|
567
613
|
readonly db_check_version: (a: number, b: number) => number;
|
|
614
|
+
readonly db_export: (a: number, b: number) => number;
|
|
568
615
|
readonly db_gc: (a: number, b: number) => number;
|
|
569
616
|
readonly db_get_back_refs: (a: number, b: number) => number;
|
|
570
617
|
readonly db_get_forward_refs: (a: number, b: number) => number;
|
|
@@ -7,7 +7,10 @@ let wasm_bindgen = (function(exports) {
|
|
|
7
7
|
/**
|
|
8
8
|
* Adds a section. `ptr`/`len` point to an encoded `AddSectionParams`.
|
|
9
9
|
*
|
|
10
|
-
* On success: writes encoded
|
|
10
|
+
* On success: writes an encoded `AddSectionResult` to the return slot and
|
|
11
|
+
* returns 0. When `params.replace` is true and a section with the same
|
|
12
|
+
* `source_key` exists, the superseded section's index entries are removed
|
|
13
|
+
* and the returned `AddSectionResult.superseded` is set to its kbid.
|
|
11
14
|
* On error: writes error message to return slot, returns -1.
|
|
12
15
|
* @param {number} ptr
|
|
13
16
|
* @param {number} len
|
|
@@ -72,6 +75,30 @@ let wasm_bindgen = (function(exports) {
|
|
|
72
75
|
}
|
|
73
76
|
exports.db_check_version = db_check_version;
|
|
74
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Exports the database to a target directory.
|
|
80
|
+
*
|
|
81
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
82
|
+
*
|
|
83
|
+
* Copies `sections/`, `documents/`, and `catalog.toml` to the target.
|
|
84
|
+
* Indexes are not copied because they can be rebuilt from the data.
|
|
85
|
+
*
|
|
86
|
+
* The target path may be absolute or relative. It is an external output
|
|
87
|
+
* destination, not a database-internal path, so no path validation is
|
|
88
|
+
* applied to it.
|
|
89
|
+
*
|
|
90
|
+
* On success a summary string is placed in the return slot:
|
|
91
|
+
* `path={target}\nsections_exported={N}\ndocuments_exported={M}`
|
|
92
|
+
* @param {number} ptr
|
|
93
|
+
* @param {number} len
|
|
94
|
+
* @returns {number}
|
|
95
|
+
*/
|
|
96
|
+
function db_export(ptr, len) {
|
|
97
|
+
const ret = wasm.db_export(ptr, len);
|
|
98
|
+
return ret;
|
|
99
|
+
}
|
|
100
|
+
exports.db_export = db_export;
|
|
101
|
+
|
|
75
102
|
/**
|
|
76
103
|
* Runs garbage collection. Returns 0 on success.
|
|
77
104
|
* On success a summary string is placed in the return slot.
|
|
@@ -644,6 +671,10 @@ let wasm_bindgen = (function(exports) {
|
|
|
644
671
|
|
|
645
672
|
/**
|
|
646
673
|
* Adds a section. Returns 0 on success, -1 on error.
|
|
674
|
+
*
|
|
675
|
+
* On success the return slot holds the binary-encoded `AddSectionResult`
|
|
676
|
+
* (kbid + indexed_terms_count + elapsed_ms + superseded + warnings +
|
|
677
|
+
* near_duplicates) using the `Encode` trait wire format.
|
|
647
678
|
* @param {number} ptr
|
|
648
679
|
* @param {number} len
|
|
649
680
|
* @returns {number}
|
|
@@ -684,6 +715,26 @@ let wasm_bindgen = (function(exports) {
|
|
|
684
715
|
}
|
|
685
716
|
exports.worker_compose = worker_compose;
|
|
686
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Exports the database to a target directory.
|
|
720
|
+
*
|
|
721
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
722
|
+
*
|
|
723
|
+
* Delegates directly to `db_export` in `kbdb-fs-database`. Does not require
|
|
724
|
+
* the worker to have been initialised because the target path is given
|
|
725
|
+
* explicitly by the caller.
|
|
726
|
+
*
|
|
727
|
+
* Returns 0 on success, -1 on error (message in return slot).
|
|
728
|
+
* @param {number} ptr
|
|
729
|
+
* @param {number} len
|
|
730
|
+
* @returns {number}
|
|
731
|
+
*/
|
|
732
|
+
function worker_export(ptr, len) {
|
|
733
|
+
const ret = wasm.worker_export(ptr, len);
|
|
734
|
+
return ret;
|
|
735
|
+
}
|
|
736
|
+
exports.worker_export = worker_export;
|
|
737
|
+
|
|
687
738
|
/**
|
|
688
739
|
* Runs garbage collection and invalidates all cache entries.
|
|
689
740
|
*
|
|
@@ -835,6 +886,14 @@ let wasm_bindgen = (function(exports) {
|
|
|
835
886
|
|
|
836
887
|
/**
|
|
837
888
|
* Rebuilds all database indexes.
|
|
889
|
+
*
|
|
890
|
+
* First clears the existing inverted, positional, and reference indexes via
|
|
891
|
+
* `db_rebuild_index`. Then re-tokenizes every stored section and re-populates
|
|
892
|
+
* the indexes via `rebuild_all_section_indexes`.
|
|
893
|
+
*
|
|
894
|
+
* On success the return slot holds the number of reindexed sections as a
|
|
895
|
+
* little-endian `u32`, and 0 is returned. On error -1 is returned and an
|
|
896
|
+
* error message is in the return slot.
|
|
838
897
|
* @returns {number}
|
|
839
898
|
*/
|
|
840
899
|
function worker_rebuild_indexes() {
|
|
Binary file
|
|
@@ -8,6 +8,7 @@ export const set_return: (a: number, b: number) => void;
|
|
|
8
8
|
export const worker_add_section: (a: number, b: number) => number;
|
|
9
9
|
export const worker_check_integrity: () => number;
|
|
10
10
|
export const worker_compose: (a: number, b: number) => number;
|
|
11
|
+
export const worker_export: (a: number, b: number) => number;
|
|
11
12
|
export const worker_garbage_collect: () => number;
|
|
12
13
|
export const worker_get_result: (a: number) => number;
|
|
13
14
|
export const worker_group_sections: (a: number, b: number) => number;
|
|
@@ -48,6 +49,7 @@ export const db_add_section: (a: number, b: number) => number;
|
|
|
48
49
|
export const db_add_to_index: (a: number, b: number) => number;
|
|
49
50
|
export const db_check_integrity: (a: number, b: number) => number;
|
|
50
51
|
export const db_check_version: (a: number, b: number) => number;
|
|
52
|
+
export const db_export: (a: number, b: number) => number;
|
|
51
53
|
export const db_gc: (a: number, b: number) => number;
|
|
52
54
|
export const db_get_back_refs: (a: number, b: number) => number;
|
|
53
55
|
export const db_get_forward_refs: (a: number, b: number) => number;
|
|
Binary file
|