@workglow/storage 0.2.26 → 0.2.28

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.
Files changed (94) hide show
  1. package/dist/browser.d.ts +0 -10
  2. package/dist/browser.d.ts.map +1 -1
  3. package/dist/browser.js +407 -4002
  4. package/dist/browser.js.map +8 -24
  5. package/dist/bun.js +496 -6711
  6. package/dist/bun.js.map +8 -34
  7. package/dist/common-server.d.ts +1 -21
  8. package/dist/common-server.d.ts.map +1 -1
  9. package/dist/common.d.ts +1 -6
  10. package/dist/common.d.ts.map +1 -1
  11. package/dist/node.js +496 -6712
  12. package/dist/node.js.map +8 -34
  13. package/dist/tabular/SharedInMemoryTabularStorage.d.ts +2 -1
  14. package/dist/tabular/SharedInMemoryTabularStorage.d.ts.map +1 -1
  15. package/package.json +5 -71
  16. package/dist/kv/IndexedDbKvStorage.d.ts +0 -27
  17. package/dist/kv/IndexedDbKvStorage.d.ts.map +0 -1
  18. package/dist/kv/PostgresKvStorage.d.ts +0 -28
  19. package/dist/kv/PostgresKvStorage.d.ts.map +0 -1
  20. package/dist/kv/SqliteKvStorage.d.ts +0 -28
  21. package/dist/kv/SqliteKvStorage.d.ts.map +0 -1
  22. package/dist/kv/SupabaseKvStorage.d.ts +0 -33
  23. package/dist/kv/SupabaseKvStorage.d.ts.map +0 -1
  24. package/dist/postgres/browser.d.ts +0 -32
  25. package/dist/postgres/browser.d.ts.map +0 -1
  26. package/dist/postgres/browser.js +0 -150
  27. package/dist/postgres/browser.js.map +0 -11
  28. package/dist/postgres/node-bun.d.ts +0 -26
  29. package/dist/postgres/node-bun.d.ts.map +0 -1
  30. package/dist/postgres/node-bun.js +0 -41
  31. package/dist/postgres/node-bun.js.map +0 -10
  32. package/dist/postgres/pglite-pool.d.ts +0 -21
  33. package/dist/postgres/pglite-pool.d.ts.map +0 -1
  34. package/dist/queue/IQueueStorage.d.ts +0 -206
  35. package/dist/queue/IQueueStorage.d.ts.map +0 -1
  36. package/dist/queue/InMemoryQueueStorage.d.ts +0 -148
  37. package/dist/queue/InMemoryQueueStorage.d.ts.map +0 -1
  38. package/dist/queue/IndexedDbQueueStorage.d.ts +0 -165
  39. package/dist/queue/IndexedDbQueueStorage.d.ts.map +0 -1
  40. package/dist/queue/PostgresQueueStorage.d.ts +0 -133
  41. package/dist/queue/PostgresQueueStorage.d.ts.map +0 -1
  42. package/dist/queue/SqliteQueueStorage.d.ts +0 -141
  43. package/dist/queue/SqliteQueueStorage.d.ts.map +0 -1
  44. package/dist/queue/SupabaseQueueStorage.d.ts +0 -194
  45. package/dist/queue/SupabaseQueueStorage.d.ts.map +0 -1
  46. package/dist/queue/TelemetryQueueStorage.d.ts +0 -32
  47. package/dist/queue/TelemetryQueueStorage.d.ts.map +0 -1
  48. package/dist/queue-limiter/IRateLimiterStorage.d.ts +0 -81
  49. package/dist/queue-limiter/IRateLimiterStorage.d.ts.map +0 -1
  50. package/dist/queue-limiter/InMemoryRateLimiterStorage.d.ts +0 -32
  51. package/dist/queue-limiter/InMemoryRateLimiterStorage.d.ts.map +0 -1
  52. package/dist/queue-limiter/IndexedDbRateLimiterStorage.d.ts +0 -52
  53. package/dist/queue-limiter/IndexedDbRateLimiterStorage.d.ts.map +0 -1
  54. package/dist/queue-limiter/PostgresRateLimiterStorage.d.ts +0 -54
  55. package/dist/queue-limiter/PostgresRateLimiterStorage.d.ts.map +0 -1
  56. package/dist/queue-limiter/SqliteRateLimiterStorage.d.ts +0 -53
  57. package/dist/queue-limiter/SqliteRateLimiterStorage.d.ts.map +0 -1
  58. package/dist/queue-limiter/SupabaseRateLimiterStorage.d.ts +0 -49
  59. package/dist/queue-limiter/SupabaseRateLimiterStorage.d.ts.map +0 -1
  60. package/dist/sqlite/browser.d.ts +0 -37
  61. package/dist/sqlite/browser.d.ts.map +0 -1
  62. package/dist/sqlite/browser.js +0 -125
  63. package/dist/sqlite/browser.js.map +0 -10
  64. package/dist/sqlite/bun.d.ts +0 -32
  65. package/dist/sqlite/bun.d.ts.map +0 -1
  66. package/dist/sqlite/bun.js +0 -84
  67. package/dist/sqlite/bun.js.map +0 -10
  68. package/dist/sqlite/canonical-api.d.ts +0 -34
  69. package/dist/sqlite/canonical-api.d.ts.map +0 -1
  70. package/dist/sqlite/node.d.ts +0 -34
  71. package/dist/sqlite/node.d.ts.map +0 -1
  72. package/dist/sqlite/node.js +0 -65
  73. package/dist/sqlite/node.js.map +0 -10
  74. package/dist/tabular/IndexedDbTabularStorage.d.ts +0 -199
  75. package/dist/tabular/IndexedDbTabularStorage.d.ts.map +0 -1
  76. package/dist/tabular/PostgresTabularStorage.d.ts +0 -196
  77. package/dist/tabular/PostgresTabularStorage.d.ts.map +0 -1
  78. package/dist/tabular/SqliteTabularStorage.d.ts +0 -167
  79. package/dist/tabular/SqliteTabularStorage.d.ts.map +0 -1
  80. package/dist/tabular/SupabaseTabularStorage.d.ts +0 -174
  81. package/dist/tabular/SupabaseTabularStorage.d.ts.map +0 -1
  82. package/dist/util/IndexedDbTable.d.ts +0 -40
  83. package/dist/util/IndexedDbTable.d.ts.map +0 -1
  84. package/dist/util/traced.d.ts +0 -10
  85. package/dist/util/traced.d.ts.map +0 -1
  86. package/dist/vector/IndexedDbVectorStorage.d.ts +0 -53
  87. package/dist/vector/IndexedDbVectorStorage.d.ts.map +0 -1
  88. package/dist/vector/PostgresVectorStorage.d.ts +0 -39
  89. package/dist/vector/PostgresVectorStorage.d.ts.map +0 -1
  90. package/dist/vector/SqliteAiVectorStorage.d.ts +0 -100
  91. package/dist/vector/SqliteAiVectorStorage.d.ts.map +0 -1
  92. package/dist/vector/SqliteVectorStorage.d.ts +0 -49
  93. package/dist/vector/SqliteVectorStorage.d.ts.map +0 -1
  94. package/src/queue/README.md +0 -41
