@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
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { DataPortSchemaObject, FromSchema, TypedArraySchemaOptions } from "@workglow/util/schema";
7
7
  import { BaseTabularStorage, ClientProvidedKeysOption } from "./BaseTabularStorage";
8
- import { AnyTabularStorage, AutoGeneratedKeys, DeleteSearchCriteria, InsertEntity, QueryOptions, SearchCriteria, SimplifyPrimaryKey, TabularSubscribeOptions } from "./ITabularStorage";
8
+ import { AnyTabularStorage, AutoGeneratedKeys, CoveringIndexQueryOptions, DeleteSearchCriteria, InsertEntity, QueryOptions, SearchCriteria, SimplifyPrimaryKey, TabularSubscribeOptions } from "./ITabularStorage";
9
9
  export declare const SHARED_IN_MEMORY_TABULAR_REPOSITORY: import("@workglow/util").ServiceToken<AnyTabularStorage>;
10
10
  /**
11
11
  * A tabular repository implementation that shares data across browser tabs/windows
@@ -117,6 +117,7 @@ export declare class SharedInMemoryTabularStorage<Schema extends DataPortSchemaO
117
117
  * @returns Array of matching entities or undefined if no matches found
118
118
  */
119
119
  query(criteria: SearchCriteria<Entity>, options?: QueryOptions<Entity>): Promise<Entity[] | undefined>;
