Skip to content

Commit ecd89c4

Browse files
fix(workflows): complete application boundary migration
1 parent 0d31401 commit ecd89c4

88 files changed

Lines changed: 5951 additions & 5503 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/sim/app/api/chat/manage/[id]/route.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@ import { isDev } from '@/lib/core/config/env-flags'
1212
import { encryptSecret } from '@/lib/core/security/encryption'
1313
import { getEmailDomain } from '@/lib/core/utils/urls'
1414
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
15+
import { checkNeedsRedeployment } from '@/lib/workflows/deployment-status'
1516
import {
1617
getWorkflowDeploymentSummary,
1718
performChatUndeploy,
1819
performFullDeploy,
1920
} from '@/lib/workflows/orchestration'
2021
import { checkChatAccess } from '@/app/api/chat/utils'
21-
import {
22-
checkNeedsRedeployment,
23-
createErrorResponse,
24-
createSuccessResponse,
25-
} from '@/app/api/workflows/utils'
22+
import { createErrorResponse, createSuccessResponse } from '@/app/api/workflows/utils'
2623
import {
2724
ChatDeployAuthNotAllowedError,
2825
validateChatDeployAuth,

apps/sim/app/api/v2/workflows/[id]/deploy/route.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const mocks = vi.hoisted(() => ({
1010

1111
vi.mock('@/lib/api/server/routes', () => ({
1212
createInternalSessionOrExecutorAuth: vi.fn(() => ({ kind: 'internal-workflow' })),
13+
createV2ResourceConcealmentPolicy: vi.fn(() => ({ kind: 'conceal-workflow' })),
1314
defineV2JsonRoute: mocks.defineRoute,
1415
v2ApiKeyAuth: { kind: 'v2-api-key' },
1516
v2RateLimits: { publicApi: { kind: 'public-api' } },
@@ -40,7 +41,6 @@ describe('/api/v2/workflows/[id]/deploy route definitions', () => {
4041
workflowId: 'workflow-1',
4142
name: undefined,
4243
description: undefined,
43-
analytics: 'human',
4444
})
4545
)
4646

apps/sim/app/api/v2/workflows/[id]/deploy/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const POST = defineV2JsonRoute({
3030
name: body.name,
3131
description: body.description ?? undefined,
3232
requestId: generateRequestId(),
33-
analytics: 'human' as const,
3433
}),
3534
useCase: deployWorkflow,
3635
present: (result) => ({

apps/sim/app/api/v2/workflows/[id]/execute/route.test.ts

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,22 @@ describe('POST /api/v2/workflows/[id]/execute', () => {
236236
rateLimitSubscription: null,
237237
keyType: 'workspace',
238238
})
239-
dbChainMockFns.limit.mockResolvedValue([applicationContext])
239+
dbChainMockFns.limit
240+
.mockResolvedValueOnce([
241+
{
242+
workflowId: workflowRecord.id,
243+
workflow: workflowRecord,
244+
workspaceId: workflowRecord.workspaceId,
245+
},
246+
])
247+
.mockResolvedValueOnce([
248+
{
249+
id: applicationContext.workspaceId,
250+
organizationId: applicationContext.workspaceOrganizationId,
251+
allowPersonalApiKeys: applicationContext.allowPersonalApiKeys,
252+
billedAccountUserId: applicationContext.billedAccountUserId,
253+
},
254+
])
240255
mockAuthorize.mockResolvedValue({ allowed: true, workflow: workflowRecord })
241256
mockClaimExecutionId.mockImplementation(async (executionId: string) => ({
242257
key: `workflow-execution-id:${executionId}`,
@@ -420,9 +435,23 @@ describe('POST /api/v2/workflows/[id]/execute', () => {
420435
rateLimitSubscription: null,
421436
keyType: 'personal',
422437
})
423-
dbChainMockFns.limit.mockResolvedValueOnce([
424-
{ ...applicationContext, allowPersonalApiKeys: false },
425-
])
438+
dbChainMockFns.limit.mockReset()
439+
dbChainMockFns.limit
440+
.mockResolvedValueOnce([
441+
{
442+
workflowId: workflowRecord.id,
443+
workflow: workflowRecord,
444+
workspaceId: workflowRecord.workspaceId,
445+
},
446+
])
447+
.mockResolvedValueOnce([
448+
{
449+
id: applicationContext.workspaceId,
450+
organizationId: applicationContext.workspaceOrganizationId,
451+
allowPersonalApiKeys: false,
452+
billedAccountUserId: applicationContext.billedAccountUserId,
453+
},
454+
])
426455

427456
const res = await callExecute({ input: {} })
428457

@@ -487,6 +516,7 @@ describe('POST /api/v2/workflows/[id]/execute', () => {
487516
})
488517

489518
it('runs the anonymous public path sync but refuses async', async () => {
519+
dbChainMockFns.limit.mockReset()
490520
dbChainMockFns.limit.mockResolvedValueOnce([
491521
{ isPublicApi: true, isDeployed: true, userId: 'owner-1', workspaceId: 'workspace-1' },
492522
])
@@ -526,6 +556,7 @@ describe('POST /api/v2/workflows/[id]/execute', () => {
526556
})
527557

528558
it('401s non-public workflows without a key', async () => {
559+
dbChainMockFns.limit.mockReset()
529560
dbChainMockFns.limit.mockResolvedValueOnce([
530561
{ isPublicApi: false, isDeployed: true, userId: 'owner-1', workspaceId: 'workspace-1' },
531562
])
@@ -551,6 +582,7 @@ describe('POST /api/v2/workflows/[id]/execute', () => {
551582
})
552583

553584
it('returns a safe error when canonical workflow lookup fails', async () => {
585+
dbChainMockFns.limit.mockReset()
554586
dbChainMockFns.limit.mockRejectedValueOnce(new Error('database connection details'))
555587

556588
const response = await callExecute({ input: {} })

apps/sim/app/api/v2/workflows/[id]/rollback/route.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const mocks = vi.hoisted(() => ({
99

1010
vi.mock('@/lib/api/server/routes', () => ({
1111
createInternalSessionOrExecutorAuth: vi.fn(() => ({ kind: 'internal-workflow' })),
12+
createV2ResourceConcealmentPolicy: vi.fn(() => ({ kind: 'conceal-workflow' })),
1213
defineV2JsonRoute: mocks.defineRoute,
1314
v2ApiKeyAuth: { kind: 'v2-api-key' },
1415
v2RateLimits: { publicApi: { kind: 'public-api' } },
@@ -35,7 +36,6 @@ describe('/api/v2/workflows/[id]/rollback route definition', () => {
3536
workflowId: 'workflow-1',
3637
version: undefined,
3738
transition: 'rollback',
38-
analytics: 'human',
3939
})
4040
)
4141

apps/sim/app/api/v2/workflows/[id]/rollback/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export const POST = defineV2JsonRoute({
2626
version: body.version,
2727
transition: 'rollback' as const,
2828
requestId: generateRequestId(),
29-
analytics: 'human' as const,
3029
}),
3130
useCase: activateWorkflowVersion,
3231
present: (result) => ({

0 commit comments

Comments
 (0)