@autofleet/shtinker 1.1.7-beta.5 → 1.1.7-beta.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.
@@ -1,5 +1,4 @@
1
1
  import { AuditLogPayload, AuditLoggerOptions, AuditLogContext } from './types';
2
- export declare const shouldSkipAuditLogic: () => boolean;
3
2
  declare class AuditLogger {
4
3
  private rabbit;
5
4
  private sequelize;
@@ -12,13 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.shouldSkipAuditLogic = void 0;
16
15
  const zehut_1 = require("@autofleet/zehut");
17
16
  const const_1 = require("./const");
18
17
  const logger_1 = __importDefault(require("./logger"));
19
- const ENVS_TO_DISABLE_AUDIT_LOGIC = ['production-jp', 'loadtesting'];
20
- const shouldSkipAuditLogic = () => ENVS_TO_DISABLE_AUDIT_LOGIC.includes(process.env.ENV_NAME);
21
- exports.shouldSkipAuditLogic = shouldSkipAuditLogic;
22
18
  const getAuditContext = () => {
23
19
  var _a;
24
20
  const currentTrace = (0, zehut_1.getCurrentPayload)();
@@ -54,9 +50,6 @@ class AuditLogger {
54
50
  Object.entries(this.sequelize.models).forEach(([modelName, modelType]) => {
55
51
  modelType.addHook('afterSave', (instance, options) => __awaiter(this, void 0, void 0, function* () {
56
52
  try {
57
- if ((0, exports.shouldSkipAuditLogic)()) {
58
- return;
59
- }
60
53
  const auditContext = getAuditContext();
61
54
  if (auditContext) {
62
55
  const changedProperties = getChangedFields(instance, options);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import AuditLogger from './audit-logger';
2
2
  import { AuditLoggerOptions } from './types';
3
+ export declare const shouldSkipAuditLogic: () => boolean;
3
4
  export declare const enableAuditing: (options: AuditLoggerOptions) => void;
4
5
  export declare const setAuditContext: (entityType: string, action: string) => (req: any, res: any, next: any) => Promise<any>;
5
6
  export declare const setRabbitAuditContext: (entityType: string, action: string) => (endpoint: string) => Promise<any>;
package/dist/index.js CHANGED
@@ -10,18 +10,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
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
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
15
  };
@@ -38,13 +26,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
39
27
  };
40
28
  Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.setRabbitAuditContext = exports.setAuditContext = exports.enableAuditing = void 0;
29
+ exports.setRabbitAuditContext = exports.setAuditContext = exports.enableAuditing = exports.shouldSkipAuditLogic = void 0;
42
30
  const zehut_1 = require("@autofleet/zehut");
43
- const audit_logger_1 = __importStar(require("./audit-logger"));
31
+ const audit_logger_1 = __importDefault(require("./audit-logger"));
44
32
  const const_1 = require("./const");
45
33
  const audit_api_1 = __importDefault(require("./audit-api"));
46
34
  const logger_1 = __importDefault(require("./logger"));
47
35
  let auditLogger;
36
+ const ENVS_TO_DISABLE_AUDIT_LOGIC = ['production-jp', 'loadtesting'];
37
+ const shouldSkipAuditLogic = () => ENVS_TO_DISABLE_AUDIT_LOGIC.includes(process.env.ENV_NAME);
38
+ exports.shouldSkipAuditLogic = shouldSkipAuditLogic;
48
39
  const enableAuditing = (options) => {
49
40
  auditLogger = new audit_logger_1.default(options);
50
41
  (0, audit_api_1.default)(options);
@@ -53,7 +44,7 @@ const enableAuditing = (options) => {
53
44
  exports.enableAuditing = enableAuditing;
54
45
  const setAuditContext = (entityType, action) => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
55
46
  try {
56
- if ((0, audit_logger_1.shouldSkipAuditLogic)()) {
47
+ if ((0, exports.shouldSkipAuditLogic)()) {
57
48
  return next();
58
49
  }
59
50
  const currentTrace = (0, zehut_1.getCurrentPayload)();
@@ -78,7 +69,7 @@ const setAuditContext = (entityType, action) => (req, res, next) => __awaiter(vo
78
69
  exports.setAuditContext = setAuditContext;
79
70
  const setRabbitAuditContext = (entityType, action) => (endpoint) => __awaiter(void 0, void 0, void 0, function* () {
80
71
  var _a;
81
- if ((0, audit_logger_1.shouldSkipAuditLogic)()) {
72
+ if ((0, exports.shouldSkipAuditLogic)()) {
82
73
  return;
83
74
  }
84
75
  const currentTrace = (0, zehut_1.getCurrentPayload)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/shtinker",
3
- "version": "1.1.7-beta.5",
3
+ "version": "1.1.7-beta.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -6,10 +6,6 @@ import { AUDIT_LOG_CONTEXT_QUEUE, AUDIT_LOG_ROWS_QUEUE, AUDIT_LOG_CONTEXT_KEY }
6
6
 
7
7
  import logger from './logger';
8
8
 
9
- const ENVS_TO_DISABLE_AUDIT_LOGIC = ['production-jp', 'loadtesting'];
10
-
11
- export const shouldSkipAuditLogic = (): boolean => ENVS_TO_DISABLE_AUDIT_LOGIC.includes(process.env.ENV_NAME);
12
-
13
9
  const getAuditContext = () => {
14
10
  const currentTrace = getCurrentTrace();
15
11
  const auditContext = currentTrace?.context?.get(AUDIT_LOG_CONTEXT_KEY);
@@ -55,9 +51,6 @@ class AuditLogger {
55
51
  Object.entries(this.sequelize.models).forEach(([modelName, modelType]) => {
56
52
  modelType.addHook('afterSave', async (instance: any, options: any) => {
57
53
  try {
58
- if (shouldSkipAuditLogic()) {
59
- return;
60
- }
61
54
  const auditContext = getAuditContext();
62
55
  if (auditContext) {
63
56
  const changedProperties = getChangedFields(instance, options);
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getCurrentPayload as getCurrentTrace } from '@autofleet/zehut';
2
- import AuditLogger, { shouldSkipAuditLogic } from './audit-logger';
2
+ import AuditLogger from './audit-logger';
3
3
  import { AuditLogContext, AuditLoggerOptions } from './types';
4
4
  import { AUDIT_LOG_CONTEXT_KEY, USER_CONTEXT_KEY } from './const';
5
5
  import addAuditApi from './audit-api';
@@ -7,6 +7,10 @@ import logger from './logger';
7
7
 
8
8
  let auditLogger: AuditLogger;
9
9
 
10
+ const ENVS_TO_DISABLE_AUDIT_LOGIC = ['production-jp', 'loadtesting'];
11
+
12
+ export const shouldSkipAuditLogic = (): boolean => ENVS_TO_DISABLE_AUDIT_LOGIC.includes(process.env.ENV_NAME);
13
+
10
14
  export const enableAuditing = (options: AuditLoggerOptions) => {
11
15
  auditLogger = new AuditLogger(options);
12
16
  addAuditApi(options as any);