@event-driven-io/emmett-postgresql 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +19 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
dumbo as dumbo4
|
|
4
4
|
} from "@event-driven-io/dumbo";
|
|
5
5
|
|
|
6
|
-
// ../emmett/dist/chunk-
|
|
6
|
+
// ../emmett/dist/chunk-AZDDB5SF.js
|
|
7
7
|
var isNumber = (val) => typeof val === "number" && val === val;
|
|
8
8
|
var isBigint = (val) => typeof val === "bigint" && val === val;
|
|
9
9
|
var isString = (val) => typeof val === "string";
|
|
@@ -12,28 +12,38 @@ var isErrorConstructor = (expect) => {
|
|
|
12
12
|
expect.prototype.constructor === expect;
|
|
13
13
|
};
|
|
14
14
|
var EmmettError = class _EmmettError extends Error {
|
|
15
|
+
static Codes = {
|
|
16
|
+
ValidationError: 400,
|
|
17
|
+
IllegalStateError: 403,
|
|
18
|
+
NotFoundError: 404,
|
|
19
|
+
ConcurrencyError: 412,
|
|
20
|
+
InternalServerError: 500
|
|
21
|
+
};
|
|
15
22
|
errorCode;
|
|
16
23
|
constructor(options) {
|
|
17
|
-
const errorCode = options && typeof options === "object" && "errorCode" in options ? options.errorCode : isNumber(options) ? options :
|
|
24
|
+
const errorCode = options && typeof options === "object" && "errorCode" in options ? options.errorCode : isNumber(options) ? options : _EmmettError.Codes.InternalServerError;
|
|
18
25
|
const message = options && typeof options === "object" && "message" in options ? options.message : isString(options) ? options : `Error with status code '${errorCode}' ocurred during Emmett processing`;
|
|
19
26
|
super(message);
|
|
20
27
|
this.errorCode = errorCode;
|
|
21
28
|
Object.setPrototypeOf(this, _EmmettError.prototype);
|
|
22
29
|
}
|
|
23
30
|
static mapFrom(error) {
|
|
24
|
-
if (error
|
|
31
|
+
if (_EmmettError.isInstanceOf(error)) {
|
|
25
32
|
return error;
|
|
26
33
|
}
|
|
27
34
|
return new _EmmettError({
|
|
28
|
-
errorCode: "errorCode" in error && error.errorCode !== void 0 && error.errorCode !== null ? error.errorCode :
|
|
35
|
+
errorCode: "errorCode" in error && error.errorCode !== void 0 && error.errorCode !== null ? error.errorCode : _EmmettError.Codes.InternalServerError,
|
|
29
36
|
message: error.message ?? "An unknown error occurred"
|
|
30
37
|
});
|
|
31
38
|
}
|
|
39
|
+
static isInstanceOf(error, errorCode) {
|
|
40
|
+
return typeof error === "object" && error !== null && "errorCode" in error && isNumber(error.errorCode) && (errorCode === void 0 || error.errorCode === errorCode);
|
|
41
|
+
}
|
|
32
42
|
};
|
|
33
43
|
var ConcurrencyError = class _ConcurrencyError extends EmmettError {
|
|
34
44
|
constructor(current, expected, message) {
|
|
35
45
|
super({
|
|
36
|
-
errorCode:
|
|
46
|
+
errorCode: EmmettError.Codes.ConcurrencyError,
|
|
37
47
|
message: message ?? `Expected version ${expected.toString()} does not match current ${current?.toString()}`
|
|
38
48
|
});
|
|
39
49
|
this.current = current;
|
|
@@ -405,8 +415,7 @@ var assertThatArray = (array) => {
|
|
|
405
415
|
};
|
|
406
416
|
};
|
|
407
417
|
var getCheckpoint = (message2) => {
|
|
408
|
-
return "checkpoint" in message2.metadata
|
|
409
|
-
isBigint(message2.metadata.checkpoint) ? (
|
|
418
|
+
return "checkpoint" in message2.metadata ? (
|
|
410
419
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
411
420
|
message2.metadata.checkpoint
|
|
412
421
|
) : "globalPosition" in message2.metadata && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|