(credentialId: string, requestBody: any, workspaceId: string)
| 167 | } |
| 168 | |
| 169 | const updateCredential = async (credentialId: string, requestBody: any, workspaceId: string): Promise<any> => { |
| 170 | try { |
| 171 | const appServer = getRunningExpressApp() |
| 172 | const credential = await appServer.AppDataSource.getRepository(Credential).findOneBy({ |
| 173 | id: credentialId, |
| 174 | workspaceId: workspaceId |
| 175 | }) |
| 176 | if (!credential) { |
| 177 | throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Credential ${credentialId} not found`) |
| 178 | } |
| 179 | const decryptedCredentialData = await decryptCredentialData(credential.encryptedData) |
| 180 | const incomingData = requestBody.plainDataObj ?? {} |
| 181 | requestBody.plainDataObj = { ...decryptedCredentialData, ...incomingData } |
| 182 | const updateCredential = await transformToCredentialEntity(requestBody) |
| 183 | updateCredential.workspaceId = workspaceId |
| 184 | await appServer.AppDataSource.getRepository(Credential).merge(credential, updateCredential) |
| 185 | const dbResponse = await appServer.AppDataSource.getRepository(Credential).save(credential) |
| 186 | return dbResponse |
| 187 | } catch (error) { |
| 188 | throw new InternalFlowiseError( |
| 189 | StatusCodes.INTERNAL_SERVER_ERROR, |
| 190 | `Error: credentialsService.updateCredential - ${getErrorMessage(error)}` |
| 191 | ) |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | const revealCredentialById = async (credentialId: string, workspaceId: string): Promise<any> => { |
| 196 | try { |
nothing calls this directly
no test coverage detected