emilsoftware-utilities 1.3.129 → 1.3.131

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,17 @@
1
+ import { DynamicModule } from "@nestjs/common";
2
+ import { AccessiOptions } from "./accessi-module/AccessiModule";
3
+ import { AllegatiOptions } from "./allegati-module/AllegatiModule";
4
+ /**
5
+ * Configuration options for the unified module that combines Accessi and Allegati functionality
6
+ */
7
+ export interface UnifiedModuleOptions {
8
+ accessiOptions: AccessiOptions;
9
+ allegatiOptions: AllegatiOptions;
10
+ }
11
+ /**
12
+ * Unified module that combines user access management (Accessi) and file attachment management (Allegati)
13
+ * into a single NestJS module with shared Swagger documentation
14
+ */
15
+ export declare class UnifiedModule {
16
+ static forRoot(options: UnifiedModuleOptions): DynamicModule;
17
+ }
@@ -0,0 +1,33 @@
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 UnifiedModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.UnifiedModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const AccessiModule_1 = require("./accessi-module/AccessiModule");
13
+ const AllegatiModule_1 = require("./allegati-module/AllegatiModule");
14
+ /**
15
+ * Unified module that combines user access management (Accessi) and file attachment management (Allegati)
16
+ * into a single NestJS module with shared Swagger documentation
17
+ */
18
+ let UnifiedModule = UnifiedModule_1 = class UnifiedModule {
19
+ static forRoot(options) {
20
+ return {
21
+ module: UnifiedModule_1,
22
+ imports: [
23
+ AccessiModule_1.AccessiModule.forRoot(options.accessiOptions),
24
+ AllegatiModule_1.AllegatiModule.forRoot(options.allegatiOptions),
25
+ ],
26
+ exports: [AccessiModule_1.AccessiModule, AllegatiModule_1.AllegatiModule],
27
+ };
28
+ }
29
+ };
30
+ exports.UnifiedModule = UnifiedModule;
31
+ exports.UnifiedModule = UnifiedModule = UnifiedModule_1 = __decorate([
32
+ (0, common_1.Module)({})
33
+ ], UnifiedModule);
@@ -28,7 +28,6 @@ exports.initializeAccessiModule = initializeAccessiModule;
28
28
  const core_1 = require("@nestjs/core");
29
29
  const platform_express_1 = require("@nestjs/platform-express");
30
30
  const AccessiModule_1 = require("./AccessiModule");
31
- const SwaggerConfig_1 = require("./swagger/SwaggerConfig");
32
31
  const Logger_1 = require("../Logger");
