@workglow/storage 0.0.124 → 0.0.126
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 +15 -6
- package/dist/browser.d.ts +18 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/{types.d.ts → bun.d.ts} +1 -1
- package/dist/bun.d.ts.map +1 -0
- package/dist/bun.js +3 -4
- package/dist/bun.js.map +11 -11
- package/dist/node.d.ts +7 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +3 -4
- package/dist/node.js.map +11 -11
- package/dist/postgres/browser.d.ts +32 -0
- package/dist/postgres/browser.d.ts.map +1 -0
- package/dist/postgres/browser.js +150 -0
- package/dist/postgres/browser.js.map +11 -0
- package/dist/postgres/node-bun.d.ts +26 -0
- package/dist/postgres/node-bun.d.ts.map +1 -0
- package/dist/postgres/node-bun.js +41 -0
- package/dist/postgres/node-bun.js.map +10 -0
- package/dist/postgres/pglite-pool.d.ts +21 -0
- package/dist/postgres/pglite-pool.d.ts.map +1 -0
- package/dist/queue/PostgresQueueStorage.d.ts +1 -1
- package/dist/queue/PostgresQueueStorage.d.ts.map +1 -1
- package/dist/queue/SqliteQueueStorage.d.ts +1 -1
- package/dist/queue/SqliteQueueStorage.d.ts.map +1 -1
- package/dist/queue-limiter/PostgresRateLimiterStorage.d.ts +1 -1
- package/dist/queue-limiter/PostgresRateLimiterStorage.d.ts.map +1 -1
- package/dist/queue-limiter/SqliteRateLimiterStorage.d.ts +1 -1
- package/dist/queue-limiter/SqliteRateLimiterStorage.d.ts.map +1 -1
- package/dist/sqlite/browser.d.ts +37 -0
- package/dist/sqlite/browser.d.ts.map +1 -0
- package/dist/sqlite/browser.js +125 -0
- package/dist/sqlite/browser.js.map +10 -0
- package/dist/sqlite/bun.d.ts +32 -0
- package/dist/sqlite/bun.d.ts.map +1 -0
- package/dist/sqlite/bun.js +84 -0
- package/dist/sqlite/bun.js.map +10 -0
- package/dist/sqlite/canonical-api.d.ts +34 -0
- package/dist/sqlite/canonical-api.d.ts.map +1 -0
- package/dist/sqlite/node.d.ts +34 -0
- package/dist/sqlite/node.d.ts.map +1 -0
- package/dist/sqlite/node.js +65 -0
- package/dist/sqlite/node.js.map +10 -0
- package/dist/tabular/PostgresTabularStorage.d.ts +1 -1
- package/dist/tabular/PostgresTabularStorage.d.ts.map +1 -1
- package/dist/tabular/SqliteTabularStorage.d.ts +1 -1
- package/dist/tabular/SqliteTabularStorage.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 +85 -21
- package/src/kv/README.md +4 -3
- package/src/queue/README.md +1 -1
- package/src/tabular/README.md +8 -1
- package/src/vector/README.md +6 -6
- package/dist/types.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -142,6 +142,10 @@ The package uses conditional exports, so importing from `@workglow/storage` auto
|
|
|
142
142
|
import { InMemoryKvStorage, SqliteTabularStorage } from "@workglow/storage";
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
+
### SQLite setup (`@workglow/storage/sqlite`)
|
|
146
|
+
|
|
147
|
+
Before you open SQLite with a **file path** or construct **`new Sqlite.Database(...)`**, call **`await Sqlite.init()`** once per runtime (Node.js, Bun, or browser). Export is available from **`workglow`** and **`@workglow/storage/sqlite`**. The call is idempotent. On the browser it loads the SQLite WASM build; on Node.js it loads `better-sqlite3`; on Bun it resolves `bun:sqlite`.
|
|
148
|
+
|
|
145
149
|
## Storage Types
|
|
146
150
|
|
|
147
151
|
### Key-Value Storage
|
|
@@ -171,12 +175,15 @@ const browserStore = new IndexedDbKvRepository("my-app-storage");
|
|
|
171
175
|
|
|
172
176
|
// Node.js/Bun (using SQLite)
|
|
173
177
|
import { SqliteKvRepository } from "@workglow/storage";
|
|
174
|
-
|
|
178
|
+
import { Sqlite } from "@workglow/storage/sqlite";
|
|
179
|
+
|
|
180
|
+
await Sqlite.init();
|
|
181
|
+
// Pass a file path or a Sqlite.Database instance (see @workglow/storage/sqlite)
|
|
175
182
|
const sqliteStore = new SqliteKvRepository("./data.db", "config_table");
|
|
176
183
|
|
|
177
184
|
// PostgreSQL (Node.js/Bun)
|
|
178
185
|
import { PostgresKvRepository } from "@workglow/storage";
|
|
179
|
-
import { Pool } from "
|
|
186
|
+
import type { Pool } from "@workglow/storage/postgres";
|
|
180
187
|
const pool = new Pool({ connectionString: "postgresql://..." });
|
|
181
188
|
const pgStore = new PostgresKvRepository(pool, "settings");
|
|
182
189
|
|
|
@@ -390,7 +397,9 @@ await userRepo.deleteSearch({
|
|
|
390
397
|
```typescript
|
|
391
398
|
// SQLite (Node.js/Bun)
|
|
392
399
|
import { SqliteTabularStorage } from "@workglow/storage";
|
|
400
|
+
import { Sqlite } from "@workglow/storage/sqlite";
|
|
393
401
|
|
|
402
|
+
await Sqlite.init();
|
|
394
403
|
const sqliteUsers = new SqliteTabularStorage<typeof UserSchema, ["id"]>(
|
|
395
404
|
"./users.db",
|
|
396
405
|
"users",
|
|
@@ -401,7 +410,7 @@ const sqliteUsers = new SqliteTabularStorage<typeof UserSchema, ["id"]>(
|
|
|
401
410
|
|
|
402
411
|
// PostgreSQL (Node.js/Bun)
|
|
403
412
|
import { PostgresTabularStorage } from "@workglow/storage";
|
|
404
|
-
import { Pool } from "
|
|
413
|
+
import type { Pool } from "@workglow/storage/postgres";
|
|
405
414
|
|
|
406
415
|
const pool = new Pool({ connectionString: "postgresql://..." });
|
|
407
416
|
const pgUsers = new PostgresTabularStorage<typeof UserSchema, ["id"]>(
|
|
@@ -554,11 +563,11 @@ import {
|
|
|
554
563
|
PostgresQueueStorage,
|
|
555
564
|
SupabaseTabularStorage,
|
|
556
565
|
} from "@workglow/storage";
|
|
557
|
-
|
|
558
|
-
import { Database } from "bun:sqlite";
|
|
566
|
+
import { Sqlite } from "@workglow/storage/sqlite";
|
|
559
567
|
import { createClient } from "@supabase/supabase-js";
|
|
560
568
|
|
|
561
|
-
|
|
569
|
+
await Sqlite.init();
|
|
570
|
+
const db = new Sqlite.Database("./app.db");
|
|
562
571
|
const data = new SqliteTabularStorage(db, "items", ItemSchema, ["id"]);
|
|
563
572
|
|
|
564
573
|
// Or use Supabase for cloud storage
|
|
@@ -0,0 +1,18 @@
|
|
|
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/IndexedDbTabularStorage";
|
|
8
|
+
export * from "./tabular/SharedInMemoryTabularStorage";
|
|
9
|
+
export * from "./tabular/SupabaseTabularStorage";
|
|
10
|
+
export * from "./kv/IndexedDbKvStorage";
|
|
11
|
+
export * from "./kv/SupabaseKvStorage";
|
|
12
|
+
export * from "./queue/IndexedDbQueueStorage";
|
|
13
|
+
export * from "./queue/SupabaseQueueStorage";
|
|
14
|
+
export * from "./queue-limiter/IndexedDbRateLimiterStorage";
|
|
15
|
+
export * from "./queue-limiter/SupabaseRateLimiterStorage";
|
|
16
|
+
export * from "./vector/IndexedDbVectorStorage";
|
|
17
|
+
export * from "./util/IndexedDbTable";
|
|
18
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AAEzB,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AAEjD,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAE7C,cAAc,6CAA6C,CAAC;AAC5D,cAAc,4CAA4C,CAAC;AAE3D,cAAc,iCAAiC,CAAC;AAEhD,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../src/bun.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iBAAiB,CAAC"}
|
package/dist/bun.js
CHANGED
|
@@ -3108,10 +3108,9 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
|
|
|
3108
3108
|
}
|
|
3109
3109
|
}
|
|
3110
3110
|
// src/tabular/SqliteTabularStorage.ts
|
|
3111
|
-
import { Sqlite } from "@workglow/sqlite";
|
|
3111
|
+
import { Sqlite } from "@workglow/storage/sqlite";
|
|
3112
3112
|
import { createServiceToken as createServiceToken14, uuid4 as uuid44 } from "@workglow/util";
|
|
3113
3113
|
var SQLITE_TABULAR_REPOSITORY = createServiceToken14("storage.tabularRepository.sqlite");
|
|
3114
|
-
var Database = Sqlite.Database;
|
|
3115
3114
|
|
|
3116
3115
|
class SqliteTabularStorage extends BaseSqlTabularStorage {
|
|
3117
3116
|
db;
|
|
@@ -3121,7 +3120,7 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
|
|
|
3121
3120
|
constructor(dbOrPath, table = "tabular_store", schema, primaryKeyNames, indexes = [], clientProvidedKeys = "if-missing") {
|
|
3122
3121
|
super(table, schema, primaryKeyNames, indexes, clientProvidedKeys);
|
|
3123
3122
|
if (typeof dbOrPath === "string") {
|
|
3124
|
-
this.db = new Database(dbOrPath);
|
|
3123
|
+
this.db = new Sqlite.Database(dbOrPath);
|
|
3125
3124
|
} else {
|
|
3126
3125
|
this.db = dbOrPath;
|
|
3127
3126
|
}
|
|
@@ -8259,4 +8258,4 @@ export {
|
|
|
8259
8258
|
BaseTabularStorage
|
|
8260
8259
|
};
|
|
8261
8260
|
|
|
8262
|
-
//# debugId=
|
|
8261
|
+
//# debugId=0AEFE15161887D3364756E2164756E21
|