@open-mercato/events 0.6.8-develop.6893.1.7af3b3a72d → 0.6.8-develop.6898.1.8b42ed5e41

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/events",
3
- "version": "0.6.8-develop.6893.1.7af3b3a72d",
3
+ "version": "0.6.8-develop.6898.1.8b42ed5e41",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,8 +33,8 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "@open-mercato/queue": "0.6.8-develop.6893.1.7af3b3a72d",
37
- "@open-mercato/shared": "0.6.8-develop.6893.1.7af3b3a72d",
36
+ "@open-mercato/queue": "0.6.8-develop.6898.1.8b42ed5e41",
37
+ "@open-mercato/shared": "0.6.8-develop.6898.1.8b42ed5e41",
38
38
  "pg": "8.22.0"
39
39
  },
40
40
  "devDependencies": {
@@ -108,6 +108,26 @@ describe('Event bus single-delivery (OM_EVENTS_SINGLE_DELIVERY)', () => {
108
108
  expect(Array.isArray(list)).toBe(true)
109
109
  expect(list.length).toBeGreaterThanOrEqual(1)
110
110
  })
111
+
112
+ test('flag ON: the queued job keeps the trusted scope from the emit options', async () => {
113
+ // The worker is the sole dispatcher for persistent subscribers here, and it
114
+ // builds the subscriber context from the job's `options` alone. If enqueue
115
+ // dropped them, every wildcard persistent subscriber would receive a
116
+ // null-scoped context and bail out before matching.
117
+ process.env.OM_EVENTS_SINGLE_DELIVERY = 'true'
118
+ const queuePath = path.join(path.resolve('.mercato/queue', 'events'), 'queue.json')
119
+ const calls: string[] = []
120
+ const bus = createEventBus({ resolve: ((name: string) => name) as never })
121
+ bus.registerModuleSubscribers([makeSub('persistent-sub', 'demo', true, calls)])
122
+
123
+ await bus.emit('demo', { a: 1 }, { persistent: true, tenantId: 'tenant-1', organizationId: 'org-1' })
124
+
125
+ const list = JSON.parse(fs.readFileSync(queuePath, 'utf8'))
126
+ expect(list[0].payload).toMatchObject({
127
+ event: 'demo',
128
+ options: { persistent: true, tenantId: 'tenant-1', organizationId: 'org-1' },
129
+ })
130
+ })
111
131
  })
112
132
 
113
133
  /**