Skip to content

Commit 4e77c3e

Browse files
authored
tweaks to docs here and there (#97)
* fix: update import syntax, remove deprecated code, and clarify documentation Refactors import statements to use default imports, removes unused simulateFailure step, and updates instructions for consistency. Also corrects minor formatting issues in docs. * fix(docs): correct installation prerequisites and remove redundant content Update the documentation to fix a typo in the create-first-flow guide, and revise the prerequisites in the install-pgflow guide by specifying the correct Deno version. * feat: update flow and task files for greeting workflow and rename related components Refactors the example to create a greeting flow instead of website analysis, including modifying flow definitions, task implementations, and worker setup for the new flow. Also updates migration and documentation to reflect the new greeting workflow. * docs: update documentation to mark page as draft and clarify structure guidance - Set the page as a draft to prevent premature publication - Slight wording adjustment for clarity in the introduction - Corrected a minor formatting issue at the end of the file * refactor: update flow step names and references for consistency in documentation - Renamed 'format_name' step to 'full_name' in SQL, flow definition, and documentation - Updated corresponding references and output examples across multiple files - Minor formatting adjustments for clarity and consistency in the tutorials and SQL snippets * feat: add website analysis workflow and update documentation - Introduced a new code example demonstrating a website analysis flow with scraping, summarization, and tagging steps - Updated documentation to correct typo in tagline and improve clarity of workflow orchestration examples - Refactored existing workflow code to include the new analyze_website flow, replacing previous placeholder - Minor formatting and consistency improvements across code and docs * docs: update tutorial content, improve structure, and clarify installation steps - Revised 'create-first-flow' MDX to update example workflow description and add step details - Enhanced readability by adjusting formatting and removing deprecated sections - Clarified 'install-pgflow' instructions with a new 'What was installed?' section - Removed outdated navigation links from index page for better clarity and accuracy * docs: update documentation to remove NotProductionReady component and improve flow creation instructions - Removed deprecated NotProductionReady component from compile-to-sql.md - Clarified steps for compiling, examining, and applying SQL migrations - Changed note styling from Aside to note for better emphasis - Minor formatting adjustments for clarity and consistency * docs: add new guide on versioning flows and remove deprecated flow management warnings - Introduced a new documentation page detailing safe flow versioning strategies - Removed outdated caution and danger sections from existing flow compilation docs - Updated content to include best practices for managing flow migrations and updates - Ensured consistency across documentation regarding flow versioning and modification guidelines * docs: update documentation to remove aside in compile-to-sql and clarify flow creation steps - Removed deprecated aside note in compile-to-sql.md - Clarified project structure and flow creation instructions in create-first-flow.md - Improved explanations of flow features and key concepts for better understanding * chore(docs): update manual installation instructions for migration files, environment setup, and runtime policy - Clarify steps to download, extract, and copy migration files - Add instructions for creating environment variables with proper URL encoding - Include configuration changes for connection pooling and Edge Runtime policy - Update restart commands to reflect the latest setup process * docs: update prerequisite requirements in getting started guide - Clarify that Deno version 1.45.x or higher is required before compiling flows to SQL * docs: add NotProductionReady component to multiple docs and remove redundant import * docs: remove draft status from organize-flows-codebase documentation
1 parent 4adf048 commit 4e77c3e

File tree

10 files changed

+590
-572
lines changed

10 files changed

+590
-572
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
new Flow<{ url: string }>({
2+
slug: 'analyze_website',
3+
})
4+
.step(
5+
{ slug: 'website' },
6+
async (input) => await scrapeWebsite(input.run.url)
7+
)
8+
.step(
9+
{ slug: 'summary', dependsOn: ['website'] },
10+
async (input) => await summarizeWithAI(input.website.content)
11+
)
12+
.step(
13+
{ slug: 'tags', dependsOn: ['website'] },
14+
async ({}) => await extractTags(input.website.content)
15+
)
16+
.step(
17+
{ slug: 'saveToDb', dependsOn: ['summary', 'tags'] },
18+
async ({ run, summary, tags }) =>
19+
await saveWebsite({
20+
user_id: run.user_id,
21+
website_url: run.url,
22+
summary,
23+
tags,
24+
})
25+
);

pkgs/website/src/content/docs/getting-started/compile-to-sql.mdx

Lines changed: 41 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import NotProductionReady from '@/components/NotProductionReady.astro';
1010

1111
Now that we've defined our flow, we need to register it in the database. pgflow provides a CLI tool that compiles your TypeScript flow definition into SQL migrations that can be applied to your Supabase database.
1212

13-
<NotProductionReady />
13+
<NotProductionReady/>
1414

1515
## What is compilation?
1616

@@ -27,163 +27,66 @@ This is an essential step because pgflow's runtime executes flows based on their
2727
Before continuing, make sure you have:
2828
- Completed the [flow definition](/getting-started/create-first-flow/) from the previous step
2929
- The Supabase CLI installed and configured
30+
- Deno version 1.45.x or higher
3031
</Aside>
3132

32-
<Steps>
33-
1. ### Compile the flow to SQL
33+
### 1. Compile the flow to SQL
3434

35-
Run the pgflow compile command, pointing to your flow definition file:
35+
Run the pgflow compile command, pointing to your flow definition file:
3636

37-
```bash frame="none"
38-
npx pgflow@latest compile supabase/functions/_flows/analyze_website.ts
39-
```
40-
41-
This will:
42-
- Parse your TypeScript flow definition
43-
- Extract the flow structure, step dependencies, and configuration
44-
- Generate SQL commands to register the flow in the database
45-
- Create a timestamped migration file in your Supabase migrations folder
46-
47-
You should see output like this:
48-
49-
```
50-
✓ Successfully compiled flow to SQL
51-
✓ Migration file created: supabase/migrations/20250505120000_create_analyze_website_flow.sql
52-
```
53-
54-
2. ### Examine the generated SQL
55-
56-
Let's look at what got generated. Open the migration file in your editor:
57-
58-
```bash frame="none"
59-
cat supabase/migrations/20250505120000_create_analyze_website_flow.sql
60-
```
61-
62-
The migration file contains SQL commands that:
63-
64-
1. Create the flow definition
65-
2. Add each step with its configuration
66-
3. Define dependencies between steps
67-
68-
Here's a simplified view of what the SQL looks like:
69-
70-
```sql
71-
-- Create the flow
72-
SELECT pgflow.create_flow('analyze_website', max_attempts => 3, base_delay => 1, timeout => 4);
73-
74-
-- Add steps and define their dependencies
75-
SELECT pgflow.add_step('analyze_website', 'website');
76-
SELECT pgflow.add_step('analyze_website', 'summary', ARRAY['website']);
77-
SELECT pgflow.add_step('analyze_website', 'tags', ARRAY['website']);
78-
SELECT pgflow.add_step('analyze_website', 'saveToDb', ARRAY['summary', 'tags']);
79-
```
80-
81-
This SQL representation is what the pgflow runtime system uses to execute your workflow.
82-
83-
3. ### Apply the migration
84-
85-
Now that we have the SQL migration, we need to apply it to our database:
86-
87-
```bash frame="none"
88-
npx supabase migrations up
89-
```
90-
91-
This will execute the SQL migration and register your flow definition in the database.
92-
93-
If successful, you should see output like:
94-
95-
```
96-
Applying migration 20250505120000_create_analyze_website_flow.sql...done
97-
```
98-
99-
</Steps>
37+
```bash frame="none"
38+
npx pgflow@latest compile supabase/functions/_flows/greet_user.ts
39+
```
10040

101-
## Managing flow changes and versioning
41+
This will:
42+
- Parse your TypeScript flow definition
43+
- Extract the flow structure, step dependencies, and configuration
44+
- Generate SQL commands to register the flow in the database
45+
- Create a timestamped migration file in your Supabase migrations folder
10246

103-
:::caution[Current Compilation Limitations]
104-
**Important:** The current version of pgflow's compiler:
47+
You should see output like this:
10548

106-
1. Always creates a **new migration file** for any changes
107-
2. Does not provide automatic update functionality for existing flows
108-
3. Cannot safely change step dependencies or flow structure
49+
```
50+
✓ Successfully compiled flow to SQL
51+
✓ Migration file created: supabase/migrations/20250505120000_create_greet_user_flow.sql
52+
```
10953

110-
For any changes to an existing flow, you must:
111-
- Manually handle migration files
112-
- **NEVER** change dependencies, step slugs, or flow structure in existing flows
113-
- For non-breaking changes, manually update using SQL commands
114-
:::
54+
### 2. Examine the generated SQL
11555

116-
:::danger[Prohibited Changes]
117-
DO NOT attempt to change these aspects of an existing flow:
118-
- Step slugs
119-
- Dependencies between steps
120-
- Adding or removing steps
121-
- Altering the flow's input type structure
56+
Let's look at what got generated. Open the migration file in your editor:
12257

123-
These changes will break in-progress runs and cause data compatibility issues.
124-
:::
58+
```bash frame="none"
59+
cat supabase/migrations/20250505120000_create_greet_user_flow.sql
60+
```
12561

126-
### Version management strategy
62+
The migration file contains SQL commands that:
12763

128-
pgflow uses the flow's `slug` as its identifier, so to create a new version:
64+
1. Create the flow definition
65+
2. Add each step with its configuration
66+
3. Define dependencies between steps
12967

130-
1. **Create a new flow definition file** with a versioned slug (e.g., `analyze_website_v2.ts`)
131-
2. **Manually manage migration files**:
132-
- Keep previous migration files for existing runs
133-
- Create new migrations for the new flow version
68+
The generated SQL looks like this:
13469

135-
```typescript
136-
// analyze_website_v2.ts
137-
export default new Flow<Input>({
138-
slug: 'analyze_website_v2', // Note the versioned slug
139-
// ...configuration
140-
})
70+
```sql
71+
SELECT pgflow.create_flow('greet_user');
72+
SELECT pgflow.add_step('greet_user', 'full_name');
73+
SELECT pgflow.add_step('greet_user', 'greeting', ARRAY['full_name']);
14174
```
14275

143-
### Safe vs. breaking changes
144-
145-
| Safe Changes | Breaking Changes |
146-
| ------------ | --------------- |
147-
| Modifying step implementation | Adding/removing steps |
148-
| Adjusting retry parameters | Changing step dependencies |
149-
| Updating timeout values | Modifying input/output types |
150-
| Bug fixes within steps | Changing step slug names |
76+
This SQL representation is what the pgflow runtime system uses to execute your workflow.
15177

152-
### Updating non-breaking configuration options
78+
### 3. Apply the migration
15379

154-
For non-breaking changes like adjusting retry settings or timeouts, you must manually update the database with SQL commands.
80+
Now that we have the SQL migration, we need to apply it to our database:
15581

156-
:::tip[How To Guide]
157-
We've created a detailed guide on [how to update flow options](/how-to/update-flow-options/) that covers:
158-
- All available configuration options
159-
- SQL commands for updating flows and steps
160-
- Best practices for maintaining compatibility
161-
162-
For any non-breaking changes to existing flows, refer to this guide rather than recompiling.
163-
:::
164-
165-
### Task reusability
82+
```bash frame="none"
83+
npx supabase migrations up
84+
```
16685

167-
The separation of tasks from flows helps with versioning:
86+
This will execute the SQL migration and register your flow definition in the database.
16887

169-
- Tasks can be reused across multiple flow versions
170-
- Implementation details can evolve independently of flow structure
171-
- New flow versions can reuse existing task implementations
88+
If successful, you should see output like:
17289

173-
```typescript
174-
// Both flow versions can use the same task implementations
175-
// analyze_website_v1.ts and analyze_website_v2.ts
176-
import { scrapeWebsite } from '../_tasks/scrapeWebsite.ts';
17790
```
178-
179-
:::note[Flow Versioning Tips]
180-
- For non-breaking configuration changes: Update database directly with SQL
181-
- For breaking changes: Always create a new flow with a versioned slug
182-
- Consider a versioning scheme (v1, v2, etc.) for your flow slugs
183-
- Always test migrations thoroughly before applying in production
184-
- Plan how to migrate in-progress runs when deploying new versions
185-
:::
186-
187-
<Aside>
188-
Now that your flow is registered in the database, the next step is to [set up a worker and trigger the flow](/getting-started/trigger-and-monitor/).
189-
</Aside>
91+
Applying migration 20250505120000_create_greet_user_flow.sql...done
92+
```

0 commit comments

Comments
 (0)