@camstack/system 1.2.48 → 1.2.49
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/builtins/sqlite-storage/filesystem-storage-provider.d.ts +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +63 -63
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +63 -63
- package/dist/builtins/sqlite-storage/index.d.ts +5 -6
- package/dist/builtins/sqlite-storage/index.js +20 -20
- package/dist/builtins/sqlite-storage/index.mjs +20 -20
- package/dist/builtins/sqlite-storage/integration-registry.d.ts +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +1 -4
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -4
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { IStorageProviderImpl, StorageLocation, StorageProviderInfoSchema } from '@camstack/types';
|
|
2
|
+
import { z } from 'zod';
|
|
3
3
|
type StorageProviderInfo = z.infer<typeof StorageProviderInfoSchema>;
|
|
4
4
|
export declare class FilesystemStorageProvider implements IStorageProviderImpl {
|
|
5
5
|
static readonly providerId = "filesystem-storage";
|
|
@@ -11,6 +11,69 @@ node_path = require_chunk.__toESM(node_path);
|
|
|
11
11
|
let node_crypto = require("node:crypto");
|
|
12
12
|
let node_os = require("node:os");
|
|
13
13
|
let node_fs_promises = require("node:fs/promises");
|
|
14
|
+
//#region src/builtins/sqlite-storage/path-guard.ts
|
|
15
|
+
/**
|
|
16
|
+
* Allowed-root containment guard for the filesystem-browse cap. Pure +
|
|
17
|
+
* synchronous so it is trivially unit-testable; the provider applies it AFTER
|
|
18
|
+
* resolving the real path (so symlink escapes are also caught upstream).
|
|
19
|
+
*/
|
|
20
|
+
/** True iff `candidate` is one of, or nested under, an allowed root. */
|
|
21
|
+
function isWithinAllowedRoots(candidate, allowedRoots) {
|
|
22
|
+
const norm = (0, node_path.resolve)(candidate);
|
|
23
|
+
return allowedRoots.some((root) => {
|
|
24
|
+
const r = (0, node_path.resolve)(root);
|
|
25
|
+
return norm === r || norm.startsWith(r.endsWith(node_path.sep) ? r : r + node_path.sep);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Throws unless `candidate` is within an allowed root. */
|
|
29
|
+
function assertWithinAllowedRoots(candidate, allowedRoots) {
|
|
30
|
+
if (!isWithinAllowedRoots(candidate, allowedRoots)) throw new Error(`path "${candidate}" is not within an allowed root`);
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/builtins/sqlite-storage/filesystem-browse-provider.ts
|
|
34
|
+
/**
|
|
35
|
+
* Per-node filesystem-browse provider. Lists/creates directories under
|
|
36
|
+
* operator-configured allowed roots only (sandboxed by `path-guard`). Backs the
|
|
37
|
+
* `filesystem-browse` cap so the admin UI can pick a node + path for a
|
|
38
|
+
* node-local storage location.
|
|
39
|
+
*/
|
|
40
|
+
var FilesystemBrowseProvider = class {
|
|
41
|
+
allowedRoots;
|
|
42
|
+
/** allowedRoots is injected (read from addon config) so it stays per-node + testable. */
|
|
43
|
+
constructor(allowedRoots) {
|
|
44
|
+
this.allowedRoots = allowedRoots;
|
|
45
|
+
}
|
|
46
|
+
async listAllowedRoots() {
|
|
47
|
+
return [...this.allowedRoots()];
|
|
48
|
+
}
|
|
49
|
+
async browse({ path }) {
|
|
50
|
+
const real = await (0, node_fs_promises.realpath)(path).catch(() => path);
|
|
51
|
+
assertWithinAllowedRoots(real, await this.resolvedRoots());
|
|
52
|
+
const entries = (await (0, node_fs_promises.readdir)(real, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => ({
|
|
53
|
+
name: d.name,
|
|
54
|
+
path: (0, node_path.join)(real, d.name)
|
|
55
|
+
}));
|
|
56
|
+
const fs = await (0, node_fs_promises.statfs)(real);
|
|
57
|
+
const totalBytes = fs.blocks * fs.bsize;
|
|
58
|
+
return {
|
|
59
|
+
path: real,
|
|
60
|
+
entries,
|
|
61
|
+
freeBytes: fs.bavail * fs.bsize,
|
|
62
|
+
totalBytes
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async createDir({ path }) {
|
|
66
|
+
const parent = (0, node_path.dirname)(path);
|
|
67
|
+
assertWithinAllowedRoots((0, node_path.join)(await (0, node_fs_promises.realpath)(parent).catch(() => parent), (0, node_path.basename)(path)), await this.resolvedRoots());
|
|
68
|
+
await (0, node_fs_promises.mkdir)(path, { recursive: true });
|
|
69
|
+
return { path };
|
|
70
|
+
}
|
|
71
|
+
/** Allowed roots with symlinks resolved (falls back to the raw root if it does not exist). */
|
|
72
|
+
async resolvedRoots() {
|
|
73
|
+
return Promise.all(this.allowedRoots().map((r) => (0, node_fs_promises.realpath)(r).catch(() => r)));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
14
77
|
//#region src/builtins/sqlite-storage/filesystem-storage-provider.ts
|
|
15
78
|
/**
|
|
16
79
|
* Filesystem `storage-provider` (Task 7).
|
|
@@ -272,69 +335,6 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
|
|
|
272
335
|
}
|
|
273
336
|
};
|
|
274
337
|
//#endregion
|
|
275
|
-
//#region src/builtins/sqlite-storage/path-guard.ts
|
|
276
|
-
/**
|
|
277
|
-
* Allowed-root containment guard for the filesystem-browse cap. Pure +
|
|
278
|
-
* synchronous so it is trivially unit-testable; the provider applies it AFTER
|
|
279
|
-
* resolving the real path (so symlink escapes are also caught upstream).
|
|
280
|
-
*/
|
|
281
|
-
/** True iff `candidate` is one of, or nested under, an allowed root. */
|
|
282
|
-
function isWithinAllowedRoots(candidate, allowedRoots) {
|
|
283
|
-
const norm = (0, node_path.resolve)(candidate);
|
|
284
|
-
return allowedRoots.some((root) => {
|
|
285
|
-
const r = (0, node_path.resolve)(root);
|
|
286
|
-
return norm === r || norm.startsWith(r.endsWith(node_path.sep) ? r : r + node_path.sep);
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
/** Throws unless `candidate` is within an allowed root. */
|
|
290
|
-
function assertWithinAllowedRoots(candidate, allowedRoots) {
|
|
291
|
-
if (!isWithinAllowedRoots(candidate, allowedRoots)) throw new Error(`path "${candidate}" is not within an allowed root`);
|
|
292
|
-
}
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region src/builtins/sqlite-storage/filesystem-browse-provider.ts
|
|
295
|
-
/**
|
|
296
|
-
* Per-node filesystem-browse provider. Lists/creates directories under
|
|
297
|
-
* operator-configured allowed roots only (sandboxed by `path-guard`). Backs the
|
|
298
|
-
* `filesystem-browse` cap so the admin UI can pick a node + path for a
|
|
299
|
-
* node-local storage location.
|
|
300
|
-
*/
|
|
301
|
-
var FilesystemBrowseProvider = class {
|
|
302
|
-
allowedRoots;
|
|
303
|
-
/** allowedRoots is injected (read from addon config) so it stays per-node + testable. */
|
|
304
|
-
constructor(allowedRoots) {
|
|
305
|
-
this.allowedRoots = allowedRoots;
|
|
306
|
-
}
|
|
307
|
-
async listAllowedRoots() {
|
|
308
|
-
return [...this.allowedRoots()];
|
|
309
|
-
}
|
|
310
|
-
async browse({ path }) {
|
|
311
|
-
const real = await (0, node_fs_promises.realpath)(path).catch(() => path);
|
|
312
|
-
assertWithinAllowedRoots(real, await this.resolvedRoots());
|
|
313
|
-
const entries = (await (0, node_fs_promises.readdir)(real, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => ({
|
|
314
|
-
name: d.name,
|
|
315
|
-
path: (0, node_path.join)(real, d.name)
|
|
316
|
-
}));
|
|
317
|
-
const fs = await (0, node_fs_promises.statfs)(real);
|
|
318
|
-
const totalBytes = fs.blocks * fs.bsize;
|
|
319
|
-
return {
|
|
320
|
-
path: real,
|
|
321
|
-
entries,
|
|
322
|
-
freeBytes: fs.bavail * fs.bsize,
|
|
323
|
-
totalBytes
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
async createDir({ path }) {
|
|
327
|
-
const parent = (0, node_path.dirname)(path);
|
|
328
|
-
assertWithinAllowedRoots((0, node_path.join)(await (0, node_fs_promises.realpath)(parent).catch(() => parent), (0, node_path.basename)(path)), await this.resolvedRoots());
|
|
329
|
-
await (0, node_fs_promises.mkdir)(path, { recursive: true });
|
|
330
|
-
return { path };
|
|
331
|
-
}
|
|
332
|
-
/** Allowed roots with symlinks resolved (falls back to the raw root if it does not exist). */
|
|
333
|
-
async resolvedRoots() {
|
|
334
|
-
return Promise.all(this.allowedRoots().map((r) => (0, node_fs_promises.realpath)(r).catch(() => r)));
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
//#endregion
|
|
338
338
|
//#region src/builtins/sqlite-storage/filesystem-storage.addon.ts
|
|
339
339
|
function defaultAllowedRoots() {
|
|
340
340
|
return [
|
|
@@ -5,6 +5,69 @@ import { basename, dirname, join, resolve, sep } from "node:path";
|
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import { mkdir, readdir, realpath, statfs } from "node:fs/promises";
|
|
8
|
+
//#region src/builtins/sqlite-storage/path-guard.ts
|
|
9
|
+
/**
|
|
10
|
+
* Allowed-root containment guard for the filesystem-browse cap. Pure +
|
|
11
|
+
* synchronous so it is trivially unit-testable; the provider applies it AFTER
|
|
12
|
+
* resolving the real path (so symlink escapes are also caught upstream).
|
|
13
|
+
*/
|
|
14
|
+
/** True iff `candidate` is one of, or nested under, an allowed root. */
|
|
15
|
+
function isWithinAllowedRoots(candidate, allowedRoots) {
|
|
16
|
+
const norm = resolve(candidate);
|
|
17
|
+
return allowedRoots.some((root) => {
|
|
18
|
+
const r = resolve(root);
|
|
19
|
+
return norm === r || norm.startsWith(r.endsWith(sep) ? r : r + sep);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** Throws unless `candidate` is within an allowed root. */
|
|
23
|
+
function assertWithinAllowedRoots(candidate, allowedRoots) {
|
|
24
|
+
if (!isWithinAllowedRoots(candidate, allowedRoots)) throw new Error(`path "${candidate}" is not within an allowed root`);
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/builtins/sqlite-storage/filesystem-browse-provider.ts
|
|
28
|
+
/**
|
|
29
|
+
* Per-node filesystem-browse provider. Lists/creates directories under
|
|
30
|
+
* operator-configured allowed roots only (sandboxed by `path-guard`). Backs the
|
|
31
|
+
* `filesystem-browse` cap so the admin UI can pick a node + path for a
|
|
32
|
+
* node-local storage location.
|
|
33
|
+
*/
|
|
34
|
+
var FilesystemBrowseProvider = class {
|
|
35
|
+
allowedRoots;
|
|
36
|
+
/** allowedRoots is injected (read from addon config) so it stays per-node + testable. */
|
|
37
|
+
constructor(allowedRoots) {
|
|
38
|
+
this.allowedRoots = allowedRoots;
|
|
39
|
+
}
|
|
40
|
+
async listAllowedRoots() {
|
|
41
|
+
return [...this.allowedRoots()];
|
|
42
|
+
}
|
|
43
|
+
async browse({ path }) {
|
|
44
|
+
const real = await realpath(path).catch(() => path);
|
|
45
|
+
assertWithinAllowedRoots(real, await this.resolvedRoots());
|
|
46
|
+
const entries = (await readdir(real, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => ({
|
|
47
|
+
name: d.name,
|
|
48
|
+
path: join(real, d.name)
|
|
49
|
+
}));
|
|
50
|
+
const fs = await statfs(real);
|
|
51
|
+
const totalBytes = fs.blocks * fs.bsize;
|
|
52
|
+
return {
|
|
53
|
+
path: real,
|
|
54
|
+
entries,
|
|
55
|
+
freeBytes: fs.bavail * fs.bsize,
|
|
56
|
+
totalBytes
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async createDir({ path }) {
|
|
60
|
+
const parent = dirname(path);
|
|
61
|
+
assertWithinAllowedRoots(join(await realpath(parent).catch(() => parent), basename(path)), await this.resolvedRoots());
|
|
62
|
+
await mkdir(path, { recursive: true });
|
|
63
|
+
return { path };
|
|
64
|
+
}
|
|
65
|
+
/** Allowed roots with symlinks resolved (falls back to the raw root if it does not exist). */
|
|
66
|
+
async resolvedRoots() {
|
|
67
|
+
return Promise.all(this.allowedRoots().map((r) => realpath(r).catch(() => r)));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
8
71
|
//#region src/builtins/sqlite-storage/filesystem-storage-provider.ts
|
|
9
72
|
/**
|
|
10
73
|
* Filesystem `storage-provider` (Task 7).
|
|
@@ -266,69 +329,6 @@ var FilesystemStorageProvider = class FilesystemStorageProvider {
|
|
|
266
329
|
}
|
|
267
330
|
};
|
|
268
331
|
//#endregion
|
|
269
|
-
//#region src/builtins/sqlite-storage/path-guard.ts
|
|
270
|
-
/**
|
|
271
|
-
* Allowed-root containment guard for the filesystem-browse cap. Pure +
|
|
272
|
-
* synchronous so it is trivially unit-testable; the provider applies it AFTER
|
|
273
|
-
* resolving the real path (so symlink escapes are also caught upstream).
|
|
274
|
-
*/
|
|
275
|
-
/** True iff `candidate` is one of, or nested under, an allowed root. */
|
|
276
|
-
function isWithinAllowedRoots(candidate, allowedRoots) {
|
|
277
|
-
const norm = resolve(candidate);
|
|
278
|
-
return allowedRoots.some((root) => {
|
|
279
|
-
const r = resolve(root);
|
|
280
|
-
return norm === r || norm.startsWith(r.endsWith(sep) ? r : r + sep);
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
/** Throws unless `candidate` is within an allowed root. */
|
|
284
|
-
function assertWithinAllowedRoots(candidate, allowedRoots) {
|
|
285
|
-
if (!isWithinAllowedRoots(candidate, allowedRoots)) throw new Error(`path "${candidate}" is not within an allowed root`);
|
|
286
|
-
}
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region src/builtins/sqlite-storage/filesystem-browse-provider.ts
|
|
289
|
-
/**
|
|
290
|
-
* Per-node filesystem-browse provider. Lists/creates directories under
|
|
291
|
-
* operator-configured allowed roots only (sandboxed by `path-guard`). Backs the
|
|
292
|
-
* `filesystem-browse` cap so the admin UI can pick a node + path for a
|
|
293
|
-
* node-local storage location.
|
|
294
|
-
*/
|
|
295
|
-
var FilesystemBrowseProvider = class {
|
|
296
|
-
allowedRoots;
|
|
297
|
-
/** allowedRoots is injected (read from addon config) so it stays per-node + testable. */
|
|
298
|
-
constructor(allowedRoots) {
|
|
299
|
-
this.allowedRoots = allowedRoots;
|
|
300
|
-
}
|
|
301
|
-
async listAllowedRoots() {
|
|
302
|
-
return [...this.allowedRoots()];
|
|
303
|
-
}
|
|
304
|
-
async browse({ path }) {
|
|
305
|
-
const real = await realpath(path).catch(() => path);
|
|
306
|
-
assertWithinAllowedRoots(real, await this.resolvedRoots());
|
|
307
|
-
const entries = (await readdir(real, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => ({
|
|
308
|
-
name: d.name,
|
|
309
|
-
path: join(real, d.name)
|
|
310
|
-
}));
|
|
311
|
-
const fs = await statfs(real);
|
|
312
|
-
const totalBytes = fs.blocks * fs.bsize;
|
|
313
|
-
return {
|
|
314
|
-
path: real,
|
|
315
|
-
entries,
|
|
316
|
-
freeBytes: fs.bavail * fs.bsize,
|
|
317
|
-
totalBytes
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
async createDir({ path }) {
|
|
321
|
-
const parent = dirname(path);
|
|
322
|
-
assertWithinAllowedRoots(join(await realpath(parent).catch(() => parent), basename(path)), await this.resolvedRoots());
|
|
323
|
-
await mkdir(path, { recursive: true });
|
|
324
|
-
return { path };
|
|
325
|
-
}
|
|
326
|
-
/** Allowed roots with symlinks resolved (falls back to the raw root if it does not exist). */
|
|
327
|
-
async resolvedRoots() {
|
|
328
|
-
return Promise.all(this.allowedRoots().map((r) => realpath(r).catch(() => r)));
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
//#endregion
|
|
332
332
|
//#region src/builtins/sqlite-storage/filesystem-storage.addon.ts
|
|
333
333
|
function defaultAllowedRoots() {
|
|
334
334
|
return [
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
export { ConfigStore } from './config-store.js';
|
|
2
|
+
export type { DeviceRow } from './device-store.js';
|
|
3
|
+
export { DeviceStore } from './device-store.js';
|
|
4
|
+
export { FilesystemStorageAddon, FilesystemStorageAddon as default, } from './filesystem-storage.addon.js';
|
|
1
5
|
export { FilesystemStorageProvider } from './filesystem-storage-provider.js';
|
|
2
|
-
export { FilesystemStorageAddon } from './filesystem-storage.addon.js';
|
|
3
|
-
export { SqliteSettingsBackend } from './sqlite-settings-backend.js';
|
|
4
6
|
export { SqliteSettingsAddon } from './sqlite-settings.addon.js';
|
|
5
|
-
export {
|
|
6
|
-
export type { DeviceRow } from './device-store.js';
|
|
7
|
-
export { ConfigStore } from './config-store.js';
|
|
8
|
-
export { FilesystemStorageAddon as default } from './filesystem-storage.addon.js';
|
|
7
|
+
export { SqliteSettingsBackend } from './sqlite-settings-backend.js';
|
|
@@ -5,26 +5,6 @@ Object.defineProperties(exports, {
|
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
6
|
const require_builtins_sqlite_storage_filesystem_storage_addon = require("./filesystem-storage.addon.js");
|
|
7
7
|
const require_builtins_sqlite_storage_sqlite_settings_addon = require("./sqlite-settings.addon.js");
|
|
8
|
-
//#region src/builtins/sqlite-storage/device-store.ts
|
|
9
|
-
var DeviceStore = class {
|
|
10
|
-
db;
|
|
11
|
-
constructor(db) {
|
|
12
|
-
this.db = db;
|
|
13
|
-
}
|
|
14
|
-
insert(addonId, device) {
|
|
15
|
-
this.db.prepare(`INSERT INTO devices (addon_id, stable_id, type, name, parent_stable_id) VALUES (?, ?, ?, ?, ?)`).run(addonId, device.stableId, device.type, device.name, device.parentStableId);
|
|
16
|
-
}
|
|
17
|
-
listByAddon(addonId) {
|
|
18
|
-
return this.db.prepare(`SELECT stable_id as stableId, type, name, parent_stable_id as parentStableId, enabled FROM devices WHERE addon_id = ?`).all(addonId);
|
|
19
|
-
}
|
|
20
|
-
listChildren(addonId, parentStableId) {
|
|
21
|
-
return this.db.prepare(`SELECT stable_id as stableId, type, name, parent_stable_id as parentStableId, enabled FROM devices WHERE addon_id = ? AND parent_stable_id = ?`).all(addonId, parentStableId);
|
|
22
|
-
}
|
|
23
|
-
remove(addonId, stableId) {
|
|
24
|
-
this.db.prepare(`DELETE FROM devices WHERE addon_id = ? AND stable_id = ?`).run(addonId, stableId);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//#endregion
|
|
28
8
|
//#region src/builtins/sqlite-storage/config-store.ts
|
|
29
9
|
var ConfigStore = class {
|
|
30
10
|
db;
|
|
@@ -51,6 +31,26 @@ var ConfigStore = class {
|
|
|
51
31
|
}
|
|
52
32
|
};
|
|
53
33
|
//#endregion
|
|
34
|
+
//#region src/builtins/sqlite-storage/device-store.ts
|
|
35
|
+
var DeviceStore = class {
|
|
36
|
+
db;
|
|
37
|
+
constructor(db) {
|
|
38
|
+
this.db = db;
|
|
39
|
+
}
|
|
40
|
+
insert(addonId, device) {
|
|
41
|
+
this.db.prepare(`INSERT INTO devices (addon_id, stable_id, type, name, parent_stable_id) VALUES (?, ?, ?, ?, ?)`).run(addonId, device.stableId, device.type, device.name, device.parentStableId);
|
|
42
|
+
}
|
|
43
|
+
listByAddon(addonId) {
|
|
44
|
+
return this.db.prepare(`SELECT stable_id as stableId, type, name, parent_stable_id as parentStableId, enabled FROM devices WHERE addon_id = ?`).all(addonId);
|
|
45
|
+
}
|
|
46
|
+
listChildren(addonId, parentStableId) {
|
|
47
|
+
return this.db.prepare(`SELECT stable_id as stableId, type, name, parent_stable_id as parentStableId, enabled FROM devices WHERE addon_id = ? AND parent_stable_id = ?`).all(addonId, parentStableId);
|
|
48
|
+
}
|
|
49
|
+
remove(addonId, stableId) {
|
|
50
|
+
this.db.prepare(`DELETE FROM devices WHERE addon_id = ? AND stable_id = ?`).run(addonId, stableId);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
54
|
exports.ConfigStore = ConfigStore;
|
|
55
55
|
exports.ConfigStore$1 = ConfigStore;
|
|
56
56
|
exports.DeviceStore = DeviceStore;
|
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
import { FilesystemStorageAddon, t as FilesystemStorageProvider } from "./filesystem-storage.addon.mjs";
|
|
2
2
|
import { SqliteSettingsAddon, t as SqliteSettingsBackend } from "./sqlite-settings.addon.mjs";
|
|
3
|
-
//#region src/builtins/sqlite-storage/device-store.ts
|
|
4
|
-
var DeviceStore = class {
|
|
5
|
-
db;
|
|
6
|
-
constructor(db) {
|
|
7
|
-
this.db = db;
|
|
8
|
-
}
|
|
9
|
-
insert(addonId, device) {
|
|
10
|
-
this.db.prepare(`INSERT INTO devices (addon_id, stable_id, type, name, parent_stable_id) VALUES (?, ?, ?, ?, ?)`).run(addonId, device.stableId, device.type, device.name, device.parentStableId);
|
|
11
|
-
}
|
|
12
|
-
listByAddon(addonId) {
|
|
13
|
-
return this.db.prepare(`SELECT stable_id as stableId, type, name, parent_stable_id as parentStableId, enabled FROM devices WHERE addon_id = ?`).all(addonId);
|
|
14
|
-
}
|
|
15
|
-
listChildren(addonId, parentStableId) {
|
|
16
|
-
return this.db.prepare(`SELECT stable_id as stableId, type, name, parent_stable_id as parentStableId, enabled FROM devices WHERE addon_id = ? AND parent_stable_id = ?`).all(addonId, parentStableId);
|
|
17
|
-
}
|
|
18
|
-
remove(addonId, stableId) {
|
|
19
|
-
this.db.prepare(`DELETE FROM devices WHERE addon_id = ? AND stable_id = ?`).run(addonId, stableId);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
23
3
|
//#region src/builtins/sqlite-storage/config-store.ts
|
|
24
4
|
var ConfigStore = class {
|
|
25
5
|
db;
|
|
@@ -46,4 +26,24 @@ var ConfigStore = class {
|
|
|
46
26
|
}
|
|
47
27
|
};
|
|
48
28
|
//#endregion
|
|
29
|
+
//#region src/builtins/sqlite-storage/device-store.ts
|
|
30
|
+
var DeviceStore = class {
|
|
31
|
+
db;
|
|
32
|
+
constructor(db) {
|
|
33
|
+
this.db = db;
|
|
34
|
+
}
|
|
35
|
+
insert(addonId, device) {
|
|
36
|
+
this.db.prepare(`INSERT INTO devices (addon_id, stable_id, type, name, parent_stable_id) VALUES (?, ?, ?, ?, ?)`).run(addonId, device.stableId, device.type, device.name, device.parentStableId);
|
|
37
|
+
}
|
|
38
|
+
listByAddon(addonId) {
|
|
39
|
+
return this.db.prepare(`SELECT stable_id as stableId, type, name, parent_stable_id as parentStableId, enabled FROM devices WHERE addon_id = ?`).all(addonId);
|
|
40
|
+
}
|
|
41
|
+
listChildren(addonId, parentStableId) {
|
|
42
|
+
return this.db.prepare(`SELECT stable_id as stableId, type, name, parent_stable_id as parentStableId, enabled FROM devices WHERE addon_id = ? AND parent_stable_id = ?`).all(addonId, parentStableId);
|
|
43
|
+
}
|
|
44
|
+
remove(addonId, stableId) {
|
|
45
|
+
this.db.prepare(`DELETE FROM devices WHERE addon_id = ? AND stable_id = ?`).run(addonId, stableId);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
49
|
export { ConfigStore, DeviceStore, FilesystemStorageAddon, FilesystemStorageAddon as default, FilesystemStorageProvider, SqliteSettingsAddon, SqliteSettingsBackend };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateDeviceInput, CreateIntegrationInput, IIntegrationRegistry, Integration, ISettingsStoreProvider, PersistedDevice } from '@camstack/types';
|
|
2
2
|
export declare class IntegrationRegistry implements IIntegrationRegistry {
|
|
3
3
|
private readonly store;
|
|
4
4
|
constructor(backend: ISettingsStoreProvider);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { CollectionColumn, CollectionIndex, DataStoreEngineInfo, HistogramBucket, ISettingsBackend, SettingsCountInput, SettingsDeleteInput, SettingsGetInput, SettingsHistogramInput, SettingsInsertInput, SettingsIsEmptyInput, SettingsQueryInput, SettingsRecord, SettingsSetInput, SettingsUpdateInput } from '@camstack/types';
|
|
1
2
|
import { default as Database } from 'better-sqlite3';
|
|
2
|
-
import { DataStoreEngineInfo, ISettingsBackend, SettingsRecord, SettingsGetInput, SettingsSetInput, SettingsQueryInput, SettingsInsertInput, SettingsUpdateInput, SettingsDeleteInput, SettingsCountInput, SettingsIsEmptyInput, SettingsHistogramInput, HistogramBucket, CollectionColumn, CollectionIndex } from '@camstack/types';
|
|
3
3
|
import { MutationFilterInput } from './filter-compiler.js';
|
|
4
4
|
/** Input for {@link SqliteSettingsBackend.deleteWhere}. */
|
|
5
5
|
interface SettingsDeleteWhereInput {
|
|
@@ -743,10 +743,7 @@ var SqliteVectorIndex = class {
|
|
|
743
743
|
const dim = row.data["dim"];
|
|
744
744
|
const metric = row.data["metric"];
|
|
745
745
|
if (typeof dim !== "number") continue;
|
|
746
|
-
this.
|
|
747
|
-
dim,
|
|
748
|
-
metric: isMetric(metric) ? metric : "cosine"
|
|
749
|
-
});
|
|
746
|
+
await this.declareIndex(row.id, dim, isMetric(metric) ? metric : "cosine");
|
|
750
747
|
}
|
|
751
748
|
this.logger.info("vector-store index registry loaded", { meta: { indexes: this.specs.size } });
|
|
752
749
|
} catch (err) {
|
|
@@ -737,10 +737,7 @@ var SqliteVectorIndex = class {
|
|
|
737
737
|
const dim = row.data["dim"];
|
|
738
738
|
const metric = row.data["metric"];
|
|
739
739
|
if (typeof dim !== "number") continue;
|
|
740
|
-
this.
|
|
741
|
-
dim,
|
|
742
|
-
metric: isMetric(metric) ? metric : "cosine"
|
|
743
|
-
});
|
|
740
|
+
await this.declareIndex(row.id, dim, isMetric(metric) ? metric : "cosine");
|
|
744
741
|
}
|
|
745
742
|
this.logger.info("vector-store index registry loaded", { meta: { indexes: this.specs.size } });
|
|
746
743
|
} catch (err) {
|