@golemio/audit-logs 1.0.0-dev.1590464100 → 1.0.0-dev.1594393090

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.
package/README.md CHANGED
@@ -54,21 +54,31 @@ npx golemio migrate-db up --postgres --schema audit_logs
54
54
  For information on how to use this module with default module schema migrations, see [golemio-cli docs](https://gitlab.com/operator-ict/golemio/code/golemio-cli/-/blob/release/docs/migrations.md?ref_type=heads#default-module-schema-migrations).
55
55
 
56
56
  Configuring the database schema to use for audit logging using dependency injection:
57
+
57
58
  ```ts
58
59
  // Di.ts
59
- import { AuditLogsContainer, AuditLogsContainerToken, AuditLogger, IAuditLogsConfig } from "@golemio/audit-logs";
60
-
61
- const YourModuleContainer: DependencyContainer = SomeOtherContainer.createChildContainer();
62
-
63
- const config: IAuditLogsConfig = { schema: "your_module_schema" };
64
- const YourAuditLogsContainer: DependencyContainer = AuditLogsContainer.createChildContainer();
65
- YourAuditLogsContainer.register(AuditLogsContainerToken.AuditLogsConfig, { useValue: config });
66
- YourModuleContainer.registerInstance(
67
- "your_audit_logs_token", YourAuditLogsContainer.resolve<AuditLogger>(AuditLogsContainerToken.AuditLogger)
68
- );
60
+ import { AuditLogsContainer } from "@golemio/audit-logs";
61
+ import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector";
62
+ import { ILogger } from "@golemio/core/dist/helpers";
63
+ import { instanceCachingFactory } from "@golemio/core/dist/shared/tsyringe";
64
+
65
+ // ...create your module container
66
+ // ...register database connector for your module container
67
+ // ...register logger for your module container
68
+
69
+ YourModuleContainer.register("your_audit_logs_token", {
70
+ useFactory: instanceCachingFactory<AuditLogger>((c) => {
71
+ return new AuditLogger(
72
+ YourModuleContainer.resolve<IDatabaseConnector>("your_database_connector_token"),
73
+ YourModuleContainer.resolve<ILogger>("your_logger_token"),
74
+ { schema: "your_module_database_schema" }
75
+ );
76
+ }),
77
+ });
69
78
  ```
70
79
 
71
80
  The audit logger can then be used as follows:
81
+
72
82
  ```ts
73
83
  // YourClass.ts
74
84
  import { inject } from "@golemio/core/dist/shared/tsyringe";
@@ -77,9 +87,10 @@ import { AuditLogger } from "@golemio/audit-logs";
77
87
  export class YourClass {
78
88
  constructor(@inject("your_audit_logs_token") private auditLogger: AuditLogger) {}
79
89
 
80
- someMethod() {
81
- this.auditLogger.log({ action: "test-action", entity: "test-entity", userId: "test-user-id" /*, data: {...} */ });
82
- // .then(...).catch(...)
90
+ async someMethod() {
91
+ await this.auditLogger.log({ action: "test-action", entity: "test-entity", userId: "test-user-id" /*, data: {...} */ });
83
92
  }
84
93
  }
85
94
  ```
95
+
96
+ Note that logging can be used only after your database connector has been connected to the database.
@@ -0,0 +1 @@
1
+ { "schema": "audit_logs" }
@@ -0,0 +1 @@
1
+ truncate "audit_logs";
@@ -0,0 +1,4 @@
1
+ insert into audit_logs(id, action, entity, user_id, data, created_at) values
2
+ ('40507cee-6468-488e-ba78-e36d9c20e67c', 'create-user', 'User', 'test-user-1', '{"test": "test-data"}', '2024-12-02T12:00:00.000Z'),
3
+ ('6bdc3fdb-dd18-438b-878a-7972bddb0d92', 'create-user', 'User', 'test-user-2', null, '2024-12-02T12:01:00.000Z'),
4
+ ('eba39046-86d2-4f8c-aa39-932dfcfd6d0f', 'delete-user', 'User', 'test-user-1', null, '2024-12-02T12:02:00.000Z');
@@ -0,0 +1 @@
1
+ { "schema": "$DEFAULT_MODULE_PG_SCHEMA" }
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var dbm;
4
+ var type;
5
+ var seed;
6
+ var fs = require('fs');
7
+ var path = require('path');
8
+ var Promise;
9
+
10
+ /**
11
+ * We receive the dbmigrate dependency from dbmigrate initially.
12
+ * This enables us to not have to rely on NODE_PATH.
13
+ */
14
+ exports.setup = function(options, seedLink) {
15
+ dbm = options.dbmigrate;
16
+ type = dbm.dataType;
17
+ seed = seedLink;
18
+ Promise = options.Promise;
19
+ };
20
+
21
+ exports.up = function(db) {
22
+ var filePath = path.join(__dirname, 'sqls', '20241128105829-init-audit-logs-up.sql');
23
+ return new Promise( function( resolve, reject ) {
24
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
25
+ if (err) return reject(err);
26
+ console.log('received data: ' + data);
27
+
28
+ resolve(data);
29
+ });
30
+ })
31
+ .then(function(data) {
32
+ return db.runSql(data);
33
+ });
34
+ };
35
+
36
+ exports.down = function(db) {
37
+ var filePath = path.join(__dirname, 'sqls', '20241128105829-init-audit-logs-down.sql');
38
+ return new Promise( function( resolve, reject ) {
39
+ fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
40
+ if (err) return reject(err);
41
+ console.log('received data: ' + data);
42
+
43
+ resolve(data);
44
+ });
45
+ })
46
+ .then(function(data) {
47
+ return db.runSql(data);
48
+ });
49
+ };
50
+
51
+ exports._meta = {
52
+ "version": 1
53
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,8 @@
1
+ create table audit_logs (
2
+ id uuid not null,
3
+ action text not null,
4
+ entity text not null,
5
+ user_id text not null,
6
+ data jsonb,
7
+ created_at timestamptz not null
8
+ );
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -1,9 +1,10 @@
1
+ import { ILogger } from "@golemio/core/dist/helpers";
2
+ import { IDatabaseConnector } from "@golemio/core/dist/helpers/data-access/postgres/IDatabaseConnector";
1
3
  import { IAuditLog } from "../interfaces/IAuditLog";
2
- import { AuditLogsRepository } from "../repositories/AuditLogsRepository";
3
- import { AuditLogTransformation } from "../transformations/AuditLogTransformation";
4
+ import { IAuditLogsConfig } from "../interfaces/IAuditLogsConfig";
4
5
  export declare class AuditLogger {
5
6
  private auditLogsRepository;
6
7
  private auditLogTransformation;
7
- constructor(auditLogsRepository: AuditLogsRepository, auditLogTransformation: AuditLogTransformation);
8
+ constructor(databaseConnector: IDatabaseConnector, logger: ILogger, config: IAuditLogsConfig);
8
9
  log(auditLog: IAuditLog): Promise<void>;
9
10
  }
@@ -1,16 +1,4 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -22,15 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
10
  };