33
32
  function initializeAccessiModule(app, options) {
34
33
  return __awaiter(this, void 0, void 0, function* () {
@@ -45,7 +44,7 @@ function initializeAccessiModule(app, options) {
45
44
  nestApp.setGlobalPrefix('api', {
46
45
  exclude: ['/swagger', '/swagger/(.*)']
47
46
  });
48
- (0, SwaggerConfig_1.setupAccessiSwagger)(nestApp);
47
+ // Note: Swagger setup is now handled by the unified module
49
48
  yield nestApp.init();
50
49
  }
51
50
  catch (error) {
@@ -113,11 +113,11 @@ let AllegatiService = class AllegatiService {
113
113
  uploadSingleFileRequest.riferimentoDocumento
114
114
  ];
115
115
  const result = yield Orm_1.Orm.query(this.allegatiOptions.databaseOptions, insertQuery, params);
116
- if (!result || !result[0] || !result[0].IDXALL) {
116
+ if (!result || !result.IDXALL) {
117
117
  throw new common_1.InternalServerErrorException('Errore durante il salvataggio del file');
118
118
  }
119
119
  return {
120
- id: result[0].IDXALL,
120
+ id: result.IDXALL,
121
121
  filename: file.originalname,
122
122
  };
123
123
  }
@@ -28,7 +28,6 @@ exports.initializeAllegatiModule = initializeAllegatiModule;
28
28
  const core_1 = require("@nestjs/core");
29
29
  const platform_express_1 = require("@nestjs/platform-express");
30
30
  const AllegatiModule_1 = require("./AllegatiModule");
31
- const SwaggerConfig_1 = require("./swagger/SwaggerConfig");
32
31
  const Logger_1 = require("../Logger");
33
32
  function initializeAllegatiModule(app, options) {
34
33
  return __awaiter(this, void 0, void 0, function* () {
@@ -40,10 +39,9 @@ function initializeAllegatiModule(app, options) {
40
39
  });
41
40
  nestApp.enableCors();
42
41
  nestApp.setGlobalPrefix('api', {
43
- exclude: ['/swagger', '/swagger/(.*)'] // oppure più fine
42
+ exclude: ['/swagger', '/swagger/(.*)']
44
43
  });
45
- // (opzionale) puoi settare Swagger se vuoi:
46
- (0, SwaggerConfig_1.setupAllegatiSwagger)(nestApp);
44
+ // Note: Swagger setup is now handled by the unified module
47
45
  yield nestApp.init();
48
46
  }
49
47
  catch (error) {
package/dist/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
- import { DatabaseUpdater } from "./DatabaseUpdater";
2
- import { ExecutionTimeLogger } from "./ExecutionTimeLogger";
3
- import { LogLevels, Logger } from "./Logger";
4
- import { Orm } from "./Orm";
5
- import { DateUtilities, RestUtilities, DatabaseUtilities, StatusCode } from "./Utilities";
6
- import { autobind } from "./autobind";
7
- import { DocumentGenerator } from "./ContractGenerator";
8
- export * from "./allegati-module";
1
+ export * from "./Orm";
2
+ export * from "./Utilities";
3
+ export * from "./Logger";
4
+ export * from "./autobind";
5
+ export * from "./ExecutionTimeLogger";
6
+ export * from "./RoutesLoggerMiddleware";
7
+ export * from "./ContractGenerator";
8
+ export * from "./DatabaseUpdater";
9
9
  export * from "./accessi-module";
10
- export * from "es-node-firebird";
11
- export { autobind, ExecutionTimeLogger, Logger, LogLevels, Orm, DateUtilities, RestUtilities, DatabaseUtilities, DatabaseUpdater, StatusCode, DocumentGenerator };
10
+ export * from "./allegati-module";
11
+ export * from "./UnifiedModule";
12
+ export * from "./initializeUnifiedModule";
13
+ export * from "./swagger/SwaggerConfig";
package/dist/index.js CHANGED
@@ -14,25 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.DocumentGenerator = exports.StatusCode = exports.DatabaseUpdater = exports.DatabaseUtilities = exports.RestUtilities = exports.DateUtilities = exports.Orm = exports.LogLevels = exports.Logger = exports.ExecutionTimeLogger = exports.autobind = void 0;
18
- const DatabaseUpdater_1 = require("./DatabaseUpdater");
19
- Object.defineProperty(exports, "DatabaseUpdater", { enumerable: true, get: function () { return DatabaseUpdater_1.DatabaseUpdater; } });
20
- const ExecutionTimeLogger_1 = require("./ExecutionTimeLogger");
21
- Object.defineProperty(exports, "ExecutionTimeLogger", { enumerable: true, get: function () { return ExecutionTimeLogger_1.ExecutionTimeLogger; } });
22
- const Logger_1 = require("./Logger");
23
- Object.defineProperty(exports, "LogLevels", { enumerable: true, get: function () { return Logger_1.LogLevels; } });
24
- Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return Logger_1.Logger; } });
25
- const Orm_1 = require("./Orm");
26
- Object.defineProperty(exports, "Orm", { enumerable: true, get: function () { return Orm_1.Orm; } });
27
- const Utilities_1 = require("./Utilities");
28
- Object.defineProperty(exports, "DateUtilities", { enumerable: true, get: function () { return Utilities_1.DateUtilities; } });
29
- Object.defineProperty(exports, "RestUtilities", { enumerable: true, get: function () { return Utilities_1.RestUtilities; } });
30
- Object.defineProperty(exports, "DatabaseUtilities", { enumerable: true, get: function () { return Utilities_1.DatabaseUtilities; } });
31
- Object.defineProperty(exports, "StatusCode", { enumerable: true, get: function () { return Utilities_1.StatusCode; } });
32
- const autobind_1 = require("./autobind");
33
- Object.defineProperty(exports, "autobind", { enumerable: true, get: function () { return autobind_1.autobind; } });
34
- const ContractGenerator_1 = require("./ContractGenerator");
35
- Object.defineProperty(exports, "DocumentGenerator", { enumerable: true, get: function () { return ContractGenerator_1.DocumentGenerator; } });
36
- __exportStar(require("./allegati-module"), exports);
17
+ __exportStar(require("./Orm"), exports);
18
+ __exportStar(require("./Utilities"), exports);
19
+ __exportStar(require("./Logger"), exports);
20
+ __exportStar(require("./autobind"), exports);
21
+ __exportStar(require("./ExecutionTimeLogger"), exports);
22
+ __exportStar(require("./RoutesLoggerMiddleware"), exports);
23
+ __exportStar(require("./ContractGenerator"), exports);
24
+ __exportStar(require("./DatabaseUpdater"), exports);
37
25
  __exportStar(require("./accessi-module"), exports);
38
- __exportStar(require("es-node-firebird"), exports);
26
+ __exportStar(require("./allegati-module"), exports);
27
+ // Unified module exports
28
+ __exportStar(require("./UnifiedModule"), exports);
29
+ __exportStar(require("./initializeUnifiedModule"), exports);
30
+ __exportStar(require("./swagger/SwaggerConfig"), exports);
@@ -0,0 +1,8 @@
1
+ import { Application } from "express";
2
+ import { UnifiedModuleOptions } from "./UnifiedModule";
3
+ /**
4
+ * Initializes the unified module that combines Accessi and Allegati functionality
5
+ * @param app Express application instance
6
+ * @param options Configuration options for both modules
7
+ */
8
+ export declare function initializeUnifiedModule(app: Application, options: UnifiedModuleOptions): Promise<void>;
@@ -0,0 +1,45 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.initializeUnifiedModule = initializeUnifiedModule;
13
+ const core_1 = require("@nestjs/core");
14
+ const platform_express_1 = require("@nestjs/platform-express");
15
+ const UnifiedModule_1 = require("./UnifiedModule");
16
+ const SwaggerConfig_1 = require("./swagger/SwaggerConfig");
17
+ const Logger_1 = require("./Logger");
18
+ /**
19
+ * Initializes the unified module that combines Accessi and Allegati functionality
20
+ * @param app Express application instance
21
+ * @param options Configuration options for both modules
22
+ */
23
+ function initializeUnifiedModule(app, options) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const logger = new Logger_1.Logger("initializeUnifiedModule");
26
+ try {
27
+ const nestExpressInstance = new platform_express_1.ExpressAdapter(app);
28
+ const nestApp = yield core_1.NestFactory.create(UnifiedModule_1.UnifiedModule.forRoot(options), nestExpressInstance, {
29
+ bufferLogs: true
30
+ });
31
+ nestApp.enableCors();
32
+ nestApp.setGlobalPrefix('api', {
33
+ exclude: ['/swagger', '/swagger/(.*)']
34
+ });
35
+ // Setup unified Swagger documentation for all modules
36
+ (0, SwaggerConfig_1.setupSwagger)(nestApp);
37
+ yield nestApp.init();
38
+ logger.info("Unified module (Accessi + Allegati) initialized successfully");
39
+ }
40
+ catch (error) {
41
+ logger.error("Error initializing UnifiedModule:", error);
42
+ throw error;
43
+ }
44
+ });
45
+ }
@@ -0,0 +1,2 @@
1
+ import { INestApplication } from "@nestjs/common";
2
+ export declare function setupSwagger(app: INestApplication): void;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupAccessiSwagger = setupAccessiSwagger;
3
+ exports.setupSwagger = setupSwagger;
4
4
  const swagger_1 = require("@nestjs/swagger");
