@event-driven-io/emmett 0.5.5 → 0.7.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.
Files changed (115) hide show
  1. package/dist/chunk-4PGUBQK3.js +2 -0
  2. package/dist/chunk-4PGUBQK3.js.map +1 -0
  3. package/dist/chunk-5BGN2FV4.js +1 -0
  4. package/dist/chunk-6WITJBGG.js +2 -0
  5. package/dist/chunk-6WITJBGG.js.map +1 -0
  6. package/dist/chunk-7D2LV2X5.js +5 -0
  7. package/dist/chunk-7D2LV2X5.js.map +1 -0
  8. package/dist/chunk-AMRL5G7K.mjs +2 -0
  9. package/dist/chunk-AMRL5G7K.mjs.map +1 -0
  10. package/dist/chunk-AWUWW7EJ.mjs +2 -0
  11. package/dist/chunk-AWUWW7EJ.mjs.map +1 -0
  12. package/dist/chunk-AYVR4VYR.mjs +2 -0
  13. package/dist/chunk-AYVR4VYR.mjs.map +1 -0
  14. package/dist/chunk-DOHUIBZQ.mjs +1 -0
  15. package/dist/chunk-HVU6UBXF.mjs +5 -0
  16. package/dist/chunk-HVU6UBXF.mjs.map +1 -0
  17. package/dist/chunk-JDYZZRJE.mjs +2 -0
  18. package/dist/chunk-JDYZZRJE.mjs.map +1 -0
  19. package/dist/chunk-MHB2JU4U.js +2 -0
  20. package/dist/chunk-MHB2JU4U.js.map +1 -0
  21. package/dist/chunk-S3PRXL2J.js +2 -0
  22. package/dist/chunk-S3PRXL2J.js.map +1 -0
  23. package/dist/chunk-TDCMNVXU.mjs +1 -0
  24. package/dist/chunk-YWRV75GA.mjs +1 -0
  25. package/dist/chunk-Z4Z6POJH.js +1 -0
  26. package/dist/chunk-ZLASBJGR.js +1 -0
  27. package/dist/commandHandling/handleCommand.d.mts +3 -2
  28. package/dist/commandHandling/handleCommand.d.ts +3 -2
  29. package/dist/commandHandling/handleCommandWithDecider.d.mts +3 -2
  30. package/dist/commandHandling/handleCommandWithDecider.d.ts +3 -2
  31. package/dist/commandHandling/index.d.mts +1 -0
  32. package/dist/commandHandling/index.d.ts +1 -0
  33. package/dist/eventStore/eventStore.d.mts +1 -0
  34. package/dist/eventStore/eventStore.d.ts +1 -0
  35. package/dist/eventStore/expectedVersion.d.mts +1 -0
  36. package/dist/eventStore/expectedVersion.d.ts +1 -0
  37. package/dist/eventStore/inMemoryEventStore.d.mts +1 -0
  38. package/dist/eventStore/inMemoryEventStore.d.ts +1 -0
  39. package/dist/eventStore/index.d.mts +1 -0
  40. package/dist/eventStore/index.d.ts +1 -0
  41. package/dist/index.d.mts +4 -1
  42. package/dist/index.d.ts +4 -1
  43. package/dist/index.js +1 -1
  44. package/dist/index.mjs +1 -1
  45. package/dist/messageBus/index.d.mts +44 -0
  46. package/dist/messageBus/index.d.ts +44 -0
  47. package/dist/messageBus/index.js +2 -0
  48. package/dist/messageBus/index.js.map +1 -0
  49. package/dist/messageBus/index.mjs +2 -0
  50. package/dist/messageBus/index.mjs.map +1 -0
  51. package/dist/serialization/json/JSONParser.d.mts +1 -1
  52. package/dist/serialization/json/JSONParser.d.ts +1 -1
  53. package/dist/testing/assertions.js +1 -1
  54. package/dist/testing/assertions.mjs +1 -1
  55. package/dist/testing/deciderSpecification.d.mts +4 -4
  56. package/dist/testing/deciderSpecification.d.ts +4 -4
  57. package/dist/testing/features.d.mts +13 -0
  58. package/dist/testing/features.d.ts +13 -0
  59. package/dist/testing/features.js +2 -0
  60. package/dist/testing/features.mjs +2 -0
  61. package/dist/testing/index.d.mts +6 -0
  62. package/dist/testing/index.d.ts +6 -0
  63. package/dist/testing/index.js +1 -1
  64. package/dist/testing/index.mjs +1 -1
  65. package/dist/testing/shoppingCart.domain.d.mts +23 -0
  66. package/dist/testing/shoppingCart.domain.d.ts +23 -0
  67. package/dist/testing/shoppingCart.domain.js +2 -0
  68. package/dist/testing/shoppingCart.domain.js.map +1 -0
  69. package/dist/testing/shoppingCart.domain.mjs +2 -0
  70. package/dist/testing/shoppingCart.domain.mjs.map +1 -0
  71. package/dist/typing/command.d.mts +2 -1
  72. package/dist/typing/command.d.ts +2 -1
  73. package/dist/typing/command.js +1 -1
  74. package/dist/typing/command.mjs +1 -1
  75. package/dist/typing/decider.d.mts +1 -0
  76. package/dist/typing/decider.d.ts +1 -0
  77. package/dist/typing/deepReadonly.d.mts +15 -0
  78. package/dist/typing/deepReadonly.d.ts +15 -0
  79. package/dist/typing/deepReadonly.js +2 -0
  80. package/dist/typing/deepReadonly.js.map +1 -0
  81. package/dist/typing/deepReadonly.mjs +2 -0
  82. package/dist/typing/deepReadonly.mjs.map +1 -0
  83. package/dist/typing/event.d.mts +2 -1
  84. package/dist/typing/event.d.ts +2 -1
  85. package/dist/typing/event.js +1 -1
  86. package/dist/typing/event.mjs +1 -1
  87. package/dist/typing/index.d.mts +28 -11
  88. package/dist/typing/index.d.ts +28 -11
  89. package/dist/typing/index.js +1 -1
  90. package/dist/typing/index.mjs +1 -1
  91. package/dist/typing/workflow.d.mts +1 -0
  92. package/dist/typing/workflow.d.ts +1 -0
  93. package/dist/utils/index.js +1 -1
  94. package/dist/utils/index.mjs +1 -1
  95. package/package.json +1 -1
  96. package/dist/chunk-7H3QW2YD.js +0 -1
  97. package/dist/chunk-BARLLX6S.js +0 -1
  98. package/dist/chunk-C4CXU3PY.mjs +0 -1
  99. package/dist/chunk-DFPI5IXT.js +0 -5
  100. package/dist/chunk-DFPI5IXT.js.map +0 -1
  101. package/dist/chunk-HKEQAT6F.mjs +0 -1
  102. package/dist/chunk-IZWGWZ3P.mjs +0 -1
  103. package/dist/chunk-QSAFGRYV.js +0 -1
  104. package/dist/chunk-RWKXC5FZ.mjs +0 -5
  105. package/dist/chunk-RWKXC5FZ.mjs.map +0 -1
  106. package/dist/chunk-YKICRTHH.mjs +0 -1
  107. package/dist/chunk-Z7EDILIO.js +0 -1
  108. /package/dist/{chunk-7H3QW2YD.js.map → chunk-5BGN2FV4.js.map} +0 -0
  109. /package/dist/{chunk-C4CXU3PY.mjs.map → chunk-DOHUIBZQ.mjs.map} +0 -0
  110. /package/dist/{chunk-HKEQAT6F.mjs.map → chunk-TDCMNVXU.mjs.map} +0 -0
  111. /package/dist/{chunk-IZWGWZ3P.mjs.map → chunk-YWRV75GA.mjs.map} +0 -0
  112. /package/dist/{chunk-BARLLX6S.js.map → chunk-Z4Z6POJH.js.map} +0 -0
  113. /package/dist/{chunk-QSAFGRYV.js.map → chunk-ZLASBJGR.js.map} +0 -0
  114. /package/dist/{chunk-Z7EDILIO.js.map → testing/features.js.map} +0 -0
  115. /package/dist/{chunk-YKICRTHH.mjs.map → testing/features.mjs.map} +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6WITJBGGjs = require('../chunk-6WITJBGG.js');require('../chunk-4PGUBQK3.js');require('../chunk-ZLASBJGR.js');require('../chunk-MHB2JU4U.js');require('../chunk-7FJXUW3D.js');require('../chunk-5BGN2FV4.js');require('../chunk-S3PRXL2J.js');require('../chunk-7EZVPMJ6.js');exports.testAggregateStream = _chunk6WITJBGGjs.a;