23
11
  Object.defineProperty(exports, "__esModule", { value: true });
24
12
  exports.AuditLogger = void 0;
25
- const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
26
- const AuditLogsContainerToken_1 = require("../ioc/AuditLogsContainerToken");
27
13
  const AuditLogsRepository_1 = require("../repositories/AuditLogsRepository");
28
14
  const AuditLogTransformation_1 = require("../transformations/AuditLogTransformation");
29
- let AuditLogger = exports.AuditLogger = class AuditLogger {
30
- constructor(auditLogsRepository, auditLogTransformation) {
31
- this.auditLogsRepository = auditLogsRepository;
32
- this.auditLogTransformation = auditLogTransformation;
33
- // do nothing
15
+ class AuditLogger {
16
+ constructor(databaseConnector, logger, config) {
17
+ this.auditLogsRepository = new AuditLogsRepository_1.AuditLogsRepository(databaseConnector, logger, config);
18
+ this.auditLogTransformation = new AuditLogTransformation_1.AuditLogTransformation();
34
19
  }
35
20
  log(auditLog) {
36
21
  return __awaiter(this, void 0, void 0, function* () {
@@ -38,12 +23,6 @@ let AuditLogger = exports.AuditLogger = class AuditLogger {
38
23
  yield this.auditLogsRepository.insert(transformedAuditLog);
39
24
  });
40
25
  }
41
- };
42
- exports.AuditLogger = AuditLogger = __decorate([
43
- (0, tsyringe_1.injectable)(),
44
- __param(0, (0, tsyringe_1.inject)(AuditLogsContainerToken_1.AuditLogsContainerToken.AuditLogsRepository)),
45
- __param(1, (0, tsyringe_1.inject)(AuditLogsContainerToken_1.AuditLogsContainerToken.AuditLogTransformation)),
46
- __metadata("design:paramtypes", [AuditLogsRepository_1.AuditLogsRepository,
47
- AuditLogTransformation_1.AuditLogTransformation])
48
- ], AuditLogger);
26
+ }
27
+ exports.AuditLogger = AuditLogger;
49
28
  //# sourceMappingURL=AuditLogger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuditLogger.js","sourceRoot":"","sources":["../../src/helpers/AuditLogger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAwE;AAExE,4EAAyE;AACzE,6EAA0E;AAC1E,sFAAmF;AAG5E,IAAM,WAAW,yBAAjB,MAAM,WAAW;IACpB,YACiE,mBAAwC,EACrC,sBAA8C;QADjD,wBAAmB,GAAnB,mBAAmB,CAAqB;QACrC,2BAAsB,GAAtB,sBAAsB,CAAwB;QAE9G,aAAa;IACjB,CAAC;IAEY,GAAG,CAAC,QAAmB;;YAChC,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YACnF,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC/D,CAAC;KAAA;CACJ,CAAA;sBAZY,WAAW;IADvB,IAAA,qBAAU,GAAE;IAGJ,WAAA,IAAA,iBAAM,EAAC,iDAAuB,CAAC,mBAAmB,CAAC,CAAA;IACnD,WAAA,IAAA,iBAAM,EAAC,iDAAuB,CAAC,sBAAsB,CAAC,CAAA;qCAD2B,yCAAmB;QACb,+CAAsB;GAHzG,WAAW,CAYvB"}
1
+ {"version":3,"file":"AuditLogger.js","sourceRoot":"","sources":["../../src/helpers/AuditLogger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,6EAA0E;AAC1E,sFAAmF;AAEnF,MAAa,WAAW;IAIpB,YAAY,iBAAqC,EAAE,MAAe,EAAE,MAAwB;QACxF,IAAI,CAAC,mBAAmB,GAAG,IAAI,yCAAmB,CAAC,iBAAiB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtF,IAAI,CAAC,sBAAsB,GAAG,IAAI,+CAAsB,EAAE,CAAC;IAC/D,CAAC;IAEY,GAAG,CAAC,QAAmB;;YAChC,MAAM,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YACnF,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC/D,CAAC;KAAA;CACJ;AAbD,kCAaC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
1
  export { AuditLogger } from "./helpers/AuditLogger";
2
2
  export { IAuditLog } from "./interfaces/IAuditLog";
3
3
  export { IAuditLogsConfig } from "./interfaces/IAuditLogsConfig";
4
- export { AuditLogsContainerToken } from "./ioc/AuditLogsContainerToken";
5
- export { AuditLogsContainer } from "./ioc/Di";
package/dist/index.js CHANGED
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuditLogsContainer = exports.AuditLogsContainerToken = exports.AuditLogger = void 0;
3
+ exports.AuditLogger = void 0;
4
4
  var AuditLogger_1 = require("./helpers/AuditLogger");
5
5
  Object.defineProperty(exports, "AuditLogger", { enumerable: true, get: function () { return AuditLogger_1.AuditLogger; } });
6
- var AuditLogsContainerToken_1 = require("./ioc/AuditLogsContainerToken");
7
- Object.defineProperty(exports, "AuditLogsContainerToken", { enumerable: true, get: function () { return AuditLogsContainerToken_1.AuditLogsContainerToken; } });
8
- var Di_1 = require("./ioc/Di");
9
- Object.defineProperty(exports, "AuditLogsContainer", { enumerable: true, get: function () { return Di_1.AuditLogsContainer; } });
10
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AAGpB,yEAAwE;AAA/D,kIAAA,uBAAuB,OAAA;AAChC,+BAA8C;AAArC,wGAAA,kBAAkB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAA3C,0GAAA,WAAW,OAAA"}
@@ -1,16 +1,4 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,14 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
11
  Object.defineProperty(exports, "__esModule", { value: true });
24
12
  exports.AuditLogsRepository = void 0;
25
13
  const AbstractValidatableRepository_1 = require("@golemio/core/dist/helpers/data-access/postgres/repositories/AbstractValidatableRepository");
26
- const CoreToken_1 = require("@golemio/core/dist/helpers/ioc/CoreToken");
27
14
  const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
28
15
  const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
29
16
  const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
30
- const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
31
- const AuditLogsContainerToken_1 = require("../ioc/AuditLogsContainerToken");
32
17
  const AuditLogsModel_1 = require("../models/AuditLogsModel");
33
- let AuditLogsRepository = exports.AuditLogsRepository = class AuditLogsRepository extends AbstractValidatableRepository_1.AbstractValidatableRepository {
18
+ class AuditLogsRepository extends AbstractValidatableRepository_1.AbstractValidatableRepository {
34
19
  constructor(connector, logger, config) {
35
20
  super(connector, logger);
36
21
  this.logger = logger;
@@ -60,12 +45,6 @@ let AuditLogsRepository = exports.AuditLogsRepository = class AuditLogsRepositor
60
45
  }
61
46
  });
62
47
  }
63
- };
64
- exports.AuditLogsRepository = AuditLogsRepository = __decorate([
65
- (0, tsyringe_1.injectable)(),
66
- __param(0, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.PostgresConnector)),
67
- __param(1, (0, tsyringe_1.inject)(CoreToken_1.CoreToken.Logger)),
68
- __param(2, (0, tsyringe_1.inject)(AuditLogsContainerToken_1.AuditLogsContainerToken.AuditLogsConfig)),
69
- __metadata("design:paramtypes", [Object, Object, Object])
70
- ], AuditLogsRepository);
48
+ }
49
+ exports.AuditLogsRepository = AuditLogsRepository;
71
50
  //# sourceMappingURL=AuditLogsRepository.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuditLogs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3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.AuditLogTransformation = void 0;
