@estgbue/mezgeb 0.0.31 → 0.0.33

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,11 +1,4 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- export interface AuditClientModuleOptions {
3
- /** Optional TypeORM connection name; defaults to the default connection. */
4
- connectionName?: string;
5
- /** Custom DataSource injection token; overrides connectionName when provided. */
6
- dataSourceToken?: string | symbol;
7
- }
8
1
  export declare class AuditClientModule {
9
- static register(options?: AuditClientModuleOptions): DynamicModule;
2
+ constructor();
10
3
  }
11
4
  //# sourceMappingURL=client.module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.module.d.ts","sourceRoot":"","sources":["../../../libs/mezgeb/src/mezgeb/client/client.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAUvD,MAAM,WAAW,wBAAwB;IACvC,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iFAAiF;IACjF,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAED,qBACa,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,CAAC,OAAO,GAAE,wBAA6B,GAAG,aAAa;CA0BvE"}
1
+ {"version":3,"file":"client.module.d.ts","sourceRoot":"","sources":["../../../libs/mezgeb/src/mezgeb/client/client.module.ts"],"names":[],"mappings":"AAUA,qBAqBa,iBAAiB;;CAI5B"}
@@ -5,7 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
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
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var AuditClientModule_1;
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
9
11
  Object.defineProperty(exports, "__esModule", { value: true });
10
12
  exports.AuditClientModule = void 0;
11
13
  const common_1 = require("@nestjs/common");
@@ -16,34 +18,31 @@ const mezgeb_enum_1 = require("../mezgeb.enum");
16
18
  const client_audit_interceptor_1 = require("./client-audit.interceptor");
17
19
  const client_logger_config_1 = require("./client.logger.config");
18
20
  const client_subscriber_1 = require("./client.subscriber");
