MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / updateCredential

Function updateCredential

packages/server/src/services/credentials/index.ts:169–193  ·  view source on GitHub ↗
(credentialId: string, requestBody: any, workspaceId: string)

Source from the content-addressed store, hash-verified

167}
168
169const 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
195const revealCredentialById = async (credentialId: string, workspaceId: string): Promise<any> => {
196 try {

Callers

nothing calls this directly

Calls 4

getRunningExpressAppFunction · 0.90
decryptCredentialDataFunction · 0.90
getErrorMessageFunction · 0.90

Tested by

no test coverage detected