@volontariapp/outbox 0.9.2 → 0.9.3-snap-18f07d0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+
9
+ - @volontariapp/shared@0.5.1
10
+
11
+ - Updated dependencies []:
12
+ - @volontariapp/messaging@2.3.0
13
+ - @volontariapp/database@3.2.0
14
+
3
15
  ## 0.9.2
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,6 @@
1
+ import { BaseRepository, EventQueueEntity, EventQueueModel, type Repository } from '@volontariapp/database';
2
+ import type { DataSource } from 'typeorm';
3
+ export declare class EventQueueRepository extends BaseRepository<EventQueueModel, EventQueueEntity, string> {
4
+ constructor(dataSourceOrRepository: DataSource | Repository<EventQueueModel>);
5
+ }
6
+ //# sourceMappingURL=event-queue.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-queue.repository.d.ts","sourceRoot":"","sources":["../../src/repositories/event-queue.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,qBAAa,oBAAqB,SAAQ,cAAc,CACtD,eAAe,EACf,gBAAgB,EAChB,MAAM,CACP;gBACa,sBAAsB,EAAE,UAAU,GAAG,UAAU,CAAC,eAAe,CAAC;CAW7E"}
@@ -0,0 +1,12 @@
1
+ import { BaseRepository, EventQueueEntity, EventQueueModel, } from '@volontariapp/database';
2
+ export class EventQueueRepository extends BaseRepository {
3
+ constructor(dataSourceOrRepository) {
4
+ if ('getRepository' in dataSourceOrRepository) {
5
+ super(dataSourceOrRepository.getRepository(EventQueueModel), EventQueueEntity, EventQueueModel);
6
+ }
7
+ else {
8
+ super(dataSourceOrRepository, EventQueueEntity, EventQueueModel);
9
+ }
10
+ }
11
+ }
12
+ //# sourceMappingURL=event-queue.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-queue.repository.js","sourceRoot":"","sources":["../../src/repositories/event-queue.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,GAEhB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,OAAO,oBAAqB,SAAQ,cAIzC;IACC,YAAY,sBAAgE;QAC1E,IAAI,eAAe,IAAI,sBAAsB,EAAE,CAAC;YAC9C,KAAK,CACH,sBAAsB,CAAC,aAAa,CAAC,eAAe,CAAC,EACrD,gBAAgB,EAChB,eAAe,CAChB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,sBAAsB,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF"}
@@ -1,2 +1,3 @@
1
1
  export * from './jobs-outbox.repository.js';
2
+ export * from './event-queue.repository.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from './jobs-outbox.repository.js';
2
+ export * from './event-queue.repository.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=event-queue.repository.int.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-queue.repository.int.spec.d.ts","sourceRoot":"","sources":["../../../src/test/repositories/event-queue.repository.int.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ import { describe, it, expect, beforeEach, afterAll, beforeAll } from '@jest/globals';
2
+ import { databaseMapper, EventQueueModel, EventQueueEntity, OutboxStatus, } from '@volontariapp/database';
3
+ import { testDataSource, initializeTestDb, closeTestDb } from '../data-source.js';
4
+ import { EventQueueRepository } from '../../repositories/event-queue.repository.js';
5
+ import { randomUUID } from 'node:crypto';
6
+ import { Streams } from '@volontariapp/shared';
7
+ describe('EventQueueRepository Integration', () => {
8
+ let repository;
9
+ beforeAll(async () => {
10
+ await initializeTestDb();
11
+ databaseMapper.registerBidirectional(EventQueueModel, EventQueueEntity);
12
+ repository = new EventQueueRepository(testDataSource);
13
+ });
14
+ afterAll(async () => {
15
+ await closeTestDb().catch(() => undefined);
16
+ });
17
+ beforeEach(async () => {
18
+ const rawRepo = testDataSource.getRepository(EventQueueModel);
19
+ await rawRepo.createQueryBuilder().delete().execute();
20
+ });
21
+ it('should check if an event exists', async () => {
22
+ const eventId = randomUUID();
23
+ let exists = await repository.exists({ id: eventId });
24
+ expect(exists).toBe(false);
25
+ const rawRepo = testDataSource.getRepository(EventQueueModel);
26
+ const event = rawRepo.create({
27
+ id: eventId,
28
+ type: 'test-event',
29
+ emitter: 'test-emitter',
30
+ emitterId: '00000000-0000-0000-0000-000000000000',
31
+ target: 'test-target',
32
+ status: OutboxStatus.PENDING,
33
+ attempts: 0,
34
+ payload: { after: { action: 'test', data: {} } },
35
+ version: 1,
36
+ createdAt: new Date(),
37
+ updatedAt: new Date(),
38
+ targetServices: [Streams.EVENT_EVENTS],
39
+ });
40
+ await rawRepo.save(event);
41
+ exists = await repository.exists({ id: eventId });
42
+ expect(exists).toBe(true);
43
+ });
44
+ it('should find an event by id', async () => {
45
+ const eventId = randomUUID();
46
+ let entity = await repository.findById(eventId);
47
+ expect(entity).toBeNull();
48
+ const rawRepo = testDataSource.getRepository(EventQueueModel);
49
+ const event = rawRepo.create({
50
+ id: eventId,
51
+ type: 'test-event',
52
+ emitter: 'test-emitter',
53
+ emitterId: '00000000-0000-0000-0000-000000000000',
54
+ target: 'test-target',
55
+ status: OutboxStatus.PENDING,
56
+ attempts: 0,
57
+ payload: { after: { action: 'test', data: {} } },
58
+ version: 1,
59
+ createdAt: new Date(),
60
+ updatedAt: new Date(),
61
+ targetServices: [Streams.EVENT_EVENTS],
62
+ });
63
+ await rawRepo.save(event);
64
+ entity = await repository.findById(eventId);
65
+ expect(entity).toBeDefined();
66
+ expect(entity?.id).toBe(eventId);
67
+ expect(entity?.status).toBe(OutboxStatus.PENDING);
68
+ });
69
+ });
70
+ //# sourceMappingURL=event-queue.repository.int.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-queue.repository.int.spec.js","sourceRoot":"","sources":["../../../src/test/repositories/event-queue.repository.int.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,IAA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AC;QAE1B,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7B,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volontariapp/outbox",
3
- "version": "0.9.2",
3
+ "version": "0.9.3-snap-18f07d0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -42,11 +42,11 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@volontariapp/config": "3.1.1",
45
- "@volontariapp/database": "3.1.0",
45
+ "@volontariapp/database": "3.2.0-snap-18f07d0",
46
46
  "@volontariapp/errors": "0.5.2",
47
47
  "@volontariapp/logger": "0.2.5",
48
- "@volontariapp/messaging": "2.2.3",
49
- "@volontariapp/shared": "0.5.0",
48
+ "@volontariapp/messaging": "2.3.0-snap-18f07d0",
49
+ "@volontariapp/shared": "0.5.1-snap-18f07d0",
50
50
  "@volontariapp/testing": "1.0.1",
51
51
  "bullmq": "^5.76.5",
52
52
  "ioredis": "^5.10.1"