Skip to content

Commit 38d9b31

Browse files
authored
improvement(workflow-code): v9 benchmark findings (table row shape, retry and child result rules, ops help, column types, queryRows paging) (#10361)
* improvement(workflow-code): v9 benchmark findings (table row shape, retry and child result rules, ops help, column types, queryRows paging) - Table blocks declare row/rows as {id, data, position, createdAt, updatedAt}: check flags row.<column> (W_UNKNOWN_OUTPUT_PATH, hint names the members) and `sim blocks get` publishes nested output shapes (OutputFieldDefinition gains properties/items) - Primer: block retry vs an api block's retries, a child workflow's c.result.data.<field>, run inputs in the workspace loop - operations apply help: same-batch renames, connections {} and parentId moves, inputs replace whole fields, nested retries, the table row path - Column types named in tables create/columns create help, from the contract - table.queryRows note: no limit maximum, page by nextCursor - workflows source help points tables at workspaces source - Generated special params types name the params core.d.ts adds (HumanParams: inputFormat) * fix(workflow-code): declare orderKey and executions on table query and insert rows query_rows, batch_insert_rows and insert_row present rows with presentNamedTableQueryRow, which adds orderKey and executions; the declared row shape omitted them, so a check reading either warned W_UNKNOWN_OUTPUT_PATH. * fix(tables): state the public column types as one sentence in the column inputs' help
1 parent 6afcff9 commit 38d9b31

25 files changed

Lines changed: 400 additions & 104 deletions

File tree

‎apps/docs/content/docs/cli/reference.mdx‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5891,7 +5891,7 @@ sim tables columns create <tableId> [options]
58915891

58925892
| Option | Required | Description |
58935893
| --- | --- | --- |
5894-
| `--column <json\|@file>` | Yes | Column definition to add. (JSON, or @path / @- to read a file or stdin). |
5894+
| `--column <json\|@file>` | Yes | Column definition to add: &#123;"name":"status","type":"string"&#125;. A column's type is one of string, number, currency, boolean, date, json, select; a select column also takes options. (JSON, or @path / @- to read a file or stdin). |
58955895

58965896
</CommandTable>
58975897

@@ -6797,7 +6797,7 @@ sim tables create [options]
67976797
| --- | --- | --- |
67986798
| `--name <value>` | Yes | Identifier: letters, numbers, and underscores; cannot start with a number. |
67996799
| `--description <value>` | No | Optional table description. |
6800-
| `--schema <json\|@file>` | Yes | Table schema: &#123;"columns":[&#123;"name":"email","type":"string"&#125;]&#125; (JSON, or @path / @- to read a file or stdin). |
6800+
| `--schema <json\|@file>` | Yes | Initial table column definitions: &#123;"columns":[&#123;"name":"email","type":"string"&#125;]&#125;. A column's type is one of string, number, currency, boolean, date, json, select; a select column also takes options. (JSON, or @path / @- to read a file or stdin). |
68016801
| `--folder <value>` | No | Folder path as shown in the app; the leading / is optional. |
68026802

68036803
</CommandTable>
@@ -7773,7 +7773,9 @@ Edges:
77737773
connections maps a source handle to its targets: {"source":"<id>"}, {"source":["<a>","<b>"]},
77747774
or {"source":{"block":"<id>","handle":"<target handle>"}}; "success" is an alias of "source".
77757775
An add's connections create the new block's edges. An edit's connections REPLACE every
7776-
outgoing edge of that block, on every handle: list again each edge to keep.
7776+
outgoing edge of that block, on every handle: list again each edge to keep; {} removes them all.
7777+
A block moved into or out of a loop or parallel (parentId) loses every edge that would cross the
7778+
container's boundary: to leave the loop, wire its loop-end-source (parallel-end-source).
77777779
To remove one edge, edit its source block with
77787780
{"removeEdges":[{"targetBlockId":"<id>","sourceHandle":"source"}]} (sourceHandle defaults to
77797781
"source").
@@ -7786,12 +7788,14 @@ Source handles:
77867788
parallel-start-source, parallel-end-source the same for a parallel
77877789
Renames:
77887790
An edit's {"name":"New name"} also rewrites every <old key.field> reference to the block, in
7789-
other blocks' inputs and in a loop's or parallel's collection and condition.
7791+
other blocks' inputs and in a loop's or parallel's collection and condition. Edits run after the
7792+
batch's adds, so a block added in the same batch is rewritten too.
77907793
Inputs:
77917794
inputs takes the field ids `sim blocks get <type>` lists (inputSchema, operationInputSchema),
77927795
or the name a pair of them shares (inputDefinitions: tableId for tableSelector and
77937796
manualTableId; a string goes to the typed field). Add the type it answers with: `blocks get
7794-
table` answers table_v2, and an add of legacy table is refused.
7797+
table` answers table_v2, and an add of legacy table is refused. An edit's inputs replace each
7798+
field they name whole (a responseFormat schema too) and keep the fields they do not name.
77957799
conditions (condition): [{"title":"if","value":"<start.n> > 3"},{"title":"else if","value":"…"},
77967800
{"title":"else","value":""}]; the last entry is the else. Each entry's id comes from its
77977801
position (<block id>-if, <block id>-else-if-0, …, <block id>-else): an id you pass is replaced.
@@ -7800,14 +7804,16 @@ Inputs:
78007804
Block settings, beside inputs in an add's or edit's params:
78017805
"retry":{"enabled":true,"maxTries":3,"waitBetweenTriesMs":1000} retries a failed block; null
78027806
clears it. An api block's retries input repeats the request after a timeout, reset, 429 or
7803-
5xx, not when the host does not resolve or refuses the connection; "retry" covers that.
7807+
5xx, not when the host does not resolve or refuses the connection; "retry" covers that. They
7808+
nest: every try of "retry" runs the request with its retries.
78047809
Outputs:
78057810
A block that fails outputs {"error":"<message>"}: connect its error handle and read
78067811
<name.error> there (without one, the run fails). A Function's error leads with the line and
78077812
code that threw; its <name.errorMessage> is the thrown message alone, the one to reply with.
78087813
A Workflow block's result is the child's
78097814
output; a child ending in a Response block gives {data, status, headers}, so read
7810-
<call.result.data.x>.
7815+
<call.result.data.x>. A Table block's row holds its cells under data: read a cell as
7816+
<name.row.data.column> (<name.rows[0].data.column>).
78117817
References:
78127818
Inside a loop or parallel body read <loop.currentItem> and <loop.index>, or
78137819
<parallel.currentItem> and <parallel.index>; after it, <name.results>. A reference to a block

‎apps/docs/content/docs/cli/tables.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ sim tables create [options]
6868
| --- | --- | --- |
6969
| `--name <value>` | Yes | Identifier: letters, numbers, and underscores; cannot start with a number. |
7070
| `--description <value>` | No | Optional table description. |
71-
| `--schema <json\|@file>` | Yes | Table schema: &#123;"columns":[&#123;"name":"email","type":"string"&#125;]&#125; (JSON, or @path / @- to read a file or stdin). |
71+
| `--schema <json\|@file>` | Yes | Initial table column definitions: &#123;"columns":[&#123;"name":"email","type":"string"&#125;]&#125;. A column's type is one of string, number, currency, boolean, date, json, select; a select column also takes options. (JSON, or @path / @- to read a file or stdin). |
7272
| `--folder <value>` | No | Folder path as shown in the app; the leading / is optional. |
7373

7474
</CommandTable>
@@ -624,7 +624,7 @@ sim tables columns create <tableId> [options]
624624

625625
| Option | Required | Description |
626626
| --- | --- | --- |
627-
| `--column <json\|@file>` | Yes | Column definition to add. (JSON, or @path / @- to read a file or stdin). |
627+
| `--column <json\|@file>` | Yes | Column definition to add: &#123;"name":"status","type":"string"&#125;. A column's type is one of string, number, currency, boolean, date, json, select; a select column also takes options. (JSON, or @path / @- to read a file or stdin). |
628628

629629
</CommandTable>
630630

‎apps/docs/content/docs/cli/workflows.mdx‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,9 @@ Edges:
342342
connections maps a source handle to its targets: {"source":"<id>"}, {"source":["<a>","<b>"]},
343343
or {"source":{"block":"<id>","handle":"<target handle>"}}; "success" is an alias of "source".
344344
An add's connections create the new block's edges. An edit's connections REPLACE every
345-
outgoing edge of that block, on every handle: list again each edge to keep.
345+
outgoing edge of that block, on every handle: list again each edge to keep; {} removes them all.
346+
A block moved into or out of a loop or parallel (parentId) loses every edge that would cross the
347+
container's boundary: to leave the loop, wire its loop-end-source (parallel-end-source).
346348
To remove one edge, edit its source block with
347349
{"removeEdges":[{"targetBlockId":"<id>","sourceHandle":"source"}]} (sourceHandle defaults to
348350
"source").
@@ -355,12 +357,14 @@ Source handles:
355357
parallel-start-source, parallel-end-source the same for a parallel
356358
Renames:
357359
An edit's {"name":"New name"} also rewrites every <old key.field> reference to the block, in
358-
other blocks' inputs and in a loop's or parallel's collection and condition.
360+
other blocks' inputs and in a loop's or parallel's collection and condition. Edits run after the
361+
batch's adds, so a block added in the same batch is rewritten too.
359362
Inputs:
360363
inputs takes the field ids `sim blocks get <type>` lists (inputSchema, operationInputSchema),
361364
or the name a pair of them shares (inputDefinitions: tableId for tableSelector and
362365
manualTableId; a string goes to the typed field). Add the type it answers with: `blocks get
363-
table` answers table_v2, and an add of legacy table is refused.
366+
table` answers table_v2, and an add of legacy table is refused. An edit's inputs replace each
367+
field they name whole (a responseFormat schema too) and keep the fields they do not name.
364368
conditions (condition): [{"title":"if","value":"<start.n> > 3"},{"title":"else if","value":"…"},
365369
{"title":"else","value":""}]; the last entry is the else. Each entry's id comes from its
366370
position (<block id>-if, <block id>-else-if-0, …, <block id>-else): an id you pass is replaced.
@@ -369,14 +373,16 @@ Inputs:
369373
Block settings, beside inputs in an add's or edit's params:
370374
"retry":{"enabled":true,"maxTries":3,"waitBetweenTriesMs":1000} retries a failed block; null
371375
clears it. An api block's retries input repeats the request after a timeout, reset, 429 or
372-
5xx, not when the host does not resolve or refuses the connection; "retry" covers that.
376+
5xx, not when the host does not resolve or refuses the connection; "retry" covers that. They
377+
nest: every try of "retry" runs the request with its retries.
373378
Outputs:
374379
A block that fails outputs {"error":"<message>"}: connect its error handle and read
375380
<name.error> there (without one, the run fails). A Function's error leads with the line and
376381
code that threw; its <name.errorMessage> is the thrown message alone, the one to reply with.
377382
A Workflow block's result is the child's
378383
output; a child ending in a Response block gives {data, status, headers}, so read
379-
<call.result.data.x>.
384+
<call.result.data.x>. A Table block's row holds its cells under data: read a cell as
385+
<name.row.data.column> (<name.rows[0].data.column>).
380386
References:
381387
Inside a loop or parallel body read <loop.currentItem> and <loop.index>, or
382388
<parallel.currentItem> and <parallel.index>; after it, <name.results>. A reference to a block

‎apps/docs/openapi-v2-resources.json‎

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22253,11 +22253,47 @@
2225322253
"properties": {
2225422254
"type": {
2225522255
"type": "string",
22256-
"description": "Value type of the output."
22256+
"description": "Value type of the output field."
2225722257
},
2225822258
"description": {
22259-
"description": "What the output holds.",
22259+
"description": "What the field holds.",
2226022260
"type": "string"
22261+
},
22262+
"properties": {
22263+
"description": "Members of an object-typed output, keyed by field name.",
22264+
"type": "object",
22265+
"propertyNames": {
22266+
"type": "string"
22267+
},
22268+
"additionalProperties": {
22269+
"description": "Nested output field, in this same shape."
22270+
}
22271+
},
22272+
"items": {
22273+
"description": "Element shape of an array-typed output.",
22274+
"type": "object",
22275+
"properties": {
22276+
"type": {
22277+
"type": "string",
22278+
"description": "Element value type."
22279+
},
22280+
"description": {
22281+
"description": "What an element holds.",
22282+
"type": "string"
22283+
},
22284+
"properties": {
22285+
"description": "Members of an object-typed element, keyed by field name.",
22286+
"type": "object",
22287+
"propertyNames": {
22288+
"type": "string"
22289+
},
22290+
"additionalProperties": {
22291+
"description": "Nested output field, in this same shape."
22292+
}
22293+
}
22294+
},
22295+
"required": ["type"],
22296+
"additionalProperties": false
2226122297
}
2226222298
},
2226322299
"required": ["type"],
@@ -22381,11 +22417,47 @@
2238122417
"properties": {
2238222418
"type": {
2238322419
"type": "string",
22384-
"description": "Value type of the output."
22420+
"description": "Value type of the output field."
2238522421
},
2238622422
"description": {
22387-
"description": "What the output holds.",
22423+
"description": "What the field holds.",
2238822424
"type": "string"
22425+
},
22426+
"properties": {
22427+
"description": "Members of an object-typed output, keyed by field name.",
22428+
"type": "object",
22429+
"propertyNames": {
22430+
"type": "string"
22431+
},
22432+
"additionalProperties": {
22433+
"description": "Nested output field, in this same shape."
22434+
}
22435+
},
22436+
"items": {
22437+
"description": "Element shape of an array-typed output.",
22438+
"type": "object",
22439+
"properties": {
22440+
"type": {
22441+
"type": "string",
22442+
"description": "Element value type."
22443+
},
22444+
"description": {
22445+
"description": "What an element holds.",
22446+
"type": "string"
22447+
},
22448+
"properties": {
22449+
"description": "Members of an object-typed element, keyed by field name.",
22450+
"type": "object",
22451+
"propertyNames": {
22452+
"type": "string"
22453+
},
22454+
"additionalProperties": {
22455+
"description": "Nested output field, in this same shape."
22456+
}
22457+
}
22458+
},
22459+
"required": ["type"],
22460+
"additionalProperties": false
2238922461
}
2239022462
},
2239122463
"required": ["type"],

‎apps/docs/openapi-v2-tables.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6422,7 +6422,7 @@
64226422
},
64236423
"required": ["columns"],
64246424
"additionalProperties": false,
6425-
"description": "Initial table column definitions."
6425+
"description": "Initial table column definitions: {\"columns\":[{\"name\":\"email\",\"type\":\"string\"}]}. A column's type is one of string, number, currency, boolean, date, json, select; a select column also takes options."
64266426
},
64276427
"folderPath": {
64286428
"description": "Folder in which to create the table.",
@@ -6701,7 +6701,7 @@
67016701
},
67026702
"required": ["name", "type"],
67036703
"additionalProperties": false,
6704-
"description": "Column definition to add."
6704+
"description": "Column definition to add: {\"name\":\"status\",\"type\":\"string\"}. A column's type is one of string, number, currency, boolean, date, json, select; a select column also takes options."
67056705
}
67066706
},
67076707
"required": ["workspaceId", "column"],