@@ -1,174 +0,0 @@
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 { DataPortSchemaObject, FromSchema, JsonSchema, TypedArraySchemaOptions } from "@workglow/util/schema";
8
- import { BaseSqlTabularStorage } from "./BaseSqlTabularStorage";
9
- import { ClientProvidedKeysOption } from "./BaseTabularStorage";
10
- import { AnyTabularStorage, AutoGeneratedKeys, CoveringIndexQueryOptions, DeleteSearchCriteria, InsertEntity, QueryOptions, SearchCriteria, SimplifyPrimaryKey, TabularChangePayload, TabularSubscribeOptions, ValueOptionType } from "./ITabularStorage";
11
- export declare const SUPABASE_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<AnyTabularStorage>;
12
- /**
13
- * A Supabase-based tabular repository implementation that extends BaseSqlTabularStorage.
14
- * This class provides persistent storage for data in a Supabase database,
15
- * making it suitable for multi-user scenarios.
16
- *
17
- * @template Schema - The schema definition for the entity
18
- * @template PrimaryKeyNames - Array of property names that form the primary key
19
- */
20
- export declare class SupabaseTabularStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Entity = FromSchema<Schema, TypedArraySchemaOptions>, PrimaryKey = SimplifyPrimaryKey<Entity, PrimaryKeyNames>, Value = Omit<Entity, PrimaryKeyNames[number] & keyof Entity>, InsertType extends InsertEntity<Entity, AutoGeneratedKeys<Schema>> = InsertEntity<Entity, AutoGeneratedKeys<Schema>>> extends BaseSqlTabularStorage<Schema, PrimaryKeyNames, Entity, PrimaryKey, Value, InsertType> {
21
- protected readonly client: SupabaseClient;
22
- private realtimeChannel;
23
- /**
24
- * Creates a new SupabaseTabularStorage instance.
25
- *
26
- * @param client - Supabase client instance
27
- * @param table - Name of the table to store data (defaults to "tabular_store")
28
- * @param schema - Schema defining the structure of the entity
29
- * @param primaryKeyNames - Array of property names that form the primary key
30
- * @param indexes - Array of columns or column arrays to make searchable. Each string or single column creates a single-column index,
31
- * while each array creates a compound index with columns in the specified order.
32
- * @param clientProvidedKeys - How to handle client-provided values for auto-generated keys
33
- */
34
- constructor(client: unknown, table: string | undefined, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes?: readonly (keyof NoInfer<Entity> | readonly (keyof NoInfer<Entity>)[])[], clientProvidedKeys?: ClientProvidedKeysOption);
35
- /**
36
- * Initializes the database table with the required schema.
37
- * Creates the table if it doesn't exist with primary key and value columns.
38
- * Must be called before using any other methods.
39
- */
40
- setupDatabase(): Promise<void>;
41
- /**
42
- * Maps TypeScript/JavaScript types to corresponding PostgreSQL data types.
43
- * Uses additional schema information like minimum/maximum values, nullable status,
44
- * and string lengths to create more optimized column types.
45
- *
46
- * @param typeDef - The TypeScript/JavaScript type to map
47
- * @returns The corresponding PostgreSQL data type
48
- */
49
- protected mapTypeToSQL(typeDef: JsonSchema): string;
50
- /**
51
- * Generates the SQL column definitions for primary key fields with constraints
52
- * Handles auto-generated keys using SERIAL for integers and UUID DEFAULT for strings
53
- * @returns SQL string containing primary key column definitions
54
- */
55
- protected constructPrimaryKeyColumns($delimiter?: string): string;
56
- /**
57
- * Generates the SQL column definitions for value fields with constraints
58
- * @returns SQL string containing value column definitions
59
- */
60
- protected constructValueColumns($delimiter?: string): string;
61
- /**
62
- * Convert Supabase values to JS values. Ensures numeric strings become numbers where schema says number.
63
- */
64
- protected sqlToJsValue(column: string, value: ValueOptionType): Entity[keyof Entity];
65
- /**
66
- * Determines if a field should be treated as unsigned based on schema properties
67
- * @param typeDef - The schema type definition
68
- * @returns true if the field should be treated as unsigned
69
- */
70
- protected shouldBeUnsigned(typeDef: JsonSchema): boolean;
71
- /**
72
- * Stores or updates a row in the database.
73
- * Uses UPSERT (INSERT ... ON CONFLICT DO UPDATE) for atomic operations.
74
- *
75
- * @param entity - The entity to store (may be missing auto-generated keys)
76
- * @returns The entity with any server-generated fields updated
77
- * @emits "put" event with the updated entity when successful
78
- */
79
- put(entity: InsertType): Promise<Entity>;
80
- /**
81
- * Stores multiple rows in the database in a bulk operation.
82
- * Uses individual put calls to ensure auto-generated keys are handled correctly.
83
- *
84
- * @param entities - Array of entities to store (may be missing auto-generated keys)
85
- * @returns Array of entities with any server-generated fields updated
86
- * @emits "put" event for each entity stored
87
- */
88
- putBulk(entities: InsertType[]): Promise<Entity[]>;
89
- /**
90
- * Retrieves a value from the database by its primary key.
91
- *
92
- * @param key - The primary key object to look up
93
- * @returns The stored entity or undefined if not found
94
- * @emits "get" event with the key when successful
95
- */
96
- get(key: PrimaryKey): Promise<Entity | undefined>;
97
- /**
98
- * Deletes a row from the database.
99
- *
100
- * @param value - The primary key object or entity to delete
101
- * @emits "delete" event with the key when successful
102
- */
103
- delete(value: PrimaryKey | Entity): Promise<void>;
104
- /**
105
- * Retrieves all entries from the database table, with optional ordering, offset, and limit.
106
- * @param options - Optional ordering, limit, and offset options
107
- * @returns Promise resolving to an array of entries or undefined if not found
108
- */
109
- getAll(options?: QueryOptions<Entity>): Promise<Entity[] | undefined>;
110
- /**
111
- * Deletes all rows from the database table.
112
- * @emits "clearall" event when successful
113
- */
114
- deleteAll(): Promise<void>;
115
- /**
116
- * Returns the total number of rows in the database.
117
- *
118
- * @returns Promise resolving to the count of stored items
119
- */
120
- size(): Promise<number>;
121
- /**
122
- * Fetches a page of records from the repository.
123
- * @param offset - Number of records to skip
124
- * @param limit - Maximum number of records to return
125
- * @returns Array of entities or undefined if no records found
126
- */
127
- getBulk(offset: number, limit: number): Promise<Entity[] | undefined>;
128
- /**
129
- * Applies criteria to a Supabase filter builder. Typed as `any` because the
130
- * `PostgrestFilterBuilder` generics are deep enough to trip TS2589.
131
- */
132
- private applyCriteriaToFilter;
133
- /**
134
- * Counts rows matching the specified search criteria.
135
- */
136
- count(criteria?: SearchCriteria<Entity>): Promise<number>;
137
- /**
138
- * Deletes all entries matching the specified search criteria.
139
- * Supports multiple columns with optional comparison operators.
140
- *
141
- * @param criteria - Object with column names as keys and values or SearchConditions
142
- */
143
- deleteSearch(criteria: DeleteSearchCriteria<Entity>): Promise<void>;
144
- /**
145
- * Queries entries matching the specified search criteria with optional ordering, limit, and offset.
146
- *
147
- * @param criteria - Object with column names as keys and values or SearchConditions
148
- * @param options - Optional ordering, limit, and offset options
149
- * @returns Array of matching entities or undefined if no matches found
150
- */
151
- query(criteria: SearchCriteria<Entity>, options?: QueryOptions<Entity>): Promise<Entity[] | undefined>;
152
- queryIndex<K extends keyof Entity & string>(criteria: SearchCriteria<Entity>, options: CoveringIndexQueryOptions<Entity, K>): Promise<Pick<Entity, K>[]>;
153
- /**
154
- * Converts a row from Supabase realtime payload to an Entity with proper type conversions.
155
- *
156
- * @param row - The raw row data from Supabase realtime
157
- * @returns The converted entity
158
- */
159
- private convertRealtimeRow;
160
- /**
161
- * Subscribes to changes in the repository using Supabase realtime.
162
- * Receives notifications for INSERT, UPDATE, and DELETE operations from any source.
163
- *
164
- * @param callback - Function called when a change occurs
165
- * @param options - Optional subscription options (not used for Supabase realtime)
166
- * @returns Unsubscribe function
167
- */
168
- subscribeToChanges(callback: (change: TabularChangePayload<Entity>) => void, options?: TabularSubscribeOptions): () => void;
169
- /**
170
- * Destroys the repository and frees up resources.
171
- */
172
- destroy(): void;
173
- }
174
- //# sourceMappingURL=SupabaseTabularStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SupabaseTabularStorage.d.ts","sourceRoot":"","sources":["../../src/tabular/SupabaseTabularStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,EAEZ,YAAY,EACZ,cAAc,EAEd,kBAAkB,EAClB,oBAAoB,EAEpB,uBAAuB,EACvB,eAAe,EAChB,MA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;IAED;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA+CxE;IAED;;;;;;OAMG;IACG,KAAK,CACT,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,EAChC,OAAO,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAC7B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAsC/B;IAEc,UAAU,CAAC,CAAC,SAAS,MAAM,MAAM,GAAG,MAAM,EACvD,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,EAChC,OAAO,EAAE,yBAAyB,CAAC,MAAM,EAAE,CAAC,CAAC,GAC5C,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAqD5B;IAED;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;;;;;;OAOG;IACa,kBAAkB,CAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAAK,IAAI,EACxD,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,IAAI,CAoCZ;IAED;;OAEG;IACa,OAAO,IAAI,IAAI,CAK9B;CACF"}
@@ -1,40 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- export interface ExpectedIndexDefinition {
7
- name: string;
8
- keyPath: string | string[];
9
- options?: IDBIndexParameters;
10
- }
11
- export interface MigrationContext {
12
- db: IDBDatabase;
13
- transaction: IDBTransaction;
14
- oldVersion: number;
15
- newVersion: number;
16
- tableName: string;
17
- }
18
- export interface DataTransformer {
19
- (oldData: any): any | Promise<any>;
20
- }
21
- export interface MigrationOptions {
22
- /** Custom data transformer to apply during migration */
23
- dataTransformer?: DataTransformer;
24
- /** Whether to allow destructive operations (delete and recreate). Default: false */
25
- allowDestructiveMigration?: boolean;
26
- /** Callback for migration progress/logging */
27
- onMigrationProgress?: (message: string, progress?: number) => void;
28
- /** Callback for migration errors (non-fatal warnings) */
29
- onMigrationWarning?: (message: string, error?: Error) => void;
30
- }
31
- /**
32
- * Ensures that an IndexedDB table exists with the specified schema.
33
- * Performs migrations as needed without data loss when possible.
34
- */
35
- export declare function ensureIndexedDbTable(tableName: string, primaryKey: string | string[], expectedIndexes?: ExpectedIndexDefinition[], options?: MigrationOptions, autoIncrement?: boolean): Promise<IDBDatabase>;
36
- /**
37
- * Utility function to delete a database (for testing or cleanup)
38
- */
39
- export declare function dropIndexedDbTable(tableName: string): Promise<void>;
40
- //# sourceMappingURL=IndexedDbTable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IndexedDbTable.d.ts","sourceRoot":"","sources":["../../src/util/IndexedDbTable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,WAAW,CAAC;IAChB,WAAW,EAAE,cAAc,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,wDAAwD;IACxD,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,oFAAoF;IACpF,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,8CAA8C;IAC9C,mBAAmB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnE,yDAAyD;IACzD,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/D;AAsZD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,EAC7B,eAAe,GAAE,uBAAuB,EAAO,EAC/C,OAAO,GAAE,gBAAqB,EAC9B,aAAa,GAAE,OAAe,GAC7B,OAAO,CAAC,WAAW,CAAC,CA6KtB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzE"}
@@ -1,10 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- /**
7
- * Executes an async function within a telemetry span.
8
- */
9
- export declare function traced<T>(spanName: string, storageName: string, fn: () => Promise<T>): Promise<T>;
10
- //# sourceMappingURL=traced.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"traced.d.ts","sourceRoot":"","sources":["../../src/util/traced.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAC5B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAgBZ"}
@@ -1,53 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import type { DataPortSchemaObject, FromSchema, TypedArray, TypedArrayConstructor, TypedArraySchemaOptions } from "@workglow/util/schema";
7
- import type { ClientProvidedKeysOption } from "../tabular/BaseTabularStorage";
8
- import { IndexedDbTabularStorage } from "../tabular/IndexedDbTabularStorage";
9
- import type { MigrationOptions } from "../util/IndexedDbTable";
10
- import type { AnyVectorStorage, HybridSearchOptions, IVectorStorage, VectorSearchOptions } from "./IVectorStorage";
11
- export declare const IDB_VECTOR_REPOSITORY: import("@workglow/util").ServiceToken<AnyVectorStorage>;
12
- /**
13
- * IndexedDB vector storage implementation.
14
- * Extends IndexedDbTabularStorage for storage.
15
- * Suitable for browser applications that need persistent vector storage.
16
- * No vector serialization needed since IndexedDB supports TypedArrays
17
- * natively via structured clone.
18
- *
19
- * @template Schema - The schema definition for the entity
20
- * @template PrimaryKeyNames - The primary key names
21
- * @template Metadata - The metadata type for the vector
22
- * @template VectorCtor - Constructor for stored vectors (default {@link typeof Float32Array})
23
- * @template Entity - The entity type
24
- */
25
- export declare class IndexedDbVectorStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Metadata extends Record<string, unknown> = Record<string, unknown>, Entity = FromSchema<Schema, TypedArraySchemaOptions>> extends IndexedDbTabularStorage<Schema, PrimaryKeyNames, Entity> implements IVectorStorage<Metadata, Schema, Entity, PrimaryKeyNames> {
26
- private vectorDimensions;
27
- private vectorPropertyName;
28
- private metadataPropertyName;
29
- /**
30
- * Creates a new IndexedDB vector storage
31
- * @param table - The name of the IndexedDB store (defaults to 'vectors')
32
- * @param schema - The schema definition for the entity
33
- * @param primaryKeyNames - Array of property names that form the primary key
34
- * @param indexes - Array of columns or column arrays to make searchable
35
- * @param dimensions - The number of dimensions of the vector
36
- * @param _vectorCtor - TypedArray constructor (unused, IndexedDB stores typed arrays natively)
37
- * @param migrationOptions - Options for handling database schema migrations
38
- * @param clientProvidedKeys - How to handle client-provided values for auto-generated keys
39
- */
40
- constructor(table: string | undefined, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes: readonly (keyof NoInfer<Entity> | readonly (keyof NoInfer<Entity>)[])[] | undefined, dimensions: number, _vectorCtor?: TypedArrayConstructor, migrationOptions?: MigrationOptions, clientProvidedKeys?: ClientProvidedKeysOption);
41
- /**
42
- * Get the vector dimensions
43
- * @returns The vector dimensions
44
- */
45
- getVectorDimensions(): number;
46
- similaritySearch(query: TypedArray, options?: VectorSearchOptions<Record<string, unknown>>): Promise<(Entity & {
47
- score: number;
48
- })[]>;
49
- hybridSearch(query: TypedArray, options: HybridSearchOptions<Record<string, unknown>>): Promise<(Entity & {
50
- score: number;
51
- })[]>;
52
- }
53
- //# sourceMappingURL=IndexedDbVectorStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IndexedDbVectorStorage.d.ts","sourceRoot":"","sources":["../../src/vector/IndexedDbVectorStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAG1B,eAAO,MAAM,qBAAqB,yDAEjC,CAAC;AAiCF;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAsB,CACjC,MAAM,SAAS,oBAAoB,EACnC,eAAe,SAAS,aAAa,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,EACjE,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAEpD,SAAQ,uBAAuB,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,CAC/D,YAAW,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC;IAEpE,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,kBAAkB,CAAe;IACzC,OAAO,CAAC,oBAAoB,CAA2B;IAEvD;;;;;;;;;;OAUG;IACH,YACE,KAAK,EAAE,MAAM,YAAY,EACzB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,SAAS,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,YAAK,EACrF,UAAU,EAAE,MAAM,EAClB,WAAW,GAAE,qBAAoC,EACjD,gBAAgB,GAAE,gBAAqB,EACvC,kBAAkB,GAAE,wBAAuC,EAa5D;IAED;;;OAGG;IACH,mBAAmB,IAAI,MAAM,CAE5B;IAEK,gBAAgB,CACpB,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;eAGnB,MAAM;UAmC9C;IAEK,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;eArClD,MAAM;UAsF9C;CACF"}
@@ -1,39 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import type { Pool } from "@workglow/storage/postgres";
7
- import type { DataPortSchemaObject, FromSchema, TypedArray, TypedArrayConstructor, TypedArraySchemaOptions } from "@workglow/util/schema";
8
- import { PostgresTabularStorage } from "../tabular/PostgresTabularStorage";
9
- import type { HybridSearchOptions, IVectorStorage, VectorSearchOptions } from "./IVectorStorage";
10
- export declare class PostgresVectorStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Metadata extends Record<string, unknown> = Record<string, unknown>, Entity = FromSchema<Schema, TypedArraySchemaOptions>> extends PostgresTabularStorage<Schema, PrimaryKeyNames, Entity> implements IVectorStorage<Metadata, Schema, Entity, PrimaryKeyNames> {
11
- private vectorDimensions;
12
- private readonly vectorCtor;
13
- private vectorPropertyName;
14
- private metadataPropertyName;
15
- /**
16
- * Creates a new PostgreSQL vector repository
17
- * @param db - PostgreSQL connection pool
18
- * @param table - The name of the table to use for storage
19
- * @param schema - The schema definition for the entity
20
- * @param primaryKeyNames - Array of property names that form the primary key
21
- * @param indexes - Array of columns or column arrays to make searchable
22
- * @param dimensions - The number of dimensions of the vector
23
- * @param vectorCtor - TypedArray constructor used when hydrating vectors from SQL text (e.g. {@link Float32Array})
24
- */
25
- constructor(db: Pool, table: string, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes: readonly (keyof NoInfer<Entity> | readonly (keyof NoInfer<Entity>)[])[] | undefined, dimensions: number, vectorCtor?: TypedArrayConstructor);
26
- getVectorDimensions(): number;
27
- similaritySearch(query: TypedArray, options?: VectorSearchOptions<Metadata>): Promise<Array<Entity & {
28
- score: number;
29
- }>>;
30
- hybridSearch(query: TypedArray, options: HybridSearchOptions<Metadata>): Promise<(Entity & {
31
- score: number;
32
- })[]>;
33
- private searchFallback;
34
- private hybridSearchFallback;
35
- private getPrimaryKeyWhereClause;
36
- private getPrimaryKeyValues;
37
- private matchesFilter;
38
- }
39
- //# sourceMappingURL=PostgresVectorStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostgresVectorStorage.d.ts","sourceRoot":"","sources":["../../src/vector/PostgresVectorStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,sBAAs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,EAAE,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC;eA1EzC,MAAM;UA8JxC;YAKa,cAAc;YA+Bd,oBAAoB;IA8ClC,OAAO,CAAC,wBAAwB;IAKhC,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,aAAa;CAQtB"}
@@ -1,100 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { Sqlite } from "@workglow/storage/sqlite";
7
- import type { DataPortSchemaObject, FromSchema, TypedArray, TypedArrayConstructor, TypedArraySchemaOptions } from "@workglow/util/schema";
8
- import { SqliteTabularStorage } from "../tabular/SqliteTabularStorage";
9
- import type { HybridSearchOptions, IVectorStorage, VectorSearchOptions } from "./IVectorStorage";
10
- /**
11
- * SQLite vector storage implementation using the @sqliteai/sqlite-vector extension.
12
- * Provides native vector similarity search via SQLite virtual table functions
13
- * instead of in-memory brute-force search.
14
- *
15
- * Requirements:
16
- * - @sqliteai/sqlite-vector package installed
17
- * - Extension loaded via db.loadExtension(getExtensionPath())
18
- *
19
- * Vectors are stored as BLOBs using sqlite-vector encoding functions (vector_as_f32, etc.)
20
- * and searched using vector_full_scan for efficient KNN queries.
21
- *
22
- * @template Schema - The schema for the vector storage
23
- * @template PrimaryKeyNames - The primary key names
24
- * @template VectorCtor - Constructor for stored vectors (default {@link typeof Float32Array})
25
- * @template Metadata - The metadata type
26
- */
27
- export declare class SqliteAiVectorStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Metadata extends Record<string, unknown> | undefined = Record<string, unknown>, Entity = FromSchema<Schema, TypedArraySchemaOptions>> extends SqliteTabularStorage<Schema, PrimaryKeyNames, Entity> implements IVectorStorage<Metadata, Schema, Entity, PrimaryKeyNames> {
28
- private vectorDimensions;
29
- private readonly vectorCtor;
30
- private vectorPropertyName;
31
- private metadataPropertyName;
32
- private vectorTypeSuffix;
33
- private extensionLoaded;
34
- /**
35
- * Creates a new SQLite AI vector storage
36
- * @param dbOrPath - Either a Database instance or a path to the SQLite database file
37
- * @param table - The name of the table to use for storage
38
- * @param schema - The schema for the entity
39
- * @param primaryKeyNames - Array of property names forming the primary key
40
- * @param indexes - Array of columns to index
41
- * @param dimensions - The number of dimensions of the vector
42
- * @param vectorCtor - TypedArray constructor for stored vectors (e.g. {@link Float32Array})
43
- */
44
- constructor(dbOrPath: string | Sqlite.Database, table: string | undefined, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes: readonly (keyof NoInfer<Entity> | readonly (keyof NoInfer<Entity>)[])[] | undefined, dimensions: number, vectorCtor?: TypedArrayConstructor);
45
- getVectorDimensions(): number;
46
- /**
47
- * Load the sqlite-vector extension and initialize vector indexing on the vector column.
48
- * Extension loading is best-effort: if unavailable, operations fall back to in-memory search.
49
- */
50
- setupDatabase(): Promise<void>;
51
- /**
52
- * Encode a vector as a BLOB using sqlite-vector functions.
53
- * Returns a JSON string representation suitable for vector_as_f32() etc.
54
- */
55
- private encodeVectorJson;
56
- /**
57
- * Decode a vector BLOB from SQLite back to a TypedArray.
58
- * sqlite-vector stores vectors as BLOBs, but when we SELECT them
59
- * they come back as Buffer/Uint8Array. We also handle JSON string fallback.
60
- */
61
- private decodeVector;
62
- /**
63
- * Override jsToSqlValue to encode vectors as BLOBs via sqlite-vector functions
64
- */
65
- protected jsToSqlValue(column: string, value: Entity[keyof Entity]): ReturnType<SqliteTabularStorage<Schema, PrimaryKeyNames, Entity>["jsToSqlValue"]>;
66
- /**
67
- * Override sqlToJsValue to decode vector BLOBs back to TypedArrays
68
- */
69
- protected sqlToJsValue(column: string, value: any): Entity[keyof Entity];
70
- /**
71
- * Override mapTypeToSQL to use BLOB for vector columns instead of TEXT
72
- */
73
- protected mapTypeToSQL(typeDef: any): string;
74
- /**
75
- * Override put to use sqlite-vector encoding for vector data.
76
- * Builds a custom INSERT OR REPLACE that wraps the vector column
77
- * with vector_as_fXX() to encode as a native vector BLOB.
78
- * Falls back to base class put() if the extension is not available.
79
- */
80
- put(entity: any): Promise<Entity>;
81
- /**
82
- * Perform similarity search using sqlite-vector's vector_full_scan.
83
- * Uses native COSINE distance computation in SQLite rather than in-memory JS.
84
- * Falls back to in-memory search if the extension is unavailable.
85
- */
86
- similaritySearch(query: TypedArray, options?: VectorSearchOptions<Metadata>): Promise<(Entity & {
87
- score: number;
88
- })[]>;
89
- /**
90
- * Hybrid search combining vector similarity with text relevance.
91
- * Uses sqlite-vector for the vector component and keyword matching for text.
92
- * Falls back to in-memory search if the extension is unavailable.
93
- */
94
- hybridSearch(query: TypedArray, options: HybridSearchOptions<Metadata>): Promise<(Entity & {
95
- score: number;
96
- })[]>;
97
- private searchFallback;
98
- private hybridSearchFallback;
99
- }
100
- //# sourceMappingURL=SqliteAiVectorStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SqliteAiVectorStorage.d.ts","sourceRoot":"","sources":["../../src/vector/SqliteAiVectorStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAwDjG;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,qBAAqB,CAChC,MAAM,SAAS,oBAAoB,EACnC,eAAe,SAAS,aAAa,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,EACjE,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9E,MAAM,GAAG,U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ED;;OAEG;IACH,UAAmB,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAQpD;IAED;;;;;OAKG;IACmB,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAwGtD;IAED;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,GAAE,mBAAmB,CAAC,QAAQ,CAAM;eA+BxC,MAAM;UAqElD;IAED;;;;OAIG;IACG,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC;eA5E/B,MAAM;UAiKlD;YAKa,cAAc;YA6Bd,oBAAoB;CA2CnC"}
@@ -1,49 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { Sqlite } from "@workglow/storage/sqlite";
7
- import type { DataPortSchemaObject, FromSchema, TypedArray, TypedArrayConstructor, TypedArraySchemaOptions } from "@workglow/util/schema";
8
- import { SqliteTabularStorage } from "../tabular/SqliteTabularStorage";
9
- import type { HybridSearchOptions, IVectorStorage, VectorSearchOptions } from "./IVectorStorage";
10
- /**
11
- * SQLite vector repository implementation using tabular storage underneath.
12
- * Stores vectors as JSON-encoded arrays with metadata.
13
- *
14
- * @template Schema - The schema for the vector
15
- * @template PrimaryKeyNames - The primary key names for the vector
16
- * @template VectorCtor - Constructor for stored vectors (default {@link typeof Float32Array})
17
- * @template Metadata - The metadata type for the vector
18
- * @template Entity - The entity type for the vector
19
- */
20
- export declare class SqliteVectorStorage<Schema extends DataPortSchemaObject, PrimaryKeyNames extends ReadonlyArray<keyof Schema["properties"]>, Metadata extends Record<string, unknown> | undefined = Record<string, unknown>, Entity = FromSchema<Schema, TypedArraySchemaOptions>> extends SqliteTabularStorage<Schema, PrimaryKeyNames, Entity> implements IVectorStorage<Metadata, Schema, Entity, PrimaryKeyNames> {
21
- private vectorDimensions;
22
- private readonly vectorCtor;
23
- private vectorPropertyName;
24
- private metadataPropertyName;
25
- /**
26
- * Creates a new SQLite vector repository
27
- * @param dbOrPath - Either a Database instance or a path to the SQLite database file
28
- * @param table - The name of the table to use for storage (defaults to 'vectors')
29
- * @param schema - The schema for the entity
30
- * @param primaryKeyNames - Array of property names forming the primary key
31
- * @param indexes - Array of columns to index
32
- * @param dimensions - The number of dimensions of the vector
33
- * @param vectorCtor - TypedArray constructor used when deserializing JSON vectors (e.g. {@link Float32Array})
34
- */
35
- constructor(dbOrPath: string | Sqlite.Database, table: string | undefined, schema: Schema, primaryKeyNames: PrimaryKeyNames, indexes: readonly (keyof NoInfer<Entity> | readonly (keyof NoInfer<Entity>)[])[] | undefined, dimensions: number, vectorCtor?: TypedArrayConstructor);
36
- getVectorDimensions(): number;
37
- /**
38
- * Deserialize vector from JSON string
39
- * Defaults to Float32Array for compatibility with typical embedding vectors
40
- */
41
- private deserializeVector;
42
- similaritySearch(query: TypedArray, options?: VectorSearchOptions<Metadata>): Promise<(Entity & {
43
- score: number;
44
- })[]>;
45
- hybridSearch(query: TypedArray, options: HybridSearchOptions<Metadata>): Promise<(Entity & {
46
- score: number;
47
- })[]>;
48
- }
49
- //# sourceMappingURL=SqliteVectorStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SqliteVectorStorage.d.ts","sourceRoot":"","sources":["../../src/vector/SqliteVectorStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAejG;;;;;;;;;GASG;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ue Storage Package
2
-
3
- This is not a job queue implementation. It is a storage implementation for job queues. See the [@workglow/job-queue](../../../job-queue/README.md) package for a job queue implementation that uses these storage implementations.
4
-
5
- - [Features](#features)
6
- - [Performance Considerations](#performance-considerations)
7
- - [Job Lifecycle](#job-lifecycle)
8
-
9
- ## Features
10
-
11
- - Multiple storage implementations:
12
- - `InMemoryQueueStorage` - Volatile memory (dev/testing)
13
- - `IndexedDbQueueStorage` - Browser-based storage
14
- - `SqliteQueueStorage` - Embedded SQLite (pass a `Sqlite.Database` from `@workglow/storage/sqlite`; call `await Sqlite.init()` before opening the DB)
15
- - `PostgresQueueStorage` - Production-grade PostgreSQL
16
- - Job lifecycle management:
17
- - PENDING → PROCESSING → COMPLETED/FAILED/ABORTED
18
- - PENDING → DISABLED
19
- - Automatic retry mechanisms
20
- - Progress tracking with message/details
21
- - Fingerprint-based input deduplication
22
- - Transactional operations with SKIP LOCKED
23
- - Job expiration policies
24
-
25
- ## Performance Considerations
26
-
27
- 1. **IndexedDB**: Best for client-side applications with <10k jobs
28
- 2. **SQLite**: Ideal for single-process applications
29
- 3. **PostgreSQL**: Recommended for distributed systems with high throughput
30
- 4. **In-Memory**: Suitable for testing/development only
31
-
32
- ## Job Lifecycle
33
-
34
- 1. Jobs start as `PENDING`
35
- 2. Acquired via `next()` → `PROCESSING`
36
- 3. Final states:
37
- - `COMPLETED`: Successful execution
38
- - `FAILED`: Unrecoverable error
39
- - `ABORTED`: Manual cancellation
40
- - `DISABLED`: Disabled due to conditions not met
41
- - Auto-retried while `PENDING` if within retry limits