@workglow/storage 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -16
- package/dist/browser.js +80 -19
- package/dist/browser.js.map +11 -10
- package/dist/bun.js +52 -15
- package/dist/bun.js.map +14 -13
- package/dist/common.d.ts +1 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/credentials/LazyEncryptedCredentialStore.d.ts +63 -0
- package/dist/credentials/LazyEncryptedCredentialStore.d.ts.map +1 -0
- package/dist/node.js +52 -15
- package/dist/node.js.map +14 -13
- package/dist/queue/InMemoryQueueStorage.d.ts.map +1 -1
- package/dist/tabular/BaseTabularStorage.d.ts +2 -2
- package/dist/tabular/BaseTabularStorage.d.ts.map +1 -1
- package/dist/tabular/PostgresTabularStorage.d.ts.map +1 -1
- package/dist/tabular/SharedInMemoryTabularStorage.d.ts +2 -0
- package/dist/tabular/SharedInMemoryTabularStorage.d.ts.map +1 -1
- package/dist/tabular/StorageError.d.ts +0 -2
- package/dist/tabular/StorageError.d.ts.map +1 -1
- package/dist/tabular/TabularStorageRegistry.d.ts.map +1 -1
- package/dist/vector/InMemoryVectorStorage.d.ts +1 -1
- package/dist/vector/InMemoryVectorStorage.d.ts.map +1 -1
- package/dist/vector/IndexedDbVectorStorage.d.ts +1 -1
- package/dist/vector/IndexedDbVectorStorage.d.ts.map +1 -1
- package/dist/vector/PostgresVectorStorage.d.ts +1 -1
- package/dist/vector/PostgresVectorStorage.d.ts.map +1 -1
- package/dist/vector/SqliteAiVectorStorage.d.ts +1 -1
- package/dist/vector/SqliteAiVectorStorage.d.ts.map +1 -1
- package/dist/vector/SqliteVectorStorage.d.ts +1 -1
- package/dist/vector/SqliteVectorStorage.d.ts.map +1 -1
- package/package.json +12 -15
package/dist/common.d.ts
CHANGED
|
@@ -28,4 +28,5 @@ export * from "./vector/InMemoryVectorStorage";
|
|
|
28
28
|
export * from "./vector/IVectorStorage";
|
|
29
29
|
export * from "./vector/TelemetryVectorStorage";
|
|
30
30
|
export * from "./credentials/EncryptedKvCredentialStore";
|
|
31
|
+
export * from "./credentials/LazyEncryptedCredentialStore";
|
|
31
32
|
//# sourceMappingURL=common.d.ts.map
|
package/dist/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAElD,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AAExC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC;AAEpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,eAAe,CAAC;AAE9B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAEhD,cAAc,0CAA0C,CAAC"}
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAElD,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AAExC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qCAAqC,CAAC;AAEpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,eAAe,CAAC;AAE9B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAEhD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { CredentialPutOptions, ICredentialStore } from "@workglow/util";
|
|
7
|
+
import type { IKvStorage } from "../kv/IKvStorage";
|
|
8
|
+
/**
|
|
9
|
+
* An {@link ICredentialStore} wrapper that starts in a locked state and defers
|
|
10
|
+
* construction of the underlying {@link EncryptedKvCredentialStore} until
|
|
11
|
+
* {@link unlock} is called with a passphrase.
|
|
12
|
+
*
|
|
13
|
+
* **Locked behavior** (before {@link unlock}):
|
|
14
|
+
* - `get()` returns `undefined` (falls through in a {@link ChainedCredentialStore})
|
|
15
|
+
* - `has()` returns `false`
|
|
16
|
+
* - `keys()` returns `[]`
|
|
17
|
+
* - `put()` throws an error
|
|
18
|
+
* - `delete()` returns `false`
|
|
19
|
+
* - `deleteAll()` is a no-op
|
|
20
|
+
*
|
|
21
|
+
* **Unlocked behavior**: all methods delegate to the inner
|
|
22
|
+
* {@link EncryptedKvCredentialStore}.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const lazy = new LazyEncryptedCredentialStore(kvStorage);
|
|
27
|
+
* await lazy.get("key"); // undefined (locked)
|
|
28
|
+
*
|
|
29
|
+
* lazy.unlock("my-passphrase");
|
|
30
|
+
* await lazy.get("key"); // decrypted value
|
|
31
|
+
*
|
|
32
|
+
* lazy.lock(); // discards inner store
|
|
33
|
+
* await lazy.get("key"); // undefined again
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class LazyEncryptedCredentialStore implements ICredentialStore {
|
|
37
|
+
private readonly kv;
|
|
38
|
+
private inner;
|
|
39
|
+
constructor(kv: IKvStorage<string, unknown>);
|
|
40
|
+
/**
|
|
41
|
+
* Whether the store is currently unlocked and able to decrypt credentials.
|
|
42
|
+
*/
|
|
43
|
+
get isUnlocked(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Unlock the store by providing a passphrase. Creates the underlying
|
|
46
|
+
* {@link EncryptedKvCredentialStore} using the same KV backend.
|
|
47
|
+
*
|
|
48
|
+
* @throws if the passphrase is empty
|
|
49
|
+
*/
|
|
50
|
+
unlock(passphrase: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Lock the store, discarding the inner {@link EncryptedKvCredentialStore}
|
|
53
|
+
* and its derived key cache.
|
|
54
|
+
*/
|
|
55
|
+
lock(): void;
|
|
56
|
+
get(key: string): Promise<string | undefined>;
|
|
57
|
+
put(key: string, value: string, options?: CredentialPutOptions): Promise<void>;
|
|
58
|
+
delete(key: string): Promise<boolean>;
|
|
59
|
+
has(key: string): Promise<boolean>;
|
|
60
|
+
keys(): Promise<readonly string[]>;
|
|
61
|
+
deleteAll(): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=LazyEncryptedCredentialStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LazyEncryptedCredentialStore.d.ts","sourceRoot":"","sources":["../../src/credentials/LazyEncryptedCredentialStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,4BAA6B,YAAW,gBAAgB;IAGvD,OAAO,CAAC,QAAQ,CAAC,EAAE;IAF/B,OAAO,CAAC,KAAK,CAAyC;IAEtD,YAA6B,EAAE,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,EAAI;IAEhE;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;;;;OAKG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAE/B;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,CAEX;IAEK,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAGlD;IAEK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKnF;IAEK,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG1C;IAEK,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGvC;IAEK,IAAI,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAGvC;IAEK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAG/B;CACF"}
|
package/dist/node.js
CHANGED
|
@@ -14,16 +14,10 @@ import { BaseError } from "@workglow/util";
|
|
|
14
14
|
|
|
15
15
|
class StorageError extends BaseError {
|
|
16
16
|
static type = "StorageError";
|
|
17
|
-
constructor(message) {
|
|
18
|
-
super(message);
|
|
19
|
-
}
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
class StorageValidationError extends StorageError {
|
|
23
20
|
static type = "StorageValidationError";
|
|
24
|
-
constructor(message) {
|
|
25
|
-
super(message);
|
|
26
|
-
}
|
|
27
21
|
}
|
|
28
22
|
|
|
29
23
|
class StorageEmptyCriteriaError extends StorageValidationError {
|
|
@@ -124,14 +118,10 @@ class BaseTabularStorage {
|
|
|
124
118
|
}
|
|
125
119
|
}
|
|
126
120
|
if (autoGeneratedKeys.length > 1) {
|
|
127
|
-
throw new Error(`Multiple auto-generated keys detected: ${autoGeneratedKeys.join(", ")}. ` + `
|
|
121
|
+
throw new Error(`Multiple auto-generated keys detected: ${autoGeneratedKeys.join(", ")}. ` + `At most one primary key column can be auto-generated.`);
|
|
128
122
|
}
|
|
129
123
|
if (autoGeneratedKeys.length > 0) {
|
|
130
124
|
const autoGenKeyName = autoGeneratedKeys[0];
|
|
131
|
-
const firstPrimaryKey = String(primaryKeyNames[0]);
|
|
132
|
-
if (autoGenKeyName !== firstPrimaryKey) {
|
|
133
|
-
throw new Error(`Auto-generated key "${autoGenKeyName}" must be the first primary key column. ` + `Current first primary key is "${firstPrimaryKey}".`);
|
|
134
|
-
}
|
|
135
125
|
this.autoGeneratedKeyName = autoGenKeyName;
|
|
136
126
|
this.autoGeneratedKeyStrategy = this.determineGenerationStrategy(autoGenKeyName, schema.properties[autoGenKeyName]);
|
|
137
127
|
}
|
|
@@ -1117,9 +1107,7 @@ import {
|
|
|
1117
1107
|
registerInputResolver
|
|
1118
1108
|
} from "@workglow/util";
|
|
1119
1109
|
var TABULAR_REPOSITORIES = createServiceToken5("storage.tabular.repositories");
|
|
1120
|
-
|
|
1121
|
-
globalServiceRegistry.register(TABULAR_REPOSITORIES, () => new Map, true);
|
|
1122
|
-
}
|
|
1110
|
+
globalServiceRegistry.registerIfAbsent(TABULAR_REPOSITORIES, () => new Map, true);
|
|
1123
1111
|
function getGlobalTabularRepositories() {
|
|
1124
1112
|
return globalServiceRegistry.get(TABULAR_REPOSITORIES);
|
|
1125
1113
|
}
|
|
@@ -2246,6 +2234,54 @@ class EncryptedKvCredentialStore {
|
|
|
2246
2234
|
await this.kv.deleteAll();
|
|
2247
2235
|
}
|
|
2248
2236
|
}
|
|
2237
|
+
// src/credentials/LazyEncryptedCredentialStore.ts
|
|
2238
|
+
class LazyEncryptedCredentialStore {
|
|
2239
|
+
kv;
|
|
2240
|
+
inner;
|
|
2241
|
+
constructor(kv) {
|
|
2242
|
+
this.kv = kv;
|
|
2243
|
+
}
|
|
2244
|
+
get isUnlocked() {
|
|
2245
|
+
return this.inner !== undefined;
|
|
2246
|
+
}
|
|
2247
|
+
unlock(passphrase) {
|
|
2248
|
+
this.inner = new EncryptedKvCredentialStore(this.kv, passphrase);
|
|
2249
|
+
}
|
|
2250
|
+
lock() {
|
|
2251
|
+
this.inner = undefined;
|
|
2252
|
+
}
|
|
2253
|
+
async get(key) {
|
|
2254
|
+
if (!this.inner)
|
|
2255
|
+
return;
|
|
2256
|
+
return this.inner.get(key);
|
|
2257
|
+
}
|
|
2258
|
+
async put(key, value, options) {
|
|
2259
|
+
if (!this.inner) {
|
|
2260
|
+
throw new Error("Credential store is locked. Call unlock() before storing credentials.");
|
|
2261
|
+
}
|
|
2262
|
+
return this.inner.put(key, value, options);
|
|
2263
|
+
}
|
|
2264
|
+
async delete(key) {
|
|
2265
|
+
if (!this.inner)
|
|
2266
|
+
return false;
|
|
2267
|
+
return this.inner.delete(key);
|
|
2268
|
+
}
|
|
2269
|
+
async has(key) {
|
|
2270
|
+
if (!this.inner)
|
|
2271
|
+
return false;
|
|
2272
|
+
return this.inner.has(key);
|
|
2273
|
+
}
|
|
2274
|
+
async keys() {
|
|
2275
|
+
if (!this.inner)
|
|
2276
|
+
return [];
|
|
2277
|
+
return this.inner.keys();
|
|
2278
|
+
}
|
|
2279
|
+
async deleteAll() {
|
|
2280
|
+
if (!this.inner)
|
|
2281
|
+
return;
|
|
2282
|
+
return this.inner.deleteAll();
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2249
2285
|
// src/tabular/FsFolderTabularStorage.ts
|
|
2250
2286
|
import { createServiceToken as createServiceToken12, getLogger as getLogger3, makeFingerprint as makeFingerprint5, sleep as sleep3, uuid4 as uuid43 } from "@workglow/util";
|
|
2251
2287
|
import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
@@ -8291,6 +8327,7 @@ export {
|
|
|
8291
8327
|
POSTGRES_KV_REPOSITORY,
|
|
8292
8328
|
MEMORY_TABULAR_REPOSITORY,
|
|
8293
8329
|
MEMORY_KV_REPOSITORY,
|
|
8330
|
+
LazyEncryptedCredentialStore,
|
|
8294
8331
|
KvViaTabularStorage,
|
|
8295
8332
|
KvStorage,
|
|
8296
8333
|
KV_REPOSITORY,
|
|
@@ -8329,4 +8366,4 @@ export {
|
|
|
8329
8366
|
BaseTabularStorage
|
|
8330
8367
|
};
|
|
8331
8368
|
|
|
8332
|
-
//# debugId=
|
|
8369
|
+
//# debugId=9CB3D41A4B06ADAC64756E2164756E21
|