Skip to content

Commit d567ec3

Browse files
authored
Merge pull request #175 from nocodb/couple-changes
feat: scripts steps api
2 parents 6d6f466 + 61f379e commit d567ec3

File tree

10 files changed

+492
-2
lines changed

10 files changed

+492
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ yarn-error.log*
2929
next-env.d.ts
3030

3131
.env
32+
3233
/public/robots.txt
3334
/public/sitemap.xml
3435
/public/sitemap-*.xml
35-
/public/llms.txt
36+
/public/llms.txt

content/scripts/api-reference/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"session",
1313
"collaborator",
1414
"script-settings",
15+
"script-steps",
1516
"input",
1617
"output",
1718
"fetch"
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
---
2+
title: 'Script Steps'
3+
description: 'Visually guide users through your script with clear subsections'
4+
---
5+
6+
Script Steps let your users see what’s happening while your script runs—making complex operations easier to follow with clear, real-time visual subsections.
7+
8+
Instead of a blank screen, users get progress feedback through titled steps, icons, colors, and descriptions—bringing transparency, trust, and a polished experience.
9+
10+
<img src="/img/v2/scripts/steps.png" alt="script steps" style={{ width: "50%" }} />
11+
12+
13+
### Basic Step
14+
15+
Add a step with just a title:
16+
17+
```js
18+
script.step('Loading your data...');
19+
```
20+
21+
<img src="/img/v2/scripts/simple-step.png" alt="script steps" style={{ width: "50%" }} />
22+
23+
### Detailed Step
24+
25+
Enhance the step with optional visuals:
26+
27+
```js
28+
script.step({
29+
title: 'Getting Latest Data',
30+
description: 'Fetching records from your selected table',
31+
color: 'blue',
32+
icon: 'download'
33+
});
34+
```
35+
36+
<img src="/img/v2/scripts/detailed-step.png" alt="detailed step" style={{ width: "50%" }} />
37+
38+
39+
## Customization Options
40+
41+
### Colors
42+
43+
Use colors to indicate the type of action:
44+
45+
| Color | Use Case |
46+
|----------|----------------------------------|
47+
| `blue` | General info, loading data |
48+
| `green` | Success, completed actions |
49+
| `yellow` | Validation, warnings |
50+
| `red` | Errors, critical issues |
51+
| `purple` | Special or custom operations |
52+
| `orange` | Updates or changes |
53+
| `gray` | Background or neutral operations |
54+
55+
### Icons
56+
57+
Suggested icons for common use cases:
58+
59+
| Icon | Meaning |
60+
|---------------|-----------------------------|
61+
| `download` | Fetching or retrieving data |
62+
| `upload` | Sending or submitting data |
63+
| `database` | Interacting with tables |
64+
| `sync` | Updating or syncing |
65+
| `checkCircle` | Completion or success |
66+
| `settings` | Configuration steps |
67+
| `mail` | Email-related actions |
68+
69+
70+
## Full Example
71+
72+
Here’s a complete example that guides the user through an import process:
73+
74+
```js
75+
// Step 1: Start import
76+
script.step({
77+
title: 'Starting Import',
78+
description: 'Preparing to import customer data',
79+
color: 'blue',
80+
icon: 'database'
81+
});
82+
83+
const sourceTable = await input.tableAsync('Which table has your customer data?');
84+
const targetTable = await input.tableAsync('Which table should we import to?');
85+
86+
// Step 2: Validate data
87+
script.step({
88+
title: 'Checking Your Data',
89+
description: 'Making sure the data will import correctly',
90+
color: 'yellow',
91+
icon: 'checkCircle'
92+
});
93+
94+
const sourceRecords = await sourceTable.selectRecordsAsync();
95+
if (sourceRecords.length === 0) {
96+
output.text('No records found to import!');
97+
return;
98+
}
99+
100+
// Step 3: Import records
101+
script.step({
102+
title: 'Importing Records',
103+
description: `Moving ${sourceRecords.length} customer records`,
104+
color: 'purple',
105+
icon: 'sync'
106+
});
107+
108+
const newRecords = sourceRecords.map(record => ({
109+
'Customer Name': record.getCellValue('Name'),
110+
'Email': record.getCellValue('Email'),
111+
'Import Date': new Date()
112+
}));
113+
114+
await targetTable.createRecordsAsync(newRecords);
115+
116+
// Step 4: Finish
117+
script.step({
118+
title: 'Import Complete',
119+
description: `Successfully imported ${newRecords.length} customers`,
120+
color: 'green',
121+
icon: 'checkCircle'
122+
});
123+
124+
script.clear();
125+
output.text(`✅ Done! Imported ${newRecords.length} customer records.`);
126+
```
127+
128+
129+
## Advanced Usage
130+
131+
### Manually Clear a Step
132+
133+
Steps auto-clear when a new one starts, but you can also clear them explicitly:
134+
135+
```js
136+
script.step('Processing...');
137+
await someAsyncTask();
138+
script.clear();
139+
```
140+
141+
### Handling Errors Gracefully
142+
143+
Show errors in context to keep users informed:
144+
145+
```js
146+
script.step({
147+
title: 'Sending Emails',
148+
description: 'Notifying customers about their orders',
149+
color: 'blue',
150+
icon: 'mail'
151+
});
152+
153+
try {
154+
await sendEmails();
155+
156+
script.step({
157+
title: 'Emails Sent',
158+
description: 'All customers have been notified',
159+
color: 'green',
160+
icon: 'checkCircle'
161+
});
162+
} catch (err) {
163+
script.step({
164+
title: 'Email Error',
165+
description: 'Could not send some emails – check your settings',
166+
color: 'red',
167+
icon: 'alert'
168+
});
169+
}
170+
```
171+
172+
173+
## Best practices
174+
175+
### Step Titles
176+
177+
Use descriptive, action-based titles:
178+
179+
| ✅ Do | 🚫 Avoid |
180+
|-------------------------|--------------|
181+
| "Loading customer data" | "Step 1" |
182+
| "Sending invoices" | "Processing" |
183+
| "Updating inventory" | "Working" |
184+
185+
### When to Use Steps
186+
187+
Use script steps to improve clarity in:
188+
189+
* Long-running operations (API calls, imports, etc.)
190+
* Multi-phase workflows (setup → validate → process → complete)
191+
* Any place where user feedback improves trust
192+
193+
Avoid steps for very fast or trivial operations that don’t need explanation.
194+
195+
### How Many Steps?
196+
197+
* **3–7 steps** is ideal for most scripts
198+
* Too few → lack of visibility
199+
* Too many → unnecessary noise
200+
201+
### Step Descriptions
202+
203+
Explain **what’s happening**, not **how it’s implemented**:
204+
205+
| ✅ Good | 🚫 Avoid |
206+
|------------------------------------------|-------------------------------------|
207+
| "Fetching latest orders from your store" | "Calling API endpoint with headers" |
208+
209+
---

