@workflow/world-postgres 4.1.0-beta.5 → 4.1.0-beta.51

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 (60) hide show
  1. package/README.md +48 -8
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +14 -13
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts +12 -2
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/drizzle/cbor.d.ts +38 -0
  8. package/dist/drizzle/cbor.d.ts.map +1 -0
  9. package/dist/drizzle/cbor.js +10 -0
  10. package/dist/drizzle/cbor.js.map +1 -0
  11. package/dist/drizzle/index.d.ts +4 -2
  12. package/dist/drizzle/index.d.ts.map +1 -1
  13. package/dist/drizzle/index.js +3 -3
  14. package/dist/drizzle/index.js.map +1 -1
  15. package/dist/drizzle/schema.d.ts +756 -59
  16. package/dist/drizzle/schema.d.ts.map +1 -1
  17. package/dist/drizzle/schema.js +68 -37
  18. package/dist/drizzle/schema.js.map +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +24 -9
  21. package/dist/index.js.map +1 -1
  22. package/dist/message.d.ts +16 -0
  23. package/dist/message.d.ts.map +1 -0
  24. package/dist/{boss.js → message.js} +7 -6
  25. package/dist/message.js.map +1 -0
  26. package/dist/queue.d.ts +8 -6
  27. package/dist/queue.d.ts.map +1 -1
  28. package/dist/queue.js +306 -57
  29. package/dist/queue.js.map +1 -1
  30. package/dist/storage.d.ts.map +1 -1
  31. package/dist/storage.js +989 -219
  32. package/dist/storage.js.map +1 -1
  33. package/dist/streamer.d.ts +13 -2
  34. package/dist/streamer.d.ts.map +1 -1
  35. package/dist/streamer.js +184 -12
  36. package/dist/streamer.js.map +1 -1
  37. package/dist/zod.d.ts +1 -1
  38. package/dist/zod.d.ts.map +1 -1
  39. package/dist/zod.js +1 -1
  40. package/dist/zod.js.map +1 -1
  41. package/package.json +22 -19
  42. package/src/drizzle/migrations/{0000_redundant_smasher.sql → 0000_cultured_the_anarchist.sql} +17 -13
  43. package/src/drizzle/migrations/0001_tricky_sersi.sql +11 -0
  44. package/src/drizzle/migrations/0002_add_expired_at.sql +2 -0
  45. package/src/drizzle/migrations/0003_add_stream_run_id.sql +3 -0
  46. package/src/drizzle/migrations/0004_remove_run_pause_status.sql +14 -0
  47. package/src/drizzle/migrations/0005_add_spec_version.sql +5 -0
  48. package/src/drizzle/migrations/0006_add_error_cbor.sql +5 -0
  49. package/src/drizzle/migrations/0007_add_waits_table.sql +13 -0
  50. package/src/drizzle/migrations/0008_migrate_pgboss_to_graphile.sql +20 -0
  51. package/src/drizzle/migrations/0009_add_is_webhook.sql +1 -0
  52. package/src/drizzle/migrations/meta/0000_snapshot.json +499 -0
  53. package/src/drizzle/migrations/meta/0001_snapshot.json +548 -0
  54. package/src/drizzle/migrations/meta/0002_snapshot.json +554 -0
  55. package/src/drizzle/migrations/meta/0003_snapshot.json +576 -0
  56. package/src/drizzle/migrations/meta/0005_snapshot.json +575 -0
  57. package/src/drizzle/migrations/meta/_journal.json +76 -0
  58. package/dist/boss.d.ts +0 -15
  59. package/dist/boss.d.ts.map +0 -1
  60. package/dist/boss.js.map +0 -1
package/README.md CHANGED
@@ -35,12 +35,16 @@ export WORKFLOW_POSTGRES_JOB_PREFIX="myapp"
35
35
 
36
36
  # Optional: Worker concurrency (default: 10)
37
37
  export WORKFLOW_POSTGRES_WORKER_CONCURRENCY="10"
38
+
39
+ # Optional: Internal pg.Pool max size (default: 10)
40
+ export WORKFLOW_POSTGRES_MAX_POOL_SIZE="10"
38
41
  ```
39
42
 
40
43
  ### Programmatic Usage
41
44
 
42
45
  You can also create a PostgreSQL world directly in your code:
43
46
 
47
+ <!-- @skip-typecheck: incomplete code sample -->
44
48
  ```typescript
45
49
  import { createWorld } from "@workflow/world-postgres";
46
50
 
