@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
@@ -525,6 +525,8 @@ export function ActivityConfigFields({ activityType, idPrefix, config, onChange,
525
525
  case 'eventName':
526
526
  return (
527
527
  <EventPatternInput
528
+ workflowEmittableOnly
529
+ placeholder={t('ui.inputs.eventSelect.placeholder', 'Select an event...')}
528
530
  value={stringValue(rawValue)}
529
531
  onChange={(nextValue) => setField(spec, nextValue)}
530
532
  disabled={disabled}
@@ -6,6 +6,20 @@ import { createModuleEvents } from '@open-mercato/shared/modules/events'
6
6
  * Declares all events that can be emitted by the workflows module.
7
7
  */
8
8
  const events = [
9
+ { id: 'approval.completed', label: 'Approval Completed', category: 'lifecycle', workflowEmittable: true },
10
+ { id: 'approval.requested', label: 'Approval Requested', category: 'lifecycle', workflowEmittable: true },
11
+ { id: 'checkout.started', label: 'Checkout Started', category: 'lifecycle', workflowEmittable: true },
12
+ { id: 'fulfillment.ready', label: 'Fulfillment Ready', category: 'lifecycle', workflowEmittable: true },
13
+ { id: 'order.approved', label: 'Order Approved', category: 'lifecycle', workflowEmittable: true },
14
+ { id: 'order.created', label: 'Order Created', category: 'lifecycle', workflowEmittable: true },
15
+ { id: 'oze.install.failed', label: 'Oze Install Failed', category: 'lifecycle', workflowEmittable: true },
16
+ { id: 'oze.quote.sent', label: 'Oze Quote Sent', category: 'lifecycle', workflowEmittable: true },
17
+ { id: 'sales.order.approval.approved', label: 'Sales Order Approval Approved', category: 'lifecycle', workflowEmittable: true },
18
+ { id: 'sales.order.approval.rejected', label: 'Sales Order Approval Rejected', category: 'lifecycle', workflowEmittable: true },
19
+ { id: 'sales.order.approval.requested', label: 'Sales Order Approval Requested', category: 'lifecycle', workflowEmittable: true },
20
+ { id: 'sales.pipeline.completed', label: 'Sales Pipeline Completed', category: 'lifecycle', workflowEmittable: true },
21
+ { id: 'workflows.task.escalated', label: 'Workflows Task Escalated', category: 'lifecycle', workflowEmittable: true },
22
+
9
23
  // Workflow Definitions
10
24
  { id: 'workflows.definition.created', label: 'Workflow Definition Created', entity: 'definition', category: 'crud' },
11
25
  { id: 'workflows.definition.updated', label: 'Workflow Definition Updated', entity: 'definition', category: 'crud' },
@@ -24,7 +24,7 @@ import {
24
24
  type HostLookup,
25
25
  } from '@open-mercato/shared/lib/url-safety'
26
26
  import { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'
27
- import { isPrivateCrossProcessBroadcastEvent } from '@open-mercato/shared/modules/events'
27
+ import { getDeclaredEvents, isPrivateCrossProcessBroadcastEvent } from '@open-mercato/shared/modules/events'
28
28
  import { hasAllFeatures } from '@open-mercato/shared/security/features'
29
29
  import {
30
30
  definitionDeclaresGrant,
@@ -963,9 +963,9 @@ export async function executeEmitEvent(
963
963
  container: AwilixContainer,
964
964
  signal?: AbortSignal
965
965
  ): Promise<any> {
966
- const { eventName, payload } = config
966
+ const { eventName, payload }: { eventName?: unknown; payload?: Record<string, unknown> } = config
967
967
 
968
- if (!eventName) {
968
+ if (typeof eventName !== 'string' || !eventName) {
969
969
  throw new Error('EMIT_EVENT requires "eventName" field')
970
970
  }
971
971
 
@@ -977,6 +977,11 @@ export async function executeEmitEvent(
977
977
  throw new Error(`EMIT_EVENT cannot emit private cross-process event "${eventName}"`)
978
978
  }
979
979
 
980
+ const declaration = getDeclaredEvents().find((event) => event.id === eventName)
981
+ if (declaration?.workflowEmittable !== true || declaration.portalBroadcast || declaration.crossProcessBroadcast) {
982
+ throw new Error(`EMIT_EVENT cannot emit event "${eventName}" from a workflow`)
983
+ }
984
+
980
985
  // Emissions are fire-and-forget and no subscriber validates the payload shape,
981
986
  // so an unresolved `{{context.x}}` here is even quieter than on the command
982
987
  // path — it ships the literal template to every consumer. Fail loudly instead.
@@ -998,22 +1003,23 @@ export async function executeEmitEvent(
998
1003
  }
999
1004
 
1000
1005
  // Publish event with workflow metadata
1001
- const enrichedPayload = {
1006
+ const { tenantId, organizationId } = context.workflowInstance
1007
+ const enrichedPayload: Record<string, unknown> = {
1002
1008
  ...payload,
1009
+ tenantId,
1010
+ organizationId,
1003
1011
  _workflow: {
1004
1012
  workflowInstanceId: context.workflowInstance.id,
1005
1013
  workflowId: context.workflowInstance.workflowId,
1006
- tenantId: context.workflowInstance.tenantId,
1007
- organizationId: context.workflowInstance.organizationId,
1014
+ tenantId,
1015
+ organizationId,
1008
1016
  },
1009
1017
  }
1018
+ delete enrichedPayload.organizationIds
1010
1019
 
1011
1020
  await raceAbortable(
1012
1021
  Promise.resolve(
1013
- eventBus.emitEvent(eventName, enrichedPayload, {
1014
- tenantId: context.workflowInstance.tenantId,
1015
- organizationId: context.workflowInstance.organizationId,
1016
- })
1022
+ eventBus.emitEvent(eventName, enrichedPayload, { tenantId, organizationId })
1017
1023
  ),
1018
1024
  signal
1019
1025
  )