Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions apps/docs/content/docs/cli/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5891,7 +5891,7 @@ sim tables columns create <tableId> [options]

| Option | Required | Description |
| --- | --- | --- |
| `--column <json\|@file>` | Yes | Column definition to add. (JSON, or @path / @- to read a file or stdin). |
| `--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). |

</CommandTable>

Expand Down Expand Up @@ -6797,7 +6797,7 @@ sim tables create [options]
| --- | --- | --- |
| `--name <value>` | Yes | Identifier: letters, numbers, and underscores; cannot start with a number. |
| `--description <value>` | No | Optional table description. |
| `--schema <json\|@file>` | Yes | Table schema: &#123;"columns":[&#123;"name":"email","type":"string"&#125;]&#125; (JSON, or @path / @- to read a file or stdin). |
| `--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). |
| `--folder <value>` | No | Folder path as shown in the app; the leading / is optional. |

</CommandTable>
Expand Down Expand Up @@ -7773,7 +7773,9 @@ Edges:
connections maps a source handle to its targets: {"source":"<id>"}, {"source":["<a>","<b>"]},
or {"source":{"block":"<id>","handle":"<target handle>"}}; "success" is an alias of "source".
An add's connections create the new block's edges. An edit's connections REPLACE every
outgoing edge of that block, on every handle: list again each edge to keep.
outgoing edge of that block, on every handle: list again each edge to keep; {} removes them all.
A block moved into or out of a loop or parallel (parentId) loses every edge that would cross the
container's boundary: to leave the loop, wire its loop-end-source (parallel-end-source).
To remove one edge, edit its source block with
{"removeEdges":[{"targetBlockId":"<id>","sourceHandle":"source"}]} (sourceHandle defaults to
"source").
Expand All @@ -7786,12 +7788,14 @@ Source handles:
parallel-start-source, parallel-end-source the same for a parallel
Renames:
An edit's {"name":"New name"} also rewrites every <old key.field> reference to the block, in
other blocks' inputs and in a loop's or parallel's collection and condition.
other blocks' inputs and in a loop's or parallel's collection and condition. Edits run after the
batch's adds, so a block added in the same batch is rewritten too.
Inputs:
inputs takes the field ids `sim blocks get <type>` lists (inputSchema, operationInputSchema),
or the name a pair of them shares (inputDefinitions: tableId for tableSelector and
manualTableId; a string goes to the typed field). Add the type it answers with: `blocks get
table` answers table_v2, and an add of legacy table is refused.
table` answers table_v2, and an add of legacy table is refused. An edit's inputs replace each
field they name whole (a responseFormat schema too) and keep the fields they do not name.
conditions (condition): [{"title":"if","value":"<start.n> > 3"},{"title":"else if","value":"…"},
{"title":"else","value":""}]; the last entry is the else. Each entry's id comes from its
position (<block id>-if, <block id>-else-if-0, …, <block id>-else): an id you pass is replaced.
Expand All @@ -7800,14 +7804,16 @@ Inputs:
Block settings, beside inputs in an add's or edit's params:
"retry":{"enabled":true,"maxTries":3,"waitBetweenTriesMs":1000} retries a failed block; null
clears it. An api block's retries input repeats the request after a timeout, reset, 429 or
5xx, not when the host does not resolve or refuses the connection; "retry" covers that.
5xx, not when the host does not resolve or refuses the connection; "retry" covers that. They
nest: every try of "retry" runs the request with its retries.
Outputs:
A block that fails outputs {"error":"<message>"}: connect its error handle and read
<name.error> there (without one, the run fails). A Function's error leads with the line and
code that threw; its <name.errorMessage> is the thrown message alone, the one to reply with.
A Workflow block's result is the child's
output; a child ending in a Response block gives {data, status, headers}, so read
<call.result.data.x>.
<call.result.data.x>. A Table block's row holds its cells under data: read a cell as
<name.row.data.column> (<name.rows[0].data.column>).
References:
Inside a loop or parallel body read <loop.currentItem> and <loop.index>, or
<parallel.currentItem> and <parallel.index>; after it, <name.results>. A reference to a block
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/docs/cli/tables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sim tables create [options]
| --- | --- | --- |
| `--name <value>` | Yes | Identifier: letters, numbers, and underscores; cannot start with a number. |
| `--description <value>` | No | Optional table description. |
| `--schema <json\|@file>` | Yes | Table schema: &#123;"columns":[&#123;"name":"email","type":"string"&#125;]&#125; (JSON, or @path / @- to read a file or stdin). |
| `--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). |
| `--folder <value>` | No | Folder path as shown in the app; the leading / is optional. |

