@workglow/postgres 0.2.31 → 0.2.32
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 +33 -0
- package/dist/job-queue/PostgresQueueStorage.d.ts +12 -19
- package/dist/job-queue/PostgresQueueStorage.d.ts.map +1 -1
- package/dist/job-queue/PostgresRateLimiterStorage.d.ts +9 -19
- package/dist/job-queue/PostgresRateLimiterStorage.d.ts.map +1 -1
- package/dist/job-queue/browser.js +331 -165
- package/dist/job-queue/browser.js.map +8 -5
- package/dist/job-queue/common.d.ts +3 -0
- package/dist/job-queue/common.d.ts.map +1 -1
- package/dist/job-queue/node.js +331 -165
- package/dist/job-queue/node.js.map +8 -5
- package/dist/migrations/PostgresMigrationRunner.d.ts +31 -0
- package/dist/migrations/PostgresMigrationRunner.d.ts.map +1 -0
- package/dist/migrations/common.d.ts +9 -0
- package/dist/migrations/common.d.ts.map +1 -0
- package/dist/migrations/postgresQueueMigrations.d.ts +18 -0
- package/dist/migrations/postgresQueueMigrations.d.ts.map +1 -0
- package/dist/migrations/postgresRateLimiterMigrations.d.ts +11 -0
- package/dist/migrations/postgresRateLimiterMigrations.d.ts.map +1 -0
- package/dist/storage/PostgresTabularStorage.d.ts +175 -10
- package/dist/storage/PostgresTabularStorage.d.ts.map +1 -1
- package/dist/storage/PostgresVectorStorage.d.ts +52 -2
- package/dist/storage/PostgresVectorStorage.d.ts.map +1 -1
- package/dist/storage/browser.js +454 -75
- package/dist/storage/browser.js.map +4 -4
- package/dist/storage/common.d.ts +1 -0
- package/dist/storage/common.d.ts.map +1 -1
- package/dist/storage/node.js +564 -75
- package/dist/storage/node.js.map +6 -5
- package/package.json +7 -7
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @workglow/postgres
|
|
2
|
+
|
|
3
|
+
Postgres backends for @workglow/storage and @workglow/job-queue.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Postgres implementation of `@workglow/storage` interfaces
|
|
8
|
+
- Postgres implementation of `@workglow/job-queue` interfaces
|
|
9
|
+
- Persistent storage for tasks, vectors, and queues
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @workglow/postgres
|
|
15
|
+
# or
|
|
16
|
+
bun add @workglow/postgres
|
|
17
|
+
# or
|
|
18
|
+
yarn add @workglow/postgres
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { PostgresTabularStorage } from "@workglow/postgres/storage";
|
|
25
|
+
import { PostgresQueueStorage } from "@workglow/postgres/job-queue";
|
|
26
|
+
|
|
27
|
+
const storage = new PostgresTabularStorage(connectionConfig);
|
|
28
|
+
const queue = new PostgresQueueStorage(connectionConfig);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
Apache 2.0 - See [LICENSE](../../LICENSE) for details.
|
|
@@ -22,29 +22,22 @@ export declare class PostgresQueueStorage<Input, Output> implements IQueueStorag
|
|
|
22
22
|
/** The table name for the job queue */
|
|
23
23
|
protected readonly tableName: string;
|
|
24
24
|
constructor(db: Pool, queueName: string, options?: QueueStorageOptions);
|
|
25
|
+
/** WHERE-clause helper specialized for this instance's dialect + prefix values. */
|
|
26
|
+
private buildPrefixWhereClause;
|
|
27
|
+
/** Returns prefix values in column order. */
|
|
28
|
+
private getPrefixParamValues;
|
|
25
29
|
/**
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Builds the prefix columns SQL for CREATE TABLE
|
|
31
|
-
*/
|
|
32
|
-
private buildPrefixColumnsSql;
|
|
33
|
-
/**
|
|
34
|
-
* Builds prefix column names for use in queries
|
|
35
|
-
*/
|
|
36
|
-
private getPrefixColumnNames;
|
|
37
|
-
/**
|
|
38
|
-
* Builds WHERE clause conditions for prefix filtering
|
|
39
|
-
* @param startParam - The starting parameter number for parameterized queries
|
|
40
|
-
* @returns Object with conditions string and parameter values
|
|
30
|
+
* Returns the versioned migrations that this storage's table layout depends
|
|
31
|
+
* on. Callers can compose them with other storages' migrations under a
|
|
32
|
+
* shared {@link PostgresMigrationRunner}; otherwise call {@link migrate}.
|
|
41
33
|
*/
|
|
42
|
-
|
|
34
|
+
getMigrations(): import("@workglow/storage").IMigration<Pool>[];
|
|
43
35
|
/**
|
|
44
|
-
*
|
|
36
|
+
* Applies any pending migrations for this queue's table. Idempotent —
|
|
37
|
+
* already-applied versions are recorded in `_storage_migrations` and
|
|
38
|
+
* skipped on subsequent calls.
|
|
45
39
|
*/
|
|
46
|
-
|
|
47
|
-
setupDatabase(): Promise<void>;
|
|
40
|
+
migrate(): Promise<void>;
|
|
48
41
|
/**
|
|
49
42
|
* Channel name for this storage's LISTEN/NOTIFY. Mirrors the trigger's
|
|
50
43
|
* computation so subscriber and notifier agree.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresQueueStorage.d.ts","sourceRoot":"","sources":["../../src/job-queue/PostgresQueueStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgresQueueStorage.d.ts","sourceRoot":"","sources":["../../src/job-queue/PostgresQueueStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EACV,aAAa,EACb,gBA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IAED;;;;OAIG;IACU,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAW3F;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,kBAAkB,CACvB,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAC7D,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,IAAI,CA+JZ;CACF"}
|
|
@@ -23,28 +23,18 @@ export declare class PostgresRateLimiterStorage implements IRateLimiterStorage {
|
|
|
23
23
|
/** The table name for next available times */
|
|
24
24
|
protected readonly nextAvailableTableName: string;
|
|
25
25
|
constructor(db: Pool, options?: RateLimiterStorageOptions);
|
|
26
|
-
/**
|
|
27
|
-
* Gets the SQL column type for a prefix column.
|
|
28
|
-
*/
|
|
29
|
-
private getPrefixColumnType;
|
|
30
|
-
/**
|
|
31
|
-
* Builds the prefix columns SQL for CREATE TABLE.
|
|
32
|
-
*/
|
|
33
|
-
private buildPrefixColumnsSql;
|
|
34
|
-
/**
|
|
35
|
-
* Builds prefix column names for use in queries.
|
|
36
|
-
*/
|
|
37
|
-
private getPrefixColumnNames;
|
|
38
|
-
/**
|
|
39
|
-
* Builds WHERE clause conditions for prefix filtering.
|
|
40
|
-
* @param startParam - The starting parameter number for parameterized queries
|
|
41
|
-
*/
|
|
26
|
+
/** WHERE-clause helper specialized for the Postgres dialect. */
|
|
42
27
|
private buildPrefixWhereClause;
|
|
28
|
+
/** Returns prefix values in column order. */
|
|
29
|
+
private getPrefixParamValues;
|
|
43
30
|
/**
|
|
44
|
-
*
|
|
31
|
+
* Returns the versioned migrations that this storage's tables depend on.
|
|
32
|
+
* Callers can compose them with other storages' migrations under a shared
|
|
33
|
+
* {@link PostgresMigrationRunner}; otherwise call {@link migrate}.
|
|
45
34
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
getMigrations(): import("@workglow/storage").IMigration<Pool>[];
|
|
36
|
+
/** Applies any pending migrations for this rate limiter's tables. */
|
|
37
|
+
migrate(): Promise<void>;
|
|
48
38
|
tryReserveExecution(queueName: string, maxExecutions: number, windowMs: number): Promise<unknown | null>;
|
|
49
39
|
releaseExecution(queueName: string, token: unknown): Promise<void>;
|
|
50
40
|
recordExecution(queueName: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresRateLimiterStorage.d.ts","sourceRoot":"","sources":["../../src/job-queue/PostgresRateLimiterStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgresRateLimiterStorage.d.ts","sourceRoot":"","sources":["../../src/job-queue/PostgresRateLimiterStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAW7B,eAAO,MAAM,6BAA6B,4DAEzC,CAAC;AAEF;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAYlE,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI;IAX7B,SAAgB,KAAK,EAAE,uBAAuB,CAAa;IAC3D,oCAAoC;IACpC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IACrD,sCAAsC;IACtC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,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