19
- let AuditClientModule = AuditClientModule_1 = class AuditClientModule {
20
- static register(options = {}) {
21
- var _a;
22
- const dataSourceToken = (_a = options.dataSourceToken) !== null && _a !== void 0 ? _a : (0, typeorm_1.getDataSourceToken)(options.connectionName);
23
- return {
24
- module: AuditClientModule_1,
25
- imports: [
26
- microservices_1.ClientsModule.register([client_logger_config_1.auditLoggerConfig]),
27
- typeorm_1.TypeOrmModule.forFeature([], options.connectionName),
28
- ],
29
- providers: [
30
- core_1.Reflector,
31
- {
32
- provide: core_1.APP_INTERCEPTOR,
33
- useClass: client_audit_interceptor_1.ClientLoggerInterceptor,
34
- },
35
- {
36
- provide: mezgeb_enum_1.AuditDatasource,
37
- useFactory: (dataSource) => dataSource,
38
- inject: [dataSourceToken],
39
- },
40
- client_subscriber_1.ClientSubscriber,
41
- ],
42
- exports: [mezgeb_enum_1.AuditDatasource],
43
- };
21
+ let AuditClientModule = class AuditClientModule {
22
+ constructor() {
23
+ common_1.Logger.log('Audit Client Module initialized');
44
24
  }
45
25
  };
46
26
  exports.AuditClientModule = AuditClientModule;
47
- exports.AuditClientModule = AuditClientModule = AuditClientModule_1 = __decorate([
48
- (0, common_1.Module)({})
27
+ exports.AuditClientModule = AuditClientModule = __decorate([
28
+ (0, common_1.Module)({
29
+ imports: [
30
+ microservices_1.ClientsModule.register([client_logger_config_1.auditLoggerConfig]),
31
+ typeorm_1.TypeOrmModule.forFeature([]), // 👈 required even if no entities
32
+ ],
33
+ providers: [
34
+ core_1.Reflector,
35
+ {
36
+ provide: core_1.APP_INTERCEPTOR,
37
+ useClass: client_audit_interceptor_1.ClientLoggerInterceptor,
38
+ },
39
+ {
40
+ provide: mezgeb_enum_1.AuditDatasource,
41
+ useFactory: (dataSource) => dataSource,
42
+ inject: [(0, typeorm_1.getDataSourceToken)()],
43
+ },
44
+ client_subscriber_1.ClientSubscriber,
45
+ ],
46
+ }),
47
+ __metadata("design:paramtypes", [])
49
48
  ], AuditClientModule);
@@ -1 +1 @@
1
- {"version":3,"file":"audit-log-command.entity.d.ts","sourceRoot":"","sources":["../../../../libs/mezgeb/src/mezgeb/listener/entities/audit-log-command.entity.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,qBACa,eAAe;IAE1B,EAAE,CAAC,EAAE,MAAM,CAAC;IAGZ,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,CAAC,EAAE,IAAI,CAAC;IAGjB,MAAM,EAAE,GAAG,CAAC;IAGZ,QAAQ,EAAG,MAAM,CAAC;IAGlB,UAAU,EAAG,MAAM,CAAC;IAGpB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IAGF,OAAO,CAAC,EACJ;QACE,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,GAAG,CAAC;QACV,EAAE,EAAE,GAAG,CAAC;KACT,EAAE,GACH,IAAI,CAAC;IAGT,WAAW,EAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,GAAG,cAAc,CAAC;IAG/E,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IAGnB,MAAM,EAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;IAGzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAIlB,MAAM,CAAC,EAAE,eAAe,CAAC;IAGzB,UAAU,CAAC,EAAE,MAAM,CAAC;IAMpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB"}
1
+ {"version":3,"file":"audit-log-command.entity.d.ts","sourceRoot":"","sources":["../../../../libs/mezgeb/src/mezgeb/listener/entities/audit-log-command.entity.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,qBACa,eAAe;IAE1B,EAAE,CAAC,EAAE,MAAM,CAAC;IAGZ,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,CAAC,EAAE,IAAI,CAAC;IAGjB,MAAM,EAAE,GAAG,CAAC;IAGZ,QAAQ,EAAG,MAAM,CAAC;IAGlB,UAAU,EAAG,MAAM,CAAC;IAGpB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IAGF,OAAO,CAAC,EACJ;QACE,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,GAAG,CAAC;QACV,EAAE,EAAE,GAAG,CAAC;KACT,EAAE,GACH,IAAI,CAAC;IAGT,WAAW,EAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,GAAG,cAAc,CAAC;IAG/E,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IAGnB,MAAM,EAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;IAGzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAIlB,MAAM,CAAC,EAAE,eAAe,CAAC;IAGzB,UAAU,CAAC,EAAE,MAAM,CAAC;IAMpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB"}
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AuditLogCommand = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const audit_log_entity_1 = require("./audit-log.entity");
15
+ const mezgeb_enum_1 = require("../../mezgeb.enum");
15
16
  let AuditLogCommand = class AuditLogCommand {
16
17
  };
17
18
  exports.AuditLogCommand = AuditLogCommand;
@@ -84,5 +85,5 @@ __decorate([
84
85
  __metadata("design:type", audit_log_entity_1.AuditLog)
85
86
  ], AuditLogCommand.prototype, "auditLog", void 0);
86
87
  exports.AuditLogCommand = AuditLogCommand = __decorate([
87
- (0, typeorm_1.Entity)({ name: 'audit_log_commands' })
88
+ (0, typeorm_1.Entity)({ name: mezgeb_enum_1.AuditCommandTableName, schema: mezgeb_enum_1.AuditTableSchema })
88
89
  ], AuditLogCommand);
@@ -1 +1 @@
1
- {"version":3,"file":"migrator.d.ts","sourceRoot":"","sources":["../../../libs/mezgeb/src/mezgeb/listener/migrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,WAAW,EAAE,MAAM,SAAS,CAAC;AAGvC,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,qBAAqB,CAAgD;IAC7E,OAAO,CAAC,cAAc,CAAiC;IAE1C,EAAE,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IA8D3C,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAM7D"}
1
+ {"version":3,"file":"migrator.d.ts","sourceRoot":"","sources":["../../../libs/mezgeb/src/mezgeb/listener/migrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,WAAW,EAAE,MAAM,SAAS,CAAC;AAGvC,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,qBAAqB,CAAgD;IAC7E,OAAO,CAAC,cAAc,CAAiC;IAE1C,EAAE,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAoF3C,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAM7D"}
@@ -62,18 +62,39 @@ class AuditLogMigrator {
62
62
  CONSTRAINT "PK_1bb179d048bbc581caa3b013439" PRIMARY KEY ("id")
63
63
  )
64
64
  `);
65
- // Add foreign keys (will fail if the table already has them, so you may want to drop first or check)
66
65
  yield queryRunner.query(`
67
- ALTER TABLE "${this.schema}"."${this.auditLogCommandsTable}"
68
- ADD CONSTRAINT IF NOT EXISTS "FK_12094509e8bc3a6bb091f2f1987"
69
- FOREIGN KEY ("parent_id") REFERENCES "${this.schema}"."${this.auditLogCommandsTable}"("id")
70
- ON DELETE NO ACTION ON UPDATE NO ACTION
66
+ DO $$
67
+ BEGIN
68
+ IF NOT EXISTS (
69
+ SELECT 1
70
+ FROM pg_constraint
71
+ WHERE conname = 'FK_12094509e8bc3a6bb091f2f1987'
72
+ AND conrelid = '"${this.schema}"."${this.auditLogCommandsTable}"'::regclass
73
+ ) THEN
74
+ ALTER TABLE "${this.schema}"."${this.auditLogCommandsTable}"
75
+ ADD CONSTRAINT "FK_12094509e8bc3a6bb091f2f1987"
76
+ FOREIGN KEY ("parent_id") REFERENCES "${this.schema}"."${this.auditLogCommandsTable}"("id")
77
+ ON DELETE NO ACTION ON UPDATE NO ACTION;
78
+ END IF;
79
+ END
80
+ $$;
71
81
  `);
72
82
  yield queryRunner.query(`
73
- ALTER TABLE "${this.schema}"."${this.auditLogCommandsTable}"
74
- ADD CONSTRAINT IF NOT EXISTS "FK_ec7bf138fb9f823c358f54e8ce7"
75
- FOREIGN KEY ("audit_log_id") REFERENCES "${this.schema}"."${this.auditLogsTable}"("id")
76
- ON DELETE CASCADE ON UPDATE NO ACTION
83
+ DO $$
84
+ BEGIN
85
+ IF NOT EXISTS (
86
+ SELECT 1
87
+ FROM pg_constraint
88
+ WHERE conname = 'FK_ec7bf138fb9f823c358f54e8ce7'
89
+ AND conrelid = '"${this.schema}"."${this.auditLogCommandsTable}"'::regclass
90
+ ) THEN
91
+ ALTER TABLE "${this.schema}"."${this.auditLogCommandsTable}"
92
+ ADD CONSTRAINT "FK_ec7bf138fb9f823c358f54e8ce7"
93
+ FOREIGN KEY ("audit_log_id") REFERENCES "${this.schema}"."${this.auditLogsTable}"("id")
94
+ ON DELETE CASCADE ON UPDATE NO ACTION;
95
+ END IF;
96
+ END
97
+ $$;
77
98
  `);
78
99
  });
79
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estgbue/mezgeb",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "main": "./src/index",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"