diff --git a/apps/docs/openapi-v2-workflows.json b/apps/docs/openapi-v2-workflows.json index 92fb0894f75..baa318608ea 100644 --- a/apps/docs/openapi-v2-workflows.json +++ b/apps/docs/openapi-v2-workflows.json @@ -489,6 +489,18 @@ "description": "Validate and lint without writing, auditing, or notifying collaborators. Returns the same validation, preparation warnings, lint findings, and ID-ownership conflicts (`409`) as a committed write. `needsRedeployment` describes the pre-write state. For semantic operations, `mintedBlockIds` is empty; `previewBlockIds` contains provisional IDs with a warning, since committing mints new IDs.", "type": "boolean" } + }, + { + "name": "dryRun", + "in": "query", + "required": false, + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "schema": { + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "type": "boolean" + } } ], "requestBody": { @@ -539,6 +551,7 @@ "warnings": [], "needsRedeployment": true, "dry": false, + "dryRun": false, "lint": { "sources": [], "sinks": [], @@ -736,6 +749,18 @@ "description": "Validate and lint without writing, auditing, or notifying collaborators. Returns the same validation, preparation warnings, lint findings, and ID-ownership conflicts (`409`) as a committed write. `needsRedeployment` describes the pre-write state. For semantic operations, `mintedBlockIds` is empty; `previewBlockIds` contains provisional IDs with a warning, since committing mints new IDs.", "type": "boolean" } + }, + { + "name": "dryRun", + "in": "query", + "required": false, + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "schema": { + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "type": "boolean" + } } ], "requestBody": { @@ -845,7 +870,8 @@ "Workflow lint found issues (Blocks missing required fields: 1). The findings are in `lint`." ], "needsRedeployment": true, - "dry": false + "dry": false, + "dryRun": false } } } @@ -6083,6 +6109,18 @@ "description": "Allow the apply to delete blocks and variables the source no longer declares. Without it, an apply that would delete any block is refused with `E_APPLY_BLOCK_DELETE`, and one that would delete any variable with `E_APPLY_VARIABLE_DELETE`, naming them. Ignored when creating a workflow.", "type": "boolean" } + }, + { + "name": "dryRun", + "in": "query", + "required": false, + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "schema": { + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "type": "boolean" + } } ], "requestBody": { @@ -6152,6 +6190,7 @@ "workflowId": "3b1f7c92-8d4e-4a6b-9c0d-5e2f8a714b36", "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": false, + "dryRun": false, "applied": false, "diff": { "noop": true, @@ -6349,6 +6388,7 @@ "workflowId": "3b1f7c92-8d4e-4a6b-9c0d-5e2f8a714b36", "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": true, + "dryRun": true, "applied": false, "diff": { "noop": true, @@ -6481,6 +6521,18 @@ "description": "Allow the apply to delete blocks and variables the source no longer declares. Without it, an apply that would delete any block is refused with `E_APPLY_BLOCK_DELETE`, and one that would delete any variable with `E_APPLY_VARIABLE_DELETE`, naming them. Ignored when creating a workflow.", "type": "boolean" } + }, + { + "name": "dryRun", + "in": "query", + "required": false, + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "schema": { + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "type": "boolean" + } } ], "requestBody": { @@ -6532,6 +6584,7 @@ "workflowId": "3b1f7c92-8d4e-4a6b-9c0d-5e2f8a714b36", "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": false, + "dryRun": false, "applied": true, "diff": { "noop": false, @@ -8907,6 +8960,18 @@ "description": "Plan, check and authorize every change without writing. Findings, errors included, come back in `diagnostics` with a `200`.", "type": "boolean" } + }, + { + "name": "dryRun", + "in": "query", + "required": false, + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "schema": { + "deprecated": true, + "description": "Deprecated name of `dry`, accepted with the same meaning. Send `dry`; a request that sends both with different values is refused.", + "type": "boolean" + } } ], "requestBody": { @@ -8979,6 +9044,7 @@ "data": { "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": false, + "dryRun": false, "plan": [ { "kind": "table", @@ -9156,6 +9222,7 @@ "data": { "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": true, + "dryRun": true, "plan": [ { "kind": "table", @@ -11481,9 +11548,14 @@ "dry": { "type": "boolean", "description": "Whether this request only validated. `true` means nothing was persisted; the findings describe what a committed write of the same body would produce." + }, + "dryRun": { + "type": "boolean", + "deprecated": true, + "description": "Deprecated name of `dry`, always sent with the same value. Read `dry`." } }, - "required": ["id", "warnings", "needsRedeployment", "lint", "dry"], + "required": ["id", "warnings", "needsRedeployment", "lint", "dry", "dryRun"], "additionalProperties": false, "title": "Replace workflow state result", "description": "Outcome of replacing a workflow draft graph, with its advisory findings." @@ -11507,6 +11579,7 @@ "warnings": [], "needsRedeployment": true, "dry": false, + "dryRun": false, "lint": { "sources": [], "sinks": [], @@ -12144,6 +12217,11 @@ "dry": { "type": "boolean", "description": "Whether this request only evaluated. `true` means nothing was persisted; the outcome describes what a committed apply of the same body would produce." + }, + "dryRun": { + "type": "boolean", + "deprecated": true, + "description": "Deprecated name of `dry`, always sent with the same value. Read `dry`." } }, "required": [ @@ -12156,7 +12234,8 @@ "inputValidationErrors", "mintedBlockIds", "lint", - "dry" + "dry", + "dryRun" ], "additionalProperties": false, "title": "Apply workflow operations result", @@ -12222,7 +12301,8 @@ "Workflow lint found issues (Blocks missing required fields: 1). The findings are in `lint`." ], "needsRedeployment": true, - "dry": false + "dry": false, + "dryRun": false } } ] @@ -17827,9 +17907,9 @@ "type": "object", "properties": { "source": { + "description": "Run the saved draft. `manual` is a deprecated name of `draft`.", "type": "string", - "const": "draft", - "description": "Run the saved draft." + "enum": ["draft", "manual"] }, "entry": { "description": "Where the draft run enters. Omit to enter through the workflow trigger; a block entry requires an exact source run.", @@ -17850,6 +17930,11 @@ "sample": { "description": "Run with the selected trigger's sample payload, which the server derives from the trigger, instead of `input`. Its writes are sent unless `dry`. Cannot be combined with `input`.", "type": "boolean" + }, + "useMockPayload": { + "deprecated": true, + "description": "Deprecated name of `sample`, accepted with the same meaning. Send `sample`; a request that sends both with different values is refused.", + "type": "boolean" } }, "required": ["type"], @@ -18002,58 +18087,7 @@ }, "additionalProperties": false, "title": "Execute workflow request", - "description": "Input, workflow-state selection, and execution-mode options. Input descriptions specify compatible modes; invalid combinations return `400`.", - "examples": [ - { - "input": { - "ticketId": "ticket_123" - } - }, - { - "input": { - "ticketId": "ticket_123" - }, - "async": true - }, - { - "input": { - "ticketId": "ticket_123" - }, - "stream": true - }, - { - "run": { - "source": "draft" - } - }, - { - "run": { - "source": "draft" - }, - "waitTimeoutSeconds": 240 - }, - { - "run": { - "source": "draft", - "entry": { - "type": "block", - "blockId": "block_123", - "sourceRunId": "run_123" - } - } - }, - { - "run": { - "source": "draft", - "entry": { - "type": "block", - "blockId": "block_123", - "sourceRunId": "run_123" - }, - "stopAfterBlockId": "block_123" - } - } - ] + "description": "Input, workflow-state selection, and execution-mode options. Input descriptions specify compatible modes; invalid combinations return `400`." }, "WorkflowRunListItem": { "type": "object", @@ -19977,6 +20011,11 @@ "type": "boolean", "description": "True when nothing was written because `dry` was set." }, + "dryRun": { + "type": "boolean", + "deprecated": true, + "description": "Deprecated name of `dry`, always sent with the same value. Read `dry`." + }, "applied": { "type": "boolean", "description": "True when the draft was written or the workflow renamed or redescribed; false on a dry run and on a no-op." @@ -20646,6 +20685,7 @@ "workflowId", "workspaceId", "dry", + "dryRun", "applied", "diff", "diagnostics", @@ -20671,6 +20711,7 @@ "workflowId": "3b1f7c92-8d4e-4a6b-9c0d-5e2f8a714b36", "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": false, + "dryRun": false, "applied": false, "diff": { "noop": true, @@ -20960,6 +21001,11 @@ "type": "boolean", "description": "True when nothing was written because `dry` was set." }, + "dryRun": { + "type": "boolean", + "deprecated": true, + "description": "Deprecated name of `dry`, always sent with the same value. Read `dry`." + }, "applied": { "type": "boolean", "description": "True when the draft was written or the workflow renamed or redescribed; false on a dry run and on a no-op." @@ -21629,6 +21675,7 @@ "workflowId", "workspaceId", "dry", + "dryRun", "applied", "diff", "diagnostics", @@ -21654,6 +21701,7 @@ "workflowId": "3b1f7c92-8d4e-4a6b-9c0d-5e2f8a714b36", "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": true, + "dryRun": true, "applied": false, "diff": { "noop": true, @@ -21919,6 +21967,11 @@ "type": "boolean", "description": "True when nothing was written because `dry` was set." }, + "dryRun": { + "type": "boolean", + "deprecated": true, + "description": "Deprecated name of `dry`, always sent with the same value. Read `dry`." + }, "applied": { "type": "boolean", "description": "True when the draft was written or the workflow renamed or redescribed; false on a dry run and on a no-op." @@ -22588,6 +22641,7 @@ "workflowId", "workspaceId", "dry", + "dryRun", "applied", "diff", "diagnostics", @@ -22613,6 +22667,7 @@ "workflowId": "3b1f7c92-8d4e-4a6b-9c0d-5e2f8a714b36", "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": false, + "dryRun": false, "applied": true, "diff": { "noop": false, @@ -27501,6 +27556,11 @@ "type": "boolean", "description": "True when nothing was written because `dry` was set." }, + "dryRun": { + "type": "boolean", + "deprecated": true, + "description": "Deprecated name of `dry`, always sent with the same value. Read `dry`." + }, "plan": { "type": "array", "items": { @@ -28440,6 +28500,7 @@ "required": [ "workspaceId", "dry", + "dryRun", "plan", "applied", "needBlobs", @@ -28460,6 +28521,7 @@ "data": { "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": false, + "dryRun": false, "plan": [ { "kind": "table", @@ -28785,6 +28847,11 @@ "type": "boolean", "description": "True when nothing was written because `dry` was set." }, + "dryRun": { + "type": "boolean", + "deprecated": true, + "description": "Deprecated name of `dry`, always sent with the same value. Read `dry`." + }, "plan": { "type": "array", "items": { @@ -29724,6 +29791,7 @@ "required": [ "workspaceId", "dry", + "dryRun", "plan", "applied", "needBlobs", @@ -29744,6 +29812,7 @@ "data": { "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64", "dry": true, + "dryRun": true, "plan": [ { "kind": "table", diff --git a/apps/sim/app/api/v2/workflows/[workflowId]/execute/route.test.ts b/apps/sim/app/api/v2/workflows/[workflowId]/execute/route.test.ts index ec89d17b083..6dca7256291 100644 --- a/apps/sim/app/api/v2/workflows/[workflowId]/execute/route.test.ts +++ b/apps/sim/app/api/v2/workflows/[workflowId]/execute/route.test.ts @@ -597,6 +597,43 @@ describe('POST /api/v2/workflows/[workflowId]/execute', () => { expect(mockExecuteWorkflowCore).not.toHaveBeenCalled() }) + describe('names used before the draft-run rename', () => { + it('keeps the draft-run limits for source manual: no async, no input beside the sample', async () => { + authenticatePersonalKey() + + const asyncResponse = await callExecute({ run: { source: 'manual' }, async: true }) + expect(asyncResponse.status).toBe(400) + expect((await asyncResponse.json()).error.message).toBe( + 'A draft run does not support async mode' + ) + + const withInput = await callExecute({ + input: { event: 'created' }, + run: { source: 'manual', entry: { type: 'trigger', useMockPayload: true } }, + }) + expect(withInput.status).toBe(400) + expect((await withInput.json()).error.message).toBe( + 'input and run.entry.sample cannot be combined' + ) + expect(mockExecuteManualTrigger).not.toHaveBeenCalled() + expect(mockExecuteWorkflowCore).not.toHaveBeenCalled() + }) + + it('refuses useMockPayload and sample that disagree, before dispatch', async () => { + authenticatePersonalKey() + + const response = await callExecute({ + run: { source: 'draft', entry: { type: 'trigger', sample: true, useMockPayload: false } }, + }) + + expect(response.status).toBe(400) + expect(JSON.stringify(await response.json())).toContain( + 'useMockPayload is the deprecated name of sample' + ) + expect(mockExecuteManualTrigger).not.toHaveBeenCalled() + }) + }) + it('dispatches an OAuth manual trigger run through the same manual operation', async () => { mockAuthenticateV2ApiKey.mockResolvedValue({ principal: { @@ -1045,6 +1082,17 @@ describe('POST /api/v2/workflows/[workflowId]/execute', () => { expect(mockExecuteManualTrigger).not.toHaveBeenCalled() }) + it('never permits a run named source manual on the anonymous public path', async () => { + dbChainMockFns.limit.mockReset() + queuePublicWorkflowReads() + + const response = await callPublicExecute({ run: { source: 'manual' } }) + + expect(response.status).toBe(401) + expect(mockExecuteManualTrigger).not.toHaveBeenCalled() + expect(mockExecuteWorkflowCore).not.toHaveBeenCalled() + }) + it('returns not found when a public workflow disappears before authorization', async () => { dbChainMockFns.limit.mockReset() queuePublicWorkflowReads() diff --git a/apps/sim/app/api/v2/workflows/[workflowId]/operations/route.ts b/apps/sim/app/api/v2/workflows/[workflowId]/operations/route.ts index f5b151f283c..bf8eae1607b 100644 --- a/apps/sim/app/api/v2/workflows/[workflowId]/operations/route.ts +++ b/apps/sim/app/api/v2/workflows/[workflowId]/operations/route.ts @@ -1,3 +1,4 @@ +import { presentDry } from '@/lib/api/contracts/v2/deprecated-names' import { v2ApplyWorkflowOperationsContract } from '@/lib/api/contracts/v2/workflows' import { defineV2JsonRoute, v2ApiKeyAuth, v2RateLimits } from '@/lib/api/server/routes' import { v2WorkflowErrorPolicies } from '@/lib/workflows/api' @@ -53,7 +54,7 @@ export const POST = defineV2JsonRoute({ lint: presentWorkflowLint(result.lint), warnings: result.warnings, needsRedeployment: result.needsRedeployment, - dry: result.dryRun, + ...presentDry(result.dryRun), }, }), }) diff --git a/apps/sim/app/api/v2/workflows/[workflowId]/state/route.ts b/apps/sim/app/api/v2/workflows/[workflowId]/state/route.ts index 180899f3491..f891c1116fa 100644 --- a/apps/sim/app/api/v2/workflows/[workflowId]/state/route.ts +++ b/apps/sim/app/api/v2/workflows/[workflowId]/state/route.ts @@ -1,4 +1,5 @@ import type { BlockState, WorkflowState } from '@sim/workflow-types/workflow' +import { presentDry } from '@/lib/api/contracts/v2/deprecated-names' import { v2GetWorkflowStateContract, v2ReplaceWorkflowStateContract, @@ -71,7 +72,7 @@ export const PUT = defineV2JsonRoute({ warnings, needsRedeployment, lint: presentWorkflowLint(lint), - dry: dryRun, + ...presentDry(dryRun), }, }), }) diff --git a/apps/sim/app/api/v2/workspaces/[workspaceId]/source/route.test.ts b/apps/sim/app/api/v2/workspaces/[workspaceId]/source/route.test.ts index 6fd6fafd3b9..1c31117b52b 100644 --- a/apps/sim/app/api/v2/workspaces/[workspaceId]/source/route.test.ts +++ b/apps/sim/app/api/v2/workspaces/[workspaceId]/source/route.test.ts @@ -106,6 +106,29 @@ describe('POST /api/v2/workspaces/{workspaceId}/source', () => { expect(charges()).toEqual(['workflows.source.write 1', 'workflows.source.write 39']) }) + it('runs the pre-rename ?dryRun as a dry run, in the plan bucket, answering under both names', async () => { + v2RouteMocks.operationRate.mockClear() + mocks.apply.mockClear() + mocks.apply.mockResolvedValue({ + workspaceId: WORKSPACE_ID, + dryRun: true, + plan: [], + applied: [], + needBlobs: [], + files: {}, + base: { version: 1, workspaceId: WORKSPACE_ID, resources: {} }, + diagnostics: [], + }) + + const response = await apply('?dryRun=true') + + expect(response.status).toBe(200) + expect(mocks.apply.mock.calls[0][0].input).toMatchObject({ dryRun: true }) + const buckets = v2RouteMocks.operationRate.mock.calls.map(([key]) => String(key).split(':')[1]) + expect(new Set(buckets)).toEqual(new Set(['source.plan'])) + expect((await response.json()).data).toMatchObject({ dry: true, dryRun: true }) + }) + it('runs dry runs in plan slots, never in an apply’s: past the plans this server runs at once a dry run answers 429 and a real apply still runs', async () => { const result = { workspaceId: WORKSPACE_ID, diff --git a/apps/sim/app/api/v2/workspaces/[workspaceId]/workflows/source/route.test.ts b/apps/sim/app/api/v2/workspaces/[workspaceId]/workflows/source/route.test.ts index 46d66536820..027fdfff54e 100644 --- a/apps/sim/app/api/v2/workspaces/[workspaceId]/workflows/source/route.test.ts +++ b/apps/sim/app/api/v2/workspaces/[workspaceId]/workflows/source/route.test.ts @@ -194,4 +194,14 @@ describe('POST /api/v2/workspaces/{workspaceId}/workflows/source', () => { expect(response.status).toBe(200) expect(mocks.create.mock.calls[0][0].input).toMatchObject({ dryRun: true }) }) + + it('treats the pre-rename ?dryRun as dry and answers under both names', async () => { + mocks.create.mockResolvedValue({ ...created, dryRun: true, applied: false }) + + const response = await POST(createRequest({ files }, '?dryRun=true'), context) + + expect(response.status).toBe(200) + expect(mocks.create.mock.calls[0][0].input).toMatchObject({ dryRun: true }) + expect((await response.json()).data).toMatchObject({ dry: true, dryRun: true }) + }) }) diff --git a/apps/sim/lib/api/contracts/v2/deprecated-names.ts b/apps/sim/lib/api/contracts/v2/deprecated-names.ts new file mode 100644 index 00000000000..c29f3a2b671 --- /dev/null +++ b/apps/sim/lib/api/contracts/v2/deprecated-names.ts @@ -0,0 +1,58 @@ +import { z } from 'zod' + +/** + * Deprecated names on the public v2 surface. A field, query parameter or value renamed after it + * shipped keeps its old name as an alias, so a client written against the earlier name keeps + * working: a request alias is folded into the current name at parse time (routes and use cases + * only ever see the current one), and a renamed response field is sent under both names. + */ + +/** A request field kept under its old name: same meaning as `current`, marked deprecated. */ +export function deprecatedRequestName(current: string, schema: S): S { + return schema.meta({ + deprecated: true, + description: `Deprecated name of \`${current}\`, accepted with the same meaning. Send \`${current}\`; a request that sends both with different values is refused.`, + }) +} + +/** A response field still sent under its old name: always equal to `current`, marked deprecated. */ +function deprecatedResponseName(current: string, schema: S): S { + return schema.meta({ + deprecated: true, + description: `Deprecated name of \`${current}\`, always sent with the same value. Read \`${current}\`.`, + }) +} + +/** + * Folds the deprecated `old` field of an object into `current` and drops it from the parsed + * value. Sending only `old` acts exactly as sending `current`; sending both is refused unless + * they agree. + */ +export function foldDeprecatedName< + S extends z.ZodType>, + Old extends keyof z.output & string, + Current extends keyof z.output & string, +>(schema: S, old: Old, current: Current) { + return schema.transform((value, ctx): Omit, Old> => { + const { [old]: legacy, ...rest } = value + if (legacy === undefined) return rest + const given: unknown = value[current] + if (given !== undefined && given !== legacy) { + ctx.addIssue({ + code: 'custom', + path: [old], + message: `${old} is the deprecated name of ${current}; send only ${current}`, + }) + return z.NEVER + } + return { ...rest, [current]: legacy } + }) +} + +/** Both names of a dry-run flag in a response: `dry`, and the deprecated `dryRun`. */ +export function presentDry(dry: boolean): { dry: boolean; dryRun: boolean } { + return { dry, dryRun: dry } +} + +/** The deprecated `dryRun` response field beside `dry`. */ +export const deprecatedDryRunResponseField = deprecatedResponseName('dry', z.boolean()) diff --git a/apps/sim/lib/api/contracts/v2/openapi/workflow-source.ts b/apps/sim/lib/api/contracts/v2/openapi/workflow-source.ts index c71855ee100..d1a09326ce9 100644 --- a/apps/sim/lib/api/contracts/v2/openapi/workflow-source.ts +++ b/apps/sim/lib/api/contracts/v2/openapi/workflow-source.ts @@ -116,6 +116,7 @@ export const workflowSourceOpenApiRoutes = [ workflowId: WORKFLOW_SOURCE_EXAMPLE.workflowId, workspaceId: WORKFLOW_SOURCE_EXAMPLE.workspaceId, dry: false, + dryRun: false, applied: false, diff: { noop: true, @@ -180,6 +181,7 @@ export const workflowSourceOpenApiRoutes = [ workflowId: WORKFLOW_SOURCE_EXAMPLE.workflowId, workspaceId: WORKFLOW_SOURCE_EXAMPLE.workspaceId, dry: true, + dryRun: true, applied: false, diff: { noop: true, @@ -243,6 +245,7 @@ export const workflowSourceOpenApiRoutes = [ workflowId: WORKFLOW_SOURCE_EXAMPLE.workflowId, workspaceId: WORKFLOW_SOURCE_EXAMPLE.workspaceId, dry: false, + dryRun: false, applied: true, diff: { noop: false, diff --git a/apps/sim/lib/api/contracts/v2/openapi/workflows.ts b/apps/sim/lib/api/contracts/v2/openapi/workflows.ts index 0c9acfd0ce7..f88c2890bf2 100644 --- a/apps/sim/lib/api/contracts/v2/openapi/workflows.ts +++ b/apps/sim/lib/api/contracts/v2/openapi/workflows.ts @@ -429,6 +429,7 @@ const declaredRoutes = [ warnings: [], needsRedeployment: true, dry: false, + dryRun: false, lint: EMPTY_LINT_EXAMPLE, }, }, @@ -507,6 +508,7 @@ const declaredRoutes = [ ], needsRedeployment: true, dry: false, + dryRun: false, }, }, ] diff --git a/apps/sim/lib/api/contracts/v2/openapi/workspace-source.ts b/apps/sim/lib/api/contracts/v2/openapi/workspace-source.ts index d4f12a047fa..5a0775f087a 100644 --- a/apps/sim/lib/api/contracts/v2/openapi/workspace-source.ts +++ b/apps/sim/lib/api/contracts/v2/openapi/workspace-source.ts @@ -138,6 +138,7 @@ export const workspaceSourceOpenApiRoutes = [ data: { workspaceId: WORKSPACE_ID, dry: false, + dryRun: false, plan: [{ kind: 'table', key: 'leads', action: 'noop', id: TABLE_ID }], applied: [], needBlobs: [], @@ -192,6 +193,7 @@ export const workspaceSourceOpenApiRoutes = [ data: { workspaceId: WORKSPACE_ID, dry: true, + dryRun: true, plan: [{ kind: 'table', key: 'leads', action: 'noop', id: TABLE_ID }], applied: [], needBlobs: [], diff --git a/apps/sim/lib/api/contracts/v2/workflow-graph.test.ts b/apps/sim/lib/api/contracts/v2/workflow-graph.test.ts index 66ddaef2bad..979eeab115f 100644 --- a/apps/sim/lib/api/contracts/v2/workflow-graph.test.ts +++ b/apps/sim/lib/api/contracts/v2/workflow-graph.test.ts @@ -189,6 +189,7 @@ describe('v2ApplyWorkflowOperationsDataSchema', () => { mintedBlockIds: {}, lint: EMPTY_LINT, dry: false, + dryRun: false, }) expect(result.success, `skip type ${type} is not published`).toBe(true) } @@ -211,6 +212,7 @@ describe('v2ApplyWorkflowOperationsDataSchema', () => { mintedBlockIds: {}, lint: FULL_LINT, dry: false, + dryRun: false, }) expect(result.error?.issues ?? []).toEqual([]) diff --git a/apps/sim/lib/api/contracts/v2/workflow-source.ts b/apps/sim/lib/api/contracts/v2/workflow-source.ts index cb219df898f..e5b77bada1a 100644 --- a/apps/sim/lib/api/contracts/v2/workflow-source.ts +++ b/apps/sim/lib/api/contracts/v2/workflow-source.ts @@ -3,6 +3,11 @@ import { SOURCE_ENTRY_FILE, SOURCE_LIMITS } from '@sim/workflow-code/limits' import { z } from 'zod' import { booleanQueryFlagSchema, workspaceIdSchema } from '@/lib/api/contracts/primitives' import { defineRouteContract } from '@/lib/api/contracts/types' +import { + deprecatedDryRunResponseField, + deprecatedRequestName, + foldDeprecatedName, +} from '@/lib/api/contracts/v2/deprecated-names' import { v2DataResponse, v2FolderPathInputSchema } from '@/lib/api/contracts/v2/shared' import { v2WorkflowIdParamsSchema } from '@/lib/api/contracts/v2/workflows' import { @@ -22,20 +27,25 @@ export const v2GetWorkflowSourceContract = defineRouteContract({ response: { mode: 'json', schema: v2DataResponse(workflowSourceSchema) }, }) -const applyWorkflowSourceQuerySchema = z - .object({ - dry: booleanQueryFlagSchema - .optional() - .describe( - 'Run every check without writing, auditing, or notifying collaborators. Findings, errors included, come back in `diagnostics` with `applied: false` and a `200`, and the files, lock and fingerprint show what a committed apply would store. A request refused before the source is evaluated (an invalid or oversized body, a locked workflow or folder) gets the same status as without `dry`, and a create under a taken name answers `409`.' - ), - allowDelete: booleanQueryFlagSchema - .optional() - .describe( - 'Allow the apply to delete blocks and variables the source no longer declares. Without it, an apply that would delete any block is refused with `E_APPLY_BLOCK_DELETE`, and one that would delete any variable with `E_APPLY_VARIABLE_DELETE`, naming them. Ignored when creating a workflow.' - ), - }) - .strict() +const applyWorkflowSourceQuerySchema = foldDeprecatedName( + z + .object({ + dry: booleanQueryFlagSchema + .optional() + .describe( + 'Run every check without writing, auditing, or notifying collaborators. Findings, errors included, come back in `diagnostics` with `applied: false` and a `200`, and the files, lock and fingerprint show what a committed apply would store. A request refused before the source is evaluated (an invalid or oversized body, a locked workflow or folder) gets the same status as without `dry`, and a create under a taken name answers `409`.' + ), + allowDelete: booleanQueryFlagSchema + .optional() + .describe( + 'Allow the apply to delete blocks and variables the source no longer declares. Without it, an apply that would delete any block is refused with `E_APPLY_BLOCK_DELETE`, and one that would delete any variable with `E_APPLY_VARIABLE_DELETE`, naming them. Ignored when creating a workflow.' + ), + dryRun: deprecatedRequestName('dry', booleanQueryFlagSchema.optional()), + }) + .strict(), + 'dryRun', + 'dry' +) /** Longest path a source file may have, in a workflow's source and in a workspace's alike. */ export const SOURCE_PATH_MAX_LENGTH = 1024 @@ -231,6 +241,7 @@ const applyWorkflowSourceDataSchema = z workflowId: z.string().describe('Workflow id.'), workspaceId: z.string().describe('Workspace id.'), dry: z.boolean().describe('True when nothing was written because `dry` was set.'), + dryRun: deprecatedDryRunResponseField, applied: z .boolean() .describe( diff --git a/apps/sim/lib/api/contracts/v2/workflows.ts b/apps/sim/lib/api/contracts/v2/workflows.ts index ac1d89cbddc..b54c78ed4bb 100644 --- a/apps/sim/lib/api/contracts/v2/workflows.ts +++ b/apps/sim/lib/api/contracts/v2/workflows.ts @@ -33,6 +33,11 @@ import { v1RollbackWorkflowBodySchema, v1WorkflowExportPayloadSchema, } from '@/lib/api/contracts/v1/workflows' +import { + deprecatedDryRunResponseField, + deprecatedRequestName, + foldDeprecatedName, +} from '@/lib/api/contracts/v2/deprecated-names' import { V2_FOLDER_FILTER_MISS, v2CreateFolderBodySchema, @@ -1655,29 +1660,37 @@ export const v2WorkflowRunSelectionSchema = z.discriminatedUnion('source', [ .strict(), z .object({ - source: z.literal('draft').describe('Run the saved draft.'), + source: z + .enum(['draft', 'manual']) + .transform((): 'draft' => 'draft') + .describe('Run the saved draft. `manual` is a deprecated name of `draft`.'), entry: z .discriminatedUnion('type', [ - z - .object({ - type: z - .literal('trigger') - .describe('Enter the draft run through a runnable trigger.'), - blockId: z - .string() - .min(1, 'run.entry.blockId cannot be empty') - .optional() - .describe( - 'Runnable trigger block to enter through. Omit only when the saved workflow has exactly one runnable trigger.' - ), - sample: z - .boolean() - .optional() - .describe( - "Run with the selected trigger's sample payload, which the server derives from the trigger, instead of `input`. Its writes are sent unless `dry`. Cannot be combined with `input`." - ), - }) - .strict(), + foldDeprecatedName( + z + .object({ + type: z + .literal('trigger') + .describe('Enter the draft run through a runnable trigger.'), + blockId: z + .string() + .min(1, 'run.entry.blockId cannot be empty') + .optional() + .describe( + 'Runnable trigger block to enter through. Omit only when the saved workflow has exactly one runnable trigger.' + ), + sample: z + .boolean() + .optional() + .describe( + "Run with the selected trigger's sample payload, which the server derives from the trigger, instead of `input`. Its writes are sent unless `dry`. Cannot be combined with `input`." + ), + useMockPayload: deprecatedRequestName('sample', z.boolean().optional()), + }) + .strict(), + 'useMockPayload', + 'sample' + ), z .object({ type: z @@ -3739,15 +3752,20 @@ const v2WorkflowGraphWriteResultSchema = z * (`validateOnly`) both keep it outside the represented resource for the same * reason. */ -const v2GraphWriteDryQuerySchema = z - .object({ - dry: booleanQueryFlagSchema - .optional() - .describe( - 'Validate and lint without writing, auditing, or notifying collaborators. Returns the same validation, preparation warnings, lint findings, and ID-ownership conflicts (`409`) as a committed write. `needsRedeployment` describes the pre-write state. For semantic operations, `mintedBlockIds` is empty; `previewBlockIds` contains provisional IDs with a warning, since committing mints new IDs.' - ), - }) - .strict() +const v2GraphWriteDryQuerySchema = foldDeprecatedName( + z + .object({ + dry: booleanQueryFlagSchema + .optional() + .describe( + 'Validate and lint without writing, auditing, or notifying collaborators. Returns the same validation, preparation warnings, lint findings, and ID-ownership conflicts (`409`) as a committed write. `needsRedeployment` describes the pre-write state. For semantic operations, `mintedBlockIds` is empty; `previewBlockIds` contains provisional IDs with a warning, since committing mints new IDs.' + ), + dryRun: deprecatedRequestName('dry', booleanQueryFlagSchema.optional()), + }) + .strict(), + 'dryRun', + 'dry' +) export const v2ReplaceWorkflowStateDataSchema = v2WorkflowGraphWriteResultSchema .extend({ @@ -3757,6 +3775,7 @@ export const v2ReplaceWorkflowStateDataSchema = v2WorkflowGraphWriteResultSchema .describe( 'Whether this request only validated. `true` means nothing was persisted; the findings describe what a committed write of the same body would produce.' ), + dryRun: deprecatedDryRunResponseField, }) .meta({ id: 'ReplaceWorkflowStateResult', @@ -4489,6 +4508,7 @@ export const v2ApplyWorkflowOperationsDataSchema = v2WorkflowGraphWriteResultSch .describe( 'Whether this request only evaluated. `true` means nothing was persisted; the outcome describes what a committed apply of the same body would produce.' ), + dryRun: deprecatedDryRunResponseField, }) .meta({ id: 'ApplyWorkflowOperationsResult', diff --git a/apps/sim/lib/api/contracts/v2/workspace-source.ts b/apps/sim/lib/api/contracts/v2/workspace-source.ts index 3a56c277e24..b91c0a7e614 100644 --- a/apps/sim/lib/api/contracts/v2/workspace-source.ts +++ b/apps/sim/lib/api/contracts/v2/workspace-source.ts @@ -10,6 +10,11 @@ import { workspaceIdSchema, } from '@/lib/api/contracts/primitives' import { defineRouteContract } from '@/lib/api/contracts/types' +import { + deprecatedDryRunResponseField, + deprecatedRequestName, + foldDeprecatedName, +} from '@/lib/api/contracts/v2/deprecated-names' import { v2DataResponse } from '@/lib/api/contracts/v2/shared' import { provenanceGitShaSchema, @@ -237,15 +242,20 @@ export const v2GetWorkspaceSourceContract = defineRouteContract({ response: { mode: 'json', schema: v2DataResponse(readDataSchema) }, }) -const applyQuerySchema = z - .object({ - dry: booleanQueryFlagSchema - .optional() - .describe( - 'Plan, check and authorize every change without writing. Findings, errors included, come back in `diagnostics` with a `200`.' - ), - }) - .strict() +const applyQuerySchema = foldDeprecatedName( + z + .object({ + dry: booleanQueryFlagSchema + .optional() + .describe( + 'Plan, check and authorize every change without writing. Findings, errors included, come back in `diagnostics` with a `200`.' + ), + dryRun: deprecatedRequestName('dry', booleanQueryFlagSchema.optional()), + }) + .strict(), + 'dryRun', + 'dry' +) const applyBodySchema = z .object({ @@ -300,6 +310,7 @@ const applyDataSchema = z .object({ workspaceId: z.string().describe('Workspace id.'), dry: z.boolean().describe('True when nothing was written because `dry` was set.'), + dryRun: deprecatedDryRunResponseField, plan: z.array(changeSchema).describe('Every planned change, no-ops included, in apply order.'), refuses: z .boolean() diff --git a/apps/sim/lib/api/server/routes/v2-json-route.ts b/apps/sim/lib/api/server/routes/v2-json-route.ts index 719f3a1cefe..60ba56870a0 100644 --- a/apps/sim/lib/api/server/routes/v2-json-route.ts +++ b/apps/sim/lib/api/server/routes/v2-json-route.ts @@ -196,10 +196,15 @@ const V2_SOURCE_PLAN_RATE_LIMIT: TokenBucketConfig = { refillIntervalMs: 60_000, } -/** Whether `request` asks for a dry run (`?dry=true`), as the source apply contract reads it. */ +/** + * Whether `request` asks for a dry run (`?dry=true`, or its deprecated name `?dryRun=true`), as + * the source apply contract reads it. It runs before the query is parsed, so a request naming + * both with different values is charged here and refused by the parse. + */ function isDryRequest(request: NextRequest): boolean { + const { searchParams } = request.nextUrl const flag = booleanQueryFlagSchema.safeParse( - request.nextUrl.searchParams.get('dry') ?? undefined + searchParams.get('dry') ?? searchParams.get('dryRun') ?? undefined ) return flag.success && flag.data } diff --git a/apps/sim/lib/workflows/api/deprecated-names.integration.ts b/apps/sim/lib/workflows/api/deprecated-names.integration.ts new file mode 100644 index 00000000000..2af9e92c6e9 --- /dev/null +++ b/apps/sim/lib/workflows/api/deprecated-names.integration.ts @@ -0,0 +1,270 @@ +/** + * The v2 names clients used before they were renamed, against real PostgreSQL, over HTTP and over + * the Sim MCP server (whose call tools dispatch through the same routes). `?dryRun=true` must stay + * a dry run on `PUT /state` and `POST /operations`: the response says so under both names and no + * block row is written; a request whose two names disagree is refused without a write. An execute + * naming `run.source: "manual"` with `run.entry.useMockPayload` runs the saved draft with the + * trigger's sample payload. + */ +import { db } from '@sim/db' +import { apiKey, permissions, user, workflow, workflowBlocks, workspace } from '@sim/db/schema' +import { deleteWorkspaceFixture, insertWorkspaceFixture } from '@sim/db/testing/workspace-fixtures' +import { generateId } from '@sim/utils/id' +import { eq } from 'drizzle-orm' +import { NextRequest } from 'next/server' +import { afterAll, beforeAll, describe, expect, it } from 'vitest' +import { hashApiKey } from '@/lib/api-key/crypto' +import { POST as simMcpPost } from '@/app/api/mcp/route' +import { POST as executeWorkflow } from '@/app/api/v2/workflows/[workflowId]/execute/route' +import { POST as applyOperations } from '@/app/api/v2/workflows/[workflowId]/operations/route' +import { PUT as replaceState } from '@/app/api/v2/workflows/[workflowId]/state/route' + +const ORIGIN = 'http://localhost:3000' +const userId = generateId() +const workspaceId = generateId() +const workflowId = generateId() +const personalKey = `sk-sim-fixture-${generateId()}` + +type RouteHandler = ( + request: NextRequest, + context: { params: Promise<{ workflowId: string }> } +) => Promise + +async function call(handler: unknown, method: string, path: string, body: unknown) { + const response = await (handler as RouteHandler)( + new NextRequest(`${ORIGIN}${path}`, { + method, + headers: { + 'x-forwarded-for': '127.0.0.1', + 'x-api-key': personalKey, + 'content-type': 'application/json', + accept: 'application/json, text/event-stream', + }, + body: JSON.stringify(body), + }), + { params: Promise.resolve({ workflowId }) } + ) + return { status: response.status, body: await response.json() } +} + +function graphWith(blockId: string, name: string) { + return { + blocks: { + [blockId]: { + id: blockId, + type: 'function', + name, + position: { x: 0, y: 0 }, + subBlocks: { code: { id: 'code', type: 'code', value: 'return 1' } }, + outputs: {}, + enabled: true, + }, + }, + edges: [], + } +} + +/** A Sim MCP `call_write_operation` call, answered with its tool result text. */ +async function callOverMcp(args: Record): Promise { + const response = await call(simMcpPost, 'POST', '/api/mcp', { + jsonrpc: '2.0', + id: 1, + method: 'tools/call', + params: { name: 'call_write_operation', arguments: args }, + }) + expect(response.status).toBe(200) + return JSON.stringify(response.body) +} + +const startId = generateId() +const doneId = generateId() + +/** A start trigger whose input field has a sample value, answered by a Response block. */ +const runnableGraph = { + blocks: { + [startId]: { + id: startId, + type: 'start_trigger', + name: 'Start', + position: { x: 0, y: 0 }, + subBlocks: { + inputFormat: { + id: 'inputFormat', + type: 'input-format', + value: [{ id: 'topic', name: 'topic', type: 'string', value: 'sample-topic' }], + }, + }, + outputs: {}, + enabled: true, + }, + [doneId]: { + id: doneId, + type: 'response', + name: 'Done', + position: { x: 300, y: 0 }, + subBlocks: { + dataMode: { id: 'dataMode', type: 'dropdown', value: 'json' }, + data: { id: 'data', type: 'code', value: '{"topic": ""}' }, + status: { id: 'status', type: 'short-input', value: '200' }, + }, + outputs: {}, + enabled: true, + }, + }, + edges: [{ id: generateId(), source: startId, target: doneId }], +} + +const legacyDraftRun = { + run: { source: 'manual', entry: { type: 'trigger', useMockPayload: true } }, +} + +async function blockNames(): Promise { + const rows = await db + .select({ name: workflowBlocks.name }) + .from(workflowBlocks) + .where(eq(workflowBlocks.workflowId, workflowId)) + return rows.map((row) => row.name).sort() +} + +const statePath = `/api/v2/workflows/${workflowId}/state` +const operationsPath = `/api/v2/workflows/${workflowId}/operations` + +describe('pre-rename v2 names in PostgreSQL', () => { + let committedData: unknown + beforeAll(async () => { + const now = new Date() + await db.insert(user).values({ + id: userId, + name: 'Deprecated names fixture', + email: `${userId}@deprecated-names.test`, + emailVerified: true, + createdAt: now, + updatedAt: now, + }) + await insertWorkspaceFixture(db, { + id: workspaceId, + name: 'Deprecated names fixture', + ownerId: userId, + billedAccountUserId: userId, + allowPersonalApiKeys: true, + }) + await db.insert(permissions).values({ + id: generateId(), + userId, + entityType: 'workspace', + entityId: workspaceId, + permissionType: 'admin', + }) + await db.insert(workflow).values({ + id: workflowId, + userId, + workspaceId, + name: 'Deprecated names fixture', + lastSynced: now, + createdAt: now, + updatedAt: now, + }) + await db.insert(apiKey).values({ + id: generateId(), + userId, + name: 'Full access', + key: personalKey, + keyHash: hashApiKey(personalKey), + type: 'personal', + }) + + const committed = await call(replaceState, 'PUT', statePath, runnableGraph) + expect(committed.status).toBe(200) + committedData = committed.body.data + }) + + afterAll(async () => { + await deleteWorkspaceFixture(db, eq(workspace.id, workspaceId)) + await db.delete(user).where(eq(user.id, userId)) + await db.$client.end() + }) + + it('answers a committed write with dryRun beside dry, and persists it', async () => { + expect(committedData).toMatchObject({ dry: false, dryRun: false }) + expect(await blockNames()).toEqual(['Done', 'Start']) + }) + + it('validates PUT /state?dryRun=true without persisting, answering dry under both names', async () => { + const response = await call( + replaceState, + 'PUT', + `${statePath}?dryRun=true`, + graphWith(generateId(), 'Proposed') + ) + + expect(response.status).toBe(200) + expect(response.body.data).toMatchObject({ dry: true, dryRun: true }) + expect(await blockNames()).toEqual(['Done', 'Start']) + }) + + it('evaluates POST /operations?dryRun=true without persisting, answering dry under both names', async () => { + const response = await call(applyOperations, 'POST', `${operationsPath}?dryRun=true`, { + operations: [ + { + operation_type: 'add', + block_id: 'proposed-fn', + params: { type: 'function', name: 'Proposed', inputs: { code: 'return 2' } }, + }, + ], + }) + + expect(response.status).toBe(200) + expect(response.body.data).toMatchObject({ dry: true, dryRun: true }) + expect(await blockNames()).toEqual(['Done', 'Start']) + }) + + it('refuses ?dry and ?dryRun that disagree, without writing', async () => { + const response = await call( + replaceState, + 'PUT', + `${statePath}?dry=false&dryRun=true`, + graphWith(generateId(), 'Conflicting') + ) + + expect(response.status).toBe(400) + expect(JSON.stringify(response.body)).toContain('dryRun is the deprecated name of dry') + expect(await blockNames()).toEqual(['Done', 'Start']) + }) + + it('validates replaceWorkflowState with dryRun over MCP without persisting', async () => { + const text = await callOverMcp({ + operation: 'replaceWorkflowState', + params: { workflowId }, + query: { dryRun: true }, + body: graphWith(generateId(), 'Proposed'), + }) + + expect(text).toContain('\\"dry\\":true') + expect(text).toContain('\\"dryRun\\":true') + expect(await blockNames()).toEqual(['Done', 'Start']) + }) + + it('runs source manual with entry.useMockPayload as a draft run with the sample payload', async () => { + const response = await call( + executeWorkflow, + 'POST', + `/api/v2/workflows/${workflowId}/execute`, + legacyDraftRun + ) + + expect(response.status, JSON.stringify(response.body)).toBe(200) + expect(response.body.data.status).toBe('completed') + expect(JSON.stringify(response.body.data.output)).toContain('sample-topic') + }) + + it('runs the same pre-rename draft run over MCP', async () => { + const text = await callOverMcp({ + operation: 'executeWorkflow', + params: { workflowId }, + body: legacyDraftRun, + }) + + expect(text).toContain('sample-topic') + expect(text).not.toContain('isError') + }) +}) diff --git a/apps/sim/lib/workflows/api/source-presenters.ts b/apps/sim/lib/workflows/api/source-presenters.ts index aa2fef47034..fa8e9e14b0a 100644 --- a/apps/sim/lib/workflows/api/source-presenters.ts +++ b/apps/sim/lib/workflows/api/source-presenters.ts @@ -1,5 +1,6 @@ import { boundAnswerFindings } from '@sim/workflow-code/diagnostics' import type { ContractJsonResponse } from '@/lib/api/contracts/types' +import { presentDry } from '@/lib/api/contracts/v2/deprecated-names' import type { v2ApplyWorkflowSourceContract } from '@/lib/api/contracts/v2/workflow-source' import type { SourceOutcome } from '@/lib/workflows/application/source-pipeline' @@ -15,7 +16,7 @@ export function presentSourceOutcome(outcome: SourceOutcome): SourceOutcomeData return { workflowId: outcome.workflowId, workspaceId: outcome.workspaceId, - dry: outcome.dryRun, + ...presentDry(outcome.dryRun), applied: outcome.applied, diff: outcome.diff, diagnostics: boundAnswerFindings(outcome.diagnostics), diff --git a/apps/sim/lib/workspace-source/api/route-policies.ts b/apps/sim/lib/workspace-source/api/route-policies.ts index 2a8d31b98ee..3677a618e86 100644 --- a/apps/sim/lib/workspace-source/api/route-policies.ts +++ b/apps/sim/lib/workspace-source/api/route-policies.ts @@ -5,6 +5,7 @@ import { KIND_LAYOUTS } from '@sim/workspace-code/kinds/registry' import { workflowCodec, workflowFolder } from '@sim/workspace-code/kinds/workflow' import { kindOfPath } from '@sim/workspace-code/layout' import { WORKSPACE_SOURCE_LIMITS } from '@sim/workspace-code/limits' +import { presentDry } from '@/lib/api/contracts/v2/deprecated-names' import { createV2ResourceConcealmentPolicy } from '@/lib/api/server/routes' import { renderSourceSlotBusy } from '@/lib/workflows/api/source-slots' import type { ApplyWorkspaceSourceResult } from '@/lib/workspace-source/application/apply-workspace-source' @@ -56,9 +57,9 @@ export function withBoundWorkspaceFindings< return { ...result, diagnostics: boundAnswerFindings(result.diagnostics, WORKSPACE_ANSWER_BOUND) } } -/** An apply's or plan's result as the routes answer it: {@link withBoundWorkspaceFindings}, with `dry`. */ +/** An apply's or plan's result as the routes answer it: {@link withBoundWorkspaceFindings}, with `dry` (and its deprecated name `dryRun`). */ export function presentWorkspaceApply({ dryRun, ...result }: ApplyWorkspaceSourceResult) { - return { ...withBoundWorkspaceFindings(result), dry: dryRun } + return { ...withBoundWorkspaceFindings(result), ...presentDry(dryRun) } } /** Non-workflow text bytes (declarations and table rows) one source-write unit covers. */ diff --git a/packages/sim-cli/src/generated/v2-api.ts b/packages/sim-cli/src/generated/v2-api.ts index 34563ccf469..0f5cb641fb4 100644 --- a/packages/sim-cli/src/generated/v2-api.ts +++ b/packages/sim-cli/src/generated/v2-api.ts @@ -436,6 +436,7 @@ export type ApplyWorkflowOperationsParams = { export type ApplyWorkflowOperationsQuery = { dry?: boolean + dryRun?: boolean } type ApplyWorkflowOperationsBodyRef0 = @@ -708,6 +709,7 @@ type ApplyWorkflowOperationsResponseRef3 = { previewBlockIds?: Record lint: ApplyWorkflowOperationsResponseRef2 dry: boolean + dryRun: boolean } export type ApplyWorkflowOperationsResponse = { @@ -722,6 +724,7 @@ export type ApplyWorkflowSourceParams = { export type ApplyWorkflowSourceQuery = { dry?: boolean allowDelete?: boolean + dryRun?: boolean } export type ApplyWorkflowSourceBody = { @@ -779,6 +782,7 @@ export type ApplyWorkflowSourceResponse = { workflowId: string workspaceId: string dry: boolean + dryRun: boolean applied: boolean diff: { noop: boolean @@ -1092,6 +1096,7 @@ export type ApplyWorkspaceSourceParams = { export type ApplyWorkspaceSourceQuery = { dry?: boolean + dryRun?: boolean } export type ApplyWorkspaceSourceBody = { @@ -1172,6 +1177,7 @@ export type ApplyWorkspaceSourceResponse = { data: { workspaceId: string dry: boolean + dryRun: boolean plan: Array<{ kind: | 'secret' @@ -5241,6 +5247,7 @@ export type CreateWorkflowFromSourceParams = { export type CreateWorkflowFromSourceQuery = { dry?: boolean allowDelete?: boolean + dryRun?: boolean } type CreateWorkflowFromSourceBodyRef0 = string @@ -5262,6 +5269,7 @@ export type CreateWorkflowFromSourceResponse = { workflowId: string workspaceId: string dry: boolean + dryRun: boolean applied: boolean diff: { noop: boolean @@ -7115,12 +7123,13 @@ export type ExecuteWorkflowBody = { version?: number } | { - source: 'draft' + source: 'draft' | 'manual' entry?: | { type: 'trigger' blockId?: string sample?: boolean + useMockPayload?: boolean } | { type: 'block' @@ -14527,6 +14536,7 @@ export type PlanWorkflowSourceResponse = { workflowId: string workspaceId: string dry: boolean + dryRun: boolean applied: boolean diff: { noop: boolean @@ -14875,6 +14885,7 @@ export type PlanWorkspaceSourceResponse = { data: { workspaceId: string dry: boolean + dryRun: boolean plan: Array<{ kind: | 'secret' @@ -17268,6 +17279,7 @@ export type ReplaceWorkflowStateParams = { export type ReplaceWorkflowStateQuery = { dry?: boolean + dryRun?: boolean } type ReplaceWorkflowStateBodyRef0 = { @@ -17451,6 +17463,7 @@ type ReplaceWorkflowStateResponseRef1 = { needsRedeployment: boolean lint: ReplaceWorkflowStateResponseRef0 dry: boolean + dryRun: boolean } export type ReplaceWorkflowStateResponse = { diff --git a/scripts/generate-v2-cli-api.ts b/scripts/generate-v2-cli-api.ts index e01fa9f5c25..4ab72deb455 100644 --- a/scripts/generate-v2-cli-api.ts +++ b/scripts/generate-v2-cli-api.ts @@ -477,7 +477,11 @@ export function renderSlotMap( } } - const keys = Object.keys(properties).filter((key) => !exclude?.has(key)) + // A deprecated name the server still accepts for older clients gets no flag: the CLI sends the + // current name only. + const keys = Object.keys(properties).filter( + (key) => !exclude?.has(key) && deref(properties[key]).deprecated !== true + ) // A union body (e.g. single-row vs batch insert) has no flat field list. The // caller marks it `opaqueBody` so the runtime can offer the whole body as one diff --git a/scripts/openapi/generator.ts b/scripts/openapi/generator.ts index 6d375bade73..ad866fbc2e2 100644 --- a/scripts/openapi/generator.ts +++ b/scripts/openapi/generator.ts @@ -322,6 +322,7 @@ function parametersFor( name, in: location, required: location === 'path' || required.has(name), + ...((property as JsonObject).deprecated === true ? { deprecated: true } : {}), description, schema: property, }