@open-mercato/core 0.11.1-develop.8567.1.a167594505 → 0.11.1-develop.8581.1.535dac92b7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/attachments/di.js +25 -0
  3. package/dist/modules/attachments/di.js.map +2 -2
  4. package/dist/modules/catalog/lib/productScopeReindex.js +1 -1
  5. package/dist/modules/catalog/lib/productScopeReindex.js.map +2 -2
  6. package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js +1 -1
  7. package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js.map +2 -2
  8. package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js +2 -1
  9. package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js.map +2 -2
  10. package/dist/modules/dictionaries/api/context.js +11 -8
  11. package/dist/modules/dictionaries/api/context.js.map +2 -2
  12. package/dist/modules/dictionaries/api/route.js +2 -1
  13. package/dist/modules/dictionaries/api/route.js.map +2 -2
  14. package/dist/modules/dictionaries/commands/entries.js +30 -4
  15. package/dist/modules/dictionaries/commands/entries.js.map +2 -2
  16. package/dist/modules/entities/api/relations/options.js +85 -5
  17. package/dist/modules/entities/api/relations/options.js.map +2 -2
  18. package/dist/modules/payment_gateways/lib/gateway-service.js +1 -1
  19. package/dist/modules/payment_gateways/lib/gateway-service.js.map +2 -2
  20. package/dist/modules/query_index/api/purge.js +1 -1
  21. package/dist/modules/query_index/api/purge.js.map +2 -2
  22. package/dist/modules/query_index/api/reindex.js +1 -1
  23. package/dist/modules/query_index/api/reindex.js.map +2 -2
  24. package/dist/modules/query_index/cli.js +2 -2
  25. package/dist/modules/query_index/cli.js.map +2 -2
  26. package/dist/modules/query_index/lib/engine.js +5 -1
  27. package/dist/modules/query_index/lib/engine.js.map +2 -2
  28. package/dist/modules/query_index/subscribers/purge.js +3 -3
  29. package/dist/modules/query_index/subscribers/purge.js.map +2 -2
  30. package/dist/modules/query_index/subscribers/reindex.js +11 -13
  31. package/dist/modules/query_index/subscribers/reindex.js.map +2 -2
  32. package/dist/modules/staff/api/interceptors.js +28 -24
  33. package/dist/modules/staff/api/interceptors.js.map +2 -2
  34. package/dist/modules/staff/di.js +23 -0
  35. package/dist/modules/staff/di.js.map +2 -2
  36. package/dist/modules/workflows/components/fields/ActivityConfigFields.js +2 -0
  37. package/dist/modules/workflows/components/fields/ActivityConfigFields.js.map +2 -2
  38. package/dist/modules/workflows/events.js +13 -0
  39. package/dist/modules/workflows/events.js.map +2 -2
  40. package/dist/modules/workflows/lib/activity-executor.js +13 -8
  41. package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
  42. package/package.json +7 -7
  43. package/src/modules/attachments/di.ts +29 -0
  44. package/src/modules/catalog/lib/productScopeReindex.ts +1 -1
  45. package/src/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.ts +1 -1
  46. package/src/modules/dictionaries/api/[dictionaryId]/entries/route.ts +2 -1
  47. package/src/modules/dictionaries/api/context.ts +11 -8
  48. package/src/modules/dictionaries/api/route.ts +1 -0
  49. package/src/modules/dictionaries/commands/entries.ts +40 -3
  50. package/src/modules/entities/api/relations/options.ts +88 -6
  51. package/src/modules/payment_gateways/lib/gateway-service.ts +2 -2
  52. package/src/modules/query_index/api/purge.ts +1 -1
  53. package/src/modules/query_index/api/reindex.ts +1 -1
  54. package/src/modules/query_index/cli.ts +2 -2
  55. package/src/modules/query_index/lib/engine.ts +5 -1
  56. package/src/modules/query_index/subscribers/purge.ts +5 -4
  57. package/src/modules/query_index/subscribers/reindex.ts +14 -15
  58. package/src/modules/staff/api/interceptors.ts +33 -26
  59. package/src/modules/staff/di.ts +25 -0
  60. package/src/modules/workflows/components/fields/ActivityConfigFields.tsx +2 -0
  61. package/src/modules/workflows/events.ts +14 -0
  62. package/src/modules/workflows/lib/activity-executor.ts +16 -10
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/workflows/events.ts"],
4
- "sourcesContent": ["import { createModuleEvents } from '@open-mercato/shared/modules/events'\n\n/**\n * Workflows Module Events\n *\n * Declares all events that can be emitted by the workflows module.\n */\nconst events = [\n // Workflow Definitions\n { id: 'workflows.definition.created', label: 'Workflow Definition Created', entity: 'definition', category: 'crud' },\n { id: 'workflows.definition.updated', label: 'Workflow Definition Updated', entity: 'definition', category: 'crud' },\n { id: 'workflows.definition.deleted', label: 'Workflow Definition Deleted', entity: 'definition', category: 'crud' },\n { id: 'workflows.definition.customized', label: 'Workflow Definition Customized', entity: 'definition', category: 'lifecycle' },\n { id: 'workflows.definition.reset_to_code', label: 'Workflow Definition Reset to Code', entity: 'definition', category: 'lifecycle' },\n { id: 'workflows.definition.published', label: 'Workflow Definition Published', entity: 'definition', category: 'lifecycle' },\n\n // Workflow Instances\n { id: 'workflows.instance.created', label: 'Workflow Instance Created', entity: 'instance', category: 'crud' },\n { id: 'workflows.instance.updated', label: 'Workflow Instance Updated', entity: 'instance', category: 'crud' },\n { id: 'workflows.instance.deleted', label: 'Workflow Instance Deleted', entity: 'instance', category: 'crud' },\n\n /**\n * Workflow lifecycle. All six carry `clientBroadcast: true` so the run views\n * update live through the DOM Event Bridge (spec \u00A78.3).\n *\n * Safe to broadcast: the payload `emitInstanceLifecycleEvent` publishes is\n * instance identity and state \u2014 id, tenant, organization, workflowId,\n * version, status, current stepId \u2014 and carries no authored content, no task\n * name and no run context. It is also already tenant + organization scoped by\n * the bridge, which refuses to deliver a payload with no `tenantId` at all.\n *\n * `paused` and `resumed` are declared but have never had an emit site (see\n * `InstanceLifecycleEventId` in `lib/workflow-executor.ts`); the flag is\n * declared on them anyway so that whoever wires the emit does not have to\n * revisit the contract.\n */\n { id: 'workflows.instance.started', label: 'Workflow Started', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.completed', label: 'Workflow Completed', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.failed', label: 'Workflow Failed', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.cancelled', label: 'Workflow Cancelled', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.paused', label: 'Workflow Paused', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.resumed', label: 'Workflow Resumed', category: 'lifecycle', clientBroadcast: true },\n /**\n * A BUSINESS milestone the run announced \u2014 emitted when a step carrying a\n * `milestone` annotation completes.\n *\n * It is deliberately not a step event. A milestone can be announced after a\n * parallel join, after a retry, or after ten steps, and a consumer reading the\n * business narrative must never have to know which. `milestoneKey` is the\n * business vocabulary; `stepId` rides along for the trace, not for matching.\n */\n { id: 'workflows.instance.milestone_reached', label: 'Workflow Milestone Reached', category: 'lifecycle', clientBroadcast: true },\n\n // User Task Events\n { id: 'workflows.task.assigned', label: 'Task Assigned', entity: 'task', category: 'lifecycle' },\n { id: 'workflows.task.reminder_due', label: 'Task Reminder Due', entity: 'task', category: 'lifecycle' },\n { id: 'workflows.task.deadline_breached', label: 'Task Deadline Breached', entity: 'task', category: 'lifecycle' },\n /**\n * A task addressed to a PORTAL principal, bridged to that principal's browser\n * so it appears without a reload.\n *\n * A separate event rather than `portalBroadcast` on `workflows.task.assigned`,\n * and the difference is a leak. The portal SSE bridge scopes a payload by\n * tenant + organization and narrows to one user ONLY when the payload carries\n * `recipientUserId`; `workflows.task.assigned` carries none, plus the task\n * name and its entity bindings \u2014 broadcasting it would hand every portal user\n * in the organization the name of every other customer's task. This one is\n * addressed to exactly one principal and carries an ID and nothing else, so\n * the receiver has to ask the (authorized) API what it is.\n */\n { id: 'workflows.task.portal_assigned', label: 'Portal Task Assigned', entity: 'task', category: 'lifecycle', portalBroadcast: true, excludeFromTriggers: true },\n\n // Activity Events\n { id: 'workflows.activity.started', label: 'Activity Started', category: 'lifecycle' },\n { id: 'workflows.activity.completed', label: 'Activity Completed', category: 'lifecycle' },\n { id: 'workflows.activity.failed', label: 'Activity Failed', category: 'lifecycle' },\n\n /**\n * Live agent-action telemetry for an INVOKE_AGENT step (spec \u00A7Phase 2). Emitted\n * per AI-SDK step by the optional `agent_orchestrator` peer's native runner so\n * the run view can show what the agent is doing WHILE it runs, instead of only\n * refetching on `instance.*` lifecycle changes. `clientBroadcast` so it reaches\n * the browser via the DOM Event Bridge; `excludeFromTriggers` because it is UI\n * telemetry, not a business signal a workflow should react to.\n *\n * Ephemeral and safe to broadcast: the payload is instance/step identity plus\n * a coarse action descriptor (`kind`: step_finish | tool_call, an optional tool\n * `name`, step index, tool-call count) \u2014 NO token text, NO model output, NO\n * authored content \u2014 and is tenant + organization scoped like the lifecycle\n * events. Low-frequency (a handful per agent run), so it fits the bridge's\n * dedup/heartbeat envelope where a token stream never could.\n */\n { id: 'workflows.agent.action', label: 'Workflow Agent Action', category: 'lifecycle', clientBroadcast: true, excludeFromTriggers: true },\n\n // Event Triggers\n { id: 'workflows.trigger.created', label: 'Trigger Created', entity: 'trigger', category: 'crud' },\n { id: 'workflows.trigger.updated', label: 'Trigger Updated', entity: 'trigger', category: 'crud' },\n { id: 'workflows.trigger.deleted', label: 'Trigger Deleted', entity: 'trigger', category: 'crud' },\n\n // Parallel Fork / Join (branch lifecycle)\n { id: 'workflows.branch.opened', label: 'Parallel Branch Opened', entity: 'branch', category: 'lifecycle' },\n { id: 'workflows.branch.completed', label: 'Parallel Branch Completed', entity: 'branch', category: 'lifecycle' },\n { id: 'workflows.branch.cancelled', label: 'Parallel Branch Cancelled', entity: 'branch', category: 'lifecycle' },\n { id: 'workflows.branch.failed', label: 'Parallel Branch Failed', entity: 'branch', category: 'lifecycle' },\n { id: 'workflows.join.completed', label: 'Parallel Join Completed', entity: 'branch', category: 'lifecycle' },\n] as const\n\nexport const eventsConfig = createModuleEvents({\n moduleId: 'workflows',\n events,\n})\n\n/** Type-safe event emitter for workflows module */\nexport const emitWorkflowsEvent = eventsConfig.emit\n\n/** Event IDs that can be emitted by the workflows module */\nexport type WorkflowsEventId = typeof events[number]['id']\n\nexport default event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,YAAY;AAAA,EAC1G,EAAE,IAAI,8BAA8B,OAAO,6BAA6B,QAAQ,UAAU,UAAU,YAAY;AAAA,EAChH,EAAE,IAAI,8BAA8B,OAAO,6BAA6B,QAAQ,UAAU,UAAU,YAAY;AAAA,EAChH,EAAE,IAAI,2BAA2B,OAAO,0BAA0B,QAAQ,UAAU,UAAU,YAAY;AAAA,EAC1G,EAAE,IAAI,4BAA4B,OAAO,2BAA2B,QAAQ,UAAU,UAAU,YAAY;AAC9G;AAEO,MAAM,eAAe,mBAAmB;AAAA,EAC7C,UAAU;AAAA,EACV;AACF,CAAC;AAGM,MAAM,qBAAqB,aAAa;AAK/C,IAAO,iBAAQ;",
4
+ "sourcesContent": ["import { createModuleEvents } from '@open-mercato/shared/modules/events'\n\n/**\n * Workflows Module Events\n *\n * Declares all events that can be emitted by the workflows module.\n */\nconst events = [\n { id: 'approval.completed', label: 'Approval Completed', category: 'lifecycle', workflowEmittable: true },\n { id: 'approval.requested', label: 'Approval Requested', category: 'lifecycle', workflowEmittable: true },\n { id: 'checkout.started', label: 'Checkout Started', category: 'lifecycle', workflowEmittable: true },\n { id: 'fulfillment.ready', label: 'Fulfillment Ready', category: 'lifecycle', workflowEmittable: true },\n { id: 'order.approved', label: 'Order Approved', category: 'lifecycle', workflowEmittable: true },\n { id: 'order.created', label: 'Order Created', category: 'lifecycle', workflowEmittable: true },\n { id: 'oze.install.failed', label: 'Oze Install Failed', category: 'lifecycle', workflowEmittable: true },\n { id: 'oze.quote.sent', label: 'Oze Quote Sent', category: 'lifecycle', workflowEmittable: true },\n { id: 'sales.order.approval.approved', label: 'Sales Order Approval Approved', category: 'lifecycle', workflowEmittable: true },\n { id: 'sales.order.approval.rejected', label: 'Sales Order Approval Rejected', category: 'lifecycle', workflowEmittable: true },\n { id: 'sales.order.approval.requested', label: 'Sales Order Approval Requested', category: 'lifecycle', workflowEmittable: true },\n { id: 'sales.pipeline.completed', label: 'Sales Pipeline Completed', category: 'lifecycle', workflowEmittable: true },\n { id: 'workflows.task.escalated', label: 'Workflows Task Escalated', category: 'lifecycle', workflowEmittable: true },\n\n // Workflow Definitions\n { id: 'workflows.definition.created', label: 'Workflow Definition Created', entity: 'definition', category: 'crud' },\n { id: 'workflows.definition.updated', label: 'Workflow Definition Updated', entity: 'definition', category: 'crud' },\n { id: 'workflows.definition.deleted', label: 'Workflow Definition Deleted', entity: 'definition', category: 'crud' },\n { id: 'workflows.definition.customized', label: 'Workflow Definition Customized', entity: 'definition', category: 'lifecycle' },\n { id: 'workflows.definition.reset_to_code', label: 'Workflow Definition Reset to Code', entity: 'definition', category: 'lifecycle' },\n { id: 'workflows.definition.published', label: 'Workflow Definition Published', entity: 'definition', category: 'lifecycle' },\n\n // Workflow Instances\n { id: 'workflows.instance.created', label: 'Workflow Instance Created', entity: 'instance', category: 'crud' },\n { id: 'workflows.instance.updated', label: 'Workflow Instance Updated', entity: 'instance', category: 'crud' },\n { id: 'workflows.instance.deleted', label: 'Workflow Instance Deleted', entity: 'instance', category: 'crud' },\n\n /**\n * Workflow lifecycle. All six carry `clientBroadcast: true` so the run views\n * update live through the DOM Event Bridge (spec \u00A78.3).\n *\n * Safe to broadcast: the payload `emitInstanceLifecycleEvent` publishes is\n * instance identity and state \u2014 id, tenant, organization, workflowId,\n * version, status, current stepId \u2014 and carries no authored content, no task\n * name and no run context. It is also already tenant + organization scoped by\n * the bridge, which refuses to deliver a payload with no `tenantId` at all.\n *\n * `paused` and `resumed` are declared but have never had an emit site (see\n * `InstanceLifecycleEventId` in `lib/workflow-executor.ts`); the flag is\n * declared on them anyway so that whoever wires the emit does not have to\n * revisit the contract.\n */\n { id: 'workflows.instance.started', label: 'Workflow Started', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.completed', label: 'Workflow Completed', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.failed', label: 'Workflow Failed', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.cancelled', label: 'Workflow Cancelled', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.paused', label: 'Workflow Paused', category: 'lifecycle', clientBroadcast: true },\n { id: 'workflows.instance.resumed', label: 'Workflow Resumed', category: 'lifecycle', clientBroadcast: true },\n /**\n * A BUSINESS milestone the run announced \u2014 emitted when a step carrying a\n * `milestone` annotation completes.\n *\n * It is deliberately not a step event. A milestone can be announced after a\n * parallel join, after a retry, or after ten steps, and a consumer reading the\n * business narrative must never have to know which. `milestoneKey` is the\n * business vocabulary; `stepId` rides along for the trace, not for matching.\n */\n { id: 'workflows.instance.milestone_reached', label: 'Workflow Milestone Reached', category: 'lifecycle', clientBroadcast: true },\n\n // User Task Events\n { id: 'workflows.task.assigned', label: 'Task Assigned', entity: 'task', category: 'lifecycle' },\n { id: 'workflows.task.reminder_due', label: 'Task Reminder Due', entity: 'task', category: 'lifecycle' },\n { id: 'workflows.task.deadline_breached', label: 'Task Deadline Breached', entity: 'task', category: 'lifecycle' },\n /**\n * A task addressed to a PORTAL principal, bridged to that principal's browser\n * so it appears without a reload.\n *\n * A separate event rather than `portalBroadcast` on `workflows.task.assigned`,\n * and the difference is a leak. The portal SSE bridge scopes a payload by\n * tenant + organization and narrows to one user ONLY when the payload carries\n * `recipientUserId`; `workflows.task.assigned` carries none, plus the task\n * name and its entity bindings \u2014 broadcasting it would hand every portal user\n * in the organization the name of every other customer's task. This one is\n * addressed to exactly one principal and carries an ID and nothing else, so\n * the receiver has to ask the (authorized) API what it is.\n */\n { id: 'workflows.task.portal_assigned', label: 'Portal Task Assigned', entity: 'task', category: 'lifecycle', portalBroadcast: true, excludeFromTriggers: true },\n\n // Activity Events\n { id: 'workflows.activity.started', label: 'Activity Started', category: 'lifecycle' },\n { id: 'workflows.activity.completed', label: 'Activity Completed', category: 'lifecycle' },\n { id: 'workflows.activity.failed', label: 'Activity Failed', category: 'lifecycle' },\n\n /**\n * Live agent-action telemetry for an INVOKE_AGENT step (spec \u00A7Phase 2). Emitted\n * per AI-SDK step by the optional `agent_orchestrator` peer's native runner so\n * the run view can show what the agent is doing WHILE it runs, instead of only\n * refetching on `instance.*` lifecycle changes. `clientBroadcast` so it reaches\n * the browser via the DOM Event Bridge; `excludeFromTriggers` because it is UI\n * telemetry, not a business signal a workflow should react to.\n *\n * Ephemeral and safe to broadcast: the payload is instance/step identity plus\n * a coarse action descriptor (`kind`: step_finish | tool_call, an optional tool\n * `name`, step index, tool-call count) \u2014 NO token text, NO model output, NO\n * authored content \u2014 and is tenant + organization scoped like the lifecycle\n * events. Low-frequency (a handful per agent run), so it fits the bridge's\n * dedup/heartbeat envelope where a token stream never could.\n */\n { id: 'workflows.agent.action', label: 'Workflow Agent Action', category: 'lifecycle', clientBroadcast: true, excludeFromTriggers: true },\n\n // Event Triggers\n { id: 'workflows.trigger.created', label: 'Trigger Created', entity: 'trigger', category: 'crud' },\n { id: 'workflows.trigger.updated', label: 'Trigger Updated', entity: 'trigger', category: 'crud' },\n { id: 'workflows.trigger.deleted', label: 'Trigger Deleted', entity: 'trigger', category: 'crud' },\n\n // Parallel Fork / Join (branch lifecycle)\n { id: 'workflows.branch.opened', label: 'Parallel Branch Opened', entity: 'branch', category: 'lifecycle' },\n { id: 'workflows.branch.completed', label: 'Parallel Branch Completed', entity: 'branch', category: 'lifecycle' },\n { id: 'workflows.branch.cancelled', label: 'Parallel Branch Cancelled', entity: 'branch', category: 'lifecycle' },\n { id: 'workflows.branch.failed', label: 'Parallel Branch Failed', entity: 'branch', category: 'lifecycle' },\n { id: 'workflows.join.completed', label: 'Parallel Join Completed', entity: 'branch', category: 'lifecycle' },\n] as const\n\nexport const eventsConfig = createModuleEvents({\n moduleId: 'workflows',\n events,\n})\n\n/** Type-safe event emitter for workflows module */\nexport const emitWorkflowsEvent = eventsConfig.emit\n\n/** Event IDs that can be emitted by the workflows module */\nexport type WorkflowsEventId = typeof events[number]['id']\n\nexport default eventsConfig\n"],
5
+ "mappings": "AAAA,SAAS,0BAA0B;AAOnC,MAAM,SAAS;AAAA,EACb,EAAE,IAAI,s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V;AACF,CAAC;AAGM,MAAM,qBAAqB,aAAa;AAK/C,IAAO,iBAAQ;",
6
6
  "names": []
7
7
  }
