@volontariapp/messaging 2.15.2 → 2.16.0-snap-68b0301

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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat(messaging): contrats et registres de complétion des Sagas Scatter-Gather - [#197](https://github.com/Volontariapp/npm-packages/issues/197)
8
+
3
9
  ## 2.15.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export type { EventRegistry } from './events/index.js';
4
4
  export * from './jobs/index.js';
5
5
  export * from './websockets/index.js';
6
6
  export * from './helpers/index.js';
7
+ export * from './sagas/index.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -3,4 +3,5 @@ export { EventMessagingType } from './events/index.js';
3
3
  export * from './jobs/index.js';
4
4
  export * from './websockets/index.js';
5
5
  export * from './helpers/index.js';
6
+ export * from './sagas/index.js';
6
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { IGatherCompletionConfig } from './types.js';
2
+ export declare const SagaGatherType: {
3
+ readonly EVENT_CREATION: "EVENT_CREATION_GATHER";
4
+ readonly EVENT_DELETION: "EVENT_DELETION_GATHER";
5
+ readonly POST_CREATION: "POST_CREATION_GATHER";
6
+ readonly POST_DELETION: "POST_DELETION_GATHER";
7
+ readonly USER_DELETION: "USER_DELETION_GATHER";
8
+ };
9
+ export type SagaGatherType = (typeof SagaGatherType)[keyof typeof SagaGatherType];
10
+ export declare const SAGA_GATHER_COMPLETION_MAPPING: Record<SagaGatherType, IGatherCompletionConfig>;
11
+ export declare function getGatherCompletionConfig(gatherType: SagaGatherType): IGatherCompletionConfig;
12
+ //# sourceMappingURL=gather-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gather-registry.d.ts","sourceRoot":"","sources":["../../src/sagas/gather-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAK1D,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAKlF,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,cAAc,EAAE,uBAAuB,CA0BjF,CAAC;AAKX,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,cAAc,GAAG,uBAAuB,CAM7F"}
@@ -0,0 +1,44 @@
1
+ import { EventMessagingType } from '../events/index.js';
2
+ import { WebsocketMessagingType } from '../websockets/index.js';
3
+ export const SagaGatherType = {
4
+ EVENT_CREATION: 'EVENT_CREATION_GATHER',
5
+ EVENT_DELETION: 'EVENT_DELETION_GATHER',
6
+ POST_CREATION: 'POST_CREATION_GATHER',
7
+ POST_DELETION: 'POST_DELETION_GATHER',
8
+ USER_DELETION: 'USER_DELETION_GATHER',
9
+ };
10
+ export const SAGA_GATHER_COMPLETION_MAPPING = {
11
+ [SagaGatherType.EVENT_CREATION]: {
12
+ targetEvent: EventMessagingType.EVENT_CREATED,
13
+ stream: 'event:created',
14
+ wsEvent: WebsocketMessagingType.EVENT_CREATED,
15
+ },
16
+ [SagaGatherType.EVENT_DELETION]: {
17
+ targetEvent: EventMessagingType.EVENT_DELETED,
18
+ stream: 'event:deleted',
19
+ wsEvent: WebsocketMessagingType.EVENT_DELETED,
20
+ },
21
+ [SagaGatherType.POST_CREATION]: {
22
+ targetEvent: EventMessagingType.POST_CREATED,
23
+ stream: 'post:created',
24
+ wsEvent: WebsocketMessagingType.POST_CREATED,
25
+ },
26
+ [SagaGatherType.POST_DELETION]: {
27
+ targetEvent: EventMessagingType.POST_DELETED,
28
+ stream: 'post:deleted',
29
+ wsEvent: WebsocketMessagingType.POST_DELETED,
30
+ },
31
+ [SagaGatherType.USER_DELETION]: {
32
+ targetEvent: EventMessagingType.USER_DELETED,
33
+ stream: 'user:deleted',
34
+ wsEvent: WebsocketMessagingType.USER_DELETED,
35
+ },
36
+ };
37
+ export function getGatherCompletionConfig(gatherType) {
38
+ const config = SAGA_GATHER_COMPLETION_MAPPING[gatherType];
39
+ if (!config) {
40
+ throw new Error(`[Messaging] No completion config found for saga gather type: ${gatherType}`);
41
+ }
42
+ return config;
43
+ }
44
+ //# sourceMappingURL=gather-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gather-registry.js","sourceRoot":"","sources":["../../src/sagas/gather-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAMhE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,cAAc,EAAE,uBAAuB;IACvC,cAAc,EAAE,uBAAuB;IACvC,aAAa,EAAE,sBAAsB;IACrC,aAAa,EAAE,sBAAsB;IACrC,aAAa,EAAE,sBAAsB;CAC7B,CAAC;AAOX,MAAM,CAAC,MAAM,8BAA8B,GAAoD;IAC7F,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE;QAC/B,WAAW,EAAE,kBAAkB,CAAC,aAAa;QAC7C,MAAM,EAAE,eAAe;QACvB,OAAO,EAAE,sBAAsB,CAAC,aAAa;KAC9C;IACD,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE;QAC/B,WAAW,EAAE,kBAAkB,CAAC,aAAa;QAC7C,MAAM,EAAE,eAAe;QACvB,OAAO,EAAE,sBAAsB,CAAC,aAAa;KAC9C;IACD,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE;QAC9B,WAAW,EAAE,kBAAkB,CAAC,YAAY;QAC5C,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,sBAAsB,CAAC,YAAY;KAC7C;IACD,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE;QAC9B,WAAW,EAAE,kBAAkB,CAAC,YAAY;QAC5C,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,sBAAsB,CAAC,YAAY;KAC7C;IACD,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE;QAC9B,WAAW,EAAE,kBAAkB,CAAC,YAAY;QAC5C,MAAM,EAAE,cAAc;QACtB,OAAO,EAAE,sBAAsB,CAAC,YAAY;KAC7C;CACO,CAAC;AAKX,MAAM,UAAU,yBAAyB,CAAC,UAA0B;IAClE,MAAM,MAAM,GAAG,8BAA8B,CAAC,UAAU,CAAC,CAAC;IAC1D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,gEAAgE,UAAU,EAAE,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=gather-registry.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gather-registry.test.d.ts","sourceRoot":"","sources":["../../src/sagas/gather-registry.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { describe, it, expect } from '@jest/globals';
2
+ import { SagaGatherType, SAGA_GATHER_COMPLETION_MAPPING, getGatherCompletionConfig, } from './gather-registry.js';
3
+ import { EventMessagingType } from '../events/index.js';
4
+ import { WebsocketMessagingType } from '../websockets/index.js';
5
+ describe('SagaGatherRegistry', () => {
6
+ it('should return valid completion config for EVENT_CREATION', () => {
7
+ const config = getGatherCompletionConfig(SagaGatherType.EVENT_CREATION);
8
+ expect(config).toEqual(SAGA_GATHER_COMPLETION_MAPPING[SagaGatherType.EVENT_CREATION]);
9
+ expect(config).toEqual({
10
+ targetEvent: EventMessagingType.EVENT_CREATED,
11
+ stream: 'event:created',
12
+ wsEvent: WebsocketMessagingType.EVENT_CREATED,
13
+ });
14
+ });
15
+ it('should return valid completion config for EVENT_DELETION', () => {
16
+ const config = getGatherCompletionConfig(SagaGatherType.EVENT_DELETION);
17
+ expect(config).toEqual({
18
+ targetEvent: EventMessagingType.EVENT_DELETED,
19
+ stream: 'event:deleted',
20
+ wsEvent: WebsocketMessagingType.EVENT_DELETED,
21
+ });
22
+ });
23
+ it('should throw an error if an invalid gather type is requested', () => {
24
+ expect(() => getGatherCompletionConfig('INVALID_GATHER')).toThrow('[Messaging] No completion config found for saga gather type: INVALID_GATHER');
25
+ });
26
+ });
27
+ //# sourceMappingURL=gather-registry.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gather-registry.test.js","sourceRoot":"","sources":["../../src/sagas/gather-registry.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACL,cAAc,EACd,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,MAAM,GAAG,yBAAyB,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QACxE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC;QACtF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,WAAW,EAAE,kBAAkB,CAAC,aAAa;YAC7C,MAAM,EAAE,eAAe;YACvB,OAAO,EAAE,sBAAsB,CAAC,aAAa;SAC9C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,MAAM,GAAG,yBAAyB,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QACxE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,WAAW,EAAE,kBAAkB,CAAC,aAAa;YAC7C,MAAM,EAAE,eAAe;YACvB,OAAO,EAAE,sBAAsB,CAAC,aAAa;SAC9C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,CAAC,GAAG,EAAE,CAAC,yBAAyB,CAAC,gBAAuB,CAAC,CAAC,CAAC,OAAO,CACtE,6EAA6E,CAC9E,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './gather-registry.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sagas/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './gather-registry.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sagas/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { EventMessagingType, EventRegistry } from '../events/index.js';
2
+ import type { WebsocketMessagingType } from '../websockets/index.js';
3
+ export interface IGatherCompletionOutput<TEvent extends EventMessagingType = EventMessagingType, TPayload = TEvent extends keyof EventRegistry ? EventRegistry[TEvent] : Record<string, unknown>> {
4
+ targetEvent: TEvent;
5
+ stream: string;
6
+ payload: TPayload;
7
+ wsEvent?: WebsocketMessagingType;
8
+ }
9
+ export interface IGatherCompletionConfig<TEvent extends EventMessagingType = EventMessagingType> {
10
+ targetEvent: TEvent;
11
+ stream: string;
12
+ wsEvent?: WebsocketMessagingType;
13
+ }
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sagas/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAKrE,MAAM,WAAW,uBAAuB,CACtC,MAAM,SAAS,kBAAkB,GAAG,kBAAkB,EACtD,QAAQ,GAAG,MAAM,SAAS,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAG/F,WAAW,EAAE,MAAM,CAAC;IAGpB,MAAM,EAAE,MAAM,CAAC;IAGf,OAAO,EAAE,QAAQ,CAAC;IAGlB,OAAO,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAKD,MAAM,WAAW,uBAAuB,CACtC,MAAM,SAAS,kBAAkB,GAAG,kBAAkB;IAEtD,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,sBAAsB,CAAC;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sagas/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volontariapp/messaging",
3
- "version": "2.15.2",
3
+ "version": "2.16.0-snap-68b0301",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true