Skip to content

Commit a3cd487

Browse files
committed
docs: fix the cookbook upsert and workspace help; pin the unknown-type error's line
The cookbook wrote a status option and a column the orders table lacks and upserted on a column not declared unique; a check of the example against the cookbook workspace now guards it. The help says a source directory keeps its recorded workspace and what -w does with a variable holding the whole option.
1 parent e0d4d25 commit a3cd487

8 files changed

Lines changed: 18 additions & 12 deletions

File tree

‎apps/sim/lib/workflows/application/apply-workflow-source.integration.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,12 @@ check('a new block of an unknown type is one error, at its source line', async (
11261126

11271127
const errors = result.diagnostics.filter((d) => d.severity === 'error')
11281128
expect(errors.map((d) => d.code)).toEqual(['E_APPLY_INVALID_BLOCK_TYPE'])
1129-
expect(errors[0]).toMatchObject({ file: 'workflow.ts', blockKey: 'ghost' })
1129+
const ghostLine =
1130+
files['workflow.ts']
1131+
.split('\n')
1132+
.findIndex((line) => line.includes("block('qa_nonexistent_type'")) + 1
1133+
expect(ghostLine).toBeGreaterThan(0)
1134+
expect(errors[0]).toMatchObject({ file: 'workflow.ts', line: ghostLine, blockKey: 'ghost' })
11301135
expect(errors[0]?.message).toContain('qa_nonexistent_type')
11311136
expect(result.applied).toBe(false)
11321137
})

‎apps/sim/lib/workflows/code/real-catalog.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const COOKBOOK_WORKSPACE: WorkspaceManifest = {
5656
columns: {
5757
orderId: { type: 'string' },
5858
status: { type: 'string' },
59-
risk: { type: 'string' },
6059
},
6160
},
6261
leads: {

‎packages/sim-cli/src/commands/protocol/source-loop-help.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ function loopRows(rows: ReadonlyArray<readonly [string, string]>): string {
1414

1515
/** Where the commands of either group find their workspace. */
1616
const WORKSPACE_LINE = `Workspace: a command run on a directory reads it from .sim/base.json; any other takes -w <id>
17-
or SIM_WORKSPACE (export it once: a shell variable holding "--workspace <id>" arrives as one
18-
argument, which is refused).`
17+
or SIM_WORKSPACE (export it once, or keep only the ID in a variable: a variable holding
18+
"--workspace <id>" is one argument, an unknown option alone and the whole ID after -w).`
1919

2020
/** The status line both groups end with, for a directory at `dir`. */
2121
function statusLine(group: string, dir: string): string {

‎packages/sim-cli/src/program.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ Profiles work like the AWS CLI: settings live in ~/.sim/config, keys in
2828
with -P, --profile, or SIM_PROFILE.
2929
3030
A command targets the profile's workspace unless -w <id> (--workspace <id>) or
31-
SIM_WORKSPACE names another. In a script, export SIM_WORKSPACE=<id> once, or
32-
write -w "$WS": a variable holding "--workspace <id>" reaches the CLI as one
33-
argument, which it refuses.
31+
SIM_WORKSPACE names another; a source directory keeps to the workspace its
32+
.sim/base.json records, and refuses a -w naming another. In a script, export
33+
SIM_WORKSPACE=<id> once, or keep only the ID in a variable and write -w "$WS".
34+
A variable holding "--workspace <id>" is one argument: alone it is an unknown
35+
option, and after -w all of it is taken as the ID.
3436
3537
Workflow, knowledge-base and workspace IDs are bare UUIDs. Table IDs carry a
3638
tbl_ prefix and file IDs a wf_ one, so wf_ never names a workflow. An audit-log

‎packages/workflow-sdk/cookbook/examples/cookbook.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ export default workflow('Cookbook', { description: 'One example of each common b
7474
})
7575
const save = table.insertRow('Save Order', {
7676
tableId: table('orders'),
77-
data: { orderId: start.orderId, status: 'open', risk: check.risk },
77+
data: { orderId: start.orderId, status: 'open' },
7878
})
7979
// Upsert: updates the row whose conflictColumn (a unique column, by name) matches data, else
8080
// inserts one. data is keyed by column name, as for insertRow.
8181
const touch = table.upsertRow('Touch Order', {
8282
tableId: table('orders'),
83-
data: { orderId: start.orderId, status: 'seen' },
83+
data: { orderId: start.orderId, status: 'answered' },
8484
conflictColumn: 'orderId',
8585
})
8686

‎packages/workflow-sdk/cookbook/workspace/tables/orders.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineTable({
77
name: 'orders',
88
description: 'Order questions the support workflow answered',
99
columns: {
10-
orderId: column.string({ required: true }),
10+
orderId: column.string({ required: true, unique: true }),
1111
status: column.select({ options: ['open', 'answered'] }),
1212
total: column.number(),
1313
},

‎packages/workflow-sdk/src/codegen/cookbook-text.generated.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎packages/workflow-sdk/src/codegen/workspace-cookbook-text.generated.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)