@@ -48,16 +52,24 @@ const world = createWorld({
48
52
  connectionString: "postgres://username:password@localhost:5432/database",
49
53
  jobPrefix: "myapp", // optional
50
54
  queueConcurrency: 10, // optional
55
+ maxPoolSize: 10, // optional, overrides WORKFLOW_POSTGRES_MAX_POOL_SIZE when `pool` is omitted
51
56
  });
57
+
58
+ // Or pass an existing pg.Pool (shared with your app Drizzle, etc.); `world.close()` will not end it.
59
+ import { Pool } from "pg";
60
+ const pool = new Pool({ connectionString: process.env.DATABASE_URL });
61
+ const worldFromPool = createWorld({ pool });
52
62
  ```
53
63
 
54
64
  ## Configuration Options
55
65
 
56
- | Option | Type | Default | Description |
57
- | ------------------ | -------- | -------------------------------------------------------------------------------------- | ----------------------------------- |
58
- | `connectionString` | `string` | `process.env.WORKFLOW_POSTGRES_URL` or `'postgres://world:world@localhost:5432/world'` | PostgreSQL connection string |
59
- | `jobPrefix` | `string` | `process.env.WORKFLOW_POSTGRES_JOB_PREFIX` | Optional prefix for queue job names |
60
- | `queueConcurrency` | `number` | `10` | Number of concurrent queue workers |
66
+ | Option | Type | Default | Description |
67
+ | ------------------ | --------- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
68
+ | `connectionString` | `string` | `process.env.WORKFLOW_POSTGRES_URL` or `'postgres://world:world@localhost:5432/world'` | Used only when `pool` is omitted, to construct an internal pool |
69
+ | `maxPoolSize` | `number` | `process.env.WORKFLOW_POSTGRES_MAX_POOL_SIZE` or `pg.Pool` default (`10`) | Optional. Sets the internal `pg.Pool` max size when `createWorld()` creates the pool |
70
+ | `pool` | `pg.Pool` | — | Optional. When set, used for Drizzle, Graphile Worker, and stream writes. `world.close()` does not end it. |
71
+ | `jobPrefix` | `string` | `process.env.WORKFLOW_POSTGRES_JOB_PREFIX` | Optional prefix for queue job names |
72
+ | `queueConcurrency` | `number` | `10` | Number of concurrent active step executions per process |
61
73
 
62
74
  ## Environment Variables
63
75
 
@@ -67,14 +79,19 @@ const world = createWorld({
67
79
  | `WORKFLOW_POSTGRES_URL` | PostgreSQL connection string | `'postgres://world:world@localhost:5432/world'` |
68
80
  | `WORKFLOW_POSTGRES_JOB_PREFIX` | Prefix for queue job names | - |
69
81
  | `WORKFLOW_POSTGRES_WORKER_CONCURRENCY` | Number of concurrent workers | `10` |
82
+ | `WORKFLOW_POSTGRES_MAX_POOL_SIZE` | Internal `pg.Pool` max size | `10` |
83
+
84
+ When `pool` is omitted, `maxPoolSize` precedence is: `createWorld({ maxPoolSize })`, then `WORKFLOW_POSTGRES_MAX_POOL_SIZE`, then the `pg.Pool` default.
85
+
86
+ For higher worker concurrency, Graphile Worker recommends setting `maxPoolSize` to `10` or `queueConcurrency + 2`, whichever is larger.
70
87
 
71
88
  ## Database Setup
72
89
 
73
90
  This package uses PostgreSQL with the following components:
74
91
 
75
- - **pg-boss**: For queue processing and job management
92
+ - **graphile-worker**: For queue processing and job management
76
93
  - **Drizzle ORM**: For database operations and schema management
77
- - **postgres**: For PostgreSQL client connections
94
+ - **pg** (node-postgres): For PostgreSQL client connections. Drizzle and Graphile Worker share a `pg.Pool`, while LISTEN uses a dedicated `pg.Client` created from the same connection options.
78
95
 
79
96
  ### Quick Setup with CLI
80
97
 
@@ -114,11 +131,20 @@ Make sure your PostgreSQL database is accessible and the user has sufficient per
114
131
  ## Features
115
132
 
116
133
  - **Durable Storage**: Stores workflow runs, events, steps, hooks, and webhooks in PostgreSQL
117
- - **Queue Processing**: Uses pg-boss for reliable job queue processing
134
+ - **Queue Processing**: Uses graphile-worker as the durable queue and executes jobs over the workflow HTTP routes
135
+ - **Durable Delays**: Re-schedules waits and retries in PostgreSQL
118
136
  - **Streaming**: Real-time event streaming capabilities
119
137
  - **Health Checks**: Built-in connection health monitoring
120
138
  - **Configurable Concurrency**: Adjustable worker concurrency for queue processing
121
139
 
140
+ ## Queue Behavior
141
+
142
+
143
+ - Graphile jobs are acknowledged only after the workflow or step execution finishes, or after the worker durably schedules a delayed follow-up job
144
+ - Backlog stays in PostgreSQL when all execution slots are busy
145
+ - Retry and sleep-style delays use Graphile `runAt` scheduling
146
+ - Workflow and step execution is sent through `/.well-known/workflow/v1/flow` and `/.well-known/workflow/v1/step`
147
+
122
148
  ## Development
123
149
 
124
150
  For local development, you can use the included Docker Compose configuration:
@@ -136,6 +162,20 @@ export WORKFLOW_POSTGRES_URL="postgres://world:world@localhost:5432/world"
136
162
  export WORKFLOW_TARGET_WORLD="@workflow/world-postgres"
137
163
  ```
