@autofleet/shtinker 0.0.7 → 0.0.9-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.
@@ -0,0 +1,12 @@
1
+ export const testEnvironment: string;
2
+ export const roots: string[];
3
+ export const transform: {
4
+ '^.+\\.tsx?$': string;
5
+ };
6
+ export const testRegex: string;
7
+ export const moduleFileExtensions: string[];
8
+ export namespace coverageThreshold {
9
+ namespace global {
10
+ const lines: number;
11
+ }
12
+ }
@@ -0,0 +1,6 @@
1
+ import { Router } from 'express';
2
+ declare const _default: ({ router, entiyScopedModelMap, }: {
3
+ router: Router;
4
+ entiyScopedModelMap: Array<any>;
5
+ }) => Promise<void>;
6
+ export default _default;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const errors_1 = require("@autofleet/errors");
16
+ const logger_1 = __importDefault(require("./logger"));
17
+ const audit_ms_1 = __importDefault(require("./audit-ms"));
18
+ exports.default = ({ router, entiyScopedModelMap, }) => __awaiter(void 0, void 0, void 0, function* () {
19
+ logger_1.default.info('*** SEPHI got here', { entiyScopedModelMap });
20
+ if (entiyScopedModelMap) {
21
+ Object.entries(entiyScopedModelMap).forEach(([entity, ScopedModel]) => {
22
+ router.get(`${entity}/:id/audit`, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
23
+ try {
24
+ const { id } = req.params;
25
+ const entityData = yield ScopedModel.findByPk(id);
26
+ if (!entityData) {
27
+ return (0, errors_1.handleError)(new errors_1.ResourceNotFoundError(), res);
28
+ }
29
+ const auditData = audit_ms_1.default.getByEntityId(id);
30
+ return res.json(auditData);
31
+ }
32
+ catch (err) {
33
+ return (0, errors_1.handleError)(new errors_1.UnexpectedError(err), res);
34
+ }
35
+ }));
36
+ });
37
+ }
38
+ });
@@ -0,0 +1,11 @@
1
+ import { AuditLogPayload, AuditLoggerOptions, AuditLogContext } from './types';
2
+ declare class AuditLogger {
3
+ private rabbit;
4
+ private sequelize;
5
+ private logger;
6
+ constructor(options: AuditLoggerOptions);
7
+ registerHooks(): void;
8
+ sendAuditLogContext(context: AuditLogContext): Promise<void>;
9
+ sendAuditLogRows(payload: AuditLogPayload): Promise<void>;
10
+ }
11
+ export default AuditLogger;
@@ -8,25 +8,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  const zehut_1 = require("@autofleet/zehut");
13
16
  const const_1 = require("./const");
17
+ const logger_1 = __importDefault(require("./logger"));
14
18
  const getAuditContext = () => {
15
19
  var _a;
16
20
  const currentTrace = (0, zehut_1.getCurrentPayload)();
17
21
  const auditContext = (_a = currentTrace === null || currentTrace === void 0 ? void 0 : currentTrace.context) === null || _a === void 0 ? void 0 : _a.get(const_1.AUDIT_LOG_CONTEXT_KEY);
22
+ logger_1.default.info('*** SEPHI getAuditContext', { currentTrace, auditContext });
18
23
  return auditContext;
19
24
  };
20
25
  class AuditLogger {
21
26
  constructor(options) {
22
27
  this.rabbit = options.rabbit;
23
28
  this.sequelize = options.sequelize;
29
+ this.logger = options.logger;
24
30
  }
25
- addModelHooks() {
31
+ registerHooks() {
26
32
  Object.entries(this.sequelize.models).forEach(([modelName, modelType]) => {
27
33
  modelType.addHook('afterSave', (instance) => __awaiter(this, void 0, void 0, function* () {
28
34
  const auditContext = getAuditContext();
35
+ logger_1.default.info('*** SEPHI after save', { instance, auditContext });
29
36
  if (auditContext) {
37
+ logger_1.default.info('*** SEPHI after save got context', { instance, auditContext });
30
38
  const changedProperties = instance.changed();
31
39
  const payload = {
32
40
  entityType: modelName,
@@ -37,14 +45,32 @@ class AuditLogger {
37
45
  newValue: instance.get(property),
38
46
  })),
39
47
  };
40
- yield this.rabbit.sendToQueue(const_1.AUDIT_LOG_ROWS_QUEUE, payload);
48
+ logger_1.default.info('*** SEPHI after save got context payload', { payload, changedProperties });
49
+ this.sendAuditLogRows(payload);
41
50
  }
42
51
  }));
43
52
  });
44
53
  }
