@unstable-dev/unmeshed-mcp 0.1.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 +64 -0
- package/dist/auth.d.ts +6 -0
- package/dist/auth.js +11 -0
- package/dist/client.d.ts +46 -0
- package/dist/client.js +97 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +31 -0
- package/dist/get-docs.d.ts +8 -0
- package/dist/get-docs.js +64 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +35 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +203 -0
- package/knowledge/README.md +16 -0
- package/knowledge/SKILL.md +359 -0
- package/knowledge/assets/patterns.md +637 -0
- package/knowledge/execution/debugging-guide.md +18 -0
- package/knowledge/execution/process-run.schema.md +24 -0
- package/knowledge/execution/step-run.schema.md +21 -0
- package/knowledge/process-definition.schema.md +36 -0
- package/knowledge/references/integrations.md +914 -0
- package/knowledge/references/steps-knowledge.md +834 -0
- package/knowledge/step-definition.schema.md +140 -0
- package/knowledge/step-output-paths.md +45 -0
- package/knowledge/steps/DECISION_ENGINE.md +248 -0
- package/knowledge/steps/DEPENDSON.md +296 -0
- package/knowledge/steps/EXIT.md +220 -0
- package/knowledge/steps/FAIL.md +198 -0
- package/knowledge/steps/FLOW_GATEWAY.md +405 -0
- package/knowledge/steps/FOREACH.md +250 -0
- package/knowledge/steps/HTTP.md +183 -0
- package/knowledge/steps/JAVASCRIPT.md +192 -0
- package/knowledge/steps/JQ.md +189 -0
- package/knowledge/steps/LIST.md +279 -0
- package/knowledge/steps/NOOP.md +165 -0
- package/knowledge/steps/PARALLEL.md +366 -0
- package/knowledge/steps/PYTHON.md +206 -0
- package/knowledge/steps/SEND_RESPONSE.md +301 -0
- package/knowledge/steps/SQLITE.md +301 -0
- package/knowledge/steps/SUB_PROCESS.md +296 -0
- package/knowledge/steps/SWITCH.md +369 -0
- package/knowledge/steps/UPDATE_STEP.md +257 -0
- package/knowledge/steps/WAIT.md +218 -0
- package/knowledge/steps/WHILE.md +328 -0
- package/knowledge/steps/WORKER.md +233 -0
- package/knowledge/system-prompt.md +274 -0
- package/package.json +39 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# Send Response Step Schema
|
|
2
|
+
|
|
3
|
+
`SEND_RESPONSE` lets a workflow send an HTTP response payload back to the
|
|
4
|
+
waiting API caller before or during the rest of the workflow execution. Use it
|
|
5
|
+
when an API-triggered process must control the HTTP status code and response
|
|
6
|
+
body directly from inside the workflow.
|
|
7
|
+
|
|
8
|
+
From the engine source:
|
|
9
|
+
- The step copies a mapped payload into the **process-level output**.
|
|
10
|
+
- It resolves the response payload from `input.outputMapping`, unless the
|
|
11
|
+
process definition has a top-level `outputMapping`, in which case that
|
|
12
|
+
process-level mapping is used instead.
|
|
13
|
+
- If `httpStatusCode` is `2xx`, it streams a normal response to the waiting
|
|
14
|
+
caller.
|
|
15
|
+
- If `httpStatusCode` is not `2xx`, it streams a `CustomHttpException` to the
|
|
16
|
+
waiting caller with `errorMessage` and the mapped output as `context`.
|
|
17
|
+
- The step itself is still marked `COMPLETED` and proceeds through the normal
|
|
18
|
+
engine update path.
|
|
19
|
+
|
|
20
|
+
Important:
|
|
21
|
+
- `SEND_RESPONSE` is most meaningful for synchronous API/endpoint execution.
|
|
22
|
+
- If there is no active waiting caller, the stream call has no visible external
|
|
23
|
+
effect, but the process-level output is still updated.
|
|
24
|
+
|
|
25
|
+
## Definition Input Schema
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"httpStatusCode": 400,
|
|
30
|
+
"outputMapping": {
|
|
31
|
+
"result": "failed"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Field | Type | Required | Description |
|
|
37
|
+
|---|---|---|---|
|
|
38
|
+
| `httpStatusCode` | number or numeric string | No | HTTP status code to send back to the waiting caller. Defaults to `200`. |
|
|
39
|
+
| `outputMapping` | object | No | Response payload to merge into process output and return to the caller. |
|
|
40
|
+
|
|
41
|
+
Observed source behavior:
|
|
42
|
+
- `httpStatusCode` may be a number like `400` or a numeric string like `"202"`.
|
|
43
|
+
- If `httpStatusCode` is an invalid non-numeric string, the step fails with `output.error = "httpStatusCode should be a valid numerical status code"`.
|
|
44
|
+
- If the **process definition** has a top-level `outputMapping`, that mapping is resolved and used instead of the step input `outputMapping`.
|
|
45
|
+
|
|
46
|
+
## Runtime Output Schema
|
|
47
|
+
|
|
48
|
+
The step record itself usually has an empty `output` map on success:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
But it mutates the **process-level output**. For example, with `httpStatusCode`
|
|
55
|
+
`200`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"result": "failed",
|
|
60
|
+
"__currentExecutionStartTime": 1778615728768
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
When called through a synchronous endpoint with a non-2xx status, the caller
|
|
65
|
+
receives an error payload like:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"result": "failed",
|
|
70
|
+
"errorMessage": "Request failed with HTTP status code: 400",
|
|
71
|
+
"context": {
|
|
72
|
+
"result": "failed"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
When the status code is invalid, the step itself fails with:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"error": "httpStatusCode should be a valid numerical status code"
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Output Access Paths
|
|
86
|
+
|
|
87
|
+
Use:
|
|
88
|
+
- `context.output.<field>` conceptually at the process level, because
|
|
89
|
+
`SEND_RESPONSE` writes to the process output rather than to its own normal
|
|
90
|
+
`step.output.result`.
|
|
91
|
+
- In run debugging, inspect the **process-level** `output` to see the mapped
|
|
92
|
+
response payload.
|
|
93
|
+
- Inspect `stepRecords[].output.error` only when the step itself fails, for
|
|
94
|
+
example because `httpStatusCode` is invalid.
|
|
95
|
+
|
|
96
|
+
Do not use:
|
|
97
|
+
- `steps.<ref>.output.result`
|
|
98
|
+
- `steps.<ref>.output.response`
|
|
99
|
+
- `steps.<ref>.output.<field>` to read the successful response payload
|
|
100
|
+
|
|
101
|
+
## Generation Rules
|
|
102
|
+
|
|
103
|
+
- Use uppercase step type: `"SEND_RESPONSE"`.
|
|
104
|
+
- Use `children: []`; SEND_RESPONSE is not a container.
|
|
105
|
+
- Put `httpStatusCode` and `outputMapping` in `input`.
|
|
106
|
+
- Use `outputMapping` to shape the response payload that should be returned to
|
|
107
|
+
the caller.
|
|
108
|
+
- Prefer `2xx` status codes when the API call should succeed.
|
|
109
|
+
- Use non-2xx status codes when the caller should receive an HTTP error with a
|
|
110
|
+
structured body.
|
|
111
|
+
- Remember that `SEND_RESPONSE` changes the process-level output, not the step's
|
|
112
|
+
own output structure.
|
|
113
|
+
- If the process definition already has a top-level `outputMapping`, remember
|
|
114
|
+
that source code gives that mapping precedence over the step input mapping.
|
|
115
|
+
- Use templating inside `outputMapping` when you want to return data from
|
|
116
|
+
previous steps, for example values from `steps.http_1.output.response`.
|
|
117
|
+
- Do not expect `SEND_RESPONSE` to behave like `EXIT`; it is for returning a
|
|
118
|
+
response, not intentionally ending the process with a final process status.
|
|
119
|
+
|
|
120
|
+
## Debugging Rules
|
|
121
|
+
|
|
122
|
+
When debugging a SEND_RESPONSE step:
|
|
123
|
+
- Inspect `input.httpStatusCode`.
|
|
124
|
+
- Inspect whether the process definition also has a top-level `outputMapping`.
|
|
125
|
+
- Inspect the final **process-level** `output` instead of expecting payload
|
|
126
|
+
fields under the SEND_RESPONSE step record.
|
|
127
|
+
- If the caller saw an HTTP error response, check whether `httpStatusCode` was
|
|
128
|
+
non-2xx.
|
|
129
|
+
- If the caller saw `errorMessage: "Request failed with HTTP status code: ..."`
|
|
130
|
+
that came from the SEND_RESPONSE step runner's error streaming logic.
|
|
131
|
+
- If the step failed outright, check whether `httpStatusCode` was an invalid
|
|
132
|
+
non-numeric string.
|
|
133
|
+
- If later steps still ran, remember that SEND_RESPONSE is not EXIT; the step is
|
|
134
|
+
marked `COMPLETED` and follows the normal update path.
|
|
135
|
+
|
|
136
|
+
Common failures:
|
|
137
|
+
- Looking for successful payload fields under `steps.send_response_1.output`.
|
|
138
|
+
- Assuming SEND_RESPONSE stops the workflow like EXIT.
|
|
139
|
+
- Forgetting that process definition `outputMapping` overrides the step's own
|
|
140
|
+
`input.outputMapping`.
|
|
141
|
+
- Passing `"bad-request"` instead of a numeric code like `400`.
|
|
142
|
+
- Using SEND_RESPONSE in a background/asynchronous context and expecting an HTTP
|
|
143
|
+
caller to receive it immediately.
|
|
144
|
+
|
|
145
|
+
## Minimal Process Definition Example
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"orgId": 1,
|
|
150
|
+
"namespace": "default",
|
|
151
|
+
"name": "send_response_test",
|
|
152
|
+
"version": 1,
|
|
153
|
+
"type": "API_ORCHESTRATION",
|
|
154
|
+
"description": "Call HTTP and then send a mapped response to the API caller.",
|
|
155
|
+
"configuration": null,
|
|
156
|
+
"steps": [
|
|
157
|
+
{
|
|
158
|
+
"orgId": 1,
|
|
159
|
+
"namespace": "default",
|
|
160
|
+
"name": "http",
|
|
161
|
+
"type": "HTTP",
|
|
162
|
+
"ref": "http_1",
|
|
163
|
+
"optional": false,
|
|
164
|
+
"createdBy": "system",
|
|
165
|
+
"updatedBy": "system",
|
|
166
|
+
"description": null,
|
|
167
|
+
"label": null,
|
|
168
|
+
"created": 1700000000000,
|
|
169
|
+
"updated": 1700000000000,
|
|
170
|
+
"configuration": {
|
|
171
|
+
"errorPolicyName": null,
|
|
172
|
+
"useCache": false,
|
|
173
|
+
"cacheKey": null,
|
|
174
|
+
"cacheTimeoutSeconds": 0,
|
|
175
|
+
"stream": false,
|
|
176
|
+
"streamAllStatuses": false,
|
|
177
|
+
"preExecutionScript": null,
|
|
178
|
+
"constructInputFromScript": false,
|
|
179
|
+
"scriptLanguage": null,
|
|
180
|
+
"jqTransformer": null,
|
|
181
|
+
"rateLimitMaxRequests": 0,
|
|
182
|
+
"rateLimitWindowSeconds": 0
|
|
183
|
+
},
|
|
184
|
+
"children": [],
|
|
185
|
+
"input": {
|
|
186
|
+
"method": "GET",
|
|
187
|
+
"url": "http://localhost:8080/api/test/get",
|
|
188
|
+
"headers": {
|
|
189
|
+
"Content-Type": "application/json",
|
|
190
|
+
"Accept": "application/json",
|
|
191
|
+
"Authorization": "Bearer {{secrets.test_token}}"
|
|
192
|
+
},
|
|
193
|
+
"params": {
|
|
194
|
+
"sampleKey": "sampleValue"
|
|
195
|
+
},
|
|
196
|
+
"repeatUntilEnabled": null,
|
|
197
|
+
"repeatUntilCondition": {
|
|
198
|
+
"script": "(steps, context) => {\n return steps.__self.output.response.counter === 100;\n}"
|
|
199
|
+
},
|
|
200
|
+
"repeatIntervalSeconds": null,
|
|
201
|
+
"maxRepeatCount": null,
|
|
202
|
+
"includeFullResponseString": false,
|
|
203
|
+
"noEncode": false,
|
|
204
|
+
"extraLongTimeouts": false
|
|
205
|
+
},
|
|
206
|
+
"output": null
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"orgId": 1,
|
|
210
|
+
"namespace": "default",
|
|
211
|
+
"name": "send_response",
|
|
212
|
+
"type": "SEND_RESPONSE",
|
|
213
|
+
"ref": "send_response_1",
|
|
214
|
+
"optional": false,
|
|
215
|
+
"createdBy": "system",
|
|
216
|
+
"updatedBy": "system",
|
|
217
|
+
"description": null,
|
|
218
|
+
"label": null,
|
|
219
|
+
"created": 1700000000000,
|
|
220
|
+
"updated": 1700000000000,
|
|
221
|
+
"configuration": {
|
|
222
|
+
"errorPolicyName": null,
|
|
223
|
+
"useCache": false,
|
|
224
|
+
"cacheKey": null,
|
|
225
|
+
"cacheTimeoutSeconds": 0,
|
|
226
|
+
"stream": false,
|
|
227
|
+
"streamAllStatuses": false,
|
|
228
|
+
"preExecutionScript": null,
|
|
229
|
+
"constructInputFromScript": false,
|
|
230
|
+
"scriptLanguage": null,
|
|
231
|
+
"jqTransformer": null,
|
|
232
|
+
"rateLimitMaxRequests": 0,
|
|
233
|
+
"rateLimitWindowSeconds": 0
|
|
234
|
+
},
|
|
235
|
+
"children": [],
|
|
236
|
+
"input": {
|
|
237
|
+
"httpStatusCode": 400,
|
|
238
|
+
"outputMapping": {
|
|
239
|
+
"result": "failed"
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
"output": null
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
"defaultInput": null,
|
|
246
|
+
"defaultOutput": null,
|
|
247
|
+
"outputMapping": null,
|
|
248
|
+
"signature": null,
|
|
249
|
+
"metadata": null,
|
|
250
|
+
"tags": null,
|
|
251
|
+
"dependencies": null,
|
|
252
|
+
"dependents": null
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Minimal Executed Step Example
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"id": 30050047,
|
|
261
|
+
"processId": 30050044,
|
|
262
|
+
"ref": "send_response_1",
|
|
263
|
+
"namespace": "default",
|
|
264
|
+
"name": "send_response",
|
|
265
|
+
"type": "SEND_RESPONSE",
|
|
266
|
+
"status": "COMPLETED",
|
|
267
|
+
"input": {
|
|
268
|
+
"outputMapping": {
|
|
269
|
+
"result": "failed"
|
|
270
|
+
},
|
|
271
|
+
"__currentExecutionStartTime": 1778615728762,
|
|
272
|
+
"httpStatusCode": 200
|
|
273
|
+
},
|
|
274
|
+
"output": {}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Example: Return Upstream HTTP Data To The Caller
|
|
279
|
+
|
|
280
|
+
```json
|
|
281
|
+
{
|
|
282
|
+
"httpStatusCode": 200,
|
|
283
|
+
"outputMapping": {
|
|
284
|
+
"counter": "{{steps.http_1.output.response.counter}}",
|
|
285
|
+
"randomId": "{{steps.http_1.output.response.randomId}}"
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Source Notes
|
|
291
|
+
|
|
292
|
+
Observed from:
|
|
293
|
+
- `SendResponseStepRunnerActor`
|
|
294
|
+
- `SendResponseStepRunnerActorTest`
|
|
295
|
+
|
|
296
|
+
Key implementation details:
|
|
297
|
+
- Default status code is `200`.
|
|
298
|
+
- Numeric strings like `"202"` are accepted.
|
|
299
|
+
- Invalid strings fail the step.
|
|
300
|
+
- Success calls `ProcessExecutionHandler.streamResultFull(processContext)`.
|
|
301
|
+
- Non-2xx calls `ProcessExecutionHandler.streamErrorFull(...)`.
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# SQLITE Step Schema
|
|
2
|
+
|
|
3
|
+
`SQLITE` executes SQL statements against a named SQLite datastore managed by
|
|
4
|
+
Unmeshed. It supports `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and DDL
|
|
5
|
+
statements. Use it for lightweight persistent storage, lookup tables,
|
|
6
|
+
accumulating run data, or any scenario where a full external database is
|
|
7
|
+
overkill.
|
|
8
|
+
|
|
9
|
+
## Definition Input Schema
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"storeName": "my-database",
|
|
14
|
+
"sql": "select * from sample_table where name = :#name;",
|
|
15
|
+
"parameters": {
|
|
16
|
+
"name": "Alice"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Field | Type | Required | Description |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| `storeName` | string | Yes | Name of the SQLite datastore (managed via Unmeshed config). The store is created automatically if it does not exist. |
|
|
24
|
+
| `sql` | string | Yes | SQL statement to execute. Use `:#paramName` syntax for parameterised bindings (see below). |
|
|
25
|
+
| `parameters` | object | No | Key-value map of parameter bindings. Each key must match a `:#key` placeholder in `sql`. Values can be strings, numbers, or booleans. |
|
|
26
|
+
|
|
27
|
+
### Parameter Binding Syntax
|
|
28
|
+
|
|
29
|
+
Parameters use the `:#<name>` prefix inside the SQL string:
|
|
30
|
+
|
|
31
|
+
```sql
|
|
32
|
+
select * from users where name = :#name and age > :#minAge;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
With parameters:
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"name": "Alice",
|
|
39
|
+
"minAge": 18
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- `:#name` → binds the value of `parameters.name`
|
|
44
|
+
- `:#minAge` → binds the value of `parameters.minAge`
|
|
45
|
+
- Always use parameter bindings for user-supplied values to prevent SQL injection.
|
|
46
|
+
- Do not use string concatenation or template literals inside the SQL string.
|
|
47
|
+
|
|
48
|
+
### Supported SQL Operations
|
|
49
|
+
|
|
50
|
+
| Operation | Example |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `SELECT` | `select * from users where id = :#id;` |
|
|
53
|
+
| `INSERT` | `insert into users (name, age) values (:#name, :#age);` |
|
|
54
|
+
| `UPDATE` | `update users set age = :#age where name = :#name;` |
|
|
55
|
+
| `DELETE` | `delete from users where id = :#id;` |
|
|
56
|
+
| `CREATE TABLE` | `create table if not exists users (id integer primary key autoincrement, name text, age integer);` |
|
|
57
|
+
|
|
58
|
+
## Runtime Output Schema
|
|
59
|
+
|
|
60
|
+
### SELECT (returns rows)
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"result": {
|
|
65
|
+
"rowsAffected": 0,
|
|
66
|
+
"rows": [
|
|
67
|
+
{
|
|
68
|
+
"name": "Alice",
|
|
69
|
+
"id": 1,
|
|
70
|
+
"age": 25
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### INSERT / UPDATE / DELETE (returns affected count)
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"result": {
|
|
82
|
+
"rowsAffected": 1,
|
|
83
|
+
"rows": []
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### CREATE TABLE / DDL
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"result": {
|
|
93
|
+
"rowsAffected": 0,
|
|
94
|
+
"rows": []
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Output Access Paths
|
|
100
|
+
|
|
101
|
+
Use:
|
|
102
|
+
- `steps.<ref>.output.result.rows` — array of row objects for SELECT queries.
|
|
103
|
+
- `steps.<ref>.output.result.rows[0]` — first row of a SELECT result.
|
|
104
|
+
- `steps.<ref>.output.result.rows[0].<column>` — specific column from the first row.
|
|
105
|
+
- `steps.<ref>.output.result.rowsAffected` — number of rows affected (INSERT/UPDATE/DELETE).
|
|
106
|
+
- `steps.<ref>.output.result.rows.length` — row count from a SELECT.
|
|
107
|
+
|
|
108
|
+
Do not use:
|
|
109
|
+
- `steps.<ref>.output.response` — SQLITE does not use `response`; that is for HTTP steps.
|
|
110
|
+
- `steps.<ref>.output.results` — the field is `result` (singular), not `results`.
|
|
111
|
+
- `steps.<ref>.output.result.data` — rows are at `result.rows`, not `result.data`.
|
|
112
|
+
|
|
113
|
+
## Generation Rules
|
|
114
|
+
|
|
115
|
+
- Use uppercase step type: `"SQLITE"`.
|
|
116
|
+
- Use `children: []`; SQLITE is not a container.
|
|
117
|
+
- `storeName` must be a valid SQLite datastore name configured in the org.
|
|
118
|
+
- `sql` must end with a semicolon `;`.
|
|
119
|
+
- Always use `:#paramName` parameter bindings — never interpolate values into SQL.
|
|
120
|
+
- Parameters must be a flat key-value object (no nested objects or arrays).
|
|
121
|
+
- For multi-step database operations (e.g. create table then insert), use
|
|
122
|
+
separate SQLITE steps in a LIST.
|
|
123
|
+
- When reading SELECT results in a subsequent step, always guard against empty
|
|
124
|
+
rows: `steps.<ref>.output.result.rows[0] || {}`.
|
|
125
|
+
- When using `steps.<ref>.output.result` reference from another step's input,
|
|
126
|
+
make sure to access `.rows` for the actual data.
|
|
127
|
+
|
|
128
|
+
## Debugging Rules
|
|
129
|
+
|
|
130
|
+
When debugging a SQLITE step:
|
|
131
|
+
- Check `output.result.rowsAffected` — 0 for SELECT/DDL, > 0 for INSERT/UPDATE/DELETE.
|
|
132
|
+
- Check `output.result.rows` — array of row objects for SELECT, empty `[]` for non-SELECT.
|
|
133
|
+
- If `status: "FAILED"`, check the step `output.error` for the SQL error message.
|
|
134
|
+
- Common SQL errors:
|
|
135
|
+
- `no such table` — the table does not exist; add a CREATE TABLE step first.
|
|
136
|
+
- `no such column` — column name mismatch between SQL and actual schema.
|
|
137
|
+
- Parameter binding mismatch — `:#paramName` in SQL without a matching key in `parameters`.
|
|
138
|
+
|
|
139
|
+
Common failures:
|
|
140
|
+
- Missing `storeName` — the step will fail because it doesn't know which database to use.
|
|
141
|
+
- Missing semicolon at end of SQL — may cause parse errors.
|
|
142
|
+
- Using `steps.<ref>.output.result` directly instead of `steps.<ref>.output.result.rows` for SELECT data.
|
|
143
|
+
- Forgetting to create the table before INSERT — use a separate SQLITE step with `CREATE TABLE IF NOT EXISTS`.
|
|
144
|
+
|
|
145
|
+
## Minimal Process Definition Example
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"orgId": 1,
|
|
150
|
+
"namespace": "default",
|
|
151
|
+
"name": "sqlite-query-example",
|
|
152
|
+
"version": 1,
|
|
153
|
+
"type": "API_ORCHESTRATION",
|
|
154
|
+
"description": "Query a SQLite table by name parameter.",
|
|
155
|
+
"configuration": null,
|
|
156
|
+
"steps": [
|
|
157
|
+
{
|
|
158
|
+
"orgId": 1,
|
|
159
|
+
"namespace": "default",
|
|
160
|
+
"name": "select",
|
|
161
|
+
"type": "SQLITE",
|
|
162
|
+
"ref": "select_1",
|
|
163
|
+
"optional": false,
|
|
164
|
+
"createdBy": "system",
|
|
165
|
+
"updatedBy": "system",
|
|
166
|
+
"description": null,
|
|
167
|
+
"label": null,
|
|
168
|
+
"created": 1700000000000,
|
|
169
|
+
"updated": 1700000000000,
|
|
170
|
+
"configuration": {
|
|
171
|
+
"errorPolicyName": null,
|
|
172
|
+
"useCache": false,
|
|
173
|
+
"cacheKey": null,
|
|
174
|
+
"cacheTimeoutSeconds": 0,
|
|
175
|
+
"stream": false,
|
|
176
|
+
"streamAllStatuses": false,
|
|
177
|
+
"preExecutionScript": null,
|
|
178
|
+
"constructInputFromScript": false,
|
|
179
|
+
"scriptLanguage": null,
|
|
180
|
+
"jqTransformer": null,
|
|
181
|
+
"rateLimitMaxRequests": 0,
|
|
182
|
+
"rateLimitWindowSeconds": 0
|
|
183
|
+
},
|
|
184
|
+
"children": [],
|
|
185
|
+
"input": {
|
|
186
|
+
"storeName": "my-database",
|
|
187
|
+
"sql": "select * from sample_table where name = :#name;",
|
|
188
|
+
"parameters": {
|
|
189
|
+
"name": "Alice"
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"output": null
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"defaultInput": null,
|
|
196
|
+
"defaultOutput": null,
|
|
197
|
+
"outputMapping": null,
|
|
198
|
+
"signature": null,
|
|
199
|
+
"metadata": null,
|
|
200
|
+
"tags": null,
|
|
201
|
+
"dependencies": null,
|
|
202
|
+
"dependents": null
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Minimal Executed Step Example
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"id": 765971854,
|
|
211
|
+
"processId": 765971852,
|
|
212
|
+
"ref": "select_1",
|
|
213
|
+
"namespace": "automated_tests",
|
|
214
|
+
"name": "select",
|
|
215
|
+
"type": "SQLITE",
|
|
216
|
+
"status": "COMPLETED",
|
|
217
|
+
"input": {
|
|
218
|
+
"storeName": "automated-test-db",
|
|
219
|
+
"sql": "select * from sample_table where name = :#name;",
|
|
220
|
+
"parameters": {
|
|
221
|
+
"name": "Alice"
|
|
222
|
+
},
|
|
223
|
+
"__currentExecutionStartTime": 1765971852500
|
|
224
|
+
},
|
|
225
|
+
"output": {
|
|
226
|
+
"result": {
|
|
227
|
+
"rowsAffected": 0,
|
|
228
|
+
"rows": [
|
|
229
|
+
{
|
|
230
|
+
"name": "Alice",
|
|
231
|
+
"id": 1,
|
|
232
|
+
"age": 25
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Example: Create Table Then Insert and Query
|
|
241
|
+
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"steps": [
|
|
245
|
+
{
|
|
246
|
+
"type": "SQLITE",
|
|
247
|
+
"ref": "create_table_1",
|
|
248
|
+
"name": "create_table",
|
|
249
|
+
"input": {
|
|
250
|
+
"storeName": "my-database",
|
|
251
|
+
"sql": "create table if not exists users (id integer primary key autoincrement, name text not null, age integer);",
|
|
252
|
+
"parameters": {}
|
|
253
|
+
},
|
|
254
|
+
"children": [],
|
|
255
|
+
"...": "..."
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"type": "SQLITE",
|
|
259
|
+
"ref": "insert_user_1",
|
|
260
|
+
"name": "insert_user",
|
|
261
|
+
"input": {
|
|
262
|
+
"storeName": "my-database",
|
|
263
|
+
"sql": "insert into users (name, age) values (:#name, :#age);",
|
|
264
|
+
"parameters": {
|
|
265
|
+
"name": "Bob",
|
|
266
|
+
"age": 30
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"children": [],
|
|
270
|
+
"...": "..."
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"type": "SQLITE",
|
|
274
|
+
"ref": "query_users_1",
|
|
275
|
+
"name": "query_users",
|
|
276
|
+
"input": {
|
|
277
|
+
"storeName": "my-database",
|
|
278
|
+
"sql": "select * from users;",
|
|
279
|
+
"parameters": {}
|
|
280
|
+
},
|
|
281
|
+
"children": [],
|
|
282
|
+
"...": "..."
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Example: Using SQLITE Output in a JAVASCRIPT Step
|
|
289
|
+
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"type": "JAVASCRIPT",
|
|
293
|
+
"ref": "process_results_1",
|
|
294
|
+
"name": "process_results",
|
|
295
|
+
"input": {
|
|
296
|
+
"script": "(steps, context) => {\n const rows = steps.select_1.output.result.rows || [];\n return {\n count: rows.length,\n names: rows.map(r => r.name)\n };\n}"
|
|
297
|
+
},
|
|
298
|
+
"children": [],
|
|
299
|
+
"...": "..."
|
|
300
|
+
}
|
|
301
|
+
```
|