@autofleet/shtinker 1.1.1 → 1.1.3-beta.1

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.
@@ -38,19 +38,24 @@ class AuditLogger {
38
38
  registerHooks() {
39
39
  Object.entries(this.sequelize.models).forEach(([modelName, modelType]) => {
40
40
  modelType.addHook('afterSave', (instance, options) => __awaiter(this, void 0, void 0, function* () {
41
- const auditContext = getAuditContext();
42
- if (auditContext) {
43
- const changedProperties = getChangedFields(instance, options);
44
- const payload = {
45
- entityType: modelName,
46
- entityId: instance.id,
47
- rows: changedProperties.map((property) => ({
48
- property,
49
- previousValue: instance.previous(property),
50
- newValue: instance.get(property),
51
- })),
52
- };
53
- this.sendAuditLogRows(payload);
41
+ try {
42
+ const auditContext = getAuditContext();
43
+ if (auditContext) {
44
+ const changedProperties = getChangedFields(instance, options);
45
+ const payload = {
46
+ entityType: modelName,
47
+ entityId: instance.id,
48
+ rows: changedProperties.map((property) => ({
49
+ property,
50
+ previousValue: instance.previous(property),
51
+ newValue: instance.get(property),
52
+ })),
53
+ };
54
+ this.sendAuditLogRows(payload);
55
+ }
56
+ }
57
+ catch (error) {
58
+ logger_1.default.error('Failed to send audit log context', error);
54
59
  }
55
60
  }));
56
61
  });
package/dist/types.d.ts CHANGED
@@ -35,6 +35,8 @@ export declare enum Action {
35
35
  REASSIGN = "reassign",
36
36
  DISPATCH = "dispatch",
37
37
  BULK_DISPATCH = "bulk-dispatch",
38
+ BULK_UPSERT = "bulk-upsert",
39
+ UPSERT = "upsert",
38
40
  JOIN = "join",
39
41
  MOVE = "move"
40
42
  }
package/dist/types.js CHANGED
@@ -15,6 +15,8 @@ var Action;
15
15
  Action["REASSIGN"] = "reassign";
16
16
  Action["DISPATCH"] = "dispatch";
17
17
  Action["BULK_DISPATCH"] = "bulk-dispatch";
18
+ Action["BULK_UPSERT"] = "bulk-upsert";
19
+ Action["UPSERT"] = "upsert";
18
20
  Action["JOIN"] = "join";
19
21
  Action["MOVE"] = "move";
20
22
  })(Action = exports.Action || (exports.Action = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/shtinker",
3
- "version": "1.1.1",
3
+ "version": "1.1.3-beta.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -37,19 +37,23 @@ class AuditLogger {
37
37
  registerHooks(): void {
38
38
  Object.entries(this.sequelize.models).forEach(([modelName, modelType]) => {
39
39
  modelType.addHook('afterSave', async (instance: any, options: any) => {
40
- const auditContext = getAuditContext();
41
- if (auditContext) {
42
- const changedProperties = getChangedFields(instance, options);
43
- const payload: AuditLogPayload = {
44
- entityType: modelName,
45
- entityId: instance.id,
46
- rows: changedProperties.map((property: string) => ({
47
- property,
48
- previousValue: instance.previous(property),
49
- newValue: instance.get(property),
50
- })),
51
- };
52
- this.sendAuditLogRows(payload);
40
+ try {
41
+ const auditContext = getAuditContext();
42
+ if (auditContext) {
43
+ const changedProperties = getChangedFields(instance, options);
44
+ const payload: AuditLogPayload = {
45
+ entityType: modelName,
46
+ entityId: instance.id,
47
+ rows: changedProperties.map((property: string) => ({
48
+ property,
49
+ previousValue: instance.previous(property),
50
+ newValue: instance.get(property),
51
+ })),
52
+ };
53
+ this.sendAuditLogRows(payload);
54
+ }
55
+ } catch (error) {
56
+ logger.error('Failed to send audit log context', error);
53
57
  }
54
58
  });
55
59
  });
package/src/types.ts CHANGED
@@ -41,6 +41,8 @@ export enum Action {
41
41
  REASSIGN = 'reassign',
42
42
  DISPATCH = 'dispatch',
43
43
  BULK_DISPATCH = 'bulk-dispatch',
44
+ BULK_UPSERT = 'bulk-upsert',
45
+ UPSERT = 'upsert',
44
46
  JOIN = 'join',
45
47
  MOVE = 'move',
46
48
  }