2
+ //# sourceMappingURL=features.js.map
@@ -0,0 +1,2 @@
1
+ import{a}from"../chunk-AMRL5G7K.mjs";import"../chunk-AYVR4VYR.mjs";import"../chunk-YWRV75GA.mjs";import"../chunk-JDYZZRJE.mjs";import"../chunk-3LYVXI5R.mjs";import"../chunk-DOHUIBZQ.mjs";import"../chunk-AWUWW7EJ.mjs";import"../chunk-ERDVHQZL.mjs";export{a as testAggregateStream};
2
+ //# sourceMappingURL=features.mjs.map
@@ -1,2 +1,8 @@
1
1
  export { assertMatches, isSubset } from './assertions.mjs';
2
2
  export { DeciderSpecfication, DeciderSpecification } from './deciderSpecification.mjs';
3
+ export { EventStoreFactory, testAggregateStream } from './features.mjs';
4
+ export { DiscountApplied, PricedProductItem, ProductItemAdded, ShoppingCart, ShoppingCartEvent, evolve, getInitialState } from './shoppingCart.domain.mjs';
5
+ import '../eventStore-DLezSgsV.mjs';
6
+ import '../typing/index.mjs';
7
+ import '../typing/deepReadonly.mjs';
8
+ import '../errors/index.mjs';
@@ -1,2 +1,8 @@
1
1
  export { assertMatches, isSubset } from './assertions.js';
2
2
  export { DeciderSpecfication, DeciderSpecification } from './deciderSpecification.js';