45
- sendAuditLog(context) {
54
+ sendAuditLogContext(context) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ logger_1.default.info('*** SEPHI sendAuditLogContext', { context });
57
+ try {
58
+ yield this.rabbit.sendToQueue(const_1.AUDIT_LOG_CONTEXT_QUEUE, context);
59
+ }
60
+ catch (err) {
61
+ logger_1.default.error('Failed to send audit log context', err);
62
+ }
63
+ });
64
+ }
65
+ sendAuditLogRows(payload) {
46
66
  return __awaiter(this, void 0, void 0, function* () {
47
- yield this.rabbit.sendToQueue(const_1.AUDIT_LOG_CONTEXT_QUEUE, context);
67
+ logger_1.default.info('*** SEPHI sendAuditLogRows', { payload });
68
+ try {
69
+ yield this.rabbit.sendToQueue(const_1.AUDIT_LOG_ROWS_QUEUE, payload);
70
+ }
71
+ catch (err) {
72
+ logger_1.default.error('Failed to send audit log rows', err);
73
+ }
48
74
  });
49
75
  }
50
76
  }
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ getByEntityId: (entityId: string) => any;
3
+ };
4
+ export default _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const Network = __importStar(require("@autofleet/network"));
27
+ const auditMs = new Network({ serviceName: 'AUDIT_MS', timeout: 1000 * 60 });
28
+ const getByEntityId = (entityId) => {
29
+ const { data } = auditMs.get(`api/v1/audit-logs/${entityId}`);
30
+ return data;
31
+ };
32
+ exports.default = {
33
+ getByEntityId,
34
+ };
@@ -1,3 +1,4 @@
1
1
  export declare const AUDIT_LOG_CONTEXT_QUEUE = "audit-log-context";
2
2
  export declare const AUDIT_LOG_ROWS_QUEUE = "audit-log-rows";
3
3
  export declare const AUDIT_LOG_CONTEXT_KEY = "auditLogContext";
4
+ export declare const USER_CONTEXT_KEY = "userObject";
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AUDIT_LOG_CONTEXT_KEY = exports.AUDIT_LOG_ROWS_QUEUE = exports.AUDIT_LOG_CONTEXT_QUEUE = void 0;
3
+ exports.USER_CONTEXT_KEY = exports.AUDIT_LOG_CONTEXT_KEY = exports.AUDIT_LOG_ROWS_QUEUE = exports.AUDIT_LOG_CONTEXT_QUEUE = void 0;
4
4
  exports.AUDIT_LOG_CONTEXT_QUEUE = 'audit-log-context';
5
5
  exports.AUDIT_LOG_ROWS_QUEUE = 'audit-log-rows';
6
6
  exports.AUDIT_LOG_CONTEXT_KEY = 'auditLogContext';
7
+ exports.USER_CONTEXT_KEY = 'userObject';
@@ -1,7 +1,7 @@
1
1
  import AuditLogger from './audit-logger';
2
2
  import { AuditLoggerOptions } from './types';
3
3
  export declare const enableAuditing: (options: AuditLoggerOptions) => void;
4
- export declare const setAuditContext: (entityType: string, entityIdFetcher: (req: any) => any, action: string) => (req: any, res: any, next: any) => Promise<any>;
4
+ export declare const setAuditContext: (entityType: string, entityId: string, action: string) => (req: any, res: any, next: any) => Promise<any>;
5
5
  export * from './types';
6
6
  export * from './const';
7
7
  export default AuditLogger;
@@ -30,26 +30,40 @@ exports.setAuditContext = exports.enableAuditing = void 0;
30
30
  const zehut_1 = require("@autofleet/zehut");
31
31
  const audit_logger_1 = __importDefault(require("./audit-logger"));
32
32
  const const_1 = require("./const");
33
+ const audit_api_1 = __importDefault(require("./audit-api"));
34
+ const logger_1 = __importDefault(require("./logger"));
33
35
  let auditLogger;
36
+ // export let getCurrentTrace: () => any;
34
37
  const enableAuditing = (options) => {
35
38
  auditLogger = new audit_logger_1.default(options);
36
- auditLogger.addModelHooks();
39
+ // getCurrentTrace = options.getCurrentTrace;
40
+ (0, audit_api_1.default)(options);
41
+ auditLogger.registerHooks();
37
42
  };
38
43
  exports.enableAuditing = enableAuditing;
39
- const setAuditContext = (entityType, entityIdFetcher, action) => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
44
+ const setAuditContext = (entityType, entityId, action) => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
40
45
  const currentTrace = (0, zehut_1.getCurrentPayload)();