</CommandTable>
Expand Down Expand Up @@ -624,7 +624,7 @@ sim tables columns create <tableId> [options]

| Option | Required | Description |
| --- | --- | --- |
| `--column <json\|@file>` | Yes | Column definition to add. (JSON, or @path / @- to read a file or stdin). |
| `--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). |

</CommandTable>

Expand Down
16 changes: 11 additions & 5 deletions apps/docs/content/docs/cli/workflows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ Edges:
connections maps a source handle to its targets: {"source":"<id>"}, {"source":["<a>","<b>"]},
or {"source":{"block":"<id>","handle":"<target handle>"}}; "success" is an alias of "source".
An add's connections create the new block's edges. An edit's connections REPLACE every
outgoing edge of that block, on every handle: list again each edge to keep.
outgoing edge of that block, on every handle: list again each edge to keep; {} removes them all.
A block moved into or out of a loop or parallel (parentId) loses every edge that would cross the
container's boundary: to leave the loop, wire its loop-end-source (parallel-end-source).
To remove one edge, edit its source block with
{"removeEdges":[{"targetBlockId":"<id>","sourceHandle":"source"}]} (sourceHandle defaults to
"source").
Expand All @@ -355,12 +357,14 @@ Source handles:
parallel-start-source, parallel-end-source the same for a parallel
Renames:
An edit's {"name":"New name"} also rewrites every <old key.field> reference to the block, in
other blocks' inputs and in a loop's or parallel's collection and condition.
other blocks' inputs and in a loop's or parallel's collection and condition. Edits run after the
batch's adds, so a block added in the same batch is rewritten too.
Inputs:
inputs takes the field ids `sim blocks get <type>` lists (inputSchema, operationInputSchema),
or the name a pair of them shares (inputDefinitions: tableId for tableSelector and
manualTableId; a string goes to the typed field). Add the type it answers with: `blocks get
table` answers table_v2, and an add of legacy table is refused.
table` answers table_v2, and an add of legacy table is refused. An edit's inputs replace each
field they name whole (a responseFormat schema too) and keep the fields they do not name.
conditions (condition): [{"title":"if","value":"<start.n> > 3"},{"title":"else if","value":"…"},
{"title":"else","value":""}]; the last entry is the else. Each entry's id comes from its
position (<block id>-if, <block id>-else-if-0, …, <block id>-else): an id you pass is replaced.
Expand All @@ -369,14 +373,16 @@ Inputs:
Block settings, beside inputs in an add's or edit's params:
"retry":{"enabled":true,"maxTries":3,"waitBetweenTriesMs":1000} retries a failed block; null
clears it. An api block's retries input repeats the request after a timeout, reset, 429 or
5xx, not when the host does not resolve or refuses the connection; "retry" covers that.
5xx, not when the host does not resolve or refuses the connection; "retry" covers that. They
nest: every try of "retry" runs the request with its retries.
Outputs:
A block that fails outputs {"error":"<message>"}: connect its error handle and read
<name.error> there (without one, the run fails). A Function's error leads with the line and
code that threw; its <name.errorMessage> is the thrown message alone, the one to reply with.
A Workflow block's result is the child's
output; a child ending in a Response block gives {data, status, headers}, so read
<call.result.data.x>.
<call.result.data.x>. A Table block's row holds its cells under data: read a cell as
<name.row.data.column> (<name.rows[0].data.column>).
References:
Inside a loop or parallel body read <loop.currentItem> and <loop.index>, or
<parallel.currentItem> and <parallel.index>; after it, <name.results>. A reference to a block
Expand Down
80 changes: 76 additions & 4 deletions apps/docs/openapi-v2-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -22253,11 +22253,47 @@
"properties": {
"type": {
"type": "string",
"description": "Value type of the output."
"description": "Value type of the output field."
},
"description": {
"description": "What the output holds.",
"description": "What the field holds.",
"type": "string"
},
"properties": {
"description": "Members of an object-typed output, keyed by field name.",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"description": "Nested output field, in this same shape."
}
},
"items": {
"description": "Element shape of an array-typed output.",
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "Element value type."
},
"description": {
"description": "What an element holds.",
"type": "string"
},
"properties": {
"description": "Members of an object-typed element, keyed by field name.",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"description": "Nested output field, in this same shape."
}
}
},
"required": ["type"],
"additionalProperties": false
}
},
"required": ["type"],
Expand Down Expand Up @@ -22381,11 +22417,47 @@
"properties": {
"type": {
"type": "string",
"description": "Value type of the output."
"description": "Value type of the output field."
},
"description": {
"description": "What the output holds.",
"description": "What the field holds.",
"type": "string"
},
"properties": {
"description": "Members of an object-typed output, keyed by field name.",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"description": "Nested output field, in this same shape."
}
},
"items": {
"description": "Element shape of an array-typed output.",
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "Element value type."
},
"description": {
"description": "What an element holds.",
"type": "string"
},
"properties": {
"description": "Members of an object-typed element, keyed by field name.",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"description": "Nested output field, in this same shape."
}
}
},
"required": ["type"],
"additionalProperties": false
}
},
"required": ["type"],
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/openapi-v2-tables.json
Original file line number Diff line number Diff line change
Expand Up @@ -6422,7 +6422,7 @@
},
"required": ["columns"],
"additionalProperties": false,
"description": "Initial table column definitions."
"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."
},
"folderPath": {
"description": "Folder in which to create the table.",
Expand Down Expand Up @@ -6701,7 +6701,7 @@
},
"required": ["name", "type"],
"additionalProperties": false,
"description": "Column definition to add."
"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."
}
},
"required": ["workspaceId", "column"],
Expand Down
8 changes: 4 additions & 4 deletions apps/docs/scripts/fixtures/content-baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -12982,8 +12982,8 @@
{
"lang": "text",
"meta": null,
"sha256": "2143e5d8691f486425a8fb17938c12cc7875efc2b5aaf53d77685941a08835af",
"bytes": 3532,
"sha256": "6cf7c87da84d5ace685f6752652f51790aadb86153cc83330070235579ddb15d",
"bytes": 4141,
"line": 7771
},
{
Expand Down Expand Up @@ -17505,8 +17505,8 @@
{
"lang": "text",
"meta": null,
"sha256": "2143e5d8691f486425a8fb17938c12cc7875efc2b5aaf53d77685941a08835af",
"bytes": 3532,
"sha256": "6cf7c87da84d5ace685f6752652f51790aadb86153cc83330070235579ddb15d",
"bytes": 4141,
"line": 340
},
{
Expand Down
17 changes: 4 additions & 13 deletions apps/sim/blocks/blocks/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
TABLE_IGNORED_COLUMNS_OUTPUT,
TABLE_OUTPUT_COLUMNS_INPUT,
TABLE_OUTPUT_COLUMNS_SUBBLOCK,
TABLE_ROW_OUTPUT,
TABLE_ROWS_OUTPUT,
toolCallArg,
} from '@/blocks/utils'
import { TABLE_ID_PARAM } from '@/tools/table/params'
Expand Down Expand Up @@ -816,24 +818,13 @@ Return ONLY the sort JSON:`,

outputs: {
success: { type: 'boolean', description: 'Operation success status' },
row: {
type: 'json',
description: 'Single row data',
condition: {
field: 'operation',
value: ['get_row', 'insert_row', 'upsert_row', 'update_row'],
},
},
row: TABLE_ROW_OUTPUT,
operation: {
type: 'string',
description: 'Operation performed (insert or update)',
condition: { field: 'operation', value: 'upsert_row' },
},
rows: {
type: 'array',
description: 'Array of rows',
condition: { field: 'operation', value: ['query_rows', 'batch_insert_rows'] },
},
rows: TABLE_ROWS_OUTPUT,
rowCount: {
type: 'number',
description: 'Rows returned (query) or total rows in the table (get schema)',
Expand Down
17 changes: 4 additions & 13 deletions apps/sim/blocks/blocks/table_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
TABLE_IGNORED_COLUMNS_OUTPUT,
TABLE_OUTPUT_COLUMNS_INPUT,
TABLE_OUTPUT_COLUMNS_SUBBLOCK,
TABLE_ROW_OUTPUT,
TABLE_ROWS_OUTPUT,
toolCallArg,
} from '@/blocks/utils'
import { TABLE_ID_PARAM } from '@/tools/table/params'
Expand Down Expand Up @@ -611,24 +613,13 @@ Return ONLY the JSON object:`,

outputs: {
success: { type: 'boolean', description: 'Operation success status' },
row: {
type: 'json',
description: 'Single row data',
condition: {
field: 'operation',
value: ['get_row', 'insert_row', 'upsert_row', 'update_row'],
},
},
row: TABLE_ROW_OUTPUT,
operation: {
type: 'string',
description: 'Operation performed (insert or update)',
condition: { field: 'operation', value: 'upsert_row' },
},
rows: {
type: 'array',
description: 'Array of rows',
condition: { field: 'operation', value: ['query_rows', 'batch_insert_rows'] },
},
rows: TABLE_ROWS_OUTPUT,
rowCount: {
type: 'number',
description: 'Rows returned (query) or total rows in the table (get schema)',
Expand Down
36 changes: 36 additions & 0 deletions apps/sim/blocks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,42 @@ export const TABLE_IGNORED_COLUMNS_OUTPUT = {
},
} satisfies OutputFieldDefinition

/**
* One row as the Table blocks output it (`presentNamedTableRow` and `presentNamedTableQueryRow`
* in `lib/internal/table/presentation.ts`): its cells sit under `data`, keyed by column name.
*/
const TABLE_ROW_PROPERTIES = {
id: { type: 'string', description: 'Row ID' },
Comment thread
waleedlatif1 marked this conversation as resolved.
Resolved
data: { type: 'json', description: 'The row’s cells, keyed by column name' },
position: { type: 'number', description: 'Row position in the table' },
orderKey: { type: 'string', description: 'Sort key (query and insert results only)' },
executions: {
type: 'json',
description: 'Workflow run state per column group (query and insert results only)',
},
createdAt: { type: 'string', description: 'ISO timestamp when the row was created' },
updatedAt: { type: 'string', description: 'ISO timestamp when the row was last updated' },
} satisfies Record<string, OutputFieldDefinition>

/** The `row` output of the Table blocks: a cell reads as `row.data.<column>`. */
export const TABLE_ROW_OUTPUT = {
type: 'json',
description: 'The row: its cells are row.data.<column name>',
condition: {
field: 'operation',
value: ['get_row', 'insert_row', 'upsert_row', 'update_row'],
},
properties: TABLE_ROW_PROPERTIES,
} satisfies OutputFieldDefinition

/** The `rows` output of the Table blocks: a cell reads as `rows[i].data.<column>`. */
export const TABLE_ROWS_OUTPUT = {
type: 'array',
description: 'The rows: a cell is rows[i].data.<column name>',
condition: { field: 'operation', value: ['query_rows', 'batch_insert_rows'] },
items: { type: 'json', properties: TABLE_ROW_PROPERTIES },
} satisfies OutputFieldDefinition

/** Block input entry for {@link TABLE_OUTPUT_COLUMNS_SUBBLOCK}. */
export const TABLE_OUTPUT_COLUMNS_INPUT = {
type: 'array',
Expand Down
Loading