5
- const Logger_1 = require("../../Logger");
6
- function setupAccessiSwagger(app) {
5
+ const Logger_1 = require("../Logger");
6
+ function setupSwagger(app) {
7
7
  var _a, _b;
8
8
  const logger = new Logger_1.Logger("SwaggerConfig");
9
- const swaggerPath = "swagger/accessi";
9
+ const swaggerPath = "swagger";
10
10
  const swaggerJsonPath = `${swaggerPath}-json`;
11
11
  const config = new swagger_1.DocumentBuilder()
12
- .setTitle("Accessi API")
13
- .setDescription("API per la gestione degli accessi utenti")
12
+ .setTitle("API Documentation")
13
+ .setDescription("API per la gestione di accessi utenti e allegati")
14
14
  .setVersion("1.0")
15
15
  .addBearerAuth() // Per abilitare l'autenticazione JWT
16
16
  .build();
@@ -21,5 +21,5 @@ function setupAccessiSwagger(app) {
21
21
  res.send(document);
22
22
  });
23
23
  let port = ((_b = (_a = app.getHttpServer()) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.port) || 3000;
24
- logger.info(`Swagger disponibile su: http://localhost:${port}/${swaggerPath}`);
24
+ logger.info(`Swagger documentation available at: http://localhost:${port}/${swaggerPath}`);
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emilsoftware-utilities",
3
- "version": "1.3.129",
3
+ "version": "1.3.131",
4
4
  "description": "Utilities for EmilSoftware",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,2 +0,0 @@
1
- import { INestApplication } from "@nestjs/common";
2
- export declare function setupAccessiSwagger(app: INestApplication): void;
@@ -1,2 +0,0 @@
1
- import { INestApplication } from "@nestjs/common";
2
- export declare function setupAllegatiSwagger(app: INestApplication): void;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupAllegatiSwagger = setupAllegatiSwagger;
4
- const swagger_1 = require("@nestjs/swagger");
5
- const Logger_1 = require("../../Logger");
6
- function setupAllegatiSwagger(app) {
7
- var _a, _b;
8
- const logger = new Logger_1.Logger("SwaggerConfig");
9
- const swaggerPath = "swagger/allegati";
10
- const swaggerJsonPath = `${swaggerPath}-json`;
11
- const config = new swagger_1.DocumentBuilder()
12
- .setTitle("Allegati API")
13
- .setDescription("API per la gestione degli allegati")
14
- .setVersion("1.0")
15
- .addBearerAuth()
16
- .build();
17
- const document = swagger_1.SwaggerModule.createDocument(app, config);
18
- swagger_1.SwaggerModule.setup(swaggerPath, app, document);
19
- app.use(`/${swaggerJsonPath}`, (_, res) => {
20
- res.setHeader("Content-Type", "application/json");
21
- res.send(document);
22
- });
23
- let port = ((_b = (_a = app.getHttpServer()) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.port) || 3000;
24
- logger.info(`Swagger disponibile su: http://localhost:${port}/${swaggerPath}`);
25
- }