( params: PerformFullDeployParams )
| 100 | * deploy tools must use this single function so behaviour stays consistent. |
| 101 | */ |
| 102 | export async function performFullDeploy( |
| 103 | params: PerformFullDeployParams |
| 104 | ): Promise<PerformFullDeployResult> { |
| 105 | const { workflowId, userId, workflowName } = params |
| 106 | const actorId = params.actorId ?? userId |
| 107 | const requestId = params.requestId ?? generateRequestId() |
| 108 | |
| 109 | const [workflowRecord] = await db |
| 110 | .select() |
| 111 | .from(workflowTable) |
| 112 | .where(eq(workflowTable.id, workflowId)) |
| 113 | .limit(1) |
| 114 | |
| 115 | if (!workflowRecord) { |
| 116 | return { success: false, error: 'Workflow not found', errorCode: 'not_found' } |
| 117 | } |
| 118 | |
| 119 | const workflowData = workflowRecord as Record<string, unknown> |
| 120 | let outboxEventId: string | undefined |
| 121 | |
| 122 | const deployResult = await deployWorkflow({ |
| 123 | workflowId, |
| 124 | deployedBy: actorId, |
| 125 | workflowName: workflowName || workflowRecord.name || undefined, |
| 126 | description: params.versionDescription, |
| 127 | name: params.versionName, |
| 128 | validateWorkflowState: async (workflowState, executor) => { |
| 129 | const scheduleValidation = validateWorkflowSchedules(workflowState.blocks) |
| 130 | if (!scheduleValidation.isValid) { |
| 131 | return { |
| 132 | success: false, |
| 133 | error: `Invalid schedule configuration: ${scheduleValidation.error}`, |
| 134 | errorCode: 'validation', |
| 135 | } |
| 136 | } |
| 137 | const triggerValidation = await validateTriggerWebhookConfigForDeploy( |
| 138 | workflowState.blocks, |
| 139 | executor |
| 140 | ) |
| 141 | if (!triggerValidation.success) { |
| 142 | return { |
| 143 | success: false, |
| 144 | error: triggerValidation.error?.message || 'Invalid trigger configuration', |
| 145 | errorCode: 'validation', |
| 146 | } |
| 147 | } |
| 148 | return { success: true } |
| 149 | }, |
| 150 | onDeployTransaction: async (tx, result) => { |
| 151 | outboxEventId = await enqueueWorkflowDeploymentSideEffects(tx, { |
| 152 | workflowId, |
| 153 | deploymentVersionId: result.deploymentVersionId, |
| 154 | userId, |
| 155 | requestId, |
| 156 | }) |
| 157 | }, |
| 158 | }) |
| 159 |
no test coverage detected