@pgflow/dsl 0.5.2 → 0.5.4

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
@@ -13,7 +13,7 @@ Key features:
13
13
 
14
14
  - **Type Safety** - Complete TypeScript type checking from flow inputs to outputs
15
15
  - **Fluent Interface** - Chainable method calls for defining steps and dependencies
16
- - **Functional Approach** - Clean separation between task implementation and flow orchestration
16
+ - **Functional Approach** - Clean separation between task implementation and flow orchestration
17
17
  - **JSON-Compatible** - All inputs and outputs are JSON-serializable for database storage
18
18
  - **Immutable Flow Definitions** - Each step operation returns a new Flow instance
19
19
 
@@ -68,21 +68,101 @@ In pgflow, each step receives an `input` object that contains:
68
68
  2. **`input.{stepName}`** - Outputs from dependency steps
69
69
 
70
70
  This design ensures:
71
+
71
72
  - Original flow parameters are accessible throughout the entire flow
72
73
  - Data doesn't need to be manually forwarded through intermediate steps
73
74
  - Steps can combine original input with processed data from previous steps
74
75
 
76
+ ### Context Object
77
+
78
+ Step handlers can optionally receive a second parameter - the **context object** - which provides access to platform resources and runtime information.
79
+
80
+ ```typescript
81
+ .step(
82
+ { slug: 'saveToDb' },
83
+ async (input, context) => {
84
+ // Access platform resources through context
85
+ const result = await context.sql`SELECT * FROM users WHERE id = ${input.userId}`;
86
+ return result[0];
87
+ }
88
+ )
89
+ ```
90
+
91
+ #### Core Context Resources
92
+
93
+ All platforms provide these core resources:
94
+
95
+ - **`context.env`** - Environment variables (`Record<string, string | undefined>`)
96
+ - **`context.shutdownSignal`** - AbortSignal for graceful shutdown handling
97
+ - **`context.rawMessage`** - Original pgmq message with metadata
98
+ ```typescript
99
+ interface PgmqMessageRecord<T> {
100
+ msg_id: number;
101
+ read_ct: number;
102
+ enqueued_at: Date;
103
+ vt: Date;
104
+ message: T; // <-- this is your 'input'
105
+ }
106
+ ```
107
+ - **`context.stepTask`** - Current step task details (flow handlers only)
108
+ ```typescript
109
+ interface StepTaskRecord<TFlow> {
110
+ flow_slug: string;
111
+ run_id: string;
112
+ step_slug: string;
113
+ input: StepInput<TFlow, StepSlug>; // <-- this is handler 'input'
114
+ msg_id: number;
115
+ }
116
+ ```
117
+
118
+ #### Supabase Platform Resources
119
+
120
+ When using the Supabase platform with EdgeWorker, additional resources are available:
121
+
122
+ - **`context.sql`** - PostgreSQL client (postgres.js)
123
+ - **`context.anonSupabase`** - Supabase client with anonymous key
124
+ - **`context.serviceSupabase`** - Supabase client with service role key
125
+
126
+ To use Supabase resources, import the `Flow` class from the Supabase preset:
127
+
128
+ ```typescript
129
+ import { Flow } from '@pgflow/dsl/supabase';
130
+
131
+ const MyFlow = new Flow<{ userId: string }>({
132
+ slug: 'my_flow',
133
+ }).step({ slug: 'process' }, async (input, context) => {
134
+ // TypeScript knows context includes Supabase resources
135
+ const { data } = await context.serviceSupabase
136
+ .from('users')
137
+ .select('*')
138
+ .eq('id', input.userId);
139
+
140
+ // Use SQL directly
141
+ const stats = await context.sql`
142
+ SELECT COUNT(*) as total FROM events
143
+ WHERE user_id = ${input.userId}
144
+ `;
145
+
146
+ return { user: data[0], eventCount: stats[0].total };
147
+ });
148
+ ```
149
+
150
+ > [!NOTE]
151
+ > Context is optional - handlers that don't need platform resources can omit the second parameter for backward compatibility.
152
+
153
+ For more details on available resources and platform configuration, see the [@pgflow/edge-worker documentation](https://github.com/pgflow-org/pgflow/tree/main/pkgs/edge-worker#context-resources).
154
+
75
155
  ### Flow Configuration
76
156
 
77
157
  Configure flows and steps with runtime options:
78
158
 
79
159
  ```typescript
80
160
  new Flow<Input>({
81
- slug: 'my_flow', // Required: Unique flow identifier
82
- maxAttempts: 3, // Optional: Maximum retry attempts (default: 1)
83
- baseDelay: 5, // Optional: Base delay in seconds for retries (default: 1)
84
- timeout: 10, // Optional: Task timeout in seconds (default: 30)
85
- })
161
+ slug: 'my_flow', // Required: Unique flow identifier
162
+ maxAttempts: 3, // Optional: Maximum retry attempts (default: 1)
163
+ baseDelay: 5, // Optional: Base delay in seconds for retries (default: 1)
164
+ timeout: 10, // Optional: Task timeout in seconds (default: 30)
165
+ });
86
166
  ```
87
167
 
88
168
  ## Compiling Flows
@@ -120,4 +200,5 @@ Run `nx test dsl` to execute the unit tests via [Vitest](https://vitest.dev/).
120
200
  ## Documentation
121
201
 
122
202
  For detailed documentation on the Flow DSL, visit:
123
- - [Understanding the Flow DSL](https://pgflow.dev/explanations/flow-dsl/)
203
+
204
+ - [Understanding the Flow DSL](https://pgflow.dev/explanations/flow-dsl/)
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,129 @@
1
1
  # @pgflow/dsl
2
2
 
3
+ ## 0.5.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 9f219a4: Add context object as second parameter to handlers
8
+
9
+ 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.
10
+
11
+ ```typescript
12
+ // Queue handler
13
+ EdgeWorker.start(async (payload, context) => {
14
+ await context.sql`INSERT INTO tasks (data) VALUES (${payload})`;
15
+ });
16
+
17
+ // Flow step handler
18
+ .step({ slug: 'process' }, async (input, context) => {
19
+ const result = await context.serviceSupabase.from('users').select();
20
+ })
21
+ ```
22
+
23
+ **Core resources** (always available):
24
+
25
+ - `context.env` - Environment variables
26
+ - `context.shutdownSignal` - AbortSignal for graceful shutdown
27
+ - `context.rawMessage` - Original pgmq message with metadata
28
+ - `context.stepTask` - Current step task details (flow handlers only)
29
+
30
+ **Supabase platform resources**:
31
+
32
+ - `context.sql` - PostgreSQL client (postgres.js)
33
+ - `context.anonSupabase` - Supabase client with anonymous key
34
+ - `context.serviceSupabase` - Supabase client with service role key
35
+
36
+ To use Supabase resources in flows, import from the Supabase preset:
37
+
38
+ ```typescript
39
+ import { Flow } from '@pgflow/dsl/supabase';
40
+ ```
41
+
42
+ The context parameter is optional for backward compatibility - existing single-parameter handlers continue to work unchanged.
43
+
44
+ ## 0.5.3
45
+
46
+ ### Patch Changes
47
+
48
+ - af787ff: Add `startDelay` option for workflow steps
49
+
50
+ 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.
51
+
52
+ **Important**: `startDelay` only applies to the first execution attempt. Retries use the standard exponential backoff mechanism based on `baseDelay`, not `startDelay`.
53
+
54
+ ### Core Changes (@pgflow/core)
55
+
56
+ - Added `opt_start_delay` column (integer, nullable, CHECK >= 0) to `pgflow.steps` table
57
+ - Updated `add_step` function to accept and validate the new `start_delay` parameter
58
+ - Modified `start_ready_steps` to schedule initial task execution with delay via `pgmq.send(queue, message, delay)`
59
+ - Requires pgmq >= 0.40 for delay support
60
+ - Migration: `20250707210212_pgflow_add_opt_start_delay.sql`
61
+ - Added comprehensive PgTAP tests for validation and scheduling behavior
62
+
63
+ ### DSL Changes (@pgflow/dsl)
64
+
65
+ - Extended `StepOptions` and `StepRuntimeOptions` interfaces with optional `startDelay` (in seconds)
66
+ - Updated `compileFlow()` to emit `start_delay => value` in generated SQL
67
+ - Added validation: `startDelay` is only allowed at step level, not flow level (prevents cascading delays)
68
+ - Valid range: 0 to 2,147,483,647 seconds (~68 years)
69
+ - Added unit tests for compilation and validation
70
+
71
+ ### Documentation Updates (@pgflow/website)
72
+
73
+ - Added `startDelay` section in configuration guide with detailed explanation
74
+ - Created multi-day workflow example (onboarding email sequence)
75
+ - Updated "Update Flow Options" to include `opt_start_delay`
76
+ - Enhanced VS comparison pages to mention "Native step delays" capability
77
+ - Documented why `startDelay` is step-level only
78
+
79
+ ### Example Usage
80
+
81
+ ```typescript
82
+ new Flow({
83
+ slug: 'user_onboarding',
84
+ maxAttempts: 3,
85
+ baseDelay: 5, // Retry delay (not initial delay)
86
+ timeout: 60,
87
+ })
88
+ .step(
89
+ {
90
+ slug: 'send_welcome_email',
91
+ // Executes immediately when step becomes ready
92
+ },
93
+ sendWelcomeHandler
94
+ )
95
+ .step(
96
+ {
97
+ slug: 'send_day_3_tips',
98
+ startDelay: 259200, // Wait 3 days before first execution
99
+ timeout: 120,
100
+ },
101
+ sendTipsHandler
102
+ )
103
+ .step(
104
+ {
105
+ slug: 'send_week_review',
106
+ startDelay: 604800, // Wait 7 days after dependencies complete
107
+ timeout: 120,
108
+ },
109
+ sendReviewHandler
110
+ );
111
+ ```
112
+
113
+ ### Use Cases
114
+
115
+ - **Multi-day workflows**: Onboarding sequences, follow-up reminders
116
+ - **Scheduled notifications**: Send reports or alerts at specific intervals
117
+ - **Rate limiting**: Enforce minimum time between API calls
118
+ - **Compliance delays**: Cooling-off periods before actions
119
+
120
+ ### Technical Notes
121
+
122
+ - Non-breaking, additive change (hence minor version bump)
123
+ - No changes required in `@pgflow/edge-worker` - delays handled by pgmq
124
+ - `startDelay` does not affect retry timing - only the initial execution
125
+ - Delays are reliable even across worker restarts (persisted in queue)
126
+
3
127
  ## 0.5.2
4
128
 
5
129
  ## 0.5.1
package/dist/README.md CHANGED
@@ -13,7 +13,7 @@ Key features:
13
13
 
14
14
  - **Type Safety** - Complete TypeScript type checking from flow inputs to outputs
15
15
  - **Fluent Interface** - Chainable method calls for defining steps and dependencies
16
- - **Functional Approach** - Clean separation between task implementation and flow orchestration
16
+ - **Functional Approach** - Clean separation between task implementation and flow orchestration
17
17
  - **JSON-Compatible** - All inputs and outputs are JSON-serializable for database storage
18
18
  - **Immutable Flow Definitions** - Each step operation returns a new Flow instance
19
19
 
@@ -68,21 +68,101 @@ In pgflow, each step receives an `input` object that contains:
68
68
  2. **`input.{stepName}`** - Outputs from dependency steps
69
69
 
70
70
  This design ensures:
71
+
71
72
  - Original flow parameters are accessible throughout the entire flow
72
73
  - Data doesn't need to be manually forwarded through intermediate steps
73
74
  - Steps can combine original input with processed data from previous steps
74
75
 
76
+ ### Context Object
77
+
78
+ Step handlers can optionally receive a second parameter - the **context object** - which provides access to platform resources and runtime information.
79
+
80
+ ```typescript
81
+ .step(
82
+ { slug: 'saveToDb' },
83
+ async (input, context) => {
84
+ // Access platform resources through context
85
+ const result = await context.sql`SELECT * FROM users WHERE id = ${input.userId}`;
86
+ return result[0];
87
+ }
88
+ )
89
+ ```
90
+
91
+ #### Core Context Resources
92
+
93
+ All platforms provide these core resources:
94
+
95
+ - **`context.env`** - Environment variables (`Record<string, string | undefined>`)
96
+ - **`context.shutdownSignal`** - AbortSignal for graceful shutdown handling
97
+ - **`context.rawMessage`** - Original pgmq message with metadata
98
+ ```typescript
99
+ interface PgmqMessageRecord<T> {
100
+ msg_id: number;
101
+ read_ct: number;
102
+ enqueued_at: Date;
103
+ vt: Date;
104
+ message: T; // <-- this is your 'input'
105
+ }
106
+ ```
107
+ - **`context.stepTask`** - Current step task details (flow handlers only)
108
+ ```typescript
109
+ interface StepTaskRecord<TFlow> {
110
+ flow_slug: string;
111
+ run_id: string;
112
+ step_slug: string;
113
+ input: StepInput<TFlow, StepSlug>; // <-- this is handler 'input'
114
+ msg_id: number;
115
+ }
116
+ ```
117
+
118
+ #### Supabase Platform Resources
119
+
120
+ When using the Supabase platform with EdgeWorker, additional resources are available:
121
+
122
+ - **`context.sql`** - PostgreSQL client (postgres.js)
123
+ - **`context.anonSupabase`** - Supabase client with anonymous key
124
+ - **`context.serviceSupabase`** - Supabase client with service role key
125
+
126
+ To use Supabase resources, import the `Flow` class from the Supabase preset:
127
+
128
+ ```typescript
129
+ import { Flow } from '@pgflow/dsl/supabase';
130
+
131
+ const MyFlow = new Flow<{ userId: string }>({
132
+ slug: 'my_flow',
133
+ }).step({ slug: 'process' }, async (input, context) => {
134
+ // TypeScript knows context includes Supabase resources
135
+ const { data } = await context.serviceSupabase
136
+ .from('users')
137
+ .select('*')
138
+ .eq('id', input.userId);
139
+
140
+ // Use SQL directly
141
+ const stats = await context.sql`
142
+ SELECT COUNT(*) as total FROM events
143
+ WHERE user_id = ${input.userId}
144
+ `;
145
+
146
+ return { user: data[0], eventCount: stats[0].total };
147
+ });
148
+ ```
149
+
150
+ > [!NOTE]
151
+ > Context is optional - handlers that don't need platform resources can omit the second parameter for backward compatibility.
152
+
153
+ For more details on available resources and platform configuration, see the [@pgflow/edge-worker documentation](https://github.com/pgflow-org/pgflow/tree/main/pkgs/edge-worker#context-resources).
154
+
75
155
  ### Flow Configuration
76
156
 
77
157
  Configure flows and steps with runtime options:
78
158
 
79
159
  ```typescript
80
160
  new Flow<Input>({
81
- slug: 'my_flow', // Required: Unique flow identifier
82
- maxAttempts: 3, // Optional: Maximum retry attempts (default: 1)
83
- baseDelay: 5, // Optional: Base delay in seconds for retries (default: 1)
84
- timeout: 10, // Optional: Task timeout in seconds (default: 30)
85
- })
161
+ slug: 'my_flow', // Required: Unique flow identifier
162
+ maxAttempts: 3, // Optional: Maximum retry attempts (default: 1)
163
+ baseDelay: 5, // Optional: Base delay in seconds for retries (default: 1)
164
+ timeout: 10, // Optional: Task timeout in seconds (default: 30)
165
+ });
86
166
  ```
87
167
 
88
168
  ## Compiling Flows
@@ -120,4 +200,5 @@ Run `nx test dsl` to execute the unit tests via [Vitest](https://vitest.dev/).
120
200
  ## Documentation
121
201
 
122
202
  For detailed documentation on the Flow DSL, visit:
123
- - [Understanding the Flow DSL](https://pgflow.dev/explanations/flow-dsl/)
203
+
204
+ - [Understanding the Flow DSL](https://pgflow.dev/explanations/flow-dsl/)
@@ -1 +1 @@
1
- {"version":3,"file":"compile-flow.d.ts","sourceRoot":"","sources":["../src/compile-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,UAAU,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,CAyBnD"}
1
+ {"version":3,"file":"compile-flow.d.ts","sourceRoot":"","sources":["../src/compile-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsC,MAAM,UAAU,CAAC;AAEvE;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,CAyBnD"}
@@ -38,5 +38,8 @@ function formatRuntimeOptions(options) {
38
38
  if (options.timeout !== undefined) {
39
39
  parts.push(`timeout => ${options.timeout}`);
40
40
  }
41
+ if ('startDelay' in options && options.startDelay !== undefined) {
42
+ parts.push(`start_delay => ${options.startDelay}`);
43
+ }
41
44
  return parts.length > 0 ? `, ${parts.join(', ')}` : '';
42
45
  }
package/dist/dsl.d.ts CHANGED
@@ -4,6 +4,13 @@ export type Json = string | number | boolean | null | Json[] | {
4
4
  export type Simplify<T> = {
5
5
  [KeyType in keyof T]: T[KeyType];
6
6
  } & {};
7
+ type AwaitedReturn<T> = T extends (...args: any[]) => Promise<infer R> ? R : T extends (...args: any[]) => infer R ? R : never;
8
+ export interface Env {
9
+ [key: string]: string | undefined;
10
+ }
11
+ export type ValidEnv<T> = T extends Env ? T : never;
12
+ export interface UserEnv extends Env {
13
+ }
7
14
  export type AnyInput = Json;
8
15
  export type AnyOutput = Json;
9
16
  export type EmptySteps = Record<never, never>;
@@ -14,35 +21,47 @@ export type AnyDeps = Record<string, string[]>;
14
21
  /**
15
22
  * Represents a Flow that has not steps nor deps defined yet
16
23
  */
17
- export type EmptyFlow = Flow<AnyInput, EmptySteps, EmptyDeps>;
24
+ export type EmptyFlow = Flow<AnyInput, BaseContext, EmptySteps, EmptyDeps>;
18
25
  /**
19
- * Represents any Flow with flexible input, steps, and dependencies.
26
+ * Represents any Flow with flexible input, context, steps, and dependencies.
20
27
  * This type is intentionally more permissive to allow for better type inference
21
28
  * in utility types like StepOutput.
22
29
  */
23
- export type AnyFlow = Flow<any, any, any>;
30
+ export type AnyFlow = Flow<any, any, any, any>;
24
31
  /**
25
32
  * Extracts the input type from a Flow
26
33
  * @template TFlow - The Flow type to extract from
27
34
  */
28
- export type ExtractFlowInput<TFlow extends AnyFlow> = TFlow extends Flow<infer TI, infer _TS, infer _TD> ? TI : never;
35
+ export type ExtractFlowInput<TFlow extends AnyFlow> = TFlow extends Flow<infer TI, infer _TC, infer _TS, infer _TD> ? TI : never;
36
+ /**
37
+ * Utility type to extract all possible step inputs from a flow
38
+ * This creates a union of all step input types
39
+ */
40
+ export type AllStepInputs<TFlow extends AnyFlow> = {
41
+ [K in keyof ExtractFlowSteps<TFlow> & string]: StepInput<TFlow, K>;
42
+ }[keyof ExtractFlowSteps<TFlow> & string];
29
43
  /**
30
44
  * Extracts the output type from a Flow
31
45
  * @template TFlow - The Flow type to extract from
32
46
  */
33
- export type ExtractFlowOutput<TFlow extends AnyFlow> = TFlow extends Flow<infer _TI, infer _TS, infer _TD> ? {
47
+ export type ExtractFlowOutput<TFlow extends AnyFlow> = TFlow extends Flow<infer _TI, infer _TC, infer _TS, infer _TD> ? {
34
48
  [K in keyof ExtractFlowLeafSteps<TFlow> as K extends string ? K : never]: StepOutput<TFlow, K & string>;
35
49
  } : never;
36
50
  /**
37
51
  * Extracts the steps type from a Flow
38
52
  * @template TFlow - The Flow type to extract from
39
53
  */
40
- export type ExtractFlowSteps<TFlow extends AnyFlow> = TFlow extends Flow<infer _TI, infer TS, infer _TD> ? TS : never;
54
+ export type ExtractFlowSteps<TFlow extends AnyFlow> = TFlow extends Flow<infer _TI, infer _TC, infer TS, infer _TD> ? TS : never;
41
55
  /**
42
56
  * Extracts the dependencies type from a Flow
43
57
  * @template TFlow - The Flow type to extract from
44
58
  */
45
- export type ExtractFlowDeps<TFlow extends AnyFlow> = TFlow extends Flow<infer _TI, infer _TS, infer TD> ? TD : never;
59
+ export type ExtractFlowDeps<TFlow extends AnyFlow> = TFlow extends Flow<infer _TI, infer _TC, infer _TS, infer TD> ? TD : never;
60
+ /**
61
+ * Extracts the context type from a Flow
62
+ * @template TFlow - The Flow type to extract from
63
+ */
64
+ export type ExtractFlowContext<TFlow extends AnyFlow> = TFlow extends Flow<infer _TI, infer TC, infer _TS, infer _TD> ? TC : never;
46
65
  /**
47
66
  * Extracts the dependencies type from a Flow
48
67
  * @template TFlow - The Flow type to extract from
@@ -73,13 +92,23 @@ export interface RuntimeOptions {
73
92
  baseDelay?: number;
74
93
  timeout?: number;
75
94
  }
76
- export interface StepDefinition<TInput extends AnyInput, TOutput extends AnyOutput> {
95
+ export interface BaseContext {
96
+ env: Env & ValidEnv<UserEnv>;
97
+ shutdownSignal: AbortSignal;
98
+ }
99
+ export type Context<T extends Record<string, unknown> = Record<string, never>> = BaseContext & T;
100
+ type ExtractHandlerContext<T> = T extends (input: any, context: infer C) => any ? C : never;
101
+ export interface StepRuntimeOptions extends RuntimeOptions {
102
+ startDelay?: number;
103
+ }
104
+ export interface StepDefinition<TInput extends AnyInput, TOutput extends AnyOutput, TContext = BaseContext> {
77
105
  slug: string;
78
- handler: (input: TInput) => TOutput | Promise<TOutput>;
106
+ handler: (input: TInput, context: TContext) => TOutput | Promise<TOutput>;
79
107
  dependencies: string[];
80
- options: RuntimeOptions;
108
+ options: StepRuntimeOptions;
81
109
  }
82
- export declare class Flow<TFlowInput extends AnyInput = AnyInput, Steps extends AnySteps = EmptySteps, StepDependencies extends AnyDeps = EmptyDeps> {
110
+ export declare class Flow<TFlowInput extends AnyInput = AnyInput, TContext = BaseContext, // Accumulated context requirements (starts with BaseContext)
111
+ Steps extends AnySteps = EmptySteps, StepDependencies extends AnyDeps = EmptyDeps> {
83
112
  /**
84
113
  * Store step definitions with their proper types
85
114
  *
@@ -103,15 +132,15 @@ export declare class Flow<TFlowInput extends AnyInput = AnyInput, Steps extends
103
132
  } & {
104
133
  [K in StepDependencies[SlugType][number]]: K extends keyof Steps ? Steps[K] : never;
105
134
  }>, Steps[SlugType]>;
106
- step<Slug extends string, Deps extends Extract<keyof Steps, string> = never, RetType extends AnyOutput = AnyOutput>(opts: Simplify<{
107
- slug: Slug;
108
- dependsOn?: Deps[];
109
- } & RuntimeOptions>, handler: (input: Simplify<{
135
+ step<Slug extends string, THandler extends (input: Simplify<{
110
136
  run: TFlowInput;
111
137
  } & {
112
138
  [K in Deps]: K extends keyof Steps ? Steps[K] : never;
113
- }>) => RetType | Promise<RetType>): Flow<TFlowInput, Steps & {
114
- [K in Slug]: Awaited<RetType>;
139
+ }>, context: BaseContext & TContext) => any, Deps extends Extract<keyof Steps, string> = never>(opts: Simplify<{
140
+ slug: Slug;
141
+ dependsOn?: Deps[];
142
+ } & StepRuntimeOptions>, handler: THandler): Flow<TFlowInput, TContext & BaseContext & ExtractHandlerContext<THandler>, Steps & {
143
+ [K in Slug]: AwaitedReturn<THandler>;
115
144
  }, StepDependencies & {
116
145
  [K in Slug]: Deps[];
117
146
  }>;
package/dist/dsl.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dsl.d.ts","sourceRoot":"","sources":["../src/dsl.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,IAAI,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,IAAI,EAAE,GACN;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,CAAC;AAGxC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;CAAE,GAAG,EAAE,CAAC;AAOpE,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC;AAC5B,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC;AAG7B,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC9C,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAGjD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/C,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACnD,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAM/C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAE9D;;;;GAIG;AACH,MAA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AE,UAAU,CAAC;KACjB,GAAG;SACD,CAAC,IAAI,IAAI,GAAG,CAAC,SAAS,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK;KACtD,CACF,EACD,OAAO,EAAE,WAAW,GAAG,QAAQ,KAC5B,GAAG,EACR,IAAI,SAAS,OAAO,CAAC,MAAM,KAAK,EAAE,MAAM,CAAC,GAAG,KAAK,EAEjD,IAAI,EAAE,QAAQ,CAAC;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAA;KAAE,GAAG,kBAAkB,CAAC,EACvE,OAAO,EAAE,QAAQ,GAChB,IAAI,CACL,UAAU,EACV,QAAQ,GAAG,WAAW,GAAG,qBAAqB,CAAC,QAAQ,CAAC,EACxD,KAAK,GAAG;SAAG,CAAC,IAAI,IAAI,GAAG,aAAa,CAAC,QAAQ,CAAC;KAAE,EAChD,gBAAgB,GAAG;SAAG,CAAC,IAAI,IAAI,GAAG,IAAI,EAAE;KAAE,CAC3C;CAyEF"}
package/dist/dsl.js CHANGED
@@ -64,12 +64,14 @@ export class Flow {
64
64
  options.baseDelay = opts.baseDelay;
65
65
  if (opts.timeout !== undefined)
66
66
  options.timeout = opts.timeout;
67
+ if (opts.startDelay !== undefined)
68
+ options.startDelay = opts.startDelay;
67
69
  // Validate runtime options (optional for step level)
68
70
  validateRuntimeOptions(options, { optional: true });
69
71
  // Preserve the exact type of the handler
70
72
  const newStepDefinition = {
71
73
  slug,
72
- handler: handler,
74
+ handler: handler, // Type assertion needed due to complex generic constraints
73
75
  dependencies: dependencies,
74
76
  options,
75
77
  };
@@ -2,7 +2,7 @@ import { Flow } from './dsl.js';
2
2
  type Input = {
3
3
  url: string;
4
4
  };
5
- export declare const AnalyzeWebsite: Flow<Input, import("./dsl.js").EmptySteps & {
5
+ export declare const AnalyzeWebsite: Flow<Input, import("./dsl.js").BaseContext, import("./dsl.js").EmptySteps & {
6
6
  website: {
7
7
  content: string;
8
8
  };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgflow/dsl",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -14,12 +14,22 @@
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.js"
17
+ },
18
+ "./platforms": {
19
+ "types": "./dist/platforms/index.d.ts",
20
+ "import": "./dist/platforms/index.js"
21
+ },
22
+ "./supabase": {
23
+ "types": "./dist/platforms/supabase.d.ts",
24
+ "import": "./dist/platforms/supabase.js"
17
25
  }
18
26
  },
19
27
  "publishConfig": {
20
28
  "access": "public"
21
29
  },
22
30
  "devDependencies": {
23
- "@types/node": "^22.14.1"
31
+ "@types/node": "^22.14.1",
32
+ "postgres": "^3.4.5",
33
+ "@supabase/supabase-js": "^2.47.10"
24
34
  }
25
35
  }
@@ -0,0 +1,2 @@
1
+ export type { BaseContext, Context } from '../index.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/platforms/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ // Future: utility types for platform implementations can go here
@@ -0,0 +1,30 @@
1
+ import type { Sql } from 'postgres';
2
+ import type { SupabaseClient } from '@supabase/supabase-js';
3
+ import { Flow as CoreFlow, type AnyInput, type AnySteps, type AnyDeps, EmptySteps, EmptyDeps, type Env, type UserEnv, type ValidEnv, type AnyFlow, type Json, type BaseContext } from '../index.js';
4
+ export interface SupabaseResources extends Record<string, unknown> {
5
+ sql: Sql;
6
+ anonSupabase: SupabaseClient;
7
+ serviceSupabase: SupabaseClient;
8
+ }
9
+ export interface SupabaseEnv extends Env {
10
+ EDGE_WORKER_DB_URL: string;
11
+ SUPABASE_URL: string;
12
+ SUPABASE_ANON_KEY: string;
13
+ SUPABASE_SERVICE_ROLE_KEY: string;
14
+ SB_EXECUTION_ID: string;
15
+ EDGE_WORKER_LOG_LEVEL?: string;
16
+ }
17
+ export type SupabasePlatformContext = BaseContext & SupabaseResources & {
18
+ env: SupabaseEnv & ValidEnv<UserEnv>;
19
+ };
20
+ export type SupabaseMessageContext<T extends Json = Json> = SupabasePlatformContext & {
21
+ rawMessage: any;
22
+ };
23
+ export type SupabaseStepTaskContext<F extends AnyFlow = AnyFlow> = SupabasePlatformContext & {
24
+ rawMessage: any;
25
+ stepTask: any;
26
+ };
27
+ export declare class Flow<I extends AnyInput = AnyInput, ExtraCtx extends Record<string, unknown> = Record<string, never>, S extends AnySteps = EmptySteps, D extends AnyDeps = EmptyDeps> extends CoreFlow<I, SupabasePlatformContext & ExtraCtx, // <── full ctx in handlers
28
+ S, D> {
29
+ }
30
+ //# sourceMappingURL=supabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/platforms/supabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,IAAI,IAAI,QAAQ,EAChB,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,OAAO,EAC1C,UAAU,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAC5D,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,WAAW,EAC1C,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,iBAAkB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAChE,GAAG,EAAc,GAAG,CAAC;IACrB,YAAY,EAAK,cAAc,CAAC;IAChC,eAAe,EAAE,cAAc,CAAC;CACjC;AAGD,MAAM,WAAW,WAAY,SAAQ,GAAG;IACtC,kBAAkB,EAAQ,MAAM,CAAC;IACjC,YAAY,EAAc,MAAM,CAAC;IACjC,iBAAiB,EAAS,MAAM,CAAC;IACjC,yBAAyB,EAAE,MAAM,CAAC;IAClC,eAAe,EAAW,MAAM,CAAC;IACjC,qBAAqB,CAAC,EAAI,MAAM,CAAC;CAClC;AAGD,MAAM,MAAM,uBAAuB,GACjC,WAAW,GAAG,iBAAiB,GAAG;IAChC,GAAG,EAAE,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;CACtC,CAAC;AAGJ,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,IACtD,uBAAuB,GAAG;IACxB,UAAU,EAAE,GAAG,CAAC;CACjB,CAAC;AAEJ,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAC7D,uBAAuB,GAAG;IACxB,UAAU,EAAE,GAAG,CAAC;IAChB,QAAQ,EAAE,GAAG,CAAC;CACf,CAAC;AAGJ,qBAAa,IAAI,CACf,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAChE,CAAC,SAAS,QAAQ,GAAG,UAAU,EAC/B,CAAC,SAAS,OAAO,GAAK,SAAS,CAC/B,SAAQ,QAAQ,CAChB,CAAC,EACD,uBAAuB,GAAG,QAAQ,EAAI,2BAA2B;AACjE,CAAC,EAAE,CAAC,CACL;CAAG"}
@@ -0,0 +1,4 @@
1
+ import { Flow as CoreFlow } from '../index.js';
2
+ /* ---------- 5. pre-wired Flow helper -------------------------------- */
3
+ export class Flow extends CoreFlow {
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from './platforms/supabase.js';
2
+ //# sourceMappingURL=supabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../src/supabase.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ // Re-export everything from platforms/supabase
2
+ export * from './platforms/supabase.js';
package/dist/utils.d.ts CHANGED
@@ -21,6 +21,7 @@ export interface ValidateRuntimeOptionsOpts {
21
21
  * - maxAttempts should be >= 1
22
22
  * - baseDelay should be >= 1
23
23
  * - timeout should be >= 3
24
+ * - startDelay should be >= 0
24
25
  *
25
26
  * @param options The runtime options to validate
26
27
  * @param opts Configuration options for validation
@@ -31,5 +32,6 @@ export declare function validateRuntimeOptions(options: {
31
32
  maxAttempts?: number;
32
33
  baseDelay?: number;
33
34
  timeout?: number;
35
+ startDelay?: number;
34
36
  }, opts?: ValidateRuntimeOptionsOpts): void;
35
37
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAsB/C;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EACvE,IAAI,GAAE,0BAAgD,GACrD,IAAI,CA2BN"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAsB/C;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5F,IAAI,GAAE,0BAAgD,GACrD,IAAI,CAiCN"}
package/dist/utils.js CHANGED
@@ -31,6 +31,7 @@ export function validateSlug(slug) {
31
31
  * - maxAttempts should be >= 1
32
32
  * - baseDelay should be >= 1
33
33
  * - timeout should be >= 3
34
+ * - startDelay should be >= 0
34
35
  *
35
36
  * @param options The runtime options to validate
36
37
  * @param opts Configuration options for validation
@@ -38,7 +39,7 @@ export function validateSlug(slug) {
38
39
  * @throws Error if any runtime option is invalid
39
40
  */
40
41
  export function validateRuntimeOptions(options, opts = { optional: false }) {
41
- const { maxAttempts, baseDelay, timeout } = options;
42
+ const { maxAttempts, baseDelay, timeout, startDelay } = options;
42
43
  // If optional is true, skip validation for undefined/null values
43
44
  if (maxAttempts !== undefined && maxAttempts !== null) {
44
45
  if (maxAttempts < 1) {
@@ -64,4 +65,9 @@ export function validateRuntimeOptions(options, opts = { optional: false }) {
64
65
  else if (!opts.optional) {
65
66
  throw new Error('timeout is required');
66
67
  }
68
+ if (startDelay !== undefined && startDelay !== null) {
69
+ if (startDelay < 0) {
70
+ throw new Error('startDelay must be greater than or equal to 0');
71
+ }
72
+ }
67
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgflow/dsl",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -14,12 +14,22 @@
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.js"
17
+ },
18
+ "./platforms": {
19
+ "types": "./dist/platforms/index.d.ts",
20
+ "import": "./dist/platforms/index.js"
21
+ },
22
+ "./supabase": {
23
+ "types": "./dist/platforms/supabase.d.ts",
24
+ "import": "./dist/platforms/supabase.js"
17
25
  }
18
26
  },
19
27
  "publishConfig": {
20
28
  "access": "public"
21
29
  },
22
30
  "devDependencies": {
23
- "@types/node": "^22.14.1"
31
+ "@types/node": "^22.14.1",
32
+ "postgres": "^3.4.5",
33
+ "@supabase/supabase-js": "^2.47.10"
24
34
  }
25
35
  }