@autofleet/sequelize-utils 5.2.4 → 5.2.6

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.
@@ -11,10 +11,6 @@ const httpBasedTransaction = (sequelize, req, res, cb) => {
11
11
  throw new Error(abortErrorText);
12
12
  }
13
13
  return sequelize.transaction(async (transaction) => {
14
- // https://github.com/nodejs/node/blob/e46c680bf2b211bbd52cf959ca17ee98c7f657f5/test/parallel/test-http-aborted.js#L9
15
- // 2023-04-13: Node.js 16.0.0
16
- // Added also the `res.writableFinished` check, because it seems that the socket is not destroyed when the request is aborted, but the response is not finished.
17
- // https://github.com/Jimbly/http-proxy-node16/commit/ba0c414cd03799e357c5d867c11dea06a9c34ec8#diff-b2d1e3b7c5f3b424a0af7971c582c822fd25a5ea279040ef6dc93fc4b2cf619dR151
18
14
  const rollback = async () => {
19
15
  (0, common_1.debugLog)(abortErrorText);
20
16
  if (aborted)
@@ -7,7 +7,6 @@ const events_1 = __importDefault(require("./events"));
7
7
  const logger_1 = __importDefault(require("./logger"));
8
8
  const runAfterTransactionCommits_1 = __importDefault(require("./runAfterTransactionCommits"));
9
9
  const isDate = (input) => input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
10
- // eslint-disable-next-line @typescript-eslint/ban-types
11
10
  const formatDatesInObject = (obj) => {
12
11
  const newObj = { ...obj };
13
12
  Object.entries(newObj).filter(([, value]) => isDate(value)).forEach(([key, value]) => {
@@ -16,7 +15,7 @@ const formatDatesInObject = (obj) => {
16
15
  return newObj;
17
16
  };
18
17
  const addModelEventHooks = (sequelize, modelTableMapping) => {
19
- const updateEventToDimTable = async (object, isDelete = false) => {
18
+ const updateEventToDimTable = (object, isDelete = false) => {
20
19
  try {
21
20
  const objectToSend = object.get();
22
21
  if (isDelete) {
@@ -25,11 +24,12 @@ const addModelEventHooks = (sequelize, modelTableMapping) => {
25
24
  const tableName = modelTableMapping[object.constructor.name]?.tableName;
26
25
  const eventVersion = '1';
27
26
  const objectToSendFormatted = formatDatesInObject(objectToSend);
28
- if (tableName) {
29
- await events_1.default.sendObject(tableName, eventVersion, objectToSendFormatted,
30
- // @ts-expect-error the rawAttributes is typed as static, while it actually is on the instance level.
31
- Object.keys(object.rawAttributes));
27
+ if (!tableName) {
28
+ return;
32
29
  }
30
+ events_1.default.sendObject(tableName, eventVersion, objectToSendFormatted, Object.keys(object.rawAttributes)).catch((e) => {
31
+ logger_1.default.error('sendObject error', { tableName, eventVersion, e });
32
+ });
33
33
  }
34
34
  catch (e) {
35
35
  logger_1.default.error('dimTables error', { e });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sequelize-utils",
3
- "version": "5.2.4",
3
+ "version": "5.2.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -16,7 +16,7 @@
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
18
  "@autofleet/errors": "^1.2.3",
19
- "@autofleet/events": "^3.0.7",
19
+ "@autofleet/events": "^4.0.0",
20
20
  "@autofleet/network": "^1.3.7",
21
21
  "debug": "^4.3.2"
22
22
  },
@@ -19,7 +19,7 @@ const formatDatesInObject = (obj: object) => {
19
19
  };
20
20
 
21
21
  const addModelEventHooks = (sequelize: Sequelize, modelTableMapping: ModelMapping): void => {
22
- const updateEventToDimTable = async (object: Model, isDelete = false) => {
22
+ const updateEventToDimTable = (object: Model, isDelete = false) => {
23
23
  try {
24
24
  const objectToSend = object.get();
25
25
  if (isDelete) {
@@ -28,15 +28,18 @@ const addModelEventHooks = (sequelize: Sequelize, modelTableMapping: ModelMappin
28
28
  const tableName = modelTableMapping[object.constructor.name]?.tableName;
29
29
  const eventVersion = '1';
30
30
  const objectToSendFormatted = formatDatesInObject(objectToSend);
31
- if (tableName) {
32
- await events.sendObject(
33
- tableName,
34
- eventVersion,
35
- objectToSendFormatted,
36
- // @ts-expect-error the rawAttributes is typed as static, while it actually is on the instance level.
37
- Object.keys(object.rawAttributes),
38
- );
31
+ if (!tableName) {
32
+ return;
39
33
  }
34
+ events.sendObject(
35
+ tableName,
36
+ eventVersion,
37
+ objectToSendFormatted,
38
+ // @ts-expect-error the rawAttributes is typed as static, while it actually is on the instance level.
39
+ Object.keys(object.rawAttributes),
40
+ ).catch((e) => {
41
+ logger.error('sendObject error', { tableName, eventVersion, e });
42
+ });
40
43
  } catch (e) {
41
44
  logger.error('dimTables error', { e });
42
45
  }
package/tsconfig.json CHANGED
@@ -6,7 +6,8 @@
6
6
  "outDir": "./dist",
7
7
  "strict": false,
8
8
  "esModuleInterop": true,
9
- "skipLibCheck": true
9
+ "skipLibCheck": true,
10
+ "removeComments": true,
10
11
  },
11
12
  "include": ["src/**/*"],
12
13
  "exclude": [