@open-mercato/core 0.4.2-canary-ed15f2e753 → 0.4.2-canary-f075c3eb92

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 (241) hide show
  1. package/dist/generated/entities.ids.generated.js +0 -1
  2. package/dist/generated/entities.ids.generated.js.map +2 -2
  3. package/dist/generated/entity-fields-registry.js +0 -2
  4. package/dist/generated/entity-fields-registry.js.map +2 -2
  5. package/dist/modules/api_keys/setup.js +11 -0
  6. package/dist/modules/api_keys/setup.js.map +7 -0
  7. package/dist/modules/attachments/components/AttachmentLibrary.js +1 -1
  8. package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
  9. package/dist/modules/attachments/lib/assignmentDetails.js +31 -17
  10. package/dist/modules/attachments/lib/assignmentDetails.js.map +2 -2
  11. package/dist/modules/attachments/lib/partitions.js +3 -3
  12. package/dist/modules/attachments/lib/partitions.js.map +2 -2
  13. package/dist/modules/attachments/setup.js +11 -0
  14. package/dist/modules/attachments/setup.js.map +7 -0
  15. package/dist/modules/audit_logs/setup.js +12 -0
  16. package/dist/modules/audit_logs/setup.js.map +7 -0
  17. package/dist/modules/auth/lib/setup-app.js +29 -159
  18. package/dist/modules/auth/lib/setup-app.js.map +2 -2
  19. package/dist/modules/auth/setup.js +11 -0
  20. package/dist/modules/auth/setup.js.map +7 -0
  21. package/dist/modules/business_rules/data/validators.js +0 -34
  22. package/dist/modules/business_rules/data/validators.js.map +2 -2
  23. package/dist/modules/business_rules/index.js +1 -21
  24. package/dist/modules/business_rules/index.js.map +2 -2
  25. package/dist/modules/business_rules/lib/rule-engine.js +1 -182
  26. package/dist/modules/business_rules/lib/rule-engine.js.map +2 -2
  27. package/dist/modules/business_rules/setup.js +11 -0
  28. package/dist/modules/business_rules/setup.js.map +7 -0
  29. package/dist/modules/catalog/setup.js +22 -0
  30. package/dist/modules/catalog/setup.js.map +7 -0
  31. package/dist/modules/configs/lib/upgrade-actions.js +65 -15
  32. package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
  33. package/dist/modules/configs/setup.js +16 -0
  34. package/dist/modules/configs/setup.js.map +7 -0
  35. package/dist/modules/currencies/setup.js +16 -0
  36. package/dist/modules/currencies/setup.js.map +7 -0
  37. package/dist/modules/customers/setup.js +36 -0
  38. package/dist/modules/customers/setup.js.map +7 -0
  39. package/dist/modules/dashboards/setup.js +12 -0
  40. package/dist/modules/dashboards/setup.js.map +7 -0
  41. package/dist/modules/dictionaries/setup.js +12 -0
  42. package/dist/modules/dictionaries/setup.js.map +7 -0
  43. package/dist/modules/directory/setup.js +12 -0
  44. package/dist/modules/directory/setup.js.map +7 -0
  45. package/dist/modules/entities/setup.js +11 -0
  46. package/dist/modules/entities/setup.js.map +7 -0
  47. package/dist/modules/feature_toggles/setup.js +11 -0
  48. package/dist/modules/feature_toggles/setup.js.map +7 -0
  49. package/dist/modules/perspectives/setup.js +12 -0
  50. package/dist/modules/perspectives/setup.js.map +7 -0
  51. package/dist/modules/planner/setup.js +21 -0
  52. package/dist/modules/planner/setup.js.map +7 -0
  53. package/dist/modules/query_index/setup.js +11 -0
  54. package/dist/modules/query_index/setup.js.map +7 -0
  55. package/dist/modules/resources/setup.js +21 -0
  56. package/dist/modules/resources/setup.js.map +7 -0
  57. package/dist/modules/sales/acl.js +0 -1
  58. package/dist/modules/sales/acl.js.map +2 -2
  59. package/dist/modules/sales/backend/sales/documents/[id]/page.js +0 -12
  60. package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
  61. package/dist/modules/sales/commands/documents.js +0 -62
  62. package/dist/modules/sales/commands/documents.js.map +2 -2
  63. package/dist/modules/sales/lib/dictionaries.js +0 -3
  64. package/dist/modules/sales/lib/dictionaries.js.map +2 -2
  65. package/dist/modules/sales/setup.js +99 -0
  66. package/dist/modules/sales/setup.js.map +7 -0
  67. package/dist/modules/staff/setup.js +27 -0
  68. package/dist/modules/staff/setup.js.map +7 -0
  69. package/dist/modules/workflows/acl.js +0 -2
  70. package/dist/modules/workflows/acl.js.map +2 -2
  71. package/dist/modules/workflows/api/instances/route.js +6 -18
  72. package/dist/modules/workflows/api/instances/route.js.map +2 -2
  73. package/dist/modules/workflows/api/tasks/route.js +1 -6
  74. package/dist/modules/workflows/api/tasks/route.js.map +2 -2
  75. package/dist/modules/workflows/backend/definitions/[id]/page.js +1 -9
  76. package/dist/modules/workflows/backend/definitions/[id]/page.js.map +2 -2
  77. package/dist/modules/workflows/backend/definitions/[id]/page.meta.js +1 -1
  78. package/dist/modules/workflows/backend/definitions/[id]/page.meta.js.map +2 -2
  79. package/dist/modules/workflows/backend/definitions/create/page.js +15 -24
  80. package/dist/modules/workflows/backend/definitions/create/page.js.map +2 -2
  81. package/dist/modules/workflows/backend/definitions/create/page.meta.js +1 -1
  82. package/dist/modules/workflows/backend/definitions/create/page.meta.js.map +2 -2
  83. package/dist/modules/workflows/backend/definitions/visual-editor/page.js +132 -150
  84. package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
  85. package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js +1 -1
  86. package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js.map +2 -2
  87. package/dist/modules/workflows/backend/events/[id]/page.js +1 -1
  88. package/dist/modules/workflows/backend/events/[id]/page.js.map +2 -2
  89. package/dist/modules/workflows/backend/events/[id]/page.meta.js +2 -2
  90. package/dist/modules/workflows/backend/events/[id]/page.meta.js.map +2 -2
  91. package/dist/modules/workflows/backend/instances/[id]/page.meta.js +2 -2
  92. package/dist/modules/workflows/backend/instances/[id]/page.meta.js.map +2 -2
  93. package/dist/modules/workflows/backend/tasks/[id]/page.js +1 -1
  94. package/dist/modules/workflows/backend/tasks/[id]/page.js.map +2 -2
  95. package/dist/modules/workflows/backend/tasks/[id]/page.meta.js +2 -2
  96. package/dist/modules/workflows/backend/tasks/[id]/page.meta.js.map +2 -2
  97. package/dist/modules/workflows/backend/tasks/page.js +6 -5
  98. package/dist/modules/workflows/backend/tasks/page.js.map +2 -2
  99. package/dist/modules/workflows/cli.js +3 -81
  100. package/dist/modules/workflows/cli.js.map +3 -3
  101. package/dist/modules/workflows/data/entities.js +1 -64
  102. package/dist/modules/workflows/data/entities.js.map +2 -2
  103. package/dist/modules/workflows/data/validators.js +0 -115
  104. package/dist/modules/workflows/data/validators.js.map +2 -2
  105. package/dist/modules/workflows/examples/checkout-demo-definition.json +5 -1
  106. package/dist/modules/workflows/lib/activity-executor.js +13 -75
  107. package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
  108. package/dist/modules/workflows/lib/graph-utils.js +2 -71
  109. package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
  110. package/dist/modules/workflows/lib/seeds.js +7 -36
  111. package/dist/modules/workflows/lib/seeds.js.map +2 -2
  112. package/dist/modules/workflows/lib/start-validator.js +23 -33
  113. package/dist/modules/workflows/lib/start-validator.js.map +2 -2
  114. package/dist/modules/workflows/lib/transition-handler.js +45 -157
  115. package/dist/modules/workflows/lib/transition-handler.js.map +3 -3
  116. package/dist/modules/workflows/migrations/Migration20251207131955.js +76 -72
  117. package/dist/modules/workflows/migrations/Migration20251207131955.js.map +2 -2
  118. package/dist/modules/workflows/setup.js +16 -0
  119. package/dist/modules/workflows/setup.js.map +7 -0
  120. package/generated/entities.ids.generated.ts +0 -1
  121. package/generated/entity-fields-registry.ts +0 -2
  122. package/package.json +2 -2
  123. package/src/__tests__/module-decoupling.test.ts +356 -0
  124. package/src/modules/api_keys/setup.ts +9 -0
  125. package/src/modules/attachments/components/AttachmentLibrary.tsx +2 -2
  126. package/src/modules/attachments/lib/assignmentDetails.ts +32 -16
  127. package/src/modules/attachments/lib/partitions.ts +3 -3
  128. package/src/modules/attachments/setup.ts +9 -0
  129. package/src/modules/audit_logs/setup.ts +10 -0
  130. package/src/modules/auth/__tests__/cli-setup-acl.test.ts +30 -0
  131. package/src/modules/auth/lib/setup-app.ts +40 -177
  132. package/src/modules/auth/setup.ts +9 -0
  133. package/src/modules/business_rules/data/validators.ts +0 -40
  134. package/src/modules/business_rules/index.ts +0 -25
  135. package/src/modules/business_rules/lib/rule-engine.ts +1 -281
  136. package/src/modules/business_rules/setup.ts +9 -0
  137. package/src/modules/catalog/setup.ts +22 -0
  138. package/src/modules/configs/lib/upgrade-actions.ts +78 -17
  139. package/src/modules/configs/setup.ts +14 -0
  140. package/src/modules/currencies/setup.ts +15 -0
  141. package/src/modules/customers/setup.ts +36 -0
  142. package/src/modules/dashboards/setup.ts +10 -0
  143. package/src/modules/dictionaries/setup.ts +10 -0
  144. package/src/modules/directory/setup.ts +10 -0
  145. package/src/modules/entities/setup.ts +9 -0
  146. package/src/modules/feature_toggles/setup.ts +9 -0
  147. package/src/modules/perspectives/setup.ts +10 -0
  148. package/src/modules/planner/setup.ts +21 -0
  149. package/src/modules/query_index/setup.ts +9 -0
  150. package/src/modules/resources/setup.ts +21 -0
  151. package/src/modules/sales/acl.ts +0 -1
  152. package/src/modules/sales/backend/sales/documents/[id]/page.tsx +0 -16
  153. package/src/modules/sales/commands/documents.ts +1 -74
  154. package/src/modules/sales/lib/dictionaries.ts +0 -3
  155. package/src/modules/sales/setup.ts +108 -0
  156. package/src/modules/staff/setup.ts +27 -0
  157. package/src/modules/workflows/acl.ts +0 -2
  158. package/src/modules/workflows/api/__tests__/instances.route.test.ts +2 -5
  159. package/src/modules/workflows/api/instances/route.ts +7 -21
  160. package/src/modules/workflows/api/tasks/route.ts +1 -7
  161. package/src/modules/workflows/backend/definitions/[id]/page.meta.ts +1 -1
  162. package/src/modules/workflows/backend/definitions/[id]/page.tsx +0 -9
  163. package/src/modules/workflows/backend/definitions/create/page.meta.ts +1 -1
  164. package/src/modules/workflows/backend/definitions/create/page.tsx +0 -9
  165. package/src/modules/workflows/backend/definitions/visual-editor/page.meta.ts +1 -1
  166. package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +3 -21
  167. package/src/modules/workflows/backend/events/[id]/page.meta.ts +2 -2
  168. package/src/modules/workflows/backend/events/[id]/page.tsx +1 -1
  169. package/src/modules/workflows/backend/instances/[id]/page.meta.ts +2 -2
  170. package/src/modules/workflows/backend/tasks/[id]/page.meta.ts +2 -2
  171. package/src/modules/workflows/backend/tasks/[id]/page.tsx +1 -1
  172. package/src/modules/workflows/backend/tasks/page.tsx +6 -5
  173. package/src/modules/workflows/cli.ts +0 -111
  174. package/src/modules/workflows/data/entities.ts +0 -124
  175. package/src/modules/workflows/data/validators.ts +0 -138
  176. package/src/modules/workflows/examples/checkout-demo-definition.json +5 -1
  177. package/src/modules/workflows/i18n/en.json +0 -71
  178. package/src/modules/workflows/lib/__tests__/activity-executor.test.ts +36 -43
  179. package/src/modules/workflows/lib/__tests__/transition-handler.test.ts +90 -170
  180. package/src/modules/workflows/lib/activity-executor.ts +16 -129
  181. package/src/modules/workflows/lib/graph-utils.ts +2 -117
  182. package/src/modules/workflows/lib/seeds.ts +12 -50
  183. package/src/modules/workflows/lib/start-validator.ts +28 -38
  184. package/src/modules/workflows/lib/transition-handler.ts +55 -208
  185. package/src/modules/workflows/migrations/Migration20251207131955.ts +77 -143
  186. package/src/modules/workflows/setup.ts +15 -0
  187. package/dist/generated/entities/workflow_event_trigger/index.js +0 -33
  188. package/dist/generated/entities/workflow_event_trigger/index.js.map +0 -7
  189. package/dist/modules/auth/events.js +0 -30
  190. package/dist/modules/auth/events.js.map +0 -7
  191. package/dist/modules/business_rules/api/execute/[ruleId]/route.js +0 -145
  192. package/dist/modules/business_rules/api/execute/[ruleId]/route.js.map +0 -7
  193. package/dist/modules/catalog/events.js +0 -34
  194. package/dist/modules/catalog/events.js.map +0 -7
  195. package/dist/modules/customers/events.js +0 -49
  196. package/dist/modules/customers/events.js.map +0 -7
  197. package/dist/modules/directory/events.js +0 -23
  198. package/dist/modules/directory/events.js.map +0 -7
  199. package/dist/modules/sales/events.js +0 -63
  200. package/dist/modules/sales/events.js.map +0 -7
  201. package/dist/modules/sales/lib/frontend/documentDataEvents.js +0 -25
  202. package/dist/modules/sales/lib/frontend/documentDataEvents.js.map +0 -7
  203. package/dist/modules/workflows/components/DefinitionTriggersEditor.js +0 -481
  204. package/dist/modules/workflows/components/DefinitionTriggersEditor.js.map +0 -7
  205. package/dist/modules/workflows/components/EventTriggersEditor.js +0 -553
  206. package/dist/modules/workflows/components/EventTriggersEditor.js.map +0 -7
  207. package/dist/modules/workflows/events.js +0 -38
  208. package/dist/modules/workflows/events.js.map +0 -7
  209. package/dist/modules/workflows/examples/order-approval-definition.json +0 -257
  210. package/dist/modules/workflows/examples/order-approval-guard-rules.json +0 -32
  211. package/dist/modules/workflows/lib/event-trigger-service.js +0 -308
  212. package/dist/modules/workflows/lib/event-trigger-service.js.map +0 -7
  213. package/dist/modules/workflows/migrations/Migration20260123143500.js +0 -36
  214. package/dist/modules/workflows/migrations/Migration20260123143500.js.map +0 -7
  215. package/dist/modules/workflows/subscribers/event-trigger.js +0 -78
  216. package/dist/modules/workflows/subscribers/event-trigger.js.map +0 -7
  217. package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js +0 -323
  218. package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js.map +0 -7
  219. package/dist/modules/workflows/widgets/injection/order-approval/widget.js +0 -17
  220. package/dist/modules/workflows/widgets/injection/order-approval/widget.js.map +0 -7
  221. package/dist/modules/workflows/widgets/injection-table.js +0 -19
  222. package/dist/modules/workflows/widgets/injection-table.js.map +0 -7
  223. package/generated/entities/workflow_event_trigger/index.ts +0 -15
  224. package/src/modules/auth/events.ts +0 -39
  225. package/src/modules/business_rules/api/execute/[ruleId]/route.ts +0 -163
  226. package/src/modules/catalog/events.ts +0 -45
  227. package/src/modules/customers/events.ts +0 -63
  228. package/src/modules/directory/events.ts +0 -31
  229. package/src/modules/sales/events.ts +0 -82
  230. package/src/modules/sales/lib/frontend/documentDataEvents.ts +0 -28
  231. package/src/modules/workflows/components/DefinitionTriggersEditor.tsx +0 -581
  232. package/src/modules/workflows/components/EventTriggersEditor.tsx +0 -664
  233. package/src/modules/workflows/events.ts +0 -49
  234. package/src/modules/workflows/examples/order-approval-definition.json +0 -257
  235. package/src/modules/workflows/examples/order-approval-guard-rules.json +0 -32
  236. package/src/modules/workflows/lib/event-trigger-service.ts +0 -557
  237. package/src/modules/workflows/migrations/Migration20260123143500.ts +0 -38
  238. package/src/modules/workflows/subscribers/event-trigger.ts +0 -109
  239. package/src/modules/workflows/widgets/injection/order-approval/widget.client.tsx +0 -446
  240. package/src/modules/workflows/widgets/injection/order-approval/widget.ts +0 -16
  241. package/src/modules/workflows/widgets/injection-table.ts +0 -21