138
164
 
165
+ ## Testing
166
+
167
+ Integration tests use [Testcontainers](https://testcontainers.com/) to start a PostgreSQL container. **Docker must be installed and running** before you run tests.
168
+
169
+ - **Linux/macOS**: Start the Docker daemon (e.g. `sudo systemctl start docker` or Docker Desktop).
170
+ - **WSL2**: Use Docker Desktop with WSL2 integration, or run the Docker engine inside WSL and ensure the daemon is started. Verify with `docker info`.
171
+
172
+ Then from the package directory:
173
+
174
+ ```bash
175
+ pnpm build
176
+ pnpm test
177
+ ```
178
+
139
179
  ## World Selection
140
180
 
141
181
  To use the PostgreSQL world, set the `WORKFLOW_TARGET_WORLD` environment variable to the package name:
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAQA,iBAAe,aAAa,kBA+C3B;AAOD,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AASA,iBAAe,aAAa,kBA8C3B;AAOD,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/dist/cli.js CHANGED
@@ -1,8 +1,9 @@
1
- import { readFile } from 'node:fs/promises';
2
1
  import { dirname, join } from 'node:path';
3
2
  import { fileURLToPath } from 'node:url';
4
3
  import { config } from 'dotenv';
5
- import postgres from 'postgres';
4
+ import { drizzle } from 'drizzle-orm/node-postgres';
5
+ import { migrate } from 'drizzle-orm/node-postgres/migrator';
6
+ import { Pool } from 'pg';
6
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
7
8
  async function setupDatabase() {
8
9
  // Load .env file if it exists
@@ -12,26 +13,26 @@ async function setupDatabase() {
12
13
  'postgres://world:world@localhost:5432/world';
13
14
  console.log('🔧 Setting up database schema...');
14
15
  console.log(`📍 Connection: ${connectionString.replace(/^(\w+:\/\/)([^@]+)@/, '$1[redacted]@')}`);
16
+ const pool = new Pool({ connectionString, max: 1 });
17
+ const db = drizzle(pool);
15
18
  try {
16
- const sql = postgres(connectionString);
17
19
  // Read the migration SQL file
18
20
  // The migrations are in src/drizzle/migrations, and this CLI is in dist/
19
21
  // So we need to go up one level from dist/ to reach src/
20
- const migrationPath = join(__dirname, '..', 'src', 'drizzle', 'migrations', '0000_redundant_smasher.sql');
21
- const migrationSQL = await readFile(migrationPath, 'utf-8');
22
+ const migrationsFolder = join(__dirname, '..', 'src', 'drizzle', 'migrations');
23
+ console.log(`📂 Running migrations from: ${migrationsFolder}`);
22
24
  // Execute the migration
23
- await sql.unsafe(migrationSQL);
25
+ await migrate(db, {
26
+ migrationsFolder,
27
+ migrationsTable: 'workflow_migrations',
28
+ migrationsSchema: 'workflow_drizzle',
29
+ });
24
30
  console.log('✅ Database schema created successfully!');
25
- console.log('\nCreated tables:');
26
- console.log(' - workflow_runs');
27
- console.log(' - workflow_events');
28
- console.log(' - workflow_steps');
29
- console.log(' - workflow_hooks');
30
- console.log(' - workflow_stream_chunks');
31
- await sql.end();
31
+ await pool.end();
32
32
  process.exit(0);
33
33
  }
34
34
  catch (error) {
35
+ await pool.end().catch(() => { });
35
36
  console.error('❌ Failed to setup database:', error);
36
37
  process.exit(1);
37
38
  }
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ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type PgConnectionConfig = {
2
3
  connectionString: string;
4
+ maxPoolSize?: number;
5
+ pool?: undefined;
6
+ } | {
7
+ pool: Pool;
8
+ connectionString?: undefined;
9
+ maxPoolSize?: undefined;
10
+ };
11
+ export type PostgresWorldConfig = PgConnectionConfig & {
3
12
  jobPrefix?: string;
4
13
  queueConcurrency?: number;
5
- }
14
+ };
15
+ export {};
6
16
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,KAAK,kBAAkB,GACnB;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAAC,WAAW,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAE1E,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC"}
@@ -0,0 +1,38 @@
1
+ export declare function Cbor<T>(): {
2
+ (): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
3
+ name: "";
4
+ dataType: "custom";
5
+ columnType: "PgCustomColumn";
6
+ data: T;
7
+ driverParam: Buffer<ArrayBufferLike>;
8
+ enumValues: undefined;
9
+ }>;
10
+ <TConfig extends Record<string, any>>(fieldConfig?: TConfig | undefined): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
11
+ name: "";
12
+ dataType: "custom";
13
+ columnType: "PgCustomColumn";
14
+ data: T;
15
+ driverParam: Buffer<ArrayBufferLike>;
16
+ enumValues: undefined;
17
+ }>;
18
+ <TName extends string>(dbName: TName, fieldConfig?: unknown): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
19
+ name: TName;
20
+ dataType: "custom";
21
+ columnType: "PgCustomColumn";
22
+ data: T;
23
+ driverParam: Buffer<ArrayBufferLike>;
24
+ enumValues: undefined;
25
+ }>;
26
+ };
27
+ /**
28
+ * Adds a `{key}Json` property to the given type V, representing a key that was
29
+ * migrated to CBOR and can contain a previous JSONB representation.
30
+ *
31
+ * We migrated from JSONB to CBOR, but to avoid breaking changes in the codebase,
32
+ * we keep both representations in the database, and therefore we need to extend
33
+ * the types accordingly.
34
+ */
35
+ export type Cborized<V extends object, K extends keyof V> = V & {
36
+ [key in `${Extract<K, string>}Json`]: unknown;
37
+ };
38
+ //# sourceMappingURL=cbor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor.d.ts","sourceRoot":"","sources":["../../src/drizzle/cbor.ts"],"names":[],"mappings":"AAGA,wBAAgB,IAAI,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;EAMrB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG;KAC7D,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,OAAO;CAC9C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { decode, encode } from 'cbor-x';
2
+ import { customType } from 'drizzle-orm/pg-core';
3
+ export function Cbor() {
4
+ return customType({
5
+ dataType: () => 'bytea',
6
+ fromDriver: (value) => decode(value),
7
+ toDriver: (value) => encode(value),
8
+ });
9
+ }
10
+ //# sourceMappingURL=cbor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor.js","sourceRoot":"","sources":["../../src/drizzle/cbor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,UAAU,IAAI;IAClB,OAAO,UAAU,CAAkC;QACjD,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO;QACvB,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;QACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;KACnC,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +1,8 @@
1
- import type Postgres from 'postgres';
1
+ import type { Pool } from 'pg';
2
2
  import * as Schema from './schema.js';
