@workglow/storage 0.0.52
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/LICENSE +201 -0
- package/README.md +1015 -0
- package/dist/browser.js +2635 -0
- package/dist/browser.js.map +27 -0
- package/dist/bun.js +3880 -0
- package/dist/bun.js.map +35 -0
- package/dist/common-server.d.ts +23 -0
- package/dist/common-server.d.ts.map +1 -0
- package/dist/common.d.ts +16 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/kv/FsFolderJsonKvRepository.d.ts +27 -0
- package/dist/kv/FsFolderJsonKvRepository.d.ts.map +1 -0
- package/dist/kv/FsFolderKvRepository.d.ts +74 -0
- package/dist/kv/FsFolderKvRepository.d.ts.map +1 -0
- package/dist/kv/IKvRepository.d.ts +65 -0
- package/dist/kv/IKvRepository.d.ts.map +1 -0
- package/dist/kv/InMemoryKvRepository.d.ts +26 -0
- package/dist/kv/InMemoryKvRepository.d.ts.map +1 -0
- package/dist/kv/IndexedDbKvRepository.d.ts +27 -0
- package/dist/kv/IndexedDbKvRepository.d.ts.map +1 -0
- package/dist/kv/KvRepository.d.ts +109 -0
- package/dist/kv/KvRepository.d.ts.map +1 -0
- package/dist/kv/KvViaTabularRepository.d.ts +64 -0
- package/dist/kv/KvViaTabularRepository.d.ts.map +1 -0
- package/dist/kv/PostgresKvRepository.d.ts +28 -0
- package/dist/kv/PostgresKvRepository.d.ts.map +1 -0
- package/dist/kv/SqliteKvRepository.d.ts +28 -0
- package/dist/kv/SqliteKvRepository.d.ts.map +1 -0
- package/dist/kv/SupabaseKvRepository.d.ts +34 -0
- package/dist/kv/SupabaseKvRepository.d.ts.map +1 -0
- package/dist/node.js +3879 -0
- package/dist/node.js.map +35 -0
- package/dist/queue/IQueueStorage.d.ts +125 -0
- package/dist/queue/IQueueStorage.d.ts.map +1 -0
- package/dist/queue/InMemoryQueueStorage.d.ts +109 -0
- package/dist/queue/InMemoryQueueStorage.d.ts.map +1 -0
- package/dist/queue/IndexedDbQueueStorage.d.ts +89 -0
- package/dist/queue/IndexedDbQueueStorage.d.ts.map +1 -0
- package/dist/queue/PostgresQueueStorage.d.ts +92 -0
- package/dist/queue/PostgresQueueStorage.d.ts.map +1 -0
- package/dist/queue/SqliteQueueStorage.d.ts +116 -0
- package/dist/queue/SqliteQueueStorage.d.ts.map +1 -0
- package/dist/queue/SupabaseQueueStorage.d.ts +93 -0
- package/dist/queue/SupabaseQueueStorage.d.ts.map +1 -0
- package/dist/tabular/BaseSqlTabularRepository.d.ts +94 -0
- package/dist/tabular/BaseSqlTabularRepository.d.ts.map +1 -0
- package/dist/tabular/CachedTabularRepository.d.ts +110 -0
- package/dist/tabular/CachedTabularRepository.d.ts.map +1 -0
- package/dist/tabular/FsFolderTabularRepository.d.ts +92 -0
- package/dist/tabular/FsFolderTabularRepository.d.ts.map +1 -0
- package/dist/tabular/ITabularRepository.d.ts +52 -0
- package/dist/tabular/ITabularRepository.d.ts.map +1 -0
- package/dist/tabular/InMemoryTabularRepository.d.ts +93 -0
- package/dist/tabular/InMemoryTabularRepository.d.ts.map +1 -0
- package/dist/tabular/IndexedDbTabularRepository.d.ts +100 -0
- package/dist/tabular/IndexedDbTabularRepository.d.ts.map +1 -0
- package/dist/tabular/PostgresTabularRepository.d.ts +133 -0
- package/dist/tabular/PostgresTabularRepository.d.ts.map +1 -0
- package/dist/tabular/SharedInMemoryTabularRepository.d.ts +126 -0
- package/dist/tabular/SharedInMemoryTabularRepository.d.ts.map +1 -0
- package/dist/tabular/SqliteTabularRepository.d.ts +110 -0
- package/dist/tabular/SqliteTabularRepository.d.ts.map +1 -0
- package/dist/tabular/SupabaseTabularRepository.d.ts +132 -0
- package/dist/tabular/SupabaseTabularRepository.d.ts.map +1 -0
- package/dist/tabular/TabularRepository.d.ts +123 -0
- package/dist/tabular/TabularRepository.d.ts.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util/IndexedDbTable.d.ts +40 -0
- package/dist/util/IndexedDbTable.d.ts.map +1 -0
- package/package.json +60 -0
- package/src/kv/README.md +159 -0
- package/src/queue/README.md +41 -0
- package/src/tabular/README.md +298 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export * from "./common";
|
|
7
|
+
export * from "./tabular/FsFolderTabularRepository";
|
|
8
|
+
export * from "./tabular/PostgresTabularRepository";
|
|
9
|
+
export * from "./tabular/SqliteTabularRepository";
|
|
10
|
+
export * from "./tabular/SupabaseTabularRepository";
|
|
11
|
+
export * from "./kv/FsFolderJsonKvRepository";
|
|
12
|
+
export * from "./kv/FsFolderKvRepository";
|
|
13
|
+
export * from "./kv/PostgresKvRepository";
|
|
14
|
+
export * from "./kv/SqliteKvRepository";
|
|
15
|
+
export * from "./kv/SupabaseKvRepository";
|
|
16
|
+
export * from "./queue/PostgresQueueStorage";
|
|
17
|
+
export * from "./queue/SqliteQueueStorage";
|
|
18
|
+
export * from "./queue/SupabaseQueueStorage";
|
|
19
|
+
export * from "./kv/IndexedDbKvRepository";
|
|
20
|
+
export * from "./queue/IndexedDbQueueStorage";
|
|
21
|
+
export * from "./tabular/IndexedDbTabularRepository";
|
|
22
|
+
export * from "./util/IndexedDbTable";
|
|
23
|
+
//# sourceMappingURL=common-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-server.d.ts","sourceRoot":"","sources":["../src/common-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AAEzB,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AAEpD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAE1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAG7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC"}
|
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export * from "./tabular/CachedTabularRepository";
|
|
7
|
+
export * from "./tabular/InMemoryTabularRepository";
|
|
8
|
+
export * from "./tabular/ITabularRepository";
|
|
9
|
+
export * from "./tabular/TabularRepository";
|
|
10
|
+
export * from "./kv/IKvRepository";
|
|
11
|
+
export * from "./kv/InMemoryKvRepository";
|
|
12
|
+
export * from "./kv/KvRepository";
|
|
13
|
+
export * from "./kv/KvViaTabularRepository";
|
|
14
|
+
export * from "./queue/InMemoryQueueStorage";
|
|
15
|
+
export * from "./queue/IQueueStorage";
|
|
16
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { JsonSchema } from "@workglow/util";
|
|
7
|
+
import { FsFolderTabularRepository } from "../tabular/FsFolderTabularRepository";
|
|
8
|
+
import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvRepository } from "./IKvRepository";
|
|
9
|
+
import { KvViaTabularRepository } from "./KvViaTabularRepository";
|
|
10
|
+
export declare const FS_FOLDER_JSON_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvRepository<string, any, any>>;
|
|
11
|
+
/**
|
|
12
|
+
* A key-value repository implementation that stores values as JSON files in a specified folder.
|
|
13
|
+
* Uses a tabular repository abstraction for file-based persistence.
|
|
14
|
+
*
|
|
15
|
+
* @template Key - The type of the primary key
|
|
16
|
+
* @template Value - The type of the value being stored
|
|
17
|
+
* @template Combined - Combined type of Key & Value
|
|
18
|
+
*/
|
|
19
|
+
export declare class FsFolderJsonKvRepository extends KvViaTabularRepository {
|
|
20
|
+
folderPath: string;
|
|
21
|
+
tabularRepository: FsFolderTabularRepository<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new KvRepository instance
|
|
24
|
+
*/
|
|
25
|
+
constructor(folderPath: string, keySchema?: JsonSchema, valueSchema?: JsonSchema);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=FsFolderJsonKvRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsFolderJsonKvRepository.d.ts","sourceRoot":"","sources":["../../src/kv/FsFolderJsonKvRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,4BAA4B,wEAExC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,sBAAsB;IAUzD,UAAU,EAAE,MAAM;IATpB,iBAAiB,EAAE,yBAAyB,CACjD,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;OAEG;gBAEM,UAAU,EAAE,MAAM,EACzB,SAAS,GAAE,UAA+B,EAC1C,WAAW,GAAE,UAAe;CAS/B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { JsonSchema } from "@workglow/util";
|
|
7
|
+
import { IKvRepository } from "./IKvRepository";
|
|
8
|
+
import { KvRepository } from "./KvRepository";
|
|
9
|
+
export declare const FS_FOLDER_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvRepository<string, any, any>>;
|
|
10
|
+
/**
|
|
11
|
+
* A key-value repository implementation that stores each value as a file in a specified folder.
|
|
12
|
+
* Uses the file system for persistence, with each key mapped to a file path.
|
|
13
|
+
*
|
|
14
|
+
* @template Key - The type of the primary key
|
|
15
|
+
* @template Value - The type of the value being stored
|
|
16
|
+
* @template Combined - Combined type of Key & Value
|
|
17
|
+
*/
|
|
18
|
+
export declare class FsFolderKvRepository<Key extends string = string, Value extends any = any, Combined = {
|
|
19
|
+
key: Key;
|
|
20
|
+
value: Value;
|
|
21
|
+
}> extends KvRepository<Key, Value, Combined> {
|
|
22
|
+
folderPath: string;
|
|
23
|
+
pathWriter: (key: Key) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new KvRepository instance
|
|
26
|
+
*/
|
|
27
|
+
constructor(folderPath: string, pathWriter: (key: Key) => string, keySchema?: JsonSchema, valueSchema?: JsonSchema);
|
|
28
|
+
/**
|
|
29
|
+
* Sets up the directory for the repository (creates directory)
|
|
30
|
+
*/
|
|
31
|
+
private setupDirectory;
|
|
32
|
+
/**
|
|
33
|
+
* Stores a row in the repository.
|
|
34
|
+
* @param key - The primary key
|
|
35
|
+
* @param value - The value to store
|
|
36
|
+
*/
|
|
37
|
+
put(key: Key, value: Value): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Stores multiple rows in the repository in a bulk operation.
|
|
40
|
+
* @param items - Array of key-value pairs to store
|
|
41
|
+
*/
|
|
42
|
+
putBulk(items: Array<{
|
|
43
|
+
key: Key;
|
|
44
|
+
value: Value;
|
|
45
|
+
}>): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves a value by its key.
|
|
48
|
+
* This is a convenience method that automatically converts simple types to structured format if using default schema.
|
|
49
|
+
*
|
|
50
|
+
* @param key - Primary key to look up (basic key like default schema)
|
|
51
|
+
* @returns The stored value or undefined if not found
|
|
52
|
+
*/
|
|
53
|
+
get(key: Key): Promise<Value | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* Deletes a row from the repository.
|
|
56
|
+
* @param key - The primary key of the row to delete
|
|
57
|
+
*/
|
|
58
|
+
delete(key: Key): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves all rows from the repository.
|
|
61
|
+
* @returns An array of all rows in the repository or undefined if empty
|
|
62
|
+
*/
|
|
63
|
+
getAll(): Promise<Combined[] | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* Deletes all rows from the repository.
|
|
66
|
+
*/
|
|
67
|
+
deleteAll(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Retrieves the number of rows in the repository.
|
|
70
|
+
* @returns The number of rows in the repository
|
|
71
|
+
*/
|
|
72
|
+
size(): Promise<number>;
|
|
73
|
+
}
|
|
74
|
+
//# s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,CAAC;IAsCtD;;;OAGG;IACU,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C;;;OAGG;IACU,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE,GAAG,SAAS,CAAC;IAItD;;OAEG;IACU,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAKvC;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;CAGrC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventParameters } from "@workglow/util";
|
|
7
|
+
import { JSONValue } from "../tabular/ITabularRepository";
|
|
8
|
+
/**
|
|
9
|
+
* Default schema types for simple string row data
|
|
10
|
+
*/
|
|
11
|
+
export declare const DefaultKeyValueSchema: {
|
|
12
|
+
readonly type: "object";
|
|
13
|
+
readonly properties: {
|
|
14
|
+
readonly key: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
};
|
|
17
|
+
readonly value: {};
|
|
18
|
+
};
|
|
19
|
+
readonly additionalProperties: false;
|
|
20
|
+
};
|
|
21
|
+
export declare const DefaultKeyValueKey: readonly ["key"];
|
|
22
|
+
/**
|
|
23
|
+
* Type definitions for kv repository events
|
|
24
|
+
*/
|
|
25
|
+
export type KvEventListeners<Key, Value, Combined> = {
|
|
26
|
+
put: (key: Key, value: Value) => void;
|
|
27
|
+
get: (key: Key, value: Value | undefined) => void;
|
|
28
|
+
getAll: (results: Combined[] | undefined) => void;
|
|
29
|
+
delete: (key: unknown) => void;
|
|
30
|
+
deleteall: () => void;
|
|
31
|
+
};
|
|
32
|
+
export type KvEventName = keyof KvEventListeners<any, any, any>;
|
|
33
|
+
export type KvEventListener<Event extends KvEventName, Key, Value, Combined> = KvEventListeners<Key, Value, Combined>[Event];
|
|
34
|
+
export type KvEventParameters<Event extends KvEventName, Key, Value, Combined> = EventParameters<KvEventListeners<Key, Value, Combined>, Event>;
|
|
35
|
+
/**
|
|
36
|
+
* Interface defining the contract for kv storage repositories.
|
|
37
|
+
* Provides a flexible interface for storing and retrieving data with typed
|
|
38
|
+
* primary keys and values, and supports compound keys and partial key lookup.
|
|
39
|
+
*
|
|
40
|
+
* @typeParam Key - Type for the primary key
|
|
41
|
+
* @typeParam Value - Type for the value struct re
|
|
42
|
+
* @typeParam Combined - Combined type of Key & Value
|
|
43
|
+
*/
|
|
44
|
+
export interface IKvRepository<Key extends string | number = string, Value extends any = any, Combined = {
|
|
45
|
+
key: Key;
|
|
46
|
+
value: Value;
|
|
47
|
+
}> {
|
|
48
|
+
put(key: Key, value: Value): Promise<void>;
|
|
49
|
+
putBulk(items: Array<{
|
|
50
|
+
key: Key;
|
|
51
|
+
value: Value;
|
|
52
|
+
}>): Promise<void>;
|
|
53
|
+
get(key: Key): Promise<Value | undefined>;
|
|
54
|
+
delete(key: Key): Promise<void>;
|
|
55
|
+
getAll(): Promise<Combined[] | undefined>;
|
|
56
|
+
deleteAll(): Promise<void>;
|
|
57
|
+
size(): Promise<number>;
|
|
58
|
+
getObjectAsIdString(object: JSONValue): Promise<string>;
|
|
59
|
+
on<Event extends KvEventName>(name: Event, fn: KvEventListener<Event, Key, Value, Combined>): void;
|
|
60
|
+
off<Event extends KvEventName>(name: Event, fn: KvEventListener<Event, Key, Value, Combined>): void;
|
|
61
|
+
emit<Event extends KvEventName>(name: Event, ...args: KvEventParameters<Event, Key, Value, Combined>): void;
|
|
62
|
+
once<Event extends KvEventName>(name: Event, fn: KvEventListener<Event, Key, Value, Combined>): void;
|
|
63
|
+
waitOn<Event extends KvEventName>(name: Event): Promise<KvEventParameters<Event, Key, Value, Combined>>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=IKvRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IKv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AG,EAAE,KAAK,EAAE,QAAQ,CAAC,GACtD,IAAI,CAAC;IACR,IAAI,CAAC,KAAK,SAAS,WAAW,EAC5B,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,GAC/C,IAAI,CAAC;IACR,MAAM,CAAC,KAAK,SAAS,WAAW,EAC9B,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;CAC5D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { JsonSchema } from "@workglow/util";
|
|
7
|
+
import { InMemoryTabularRepository } from "../tabular/InMemoryTabularRepository";
|
|
8
|
+
import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvRepository } from "./IKvRepository";
|
|
9
|
+
import { KvViaTabularRepository } from "./KvViaTabularRepository";
|
|
10
|
+
export declare const MEMORY_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvRepository<string, any, any>>;
|
|
11
|
+
/**
|
|
12
|
+
* An in-memory key-value repository implementation for fast, ephemeral storage.
|
|
13
|
+
* Uses a tabular repository abstraction for in-memory persistence.
|
|
14
|
+
*
|
|
15
|
+
* @template Key - The type of the primary key
|
|
16
|
+
* @template Value - The type of the value being stored
|
|
17
|
+
* @template Combined - Combined type of Key & Value
|
|
18
|
+
*/
|
|
19
|
+
export declare class InMemoryKvRepository extends KvViaTabularRepository {
|
|
20
|
+
tabularRepository: InMemoryTabularRepository<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new KvRepository instance
|
|
23
|
+
*/
|
|
24
|
+
constructor(keySchema?: JsonSchema, valueSchema?: JsonSchema);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=InMemoryKvRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InMemoryKvRepository.d.ts","sourceRoot":"","sources":["../../src/kv/InMemoryKvRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,oBAAoB,wEAEhC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,sBAAsB;IACvD,iBAAiB,EAAE,yBAAyB,CACjD,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;OAEG;gBACS,SAAS,GAAE,UAA+B,EAAE,WAAW,GAAE,UAAe;CAOrF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { JsonSchema } from "@workglow/util";
|
|
7
|
+
import { IndexedDbTabularRepository } from "../tabular/IndexedDbTabularRepository";
|
|
8
|
+
import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvRepository } from "./IKvRepository";
|
|
9
|
+
import { KvViaTabularRepository } from "./KvViaTabularRepository";
|
|
10
|
+
export declare const IDB_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvRepository<string, any, any>>;
|
|
11
|
+
/**
|
|
12
|
+
* A key-value repository implementation that uses IndexedDB for persistent storage in the browser.
|
|
13
|
+
* Leverages a tabular repository abstraction for IndexedDB operations.
|
|
14
|
+
*
|
|
15
|
+
* @template Key - The type of the primary key
|
|
16
|
+
* @template Value - The type of the value being stored
|
|
17
|
+
* @template Combined - Combined type of Key & Value
|
|
18
|
+
*/
|
|
19
|
+
export declare class IndexedDbKvRepository extends KvViaTabularRepository {
|
|
20
|
+
dbName: string;
|
|
21
|
+
tabularRepository: IndexedDbTabularRepository<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new KvRepository instance
|
|
24
|
+
*/
|
|
25
|
+
constructor(dbName: string, keySchema?: JsonSchema, valueSchema?: JsonSchema);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=IndexedDbKvRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexedDbKvRepository.d.ts","sourceRoot":"","sources":["../../src/kv/IndexedDbKvRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,iBAAiB,wEAE7B,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,qBAAsB,SAAQ,sBAAsB;IAUtD,MAAM,EAAE,MAAM;IAThB,iBAAiB,EAAE,0BAA0B,CAClD,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;OAEG;gBAEM,MAAM,EAAE,MAAM,EACrB,SAAS,GAAE,UAA+B,EAC1C,WAAW,GAAE,UAAe;CAS/B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventEmitter, JsonSchema } from "@workglow/util";
|
|
7
|
+
import { JSONValue } from "../tabular/ITabularRepository";
|
|
8
|
+
import { IKvRepository, KvEventListener, KvEventListeners, KvEventName, KvEventParameters } from "./IKvRepository";
|
|
9
|
+
export declare const KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvRepository<any, any, any>>;
|
|
10
|
+
/**
|
|
11
|
+
* Abstract base class for key-value storage repositories.
|
|
12
|
+
* Has a basic event emitter for listening to repository events.
|
|
13
|
+
*
|
|
14
|
+
* @template Key - The type of the primary key
|
|
15
|
+
* @template Value - The type of the value being stored
|
|
16
|
+
* @template Combined - Combined type of Key & Value
|
|
17
|
+
*/
|
|
18
|
+
export declare abstract class KvRepository<Key extends string = string, Value extends any = any, Combined = {
|
|
19
|
+
key: Key;
|
|
20
|
+
value: Value;
|
|
21
|
+
}> implements IKvRepository<Key, Value, Combined> {
|
|
22
|
+
keySchema: JsonSchema;
|
|
23
|
+
valueSchema: JsonSchema;
|
|
24
|
+
/** Event emitter for repository events */
|
|
25
|
+
protected events: EventEmitter<KvEventListeners<Key, Value, Combined>>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new KvRepository instance
|
|
28
|
+
*/
|
|
29
|
+
constructor(keySchema?: JsonSchema, valueSchema?: JsonSchema);
|
|
30
|
+
/**
|
|
31
|
+
* Stores a row in the repository.
|
|
32
|
+
* @param key - The primary key
|
|
33
|
+
* @param value - The value to store
|
|
34
|
+
*/
|
|
35
|
+
abstract put(key: Key, value: Value): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Stores multiple rows in the repository in a bulk operation.
|
|
38
|
+
* @param items - Array of key-value pairs to store
|
|
39
|
+
*/
|
|
40
|
+
abstract putBulk(items: Array<{
|
|
41
|
+
key: Key;
|
|
42
|
+
value: Value;
|
|
43
|
+
}>): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves a value by its key.
|
|
46
|
+
* This is a convenience method that automatically converts simple types to structured format if using default schema.
|
|
47
|
+
*
|
|
48
|
+
* @param key - Primary key to look up (basic key like default schema)
|
|
49
|
+
* @returns The stored value or undefined if not found
|
|
50
|
+
*/
|
|
51
|
+
abstract get(key: Key): Promise<Value | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Deletes a row from the repository.
|
|
54
|
+
* @param key - The primary key of the row to delete
|
|
55
|
+
*/
|
|
56
|
+
abstract delete(key: Key): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves all rows from the repository.
|
|
59
|
+
* @returns An array of all rows in the repository or undefined if empty
|
|
60
|
+
*/
|
|
61
|
+
abstract getAll(): Promise<Combined[] | undefined>;
|
|
62
|
+
/**
|
|
63
|
+
* Deletes all rows from the repository.
|
|
64
|
+
*/
|
|
65
|
+
abstract deleteAll(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the number of rows in the repository.
|
|
68
|
+
* @returns The number of rows in the repository
|
|
69
|
+
*/
|
|
70
|
+
abstract size(): Promise<number>;
|
|
71
|
+
/**
|
|
72
|
+
* Generates a consistent string identifier for a given key.
|
|
73
|
+
*
|
|
74
|
+
* @param object - Object to convert
|
|
75
|
+
* @returns Promise resolving to a string fingerprint of the object for use as an id
|
|
76
|
+
*/
|
|
77
|
+
getObjectAsIdString(object: JSONValue): Promise<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Adds an event listener for a specific event
|
|
80
|
+
* @param name The name of the event to listen for
|
|
81
|
+
* @param fn The callback function to execute when the event occurs
|
|
82
|
+
*/
|
|
83
|
+
on<Event extends KvEventName>(name: Event, fn: KvEventListener<Event, Key, Value, Combined>): void;
|
|
84
|
+
/**
|
|
85
|
+
* Removes an event listener for a specific event
|
|
86
|
+
* @param name The name of the event to remove the listener from
|
|
87
|
+
* @param fn The callback function to remove
|
|
88
|
+
*/
|
|
89
|
+
off<Event extends KvEventName>(name: Event, fn: KvEventListener<Event, Key, Value, Combined>): void;
|
|
90
|
+
/**
|
|
91
|
+
* Adds an event listener that will only be called once
|
|
92
|
+
* @param name The name of the event to listen for
|
|
93
|
+
* @param fn The callback function to execute when the event occurs
|
|
94
|
+
*/
|
|
95
|
+
once<Event extends KvEventName>(name: Event, fn: KvEventListener<Event, Key, Value, Combined>): void;
|
|
96
|
+
/**
|
|
97
|
+
* Emits an event with the specified name and arguments
|
|
98
|
+
* @param name The name of the event to emit
|
|
99
|
+
* @param args The arguments to pass to the event listeners
|
|
100
|
+
*/
|
|
101
|
+
emit<Event extends KvEventName>(name: Event, ...args: KvEventParameters<Event, Key, Value, Combined>): void;
|
|
102
|
+
/**
|
|
103
|
+
* Returns when the event was emitted (promise form of once)
|
|
104
|
+
* @param name The name of the event to check
|
|
105
|
+
* @returns true if the event has listeners, false otherwise
|
|
106
|
+
*/
|
|
107
|
+
waitOn<Event extends KvEventName>(name: Event): Promise<KvEventParameters<Event, Key, Value, Combined>>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=KvRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KvRepository.d.ts","sourceRoot":"","sources":["../../src/kv/KvRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,YAAY,EAAE,UAAU,EAAmB,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EACH,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACpB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,aAAa,qEACgD,CAAC;AAE3E;;;;;;;GAOG;AACH,8BAAsB,YAAY,CAChC,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,KAAK,SAAS,GAAG,GAAG,GAAG,EACvB,QAAQ,GAAG;IAAE,GAAG,EAAE,GAAG,CA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;OAIG;IACH,GAAG,CAAC,KAAK,SAAS,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC;IAI5F;;;;OAIG;IACH,IAAI,CAAC,KAAK,SAAS,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC;IAI7F;;;;OAIG;IACH,IAAI,CAAC,KAAK,SAAS,WAAW,EAC5B,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC;IAKzD;;;;OAIG;IACH,MAAM,CAAC,KAAK,SAAS,WAAW,EAC9B,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;CAG3D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { TabularRepository } from "../tabular/TabularRepository";
|
|
7
|
+
import { DefaultKeyValueKey, DefaultKeyValueSchema } from "./IKvRepository";
|
|
8
|
+
import { KvRepository } from "./KvRepository";
|
|
9
|
+
/**
|
|
10
|
+
* Abstract base class for key-value storage repositories that uses a tabular repository for storage.
|
|
11
|
+
* Has a basic event emitter for listening to repository events.
|
|
12
|
+
*
|
|
13
|
+
* @template Key - The type of the primary key
|
|
14
|
+
* @template Value - The type of the value being stored
|
|
15
|
+
* @template Combined - Combined type of Key & Value
|
|
16
|
+
*/
|
|
17
|
+
export declare abstract class KvViaTabularRepository<Key extends string = string, Value extends any = any, Combined = {
|
|
18
|
+
key: Key;
|
|
19
|
+
value: Value;
|
|
20
|
+
}> extends KvRepository<Key, Value, Combined> {
|
|
21
|
+
abstract tabularRepository: TabularRepository<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
|
|
22
|
+
/**
|
|
23
|
+
* Stores a row in the repository.
|
|
24
|
+
* @param key - The primary key
|
|
25
|
+
* @param value - The value to store
|
|
26
|
+
*/
|
|
27
|
+
put(key: Key, value: Value): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Stores multiple rows in the repository in a bulk operation.
|
|
30
|
+
* @param items - Array of key-value pairs to store
|
|
31
|
+
*/
|
|
32
|
+
putBulk(items: Array<{
|
|
33
|
+
key: Key;
|
|
34
|
+
value: Value;
|
|
35
|
+
}>): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a value by its key.
|
|
38
|
+
* This is a convenience method that automatically converts simple types to structured format if using default schema.
|
|
39
|
+
*
|
|
40
|
+
* @param key - Primary key to look up (basic key like default schema)
|
|
41
|
+
* @returns The stored value or undefined if not found
|
|
42
|
+
*/
|
|
43
|
+
get(key: Key): Promise<Value | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Deletes a row from the repository.
|
|
46
|
+
* @param key - The primary key of the row to delete
|
|
47
|
+
*/
|
|
48
|
+
delete(key: Key): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves all rows from the repository.
|
|
51
|
+
* @returns An array of all rows in the repository or undefined if empty
|
|
52
|
+
*/
|
|
53
|
+
getAll(): Promise<Combined[] | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* Deletes all rows from the repository.
|
|
56
|
+
*/
|
|
57
|
+
deleteAll(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves the number of rows in the repository.
|
|
60
|
+
* @returns The number of rows in the repository
|
|
61
|
+
*/
|
|
62
|
+
size(): Promise<number>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=KvViaTabularRepository.d.ts.map
|
|
@@ -0,0 +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C;IAIvC;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;CAGrC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { JsonSchema } from "@workglow/util";
|
|
7
|
+
import { PostgresTabularRepository } from "../tabular/PostgresTabularRepository";
|
|
8
|
+
import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvRepository } from "./IKvRepository";
|
|
9
|
+
import { KvViaTabularRepository } from "./KvViaTabularRepository";
|
|
10
|
+
export declare const POSTGRES_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvRepository<string, any, any>>;
|
|
11
|
+
/**
|
|
12
|
+
* A key-value repository implementation that uses PostgreSQL for persistent storage.
|
|
13
|
+
* Leverages a tabular repository abstraction for PostgreSQL operations.
|
|
14
|
+
*
|
|
15
|
+
* @template Key - The type of the primary key
|
|
16
|
+
* @template Value - The type of the value being stored
|
|
17
|
+
* @template Combined - Combined type of Key & Value
|
|
18
|
+
*/
|
|
19
|
+
export declare class PostgresKvRepository extends KvViaTabularRepository {
|
|
20
|
+
db: any;
|
|
21
|
+
dbName: string;
|
|
22
|
+
tabularRepository: PostgresTabularRepository<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new KvRepository instance
|
|
25
|
+
*/
|
|
26
|
+
constructor(db: any, dbName: string, keySchema?: JsonSchema, valueSchema?: JsonSchema);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=PostgresKvRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresKvRepository.d.ts","sourceRoot":"","sources":["../../src/kv/PostgresKvRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,sBAAsB,wEAElC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,sBAAsB;IAUrD,EAAE,EAAE,GAAG;IACP,MAAM,EAAE,MAAM;IAVhB,iBAAiB,EAAE,yBAAyB,CACjD,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;OAEG;gBAEM,EAAE,EAAE,GAAG,EACP,MAAM,EAAE,MAAM,EACrB,SAAS,GAAE,UAA+B,EAC1C,WAAW,GAAE,UAAe;CAU/B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { JsonSchema } from "@workglow/util";
|
|
7
|
+
import { SqliteTabularRepository } from "../tabular/SqliteTabularRepository";
|
|
8
|
+
import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvRepository } from "./IKvRepository";
|
|
9
|
+
import { KvViaTabularRepository } from "./KvViaTabularRepository";
|
|
10
|
+
export declare const SQLITE_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvRepository<string, any, any>>;
|
|
11
|
+
/**
|
|
12
|
+
* A key-value repository implementation that uses SQLite for persistent storage.
|
|
13
|
+
* Leverages a tabular repository abstraction for SQLite operations.
|
|
14
|
+
*
|
|
15
|
+
* @template Key - The type of the primary key
|
|
16
|
+
* @template Value - The type of the value being stored
|
|
17
|
+
* @template Combined - Combined type of Key & Value
|
|
18
|
+
*/
|
|
19
|
+
export declare class SqliteKvRepository extends KvViaTabularRepository {
|
|
20
|
+
db: any;
|
|
21
|
+
dbName: string;
|
|
22
|
+
tabularRepository: SqliteTabularRepository<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new KvRepository instance
|
|
25
|
+
*/
|
|
26
|
+
constructor(db: any, dbName: string, keySchema?: JsonSchema, valueSchema?: JsonSchema);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=SqliteKvRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqliteKvRepository.d.ts","sourceRoot":"","sources":["../../src/kv/SqliteKvRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,oBAAoB,wEAEhC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,sBAAsB;IAUnD,EAAE,EAAE,GAAG;IACP,MAAM,EAAE,MAAM;IAVhB,iBAAiB,EAAE,uBAAuB,CAC/C,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;OAEG;gBAEM,EAAE,EAAE,GAAG,EACP,MAAM,EAAE,MAAM,EACrB,SAAS,GAAE,UAA+B,EAC1C,WAAW,GAAE,UAAe;CAU/B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
7
|
+
import { JsonSchema } from "@workglow/util";
|
|
8
|
+
import { SupabaseTabularRepository } from "../tabular/SupabaseTabularRepository";
|
|
9
|
+
import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvRepository } from "./IKvRepository";
|
|
10
|
+
import { KvViaTabularRepository } from "./KvViaTabularRepository";
|
|
11
|
+
export declare const SUPABASE_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvRepository<string, any, any>>;
|
|
12
|
+
/**
|
|
13
|
+
* A key-value repository implementation that uses Supabase for persistent storage.
|
|
14
|
+
* Leverages a tabular repository abstraction for Supabase operations.
|
|
15
|
+
*
|
|
16
|
+
* @template Key - The type of the primary key
|
|
17
|
+
* @template Value - The type of the value being stored
|
|
18
|
+
* @template Combined - Combined type of Key & Value
|
|
19
|
+
*/
|
|
20
|
+
export declare class SupabaseKvRepository extends KvViaTabularRepository {
|
|
21
|
+
client: SupabaseClient;
|
|
22
|
+
tableName: string;
|
|
23
|
+
tabularRepository: SupabaseTabularRepository<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new SupabaseKvRepository instance
|
|
26
|
+
*
|
|
27
|
+
* @param client - Supabase client instance
|
|
28
|
+
* @param tableName - Name of the table to store data
|
|
29
|
+
* @param keySchema - Schema for the key type (defaults to string)
|
|
30
|
+
* @param valueSchema - Schema for the value type (defaults to any)
|
|
31
|
+
*/
|
|
32
|
+
constructor(client: SupabaseClient, tableName: string, keySchema?: JsonSchema, valueSchema?: JsonSchema, tabularRepository?: SupabaseTabularRepository<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=SupabaseKvRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupabaseKvRepository.d.ts","sourceRoot":"","sources":["../../src/kv/SupabaseKvRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAsB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,sBAAsB,wEAElC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,sBAAsB;IAerD,MAAM,EAAE,cAAc;IACtB,SAAS,EAAE,MAAM;IAfnB,iBAAiB,EAAE,yBAAyB,CACjD,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;;;;;;OAOG;gBAEM,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACxB,SAAS,GAAE,UAA+B,EAC1C,WAAW,GAAE,UAAe,EAC5B,iBAAiB,CAAC,EAAE,yBAAyB,CAC3C,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B;CAOJ"}
|