10
4
  const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation");
11
- const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe");
12
- let AuditLogTransformation = exports.AuditLogTransformation = class AuditLogTransformation extends AbstractTransformation_1.AbstractTransformation {
5
+ class AuditLogTransformation extends AbstractTransformation_1.AbstractTransformation {
13
6
  constructor() {
14
7
  super(...arguments);
15
8
  this.name = "AuditLogTransformation";
16
9
  this.transformInternal = (auditLog) => (Object.assign({ action: auditLog.action, entity: auditLog.entity, user_id: auditLog.userId }, (auditLog.data ? { data: auditLog.data } : {})));
17
10
  }
18
- };
19
- exports.AuditLogTransformation = AuditLogTransformation = __decorate([
20
- (0, tsyringe_1.injectable)()
21
- ], AuditLogTransformation);
11
+ }
12
+ exports.AuditLogTransformation = AuditLogTransformation;
22
13
  //# sourceMappingURL=AuditLogTransformation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuditLogTransformation.js","sourceRoot":"","sources":["../../src/transformations/AuditLogTransformation.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6GAA0G;AAC1G,iEAAgE;AAQzD,IAAM,sBAAsB,oCAA5B,MAAM,sBAAuB,SAAQ,+CAAiD;IAAtF;;QACI,SAAI,GAAG,wBAAwB,CAAC;QAE7B,sBAAiB,GAAG,CAAC,QAAqB,EAAgB,EAAE,CAAC,iBACnE,MAAM,EAAE,QAAQ,CAAC,MAAM,EACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,EACvB,OAAO,EAAE,QAAQ,CAAC,MAAM,IACrB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACnD,CAAC;IACP,CAAC;CAAA,CAAA;iCATY,sBAAsB;IADlC,IAAA,qBAAU,GAAE;GACA,sBAAsB,CASlC"}