46
+ logger_1.default.info('*** SEPHI current trace', { currentTrace });
41
47
  if (currentTrace) {
42
- const user = currentTrace.context.get('userObject');
43
- const auditLogContext = {
44
- entityType,
45
- entityId: entityIdFetcher(req),
46
- action,
47
- endpoint: req.url,
48
- method: req.method,
49
- performedBy: user.id,
50
- };
51
- currentTrace.context.set(const_1.AUDIT_LOG_CONTEXT_KEY, auditLogContext);
52
- yield auditLogger.sendAuditLog(auditLogContext);
48
+ try {
49
+ logger_1.default.info('*** SEPHI entered if');
50
+ const user = currentTrace.context.get(const_1.USER_CONTEXT_KEY);
51
+ logger_1.default.info('*** SEPHI user', { user });
52
+ const auditLogContext = {
53
+ entityType,
54
+ entityId,
55
+ action,
56
+ endpoint: req.url,
57
+ method: req.method,
58
+ performedBy: user.id,
59
+ };
60
+ logger_1.default.info('*** SEPHI auditLogContext', { auditLogContext });
61
+ currentTrace.context.set(const_1.AUDIT_LOG_CONTEXT_KEY, auditLogContext);
62
+ yield auditLogger.sendAuditLogContext(auditLogContext);
63
+ }
64
+ catch (err) {
65
+ logger_1.default.error('*** SEPHI something wrong with trace', err);
66
+ }
53
67
  }
54
68
  return next();
55
69
  });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("winston").Logger;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const logger_1 = __importDefault(require("@autofleet/logger"));
7
+ exports.default = (0, logger_1.default)(null);
@@ -3,6 +3,8 @@ import RabbitMq from '@autofleet/rabbit';
3
3
  export type AuditLoggerOptions = {
4
4
  rabbit: RabbitMq;
5
5
  sequelize: Sequelize;
6
+ getCurrentTrace: () => any;
7
+ logger: any;
6
8
  };
7
9
  export interface AuditLogContext {
8
10
  entityType: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/shtinker",
3
- "version": "0.0.7",
3
+ "version": "0.0.9-beta-1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -12,14 +12,18 @@
12
12
  "dev": "nodemon"
13
13
  },
14
14
  "dependencies": {
15
+ "@autofleet/errors": "^1.2.2",
15
16
  "@autofleet/logger": "^2.0.5",
17
+ "@autofleet/network": "^1.4.7",
16
18
  "@autofleet/rabbit": "^2.4.1",
17
19
  "@autofleet/zehut": "^2.0.4",
18
20
  "sequelize-typescript": "^2.1.5"
19
21
  },
