( credentialId: string, workspaceId: string, needle: string )
| 94 | } |
| 95 | |
| 96 | async function clearInWorkflowBlocks( |
| 97 | credentialId: string, |
| 98 | workspaceId: string, |
| 99 | needle: string |
| 100 | ): Promise<void> { |
| 101 | const rows = await db |
| 102 | .select({ |
| 103 | id: schema.workflowBlocks.id, |
| 104 | subBlocks: schema.workflowBlocks.subBlocks, |
| 105 | }) |
| 106 | .from(schema.workflowBlocks) |
| 107 | .innerJoin(schema.workflow, eq(schema.workflow.id, schema.workflowBlocks.workflowId)) |
| 108 | .where( |
| 109 | and( |
| 110 | eq(schema.workflow.workspaceId, workspaceId), |
| 111 | sql`${schema.workflowBlocks.subBlocks}::text LIKE ${needle}` |
| 112 | ) |
| 113 | ) |
| 114 | |
| 115 | let updated = 0 |
| 116 | for (const row of rows) { |
| 117 | const next = clearCredentialInValue(row.subBlocks, credentialId) |
| 118 | if (next.changed) { |
| 119 | await db |
| 120 | .update(schema.workflowBlocks) |
| 121 | .set({ subBlocks: next.value, updatedAt: new Date() }) |
| 122 | .where(eq(schema.workflowBlocks.id, row.id)) |
| 123 | updated += 1 |
| 124 | } |
| 125 | } |
| 126 | if (updated > 0) { |
| 127 | logger.info('Cleared credential refs in workflow_blocks', { |
| 128 | credentialId, |
| 129 | workspaceId, |
| 130 | updated, |
| 131 | }) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | async function clearInDeploymentVersions( |
| 136 | credentialId: string, |
no test coverage detected