3
+ export { EventStoreFactory, testAggregateStream } from './features.js';
4
+ export { DiscountApplied, PricedProductItem, ProductItemAdded, ShoppingCart, ShoppingCartEvent, evolve, getInitialState } from './shoppingCart.domain.js';
5
+ import '../eventStore-N_YMFCDT.js';
6
+ import '../typing/index.js';
7
+ import '../typing/deepReadonly.js';
8
+ import '../errors/index.js';
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-7H3QW2YD.js');var _chunkDFPI5IXTjs = require('../chunk-DFPI5IXT.js');var _chunkO34VKX7Rjs = require('../chunk-O34VKX7R.js');exports.DeciderSpecification = _chunkO34VKX7Rjs.a; exports.assertMatches = _chunkDFPI5IXTjs.b; exports.isSubset = _chunkDFPI5IXTjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-Z4Z6POJH.js');var _chunk7D2LV2X5js = require('../chunk-7D2LV2X5.js');var _chunkO34VKX7Rjs = require('../chunk-O34VKX7R.js');var _chunk6WITJBGGjs = require('../chunk-6WITJBGG.js');var _chunk4PGUBQK3js = require('../chunk-4PGUBQK3.js');require('../chunk-ZLASBJGR.js');require('../chunk-MHB2JU4U.js');require('../chunk-7FJXUW3D.js');require('../chunk-5BGN2FV4.js');require('../chunk-S3PRXL2J.js');require('../chunk-7EZVPMJ6.js');exports.DeciderSpecification = _chunkO34VKX7Rjs.a; exports.assertMatches = _chunk7D2LV2X5js.b; exports.evolve = _chunk4PGUBQK3js.a; exports.getInitialState = _chunk4PGUBQK3js.b; exports.isSubset = _chunk7D2LV2X5js.a; exports.testAggregateStream = _chunk6WITJBGGjs.a;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import"../chunk-HKEQAT6F.mjs";import{a,b}from"../chunk-RWKXC5FZ.mjs";import{a as c}from"../chunk-32IWULJJ.mjs";export{c as DeciderSpecification,b as assertMatches,a as isSubset};
1
+ import"../chunk-TDCMNVXU.mjs";import{a,b}from"../chunk-HVU6UBXF.mjs";import{a as c}from"../chunk-32IWULJJ.mjs";import{a as f}from"../chunk-AMRL5G7K.mjs";import{a as d,b as e}from"../chunk-AYVR4VYR.mjs";import"../chunk-YWRV75GA.mjs";import"../chunk-JDYZZRJE.mjs";import"../chunk-3LYVXI5R.mjs";import"../chunk-DOHUIBZQ.mjs";import"../chunk-AWUWW7EJ.mjs";import"../chunk-ERDVHQZL.mjs";export{c as DeciderSpecification,b as assertMatches,d as evolve,e as getInitialState,a as isSubset,f as testAggregateStream};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,23 @@
1
+ import { Event } from '../typing/index.mjs';
2
+ import '../typing/deepReadonly.mjs';
3
+
4
+ type PricedProductItem = {
5
+ productId: string;
6
+ quantity: number;
7
+ price: number;
8
+ };
9
+ type ShoppingCart = {
10
+ productItems: PricedProductItem[];
11
+ totalAmount: number;
12
+ };
13
+ type ProductItemAdded = Event<'ProductItemAdded', {
14
+ productItem: PricedProductItem;
15
+ }>;
16
+ type DiscountApplied = Event<'DiscountApplied', {
17
+ percent: number;
18
+ }>;
19
+ type ShoppingCartEvent = ProductItemAdded | DiscountApplied;
20
+ declare const evolve: (state: ShoppingCart, { type, data }: ShoppingCartEvent) => ShoppingCart;
21
+ declare const getInitialState: () => ShoppingCart;
22
+
23
+ export { type DiscountApplied, type PricedProductItem, type ProductItemAdded, type ShoppingCart, type ShoppingCartEvent, evolve, getInitialState };
@@ -0,0 +1,23 @@
1
+ import { Event } from '../typing/index.js';
2
+ import '../typing/deepReadonly.js';
3
+
4
+ type PricedProductItem = {
5
+ productId: string;
6
+ quantity: number;
7
+ price: number;
8
+ };
9
+ type ShoppingCart = {
10
+ productItems: PricedProductItem[];
11
+ totalAmount: number;
12
+ };
13
+ type ProductItemAdded = Event<'ProductItemAdded', {
14
+ productItem: PricedProductItem;
15
+ }>;
16
+ type DiscountApplied = Event<'DiscountApplied', {
17
+ percent: number;
18
+ }>;
19
+ type ShoppingCartEvent = ProductItemAdded | DiscountApplied;
20
+ declare const evolve: (state: ShoppingCart, { type, data }: ShoppingCartEvent) => ShoppingCart;
21
+ declare const getInitialState: () => ShoppingCart;
22
+
23
+ export { type DiscountApplied, type PricedProductItem, type ProductItemAdded, type ShoppingCart, type ShoppingCartEvent, evolve, getInitialState };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4PGUBQK3js = require('../chunk-4PGUBQK3.js');require('../chunk-ZLASBJGR.js');require('../chunk-MHB2JU4U.js');require('../chunk-7FJXUW3D.js');require('../chunk-5BGN2FV4.js');require('../chunk-S3PRXL2J.js');require('../chunk-7EZVPMJ6.js');exports.evolve = _chunk4PGUBQK3js.a; exports.getInitialState = _chunk4PGUBQK3js.b;
2
+ //# sourceMappingURL=shoppingCart.domain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{a,b}from"../chunk-AYVR4VYR.mjs";import"../chunk-YWRV75GA.mjs";import"../chunk-JDYZZRJE.mjs";import"../chunk-3LYVXI5R.mjs";import"../chunk-DOHUIBZQ.mjs";import"../chunk-AWUWW7EJ.mjs";import"../chunk-ERDVHQZL.mjs";export{a as evolve,b as getInitialState};
2
+ //# sourceMappingURL=shoppingCart.domain.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +1,2 @@
1
- export { Command, DefaultCommandMetadata } from './index.mjs';
1
+ export { Command, CommandDataOf, CommandMetaDataOf, CommandTypeOf, CreateCommandType, DefaultCommandMetadata, command } from './index.mjs';
2
+ import './deepReadonly.mjs';
@@ -1 +1,2 @@
1
- export { Command, DefaultCommandMetadata } from './index.js';
1
+ export { Command, CommandDataOf, CommandMetaDataOf, CommandTypeOf, CreateCommandType, DefaultCommandMetadata, command } from './index.js';
2
+ import './deepReadonly.js';
@@ -1,2 +1,2 @@
1
- "use strict";require('../chunk-QSAFGRYV.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMHB2JU4Ujs = require('../chunk-MHB2JU4U.js');exports.command = _chunkMHB2JU4Ujs.a;
2
2
  //# sourceMappingURL=command.js.map
@@ -1,2 +1,2 @@
1
- import"../chunk-IZWGWZ3P.mjs";
1
+ import{a}from"../chunk-JDYZZRJE.mjs";export{a as command};
2
2
  //# sourceMappingURL=command.mjs.map
@@ -1 +1,2 @@
1
1
  export { Decider } from './index.mjs';
2
+ import './deepReadonly.mjs';
@@ -1 +1,2 @@
1
1
  export { Decider } from './index.js';
2
+ import './deepReadonly.js';
@@ -0,0 +1,15 @@
1
+ type Primitive = undefined | null | boolean | string | number | bigint | symbol | Function;
2
+ type ImmutableTypes = Date | RegExp;
3
+ type DeepReadonly<T> = T extends Primitive | ImmutableTypes ? T : T extends Array<infer U> ? ReadonlyArray<DeepReadonly<U>> : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer M> ? ReadonlySet<DeepReadonly<M>> : T extends Promise<infer U> ? Promise<DeepReadonly<U>> : T extends object ? DeepReadonlyObject<T> : Readonly<T>;
4
+ type DeepReadonlyObject<T> = {
5
+ readonly [P in keyof T]: DeepReadonly<T[P]>;
6
+ };
7
+ type Mutable<T> = T extends Primitive ? T : T extends ReadonlyArray<infer U> ? MutableArray<U> : T extends ReadonlyMap<infer K, infer V> ? MutableMap<K, V> : T extends ReadonlySet<infer M> ? MutableSet<M> : T extends Function ? T : T extends object ? MutableObject<T> : unknown;
8
+ type MutableArray<T> = Array<Mutable<T>>;
9
+ type MutableMap<K, V> = Map<Mutable<K>, Mutable<V>>;
10
+ type MutableSet<T> = Set<Mutable<T>>;
11
+ type MutableObject<T> = {
12
+ -readonly [P in keyof T]: Mutable<T[P]>;
13
+ };
14
+
15
+ export type { DeepReadonly, Mutable };
@@ -0,0 +1,15 @@
1
+ type Primitive = undefined | null | boolean | string | number | bigint | symbol | Function;
2
+ type ImmutableTypes = Date | RegExp;
3
+ type DeepReadonly<T> = T extends Primitive | ImmutableTypes ? T : T extends Array<infer U> ? ReadonlyArray<DeepReadonly<U>> : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer M> ? ReadonlySet<DeepReadonly<M>> : T extends Promise<infer U> ? Promise<DeepReadonly<U>> : T extends object ? DeepReadonlyObject<T> : Readonly<T>;
4
+ type DeepReadonlyObject<T> = {
5
+ readonly [P in keyof T]: DeepReadonly<T[P]>;
6
+ };
7
+ type Mutable<T> = T extends Primitive ? T : T extends ReadonlyArray<infer U> ? MutableArray<U> : T extends ReadonlyMap<infer K, infer V> ? MutableMap<K, V> : T extends ReadonlySet<infer M> ? MutableSet<M> : T extends Function ? T : T extends object ? MutableObject<T> : unknown;
8
+ type MutableArray<T> = Array<Mutable<T>>;
9
+ type MutableMap<K, V> = Map<Mutable<K>, Mutable<V>>;
10
+ type MutableSet<T> = Set<Mutable<T>>;
11
+ type MutableObject<T> = {
12
+ -readonly [P in keyof T]: Mutable<T[P]>;
13
+ };
14
+
15
+ export type { DeepReadonly, Mutable };
@@ -0,0 +1,2 @@
1
+ "use strict";require('../chunk-5BGN2FV4.js');
2
+ //# sourceMappingURL=deepReadonly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import"../chunk-DOHUIBZQ.mjs";
2
+ //# sourceMappingURL=deepReadonly.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +1,2 @@
1
- export { Event } from './index.mjs';
1
+ export { CreateEventType, Event, EventDataOf, EventMetaDataOf, EventTypeOf, event } from './index.mjs';
2
+ import './deepReadonly.mjs';
@@ -1 +1,2 @@
1
- export { Event } from './index.js';
1
+ export { CreateEventType, Event, EventDataOf, EventMetaDataOf, EventTypeOf, event } from './index.js';
2
+ import './deepReadonly.js';
@@ -1,2 +1,2 @@
1
- "use strict";require('../chunk-BARLLX6S.js');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkS3PRXL2Jjs = require('../chunk-S3PRXL2J.js');exports.event = _chunkS3PRXL2Jjs.a;
2
2
  //# sourceMappingURL=event.js.map
@@ -1,2 +1,2 @@
1
- import"../chunk-YKICRTHH.mjs";
1
+ import{a}from"../chunk-AWUWW7EJ.mjs";export{a as event};
2
2
  //# sourceMappingURL=event.mjs.map
@@ -1,17 +1,37 @@
1
- type Command<CommandType extends string = string, CommandData extends Record<string, unknown> = Record<string, unknown>, CommandMetaData extends Record<string, unknown> = DefaultCommandMetadata> = Flavour<Readonly<{
1
+ export { DeepReadonly, Mutable } from './deepReadonly.mjs';
2
+
3
+ type Command<CommandType extends string = string, CommandData extends DefaultRecord = DefaultRecord, CommandMetaData extends DefaultRecord = DefaultCommandMetadata> = Flavour<Readonly<{
2
4
  type: CommandType;
3
5
  data: Readonly<CommandData>;
4
6
  metadata?: CommandMetaData | undefined;
5
7
  }>, 'Command'>;
8
+ type CommandTypeOf<T extends Command> = T['type'];
9
+ type CommandDataOf<T extends Command> = T['data'];
10
+ type CommandMetaDataOf<T extends Command> = T['metadata'];
11
+ type CreateCommandType<CommandType extends string, CommandData extends DefaultRecord, CommandMetaData extends DefaultRecord | undefined> = Readonly<{
12
+ type: CommandType;
13
+ data: CommandData;
14
+ metadata?: CommandMetaData;
15
+ }>;
16
+ declare const command: <CommandType extends Command<string, DefaultRecord, DefaultCommandMetadata>>(type: CommandTypeOf<CommandType>, data: CommandDataOf<CommandType>, metadata?: CommandMetaDataOf<CommandType>) => CreateCommandType<CommandTypeOf<CommandType>, CommandDataOf<CommandType>, CommandMetaDataOf<CommandType>>;
6
17
  type DefaultCommandMetadata = {
7
18
  now: Date;
8
19
  };
9
20
 
10
- type Event<EventType extends string = string, EventData extends Record<string, unknown> = Record<string, unknown>, EventMetaData extends Record<string, unknown> = Record<string, unknown>> = Flavour<Readonly<{
21
+ type Event<EventType extends string = string, EventData extends DefaultRecord = DefaultRecord, EventMetaData extends DefaultRecord = DefaultRecord> = Flavour<Readonly<{
11
22
  type: EventType;
12
- data: Readonly<EventData>;
13
- metadata?: EventMetaData | undefined;
23
+ data: EventData;
24
+ metadata?: EventMetaData;
14
25
  }>, 'Event'>;
26
+ type EventTypeOf<T extends Event> = T['type'];
27
+ type EventDataOf<T extends Event> = T['data'];
28
+ type EventMetaDataOf<T extends Event> = T['metadata'];
29
+ type CreateEventType<EventType extends string, EventData extends DefaultRecord, EventMetaData extends DefaultRecord | undefined> = Readonly<{
30
+ type: EventType;
31
+ data: EventData;
32
+ metadata?: EventMetaData;
33
+ }>;
34
+ declare const event: <EventType extends Event<string, DefaultRecord, DefaultRecord>>(type: EventTypeOf<EventType>, data: EventDataOf<EventType>, metadata?: EventMetaDataOf<EventType>) => CreateEventType<EventTypeOf<EventType>, EventDataOf<EventType>, EventMetaDataOf<EventType>>;
15
35
 
16
36
  type Decider<State, CommandType extends Command, StreamEvent extends Event> = {
17
37
  decide: (command: CommandType, state: State) => StreamEvent | StreamEvent[];
@@ -59,12 +79,8 @@ type WorkflowOutput<TOutput extends Command | Event> = {
59
79
  reason: string;
60
80
  };
61
81
  declare const reply: <TOutput extends Command | Event>(message: TOutput) => WorkflowOutput<TOutput>;
62
- declare const send: <TOutput extends Command | Event>(message: Extract<TOutput, {
63
- __brand?: "Command" | undefined;
64
- }>) => WorkflowOutput<TOutput>;
65
- declare const publish: <TOutput extends Command | Event>(message: Extract<TOutput, {
66
- __brand?: "Event" | undefined;
67
- }>) => WorkflowOutput<TOutput>;
82
+ declare const send: <TOutput extends Command | Event>(message: WorkflowCommand<TOutput>) => WorkflowOutput<TOutput>;
83
+ declare const publish: <TOutput extends Command | Event>(message: WorkflowEvent<TOutput>) => WorkflowOutput<TOutput>;
68
84
  declare const schedule: <TOutput extends Command | Event>(message: TOutput, when: {
69
85
  afterInMs: number;
70
86
  } | {
@@ -81,5 +97,6 @@ type Brand<K, T> = K & {
81
97
  type Flavour<K, T> = K & {
82
98
  readonly __brand?: T;
83
99
  };
100
+ type DefaultRecord = Record<string, unknown>;
84
101
 
85
- export { type Brand, type Command, type Decider, type DefaultCommandMetadata, type Event, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send };
102
+ export { type Brand, type Command, type CommandDataOf, type CommandMetaDataOf, type CommandTypeOf, type CreateCommandType, type CreateEventType, type Decider, type DefaultCommandMetadata, type DefaultRecord, type Event, type EventDataOf, type EventMetaDataOf, type EventTypeOf, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, command, complete, error, event, ignore, publish, reply, schedule, send };
@@ -1,17 +1,37 @@
1
- type Command<CommandType extends string = string, CommandData extends Record<string, unknown> = Record<string, unknown>, CommandMetaData extends Record<string, unknown> = DefaultCommandMetadata> = Flavour<Readonly<{
1
+ export { DeepReadonly, Mutable } from './deepReadonly.js';
2
+
3
+ type Command<CommandType extends string = string, CommandData extends DefaultRecord = DefaultRecord, CommandMetaData extends DefaultRecord = DefaultCommandMetadata> = Flavour<Readonly<{
2
4
  type: CommandType;
3
5
  data: Readonly<CommandData>;
4
6
  metadata?: CommandMetaData | undefined;
5
7
  }>, 'Command'>;
8
+ type CommandTypeOf<T extends Command> = T['type'];
9
+ type CommandDataOf<T extends Command> = T['data'];
10
+ type CommandMetaDataOf<T extends Command> = T['metadata'];
11
+ type CreateCommandType<CommandType extends string, CommandData extends DefaultRecord, CommandMetaData extends DefaultRecord | undefined> = Readonly<{
12
+ type: CommandType;
13
+ data: CommandData;
14
+ metadata?: CommandMetaData;
15
+ }>;
16
+ declare const command: <CommandType extends Command<string, DefaultRecord, DefaultCommandMetadata>>(type: CommandTypeOf<CommandType>, data: CommandDataOf<CommandType>, metadata?: CommandMetaDataOf<CommandType>) => CreateCommandType<CommandTypeOf<CommandType>, CommandDataOf<CommandType>, CommandMetaDataOf<CommandType>>;
6
17
  type DefaultCommandMetadata = {
7
18
  now: Date;
8
19
  };
9
20
 
10
- type Event<EventType extends string = string, EventData extends Record<string, unknown> = Record<string, unknown>, EventMetaData extends Record<string, unknown> = Record<string, unknown>> = Flavour<Readonly<{
21
+ type Event<EventType extends string = string, EventData extends DefaultRecord = DefaultRecord, EventMetaData extends DefaultRecord = DefaultRecord> = Flavour<Readonly<{
11
22
  type: EventType;
12
- data: Readonly<EventData>;
13
- metadata?: EventMetaData | undefined;
23
+ data: EventData;
24
+ metadata?: EventMetaData;
14
25
  }>, 'Event'>;
26
+ type EventTypeOf<T extends Event> = T['type'];
27
+ type EventDataOf<T extends Event> = T['data'];
28
+ type EventMetaDataOf<T extends Event> = T['metadata'];
29
+ type CreateEventType<EventType extends string, EventData extends DefaultRecord, EventMetaData extends DefaultRecord | undefined> = Readonly<{
30
+ type: EventType;
31
+ data: EventData;
32
+ metadata?: EventMetaData;
33
+ }>;
34
+ declare const event: <EventType extends Event<string, DefaultRecord, DefaultRecord>>(type: EventTypeOf<EventType>, data: EventDataOf<EventType>, metadata?: EventMetaDataOf<EventType>) => CreateEventType<EventTypeOf<EventType>, EventDataOf<EventType>, EventMetaDataOf<EventType>>;
15
35
 
16
36
  type Decider<State, CommandType extends Command, StreamEvent extends Event> = {
17
37
  decide: (command: CommandType, state: State) => StreamEvent | StreamEvent[];
@@ -59,12 +79,8 @@ type WorkflowOutput<TOutput extends Command | Event> = {
59
79
  reason: string;
60
80
  };
61
81
  declare const reply: <TOutput extends Command | Event>(message: TOutput) => WorkflowOutput<TOutput>;
62
- declare const send: <TOutput extends Command | Event>(message: Extract<TOutput, {
63
- __brand?: "Command" | undefined;
64
- }>) => WorkflowOutput<TOutput>;
65
- declare const publish: <TOutput extends Command | Event>(message: Extract<TOutput, {
66
- __brand?: "Event" | undefined;
67
- }>) => WorkflowOutput<TOutput>;
82
+ declare const send: <TOutput extends Command | Event>(message: WorkflowCommand<TOutput>) => WorkflowOutput<TOutput>;
83
+ declare const publish: <TOutput extends Command | Event>(message: WorkflowEvent<TOutput>) => WorkflowOutput<TOutput>;
68
84
  declare const schedule: <TOutput extends Command | Event>(message: TOutput, when: {
69
85
  afterInMs: number;
70
86
  } | {
@@ -81,5 +97,6 @@ type Brand<K, T> = K & {
81
97
  type Flavour<K, T> = K & {
82
98
  readonly __brand?: T;
83
99
  };
100
+ type DefaultRecord = Record<string, unknown>;
84
101
 
85
- export { type Brand, type Command, type Decider, type DefaultCommandMetadata, type Event, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send };
102
+ export { type Brand, type Command, type CommandDataOf, type CommandMetaDataOf, type CommandTypeOf, type CreateCommandType, type CreateEventType, type Decider, type DefaultCommandMetadata, type DefaultRecord, type Event, type EventDataOf, type EventMetaDataOf, type EventTypeOf, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, command, complete, error, event, ignore, publish, reply, schedule, send };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-Z7EDILIO.js');var _chunk7EZVPMJ6js = require('../chunk-7EZVPMJ6.js');require('../chunk-QSAFGRYV.js');require('../chunk-7FJXUW3D.js');require('../chunk-BARLLX6S.js');exports.accept = _chunk7EZVPMJ6js.h; exports.complete = _chunk7EZVPMJ6js.e; exports.error = _chunk7EZVPMJ6js.g; exports.ignore = _chunk7EZVPMJ6js.f; exports.publish = _chunk7EZVPMJ6js.c; exports.reply = _chunk7EZVPMJ6js.a; exports.schedule = _chunk7EZVPMJ6js.d; exports.send = _chunk7EZVPMJ6js.b;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-ZLASBJGR.js');var _chunkMHB2JU4Ujs = require('../chunk-MHB2JU4U.js');require('../chunk-7FJXUW3D.js');require('../chunk-5BGN2FV4.js');var _chunkS3PRXL2Jjs = require('../chunk-S3PRXL2J.js');var _chunk7EZVPMJ6js = require('../chunk-7EZVPMJ6.js');exports.accept = _chunk7EZVPMJ6js.h; exports.command = _chunkMHB2JU4Ujs.a; exports.complete = _chunk7EZVPMJ6js.e; exports.error = _chunk7EZVPMJ6js.g; exports.event = _chunkS3PRXL2Jjs.a; exports.ignore = _chunk7EZVPMJ6js.f; exports.publish = _chunk7EZVPMJ6js.c; exports.reply = _chunk7EZVPMJ6js.a; exports.schedule = _chunk7EZVPMJ6js.d; exports.send = _chunk7EZVPMJ6js.b;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import"../chunk-C4CXU3PY.mjs";import{a,b,c,d,e,f,g,h}from"../chunk-ERDVHQZL.mjs";import"../chunk-IZWGWZ3P.mjs";import"../chunk-3LYVXI5R.mjs";import"../chunk-YKICRTHH.mjs";export{h as accept,e as complete,g as error,f as ignore,c as publish,a as reply,d as schedule,b as send};
1
+ import"../chunk-YWRV75GA.mjs";import{a}from"../chunk-JDYZZRJE.mjs";import"../chunk-3LYVXI5R.mjs";import"../chunk-DOHUIBZQ.mjs";import{a as b}from"../chunk-AWUWW7EJ.mjs";import{a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j}from"../chunk-ERDVHQZL.mjs";export{j as accept,a as command,g as complete,i as error,b as event,h as ignore,e as publish,c as reply,f as schedule,d as send};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1,2 @@
1
1
  export { Workflow, WorkflowCommand, WorkflowEvent, WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send } from './index.mjs';
2
+ import './deepReadonly.mjs';
@@ -1 +1,2 @@
1
1
  export { Workflow, WorkflowCommand, WorkflowEvent, WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send } from './index.js';
2
+ import './deepReadonly.js';
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWIMBG2PXjs = require('../chunk-WIMBG2PX.js');var _chunkFE73T2NSjs = require('../chunk-FE73T2NS.js');var _chunk3JE5DUJ2js = require('../chunk-3JE5DUJ2.js');exports.default = _chunkWIMBG2PXjs.a; exports.merge = _chunk3JE5DUJ2js.a; exports.sum = _chunkFE73T2NSjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWIMBG2PXjs = require('../chunk-WIMBG2PX.js');var _chunk3JE5DUJ2js = require('../chunk-3JE5DUJ2.js');var _chunkFE73T2NSjs = require('../chunk-FE73T2NS.js');exports.default = _chunkWIMBG2PXjs.a; exports.merge = _chunk3JE5DUJ2js.a; exports.sum = _chunkFE73T2NSjs.a;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{a as c}from"../chunk-PNOEBD4U.mjs";import{a}from"../chunk-OBA6MZMG.mjs";import{a as b}from"../chunk-YKFEDBH4.mjs";export{c as default,b as merge,a as sum};
1
+ import{a as c}from"../chunk-PNOEBD4U.mjs";import{a as b}from"../chunk-YKFEDBH4.mjs";import{a}from"../chunk-OBA6MZMG.mjs";export{c as default,b as merge,a as sum};
2
2
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-driven-io/emmett",
3
- "version": "0.5.5",
3
+ "version": "0.7.0",
4
4
  "description": "Emmett - Event Sourcing development made simple",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-7H3QW2YD.js.map
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-BARLLX6S.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-C4CXU3PY.mjs.map
@@ -1,5 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var u=(s,o)=>{let t=s,r=o;return Object.keys(r).every(n=>typeof r[n]=="object"?u(t[n],r[n]):r[n]===t[n])},i= exports.b =(s,o)=>{if(!u(s,o))throw Error(`subObj:
2
- ${JSON.stringify(o)}
3
- is not subset of
4
- ${JSON.stringify(s)}`)};exports.a = u; exports.b = i;
5
- //# sourceMappingURL=chunk-DFPI5IXT.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/testing/assertions.ts"],"names":["isSubset","superObj","subObj","sup","sub","ele","assertMatches","actual","expected"],"mappings":"AAAO,IAAMA,EAAW,CAACC,EAAmBC,IAA6B,CACvE,IAAMC,EAAMF,EACNG,EAAMF,EAEZ,OAAO,OAAO,KAAKE,CAAG,EAAE,MAAOC,GACzB,OAAOD,EAAIC,CAAG,GAAK,SACdL,EACLG,EAAIE,CAAG,EACPD,EAAIC,CAAG,CACT,EAEKD,EAAIC,CAAG,IAAMF,EAAIE,CAAG,CAC5B,CACH,EAEaC,EAAgB,CAACC,EAAiBC,IAAsB,CACnE,GAAI,CAACR,EAASO,EAAQC,CAAQ,EAC5B,MAAM,MACJ;AAAA,EAAY,KAAK,UAAUA,CAAQ,CAAC;AAAA;AAAA,EAAuB,KAAK,UAAUD,CAAM,CAAC,EACnF,CACJ","sourcesContent":["export const isSubset = (superObj: unknown, subObj: unknown): boolean => {\n const sup = superObj as Record<string, unknown>;\n const sub = subObj as Record<string, unknown>;\n\n return Object.keys(sub).every((ele: string) => {\n if (typeof sub[ele] == 'object') {\n return isSubset(\n sup[ele] as Record<string, unknown>,\n sub[ele] as Record<string, unknown>,\n );\n }\n return sub[ele] === sup[ele];\n });\n};\n\nexport const assertMatches = (actual: unknown, expected: unknown) => {\n if (!isSubset(actual, expected))\n throw Error(\n `subObj:\\n${JSON.stringify(expected)}\\nis not subset of\\n${JSON.stringify(actual)}`,\n );\n};\n"]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-HKEQAT6F.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-IZWGWZ3P.mjs.map
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-QSAFGRYV.js.map
@@ -1,5 +0,0 @@
1
- var u=(s,o)=>{let t=s,r=o;return Object.keys(r).every(n=>typeof r[n]=="object"?u(t[n],r[n]):r[n]===t[n])},i=(s,o)=>{if(!u(s,o))throw Error(`subObj:
2
- ${JSON.stringify(o)}
3
- is not subset of
4
- ${JSON.stringify(s)}`)};export{u as a,i as b};
5
- //# sourceMappingURL=chunk-RWKXC5FZ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/testing/assertions.ts"],"sourcesContent":["export const isSubset = (superObj: unknown, subObj: unknown): boolean => {\n const sup = superObj as Record<string, unknown>;\n const sub = subObj as Record<string, unknown>;\n\n return Object.keys(sub).every((ele: string) => {\n if (typeof sub[ele] == 'object') {\n return isSubset(\n sup[ele] as Record<string, unknown>,\n sub[ele] as Record<string, unknown>,\n );\n }\n return sub[ele] === sup[ele];\n });\n};\n\nexport const assertMatches = (actual: unknown, expected: unknown) => {\n if (!isSubset(actual, expected))\n throw Error(\n `subObj:\\n${JSON.stringify(expected)}\\nis not subset of\\n${JSON.stringify(actual)}`,\n );\n};\n"],"mappings":"AAAO,IAAMA,EAAW,CAACC,EAAmBC,IAA6B,CACvE,IAAMC,EAAMF,EACNG,EAAMF,EAEZ,OAAO,OAAO,KAAKE,CAAG,EAAE,MAAOC,GACzB,OAAOD,EAAIC,CAAG,GAAK,SACdL,EACLG,EAAIE,CAAG,EACPD,EAAIC,CAAG,CACT,EAEKD,EAAIC,CAAG,IAAMF,EAAIE,CAAG,CAC5B,CACH,EAEaC,EAAgB,CAACC,EAAiBC,IAAsB,CACnE,GAAI,CAACR,EAASO,EAAQC,CAAQ,EAC5B,MAAM,MACJ;AAAA,EAAY,KAAK,UAAUA,CAAQ,CAAC;AAAA;AAAA,EAAuB,KAAK,UAAUD,CAAM,CAAC,EACnF,CACJ","names":["isSubset","superObj","subObj","sup","sub","ele","assertMatches","actual","expected"]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-YKICRTHH.mjs.map
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-Z7EDILIO.js.map