@autofleet/shtinker 1.1.3 → 1.1.4-beta-2

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.
@@ -32,37 +32,27 @@ const getChangedFields = (instance, options) => {
32
32
  class AuditLogger {
33
33
  constructor(options) {
34
34
  this.rabbit = options.rabbit;
35
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
36
+ // @ts-ignore
35
37
  this.sequelize = options.sequelize;
36
38
  this.logger = options.logger;
37
39
  }
38
40
  registerHooks() {
39
41
  Object.entries(this.sequelize.models).forEach(([modelName, modelType]) => {
40
42
  modelType.addHook('afterSave', (instance, options) => __awaiter(this, void 0, void 0, function* () {
41
- try {
42
- const auditContext = getAuditContext();
43
- logger_1.default.info('shtinker afterSave', {
44
- auditContext,
45
- modelName,
46
- instance,
47
- options,
48
- changedProperties: getChangedFields(instance, options),
49
- });
50
- if (auditContext) {
51
- const changedProperties = getChangedFields(instance, options);
52
- const payload = {
53
- entityType: modelName,
54
- entityId: instance.id,
55
- rows: changedProperties.map((property) => ({
56
- property,
57
- previousValue: instance.previous(property),
58
- newValue: instance.get(property),
59
- })),
60
- };
61
- this.sendAuditLogRows(payload);
62
- }
63
- }
64
- catch (error) {
65
- logger_1.default.error('Failed to send audit log context', err);
43
+ const auditContext = getAuditContext();
44
+ if (auditContext) {
45
+ const changedProperties = getChangedFields(instance, options);
46
+ const payload = {
47
+ entityType: modelName,
48
+ entityId: instance.id,
49
+ rows: changedProperties.map((property) => ({
50
+ property,
51
+ previousValue: instance.previous(property),
52
+ newValue: instance.get(property),
53
+ })),
54
+ };
55
+ this.sendAuditLogRows(payload);
66
56
  }
67
57
  }));
68
58
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/shtinker",
3
- "version": "1.1.3",
3
+ "version": "1.1.4-beta-2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  import { getCurrentPayload as getCurrentTrace } from '@autofleet/zehut';
2
+ // eslint-disable-next-line import/no-unresolved
2
3
  import { Sequelize } from 'sequelize';
3
4
 
4
5
  import { AuditLogPayload, AuditLoggerOptions, AuditLogContext } from './types';
@@ -30,6 +31,8 @@ class AuditLogger {
30
31
 
31
32
  constructor(options: AuditLoggerOptions) {
32
33
  this.rabbit = options.rabbit;
34
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
35
+ // @ts-ignore
33
36
  this.sequelize = options.sequelize;
34
37
  this.logger = options.logger;
35
38
  }
@@ -53,7 +56,7 @@ class AuditLogger {
53
56
  this.sendAuditLogRows(payload);
54
57
  }
55
58
  } catch (error) {
56
- logger.error('Failed to send audit log context', error);
59
+ logger.error('Failed to send audit log rows', error);
57
60
  }
58
61
  });
59
62
  });
package/tsconfig.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "declaration": true,
6
6
  "outDir": "./dist",
7
7
  "esModuleInterop": true,
8
+ "skipLibCheck": true,
8
9
  "experimentalDecorators": true,
9
10
  "emitDecoratorMetadata": true
10
11
  },