MCPcopy
hub / github.com/simstudioai/sim / clearInWorkflowBlocks

Function clearInWorkflowBlocks

apps/sim/lib/credentials/deletion.ts:96–133  ·  view source on GitHub ↗
(
  credentialId: string,
  workspaceId: string,
  needle: string
)

Source from the content-addressed store, hash-verified

94}
95
96async 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
135async function clearInDeploymentVersions(
136 credentialId: string,

Callers 1

clearCredentialRefsFunction · 0.85

Calls 4

clearCredentialInValueFunction · 0.85
infoMethod · 0.80
setMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected