Skip to content

Commit 75894e2

Browse files
committed
improvement(cli): self-sufficient workflow export, atomic subflow moves, documented table columns
- `sim workflows export` keeps workspace bindings (table, knowledge base, child workflow ids) by default, so a table block prints its tableId; `--no-include-workspace-bindings` clears them for a copy to share. The stderr note pointing at `workflows outline` is gone. - Moving a block into or out of a loop or parallel removes the stored edges the move leaves crossing the boundary and names them in `warnings`, instead of recording them as skipped items that made `atomic` refuse the batch. Edges the batch itself asks for across a boundary are still refused. Operations help states this. - `tables create --schema` and `tables columns create --column` list every column field (required, unique, options, multiple, currencyCode, id, position) generated from the shape the server validates.
1 parent cca5ca3 commit 75894e2

16 files changed

Lines changed: 248 additions & 103 deletions

File tree

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

Lines changed: 8 additions & 6 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: &#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). |
5894+
| `--column <json\|@file>` | Yes | Column definition to add: &#123;"name":"status","type":"string"&#125;. Column fields: id - Optional client-provided column identifier; name (required) - Column name; type (required) - Column data type; required - Whether inserts must supply a value for this column; unique - Whether values in the column must be unique; options - Select options for select-type columns, as [&#123;"id":"open","name":"Open"&#125;]; multiple - Whether a select column accepts multiple values; currencyCode - ISO 4217 code for currency columns; position - Zero-based insertion position for the column. 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 | 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). |
6800+
| `--schema <json\|@file>` | Yes | Initial table column definitions: &#123;"columns":[&#123;"name":"email","type":"string","required":true,"unique":true&#125;]&#125;. Column fields: id - Optional client-provided column identifier; name (required) - Column name; type (required) - Column data type; required - Whether inserts must supply a value for this column; unique - Whether values in the column must be unique; options - Select options for select-type columns, as [&#123;"id":"open","name":"Open"&#125;]; multiple - Whether a select column accepts multiple values; currencyCode - ISO 4217 code for currency columns. 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>
@@ -7774,8 +7774,10 @@ Edges:
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
77767776
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).
7777+
Moving a block into or out of a loop or parallel (parentId) removes each of its existing edges
7778+
that would cross the container's boundary, atomic or not, and names them in warnings. Edges the
7779+
batch itself asks for across a boundary are refused. Wire into the body from loop-start-source
7780+
and onward from loop-end-source (parallel-start-source, parallel-end-source).
77797781
To remove one edge, edit its source block with
77807782
{"removeEdges":[{"targetBlockId":"<id>","sourceHandle":"source"}]} (sourceHandle defaults to
77817783
"source").
@@ -8562,12 +8564,12 @@ sim workflows export <workflowId> [options]
85628564
| Option | Required | Description |
85638565
| --- | --- | --- |
85648566
| `--include-references` | No | Include non-secret resource identities for mapped import. |
8565-
| `--include-workspace-bindings` | No | Keep non-secret table, knowledge base, document, folder, channel, and other workspace bindings for a same-workspace import. Defaults to false, which clears these IDs. Registered credential fields and opaque table/tool values are cleared either way; environment references and ordinary workflow variables remain included. |
8567+
| `--include-workspace-bindings` | No | Keep table, knowledge base, document, folder, channel and other workspace bindings. On by default; --no-include-workspace-bindings clears them for a copy to share outside this workspace. Credentials are cleared either way. |
85668568
| `--no-include-workspace-bindings` | No | Send --include-workspace-bindings as false. |
85678569

85688570
</CommandTable>
85698571

8570-
Workspace bindings (a table, a child workflow, a knowledge base) print as null unless --include-workspace-bindings, and credentials always do: that is the export, not an unset block. To read what a block is set to, use `sim workflows outline` or `sim workflows state get`.
8572+
A table, child workflow, knowledge base or other workspace binding prints as its id; a credential always prints as null. For a copy to share outside this workspace, pass --no-include-workspace-bindings to clear the bindings too.
85718573

85728574
API request and response schemas: [exportWorkflow](/api-reference/workflows/exportWorkflow).
85738575