120
+ queryIndex<K extends keyof Entity & string>(criteria: SearchCriteria<Entity>, options: CoveringIndexQueryOptions<Entity, K>): Promise<Pick<Entity, K>[]>;
120
121
  /**
121
122
  * Deletes all entries matching the specified search criteria.
122
123
  * Supports multiple columns with optional comparison operators.
@@ -1 +1 @@
1
- {"version":3,"file":"SharedInMemoryTabularStorage.d.ts","sourceRoot":"","sources":["../../src/tabular/SharedInMemoryTabularStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAElG,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,mCAAmC,0DAE/C,CAAC;AAiBF;;;;;;;GAOG;AACH,qBAAa,4BAA4B,CACvC,MAAM,SAAS,oBA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,IAAI,OAAO,CAAC,MAAM,CAAC,CAE5B;IAED;;;;;OAKG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAE1E;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,CAE/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,CAE5B;IAED;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAMxE;IAED;;;;;;;;OAQG;IACa,kBAAkB,CAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,EAC/B,OAAO,CAAC,EAAE,uBAAuB,GAChC,MAAM,IAAI,CAEZ;IAED;;OAEG;IACa,OAAO,IAAI,IAAI,CAM9B;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workglow/storage",
3
3
  "type": "module",
4
- "version": "0.2.26",
4
+ "version": "0.2.28",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/workglow-dev/workglow.git",
@@ -10,73 +10,31 @@
10
10
  "description": "Storage abstraction layer for Workglow, supporting IndexedDB, PostgreSQL, and Supabase with unified interfaces.",
11
11
  "scripts": {
12
12
  "watch": "concurrently -c 'auto' 'bun:watch-*'",
13
- "watch-js": "concurrently -c 'auto' -n 'browser,node,bun,sqlite-br,sqlite-n,sqlite-bu,pg-br,pg-nb' 'bun run watch-browser' 'bun run watch-node' 'bun run watch-bun' 'bun run watch-sqlite-browser' 'bun run watch-sqlite-node' 'bun run watch-sqlite-bun' 'bun run watch-postgres-browser' 'bun run watch-postgres-node-bun'",
13
+ "watch-js": "concurrently -c 'auto' -n 'browser,node,bun' 'bun run watch-browser' 'bun run watch-node' 'bun run watch-bun'",
14
14
  "watch-browser": "bun build --watch --no-clear-screen --target=browser --sourcemap=external --packages=external --outdir ./dist ./src/browser.ts",
15
15
  "watch-node": "bun build --watch --no-clear-screen --target=node --sourcemap=external --packages=external --outdir ./dist ./src/node.ts",
16
16
  "watch-bun": "bun build --watch --no-clear-screen --target=bun --sourcemap=external --packages=external --outdir ./dist ./src/bun.ts",
17
- "watch-sqlite-browser": "bun build --watch --no-clear-screen --target=browser --sourcemap=external --packages=external --outdir ./dist/sqlite ./src/sqlite/browser.ts",
18
- "watch-sqlite-node": "bun build --watch --no-clear-screen --target=node --sourcemap=external --packages=external --outdir ./dist/sqlite ./src/sqlite/node.ts",
19
- "watch-sqlite-bun": "bun build --watch --no-clear-screen --target=bun --sourcemap=external --packages=external --outdir ./dist/sqlite ./src/sqlite/bun.ts",
20
- "watch-postgres-browser": "bun build --watch --no-clear-screen --target=browser --sourcemap=external --packages=external --outdir ./dist/postgres ./src/postgres/browser.ts",
21
- "watch-postgres-node-bun": "bun build --watch --no-clear-screen --target=node --sourcemap=external --packages=external --outdir ./dist/postgres ./src/postgres/node-bun.ts",
22
17
  "watch-types": "tsc --watch --preserveWatchOutput",
23
18
  "build-package": "bun run build-js && bun run build-types",
24
- "build-js": "concurrently -c 'auto' -n 'browser,node,bun,sqlite-br,sqlite-n,sqlite-bu,pg-br,pg-nb' 'bun run build-browser' 'bun run build-node' 'bun run build-bun' 'bun run build-sqlite-browser' 'bun run build-sqlite-node' 'bun run build-sqlite-bun' 'bun run build-postgres-browser' 'bun run build-postgres-node-bun'",
19
+ "build-js": "concurrently -c 'auto' -n 'browser,node,bun' 'bun run build-browser' 'bun run build-node' 'bun run build-bun'",
25
20
  "build-clean": "rm -fr dist/* tsconfig.tsbuildinfo",
26
21
  "build-browser": "bun build --target=browser --sourcemap=external --packages=external --outdir ./dist ./src/browser.ts",
27
22
  "build-node": "bun build --target=node --sourcemap=external --packages=external --outdir ./dist ./src/node.ts",
28
23
  "build-bun": "bun build --target=bun --sourcemap=external --packages=external --outdir ./dist ./src/bun.ts",
29
- "build-sqlite-browser": "bun build --target=browser --sourcemap=external --packages=external --outdir ./dist/sqlite ./src/sqlite/browser.ts",
30
- "build-sqlite-node": "bun build --target=node --sourcemap=external --packages=external --outdir ./dist/sqlite ./src/sqlite/node.ts",
31
- "build-sqlite-bun": "bun build --target=bun --sourcemap=external --packages=external --outdir ./dist/sqlite ./src/sqlite/bun.ts",
32
- "build-postgres-browser": "bun build --target=browser --sourcemap=external --packages=external --outdir ./dist/postgres ./src/postgres/browser.ts",
33
- "build-postgres-node-bun": "bun build --target=node --sourcemap=external --packages=external --outdir ./dist/postgres ./src/postgres/node-bun.ts",
34
24
  "build-types": "rm -f tsconfig.tsbuildinfo && tsgo",
35
25
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
36
26
  "test": "bun test"
37
27
  },
38
28
  "peerDependencies": {
39
- "@electric-sql/pglite": "^0.4.5",
40
- "@sqlite.org/sqlite-wasm": "^3.53.0-build1",
41
- "@supabase/supabase-js": "^2.105.1",
42
- "@sqliteai/sqlite-vector": "^0.9.90",
43
- "@workglow/util": "0.2.26",
44
- "better-sqlite3": "^12.9.0",
45
- "pg": "^8.20.0"
29
+ "@workglow/util": "0.2.28"
46
30
  },
47
31
  "peerDependenciesMeta": {
48
- "@electric-sql/pglite": {
49
- "optional": true
50
- },
51
- "@sqlite.org/sqlite-wasm": {
52
- "optional": true
53
- },
54
- "@sqliteai/sqlite-vector": {
55
- "optional": true
56
- },
57
32
  "@workglow/util": {
58
33
  "optional": false
59
- },
60
- "better-sqlite3": {
61
- "optional": true
62
- },
63
- "pg": {
64
- "optional": true
65
- },
66
- "@supabase/supabase-js": {
67
- "optional": true
68
34
  }
69
35
  },
70
36
  "devDependencies": {
71
- "@electric-sql/pglite": "^0.4.5",
72
- "@sqlite.org/sqlite-wasm": "^3.53.0-build1",
73
- "@supabase/supabase-js": "^2.105.1",
74
- "@types/better-sqlite3": "^7.6.13",
75
- "@types/pg": "^8.18.0",
76
- "@workglow/util": "0.2.26",
77
- "better-sqlite3": "^12.9.0",
78
- "fake-indexeddb": "^6.2.4",
79
- "pg": "^8.20.0"
37
+ "@workglow/util": "0.2.28"
80
38
  },
81
39
  "exports": {
82
40
  ".": {
@@ -90,30 +48,6 @@
90
48
  },
91
49
  "types": "./dist/node.d.ts",
92
50
  "import": "./dist/node.js"
93
- },
94
- "./sqlite": {
95
- "browser": {
96
- "types": "./dist/sqlite/browser.d.ts",
97
- "import": "./dist/sqlite/browser.js"
98
- },
99
- "bun": {
100
- "types": "./dist/sqlite/bun.d.ts",
101
- "import": "./dist/sqlite/bun.js"
102
- },
103
- "types": "./dist/sqlite/node.d.ts",
104
- "import": "./dist/sqlite/node.js"
105
- },
106
- "./postgres": {
107
- "browser": {
108
- "types": "./dist/postgres/browser.d.ts",
109
- "import": "./dist/postgres/browser.js"
110
- },
111
- "bun": {
112
- "types": "./dist/postgres/node-bun.d.ts",
113
- "import": "./dist/postgres/node-bun.js"
114
- },
115
- "types": "./dist/postgres/node-bun.d.ts",
116
- "import": "./dist/postgres/node-bun.js"
117
51
  }
118
52
  },
119
53
  "files": [
@@ -1,27 +0,0 @@
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/schema";
7
- import { IndexedDbTabularStorage } from "../tabular/IndexedDbTabularStorage";
8
- import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvStorage } from "./IKvStorage";
9
- import { KvViaTabularStorage } from "./KvViaTabularStorage";
10
- export declare const IDB_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvStorage<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 IndexedDbKvStorage extends KvViaTabularStorage {
20
- dbName: string;
21
- tabularRepository: IndexedDbTabularStorage<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
22
- /**
23
- * Creates a new KvStorage instance
24
- */
25
- constructor(dbName: string, keySchema?: JsonSchema, valueSchema?: JsonSchema);
26
- }
27
- //# sourceMappingURL=IndexedDbKvStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IndexedDbKvStorage.d.ts","sourceRoot":"","sources":["../../src/kv/IndexedDbKvStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,iBAAiB,qEAE7B,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,mBAAmB;IAUhD,MAAM,EAAE,MAAM;IAThB,iBAAiB,EAAE,uBAAuB,CAC/C,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;OAEG;IACH,YACS,MAAM,EAAE,MAAM,EACrB,SAAS,GAAE,UAA+B,EAC1C,WAAW,GAAE,UAAe,EAQ7B;CACF"}
@@ -1,28 +0,0 @@
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/schema";
7
- import { PostgresTabularStorage } from "../tabular/PostgresTabularStorage";
8
- import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvStorage } from "./IKvStorage";
9
- import { KvViaTabularStorage } from "./KvViaTabularStorage";
10
- export declare const POSTGRES_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvStorage<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 PostgresKvStorage extends KvViaTabularStorage {
20
- db: any;
21
- dbName: string;
22
- tabularRepository: PostgresTabularStorage<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
23
- /**
24
- * Creates a new KvStorage instance
25
- */
26
- constructor(db: any, dbName: string, keySchema?: JsonSchema, valueSchema?: JsonSchema);
27
- }
28
- //# sourceMappingURL=PostgresKvStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostgresKvStorage.d.ts","sourceRoot":"","sources":["../../src/kv/PostgresKvStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,sBAAsB,qEAElC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,mBAAmB;IAU/C,EAAE,EAAE,GAAG;IACP,MAAM,EAAE,MAAM;IAVhB,iBAAiB,EAAE,sBAAsB,CAC9C,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;OAEG;IACH,YACS,EAAE,EAAE,GAAG,EACP,MAAM,EAAE,MAAM,EACrB,SAAS,GAAE,UAA+B,EAC1C,WAAW,GAAE,UAAe,EAS7B;CACF"}
@@ -1,28 +0,0 @@
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/schema";
7
- import { SqliteTabularStorage } from "../tabular/SqliteTabularStorage";
8
- import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvStorage } from "./IKvStorage";
9
- import { KvViaTabularStorage } from "./KvViaTabularStorage";
10
- export declare const SQLITE_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvStorage<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 SqliteKvStorage extends KvViaTabularStorage {
20
- db: any;
21
- dbName: string;
22
- tabularRepository: SqliteTabularStorage<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
23
- /**
24
- * Creates a new KvStorage instance
25
- */
26
- constructor(db: any, dbName: string, keySchema?: JsonSchema, valueSchema?: JsonSchema);
27
- }
28
- //# sourceMappingURL=SqliteKvStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SqliteKvStorage.d.ts","sourceRoot":"","sources":["../../src/kv/SqliteKvStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,qEAEhC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,mBAAmB;IAU7C,EAAE,EAAE,GAAG;IACP,MAAM,EAAE,MAAM;IAVhB,iBAAiB,EAAE,oBAAoB,CAC5C,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;OAEG;IACH,YACS,EAAE,EAAE,GAAG,EACP,MAAM,EAAE,MAAM,EACrB,SAAS,GAAE,UAA+B,EAC1C,WAAW,GAAE,UAAe,EAS7B;CACF"}
@@ -1,33 +0,0 @@
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/schema";
7
- import { SupabaseTabularStorage } from "../tabular/SupabaseTabularStorage";
8
- import { DefaultKeyValueKey, DefaultKeyValueSchema, IKvStorage } from "./IKvStorage";
9
- import { KvViaTabularStorage } from "./KvViaTabularStorage";
10
- export declare const SUPABASE_KV_REPOSITORY: import("@workglow/util").ServiceToken<IKvStorage<string, any, any>>;
11
- /**
12
- * A key-value repository implementation that uses Supabase for persistent storage.
13
- * Leverages a tabular repository abstraction for Supabase 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 SupabaseKvStorage extends KvViaTabularStorage {
20
- client: unknown;
21
- tableName: string;
22
- tabularRepository: SupabaseTabularStorage<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>;
23
- /**
24
- * Creates a new SupabaseKvStorage instance
25
- *
26
- * @param client - Supabase client instance
27
- * @param tableName - Name of the table to store data
28
- * @param keySchema - Schema for the key type (defaults to string)
29
- * @param valueSchema - Schema for the value type (defaults to any)
30
- */
31
- constructor(client: unknown, tableName: string, keySchema?: JsonSchema, valueSchema?: JsonSchema, tabularRepository?: SupabaseTabularStorage<typeof DefaultKeyValueSchema, typeof DefaultKeyValueKey>);
32
- }
33
- //# sourceMappingURL=SupabaseKvStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SupabaseKvStorage.d.ts","sourceRoot":"","sources":["../../src/kv/SupabaseKvStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,sBAAsB,qEAElC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,mBAAmB;IAe/C,MAAM,EAAE,OAAO;IACf,SAAS,EAAE,MAAM;IAfnB,iBAAiB,EAAE,sBAAsB,CAC9C,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,CAAC;IAEF;;;;;;;OAOG;IACH,YACS,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACxB,SAAS,GAAE,UAA+B,EAC1C,WAAW,GAAE,UAAe,EAC5B,iBAAiB,CAAC,EAAE,sBAAsB,CACxC,OAAO,qBAAqB,EAC5B,OAAO,kBAAkB,CAC1B,EAMF;CACF"}
@@ -1,32 +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, PoolConfig } from "pg";
7
- export type { Pool, PoolConfig };
8
- /**
9
- * Loads `@electric-sql/pglite` (browser WASM Postgres). Idempotent; same implementation as
10
- * {@link Postgres.init} (mirrors {@link Sqlite.init} from `@workglow/storage/sqlite`).
11
- */
12
- export declare function loadPostgres(): Promise<void>;
13
- /**
14
- * Minimal `pg`-shaped module: `Pool` is a constructor compatible with `new Pool(config)` on Node.
15
- * Call {@link Postgres.init} / {@link loadPostgres} first.
16
- */
17
- export declare function getPostgres(): typeof import("pg");
18
- /**
19
- * Creates a PGlite-backed pool whose {@link Pool.query} matches `pg` (string + params or {@link import("pg").QueryConfig}).
20
- *
21
- * `PoolConfig` mapping: default data dir is `memory://`. Use `connectionString` `memory://` or `idb://…`,
22
- * or `dataDir` / `pglite.dataDir`, or `pglite: { … }` for full {@link import("@electric-sql/pglite").PGliteOptions}.
23
- */
24
- export declare function createPool(config?: PoolConfig): Promise<Pool>;
25
- /** Same entry shape as the Node/Bun entry of this package. {@link Postgres.init} matches {@link Sqlite.init}. */
26
- export declare const Postgres: {
27
- readonly init: typeof loadPostgres;
28
- readonly load: typeof loadPostgres;
29
- readonly module: typeof import("pg");
30
- readonly createPool: typeof createPool;
31
- };
32
- //# sourceMappingURL=browser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/postgres/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAI3C,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAKjC;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAuBlD;AAWD;;;GAGG;AACH,wBAAgB,WAAW,IAAI,cAAc,IAAI,CAAC,CAKjD;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAKnE;AAED,iHAAiH;AACjH,eAAO,MAAM,QAAQ;;;qBAGL,cAAc,IAAI,CAAC;;CAIzB,CAAC"}
@@ -1,150 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
- // src/postgres/pglite-pool.ts
10
- function toFieldDefs(fields) {
11
- return fields.map((f) => ({
12
- name: f.name,
13
- tableID: 0,
14
- columnID: 0,
15
- dataTypeID: f.dataTypeID,
16
- dataTypeSize: 0,
17
- dataTypeModifier: 0,
18
- format: "text"
19
- }));
20
- }
21
- function toQueryResult(r) {
22
- const rowCount = r.affectedRows ?? r.rows.length;
23
- return {
24
- rows: r.rows,
25
- rowCount,
26
- command: "",
27
- oid: 0,
28
- fields: toFieldDefs(r.fields)
29
- };
30
- }
31
- function dataDirFromPoolConfig(config) {
32
- if (!config) {
33
- return "memory://";
34
- }
35
- const extended = config;
36
- if (typeof extended.dataDir === "string") {
37
- return extended.dataDir;
38
- }
39
- if (extended.pglite && typeof extended.pglite.dataDir === "string") {
40
- return extended.pglite.dataDir;
41
- }
42
- const cs = config.connectionString;
43
- if (typeof cs === "string" && (cs.startsWith("memory://") || cs.startsWith("idb://"))) {
44
- return cs;
45
- }
46
- return "memory://";
47
- }
48
- function pgliteOptionsFromPoolConfig(config) {
49
- const extended = config;
50
- return extended.pglite ?? {};
51
- }
52
- function normalizeParams(values) {
53
- if (values === undefined) {
54
- return;
55
- }
56
- return Array.isArray(values) ? [...values] : Object.values(values);
57
- }
58
-
59
- class PGLitePool {
60
- #db;
61
- constructor(PGliteCtor, config) {
62
- const dataDir = dataDirFromPoolConfig(config);
63
- const opts = pgliteOptionsFromPoolConfig(config);
64
- this.#db = new PGliteCtor(dataDir, opts);
65
- }
66
- async waitUntilReady() {
67
- await this.#db.waitReady;
68
- }
69
- query(queryTextOrConfig, values) {
70
- if (queryTextOrConfig !== null && typeof queryTextOrConfig === "object" && "submit" in queryTextOrConfig) {
71
- return queryTextOrConfig;
72
- }
73
- let text;
74
- let params;
75
- if (typeof queryTextOrConfig === "string") {
76
- text = queryTextOrConfig;
77
- params = normalizeParams(values);
78
- } else {
79
- const cfg = queryTextOrConfig;
80
- if ("rowMode" in cfg && cfg.rowMode === "array") {
81
- throw new Error('PGLitePool (browser): rowMode "array" is not supported; use default row objects.');
82
- }
83
- text = cfg.text;
84
- params = normalizeParams(cfg.values);
85
- }
86
- return this.#db.query(text, params).then((r) => toQueryResult(r));
87
- }
88
- async end() {
89
- await this.#db.close();
90
- }
91
- }
92
-
93
- // src/postgres/browser.ts
94
- var _PGlite;
95
- var _PoolBound;
96
- async function loadPostgres() {
97
- if (_PGlite) {
98
- return;
99
- }
100
- try {
101
- const m = await import("@electric-sql/pglite");
102
- const PGliteCtor = m.PGlite ?? m.default;
103
- if (!PGliteCtor) {
104
- throw new Error("PGlite export not found");
105
- }
106
- _PGlite = PGliteCtor;
107
- const Base = PGliteCtor;
108
- _PoolBound = class BrowserPGLitePool extends PGLitePool {
109
- constructor(config) {
110
- super(Base, config);
111
- }
112
- };
113
- } catch {
114
- throw new Error("@electric-sql/pglite is required for @workglow/storage/postgres in the browser. Install: bun add @electric-sql/pglite");
115
- }
116
- }
117
- function requirePoolCtor() {
118
- if (!_PoolBound) {
119
- throw new Error("Postgres is not ready. Await Postgres.init() before using @workglow/storage/postgres in the browser.");
120
- }
121
- return _PoolBound;
122
- }
123
- function getPostgres() {
124
- const PoolCtor = requirePoolCtor();
125
- return {
126
- Pool: PoolCtor
127
- };
128
- }
129
- async function createPool(config) {
130
- await loadPostgres();
131
- const pool = new (requirePoolCtor())(config);
132
- await pool.waitUntilReady();
133
- return pool;
134
- }
135
- var Postgres = {
136
- init: loadPostgres,
137
- load: loadPostgres,
138
- get module() {
139
- return getPostgres();
140
- },
141
- createPool
142
- };
143
- export {
144
- loadPostgres,
145
- getPostgres,
146
- createPool,
147
- Postgres
148
- };
149
-
150
- //# debugId=FA60C069F301C54264756E2164756E21
@@ -1,11 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/postgres/pglite-pool.ts", "../../src/postgres/browser.ts"],
4
- "sourcesContent": [
5
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { PGliteInterface, PGliteOptions, Results } from \"@electric-sql/pglite\";\nimport type { PoolConfig, QueryConfig, QueryResult, QueryResultRow, Submittable } from \"pg\";\n\nfunction toFieldDefs(fields: Results[\"fields\"]): QueryResult[\"fields\"] {\n return fields.map((f) => ({\n name: f.name,\n tableID: 0,\n columnID: 0,\n dataTypeID: f.dataTypeID,\n dataTypeSize: 0,\n dataTypeModifier: 0,\n format: \"text\" as const,\n }));\n}\n\nfunction toQueryResult<R extends QueryResultRow>(r: Results<R>): QueryResult<R> {\n const rowCount = r.affectedRows ?? r.rows.length;\n return {\n rows: r.rows,\n rowCount,\n command: \"\",\n oid: 0,\n fields: toFieldDefs(r.fields),\n };\n}\n\nfunction dataDirFromPoolConfig(config?: PoolConfig): string {\n if (!config) {\n return \"memory://\";\n }\n const extended = config as PoolConfig & { dataDir?: string; pglite?: { dataDir?: string } };\n if (typeof extended.dataDir === \"string\") {\n return extended.dataDir;\n }\n if (extended.pglite && typeof extended.pglite.dataDir === \"string\") {\n return extended.pglite.dataDir;\n }\n const cs = config.connectionString;\n if (typeof cs === \"string\" && (cs.startsWith(\"memory://\") || cs.startsWith(\"idb://\"))) {\n return cs;\n }\n return \"memory://\";\n}\n\nfunction pgliteOptionsFromPoolConfig(config?: PoolConfig): PGliteOptions {\n const extended = config as PoolConfig & { pglite?: PGliteOptions };\n return extended.pglite ?? {};\n}\n\nfunction normalizeParams<I extends any[]>(\n values?: import(\"pg\").QueryConfigValues<I>\n): unknown[] | undefined {\n if (values === undefined) {\n return undefined;\n }\n return Array.isArray(values) ? [...values] : Object.values(values as Record<string, unknown>);\n}\n\n/**\n * Wraps a {@link PGliteInterface} so {@link import(\"pg\").Pool#query} call sites can stay the same\n * as with `pg` (string + optional params, or {@link QueryConfig} with `text` / `values`).\n */\nexport class PGLitePool {\n readonly #db: PGliteInterface;\n\n constructor(PGliteCtor: typeof import(\"@electric-sql/pglite\").PGlite, config?: PoolConfig) {\n const dataDir = dataDirFromPoolConfig(config);\n const opts = pgliteOptionsFromPoolConfig(config);\n this.#db = new PGliteCtor(dataDir, opts);\n }\n\n /** Resolve when WASM / FS initialization has finished. */\n async waitUntilReady(): Promise<void> {\n await this.#db.waitReady;\n }\n\n query<T extends Submittable>(queryStream: T): T;\n query<R extends QueryResultRow = any, I extends any[] = any[]>(\n queryConfig: QueryConfig<I>\n ): Promise<QueryResult<R>>;\n query<R extends QueryResultRow = any, I extends any[] = any[]>(\n queryTextOrConfig: string | QueryConfig<I>,\n values?: import(\"pg\").QueryConfigValues<I>\n ): Promise<QueryResult<R>>;\n query(queryTextOrConfig: unknown, values?: unknown): unknown {\n if (\n queryTextOrConfig !== null &&\n typeof queryTextOrConfig === \"object\" &&\n \"submit\" in (queryTextOrConfig as object)\n ) {\n return queryTextOrConfig;\n }\n\n let text: string;\n let params: unknown[] | undefined;\n\n if (typeof queryTextOrConfig === \"string\") {\n text = queryTextOrConfig;\n params = normalizeParams(values as import(\"pg\").QueryConfigValues<any>);\n } else {\n const cfg = queryTextOrConfig as QueryConfig<any>;\n if (\"rowMode\" in cfg && cfg.rowMode === \"array\") {\n throw new Error(\n 'PGLitePool (browser): rowMode \"array\" is not supported; use default row objects.'\n );\n }\n text = cfg.text;\n params = normalizeParams(cfg.values as import(\"pg\").QueryConfigValues<any>);\n }\n\n return this.#db.query(text, params).then((r) => toQueryResult(r as Results<QueryResultRow>));\n }\n\n async end(): Promise<void> {\n await this.#db.close();\n }\n}\n",
6
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Pool, PoolConfig } from \"pg\";\n\nimport { PGLitePool } from \"./pglite-pool\";\n\nexport type { Pool, PoolConfig };\n\nlet _PGlite: typeof import(\"@electric-sql/pglite\").PGlite | undefined;\nlet _PoolBound: (new (config?: PoolConfig) => PGLitePool) | undefined;\n\n/**\n * Loads `@electric-sql/pglite` (browser WASM Postgres). Idempotent; same implementation as\n * {@link Postgres.init} (mirrors {@link Sqlite.init} from `@workglow/storage/sqlite`).\n */\nexport async function loadPostgres(): Promise<void> {\n if (_PGlite) {\n return;\n }\n try {\n const m = await import(\"@electric-sql/pglite\");\n const PGliteCtor =\n m.PGlite ?? (m as { default?: typeof import(\"@electric-sql/pglite\").PGlite }).default;\n if (!PGliteCtor) {\n throw new Error(\"PGlite export not found\");\n }\n _PGlite = PGliteCtor;\n const Base = PGliteCtor;\n _PoolBound = class BrowserPGLitePool extends PGLitePool {\n constructor(config?: PoolConfig) {\n super(Base, config);\n }\n };\n } catch {\n throw new Error(\n \"@electric-sql/pglite is required for @workglow/storage/postgres in the browser. Install: bun add @electric-sql/pglite\"\n );\n }\n}\n\nfunction requirePoolCtor(): new (config?: PoolConfig) => PGLitePool {\n if (!_PoolBound) {\n throw new Error(\n \"Postgres is not ready. Await Postgres.init() before using @workglow/storage/postgres in the browser.\"\n );\n }\n return _PoolBound;\n}\n\n/**\n * Minimal `pg`-shaped module: `Pool` is a constructor compatible with `new Pool(config)` on Node.\n * Call {@link Postgres.init} / {@link loadPostgres} first.\n */\nexport function getPostgres(): typeof import(\"pg\") {\n const PoolCtor = requirePoolCtor();\n return {\n Pool: PoolCtor as unknown as typeof import(\"pg\").Pool,\n } as unknown as typeof import(\"pg\");\n}\n\n/**\n * Creates a PGlite-backed pool whose {@link Pool.query} matches `pg` (string + params or {@link import(\"pg\").QueryConfig}).\n *\n * `PoolConfig` mapping: default data dir is `memory://`. Use `connectionString` `memory://` or `idb://…`,\n * or `dataDir` / `pglite.dataDir`, or `pglite: { … }` for full {@link import(\"@electric-sql/pglite\").PGliteOptions}.\n */\nexport async function createPool(config?: PoolConfig): Promise<Pool> {\n await loadPostgres();\n const pool = new (requirePoolCtor())(config);\n await pool.waitUntilReady();\n return pool as unknown as Pool;\n}\n\n/** Same entry shape as the Node/Bun entry of this package. {@link Postgres.init} matches {@link Sqlite.init}. */\nexport const Postgres = {\n init: loadPostgres,\n load: loadPostgres,\n get module(): typeof import(\"pg\") {\n return getPostgres();\n },\n createPool,\n} as const;\n"
7
- ],
8
- "mappings": ";;;;;;;;;AASA,SAAS,WAAW,CAAC,QAAkD;AAAA,EACrE,OAAO,OAAO,IAAI,CAAC,OAAO;AAAA,IACxB,MAAM,EAAE;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,YAAY,EAAE;AAAA,IACd,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,QAAQ;AAAA,EACV,EAAE;AAAA;AAGJ,SAAS,aAAuC,CAAC,GAA+B;AAAA,EAC9E,MAAM,WAAW,EAAE,gBAAgB,EAAE,KAAK;AAAA,EAC1C,OAAO;AAAA,IACL,MAAM,EAAE;AAAA,IACR;AAAA,IACA,SAAS;AAAA,IACT,KAAK;AAAA,IACL,QAAQ,YAAY,EAAE,MAAM;AAAA,EAC9B;AAAA;AAGF,SAAS,qBAAqB,CAAC,QAA6B;AAAA,EAC1D,IAAI,CAAC,QAAQ;AAAA,IACX,OAAO;AAAA,EACT;AAAA,EACA,MAAM,WAAW;AAAA,EACjB,IAAI,OAAO,SAAS,YAAY,UAAU;AAAA,IACxC,OAAO,SAAS;AAAA,EAClB;AAAA,EACA,IAAI,SAAS,UAAU,OAAO,SAAS,OAAO,YAAY,UAAU;AAAA,IAClE,OAAO,SAAS,OAAO;AAAA,EACzB;AAAA,EACA,MAAM,KAAK,OAAO;AAAA,EAClB,IAAI,OAAO,OAAO,aAAa,GAAG,WAAW,WAAW,KAAK,GAAG,WAAW,QAAQ,IAAI;AAAA,IACrF,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA;AAGT,SAAS,2BAA2B,CAAC,QAAoC;AAAA,EACvE,MAAM,WAAW;AAAA,EACjB,OAAO,SAAS,UAAU,CAAC;AAAA;AAG7B,SA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,MAAM,aACJ,EAAE,UAAW,EAAiE;AAAA,IAChF,IAAI,CAAC,YAAY;AAAA,MACf,MAAM,IAAI,MAAM,yBAAyB;AAAA,IAC3C;AAAA,IACA,UAAU;AAAA,IACV,MAAM,OAAO;AAAA,IACb,aAAa,MAAM,0BAA0B,WAAW;AAAA,MACtD,WAAW,CAAC,QAAqB;AAAA,QAC/B,MAAM,MAAM,MAAM;AAAA;AAAA,IAEtB;AAAA,IACA,MAAM;AAAA,IACN,MAAM,IAAI,MACR,uHACF;AAAA;AAAA;AAIJ,SAAS,eAAe,GAA4C;AAAA,EAClE,IAAI,CAAC,YAAY;AAAA,IACf,MAAM,IAAI,MACR,sGACF;AAAA,EACF;AAAA,EACA,OAAO;AAAA;AAOF,SAAS,WAAW,GAAwB;AAAA,EACjD,MAAM,WAAW,gBAAgB;AAAA,EACjC,OAAO;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AASF,eAAsB,UAAU,CAAC,QAAoC;AAAA,EACnE,MAAM,aAAa;AAAA,EACnB,MAAM,OAAO,KAAK,gBAAgB,GAAG,MAAM;AAAA,EAC3C,MAAM,KAAK,eAAe;AAAA,EAC1B,OAAO;AAAA;AAIF,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,MAAM;AAAA,MACF,MAAM,GAAwB;AAAA,IAChC,OAAO,YAAY;AAAA;AAAA,EAErB;AACF;",
9
- "debugId": "FA60C069F301C54264756E2164756E21",
10
- "names": []
11
- }
@@ -1,26 +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, PoolConfig } from "pg";
7
- export type { Pool, PoolConfig };
8
- /**
9
- * Dynamically loads the `pg` package (Node.js and Bun). Idempotent; same implementation as
10
- * {@link Postgres.init} (mirrors {@link Sqlite.init} from `@workglow/storage/sqlite`).
11
- *
12
- * Call before using {@link getPostgres} or {@link createPool}.
13
- */
14
- export declare function loadPostgres(): Promise<void>;
15
- /** Resolved `pg` module after {@link Postgres.init} / {@link loadPostgres}. */
16
- export declare function getPostgres(): typeof import("pg");
17
- /** Creates a connection pool after loading `pg`. */
18
- export declare function createPool(config: PoolConfig): Promise<Pool>;
19
- /** Namespaced helpers (lazy `pg` load). {@link Postgres.init} matches {@link Sqlite.init}. */
20
- export declare const Postgres: {
21
- readonly init: typeof loadPostgres;
22
- readonly load: typeof loadPostgres;
23
- readonly module: typeof import("pg");
24
- readonly createPool: typeof createPool;
25
- };
26
- //# sourceMappingURL=node-bun.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-bun.d.ts","sourceRoot":"","sources":["../../src/postgres/node-bun.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAE3C,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAIjC;;;;;GAKG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAWlD;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,IAAI,cAAc,IAAI,CAAC,CAOjD;AAED,oDAAoD;AACpD,wBAAsB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlE;AAED,8FAA8F;AAC9F,eAAO,MAAM,QAAQ;;;qBAGL,cAAc,IAAI,CAAC;;CAIzB,CAAC"}
@@ -1,41 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- // src/postgres/node-bun.ts
5
- var _pg;
6
- async function loadPostgres() {
7
- if (_pg) {
8
- return;
9
- }
10
- try {
11
- _pg = await import("pg");
12
- } catch {
13
- throw new Error('The "pg" package is required for @workglow/storage/postgres on Node.js or Bun. Install: bun add pg');
14
- }
15
- }
16
- function getPostgres() {
17
- if (!_pg) {
18
- throw new Error("Postgres is not ready. Await Postgres.init() before using getPostgres() or Postgres.module.");
19
- }
20
- return _pg;
21
- }
22
- async function createPool(config) {
23
- await loadPostgres();
24
- return new _pg.Pool(config);
25
- }
26
- var Postgres = {
27
- init: loadPostgres,
28
- load: loadPostgres,
29
- get module() {
30
- return getPostgres();
31
- },
32
- createPool
33
- };
34
- export {
35
- loadPostgres,
36
- getPostgres,
37
- createPool,
38
- Postgres
39
- };
40
-
41
- //# debugId=B83E4D3B07104B3B64756E2164756E21
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/postgres/node-bun.ts"],
4
- "sourcesContent": [
5
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Pool, PoolConfig } from \"pg\";\n\nexport type { Pool, PoolConfig };\n\nlet _pg: typeof import(\"pg\") | undefined;\n\n/**\n * Dynamically loads the `pg` package (Node.js and Bun). Idempotent; same implementation as\n * {@link Postgres.init} (mirrors {@link Sqlite.init} from `@workglow/storage/sqlite`).\n *\n * Call before using {@link getPostgres} or {@link createPool}.\n */\nexport async function loadPostgres(): Promise<void> {\n if (_pg) {\n return;\n }\n try {\n _pg = await import(\"pg\");\n } catch {\n throw new Error(\n 'The \"pg\" package is required for @workglow/storage/postgres on Node.js or Bun. Install: bun add pg'\n );\n }\n}\n\n/** Resolved `pg` module after {@link Postgres.init} / {@link loadPostgres}. */\nexport function getPostgres(): typeof import(\"pg\") {\n if (!_pg) {\n throw new Error(\n \"Postgres is not ready. Await Postgres.init() before using getPostgres() or Postgres.module.\"\n );\n }\n return _pg;\n}\n\n/** Creates a connection pool after loading `pg`. */\nexport async function createPool(config: PoolConfig): Promise<Pool> {\n await loadPostgres();\n return new _pg!.Pool(config);\n}\n\n/** Namespaced helpers (lazy `pg` load). {@link Postgres.init} matches {@link Sqlite.init}. */\nexport const Postgres = {\n init: loadPostgres,\n load: loadPostgres,\n get module(): typeof import(\"pg\") {\n return getPostgres();\n },\n createPool,\n} as const;\n"
6
- ],
7
- "mappings": ";;;;AAUA,IAAI;AAQJ,eAAsB,YAAY,GAAkB;AAAA,EAClD,IAAI,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EACA,IAAI;AAAA,IACF,MAAM,MAAa;AAAA,IACnB,MAAM;AAAA,IACN,MAAM,IAAI,MACR,oGACF;AAAA;AAAA;AAKG,SAAS,WAAW,GAAwB;AAAA,EACjD,IAAI,CAAC,KAAK;AAAA,IACR,MAAM,IAAI,MACR,6FACF;AAAA,EACF;AAAA,EACA,OAAO;AAAA;AAIT,eAAsB,UAAU,CAAC,QAAmC;AAAA,EAClE,MAAM,aAAa;AAAA,EACnB,OAAO,IAAI,IAAK,KAAK,MAAM;AAAA;AAItB,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,MAAM;AAAA,MACF,MAAM,GAAwB;AAAA,IAChC,OAAO,YAAY;AAAA;AAAA,EAErB;AACF;",
8
- "debugId": "B83E4D3B07104B3B64756E2164756E21",
9
- "names": []
10
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import type { PoolConfig, QueryConfig, QueryResult, QueryResultRow, Submittable } from "pg";
7
- /**
8
- * Wraps a {@link PGliteInterface} so {@link import("pg").Pool#query} call sites can stay the same
9
- * as with `pg` (string + optional params, or {@link QueryConfig} with `text` / `values`).
10
- */
11
- export declare class PGLitePool {
12
- #private;
13
- constructor(PGliteCtor: typeof import("@electric-sql/pglite").PGlite, config?: PoolConfig);
14
- /** Resolve when WASM / FS initialization has finished. */
15
- waitUntilReady(): Promise<void>;
16
- query<T extends Submittable>(queryStream: T): T;
17
- query<R extends QueryResultRow = any, I extends any[] = any[]>(queryConfig: QueryConfig<I>): Promise<QueryResult<R>>;
18
- query<R extends QueryResultRow = any, I extends any[] = any[]>(queryTextOrConfig: string | QueryConfig<I>, values?: import("pg").QueryConfigValues<I>): Promise<QueryResult<R>>;
19
- end(): Promise<void>;
20
- }
21
- //# sourceMappingURL=pglite-pool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pglite-pool.d.ts","sourceRoot":"","sources":["../../src/postgres/pglite-pool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAyD5F;;;GAGG;AACH,qBAAa,UAAU;;IAGrB,YAAY,UAAU,EAAE,cAAc,sBAAsB,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,EAIxF;IAED,0DAA0D;IACpD,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpC;IAED,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;IAChD,KAAK,CAAC,CAAC,SAAS,cAAc,GAAG,GAAG,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAC3D,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,CAAC,SAAS,cAAc,GAAG,GAAG,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAC3D,iBAAiB,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,EAC1C,MAAM,CAAC,EAAE,OAAO,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IA8BrB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAEzB;CACF"}