@pgflow/core 0.0.0-test-snapshot-releases-8d5d9bc1-20250922101013 → 0.0.0-testsnap-9294d743-20251207205914
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 +177 -73
- package/dist/ATLAS.md +32 -0
- package/dist/CHANGELOG.md +824 -0
- package/dist/PgflowSqlClient.d.ts +17 -0
- package/dist/PgflowSqlClient.d.ts.map +1 -0
- package/dist/PgflowSqlClient.js +70 -0
- package/dist/README.md +497 -0
- package/dist/database-types.d.ts +1041 -0
- package/dist/database-types.d.ts.map +1 -0
- package/dist/database-types.js +8 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/package.json +31 -0
- package/dist/supabase/migrations/20250429164909_pgflow_initial.sql +579 -0
- package/dist/supabase/migrations/20250517072017_pgflow_fix_poll_for_tasks_to_use_separate_statement_for_polling.sql +101 -0
- package/dist/supabase/migrations/20250609105135_pgflow_add_start_tasks_and_started_status.sql +371 -0
- package/dist/supabase/migrations/20250610180554_pgflow_add_set_vt_batch_and_use_it_in_start_tasks.sql +127 -0
- package/dist/supabase/migrations/20250614124241_pgflow_add_realtime.sql +501 -0
- package/dist/supabase/migrations/20250619195327_pgflow_fix_fail_task_missing_realtime_event.sql +185 -0
- package/dist/supabase/migrations/20250627090700_pgflow_fix_function_search_paths.sql +6 -0
- package/dist/supabase/migrations/20250707210212_pgflow_add_opt_start_delay.sql +103 -0
- package/dist/supabase/migrations/20250719205006_pgflow_worker_deprecation.sql +2 -0
- package/dist/supabase/migrations/20251006073122_pgflow_add_map_step_type.sql +1244 -0
- package/dist/supabase/migrations/20251103222045_pgflow_fix_broadcast_order_and_timestamp_handling.sql +622 -0
- package/dist/supabase/migrations/20251104080523_pgflow_upgrade_pgmq_1_5_1.sql +93 -0
- package/dist/supabase/migrations/20251130000000_pgflow_auto_compilation.sql +268 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/dist/types.d.ts +93 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +4 -5
|
@@ -0,0 +1,824 @@
|
|
|
1
|
+
# @pgflow/core
|
|
2
|
+
|
|
3
|
+
## 0.0.0-testsnap-9294d743-20251207205914
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0b84bb0: Add automatic flow compilation at worker startup. Workers now call ensure_flow_compiled to verify flows are up-to-date. In development, mismatched flows are recompiled automatically. In production, mismatches cause errors. Use ensureCompiledOnStartup: false to opt-out.
|
|
8
|
+
- Updated dependencies [0b84bb0]
|
|
9
|
+
- @pgflow/dsl@0.0.0-testsnap-9294d743-20251207205914
|
|
10
|
+
|
|
11
|
+
## 0.9.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [992a86b]
|
|
16
|
+
- @pgflow/dsl@0.9.1
|
|
17
|
+
|
|
18
|
+
## 0.9.0
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- @pgflow/dsl@0.9.0
|
|
23
|
+
|
|
24
|
+
## 0.8.1
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- f1d3c32: Fix incorrect Supabase CLI version requirement from 2.34.3 to 2.50.3. CLI 2.50.3 is the first version to include pgmq 1.5.0+, which is required for pgflow 0.8.0+.
|
|
29
|
+
- @pgflow/dsl@0.8.1
|
|
30
|
+
|
|
31
|
+
## 0.8.0
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- 7380237: BREAKING CHANGE: pgflow 0.8.0 requires pgmq 1.5.0+, PostgreSQL 17, and Supabase CLI 2.50.3+
|
|
36
|
+
|
|
37
|
+
This version modernizes infrastructure dependencies and will NOT work with pgmq 1.4.x or earlier. The migration includes a compatibility check that aborts with a clear error message if requirements are not met.
|
|
38
|
+
|
|
39
|
+
**Requirements:**
|
|
40
|
+
|
|
41
|
+
- pgmq 1.5.0 or higher (previously supported 1.4.x)
|
|
42
|
+
- PostgreSQL 17 (from 15)
|
|
43
|
+
- Supabase CLI 2.50.3 or higher (includes pgmq 1.5.0+)
|
|
44
|
+
|
|
45
|
+
**For Supabase users:** Upgrade your Supabase CLI to 2.50.3+ which includes pgmq 1.5.0 by default.
|
|
46
|
+
|
|
47
|
+
**For self-hosted users:** Upgrade pgmq to 1.5.0+ and PostgreSQL to 17 before upgrading pgflow.
|
|
48
|
+
|
|
49
|
+
**If you cannot upgrade immediately:** Stay on pgflow 0.7.x until your infrastructure is ready. The migration safety check ensures you cannot accidentally upgrade to an incompatible version.
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- @pgflow/dsl@0.8.0
|
|
54
|
+
|
|
55
|
+
## 0.7.3
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- @pgflow/dsl@0.7.3
|
|
60
|
+
|
|
61
|
+
## 0.7.2
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- c22a1e5: Fix missing realtime broadcasts for step:started and step:completed events
|
|
66
|
+
|
|
67
|
+
**Critical bug fix:** Clients were not receiving `step:started` events when steps transitioned to Started status, and `step:completed` events for empty map steps and cascade completions were also missing.
|
|
68
|
+
|
|
69
|
+
**Root cause:** PostgreSQL query optimizer was eliminating CTEs containing `realtime.send()` calls because they were not referenced by subsequent operations or the final RETURN statement.
|
|
70
|
+
|
|
71
|
+
**Solution:** Moved `realtime.send()` calls directly into RETURNING clauses of UPDATE statements, ensuring they execute atomically with state changes and cannot be optimized away.
|
|
72
|
+
|
|
73
|
+
**Changes:**
|
|
74
|
+
|
|
75
|
+
- `start_ready_steps()`: Broadcasts step:started and step:completed events in RETURNING clauses
|
|
76
|
+
- `cascade_complete_taskless_steps()`: Broadcasts step:completed events atomically with cascade completion
|
|
77
|
+
- `complete_task()`: Added PERFORM statements for run:failed and step:failed broadcasts
|
|
78
|
+
- Client: Added `applySnapshot()` methods to FlowRun and FlowStep for proper initial state hydration without event emission
|
|
79
|
+
- @pgflow/dsl@0.7.2
|
|
80
|
+
|
|
81
|
+
## 0.7.1
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- a71b371: Fix installation failures on new Supabase projects by removing pgmq version pin.
|
|
86
|
+
|
|
87
|
+
Supabase upgraded to pgmq 1.5.1 in Postgres 17.6.1.016+ (https://github.com/supabase/postgres/pull/1668), but pgflow was pinned to 1.4.4, causing "extension has no installation script" errors on fresh instances.
|
|
88
|
+
|
|
89
|
+
Only affects new projects - existing installations are unaffected and require no action.
|
|
90
|
+
|
|
91
|
+
Thanks to @kallebysantos for reporting this issue!
|
|
92
|
+
|
|
93
|
+
- @pgflow/dsl@0.7.1
|
|
94
|
+
|
|
95
|
+
## 0.7.0
|
|
96
|
+
|
|
97
|
+
### Minor Changes
|
|
98
|
+
|
|
99
|
+
- 524db03: Add map step type infrastructure in SQL core
|
|
100
|
+
|
|
101
|
+
⚠️ **This migration includes automatic data migration**
|
|
102
|
+
|
|
103
|
+
The migration will automatically update existing `step_states` rows to satisfy new constraints. This should complete without issues due to strict check constraints enforced in previous versions.
|
|
104
|
+
|
|
105
|
+
💡 **Recommended: Verify before deploying to production**
|
|
106
|
+
|
|
107
|
+
If you have existing production data and want to verify the migration will succeed cleanly, run this **read-only check query** (does not modify data) in **Supabase Studio** against your **production database**:
|
|
108
|
+
|
|
109
|
+
1. Open Supabase Studio → SQL Editor
|
|
110
|
+
2. Copy contents of `pkgs/core/queries/PRE_MIGRATION_CHECK_20251006073122.sql`
|
|
111
|
+
3. Execute against your production database (not local dev!)
|
|
112
|
+
4. Review results
|
|
113
|
+
|
|
114
|
+
**Expected output for successful migration:**
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
type | identifier | details
|
|
118
|
+
---------------------------|---------------------------|------------------------------------------
|
|
119
|
+
DATA_BACKFILL_STARTED | run=def67890 step=process | initial_tasks will be set to 1 (...)
|
|
120
|
+
DATA_BACKFILL_COMPLETED | Found 100 completed steps | initial_tasks will be set to 1 (...)
|
|
121
|
+
INFO_SUMMARY | total_step_states=114 | created=0 started=1 completed=113 failed=0
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Interpretation:**
|
|
125
|
+
|
|
126
|
+
- ✅ Only `DATA_BACKFILL_*` and `INFO_SUMMARY` rows? **Safe to migrate**
|
|
127
|
+
- ⚠️ These are expected data migrations handled automatically by the migration
|
|
128
|
+
- 🆘 Unexpected rows or errors? Copy output and share on Discord for help
|
|
129
|
+
|
|
130
|
+
📝 **Note:** This check identifies data that needs migration but does not modify anything. Only useful for production databases with existing runs.
|
|
131
|
+
|
|
132
|
+
**Automatic data updates:**
|
|
133
|
+
|
|
134
|
+
- Sets `initial_tasks = 1` for all existing steps (correct for pre-map-step schema)
|
|
135
|
+
- Sets `remaining_tasks = NULL` for 'created' status steps (new semantics)
|
|
136
|
+
|
|
137
|
+
No manual intervention required.
|
|
138
|
+
|
|
139
|
+
***
|
|
140
|
+
|
|
141
|
+
## Changes
|
|
142
|
+
|
|
143
|
+
This patch introduces the foundation for map step functionality in the SQL core layer:
|
|
144
|
+
|
|
145
|
+
### Schema Changes
|
|
146
|
+
|
|
147
|
+
- Added `step_type` column to `steps` table with constraint allowing 'single' or 'map' values
|
|
148
|
+
- Added `initial_tasks` column to `step_states` table (defaults to 1, stores planned task count)
|
|
149
|
+
- Modified `remaining_tasks` column to be nullable (NULL = not started, >0 = active countdown)
|
|
150
|
+
- Added constraint `remaining_tasks_state_consistency` to ensure `remaining_tasks` is only set when step has started
|
|
151
|
+
- Removed `only_single_task_per_step` constraint from `step_tasks` table to allow multiple tasks per step
|
|
152
|
+
|
|
153
|
+
### Function Updates
|
|
154
|
+
|
|
155
|
+
- **`add_step()`**: Now accepts `step_type` parameter (defaults to 'single') with validation that map steps can have at most 1 dependency
|
|
156
|
+
- **`start_flow()`**: Sets `initial_tasks = 1` for all steps (map step array handling will come in future phases)
|
|
157
|
+
- **`start_ready_steps()`**: Copies `initial_tasks` to `remaining_tasks` when starting a step, maintaining proper task counting semantics
|
|
158
|
+
|
|
159
|
+
### Testing
|
|
160
|
+
|
|
161
|
+
- Added comprehensive test coverage for map step creation and validation
|
|
162
|
+
- All existing tests pass with the new schema changes
|
|
163
|
+
- Tests validate the new step_type parameter and dependency constraints for map steps
|
|
164
|
+
|
|
165
|
+
This is Phase 2a of the map step implementation, establishing the SQL infrastructure needed for parallel task execution in future phases.
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- 524db03: Improve failure handling and prevent orphaned messages in queue
|
|
170
|
+
|
|
171
|
+
- Archive all queued messages when a run fails to prevent resource waste
|
|
172
|
+
- Handle type constraint violations gracefully without exceptions
|
|
173
|
+
- Store output on failed tasks (including type violations) for debugging
|
|
174
|
+
- Add performance index for efficient message archiving
|
|
175
|
+
- Prevent retries on already-failed runs
|
|
176
|
+
- Update table constraint to allow output storage on failed tasks
|
|
177
|
+
|
|
178
|
+
- Updated dependencies [524db03]
|
|
179
|
+
- Updated dependencies [524db03]
|
|
180
|
+
- @pgflow/dsl@0.7.0
|
|
181
|
+
|
|
182
|
+
## 0.6.1
|
|
183
|
+
|
|
184
|
+
### Patch Changes
|
|
185
|
+
|
|
186
|
+
- @pgflow/dsl@0.6.1
|
|
187
|
+
|
|
188
|
+
## 0.6.0
|
|
189
|
+
|
|
190
|
+
### Patch Changes
|
|
191
|
+
|
|
192
|
+
- 81d552f: Implement worker deprecation for graceful shutdowns
|
|
193
|
+
|
|
194
|
+
- Add deprecation support to enable zero-downtime deployments
|
|
195
|
+
- Workers now check deprecation status via heartbeat and stop accepting new work when deprecated
|
|
196
|
+
- Repurpose unused `stopped_at` column as `deprecated_at` for tracking deprecation timestamps
|
|
197
|
+
- Refactor heartbeat logic directly into lifecycle classes for improved type safety
|
|
198
|
+
- Add configurable heartbeat interval (default: 5 seconds)
|
|
199
|
+
- Workers complete in-flight work before shutting down when deprecated
|
|
200
|
+
|
|
201
|
+
- Updated dependencies [a67bf27]
|
|
202
|
+
- @pgflow/dsl@0.6.0
|
|
203
|
+
|
|
204
|
+
## 0.5.4
|
|
205
|
+
|
|
206
|
+
### Patch Changes
|
|
207
|
+
|
|
208
|
+
- Updated dependencies [9f219a4]
|
|
209
|
+
- @pgflow/dsl@0.5.4
|
|
210
|
+
|
|
211
|
+
## 0.5.3
|
|
212
|
+
|
|
213
|
+
### Patch Changes
|
|
214
|
+
|
|
215
|
+
- af787ff: Add `startDelay` option for workflow steps
|
|
216
|
+
|
|
217
|
+
Introduces the ability to delay a step's **initial execution** by a specified number of seconds, enabling multi-day workflows and scheduled tasks within pgflow.
|
|
218
|
+
|
|
219
|
+
**Important**: `startDelay` only applies to the first execution attempt. Retries use the standard exponential backoff mechanism based on `baseDelay`, not `startDelay`.
|
|
220
|
+
|
|
221
|
+
### Core Changes (@pgflow/core)
|
|
222
|
+
|
|
223
|
+
- Added `opt_start_delay` column (integer, nullable, CHECK >= 0) to `pgflow.steps` table
|
|
224
|
+
- Updated `add_step` function to accept and validate the new `start_delay` parameter
|
|
225
|
+
- Modified `start_ready_steps` to schedule initial task execution with delay via `pgmq.send(queue, message, delay)`
|
|
226
|
+
- Requires pgmq >= 0.40 for delay support
|
|
227
|
+
- Migration: `20250707210212_pgflow_add_opt_start_delay.sql`
|
|
228
|
+
- Added comprehensive PgTAP tests for validation and scheduling behavior
|
|
229
|
+
|
|
230
|
+
### DSL Changes (@pgflow/dsl)
|
|
231
|
+
|
|
232
|
+
- Extended `StepOptions` and `StepRuntimeOptions` interfaces with optional `startDelay` (in seconds)
|
|
233
|
+
- Updated `compileFlow()` to emit `start_delay => value` in generated SQL
|
|
234
|
+
- Added validation: `startDelay` is only allowed at step level, not flow level (prevents cascading delays)
|
|
235
|
+
- Valid range: 0 to 2,147,483,647 seconds (~68 years)
|
|
236
|
+
- Added unit tests for compilation and validation
|
|
237
|
+
|
|
238
|
+
### Documentation Updates (@pgflow/website)
|
|
239
|
+
|
|
240
|
+
- Added `startDelay` section in configuration guide with detailed explanation
|
|
241
|
+
- Created multi-day workflow example (onboarding email sequence)
|
|
242
|
+
- Updated "Update Flow Options" to include `opt_start_delay`
|
|
243
|
+
- Enhanced VS comparison pages to mention "Native step delays" capability
|
|
244
|
+
- Documented why `startDelay` is step-level only
|
|
245
|
+
|
|
246
|
+
### Example Usage
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
new Flow({
|
|
250
|
+
slug: 'user_onboarding',
|
|
251
|
+
maxAttempts: 3,
|
|
252
|
+
baseDelay: 5, // Retry delay (not initial delay)
|
|
253
|
+
timeout: 60,
|
|
254
|
+
})
|
|
255
|
+
.step(
|
|
256
|
+
{
|
|
257
|
+
slug: 'send_welcome_email',
|
|
258
|
+
// Executes immediately when step becomes ready
|
|
259
|
+
},
|
|
260
|
+
sendWelcomeHandler
|
|
261
|
+
)
|
|
262
|
+
.step(
|
|
263
|
+
{
|
|
264
|
+
slug: 'send_day_3_tips',
|
|
265
|
+
startDelay: 259200, // Wait 3 days before first execution
|
|
266
|
+
timeout: 120,
|
|
267
|
+
},
|
|
268
|
+
sendTipsHandler
|
|
269
|
+
)
|
|
270
|
+
.step(
|
|
271
|
+
{
|
|
272
|
+
slug: 'send_week_review',
|
|
273
|
+
startDelay: 604800, // Wait 7 days after dependencies complete
|
|
274
|
+
timeout: 120,
|
|
275
|
+
},
|
|
276
|
+
sendReviewHandler
|
|
277
|
+
);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Use Cases
|
|
281
|
+
|
|
282
|
+
- **Multi-day workflows**: Onboarding sequences, follow-up reminders
|
|
283
|
+
- **Scheduled notifications**: Send reports or alerts at specific intervals
|
|
284
|
+
- **Rate limiting**: Enforce minimum time between API calls
|
|
285
|
+
- **Compliance delays**: Cooling-off periods before actions
|
|
286
|
+
|
|
287
|
+
### Technical Notes
|
|
288
|
+
|
|
289
|
+
- Non-breaking, additive change (hence minor version bump)
|
|
290
|
+
- No changes required in `@pgflow/edge-worker` - delays handled by pgmq
|
|
291
|
+
- `startDelay` does not affect retry timing - only the initial execution
|
|
292
|
+
- Delays are reliable even across worker restarts (persisted in queue)
|
|
293
|
+
|
|
294
|
+
- Updated dependencies [af787ff]
|
|
295
|
+
- @pgflow/dsl@0.5.3
|
|
296
|
+
|
|
297
|
+
## 0.5.2
|
|
298
|
+
|
|
299
|
+
### Patch Changes
|
|
300
|
+
|
|
301
|
+
- @pgflow/dsl@0.5.2
|
|
302
|
+
|
|
303
|
+
## 0.5.1
|
|
304
|
+
|
|
305
|
+
### Patch Changes
|
|
306
|
+
|
|
307
|
+
- @pgflow/dsl@0.5.1
|
|
308
|
+
|
|
309
|
+
## 0.5.0
|
|
310
|
+
|
|
311
|
+
### Patch Changes
|
|
312
|
+
|
|
313
|
+
- @pgflow/dsl@0.5.0
|
|
314
|
+
|
|
315
|
+
## 0.4.3
|
|
316
|
+
|
|
317
|
+
### Patch Changes
|
|
318
|
+
|
|
319
|
+
- fa78968: Fix Supabase Security Advisor warnings by setting empty search_path on functions
|
|
320
|
+
- @pgflow/dsl@0.4.3
|
|
321
|
+
|
|
322
|
+
## 0.4.2
|
|
323
|
+
|
|
324
|
+
### Patch Changes
|
|
325
|
+
|
|
326
|
+
- 220c867: Fix step:failed events not being broadcast when steps fail
|
|
327
|
+
|
|
328
|
+
Fixed a bug where step:failed events were not being broadcast to real-time subscribers when a step failed permanently. The issue was caused by PostgreSQL optimizing away the CTE that contained the realtime.send() call. The fix replaces the CTE approach with a direct PERFORM statement in the function body, ensuring the event is always sent when a step fails.
|
|
329
|
+
|
|
330
|
+
- @pgflow/dsl@0.4.2
|
|
331
|
+
|
|
332
|
+
## 0.4.1
|
|
333
|
+
|
|
334
|
+
### Patch Changes
|
|
335
|
+
|
|
336
|
+
- 50ab557: feat: add multi-target build support for @pgflow/client package
|
|
337
|
+
|
|
338
|
+
The @pgflow/client package now builds for multiple environments, making it usable in Node.js, browsers, and bundlers.
|
|
339
|
+
|
|
340
|
+
**What's new:**
|
|
341
|
+
|
|
342
|
+
- ES modules (`.js`) and CommonJS (`.cjs`) builds for Node.js
|
|
343
|
+
- Browser bundle (`.browser.js`) with all dependencies included
|
|
344
|
+
- Full TypeScript declarations
|
|
345
|
+
- CDN support via unpkg
|
|
346
|
+
- Production builds with minification
|
|
347
|
+
- Proper tree-shaking support
|
|
348
|
+
- `@supabase/supabase-js` is now a regular dependency (not peer dependency)
|
|
349
|
+
|
|
350
|
+
**You can now use it in:**
|
|
351
|
+
|
|
352
|
+
- Node.js: `import { PgflowClient } from '@pgflow/client'`
|
|
353
|
+
- CommonJS: `const { PgflowClient } = require('@pgflow/client')`
|
|
354
|
+
- Browser: `<script src="https://unpkg.com/@pgflow/client"></script>` - then use `window.pgflow.createClient(supabase)`
|
|
355
|
+
- Bundlers: Automatically picks the right format
|
|
356
|
+
|
|
357
|
+
**Other changes:**
|
|
358
|
+
|
|
359
|
+
- Pin Supabase CLI to exact version 2.21.1 to ensure consistent type generation between local and CI environments
|
|
360
|
+
- @pgflow/dsl@0.4.1
|
|
361
|
+
|
|
362
|
+
## 0.4.0
|
|
363
|
+
|
|
364
|
+
### Minor Changes
|
|
365
|
+
|
|
366
|
+
- 98556d3: Add TypeScript client library for pgflow workflow management
|
|
367
|
+
|
|
368
|
+
## @pgflow/client
|
|
369
|
+
|
|
370
|
+
Introduces a new TypeScript client library that provides both event-based and promise-based APIs for interacting with pgflow workflows:
|
|
371
|
+
|
|
372
|
+
### Features
|
|
373
|
+
|
|
374
|
+
- **Type-safe workflow management** with full TypeScript support and automatic type inference from flow definitions
|
|
375
|
+
- **Dual API approach**: Choose between event-based subscriptions or promise-based async/await patterns
|
|
376
|
+
- **Real-time monitoring** via Supabase broadcasts with granular event subscriptions
|
|
377
|
+
- **Resource management** with automatic cleanup and disposal
|
|
378
|
+
- **Comprehensive error handling** and recovery mechanisms
|
|
379
|
+
|
|
380
|
+
### Core Components
|
|
381
|
+
|
|
382
|
+
- `PgflowClient` - Main client for starting and managing workflow runs
|
|
383
|
+
- `FlowRun` - Monitor and interact with workflow executions
|
|
384
|
+
- `FlowStep` - Track individual step progress and outputs
|
|
385
|
+
|
|
386
|
+
### Example Usage
|
|
387
|
+
|
|
388
|
+
```typescript
|
|
389
|
+
// Start a workflow
|
|
390
|
+
const pgflow = new PgflowClient(supabase);
|
|
391
|
+
const run = await pgflow.startFlow('analyze_website', {
|
|
392
|
+
url: 'https://example.com',
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// Event-based monitoring
|
|
396
|
+
run.on('completed', (event) => {
|
|
397
|
+
console.log('Workflow completed:', event.output);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// Promise-based monitoring
|
|
401
|
+
const completed = await run.waitForStatus(FlowRunStatus.Completed, {
|
|
402
|
+
timeoutMs: 30000,
|
|
403
|
+
});
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## @pgflow/core
|
|
407
|
+
|
|
408
|
+
### Database Enhancements
|
|
409
|
+
|
|
410
|
+
- Add `start_flow_with_states()` function to start flows and return complete initial state
|
|
411
|
+
- Add `get_run_with_states()` function to retrieve runs with all step states efficiently
|
|
412
|
+
- Implement `SECURITY DEFINER` functions for secure API access
|
|
413
|
+
- Add real-time broadcast support for workflow state changes
|
|
414
|
+
|
|
415
|
+
## @pgflow/edge-worker
|
|
416
|
+
|
|
417
|
+
### Test Infrastructure Updates
|
|
418
|
+
|
|
419
|
+
- Update test database configuration to use standard PostgreSQL credentials
|
|
420
|
+
- Improve test helper functions for database transactions
|
|
421
|
+
- Update Docker Compose configuration for test environment
|
|
422
|
+
|
|
423
|
+
## @pgflow/dsl
|
|
424
|
+
|
|
425
|
+
### Build Configuration
|
|
426
|
+
|
|
427
|
+
- Add TypeScript references to tsconfig.spec.json for improved type checking in tests
|
|
428
|
+
|
|
429
|
+
### Patch Changes
|
|
430
|
+
|
|
431
|
+
- Updated dependencies [98556d3]
|
|
432
|
+
- @pgflow/dsl@0.4.0
|
|
433
|
+
|
|
434
|
+
## 0.3.1
|
|
435
|
+
|
|
436
|
+
### Patch Changes
|
|
437
|
+
|
|
438
|
+
- d08fd2d: Optimize message visibility timeout updates with batch operations
|
|
439
|
+
|
|
440
|
+
- Added `pgflow.set_vt_batch()` function to update multiple message visibility timeouts in a single database call
|
|
441
|
+
- Replaced individual `pgmq.set_vt()` calls in `start_tasks()` with efficient batch updates
|
|
442
|
+
- Reduces database round-trips from N calls to 1 call when starting N tasks
|
|
443
|
+
- Improves performance and reduces database load during high-throughput task processing
|
|
444
|
+
- @pgflow/dsl@0.3.1
|
|
445
|
+
|
|
446
|
+
## 0.3.0
|
|
447
|
+
|
|
448
|
+
### Minor Changes
|
|
449
|
+
|
|
450
|
+
- c3653fa: Replace single-phase polling with two-phase approach to eliminate race conditions
|
|
451
|
+
|
|
452
|
+
**Breaking Change**: The `poll_for_tasks` function is now deprecated and returns an empty set. Edge workers must be updated to use the new two-phase polling mechanism.
|
|
453
|
+
|
|
454
|
+
**What Changed:**
|
|
455
|
+
|
|
456
|
+
- Added new "started" status for step_tasks with `started_at` timestamp and `last_worker_id` tracking
|
|
457
|
+
- Introduced `start_tasks` function for the second phase of task processing
|
|
458
|
+
- Edge worker now uses two-phase approach: first `read_with_poll` to get messages, then `start_tasks` to process them
|
|
459
|
+
- This eliminates race conditions where tasks might not be visible when processing messages
|
|
460
|
+
|
|
461
|
+
**Migration Instructions:**
|
|
462
|
+
|
|
463
|
+
1. Run `npx pgflow install` to apply database migrations and update dependencies
|
|
464
|
+
2. Redeploy your edge workers - they will automatically use the new polling mechanism
|
|
465
|
+
3. Old workers will continue running but won't process any tasks (safe degradation)
|
|
466
|
+
|
|
467
|
+
**Why This Change:**
|
|
468
|
+
The previous `poll_for_tasks` had subtle race conditions on slower systems where messages could be read but matching step_tasks weren't visible in the same transaction, leading to lost work. The new two-phase approach provides stronger guarantees and better observability.
|
|
469
|
+
|
|
470
|
+
### Patch Changes
|
|
471
|
+
|
|
472
|
+
- @pgflow/dsl@0.3.0
|
|
473
|
+
|
|
474
|
+
## 0.2.6
|
|
475
|
+
|
|
476
|
+
### Patch Changes
|
|
477
|
+
|
|
478
|
+
- @pgflow/dsl@0.2.6
|
|
479
|
+
|
|
480
|
+
## 0.2.5
|
|
481
|
+
|
|
482
|
+
### Patch Changes
|
|
483
|
+
|
|
484
|
+
- @pgflow/dsl@0.2.5
|
|
485
|
+
|
|
486
|
+
## 0.2.4
|
|
487
|
+
|
|
488
|
+
### Patch Changes
|
|
489
|
+
|
|
490
|
+
- 2f13e8b: Fix `poll_for_tasks` latency
|
|
491
|
+
|
|
492
|
+
The previous implementation were calling `read_with_poll` in same statement
|
|
493
|
+
as the `SELECT FROM step_tasks`, which resulted in new tasks that were inserted
|
|
494
|
+
after the `read_with_poll` started were not discovered as those were not visible
|
|
495
|
+
in the statement.
|
|
496
|
+
|
|
497
|
+
Now `poll_for_tasks` is split to separate statements so step tasks created
|
|
498
|
+
during the `poll_for_tasks` will be immediately picked up.
|
|
499
|
+
|
|
500
|
+
- @pgflow/dsl@0.2.4
|
|
501
|
+
|
|
502
|
+
## 0.2.3
|
|
503
|
+
|
|
504
|
+
### Patch Changes
|
|
505
|
+
|
|
506
|
+
- @pgflow/dsl@0.2.3
|
|
507
|
+
|
|
508
|
+
## 0.2.2
|
|
509
|
+
|
|
510
|
+
### Patch Changes
|
|
511
|
+
|
|
512
|
+
- @pgflow/dsl@0.2.2
|
|
513
|
+
|
|
514
|
+
## 0.2.1
|
|
515
|
+
|
|
516
|
+
### Patch Changes
|
|
517
|
+
|
|
518
|
+
- d553c07: Fix critical migration error that prevented installing if PGMQ was installed previously
|
|
519
|
+
- Updated dependencies [3f3174e]
|
|
520
|
+
- @pgflow/dsl@0.2.1
|
|
521
|
+
|
|
522
|
+
## 0.2.0
|
|
523
|
+
|
|
524
|
+
### Patch Changes
|
|
525
|
+
|
|
526
|
+
- @pgflow/dsl@0.2.0
|
|
527
|
+
|
|
528
|
+
## 0.1.23
|
|
529
|
+
|
|
530
|
+
### Patch Changes
|
|
531
|
+
|
|
532
|
+
- @pgflow/dsl@0.1.23
|
|
533
|
+
|
|
534
|
+
## 0.1.22
|
|
535
|
+
|
|
536
|
+
### Patch Changes
|
|
537
|
+
|
|
538
|
+
- Updated dependencies [8f6eb3d]
|
|
539
|
+
- @pgflow/dsl@0.1.22
|
|
540
|
+
|
|
541
|
+
## 0.1.21
|
|
542
|
+
|
|
543
|
+
### Patch Changes
|
|
544
|
+
|
|
545
|
+
- ea1ce78: Make visibilityTimeout the last option to pollForTasks so it can be skipped
|
|
546
|
+
- @pgflow/dsl@0.1.21
|
|
547
|
+
|
|
548
|
+
## 0.1.20
|
|
549
|
+
|
|
550
|
+
### Patch Changes
|
|
551
|
+
|
|
552
|
+
- 09e3210: Change name of initial migration :-(
|
|
553
|
+
- 985176e: Add step_index to steps and various status timestamps to runtime tables
|
|
554
|
+
- @pgflow/dsl@0.1.20
|
|
555
|
+
|
|
556
|
+
## 0.1.19
|
|
557
|
+
|
|
558
|
+
### Patch Changes
|
|
559
|
+
|
|
560
|
+
- a10b442: Add minimum set of indexes
|
|
561
|
+
- efbd108: Convert migrations to declarative schemas and generate initial migration
|
|
562
|
+
- @pgflow/dsl@0.1.19
|
|
563
|
+
|
|
564
|
+
## 0.1.18
|
|
565
|
+
|
|
566
|
+
### Patch Changes
|
|
567
|
+
|
|
568
|
+
- 3a7e132: Do not build edge-worker for npm
|
|
569
|
+
- Updated dependencies [3a7e132]
|
|
570
|
+
- @pgflow/dsl@0.1.18
|
|
571
|
+
|
|
572
|
+
## 0.1.17
|
|
573
|
+
|
|
574
|
+
### Patch Changes
|
|
575
|
+
|
|
576
|
+
- d215ed2: Trigger version change
|
|
577
|
+
- Updated dependencies [d215ed2]
|
|
578
|
+
- @pgflow/dsl@0.1.17
|
|
579
|
+
|
|
580
|
+
## 0.1.16
|
|
581
|
+
|
|
582
|
+
### Patch Changes
|
|
583
|
+
|
|
584
|
+
- cc7c431: Test release to verify combined publishing of both npm and jsr packages
|
|
585
|
+
- Updated dependencies [cc7c431]
|
|
586
|
+
- @pgflow/dsl@0.1.16
|
|
587
|
+
|
|
588
|
+
## 0.1.15
|
|
589
|
+
|
|
590
|
+
### Patch Changes
|
|
591
|
+
|
|
592
|
+
- ce34a2c: Update release pipeline to publish to jsr
|
|
593
|
+
- Updated dependencies [ce34a2c]
|
|
594
|
+
- @pgflow/dsl@0.1.15
|
|
595
|
+
|
|
596
|
+
## 0.1.14
|
|
597
|
+
|
|
598
|
+
### Patch Changes
|
|
599
|
+
|
|
600
|
+
- @pgflow/dsl@0.1.14
|
|
601
|
+
|
|
602
|
+
## 0.1.13
|
|
603
|
+
|
|
604
|
+
### Patch Changes
|
|
605
|
+
|
|
606
|
+
- @pgflow/dsl@0.1.13
|
|
607
|
+
|
|
608
|
+
## 0.1.12
|
|
609
|
+
|
|
610
|
+
### Patch Changes
|
|
611
|
+
|
|
612
|
+
- Updated dependencies [7b1328e]
|
|
613
|
+
- @pgflow/dsl@0.1.12
|
|
614
|
+
|
|
615
|
+
## 0.1.11
|
|
616
|
+
|
|
617
|
+
### Patch Changes
|
|
618
|
+
|
|
619
|
+
- @pgflow/dsl@0.1.11
|
|
620
|
+
|
|
621
|
+
## 0.1.10
|
|
622
|
+
|
|
623
|
+
### Patch Changes
|
|
624
|
+
|
|
625
|
+
- bafe767: Fix deno/ folder for cli being missing
|
|
626
|
+
- Updated dependencies [bafe767]
|
|
627
|
+
- @pgflow/dsl@0.1.10
|
|
628
|
+
|
|
629
|
+
## 0.1.9
|
|
630
|
+
|
|
631
|
+
### Patch Changes
|
|
632
|
+
|
|
633
|
+
- 1a30c6c: Make sure to tag and push tags
|
|
634
|
+
- Updated dependencies [1a30c6c]
|
|
635
|
+
- @pgflow/dsl@0.1.9
|
|
636
|
+
|
|
637
|
+
## 0.1.8
|
|
638
|
+
|
|
639
|
+
### Patch Changes
|
|
640
|
+
|
|
641
|
+
- 05f5bd8: Update release script
|
|
642
|
+
- Updated dependencies [05f5bd8]
|
|
643
|
+
- @pgflow/dsl@0.1.8
|
|
644
|
+
|
|
645
|
+
## 0.1.7
|
|
646
|
+
|
|
647
|
+
### Patch Changes
|
|
648
|
+
|
|
649
|
+
- summary
|
|
650
|
+
- @pgflow/dsl@0.1.7
|
|
651
|
+
|
|
652
|
+
## 0.1.6
|
|
653
|
+
|
|
654
|
+
### Patch Changes
|
|
655
|
+
|
|
656
|
+
- Test release to verify problem with bumping edge-worker
|
|
657
|
+
- Updated dependencies
|
|
658
|
+
- @pgflow/dsl@0.1.6
|
|
659
|
+
|
|
660
|
+
## 0.1.5
|
|
661
|
+
|
|
662
|
+
### Patch Changes
|
|
663
|
+
|
|
664
|
+
- 5820e7a: Bump version for tests
|
|
665
|
+
- Updated dependencies [5820e7a]
|
|
666
|
+
- @pgflow/dsl@0.1.5
|
|
667
|
+
|
|
668
|
+
## 0.1.4
|
|
669
|
+
|
|
670
|
+
### Patch Changes
|
|
671
|
+
|
|
672
|
+
- @pgflow/dsl@0.1.4
|
|
673
|
+
|
|
674
|
+
## 0.1.3
|
|
675
|
+
|
|
676
|
+
### Patch Changes
|
|
677
|
+
|
|
678
|
+
- @pgflow/dsl@0.1.3
|
|
679
|
+
|
|
680
|
+
## 0.1.2
|
|
681
|
+
|
|
682
|
+
### Patch Changes
|
|
683
|
+
|
|
684
|
+
- @pgflow/dsl@0.1.2
|
|
685
|
+
|
|
686
|
+
## 0.1.1
|
|
687
|
+
|
|
688
|
+
### Patch Changes
|
|
689
|
+
|
|
690
|
+
- Updated dependencies [b362364]
|
|
691
|
+
- @pgflow/dsl@0.1.1
|
|
692
|
+
|
|
693
|
+
## 0.1.0
|
|
694
|
+
|
|
695
|
+
### Minor Changes
|
|
696
|
+
|
|
697
|
+
- 7c40238: fix migration files to not set `search_path`
|
|
698
|
+
|
|
699
|
+
### Patch Changes
|
|
700
|
+
|
|
701
|
+
- @pgflow/dsl@0.1.0
|
|
702
|
+
|
|
703
|
+
## 0.0.23
|
|
704
|
+
|
|
705
|
+
### Patch Changes
|
|
706
|
+
|
|
707
|
+
- @pgflow/dsl@0.0.23
|
|
708
|
+
|
|
709
|
+
## 0.0.22
|
|
710
|
+
|
|
711
|
+
### Patch Changes
|
|
712
|
+
|
|
713
|
+
- @pgflow/dsl@0.0.22
|
|
714
|
+
|
|
715
|
+
## 0.0.21
|
|
716
|
+
|
|
717
|
+
### Patch Changes
|
|
718
|
+
|
|
719
|
+
- @pgflow/dsl@0.0.21
|
|
720
|
+
|
|
721
|
+
## 0.0.20
|
|
722
|
+
|
|
723
|
+
### Patch Changes
|
|
724
|
+
|
|
725
|
+
- @pgflow/dsl@0.0.20
|
|
726
|
+
|
|
727
|
+
## 0.0.19
|
|
728
|
+
|
|
729
|
+
### Patch Changes
|
|
730
|
+
|
|
731
|
+
- 042bc64: Move migrations to pkgs/core
|
|
732
|
+
- @pgflow/dsl@0.0.19
|
|
733
|
+
|
|
734
|
+
## 0.0.18
|
|
735
|
+
|
|
736
|
+
### Patch Changes
|
|
737
|
+
|
|
738
|
+
- 53abf4a: Fix pnpm issues with linking to dist/
|
|
739
|
+
- Updated dependencies [53abf4a]
|
|
740
|
+
- @pgflow/dsl@0.0.18
|
|
741
|
+
|
|
742
|
+
## 0.0.17
|
|
743
|
+
|
|
744
|
+
### Patch Changes
|
|
745
|
+
|
|
746
|
+
- @pgflow/dsl@0.0.17
|
|
747
|
+
|
|
748
|
+
## 0.0.16
|
|
749
|
+
|
|
750
|
+
### Patch Changes
|
|
751
|
+
|
|
752
|
+
- @pgflow/dsl@0.0.16
|
|
753
|
+
|
|
754
|
+
## 0.0.15
|
|
755
|
+
|
|
756
|
+
### Patch Changes
|
|
757
|
+
|
|
758
|
+
- @pgflow/dsl@0.0.15
|
|
759
|
+
|
|
760
|
+
## 0.0.14
|
|
761
|
+
|
|
762
|
+
### Patch Changes
|
|
763
|
+
|
|
764
|
+
- @pgflow/dsl@0.0.14
|
|
765
|
+
|
|
766
|
+
## 0.0.13
|
|
767
|
+
|
|
768
|
+
### Patch Changes
|
|
769
|
+
|
|
770
|
+
- @pgflow/dsl@0.0.13
|
|
771
|
+
|
|
772
|
+
## 0.0.12
|
|
773
|
+
|
|
774
|
+
### Patch Changes
|
|
775
|
+
|
|
776
|
+
- @pgflow/dsl@0.0.12
|
|
777
|
+
|
|
778
|
+
## 0.0.11
|
|
779
|
+
|
|
780
|
+
### Patch Changes
|
|
781
|
+
|
|
782
|
+
- Updated dependencies [17937e3]
|
|
783
|
+
- @pgflow/dsl@0.0.11
|
|
784
|
+
|
|
785
|
+
## 0.0.10
|
|
786
|
+
|
|
787
|
+
### Patch Changes
|
|
788
|
+
|
|
789
|
+
- @pgflow/dsl@0.0.10
|
|
790
|
+
|
|
791
|
+
## 0.0.9
|
|
792
|
+
|
|
793
|
+
### Patch Changes
|
|
794
|
+
|
|
795
|
+
- Updated dependencies [70d3f2d]
|
|
796
|
+
- @pgflow/dsl@0.0.9
|
|
797
|
+
|
|
798
|
+
## 0.0.8
|
|
799
|
+
|
|
800
|
+
### Patch Changes
|
|
801
|
+
|
|
802
|
+
- @pgflow/dsl@0.0.8
|
|
803
|
+
|
|
804
|
+
## 0.0.7
|
|
805
|
+
|
|
806
|
+
### Patch Changes
|
|
807
|
+
|
|
808
|
+
- 7c83db9: Add release-related options to package.json files
|
|
809
|
+
- Updated dependencies [7c83db9]
|
|
810
|
+
- @pgflow/dsl@0.0.7
|
|
811
|
+
|
|
812
|
+
## 0.0.6
|
|
813
|
+
|
|
814
|
+
### Patch Changes
|
|
815
|
+
|
|
816
|
+
- @pgflow/dsl@0.0.6
|
|
817
|
+
|
|
818
|
+
## 0.0.5
|
|
819
|
+
|
|
820
|
+
### Patch Changes
|
|
821
|
+
|
|
822
|
+
- 196f7d8: Test patch bump
|
|
823
|
+
- Updated dependencies [b4b0809]
|
|
824
|
+
- @pgflow/dsl@0.0.5
|