‎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 | 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). |
71+
| `--schema <json\|@file>` | Yes | Initial table column definitions: &#123;"columns":[&#123;"name":"email","type":"string","required":true,"unique":true&#125;]&#125;. Column fields: id - Optional client-provided column identifier; name (required) - Column name; type (required) - Column data type; required - Whether inserts must supply a value for this column; unique - Whether values in the column must be unique; options - Select options for select-type columns, as [&#123;"id":"open","name":"Open"&#125;]; multiple - Whether a select column accepts multiple values; currencyCode - ISO 4217 code for currency columns. 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: &#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). |
627+
| `--column <json\|@file>` | Yes | Column definition to add: &#123;"name":"status","type":"string"&#125;. Column fields: id - Optional client-provided column identifier; name (required) - Column name; type (required) - Column data type; required - Whether inserts must supply a value for this column; unique - Whether values in the column must be unique; options - Select options for select-type columns, as [&#123;"id":"open","name":"Open"&#125;]; multiple - Whether a select column accepts multiple values; currencyCode - ISO 4217 code for currency columns; position - Zero-based insertion position for the column. 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/workflow-sync.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Forking and sync require Enterprise on billing-enabled deployments. Billing-disa
2828

2929
### 1. Export and inspect the workflow
3030

31-
`--include-references` adds a versioned manifest of resource identities and their occurrences. Default export clears registered credential fields and workspace bindings. It does not remove every ordinary variable value or literal configuration; inspect the payload before sharing it. Credentials and secret values are not transferred as destination resources.
31+
`--include-references` adds a versioned manifest of resource identities and their occurrences. `sim workflows export` clears registered credential fields and keeps non-secret workspace bindings, such as table and knowledge base IDs; `--no-include-workspace-bindings` clears those too. It does not remove every ordinary variable value or literal configuration; inspect the payload before sharing it. Credentials and secret values are not transferred as destination resources.
3232

3333
Pin JSON because import does not accept YAML:
3434

