@event-driven-io/emmett 0.1.1 → 0.1.2
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/README.md +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +7 -3
- package/dist/commandHandling/handleCommand.d.mts +0 -6
- package/dist/commandHandling/handleCommand.d.ts +0 -6
- package/dist/commandHandling/handleCommand.js +0 -16
- package/dist/commandHandling/handleCommand.js.map +0 -1
- package/dist/commandHandling/handleCommand.mjs +0 -16
- package/dist/commandHandling/handleCommand.mjs.map +0 -1
- package/dist/commandHandling/handleCommandWithDecider.d.mts +0 -6
- package/dist/commandHandling/handleCommandWithDecider.d.ts +0 -6
- package/dist/commandHandling/handleCommandWithDecider.js +0 -20
- package/dist/commandHandling/handleCommandWithDecider.js.map +0 -1
- package/dist/commandHandling/handleCommandWithDecider.mjs +0 -20
- package/dist/commandHandling/handleCommandWithDecider.mjs.map +0 -1
- package/dist/commandHandling/index.d.mts +0 -4
- package/dist/commandHandling/index.d.ts +0 -4
- package/dist/commandHandling/index.js +0 -3
- package/dist/commandHandling/index.js.map +0 -1
- package/dist/commandHandling/index.mjs +0 -3
- package/dist/commandHandling/index.mjs.map +0 -1
- package/dist/eventStore/eventStore.d.mts +0 -12
- package/dist/eventStore/eventStore.d.ts +0 -12
- package/dist/eventStore/eventStore.js +0 -1
- package/dist/eventStore/eventStore.js.map +0 -1
- package/dist/eventStore/eventStore.mjs +0 -1
- package/dist/eventStore/eventStore.mjs.map +0 -1
- package/dist/eventStore/index.d.mts +0 -2
- package/dist/eventStore/index.d.ts +0 -2
- package/dist/eventStore/index.js +0 -2
- package/dist/eventStore/index.js.map +0 -1
- package/dist/eventStore/index.mjs +0 -2
- package/dist/eventStore/index.mjs.map +0 -1
- package/dist/immutable/index.d.mts +0 -1
- package/dist/immutable/index.d.ts +0 -1
- package/dist/immutable/index.js +0 -2
- package/dist/immutable/index.js.map +0 -1
- package/dist/immutable/index.mjs +0 -2
- package/dist/immutable/index.mjs.map +0 -1
- package/dist/immutable/merge.d.mts +0 -3
- package/dist/immutable/merge.d.ts +0 -3
- package/dist/immutable/merge.js +0 -23
- package/dist/immutable/merge.js.map +0 -1
- package/dist/immutable/merge.mjs +0 -23
- package/dist/immutable/merge.mjs.map +0 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -1
- package/dist/serialization/json/JSONParser.d.mts +0 -19
- package/dist/serialization/json/JSONParser.d.ts +0 -19
- package/dist/serialization/json/JSONParser.js +0 -23
- package/dist/serialization/json/JSONParser.js.map +0 -1
- package/dist/serialization/json/JSONParser.mjs +0 -23
- package/dist/serialization/json/JSONParser.mjs.map +0 -1
- package/dist/serialization/json/index.d.mts +0 -1
- package/dist/serialization/json/index.d.ts +0 -1
- package/dist/serialization/json/index.js +0 -2
- package/dist/serialization/json/index.js.map +0 -1
- package/dist/serialization/json/index.mjs +0 -2
- package/dist/serialization/json/index.mjs.map +0 -1
- package/dist/testing/deciderSpecification.d.mts +0 -15
- package/dist/testing/deciderSpecification.d.ts +0 -15
- package/dist/testing/deciderSpecification.js +0 -41
- package/dist/testing/deciderSpecification.js.map +0 -1
- package/dist/testing/deciderSpecification.mjs +0 -41
- package/dist/testing/deciderSpecification.mjs.map +0 -1
- package/dist/testing/index.d.mts +0 -2
- package/dist/testing/index.d.ts +0 -2
- package/dist/testing/index.js +0 -1
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/index.mjs +0 -1
- package/dist/testing/index.mjs.map +0 -1
- package/dist/typing/command.d.mts +0 -1
- package/dist/typing/command.d.ts +0 -1
- package/dist/typing/command.js +0 -1
- package/dist/typing/command.js.map +0 -1
- package/dist/typing/command.mjs +0 -1
- package/dist/typing/command.mjs.map +0 -1
- package/dist/typing/decider.d.mts +0 -1
- package/dist/typing/decider.d.ts +0 -1
- package/dist/typing/decider.js +0 -1
- package/dist/typing/decider.js.map +0 -1
- package/dist/typing/decider.mjs +0 -1
- package/dist/typing/decider.mjs.map +0 -1
- package/dist/typing/event.d.mts +0 -1
- package/dist/typing/event.d.ts +0 -1
- package/dist/typing/event.js +0 -1
- package/dist/typing/event.js.map +0 -1
- package/dist/typing/event.mjs +0 -1
- package/dist/typing/event.mjs.map +0 -1
- package/dist/typing/index.d.mts +0 -82
- package/dist/typing/index.d.ts +0 -82
- package/dist/typing/index.js +0 -5
- package/dist/typing/index.js.map +0 -1
- package/dist/typing/index.mjs +0 -5
- package/dist/typing/index.mjs.map +0 -1
- package/dist/typing/workflow.d.mts +0 -1
- package/dist/typing/workflow.d.ts +0 -1
- package/dist/typing/workflow.js +0 -56
- package/dist/typing/workflow.js.map +0 -1
- package/dist/typing/workflow.mjs +0 -56
- package/dist/typing/workflow.mjs.map +0 -1
- package/dist/validation/index.d.mts +0 -10
- package/dist/validation/index.d.ts +0 -10
- package/dist/validation/index.js +0 -32
- package/dist/validation/index.js.map +0 -1
- package/dist/validation/index.mjs +0 -32
- package/dist/validation/index.mjs.map +0 -1
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
class ParseError extends Error {
|
|
2
|
-
constructor(text) {
|
|
3
|
-
super(`Cannot parse! ${text}`);
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
const JSONParser = {
|
|
7
|
-
stringify: (value, options) => {
|
|
8
|
-
return JSON.stringify(
|
|
9
|
-
options?.map ? options.map(value) : value
|
|
10
|
-
);
|
|
11
|
-
},
|
|
12
|
-
parse: (text, options) => {
|
|
13
|
-
const parsed = JSON.parse(text, options?.reviver);
|
|
14
|
-
if (options?.typeCheck && !options?.typeCheck(parsed))
|
|
15
|
-
throw new ParseError(text);
|
|
16
|
-
return options?.map ? options.map(parsed) : parsed;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
JSONParser,
|
|
21
|
-
ParseError
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=JSONParser.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/serialization/json/JSONParser.ts"],"sourcesContent":["export class ParseError extends Error {\n constructor(text: string) {\n super(`Cannot parse! ${text}`);\n }\n}\n\nexport type Mapper<From, To = From> =\n | ((value: unknown) => To)\n | ((value: Partial<From>) => To)\n | ((value: From) => To)\n | ((value: Partial<To>) => To)\n | ((value: To) => To)\n | ((value: Partial<To | From>) => To)\n | ((value: To | From) => To);\n\nexport type MapperArgs<From, To = From> = Partial<From> &\n From &\n Partial<To> &\n To;\n\nexport type ParseOptions<From, To = From> = {\n reviver?: (key: string, value: unknown) => unknown;\n map?: Mapper<From, To>;\n typeCheck?: <To>(value: unknown) => value is To;\n};\n\nexport type StringifyOptions<From, To = From> = {\n map?: Mapper<From, To>;\n};\n\nexport const JSONParser = {\n stringify: <From, To = From>(\n value: From,\n options?: StringifyOptions<From, To>,\n ) => {\n return JSON.stringify(\n options?.map ? options.map(value as MapperArgs<From, To>) : value,\n );\n },\n parse: <From, To = From>(\n text: string,\n options?: ParseOptions<From, To>,\n ): To | undefined => {\n const parsed: unknown = JSON.parse(text, options?.reviver);\n\n if (options?.typeCheck && !options?.typeCheck<To>(parsed))\n throw new ParseError(text);\n\n return options?.map\n ? options.map(parsed as MapperArgs<From, To>)\n : (parsed as To | undefined);\n },\n};\n"],"mappings":"AAAO,MAAM,mBAAmB,MAAM;AAAA,EACpC,YAAY,MAAc;AACxB,UAAM,iBAAiB,IAAI,EAAE;AAAA,EAC/B;AACF;AA0BO,MAAM,aAAa;AAAA,EACxB,WAAW,CACT,OACA,YACG;AACH,WAAO,KAAK;AAAA,MACV,SAAS,MAAM,QAAQ,IAAI,KAA6B,IAAI;AAAA,IAC9D;AAAA,EACF;AAAA,EACA,OAAO,CACL,MACA,YACmB;AACnB,UAAM,SAAkB,KAAK,MAAM,MAAM,SAAS,OAAO;AAEzD,QAAI,SAAS,aAAa,CAAC,SAAS,UAAc,MAAM;AACtD,YAAM,IAAI,WAAW,IAAI;AAE3B,WAAO,SAAS,MACZ,QAAQ,IAAI,MAA8B,IACzC;AAAA,EACP;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { JSONParser, Mapper, MapperArgs, ParseError, ParseOptions, StringifyOptions } from './JSONParser.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { JSONParser, Mapper, MapperArgs, ParseError, ParseOptions, StringifyOptions } from './JSONParser.js';
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _JSONParser = require('./JSONParser'); _createStarExport(_JSONParser);
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/serialization/json/index.ts"],"names":[],"mappings":"AAAA,cAAc","sourcesContent":["export * from './JSONParser';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/serialization/json/index.ts"],"sourcesContent":["export * from './JSONParser';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type DeciderSpecfication<Command, Event> = (givenEvents: Event | Event[]) => {
|
|
2
|
-
when: (command: Command) => {
|
|
3
|
-
then: (expectedEvents: Event | Event[]) => void;
|
|
4
|
-
thenThrows: <Error>(assert: (error: Error) => boolean) => void;
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
declare const DeciderSpecification: {
|
|
8
|
-
for: <Command, Event_1, State>(decider: {
|
|
9
|
-
decide: (command: Command, state: State) => Event_1 | Event_1[];
|
|
10
|
-
evolve: (state: State, event: Event_1) => State;
|
|
11
|
-
initialState: () => State;
|
|
12
|
-
}) => DeciderSpecfication<Command, Event_1>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { type DeciderSpecfication, DeciderSpecification };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type DeciderSpecfication<Command, Event> = (givenEvents: Event | Event[]) => {
|
|
2
|
-
when: (command: Command) => {
|
|
3
|
-
then: (expectedEvents: Event | Event[]) => void;
|
|
4
|
-
thenThrows: <Error>(assert: (error: Error) => boolean) => void;
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
declare const DeciderSpecification: {
|
|
8
|
-
for: <Command, Event_1, State>(decider: {
|
|
9
|
-
decide: (command: Command, state: State) => Event_1 | Event_1[];
|
|
10
|
-
evolve: (state: State, event: Event_1) => State;
|
|
11
|
-
initialState: () => State;
|
|
12
|
-
}) => DeciderSpecfication<Command, Event_1>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { type DeciderSpecfication, DeciderSpecification };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _assert = require('assert'); var _assert2 = _interopRequireDefault(_assert);
|
|
2
|
-
const DeciderSpecification = {
|
|
3
|
-
for: (decider) => {
|
|
4
|
-
{
|
|
5
|
-
return (givenEvents) => {
|
|
6
|
-
return {
|
|
7
|
-
when: (command) => {
|
|
8
|
-
const handle = () => {
|
|
9
|
-
const existingEvents = Array.isArray(givenEvents) ? givenEvents : [givenEvents];
|
|
10
|
-
const currentState = existingEvents.reduce(
|
|
11
|
-
decider.evolve,
|
|
12
|
-
decider.initialState()
|
|
13
|
-
);
|
|
14
|
-
return decider.decide(command, currentState);
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
then: (expectedEvents) => {
|
|
18
|
-
const resultEvents = handle();
|
|
19
|
-
const resultEventsArray = Array.isArray(resultEvents) ? resultEvents : [resultEvents];
|
|
20
|
-
const expectedEventsArray = Array.isArray(expectedEvents) ? expectedEvents : [expectedEvents];
|
|
21
|
-
_assert2.default.deepEqual(resultEventsArray, expectedEventsArray);
|
|
22
|
-
},
|
|
23
|
-
thenThrows: (check) => {
|
|
24
|
-
try {
|
|
25
|
-
handle();
|
|
26
|
-
_assert2.default.fail("Handler did not fail as expected");
|
|
27
|
-
} catch (error) {
|
|
28
|
-
_assert2.default.ok(check(error));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
exports.DeciderSpecification = DeciderSpecification;
|
|
41
|
-
//# sourceMappingURL=deciderSpecification.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/deciderSpecification.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY;AAWZ,MAAM,uBAAuB;AAAA,EAClC,KAAK,CAAwB,YAIc;AACzC;AACE,aAAO,CAAC,gBAAiC;AACvC,eAAO;AAAA,UACL,MAAM,CAAC,YAAqB;AAC1B,kBAAM,SAAS,MAAM;AACnB,oBAAM,iBAAiB,MAAM,QAAQ,WAAW,IAC5C,cACA,CAAC,WAAW;AAEhB,oBAAM,eAAe,eAAe;AAAA,gBAClC,QAAQ;AAAA,gBACR,QAAQ,aAAa;AAAA,cACvB;AAEA,qBAAO,QAAQ,OAAO,SAAS,YAAY;AAAA,YAC7C;AAEA,mBAAO;AAAA,cACL,MAAM,CAAC,mBAA0C;AAC/C,sBAAM,eAAe,OAAO;AAE5B,sBAAM,oBAAoB,MAAM,QAAQ,YAAY,IAChD,eACA,CAAC,YAAY;AAEjB,sBAAM,sBAAsB,MAAM,QAAQ,cAAc,IACpD,iBACA,CAAC,cAAc;AAEnB,uBAAO,UAAU,mBAAmB,mBAAmB;AAAA,cACzD;AAAA,cACA,YAAY,CAAQ,UAA2C;AAC7D,oBAAI;AACF,yBAAO;AACP,yBAAO,KAAK,kCAAkC;AAAA,gBAChD,SAAS,OAAO;AACd,yBAAO,GAAG,MAAM,KAAc,CAAC;AAAA,gBACjC;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["import assert from 'assert';\n\nexport type DeciderSpecfication<Command, Event> = (\n givenEvents: Event | Event[],\n) => {\n when: (command: Command) => {\n then: (expectedEvents: Event | Event[]) => void;\n thenThrows: <Error>(assert: (error: Error) => boolean) => void;\n };\n};\n\nexport const DeciderSpecification = {\n for: <Command, Event, State>(decider: {\n decide: (command: Command, state: State) => Event | Event[];\n evolve: (state: State, event: Event) => State;\n initialState: () => State;\n }): DeciderSpecfication<Command, Event> => {\n {\n return (givenEvents: Event | Event[]) => {\n return {\n when: (command: Command) => {\n const handle = () => {\n const existingEvents = Array.isArray(givenEvents)\n ? givenEvents\n : [givenEvents];\n\n const currentState = existingEvents.reduce<State>(\n decider.evolve,\n decider.initialState(),\n );\n\n return decider.decide(command, currentState);\n };\n\n return {\n then: (expectedEvents: Event | Event[]): void => {\n const resultEvents = handle();\n\n const resultEventsArray = Array.isArray(resultEvents)\n ? resultEvents\n : [resultEvents];\n\n const expectedEventsArray = Array.isArray(expectedEvents)\n ? expectedEvents\n : [expectedEvents];\n\n assert.deepEqual(resultEventsArray, expectedEventsArray);\n },\n thenThrows: <Error>(check: (error: Error) => boolean): void => {\n try {\n handle();\n assert.fail('Handler did not fail as expected');\n } catch (error) {\n assert.ok(check(error as Error));\n }\n },\n };\n },\n };\n };\n }\n },\n};\n"]}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
const DeciderSpecification = {
|
|
3
|
-
for: (decider) => {
|
|
4
|
-
{
|
|
5
|
-
return (givenEvents) => {
|
|
6
|
-
return {
|
|
7
|
-
when: (command) => {
|
|
8
|
-
const handle = () => {
|
|
9
|
-
const existingEvents = Array.isArray(givenEvents) ? givenEvents : [givenEvents];
|
|
10
|
-
const currentState = existingEvents.reduce(
|
|
11
|
-
decider.evolve,
|
|
12
|
-
decider.initialState()
|
|
13
|
-
);
|
|
14
|
-
return decider.decide(command, currentState);
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
then: (expectedEvents) => {
|
|
18
|
-
const resultEvents = handle();
|
|
19
|
-
const resultEventsArray = Array.isArray(resultEvents) ? resultEvents : [resultEvents];
|
|
20
|
-
const expectedEventsArray = Array.isArray(expectedEvents) ? expectedEvents : [expectedEvents];
|
|
21
|
-
assert.deepEqual(resultEventsArray, expectedEventsArray);
|
|
22
|
-
},
|
|
23
|
-
thenThrows: (check) => {
|
|
24
|
-
try {
|
|
25
|
-
handle();
|
|
26
|
-
assert.fail("Handler did not fail as expected");
|
|
27
|
-
} catch (error) {
|
|
28
|
-
assert.ok(check(error));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
export {
|
|
39
|
-
DeciderSpecification
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=deciderSpecification.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/deciderSpecification.ts"],"sourcesContent":["import assert from 'assert';\n\nexport type DeciderSpecfication<Command, Event> = (\n givenEvents: Event | Event[],\n) => {\n when: (command: Command) => {\n then: (expectedEvents: Event | Event[]) => void;\n thenThrows: <Error>(assert: (error: Error) => boolean) => void;\n };\n};\n\nexport const DeciderSpecification = {\n for: <Command, Event, State>(decider: {\n decide: (command: Command, state: State) => Event | Event[];\n evolve: (state: State, event: Event) => State;\n initialState: () => State;\n }): DeciderSpecfication<Command, Event> => {\n {\n return (givenEvents: Event | Event[]) => {\n return {\n when: (command: Command) => {\n const handle = () => {\n const existingEvents = Array.isArray(givenEvents)\n ? givenEvents\n : [givenEvents];\n\n const currentState = existingEvents.reduce<State>(\n decider.evolve,\n decider.initialState(),\n );\n\n return decider.decide(command, currentState);\n };\n\n return {\n then: (expectedEvents: Event | Event[]): void => {\n const resultEvents = handle();\n\n const resultEventsArray = Array.isArray(resultEvents)\n ? resultEvents\n : [resultEvents];\n\n const expectedEventsArray = Array.isArray(expectedEvents)\n ? expectedEvents\n : [expectedEvents];\n\n assert.deepEqual(resultEventsArray, expectedEventsArray);\n },\n thenThrows: <Error>(check: (error: Error) => boolean): void => {\n try {\n handle();\n assert.fail('Handler did not fail as expected');\n } catch (error) {\n assert.ok(check(error as Error));\n }\n },\n };\n },\n };\n };\n }\n },\n};\n"],"mappings":"AAAA,OAAO,YAAY;AAWZ,MAAM,uBAAuB;AAAA,EAClC,KAAK,CAAwB,YAIc;AACzC;AACE,aAAO,CAAC,gBAAiC;AACvC,eAAO;AAAA,UACL,MAAM,CAAC,YAAqB;AAC1B,kBAAM,SAAS,MAAM;AACnB,oBAAM,iBAAiB,MAAM,QAAQ,WAAW,IAC5C,cACA,CAAC,WAAW;AAEhB,oBAAM,eAAe,eAAe;AAAA,gBAClC,QAAQ;AAAA,gBACR,QAAQ,aAAa;AAAA,cACvB;AAEA,qBAAO,QAAQ,OAAO,SAAS,YAAY;AAAA,YAC7C;AAEA,mBAAO;AAAA,cACL,MAAM,CAAC,mBAA0C;AAC/C,sBAAM,eAAe,OAAO;AAE5B,sBAAM,oBAAoB,MAAM,QAAQ,YAAY,IAChD,eACA,CAAC,YAAY;AAEjB,sBAAM,sBAAsB,MAAM,QAAQ,cAAc,IACpD,iBACA,CAAC,cAAc;AAEnB,uBAAO,UAAU,mBAAmB,mBAAmB;AAAA,cACzD;AAAA,cACA,YAAY,CAAQ,UAA2C;AAC7D,oBAAI;AACF,yBAAO;AACP,yBAAO,KAAK,kCAAkC;AAAA,gBAChD,SAAS,OAAO;AACd,yBAAO,GAAG,MAAM,KAAc,CAAC;AAAA,gBACjC;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/testing/index.d.mts
DELETED
package/dist/testing/index.d.ts
DELETED
package/dist/testing/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/testing/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Command } from './index.mjs';
|
package/dist/typing/command.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Command } from './index.js';
|
package/dist/typing/command.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";//# sourceMappingURL=command.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/typing/command.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=command.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Decider } from './index.mjs';
|
package/dist/typing/decider.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Decider } from './index.js';
|
package/dist/typing/decider.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";//# sourceMappingURL=decider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/typing/decider.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=decider.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/typing/event.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Event } from './index.mjs';
|
package/dist/typing/event.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Event } from './index.js';
|
package/dist/typing/event.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";//# sourceMappingURL=event.js.map
|
package/dist/typing/event.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/typing/event.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=event.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/typing/index.d.mts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
type Command<CommandType extends string = string, CommandData extends Record<string, unknown> = Record<string, unknown>, CommandMetaData extends Record<string, unknown> = Record<string, unknown>> = Flavour<Readonly<{
|
|
2
|
-
type: CommandType;
|
|
3
|
-
data: Readonly<CommandData>;
|
|
4
|
-
metadata?: CommandMetaData | undefined;
|
|
5
|
-
}>, 'Command'>;
|
|
6
|
-
|
|
7
|
-
type Event<EventType extends string = string, EventData extends Record<string, unknown> = Record<string, unknown>, EventMetaData extends Record<string, unknown> = Record<string, unknown>> = Flavour<Readonly<{
|
|
8
|
-
type: EventType;
|
|
9
|
-
data: Readonly<EventData>;
|
|
10
|
-
metadata?: EventMetaData | undefined;
|
|
11
|
-
}>, 'Event'>;
|
|
12
|
-
|
|
13
|
-
type Decider<State, CommandType extends Command, StreamEvent extends Event> = {
|
|
14
|
-
decide: (command: CommandType, state: State) => StreamEvent | StreamEvent[];
|
|
15
|
-
evolve: (currentState: State, event: StreamEvent) => State;
|
|
16
|
-
getInitialState: () => State;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type Workflow<Input extends Event | Command, State, Output extends Event | Command> = {
|
|
20
|
-
decide: (command: Input, state: State) => WorkflowOutput<Output>[];
|
|
21
|
-
evolve: (currentState: State, event: WorkflowEvent<Output>) => State;
|
|
22
|
-
getInitialState: () => State;
|
|
23
|
-
};
|
|
24
|
-
type WorkflowEvent<Output extends Command | Event> = Extract<Output, {
|
|
25
|
-
__brand?: 'Event';
|
|
26
|
-
}>;
|
|
27
|
-
type WorkflowCommand<Output extends Command | Event> = Extract<Output, {
|
|
28
|
-
__brand?: 'Command';
|
|
29
|
-
}>;
|
|
30
|
-
type WorkflowOutput<TOutput extends Command | Event> = {
|
|
31
|
-
kind: 'Reply';
|
|
32
|
-
message: TOutput;
|
|
33
|
-
} | {
|
|
34
|
-
kind: 'Send';
|
|
35
|
-
message: WorkflowCommand<TOutput>;
|
|
36
|
-
} | {
|
|
37
|
-
kind: 'Publish';
|
|
38
|
-
message: WorkflowEvent<TOutput>;
|
|
39
|
-
} | {
|
|
40
|
-
kind: 'Schedule';
|
|
41
|
-
message: TOutput;
|
|
42
|
-
when: {
|
|
43
|
-
afterInMs: number;
|
|
44
|
-
} | {
|
|
45
|
-
at: Date;
|
|
46
|
-
};
|
|
47
|
-
} | {
|
|
48
|
-
kind: 'Complete';
|
|
49
|
-
} | {
|
|
50
|
-
kind: 'Accept';
|
|
51
|
-
} | {
|
|
52
|
-
kind: 'Ignore';
|
|
53
|
-
reason: string;
|
|
54
|
-
} | {
|
|
55
|
-
kind: 'Error';
|
|
56
|
-
reason: string;
|
|
57
|
-
};
|
|
58
|
-
declare const reply: <TOutput extends Command | Event>(message: TOutput) => WorkflowOutput<TOutput>;
|
|
59
|
-
declare const send: <TOutput extends Command | Event>(message: Extract<TOutput, {
|
|
60
|
-
__brand?: "Command" | undefined;
|
|
61
|
-
}>) => WorkflowOutput<TOutput>;
|
|
62
|
-
declare const publish: <TOutput extends Command | Event>(message: Extract<TOutput, {
|
|
63
|
-
__brand?: "Event" | undefined;
|
|
64
|
-
}>) => WorkflowOutput<TOutput>;
|
|
65
|
-
declare const schedule: <TOutput extends Command | Event>(message: TOutput, when: {
|
|
66
|
-
afterInMs: number;
|
|
67
|
-
} | {
|
|
68
|
-
at: Date;
|
|
69
|
-
}) => WorkflowOutput<TOutput>;
|
|
70
|
-
declare const complete: <TOutput extends Command | Event>() => WorkflowOutput<TOutput>;
|
|
71
|
-
declare const ignore: <TOutput extends Command | Event>(reason: string) => WorkflowOutput<TOutput>;
|
|
72
|
-
declare const error: <TOutput extends Command | Event>(reason: string) => WorkflowOutput<TOutput>;
|
|
73
|
-
declare const accept: <TOutput extends Command | Event>() => WorkflowOutput<TOutput>;
|
|
74
|
-
|
|
75
|
-
type Brand<K, T> = K & {
|
|
76
|
-
readonly __brand: T;
|
|
77
|
-
};
|
|
78
|
-
type Flavour<K, T> = K & {
|
|
79
|
-
readonly __brand?: T;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export { type Brand, type Command, type Decider, type Event, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send };
|
package/dist/typing/index.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
type Command<CommandType extends string = string, CommandData extends Record<string, unknown> = Record<string, unknown>, CommandMetaData extends Record<string, unknown> = Record<string, unknown>> = Flavour<Readonly<{
|
|
2
|
-
type: CommandType;
|
|
3
|
-
data: Readonly<CommandData>;
|
|
4
|
-
metadata?: CommandMetaData | undefined;
|
|
5
|
-
}>, 'Command'>;
|
|
6
|
-
|
|
7
|
-
type Event<EventType extends string = string, EventData extends Record<string, unknown> = Record<string, unknown>, EventMetaData extends Record<string, unknown> = Record<string, unknown>> = Flavour<Readonly<{
|
|
8
|
-
type: EventType;
|
|
9
|
-
data: Readonly<EventData>;
|
|
10
|
-
metadata?: EventMetaData | undefined;
|
|
11
|
-
}>, 'Event'>;
|
|
12
|
-
|
|
13
|
-
type Decider<State, CommandType extends Command, StreamEvent extends Event> = {
|
|
14
|
-
decide: (command: CommandType, state: State) => StreamEvent | StreamEvent[];
|
|
15
|
-
evolve: (currentState: State, event: StreamEvent) => State;
|
|
16
|
-
getInitialState: () => State;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type Workflow<Input extends Event | Command, State, Output extends Event | Command> = {
|
|
20
|
-
decide: (command: Input, state: State) => WorkflowOutput<Output>[];
|
|
21
|
-
evolve: (currentState: State, event: WorkflowEvent<Output>) => State;
|
|
22
|
-
getInitialState: () => State;
|
|
23
|
-
};
|
|
24
|
-
type WorkflowEvent<Output extends Command | Event> = Extract<Output, {
|
|
25
|
-
__brand?: 'Event';
|
|
26
|
-
}>;
|
|
27
|
-
type WorkflowCommand<Output extends Command | Event> = Extract<Output, {
|
|
28
|
-
__brand?: 'Command';
|
|
29
|
-
}>;
|
|
30
|
-
type WorkflowOutput<TOutput extends Command | Event> = {
|
|
31
|
-
kind: 'Reply';
|
|
32
|
-
message: TOutput;
|
|
33
|
-
} | {
|
|
34
|
-
kind: 'Send';
|
|
35
|
-
message: WorkflowCommand<TOutput>;
|
|
36
|
-
} | {
|
|
37
|
-
kind: 'Publish';
|
|
38
|
-
message: WorkflowEvent<TOutput>;
|
|
39
|
-
} | {
|
|
40
|
-
kind: 'Schedule';
|
|
41
|
-
message: TOutput;
|
|
42
|
-
when: {
|
|
43
|
-
afterInMs: number;
|
|
44
|
-
} | {
|
|
45
|
-
at: Date;
|
|
46
|
-
};
|
|
47
|
-
} | {
|
|
48
|
-
kind: 'Complete';
|
|
49
|
-
} | {
|
|
50
|
-
kind: 'Accept';
|
|
51
|
-
} | {
|
|
52
|
-
kind: 'Ignore';
|
|
53
|
-
reason: string;
|
|
54
|
-
} | {
|
|
55
|
-
kind: 'Error';
|
|
56
|
-
reason: string;
|
|
57
|
-
};
|
|
58
|
-
declare const reply: <TOutput extends Command | Event>(message: TOutput) => WorkflowOutput<TOutput>;
|
|
59
|
-
declare const send: <TOutput extends Command | Event>(message: Extract<TOutput, {
|
|
60
|
-
__brand?: "Command" | undefined;
|
|
61
|
-
}>) => WorkflowOutput<TOutput>;
|
|
62
|
-
declare const publish: <TOutput extends Command | Event>(message: Extract<TOutput, {
|
|
63
|
-
__brand?: "Event" | undefined;
|
|
64
|
-
}>) => WorkflowOutput<TOutput>;
|
|
65
|
-
declare const schedule: <TOutput extends Command | Event>(message: TOutput, when: {
|
|
66
|
-
afterInMs: number;
|
|
67
|
-
} | {
|
|
68
|
-
at: Date;
|
|
69
|
-
}) => WorkflowOutput<TOutput>;
|
|
70
|
-
declare const complete: <TOutput extends Command | Event>() => WorkflowOutput<TOutput>;
|
|
71
|
-
declare const ignore: <TOutput extends Command | Event>(reason: string) => WorkflowOutput<TOutput>;
|
|
72
|
-
declare const error: <TOutput extends Command | Event>(reason: string) => WorkflowOutput<TOutput>;
|
|
73
|
-
declare const accept: <TOutput extends Command | Event>() => WorkflowOutput<TOutput>;
|
|
74
|
-
|
|
75
|
-
type Brand<K, T> = K & {
|
|
76
|
-
readonly __brand: T;
|
|
77
|
-
};
|
|
78
|
-
type Flavour<K, T> = K & {
|
|
79
|
-
readonly __brand?: T;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export { type Brand, type Command, type Decider, type Event, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send };
|
package/dist/typing/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _command = require('./command'); _createStarExport(_command);
|
|
2
|
-
var _event = require('./event'); _createStarExport(_event);
|
|
3
|
-
var _decider = require('./decider'); _createStarExport(_decider);
|
|
4
|
-
var _workflow = require('./workflow'); _createStarExport(_workflow);
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
package/dist/typing/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/typing/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc","sourcesContent":["export * from './command';\nexport * from './event';\n\nexport * from './decider';\nexport * from './workflow';\n\nexport type Brand<K, T> = K & { readonly __brand: T };\nexport type Flavour<K, T> = K & { readonly __brand?: T };\n"]}
|
package/dist/typing/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/typing/index.ts"],"sourcesContent":["export * from './command';\nexport * from './event';\n\nexport * from './decider';\nexport * from './workflow';\n\nexport type Brand<K, T> = K & { readonly __brand: T };\nexport type Flavour<K, T> = K & { readonly __brand?: T };\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Workflow, WorkflowCommand, WorkflowEvent, WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send } from './index.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Workflow, WorkflowCommand, WorkflowEvent, WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send } from './index.js';
|
package/dist/typing/workflow.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});const reply = (message) => {
|
|
2
|
-
return {
|
|
3
|
-
kind: "Reply",
|
|
4
|
-
message
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
const send = (message) => {
|
|
8
|
-
return {
|
|
9
|
-
kind: "Send",
|
|
10
|
-
message
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
const publish = (message) => {
|
|
14
|
-
return {
|
|
15
|
-
kind: "Publish",
|
|
16
|
-
message
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
const schedule = (message, when) => {
|
|
20
|
-
return {
|
|
21
|
-
kind: "Schedule",
|
|
22
|
-
message,
|
|
23
|
-
when
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const complete = () => {
|
|
27
|
-
return {
|
|
28
|
-
kind: "Complete"
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
const ignore = (reason) => {
|
|
32
|
-
return {
|
|
33
|
-
kind: "Ignore",
|
|
34
|
-
reason
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
const error = (reason) => {
|
|
38
|
-
return {
|
|
39
|
-
kind: "Error",
|
|
40
|
-
reason
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
const accept = () => {
|
|
44
|
-
return { kind: "Accept" };
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
exports.accept = accept; exports.complete = complete; exports.error = error; exports.ignore = ignore; exports.publish = publish; exports.reply = reply; exports.schedule = schedule; exports.send = send;
|
|
56
|
-
//# sourceMappingURL=workflow.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/typing/workflow.ts"],"names":[],"mappings":"AAuCO,MAAM,QAAQ,CACnB,YAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,OAAO,CAClB,YAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,UAAU,CACrB,YAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,WAAW,CACtB,SACA,SAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,WAAW,MAEQ;AAC9B,SAAO;AAAA,IACL,MAAM;AAAA,EACR;AACF;AAEO,MAAM,SAAS,CACpB,WAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,QAAQ,CACnB,WAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,SAAS,MAEU;AAC9B,SAAO,EAAE,MAAM,SAAS;AAC1B","sourcesContent":["import type { Command } from './command';\nimport type { Event } from './event';\n\n/// Inspired by https://blog.bittacklr.be/the-workflow-pattern.html\n\nexport type Workflow<\n Input extends Event | Command,\n State,\n Output extends Event | Command,\n> = {\n decide: (command: Input, state: State) => WorkflowOutput<Output>[];\n evolve: (currentState: State, event: WorkflowEvent<Output>) => State;\n getInitialState: () => State;\n};\n\nexport type WorkflowEvent<Output extends Command | Event> = Extract<\n Output,\n { __brand?: 'Event' }\n>;\n\nexport type WorkflowCommand<Output extends Command | Event> = Extract<\n Output,\n { __brand?: 'Command' }\n>;\n\nexport type WorkflowOutput<TOutput extends Command | Event> =\n | { kind: 'Reply'; message: TOutput }\n | { kind: 'Send'; message: WorkflowCommand<TOutput> }\n | { kind: 'Publish'; message: WorkflowEvent<TOutput> }\n | {\n kind: 'Schedule';\n message: TOutput;\n when: { afterInMs: number } | { at: Date };\n }\n | { kind: 'Complete' }\n | { kind: 'Accept' }\n | { kind: 'Ignore'; reason: string }\n | { kind: 'Error'; reason: string };\n\nexport const reply = <TOutput extends Command | Event>(\n message: TOutput,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Reply',\n message,\n };\n};\n\nexport const send = <TOutput extends Command | Event>(\n message: WorkflowCommand<TOutput>,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Send',\n message,\n };\n};\n\nexport const publish = <TOutput extends Command | Event>(\n message: WorkflowEvent<TOutput>,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Publish',\n message,\n };\n};\n\nexport const schedule = <TOutput extends Command | Event>(\n message: TOutput,\n when: { afterInMs: number } | { at: Date },\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Schedule',\n message,\n when,\n };\n};\n\nexport const complete = <\n TOutput extends Command | Event,\n>(): WorkflowOutput<TOutput> => {\n return {\n kind: 'Complete',\n };\n};\n\nexport const ignore = <TOutput extends Command | Event>(\n reason: string,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Ignore',\n reason,\n };\n};\n\nexport const error = <TOutput extends Command | Event>(\n reason: string,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Error',\n reason,\n };\n};\n\nexport const accept = <\n TOutput extends Command | Event,\n>(): WorkflowOutput<TOutput> => {\n return { kind: 'Accept' };\n};\n"]}
|
package/dist/typing/workflow.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const reply = (message) => {
|
|
2
|
-
return {
|
|
3
|
-
kind: "Reply",
|
|
4
|
-
message
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
const send = (message) => {
|
|
8
|
-
return {
|
|
9
|
-
kind: "Send",
|
|
10
|
-
message
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
const publish = (message) => {
|
|
14
|
-
return {
|
|
15
|
-
kind: "Publish",
|
|
16
|
-
message
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
const schedule = (message, when) => {
|
|
20
|
-
return {
|
|
21
|
-
kind: "Schedule",
|
|
22
|
-
message,
|
|
23
|
-
when
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const complete = () => {
|
|
27
|
-
return {
|
|
28
|
-
kind: "Complete"
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
const ignore = (reason) => {
|
|
32
|
-
return {
|
|
33
|
-
kind: "Ignore",
|
|
34
|
-
reason
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
const error = (reason) => {
|
|
38
|
-
return {
|
|
39
|
-
kind: "Error",
|
|
40
|
-
reason
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
const accept = () => {
|
|
44
|
-
return { kind: "Accept" };
|
|
45
|
-
};
|
|
46
|
-
export {
|
|
47
|
-
accept,
|
|
48
|
-
complete,
|
|
49
|
-
error,
|
|
50
|
-
ignore,
|
|
51
|
-
publish,
|
|
52
|
-
reply,
|
|
53
|
-
schedule,
|
|
54
|
-
send
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=workflow.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/typing/workflow.ts"],"sourcesContent":["import type { Command } from './command';\nimport type { Event } from './event';\n\n/// Inspired by https://blog.bittacklr.be/the-workflow-pattern.html\n\nexport type Workflow<\n Input extends Event | Command,\n State,\n Output extends Event | Command,\n> = {\n decide: (command: Input, state: State) => WorkflowOutput<Output>[];\n evolve: (currentState: State, event: WorkflowEvent<Output>) => State;\n getInitialState: () => State;\n};\n\nexport type WorkflowEvent<Output extends Command | Event> = Extract<\n Output,\n { __brand?: 'Event' }\n>;\n\nexport type WorkflowCommand<Output extends Command | Event> = Extract<\n Output,\n { __brand?: 'Command' }\n>;\n\nexport type WorkflowOutput<TOutput extends Command | Event> =\n | { kind: 'Reply'; message: TOutput }\n | { kind: 'Send'; message: WorkflowCommand<TOutput> }\n | { kind: 'Publish'; message: WorkflowEvent<TOutput> }\n | {\n kind: 'Schedule';\n message: TOutput;\n when: { afterInMs: number } | { at: Date };\n }\n | { kind: 'Complete' }\n | { kind: 'Accept' }\n | { kind: 'Ignore'; reason: string }\n | { kind: 'Error'; reason: string };\n\nexport const reply = <TOutput extends Command | Event>(\n message: TOutput,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Reply',\n message,\n };\n};\n\nexport const send = <TOutput extends Command | Event>(\n message: WorkflowCommand<TOutput>,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Send',\n message,\n };\n};\n\nexport const publish = <TOutput extends Command | Event>(\n message: WorkflowEvent<TOutput>,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Publish',\n message,\n };\n};\n\nexport const schedule = <TOutput extends Command | Event>(\n message: TOutput,\n when: { afterInMs: number } | { at: Date },\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Schedule',\n message,\n when,\n };\n};\n\nexport const complete = <\n TOutput extends Command | Event,\n>(): WorkflowOutput<TOutput> => {\n return {\n kind: 'Complete',\n };\n};\n\nexport const ignore = <TOutput extends Command | Event>(\n reason: string,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Ignore',\n reason,\n };\n};\n\nexport const error = <TOutput extends Command | Event>(\n reason: string,\n): WorkflowOutput<TOutput> => {\n return {\n kind: 'Error',\n reason,\n };\n};\n\nexport const accept = <\n TOutput extends Command | Event,\n>(): WorkflowOutput<TOutput> => {\n return { kind: 'Accept' };\n};\n"],"mappings":"AAuCO,MAAM,QAAQ,CACnB,YAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,OAAO,CAClB,YAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,UAAU,CACrB,YAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,WAAW,CACtB,SACA,SAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,WAAW,MAEQ;AAC9B,SAAO;AAAA,IACL,MAAM;AAAA,EACR;AACF;AAEO,MAAM,SAAS,CACpB,WAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,QAAQ,CACnB,WAC4B;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,MAAM,SAAS,MAEU;AAC9B,SAAO,EAAE,MAAM,SAAS;AAC1B;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare const enum ValidationErrors {
|
|
2
|
-
NOT_A_NONEMPTY_STRING = "NOT_A_NONEMPTY_STRING",
|
|
3
|
-
NOT_A_POSITIVE_NUMBER = "NOT_A_POSITIVE_NUMBER",
|
|
4
|
-
NOT_AN_UNSIGNED_BIGINT = "NOT_AN_UNSIGNED_BIGINT"
|
|
5
|
-
}
|
|
6
|
-
declare const assertNotEmptyString: (value: unknown) => string;
|
|
7
|
-
declare const assertPositiveNumber: (value: unknown) => number;
|
|
8
|
-
declare const assertUnsignedBigInt: (value: string) => bigint;
|
|
9
|
-
|
|
10
|
-
export { ValidationErrors, assertNotEmptyString, assertPositiveNumber, assertUnsignedBigInt };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare const enum ValidationErrors {
|
|
2
|
-
NOT_A_NONEMPTY_STRING = "NOT_A_NONEMPTY_STRING",
|
|
3
|
-
NOT_A_POSITIVE_NUMBER = "NOT_A_POSITIVE_NUMBER",
|
|
4
|
-
NOT_AN_UNSIGNED_BIGINT = "NOT_AN_UNSIGNED_BIGINT"
|
|
5
|
-
}
|
|
6
|
-
declare const assertNotEmptyString: (value: unknown) => string;
|
|
7
|
-
declare const assertPositiveNumber: (value: unknown) => number;
|
|
8
|
-
declare const assertUnsignedBigInt: (value: string) => bigint;
|
|
9
|
-
|
|
10
|
-
export { ValidationErrors, assertNotEmptyString, assertPositiveNumber, assertUnsignedBigInt };
|