@pgflow/dsl 0.0.0-array-map-steps-302d00a8-20250922101336 → 0.0.0-test-snapshot-releases2-8d5d9bc1-20250922101158

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 CHANGED
@@ -73,78 +73,6 @@ This design ensures:
73
73
  - Data doesn't need to be manually forwarded through intermediate steps
74
74
  - Steps can combine original input with processed data from previous steps
75
75
 
76
- ### Step Methods
77
-
78
- The Flow DSL provides three methods for defining steps in your workflow:
79
-
80
- #### `.step()` - Regular Steps
81
-
82
- The standard method for adding steps to a flow. Each step processes input and returns output.
83
-
84
- ```typescript
85
- .step(
86
- { slug: 'process', dependsOn: ['previous'] },
87
- async (input) => {
88
- // Access input.run and input.previous
89
- return { result: 'processed' };
90
- }
91
- )
92
- ```
93
-
94
- #### `.array()` - Array-Returning Steps
95
-
96
- A semantic wrapper around `.step()` that provides type enforcement for steps that return arrays. Useful for data fetching or collection steps.
97
-
98
- ```typescript
99
- .array(
100
- { slug: 'fetch_items' },
101
- async () => [1, 2, 3, 4, 5]
102
- )
103
- ```
104
-
105
- #### `.map()` - Array Processing Steps
106
-
107
- Processes arrays element-by-element, similar to JavaScript's `Array.map()`. The handler receives individual items instead of the full input object.
108
-
109
- ```typescript
110
- // Root map - processes flow input array
111
- new Flow<string[]>({ slug: 'process_strings' })
112
- .map({ slug: 'uppercase' }, (item) => item.toUpperCase());
113
-
114
- // Dependent map - processes another step's output
115
- new Flow<{}>({ slug: 'data_pipeline' })
116
- .array({ slug: 'numbers' }, () => [1, 2, 3])
117
- .map({ slug: 'double', array: 'numbers' }, (n) => n * 2)
118
- .map({ slug: 'square', array: 'double' }, (n) => n * n);
119
- ```
120
-
121
- **Key differences from regular steps:**
122
- - Uses `array:` instead of `dependsOn:` for specifying the single array dependency
123
- - Handler signature is `(item, context) => result` instead of `(input, context) => result`
124
- - Return type is always an array
125
- - Generates SQL with `step_type => 'map'` parameter for pgflow's map processing
126
-
127
- **Type Safety:**
128
- The `.map()` method provides full TypeScript type inference for array elements:
129
-
130
- ```typescript
131
- type User = { id: number; name: string };
132
-
133
- new Flow<{}>({ slug: 'user_flow' })
134
- .array({ slug: 'users' }, (): User[] => [
135
- { id: 1, name: 'Alice' },
136
- { id: 2, name: 'Bob' }
137
- ])
138
- .map({ slug: 'greet', array: 'users' }, (user) => {
139
- // TypeScript knows user is of type User
140
- return `Hello, ${user.name} (ID: ${user.id})`;
141
- });
142
- ```
143
-
144
- **Limitations:**
145
- - Can only depend on a single array-returning step
146
- - TypeScript may not track type transformations between chained maps (use type assertions if needed)
147
-
148
76
  ### Context Object
149
77
 
150
78
  Step handlers can optionally receive a second parameter - the **context object** - which provides access to platform resources and runtime information.
@@ -186,11 +114,6 @@ All platforms provide these core resources:
186
114
  msg_id: number;
187
115
  }