@@ -4,7 +4,7 @@ import {
4
4
  UnsafeOutboundUrlError
5
5
  } from "@open-mercato/shared/lib/url-safety";
6
6
  import { parseBooleanWithDefault } from "@open-mercato/shared/lib/boolean";
7
- import { isPrivateCrossProcessBroadcastEvent } from "@open-mercato/shared/modules/events";
7
+ import { getDeclaredEvents, isPrivateCrossProcessBroadcastEvent } from "@open-mercato/shared/modules/events";
8
8
  import {
9
9
  definitionDeclaresGrant,
10
10
  resolveWorkflowDefinitionExecutionUserId
@@ -514,12 +514,16 @@ async function executeSendEmail(config, context, container, signal) {
514
514
  }
515
515
  async function executeEmitEvent(config, context, container, signal) {
516
516
  const { eventName, payload } = config;
517
- if (!eventName) {
517
+ if (typeof eventName !== "string" || !eventName) {
518
518
  throw new Error('EMIT_EVENT requires "eventName" field');
519
519
  }
520
520
  if (isPrivateCrossProcessBroadcastEvent(eventName)) {
521
521
  throw new Error(`EMIT_EVENT cannot emit private cross-process event "${eventName}"`);
522
522
  }
523
+ const declaration = getDeclaredEvents().find((event) => event.id === eventName);
524
+ if (declaration?.workflowEmittable !== true || declaration.portalBroadcast || declaration.crossProcessBroadcast) {
525
+ throw new Error(`EMIT_EVENT cannot emit event "${eventName}" from a workflow`);
526
+ }
523
527
  const unresolvedPayloadKeys = findUnresolvedTemplateKeys(payload);
524
528
  if (unresolvedPayloadKeys.length > 0) {
525
529
  throw new Error(
@@ -531,21 +535,22 @@ async function executeEmitEvent(config, context, container, signal) {
531
535
  if (!eventBus || typeof eventBus.emitEvent !== "function") {
532
536
  throw new Error("Event bus not available in container");
533
537
  }
538
+ const { tenantId, organizationId } = context.workflowInstance;
534
539
  const enrichedPayload = {
535
540
  ...payload,
541
+ tenantId,
542
+ organizationId,
536
543
  _workflow: {
537
544
  workflowInstanceId: context.workflowInstance.id,
538
545
  workflowId: context.workflowInstance.workflowId,
539
- tenantId: context.workflowInstance.tenantId,
540
- organizationId: context.workflowInstance.organizationId
546
+ tenantId,
547
+ organizationId
541
548
  }
542
549
  };
550
+ delete enrichedPayload.organizationIds;
543
551
  await raceAbortable(
544
552
  Promise.resolve(
545
- eventBus.emitEvent(eventName, enrichedPayload, {
546
- tenantId: context.workflowInstance.tenantId,
547
- organizationId: context.workflowInstance.organizationId
548
- })
553
+ eventBus.emitEvent(eventName, enrichedPayload, { tenantId, organizationId })
549
554
  ),
550
555
  signal
551
556
  );