20
22
  "devDependencies": {
23
+ "@types/express": "^4.17.17",
21
24
  "@types/jest": "^27.0.9",
22
25
  "@types/node": "^18.11.19",
26
+ "@types/sequelize": "^4.28.14",
23
27
  "@typescript-eslint/eslint-plugin": "^4.8.1",
24
28
  "eslint": "^7.13.0",
25
29
  "eslint-config-airbnb-typescript": "^12.0.0",
@@ -0,0 +1,32 @@
1
+ import { Router } from 'express';
2
+ import { handleError, ResourceNotFoundError, UnexpectedError } from '@autofleet/errors';
3
+ import logger from './logger';
4
+
5
+ import auditMs from './audit-ms';
6
+
7
+ export default async ({
8
+ router,
9
+ entiyScopedModelMap,
10
+ } : {
11
+ router: Router,
12
+ entiyScopedModelMap: Array<any>,
13
+ }): Promise<void> => {
14
+ logger.info('*** SEPHI got here', { entiyScopedModelMap });
15
+ if (entiyScopedModelMap) {
16
+ Object.entries(entiyScopedModelMap).forEach(([entity, ScopedModel]) => {
17
+ router.get(`${entity}/:id/audit`, async (req, res) => {
18
+ try {
19
+ const { id } = req.params;
20
+ const entityData = await ScopedModel.findByPk(id);
21
+ if (!entityData) {
22
+ return handleError(new ResourceNotFoundError(), res);
23
+ }
24
+ const auditData = auditMs.getByEntityId(id);
25
+ return res.json(auditData);
26
+ } catch (err) {
27
+ return handleError(new UnexpectedError(err as Error), res);
28
+ }
29
+ });
30
+ });
31
+ }
32
+ };
@@ -1,10 +1,14 @@
1
1
  import { getCurrentPayload as getCurrentTrace } from '@autofleet/zehut';
2
+ // import { getCurrentTrace } from './index';
2
3
  import { AuditLogPayload, AuditLoggerOptions, AuditLogContext } from './types';
3
4
  import { AUDIT_LOG_CONTEXT_QUEUE, AUDIT_LOG_ROWS_QUEUE, AUDIT_LOG_CONTEXT_KEY } from './const';
4
5
 
6
+ import logger from './logger';
7
+
5
8
  const getAuditContext = () => {
6
9
  const currentTrace = getCurrentTrace();
7
10
  const auditContext = currentTrace?.context?.get(AUDIT_LOG_CONTEXT_KEY);
11
+ logger.info('*** SEPHI getAuditContext', { currentTrace, auditContext });
8
12
  return auditContext;
9
13
  };
10
14
 
@@ -13,16 +17,21 @@ class AuditLogger {
13
17
 
14
18
  private sequelize;
15
19
 
20
+ private logger;
21
+
16
22
  constructor(options: AuditLoggerOptions) {
17
23
  this.rabbit = options.rabbit;
18
24
  this.sequelize = options.sequelize;
25
+ this.logger = options.logger;
19
26
  }
20
27
 
21
- addModelHooks(): void {
28
+ registerHooks(): void {
22
29
  Object.entries(this.sequelize.models).forEach(([modelName, modelType]) => {
23
- modelType.addHook('afterSave', async (instance: any) => {
30
+ (modelType as any).addHook('afterSave', async (instance: any) => {
24
31
  const auditContext = getAuditContext();
32
+ logger.info('*** SEPHI after save', { instance, auditContext });
25
33
  if (auditContext) {
34
+ logger.info('*** SEPHI after save got context', { instance, auditContext });
26
35
  const changedProperties = instance.changed();
27
36
  const payload: AuditLogPayload = {
28
37
  entityType: modelName,
@@ -33,14 +42,29 @@ class AuditLogger {
33
42
  newValue: instance.get(property),
34
43
  })),
35
44
  };
36
- await this.rabbit.sendToQueue(AUDIT_LOG_ROWS_QUEUE, payload);
45
+ logger.info('*** SEPHI after save got context payload', { payload, changedProperties });
46
+ this.sendAuditLogRows(payload);
37
47
  }
38
48
  });
39
49
  });
40
50
  }
41
51
 
42
- async sendAuditLog(context: AuditLogContext): Promise<void> {
43
- await this.rabbit.sendToQueue(AUDIT_LOG_CONTEXT_QUEUE, context);
52
+ async sendAuditLogContext(context: AuditLogContext): Promise<void> {
53
+ logger.info('*** SEPHI sendAuditLogContext', { context });
54
+ try {
55
+ await this.rabbit.sendToQueue(AUDIT_LOG_CONTEXT_QUEUE, context);
56
+ } catch (err) {
57
+ logger.error('Failed to send audit log context', err);
58
+ }
59
+ }
60
+
61
+ async sendAuditLogRows(payload: AuditLogPayload): Promise<void> {
62
+ logger.info('*** SEPHI sendAuditLogRows', { payload });
63
+ try {
64
+ await this.rabbit.sendToQueue(AUDIT_LOG_ROWS_QUEUE, payload);
65
+ } catch (err) {
66
+ logger.error('Failed to send audit log rows', err);
67
+ }
44
68
  }
45
69
  }
46
70
 
@@ -0,0 +1,12 @@
1
+ import * as Network from '@autofleet/network';
2
+
3
+ const auditMs = new Network({ serviceName: 'AUDIT_MS', timeout: 1000 * 60 });
4
+
5
+ const getByEntityId = (entityId: string) => {
6
+ const { data } = auditMs.get(`api/v1/audit-logs/${entityId}`);
7
+ return data;
8
+ };
9
+
10
+ export default {
11
+ getByEntityId,
12
+ };
package/src/const.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export const AUDIT_LOG_CONTEXT_QUEUE = 'audit-log-context';
2
2
  export const AUDIT_LOG_ROWS_QUEUE = 'audit-log-rows';
3
3
  export const AUDIT_LOG_CONTEXT_KEY = 'auditLogContext';
4
+ export const USER_CONTEXT_KEY = 'userObject';
package/src/index.ts CHANGED
@@ -1,33 +1,48 @@
1
1
  import { getCurrentPayload as getCurrentTrace } from '@autofleet/zehut';
2
2
  import AuditLogger from './audit-logger';
3
3
  import { AuditLogContext, AuditLoggerOptions } from './types';
4
- import { AUDIT_LOG_CONTEXT_KEY } from './const';
4
+ import { AUDIT_LOG_CONTEXT_KEY, USER_CONTEXT_KEY } from './const';
5
+ import addAuditApi from './audit-api';
6
+
7
+ import logger from './logger';
5
8
 
6
9
  let auditLogger: AuditLogger;
7
10
 
11
+ // export let getCurrentTrace: () => any;
12
+
8
13
  export const enableAuditing = (options: AuditLoggerOptions) => {
9
14
  auditLogger = new AuditLogger(options);
10
- auditLogger.addModelHooks();
15
+ // getCurrentTrace = options.getCurrentTrace;
16
+ addAuditApi(options as any);
17
+ auditLogger.registerHooks();
11
18
  };
12
19
 
13
20
  export const setAuditContext = (
14
21
  entityType: string,
15
- entityIdFetcher: (req: any) => any,
22
+ entityId: string,
16
23
  action: string,
17
24
  ) => async (req: any, res: any, next: any): Promise<any> => {
18
25
  const currentTrace = getCurrentTrace();
26
+ logger.info('*** SEPHI current trace', { currentTrace });
19
27
  if (currentTrace) {
20
- const user = currentTrace.context.get('userObject');
21
- const auditLogContext: AuditLogContext = {
22
- entityType,
23
- entityId: entityIdFetcher(req),
24
- action,
25
- endpoint: req.url,
26
- method: req.method,
27
- performedBy: user.id,
28
- };
29
- currentTrace.context.set(AUDIT_LOG_CONTEXT_KEY, auditLogContext);
30
- await auditLogger.sendAuditLog(auditLogContext);
28
+ try {
29
+ logger.info('*** SEPHI entered if');
30
+ const user = currentTrace.context.get(USER_CONTEXT_KEY);
31
+ logger.info('*** SEPHI user', { user });
32
+ const auditLogContext: AuditLogContext = {
33
+ entityType,
34
+ entityId,
35
+ action,
36
+ endpoint: req.url,
37
+ method: req.method,
38
+ performedBy: user.id,
39
+ };
40
+ logger.info('*** SEPHI auditLogContext', { auditLogContext });
41
+ currentTrace.context.set(AUDIT_LOG_CONTEXT_KEY, auditLogContext);
42
+ await auditLogger.sendAuditLogContext(auditLogContext);
43
+ } catch (err) {
44
+ logger.error('*** SEPHI something wrong with trace', err);
45
+ }
31
46
  }
32
47
  return next();
33
48
  };
package/src/logger.ts ADDED
@@ -0,0 +1,3 @@
1
+ import Logger from '@autofleet/logger';
2
+
3
+ export default Logger(null);
package/src/types.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import { Sequelize } from 'sequelize-typescript';
2
2
  import RabbitMq from '@autofleet/rabbit';
3
+ import { getCurrentTrace } from '@autofleet/zehut/lib/tracer';
3
4
 
4
5
  export type AuditLoggerOptions = {
5
6
  rabbit: RabbitMq;
6
7
  sequelize: Sequelize;
8
+ getCurrentTrace: () => any,
9
+ logger: any;
7
10
  };
8
11
 
9
12
  export interface AuditLogContext {
@@ -14,6 +17,7 @@ export interface AuditLogContext {
14
17
  endpoint: string;
15
18
  method: string;
16
19
  }
20
+
17
21
  export interface AuditLogRow {
18
22
  property: string;
19
23
  previousValue: any;
package/tsconfig.json CHANGED
@@ -4,10 +4,16 @@
4
4
  "module": "commonjs",
5
5
  "declaration": true,
6
6
  "outDir": "./dist",
7
- "strict": true,
8
7
  "esModuleInterop": true,
9
8
  "experimentalDecorators": true,
10
- "emitDecoratorMetadata": true
9
+ "emitDecoratorMetadata": true,
10
+ "allowJs": true,
11
+ "baseUrl": ".",
12
+ "paths": {
13
+ "*": [
14
+ "node_modules/*"
15
+ ]
16
+ }
11
17
  },
12
- "exclude": ["node_modules", "**/*.test.ts"]
18
+ "exclude": ["node_modules", "**/*.test.ts", "dist"]
13
19
  }
@@ -1,9 +0,0 @@
1
- import { AuditLoggerOptions, AuditLogContext } from './types';
2
- declare class AuditLogger {
3
- private rabbit;
4
- private sequelize;
5
- constructor(options: AuditLoggerOptions);
6
- addModelHooks(): void;
7
- sendAuditLog(context: AuditLogContext): Promise<void>;
8
- }
9
- export default AuditLogger;
File without changes