1
+ {"version":3,"file":"AuditLogTransformation.js","sourceRoot":"","sources":["../../src/transformations/AuditLogTransformation.ts"],"names":[],"mappings":";;;AAAA,6GAA0G;AAO1G,MAAa,sBAAuB,SAAQ,+CAAiD;IAA7F;;QACW,SAAI,GAAG,wBAAwB,CAAC;QAE7B,sBAAiB,GAAG,CAAC,QAAqB,EAAgB,EAAE,CAAC,iBACnE,MAAM,EAAE,QAAQ,CAAC,MAAM,EACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,EACvB,OAAO,EAAE,QAAQ,CAAC,MAAM,IACrB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACnD,CAAC;IACP,CAAC;CAAA;AATD,wDASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemio/audit-logs",
3
- "version": "1.0.0-dev.1590464100",
3
+ "version": "1.0.0-dev.1594393090",
4
4
  "description": "Golemio Audit Logs Module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +0,0 @@
1
- declare const AuditLogsContainerToken: {
2
- AuditLogsConfig: symbol;
3
- AuditLogger: symbol;
4
- AuditLogsRepository: symbol;
5
- AuditLogTransformation: symbol;
6
- };
7
- export { AuditLogsContainerToken };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuditLogsContainerToken = void 0;
4
- const AuditLogsContainerToken = {
5
- /* Config */
6
- AuditLogsConfig: Symbol("AuditLogsConfig"),
7
- /* Helpers */
8
- AuditLogger: Symbol("AuditLogger"),
9
- /* Repositories */
10
- AuditLogsRepository: Symbol("AuditLogsRepository"),
11
- /* Transformations */
12
- AuditLogTransformation: Symbol("AuditLogTransformation"),
13
- };
14
- exports.AuditLogsContainerToken = AuditLogsContainerToken;
15
- //# sourceMappingURL=AuditLogsContainerToken.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuditLogsContainerToken.js","sourceRoot":"","sources":["../../src/ioc/AuditLogsContainerToken.ts"],"names":[],"mappings":";;;AAAA,MAAM,uBAAuB,GAAG;IAC5B,YAAY;IACZ,eAAe,EAAE,MAAM,CAAC,iBAAiB,CAAC;IAC1C,aAAa;IACb,WAAW,EAAE,MAAM,CAAC,aAAa,CAAC;IAClC,kBAAkB;IAClB,mBAAmB,EAAE,MAAM,CAAC,qBAAqB,CAAC;IAClD,qBAAqB;IACrB,sBAAsB,EAAE,MAAM,CAAC,wBAAwB,CAAC;CAC3D,CAAC;AAEO,0DAAuB"}
package/dist/ioc/Di.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { DependencyContainer } from "@golemio/core/dist/shared/tsyringe";
2
- declare const AuditLogsContainer: DependencyContainer;
3
- export { AuditLogsContainer };
package/dist/ioc/Di.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuditLogsContainer = void 0;
4
- const Di_1 = require("@golemio/core/dist/integration-engine/ioc/Di");
5
- const AuditLogger_1 = require("../helpers/AuditLogger");
6
- const AuditLogsRepository_1 = require("../repositories/AuditLogsRepository");
7
- const AuditLogTransformation_1 = require("../transformations/AuditLogTransformation");
8
- const AuditLogsContainerToken_1 = require("./AuditLogsContainerToken");
9
- //#region Initialization
10
- const AuditLogsContainer = Di_1.IntegrationEngineContainer.createChildContainer();
11
- exports.AuditLogsContainer = AuditLogsContainer;
12
- //#endregion
13
- //#region Config
14
- const config = { schema: "audit_logs" };
15
- AuditLogsContainer.register(AuditLogsContainerToken_1.AuditLogsContainerToken.AuditLogsConfig, { useValue: config });
16
- //#endregion
17
- //#region Helpers
18
- AuditLogsContainer.register(AuditLogsContainerToken_1.AuditLogsContainerToken.AuditLogger, AuditLogger_1.AuditLogger);
19
- //#endregion
20
- //#region Repositories
21
- AuditLogsContainer.register(AuditLogsContainerToken_1.AuditLogsContainerToken.AuditLogsRepository, AuditLogsRepository_1.AuditLogsRepository);
22
- //#endregion
23
- //#region Transformations
24
- AuditLogsContainer.register(AuditLogsContainerToken_1.AuditLogsContainerToken.AuditLogTransformation, AuditLogTransformation_1.AuditLogTransformation);
25
- //# sourceMappingURL=Di.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Di.js","sourceRoot":"","sources":["../../src/ioc/Di.ts"],"names":[],"mappings":";;;AAAA,qEAA0F;AAE1F,wDAAqD;AAErD,6EAA0E;AAC1E,sFAAmF;AACnF,uEAAoE;AAEpE,wBAAwB;AACxB,MAAM,kBAAkB,GAAwB,+BAA0B,CAAC,oBAAoB,EAAE,CAAC;AAoBzF,gDAAkB;AAnB3B,YAAY;AAEZ,gBAAgB;AAChB,MAAM,MAAM,GAAqB,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAC1D,kBAAkB,CAAC,QAAQ,CAAC,iDAAuB,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3F,YAAY;AAEZ,iBAAiB;AACjB,kBAAkB,CAAC,QAAQ,CAAC,iDAAuB,CAAC,WAAW,EAAE,yBAAW,CAAC,CAAC;AAC9E,YAAY;AAEZ,sBAAsB;AACtB,kBAAkB,CAAC,QAAQ,CAAC,iDAAuB,CAAC,mBAAmB,EAAE,yCAAmB,CAAC,CAAC;AAC9F,YAAY;AAEZ,yBAAyB;AACzB,kBAAkB,CAAC,QAAQ,CAAC,iDAAuB,CAAC,sBAAsB,EAAE,+CAAsB,CAAC,CAAC"}