3
3
  export { Schema };
4
4
  export type Drizzle = ReturnType<typeof createClient>;
5
- export declare function createClient(postgres: Postgres.Sql): import("drizzle-orm/postgres-js").PostgresJsDatabase<typeof Schema>;
5
+ export declare function createClient(pool: Pool): import("drizzle-orm/node-postgres").NodePgDatabase<typeof Schema> & {
6
+ $client: Pool;
7
+ };
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drizzle/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACtD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,uEAElD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/drizzle/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAEtD,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI;;EAEtC"}
@@ -1,7 +1,7 @@
1
- import { drizzle } from 'drizzle-orm/postgres-js';
1
+ import { drizzle } from 'drizzle-orm/node-postgres';
2
2
  import * as Schema from './schema.js';
3
3
  export { Schema };
4
- export function createClient(postgres) {
5
- return drizzle(postgres, { schema: Schema });
4
+ export function createClient(pool) {
5
+ return drizzle(pool, { schema: Schema });
6
6
  }
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/drizzle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,CAAC;AAGlB,MAAM,UAAU,YAAY,CAAC,QAAsB;IACjD,OAAO,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAC/C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/drizzle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,CAAC;AAIlB,MAAM,UAAU,YAAY,CAAC,IAAU;IACrC,OAAO,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3C,CAAC"}