@@ -4,13 +4,8 @@ import type { AwilixContainer } from 'awilix'
4
4
  import { Role, RoleAcl } from '@open-mercato/core/modules/auth/data/entities'
5
5
  import type { RbacService } from '@open-mercato/core/modules/auth/services/rbacService'
6
6
  import { reindexModules } from '@open-mercato/core/modules/configs/lib/reindex-helpers'
7
- import { installExampleCatalogData, type CatalogSeedScope } from '@open-mercato/core/modules/catalog/lib/seeds'
8
- import { seedSalesExamples } from '@open-mercato/core/modules/sales/seed/examples'
9
- import { seedExampleCurrencies } from '@open-mercato/core/modules/currencies/lib/seeds'
10
- import { seedExampleWorkflows } from '@open-mercato/core/modules/workflows/lib/seeds'
11
- import { seedPlannerAvailabilityRuleSetDefaults, seedPlannerUnavailabilityReasons } from '@open-mercato/core/modules/planner/lib/seeds'
12
- import { seedResourcesAddressTypes, seedResourcesCapacityUnits, seedResourcesResourceExamples } from '@open-mercato/core/modules/resources/lib/seeds'
13
- import { seedStaffTeamExamples } from '@open-mercato/core/modules/staff/lib/seeds'
7
+ // Optional module imports are loaded dynamically inside each upgrade action
8
+ // so the app does not crash when a module is disabled.
14
9
  import { collectCrudCacheStats, purgeCrudCacheSegment } from '@open-mercato/shared/lib/crud/cache-stats'
