@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 CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/eventStore/postgreSQLEventStore.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// src/eventStore/postgreSQLEventStore.ts
2
2
 
3
3
 
4
4
  var _dumbo = require('@event-driven-io/dumbo');
5
5
 
6
- // ../emmett/dist/chunk-O2VMBOV4.js
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";
@@ -11,29 +11,39 @@ var isErrorConstructor = (expect) => {
11
11
  return typeof expect === "function" && expect.prototype && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
12
12
  expect.prototype.constructor === expect;
13
13
  };
14
- var EmmettError = class _EmmettError extends Error {
14
+ var EmmettError = (_class = class _EmmettError extends Error {
15
+ static __initStatic() {this.Codes = {
16
+ ValidationError: 400,
17
+ IllegalStateError: 403,
18
+ NotFoundError: 404,
19
+ ConcurrencyError: 412,
20
+ InternalServerError: 500
21
+ }}
15
22
 
16
23
  constructor(options) {
17
- const errorCode = options && typeof options === "object" && "errorCode" in options ? options.errorCode : isNumber(options) ? options : 500;
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 instanceof _EmmettError) {
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 : 500,
35
+ errorCode: "errorCode" in error && error.errorCode !== void 0 && error.errorCode !== null ? error.errorCode : _EmmettError.Codes.InternalServerError,
29
36
  message: _nullishCoalesce(error.message, () => ( "An unknown error occurred"))
30
37
  });
31
38
  }
32
- };
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
+ }
42
+ }, _class.__initStatic(), _class);
33
43
  var ConcurrencyError = class _ConcurrencyError extends EmmettError {
34
44
  constructor(current, expected, message) {
35
45
  super({
36
- errorCode: 412,
46
+ errorCode: EmmettError.Codes.ConcurrencyError,
37
47
  message: _nullishCoalesce(message, () => ( `Expected version ${expected.toString()} does not match current ${_optionalChain([current, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3()])}`))
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 && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
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