@@ -40,7 +40,7 @@ sim --profile destination --workspace "$DESTINATION_WORKSPACE" --output json \
4040
workflows import-preview --workflow @workflow.json > preview.json
4141
```
4242

43-
`--include-workspace-bindings` can preserve non-secret bindings for a same-workspace round trip. Otherwise, configure required bindings reported by import.
43+
With `--include-references`, import preview lists the bindings the destination has to map.
4444

4545
### 2. Map destination resources
4646

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,10 @@ Edges:
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
345345
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).
346+
Moving a block into or out of a loop or parallel (parentId) removes each of its existing edges
347+
that would cross the container's boundary, atomic or not, and names them in warnings. Edges the
348+
batch itself asks for across a boundary are refused. Wire into the body from loop-start-source
349+
and onward from loop-end-source (parallel-start-source, parallel-end-source).
348350
To remove one edge, edit its source block with
349351
{"removeEdges":[{"targetBlockId":"<id>","sourceHandle":"source"}]} (sourceHandle defaults to
350352
"source").
@@ -1155,12 +1157,12 @@ sim workflows export <workflowId> [options]
11551157
| Option | Required | Description |
11561158
| --- | --- | --- |
11571159
| `--include-references` | No | Include non-secret resource identities for mapped import. |
1158-
| `--include-workspace-bindings` | No | Keep non-secret table, knowledge base, document, folder, channel, and other workspace bindings for a same-workspace import. Defaults to false, which clears these IDs. Registered credential fields and opaque table/tool values are cleared either way; environment references and ordinary workflow variables remain included. |
1160+
| `--include-workspace-bindings` | No | Keep table, knowledge base, document, folder, channel and other workspace bindings. On by default; --no-include-workspace-bindings clears them for a copy to share outside this workspace. Credentials are cleared either way. |
11591161
| `--no-include-workspace-bindings` | No | Send --include-workspace-bindings as false. |
11601162

11611163
</CommandTable>
11621164

1163-
Workspace bindings (a table, a child workflow, a knowledge base) print as null unless --include-workspace-bindings, and credentials always do: that is the export, not an unset block. To read what a block is set to, use `sim workflows outline` or `sim workflows state get`.
1165+
A table, child workflow, knowledge base or other workspace binding prints as its id; a credential always prints as null. For a copy to share outside this workspace, pass --no-include-workspace-bindings to clear the bindings too.
11641166

11651167
API request and response schemas: [exportWorkflow](/api-reference/workflows/exportWorkflow).
11661168

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6383,7 +6383,7 @@
63836383
"type": "boolean"
63846384
},
63856385
"options": {
6386-
"description": "Select options for select-type columns.",
6386+
"description": "Select options for select-type columns, as [{\"id\":\"open\",\"name\":\"Open\"}].",
63876387
"maxItems": 100,
63886388
"type": "array",
63896389
"items": {
@@ -6422,7 +6422,7 @@
64226422
},
64236423
"required": ["columns"],
64246424
"additionalProperties": false,
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."
6425+
"description": "Initial table column definitions: {\"columns\":[{\"name\":\"email\",\"type\":\"string\",\"required\":true,\"unique\":true}]}. Column fields: id - Optional client-provided column identifier; name (required) - Column name; type (required) - Column data type; required - Whether inserts must supply a value for this column; unique - Whether values in the column must be unique; options - Select options for select-type columns, as [{\"id\":\"open\",\"name\":\"Open\"}]; multiple - Whether a select column accepts multiple values; currencyCode - ISO 4217 code for currency columns. 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.",
@@ -6662,7 +6662,7 @@
66626662
"type": "boolean"
66636663
},
66646664
"options": {
6665-
"description": "Select options for select-type columns.",
6665+
"description": "Select options for select-type columns, as [{\"id\":\"open\",\"name\":\"Open\"}].",
66666666
"maxItems": 100,
66676667
"type": "array",
66686668
"items": {
@@ -6701,7 +6701,7 @@
67016701
},
67026702
"required": ["name", "type"],
67036703
"additionalProperties": false,
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."
6704+
"description": "Column definition to add: {\"name\":\"status\",\"type\":\"string\"}. Column fields: id - Optional client-provided column identifier; name (required) - Column name; type (required) - Column data type; required - Whether inserts must supply a value for this column; unique - Whether values in the column must be unique; options - Select options for select-type columns, as [{\"id\":\"open\",\"name\":\"Open\"}]; multiple - Whether a select column accepts multiple values; currencyCode - ISO 4217 code for currency columns; position - Zero-based insertion position for the column. 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/sim/lib/api/contracts/v2/tables.ts‎

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,25 @@ const v2TableColumnInputShape = {
471471
type: columnTypeSchema.describe('Column data type.'),
472472
required: z.boolean().optional().describe('Whether inserts must supply a value for this column.'),
473473
unique: z.boolean().optional().describe('Whether values in the column must be unique.'),
474-
options: selectOptionsSchema.optional().describe('Select options for select-type columns.'),
474+
options: selectOptionsSchema
475+
.optional()
476+
.describe('Select options for select-type columns, as [{"id":"open","name":"Open"}].'),
475477
multiple: z.boolean().optional().describe('Whether a select column accepts multiple values.'),
476478
currencyCode: currencyCodeSchema.optional().describe('ISO 4217 code for currency columns.'),
477479
}
478480

481+
/**
482+
* Every field a column input accepts and what it means, read from the shape the server validates,
483+
* so the help cannot name a field the server rejects or leave out one it takes.
484+
*/
485+
function describeColumnFields(shape: Record<string, z.ZodType>): string {
486+
const fields = Object.entries(shape).map(
487+
([field, schema]) =>
488+
`${field}${schema.isOptional() ? '' : ' (required)'} - ${schema.description?.replace(/\.$/, '')}`
489+
)
490+
return `Column fields: ${fields.join('; ')}.`
491+
}
492+
479493
/**
480494
* Public column input.
481495
*
@@ -519,7 +533,7 @@ export const v2CreateTableBodySchema = v1CreateTableBodySchema
519533
})
520534
.strict()
521535
.describe(
522-
`Initial table column definitions: {"columns":[{"name":"email","type":"string"}]}. ${COLUMN_TYPES_HELP}`
536+
`Initial table column definitions: {"columns":[{"name":"email","type":"string","required":true,"unique":true}]}. ${describeColumnFields(v2TableColumnInputShape)} ${COLUMN_TYPES_HELP}`
523537
),
524538
folderPath: v2FolderPathInputSchema.optional().describe('Folder in which to create the table.'),
525539
})
@@ -730,23 +744,25 @@ export const v2DeleteTableContract = defineRouteContract({
730744
},
731745
})
732746

747+
const v2AddedColumnInputShape = {
748+
...v2TableColumnInputShape,
749+
position: z
750+
.number()
751+
.int()
752+
.min(0)
753+
.optional()
754+
.describe('Zero-based insertion position for the column.'),
755+
}
756+
733757
export const v2CreateTableColumnBodySchema = z
734758
.object({
735759
workspaceId: workspaceIdSchema.describe('Workspace that owns the table.'),
736760
column: z
737-
.object({
738-
...v2TableColumnInputShape,
739-
position: z
740-
.number()
741-
.int()
742-
.min(0)
743-
.optional()
744-
.describe('Zero-based insertion position for the column.'),
745-
})
761+
.object(v2AddedColumnInputShape)
746762
.strict()
747763
.superRefine(refineColumnOptions)
748764
.describe(
749-
`Column definition to add: {"name":"status","type":"string"}. ${COLUMN_TYPES_HELP}`
765+
`Column definition to add: {"name":"status","type":"string"}. ${describeColumnFields(v2AddedColumnInputShape)} ${COLUMN_TYPES_HELP}`
750766
),
751767
})
752768
.strict()

0 commit comments

Comments
 (0)