15
10
  import { isCrudCacheEnabled, resolveCrudCache } from '@open-mercato/shared/lib/crud/cache'
16
11
  import * as semver from 'semver'
@@ -91,7 +86,9 @@ async function ensureVectorSearchEncryptionMap(
91
86
  return true
92
87
  }
93
88
 
94
- export type UpgradeActionContext = CatalogSeedScope & {
89
+ export type UpgradeActionContext = {
90
+ tenantId: string
91
+ organizationId: string
95
92
  container: AwilixContainer
96
93
  em: EntityManager
97
94
  }
@@ -155,6 +152,14 @@ export const upgradeActions: UpgradeActionDefinition[] = [
155
152
  successKey: 'upgrades.v034.success',
156
153
  loadingKey: 'upgrades.v034.loading',
157
154
  async run({ container, em, tenantId, organizationId }) {
155
+ let installExampleCatalogData: typeof import('@open-mercato/core/modules/catalog/lib/seeds')['installExampleCatalogData'] | undefined
156
+ try {
157
+ const catalogSeeds = await import('@open-mercato/core/modules/catalog/lib/seeds')
158
+ installExampleCatalogData = catalogSeeds.installExampleCatalogData
159
+ } catch {
160
+ console.warn('[upgrade-actions] catalog module not available, skipping catalog example data')
161
+ return
162
+ }
158
163
  await installExampleCatalogData(container, { tenantId, organizationId }, em)
159
164
  const vectorService = resolveVectorService(container)
160
165
  await reindexModules(em, ['catalog'], { tenantId, organizationId, vectorService })
@@ -214,8 +219,16 @@ export const upgradeActions: UpgradeActionDefinition[] = [
214
219
  successKey: 'upgrades.v036.success',
215
220
  loadingKey: 'upgrades.v036.loading',
216
221
  async run({ container, em, tenantId, organizationId }) {
222
+ let seedSalesExamples: typeof import('@open-mercato/core/modules/sales/seed/examples')['seedSalesExamples'] | undefined
223
+ try {
224
+ const salesSeeds = await import('@open-mercato/core/modules/sales/seed/examples')
225
+ seedSalesExamples = salesSeeds.seedSalesExamples
226
+ } catch {
227
+ console.warn('[upgrade-actions] sales module not available, skipping sales example data')
228
+ return
229
+ }
217
230
  await em.transactional(async (tem) => {
218
- await seedSalesExamples(tem, container, { tenantId, organizationId })
231
+ await seedSalesExamples!(tem, container, { tenantId, organizationId })
219
232
  })
220
233
  const vectorService = resolveVectorService(container)
221
234
  await reindexModules(em, ['sales', 'catalog'], { tenantId, organizationId, vectorService })
@@ -262,9 +275,26 @@ export const upgradeActions: UpgradeActionDefinition[] = [
262
275
  async run({ container, em, tenantId, organizationId }) {
263
276
  const normalizedTenantId = tenantId.trim()
264
277
  const scope = { tenantId, organizationId }
278
+
279
+ let seedExampleCurrencies: typeof import('@open-mercato/core/modules/currencies/lib/seeds')['seedExampleCurrencies'] | undefined
280
+ try {
281
+ const currenciesSeeds = await import('@open-mercato/core/modules/currencies/lib/seeds')
282
+ seedExampleCurrencies = currenciesSeeds.seedExampleCurrencies
283
+ } catch {
284
+ console.warn('[upgrade-actions] currencies module not available, skipping currency seeding')
285
+ }
286
+
287
+ let seedExampleWorkflows: typeof import('@open-mercato/core/modules/workflows/lib/seeds')['seedExampleWorkflows'] | undefined
288
+ try {
289
+ const workflowsSeeds = await import('@open-mercato/core/modules/workflows/lib/seeds')
290
+ seedExampleWorkflows = workflowsSeeds.seedExampleWorkflows
291
+ } catch {
292
+ console.warn('[upgrade-actions] workflows module not available, skipping workflow seeding')
293
+ }
294
+
265
295
  await em.transactional(async (tem) => {
266
- await seedExampleCurrencies(tem, scope)
267
- await seedExampleWorkflows(tem, scope)
296
+ if (seedExampleCurrencies) await seedExampleCurrencies(tem, scope)
297
+ if (seedExampleWorkflows) await seedExampleWorkflows(tem, scope)
268
298
 
269
299
  const adminRole = await tem.findOne(Role, { name: 'admin', tenantId: normalizedTenantId, deletedAt: null })
270
300
  if (!adminRole) return
@@ -315,13 +345,44 @@ export const upgradeActions: UpgradeActionDefinition[] = [
315
345
  async run({ container, em, tenantId, organizationId }) {
316
346
  const normalizedTenantId = tenantId.trim()
317
347
  const scope = { tenantId, organizationId }
348
+
349
+ let seedPlannerAvailabilityRuleSetDefaults: typeof import('@open-mercato/core/modules/planner/lib/seeds')['seedPlannerAvailabilityRuleSetDefaults'] | undefined
350
+ let seedPlannerUnavailabilityReasons: typeof import('@open-mercato/core/modules/planner/lib/seeds')['seedPlannerUnavailabilityReasons'] | undefined
351
+ try {
352
+ const plannerSeeds = await import('@open-mercato/core/modules/planner/lib/seeds')
353
+ seedPlannerAvailabilityRuleSetDefaults = plannerSeeds.seedPlannerAvailabilityRuleSetDefaults
354
+ seedPlannerUnavailabilityReasons = plannerSeeds.seedPlannerUnavailabilityReasons
355
+ } catch {
356
+ console.warn('[upgrade-actions] planner module not available, skipping planner seeding')
357
+ }
358
+
359
+ let seedStaffTeamExamples: typeof import('@open-mercato/core/modules/staff/lib/seeds')['seedStaffTeamExamples'] | undefined
360
+ try {
361
+ const staffSeeds = await import('@open-mercato/core/modules/staff/lib/seeds')
362
+ seedStaffTeamExamples = staffSeeds.seedStaffTeamExamples
363
+ } catch {
364
+ console.warn('[upgrade-actions] staff module not available, skipping staff seeding')
365
+ }
366
+
367
+ let seedResourcesAddressTypes: typeof import('@open-mercato/core/modules/resources/lib/seeds')['seedResourcesAddressTypes'] | undefined
368
+ let seedResourcesCapacityUnits: typeof import('@open-mercato/core/modules/resources/lib/seeds')['seedResourcesCapacityUnits'] | undefined
369
+ let seedResourcesResourceExamples: typeof import('@open-mercato/core/modules/resources/lib/seeds')['seedResourcesResourceExamples'] | undefined
370
+ try {
371
+ const resourcesSeeds = await import('@open-mercato/core/modules/resources/lib/seeds')
372
+ seedResourcesAddressTypes = resourcesSeeds.seedResourcesAddressTypes
373
+ seedResourcesCapacityUnits = resourcesSeeds.seedResourcesCapacityUnits
374
+ seedResourcesResourceExamples = resourcesSeeds.seedResourcesResourceExamples
375
+ } catch {
376
+ console.warn('[upgrade-actions] resources module not available, skipping resources seeding')
377
+ }
378
+
318
379
  await em.transactional(async (tem) => {
319
- await seedPlannerAvailabilityRuleSetDefaults(tem, scope)
320
- await seedPlannerUnavailabilityReasons(tem, scope)
321
- await seedStaffTeamExamples(tem, scope)
322
- await seedResourcesCapacityUnits(tem, scope)
323
- await seedResourcesAddressTypes(tem, scope)
324
- await seedResourcesResourceExamples(tem, scope)
380
+ if (seedPlannerAvailabilityRuleSetDefaults) await seedPlannerAvailabilityRuleSetDefaults(tem, scope)
381
+ if (seedPlannerUnavailabilityReasons) await seedPlannerUnavailabilityReasons(tem, scope)
382
+ if (seedStaffTeamExamples) await seedStaffTeamExamples(tem, scope)
383
+ if (seedResourcesCapacityUnits) await seedResourcesCapacityUnits(tem, scope)
384
+ if (seedResourcesAddressTypes) await seedResourcesAddressTypes(tem, scope)
385
+ if (seedResourcesResourceExamples) await seedResourcesResourceExamples(tem, scope)
325
386
 
326
387
  const adminRole = await tem.findOne(Role, { name: 'admin', tenantId: normalizedTenantId, deletedAt: null })
327
388
  if (!adminRole) return
@@ -0,0 +1,14 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+
3
+ export const setup: ModuleSetupConfig = {
4
+ defaultRoleFeatures: {
5
+ admin: [
6
+ 'configs.system_status.view',
7
+ 'configs.cache.view',
8
+ 'configs.cache.manage',
9
+ 'configs.manage',
10
+ ],
11
+ },
12
+ }
13
+
14
+ export default setup
@@ -0,0 +1,15 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+ import { seedExampleCurrencies } from './lib/seeds'
3
+
4
+ export const setup: ModuleSetupConfig = {
5
+ seedDefaults: async (ctx) => {
6
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
7
+ await seedExampleCurrencies(ctx.em, scope)
8
+ },
9
+
10
+ defaultRoleFeatures: {
11
+ admin: ['currencies.*'],
12
+ },
13
+ }
14
+
15
+ export default setup
@@ -0,0 +1,36 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+ import { seedCustomerDictionaries, seedCurrencyDictionary, seedCustomerExamples } from './cli'
3
+
4
+ export const setup: ModuleSetupConfig = {
5
+ seedDefaults: async (ctx) => {
6
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
7
+ await seedCustomerDictionaries(ctx.em, scope)
8
+ await seedCurrencyDictionary(ctx.em, scope)
9
+ },
10
+
11
+ seedExamples: async (ctx) => {
12
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
13
+ await seedCustomerExamples(ctx.em, ctx.container, scope)
14
+ },
15
+
16
+ defaultRoleFeatures: {
17
+ admin: [
18
+ 'customers.*',
19
+ 'customers.people.view',
20
+ 'customers.people.manage',
21
+ 'customers.companies.view',
22
+ 'customers.companies.manage',
23
+ 'customers.deals.view',
24
+ 'customers.deals.manage',
25
+ ],
26
+ employee: [
27
+ 'customers.*',
28
+ 'customers.people.view',
29
+ 'customers.people.manage',
30
+ 'customers.companies.view',
31
+ 'customers.companies.manage',
32
+ ],
33
+ },
34
+ }
35
+
36
+ export default setup
@@ -0,0 +1,10 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+
3
+ export const setup: ModuleSetupConfig = {
4
+ defaultRoleFeatures: {
5
+ admin: ['dashboards.*', 'dashboards.admin.assign-widgets', 'analytics.view'],
6
+ employee: ['dashboards.view', 'dashboards.configure', 'analytics.view'],
7
+ },
8
+ }
9
+
10
+ export default setup
@@ -0,0 +1,10 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+
3
+ export const setup: ModuleSetupConfig = {
4
+ defaultRoleFeatures: {
5
+ admin: ['dictionaries.view', 'dictionaries.manage'],
6
+ employee: ['dictionaries.view'],
7
+ },
8
+ }
9
+
10
+ export default setup
@@ -0,0 +1,10 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+
3
+ export const setup: ModuleSetupConfig = {
4
+ defaultRoleFeatures: {
5
+ superadmin: ['directory.tenants.*'],
6
+ admin: ['directory.organizations.view', 'directory.organizations.manage'],
7
+ },
8
+ }
9
+
10
+ export default setup
@@ -0,0 +1,9 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+
3
+ export const setup: ModuleSetupConfig = {
4
+ defaultRoleFeatures: {
5
+ admin: ['entities.*'],
6
+ },
7
+ }
8
+
9
+ export default setup
@@ -0,0 +1,9 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+
3
+ export const setup: ModuleSetupConfig = {
4
+ defaultRoleFeatures: {
5
+ admin: ['feature_toggles.*'],
6
+ },
7
+ }
8
+
9
+ export default setup
@@ -0,0 +1,10 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+
3
+ export const setup: ModuleSetupConfig = {
4
+ defaultRoleFeatures: {
5
+ admin: ['perspectives.use', 'perspectives.role_defaults'],
6
+ employee: ['perspectives.use'],
7
+ },
8
+ }
9
+
10
+ export default setup
@@ -0,0 +1,21 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+ import { seedPlannerUnavailabilityReasons, seedPlannerAvailabilityRuleSetDefaults } from './lib/seeds'
3
+
4
+ export const setup: ModuleSetupConfig = {
5
+ seedDefaults: async (ctx) => {
6
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
7
+ await seedPlannerUnavailabilityReasons(ctx.em, scope)
8
+ },
9
+
10
+ seedExamples: async (ctx) => {
11
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
12
+ await seedPlannerAvailabilityRuleSetDefaults(ctx.em, scope)
13
+ },
14
+
15
+ defaultRoleFeatures: {
16
+ admin: ['planner.*'],
17
+ employee: ['planner.view'],
18
+ },
19
+ }
20
+
21
+ export default setup
@@ -0,0 +1,9 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+
3
+ export const setup: ModuleSetupConfig = {
4
+ defaultRoleFeatures: {
5
+ admin: ['query_index.*'],
6
+ },
7
+ }
8
+
9
+ export default setup
@@ -0,0 +1,21 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+ import { seedResourcesAddressTypes, seedResourcesCapacityUnits, seedResourcesResourceExamples } from './lib/seeds'
3
+
4
+ export const setup: ModuleSetupConfig = {
5
+ seedDefaults: async (ctx) => {
6
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
7
+ await seedResourcesAddressTypes(ctx.em, scope)
8
+ },
9
+
10
+ seedExamples: async (ctx) => {
11
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
12
+ await seedResourcesCapacityUnits(ctx.em, scope)
13
+ await seedResourcesResourceExamples(ctx.em, scope)
14
+ },
15
+
16
+ defaultRoleFeatures: {
17
+ admin: ['resources.*'],
18
+ },
19
+ }
20
+
21
+ export default setup
@@ -1,7 +1,6 @@
1
1
  export const features = [
2
2
  { id: 'sales.orders.view', title: 'View sales orders', module: 'sales' },
3
3
  { id: 'sales.orders.manage', title: 'Manage sales orders', module: 'sales' },
4
- { id: 'sales.orders.approve', title: 'Approve sales orders', module: 'sales' },
5
4
  { id: 'sales.quotes.view', title: 'View sales quotes', module: 'sales' },
6
5
  { id: 'sales.quotes.manage', title: 'Manage sales quotes', module: 'sales' },
7
6
  { id: 'sales.shipments.manage', title: 'Manage order shipments', module: 'sales' },
@@ -50,9 +50,6 @@ import {
50
50
  emitSalesDocumentTotalsRefresh,
51
51
  subscribeSalesDocumentTotalsRefresh,
52
52
  } from '@open-mercato/core/modules/sales/lib/frontend/documentTotalsEvents'
53
- import {
54
- subscribeSalesDocumentDataRefresh,
55
- } from '@open-mercato/core/modules/sales/lib/frontend/documentDataEvents'
56
53
  import type { CommentSummary, SectionAction } from '@open-mercato/ui/backend/detail'
57
54
  import { ICON_SUGGESTIONS } from '@open-mercato/core/modules/customers/lib/dictionaries'
58
55
  import { readMarkdownPreferenceCookie, writeMarkdownPreferenceCookie } from '@open-mercato/core/modules/customers/lib/markdownPreference'
@@ -2604,19 +2601,6 @@ export default function SalesDocumentDetailPage({
2604
2601
  [kind, record?.id, refreshDocumentTotals],
2605
2602
  )
2606
2603
 
2607
- // Subscribe to document data refresh events (e.g., from workflow status updates)
2608
- React.useEffect(
2609
- () =>
2610
- subscribeSalesDocumentDataRefresh((detail) => {
2611
- if (!record?.id) return
2612
- if (detail.documentId !== record.id) return
2613
- if (detail.kind && detail.kind !== kind) return
2614
- // Increment reloadKey to trigger a full document reload
2615
- setReloadKey((prev) => prev + 1)
2616
- }),
2617
- [kind, record?.id],
2618
- )
2619
-
2620
2604
  const statusDictionaryMap = React.useMemo(
2621
2605
  () =>
2622
2606
  createDictionaryMap(
@@ -4,7 +4,7 @@ import { randomUUID } from 'crypto'
4
4
  import { z } from 'zod'
5
5
  import { registerCommand } from '@open-mercato/shared/lib/commands'
6
6
  import type { CommandHandler } from '@open-mercato/shared/lib/commands'
7
- import { emitCrudSideEffects, requireId, type CrudEventsConfig } from '@open-mercato/shared/lib/commands/helpers'
7
+ import { emitCrudSideEffects, requireId } from '@open-mercato/shared/lib/commands/helpers'
8
8
  import type { EntityManager } from '@mikro-orm/postgresql'
9
9
  import type { EventBus } from '@open-mercato/events'
10
10
  import type { DataEngine } from '@open-mercato/shared/lib/data/engine'
@@ -89,29 +89,6 @@ import { resolveStatusEntryIdByValue } from '../lib/statusHelpers'
89
89
  import { SalesDocumentNumberGenerator } from '../services/salesDocumentNumberGenerator'
90
90
  import { loadSalesSettings } from './settings'
91
91
 
92
- // CRUD events configuration for workflow triggers
93
- const orderCrudEvents: CrudEventsConfig<SalesOrder> = {
94
- module: 'sales',
95
- entity: 'orders',
96
- persistent: true,
97
- buildPayload: (ctx) => ({
98
- id: ctx.identifiers.id,
99
- organizationId: ctx.identifiers.organizationId,
100
- tenantId: ctx.identifiers.tenantId,
101
- }),
102
- }
103
-
104
- const quoteCrudEvents: CrudEventsConfig<SalesQuote> = {
105
- module: 'sales',
106
- entity: 'quotes',
107
- persistent: true,
108
- buildPayload: (ctx) => ({
109
- id: ctx.identifiers.id,
110
- organizationId: ctx.identifiers.organizationId,
111
- tenantId: ctx.identifiers.tenantId,
112
- }),
113
- }
114
-
115
92
  type DocumentAddressSnapshot = {
116
93
  id: string
117
94
  organizationId: string
@@ -3134,31 +3111,6 @@ const createQuoteCommand: CommandHandler<QuoteCreateInput, { quoteId: string }>
3134
3111
  })
3135
3112
  await em.flush()
3136
3113
 
3137
- // Emit CRUD side effects to trigger workflow event listeners
3138
- const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
3139
- await emitCrudSideEffects({
3140
- dataEngine,
3141
- action: 'created',
3142
- entity: quote,
3143
- identifiers: {
3144
- id: quote.id,
3145
- organizationId: quote.organizationId,
3146
- tenantId: quote.tenantId,
3147
- },
3148
- events: quoteCrudEvents,
3149
- indexer: { entityType: E.sales.sales_quote },
3150
- })
3151
-
3152
- // Invalidate cache
3153
- const resourceKind = deriveResourceFromCommandId(createQuoteCommand.id) ?? 'sales.quote'
3154
- await invalidateCrudCache(
3155
- ctx.container,
3156
- resourceKind,
3157
- { id: quote.id, organizationId: quote.organizationId, tenantId: quote.tenantId },
3158
- ctx.auth?.tenantId ?? null,
3159
- 'created'
3160
- )
3161
-
3162
3114
  return { quoteId: quote.id }
3163
3115
  },
3164
3116
  captureAfter: async (_input, result, ctx) => {
@@ -3830,31 +3782,6 @@ const createOrderCommand: CommandHandler<OrderCreateInput, { orderId: string }>
3830
3782
  })
3831
3783
  await em.flush()
3832
3784
 
3833
- // Emit CRUD side effects to trigger workflow event listeners
3834
- const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
3835
- await emitCrudSideEffects({
3836
- dataEngine,
3837
- action: 'created',
3838
- entity: order,
3839
- identifiers: {
3840
- id: order.id,
3841
- organizationId: order.organizationId,
3842
- tenantId: order.tenantId,
3843
- },
3844
- events: orderCrudEvents,
3845
- indexer: { entityType: E.sales.sales_order },
3846
- })
3847
-
3848
- // Invalidate cache
3849
- const resourceKind = deriveResourceFromCommandId(createOrderCommand.id) ?? 'sales.order'
3850
- await invalidateCrudCache(
3851
- ctx.container,
3852
- resourceKind,
3853
- { id: order.id, organizationId: order.organizationId, tenantId: order.tenantId },
3854
- ctx.auth?.tenantId ?? null,
3855
- 'created'
3856
- )
3857
-
3858
3785
  return { orderId: order.id }
3859
3786
  },
3860
3787
  captureAfter: async (_input, result, ctx) => {
@@ -125,9 +125,6 @@ type SeedScope = { tenantId: string; organizationId: string }
125
125
 
126
126
  const ORDER_STATUS_DEFAULTS: SalesDictionarySeed[] = [
127
127
  { value: 'draft', label: 'Draft', color: '#94a3b8', icon: 'lucide:file-pen-line' },
128
- { value: 'pending_approval', label: 'Pending Approval', color: '#f59e0b', icon: 'lucide:hourglass' },
129
- { value: 'approved', label: 'Approved', color: '#16a34a', icon: 'lucide:check-circle' },
130
- { value: 'rejected', label: 'Rejected', color: '#ef4444', icon: 'lucide:x-circle' },
131
128
  { value: 'sent', label: 'Sent', color: '#0ea5e9', icon: 'lucide:send' },
132
129
  { value: 'confirmed', label: 'Confirmed', color: '#2563eb', icon: 'lucide:badge-check' },
133
130
  { value: 'in_fulfillment', label: 'In fulfillment', color: '#f59e0b', icon: 'lucide:loader-2' },
@@ -0,0 +1,108 @@
1
+ import type { EntityManager } from '@mikro-orm/postgresql'
2
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
3
+ import { SalesSettings, SalesDocumentSequence, SalesTaxRate } from './data/entities'
4
+ import { DEFAULT_ORDER_NUMBER_FORMAT, DEFAULT_QUOTE_NUMBER_FORMAT } from './lib/documentNumberTokens'
5
+ import { seedSalesStatusDictionaries, seedSalesAdjustmentKinds } from './lib/dictionaries'
6
+ import { ensureExampleShippingMethods, ensureExamplePaymentMethods } from './seed/examples-data'
7
+ import { seedSalesExamples } from './seed/examples'
8
+
9
+ type SeedScope = { tenantId: string; organizationId: string }
10
+
11
+ const DEFAULT_TAX_RATES = [
12
+ { code: 'vat-23', name: '23% VAT', rate: '23' },
13
+ { code: 'vat-0', name: '0% VAT', rate: '0' },
14
+ ] as const
15
+
16
+ async function seedSalesTaxRates(em: EntityManager, scope: SeedScope): Promise<void> {
17
+ await em.transactional(async (tem) => {
18
+ const existing = await tem.find(SalesTaxRate, {
19
+ tenantId: scope.tenantId,
20
+ organizationId: scope.organizationId,
21
+ deletedAt: null,
22
+ })
23
+ const existingCodes = new Set(existing.map((rate) => rate.code))
24
+ const hasDefault = existing.some((rate) => rate.isDefault)
25
+ const now = new Date()
26
+ let isFirst = !hasDefault
27
+
28
+ for (const seed of DEFAULT_TAX_RATES) {
29
+ if (existingCodes.has(seed.code)) continue
30
+ tem.persist(
31
+ tem.create(SalesTaxRate, {
32
+ tenantId: scope.tenantId,
33
+ organizationId: scope.organizationId,
34
+ code: seed.code,
35
+ name: seed.name,
36
+ rate: seed.rate,
37
+ priority: 0,
38
+ isCompound: false,
39
+ isDefault: isFirst,
40
+ createdAt: now,
41
+ updatedAt: now,
42
+ })
43
+ )
44
+ isFirst = false
45
+ }
46
+ })
47
+ }
48
+
49
+ export const setup: ModuleSetupConfig = {
50
+ defaultRoleFeatures: {
51
+ admin: ['sales.*'],
52
+ employee: ['sales.*'],
53
+ },
54
+
55
+ async onTenantCreated({ em, tenantId, organizationId }) {
56
+ const exists = await em.findOne(SalesSettings, { tenantId, organizationId })
57
+ if (!exists) {
58
+ em.persist(
59
+ em.create(SalesSettings, {
60
+ tenantId,
61
+ organizationId,
62
+ orderNumberFormat: DEFAULT_ORDER_NUMBER_FORMAT,
63
+ quoteNumberFormat: DEFAULT_QUOTE_NUMBER_FORMAT,
64
+ createdAt: new Date(),
65
+ updatedAt: new Date(),
66
+ })
67
+ )
68
+ }
69
+
70
+ for (const kind of ['order', 'quote'] as const) {
71
+ const seq = await em.findOne(SalesDocumentSequence, {
72
+ tenantId,
73
+ organizationId,
74
+ documentKind: kind,
75
+ })
76
+ if (!seq) {
77
+ em.persist(
78
+ em.create(SalesDocumentSequence, {
79
+ tenantId,
80
+ organizationId,
81
+ documentKind: kind,
82
+ currentValue: 0,
83
+ createdAt: new Date(),
84
+ updatedAt: new Date(),
85
+ })
86
+ )
87
+ }
88
+ }
89
+
90
+ await em.flush()
91
+ },
92
+
93
+ async seedDefaults({ em, tenantId, organizationId }) {
94
+ const scope = { tenantId, organizationId }
95
+ await seedSalesTaxRates(em, scope)
96
+ await seedSalesStatusDictionaries(em, scope)
97
+ await seedSalesAdjustmentKinds(em, scope)
98
+ await ensureExampleShippingMethods(em, scope)
99
+ await ensureExamplePaymentMethods(em, scope)
100
+ },
101
+
102
+ async seedExamples({ em, container, tenantId, organizationId }) {
103
+ const scope = { tenantId, organizationId }
104
+ await seedSalesExamples(em, container, scope)
105
+ },
106
+ }
107
+
108
+ export default setup
@@ -0,0 +1,27 @@
1
+ import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
+ import { seedStaffAddressTypes, seedStaffTeamExamples } from './lib/seeds'
3
+
4
+ export const setup: ModuleSetupConfig = {
5
+ seedDefaults: async (ctx) => {
6
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
7
+ await seedStaffAddressTypes(ctx.em, scope)
8
+ },
9
+
10
+ seedExamples: async (ctx) => {
11
+ const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
12
+ await seedStaffTeamExamples(ctx.em, scope)
13
+ },
14
+
15
+ defaultRoleFeatures: {
16
+ admin: ['staff.*', 'staff.leave_requests.manage'],
17
+ employee: [
18
+ 'staff.leave_requests.send',
19
+ 'staff.my_availability.view',
20
+ 'staff.my_availability.manage',
21
+ 'staff.my_leave_requests.view',
22
+ 'staff.my_leave_requests.send',
23
+ ],
24
+ },
25
+ }
26
+
27
+ export default setup
@@ -19,8 +19,6 @@ export const features = [
19
19
  { id: 'workflows.tasks.complete', title: 'Complete workflow tasks', module: moduleId },
20
20
  { id: 'workflows.signals.send', title: 'Send workflow signals', module: moduleId },
21
21
  { id: 'workflows.events.view', title: 'View workflow events', module: moduleId },
22
- // Note: Event triggers are now embedded in workflow definitions.
23
- // Trigger management permissions are covered by workflows.definitions.edit
24
22
  ]
25
23
 
26
24
  export default features
@@ -194,14 +194,11 @@ describe('Workflow Instances API', () => {
194
194
  const request = new NextRequest('http://localhost/api/workflows/instances?entityType=order&entityId=order-123')
195
195
  await listInstances(request)
196
196
 
197
- // The implementation uses JSONB $contains queries for metadata filtering
198
197
  expect(mockEm.findAndCount).toHaveBeenCalledWith(
199
198
  WorkflowInstance,
200
199
  expect.objectContaining({
201
- $and: expect.arrayContaining([
202
- { metadata: { $contains: { entityType: 'order' } } },
203
- { metadata: { $contains: { entityId: 'order-123' } } },
204
- ]),
200
+ 'metadata.entityType': 'order',
201
+ 'metadata.entityId': 'order-123',
205
202
  }),
206
203
  expect.any(Object)
207
204
  )