@event-driven-io/emmett 0.3.0 → 0.5.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/commandHandling/handleCommand.d.mts +6 -3
- package/dist/commandHandling/handleCommand.d.ts +6 -3
- package/dist/commandHandling/handleCommand.js +33 -29
- package/dist/commandHandling/handleCommand.js.map +1 -1
- package/dist/commandHandling/handleCommand.mjs +4 -2
- package/dist/commandHandling/handleCommand.mjs.map +1 -1
- package/dist/commandHandling/handleCommand.unit.spec.js +83 -0
- package/dist/commandHandling/handleCommand.unit.spec.js.map +1 -0
- package/dist/commandHandling/handleCommand.unit.spec.mjs +93 -0
- package/dist/commandHandling/handleCommand.unit.spec.mjs.map +1 -0
- package/dist/commandHandling/handleCommandWithDecider.d.mts +3 -2
- package/dist/commandHandling/handleCommandWithDecider.d.ts +3 -2
- package/dist/commandHandling/handleCommandWithDecider.js +4 -13
- package/dist/commandHandling/handleCommandWithDecider.js.map +1 -1
- package/dist/commandHandling/index.d.mts +1 -1
- package/dist/commandHandling/index.d.ts +1 -1
- package/dist/commandHandling/index.js +2 -2
- package/dist/commandHandling/index.js.map +1 -1
- package/dist/errors/index.js +67 -51
- package/dist/errors/index.js.map +1 -1
- package/dist/eventStore/eventStore.js +2 -1
- package/dist/eventStore/eventStore.js.map +1 -1
- package/dist/eventStore/expectedVersion.js +22 -29
- package/dist/eventStore/expectedVersion.js.map +1 -1
- package/dist/eventStore/expectedVersion.unit.spec.js +48 -60
- package/dist/eventStore/expectedVersion.unit.spec.js.map +1 -1
- package/dist/eventStore/inMemoryEventStore.js +65 -64
- package/dist/eventStore/inMemoryEventStore.js.map +1 -1
- package/dist/eventStore/inMemoryEventStore.mjs +6 -1
- package/dist/eventStore/inMemoryEventStore.mjs.map +1 -1
- package/dist/eventStore/inMemoryEventStore.unit.spec.d.mts +2 -0
- package/dist/eventStore/inMemoryEventStore.unit.spec.d.ts +2 -0
- package/dist/eventStore/inMemoryEventStore.unit.spec.js +85 -0
- package/dist/eventStore/inMemoryEventStore.unit.spec.js.map +1 -0
- package/dist/eventStore/inMemoryEventStore.unit.spec.mjs +81 -0
- package/dist/eventStore/inMemoryEventStore.unit.spec.mjs.map +1 -0
- package/dist/eventStore/index.js +3 -3
- package/dist/eventStore/index.js.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/serialization/index.js +1 -1
- package/dist/serialization/index.js.map +1 -1
- package/dist/serialization/json/JSONParser.js +16 -20
- package/dist/serialization/json/JSONParser.js.map +1 -1
- package/dist/serialization/json/index.js +1 -1
- package/dist/serialization/json/index.js.map +1 -1
- package/dist/testing/assertions.js +12 -24
- package/dist/testing/assertions.js.map +1 -1
- package/dist/testing/deciderSpecification.js +40 -39
- package/dist/testing/deciderSpecification.js.map +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/testing/index.js.map +1 -1
- package/dist/typing/command.js +2 -1
- package/dist/typing/command.js.map +1 -1
- package/dist/typing/decider.js +2 -1
- package/dist/typing/decider.js.map +1 -1
- package/dist/typing/event.js +2 -1
- package/dist/typing/event.js.map +1 -1
- package/dist/typing/index.js +4 -4
- package/dist/typing/index.js.map +1 -1
- package/dist/typing/workflow.d.ts +57 -1
- package/dist/typing/workflow.js +45 -55
- package/dist/typing/workflow.js.map +1 -1
- package/dist/utils/index.js +3 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/iterators.js +8 -10
- package/dist/utils/iterators.js.map +1 -1
- package/dist/utils/merge.js +27 -21
- package/dist/utils/merge.js.map +1 -1
- package/dist/validation/index.js +25 -33
- package/dist/validation/index.js.map +1 -1
- package/dist/validation/validation.spec.js +14 -10
- package/dist/validation/validation.spec.js.map +1 -1
- package/package.json +1 -1
- package/dist/testing/placeholder.e2e.spec.js +0 -8
- package/dist/testing/placeholder.e2e.spec.js.map +0 -1
- package/dist/testing/placeholder.e2e.spec.mjs +0 -8
- package/dist/testing/placeholder.e2e.spec.mjs.map +0 -1
- /package/dist/{testing/placeholder.e2e.spec.d.mts → commandHandling/handleCommand.unit.spec.d.mts} +0 -0
- /package/dist/{testing/placeholder.e2e.spec.d.ts → commandHandling/handleCommand.unit.spec.d.ts} +0 -0
package/dist/utils/merge.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
export const merge = (array, item, where, onExisting, onNotFound = () => undefined) => {
|
|
2
|
+
let wasFound = false;
|
|
3
|
+
const result = array
|
|
4
|
+
// merge the existing item if matches condition
|
|
5
|
+
.map((p) => {
|
|
6
|
+
if (!where(p))
|
|
7
|
+
return p;
|
|
8
|
+
wasFound = true;
|
|
9
|
+
return onExisting(p);
|
|
10
|
+
})
|
|
11
|
+
// filter out item if undefined was returned
|
|
12
|
+
// for cases of removal
|
|
13
|
+
.filter((p) => p !== undefined)
|
|
14
|
+
// make TypeScript happy
|
|
15
|
+
.map((p) => {
|
|
16
|
+
if (!p)
|
|
17
|
+
throw Error('That should not happen');
|
|
18
|
+
return p;
|
|
19
|
+
});
|
|
20
|
+
// if item was not found and onNotFound action is defined
|
|
21
|
+
// try to generate new item
|
|
22
|
+
if (!wasFound) {
|
|
23
|
+
const result = onNotFound();
|
|
24
|
+
if (result !== undefined)
|
|
25
|
+
return [...array, item];
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
19
28
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
exports.merge = merge;
|
|
23
29
|
//# sourceMappingURL=merge.js.map
|
package/dist/utils/merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/merge.ts"],"names":[
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/utils/merge.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,KAAU,EACV,IAAO,EACP,KAA8B,EAC9B,UAA6B,EAC7B,aAAkC,GAAG,EAAE,CAAC,SAAS,EACjD,EAAE;IACF,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,MAAM,MAAM,GAAG,KAAK;QAClB,+CAA+C;SAC9C,GAAG,CAAC,CAAC,CAAI,EAAE,EAAE;QACZ,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;QAExB,QAAQ,GAAG,IAAI,CAAC;QAChB,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC,CAAC;QACF,4CAA4C;QAC5C,uBAAuB;SACtB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;QAC/B,wBAAwB;SACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,IAAI,CAAC,CAAC;YAAE,MAAM,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE9C,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;IAEL,yDAAyD;IACzD,2BAA2B;IAC3B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAE5B,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/validation/index.js
CHANGED
|
@@ -1,37 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
var ValidationErrors
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})(ValidationErrors || {});
|
|
8
|
-
const isNumber = (val) => typeof val ===
|
|
9
|
-
const isString = (val) => typeof val ===
|
|
10
|
-
const assertNotEmptyString = (value) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { ValidationError } from '../errors';
|
|
2
|
+
export var ValidationErrors;
|
|
3
|
+
(function (ValidationErrors) {
|
|
4
|
+
ValidationErrors["NOT_A_NONEMPTY_STRING"] = "NOT_A_NONEMPTY_STRING";
|
|
5
|
+
ValidationErrors["NOT_A_POSITIVE_NUMBER"] = "NOT_A_POSITIVE_NUMBER";
|
|
6
|
+
ValidationErrors["NOT_AN_UNSIGNED_BIGINT"] = "NOT_AN_UNSIGNED_BIGINT";
|
|
7
|
+
})(ValidationErrors || (ValidationErrors = {}));
|
|
8
|
+
export const isNumber = (val) => typeof val === 'number' && val === val;
|
|
9
|
+
export const isString = (val) => typeof val === 'string';
|
|
10
|
+
export const assertNotEmptyString = (value) => {
|
|
11
|
+
if (!isString(value) || value.length === 0) {
|
|
12
|
+
throw new ValidationError(ValidationErrors.NOT_A_NONEMPTY_STRING);
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
15
|
};
|
|
16
|
-
const assertPositiveNumber = (value) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
export const assertPositiveNumber = (value) => {
|
|
17
|
+
if (!isNumber(value) || value <= 0) {
|
|
18
|
+
throw new ValidationError(ValidationErrors.NOT_A_POSITIVE_NUMBER);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
21
|
};
|
|
22
|
-
const assertUnsignedBigInt = (value) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
export const assertUnsignedBigInt = (value) => {
|
|
23
|
+
const number = BigInt(value);
|
|
24
|
+
if (number < 0) {
|
|
25
|
+
throw new ValidationError(ValidationErrors.NOT_AN_UNSIGNED_BIGINT);
|
|
26
|
+
}
|
|
27
|
+
return number;
|
|
28
28
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
exports.ValidationErrors = ValidationErrors; exports.assertNotEmptyString = assertNotEmptyString; exports.assertPositiveNumber = assertPositiveNumber; exports.assertUnsignedBigInt = assertUnsignedBigInt; exports.isNumber = isNumber; exports.isString = isString;
|
|
37
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/validation/index.ts"],"names":[
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,CAAN,IAAkB,gBAIjB;AAJD,WAAkB,gBAAgB;IAChC,mEAA+C,CAAA;IAC/C,mEAA+C,CAAA;IAC/C,qEAAiD,CAAA;AACnD,CAAC,EAJiB,gBAAgB,KAAhB,gBAAgB,QAIjC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAY,EAAiB,EAAE,CACtD,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,GAAG,CAAC;AAEzC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAY,EAAiB,EAAE,CACtD,OAAO,GAAG,KAAK,QAAQ,CAAC;AAE1B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAc,EAAU,EAAE;IAC7D,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,eAAe,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAc,EAAU,EAAE;IAC7D,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,eAAe,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,eAAe,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import test, { describe } from 'node:test';
|
|
4
|
+
import { assertNotEmptyString } from './index';
|
|
5
|
+
describe('Validation', () => {
|
|
6
|
+
describe('assertNotEmptyString', () => {
|
|
7
|
+
test('should throw an error if the value is an empty string', () => {
|
|
8
|
+
// Arrange
|
|
9
|
+
const value = '';
|
|
10
|
+
// Act
|
|
11
|
+
const invalidAction = () => assertNotEmptyString(value);
|
|
12
|
+
// Assert
|
|
13
|
+
assert.throws(invalidAction);
|
|
14
|
+
});
|
|
10
15
|
});
|
|
11
|
-
});
|
|
12
16
|
});
|
|
13
17
|
//# sourceMappingURL=validation.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/validation/validation.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.spec.js","sourceRoot":"","sources":["../../src/validation/validation.spec.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,IAAI,CAAC,uDAAuD,EAAE,GAAG,EAAE;YACjE,UAAU;YACV,MAAM,KAAK,GAAG,EAAE,CAAC;YAEjB,MAAM;YACN,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAExD,SAAS;YACT,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _nodeassert = require('node:assert'); var _nodeassert2 = _interopRequireDefault(_nodeassert);
|
|
2
|
-
var _nodetest = require('node:test');
|
|
3
|
-
_nodetest.describe.call(void 0, "Remove when first e2e is added", () => {
|
|
4
|
-
_nodetest.it.call(void 0, "node-globa passes no files to script so it`ll try to run all tests failing on dist", () => {
|
|
5
|
-
_nodeassert2.default.call(void 0, true);
|
|
6
|
-
});
|
|
7
|
-
});
|
|
8
|
-
//# sourceMappingURL=placeholder.e2e.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/placeholder.e2e.spec.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY;AACnB,SAAS,UAAU,UAAU;AAE7B,SAAS,kCAAkC,MAAM;AAC/C,KAAG,sFAAsF,MAAM;AAC7F,WAAO,IAAI;AAAA,EACb,CAAC;AACH,CAAC","sourcesContent":["import assert from 'node:assert';\nimport { describe, it } from 'node:test';\n\ndescribe('Remove when first e2e is added', () => {\n it('node-globa passes no files to script so it`ll try to run all tests failing on dist', () => {\n assert(true);\n });\n});\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
describe("Remove when first e2e is added", () => {
|
|
4
|
-
it("node-globa passes no files to script so it`ll try to run all tests failing on dist", () => {
|
|
5
|
-
assert(true);
|
|
6
|
-
});
|
|
7
|
-
});
|
|
8
|
-
//# sourceMappingURL=placeholder.e2e.spec.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/placeholder.e2e.spec.ts"],"sourcesContent":["import assert from 'node:assert';\nimport { describe, it } from 'node:test';\n\ndescribe('Remove when first e2e is added', () => {\n it('node-globa passes no files to script so it`ll try to run all tests failing on dist', () => {\n assert(true);\n });\n});\n"],"mappings":"AAAA,OAAO,YAAY;AACnB,SAAS,UAAU,UAAU;AAE7B,SAAS,kCAAkC,MAAM;AAC/C,KAAG,sFAAsF,MAAM;AAC7F,WAAO,IAAI;AAAA,EACb,CAAC;AACH,CAAC;","names":[]}
|
/package/dist/{testing/placeholder.e2e.spec.d.mts → commandHandling/handleCommand.unit.spec.d.mts}
RENAMED
|
File without changes
|
/package/dist/{testing/placeholder.e2e.spec.d.ts → commandHandling/handleCommand.unit.spec.d.ts}
RENAMED
|
File without changes
|