@volontariapp/outbox 0.3.0 → 0.3.1-snap-4524b24
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 +7 -0
- package/dist/consumers/event-queue.consumer.d.ts +3 -3
- package/dist/consumers/event-queue.consumer.d.ts.map +1 -1
- package/dist/consumers/event-queue.consumer.js.map +1 -1
- package/dist/consumers/jobs-outbox.consumer.d.ts +4 -3
- package/dist/consumers/jobs-outbox.consumer.d.ts.map +1 -1
- package/dist/consumers/jobs-outbox.consumer.js.map +1 -1
- package/dist/dispatchers/event-queue.dispatcher.d.ts +2 -2
- package/dist/dispatchers/event-queue.dispatcher.d.ts.map +1 -1
- package/dist/dispatchers/event-queue.dispatcher.js.map +1 -1
- package/dist/dispatchers/jobs-outbox.dispatcher.d.ts +2 -2
- package/dist/dispatchers/jobs-outbox.dispatcher.d.ts.map +1 -1
- package/dist/dispatchers/jobs-outbox.dispatcher.js.map +1 -1
- package/dist/test/consumers/event/event-queue.consumer.unit.spec.js +21 -10
- package/dist/test/consumers/event/event-queue.consumer.unit.spec.js.map +1 -1
- package/dist/test/consumers/jobs/jobs-outbox.consumer.unit.spec.js +23 -10
- package/dist/test/consumers/jobs/jobs-outbox.consumer.unit.spec.js.map +1 -1
- package/dist/test/dispatchers/event/event-queue.dispatcher.unit.spec.js +11 -5
- package/dist/test/dispatchers/event/event-queue.dispatcher.unit.spec.js.map +1 -1
- package/dist/test/dispatchers/event/event-queue.generics.int.spec.d.ts +2 -0
- package/dist/test/dispatchers/event/event-queue.generics.int.spec.d.ts.map +1 -0
- package/dist/test/dispatchers/event/event-queue.generics.int.spec.js +44 -0
- package/dist/test/dispatchers/event/event-queue.generics.int.spec.js.map +1 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.js +10 -4
- package/dist/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.js.map +1 -1
- package/dist/test/dispatchers/jobs/jobs-outbox.generics.int.spec.d.ts +2 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.generics.int.spec.d.ts.map +1 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.generics.int.spec.js +43 -0
- package/dist/test/dispatchers/jobs/jobs-outbox.generics.int.spec.js.map +1 -0
- package/dist/test/utils/helpers/event-queue-generics.helper.d.ts +9 -0
- package/dist/test/utils/helpers/event-queue-generics.helper.d.ts.map +1 -0
- package/dist/test/utils/helpers/event-queue-generics.helper.js +5 -0
- package/dist/test/utils/helpers/event-queue-generics.helper.js.map +1 -0
- package/dist/test/utils/helpers/event-queue-repository-mock.helper.d.ts +1 -1
- package/dist/test/utils/helpers/event-queue-repository-mock.helper.d.ts.map +1 -1
- package/dist/test/utils/helpers/event-queue-repository-mock.helper.js.map +1 -1
- package/dist/test/utils/helpers/jobs-outbox-generics.helper.d.ts +9 -0
- package/dist/test/utils/helpers/jobs-outbox-generics.helper.d.ts.map +1 -0
- package/dist/test/utils/helpers/jobs-outbox-generics.helper.js +5 -0
- package/dist/test/utils/helpers/jobs-outbox-generics.helper.js.map +1 -0
- package/dist/test/utils/helpers/jobs-outbox-repository-mock.helper.d.ts +1 -1
- package/dist/test/utils/helpers/jobs-outbox-repository-mock.helper.d.ts.map +1 -1
- package/dist/test/utils/helpers/jobs-outbox-repository-mock.helper.js.map +1 -1
- package/dist/test/utils/helpers/logger-mock.helper.d.ts +4 -2
- package/dist/test/utils/helpers/logger-mock.helper.d.ts.map +1 -1
- package/dist/test/utils/helpers/logger-mock.helper.js +2 -11
- package/dist/test/utils/helpers/logger-mock.helper.js.map +1 -1
- package/dist/test/utils/helpers/outbox-repository-mock.helper.d.ts +4 -9
- package/dist/test/utils/helpers/outbox-repository-mock.helper.d.ts.map +1 -1
- package/dist/test/utils/helpers/outbox-repository-mock.helper.js +2 -7
- package/dist/test/utils/helpers/outbox-repository-mock.helper.js.map +1 -1
- package/dist/test/utils/repositories/event-queue-test.repository.d.ts +2 -3
- package/dist/test/utils/repositories/event-queue-test.repository.d.ts.map +1 -1
- package/dist/test/utils/repositories/event-queue-test.repository.js +1 -1
- package/dist/test/utils/repositories/event-queue-test.repository.js.map +1 -1
- package/dist/test/utils/repositories/jobs-outbox-test.repository.d.ts +2 -3
- package/dist/test/utils/repositories/jobs-outbox-test.repository.d.ts.map +1 -1
- package/dist/test/utils/repositories/jobs-outbox-test.repository.js +1 -1
- package/dist/test/utils/repositories/jobs-outbox-test.repository.js.map +1 -1
- package/dist/writers/event-queue.writer.d.ts +2 -2
- package/dist/writers/event-queue.writer.d.ts.map +1 -1
- package/dist/writers/event-queue.writer.js.map +1 -1
- package/dist/writers/jobs-outbox.writer.d.ts +2 -2
- package/dist/writers/jobs-outbox.writer.d.ts.map +1 -1
- package/dist/writers/jobs-outbox.writer.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BaseRepository, EventQueueEntity, EventQueueModel } from '@volontariapp/database';
|
|
1
|
+
import type { BaseRepository, EventQueueEntity, EventQueueModel, EventType } from '@volontariapp/database';
|
|
2
2
|
import { OutboxConsumer } from '@volontariapp/database';
|
|
3
3
|
import type { Logger } from '@volontariapp/logger';
|
|
4
|
-
export declare class EventQueueConsumer extends OutboxConsumer<EventQueueModel, EventQueueEntity
|
|
5
|
-
constructor(logger: Logger, repository: BaseRepository<EventQueueModel, EventQueueEntity
|
|
4
|
+
export declare class EventQueueConsumer<K extends EventType = EventType> extends OutboxConsumer<EventQueueModel, EventQueueEntity<K>> {
|
|
5
|
+
constructor(logger: Logger, repository: BaseRepository<EventQueueModel, EventQueueEntity<K>, string>, batchSize: number);
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=event-queue.consumer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.consumer.d.ts","sourceRoot":"","sources":["../../src/consumers/event-queue.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"event-queue.consumer.d.ts","sourceRoot":"","sources":["../../src/consumers/event-queue.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,qBAAa,kBAAkB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,cAAc,CACrF,eAAe,EACf,gBAAgB,CAAC,CAAC,CAAC,CACpB;gBAEG,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,cAAc,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EACxE,SAAS,EAAE,MAAM;CAIpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.consumer.js","sourceRoot":"","sources":["../../src/consumers/event-queue.consumer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-queue.consumer.js","sourceRoot":"","sources":["../../src/consumers/event-queue.consumer.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF,MAAM,OAAO,kBAAoD,SAAQ,cAGxE;IACC,YACE,MAAc,EACd,UAAwE,EACxE,SAAiB;QAEjB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,oBAAoB,CAAI,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACxF,CAAC;CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { BaseRepository, JobsOutboxEntity, JobsOutboxModel } from '@volontariapp/database';
|
|
2
1
|
import { OutboxConsumer } from '@volontariapp/database';
|
|
2
|
+
import type { JobsOutboxEntity, JobsOutboxModel, JobType } from '@volontariapp/database';
|
|
3
3
|
import type { Logger } from '@volontariapp/logger';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import type { BaseRepository } from '@volontariapp/database';
|
|
5
|
+
export declare class JobsOutboxConsumer<K extends JobType = JobType> extends OutboxConsumer<JobsOutboxModel, JobsOutboxEntity<K>> {
|
|
6
|
+
constructor(logger: Logger, repository: BaseRepository<JobsOutboxModel, JobsOutboxEntity<K>, string>, batchSize: number);
|
|
6
7
|
}
|
|
7
8
|
//# sourceMappingURL=jobs-outbox.consumer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.consumer.d.ts","sourceRoot":"","sources":["../../src/consumers/jobs-outbox.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"jobs-outbox.consumer.d.ts","sourceRoot":"","sources":["../../src/consumers/jobs-outbox.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,qBAAa,kBAAkB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,CAAE,SAAQ,cAAc,CACjF,eAAe,EACf,gBAAgB,CAAC,CAAC,CAAC,CACpB;gBAEG,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,cAAc,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EACxE,SAAS,EAAE,MAAM;CAIpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.consumer.js","sourceRoot":"","sources":["../../src/consumers/jobs-outbox.consumer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jobs-outbox.consumer.js","sourceRoot":"","sources":["../../src/consumers/jobs-outbox.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAGhF,MAAM,OAAO,kBAAgD,SAAQ,cAGpE;IACC,YACE,MAAc,EACd,UAAwE,EACxE,SAAiB;QAEjB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,oBAAoB,CAAI,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACxF,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EventQueueEntity, type EventQueueModel, OutboxDispatcher } from '@volontariapp/database';
|
|
2
|
-
export declare class EventQueueDispatcher extends OutboxDispatcher<EventQueueModel, EventQueueEntity
|
|
1
|
+
import { type EventQueueEntity, type EventQueueModel, type EventType, type EventPayload, OutboxDispatcher } from '@volontariapp/database';
|
|
2
|
+
export declare class EventQueueDispatcher<K extends EventType = EventType, P = EventPayload<K>> extends OutboxDispatcher<EventQueueModel, EventQueueEntity<K, P>> {
|
|
3
3
|
}
|
|
4
4
|
//# sourceMappingURL=event-queue.dispatcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatchers/event-queue.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,
|
|
1
|
+
{"version":3,"file":"event-queue.dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatchers/event-queue.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,oBAAoB,CAC/B,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/B,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CACnB,SAAQ,gBAAgB,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.dispatcher.js","sourceRoot":"","sources":["../../src/dispatchers/event-queue.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"event-queue.dispatcher.js","sourceRoot":"","sources":["../../src/dispatchers/event-queue.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,OAAO,oBAGX,SAAQ,gBAAyD;CAAG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type JobsOutboxEntity, type JobsOutboxModel, OutboxDispatcher } from '@volontariapp/database';
|
|
2
|
-
export declare class JobsOutboxDispatcher extends OutboxDispatcher<JobsOutboxModel, JobsOutboxEntity
|
|
1
|
+
import { type JobsOutboxEntity, type JobsOutboxModel, type JobType, type JobPayload, OutboxDispatcher } from '@volontariapp/database';
|
|
2
|
+
export declare class JobsOutboxDispatcher<K extends JobType = JobType, P = JobPayload<K>> extends OutboxDispatcher<JobsOutboxModel, JobsOutboxEntity<K, P>> {
|
|
3
3
|
}
|
|
4
4
|
//# sourceMappingURL=jobs-outbox.dispatcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatchers/jobs-outbox.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,
|
|
1
|
+
{"version":3,"file":"jobs-outbox.dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatchers/jobs-outbox.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,oBAAoB,CAC/B,CAAC,SAAS,OAAO,GAAG,OAAO,EAC3B,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CACjB,SAAQ,gBAAgB,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.dispatcher.js","sourceRoot":"","sources":["../../src/dispatchers/jobs-outbox.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"jobs-outbox.dispatcher.js","sourceRoot":"","sources":["../../src/dispatchers/jobs-outbox.dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,OAAO,oBAGX,SAAQ,gBAAyD;CAAG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, it, beforeEach, jest } from '@jest/globals';
|
|
1
|
+
import { describe, expect, it, beforeEach, jest, afterEach } from '@jest/globals';
|
|
2
2
|
import { EventQueueConsumer } from '../../../consumers/event-queue.consumer.js';
|
|
3
3
|
import { makeEventQueueConsumerRepositoryMock, } from '../../utils/helpers/event-queue-repository-mock.helper.js';
|
|
4
4
|
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
@@ -11,14 +11,21 @@ describe('EventQueueConsumer (Unit)', () => {
|
|
|
11
11
|
repository = makeEventQueueConsumerRepositoryMock();
|
|
12
12
|
consumer = new EventQueueConsumer(logger, repository, 10);
|
|
13
13
|
});
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
jest.restoreAllMocks();
|
|
16
|
+
});
|
|
14
17
|
it('should be defined', () => {
|
|
15
18
|
expect(consumer).toBeDefined();
|
|
16
19
|
});
|
|
17
20
|
it('fetchPendingItems() should delegate to repository and return results', async () => {
|
|
18
21
|
const mockEntities = [{ id: '1' }, { id: '2' }];
|
|
19
|
-
|
|
22
|
+
const toEntitiesSpy = jest
|
|
23
|
+
.spyOn(repository, 'toEntities')
|
|
24
|
+
.mockReturnValue(mockEntities);
|
|
25
|
+
const executeInTransactionSpy = jest.spyOn(repository, 'executeInTransaction');
|
|
20
26
|
const result = await consumer.fetchPendingItems();
|
|
21
|
-
expect(
|
|
27
|
+
expect(executeInTransactionSpy).toHaveBeenCalled();
|
|
28
|
+
expect(toEntitiesSpy).toHaveBeenCalled();
|
|
22
29
|
expect(result).toEqual(mockEntities);
|
|
23
30
|
});
|
|
24
31
|
describe('processItems', () => {
|
|
@@ -27,11 +34,13 @@ describe('EventQueueConsumer (Unit)', () => {
|
|
|
27
34
|
{ id: '1', status: OutboxStatus.PROCESSING },
|
|
28
35
|
{ id: '2', status: OutboxStatus.PROCESSING },
|
|
29
36
|
];
|
|
30
|
-
const
|
|
37
|
+
const dispatcher = consumer
|
|
38
|
+
.outboxDispatcher;
|
|
39
|
+
const completedSpy = jest.spyOn(dispatcher, 'markAsCompleted');
|
|
31
40
|
await consumer.processItems(entities);
|
|
32
|
-
expect(
|
|
33
|
-
expect(
|
|
34
|
-
expect(
|
|
41
|
+
expect(completedSpy).toHaveBeenCalledTimes(2);
|
|
42
|
+
expect(completedSpy).toHaveBeenCalledWith(entities[0]);
|
|
43
|
+
expect(completedSpy).toHaveBeenCalledWith(entities[1]);
|
|
35
44
|
});
|
|
36
45
|
});
|
|
37
46
|
describe('markItemsAsCompleted', () => {
|
|
@@ -40,10 +49,12 @@ describe('EventQueueConsumer (Unit)', () => {
|
|
|
40
49
|
{ id: '1', status: OutboxStatus.PROCESSING },
|
|
41
50
|
{ id: '2', status: OutboxStatus.PENDING },
|
|
42
51
|
];
|
|
43
|
-
const
|
|
52
|
+
const dispatcher = consumer
|
|
53
|
+
.outboxDispatcher;
|
|
54
|
+
const completedSpy = jest.spyOn(dispatcher, 'markAsCompleted');
|
|
44
55
|
await consumer.markItemsAsCompleted(entities);
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
56
|
+
expect(completedSpy).toHaveBeenCalledTimes(1);
|
|
57
|
+
expect(completedSpy).toHaveBeenCalledWith(entities[0]);
|
|
47
58
|
});
|
|
48
59
|
});
|
|
49
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.consumer.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/consumers/event/event-queue.consumer.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"event-queue.consumer.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/consumers/event/event-queue.consumer.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EACL,oCAAoC,GAErC,MAAM,2DAA2D,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,QAA4B,CAAC;IACjC,IAAI,UAA4C,CAAC;IACjD,MAAM,MAAM,GAAe,cAAc,EAAE,CAAC;IAE5C,UAAU,CAAC,GAAG,EAAE;QACd,UAAU,GAAG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|
|
1
|
-
import { describe, expect, it, beforeEach, jest } from '@jest/globals';
|
|
1
|
+
import { describe, expect, it, beforeEach, jest, afterEach } from '@jest/globals';
|
|
2
2
|
import { JobsOutboxConsumer } from '../../../consumers/jobs-outbox.consumer.js';
|
|
3
3
|
import { makeJobsOutboxConsumerRepositoryMock, } from '../../utils/helpers/jobs-outbox-repository-mock.helper.js';
|
|
4
4
|
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
@@ -11,14 +11,21 @@ describe('JobsOutboxConsumer (Unit)', () => {
|
|
|
11
11
|
repository = makeJobsOutboxConsumerRepositoryMock();
|
|
12
12
|
consumer = new JobsOutboxConsumer(logger, repository, 10);
|
|
13
13
|
});
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
jest.restoreAllMocks();
|
|
16
|
+
});
|
|
14
17
|
it('should be defined', () => {
|
|
15
18
|
expect(consumer).toBeDefined();
|
|
16
19
|
});
|
|
17
20
|
it('fetchPendingItems() should delegate to repository and return results', async () => {
|
|
18
21
|
const mockEntities = [{ id: '1' }, { id: '2' }];
|
|
19
|
-
|
|
22
|
+
const toEntitiesSpy = jest
|
|
23
|
+
.spyOn(repository, 'toEntities')
|
|
24
|
+
.mockReturnValue(mockEntities);
|
|
25
|
+
const executeInTransactionSpy = jest.spyOn(repository, 'executeInTransaction');
|
|
20
26
|
const result = await consumer.fetchPendingItems();
|
|
21
|
-
expect(
|
|
27
|
+
expect(executeInTransactionSpy).toHaveBeenCalled();
|
|
28
|
+
expect(toEntitiesSpy).toHaveBeenCalled();
|
|
22
29
|
expect(result).toEqual(mockEntities);
|
|
23
30
|
});
|
|
24
31
|
describe('processItems', () => {
|
|
@@ -27,11 +34,14 @@ describe('JobsOutboxConsumer (Unit)', () => {
|
|
|
27
34
|
{ id: '1', status: OutboxStatus.PROCESSING },
|
|
28
35
|
{ id: '2', status: OutboxStatus.PROCESSING },
|
|
29
36
|
];
|
|
30
|
-
const
|
|
37
|
+
const dispatcher = consumer
|
|
38
|
+
.outboxDispatcher;
|
|
39
|
+
const completedSpy = jest.spyOn(dispatcher, 'markAsCompleted');
|
|
31
40
|
await consumer.processItems(entities);
|
|
32
|
-
|
|
33
|
-
expect(
|
|
34
|
-
expect(
|
|
41
|
+
const spyMock = completedSpy;
|
|
42
|
+
expect(spyMock).toHaveBeenCalledTimes(2);
|
|
43
|
+
expect(spyMock).toHaveBeenCalledWith(entities[0]);
|
|
44
|
+
expect(spyMock).toHaveBeenCalledWith(entities[1]);
|
|
35
45
|
});
|
|
36
46
|
});
|
|
37
47
|
describe('markItemsAsCompleted', () => {
|
|
@@ -40,10 +50,13 @@ describe('JobsOutboxConsumer (Unit)', () => {
|
|
|
40
50
|
{ id: '1', status: OutboxStatus.PROCESSING },
|
|
41
51
|
{ id: '2', status: OutboxStatus.PENDING },
|
|
42
52
|
];
|
|
43
|
-
const
|
|
53
|
+
const dispatcher = consumer
|
|
54
|
+
.outboxDispatcher;
|
|
55
|
+
const completedSpy = jest.spyOn(dispatcher, 'markAsCompleted');
|
|
44
56
|
await consumer.markItemsAsCompleted(entities);
|
|
45
|
-
|
|
46
|
-
expect(
|
|
57
|
+
const spyMock = completedSpy;
|
|
58
|
+
expect(spyMock).toHaveBeenCalledTimes(1);
|
|
59
|
+
expect(spyMock).toHaveBeenCalledWith(entities[0]);
|
|
47
60
|
});
|
|
48
61
|
});
|
|
49
62
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.consumer.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/consumers/jobs/jobs-outbox.consumer.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"jobs-outbox.consumer.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/consumers/jobs/jobs-outbox.consumer.unit.spec.ts"],"names":[],"mappings":"AAAA,O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BAChE,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,OAAO,EAAsB;aAC9D,CAAC;YACF,MAAM,UAAU,GAAI,QAAkE;iBACnF,gBAAgB,CAAC;YACpB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;YAE/D,MAAM,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YAE9C,MAAM,OAAO,GAAG,YAAyB,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YACzC,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { describe, expect, it, beforeEach } from '@jest/globals';
|
|
1
|
+
import { describe, expect, it, beforeEach, jest } from '@jest/globals';
|
|
2
2
|
import { UnprocessableEntityError } from '@volontariapp/errors';
|
|
3
3
|
import { EventQueueDispatcher } from '../../../dispatchers/event-queue.dispatcher.js';
|
|
4
4
|
import { OutboxStatus } from '@volontariapp/database';
|
|
5
5
|
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
6
|
-
import { makeEventQueueRepositoryMock
|
|
6
|
+
import { makeEventQueueRepositoryMock } from '../../utils/helpers/event-queue-repository-mock.helper.js';
|
|
7
7
|
import { makeEventQueueEvent } from '../../utils/helpers/event-queue-event.helper.js';
|
|
8
8
|
describe('EventQueueDispatcher (Unit)', () => {
|
|
9
9
|
let dispatcher;
|
|
@@ -13,12 +13,16 @@ describe('EventQueueDispatcher (Unit)', () => {
|
|
|
13
13
|
const loggerMock = makeLoggerMock();
|
|
14
14
|
dispatcher = new EventQueueDispatcher(loggerMock, repositoryMock);
|
|
15
15
|
});
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
jest.restoreAllMocks();
|
|
18
|
+
});
|
|
16
19
|
describe('markAsProcessing', () => {
|
|
17
20
|
it('should mark event as processing and update repository', async () => {
|
|
18
21
|
const event = makeEventQueueEvent({ status: OutboxStatus.PENDING });
|
|
22
|
+
const updateSpy = jest.spyOn(repositoryMock, 'update');
|
|
19
23
|
await dispatcher.markAsProcessing(event);
|
|
20
24
|
expect(event.status).toBe(OutboxStatus.PROCESSING);
|
|
21
|
-
expect(
|
|
25
|
+
expect(updateSpy).toHaveBeenCalledWith(event.id, event);
|
|
22
26
|
});
|
|
23
27
|
it('should throw UnprocessableEntityError if event is not in PENDING status', () => {
|
|
24
28
|
const event = makeEventQueueEvent({ status: OutboxStatus.PROCESSING });
|
|
@@ -29,10 +33,11 @@ describe('EventQueueDispatcher (Unit)', () => {
|
|
|
29
33
|
it('should mark event as failed with error and update repository', async () => {
|
|
30
34
|
const event = makeEventQueueEvent({ status: OutboxStatus.PROCESSING });
|
|
31
35
|
const error = 'Execution failed';
|
|
36
|
+
const updateSpy = jest.spyOn(repositoryMock, 'update');
|
|
32
37
|
await dispatcher.markAsFailed(event, error);
|
|
33
38
|
expect(event.status).toBe(OutboxStatus.FAILED);
|
|
34
39
|
expect(event.lastError).toBe(error);
|
|
35
|
-
expect(
|
|
40
|
+
expect(updateSpy).toHaveBeenCalledWith(event.id, event);
|
|
36
41
|
});
|
|
37
42
|
it('should throw UnprocessableEntityError if event is not in PROCESSING status', () => {
|
|
38
43
|
const event = makeEventQueueEvent({ status: OutboxStatus.PENDING });
|
|
@@ -42,9 +47,10 @@ describe('EventQueueDispatcher (Unit)', () => {
|
|
|
42
47
|
describe('markAsCompleted', () => {
|
|
43
48
|
it('should mark event as completed and update repository', async () => {
|
|
44
49
|
const event = makeEventQueueEvent({ status: OutboxStatus.PROCESSING });
|
|
50
|
+
const updateSpy = jest.spyOn(repositoryMock, 'update');
|
|
45
51
|
await dispatcher.markAsCompleted(event);
|
|
46
52
|
expect(event.status).toBe(OutboxStatus.COMPLETED);
|
|
47
|
-
expect(
|
|
53
|
+
expect(updateSpy).toHaveBeenCalledWith(event.id, event);
|
|
48
54
|
});
|
|
49
55
|
it('should throw UnprocessableEntityError if event is not in PROCESSING status', () => {
|
|
50
56
|
const event = makeEventQueueEvent({ status: OutboxStatus.PENDING });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.dispatcher.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/event/event-queue.dispatcher.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"event-queue.dispatcher.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/event/event-queue.dispatcher.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,4BAA4B,EAAE,MAAM,2DAA2D,CAAC;AACzG,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAEtF,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,IAAI,UAAgC,CAAC;IACrC,IAAI,cAA+D,CAAC;IAEpE,UAAU,CAAC,GAAG,EAAE;QACd,cAAc,GAAG,4BAA4B,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,cAAc,EAAE,CAAC;QACpC,UAAU,GAAG,IAAI,oBAAoB,CAAC,UAAU,EAAE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AC;QAEH,EAAE,CAAC,4EAA4E,EAAE,GAAG,EAAE;YACpF,MAAM,KAAK,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;YACpE,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;QACpF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue.generics.int.spec.d.ts","sourceRoot":"","sources":["../../../../src/test/dispatchers/event/event-queue.generics.int.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, expect, it, beforeAll, afterAll, beforeEach } from '@jest/globals';
|
|
2
|
+
import { databaseMapper, EventQueueModel, EventQueueEntity, OutboxStatus, } from '@volontariapp/database';
|
|
3
|
+
import { testDataSource, initializeTestDb, closeTestDb } from '../../data-source.js';
|
|
4
|
+
import { EventQueueDispatcher } from '../../../dispatchers/event-queue.dispatcher.js';
|
|
5
|
+
import { TestEventQueueRepository } from '../../utils/repositories/event-queue-test.repository.js';
|
|
6
|
+
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
7
|
+
import { EventType } from '../../utils/helpers/event-queue-generics.helper.js';
|
|
8
|
+
describe('EventQueue Generics (Integration)', () => {
|
|
9
|
+
let dispatcher;
|
|
10
|
+
let repository;
|
|
11
|
+
const logger = makeLoggerMock();
|
|
12
|
+
beforeAll(async () => {
|
|
13
|
+
await initializeTestDb();
|
|
14
|
+
databaseMapper.registerBidirectional(EventQueueModel, EventQueueEntity);
|
|
15
|
+
repository = new TestEventQueueRepository(testDataSource.getRepository(EventQueueModel));
|
|
16
|
+
dispatcher = new EventQueueDispatcher(logger, repository);
|
|
17
|
+
});
|
|
18
|
+
afterAll(async () => {
|
|
19
|
+
await closeTestDb();
|
|
20
|
+
});
|
|
21
|
+
beforeEach(async () => {
|
|
22
|
+
await testDataSource.getRepository(EventQueueModel).createQueryBuilder().delete().execute();
|
|
23
|
+
});
|
|
24
|
+
it('should persist and retrieve a perfectly typed generic event', async () => {
|
|
25
|
+
const event = new EventQueueEntity();
|
|
26
|
+
event.id = '00000000-0000-0000-0000-000000000001';
|
|
27
|
+
event.type = EventType.FAKE;
|
|
28
|
+
event.emitter = 'test';
|
|
29
|
+
event.status = OutboxStatus.PENDING;
|
|
30
|
+
event.version = 1;
|
|
31
|
+
event.payload = {
|
|
32
|
+
after: { foo: 'bar', count: 42 },
|
|
33
|
+
};
|
|
34
|
+
await repository.create(event);
|
|
35
|
+
const retrieved = await repository.findOneOrFail({ id: event.id });
|
|
36
|
+
expect(retrieved.type).toBe(EventType.FAKE);
|
|
37
|
+
expect(retrieved.payload.after.foo).toBe('bar');
|
|
38
|
+
expect(retrieved.payload.after.count).toBe(42);
|
|
39
|
+
await dispatcher.markAsProcessing(retrieved);
|
|
40
|
+
const updated = await repository.findOneOrFail({ id: event.id });
|
|
41
|
+
expect(updated.status).toBe(OutboxStatus.PROCESSING);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=event-queue.generics.int.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue.generics.int.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/event/event-queue.generics.int.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,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,sBAAsB,CAAC;AACrF,OAAO,EAA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AO,GAAG,CAAC,CAAC;QAClB,KAAK,CAAC,OAAO,GAAG;YACd,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE;SACjC,CAAC;QAEF,MAAM,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAE/B,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAEnE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE/C,MAAM,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAE7C,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QACjE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, it, beforeEach } from '@jest/globals';
|
|
1
|
+
import { describe, expect, it, beforeEach, jest, afterEach } from '@jest/globals';
|
|
2
2
|
import { UnprocessableEntityError } from '@volontariapp/errors';
|
|
3
3
|
import { JobsOutboxDispatcher } from '../../../dispatchers/jobs-outbox.dispatcher.js';
|
|
4
4
|
import { OutboxStatus } from '@volontariapp/database';
|
|
@@ -13,12 +13,16 @@ describe('JobsOutboxDispatcher (Unit)', () => {
|
|
|
13
13
|
const loggerMock = makeLoggerMock();
|
|
14
14
|
dispatcher = new JobsOutboxDispatcher(loggerMock, repositoryMock);
|
|
15
15
|
});
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
jest.restoreAllMocks();
|
|
18
|
+
});
|
|
16
19
|
describe('markAsProcessing', () => {
|
|
17
20
|
it('should mark job as processing and update repository', async () => {
|
|
18
21
|
const job = makeJobsOutboxEvent({ status: OutboxStatus.PENDING });
|
|
22
|
+
const updateSpy = jest.spyOn(repositoryMock, 'update');
|
|
19
23
|
await dispatcher.markAsProcessing(job);
|
|
20
24
|
expect(job.status).toBe(OutboxStatus.PROCESSING);
|
|
21
|
-
expect(
|
|
25
|
+
expect(updateSpy).toHaveBeenCalledWith(job.id, job);
|
|
22
26
|
});
|
|
23
27
|
it('should throw UnprocessableEntityError if job is not in PENDING status', () => {
|
|
24
28
|
const job = makeJobsOutboxEvent({ status: OutboxStatus.PROCESSING });
|
|
@@ -29,10 +33,11 @@ describe('JobsOutboxDispatcher (Unit)', () => {
|
|
|
29
33
|
it('should mark job as failed with error and update repository', async () => {
|
|
30
34
|
const job = makeJobsOutboxEvent({ status: OutboxStatus.PROCESSING });
|
|
31
35
|
const error = 'Job execution failed';
|
|
36
|
+
const updateSpy = jest.spyOn(repositoryMock, 'update');
|
|
32
37
|
await dispatcher.markAsFailed(job, error);
|
|
33
38
|
expect(job.status).toBe(OutboxStatus.FAILED);
|
|
34
39
|
expect(job.lastError).toBe(error);
|
|
35
|
-
expect(
|
|
40
|
+
expect(updateSpy).toHaveBeenCalledWith(job.id, job);
|
|
36
41
|
});
|
|
37
42
|
it('should throw UnprocessableEntityError if job is not in PROCESSING status', () => {
|
|
38
43
|
const job = makeJobsOutboxEvent({ status: OutboxStatus.PENDING });
|
|
@@ -42,9 +47,10 @@ describe('JobsOutboxDispatcher (Unit)', () => {
|
|
|
42
47
|
describe('markAsCompleted', () => {
|
|
43
48
|
it('should mark job as completed and update repository', async () => {
|
|
44
49
|
const job = makeJobsOutboxEvent({ status: OutboxStatus.PROCESSING });
|
|
50
|
+
const updateSpy = jest.spyOn(repositoryMock, 'update');
|
|
45
51
|
await dispatcher.markAsCompleted(job);
|
|
46
52
|
expect(job.status).toBe(OutboxStatus.COMPLETED);
|
|
47
|
-
expect(
|
|
53
|
+
expect(updateSpy).toHaveBeenCalledWith(job.id, job);
|
|
48
54
|
});
|
|
49
55
|
it('should throw UnprocessableEntityError if job is not in PROCESSING status', () => {
|
|
50
56
|
const job = makeJobsOutboxEvent({ status: OutboxStatus.PENDING });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.dispatcher.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"jobs-outbox.dispatcher.unit.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/jobs/jobs-outbox.dispatcher.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACL,4BAA4B,GAE7B,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAEtF,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,IAAI,UAAgC,CAAC;IACrC,IAAI,cAAwC,CAAC;IAE7C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,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAChD,MAAM,CAAC,SAAsB,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;YAClF,MAAM,GAAG,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;YAClE,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;QAClF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox.generics.int.spec.d.ts","sourceRoot":"","sources":["../../../../src/test/dispatchers/jobs/jobs-outbox.generics.int.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, expect, it, beforeAll, afterAll, beforeEach } from '@jest/globals';
|
|
2
|
+
import { databaseMapper, JobsOutboxModel, JobsOutboxEntity, OutboxStatus, } from '@volontariapp/database';
|
|
3
|
+
import { testDataSource, initializeTestDb, closeTestDb } from '../../data-source.js';
|
|
4
|
+
import { JobsOutboxDispatcher } from '../../../dispatchers/jobs-outbox.dispatcher.js';
|
|
5
|
+
import { TestJobsOutboxRepository } from '../../utils/repositories/jobs-outbox-test.repository.js';
|
|
6
|
+
import { makeLoggerMock } from '../../utils/helpers/logger-mock.helper.js';
|
|
7
|
+
import { JobType } from '../../utils/helpers/jobs-outbox-generics.helper.js';
|
|
8
|
+
describe('JobsOutbox Generics (Integration)', () => {
|
|
9
|
+
let dispatcher;
|
|
10
|
+
let repository;
|
|
11
|
+
const logger = makeLoggerMock();
|
|
12
|
+
beforeAll(async () => {
|
|
13
|
+
await initializeTestDb();
|
|
14
|
+
databaseMapper.registerBidirectional(JobsOutboxModel, JobsOutboxEntity);
|
|
15
|
+
repository = new TestJobsOutboxRepository(testDataSource.getRepository(JobsOutboxModel));
|
|
16
|
+
dispatcher = new JobsOutboxDispatcher(logger, repository);
|
|
17
|
+
});
|
|
18
|
+
afterAll(async () => {
|
|
19
|
+
await closeTestDb();
|
|
20
|
+
});
|
|
21
|
+
beforeEach(async () => {
|
|
22
|
+
await testDataSource.getRepository(JobsOutboxModel).createQueryBuilder().delete().execute();
|
|
23
|
+
});
|
|
24
|
+
it('should persist and retrieve a perfectly typed generic job', async () => {
|
|
25
|
+
const job = new JobsOutboxEntity();
|
|
26
|
+
job.id = '00000000-0000-0000-0000-000000000001';
|
|
27
|
+
job.type = JobType.FAKE;
|
|
28
|
+
job.emitter = 'test';
|
|
29
|
+
job.status = OutboxStatus.PENDING;
|
|
30
|
+
job.payload = { foo: 'bar', count: 42 };
|
|
31
|
+
job.target = 'test';
|
|
32
|
+
job.scheduledAt = new Date();
|
|
33
|
+
await repository.create(job);
|
|
34
|
+
const retrieved = await repository.findOneOrFail({ id: job.id });
|
|
35
|
+
expect(retrieved.type).toBe(JobType.FAKE);
|
|
36
|
+
expect(retrieved.payload.foo).toBe('bar');
|
|
37
|
+
expect(retrieved.payload.count).toBe(42);
|
|
38
|
+
await dispatcher.markAsProcessing(retrieved);
|
|
39
|
+
const updated = await repository.findOneOrFail({ id: job.id });
|
|
40
|
+
expect(updated.status).toBe(OutboxStatus.PROCESSING);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=jobs-outbox.generics.int.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox.generics.int.spec.js","sourceRoot":"","sources":["../../../../src/test/dispatchers/jobs/jobs-outbox.generics.int.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ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= "fake.event"
|
|
4
|
+
}
|
|
5
|
+
export interface FakePayload extends JsonObject {
|
|
6
|
+
foo: string;
|
|
7
|
+
count: number;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=event-queue-generics.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue-generics.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-generics.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,oBAAY,SAAS;IACnB,IAAI,eAAe;CACpB;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue-generics.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-generics.helper.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,gCAAmB,CAAA;AACrB,CAAC,EAFW,SAAS,KAAT,SAAS,QAEpB"}
|
|
@@ -2,7 +2,7 @@ import type { EventQueueEntity } from '@volontariapp/database';
|
|
|
2
2
|
import { EventQueueModel } from '@volontariapp/database';
|
|
3
3
|
import { type OutboxRepositoryMock } from './outbox-repository-mock.helper.js';
|
|
4
4
|
import { type OutboxConsumerRepositoryMock } from './outbox-consumer-repository-mock.helper.js';
|
|
5
|
-
export type EventQueueRepositoryMock = OutboxRepositoryMock<EventQueueEntity>;
|
|
5
|
+
export type EventQueueRepositoryMock = OutboxRepositoryMock<EventQueueEntity, EventQueueModel>;
|
|
6
6
|
export declare function makeEventQueueRepositoryMock(): EventQueueRepositoryMock;
|
|
7
7
|
export type EventQueueConsumerRepositoryMock = OutboxConsumerRepositoryMock<EventQueueModel, EventQueueEntity>;
|
|
8
8
|
export declare function makeEventQueueConsumerRepositoryMock(): EventQueueConsumerRepositoryMock;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,6CAA6C,CAAC;AAErD,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"event-queue-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,6CAA6C,CAAC;AAErD,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;AAE/F,wBAAgB,4BAA4B,IAAI,wBAAwB,CAEvE;AAED,MAAM,MAAM,gCAAgC,GAAG,4BAA4B,CACzE,eAAe,EACf,gBAAgB,CACjB,CAAC;AAEF,wBAAgB,oCAAoC,IAAI,gCAAgC,CAEvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-repository-mock.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,wBAAwB,GAEzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,gCAAgC,GAEjC,MAAM,6CAA6C,CAAC;AAIrD,MAAM,UAAU,4BAA4B;IAC1C,OAAO,wBAAwB,
|
|
1
|
+
{"version":3,"file":"event-queue-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/event-queue-repository-mock.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,wBAAwB,GAEzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,gCAAgC,GAEjC,MAAM,6CAA6C,CAAC;AAIrD,MAAM,UAAU,4BAA4B;IAC1C,OAAO,wBAAwB,EAAqC,CAAC;AACvE,CAAC;AAOD,MAAM,UAAU,oCAAoC;IAClD,OAAO,gCAAgC,CAAoC,eAAe,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox-generics.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-generics.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,oBAAY,OAAO;IACjB,IAAI,aAAa;CAClB;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs-outbox-generics.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-generics.helper.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,OAEX;AAFD,WAAY,OAAO;IACjB,4BAAiB,CAAA;AACnB,CAAC,EAFW,OAAO,KAAP,OAAO,QAElB"}
|
|
@@ -2,7 +2,7 @@ import type { JobsOutboxEntity } from '@volontariapp/database';
|
|
|
2
2
|
import { JobsOutboxModel } from '@volontariapp/database';
|
|
3
3
|
import { type OutboxRepositoryMock } from './outbox-repository-mock.helper.js';
|
|
4
4
|
import { type OutboxConsumerRepositoryMock } from './outbox-consumer-repository-mock.helper.js';
|
|
5
|
-
export type JobsOutboxRepositoryMock = OutboxRepositoryMock<JobsOutboxEntity>;
|
|
5
|
+
export type JobsOutboxRepositoryMock = OutboxRepositoryMock<JobsOutboxEntity, JobsOutboxModel>;
|
|
6
6
|
export declare function makeJobsOutboxRepositoryMock(): JobsOutboxRepositoryMock;
|
|
7
7
|
export type JobsOutboxConsumerRepositoryMock = OutboxConsumerRepositoryMock<JobsOutboxModel, JobsOutboxEntity>;
|
|
8
8
|
export declare function makeJobsOutboxConsumerRepositoryMock(): JobsOutboxConsumerRepositoryMock;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,6CAA6C,CAAC;AAErD,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"jobs-outbox-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,6CAA6C,CAAC;AAErD,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;AAE/F,wBAAgB,4BAA4B,IAAI,wBAAwB,CAEvE;AAED,MAAM,MAAM,gCAAgC,GAAG,4BAA4B,CACzE,eAAe,EACf,gBAAgB,CACjB,CAAC;AAEF,wBAAgB,oCAAoC,IAAI,gCAAgC,CAEvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-repository-mock.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,wBAAwB,GAEzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,gCAAgC,GAEjC,MAAM,6CAA6C,CAAC;AAIrD,MAAM,UAAU,4BAA4B;IAC1C,OAAO,wBAAwB,
|
|
1
|
+
{"version":3,"file":"jobs-outbox-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/jobs-outbox-repository-mock.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,wBAAwB,GAEzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,gCAAgC,GAEjC,MAAM,6CAA6C,CAAC;AAIrD,MAAM,UAAU,4BAA4B;IAC1C,OAAO,wBAAwB,EAAqC,CAAC;AACvE,CAAC;AAOD,MAAM,UAAU,oCAAoC;IAClD,OAAO,gCAAgC,CAAoC,eAAe,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { jest } from '@jest/globals';
|
|
2
|
+
import type { Logger } from '@volontariapp/logger';
|
|
3
|
+
export type LoggerMock = jest.Mocked<Logger>;
|
|
4
|
+
export declare const makeLoggerMock: () => LoggerMock;
|
|
3
5
|
//# sourceMappingURL=logger-mock.helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/logger-mock.helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/logger-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAE7C,eAAO,MAAM,cAAc,QAAO,UAEjC,CAAC"}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Logger } from '@volontariapp/logger';
|
|
1
|
+
import { createMock } from '@volontariapp/database/testing';
|
|
3
2
|
export const makeLoggerMock = () => {
|
|
4
|
-
|
|
5
|
-
jest.spyOn(logger, 'info').mockImplementation(() => { });
|
|
6
|
-
jest.spyOn(logger, 'warn').mockImplementation(() => { });
|
|
7
|
-
jest.spyOn(logger, 'error').mockImplementation(() => { });
|
|
8
|
-
jest.spyOn(logger, 'debug').mockImplementation(() => { });
|
|
9
|
-
jest.spyOn(logger, 'fatal').mockImplementation(() => { });
|
|
10
|
-
jest.spyOn(logger, 'verbose').mockImplementation(() => { });
|
|
11
|
-
jest.spyOn(logger, 'log').mockImplementation(() => { });
|
|
12
|
-
return logger;
|
|
3
|
+
return createMock();
|
|
13
4
|
};
|
|
14
5
|
//# sourceMappingURL=logger-mock.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/logger-mock.helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/logger-mock.helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAI5D,MAAM,CAAC,MAAM,cAAc,GAAG,GAAe,EAAE;IAC7C,OAAO,UAAU,EAAU,CAAC;AAC9B,CAAC,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { jest } from '@jest/globals';
|
|
2
|
-
import type { OutboxEntity } from '@volontariapp/database';
|
|
3
|
-
export type OutboxRepositoryMock<TEntity extends OutboxEntity> =
|
|
4
|
-
|
|
5
|
-
createMany: jest.MockedFunction<(dataArray: Partial<TEntity>[]) => Promise<TEntity[]>>;
|
|
6
|
-
update: jest.MockedFunction<(id: string, data: Partial<TEntity>) => Promise<TEntity | null>>;
|
|
7
|
-
delete: jest.MockedFunction<(id: string) => Promise<boolean>>;
|
|
8
|
-
};
|
|
9
|
-
export declare const makeOutboxRepositoryMock: <TEntity extends OutboxEntity>() => OutboxRepositoryMock<TEntity>;
|
|
1
|
+
import type { jest } from '@jest/globals';
|
|
2
|
+
import type { OutboxEntity, BaseRepository, OutboxModel } from '@volontariapp/database';
|
|
3
|
+
export type OutboxRepositoryMock<TEntity extends OutboxEntity, TModel extends OutboxModel = OutboxModel> = jest.Mocked<BaseRepository<TModel, TEntity, string>>;
|
|
4
|
+
export declare const makeOutboxRepositoryMock: <TEntity extends OutboxEntity, TModel extends OutboxModel = OutboxModel<string>>() => OutboxRepositoryMock<TEntity, TModel>;
|
|
10
5
|
//# sourceMappingURL=outbox-repository-mock.helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/outbox-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"outbox-repository-mock.helper.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/helpers/outbox-repository-mock.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGxF,MAAM,MAAM,oBAAoB,CAC9B,OAAO,SAAS,YAAY,EAC5B,MAAM,SAAS,WAAW,GAAG,WAAW,IACtC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAEzD,eAAO,MAAM,wBAAwB,GACnC,OAAO,SAAS,YAAY,EAC5B,MAAM,SAAS,WAAW,6BACvB,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAExC,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createMock } from '@volontariapp/database/testing';
|
|
2
2
|
export const makeOutboxRepositoryMock = () => {
|
|
3
|
-
return
|
|
4
|
-
create: jest.fn(() => Promise.resolve({})),
|
|
5
|
-
createMany: jest.fn(() => Promise.resolve([])),
|
|
6
|
-
update: jest.fn(() => Promise.resolve({})),
|
|
7
|
-
delete: jest.fn(() => Promise.resolve(true)),
|
|
8
|
-
};
|
|
3
|
+
return createMock();
|
|
9
4
|
};
|
|
10
5
|
//# sourceMappingURL=outbox-repository-mock.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/outbox-repository-mock.helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"outbox-repository-mock.helper.js","sourceRoot":"","sources":["../../../../src/test/utils/helpers/outbox-repository-mock.helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAO5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAGG,EAAE;IAC3C,OAAO,UAAU,EAA2C,CAAC;AAC/D,CAAC,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BaseRepository, EventQueueEntity, EventQueueModel } from '@volontariapp/database';
|
|
2
|
-
|
|
3
|
-
export declare class TestEventQueueRepository extends BaseRepository<EventQueueModel, EventQueueEntity, string> {
|
|
1
|
+
import { BaseRepository, EventQueueEntity, EventQueueModel, type EventType, type EventPayload, type Repository } from '@volontariapp/database';
|
|
2
|
+
export declare class TestEventQueueRepository<K extends EventType = EventType, P = EventPayload<K>> extends BaseRepository<EventQueueModel, EventQueueEntity<K, P>, string> {
|
|
4
3
|
constructor(repository: Repository<EventQueueModel>);
|
|
5
4
|
}
|
|
6
5
|
//# sourceMappingURL=event-queue-test.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue-test.repository.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/repositories/event-queue-test.repository.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"event-queue-test.repository.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/repositories/event-queue-test.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,wBAAwB,CACnC,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/B,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CACnB,SAAQ,cAAc,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC;gBAC3D,UAAU,EAAE,UAAU,CAAC,eAAe,CAAC;CAGpD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseRepository, EventQueueEntity, EventQueueModel } from '@volontariapp/database';
|
|
1
|
+
import { BaseRepository, EventQueueEntity, EventQueueModel, } from '@volontariapp/database';
|
|
2
2
|
export class TestEventQueueRepository extends BaseRepository {
|
|
3
3
|
constructor(repository) {
|
|
4
4
|
super(repository, EventQueueEntity, EventQueueModel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue-test.repository.js","sourceRoot":"","sources":["../../../../src/test/utils/repositories/event-queue-test.repository.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"event-queue-test.repository.js","sourceRoot":"","sources":["../../../../src/test/utils/repositories/event-queue-test.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,GAIhB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,OAAO,wBAGX,SAAQ,cAA+D;IACvE,YAAY,UAAuC;QACjD,KAAK,CAAC,UAAU,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BaseRepository, JobsOutboxEntity, JobsOutboxModel } from '@volontariapp/database';
|
|
2
|
-
|
|
3
|
-
export declare class TestJobsOutboxRepository extends BaseRepository<JobsOutboxModel, JobsOutboxEntity, string> {
|
|
1
|
+
import { BaseRepository, JobsOutboxEntity, JobsOutboxModel, type JobType, type JobPayload, type Repository } from '@volontariapp/database';
|
|
2
|
+
export declare class TestJobsOutboxRepository<K extends JobType = JobType, P = JobPayload<K>> extends BaseRepository<JobsOutboxModel, JobsOutboxEntity<K, P>, string> {
|
|
4
3
|
constructor(repository: Repository<JobsOutboxModel>);
|
|
5
4
|
}
|
|
6
5
|
//# sourceMappingURL=jobs-outbox-test.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox-test.repository.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/repositories/jobs-outbox-test.repository.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"jobs-outbox-test.repository.d.ts","sourceRoot":"","sources":["../../../../src/test/utils/repositories/jobs-outbox-test.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,wBAAwB,CACnC,CAAC,SAAS,OAAO,GAAG,OAAO,EAC3B,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CACjB,SAAQ,cAAc,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC;gBAC3D,UAAU,EAAE,UAAU,CAAC,eAAe,CAAC;CAGpD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseRepository, JobsOutboxEntity, JobsOutboxModel } from '@volontariapp/database';
|
|
1
|
+
import { BaseRepository, JobsOutboxEntity, JobsOutboxModel, } from '@volontariapp/database';
|
|
2
2
|
export class TestJobsOutboxRepository extends BaseRepository {
|
|
3
3
|
constructor(repository) {
|
|
4
4
|
super(repository, JobsOutboxEntity, JobsOutboxModel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox-test.repository.js","sourceRoot":"","sources":["../../../../src/test/utils/repositories/jobs-outbox-test.repository.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"jobs-outbox-test.repository.js","sourceRoot":"","sources":["../../../../src/test/utils/repositories/jobs-outbox-test.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,GAIhB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,OAAO,wBAGX,SAAQ,cAA+D;IACvE,YAAY,UAAuC;QACjD,KAAK,CAAC,UAAU,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EventQueueEntity, EventQueueModel } from '@volontariapp/database';
|
|
1
|
+
import type { EventQueueEntity, EventQueueModel, EventType } from '@volontariapp/database';
|
|
2
2
|
import { OutboxWriter } from '@volontariapp/database';
|
|
3
|
-
export declare class EventQueueWriter extends OutboxWriter<EventQueueModel, EventQueueEntity
|
|
3
|
+
export declare class EventQueueWriter<K extends EventType = EventType> extends OutboxWriter<EventQueueModel, EventQueueEntity<K>> {
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=event-queue.writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.writer.d.ts","sourceRoot":"","sources":["../../src/writers/event-queue.writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"event-queue.writer.d.ts","sourceRoot":"","sources":["../../src/writers/event-queue.writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,qBAAa,gBAAgB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,YAAY,CACjF,eAAe,EACf,gBAAgB,CAAC,CAAC,CAAC,CACpB;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.writer.js","sourceRoot":"","sources":["../../src/writers/event-queue.writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"event-queue.writer.js","sourceRoot":"","sources":["../../src/writers/event-queue.writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,OAAO,gBAAkD,SAAQ,YAGtE;CAAG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { JobsOutboxEntity, JobsOutboxModel } from '@volontariapp/database';
|
|
1
|
+
import type { JobsOutboxEntity, JobsOutboxModel, JobType } from '@volontariapp/database';
|
|
2
2
|
import { OutboxWriter } from '@volontariapp/database';
|
|
3
|
-
export declare class JobsOutboxWriter extends OutboxWriter<JobsOutboxModel, JobsOutboxEntity
|
|
3
|
+
export declare class JobsOutboxWriter<K extends JobType = JobType> extends OutboxWriter<JobsOutboxModel, JobsOutboxEntity<K>> {
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=jobs-outbox.writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.writer.d.ts","sourceRoot":"","sources":["../../src/writers/jobs-outbox.writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"jobs-outbox.writer.d.ts","sourceRoot":"","sources":["../../src/writers/jobs-outbox.writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,qBAAa,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,CAAE,SAAQ,YAAY,CAC7E,eAAe,EACf,gBAAgB,CAAC,CAAC,CAAC,CACpB;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-outbox.writer.js","sourceRoot":"","sources":["../../src/writers/jobs-outbox.writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"jobs-outbox.writer.js","sourceRoot":"","sources":["../../src/writers/jobs-outbox.writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,OAAO,gBAA8C,SAAQ,YAGlE;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volontariapp/outbox",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1-snap-4524b24",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"db:down": "docker-compose -f ../../docker-compose.test.yml down"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@volontariapp/database": "1.
|
|
40
|
+
"@volontariapp/database": "1.12.0-snap-4524b24",
|
|
41
41
|
"@volontariapp/errors": "0.5.0",
|
|
42
42
|
"@volontariapp/logger": "0.2.3"
|
|
43
43
|
},
|