@camstack/core 0.1.7 → 0.1.10
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/local-backup/index.d.mts +42 -0
- package/dist/builtins/local-backup/index.d.ts +42 -0
- package/dist/builtins/local-backup/index.mjs +2 -10
- package/dist/builtins/local-backup/index.mjs.map +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.mts +2 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts +2 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +2 -5
- package/dist/builtins/sqlite-storage/index.d.mts +4 -0
- package/dist/builtins/sqlite-storage/index.d.ts +4 -0
- package/dist/builtins/sqlite-storage/index.js +95 -197
- package/dist/builtins/sqlite-storage/index.js.map +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +6 -26
- package/dist/builtins/sqlite-storage/index.mjs.map +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.mts +2 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +2 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -4
- package/dist/builtins/winston-logging/index.d.mts +30 -0
- package/dist/builtins/winston-logging/index.d.ts +30 -0
- package/dist/builtins/winston-logging/index.mjs +2 -10
- package/dist/builtins/winston-logging/index.mjs.map +1 -1
- package/dist/chunk-2F3XZYRW.mjs +89 -0
- package/dist/chunk-2F3XZYRW.mjs.map +1 -0
- package/dist/chunk-LQFPAEQF.mjs +147 -0
- package/dist/{chunk-XSLBW5C2.mjs.map → chunk-LQFPAEQF.mjs.map} +1 -1
- package/dist/chunk-R3DIIBBX.mjs +532 -0
- package/dist/chunk-R3DIIBBX.mjs.map +1 -0
- package/dist/chunk-SO4LROOT.mjs +150 -0
- package/dist/{chunk-GBWW3JU4.mjs.map → chunk-SO4LROOT.mjs.map} +1 -1
- package/dist/chunk-SPA4JBKN.mjs +175 -0
- package/dist/{chunk-4YD6WMO6.mjs.map → chunk-SPA4JBKN.mjs.map} +1 -1
- package/dist/chunk-YXNXYYHL.mjs +282 -0
- package/dist/{chunk-CHFIH4G6.mjs.map → chunk-YXNXYYHL.mjs.map} +1 -1
- package/dist/dist-3BY63UQ5.mjs +2151 -0
- package/dist/dist-3BY63UQ5.mjs.map +1 -0
- package/dist/filesystem-storage.addon-C42r589X.d.mts +57 -0
- package/dist/filesystem-storage.addon-C42r589X.d.ts +57 -0
- package/dist/index.d.mts +1110 -0
- package/dist/index.d.ts +1110 -0
- package/dist/index.js +6002 -17264
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3408 -16481
- package/dist/index.mjs.map +1 -1
- package/dist/sql-schema-CKz78rId.d.mts +97 -0
- package/dist/sql-schema-CKz78rId.d.ts +97 -0
- package/dist/sqlite-settings.addon-DigoKwpZ.d.mts +70 -0
- package/dist/sqlite-settings.addon-DigoKwpZ.d.ts +70 -0
- package/dist/storage-location-manager-KKDQNAKA.mjs +7 -0
- package/package.json +1 -1
- package/dist/chunk-4JEXNFZZ.mjs +0 -57
- package/dist/chunk-4YD6WMO6.mjs +0 -207
- package/dist/chunk-CHFIH4G6.mjs +0 -314
- package/dist/chunk-EFQ25JFE.mjs +0 -689
- package/dist/chunk-EFQ25JFE.mjs.map +0 -1
- package/dist/chunk-GBWW3JU4.mjs +0 -180
- package/dist/chunk-XSLBW5C2.mjs +0 -177
- package/dist/onnxruntime_binding-6Q6HXASN.node +0 -0
- package/dist/onnxruntime_binding-EKZT2NRK.node +0 -0
- package/dist/onnxruntime_binding-P6S7V3CI.node +0 -0
- package/dist/onnxruntime_binding-PJNNIIUO.node +0 -0
- package/dist/onnxruntime_binding-UN6SPTQK.node +0 -0
- /package/dist/{chunk-4JEXNFZZ.mjs.map → storage-location-manager-KKDQNAKA.mjs.map} +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { IFileStorage, StorageLocationName, IStorageLocation, ICamstackAddon, IConfigurable, AddonManifest, AddonContext, CapabilityProviderMap, ConfigUISchema } from '@camstack/types';
|
|
2
|
+
|
|
3
|
+
declare class FileSystemStorage implements IFileStorage {
|
|
4
|
+
private readonly basePath;
|
|
5
|
+
constructor(basePath: string);
|
|
6
|
+
readFile(filePath: string): Promise<Buffer>;
|
|
7
|
+
writeFile(filePath: string, data: Buffer): Promise<void>;
|
|
8
|
+
deleteFile(filePath: string): Promise<void>;
|
|
9
|
+
listFiles(prefix?: string): Promise<readonly string[]>;
|
|
10
|
+
getFileUrl(_path: string): Promise<string>;
|
|
11
|
+
exists(filePath: string): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
/** @deprecated Use FilesystemStorageProvider + SqliteSettingsBackend instead */
|
|
14
|
+
declare class SqliteStorageProvider {
|
|
15
|
+
private mainDb;
|
|
16
|
+
private sharedStructured;
|
|
17
|
+
private readonly locations;
|
|
18
|
+
initialize(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Configure all storage locations.
|
|
21
|
+
* ONE single SQLite database (camstack.db) is used for ALL structured storage.
|
|
22
|
+
* File-based locations use the filesystem at their configured path.
|
|
23
|
+
*/
|
|
24
|
+
configure(config: {
|
|
25
|
+
locations: Record<string, string>;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
getLocation(name: StorageLocationName): IStorageLocation;
|
|
28
|
+
shutdown(): Promise<void>;
|
|
29
|
+
export(_locationName: StorageLocationName): Promise<Buffer>;
|
|
30
|
+
import(_locationName: StorageLocationName, _data: Buffer): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare class SqliteStorageAddon implements ICamstackAddon, IConfigurable {
|
|
34
|
+
readonly manifest: AddonManifest;
|
|
35
|
+
private provider;
|
|
36
|
+
initialize(context: AddonContext): Promise<void>;
|
|
37
|
+
shutdown(): Promise<void>;
|
|
38
|
+
getProvider(): SqliteStorageProvider;
|
|
39
|
+
getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
|
|
40
|
+
getConfigSchema(): ConfigUISchema;
|
|
41
|
+
getConfig(): Record<string, unknown>;
|
|
42
|
+
onConfigChange(_config: Record<string, unknown>): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Thin wrapper over better-sqlite3 that manages the four settings tables:
|
|
47
|
+
* system_settings, addon_settings, provider_settings, device_settings.
|
|
48
|
+
*
|
|
49
|
+
* All values are stored as JSON text and deserialized on read.
|
|
50
|
+
*/
|
|
51
|
+
declare class SettingsStore {
|
|
52
|
+
private readonly db;
|
|
53
|
+
constructor(dbPath: string);
|
|
54
|
+
getSystem(key: string): unknown;
|
|
55
|
+
setSystem(key: string, value: unknown): void;
|
|
56
|
+
getAllSystem(): Record<string, unknown>;
|
|
57
|
+
getAddon(addonId: string, key: string): unknown;
|
|
58
|
+
setAddon(addonId: string, key: string, value: unknown): void;
|
|
59
|
+
getAllAddon(addonId: string): Record<string, unknown>;
|
|
60
|
+
/** Bulk-replace all keys for an addon (within a transaction). */
|
|
61
|
+
setAllAddon(addonId: string, config: Record<string, unknown>): void;
|
|
62
|
+
getProvider(providerId: string, key: string): unknown;
|
|
63
|
+
setProvider(providerId: string, key: string, value: unknown): void;
|
|
64
|
+
getAllProvider(providerId: string): Record<string, unknown>;
|
|
65
|
+
getDevice(deviceId: string, key: string): unknown;
|
|
66
|
+
setDevice(deviceId: string, key: string, value: unknown): void;
|
|
67
|
+
getAllDevice(deviceId: string): Record<string, unknown>;
|
|
68
|
+
/** Close the SQLite connection (call on shutdown). */
|
|
69
|
+
close(): void;
|
|
70
|
+
/** Check if system_settings is empty (used for first-boot seeding). */
|
|
71
|
+
isSystemSettingsEmpty(): boolean;
|
|
72
|
+
/** Seed system_settings with RUNTIME_DEFAULTS (only on first boot). */
|
|
73
|
+
seedDefaults(): void;
|
|
74
|
+
private initTables;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Core table DDL statements -- executed on first boot */
|
|
78
|
+
declare const CORE_TABLE_DDL: readonly string[];
|
|
79
|
+
/** Addon table schema declaration */
|
|
80
|
+
interface AddonTableSchema {
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly columns: ReadonlyArray<{
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly type: 'TEXT' | 'INTEGER' | 'REAL' | 'JSON';
|
|
85
|
+
readonly primaryKey?: boolean;
|
|
86
|
+
readonly notNull?: boolean;
|
|
87
|
+
}>;
|
|
88
|
+
readonly indexes?: ReadonlyArray<{
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly columns: readonly string[];
|
|
91
|
+
readonly unique?: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
}
|
|
94
|
+
/** Generate CREATE TABLE DDL from addon schema */
|
|
95
|
+
declare function addonTableToDdl(schema: AddonTableSchema): string[];
|
|
96
|
+
|
|
97
|
+
export { type AddonTableSchema as A, CORE_TABLE_DDL as C, FileSystemStorage as F, SettingsStore as S, SqliteStorageAddon as a, SqliteStorageProvider as b, addonTableToDdl as c };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { IFileStorage, StorageLocationName, IStorageLocation, ICamstackAddon, IConfigurable, AddonManifest, AddonContext, CapabilityProviderMap, ConfigUISchema } from '@camstack/types';
|
|
2
|
+
|
|
3
|
+
declare class FileSystemStorage implements IFileStorage {
|
|
4
|
+
private readonly basePath;
|
|
5
|
+
constructor(basePath: string);
|
|
6
|
+
readFile(filePath: string): Promise<Buffer>;
|
|
7
|
+
writeFile(filePath: string, data: Buffer): Promise<void>;
|
|
8
|
+
deleteFile(filePath: string): Promise<void>;
|
|
9
|
+
listFiles(prefix?: string): Promise<readonly string[]>;
|
|
10
|
+
getFileUrl(_path: string): Promise<string>;
|
|
11
|
+
exists(filePath: string): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
/** @deprecated Use FilesystemStorageProvider + SqliteSettingsBackend instead */
|
|
14
|
+
declare class SqliteStorageProvider {
|
|
15
|
+
private mainDb;
|
|
16
|
+
private sharedStructured;
|
|
17
|
+
private readonly locations;
|
|
18
|
+
initialize(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Configure all storage locations.
|
|
21
|
+
* ONE single SQLite database (camstack.db) is used for ALL structured storage.
|
|
22
|
+
* File-based locations use the filesystem at their configured path.
|
|
23
|
+
*/
|
|
24
|
+
configure(config: {
|
|
25
|
+
locations: Record<string, string>;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
getLocation(name: StorageLocationName): IStorageLocation;
|
|
28
|
+
shutdown(): Promise<void>;
|
|
29
|
+
export(_locationName: StorageLocationName): Promise<Buffer>;
|
|
30
|
+
import(_locationName: StorageLocationName, _data: Buffer): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare class SqliteStorageAddon implements ICamstackAddon, IConfigurable {
|
|
34
|
+
readonly manifest: AddonManifest;
|
|
35
|
+
private provider;
|
|
36
|
+
initialize(context: AddonContext): Promise<void>;
|
|
37
|
+
shutdown(): Promise<void>;
|
|
38
|
+
getProvider(): SqliteStorageProvider;
|
|
39
|
+
getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
|
|
40
|
+
getConfigSchema(): ConfigUISchema;
|
|
41
|
+
getConfig(): Record<string, unknown>;
|
|
42
|
+
onConfigChange(_config: Record<string, unknown>): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Thin wrapper over better-sqlite3 that manages the four settings tables:
|
|
47
|
+
* system_settings, addon_settings, provider_settings, device_settings.
|
|
48
|
+
*
|
|
49
|
+
* All values are stored as JSON text and deserialized on read.
|
|
50
|
+
*/
|
|
51
|
+
declare class SettingsStore {
|
|
52
|
+
private readonly db;
|
|
53
|
+
constructor(dbPath: string);
|
|
54
|
+
getSystem(key: string): unknown;
|
|
55
|
+
setSystem(key: string, value: unknown): void;
|
|
56
|
+
getAllSystem(): Record<string, unknown>;
|
|
57
|
+
getAddon(addonId: string, key: string): unknown;
|
|
58
|
+
setAddon(addonId: string, key: string, value: unknown): void;
|
|
59
|
+
getAllAddon(addonId: string): Record<string, unknown>;
|
|
60
|
+
/** Bulk-replace all keys for an addon (within a transaction). */
|
|
61
|
+
setAllAddon(addonId: string, config: Record<string, unknown>): void;
|
|
62
|
+
getProvider(providerId: string, key: string): unknown;
|
|
63
|
+
setProvider(providerId: string, key: string, value: unknown): void;
|
|
64
|
+
getAllProvider(providerId: string): Record<string, unknown>;
|
|
65
|
+
getDevice(deviceId: string, key: string): unknown;
|
|
66
|
+
setDevice(deviceId: string, key: string, value: unknown): void;
|
|
67
|
+
getAllDevice(deviceId: string): Record<string, unknown>;
|
|
68
|
+
/** Close the SQLite connection (call on shutdown). */
|
|
69
|
+
close(): void;
|
|
70
|
+
/** Check if system_settings is empty (used for first-boot seeding). */
|
|
71
|
+
isSystemSettingsEmpty(): boolean;
|
|
72
|
+
/** Seed system_settings with RUNTIME_DEFAULTS (only on first boot). */
|
|
73
|
+
seedDefaults(): void;
|
|
74
|
+
private initTables;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Core table DDL statements -- executed on first boot */
|
|
78
|
+
declare const CORE_TABLE_DDL: readonly string[];
|
|
79
|
+
/** Addon table schema declaration */
|
|
80
|
+
interface AddonTableSchema {
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly columns: ReadonlyArray<{
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly type: 'TEXT' | 'INTEGER' | 'REAL' | 'JSON';
|
|
85
|
+
readonly primaryKey?: boolean;
|
|
86
|
+
readonly notNull?: boolean;
|
|
87
|
+
}>;
|
|
88
|
+
readonly indexes?: ReadonlyArray<{
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly columns: readonly string[];
|
|
91
|
+
readonly unique?: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
}
|
|
94
|
+
/** Generate CREATE TABLE DDL from addon schema */
|
|
95
|
+
declare function addonTableToDdl(schema: AddonTableSchema): string[];
|
|
96
|
+
|
|
97
|
+
export { type AddonTableSchema as A, CORE_TABLE_DDL as C, FileSystemStorage as F, SettingsStore as S, SqliteStorageAddon as a, SqliteStorageProvider as b, addonTableToDdl as c };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ISettingsBackend, SettingsCollection, QueryFilter, SettingsRecord, ICamstackAddon, IConfigurable, AddonManifest, AddonContext, CapabilityProviderMap, ConfigUISchema } from '@camstack/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SQLite implementation of ISettingsBackend.
|
|
5
|
+
*
|
|
6
|
+
* One table per collection, auto-created on first access.
|
|
7
|
+
* All data stored as JSON in a TEXT column.
|
|
8
|
+
* WAL mode for concurrent reads.
|
|
9
|
+
*/
|
|
10
|
+
declare class SqliteSettingsBackend implements ISettingsBackend {
|
|
11
|
+
private readonly dbPath;
|
|
12
|
+
private db;
|
|
13
|
+
private readonly ensuredTables;
|
|
14
|
+
private readonly runtimeDefaults;
|
|
15
|
+
constructor(dbPath: string, runtimeDefaults?: Record<string, unknown>);
|
|
16
|
+
initialize(): Promise<void>;
|
|
17
|
+
shutdown(): Promise<void>;
|
|
18
|
+
get(collection: SettingsCollection, key: string): Promise<unknown>;
|
|
19
|
+
set(collection: SettingsCollection, key: string, value: unknown): Promise<void>;
|
|
20
|
+
query(collection: SettingsCollection, filter?: QueryFilter): Promise<readonly SettingsRecord[]>;
|
|
21
|
+
insert(collection: SettingsCollection, record: SettingsRecord): Promise<void>;
|
|
22
|
+
update(collection: SettingsCollection, id: string, data: Record<string, unknown>): Promise<void>;
|
|
23
|
+
delete(collection: SettingsCollection, key: string): Promise<void>;
|
|
24
|
+
count(collection: SettingsCollection, filter?: QueryFilter): Promise<number>;
|
|
25
|
+
isEmpty(collection: SettingsCollection): Promise<boolean>;
|
|
26
|
+
/** Get a system setting by dot-notation key */
|
|
27
|
+
getSystem(key: string): unknown;
|
|
28
|
+
/** Set a system setting */
|
|
29
|
+
setSystem(key: string, value: unknown): void;
|
|
30
|
+
/** Get all system settings as flat key-value */
|
|
31
|
+
getAllSystem(): Record<string, unknown>;
|
|
32
|
+
/** Get all settings for an addon */
|
|
33
|
+
getAllAddon(addonId: string): Record<string, unknown>;
|
|
34
|
+
/** Bulk-set all settings for an addon */
|
|
35
|
+
setAllAddon(addonId: string, config: Record<string, unknown>): void;
|
|
36
|
+
/** Get all settings for a provider */
|
|
37
|
+
getAllProvider(providerId: string): Record<string, unknown>;
|
|
38
|
+
/** Set a provider setting */
|
|
39
|
+
setProvider(providerId: string, key: string, value: unknown): void;
|
|
40
|
+
/** Get all settings for a device */
|
|
41
|
+
getAllDevice(deviceId: string): Record<string, unknown>;
|
|
42
|
+
/** Set a device setting */
|
|
43
|
+
setDevice(deviceId: string, key: string, value: unknown): void;
|
|
44
|
+
/** Seed system-settings with runtime defaults (first boot) */
|
|
45
|
+
private seedDefaults;
|
|
46
|
+
private getDb;
|
|
47
|
+
private ensureTable;
|
|
48
|
+
private getAllScoped;
|
|
49
|
+
private setScopedKey;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* SQLite Settings addon — provides persistent settings storage.
|
|
54
|
+
* Capability: 'settings-store' (singleton)
|
|
55
|
+
*
|
|
56
|
+
* Depends on 'storage' capability for resolving the DB file path.
|
|
57
|
+
*/
|
|
58
|
+
declare class SqliteSettingsAddon implements ICamstackAddon, IConfigurable {
|
|
59
|
+
readonly manifest: AddonManifest;
|
|
60
|
+
private backend;
|
|
61
|
+
initialize(context: AddonContext): Promise<void>;
|
|
62
|
+
shutdown(): Promise<void>;
|
|
63
|
+
getBackend(): SqliteSettingsBackend | null;
|
|
64
|
+
getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
|
|
65
|
+
getConfigSchema(): ConfigUISchema;
|
|
66
|
+
getConfig(): Record<string, unknown>;
|
|
67
|
+
onConfigChange(_config: Record<string, unknown>): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { SqliteSettingsAddon as S, SqliteSettingsBackend as a };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ISettingsBackend, SettingsCollection, QueryFilter, SettingsRecord, ICamstackAddon, IConfigurable, AddonManifest, AddonContext, CapabilityProviderMap, ConfigUISchema } from '@camstack/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SQLite implementation of ISettingsBackend.
|
|
5
|
+
*
|
|
6
|
+
* One table per collection, auto-created on first access.
|
|
7
|
+
* All data stored as JSON in a TEXT column.
|
|
8
|
+
* WAL mode for concurrent reads.
|
|
9
|
+
*/
|
|
10
|
+
declare class SqliteSettingsBackend implements ISettingsBackend {
|
|
11
|
+
private readonly dbPath;
|
|
12
|
+
private db;
|
|
13
|
+
private readonly ensuredTables;
|
|
14
|
+
private readonly runtimeDefaults;
|
|
15
|
+
constructor(dbPath: string, runtimeDefaults?: Record<string, unknown>);
|
|
16
|
+
initialize(): Promise<void>;
|
|
17
|
+
shutdown(): Promise<void>;
|
|
18
|
+
get(collection: SettingsCollection, key: string): Promise<unknown>;
|
|
19
|
+
set(collection: SettingsCollection, key: string, value: unknown): Promise<void>;
|
|
20
|
+
query(collection: SettingsCollection, filter?: QueryFilter): Promise<readonly SettingsRecord[]>;
|
|
21
|
+
insert(collection: SettingsCollection, record: SettingsRecord): Promise<void>;
|
|
22
|
+
update(collection: SettingsCollection, id: string, data: Record<string, unknown>): Promise<void>;
|
|
23
|
+
delete(collection: SettingsCollection, key: string): Promise<void>;
|
|
24
|
+
count(collection: SettingsCollection, filter?: QueryFilter): Promise<number>;
|
|
25
|
+
isEmpty(collection: SettingsCollection): Promise<boolean>;
|
|
26
|
+
/** Get a system setting by dot-notation key */
|
|
27
|
+
getSystem(key: string): unknown;
|
|
28
|
+
/** Set a system setting */
|
|
29
|
+
setSystem(key: string, value: unknown): void;
|
|
30
|
+
/** Get all system settings as flat key-value */
|
|
31
|
+
getAllSystem(): Record<string, unknown>;
|
|
32
|
+
/** Get all settings for an addon */
|
|
33
|
+
getAllAddon(addonId: string): Record<string, unknown>;
|
|
34
|
+
/** Bulk-set all settings for an addon */
|
|
35
|
+
setAllAddon(addonId: string, config: Record<string, unknown>): void;
|
|
36
|
+
/** Get all settings for a provider */
|
|
37
|
+
getAllProvider(providerId: string): Record<string, unknown>;
|
|
38
|
+
/** Set a provider setting */
|
|
39
|
+
setProvider(providerId: string, key: string, value: unknown): void;
|
|
40
|
+
/** Get all settings for a device */
|
|
41
|
+
getAllDevice(deviceId: string): Record<string, unknown>;
|
|
42
|
+
/** Set a device setting */
|
|
43
|
+
setDevice(deviceId: string, key: string, value: unknown): void;
|
|
44
|
+
/** Seed system-settings with runtime defaults (first boot) */
|
|
45
|
+
private seedDefaults;
|
|
46
|
+
private getDb;
|
|
47
|
+
private ensureTable;
|
|
48
|
+
private getAllScoped;
|
|
49
|
+
private setScopedKey;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* SQLite Settings addon — provides persistent settings storage.
|
|
54
|
+
* Capability: 'settings-store' (singleton)
|
|
55
|
+
*
|
|
56
|
+
* Depends on 'storage' capability for resolving the DB file path.
|
|
57
|
+
*/
|
|
58
|
+
declare class SqliteSettingsAddon implements ICamstackAddon, IConfigurable {
|
|
59
|
+
readonly manifest: AddonManifest;
|
|
60
|
+
private backend;
|
|
61
|
+
initialize(context: AddonContext): Promise<void>;
|
|
62
|
+
shutdown(): Promise<void>;
|
|
63
|
+
getBackend(): SqliteSettingsBackend | null;
|
|
64
|
+
getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
|
|
65
|
+
getConfigSchema(): ConfigUISchema;
|
|
66
|
+
getConfig(): Record<string, unknown>;
|
|
67
|
+
onConfigChange(_config: Record<string, unknown>): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { SqliteSettingsAddon as S, SqliteSettingsBackend as a };
|
package/package.json
CHANGED
package/dist/chunk-4JEXNFZZ.mjs
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __glob = (map) => (path) => {
|
|
14
|
-
var fn = map[path];
|
|
15
|
-
if (fn) return fn();
|
|
16
|
-
throw new Error("Module not found in bundle: " + path);
|
|
17
|
-
};
|
|
18
|
-
var __esm = (fn, res) => function __init() {
|
|
19
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
20
|
-
};
|
|
21
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
22
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
23
|
-
};
|
|
24
|
-
var __export = (target, all) => {
|
|
25
|
-
for (var name in all)
|
|
26
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
-
};
|
|
28
|
-
var __copyProps = (to, from, except, desc) => {
|
|
29
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
-
for (let key of __getOwnPropNames(from))
|
|
31
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
-
}
|
|
34
|
-
return to;
|
|
35
|
-
};
|
|
36
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
37
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
-
mod
|
|
44
|
-
));
|
|
45
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
-
|
|
47
|
-
export {
|
|
48
|
-
__require,
|
|
49
|
-
__glob,
|
|
50
|
-
__esm,
|
|
51
|
-
__commonJS,
|
|
52
|
-
__export,
|
|
53
|
-
__reExport,
|
|
54
|
-
__toESM,
|
|
55
|
-
__toCommonJS
|
|
56
|
-
};
|
|
57
|
-
//# sourceMappingURL=chunk-4JEXNFZZ.mjs.map
|
package/dist/chunk-4YD6WMO6.mjs
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__esm,
|
|
3
|
-
__export
|
|
4
|
-
} from "./chunk-4JEXNFZZ.mjs";
|
|
5
|
-
|
|
6
|
-
// src/builtins/sqlite-storage/filesystem-storage-provider.ts
|
|
7
|
-
var filesystem_storage_provider_exports = {};
|
|
8
|
-
__export(filesystem_storage_provider_exports, {
|
|
9
|
-
FilesystemStorageProvider: () => FilesystemStorageProvider,
|
|
10
|
-
default: () => filesystem_storage_provider_default
|
|
11
|
-
});
|
|
12
|
-
import * as fs from "fs";
|
|
13
|
-
import * as path from "path";
|
|
14
|
-
var STORAGE_LOCATION_TYPES, DEFAULT_LOCATION_SUBDIRS, FilesystemStorageProvider, filesystem_storage_provider_default;
|
|
15
|
-
var init_filesystem_storage_provider = __esm({
|
|
16
|
-
"src/builtins/sqlite-storage/filesystem-storage-provider.ts"() {
|
|
17
|
-
"use strict";
|
|
18
|
-
STORAGE_LOCATION_TYPES = [
|
|
19
|
-
"recordings-high",
|
|
20
|
-
"recordings-low",
|
|
21
|
-
"recordings-clips",
|
|
22
|
-
"event-images",
|
|
23
|
-
"models",
|
|
24
|
-
"addons-data",
|
|
25
|
-
"cache",
|
|
26
|
-
"logs"
|
|
27
|
-
];
|
|
28
|
-
DEFAULT_LOCATION_SUBDIRS = {
|
|
29
|
-
"recordings-high": "recordings-high",
|
|
30
|
-
"recordings-low": "recordings-low",
|
|
31
|
-
"recordings-clips": "recordings-clips",
|
|
32
|
-
"event-images": "event-images",
|
|
33
|
-
"models": "models",
|
|
34
|
-
"addons-data": "addons-data",
|
|
35
|
-
"cache": "/tmp/camstack-cache",
|
|
36
|
-
"logs": "logs"
|
|
37
|
-
};
|
|
38
|
-
FilesystemStorageProvider = class {
|
|
39
|
-
id = "local";
|
|
40
|
-
name = "Local Filesystem";
|
|
41
|
-
supportedLocations = [...STORAGE_LOCATION_TYPES];
|
|
42
|
-
rootPath;
|
|
43
|
-
locationPaths;
|
|
44
|
-
constructor(rootPath, overrides) {
|
|
45
|
-
this.rootPath = path.resolve(rootPath);
|
|
46
|
-
this.locationPaths = /* @__PURE__ */ new Map();
|
|
47
|
-
for (const loc of STORAGE_LOCATION_TYPES) {
|
|
48
|
-
const override = overrides?.[loc];
|
|
49
|
-
if (override) {
|
|
50
|
-
this.locationPaths.set(loc, path.resolve(override));
|
|
51
|
-
} else {
|
|
52
|
-
const subdir = DEFAULT_LOCATION_SUBDIRS[loc];
|
|
53
|
-
this.locationPaths.set(
|
|
54
|
-
loc,
|
|
55
|
-
path.isAbsolute(subdir) ? subdir : path.join(this.rootPath, subdir)
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
resolve(location, relativePath) {
|
|
61
|
-
const base = this.locationPaths.get(location);
|
|
62
|
-
if (!base) throw new Error(`Unknown storage location: ${location}`);
|
|
63
|
-
return path.join(base, relativePath);
|
|
64
|
-
}
|
|
65
|
-
async write(location, relativePath, data) {
|
|
66
|
-
const filePath = this.resolve(location, relativePath);
|
|
67
|
-
await fs.promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
68
|
-
if (Buffer.isBuffer(data)) {
|
|
69
|
-
await fs.promises.writeFile(filePath, data);
|
|
70
|
-
} else {
|
|
71
|
-
const writeStream = fs.createWriteStream(filePath);
|
|
72
|
-
await new Promise((resolve2, reject) => {
|
|
73
|
-
data.pipe(writeStream);
|
|
74
|
-
writeStream.on("finish", resolve2);
|
|
75
|
-
writeStream.on("error", reject);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async read(location, relativePath) {
|
|
80
|
-
return fs.promises.readFile(this.resolve(location, relativePath));
|
|
81
|
-
}
|
|
82
|
-
async exists(location, relativePath) {
|
|
83
|
-
try {
|
|
84
|
-
await fs.promises.access(this.resolve(location, relativePath));
|
|
85
|
-
return true;
|
|
86
|
-
} catch {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
async list(location, prefix) {
|
|
91
|
-
const base = this.locationPaths.get(location);
|
|
92
|
-
if (!base) return [];
|
|
93
|
-
const dir = prefix ? path.join(base, prefix) : base;
|
|
94
|
-
try {
|
|
95
|
-
const entries = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
96
|
-
return entries.map((e) => prefix ? `${prefix}/${e.name}` : e.name);
|
|
97
|
-
} catch {
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async delete(location, relativePath) {
|
|
102
|
-
const filePath = this.resolve(location, relativePath);
|
|
103
|
-
await fs.promises.rm(filePath, { force: true });
|
|
104
|
-
}
|
|
105
|
-
async getAvailableSpace(location) {
|
|
106
|
-
const base = this.locationPaths.get(location);
|
|
107
|
-
if (!base) return null;
|
|
108
|
-
try {
|
|
109
|
-
const stats = await fs.promises.statfs(base);
|
|
110
|
-
return stats.bavail * stats.bsize;
|
|
111
|
-
} catch {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async initialize() {
|
|
116
|
-
for (const [, dirPath] of this.locationPaths) {
|
|
117
|
-
await fs.promises.mkdir(dirPath, { recursive: true });
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async shutdown() {
|
|
121
|
-
}
|
|
122
|
-
/** Get the resolved path for a location type */
|
|
123
|
-
getLocationPath(location) {
|
|
124
|
-
const p = this.locationPaths.get(location);
|
|
125
|
-
if (!p) throw new Error(`Unknown storage location: ${location}`);
|
|
126
|
-
return p;
|
|
127
|
-
}
|
|
128
|
-
/** Get the root path */
|
|
129
|
-
getRootPath() {
|
|
130
|
-
return this.rootPath;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
filesystem_storage_provider_default = FilesystemStorageProvider;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// src/builtins/sqlite-storage/filesystem-storage.addon.ts
|
|
138
|
-
var filesystem_storage_addon_exports = {};
|
|
139
|
-
__export(filesystem_storage_addon_exports, {
|
|
140
|
-
FilesystemStorageAddon: () => FilesystemStorageAddon,
|
|
141
|
-
default: () => filesystem_storage_addon_default
|
|
142
|
-
});
|
|
143
|
-
var FilesystemStorageAddon, filesystem_storage_addon_default;
|
|
144
|
-
var init_filesystem_storage_addon = __esm({
|
|
145
|
-
"src/builtins/sqlite-storage/filesystem-storage.addon.ts"() {
|
|
146
|
-
init_filesystem_storage_provider();
|
|
147
|
-
FilesystemStorageAddon = class {
|
|
148
|
-
manifest = {
|
|
149
|
-
id: "filesystem-storage",
|
|
150
|
-
name: "Local Filesystem Storage",
|
|
151
|
-
version: "1.0.0",
|
|
152
|
-
capabilities: [{ name: "storage", mode: "collection" }]
|
|
153
|
-
};
|
|
154
|
-
provider = null;
|
|
155
|
-
currentConfig = {
|
|
156
|
-
rootPath: "camstack-data"
|
|
157
|
-
};
|
|
158
|
-
async initialize(context) {
|
|
159
|
-
const rootPath = context.addonConfig.rootPath ?? this.currentConfig.rootPath;
|
|
160
|
-
this.currentConfig.rootPath = rootPath;
|
|
161
|
-
const overrides = {};
|
|
162
|
-
for (const key of Object.keys(context.addonConfig)) {
|
|
163
|
-
if (key.startsWith("override.")) {
|
|
164
|
-
const loc = key.slice("override.".length);
|
|
165
|
-
overrides[loc] = context.addonConfig[key];
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
this.provider = new FilesystemStorageProvider(rootPath, overrides);
|
|
169
|
-
await this.provider.initialize();
|
|
170
|
-
context.logger.info(`Filesystem storage initialized at ${this.provider.getRootPath()}`);
|
|
171
|
-
}
|
|
172
|
-
async shutdown() {
|
|
173
|
-
await this.provider?.shutdown();
|
|
174
|
-
}
|
|
175
|
-
getCapabilityProvider(name) {
|
|
176
|
-
if (name === "storage" && this.provider) {
|
|
177
|
-
return this.provider;
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
getProvider() {
|
|
182
|
-
return this.provider;
|
|
183
|
-
}
|
|
184
|
-
getConfigSchema() {
|
|
185
|
-
return { sections: [] };
|
|
186
|
-
}
|
|
187
|
-
getConfig() {
|
|
188
|
-
return { ...this.currentConfig };
|
|
189
|
-
}
|
|
190
|
-
async onConfigChange(config) {
|
|
191
|
-
this.currentConfig.rootPath = config.rootPath ?? this.currentConfig.rootPath;
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
filesystem_storage_addon_default = FilesystemStorageAddon;
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
export {
|
|
199
|
-
FilesystemStorageProvider,
|
|
200
|
-
filesystem_storage_provider_exports,
|
|
201
|
-
init_filesystem_storage_provider,
|
|
202
|
-
FilesystemStorageAddon,
|
|
203
|
-
filesystem_storage_addon_default,
|
|
204
|
-
filesystem_storage_addon_exports,
|
|
205
|
-
init_filesystem_storage_addon
|
|
206
|
-
};
|
|
207
|
-
//# sourceMappingURL=chunk-4YD6WMO6.mjs.map
|