sensemaking 0.12.2 → 0.13.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/dist/cjs/cli/download.js +4 -4
- package/dist/cjs/cli/download.js.map +1 -1
- package/dist/cjs/cli/init.js +4 -4
- package/dist/cjs/cli/init.js.map +1 -1
- package/dist/cjs/cli/map.js +4 -4
- package/dist/cjs/cli/map.js.map +1 -1
- package/dist/cjs/cli/named.js +2 -2
- package/dist/cjs/cli/named.js.map +1 -1
- package/dist/cjs/cli/path.js +6 -6
- package/dist/cjs/cli/path.js.map +1 -1
- package/dist/cjs/cli/peek.js +4 -4
- package/dist/cjs/cli/peek.js.map +1 -1
- package/dist/cjs/cli/related.js +4 -4
- package/dist/cjs/cli/related.js.map +1 -1
- package/dist/cjs/cli/search.js +4 -4
- package/dist/cjs/cli/search.js.map +1 -1
- package/dist/cjs/cli/shared.d.cts +2 -2
- package/dist/cjs/cli/shared.d.ts +2 -2
- package/dist/cjs/cli/shared.js +5 -5
- package/dist/cjs/cli/shared.js.map +1 -1
- package/dist/cjs/cli/status.js +16 -16
- package/dist/cjs/cli/status.js.map +1 -1
- package/dist/cjs/cli/types.d.cts +1 -1
- package/dist/cjs/cli/types.d.ts +1 -1
- package/dist/cjs/cli.js +3 -3
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/commands/index.d.cts +10 -0
- package/dist/cjs/commands/index.d.ts +10 -0
- package/dist/cjs/commands/index.js +42 -0
- package/dist/cjs/commands/index.js.map +1 -0
- package/dist/cjs/commands/map.d.cts +21 -0
- package/dist/cjs/commands/map.d.ts +21 -0
- package/dist/cjs/commands/map.js +90 -0
- package/dist/cjs/commands/map.js.map +1 -0
- package/dist/cjs/commands/peek.d.cts +20 -0
- package/dist/cjs/commands/peek.d.ts +20 -0
- package/dist/cjs/commands/peek.js +175 -0
- package/dist/cjs/commands/peek.js.map +1 -0
- package/dist/cjs/commands/related.d.cts +6 -0
- package/dist/cjs/commands/related.d.ts +6 -0
- package/dist/cjs/commands/related.js +232 -0
- package/dist/cjs/commands/related.js.map +1 -0
- package/dist/cjs/commands/scope.d.cts +10 -0
- package/dist/cjs/commands/scope.d.ts +10 -0
- package/dist/cjs/commands/scope.js +124 -0
- package/dist/cjs/commands/scope.js.map +1 -0
- package/dist/cjs/commands/search.d.cts +12 -0
- package/dist/cjs/commands/search.d.ts +12 -0
- package/dist/cjs/{commands.js → commands/search.js} +20 -358
- package/dist/cjs/commands/search.js.map +1 -0
- package/dist/cjs/commands/status.d.cts +9 -0
- package/dist/cjs/commands/status.d.ts +9 -0
- package/dist/cjs/commands/status.js +25 -0
- package/dist/cjs/commands/status.js.map +1 -0
- package/dist/cjs/config/access.d.cts +19 -0
- package/dist/cjs/config/access.d.ts +19 -0
- package/dist/cjs/config/access.js +149 -0
- package/dist/cjs/config/access.js.map +1 -0
- package/dist/cjs/config/index.d.cts +5 -0
- package/dist/cjs/config/index.d.ts +5 -0
- package/dist/cjs/config/index.js +77 -0
- package/dist/cjs/config/index.js.map +1 -0
- package/dist/cjs/config/load.d.cts +8 -0
- package/dist/cjs/config/load.d.ts +8 -0
- package/dist/cjs/config/load.js +448 -0
- package/dist/cjs/config/load.js.map +1 -0
- package/dist/cjs/config/resolve.d.cts +6 -0
- package/dist/cjs/config/resolve.d.ts +6 -0
- package/dist/cjs/config/resolve.js +50 -0
- package/dist/cjs/config/resolve.js.map +1 -0
- package/dist/{esm/config.d.ts → cjs/config/types.d.cts} +2 -32
- package/dist/cjs/{config.d.cts → config/types.d.ts} +2 -32
- package/dist/cjs/config/types.js +39 -0
- package/dist/cjs/config/types.js.map +1 -0
- package/dist/cjs/config/validate.d.cts +4 -0
- package/dist/cjs/config/validate.d.ts +4 -0
- package/dist/cjs/config/validate.js +363 -0
- package/dist/cjs/config/validate.js.map +1 -0
- package/dist/cjs/db/index.d.cts +4 -0
- package/dist/cjs/db/index.d.ts +4 -0
- package/dist/cjs/db/index.js +42 -0
- package/dist/cjs/db/index.js.map +1 -0
- package/dist/cjs/{db.d.cts → db/open.d.cts} +2 -8
- package/dist/cjs/{db.d.ts → db/open.d.ts} +2 -8
- package/dist/cjs/db/open.js +223 -0
- package/dist/cjs/db/open.js.map +1 -0
- package/dist/cjs/db/reconcile.d.cts +9 -0
- package/dist/cjs/db/reconcile.d.ts +9 -0
- package/dist/cjs/{db.js → db/reconcile.js} +24 -261
- package/dist/cjs/db/reconcile.js.map +1 -0
- package/dist/cjs/db/shared.d.cts +5 -0
- package/dist/cjs/db/shared.d.ts +5 -0
- package/dist/cjs/db/shared.js +45 -0
- package/dist/cjs/db/shared.js.map +1 -0
- package/dist/cjs/features/embed.d.cts +1 -1
- package/dist/cjs/features/embed.d.ts +1 -1
- package/dist/cjs/features/embed.js +4 -3
- package/dist/cjs/features/embed.js.map +1 -1
- package/dist/cjs/features/index.d.cts +1 -1
- package/dist/cjs/features/index.d.ts +1 -1
- package/dist/cjs/features/index.js +4 -2
- package/dist/cjs/features/index.js.map +1 -1
- package/dist/cjs/features/links.js +38 -20
- package/dist/cjs/features/links.js.map +1 -1
- package/dist/cjs/features/tags.d.cts +2 -0
- package/dist/cjs/features/tags.d.ts +2 -0
- package/dist/cjs/features/tags.js +188 -0
- package/dist/cjs/features/tags.js.map +1 -0
- package/dist/cjs/features/types.d.cts +2 -2
- package/dist/cjs/features/types.d.ts +2 -2
- package/dist/cjs/index.d.cts +6 -6
- package/dist/cjs/index.d.ts +6 -6
- package/dist/cjs/index.js +15 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/scan.d.cts +3 -1
- package/dist/cjs/scan.d.ts +3 -1
- package/dist/cjs/scan.js +9 -6
- package/dist/cjs/scan.js.map +1 -1
- package/dist/cjs/sql-functions.d.cts +2 -0
- package/dist/cjs/sql-functions.d.ts +2 -0
- package/dist/cjs/sql-functions.js +64 -0
- package/dist/cjs/sql-functions.js.map +1 -0
- package/dist/cjs/watch.d.cts +1 -1
- package/dist/cjs/watch.d.ts +1 -1
- package/dist/cjs/watch.js +12 -12
- package/dist/cjs/watch.js.map +1 -1
- package/dist/esm/cli/download.js +1 -1
- package/dist/esm/cli/download.js.map +1 -1
- package/dist/esm/cli/init.js +1 -1
- package/dist/esm/cli/init.js.map +1 -1
- package/dist/esm/cli/map.js +1 -1
- package/dist/esm/cli/map.js.map +1 -1
- package/dist/esm/cli/named.js +1 -1
- package/dist/esm/cli/named.js.map +1 -1
- package/dist/esm/cli/path.js +1 -1
- package/dist/esm/cli/path.js.map +1 -1
- package/dist/esm/cli/peek.js +1 -1
- package/dist/esm/cli/peek.js.map +1 -1
- package/dist/esm/cli/related.js +1 -1
- package/dist/esm/cli/related.js.map +1 -1
- package/dist/esm/cli/search.js +1 -1
- package/dist/esm/cli/search.js.map +1 -1
- package/dist/esm/cli/shared.d.ts +2 -2
- package/dist/esm/cli/shared.js +2 -2
- package/dist/esm/cli/shared.js.map +1 -1
- package/dist/esm/cli/status.js +3 -3
- package/dist/esm/cli/status.js.map +1 -1
- package/dist/esm/cli/types.d.ts +1 -1
- package/dist/esm/cli/types.js.map +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands/index.d.ts +10 -0
- package/dist/esm/commands/index.js +8 -0
- package/dist/esm/commands/index.js.map +1 -0
- package/dist/esm/commands/map.d.ts +21 -0
- package/dist/esm/commands/map.js +56 -0
- package/dist/esm/commands/map.js.map +1 -0
- package/dist/esm/commands/peek.d.ts +20 -0
- package/dist/esm/commands/peek.js +63 -0
- package/dist/esm/commands/peek.js.map +1 -0
- package/dist/esm/commands/related.d.ts +6 -0
- package/dist/esm/commands/related.js +47 -0
- package/dist/esm/commands/related.js.map +1 -0
- package/dist/esm/commands/scope.d.ts +10 -0
- package/dist/esm/commands/scope.js +60 -0
- package/dist/esm/commands/scope.js.map +1 -0
- package/dist/esm/commands/search.d.ts +12 -0
- package/dist/esm/commands/search.js +258 -0
- package/dist/esm/commands/search.js.map +1 -0
- package/dist/esm/commands/status.d.ts +9 -0
- package/dist/esm/commands/status.js +16 -0
- package/dist/esm/commands/status.js.map +1 -0
- package/dist/esm/config/access.d.ts +19 -0
- package/dist/esm/config/access.js +89 -0
- package/dist/esm/config/access.js.map +1 -0
- package/dist/esm/config/index.d.ts +5 -0
- package/dist/esm/config/index.js +4 -0
- package/dist/esm/config/index.js.map +1 -0
- package/dist/esm/config/load.d.ts +8 -0
- package/dist/esm/config/load.js +242 -0
- package/dist/esm/config/load.js.map +1 -0
- package/dist/esm/config/resolve.d.ts +6 -0
- package/dist/esm/config/resolve.js +35 -0
- package/dist/esm/config/resolve.js.map +1 -0
- package/dist/{cjs/config.d.ts → esm/config/types.d.ts} +2 -32
- package/dist/esm/config/types.js +15 -0
- package/dist/esm/config/types.js.map +1 -0
- package/dist/esm/config/validate.d.ts +4 -0
- package/dist/esm/config/validate.js +226 -0
- package/dist/esm/config/validate.js.map +1 -0
- package/dist/esm/db/index.d.ts +4 -0
- package/dist/esm/db/index.js +5 -0
- package/dist/esm/db/index.js.map +1 -0
- package/dist/esm/{db.d.ts → db/open.d.ts} +2 -8
- package/dist/esm/db/open.js +160 -0
- package/dist/esm/db/open.js.map +1 -0
- package/dist/esm/db/reconcile.d.ts +9 -0
- package/dist/esm/{db.js → db/reconcile.js} +12 -216
- package/dist/esm/db/reconcile.js.map +1 -0
- package/dist/esm/db/shared.d.ts +5 -0
- package/dist/esm/db/shared.js +20 -0
- package/dist/esm/db/shared.js.map +1 -0
- package/dist/esm/features/embed.d.ts +1 -1
- package/dist/esm/features/embed.js +2 -1
- package/dist/esm/features/embed.js.map +1 -1
- package/dist/esm/features/index.d.ts +1 -1
- package/dist/esm/features/index.js +3 -1
- package/dist/esm/features/index.js.map +1 -1
- package/dist/esm/features/links.js +36 -21
- package/dist/esm/features/links.js.map +1 -1
- package/dist/esm/features/tags.d.ts +2 -0
- package/dist/esm/features/tags.js +80 -0
- package/dist/esm/features/tags.js.map +1 -0
- package/dist/esm/features/types.d.ts +2 -2
- package/dist/esm/features/types.js.map +1 -1
- package/dist/esm/index.d.ts +6 -6
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/scan.d.ts +3 -1
- package/dist/esm/scan.js +5 -2
- package/dist/esm/scan.js.map +1 -1
- package/dist/esm/sql-functions.d.ts +2 -0
- package/dist/esm/sql-functions.js +47 -0
- package/dist/esm/sql-functions.js.map +1 -0
- package/dist/esm/watch.d.ts +1 -1
- package/dist/esm/watch.js +2 -2
- package/dist/esm/watch.js.map +1 -1
- package/package.json +2 -1
- package/schema.json +4 -0
- package/skills/sense/SKILL.md +3 -3
- package/skills/sense-bases/EXAMPLES.md +103 -0
- package/skills/sense-bases/SKILL.md +137 -0
- package/skills/sense-setup/SKILL.md +1 -1
- package/dist/cjs/commands.d.cts +0 -58
- package/dist/cjs/commands.d.ts +0 -58
- package/dist/cjs/commands.js.map +0 -1
- package/dist/cjs/config.js +0 -919
- package/dist/cjs/config.js.map +0 -1
- package/dist/cjs/db.js.map +0 -1
- package/dist/esm/commands.d.ts +0 -58
- package/dist/esm/commands.js +0 -486
- package/dist/esm/commands.js.map +0 -1
- package/dist/esm/config.js +0 -599
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/db.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const CONFIG_FILENAME = "sense.config.json";
|
|
2
2
|
export declare const STATE_DIR = ".sense";
|
|
3
3
|
export declare const SUPPORTED_CONFIG_VERSION = 4;
|
|
4
|
-
declare const FEATURE_NAMES: readonly ["links", "sections", "rank", "embed"];
|
|
4
|
+
export declare const FEATURE_NAMES: readonly ["links", "sections", "tags", "rank", "embed"];
|
|
5
5
|
export type FeatureName = (typeof FEATURE_NAMES)[number];
|
|
6
6
|
export interface EmbedConfig {
|
|
7
7
|
model?: string;
|
|
@@ -35,6 +35,7 @@ export interface Config {
|
|
|
35
35
|
features?: {
|
|
36
36
|
links?: boolean;
|
|
37
37
|
sections?: boolean;
|
|
38
|
+
tags?: boolean;
|
|
38
39
|
rank?: boolean;
|
|
39
40
|
};
|
|
40
41
|
embed?: EmbedConfig;
|
|
@@ -49,28 +50,6 @@ export interface ResolvedConfig extends Config {
|
|
|
49
50
|
unknownKeys?: string[];
|
|
50
51
|
migratedFrom?: number;
|
|
51
52
|
}
|
|
52
|
-
export declare function presetNames(cfg: Config): string[];
|
|
53
|
-
export declare function embedEnabled(cfg: Config): boolean;
|
|
54
|
-
export declare function presetSemanticEnabled(cfg: Config, name: string): boolean;
|
|
55
|
-
export declare function anyPresetEmbeds(cfg: Config): boolean;
|
|
56
|
-
export declare function featureEnabled(cfg: Config, name: FeatureName): boolean;
|
|
57
|
-
export declare function enabledFeatures(cfg: Config): FeatureName[];
|
|
58
|
-
export declare function featureStates(cfg: Config): {
|
|
59
|
-
on: FeatureName[];
|
|
60
|
-
off: FeatureName[];
|
|
61
|
-
};
|
|
62
|
-
export declare function embedConfig(cfg: Config): {
|
|
63
|
-
model: string;
|
|
64
|
-
type: 'static' | 'api';
|
|
65
|
-
url?: string;
|
|
66
|
-
key?: string;
|
|
67
|
-
} | null;
|
|
68
|
-
export declare function contentTokenize(cfg: Config): string | undefined;
|
|
69
|
-
export declare function featureSignature(cfg: Config): string;
|
|
70
|
-
export declare function resolvePreset(cfg: Config, name?: string): {
|
|
71
|
-
name: string;
|
|
72
|
-
preset: Preset;
|
|
73
|
-
};
|
|
74
53
|
export interface SearchOverrides {
|
|
75
54
|
preset?: string;
|
|
76
55
|
k?: number;
|
|
@@ -87,12 +66,3 @@ export interface EffectiveSearch {
|
|
|
87
66
|
exclude?: string[];
|
|
88
67
|
semantic: boolean;
|
|
89
68
|
}
|
|
90
|
-
export declare function resolveSearch(cfg: Config, opts?: SearchOverrides): EffectiveSearch;
|
|
91
|
-
export declare function migrateConfig(cfg: Config): {
|
|
92
|
-
cfg: Config;
|
|
93
|
-
from: number;
|
|
94
|
-
};
|
|
95
|
-
export declare function initConfig(dir: string): string;
|
|
96
|
-
export declare function findConfigPath(startDir: string): string | null;
|
|
97
|
-
export declare function loadConfig(explicitPath?: string): ResolvedConfig;
|
|
98
|
-
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get CONFIG_FILENAME () {
|
|
13
|
+
return CONFIG_FILENAME;
|
|
14
|
+
},
|
|
15
|
+
get DEFAULT_EMBED_MODEL () {
|
|
16
|
+
return DEFAULT_EMBED_MODEL;
|
|
17
|
+
},
|
|
18
|
+
get FEATURE_NAMES () {
|
|
19
|
+
return FEATURE_NAMES;
|
|
20
|
+
},
|
|
21
|
+
get STATE_DIR () {
|
|
22
|
+
return STATE_DIR;
|
|
23
|
+
},
|
|
24
|
+
get SUPPORTED_CONFIG_VERSION () {
|
|
25
|
+
return SUPPORTED_CONFIG_VERSION;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var CONFIG_FILENAME = 'sense.config.json';
|
|
29
|
+
var STATE_DIR = '.sense';
|
|
30
|
+
var SUPPORTED_CONFIG_VERSION = 4;
|
|
31
|
+
var FEATURE_NAMES = [
|
|
32
|
+
'links',
|
|
33
|
+
'sections',
|
|
34
|
+
'tags',
|
|
35
|
+
'rank',
|
|
36
|
+
'embed'
|
|
37
|
+
];
|
|
38
|
+
var DEFAULT_EMBED_MODEL = 'minishlab/potion-retrieval-32M';
|
|
39
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/config/types.ts"],"sourcesContent":["export const CONFIG_FILENAME = 'sense.config.json';\nexport const STATE_DIR = '.sense';\n\n// Highest sense.config.json `version` this build understands. Older versions auto-migrate on load.\nexport const SUPPORTED_CONFIG_VERSION = 4;\n\n// Each feature owns its tables, parse-time extraction, and reconcile step; commands degrade when one is off.\n// links/sections/tags/rank are opt-out toggles in the top-level `features` block; embed is not a\n// member of that block -- it is on exactly when an `embed` block names a model.\nexport const FEATURE_NAMES = ['links', 'sections', 'tags', 'rank', 'embed'] as const;\nexport type FeatureName = (typeof FEATURE_NAMES)[number];\n\n// `embed` names the model and gives the tree vectors at all; a preset's `semantic` says\n// whether that scope uses them.\nexport interface EmbedConfig {\n model?: string;\n type?: 'static' | 'api';\n url?: string; // api type: OpenAI-compatible base URL, e.g. http://localhost:11434/v1\n key?: string; // api type: name of the env var holding the bearer token, if any\n}\n\nexport const DEFAULT_EMBED_MODEL = 'minishlab/potion-retrieval-32M';\n\n// A named, self-contained file-selection scope. include/exclude are globby patterns resolved\n// relative to the config file. No inheritance between presets -- every field a preset wants\n// it declares itself. Presets may overlap freely; they are views, not partitions.\nexport interface Preset {\n include: string[];\n exclude?: string[];\n k?: number; // result count for `search` scoped to this preset; default 10\n // Vectors for the files this preset covers, and for searches scoped to it. Default true;\n // only ever written as false. A layer searched for exact wording (ingested sources,\n // archives, generated output) sets it false and costs no embedding at all.\n semantic?: boolean;\n where?: string; // standing SQL condition against frontmatter alias `f`\n}\n\n// A saved `search` invocation: `sense <name>` runs like\n// `sense search <search> [--preset] [--include] [--exclude] [--where] [--k]`.\nexport interface SavedSearch {\n search: string;\n preset?: string;\n include?: string[];\n exclude?: string[];\n where?: string;\n k?: number;\n}\n\n// An entry names the verb it runs, one to one with the commands: { sql } runs like\n// `sense sql`, { search } like `sense search`.\nexport type SavedQuery = { sql: string } | SavedSearch;\n\nexport interface Config {\n // Editor-only pointer to schema.json; never read by sense.\n $schema?: string;\n version?: number;\n // File selection, index-time, and per-preset search defaults. A file is indexed iff any\n // preset's include/exclude covers it (union). `default` is used when a command names no preset.\n presets: Record<string, Preset>;\n // Global feature defaults; absent block or key means enabled. embed is not a member here --\n // see the `embed` block.\n features?: { links?: boolean; sections?: boolean; tags?: boolean; rank?: boolean };\n // Names the embedding model. Present means every indexed file gets vectors; absent means none do.\n embed?: EmbedConfig;\n // Settings for the `content` FTS5 table. `tokenize` decides which languages the tree can be\n // word-searched in at all; changing it rebuilds the index.\n content?: { tokenize?: string };\n queries: Record<string, SavedQuery>;\n}\n\nexport interface ResolvedConfig extends Config {\n baseDir: string;\n configPath: string | null;\n // Keys the file declares that this build does not read; cli reports them.\n unknownKeys?: string[];\n // Set when loadConfig auto-migrated the file on disk; cli reports it.\n migratedFrom?: number;\n}\n\nexport interface SearchOverrides {\n preset?: string;\n k?: number;\n where?: string;\n include?: string[];\n exclude?: string[];\n noExclude?: boolean; // drop the preset's exclude for this command; --exclude still applies\n}\n\nexport interface EffectiveSearch {\n presetName: string;\n k: number;\n where?: string;\n include: string[];\n exclude?: string[];\n semantic: boolean; // the resolved preset's vector participation\n}\n"],"names":["CONFIG_FILENAME","DEFAULT_EMBED_MODEL","FEATURE_NAMES","STATE_DIR","SUPPORTED_CONFIG_VERSION"],"mappings":";;;;;;;;;;;QAAaA;eAAAA;;QAqBAC;eAAAA;;QAZAC;eAAAA;;QARAC;eAAAA;;QAGAC;eAAAA;;;AAJN,IAAMJ,kBAAkB;AACxB,IAAMG,YAAY;AAGlB,IAAMC,2BAA2B;AAKjC,IAAMF,gBAAgB;IAAC;IAAS;IAAY;IAAQ;IAAQ;CAAQ;AAYpE,IAAMD,sBAAsB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Config } from './types.js';
|
|
2
|
+
export declare function unknownConfigKeys(cfg: Record<string, unknown>): string[];
|
|
3
|
+
export declare function validateLegacyScan(parsed: unknown, configPath: string): void;
|
|
4
|
+
export declare function validateConfig(parsed: unknown, configPath: string): Config;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Config } from './types.js';
|
|
2
|
+
export declare function unknownConfigKeys(cfg: Record<string, unknown>): string[];
|
|
3
|
+
export declare function validateLegacyScan(parsed: unknown, configPath: string): void;
|
|
4
|
+
export declare function validateConfig(parsed: unknown, configPath: string): Config;
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get unknownConfigKeys () {
|
|
13
|
+
return unknownConfigKeys;
|
|
14
|
+
},
|
|
15
|
+
get validateConfig () {
|
|
16
|
+
return validateConfig;
|
|
17
|
+
},
|
|
18
|
+
get validateLegacyScan () {
|
|
19
|
+
return validateLegacyScan;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var _errorsts = require("../errors.js");
|
|
23
|
+
function _array_like_to_array(arr, len) {
|
|
24
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
25
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
26
|
+
return arr2;
|
|
27
|
+
}
|
|
28
|
+
function _array_with_holes(arr) {
|
|
29
|
+
if (Array.isArray(arr)) return arr;
|
|
30
|
+
}
|
|
31
|
+
function _iterable_to_array_limit(arr, i) {
|
|
32
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
33
|
+
if (_i == null) return;
|
|
34
|
+
var _arr = [];
|
|
35
|
+
var _n = true;
|
|
36
|
+
var _d = false;
|
|
37
|
+
var _s, _e;
|
|
38
|
+
try {
|
|
39
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
40
|
+
_arr.push(_s.value);
|
|
41
|
+
if (i && _arr.length === i) break;
|
|
42
|
+
}
|
|
43
|
+
} catch (err) {
|
|
44
|
+
_d = true;
|
|
45
|
+
_e = err;
|
|
46
|
+
} finally{
|
|
47
|
+
try {
|
|
48
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
49
|
+
} finally{
|
|
50
|
+
if (_d) throw _e;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return _arr;
|
|
54
|
+
}
|
|
55
|
+
function _non_iterable_rest() {
|
|
56
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
57
|
+
}
|
|
58
|
+
function _sliced_to_array(arr, i) {
|
|
59
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
60
|
+
}
|
|
61
|
+
function _type_of(obj) {
|
|
62
|
+
"@swc/helpers - typeof";
|
|
63
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
64
|
+
}
|
|
65
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
66
|
+
if (!o) return;
|
|
67
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
68
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
69
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
70
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
71
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
72
|
+
}
|
|
73
|
+
// Shape check for hand-edited files, so a typo names itself instead of surfacing as a
|
|
74
|
+
// TypeError. Unknown top-level keys warn (forward compat); unknown keys inside a block error.
|
|
75
|
+
var KNOWN_KEYS = new Set([
|
|
76
|
+
'$schema',
|
|
77
|
+
'version',
|
|
78
|
+
'presets',
|
|
79
|
+
'features',
|
|
80
|
+
'embed',
|
|
81
|
+
'content',
|
|
82
|
+
'queries'
|
|
83
|
+
]);
|
|
84
|
+
var KNOWN_PRESET_KEYS = new Set([
|
|
85
|
+
'include',
|
|
86
|
+
'exclude',
|
|
87
|
+
'k',
|
|
88
|
+
'semantic',
|
|
89
|
+
'where'
|
|
90
|
+
]);
|
|
91
|
+
var KNOWN_FEATURE_KEYS = new Set([
|
|
92
|
+
'links',
|
|
93
|
+
'sections',
|
|
94
|
+
'tags',
|
|
95
|
+
'rank'
|
|
96
|
+
]);
|
|
97
|
+
var KNOWN_EMBED_KEYS = new Set([
|
|
98
|
+
'model',
|
|
99
|
+
'type',
|
|
100
|
+
'url',
|
|
101
|
+
'key'
|
|
102
|
+
]);
|
|
103
|
+
var KNOWN_CONTENT_KEYS = new Set([
|
|
104
|
+
'tokenize'
|
|
105
|
+
]);
|
|
106
|
+
var SAVED_SEARCH_KEYS = new Set([
|
|
107
|
+
'search',
|
|
108
|
+
'preset',
|
|
109
|
+
'include',
|
|
110
|
+
'exclude',
|
|
111
|
+
'where',
|
|
112
|
+
'k'
|
|
113
|
+
]);
|
|
114
|
+
function unknownConfigKeys(cfg) {
|
|
115
|
+
return Object.keys(cfg).filter(function(k) {
|
|
116
|
+
return !KNOWN_KEYS.has(k);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function isNonEmptyStringArray(value) {
|
|
120
|
+
return Array.isArray(value) && value.length > 0 && value.every(function(g) {
|
|
121
|
+
return typeof g === 'string' && g.length > 0;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function validateLegacyScan(parsed, configPath) {
|
|
125
|
+
var cfg = (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === 'object' && parsed !== null && !Array.isArray(parsed) ? parsed : null;
|
|
126
|
+
var scan = cfg === null || cfg === void 0 ? void 0 : cfg.scan;
|
|
127
|
+
if (!cfg || !scan || !isNonEmptyStringArray(scan.include)) {
|
|
128
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": scan.include must be a non-empty array of glob strings"));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// Only the shape is checked here. Whether the linked SQLite accepts the tokenizer is settled
|
|
132
|
+
// by probing it in db.ts, so this never has to carry a table of which version added what.
|
|
133
|
+
function validateContentBlock(value, configPath) {
|
|
134
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) !== 'object' || value === null || Array.isArray(value)) {
|
|
135
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": content must be an object of { tokenize?: string }"));
|
|
136
|
+
}
|
|
137
|
+
var block = value;
|
|
138
|
+
var unknown = Object.keys(block).filter(function(k) {
|
|
139
|
+
return !KNOWN_CONTENT_KEYS.has(k);
|
|
140
|
+
});
|
|
141
|
+
if (unknown.length > 0) {
|
|
142
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": content has unknown key(s) ").concat(unknown.join(', '), "; content takes tokenize"));
|
|
143
|
+
}
|
|
144
|
+
if (block.tokenize !== undefined && (typeof block.tokenize !== 'string' || block.tokenize.trim() === '')) {
|
|
145
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ': content.tokenize must be a non-empty string, e.g. "trigram" or "unicode61 tokenchars \'-_\'"'));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function validateFeaturesBlock(value, configPath) {
|
|
149
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) !== 'object' || value === null || Array.isArray(value)) {
|
|
150
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": features must be an object of name -> boolean"));
|
|
151
|
+
}
|
|
152
|
+
var block = value;
|
|
153
|
+
var unknown = Object.keys(block).filter(function(k) {
|
|
154
|
+
return !KNOWN_FEATURE_KEYS.has(k);
|
|
155
|
+
});
|
|
156
|
+
if (unknown.length > 0) {
|
|
157
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": features has unknown key(s) ").concat(unknown.join(', '), '; embed is not a features key -- see the top-level "embed" block'));
|
|
158
|
+
}
|
|
159
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
160
|
+
try {
|
|
161
|
+
for(var _iterator = Object.entries(block)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
162
|
+
var _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], v = _step_value[1];
|
|
163
|
+
if (typeof v !== 'boolean') {
|
|
164
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": features.").concat(name, " must be a boolean"));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} catch (err) {
|
|
168
|
+
_didIteratorError = true;
|
|
169
|
+
_iteratorError = err;
|
|
170
|
+
} finally{
|
|
171
|
+
try {
|
|
172
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
173
|
+
_iterator.return();
|
|
174
|
+
}
|
|
175
|
+
} finally{
|
|
176
|
+
if (_didIteratorError) {
|
|
177
|
+
throw _iteratorError;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function validateEmbedBlock(value, configPath) {
|
|
183
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) !== 'object' || value === null || Array.isArray(value)) {
|
|
184
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ': embed must be an object of { model?, type?: "static"|"api", url?, key? }'));
|
|
185
|
+
}
|
|
186
|
+
var embed = value;
|
|
187
|
+
var unknown = Object.keys(embed).filter(function(k) {
|
|
188
|
+
return !KNOWN_EMBED_KEYS.has(k);
|
|
189
|
+
});
|
|
190
|
+
if (unknown.length > 0) {
|
|
191
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": embed has unknown key(s) ").concat(unknown.join(', ')));
|
|
192
|
+
}
|
|
193
|
+
if (embed.model !== undefined && typeof embed.model !== 'string') {
|
|
194
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": embed.model must be a string"));
|
|
195
|
+
}
|
|
196
|
+
// The block exists to name a model; provider settings without one would read as "vectors
|
|
197
|
+
// configured" while embedding stays off, which is the ambiguity v4 removed.
|
|
198
|
+
if (embed.model === undefined || embed.model === '') {
|
|
199
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ': embed.model is required when the "embed" block is present (it is what turns vectors on); remove the block to index without vectors'));
|
|
200
|
+
}
|
|
201
|
+
if (embed.type !== undefined && embed.type !== 'static' && embed.type !== 'api') {
|
|
202
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ': embed.type must be "static" or "api"'));
|
|
203
|
+
}
|
|
204
|
+
if (embed.url !== undefined && typeof embed.url !== 'string') {
|
|
205
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": embed.url must be a string"));
|
|
206
|
+
}
|
|
207
|
+
if (embed.key !== undefined && typeof embed.key !== 'string') {
|
|
208
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": embed.key must be a string"));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function validatePreset(name, value, configPath) {
|
|
212
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) !== 'object' || value === null || Array.isArray(value)) {
|
|
213
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": presets.").concat(name, " must be an object"));
|
|
214
|
+
}
|
|
215
|
+
var preset = value;
|
|
216
|
+
var unknown = Object.keys(preset).filter(function(k) {
|
|
217
|
+
return !KNOWN_PRESET_KEYS.has(k);
|
|
218
|
+
});
|
|
219
|
+
if (unknown.length > 0) {
|
|
220
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": presets.").concat(name, " has unknown key(s) ").concat(unknown.join(', '), "; a preset takes include, exclude, k, semantic, where"));
|
|
221
|
+
}
|
|
222
|
+
if (!isNonEmptyStringArray(preset.include)) {
|
|
223
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": presets.").concat(name, ".include must be a non-empty array of glob strings"));
|
|
224
|
+
}
|
|
225
|
+
if (preset.exclude !== undefined && !isNonEmptyStringArray(preset.exclude)) {
|
|
226
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": presets.").concat(name, ".exclude must be a non-empty array of glob strings"));
|
|
227
|
+
}
|
|
228
|
+
if (preset.semantic !== undefined && typeof preset.semantic !== 'boolean') {
|
|
229
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": presets.").concat(name, ".semantic must be a boolean"));
|
|
230
|
+
}
|
|
231
|
+
if (preset.k !== undefined && (typeof preset.k !== 'number' || !Number.isInteger(preset.k) || preset.k <= 0)) {
|
|
232
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": presets.").concat(name, ".k must be a positive integer"));
|
|
233
|
+
}
|
|
234
|
+
if (preset.where !== undefined && typeof preset.where !== 'string') {
|
|
235
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": presets.").concat(name, ".where must be a SQL condition string"));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// A queries.<name> entry: { sql } or a saved search { search, preset?, include?, exclude?, where?, k? }.
|
|
239
|
+
function validateSavedQuery(name, value, configPath) {
|
|
240
|
+
// A bare string used to mean SQL. It now fails rather than being inferred: an entry says
|
|
241
|
+
// which of the two verbs it runs, the same choice the CLI makes explicit.
|
|
242
|
+
if (typeof value === 'string') {
|
|
243
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, ' must say which verb it runs: { "sql": ').concat(JSON.stringify(value.length > 40 ? "".concat(value.slice(0, 37), "...") : value), ' } to run it as SQL, or { "search": "..." } for a ranked search'));
|
|
244
|
+
}
|
|
245
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) !== 'object' || value === null || Array.isArray(value)) {
|
|
246
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, " must be { sql } or { search, preset?, include?, exclude?, where?, k? }"));
|
|
247
|
+
}
|
|
248
|
+
var entry = value;
|
|
249
|
+
if ('sql' in entry) {
|
|
250
|
+
var unknown = Object.keys(entry).filter(function(k) {
|
|
251
|
+
return k !== 'sql';
|
|
252
|
+
});
|
|
253
|
+
if (unknown.length > 0) {
|
|
254
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, " has unknown key(s) ").concat(unknown.join(', '), "; a { sql } query takes only sql"));
|
|
255
|
+
}
|
|
256
|
+
if (typeof entry.sql !== 'string' || entry.sql.trim() === '') {
|
|
257
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, ".sql must be a non-empty string"));
|
|
258
|
+
}
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if ('search' in entry) {
|
|
262
|
+
var unknown1 = Object.keys(entry).filter(function(k) {
|
|
263
|
+
return !SAVED_SEARCH_KEYS.has(k);
|
|
264
|
+
});
|
|
265
|
+
if (unknown1.length > 0) {
|
|
266
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, " has unknown key(s) ").concat(unknown1.join(', '), "; a saved search takes search, preset, include, exclude, where, k"));
|
|
267
|
+
}
|
|
268
|
+
// A saved entry saves a question; a scope without a question is just flags.
|
|
269
|
+
if (typeof entry.search !== 'string' || entry.search.trim() === '') {
|
|
270
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, ".search must be non-empty text"));
|
|
271
|
+
}
|
|
272
|
+
if (entry.preset !== undefined && (typeof entry.preset !== 'string' || entry.preset.length === 0)) {
|
|
273
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, ".preset must be a preset name"));
|
|
274
|
+
}
|
|
275
|
+
if (entry.include !== undefined && !isNonEmptyStringArray(entry.include)) {
|
|
276
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, ".include must be a non-empty array of glob strings"));
|
|
277
|
+
}
|
|
278
|
+
if (entry.exclude !== undefined && !isNonEmptyStringArray(entry.exclude)) {
|
|
279
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, ".exclude must be a non-empty array of glob strings"));
|
|
280
|
+
}
|
|
281
|
+
if (entry.where !== undefined && typeof entry.where !== 'string') {
|
|
282
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, ".where must be a SQL condition string"));
|
|
283
|
+
}
|
|
284
|
+
if (entry.k !== undefined && (typeof entry.k !== 'number' || !Number.isInteger(entry.k) || entry.k <= 0)) {
|
|
285
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, ".k must be a positive integer"));
|
|
286
|
+
}
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries.").concat(name, " must be { sql } or { search, preset?, include?, exclude?, where?, k? }"));
|
|
290
|
+
}
|
|
291
|
+
function validateConfig(parsed, configPath) {
|
|
292
|
+
if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
293
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": config must be a JSON object"));
|
|
294
|
+
}
|
|
295
|
+
var cfg = parsed;
|
|
296
|
+
// `checks` is rejected by name, not warned: silence would hide that assertions are gone.
|
|
297
|
+
if (cfg.checks !== undefined) {
|
|
298
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": checks was removed in v3 -- sense check no longer asserts on saved queries; a returned row set is the reader's judgment"));
|
|
299
|
+
}
|
|
300
|
+
var presets = cfg.presets;
|
|
301
|
+
if (!presets || (typeof presets === "undefined" ? "undefined" : _type_of(presets)) !== 'object' || Array.isArray(presets) || Object.keys(presets).length === 0) {
|
|
302
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": presets must be a non-empty object of preset name -> { include, exclude?, k?, semantic?, where? }"));
|
|
303
|
+
}
|
|
304
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
305
|
+
try {
|
|
306
|
+
for(var _iterator = Object.entries(presets)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
307
|
+
var _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], value = _step_value[1];
|
|
308
|
+
validatePreset(name, value, configPath);
|
|
309
|
+
}
|
|
310
|
+
} catch (err) {
|
|
311
|
+
_didIteratorError = true;
|
|
312
|
+
_iteratorError = err;
|
|
313
|
+
} finally{
|
|
314
|
+
try {
|
|
315
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
316
|
+
_iterator.return();
|
|
317
|
+
}
|
|
318
|
+
} finally{
|
|
319
|
+
if (_didIteratorError) {
|
|
320
|
+
throw _iteratorError;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (presets.default === undefined) {
|
|
325
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ': presets must include a "default" preset'));
|
|
326
|
+
}
|
|
327
|
+
if (cfg.queries === undefined) cfg.queries = {};
|
|
328
|
+
if (_type_of(cfg.queries) !== 'object' || cfg.queries === null || Array.isArray(cfg.queries)) {
|
|
329
|
+
throw new _errorsts.SenseError('CONFIG_INVALID', "".concat(configPath, ": queries must be an object of name -> { sql } or { search }"));
|
|
330
|
+
}
|
|
331
|
+
var queries = cfg.queries;
|
|
332
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
333
|
+
try {
|
|
334
|
+
for(var _iterator1 = Object.entries(queries)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
335
|
+
var _step_value1 = _sliced_to_array(_step1.value, 2), name1 = _step_value1[0], value1 = _step_value1[1];
|
|
336
|
+
validateSavedQuery(name1, value1, configPath);
|
|
337
|
+
}
|
|
338
|
+
} catch (err) {
|
|
339
|
+
_didIteratorError1 = true;
|
|
340
|
+
_iteratorError1 = err;
|
|
341
|
+
} finally{
|
|
342
|
+
try {
|
|
343
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
344
|
+
_iterator1.return();
|
|
345
|
+
}
|
|
346
|
+
} finally{
|
|
347
|
+
if (_didIteratorError1) {
|
|
348
|
+
throw _iteratorError1;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (cfg.features !== undefined) {
|
|
353
|
+
validateFeaturesBlock(cfg.features, configPath);
|
|
354
|
+
}
|
|
355
|
+
if (cfg.embed !== undefined) {
|
|
356
|
+
validateEmbedBlock(cfg.embed, configPath);
|
|
357
|
+
}
|
|
358
|
+
if (cfg.content !== undefined) {
|
|
359
|
+
validateContentBlock(cfg.content, configPath);
|
|
360
|
+
}
|
|
361
|
+
return cfg;
|
|
362
|
+
}
|
|
363
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/config/validate.ts"],"sourcesContent":["import { SenseError } from '../errors.ts';\nimport type { Config } from './types.ts';\n\n// Shape check for hand-edited files, so a typo names itself instead of surfacing as a\n// TypeError. Unknown top-level keys warn (forward compat); unknown keys inside a block error.\nconst KNOWN_KEYS = new Set(['$schema', 'version', 'presets', 'features', 'embed', 'content', 'queries']);\nconst KNOWN_PRESET_KEYS = new Set(['include', 'exclude', 'k', 'semantic', 'where']);\nconst KNOWN_FEATURE_KEYS = new Set(['links', 'sections', 'tags', 'rank']);\nconst KNOWN_EMBED_KEYS = new Set(['model', 'type', 'url', 'key']);\nconst KNOWN_CONTENT_KEYS = new Set(['tokenize']);\nconst SAVED_SEARCH_KEYS = new Set(['search', 'preset', 'include', 'exclude', 'where', 'k']);\n\nexport function unknownConfigKeys(cfg: Record<string, unknown>): string[] {\n return Object.keys(cfg).filter((k) => !KNOWN_KEYS.has(k));\n}\n\nfunction isNonEmptyStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.length > 0 && value.every((g) => typeof g === 'string' && g.length > 0);\n}\n\n// Pre-v3 shape check, just enough for migrateConfig to run safely (it reads scan.include\n// directly). The full v3 shape is checked by validateConfig once migration has produced it.\nexport function validateLegacyScan(parsed: unknown, configPath: string): void {\n const cfg = typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? (parsed as Record<string, unknown>) : null;\n const scan = cfg?.scan as { include?: unknown } | undefined;\n if (!cfg || !scan || !isNonEmptyStringArray(scan.include)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: scan.include must be a non-empty array of glob strings`);\n }\n}\n\n// Only the shape is checked here. Whether the linked SQLite accepts the tokenizer is settled\n// by probing it in db.ts, so this never has to carry a table of which version added what.\nfunction validateContentBlock(value: unknown, configPath: string): void {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: content must be an object of { tokenize?: string }`);\n }\n const block = value as Record<string, unknown>;\n const unknown = Object.keys(block).filter((k) => !KNOWN_CONTENT_KEYS.has(k));\n if (unknown.length > 0) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: content has unknown key(s) ${unknown.join(', ')}; content takes tokenize`);\n }\n if (block.tokenize !== undefined && (typeof block.tokenize !== 'string' || block.tokenize.trim() === '')) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: content.tokenize must be a non-empty string, e.g. \"trigram\" or \"unicode61 tokenchars '-_'\"`);\n }\n}\n\nfunction validateFeaturesBlock(value: unknown, configPath: string): void {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: features must be an object of name -> boolean`);\n }\n const block = value as Record<string, unknown>;\n const unknown = Object.keys(block).filter((k) => !KNOWN_FEATURE_KEYS.has(k));\n if (unknown.length > 0) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: features has unknown key(s) ${unknown.join(', ')}; embed is not a features key -- see the top-level \"embed\" block`);\n }\n for (const [name, v] of Object.entries(block)) {\n if (typeof v !== 'boolean') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: features.${name} must be a boolean`);\n }\n }\n}\n\nfunction validateEmbedBlock(value: unknown, configPath: string): void {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: embed must be an object of { model?, type?: \"static\"|\"api\", url?, key? }`);\n }\n const embed = value as Record<string, unknown>;\n const unknown = Object.keys(embed).filter((k) => !KNOWN_EMBED_KEYS.has(k));\n if (unknown.length > 0) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: embed has unknown key(s) ${unknown.join(', ')}`);\n }\n if (embed.model !== undefined && typeof embed.model !== 'string') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: embed.model must be a string`);\n }\n // The block exists to name a model; provider settings without one would read as \"vectors\n // configured\" while embedding stays off, which is the ambiguity v4 removed.\n if (embed.model === undefined || embed.model === '') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: embed.model is required when the \"embed\" block is present (it is what turns vectors on); remove the block to index without vectors`);\n }\n if (embed.type !== undefined && embed.type !== 'static' && embed.type !== 'api') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: embed.type must be \"static\" or \"api\"`);\n }\n if (embed.url !== undefined && typeof embed.url !== 'string') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: embed.url must be a string`);\n }\n if (embed.key !== undefined && typeof embed.key !== 'string') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: embed.key must be a string`);\n }\n}\n\nfunction validatePreset(name: string, value: unknown, configPath: string): void {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: presets.${name} must be an object`);\n }\n const preset = value as Record<string, unknown>;\n const unknown = Object.keys(preset).filter((k) => !KNOWN_PRESET_KEYS.has(k));\n if (unknown.length > 0) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: presets.${name} has unknown key(s) ${unknown.join(', ')}; a preset takes include, exclude, k, semantic, where`);\n }\n if (!isNonEmptyStringArray(preset.include)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: presets.${name}.include must be a non-empty array of glob strings`);\n }\n if (preset.exclude !== undefined && !isNonEmptyStringArray(preset.exclude)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: presets.${name}.exclude must be a non-empty array of glob strings`);\n }\n if (preset.semantic !== undefined && typeof preset.semantic !== 'boolean') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: presets.${name}.semantic must be a boolean`);\n }\n if (preset.k !== undefined && (typeof preset.k !== 'number' || !Number.isInteger(preset.k) || preset.k <= 0)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: presets.${name}.k must be a positive integer`);\n }\n if (preset.where !== undefined && typeof preset.where !== 'string') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: presets.${name}.where must be a SQL condition string`);\n }\n}\n\n// A queries.<name> entry: { sql } or a saved search { search, preset?, include?, exclude?, where?, k? }.\nfunction validateSavedQuery(name: string, value: unknown, configPath: string): void {\n // A bare string used to mean SQL. It now fails rather than being inferred: an entry says\n // which of the two verbs it runs, the same choice the CLI makes explicit.\n if (typeof value === 'string') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name} must say which verb it runs: { \"sql\": ${JSON.stringify(value.length > 40 ? `${value.slice(0, 37)}...` : value)} } to run it as SQL, or { \"search\": \"...\" } for a ranked search`);\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name} must be { sql } or { search, preset?, include?, exclude?, where?, k? }`);\n }\n const entry = value as Record<string, unknown>;\n if ('sql' in entry) {\n const unknown = Object.keys(entry).filter((k) => k !== 'sql');\n if (unknown.length > 0) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name} has unknown key(s) ${unknown.join(', ')}; a { sql } query takes only sql`);\n }\n if (typeof entry.sql !== 'string' || entry.sql.trim() === '') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name}.sql must be a non-empty string`);\n }\n return;\n }\n if ('search' in entry) {\n const unknown = Object.keys(entry).filter((k) => !SAVED_SEARCH_KEYS.has(k));\n if (unknown.length > 0) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name} has unknown key(s) ${unknown.join(', ')}; a saved search takes search, preset, include, exclude, where, k`);\n }\n // A saved entry saves a question; a scope without a question is just flags.\n if (typeof entry.search !== 'string' || entry.search.trim() === '') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name}.search must be non-empty text`);\n }\n if (entry.preset !== undefined && (typeof entry.preset !== 'string' || entry.preset.length === 0)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name}.preset must be a preset name`);\n }\n if (entry.include !== undefined && !isNonEmptyStringArray(entry.include)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name}.include must be a non-empty array of glob strings`);\n }\n if (entry.exclude !== undefined && !isNonEmptyStringArray(entry.exclude)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name}.exclude must be a non-empty array of glob strings`);\n }\n if (entry.where !== undefined && typeof entry.where !== 'string') {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name}.where must be a SQL condition string`);\n }\n if (entry.k !== undefined && (typeof entry.k !== 'number' || !Number.isInteger(entry.k) || entry.k <= 0)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name}.k must be a positive integer`);\n }\n return;\n }\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries.${name} must be { sql } or { search, preset?, include?, exclude?, where?, k? }`);\n}\n\nexport function validateConfig(parsed: unknown, configPath: string): Config {\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: config must be a JSON object`);\n }\n const cfg = parsed as Record<string, unknown>;\n\n // `checks` is rejected by name, not warned: silence would hide that assertions are gone.\n if (cfg.checks !== undefined) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: checks was removed in v3 -- sense check no longer asserts on saved queries; a returned row set is the reader's judgment`);\n }\n\n const presets = cfg.presets as Record<string, unknown> | undefined;\n if (!presets || typeof presets !== 'object' || Array.isArray(presets) || Object.keys(presets).length === 0) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: presets must be a non-empty object of preset name -> { include, exclude?, k?, semantic?, where? }`);\n }\n for (const [name, value] of Object.entries(presets)) {\n validatePreset(name, value, configPath);\n }\n if (presets.default === undefined) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: presets must include a \"default\" preset`);\n }\n\n if (cfg.queries === undefined) cfg.queries = {};\n if (typeof cfg.queries !== 'object' || cfg.queries === null || Array.isArray(cfg.queries)) {\n throw new SenseError('CONFIG_INVALID', `${configPath}: queries must be an object of name -> { sql } or { search }`);\n }\n const queries = cfg.queries as Record<string, unknown>;\n for (const [name, value] of Object.entries(queries)) {\n validateSavedQuery(name, value, configPath);\n }\n\n if (cfg.features !== undefined) {\n validateFeaturesBlock(cfg.features, configPath);\n }\n if (cfg.embed !== undefined) {\n validateEmbedBlock(cfg.embed, configPath);\n }\n if (cfg.content !== undefined) {\n validateContentBlock(cfg.content, configPath);\n }\n\n return cfg as unknown as Config;\n}\n"],"names":["unknownConfigKeys","validateConfig","validateLegacyScan","KNOWN_KEYS","Set","KNOWN_PRESET_KEYS","KNOWN_FEATURE_KEYS","KNOWN_EMBED_KEYS","KNOWN_CONTENT_KEYS","SAVED_SEARCH_KEYS","cfg","Object","keys","filter","k","has","isNonEmptyStringArray","value","Array","isArray","length","every","g","parsed","configPath","scan","include","SenseError","validateContentBlock","block","unknown","join","tokenize","undefined","trim","validateFeaturesBlock","entries","name","v","validateEmbedBlock","embed","model","type","url","key","validatePreset","preset","exclude","semantic","Number","isInteger","where","validateSavedQuery","JSON","stringify","slice","entry","sql","search","checks","presets","default","queries","features","content"],"mappings":";;;;;;;;;;;QAYgBA;eAAAA;;QA0JAC;eAAAA;;QAhJAC;eAAAA;;;wBAtBW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG3B,sFAAsF;AACtF,8FAA8F;AAC9F,IAAMC,aAAa,IAAIC,IAAI;IAAC;IAAW;IAAW;IAAW;IAAY;IAAS;IAAW;CAAU;AACvG,IAAMC,oBAAoB,IAAID,IAAI;IAAC;IAAW;IAAW;IAAK;IAAY;CAAQ;AAClF,IAAME,qBAAqB,IAAIF,IAAI;IAAC;IAAS;IAAY;IAAQ;CAAO;AACxE,IAAMG,mBAAmB,IAAIH,IAAI;IAAC;IAAS;IAAQ;IAAO;CAAM;AAChE,IAAMI,qBAAqB,IAAIJ,IAAI;IAAC;CAAW;AAC/C,IAAMK,oBAAoB,IAAIL,IAAI;IAAC;IAAU;IAAU;IAAW;IAAW;IAAS;CAAI;AAEnF,SAASJ,kBAAkBU,GAA4B;IAC5D,OAAOC,OAAOC,IAAI,CAACF,KAAKG,MAAM,CAAC,SAACC;eAAM,CAACX,WAAWY,GAAG,CAACD;;AACxD;AAEA,SAASE,sBAAsBC,KAAc;IAC3C,OAAOC,MAAMC,OAAO,CAACF,UAAUA,MAAMG,MAAM,GAAG,KAAKH,MAAMI,KAAK,CAAC,SAACC;eAAM,OAAOA,MAAM,YAAYA,EA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mCAAA,4BAAA;;QAAL,QAAK,aAAuBnD,OAAOyB,OAAO,CAAC0B,6BAAtC,UAAA,8BAAA,SAAA,0BAAA,kCAAgD;YAAhD,oCAAA,kBAAOzB,yBAAMpB;YAChBmC,mBAAmBf,OAAMpB,QAAOO;QAClC;;QAFK;QAAA;;;iBAAA,8BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAIL,IAAId,IAAIqD,QAAQ,KAAK9B,WAAW;QAC9BE,sBAAsBzB,IAAIqD,QAAQ,EAAEvC;IACtC;IACA,IAAId,IAAI8B,KAAK,KAAKP,WAAW;QAC3BM,mBAAmB7B,IAAI8B,KAAK,EAAEhB;IAChC;IACA,IAAId,IAAIsD,OAAO,KAAK/B,WAAW;QAC7BL,qBAAqBlB,IAAIsD,OAAO,EAAExC;IACpC;IAEA,OAAOd;AACT"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Rows -> SQLite: core schema, reconcile loop, has(). Parsing lives in scan.ts;
|
|
2
|
+
// everything beyond frontmatter + content lives in src/features/.
|
|
3
|
+
"use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
function _export(target, all) {
|
|
8
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_export(exports, {
|
|
14
|
+
get DB_FILENAME () {
|
|
15
|
+
return _opents.DB_FILENAME;
|
|
16
|
+
},
|
|
17
|
+
get SCHEMA_VERSION () {
|
|
18
|
+
return _opents.SCHEMA_VERSION;
|
|
19
|
+
},
|
|
20
|
+
get clearCache () {
|
|
21
|
+
return _opents.clearCache;
|
|
22
|
+
},
|
|
23
|
+
get docCount () {
|
|
24
|
+
return _opents.docCount;
|
|
25
|
+
},
|
|
26
|
+
get getMeta () {
|
|
27
|
+
return _sharedts.getMeta;
|
|
28
|
+
},
|
|
29
|
+
get open () {
|
|
30
|
+
return _opents.open;
|
|
31
|
+
},
|
|
32
|
+
get reconcile () {
|
|
33
|
+
return _reconcilets.reconcile;
|
|
34
|
+
},
|
|
35
|
+
get setMeta () {
|
|
36
|
+
return _sharedts.setMeta;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
var _opents = require("./open.js");
|
|
40
|
+
var _reconcilets = require("./reconcile.js");
|
|
41
|
+
var _sharedts = require("./shared.js");
|
|
42
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/sensemaking/src/db/index.ts"],"sourcesContent":["// Rows -> SQLite: core schema, reconcile loop, has(). Parsing lives in scan.ts;\n// everything beyond frontmatter + content lives in src/features/.\n\nexport type { OpenResult } from './open.ts';\nexport { clearCache, DB_FILENAME, docCount, open, SCHEMA_VERSION } from './open.ts';\nexport { reconcile } from './reconcile.ts';\nexport { getMeta, setMeta } from './shared.ts';\n"],"names":["DB_FILENAME","SCHEMA_VERSION","clearCache","docCount","getMeta","open","reconcile","setMeta"],"mappings":"AAAA,gFAAgF;AAChF,kEAAkE;;;;;;;;;;;;QAG7CA;eAAAA,mBAAW;;QAAkBC;eAAAA,sBAAc;;QAAvDC;eAAAA,kBAAU;;QAAeC;eAAAA,gBAAQ;;QAEjCC;eAAAA,iBAAO;;QAF4BC;eAAAA,YAAI;;QACvCC;eAAAA,sBAAS;;QACAC;eAAAA,iBAAO;;;sBAF+C;2BAC9C;wBACO"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResolvedConfig } from '../config/index.js';
|
|
3
3
|
export declare const DB_FILENAME = "cache.db";
|
|
4
|
-
export declare const SCHEMA_VERSION = "
|
|
4
|
+
export declare const SCHEMA_VERSION = "13";
|
|
5
5
|
export interface OpenResult {
|
|
6
6
|
db: DatabaseSync;
|
|
7
7
|
cfg: ResolvedConfig;
|
|
@@ -9,12 +9,6 @@ export interface OpenResult {
|
|
|
9
9
|
parsed: number;
|
|
10
10
|
warnings: string[];
|
|
11
11
|
}
|
|
12
|
-
export declare function getMeta(db: DatabaseSync, key: string): string | null;
|
|
13
|
-
export declare function setMeta(db: DatabaseSync, key: string, value: string | null): void;
|
|
14
12
|
export declare function docCount(db: DatabaseSync): number;
|
|
15
|
-
export declare function reconcile(db: DatabaseSync, cfg: Config, baseDir: string): {
|
|
16
|
-
parsed: number;
|
|
17
|
-
warnings: string[];
|
|
18
|
-
};
|
|
19
13
|
export declare function open(cfg: ResolvedConfig): OpenResult;
|
|
20
14
|
export declare function clearCache(cfg: ResolvedConfig): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResolvedConfig } from '../config/index.js';
|
|
3
3
|
export declare const DB_FILENAME = "cache.db";
|
|
4
|
-
export declare const SCHEMA_VERSION = "
|
|
4
|
+
export declare const SCHEMA_VERSION = "13";
|
|
5
5
|
export interface OpenResult {
|
|
6
6
|
db: DatabaseSync;
|
|
7
7
|
cfg: ResolvedConfig;
|
|
@@ -9,12 +9,6 @@ export interface OpenResult {
|
|
|
9
9
|
parsed: number;
|
|
10
10
|
warnings: string[];
|
|
11
11
|
}
|
|
12
|
-
export declare function getMeta(db: DatabaseSync, key: string): string | null;
|
|
13
|
-
export declare function setMeta(db: DatabaseSync, key: string, value: string | null): void;
|
|
14
12
|
export declare function docCount(db: DatabaseSync): number;
|
|
15
|
-
export declare function reconcile(db: DatabaseSync, cfg: Config, baseDir: string): {
|
|
16
|
-
parsed: number;
|
|
17
|
-
warnings: string[];
|
|
18
|
-
};
|
|
19
13
|
export declare function open(cfg: ResolvedConfig): OpenResult;
|
|
20
14
|
export declare function clearCache(cfg: ResolvedConfig): void;
|