188
116
  ```
189
- - **`context.workerConfig`** - Resolved worker configuration with all defaults applied
190
- ```typescript
191
- // Provides access to worker settings like retry limits
192
- const isLastAttempt = context.rawMessage.read_ct >= context.workerConfig.retry.limit;
193
- ```
194
117
 
195
118
  #### Supabase Platform Resources
196
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgflow/dsl",
3
- "version": "0.0.0-array-map-steps-302d00a8-20250922101336",
3
+ "version": "0.0.0-test-snapshot-releases2-8d5d9bc1-20250922101158",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
package/dist/CHANGELOG.md DELETED
@@ -1,411 +0,0 @@
1
- # @pgflow/dsl
2
-
3
- ## 0.6.1
4
-
5
- ## 0.6.0
6
-
7
- ### Minor Changes
8
-
9
- - a67bf27: 🚨 **BREAKING**: Remove `anonSupabase` and `serviceSupabase` from context, replaced with single `supabase` client (initialized with service role key)
10
-
11
- The dual-client approach was unnecessary complexity. Edge Functions run in a trusted environment with service role access, so a single client is sufficient.
12
-
13
- **Migration guide**:
14
-
15
- ```typescript
16
- // Before
17
- const { data } = await context.serviceSupabase.from('users').select();
18
- const { data: publicData } = await context.anonSupabase
19
- .from('posts')
20
- .select();
21
-
22
- // After
23
- const { data } = await context.supabase.from('users').select();
24
- // For RLS-respecting queries, implement proper policies in your database
25
- ```
26
-
27
- ⚠️ **Breaking changes**:
28
-
29
- - Removed `anonSupabase` from context interface
30
- - Removed `serviceSupabase` from context interface
31
- - Added `supabase` field (initialized with service role key)
32
- - Removed `createAnonSupabaseClient` function
33
-
34
- ## 0.5.4
35
-
36
- ### Patch Changes
37
-
38
- - 9f219a4: Add context object as second parameter to handlers
39
-
40
- Queue and flow handlers now receive an optional context parameter that provides platform resources like database connections, environment variables, and Supabase clients - eliminating boilerplate and connection management.
41
-
42
- ```typescript
43
- // Queue handler
44
- EdgeWorker.start(async (payload, context) => {
45
- await context.sql`INSERT INTO tasks (data) VALUES (${payload})`;
46
- });
47
-
48
- // Flow step handler
49
- .step({ slug: 'process' }, async (input, context) => {
50
- const result = await context.serviceSupabase.from('users').select();
51
- })
52
- ```
53
-
54
- **Core resources** (always available):
55
-
56
- - `context.env` - Environment variables
57
- - `context.shutdownSignal` - AbortSignal for graceful shutdown
58
- - `context.rawMessage` - Original pgmq message with metadata
59
- - `context.stepTask` - Current step task details (flow handlers only)
60
-
61
- **Supabase platform resources**:
62
-
63
- - `context.sql` - PostgreSQL client (postgres.js)
64
- - `context.anonSupabase` - Supabase client with anonymous key
65
- - `context.serviceSupabase` - Supabase client with service role key
66
-
67
- To use Supabase resources in flows, import from the Supabase preset:
68
-
69
- ```typescript
70
- import { Flow } from '@pgflow/dsl/supabase';
71
- ```
72
-
73
- The context parameter is optional for backward compatibility - existing single-parameter handlers continue to work unchanged.
74
-
75
- ## 0.5.3
76
-
77
- ### Patch Changes
78
-
79
- - af787ff: Add `startDelay` option for workflow steps
80
-
81
- 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.
82
-
83
- **Important**: `startDelay` only applies to the first execution attempt. Retries use the standard exponential backoff mechanism based on `baseDelay`, not `startDelay`.
84
-
85
- ### Core Changes (@pgflow/core)
86
-
87
- - Added `opt_start_delay` column (integer, nullable, CHECK >= 0) to `pgflow.steps` table
88
- - Updated `add_step` function to accept and validate the new `start_delay` parameter
89
- - Modified `start_ready_steps` to schedule initial task execution with delay via `pgmq.send(queue, message, delay)`
90
- - Requires pgmq >= 0.40 for delay support
91
- - Migration: `20250707210212_pgflow_add_opt_start_delay.sql`
92
- - Added comprehensive PgTAP tests for validation and scheduling behavior
93
-
94
- ### DSL Changes (@pgflow/dsl)
95
-
96
- - Extended `StepOptions` and `StepRuntimeOptions` interfaces with optional `startDelay` (in seconds)
97
- - Updated `compileFlow()` to emit `start_delay => value` in generated SQL
98
- - Added validation: `startDelay` is only allowed at step level, not flow level (prevents cascading delays)
99
- - Valid range: 0 to 2,147,483,647 seconds (~68 years)
100
- - Added unit tests for compilation and validation
101
-
102
- ### Documentation Updates (@pgflow/website)
103
-
104
- - Added `startDelay` section in configuration guide with detailed explanation
105
- - Created multi-day workflow example (onboarding email sequence)
106
- - Updated "Update Flow Options" to include `opt_start_delay`
107
- - Enhanced VS comparison pages to mention "Native step delays" capability
108
- - Documented why `startDelay` is step-level only
109
-
110
- ### Example Usage
111
-
112
- ```typescript
113
- new Flow({
114
- slug: 'user_onboarding',
115
- maxAttempts: 3,
116
- baseDelay: 5, // Retry delay (not initial delay)
117
- timeout: 60,
118
- })
119
- .step(
120
- {
121
- slug: 'send_welcome_email',
122
- // Executes immediately when step becomes ready
123
- },
124
- sendWelcomeHandler
125
- )
126
- .step(
127
- {
128
- slug: 'send_day_3_tips',
129
- startDelay: 259200, // Wait 3 days before first execution
130
- timeout: 120,
131
- },
132
- sendTipsHandler
133
- )
134
- .step(
135
- {
136
- slug: 'send_week_review',
137
- startDelay: 604800, // Wait 7 days after dependencies complete
138
- timeout: 120,
139
- },
140
- sendReviewHandler
141
- );
142
- ```
143
-
144
- ### Use Cases
145
-
146
- - **Multi-day workflows**: Onboarding sequences, follow-up reminders
147
- - **Scheduled notifications**: Send reports or alerts at specific intervals
148
- - **Rate limiting**: Enforce minimum time between API calls
149
- - **Compliance delays**: Cooling-off periods before actions
150
-
151
- ### Technical Notes
152
-
153
- - Non-breaking, additive change (hence minor version bump)
154
- - No changes required in `@pgflow/edge-worker` - delays handled by pgmq
155
- - `startDelay` does not affect retry timing - only the initial execution
156
- - Delays are reliable even across worker restarts (persisted in queue)
157
-
158
- ## 0.5.2
159
-
160
- ## 0.5.1
161
-
162
- ## 0.5.0
163
-
164
- ## 0.4.3
165
-
166
- ## 0.4.2
167
-
168
- ## 0.4.1
169
-
170
- ## 0.4.0
171
-
172
- ### Patch Changes
173
-
174
- - 98556d3: Add TypeScript client library for pgflow workflow management
175
-
176
- ## @pgflow/client
177
-
178
- Introduces a new TypeScript client library that provides both event-based and promise-based APIs for interacting with pgflow workflows:
179
-
180
- ### Features
181
-
182
- - **Type-safe workflow management** with full TypeScript support and automatic type inference from flow definitions
183
- - **Dual API approach**: Choose between event-based subscriptions or promise-based async/await patterns
184
- - **Real-time monitoring** via Supabase broadcasts with granular event subscriptions
185
- - **Resource management** with automatic cleanup and disposal
186
- - **Comprehensive error handling** and recovery mechanisms
187
-
188
- ### Core Components
189
-
190
- - `PgflowClient` - Main client for starting and managing workflow runs
191
- - `FlowRun` - Monitor and interact with workflow executions
192
- - `FlowStep` - Track individual step progress and outputs
193
-
194
- ### Example Usage
195
-
196
- ```typescript
197
- // Start a workflow
198
- const pgflow = new PgflowClient(supabase);
199
- const run = await pgflow.startFlow('analyze_website', {
200
- url: 'https://example.com',
201
- });
202
-
203
- // Event-based monitoring
204
- run.on('completed', (event) => {
205
- console.log('Workflow completed:', event.output);
206
- });
207
-
208
- // Promise-based monitoring
209
- const completed = await run.waitForStatus(FlowRunStatus.Completed, {
210
- timeoutMs: 30000,
211
- });
212
- ```
213
-
214
- ## @pgflow/core
215
-
216
- ### Database Enhancements
217
-
218
- - Add `start_flow_with_states()` function to start flows and return complete initial state
219
- - Add `get_run_with_states()` function to retrieve runs with all step states efficiently
220
- - Implement `SECURITY DEFINER` functions for secure API access
221
- - Add real-time broadcast support for workflow state changes
222
-
223
- ## @pgflow/edge-worker
224
-
225
- ### Test Infrastructure Updates
226
-
227
- - Update test database configuration to use standard PostgreSQL credentials
228
- - Improve test helper functions for database transactions
229
- - Update Docker Compose configuration for test environment
230
-
231
- ## @pgflow/dsl
232
-
233
- ### Build Configuration
234
-
235
- - Add TypeScript references to tsconfig.spec.json for improved type checking in tests
236
-
237
- ## 0.3.1
238
-
239
- ## 0.3.0
240
-
241
- ## 0.2.6
242
-
243
- ## 0.2.5
244
-
245
- ## 0.2.4
246
-
247
- ## 0.2.3
248
-
249
- ## 0.2.2
250
-
251
- ## 0.2.1
252
-
253
- ### Patch Changes
254
-
255
- - 3f3174e: Update the README's
256
-
257
- ## 0.2.0
258
-
259
- ## 0.1.23
260
-
261
- ## 0.1.22
262
-
263
- ### Patch Changes
264
-
265
- - 8f6eb3d: Added ExtractFlowLeafSteps and ExtractFlowOutput utility types
266
-
267
- ## 0.1.21
268
-
269
- ## 0.1.20
270
-
271
- ## 0.1.19
272
-
273
- ## 0.1.18
274
-
275
- ### Patch Changes
276
-
277
- - 3a7e132: Do not build edge-worker for npm
278
-
279
- ## 0.1.17
280
-
281
- ### Patch Changes
282
-
283
- - d215ed2: Trigger version change
284
-
285
- ## 0.1.16
286
-
287
- ### Patch Changes
288
-
289
- - cc7c431: Test release to verify combined publishing of both npm and jsr packages
290
-
291
- ## 0.1.15
292
-
293
- ### Patch Changes
294
-
295
- - ce34a2c: Update release pipeline to publish to jsr
296
-
297
- ## 0.1.14
298
-
299
- ## 0.1.13
300
-
301
- ## 0.1.12
302
-
303
- ### Patch Changes
304
-
305
- - 7b1328e: Include invalid slug in validateSlug error message
306
-
307
- ## 0.1.11
308
-
309
- ## 0.1.10
310
-
311
- ### Patch Changes
312
-
313
- - bafe767: Fix deno/ folder for cli being missing
314
-
315
- ## 0.1.9
316
-
317
- ### Patch Changes
318
-
319
- - 1a30c6c: Make sure to tag and push tags
320
-
321
- ## 0.1.8
322
-
323
- ### Patch Changes
324
-
325
- - 05f5bd8: Update release script
326
-
327
- ## 0.1.7
328
-
329
- ## 0.1.6
330
-
331
- ### Patch Changes
332
-
333
- - Test release to verify problem with bumping edge-worker
334
-
335
- ## 0.1.5
336
-
337
- ### Patch Changes
338
-
339
- - 5820e7a: Bump version for tests
340
-
341
- ## 0.1.4
342
-
343
- ## 0.1.3
344
-
345
- ## 0.1.2
346
-
347
- ## 0.1.1
348
-
349
- ### Patch Changes
350
-
351
- - b362364: Add compileFlow function
352
-
353
- ## 0.1.0
354
-
355
- ## 0.0.23
356
-
357
- ## 0.0.22
358
-
359
- ## 0.0.21
360
-
361
- ## 0.0.20
362
-
363
- ## 0.0.19
364
-
365
- ## 0.0.18
366
-
367
- ### Patch Changes
368
-
369
- - 53abf4a: Fix pnpm issues with linking to dist/
370
-
371
- ## 0.0.17
372
-
373
- ## 0.0.16
374
-
375
- ## 0.0.15
376
-
377
- ## 0.0.14
378
-
379
- ## 0.0.13
380
-
381
- ## 0.0.12
382
-
383
- ## 0.0.11
384
-
385
- ### Patch Changes
386
-
387
- - 17937e3: Update changesets action and comment out custom publish
388
-
389
- ## 0.0.10
390
-
391
- ## 0.0.9
392
-
393
- ### Patch Changes
394
-
395
- - 70d3f2d: Tweak extension setting in tsconfig.base.json
396
-
397
- ## 0.0.8
398
-
399
- ## 0.0.7
400
-
401
- ### Patch Changes
402
-
403
- - 7c83db9: Add release-related options to package.json files
404
-
405
- ## 0.0.6
406
-
407
- ## 0.0.5
408
-
409
- ### Patch Changes
410
-
411
- - b4b0809: test changesets