content/scripts/changelog.mdx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: 'Changelog'
3+
description: 'NocoDB Scripts API changelog and version history'
4+
icon: 'clock'
5+
---
6+
7+
This page documents all changes to the NocoDB Scripts API, including new features, improvements, bug fixes, and breaking changes.
8+
9+
## July 28, 2025
10+
11+
12+
#### Script Steps API
13+
- **Added `script` object** - New global object for creating visual steps
14+
- **`script.step(config)`** - Create and start steps with rich customization options
15+
- Support for titles, descriptions, icons, and colors
16+
- Automatic step management (previous step ends when new step starts)
17+
- String shorthand: `script.step('Step Title')` or full config object
18+
- **`script.clear()`** - Manually end the current step
19+
- **`script.colors`** - Predefined color constants (red, blue, green, yellow, purple, orange, gray)
20+
- **`script.icons`** - Comprehensive icon library with 100+ icons across different categories.
21+
22+
23+
#### Improvements
24+
- Increased script timeout to 30 Minutes
25+
26+
---
27+
28+
## June 30, 2025
29+
30+
#### Initial Scripts Release
31+
- **`base` object** - Access to base metadata and configuration
32+
- **`table` object** - Create, Read operations on tables
33+
- **`record` object** - Rich record manipulation capabilities
34+
- **`field` object** - Field metadata and validation
35+
- **`input` object** - User input collection methods
36+
- **`output` object** - Rich output formatting options
37+
- **`fetch` function** - HTTP requests to external APIs
38+
- **`session` object** - Script execution context and state
39+
40+
#### Core Functionality
41+
- **JavaScript runtime** - Full ES6+ support
42+
- **Async/await support** - Modern asynchronous programming
43+
- **Error handling** - Comprehensive error reporting
44+
- **Type safety** - TypeScript definitions for all APIs
45+
46+
---
47+
48+
## Support and Resources
49+
50+
- **Documentation**: [Scripts API Reference](/docs/scripts/api-reference)
51+
- **Examples**: [Script Examples](/docs/scripts/examples)
52+
- **Community**: [NocoDB Discord](https://discord.gg/5RgZmkW)
53+
- **Issues**: [GitHub Issues](https://github.com/nocodb/nocodb/issues)
54+
55+
For questions about specific API changes or migration help, please reach out to our community or support team.

content/scripts/examples/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"save-view-ordering",
1313
"link-records-by-field",
1414
"unique-field-values-summary",
15+
"script-steps",
1516
"import-csv"
1617
]
1718
}

0 commit comments

Comments
 (0)