@pgflow/dsl 0.8.0 → 0.9.0
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 +12 -12
- package/dist/CHANGELOG.md +4 -0
- package/dist/README.md +12 -12
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ type Input = {
|
|
|
31
31
|
|
|
32
32
|
// Define a flow with steps and dependencies
|
|
33
33
|
export const AnalyzeWebsite = new Flow<Input>({
|
|
34
|
-
slug: '
|
|
34
|
+
slug: 'analyzeWebsite',
|
|
35
35
|
maxAttempts: 3,
|
|
36
36
|
baseDelay: 5,
|
|
37
37
|
timeout: 10,
|
|
@@ -98,13 +98,13 @@ A semantic wrapper around `.step()` that provides type enforcement for steps tha
|
|
|
98
98
|
```typescript
|
|
99
99
|
// Fetch an array of items to be processed
|
|
100
100
|
.array(
|
|
101
|
-
{ slug: '
|
|
101
|
+
{ slug: 'fetchItems' },
|
|
102
102
|
async () => [1, 2, 3, 4, 5]
|
|
103
103
|
)
|
|
104
104
|
|
|
105
105
|
// With dependencies - combining data from multiple sources
|
|
106
106
|
.array(
|
|
107
|
-
{ slug: '
|
|
107
|
+
{ slug: 'combineResults', dependsOn: ['source1', 'source2'] },
|
|
108
108
|
async (input) => [...input.source1, ...input.source2]
|
|
109
109
|
)
|
|
110
110
|
```
|
|
@@ -131,7 +131,7 @@ Processes arrays element-by-element, similar to JavaScript's `Array.map()`. The
|
|
|
131
131
|
```typescript
|
|
132
132
|
// ROOT MAP - No array: property means use flow input
|
|
133
133
|
// Flow input MUST be an array (e.g., ["hello", "world"])
|
|
134
|
-
new Flow<string[]>({ slug: '
|
|
134
|
+
new Flow<string[]>({ slug: 'processStrings' })
|
|
135
135
|
.map(
|
|
136
136
|
{ slug: 'uppercase' }, // No array: property!
|
|
137
137
|
(item) => item.toUpperCase()
|
|
@@ -139,7 +139,7 @@ new Flow<string[]>({ slug: 'process_strings' })
|
|
|
139
139
|
// Each string in the input array gets uppercased in parallel
|
|
140
140
|
|
|
141
141
|
// DEPENDENT MAP - array: property specifies the source step
|
|
142
|
-
new Flow<{}>({ slug: '
|
|
142
|
+
new Flow<{}>({ slug: 'dataPipeline' })
|
|
143
143
|
.array({ slug: 'numbers' }, () => [1, 2, 3])
|
|
144
144
|
.map(
|
|
145
145
|
{ slug: 'double', array: 'numbers' }, // Processes 'numbers' output
|
|
@@ -166,7 +166,7 @@ The `.map()` method provides full TypeScript type inference for array elements:
|
|
|
166
166
|
```typescript
|
|
167
167
|
type User = { id: number; name: string };
|
|
168
168
|
|
|
169
|
-
new Flow<{}>({ slug: '
|
|
169
|
+
new Flow<{}>({ slug: 'userFlow' })
|
|
170
170
|
.array({ slug: 'users' }, (): User[] => [
|
|
171
171
|
{ id: 1, name: 'Alice' },
|
|
172
172
|
{ id: 2, name: 'Bob' }
|
|
@@ -181,7 +181,7 @@ new Flow<{}>({ slug: 'user_flow' })
|
|
|
181
181
|
|
|
182
182
|
```typescript
|
|
183
183
|
// Batch processing - process multiple items in parallel
|
|
184
|
-
new Flow<number[]>({ slug: '
|
|
184
|
+
new Flow<number[]>({ slug: 'batchProcessor' })
|
|
185
185
|
.map({ slug: 'validate' }, (item) => {
|
|
186
186
|
if (item < 0) throw new Error('Invalid item');
|
|
187
187
|
return item;
|
|
@@ -192,9 +192,9 @@ new Flow<number[]>({ slug: 'batch_processor' })
|
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
// Data transformation pipeline
|
|
195
|
-
new Flow<{}>({ slug: '
|
|
196
|
-
.step({ slug: '
|
|
197
|
-
.map({ slug: 'scrape', array: '
|
|
195
|
+
new Flow<{}>({ slug: 'etlPipeline' })
|
|
196
|
+
.step({ slug: 'fetchUrls' }, () => ['url1', 'url2', 'url3'])
|
|
197
|
+
.map({ slug: 'scrape', array: 'fetchUrls' }, async (url) => {
|
|
198
198
|
return await fetchContent(url);
|
|
199
199
|
})
|
|
200
200
|
.map({ slug: 'extract', array: 'scrape' }, (html) => {
|
|
@@ -271,7 +271,7 @@ To use Supabase resources, import the `Flow` class from the Supabase preset:
|
|
|
271
271
|
import { Flow } from '@pgflow/dsl/supabase';
|
|
272
272
|
|
|
273
273
|
const MyFlow = new Flow<{ userId: string }>({
|
|
274
|
-
slug: '
|
|
274
|
+
slug: 'myFlow',
|
|
275
275
|
}).step({ slug: 'process' }, async (input, context) => {
|
|
276
276
|
// TypeScript knows context includes Supabase resources
|
|
277
277
|
const { data } = await context.supabase
|
|
@@ -300,7 +300,7 @@ Configure flows and steps with runtime options:
|
|
|
300
300
|
|
|
301
301
|
```typescript
|
|
302
302
|
new Flow<Input>({
|
|
303
|
-
slug: '
|
|
303
|
+
slug: 'myFlow', // Required: Unique flow identifier
|
|
304
304
|
maxAttempts: 3, // Optional: Maximum retry attempts (default: 1)
|
|
305
305
|
baseDelay: 5, // Optional: Base delay in seconds for retries (default: 1)
|
|
306
306
|
timeout: 10, // Optional: Task timeout in seconds (default: 30)
|
package/dist/CHANGELOG.md
CHANGED
package/dist/README.md
CHANGED
|
@@ -31,7 +31,7 @@ type Input = {
|
|
|
31
31
|
|
|
32
32
|
// Define a flow with steps and dependencies
|
|
33
33
|
export const AnalyzeWebsite = new Flow<Input>({
|
|
34
|
-
slug: '
|
|
34
|
+
slug: 'analyzeWebsite',
|
|
35
35
|
maxAttempts: 3,
|
|
36
36
|
baseDelay: 5,
|
|
37
37
|
timeout: 10,
|
|
@@ -98,13 +98,13 @@ A semantic wrapper around `.step()` that provides type enforcement for steps tha
|
|
|
98
98
|
```typescript
|
|
99
99
|
// Fetch an array of items to be processed
|
|
100
100
|
.array(
|
|
101
|
-
{ slug: '
|
|
101
|
+
{ slug: 'fetchItems' },
|
|
102
102
|
async () => [1, 2, 3, 4, 5]
|
|
103
103
|
)
|
|
104
104
|
|
|
105
105
|
// With dependencies - combining data from multiple sources
|
|
106
106
|
.array(
|
|
107
|
-
{ slug: '
|
|
107
|
+
{ slug: 'combineResults', dependsOn: ['source1', 'source2'] },
|
|
108
108
|
async (input) => [...input.source1, ...input.source2]
|
|
109
109
|
)
|
|
110
110
|
```
|
|
@@ -131,7 +131,7 @@ Processes arrays element-by-element, similar to JavaScript's `Array.map()`. The
|
|
|
131
131
|
```typescript
|
|
132
132
|
// ROOT MAP - No array: property means use flow input
|
|
133
133
|
// Flow input MUST be an array (e.g., ["hello", "world"])
|
|
134
|
-
new Flow<string[]>({ slug: '
|
|
134
|
+
new Flow<string[]>({ slug: 'processStrings' })
|
|
135
135
|
.map(
|
|
136
136
|
{ slug: 'uppercase' }, // No array: property!
|
|
137
137
|
(item) => item.toUpperCase()
|
|
@@ -139,7 +139,7 @@ new Flow<string[]>({ slug: 'process_strings' })
|
|
|
139
139
|
// Each string in the input array gets uppercased in parallel
|
|
140
140
|
|
|
141
141
|
// DEPENDENT MAP - array: property specifies the source step
|
|
142
|
-
new Flow<{}>({ slug: '
|
|
142
|
+
new Flow<{}>({ slug: 'dataPipeline' })
|
|
143
143
|
.array({ slug: 'numbers' }, () => [1, 2, 3])
|
|
144
144
|
.map(
|
|
145
145
|
{ slug: 'double', array: 'numbers' }, // Processes 'numbers' output
|
|
@@ -166,7 +166,7 @@ The `.map()` method provides full TypeScript type inference for array elements:
|
|
|
166
166
|
```typescript
|
|
167
167
|
type User = { id: number; name: string };
|
|
168
168
|
|
|
169
|
-
new Flow<{}>({ slug: '
|
|
169
|
+
new Flow<{}>({ slug: 'userFlow' })
|
|
170
170
|
.array({ slug: 'users' }, (): User[] => [
|
|
171
171
|
{ id: 1, name: 'Alice' },
|
|
172
172
|
{ id: 2, name: 'Bob' }
|
|
@@ -181,7 +181,7 @@ new Flow<{}>({ slug: 'user_flow' })
|
|
|
181
181
|
|
|
182
182
|
```typescript
|
|
183
183
|
// Batch processing - process multiple items in parallel
|
|
184
|
-
new Flow<number[]>({ slug: '
|
|
184
|
+
new Flow<number[]>({ slug: 'batchProcessor' })
|
|
185
185
|
.map({ slug: 'validate' }, (item) => {
|
|
186
186
|
if (item < 0) throw new Error('Invalid item');
|
|
187
187
|
return item;
|
|
@@ -192,9 +192,9 @@ new Flow<number[]>({ slug: 'batch_processor' })
|
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
// Data transformation pipeline
|
|
195
|
-
new Flow<{}>({ slug: '
|
|
196
|
-
.step({ slug: '
|
|
197
|
-
.map({ slug: 'scrape', array: '
|
|
195
|
+
new Flow<{}>({ slug: 'etlPipeline' })
|
|
196
|
+
.step({ slug: 'fetchUrls' }, () => ['url1', 'url2', 'url3'])
|
|
197
|
+
.map({ slug: 'scrape', array: 'fetchUrls' }, async (url) => {
|
|
198
198
|
return await fetchContent(url);
|
|
199
199
|
})
|
|
200
200
|
.map({ slug: 'extract', array: 'scrape' }, (html) => {
|
|
@@ -271,7 +271,7 @@ To use Supabase resources, import the `Flow` class from the Supabase preset:
|
|
|
271
271
|
import { Flow } from '@pgflow/dsl/supabase';
|
|
272
272
|
|
|
273
273
|
const MyFlow = new Flow<{ userId: string }>({
|
|
274
|
-
slug: '
|
|
274
|
+
slug: 'myFlow',
|
|
275
275
|
}).step({ slug: 'process' }, async (input, context) => {
|
|
276
276
|
// TypeScript knows context includes Supabase resources
|
|
277
277
|
const { data } = await context.supabase
|
|
@@ -300,7 +300,7 @@ Configure flows and steps with runtime options:
|
|
|
300
300
|
|
|
301
301
|
```typescript
|
|
302
302
|
new Flow<Input>({
|
|
303
|
-
slug: '
|
|
303
|
+
slug: 'myFlow', // Required: Unique flow identifier
|
|
304
304
|
maxAttempts: 3, // Optional: Maximum retry attempts (default: 1)
|
|
305
305
|
baseDelay: 5, // Optional: Base delay in seconds for retries (default: 1)
|
|
306
306
|
timeout: 10, // Optional: Task timeout in seconds (default: 30)
|
package/dist/package.json
CHANGED