@event-driven-io/emmett 0.1.7 → 0.3.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 +5 -2
- package/dist/commandHandling/handleCommand.d.ts +5 -2
- package/dist/commandHandling/handleCommand.js +23 -8
- package/dist/commandHandling/handleCommand.js.map +1 -1
- package/dist/commandHandling/handleCommand.mjs +23 -8
- package/dist/commandHandling/handleCommand.mjs.map +1 -1
- package/dist/commandHandling/handleCommandWithDecider.d.mts +5 -2
- package/dist/commandHandling/handleCommandWithDecider.d.ts +5 -2
- package/dist/commandHandling/handleCommandWithDecider.js +7 -13
- package/dist/commandHandling/handleCommandWithDecider.js.map +1 -1
- package/dist/commandHandling/handleCommandWithDecider.mjs +6 -12
- package/dist/commandHandling/handleCommandWithDecider.mjs.map +1 -1
- package/dist/commandHandling/index.d.mts +2 -1
- package/dist/commandHandling/index.d.ts +2 -1
- package/dist/errors/index.d.mts +27 -0
- package/dist/errors/index.d.ts +27 -0
- package/dist/errors/index.js +57 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/index.mjs +57 -0
- package/dist/errors/index.mjs.map +1 -0
- package/dist/eventStore/eventStore.d.mts +3 -12
- package/dist/eventStore/eventStore.d.ts +3 -12
- package/dist/eventStore/expectedVersion.d.mts +3 -0
- package/dist/eventStore/expectedVersion.d.ts +3 -0
- package/dist/eventStore/expectedVersion.js +33 -0
- package/dist/eventStore/expectedVersion.js.map +1 -0
- package/dist/eventStore/expectedVersion.mjs +33 -0
- package/dist/eventStore/expectedVersion.mjs.map +1 -0
- package/dist/eventStore/expectedVersion.unit.spec.d.mts +2 -0
- package/dist/eventStore/expectedVersion.unit.spec.d.ts +2 -0
- package/dist/eventStore/expectedVersion.unit.spec.js +62 -0
- package/dist/eventStore/expectedVersion.unit.spec.js.map +1 -0
- package/dist/eventStore/expectedVersion.unit.spec.mjs +62 -0
- package/dist/eventStore/expectedVersion.unit.spec.mjs.map +1 -0
- package/dist/eventStore/inMemoryEventStore.d.mts +17 -0
- package/dist/eventStore/inMemoryEventStore.d.ts +17 -0
- package/dist/eventStore/inMemoryEventStore.js +66 -0
- package/dist/eventStore/inMemoryEventStore.js.map +1 -0
- package/dist/eventStore/inMemoryEventStore.mjs +66 -0
- package/dist/eventStore/inMemoryEventStore.mjs.map +1 -0
- package/dist/eventStore/index.d.mts +3 -1
- package/dist/eventStore/index.d.ts +3 -1
- package/dist/eventStore/index.js +2 -0
- package/dist/eventStore/index.js.map +1 -1
- package/dist/eventStore/index.mjs +2 -0
- package/dist/eventStore/index.mjs.map +1 -1
- package/dist/eventStore-DLezSgsV.d.mts +54 -0
- package/dist/eventStore-N_YMFCDT.d.ts +54 -0
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/testing/assertions.d.mts +4 -0
- package/dist/testing/assertions.d.ts +4 -0
- package/dist/testing/assertions.js +27 -0
- package/dist/testing/assertions.js.map +1 -0
- package/dist/testing/assertions.mjs +27 -0
- package/dist/testing/assertions.mjs.map +1 -0
- package/dist/testing/index.d.mts +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +2 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/index.mjs +1 -0
- package/dist/testing/index.mjs.map +1 -1
- package/dist/testing/placeholder.e2e.spec.d.mts +2 -0
- package/dist/testing/placeholder.e2e.spec.d.ts +2 -0
- package/dist/testing/placeholder.e2e.spec.js +8 -0
- package/dist/testing/placeholder.e2e.spec.js.map +1 -0
- package/dist/testing/placeholder.e2e.spec.mjs +8 -0
- package/dist/testing/placeholder.e2e.spec.mjs.map +1 -0
- package/dist/validation/index.d.mts +3 -1
- package/dist/validation/index.d.ts +3 -1
- package/dist/validation/index.js +12 -7
- package/dist/validation/index.js.map +1 -1
- package/dist/validation/index.mjs +11 -6
- package/dist/validation/index.mjs.map +1 -1
- package/dist/validation/validation.spec.d.mts +2 -0
- package/dist/validation/validation.spec.d.ts +2 -0
- package/dist/validation/validation.spec.js +13 -0
- package/dist/validation/validation.spec.js.map +1 -0
- package/dist/validation/validation.spec.mjs +13 -0
- package/dist/validation/validation.spec.mjs.map +1 -0
- package/package.json +13 -9
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const isSubset = (superObj, subObj) => {
|
|
2
|
+
const sup = superObj;
|
|
3
|
+
const sub = subObj;
|
|
4
|
+
return Object.keys(sub).every((ele) => {
|
|
5
|
+
if (typeof sub[ele] == "object") {
|
|
6
|
+
return isSubset(
|
|
7
|
+
sup[ele],
|
|
8
|
+
sub[ele]
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
return sub[ele] === sup[ele];
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const assertMatches = (actual, expected) => {
|
|
15
|
+
if (!isSubset(actual, expected))
|
|
16
|
+
throw Error(
|
|
17
|
+
`subObj:
|
|
18
|
+
${JSON.stringify(expected)}
|
|
19
|
+
is not subset of
|
|
20
|
+
${JSON.stringify(actual)}`
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
assertMatches,
|
|
25
|
+
isSubset
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=assertions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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,MAAM,WAAW,CAAC,UAAmB,WAA6B;AACvE,QAAM,MAAM;AACZ,QAAM,MAAM;AAEZ,SAAO,OAAO,KAAK,GAAG,EAAE,MAAM,CAAC,QAAgB;AAC7C,QAAI,OAAO,IAAI,GAAG,KAAK,UAAU;AAC/B,aAAO;AAAA,QACL,IAAI,GAAG;AAAA,QACP,IAAI,GAAG;AAAA,MACT;AAAA,IACF;AACA,WAAO,IAAI,GAAG,MAAM,IAAI,GAAG;AAAA,EAC7B,CAAC;AACH;AAEO,MAAM,gBAAgB,CAAC,QAAiB,aAAsB;AACnE,MAAI,CAAC,SAAS,QAAQ,QAAQ;AAC5B,UAAM;AAAA,MACJ;AAAA,EAAY,KAAK,UAAU,QAAQ,CAAC;AAAA;AAAA,EAAuB,KAAK,UAAU,MAAM,CAAC;AAAA,IACnF;AACJ;","names":[]}
|
package/dist/testing/index.d.mts
CHANGED
package/dist/testing/index.d.ts
CHANGED
package/dist/testing/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
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
|
|
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 _assertions = require('./assertions'); _createStarExport(_assertions);
|
|
2
|
+
var _deciderSpecification = require('./deciderSpecification'); _createStarExport(_deciderSpecification);
|
|
2
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc","sourcesContent":["export * from './deciderSpecification';\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,cAAc","sourcesContent":["export * from './assertions';\nexport * from './deciderSpecification';\n"]}
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/index.ts"],"sourcesContent":["export * from './deciderSpecification';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/testing/index.ts"],"sourcesContent":["export * from './assertions';\nexport * from './deciderSpecification';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -3,8 +3,10 @@ declare const enum ValidationErrors {
|
|
|
3
3
|
NOT_A_POSITIVE_NUMBER = "NOT_A_POSITIVE_NUMBER",
|
|
4
4
|
NOT_AN_UNSIGNED_BIGINT = "NOT_AN_UNSIGNED_BIGINT"
|
|
5
5
|
}
|
|
6
|
+
declare const isNumber: (val: unknown) => val is number;
|
|
7
|
+
declare const isString: (val: unknown) => val is string;
|
|
6
8
|
declare const assertNotEmptyString: (value: unknown) => string;
|
|
7
9
|
declare const assertPositiveNumber: (value: unknown) => number;
|
|
8
10
|
declare const assertUnsignedBigInt: (value: string) => bigint;
|
|
9
11
|
|
|
10
|
-
export { ValidationErrors, assertNotEmptyString, assertPositiveNumber, assertUnsignedBigInt };
|
|
12
|
+
export { ValidationErrors, assertNotEmptyString, assertPositiveNumber, assertUnsignedBigInt, isNumber, isString };
|
|
@@ -3,8 +3,10 @@ declare const enum ValidationErrors {
|
|
|
3
3
|
NOT_A_POSITIVE_NUMBER = "NOT_A_POSITIVE_NUMBER",
|
|
4
4
|
NOT_AN_UNSIGNED_BIGINT = "NOT_AN_UNSIGNED_BIGINT"
|
|
5
5
|
}
|
|
6
|
+
declare const isNumber: (val: unknown) => val is number;
|
|
7
|
+
declare const isString: (val: unknown) => val is string;
|
|
6
8
|
declare const assertNotEmptyString: (value: unknown) => string;
|
|
7
9
|
declare const assertPositiveNumber: (value: unknown) => number;
|
|
8
10
|
declare const assertUnsignedBigInt: (value: string) => bigint;
|
|
9
11
|
|
|
10
|
-
export { ValidationErrors, assertNotEmptyString, assertPositiveNumber, assertUnsignedBigInt };
|
|
12
|
+
export { ValidationErrors, assertNotEmptyString, assertPositiveNumber, assertUnsignedBigInt, isNumber, isString };
|
package/dist/validation/index.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _errors = require('../errors');
|
|
2
|
+
var ValidationErrors = /* @__PURE__ */ ((ValidationErrors2) => {
|
|
2
3
|
ValidationErrors2["NOT_A_NONEMPTY_STRING"] = "NOT_A_NONEMPTY_STRING";
|
|
3
4
|
ValidationErrors2["NOT_A_POSITIVE_NUMBER"] = "NOT_A_POSITIVE_NUMBER";
|
|
4
5
|
ValidationErrors2["NOT_AN_UNSIGNED_BIGINT"] = "NOT_AN_UNSIGNED_BIGINT";
|
|
5
6
|
return ValidationErrors2;
|
|
6
7
|
})(ValidationErrors || {});
|
|
8
|
+
const isNumber = (val) => typeof val === "number" && val === val;
|
|
9
|
+
const isString = (val) => typeof val === "string";
|
|
7
10
|
const assertNotEmptyString = (value) => {
|
|
8
|
-
if (
|
|
9
|
-
throw new
|
|
11
|
+
if (!isString(value) || value.length === 0) {
|
|
12
|
+
throw new (0, _errors.ValidationError)("NOT_A_NONEMPTY_STRING" /* NOT_A_NONEMPTY_STRING */);
|
|
10
13
|
}
|
|
11
14
|
return value;
|
|
12
15
|
};
|
|
13
16
|
const assertPositiveNumber = (value) => {
|
|
14
|
-
if (
|
|
15
|
-
throw new
|
|
17
|
+
if (!isNumber(value) || value <= 0) {
|
|
18
|
+
throw new (0, _errors.ValidationError)("NOT_A_POSITIVE_NUMBER" /* NOT_A_POSITIVE_NUMBER */);
|
|
16
19
|
}
|
|
17
20
|
return value;
|
|
18
21
|
};
|
|
19
22
|
const assertUnsignedBigInt = (value) => {
|
|
20
23
|
const number = BigInt(value);
|
|
21
24
|
if (number < 0) {
|
|
22
|
-
throw new
|
|
25
|
+
throw new (0, _errors.ValidationError)("NOT_AN_UNSIGNED_BIGINT" /* NOT_AN_UNSIGNED_BIGINT */);
|
|
23
26
|
}
|
|
24
27
|
return number;
|
|
25
28
|
};
|
|
@@ -28,5 +31,7 @@ const assertUnsignedBigInt = (value) => {
|
|
|
28
31
|
|
|
29
32
|
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
exports.ValidationErrors = ValidationErrors; exports.assertNotEmptyString = assertNotEmptyString; exports.assertPositiveNumber = assertPositiveNumber; exports.assertUnsignedBigInt = assertUnsignedBigInt; exports.isNumber = isNumber; exports.isString = isString;
|
|
32
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/validation/index.ts"],"names":["ValidationErrors"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/validation/index.ts"],"names":["ValidationErrors"],"mappings":"AAAA,SAAS,uBAAuB;AAEzB,IAAW,mBAAX,kBAAWA,sBAAX;AACL,EAAAA,kBAAA,2BAAwB;AACxB,EAAAA,kBAAA,2BAAwB;AACxB,EAAAA,kBAAA,4BAAyB;AAHT,SAAAA;AAAA,GAAA;AAMX,MAAM,WAAW,CAAC,QACvB,OAAO,QAAQ,YAAY,QAAQ;AAE9B,MAAM,WAAW,CAAC,QACvB,OAAO,QAAQ;AAEV,MAAM,uBAAuB,CAAC,UAA2B;AAC9D,MAAI,CAAC,SAAS,KAAK,KAAK,MAAM,WAAW,GAAG;AAC1C,UAAM,IAAI,gBAAgB,mDAAsC;AAAA,EAClE;AACA,SAAO;AACT;AAEO,MAAM,uBAAuB,CAAC,UAA2B;AAC9D,MAAI,CAAC,SAAS,KAAK,KAAK,SAAS,GAAG;AAClC,UAAM,IAAI,gBAAgB,mDAAsC;AAAA,EAClE;AACA,SAAO;AACT;AAEO,MAAM,uBAAuB,CAAC,UAA0B;AAC7D,QAAM,SAAS,OAAO,KAAK;AAC3B,MAAI,SAAS,GAAG;AACd,UAAM,IAAI,gBAAgB,qDAAuC;AAAA,EACnE;AACA,SAAO;AACT","sourcesContent":["import { ValidationError } from '../errors';\n\nexport const enum ValidationErrors {\n NOT_A_NONEMPTY_STRING = 'NOT_A_NONEMPTY_STRING',\n NOT_A_POSITIVE_NUMBER = 'NOT_A_POSITIVE_NUMBER',\n NOT_AN_UNSIGNED_BIGINT = 'NOT_AN_UNSIGNED_BIGINT',\n}\n\nexport const isNumber = (val: unknown): val is number =>\n typeof val === 'number' && val === val;\n\nexport const isString = (val: unknown): val is string =>\n typeof val === 'string';\n\nexport const assertNotEmptyString = (value: unknown): string => {\n if (!isString(value) || value.length === 0) {\n throw new ValidationError(ValidationErrors.NOT_A_NONEMPTY_STRING);\n }\n return value;\n};\n\nexport const assertPositiveNumber = (value: unknown): number => {\n if (!isNumber(value) || value <= 0) {\n throw new ValidationError(ValidationErrors.NOT_A_POSITIVE_NUMBER);\n }\n return value;\n};\n\nexport const assertUnsignedBigInt = (value: string): bigint => {\n const number = BigInt(value);\n if (number < 0) {\n throw new ValidationError(ValidationErrors.NOT_AN_UNSIGNED_BIGINT);\n }\n return number;\n};\n"]}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
+
import { ValidationError } from "../errors";
|
|
1
2
|
var ValidationErrors = /* @__PURE__ */ ((ValidationErrors2) => {
|
|
2
3
|
ValidationErrors2["NOT_A_NONEMPTY_STRING"] = "NOT_A_NONEMPTY_STRING";
|
|
3
4
|
ValidationErrors2["NOT_A_POSITIVE_NUMBER"] = "NOT_A_POSITIVE_NUMBER";
|
|
4
5
|
ValidationErrors2["NOT_AN_UNSIGNED_BIGINT"] = "NOT_AN_UNSIGNED_BIGINT";
|
|
5
6
|
return ValidationErrors2;
|
|
6
7
|
})(ValidationErrors || {});
|
|
8
|
+
const isNumber = (val) => typeof val === "number" && val === val;
|
|
9
|
+
const isString = (val) => typeof val === "string";
|
|
7
10
|
const assertNotEmptyString = (value) => {
|
|
8
|
-
if (
|
|
9
|
-
throw new
|
|
11
|
+
if (!isString(value) || value.length === 0) {
|
|
12
|
+
throw new ValidationError("NOT_A_NONEMPTY_STRING" /* NOT_A_NONEMPTY_STRING */);
|
|
10
13
|
}
|
|
11
14
|
return value;
|
|
12
15
|
};
|
|
13
16
|
const assertPositiveNumber = (value) => {
|
|
14
|
-
if (
|
|
15
|
-
throw new
|
|
17
|
+
if (!isNumber(value) || value <= 0) {
|
|
18
|
+
throw new ValidationError("NOT_A_POSITIVE_NUMBER" /* NOT_A_POSITIVE_NUMBER */);
|
|
16
19
|
}
|
|
17
20
|
return value;
|
|
18
21
|
};
|
|
19
22
|
const assertUnsignedBigInt = (value) => {
|
|
20
23
|
const number = BigInt(value);
|
|
21
24
|
if (number < 0) {
|
|
22
|
-
throw new
|
|
25
|
+
throw new ValidationError("NOT_AN_UNSIGNED_BIGINT" /* NOT_AN_UNSIGNED_BIGINT */);
|
|
23
26
|
}
|
|
24
27
|
return number;
|
|
25
28
|
};
|
|
@@ -27,6 +30,8 @@ export {
|
|
|
27
30
|
ValidationErrors,
|
|
28
31
|
assertNotEmptyString,
|
|
29
32
|
assertPositiveNumber,
|
|
30
|
-
assertUnsignedBigInt
|
|
33
|
+
assertUnsignedBigInt,
|
|
34
|
+
isNumber,
|
|
35
|
+
isString
|
|
31
36
|
};
|
|
32
37
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/validation/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/validation/index.ts"],"sourcesContent":["import { ValidationError } from '../errors';\n\nexport const enum ValidationErrors {\n NOT_A_NONEMPTY_STRING = 'NOT_A_NONEMPTY_STRING',\n NOT_A_POSITIVE_NUMBER = 'NOT_A_POSITIVE_NUMBER',\n NOT_AN_UNSIGNED_BIGINT = 'NOT_AN_UNSIGNED_BIGINT',\n}\n\nexport const isNumber = (val: unknown): val is number =>\n typeof val === 'number' && val === val;\n\nexport const isString = (val: unknown): val is string =>\n typeof val === 'string';\n\nexport const assertNotEmptyString = (value: unknown): string => {\n if (!isString(value) || value.length === 0) {\n throw new ValidationError(ValidationErrors.NOT_A_NONEMPTY_STRING);\n }\n return value;\n};\n\nexport const assertPositiveNumber = (value: unknown): number => {\n if (!isNumber(value) || value <= 0) {\n throw new ValidationError(ValidationErrors.NOT_A_POSITIVE_NUMBER);\n }\n return value;\n};\n\nexport const assertUnsignedBigInt = (value: string): bigint => {\n const number = BigInt(value);\n if (number < 0) {\n throw new ValidationError(ValidationErrors.NOT_AN_UNSIGNED_BIGINT);\n }\n return number;\n};\n"],"mappings":"AAAA,SAAS,uBAAuB;AAEzB,IAAW,mBAAX,kBAAWA,sBAAX;AACL,EAAAA,kBAAA,2BAAwB;AACxB,EAAAA,kBAAA,2BAAwB;AACxB,EAAAA,kBAAA,4BAAyB;AAHT,SAAAA;AAAA,GAAA;AAMX,MAAM,WAAW,CAAC,QACvB,OAAO,QAAQ,YAAY,QAAQ;AAE9B,MAAM,WAAW,CAAC,QACvB,OAAO,QAAQ;AAEV,MAAM,uBAAuB,CAAC,UAA2B;AAC9D,MAAI,CAAC,SAAS,KAAK,KAAK,MAAM,WAAW,GAAG;AAC1C,UAAM,IAAI,gBAAgB,mDAAsC;AAAA,EAClE;AACA,SAAO;AACT;AAEO,MAAM,uBAAuB,CAAC,UAA2B;AAC9D,MAAI,CAAC,SAAS,KAAK,KAAK,SAAS,GAAG;AAClC,UAAM,IAAI,gBAAgB,mDAAsC;AAAA,EAClE;AACA,SAAO;AACT;AAEO,MAAM,uBAAuB,CAAC,UAA0B;AAC7D,QAAM,SAAS,OAAO,KAAK;AAC3B,MAAI,SAAS,GAAG;AACd,UAAM,IAAI,gBAAgB,qDAAuC;AAAA,EACnE;AACA,SAAO;AACT;","names":["ValidationErrors"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _strict = require('node:assert/strict'); var _strict2 = _interopRequireDefault(_strict);
|
|
2
|
+
var _nodetest = require('node:test'); var _nodetest2 = _interopRequireDefault(_nodetest);
|
|
3
|
+
var _index = require('./index');
|
|
4
|
+
_nodetest.describe.call(void 0, "Validation", () => {
|
|
5
|
+
_nodetest.describe.call(void 0, "assertNotEmptyString", () => {
|
|
6
|
+
_nodetest2.default.call(void 0, "should throw an error if the value is an empty string", () => {
|
|
7
|
+
const value = "";
|
|
8
|
+
const invalidAction = () => _index.assertNotEmptyString.call(void 0, value);
|
|
9
|
+
_strict2.default.throws(invalidAction);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=validation.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/validation/validation.spec.ts"],"names":[],"mappings":"AACA,OAAO,YAAY;AACnB,OAAO,QAAQ,gBAAgB;AAC/B,SAAS,4BAA4B;AAErC,SAAS,cAAc,MAAM;AAC3B,WAAS,wBAAwB,MAAM;AACrC,SAAK,yDAAyD,MAAM;AAElE,YAAM,QAAQ;AAGd,YAAM,gBAAgB,MAAM,qBAAqB,KAAK;AAGtD,aAAO,OAAO,aAAa;AAAA,IAC7B,CAAC;AAAA,EACH,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-floating-promises */\nimport assert from 'node:assert/strict';\nimport test, { describe } from 'node:test';\nimport { assertNotEmptyString } from './index';\n\ndescribe('Validation', () => {\n describe('assertNotEmptyString', () => {\n test('should throw an error if the value is an empty string', () => {\n // Arrange\n const value = '';\n\n // Act\n const invalidAction = () => assertNotEmptyString(value);\n\n // Assert\n assert.throws(invalidAction);\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test, { describe } from "node:test";
|
|
3
|
+
import { assertNotEmptyString } from "./index";
|
|
4
|
+
describe("Validation", () => {
|
|
5
|
+
describe("assertNotEmptyString", () => {
|
|
6
|
+
test("should throw an error if the value is an empty string", () => {
|
|
7
|
+
const value = "";
|
|
8
|
+
const invalidAction = () => assertNotEmptyString(value);
|
|
9
|
+
assert.throws(invalidAction);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=validation.spec.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/validation/validation.spec.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-floating-promises */\nimport assert from 'node:assert/strict';\nimport test, { describe } from 'node:test';\nimport { assertNotEmptyString } from './index';\n\ndescribe('Validation', () => {\n describe('assertNotEmptyString', () => {\n test('should throw an error if the value is an empty string', () => {\n // Arrange\n const value = '';\n\n // Act\n const invalidAction = () => assertNotEmptyString(value);\n\n // Assert\n assert.throws(invalidAction);\n });\n });\n});\n"],"mappings":"AACA,OAAO,YAAY;AACnB,OAAO,QAAQ,gBAAgB;AAC/B,SAAS,4BAA4B;AAErC,SAAS,cAAc,MAAM;AAC3B,WAAS,wBAAwB,MAAM;AACrC,SAAK,yDAAyD,MAAM;AAElE,YAAM,QAAQ;AAGd,YAAM,gBAAgB,MAAM,qBAAqB,KAAK;AAGtD,aAAO,OAAO,aAAa;AAAA,IAC7B,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@event-driven-io/emmett",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Emmett - Event Sourcing development made simple",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"fix:prettier": "prettier --write \"**/**/!(*.d).{ts,json,md}\"",
|
|
14
14
|
"fix:eslint": "eslint **/*.ts --fix",
|
|
15
15
|
"test": "run-s test:unit test:int test:e2e",
|
|
16
|
-
"test:unit": "
|
|
17
|
-
"test:int": "
|
|
18
|
-
"test:e2e": "
|
|
19
|
-
"test:watch": "
|
|
20
|
-
"test:unit:watch": "
|
|
21
|
-
"test:int:watch": "
|
|
22
|
-
"test:e2e:watch": "
|
|
16
|
+
"test:unit": "glob -c \"node --import tsx --test\" **/*.unit.spec.ts",
|
|
17
|
+
"test:int": "glob -c \"node --import tsx --test\" **/*.int.spec.ts",
|
|
18
|
+
"test:e2e": "glob -c \"node --import tsx --test\" **/*.e2e.spec.ts",
|
|
19
|
+
"test:watch": "node --import tsx --test --watch",
|
|
20
|
+
"test:unit:watch": "glob -c \"node --import tsx --test --watch\" **/*.unit.spec.ts",
|
|
21
|
+
"test:int:watch": "glob -c \"node --import tsx --test --watch\" **/*.int.spec.ts",
|
|
22
|
+
"test:e2e:watch": "glob -c \"node --import tsx --test --watch\" **/*.e2e.spec.ts"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
@@ -38,5 +38,9 @@
|
|
|
38
38
|
"types": "./dist/index.d.ts",
|
|
39
39
|
"files": [
|
|
40
40
|
"dist"
|
|
41
|
-
]
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"uuid": "9.0.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {}
|
|
42
46
|
}
|