MCPcopy Index your code
hub / github.com/simstudioai/sim / emitWorkflowLifecycleEvent

Function emitWorkflowLifecycleEvent

apps/sim/lib/workspace-events/emitter.ts:169–195  ·  view source on GitHub ↗

* Shared dispatch loop for workflow lifecycle events: matches subscriptions * on event type and workflow scope, never notifying the source workflow about * itself. Fire-and-forget: failures never affect the lifecycle operation.

(params: {
  eventType: 'workflow_deployed' | 'workflow_undeployed'
  workflowId: string
  workspaceId: string
  payload: SimEventPayload
})

Source from the content-addressed store, hash-verified

167 * itself. Fire-and-forget: failures never affect the lifecycle operation.
168 */
169async function emitWorkflowLifecycleEvent(params: {
170 eventType: 'workflow_deployed' | 'workflow_undeployed'
171 workflowId: string
172 workspaceId: string
173 payload: SimEventPayload
174}): Promise<void> {
175 try {
176 const subscriptions = await fetchSimTriggerSubscriptions(params.workspaceId)
177 if (subscriptions.length === 0) return
178
179 for (const subscription of subscriptions) {
180 const config = parseSubscriptionConfig(subscription.webhook.providerConfig)
181 if (!config) continue
182 if (config.eventType !== params.eventType) continue
183
184 if (subscription.webhook.workflowId === params.workflowId) continue
185 if (!matchesWorkflowScope(config, params.workflowId)) continue
186
187 await dispatchSimEvent(subscription, params.payload)
188 }
189 } catch (error) {
190 logger.error(`Failed to emit ${params.eventType} event`, {
191 error,
192 workflowId: params.workflowId,
193 })
194 }
195}
196
197/**
198 * Emits a workflow_deployed event to subscribed side-effect workflows.

Callers 2

Calls 5

parseSubscriptionConfigFunction · 0.90
matchesWorkflowScopeFunction · 0.85
dispatchSimEventFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected