atomservices 0.13.2 → 0.14.0
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +83 -50
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +101 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +38 -35
- package/dist/index.d.ts +0 -68
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`uuidv7`);const t=t=>{let{AggregateType:n,EventName:r,AggregateIdentifier:i=()=>(0,e.uuidv7)(),EventIdentifier:a=()=>(0,e.uuidv7)()}=t;return({aggregateID:e,payloads:t,_metadata:o,_version:s,_createdBy:c,...l})=>({...l,_id:a(),name:r,aggregateType:n,aggregateID:e??i(),payloads:t,_version:s,_createdBy:c,_createdAt:new Date,_metadata:o??{}})},n=e=>{let{EventStore:t,Projections:n,Reactions:r,onReactionError:i}=e,a=n.reduce((e,t)=>{let n=e[t.name]||[];return n.push(t),e[t.name]=n,e},{}),o=r.reduce((e,t)=>{let n=e[t.name]||[];return n.push(t),e[t.name]=n,e},{});return{async dispatch(e,n){try{await t.append(e);let r=a[e.name]||[];await Promise.all(r.map(t=>t.project(e))),(o[e.name]||[]).forEach(t=>{t.on(e).catch(n=>{let r=n instanceof Error?n:Error(String(n));i&&i({reactionName:t.name,eventName:e.name,eventID:e._id,error:r})})}),n?.()}catch(e){let t=e instanceof Error?e:Error(String(e));throw n?.(t),t}}}},r=(...e)=>e.flatMap(e=>Object.values(e)),i=()=>(0,e.uuidv7)();exports.composeEventBuilder=t,exports.createService=n,exports.generateID=i,exports.remap=r;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/composeEventBuilder.ts","../src/createService.ts","../src/util.ts"],"sourcesContent":["import { uuidv7 } from \"uuidv7\";\r\nimport { IEvent } from \"./core/IEvent\";\r\n\r\nexport const composeEventBuilder = <T extends IEvent>(definitions: {\r\n EventName: string;\r\n AggregateType: string;\r\n AggregateIdentifier?: () => string;\r\n EventIdentifier?: () => string;\r\n}) => {\r\n const {\r\n AggregateType,\r\n EventName,\r\n AggregateIdentifier = () => uuidv7(),\r\n EventIdentifier = () => uuidv7(),\r\n } = definitions;\r\n\r\n return ({\r\n aggregateID,\r\n payloads,\r\n _metadata,\r\n _version,\r\n _createdBy,\r\n ...others\r\n }: Omit<T, \"_id\" | \"name\" | \"aggregateID\" | \"aggregateType\" | \"_createdAt\" | \"_metadata\"> & {\r\n aggregateID?: string;\r\n _metadata?: T[\"_metadata\"];\r\n }): T => ({\r\n ...others,\r\n _id: EventIdentifier(),\r\n name: EventName,\r\n aggregateType: AggregateType,\r\n aggregateID: aggregateID ?? AggregateIdentifier(),\r\n payloads,\r\n _version,\r\n _createdBy,\r\n _createdAt: new Date(),\r\n _metadata: _metadata ?? ({} as T[\"_metadata\"]),\r\n } as T);\r\n};\r\n","// src/createService.ts\r\n\r\nimport { IEventStore } from \"./core/IEventStore\";\r\nimport { IProjection } from \"./core/IProjection\";\r\nimport { IReaction } from \"./core/IReaction\";\r\nimport { IReactionError } from \"./core/IReactionError\";\r\nimport { IService } from \"./IService\";\r\n\r\nexport const createService = (definition: {\r\n EventStore: IEventStore;\r\n Projections: IProjection[];\r\n Reactions: IReaction[];\r\n onReactionError?: (context: IReactionError) => void;\r\n}): IService => {\r\n const { EventStore, Projections, Reactions, onReactionError } = definition;\r\n\r\n // Group Projections by Event Name (Supports One-to-Many)\r\n const PROJECTION_MAP = Projections.reduce((result, projection) => {\r\n const list = result[projection.name] || [];\r\n list.push(projection);\r\n result[projection.name] = list;\r\n\r\n return result;\r\n }, {} as Record<string, IProjection[]>);\r\n\r\n const REACTION_MAP = Reactions.reduce((result, reaction) => {\r\n const list = result[reaction.name] || [];\r\n list.push(reaction);\r\n result[reaction.name] = list;\r\n\r\n return result;\r\n }, {} as Record<string, IReaction[]>);\r\n\r\n return {\r\n async dispatch(event, afterHandler): Promise<void> {\r\n try {\r\n await EventStore.append(event);\r\n\r\n const projections = PROJECTION_MAP[event.name] || [];\r\n await Promise.all(projections.map((p) => p.project(event)));\r\n\r\n const reactions = REACTION_MAP[event.name] || [];\r\n reactions.forEach((r) => {\r\n r.on(event).catch((error) => {\r\n const wrappedError = error instanceof Error ? error : new Error(String(error));\r\n if (onReactionError) {\r\n onReactionError({\r\n reactionName: r.name,\r\n eventName: event.name,\r\n eventID: event._id,\r\n error: wrappedError,\r\n });\r\n }\r\n });\r\n });\r\n\r\n // Resolve successful dispatch immediately after state is sync'd\r\n afterHandler?.();\r\n } catch (error) {\r\n const wrappedError = error instanceof Error ? error : new Error(String(error));\r\n afterHandler?.(wrappedError);\r\n throw wrappedError;\r\n }\r\n },\r\n };\r\n};\r\n","import { uuidv7 } from \"uuidv7\";\r\n\r\nexport const remap = <T>(...objs: Record<string, T>[]): T[] =>\r\n objs.flatMap(obj => Object.values(obj));\r\n\r\nexport const generateID = (): string => uuidv7();\r\n"],"mappings":"2FAGA,MAAa,EAAyC,GAKhD,CACJ,GAAM,CACJ,gBACA,YACA,2BAAA,EAAA,EAAA,SAAoC,CACpC,uBAAA,EAAA,EAAA,SAAgC,EAC9B,EAEJ,OAAQ,CACN,cACA,WACA,YACA,WACA,aACA,GAAG,MAIK,CACR,GAAG,EACH,IAAK,GAAiB,CACtB,KAAM,EACN,cAAe,EACf,YAAa,GAAe,GAAqB,CACjD,WACA,WACA,aACA,WAAY,IAAI,KAChB,UAAW,GAAc,EAAE,CAC5B,GC7BU,EAAiB,GAKd,CACd,GAAM,CAAE,aAAY,cAAa,YAAW,mBAAoB,EAG1D,EAAiB,EAAY,QAAQ,EAAQ,IAAe,CAChE,IAAM,EAAO,EAAO,EAAW,OAAS,EAAE,CAI1C,OAHA,EAAK,KAAK,EAAW,CACrB,EAAO,EAAW,MAAQ,EAEnB,GACN,EAAE,CAAkC,CAEjC,EAAe,EAAU,QAAQ,EAAQ,IAAa,CAC1D,IAAM,EAAO,EAAO,EAAS,OAAS,EAAE,CAIxC,OAHA,EAAK,KAAK,EAAS,CACnB,EAAO,EAAS,MAAQ,EAEjB,GACN,EAAE,CAAgC,CAErC,MAAO,CACL,MAAM,SAAS,EAAO,EAA6B,CACjD,GAAI,CACF,MAAM,EAAW,OAAO,EAAM,CAE9B,IAAM,EAAc,EAAe,EAAM,OAAS,EAAE,CACpD,MAAM,QAAQ,IAAI,EAAY,IAAK,GAAM,EAAE,QAAQ,EAAM,CAAC,CAAC,EAEzC,EAAa,EAAM,OAAS,EAAE,EACtC,QAAS,GAAM,CACvB,EAAE,GAAG,EAAM,CAAC,MAAO,GAAU,CAC3B,IAAM,EAAe,aAAiB,MAAQ,EAAY,MAAM,OAAO,EAAM,CAAC,CAC1E,GACF,EAAgB,CACd,aAAc,EAAE,KAChB,UAAW,EAAM,KACjB,QAAS,EAAM,IACf,MAAO,EACR,CAAC,EAEJ,EACF,CAGF,KAAgB,OACT,EAAO,CACd,IAAM,EAAe,aAAiB,MAAQ,EAAY,MAAM,OAAO,EAAM,CAAC,CAE9E,MADA,IAAe,EAAa,CACtB,IAGX,EC9DU,GAAY,GAAG,IAC1B,EAAK,QAAQ,GAAO,OAAO,OAAO,EAAI,CAAC,CAE5B,OAAA,EAAA,EAAA,SAAmC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,68 +1,101 @@
|
|
|
1
|
+
//#region src/core/IEvent.d.ts
|
|
1
2
|
interface IEvent<Payloads = any, Metadata extends Record<string, unknown> = {}> {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
_id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
aggregateID: string;
|
|
6
|
+
aggregateType: string;
|
|
7
|
+
payloads: Payloads;
|
|
8
|
+
_version: number;
|
|
9
|
+
_createdAt: Date;
|
|
10
|
+
_createdBy: string;
|
|
11
|
+
_metadata: Metadata;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/core/IEventStore.d.ts
|
|
15
|
+
interface IEventStore {
|
|
16
|
+
append: (event: IEvent) => Promise<void>;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/core/IProjection.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* PROJECTION.
|
|
22
|
+
* Responsibility: Update the Read Model.
|
|
23
|
+
* Must be idempotent and focused solely on state representation.
|
|
24
|
+
*/
|
|
25
|
+
interface IProjection<E extends IEvent = IEvent> {
|
|
26
|
+
name: string;
|
|
27
|
+
project: (event: E) => Promise<void>;
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/core/IReaction.d.ts
|
|
31
|
+
/**
|
|
32
|
+
* SIDE EFFECT HANDLER.
|
|
33
|
+
* Reactions are asynchronous, non-blocking listeners to events.
|
|
34
|
+
* They do NOT update state directly; they trigger external actions or new events.
|
|
35
|
+
*/
|
|
36
|
+
interface IReaction<E extends IEvent = IEvent> {
|
|
37
|
+
name: string;
|
|
38
|
+
on: (event: E) => Promise<void>;
|
|
25
39
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/core/IReactionError.d.ts
|
|
42
|
+
interface IReactionError {
|
|
43
|
+
reactionName: string;
|
|
44
|
+
eventName: string;
|
|
45
|
+
eventID: string;
|
|
46
|
+
error: Error;
|
|
30
47
|
}
|
|
31
|
-
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/core/IReducer.d.ts
|
|
32
50
|
/**
|
|
33
51
|
* PURE FUNCTION.
|
|
34
52
|
* Must calculate the new state immediately without side effects.
|
|
35
53
|
* Used for high-performance Aggregate Rehydration.
|
|
36
54
|
*/
|
|
37
55
|
interface IReducer<T> {
|
|
38
|
-
|
|
56
|
+
(state: T, event: IEvent): T;
|
|
39
57
|
}
|
|
40
|
-
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/IService.d.ts
|
|
41
60
|
interface IService {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Persists an event to the Store and triggers the handler in the background.
|
|
63
|
+
* * @param event The event to dispatch.
|
|
64
|
+
* @param afterHandler Optional callback triggered after background processing is complete.
|
|
65
|
+
* @returns A promise that resolves as soon as the event is successfully stored.
|
|
66
|
+
*/
|
|
67
|
+
dispatch: (event: IEvent, afterHandler?: (error?: Error) => void) => Promise<void>;
|
|
49
68
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/composeEventBuilder.d.ts
|
|
71
|
+
declare const composeEventBuilder: <T extends IEvent>(definitions: {
|
|
72
|
+
EventName: string;
|
|
73
|
+
AggregateType: string;
|
|
74
|
+
AggregateIdentifier?: () => string;
|
|
75
|
+
EventIdentifier?: () => string;
|
|
76
|
+
}) => ({
|
|
77
|
+
aggregateID,
|
|
78
|
+
payloads,
|
|
79
|
+
_metadata,
|
|
80
|
+
_version,
|
|
81
|
+
_createdBy,
|
|
82
|
+
...others
|
|
83
|
+
}: Omit<T, "_id" | "name" | "aggregateID" | "aggregateType" | "_createdAt" | "_metadata"> & {
|
|
84
|
+
aggregateID?: string;
|
|
85
|
+
_metadata?: T["_metadata"];
|
|
59
86
|
}) => T;
|
|
60
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/createService.d.ts
|
|
61
89
|
declare const createService: (definition: {
|
|
62
|
-
|
|
63
|
-
|
|
90
|
+
EventStore: IEventStore;
|
|
91
|
+
Projections: IProjection[];
|
|
92
|
+
Reactions: IReaction[];
|
|
93
|
+
onReactionError?: (context: IReactionError) => void;
|
|
64
94
|
}) => IService;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/util.d.ts
|
|
97
|
+
declare const remap: <T>(...objs: Record<string, T>[]) => T[];
|
|
98
|
+
declare const generateID: () => string;
|
|
99
|
+
//#endregion
|
|
100
|
+
export { type IEvent, type IEventStore, type IProjection, type IReaction, type IReactionError, type IReducer, type IService, composeEventBuilder, createService, generateID, remap };
|
|
101
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/IEvent.ts","../src/core/IEventStore.ts","../src/core/IProjection.ts","../src/core/IReaction.ts","../src/core/IReactionError.ts","../src/core/IReducer.ts","../src/IService.ts","../src/composeEventBuilder.ts","../src/createService.ts","../src/util.ts"],"mappings":";UAEiB,MAAA,kCAAwC,MAAA;EACvD,GAAA;EACA,IAAA;EACA,WAAA;EACA,aAAA;EACA,QAAA,EAAU,QAAA;EACV,QAAA;EACA,UAAA,EAAY,IAAA;EACZ,UAAA;EACA,SAAA,EAAW,QAAA;AAAA;;;UCPI,WAAA;EACf,MAAA,GAAS,KAAA,EAAO,MAAA,KAAW,OAAA;AAAA;;;ADH7B;;;;;AAAA,UEOiB,WAAA,WAAsB,MAAA,GAAS,MAAA;EAC9C,IAAA;EACA,OAAA,GAAU,KAAA,EAAO,CAAA,KAAM,OAAA;AAAA;;;AFTzB;;;;;AAAA,UGKiB,SAAA,WAAoB,MAAA,GAAS,MAAA;EAC5C,IAAA;EACA,EAAA,GAAK,KAAA,EAAO,CAAA,KAAM,OAAA;AAAA;;;UCTH,cAAA;EACf,YAAA;EACA,SAAA;EACA,OAAA;EACA,KAAA,EAAO,KAAA;AAAA;;;AJFT;;;;;AAAA,UKOiB,QAAA;EAAA,CACd,KAAA,EAAO,CAAA,EAAG,KAAA,EAAO,MAAA,GAAS,CAAA;AAAA;;;UCNZ,QAAA;ENFM;;;;;;EMSrB,QAAA,GAAW,KAAA,EAAO,MAAA,EAAQ,YAAA,IAAgB,KAAA,GAAQ,KAAA,cAAmB,OAAA;AAAA;;;cCR1D,mBAAA,aAAiC,MAAA,EAAQ,WAAA;EACpD,SAAA;EACA,aAAA;EACA,mBAAA;EACA,eAAA;AAAA;EASQ,WAAA;EAAA,QAAA;EAAA,SAAA;EAAA,QAAA;EAAA,UAAA;EAAA,GAAA;AAAA,GAOL,IAAA,CAAK,CAAA;EACN,WAAA;EACA,SAAA,GAAY,CAAA;AAAA,MACV,CAAA;;;cClBO,aAAA,GAAiB,UAAA;EAC5B,UAAA,EAAY,WAAA;EACZ,WAAA,EAAa,WAAA;EACb,SAAA,EAAW,SAAA;EACX,eAAA,IAAmB,OAAA,EAAS,cAAA;AAAA,MAC1B,QAAA;;;cCXS,KAAA,SAAe,IAAA,EAAM,MAAA,SAAe,CAAA,QAAO,CAAA;AAAA,cAG3C,UAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//#region src/core/IEvent.d.ts
|
|
2
|
+
interface IEvent<Payloads = any, Metadata extends Record<string, unknown> = {}> {
|
|
3
|
+
_id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
aggregateID: string;
|
|
6
|
+
aggregateType: string;
|
|
7
|
+
payloads: Payloads;
|
|
8
|
+
_version: number;
|
|
9
|
+
_createdAt: Date;
|
|
10
|
+
_createdBy: string;
|
|
11
|
+
_metadata: Metadata;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/core/IEventStore.d.ts
|
|
15
|
+
interface IEventStore {
|
|
16
|
+
append: (event: IEvent) => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/core/IProjection.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* PROJECTION.
|
|
22
|
+
* Responsibility: Update the Read Model.
|
|
23
|
+
* Must be idempotent and focused solely on state representation.
|
|
24
|
+
*/
|
|
25
|
+
interface IProjection<E extends IEvent = IEvent> {
|
|
26
|
+
name: string;
|
|
27
|
+
project: (event: E) => Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/core/IReaction.d.ts
|
|
31
|
+
/**
|
|
32
|
+
* SIDE EFFECT HANDLER.
|
|
33
|
+
* Reactions are asynchronous, non-blocking listeners to events.
|
|
34
|
+
* They do NOT update state directly; they trigger external actions or new events.
|
|
35
|
+
*/
|
|
36
|
+
interface IReaction<E extends IEvent = IEvent> {
|
|
37
|
+
name: string;
|
|
38
|
+
on: (event: E) => Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/core/IReactionError.d.ts
|
|
42
|
+
interface IReactionError {
|
|
43
|
+
reactionName: string;
|
|
44
|
+
eventName: string;
|
|
45
|
+
eventID: string;
|
|
46
|
+
error: Error;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/core/IReducer.d.ts
|
|
50
|
+
/**
|
|
51
|
+
* PURE FUNCTION.
|
|
52
|
+
* Must calculate the new state immediately without side effects.
|
|
53
|
+
* Used for high-performance Aggregate Rehydration.
|
|
54
|
+
*/
|
|
55
|
+
interface IReducer<T> {
|
|
56
|
+
(state: T, event: IEvent): T;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/IService.d.ts
|
|
60
|
+
interface IService {
|
|
61
|
+
/**
|
|
62
|
+
* Persists an event to the Store and triggers the handler in the background.
|
|
63
|
+
* * @param event The event to dispatch.
|
|
64
|
+
* @param afterHandler Optional callback triggered after background processing is complete.
|
|
65
|
+
* @returns A promise that resolves as soon as the event is successfully stored.
|
|
66
|
+
*/
|
|
67
|
+
dispatch: (event: IEvent, afterHandler?: (error?: Error) => void) => Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/composeEventBuilder.d.ts
|
|
71
|
+
declare const composeEventBuilder: <T extends IEvent>(definitions: {
|
|
72
|
+
EventName: string;
|
|
73
|
+
AggregateType: string;
|
|
74
|
+
AggregateIdentifier?: () => string;
|
|
75
|
+
EventIdentifier?: () => string;
|
|
76
|
+
}) => ({
|
|
77
|
+
aggregateID,
|
|
78
|
+
payloads,
|
|
79
|
+
_metadata,
|
|
80
|
+
_version,
|
|
81
|
+
_createdBy,
|
|
82
|
+
...others
|
|
83
|
+
}: Omit<T, "_id" | "name" | "aggregateID" | "aggregateType" | "_createdAt" | "_metadata"> & {
|
|
84
|
+
aggregateID?: string;
|
|
85
|
+
_metadata?: T["_metadata"];
|
|
86
|
+
}) => T;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/createService.d.ts
|
|
89
|
+
declare const createService: (definition: {
|
|
90
|
+
EventStore: IEventStore;
|
|
91
|
+
Projections: IProjection[];
|
|
92
|
+
Reactions: IReaction[];
|
|
93
|
+
onReactionError?: (context: IReactionError) => void;
|
|
94
|
+
}) => IService;
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/util.d.ts
|
|
97
|
+
declare const remap: <T>(...objs: Record<string, T>[]) => T[];
|
|
98
|
+
declare const generateID: () => string;
|
|
99
|
+
//#endregion
|
|
100
|
+
export { type IEvent, type IEventStore, type IProjection, type IReaction, type IReactionError, type IReducer, type IService, composeEventBuilder, createService, generateID, remap };
|
|
101
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/IEvent.ts","../src/core/IEventStore.ts","../src/core/IProjection.ts","../src/core/IReaction.ts","../src/core/IReactionError.ts","../src/core/IReducer.ts","../src/IService.ts","../src/composeEventBuilder.ts","../src/createService.ts","../src/util.ts"],"mappings":";UAEiB,MAAA,kCAAwC,MAAA;EACvD,GAAA;EACA,IAAA;EACA,WAAA;EACA,aAAA;EACA,QAAA,EAAU,QAAA;EACV,QAAA;EACA,UAAA,EAAY,IAAA;EACZ,UAAA;EACA,SAAA,EAAW,QAAA;AAAA;;;UCPI,WAAA;EACf,MAAA,GAAS,KAAA,EAAO,MAAA,KAAW,OAAA;AAAA;;;ADH7B;;;;;AAAA,UEOiB,WAAA,WAAsB,MAAA,GAAS,MAAA;EAC9C,IAAA;EACA,OAAA,GAAU,KAAA,EAAO,CAAA,KAAM,OAAA;AAAA;;;AFTzB;;;;;AAAA,UGKiB,SAAA,WAAoB,MAAA,GAAS,MAAA;EAC5C,IAAA;EACA,EAAA,GAAK,KAAA,EAAO,CAAA,KAAM,OAAA;AAAA;;;UCTH,cAAA;EACf,YAAA;EACA,SAAA;EACA,OAAA;EACA,KAAA,EAAO,KAAA;AAAA;;;AJFT;;;;;AAAA,UKOiB,QAAA;EAAA,CACd,KAAA,EAAO,CAAA,EAAG,KAAA,EAAO,MAAA,GAAS,CAAA;AAAA;;;UCNZ,QAAA;ENFM;;;;;;EMSrB,QAAA,GAAW,KAAA,EAAO,MAAA,EAAQ,YAAA,IAAgB,KAAA,GAAQ,KAAA,cAAmB,OAAA;AAAA;;;cCR1D,mBAAA,aAAiC,MAAA,EAAQ,WAAA;EACpD,SAAA;EACA,aAAA;EACA,mBAAA;EACA,eAAA;AAAA;EASQ,WAAA;EAAA,QAAA;EAAA,SAAA;EAAA,QAAA;EAAA,UAAA;EAAA,GAAA;AAAA,GAOL,IAAA,CAAK,CAAA;EACN,WAAA;EACA,SAAA,GAAY,CAAA;AAAA,MACV,CAAA;;;cClBO,aAAA,GAAiB,UAAA;EAC5B,UAAA,EAAY,WAAA;EACZ,WAAA,EAAa,WAAA;EACb,SAAA,EAAW,SAAA;EACX,eAAA,IAAmB,OAAA,EAAS,cAAA;AAAA,MAC1B,QAAA;;;cCXS,KAAA,SAAe,IAAA,EAAM,MAAA,SAAe,CAAA,QAAO,CAAA;AAAA,cAG3C,UAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{uuidv7 as e}from"uuidv7";const t=t=>{let{AggregateType:n,EventName:r,AggregateIdentifier:i=()=>e(),EventIdentifier:a=()=>e()}=t;return({aggregateID:e,payloads:t,_metadata:o,_version:s,_createdBy:c,...l})=>({...l,_id:a(),name:r,aggregateType:n,aggregateID:e??i(),payloads:t,_version:s,_createdBy:c,_createdAt:new Date,_metadata:o??{}})},n=e=>{let{EventStore:t,Projections:n,Reactions:r,onReactionError:i}=e,a=n.reduce((e,t)=>{let n=e[t.name]||[];return n.push(t),e[t.name]=n,e},{}),o=r.reduce((e,t)=>{let n=e[t.name]||[];return n.push(t),e[t.name]=n,e},{});return{async dispatch(e,n){try{await t.append(e);let r=a[e.name]||[];await Promise.all(r.map(t=>t.project(e))),(o[e.name]||[]).forEach(t=>{t.on(e).catch(n=>{let r=n instanceof Error?n:Error(String(n));i&&i({reactionName:t.name,eventName:e.name,eventID:e._id,error:r})})}),n?.()}catch(e){let t=e instanceof Error?e:Error(String(e));throw n?.(t),t}}}},r=(...e)=>e.flatMap(e=>Object.values(e)),i=()=>e();export{t as composeEventBuilder,n as createService,i as generateID,r as remap};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/composeEventBuilder.ts","../src/createService.ts","../src/util.ts"],"sourcesContent":["import { uuidv7 } from \"uuidv7\";\r\nimport { IEvent } from \"./core/IEvent\";\r\n\r\nexport const composeEventBuilder = <T extends IEvent>(definitions: {\r\n EventName: string;\r\n AggregateType: string;\r\n AggregateIdentifier?: () => string;\r\n EventIdentifier?: () => string;\r\n}) => {\r\n const {\r\n AggregateType,\r\n EventName,\r\n AggregateIdentifier = () => uuidv7(),\r\n EventIdentifier = () => uuidv7(),\r\n } = definitions;\r\n\r\n return ({\r\n aggregateID,\r\n payloads,\r\n _metadata,\r\n _version,\r\n _createdBy,\r\n ...others\r\n }: Omit<T, \"_id\" | \"name\" | \"aggregateID\" | \"aggregateType\" | \"_createdAt\" | \"_metadata\"> & {\r\n aggregateID?: string;\r\n _metadata?: T[\"_metadata\"];\r\n }): T => ({\r\n ...others,\r\n _id: EventIdentifier(),\r\n name: EventName,\r\n aggregateType: AggregateType,\r\n aggregateID: aggregateID ?? AggregateIdentifier(),\r\n payloads,\r\n _version,\r\n _createdBy,\r\n _createdAt: new Date(),\r\n _metadata: _metadata ?? ({} as T[\"_metadata\"]),\r\n } as T);\r\n};\r\n","// src/createService.ts\r\n\r\nimport { IEventStore } from \"./core/IEventStore\";\r\nimport { IProjection } from \"./core/IProjection\";\r\nimport { IReaction } from \"./core/IReaction\";\r\nimport { IReactionError } from \"./core/IReactionError\";\r\nimport { IService } from \"./IService\";\r\n\r\nexport const createService = (definition: {\r\n EventStore: IEventStore;\r\n Projections: IProjection[];\r\n Reactions: IReaction[];\r\n onReactionError?: (context: IReactionError) => void;\r\n}): IService => {\r\n const { EventStore, Projections, Reactions, onReactionError } = definition;\r\n\r\n // Group Projections by Event Name (Supports One-to-Many)\r\n const PROJECTION_MAP = Projections.reduce((result, projection) => {\r\n const list = result[projection.name] || [];\r\n list.push(projection);\r\n result[projection.name] = list;\r\n\r\n return result;\r\n }, {} as Record<string, IProjection[]>);\r\n\r\n const REACTION_MAP = Reactions.reduce((result, reaction) => {\r\n const list = result[reaction.name] || [];\r\n list.push(reaction);\r\n result[reaction.name] = list;\r\n\r\n return result;\r\n }, {} as Record<string, IReaction[]>);\r\n\r\n return {\r\n async dispatch(event, afterHandler): Promise<void> {\r\n try {\r\n await EventStore.append(event);\r\n\r\n const projections = PROJECTION_MAP[event.name] || [];\r\n await Promise.all(projections.map((p) => p.project(event)));\r\n\r\n const reactions = REACTION_MAP[event.name] || [];\r\n reactions.forEach((r) => {\r\n r.on(event).catch((error) => {\r\n const wrappedError = error instanceof Error ? error : new Error(String(error));\r\n if (onReactionError) {\r\n onReactionError({\r\n reactionName: r.name,\r\n eventName: event.name,\r\n eventID: event._id,\r\n error: wrappedError,\r\n });\r\n }\r\n });\r\n });\r\n\r\n // Resolve successful dispatch immediately after state is sync'd\r\n afterHandler?.();\r\n } catch (error) {\r\n const wrappedError = error instanceof Error ? error : new Error(String(error));\r\n afterHandler?.(wrappedError);\r\n throw wrappedError;\r\n }\r\n },\r\n };\r\n};\r\n","import { uuidv7 } from \"uuidv7\";\r\n\r\nexport const remap = <T>(...objs: Record<string, T>[]): T[] =>\r\n objs.flatMap(obj => Object.values(obj));\r\n\r\nexport const generateID = (): string => uuidv7();\r\n"],"mappings":"gCAGA,MAAa,EAAyC,GAKhD,CACJ,GAAM,CACJ,gBACA,YACA,0BAA4B,GAAQ,CACpC,sBAAwB,GAAQ,EAC9B,EAEJ,OAAQ,CACN,cACA,WACA,YACA,WACA,aACA,GAAG,MAIK,CACR,GAAG,EACH,IAAK,GAAiB,CACtB,KAAM,EACN,cAAe,EACf,YAAa,GAAe,GAAqB,CACjD,WACA,WACA,aACA,WAAY,IAAI,KAChB,UAAW,GAAc,EAAE,CAC5B,GC7BU,EAAiB,GAKd,CACd,GAAM,CAAE,aAAY,cAAa,YAAW,mBAAoB,EAG1D,EAAiB,EAAY,QAAQ,EAAQ,IAAe,CAChE,IAAM,EAAO,EAAO,EAAW,OAAS,EAAE,CAI1C,OAHA,EAAK,KAAK,EAAW,CACrB,EAAO,EAAW,MAAQ,EAEnB,GACN,EAAE,CAAkC,CAEjC,EAAe,EAAU,QAAQ,EAAQ,IAAa,CAC1D,IAAM,EAAO,EAAO,EAAS,OAAS,EAAE,CAIxC,OAHA,EAAK,KAAK,EAAS,CACnB,EAAO,EAAS,MAAQ,EAEjB,GACN,EAAE,CAAgC,CAErC,MAAO,CACL,MAAM,SAAS,EAAO,EAA6B,CACjD,GAAI,CACF,MAAM,EAAW,OAAO,EAAM,CAE9B,IAAM,EAAc,EAAe,EAAM,OAAS,EAAE,CACpD,MAAM,QAAQ,IAAI,EAAY,IAAK,GAAM,EAAE,QAAQ,EAAM,CAAC,CAAC,EAEzC,EAAa,EAAM,OAAS,EAAE,EACtC,QAAS,GAAM,CACvB,EAAE,GAAG,EAAM,CAAC,MAAO,GAAU,CAC3B,IAAM,EAAe,aAAiB,MAAQ,EAAY,MAAM,OAAO,EAAM,CAAC,CAC1E,GACF,EAAgB,CACd,aAAc,EAAE,KAChB,UAAW,EAAM,KACjB,QAAS,EAAM,IACf,MAAO,EACR,CAAC,EAEJ,EACF,CAGF,KAAgB,OACT,EAAO,CACd,IAAM,EAAe,aAAiB,MAAQ,EAAY,MAAM,OAAO,EAAM,CAAC,CAE9E,MADA,IAAe,EAAa,CACtB,IAGX,EC9DU,GAAY,GAAG,IAC1B,EAAK,QAAQ,GAAO,OAAO,OAAO,EAAI,CAAC,CAE5B,MAA2B,GAAQ"}
|
package/package.json
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "atomservices",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/index.cjs",
|
|
6
|
-
"module": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"publishConfig": {
|
|
19
|
-
"access": "public"
|
|
20
|
-
},
|
|
21
|
-
"license": "ISC",
|
|
22
|
-
"author": "Architecode",
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "
|
|
25
|
-
"dev": "
|
|
26
|
-
"test": "vitest",
|
|
27
|
-
"prepublishOnly": "npm run build"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@types/node": "^25.
|
|
31
|
-
"
|
|
32
|
-
"typescript": "^
|
|
33
|
-
"vitest": "^4.1.
|
|
34
|
-
}
|
|
35
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "atomservices",
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"author": "Architecode Corporation",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsdown --clean",
|
|
25
|
+
"dev": "tsdown --watch",
|
|
26
|
+
"test": "vitest",
|
|
27
|
+
"prepublishOnly": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^25.6.0",
|
|
31
|
+
"tsdown": "^0.21.10",
|
|
32
|
+
"typescript": "^6.0.3",
|
|
33
|
+
"vitest": "^4.1.5"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"uuidv7": "^1.2.1"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
interface IEvent<Payloads = any, Metadata extends Record<string, unknown> = {}> {
|
|
2
|
-
_id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
aggregateID: string;
|
|
5
|
-
aggregateType: string;
|
|
6
|
-
payloads: Payloads;
|
|
7
|
-
_version: number;
|
|
8
|
-
_createdAt: Date;
|
|
9
|
-
_createdBy: string;
|
|
10
|
-
_metadata: Metadata;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface IEventHandler<E extends IEvent = IEvent> {
|
|
14
|
-
name: string;
|
|
15
|
-
handle: (event: E) => Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface IEventHandlers {
|
|
19
|
-
resolve: (event: IEvent) => IEventHandler;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface IEventStore {
|
|
23
|
-
init: () => Promise<void>;
|
|
24
|
-
append: (event: IEvent) => Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface IIdentifiers {
|
|
28
|
-
AggregateID: () => string;
|
|
29
|
-
EventID: () => string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* PURE FUNCTION.
|
|
34
|
-
* Must calculate the new state immediately without side effects.
|
|
35
|
-
* Used for high-performance Aggregate Rehydration.
|
|
36
|
-
*/
|
|
37
|
-
interface IReducer<T> {
|
|
38
|
-
(state: T, event: IEvent): T;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface IService {
|
|
42
|
-
/**
|
|
43
|
-
* Persists an event to the Store and triggers the handler in the background.
|
|
44
|
-
* * @param event The event to dispatch.
|
|
45
|
-
* @param afterHandler Optional callback triggered after background processing is complete.
|
|
46
|
-
* @returns A promise that resolves as soon as the event is successfully stored.
|
|
47
|
-
*/
|
|
48
|
-
dispatch: (event: IEvent, afterHandler?: (error?: Error) => void) => Promise<void>;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
declare const composeEventBuilder: (identifiers: IIdentifiers) => <T extends IEvent>(definitions: {
|
|
52
|
-
EventName: string;
|
|
53
|
-
AggregateType: string;
|
|
54
|
-
AggregateIdentifier?: () => string;
|
|
55
|
-
EventIdentifier?: () => string;
|
|
56
|
-
}) => ({ aggregateID, _metadata, ...others }: Omit<T, "_id" | "name" | "aggregateID" | "aggregateType" | "_createdAt" | "_metadata"> & {
|
|
57
|
-
aggregateID?: string;
|
|
58
|
-
_metadata?: T["_metadata"];
|
|
59
|
-
}) => T;
|
|
60
|
-
|
|
61
|
-
declare const createService: (definition: {
|
|
62
|
-
EventStore: IEventStore;
|
|
63
|
-
EventHandlers: IEventHandler[];
|
|
64
|
-
}) => IService;
|
|
65
|
-
|
|
66
|
-
declare const reduceHandlers: (...objs: Record<string, IEventHandler>[]) => IEventHandler[];
|
|
67
|
-
|
|
68
|
-
export { type IEvent, type IEventHandler, type IEventHandlers, type IEventStore, type IIdentifiers, type IReducer, type IService, composeEventBuilder, createService, reduceHandlers };
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var m=t=>n=>{let{AggregateType:c,EventName:e,AggregateIdentifier:o=()=>t.AggregateID(),EventIdentifier:i=()=>t.EventID()}=n;return({aggregateID:s,_metadata:r,...a})=>({...a,_id:i(),name:e,aggregateType:c,aggregateID:s??o(),_metadata:r??{},_createdAt:new Date})};var p=(...t)=>{let n=t.reduce((e,o)=>{let{name:i}=o;return e[i]===void 0&&(e[i]=o),e},{});return{resolve:e=>n[e.name]}},g=t=>{let{EventStore:n,EventHandlers:c}=t,e,o=async()=>{await n.init()},i=p(...c);return{async dispatch(s,r){e||(e=o()),await e;try{await n.append(s);let a=i.resolve(s);a?a.handle(s).then(()=>{r&&r()}).catch(d=>{let I=d instanceof Error?d:new Error(String(d));r&&r(I)}):r&&r()}catch(a){let d=a instanceof Error?a:new Error(String(a));throw r&&r(d),d}}}};var f=(...t)=>t.flatMap(n=>Object.values(n));export{m as composeEventBuilder,g as createService,f as reduceHandlers};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/composeEventBuilder.ts","../src/createService.ts","../src/reduceHandlers.ts"],"sourcesContent":["import { IEvent } from \"./core/IEvent\";\r\nimport { IIdentifiers } from \"./core/IIdentifiers\";\r\n\r\nexport const composeEventBuilder = (identifiers: IIdentifiers) =>\r\n <T extends IEvent>(definitions: {\r\n EventName: string;\r\n AggregateType: string;\r\n AggregateIdentifier?: () => string;\r\n EventIdentifier?: () => string;\r\n }) => {\r\n const {\r\n AggregateType,\r\n EventName,\r\n AggregateIdentifier = () => identifiers.AggregateID(),\r\n EventIdentifier = () => identifiers.EventID(),\r\n } = definitions;\r\n\r\n return ({\r\n aggregateID,\r\n _metadata,\r\n ...others\r\n }: Omit<T, \"_id\" | \"name\" | \"aggregateID\" | \"aggregateType\" | \"_createdAt\" | \"_metadata\"> & {\r\n aggregateID?: string;\r\n _metadata?: T[\"_metadata\"];\r\n }): T => ({\r\n ...others,\r\n _id: EventIdentifier(),\r\n name: EventName,\r\n aggregateType: AggregateType,\r\n aggregateID: aggregateID ?? AggregateIdentifier(),\r\n _metadata: _metadata ?? ({} as T[\"_metadata\"]),\r\n _createdAt: new Date(),\r\n } as T);\r\n };\r\n","// src/createService.ts\r\n\r\nimport { IEvent } from \"./core/IEvent\";\r\nimport { IEventStore } from \"./core/IEventStore\";\r\nimport { IEventHandler } from \"./core/IEventHandler\";\r\nimport { IEventHandlers } from \"./core/IEventHandlers\";\r\nimport { IService } from \"./IService\";\r\n\r\nconst reduceEventHandlers = (...handlers: IEventHandler[]): IEventHandlers => {\r\n const HANDLERS_MAP = handlers.reduce((result, handler) => {\r\n const { name } = handler;\r\n\r\n if (result[name] === undefined) {\r\n result[name] = handler;\r\n } else {\r\n\r\n }\r\n\r\n return result;\r\n }, {} as Record<string, IEventHandler>);\r\n\r\n const Handlers: IEventHandlers = {\r\n resolve: (event) =>\r\n HANDLERS_MAP[event.name],\r\n };\r\n\r\n return Handlers;\r\n};\r\n\r\n\r\nexport const createService = (definition: {\r\n EventStore: IEventStore;\r\n EventHandlers: IEventHandler[];\r\n}): IService => {\r\n const { EventStore, EventHandlers } = definition;\r\n\r\n let _initPromise: Promise<void> | undefined = undefined;\r\n\r\n const initialize = async (): Promise<void> => {\r\n await EventStore.init();\r\n };\r\n\r\n const EVENT_HANDLERS = reduceEventHandlers(...EventHandlers);\r\n\r\n return {\r\n async dispatch(event: IEvent, notified?: (error?: Error) => void): Promise<void> {\r\n if (!_initPromise) {\r\n _initPromise = initialize();\r\n }\r\n\r\n await _initPromise;\r\n\r\n try {\r\n await EventStore.append(event);\r\n\r\n const handler = EVENT_HANDLERS.resolve(event);\r\n\r\n if (handler) {\r\n handler.handle(event)\r\n .then(() => {\r\n if (notified)\r\n notified();\r\n })\r\n .catch((error) => {\r\n const wrappedError = error instanceof Error ? error : new Error(String(error));\r\n\r\n if (notified)\r\n notified(wrappedError);\r\n });\r\n } else {\r\n if (notified)\r\n notified();\r\n }\r\n } catch (error) {\r\n const wrappedError = error instanceof Error ? error : new Error(String(error));\r\n\r\n if (notified)\r\n notified(wrappedError);\r\n\r\n throw wrappedError;\r\n }\r\n },\r\n };\r\n};\r\n","import { IEventHandler } from \"./core/IEventHandler\";\r\n\r\nexport const reduceHandlers = (...objs: Record<string, IEventHandler>[]): IEventHandler[] =>\r\n objs.flatMap(obj => Object.values(obj));\r\n"],"mappings":"AAGO,IAAMA,EAAuBC,GACfC,GAKb,CACJ,GAAM,CACJ,cAAAC,EACA,UAAAC,EACA,oBAAAC,EAAsB,IAAMJ,EAAY,YAAY,EACpD,gBAAAK,EAAkB,IAAML,EAAY,QAAQ,CAC9C,EAAIC,EAEJ,MAAO,CAAC,CACN,YAAAK,EACA,UAAAC,EACA,GAAGC,CACL,KAGU,CACR,GAAGA,EACH,IAAKH,EAAgB,EACrB,KAAMF,EACN,cAAeD,EACf,YAAaI,GAAeF,EAAoB,EAChD,UAAWG,GAAc,CAAC,EAC1B,WAAY,IAAI,IAClB,EACF,ECzBF,IAAME,EAAsB,IAAIC,IAA8C,CAC5E,IAAMC,EAAeD,EAAS,OAAO,CAACE,EAAQC,IAAY,CACxD,GAAM,CAAE,KAAAC,CAAK,EAAID,EAEjB,OAAID,EAAOE,CAAI,IAAM,SACnBF,EAAOE,CAAI,EAAID,GAKVD,CACT,EAAG,CAAC,CAAkC,EAOtC,MALiC,CAC/B,QAAUG,GACRJ,EAAaI,EAAM,IAAI,CAC3B,CAGF,EAGaC,EAAiBC,GAGd,CACd,GAAM,CAAE,WAAAC,EAAY,cAAAC,CAAc,EAAIF,EAElCG,EAEEC,EAAa,SAA2B,CAC5C,MAAMH,EAAW,KAAK,CACxB,EAEMI,EAAiBb,EAAoB,GAAGU,CAAa,EAE3D,MAAO,CACL,MAAM,SAASJ,EAAeQ,EAAmD,CAC1EH,IACHA,EAAeC,EAAW,GAG5B,MAAMD,EAEN,GAAI,CACF,MAAMF,EAAW,OAAOH,CAAK,EAE7B,IAAMF,EAAUS,EAAe,QAAQP,CAAK,EAExCF,EACFA,EAAQ,OAAOE,CAAK,EACjB,KAAK,IAAM,CACNQ,GACFA,EAAS,CACb,CAAC,EACA,MAAOC,GAAU,CAChB,IAAMC,EAAeD,aAAiB,MAAQA,EAAQ,IAAI,MAAM,OAAOA,CAAK,CAAC,EAEzED,GACFA,EAASE,CAAY,CACzB,CAAC,EAECF,GACFA,EAAS,CAEf,OAASC,EAAO,CACd,IAAMC,EAAeD,aAAiB,MAAQA,EAAQ,IAAI,MAAM,OAAOA,CAAK,CAAC,EAE7E,MAAID,GACFA,EAASE,CAAY,EAEjBA,CACR,CACF,CACF,CACF,ECjFO,IAAMC,EAAiB,IAAIC,IAChCA,EAAK,QAAQC,GAAO,OAAO,OAAOA,CAAG,CAAC","names":["composeEventBuilder","identifiers","definitions","AggregateType","EventName","AggregateIdentifier","EventIdentifier","aggregateID","_metadata","others","reduceEventHandlers","handlers","HANDLERS_MAP","result","handler","name","event","createService","definition","EventStore","EventHandlers","_initPromise","initialize","EVENT_HANDLERS","notified","error","wrappedError","reduceHandlers","objs","obj"]}
|