‎apps/docs/scripts/fixtures/content-baseline.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12982,8 +12982,8 @@
1298212982
{
1298312983
"lang": "text",
1298412984
"meta": null,
12985-
"sha256": "2143e5d8691f486425a8fb17938c12cc7875efc2b5aaf53d77685941a08835af",
12986-
"bytes": 3532,
12985+
"sha256": "6cf7c87da84d5ace685f6752652f51790aadb86153cc83330070235579ddb15d",
12986+
"bytes": 4141,
1298712987
"line": 7771
1298812988
},
1298912989
{
@@ -17505,8 +17505,8 @@
1750517505
{
1750617506
"lang": "text",
1750717507
"meta": null,
17508-
"sha256": "2143e5d8691f486425a8fb17938c12cc7875efc2b5aaf53d77685941a08835af",
17509-
"bytes": 3532,
17508+
"sha256": "6cf7c87da84d5ace685f6752652f51790aadb86153cc83330070235579ddb15d",
17509+
"bytes": 4141,
1751017510
"line": 340
1751117511
},
1751217512
{

‎apps/sim/blocks/blocks/table.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
TABLE_IGNORED_COLUMNS_OUTPUT,
1313
TABLE_OUTPUT_COLUMNS_INPUT,
1414
TABLE_OUTPUT_COLUMNS_SUBBLOCK,
15+
TABLE_ROW_OUTPUT,
16+
TABLE_ROWS_OUTPUT,
1517
toolCallArg,
1618
} from '@/blocks/utils'
1719
import { TABLE_ID_PARAM } from '@/tools/table/params'
@@ -816,24 +818,13 @@ Return ONLY the sort JSON:`,
816818

817819
outputs: {
818820
success: { type: 'boolean', description: 'Operation success status' },
819-
row: {
820-
type: 'json',
821-
description: 'Single row data',
822-
condition: {
823-
field: 'operation',
824-
value: ['get_row', 'insert_row', 'upsert_row', 'update_row'],
825-
},
826-
},
821+
row: TABLE_ROW_OUTPUT,
827822
operation: {
828823
type: 'string',
829824
description: 'Operation performed (insert or update)',
830825
condition: { field: 'operation', value: 'upsert_row' },
831826
},
832-
rows: {
833-
type: 'array',
834-
description: 'Array of rows',
835-
condition: { field: 'operation', value: ['query_rows', 'batch_insert_rows'] },
836-
},
827+
rows: TABLE_ROWS_OUTPUT,
837828
rowCount: {
838829
type: 'number',
839830
description: 'Rows returned (query) or total rows in the table (get schema)',

‎apps/sim/blocks/blocks/table_v2.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {
1919
TABLE_IGNORED_COLUMNS_OUTPUT,
2020
TABLE_OUTPUT_COLUMNS_INPUT,
2121
TABLE_OUTPUT_COLUMNS_SUBBLOCK,
22+
TABLE_ROW_OUTPUT,
23+
TABLE_ROWS_OUTPUT,
2224
toolCallArg,
2325
} from '@/blocks/utils'
2426
import { TABLE_ID_PARAM } from '@/tools/table/params'
@@ -611,24 +613,13 @@ Return ONLY the JSON object:`,
611613

612614
outputs: {
613615
success: { type: 'boolean', description: 'Operation success status' },
614-
row: {
615-
type: 'json',
616-
description: 'Single row data',
617-
condition: {
618-
field: 'operation',
619-
value: ['get_row', 'insert_row', 'upsert_row', 'update_row'],
620-
},
621-
},
616+
row: TABLE_ROW_OUTPUT,
622617
operation: {
623618
type: 'string',
624619
description: 'Operation performed (insert or update)',
625620
condition: { field: 'operation', value: 'upsert_row' },
626621
},
627-
rows: {
628-
type: 'array',
629-
description: 'Array of rows',
630-
condition: { field: 'operation', value: ['query_rows', 'batch_insert_rows'] },
631-
},
622+
rows: TABLE_ROWS_OUTPUT,
632623
rowCount: {
633624
type: 'number',
634625
description: 'Rows returned (query) or total rows in the table (get schema)',

‎apps/sim/blocks/utils.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,42 @@ export const TABLE_IGNORED_COLUMNS_OUTPUT = {
942942
},
943943
} satisfies OutputFieldDefinition
944944

945+
/**
946+
* One row as the Table blocks output it (`presentNamedTableRow` and `presentNamedTableQueryRow`
947+
* in `lib/internal/table/presentation.ts`): its cells sit under `data`, keyed by column name.
948+
*/
949+
const TABLE_ROW_PROPERTIES = {
950+
id: { type: 'string', description: 'Row ID' },
951+
data: { type: 'json', description: 'The row’s cells, keyed by column name' },
952+
position: { type: 'number', description: 'Row position in the table' },
953+
orderKey: { type: 'string', description: 'Sort key (query and insert results only)' },
954+
executions: {
955+
type: 'json',
956+
description: 'Workflow run state per column group (query and insert results only)',
957+
},
958+
createdAt: { type: 'string', description: 'ISO timestamp when the row was created' },
959+
updatedAt: { type: 'string', description: 'ISO timestamp when the row was last updated' },
960+
} satisfies Record<string, OutputFieldDefinition>
961+
962+
/** The `row` output of the Table blocks: a cell reads as `row.data.<column>`. */
963+
export const TABLE_ROW_OUTPUT = {
964+
type: 'json',
965+
description: 'The row: its cells are row.data.<column name>',
966+
condition: {
967+
field: 'operation',
968+
value: ['get_row', 'insert_row', 'upsert_row', 'update_row'],
969+
},
970+
properties: TABLE_ROW_PROPERTIES,
971+
} satisfies OutputFieldDefinition
972+
973+
/** The `rows` output of the Table blocks: a cell reads as `rows[i].data.<column>`. */
974+
export const TABLE_ROWS_OUTPUT = {
975+
type: 'array',
976+
description: 'The rows: a cell is rows[i].data.<column name>',
977+
condition: { field: 'operation', value: ['query_rows', 'batch_insert_rows'] },
978+
items: { type: 'json', properties: TABLE_ROW_PROPERTIES },
979+
} satisfies OutputFieldDefinition
980+
945981
/** Block input entry for {@link TABLE_OUTPUT_COLUMNS_SUBBLOCK}. */
946982
export const TABLE_OUTPUT_COLUMNS_INPUT = {
947983
type: 'array',

0 commit comments

Comments
 (0)