emilsoftware-utilities 2.0.0-dev.1 → 2.0.0-dev.3

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.
Files changed (95) hide show
  1. package/README.MD +38 -38
  2. package/dist/ContractGenerator.js.map +1 -1
  3. package/dist/DatabaseUpdater.js +24 -24
  4. package/dist/DatabaseUpdater.js.map +1 -1
  5. package/dist/EmilsoftwareModule.js.map +1 -1
  6. package/dist/ExecutionTimeLogger.js.map +1 -1
  7. package/dist/Logger.js.map +1 -1
  8. package/dist/Orm.d.ts +5 -0
  9. package/dist/Orm.js +149 -57
  10. package/dist/Orm.js.map +1 -1
  11. package/dist/RoutesLoggerMiddleware.js.map +1 -1
  12. package/dist/Utilities.d.ts +2 -2
  13. package/dist/Utilities.js +4 -0
  14. package/dist/Utilities.js.map +1 -1
  15. package/dist/accessi-module/AccessiModule.js.map +1 -1
  16. package/dist/accessi-module/Controllers/AuthController.js.map +1 -1
  17. package/dist/accessi-module/Controllers/ConfiguratorController.js.map +1 -1
  18. package/dist/accessi-module/Controllers/EmailController.js.map +1 -1
  19. package/dist/accessi-module/Controllers/FiltriController.js.map +1 -1
  20. package/dist/accessi-module/Controllers/PermissionController.js.map +1 -1
  21. package/dist/accessi-module/Controllers/UserController.js.map +1 -1
  22. package/dist/accessi-module/Dtos/Abilitazione.js.map +1 -1
  23. package/dist/accessi-module/Dtos/AbilitazioneMenu.js.map +1 -1
  24. package/dist/accessi-module/Dtos/AssignPermissionsToUserRequest.js.map +1 -1
  25. package/dist/accessi-module/Dtos/AssignRolesToUserRequest.js.map +1 -1
  26. package/dist/accessi-module/Dtos/BaseResponse.js.map +1 -1
  27. package/dist/accessi-module/Dtos/FiltriUtente.js.map +1 -1
  28. package/dist/accessi-module/Dtos/GetGroupsWithMenusResponse.js.map +1 -1
  29. package/dist/accessi-module/Dtos/GetMenusResponse.js.map +1 -1
  30. package/dist/accessi-module/Dtos/GetRolesResponse.js.map +1 -1
  31. package/dist/accessi-module/Dtos/GetUsersResponse.js.map +1 -1
  32. package/dist/accessi-module/Dtos/LoginRequest.js.map +1 -1
  33. package/dist/accessi-module/Dtos/LoginResponse.js.map +1 -1
  34. package/dist/accessi-module/Dtos/Permission.js.map +1 -1
  35. package/dist/accessi-module/Dtos/RegisterRequest.js.map +1 -1
  36. package/dist/accessi-module/Dtos/RegisterResponse.js.map +1 -1
  37. package/dist/accessi-module/Dtos/Role.js.map +1 -1
  38. package/dist/accessi-module/Dtos/RuoliMenu.js.map +1 -1
  39. package/dist/accessi-module/Dtos/SetStatoRegistrazione.js.map +1 -1
  40. package/dist/accessi-module/Dtos/StatoRegistrazione.js.map +1 -1
  41. package/dist/accessi-module/Dtos/TipoAbilitazione.js.map +1 -1
  42. package/dist/accessi-module/Dtos/TipoFiltro.js.map +1 -1
  43. package/dist/accessi-module/Dtos/TokenResult.js.map +1 -1
  44. package/dist/accessi-module/Dtos/UpdateEnabledStatusRequest.js.map +1 -1
  45. package/dist/accessi-module/Dtos/UserDto.js.map +1 -1
  46. package/dist/accessi-module/Dtos/UserGrantsDto.js.map +1 -1
  47. package/dist/accessi-module/Dtos/index.js.map +1 -1
  48. package/dist/accessi-module/Services/AuthService/AuthService.d.ts +1 -0
  49. package/dist/accessi-module/Services/AuthService/AuthService.js +12 -2
  50. package/dist/accessi-module/Services/AuthService/AuthService.js.map +1 -1
  51. package/dist/accessi-module/Services/ConfiguratorService/ConfiguratorService.js.map +1 -1
  52. package/dist/accessi-module/Services/EmailService/EmailService.js +11 -11
  53. package/dist/accessi-module/Services/EmailService/EmailService.js.map +1 -1
  54. package/dist/accessi-module/Services/FiltriService/FiltriService.js +1 -1
  55. package/dist/accessi-module/Services/FiltriService/FiltriService.js.map +1 -1
  56. package/dist/accessi-module/Services/PermissionService/PermissionService.js +87 -87
  57. package/dist/accessi-module/Services/PermissionService/PermissionService.js.map +1 -1
  58. package/dist/accessi-module/Services/UserService/UserService.js +65 -65
  59. package/dist/accessi-module/Services/UserService/UserService.js.map +1 -1
  60. package/dist/accessi-module/Views/reset-password.html +213 -213
  61. package/dist/accessi-module/database-updates/AccessiDatabaseUpdater.js +25 -16
  62. package/dist/accessi-module/database-updates/AccessiDatabaseUpdater.js.map +1 -1
  63. package/dist/accessi-module/database-updates/runAccessiDbUpdate.js.map +1 -1
  64. package/dist/accessi-module/index.js +16 -1
  65. package/dist/accessi-module/index.js.map +1 -1
  66. package/dist/accessi-module/jwt/jwt.strategy.js.map +1 -1
  67. package/dist/accessi-module/middleware/accessiRequirements.js.map +1 -1
  68. package/dist/accessi-module/middleware/authenticateGen.js.map +1 -1
  69. package/dist/accessi-module/security/accessControl.js.map +1 -1
  70. package/dist/accessi-module/security/authenticatedToken.js.map +1 -1
  71. package/dist/accessi-module/security/passwordResetToken.js.map +1 -1
  72. package/dist/accessi-module/security/publicAuthRateLimit.js.map +1 -1
  73. package/dist/allegati-module/AllegatiModule.js.map +1 -1
  74. package/dist/allegati-module/Controllers/AllegatiController.js.map +1 -1
  75. package/dist/allegati-module/Dtos/AllegatoDto.js.map +1 -1
  76. package/dist/allegati-module/Dtos/BaseResponse.js.map +1 -1
  77. package/dist/allegati-module/Dtos/UploadSingleFileRequest.js.map +1 -1
  78. package/dist/allegati-module/Dtos/index.js.map +1 -1
  79. package/dist/allegati-module/Dtos/responses/DownloadAllegatoResponseDto.js.map +1 -1
  80. package/dist/allegati-module/Dtos/responses/GetListResponse.js.map +1 -1
  81. package/dist/allegati-module/Dtos/responses/UploadAllegatoResponseDto.js.map +1 -1
  82. package/dist/allegati-module/Services/AllegatiService/AllegatiService.js +49 -49
  83. package/dist/allegati-module/Services/AllegatiService/AllegatiService.js.map +1 -1
  84. package/dist/allegati-module/index.js.map +1 -1
  85. package/dist/autobind.js.map +1 -1
  86. package/dist/firebird-compat.d.ts +15 -0
  87. package/dist/firebird-compat.js +198 -0
  88. package/dist/firebird-compat.js.map +1 -0
  89. package/dist/index.d.ts +4 -1
  90. package/dist/index.js +27 -1
  91. package/dist/index.js.map +1 -1
  92. package/dist/initEmilsoftwareModule.js.map +1 -1
  93. package/dist/swagger/SwaggerConfig.js.map +1 -1
  94. package/package.json +83 -83
  95. package/dist/emilsoftware-utilities-2.0.0-dev.1.tgz +0 -0
@@ -93,12 +93,12 @@ let AllegatiService = class AllegatiService {
93
93
  const chunk = file.buffer.slice(i, i + chunkSize);
94
94
  base64Content += chunk.toString('base64');
95
95
  }
96
- const insertQuery = `
97
- INSERT INTO ALLEGATI (
98
- CODICE, TIPCOD, ORDINE, DESALL, NOMEFILE,
99
- DADATAVAL, ADATAVAL, ALLEGATO, IDXTIPOALL, DATMODIF, DOCRIF
100
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?)
101
- RETURNING IDXALL
96
+ const insertQuery = `
97
+ INSERT INTO ALLEGATI (
98
+ CODICE, TIPCOD, ORDINE, DESALL, NOMEFILE,
99
+ DADATAVAL, ADATAVAL, ALLEGATO, IDXTIPOALL, DATMODIF, DOCRIF
100
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?)
101
+ RETURNING IDXALL
102
102
  `;
103
103
  const params = [
104
104
  uploadSingleFileRequest.codice,
@@ -133,10 +133,10 @@ let AllegatiService = class AllegatiService {
133
133
  ensureTableExists() {
134
134
  return __awaiter(this, void 0, void 0, function* () {
135
135
  try {
136
- const query = `
137
- SELECT RDB$RELATION_NAME
138
- FROM RDB$RELATIONS
139
- WHERE RDB$RELATION_NAME = 'ALLEGATI'
136
+ const query = `
137
+ SELECT RDB$RELATION_NAME
138
+ FROM RDB$RELATIONS
139
+ WHERE RDB$RELATION_NAME = 'ALLEGATI'
140
140
  `;
141
141
  const result = yield Orm_1.Orm.query(this.allegatiOptions.databaseOptions, query);
142
142
  if (!result || result.length === 0) {
@@ -155,13 +155,13 @@ let AllegatiService = class AllegatiService {
155
155
  if (!id || id <= 0) {
156
156
  throw new common_1.BadRequestException('ID allegato non valido');
157
157
  }
158
- const query = `
159
- SELECT
160
- ALLEGATO as content,
161
- NOMEFILE as filename,
162
- IDXTIPOALL as idTipoAllegato
163
- FROM ALLEGATI
164
- WHERE IDXALL = ?
158
+ const query = `
159
+ SELECT
160
+ ALLEGATO as content,
161
+ NOMEFILE as filename,
162
+ IDXTIPOALL as idTipoAllegato
163
+ FROM ALLEGATI
164
+ WHERE IDXALL = ?
165
165
  `;
166
166
  const results = yield Orm_1.Orm.query(this.allegatiOptions.databaseOptions, query, [id]);
167
167
  if (!results || results.length === 0) {
@@ -255,22 +255,22 @@ let AllegatiService = class AllegatiService {
255
255
  params.push(filters.idxtipoall);
256
256
  }
257
257
  }
258
- const query = `
259
- SELECT
260
- IDXALL as id,
261
- NOMEFILE as filename,
262
- 'application/octet-stream' as mimetype,
263
- DATMODIF as uploadDate,
264
- CODICE as codice,
265
- TIPCOD as tipoCodice,
266
- ORDINE as ordine,
267
- DESALL as descrizioneAllegato,
268
- DADATAVAL as dataInizioValidita,
269
- ADATAVAL as dataFineValidita,
270
- IDXTIPOALL as idTipoAllegato,
271
- DOCRIF as riferimentoDocumento
272
- FROM ALLEGATI
273
- ${whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : ''}
258
+ const query = `
259
+ SELECT
260
+ IDXALL as id,
261
+ NOMEFILE as filename,
262
+ 'application/octet-stream' as mimetype,
263
+ DATMODIF as uploadDate,
264
+ CODICE as codice,
265
+ TIPCOD as tipoCodice,
266
+ ORDINE as ordine,
267
+ DESALL as descrizioneAllegato,
268
+ DADATAVAL as dataInizioValidita,
269
+ ADATAVAL as dataFineValidita,
270
+ IDXTIPOALL as idTipoAllegato,
271
+ DOCRIF as riferimentoDocumento
272
+ FROM ALLEGATI
273
+ ${whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : ''}
274
274
  `;
275
275
  const results = yield Orm_1.Orm.query(this.allegatiOptions.databaseOptions, query, params);
276
276
  if (!results) {
@@ -324,22 +324,22 @@ let AllegatiService = class AllegatiService {
324
324
  whereConditions.push('IDXTIPOALL = ?');
325
325
  params.push(fields.idxtipoall);
326
326
  }
327
- const query = `
328
- SELECT
329
- IDXALL as id,
330
- NOMEFILE as filename,
331
- 'application/octet-stream' as mimetype,
332
- DATMODIF as uploadDate,
333
- CODICE as codice,
334
- TIPCOD as tipoCodice,
335
- ORDINE as ordine,
336
- DESALL as descrizioneAllegato,
337
- DADATAVAL as dataInizioValidita,
338
- ADATAVAL as dataFineValidita,
339
- IDXTIPOALL as idTipoAllegato,
340
- DOCRIF as riferimentoDocumento
341
- FROM ALLEGATI
342
- ${whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : ''}
327
+ const query = `
328
+ SELECT
329
+ IDXALL as id,
330
+ NOMEFILE as filename,
331
+ 'application/octet-stream' as mimetype,
332
+ DATMODIF as uploadDate,
333
+ CODICE as codice,
334
+ TIPCOD as tipoCodice,
335
+ ORDINE as ordine,
336
+ DESALL as descrizioneAllegato,
337
+ DADATAVAL as dataInizioValidita,
338
+ ADATAVAL as dataFineValidita,
339
+ IDXTIPOALL as idTipoAllegato,
340
+ DOCRIF as riferimentoDocumento
341
+ FROM ALLEGATI
342
+ ${whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : ''}
343
343
  `;
344
344
  const results = yield Orm_1.Orm.query(this.allegatiOptions.databaseOptions, query, params);
345
345
  if (!results) {
@@ -1 +1 @@
1
- {"version":3,"file":"AllegatiService.js","sourceRoot":"","sources":["../../../../src/allegati-module/Services/AllegatiService/AllegatiService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0H;AAC1H,gDAA6C;AAC7C,sCAAmC;AAKnC,MAAa,aAAc,SAAQ,KAAK;IACpC,YACI,OAAe,EACC,IAAY,EACZ,aAAqB,GAAG;QAExC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAc;QAGxC,IAAI,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AC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAClD,CAAC;KAAA;CAEJ,CAAA;AAlZY,0CAAe;0BAAf,eAAe;IAF3B,mBAAQ;IACR,IAAA,mBAAU,GAAE;IAaI,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;;GAZ9B,eAAe,CAkZ3B","sourcesContent":["import { Inject, Injectable, NotFoundException, BadRequestException, InternalServerErrorException } from \"@nestjs/common\";\nimport { autobind } from \"../../../autobind\";\nimport { Orm } from \"../../../Orm\";\nimport { AllegatiOptions } from \"../../AllegatiModule\";\nimport { UploadAllegatoResponseDto, DownloadAllegatoResponseDto, AllegatoDto} from \"../../Dtos\";\nimport { UploadSingleFileRequest } from \"../../Dtos/UploadSingleFileRequest\";\n\nexport class AllegatiError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly statusCode: number = 500\n ) {\n super(message);\n this.name = 'AllegatiError';\n }\n}\n\n@autobind\n@Injectable()\nexport class AllegatiService {\n private readonly MAX_FILE_SIZE = 90 * 1024 * 1024; // 90MB\n private readonly ALLOWED_MIME_TYPES = [\n 'application/pdf',\n 'image/jpeg',\n 'image/png',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/vnd.ms-excel',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n ];\n\n constructor(@Inject('ALLEGATI_OPTIONS') private readonly allegatiOptions: AllegatiOptions) {\n this.ensureTableExists().catch(error => {\n console.error('[AllegatiService] Errore creazione tabella ALLEGATI:', error);\n // throw new InternalServerErrorException('Errore durante l\\'inizializzazione del servizio allegati');\n });\n }\n\n private validateFile(file: Express.Multer.File): void {\n if (!file) {\n throw new BadRequestException('Nessun file fornito');\n }\n\n if (file.size > this.MAX_FILE_SIZE) {\n throw new BadRequestException(`File troppo grande. Dimensione massima consentita: ${this.MAX_FILE_SIZE / (1024 * 1024)}MB`);\n }\n\n if (!this.ALLOWED_MIME_TYPES.includes(file.mimetype)) {\n throw new BadRequestException(`Tipo di file non consentito. Tipi consentiti: ${this.ALLOWED_MIME_TYPES.join(', ')}`);\n }\n }\n\n\n async getAttachmentTypes(): Promise<any[]> {\n try {\n const query = `SELECT IDXTIPOALL as id, DESCRIZIONE as description FROM TIPOALL`;\n const results = await Orm.query(this.allegatiOptions.databaseOptions, query);\n \n if (!results) {\n throw new InternalServerErrorException('Errore durante il recupero dei tipi di allegato');\n }\n\n return results;\n } catch (error) {\n console.error('[AllegatiService] getAttachmentTypes - Errore:', error);\n if (error instanceof InternalServerErrorException) {\n throw error;\n }\n throw new InternalServerErrorException('Errore durante il recupero dei tipi di allegato');\n }\n }\n async uploadFile(file: Express.Multer.File, uploadSingleFileRequest: UploadSingleFileRequest): Promise<UploadAllegatoResponseDto> {\n try {\n this.validateFile(file);\n\n // Convert buffer to base64 in chunks to avoid memory issues\n const chunkSize = 1024 * 1024; // 1MB chunks\n let base64Content = '';\n for (let i = 0; i < file.buffer.length; i += chunkSize) {\n const chunk = file.buffer.slice(i, i + chunkSize);\n base64Content += chunk.toString('base64');\n }\n\n const insertQuery = `\n INSERT INTO ALLEGATI (\n CODICE, TIPCOD, ORDINE, DESALL, NOMEFILE,\n DADATAVAL, ADATAVAL, ALLEGATO, IDXTIPOALL, DATMODIF, DOCRIF\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?)\n RETURNING IDXALL\n `;\n\n const params = [\n uploadSingleFileRequest.codice,\n uploadSingleFileRequest.tipoCodice,\n uploadSingleFileRequest.ordine,\n uploadSingleFileRequest.descrizioneAllegato,\n file.originalname,\n uploadSingleFileRequest.dataInizioValidita,\n uploadSingleFileRequest.dataFineValidita,\n base64Content,\n uploadSingleFileRequest.idTipoAllegato,\n uploadSingleFileRequest.riferimentoDocumento\n ];\n\n const result = await Orm.query(this.allegatiOptions.databaseOptions, insertQuery, params);\n \n if (!result || !result.IDXALL) {\n throw new InternalServerErrorException('Errore durante il salvataggio del file');\n }\n\n return {\n id: result.IDXALL,\n filename: file.originalname,\n };\n } catch (error) {\n console.error('[AllegatiService] uploadFile - Errore:', error);\n if (error instanceof BadRequestException || error instanceof InternalServerErrorException) {\n throw error;\n }\n throw new InternalServerErrorException('Errore durante il caricamento del file');\n }\n }\n\n async ensureTableExists(): Promise<void> {\n try {\n const query = `\n SELECT RDB$RELATION_NAME \n FROM RDB$RELATIONS \n WHERE RDB$RELATION_NAME = 'ALLEGATI'\n `;\n const result = await Orm.query(this.allegatiOptions.databaseOptions, query);\n \n if (!result || result.length === 0) {\n throw new Error('Tabella ALLEGATI non trovata nel database');\n }\n } catch (error) {\n console.error('[AllegatiService] Errore verifica tabella ALLEGATI:', error);\n throw new InternalServerErrorException('Errore durante la verifica della tabella ALLEGATI');\n }\n }\n\n async downloadFile(id: number): Promise<DownloadAllegatoResponseDto> {\n try {\n if (!id || id <= 0) {\n throw new BadRequestException('ID allegato non valido');\n }\n\n const query = `\n SELECT \n ALLEGATO as content,\n NOMEFILE as filename,\n IDXTIPOALL as idTipoAllegato\n FROM ALLEGATI \n WHERE IDXALL = ?\n `;\n \n const results = await Orm.query(this.allegatiOptions.databaseOptions, query, [id]);\n \n if (!results || results.length === 0) {\n throw new NotFoundException(`Allegato con ID ${id} non trovato`);\n }\n\n const result = results[0];\n if (!result.CONTENT) {\n throw new InternalServerErrorException('Contenuto file non disponibile');\n }\n\n if (!result.FILENAME) {\n throw new InternalServerErrorException('Nome file non disponibile');\n }\n\n const mimetype = this.detectMimeType(result.FILENAME);\n \n return {\n contentBase64: result.CONTENT,\n filename: result.FILENAME,\n mimetype\n };\n } catch (error) {\n console.error('[AllegatiService] downloadFile - Errore:', error);\n if (error instanceof BadRequestException || \n error instanceof NotFoundException || \n error instanceof InternalServerErrorException) {\n throw error;\n }\n throw new InternalServerErrorException('Errore durante il download del file');\n }\n }\n\n private detectMimeType(filename: string): string {\n const extension = filename.split('.').pop()?.toLowerCase();\n const mimeTypes: { [key: string]: string } = {\n 'pdf': 'application/pdf',\n 'jpg': 'image/jpeg',\n 'jpeg': 'image/jpeg',\n 'png': 'image/png',\n 'doc': 'application/msword',\n 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'xls': 'application/vnd.ms-excel',\n 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n };\n return mimeTypes[extension || ''] || 'application/octet-stream';\n }\n\n async deleteFile(id: number): Promise<void> {\n try {\n if (!id || id <= 0) {\n throw new BadRequestException('ID allegato non valido');\n }\n\n const checkQuery = `SELECT IDXALL FROM ALLEGATI WHERE IDXALL = ?`;\n const checkResult = await Orm.query(this.allegatiOptions.databaseOptions, checkQuery, [id]);\n \n if (!checkResult || checkResult.length === 0) {\n throw new NotFoundException(`Allegato con ID ${id} non trovato`);\n }\n\n const query = `DELETE FROM ALLEGATI WHERE IDXALL = ?`;\n await Orm.execute(this.allegatiOptions.databaseOptions, query, [id]);\n \n \n } catch (error) {\n console.error('[AllegatiService] deleteFile - Errore:', error);\n if (error instanceof BadRequestException || \n error instanceof NotFoundException || \n error instanceof InternalServerErrorException) {\n throw error;\n }\n throw new InternalServerErrorException('Errore durante la cancellazione del file');\n }\n }\n\n async listFiles(filters?: { \n tipcod?: string;\n codice?: number;\n docrif?: string;\n idxtipoall?: number;\n }): Promise<AllegatoDto[]> {\n try {\n const whereConditions: string[] = [];\n const params: any[] = [];\n\n if (filters) {\n if (filters.tipcod) {\n whereConditions.push('TIPCOD = ?');\n params.push(filters.tipcod);\n }\n if (filters.codice) {\n whereConditions.push('CODICE = ?');\n params.push(filters.codice);\n }\n if (filters.docrif) {\n whereConditions.push('DOCRIF = ?');\n params.push(filters.docrif);\n }\n if (filters.idxtipoall !== undefined) {\n whereConditions.push('IDXTIPOALL = ?');\n params.push(filters.idxtipoall);\n }\n }\n\n const query = `\n SELECT \n IDXALL as id,\n NOMEFILE as filename,\n 'application/octet-stream' as mimetype,\n DATMODIF as uploadDate,\n CODICE as codice,\n TIPCOD as tipoCodice,\n ORDINE as ordine,\n DESALL as descrizioneAllegato,\n DADATAVAL as dataInizioValidita,\n ADATAVAL as dataFineValidita,\n IDXTIPOALL as idTipoAllegato,\n DOCRIF as riferimentoDocumento\n FROM ALLEGATI\n ${whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : ''}\n `;\n\n const results = await Orm.query(this.allegatiOptions.databaseOptions, query, params);\n \n if (!results) {\n throw new InternalServerErrorException('Errore durante il recupero della lista dei file');\n }\n\n return results.map((r: any) => ({\n id: r.ID,\n filename: r.FILENAME,\n mimetype: r.MIMETYPE,\n uploadDate: r.UPLOADDATE,\n codice: r.CODICE,\n tipoCodice: r.TIPOCODICE,\n ordine: r.ORDINE,\n descrizioneAllegato: r.DESCRIZIONEALLEGATO,\n dataInizioValidita: r.DATAINIZIOVALIDITA,\n dataFineValidita: r.DATAFINEVALIDITA,\n idTipoAllegato: r.IDTIPOALLEGATO,\n riferimentoDocumento: r.RIFERIMENTODOCUMENTO\n }));\n } catch (error) {\n console.error('[AllegatiService] listFiles - Errore:', error);\n if (error instanceof InternalServerErrorException) {\n throw error;\n }\n throw new InternalServerErrorException('Errore durante il recupero della lista dei file');\n }\n }\n\n /**\n * Find allegati by any combination of tipcod, codice, docrif, idxtipoall\n */\n async findByFields(fields: { tipcod?: string; codice?: number; docrif?: string; idxtipoall?: number }): Promise<AllegatoDto[]> {\n try {\n const whereConditions: string[] = [];\n const params: any[] = [];\n if (fields.tipcod) {\n whereConditions.push('TIPCOD = ?');\n params.push(fields.tipcod);\n }\n if (fields.codice) {\n whereConditions.push('CODICE = ?');\n params.push(fields.codice);\n }\n if (fields.docrif) {\n whereConditions.push('DOCRIF = ?');\n params.push(fields.docrif);\n }\n if (fields.idxtipoall !== undefined) {\n whereConditions.push('IDXTIPOALL = ?');\n params.push(fields.idxtipoall);\n }\n const query = `\n SELECT \n IDXALL as id,\n NOMEFILE as filename,\n 'application/octet-stream' as mimetype,\n DATMODIF as uploadDate,\n CODICE as codice,\n TIPCOD as tipoCodice,\n ORDINE as ordine,\n DESALL as descrizioneAllegato,\n DADATAVAL as dataInizioValidita,\n ADATAVAL as dataFineValidita,\n IDXTIPOALL as idTipoAllegato,\n DOCRIF as riferimentoDocumento\n FROM ALLEGATI\n ${whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : ''}\n `;\n const results = await Orm.query(this.allegatiOptions.databaseOptions, query, params);\n if (!results) {\n throw new InternalServerErrorException('Errore durante la ricerca degli allegati');\n }\n return results.map((r: any) => ({\n id: r.ID,\n filename: r.FILENAME,\n mimetype: r.MIMETYPE,\n uploadDate: r.UPLOADDATE,\n codice: r.CODICE,\n tipoCodice: r.TIPOCODICE,\n ordine: r.ORDINE,\n descrizioneAllegato: r.DESCRIZIONEALLEGATO,\n dataInizioValidita: r.DATAINIZIOVALIDITA,\n dataFineValidita: r.DATAFINEVALIDITA,\n idTipoAllegato: r.IDTIPOALLEGATO,\n riferimentoDocumento: r.RIFERIMENTODOCUMENTO\n }));\n } catch (error) {\n console.error('[AllegatiService] findByFields - Errore:', error);\n throw new InternalServerErrorException('Errore durante la ricerca degli allegati');\n }\n }\n\n /**\n * Update tipcod, codice, docrif, idxtipoall for a given allegato by id\n */\n async updateFieldsById(id: number, fields: { tipcod?: string; codice?: number; docrif?: string; idxtipoall?: number }): Promise<void> {\n try {\n if (!id || id <= 0) {\n throw new BadRequestException('ID allegato non valido');\n }\n const updates: string[] = [];\n const params: any[] = [];\n if (fields.tipcod !== undefined) {\n updates.push('TIPCOD = ?');\n params.push(fields.tipcod);\n }\n if (fields.codice !== undefined) {\n updates.push('CODICE = ?');\n params.push(fields.codice);\n }\n if (fields.docrif !== undefined) {\n updates.push('DOCRIF = ?');\n params.push(fields.docrif);\n }\n if (fields.idxtipoall !== undefined) {\n updates.push('IDXTIPOALL = ?');\n params.push(fields.idxtipoall);\n }\n if (updates.length === 0) {\n throw new BadRequestException('Nessun campo da aggiornare');\n }\n const query = `UPDATE ALLEGATI SET ${updates.join(', ')} WHERE IDXALL = ?`;\n params.push(id);\n const result = await Orm.execute(this.allegatiOptions.databaseOptions, query, params);\n if (!result) {\n throw new InternalServerErrorException('Errore durante l\\'aggiornamento del file');\n }\n } catch (error) {\n console.error('[AllegatiService] updateFieldsById - Errore:', error);\n throw error;\n }\n }\n\n /**\n * Get a single allegato by fields (returns the first match)\n */\n async getOneByFields(fields: { tipcod?: string; codice?: number; docrif?: string; idxtipoall?: number }): Promise<AllegatoDto | null> {\n const results = await this.findByFields(fields);\n return results.length > 0 ? results[0] : null;\n }\n\n}"]}
1
+ {"version":3,"file":"AllegatiService.js","sourceRoot":"","sources":["../../../../src/allegati-module/Services/AllegatiService/AllegatiService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0H;AAC1H,gDAA6C;AAC7C,sCAAmC;AAKnC,MAAa,aAAc,SAAQ,KAAK;IACpC,YACI,OAAe,EACC,IAAY,EACZ,aAAqB,GAAG;QAExC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAc;QAGxC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAChC,CAAC;CACJ;AATD,sCASC;AAIM,IAAM,eAAe,GAArB,MAAM,eAAe;IAYxB,YAAwC,eAAiD;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAXxE,kBAAa,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO;QACzC,uBAAkB,GAAG;YAClC,iBAAiB;YACjB,YAAY;YACZ,WAAW;YACX,oBAAoB;YACpB,yEAAyE;YACzE,0BAA0B;YAC1B,mEAAmE;SACtE,CAAC;QAGE,IAAI,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YACnC,OAAO,CAAC,KAAK,CAAC,sDAAsD,EAAE,KAAK,CAAC,CAAC;YAC9E,sGAAsG;QACzG,C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MAAM,IAAI,4BAAmB,CAAC,4BAA4B,CAAC,CAAC;gBAChE,CAAC;gBACD,MAAM,KAAK,GAAG,uBAAuB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC;gBAC3E,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAChB,MAAM,MAAM,GAAG,MAAM,SAAG,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;gBACtF,IAAI,CAAC,MAAM,EAAE,CAAC;oBACV,MAAM,IAAI,qCAA4B,CAAC,0CAA0C,CAAC,CAAC;gBACvF,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;gBACrE,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC;KAAA;IAED;;OAEG;IACG,cAAc,CAAC,MAAkF;;YACnG,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAChD,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAClD,CAAC;KAAA;CAEJ,CAAA;AAlZY,0CAAe;0BAAf,eAAe;IAF3B,mBAAQ;IACR,IAAA,mBAAU,GAAE;IAaI,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;;GAZ9B,eAAe,CAkZ3B","sourcesContent":["import { Inject, Injectable, NotFoundException, BadRequestException, InternalServerErrorException } from \"@nestjs/common\";\r\nimport { autobind } from \"../../../autobind\";\r\nimport { Orm } from \"../../../Orm\";\r\nimport { AllegatiOptions } from \"../../AllegatiModule\";\r\nimport { UploadAllegatoResponseDto, DownloadAllegatoResponseDto, AllegatoDto} from \"../../Dtos\";\r\nimport { UploadSingleFileRequest } from \"../../Dtos/UploadSingleFileRequest\";\r\n\r\nexport class AllegatiError extends Error {\r\n constructor(\r\n message: string,\r\n public readonly code: string,\r\n public readonly statusCode: number = 500\r\n ) {\r\n super(message);\r\n this.name = 'AllegatiError';\r\n }\r\n}\r\n\r\n@autobind\r\n@Injectable()\r\nexport class AllegatiService {\r\n private readonly MAX_FILE_SIZE = 90 * 1024 * 1024; // 90MB\r\n private readonly ALLOWED_MIME_TYPES = [\r\n 'application/pdf',\r\n 'image/jpeg',\r\n 'image/png',\r\n 'application/msword',\r\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\r\n 'application/vnd.ms-excel',\r\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\r\n ];\r\n\r\n constructor(@Inject('ALLEGATI_OPTIONS') private readonly allegatiOptions: AllegatiOptions) {\r\n this.ensureTableExists().catch(error => {\r\n console.error('[AllegatiService] Errore creazione tabella ALLEGATI:', error);\r\n // throw new InternalServerErrorException('Errore durante l\\'inizializzazione del servizio allegati');\r\n });\r\n }\r\n\r\n private validateFile(file: Express.Multer.File): void {\r\n if (!file) {\r\n throw new BadRequestException('Nessun file fornito');\r\n }\r\n\r\n if (file.size > this.MAX_FILE_SIZE) {\r\n throw new BadRequestException(`File troppo grande. Dimensione massima consentita: ${this.MAX_FILE_SIZE / (1024 * 1024)}MB`);\r\n }\r\n\r\n if (!this.ALLOWED_MIME_TYPES.includes(file.mimetype)) {\r\n throw new BadRequestException(`Tipo di file non consentito. Tipi consentiti: ${this.ALLOWED_MIME_TYPES.join(', ')}`);\r\n }\r\n }\r\n\r\n\r\n async getAttachmentTypes(): Promise<any[]> {\r\n try {\r\n const query = `SELECT IDXTIPOALL as id, DESCRIZIONE as description FROM TIPOALL`;\r\n const results = await Orm.query(this.allegatiOptions.databaseOptions, query);\r\n \r\n if (!results) {\r\n throw new InternalServerErrorException('Errore durante il recupero dei tipi di allegato');\r\n }\r\n\r\n return results;\r\n } catch (error) {\r\n console.error('[AllegatiService] getAttachmentTypes - Errore:', error);\r\n if (error instanceof InternalServerErrorException) {\r\n throw error;\r\n }\r\n throw new InternalServerErrorException('Errore durante il recupero dei tipi di allegato');\r\n }\r\n }\r\n async uploadFile(file: Express.Multer.File, uploadSingleFileRequest: UploadSingleFileRequest): Promise<UploadAllegatoResponseDto> {\r\n try {\r\n this.validateFile(file);\r\n\r\n // Convert buffer to base64 in chunks to avoid memory issues\r\n const chunkSize = 1024 * 1024; // 1MB chunks\r\n let base64Content = '';\r\n for (let i = 0; i < file.buffer.length; i += chunkSize) {\r\n const chunk = file.buffer.slice(i, i + chunkSize);\r\n base64Content += chunk.toString('base64');\r\n }\r\n\r\n const insertQuery = `\r\n INSERT INTO ALLEGATI (\r\n CODICE, TIPCOD, ORDINE, DESALL, NOMEFILE,\r\n DADATAVAL, ADATAVAL, ALLEGATO, IDXTIPOALL, DATMODIF, DOCRIF\r\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, ?)\r\n RETURNING IDXALL\r\n `;\r\n\r\n const params = [\r\n uploadSingleFileRequest.codice,\r\n uploadSingleFileRequest.tipoCodice,\r\n uploadSingleFileRequest.ordine,\r\n uploadSingleFileRequest.descrizioneAllegato,\r\n file.originalname,\r\n uploadSingleFileRequest.dataInizioValidita,\r\n uploadSingleFileRequest.dataFineValidita,\r\n base64Content,\r\n uploadSingleFileRequest.idTipoAllegato,\r\n uploadSingleFileRequest.riferimentoDocumento\r\n ];\r\n\r\n const result = await Orm.query(this.allegatiOptions.databaseOptions, insertQuery, params);\r\n \r\n if (!result || !result.IDXALL) {\r\n throw new InternalServerErrorException('Errore durante il salvataggio del file');\r\n }\r\n\r\n return {\r\n id: result.IDXALL,\r\n filename: file.originalname,\r\n };\r\n } catch (error) {\r\n console.error('[AllegatiService] uploadFile - Errore:', error);\r\n if (error instanceof BadRequestException || error instanceof InternalServerErrorException) {\r\n throw error;\r\n }\r\n throw new InternalServerErrorException('Errore durante il caricamento del file');\r\n }\r\n }\r\n\r\n async ensureTableExists(): Promise<void> {\r\n try {\r\n const query = `\r\n SELECT RDB$RELATION_NAME \r\n FROM RDB$RELATIONS \r\n WHERE RDB$RELATION_NAME = 'ALLEGATI'\r\n `;\r\n const result = await Orm.query(this.allegatiOptions.databaseOptions, query);\r\n \r\n if (!result || result.length === 0) {\r\n throw new Error('Tabella ALLEGATI non trovata nel database');\r\n }\r\n } catch (error) {\r\n console.error('[AllegatiService] Errore verifica tabella ALLEGATI:', error);\r\n throw new InternalServerErrorException('Errore durante la verifica della tabella ALLEGATI');\r\n }\r\n }\r\n\r\n async downloadFile(id: number): Promise<DownloadAllegatoResponseDto> {\r\n try {\r\n if (!id || id <= 0) {\r\n throw new BadRequestException('ID allegato non valido');\r\n }\r\n\r\n const query = `\r\n SELECT \r\n ALLEGATO as content,\r\n NOMEFILE as filename,\r\n IDXTIPOALL as idTipoAllegato\r\n FROM ALLEGATI \r\n WHERE IDXALL = ?\r\n `;\r\n \r\n const results = await Orm.query(this.allegatiOptions.databaseOptions, query, [id]);\r\n \r\n if (!results || results.length === 0) {\r\n throw new NotFoundException(`Allegato con ID ${id} non trovato`);\r\n }\r\n\r\n const result = results[0];\r\n if (!result.CONTENT) {\r\n throw new InternalServerErrorException('Contenuto file non disponibile');\r\n }\r\n\r\n if (!result.FILENAME) {\r\n throw new InternalServerErrorException('Nome file non disponibile');\r\n }\r\n\r\n const mimetype = this.detectMimeType(result.FILENAME);\r\n \r\n return {\r\n contentBase64: result.CONTENT,\r\n filename: result.FILENAME,\r\n mimetype\r\n };\r\n } catch (error) {\r\n console.error('[AllegatiService] downloadFile - Errore:', error);\r\n if (error instanceof BadRequestException || \r\n error instanceof NotFoundException || \r\n error instanceof InternalServerErrorException) {\r\n throw error;\r\n }\r\n throw new InternalServerErrorException('Errore durante il download del file');\r\n }\r\n }\r\n\r\n private detectMimeType(filename: string): string {\r\n const extension = filename.split('.').pop()?.toLowerCase();\r\n const mimeTypes: { [key: string]: string } = {\r\n 'pdf': 'application/pdf',\r\n 'jpg': 'image/jpeg',\r\n 'jpeg': 'image/jpeg',\r\n 'png': 'image/png',\r\n 'doc': 'application/msword',\r\n 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\r\n 'xls': 'application/vnd.ms-excel',\r\n 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\r\n };\r\n return mimeTypes[extension || ''] || 'application/octet-stream';\r\n }\r\n\r\n async deleteFile(id: number): Promise<void> {\r\n try {\r\n if (!id || id <= 0) {\r\n throw new BadRequestException('ID allegato non valido');\r\n }\r\n\r\n const checkQuery = `SELECT IDXALL FROM ALLEGATI WHERE IDXALL = ?`;\r\n const checkResult = await Orm.query(this.allegatiOptions.databaseOptions, checkQuery, [id]);\r\n \r\n if (!checkResult || checkResult.length === 0) {\r\n throw new NotFoundException(`Allegato con ID ${id} non trovato`);\r\n }\r\n\r\n const query = `DELETE FROM ALLEGATI WHERE IDXALL = ?`;\r\n await Orm.execute(this.allegatiOptions.databaseOptions, query, [id]);\r\n \r\n \r\n } catch (error) {\r\n console.error('[AllegatiService] deleteFile - Errore:', error);\r\n if (error instanceof BadRequestException || \r\n error instanceof NotFoundException || \r\n error instanceof InternalServerErrorException) {\r\n throw error;\r\n }\r\n throw new InternalServerErrorException('Errore durante la cancellazione del file');\r\n }\r\n }\r\n\r\n async listFiles(filters?: { \r\n tipcod?: string;\r\n codice?: number;\r\n docrif?: string;\r\n idxtipoall?: number;\r\n }): Promise<AllegatoDto[]> {\r\n try {\r\n const whereConditions: string[] = [];\r\n const params: any[] = [];\r\n\r\n if (filters) {\r\n if (filters.tipcod) {\r\n whereConditions.push('TIPCOD = ?');\r\n params.push(filters.tipcod);\r\n }\r\n if (filters.codice) {\r\n whereConditions.push('CODICE = ?');\r\n params.push(filters.codice);\r\n }\r\n if (filters.docrif) {\r\n whereConditions.push('DOCRIF = ?');\r\n params.push(filters.docrif);\r\n }\r\n if (filters.idxtipoall !== undefined) {\r\n whereConditions.push('IDXTIPOALL = ?');\r\n params.push(filters.idxtipoall);\r\n }\r\n }\r\n\r\n const query = `\r\n SELECT \r\n IDXALL as id,\r\n NOMEFILE as filename,\r\n 'application/octet-stream' as mimetype,\r\n DATMODIF as uploadDate,\r\n CODICE as codice,\r\n TIPCOD as tipoCodice,\r\n ORDINE as ordine,\r\n DESALL as descrizioneAllegato,\r\n DADATAVAL as dataInizioValidita,\r\n ADATAVAL as dataFineValidita,\r\n IDXTIPOALL as idTipoAllegato,\r\n DOCRIF as riferimentoDocumento\r\n FROM ALLEGATI\r\n ${whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : ''}\r\n `;\r\n\r\n const results = await Orm.query(this.allegatiOptions.databaseOptions, query, params);\r\n \r\n if (!results) {\r\n throw new InternalServerErrorException('Errore durante il recupero della lista dei file');\r\n }\r\n\r\n return results.map((r: any) => ({\r\n id: r.ID,\r\n filename: r.FILENAME,\r\n mimetype: r.MIMETYPE,\r\n uploadDate: r.UPLOADDATE,\r\n codice: r.CODICE,\r\n tipoCodice: r.TIPOCODICE,\r\n ordine: r.ORDINE,\r\n descrizioneAllegato: r.DESCRIZIONEALLEGATO,\r\n dataInizioValidita: r.DATAINIZIOVALIDITA,\r\n dataFineValidita: r.DATAFINEVALIDITA,\r\n idTipoAllegato: r.IDTIPOALLEGATO,\r\n riferimentoDocumento: r.RIFERIMENTODOCUMENTO\r\n }));\r\n } catch (error) {\r\n console.error('[AllegatiService] listFiles - Errore:', error);\r\n if (error instanceof InternalServerErrorException) {\r\n throw error;\r\n }\r\n throw new InternalServerErrorException('Errore durante il recupero della lista dei file');\r\n }\r\n }\r\n\r\n /**\r\n * Find allegati by any combination of tipcod, codice, docrif, idxtipoall\r\n */\r\n async findByFields(fields: { tipcod?: string; codice?: number; docrif?: string; idxtipoall?: number }): Promise<AllegatoDto[]> {\r\n try {\r\n const whereConditions: string[] = [];\r\n const params: any[] = [];\r\n if (fields.tipcod) {\r\n whereConditions.push('TIPCOD = ?');\r\n params.push(fields.tipcod);\r\n }\r\n if (fields.codice) {\r\n whereConditions.push('CODICE = ?');\r\n params.push(fields.codice);\r\n }\r\n if (fields.docrif) {\r\n whereConditions.push('DOCRIF = ?');\r\n params.push(fields.docrif);\r\n }\r\n if (fields.idxtipoall !== undefined) {\r\n whereConditions.push('IDXTIPOALL = ?');\r\n params.push(fields.idxtipoall);\r\n }\r\n const query = `\r\n SELECT \r\n IDXALL as id,\r\n NOMEFILE as filename,\r\n 'application/octet-stream' as mimetype,\r\n DATMODIF as uploadDate,\r\n CODICE as codice,\r\n TIPCOD as tipoCodice,\r\n ORDINE as ordine,\r\n DESALL as descrizioneAllegato,\r\n DADATAVAL as dataInizioValidita,\r\n ADATAVAL as dataFineValidita,\r\n IDXTIPOALL as idTipoAllegato,\r\n DOCRIF as riferimentoDocumento\r\n FROM ALLEGATI\r\n ${whereConditions.length > 0 ? `WHERE ${whereConditions.join(' AND ')}` : ''}\r\n `;\r\n const results = await Orm.query(this.allegatiOptions.databaseOptions, query, params);\r\n if (!results) {\r\n throw new InternalServerErrorException('Errore durante la ricerca degli allegati');\r\n }\r\n return results.map((r: any) => ({\r\n id: r.ID,\r\n filename: r.FILENAME,\r\n mimetype: r.MIMETYPE,\r\n uploadDate: r.UPLOADDATE,\r\n codice: r.CODICE,\r\n tipoCodice: r.TIPOCODICE,\r\n ordine: r.ORDINE,\r\n descrizioneAllegato: r.DESCRIZIONEALLEGATO,\r\n dataInizioValidita: r.DATAINIZIOVALIDITA,\r\n dataFineValidita: r.DATAFINEVALIDITA,\r\n idTipoAllegato: r.IDTIPOALLEGATO,\r\n riferimentoDocumento: r.RIFERIMENTODOCUMENTO\r\n }));\r\n } catch (error) {\r\n console.error('[AllegatiService] findByFields - Errore:', error);\r\n throw new InternalServerErrorException('Errore durante la ricerca degli allegati');\r\n }\r\n }\r\n\r\n /**\r\n * Update tipcod, codice, docrif, idxtipoall for a given allegato by id\r\n */\r\n async updateFieldsById(id: number, fields: { tipcod?: string; codice?: number; docrif?: string; idxtipoall?: number }): Promise<void> {\r\n try {\r\n if (!id || id <= 0) {\r\n throw new BadRequestException('ID allegato non valido');\r\n }\r\n const updates: string[] = [];\r\n const params: any[] = [];\r\n if (fields.tipcod !== undefined) {\r\n updates.push('TIPCOD = ?');\r\n params.push(fields.tipcod);\r\n }\r\n if (fields.codice !== undefined) {\r\n updates.push('CODICE = ?');\r\n params.push(fields.codice);\r\n }\r\n if (fields.docrif !== undefined) {\r\n updates.push('DOCRIF = ?');\r\n params.push(fields.docrif);\r\n }\r\n if (fields.idxtipoall !== undefined) {\r\n updates.push('IDXTIPOALL = ?');\r\n params.push(fields.idxtipoall);\r\n }\r\n if (updates.length === 0) {\r\n throw new BadRequestException('Nessun campo da aggiornare');\r\n }\r\n const query = `UPDATE ALLEGATI SET ${updates.join(', ')} WHERE IDXALL = ?`;\r\n params.push(id);\r\n const result = await Orm.execute(this.allegatiOptions.databaseOptions, query, params);\r\n if (!result) {\r\n throw new InternalServerErrorException('Errore durante l\\'aggiornamento del file');\r\n }\r\n } catch (error) {\r\n console.error('[AllegatiService] updateFieldsById - Errore:', error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Get a single allegato by fields (returns the first match)\r\n */\r\n async getOneByFields(fields: { tipcod?: string; codice?: number; docrif?: string; idxtipoall?: number }): Promise<AllegatoDto | null> {\r\n const results = await this.findByFields(fields);\r\n return results.length > 0 ? results[0] : null;\r\n }\r\n\r\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/allegati-module/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,4DAqBC;AA1BD,uCAA2C;AAC3C,+DAA0D;AAC1D,qDAAmE;AACnE,sCAAmC;AAEnC,SAAsB,wBAAwB,CAAC,GAAgB,EAAE,OAAwB;;QACrF,MAAM,MAAM,GAAW,IAAI,eAAM,CAAC,0BAA0B,CAAC,CAAC;QAC9D,IAAI,CAAC;YACD,MAAM,mBAAmB,GAAG,IAAI,iCAAc,CAAC,GAAG,CAAC,CAAC;YACpD,MAAM,OAAO,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,+BAAc,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,mBAAmB,EAAE;gBAC3F,UAAU,EAAE,IAAI;aACnB,CAAC,CAAC;YAEH,OAAO,CAAC,UAAU,EAAE,CAAC;YAErB,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE;gBAC3B,OAAO,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC;aACzC,CAAC,CAAC;YAEH,2DAA2D;YAC3D,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;QAEzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC5D,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CAAA;AAED,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,yCAAuB,CAAC,yFAAyF","sourcesContent":["import { Application } from \"express\";\nimport { NestFactory } from \"@nestjs/core\";\nimport { ExpressAdapter } from \"@nestjs/platform-express\";\nimport { AllegatiModule, AllegatiOptions } from \"./AllegatiModule\";\nimport { Logger } from \"../Logger\";\n\nexport async function initializeAllegatiModule(app: Application, options: AllegatiOptions) {\n const logger: Logger = new Logger(\"initializeAllegatiModule\");\n try {\n const nestExpressInstance = new ExpressAdapter(app);\n const nestApp = await NestFactory.create(AllegatiModule.forRoot(options), nestExpressInstance, {\n bufferLogs: true\n });\n\n nestApp.enableCors();\n\n nestApp.setGlobalPrefix('api', {\n exclude: ['/swagger', '/swagger/(.*)']\n });\n\n // Note: Swagger setup is now handled by the unified module\n await nestApp.init();\n\n } catch (error) {\n logger.error(\"Errore in initialize AllegatiModule:\", error);\n throw error;\n }\n}\n\nexport { AllegatiModule } from \"./AllegatiModule\";\nexport * from \"./Dtos\"; // per esportare automaticamente i DTOs tipo AllegatoDto, UploadAllegatoResponseDto, etc."]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/allegati-module/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,4DAqBC;AA1BD,uCAA2C;AAC3C,+DAA0D;AAC1D,qDAAmE;AACnE,sCAAmC;AAEnC,SAAsB,wBAAwB,CAAC,GAAgB,EAAE,OAAwB;;QACrF,MAAM,MAAM,GAAW,IAAI,eAAM,CAAC,0BAA0B,CAAC,CAAC;QAC9D,IAAI,CAAC;YACD,MAAM,mBAAmB,GAAG,IAAI,iCAAc,CAAC,GAAG,CAAC,CAAC;YACpD,MAAM,OAAO,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,+BAAc,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,mBAAmB,EAAE;gBAC3F,UAAU,EAAE,IAAI;aACnB,CAAC,CAAC;YAEH,OAAO,CAAC,UAAU,EAAE,CAAC;YAErB,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE;gBAC3B,OAAO,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC;aACzC,CAAC,CAAC;YAEH,2DAA2D;YAC3D,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;QAEzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC5D,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CAAA;AAED,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,yCAAuB,CAAC,yFAAyF","sourcesContent":["import { Application } from \"express\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\nimport { ExpressAdapter } from \"@nestjs/platform-express\";\r\nimport { AllegatiModule, AllegatiOptions } from \"./AllegatiModule\";\r\nimport { Logger } from \"../Logger\";\r\n\r\nexport async function initializeAllegatiModule(app: Application, options: AllegatiOptions) {\r\n const logger: Logger = new Logger(\"initializeAllegatiModule\");\r\n try {\r\n const nestExpressInstance = new ExpressAdapter(app);\r\n const nestApp = await NestFactory.create(AllegatiModule.forRoot(options), nestExpressInstance, {\r\n bufferLogs: true\r\n });\r\n\r\n nestApp.enableCors();\r\n\r\n nestApp.setGlobalPrefix('api', {\r\n exclude: ['/swagger', '/swagger/(.*)']\r\n });\r\n\r\n // Note: Swagger setup is now handled by the unified module\r\n await nestApp.init();\r\n\r\n } catch (error) {\r\n logger.error(\"Errore in initialize AllegatiModule:\", error);\r\n throw error;\r\n }\r\n}\r\n\r\nexport { AllegatiModule } from \"./AllegatiModule\";\r\nexport * from \"./Dtos\"; // per esportare automaticamente i DTOs tipo AllegatoDto, UploadAllegatoResponseDto, etc."]}
@@ -1 +1 @@
1
- {"version":3,"file":"autobind.js","sourceRoot":"","sources":["../src/autobind.ts"],"names":[],"mappings":";;AAAA,4BAYC;AAZD,SAAgB,QAAQ,CAA0C,WAAc;IAC5E,OAAO,KAAM,SAAQ,WAAW;QAC5B,YAAY,GAAG,IAAW;YACtB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBAC5D,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;gBAC/E,IAAI,UAAU,IAAI,OAAO,UAAU,CAAC,KAAK,KAAK,UAAU,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;oBAChF,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrC,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC","sourcesContent":["export function autobind<T extends { new (...args: any[]): any }>(constructor: T): T {\n return class extends constructor {\n constructor(...args: any[]) {\n super(...args);\n Object.getOwnPropertyNames(constructor.prototype).forEach(key => {\n const descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, key);\n if (descriptor && typeof descriptor.value === 'function' && key !== 'constructor') {\n this[key] = this[key].bind(this);\n }\n });\n }\n };\n}\n"]}
1
+ {"version":3,"file":"autobind.js","sourceRoot":"","sources":["../src/autobind.ts"],"names":[],"mappings":";;AAAA,4BAYC;AAZD,SAAgB,QAAQ,CAA0C,WAAc;IAC5E,OAAO,KAAM,SAAQ,WAAW;QAC5B,YAAY,GAAG,IAAW;YACtB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBAC5D,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;gBAC/E,IAAI,UAAU,IAAI,OAAO,UAAU,CAAC,KAAK,KAAK,UAAU,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;oBAChF,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrC,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC","sourcesContent":["export function autobind<T extends { new (...args: any[]): any }>(constructor: T): T {\r\n return class extends constructor {\r\n constructor(...args: any[]) {\r\n super(...args);\r\n Object.getOwnPropertyNames(constructor.prototype).forEach(key => {\r\n const descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, key);\r\n if (descriptor && typeof descriptor.value === 'function' && key !== 'constructor') {\r\n this[key] = this[key].bind(this);\r\n }\r\n });\r\n }\r\n };\r\n}\r\n"]}
@@ -0,0 +1,15 @@
1
+ import { Options } from "es-node-firebird";
2
+ export type FirebirdWireCryptMode = "disabled" | "enabled" | "required";
3
+ export type FirebirdAuthPlugin = "Legacy_Auth" | "Srp" | "Srp256";
4
+ export type FirebirdOptions = Options & {
5
+ wireCrypt?: FirebirdWireCryptMode;
6
+ pluginName?: FirebirdAuthPlugin;
7
+ authPlugins?: FirebirdAuthPlugin[];
8
+ connectTimeoutMs?: number;
9
+ connectTimeout?: number;
10
+ };
11
+ export declare function normalizeFirebirdOptions(options: Options): FirebirdOptions;
12
+ export declare function buildFirebirdCompatibilityCandidates(options: Options): FirebirdOptions[];
13
+ export declare function shouldRetryFirebirdCompatibility(error: unknown): boolean;
14
+ export declare function describeFirebirdCompatibilityOptions(options: Options): string;
15
+ export declare function ensureEsNodeFirebirdCompatibilityPatch(): void;
@@ -0,0 +1,198 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.normalizeFirebirdOptions = normalizeFirebirdOptions;
37
+ exports.buildFirebirdCompatibilityCandidates = buildFirebirdCompatibilityCandidates;
38
+ exports.shouldRetryFirebirdCompatibility = shouldRetryFirebirdCompatibility;
39
+ exports.describeFirebirdCompatibilityOptions = describeFirebirdCompatibilityOptions;
40
+ exports.ensureEsNodeFirebirdCompatibilityPatch = ensureEsNodeFirebirdCompatibilityPatch;
41
+ const Firebird = __importStar(require("es-node-firebird"));
42
+ const CNCT_PLUGIN_NAME = 8;
43
+ const CNCT_PLUGIN_LIST = 10;
44
+ const CNCT_CLIENT_CRYPT = 11;
45
+ const WIRE_CRYPT_DISABLE = 0;
46
+ const WIRE_CRYPT_ENABLE = 1;
47
+ const WIRE_CRYPT_REQUIRED = 2;
48
+ const DEFAULT_AUTH_PLUGIN_LIST = ["Srp256", "Srp", "Legacy_Auth"];
49
+ function normalizeWireCryptMode(value) {
50
+ const normalized = String(value !== null && value !== void 0 ? value : "").trim().toLowerCase();
51
+ if (normalized === "required") {
52
+ return "required";
53
+ }
54
+ if (normalized === "disabled") {
55
+ return "disabled";
56
+ }
57
+ return "enabled";
58
+ }
59
+ function normalizeAuthPlugin(value) {
60
+ const normalized = String(value !== null && value !== void 0 ? value : "").trim().toLowerCase();
61
+ if (normalized === "legacy_auth" || normalized === "legacy") {
62
+ return "Legacy_Auth";
63
+ }
64
+ if (normalized === "srp256") {
65
+ return "Srp256";
66
+ }
67
+ return "Srp";
68
+ }
69
+ function toWireCryptFlag(mode) {
70
+ switch (mode) {
71
+ case "required":
72
+ return WIRE_CRYPT_REQUIRED;
73
+ case "disabled":
74
+ return WIRE_CRYPT_DISABLE;
75
+ default:
76
+ return WIRE_CRYPT_ENABLE;
77
+ }
78
+ }
79
+ function normalizeAuthPluginList(value) {
80
+ if (!Array.isArray(value) || value.length === 0) {
81
+ return [...DEFAULT_AUTH_PLUGIN_LIST];
82
+ }
83
+ const normalized = value
84
+ .map((entry) => normalizeAuthPlugin(entry))
85
+ .filter((entry, index, source) => source.indexOf(entry) === index);
86
+ return normalized.length > 0 ? normalized : [...DEFAULT_AUTH_PLUGIN_LIST];
87
+ }
88
+ function normalizeFirebirdOptions(options) {
89
+ const compatibilityOptions = options;
90
+ return Object.assign(Object.assign({}, options), { wireCrypt: normalizeWireCryptMode(compatibilityOptions.wireCrypt), pluginName: normalizeAuthPlugin(compatibilityOptions.pluginName), authPlugins: normalizeAuthPluginList(compatibilityOptions.authPlugins) });
91
+ }
92
+ function isRetryableCompatibilityError(error) {
93
+ var _a, _b;
94
+ const message = String((_b = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error) !== null && _b !== void 0 ? _b : "").toLowerCase();
95
+ return message.includes("incompatible wire encryption")
96
+ || message.includes("no matching plugins on server")
97
+ || message.includes("unknown auth plugin")
98
+ || message.includes("unknow auth plugin");
99
+ }
100
+ function pushUniqueCandidate(target, candidate) {
101
+ var _a;
102
+ const normalized = normalizeFirebirdOptions(candidate);
103
+ const key = `${normalized.pluginName}|${normalized.wireCrypt}|${((_a = normalized.authPlugins) !== null && _a !== void 0 ? _a : []).join(",")}`;
104
+ const alreadyPresent = target.some((entry) => {
105
+ var _a;
106
+ const normalizedEntry = normalizeFirebirdOptions(entry);
107
+ return `${normalizedEntry.pluginName}|${normalizedEntry.wireCrypt}|${((_a = normalizedEntry.authPlugins) !== null && _a !== void 0 ? _a : []).join(",")}` === key;
108
+ });
109
+ if (!alreadyPresent) {
110
+ target.push(normalized);
111
+ }
112
+ }
113
+ function buildFirebirdCompatibilityCandidates(options) {
114
+ const normalized = normalizeFirebirdOptions(options);
115
+ const compatibilityOptions = options;
116
+ const hasExplicitPlugin = compatibilityOptions.pluginName !== undefined;
117
+ const hasExplicitWireCrypt = compatibilityOptions.wireCrypt !== undefined;
118
+ const candidates = [];
119
+ pushUniqueCandidate(candidates, normalized);
120
+ if (hasExplicitPlugin && hasExplicitWireCrypt) {
121
+ return candidates;
122
+ }
123
+ if (hasExplicitPlugin) {
124
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { wireCrypt: "disabled" }));
125
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { wireCrypt: "enabled" }));
126
+ return candidates;
127
+ }
128
+ if (hasExplicitWireCrypt) {
129
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { pluginName: "Srp256" }));
130
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { pluginName: "Srp" }));
131
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { pluginName: "Legacy_Auth" }));
132
+ return candidates;
133
+ }
134
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { pluginName: "Srp256", wireCrypt: "enabled" }));
135
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { pluginName: "Srp", wireCrypt: "enabled" }));
136
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { pluginName: "Srp256", wireCrypt: "disabled" }));
137
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { pluginName: "Srp", wireCrypt: "disabled" }));
138
+ pushUniqueCandidate(candidates, Object.assign(Object.assign({}, normalized), { pluginName: "Legacy_Auth", wireCrypt: "disabled" }));
139
+ return candidates;
140
+ }
141
+ function shouldRetryFirebirdCompatibility(error) {
142
+ return isRetryableCompatibilityError(error);
143
+ }
144
+ function describeFirebirdCompatibilityOptions(options) {
145
+ var _a;
146
+ const normalized = normalizeFirebirdOptions(options);
147
+ return `plugin=${normalized.pluginName}, wireCrypt=${normalized.wireCrypt}, authPlugins=${((_a = normalized.authPlugins) !== null && _a !== void 0 ? _a : []).join("/")}`;
148
+ }
149
+ function ensureEsNodeFirebirdCompatibilityPatch() {
150
+ var _a;
151
+ const firebird = Firebird;
152
+ const connectionPrototype = (_a = firebird.Connection) === null || _a === void 0 ? void 0 : _a.prototype;
153
+ if (!(connectionPrototype === null || connectionPrototype === void 0 ? void 0 : connectionPrototype.connect) || connectionPrototype.__emilsoftwareWireCryptPatched) {
154
+ return;
155
+ }
156
+ const originalConnect = connectionPrototype.connect;
157
+ connectionPrototype.connect = function patchedConnect(options, callback) {
158
+ var _a, _b;
159
+ const normalizedOptions = normalizeFirebirdOptions(options);
160
+ const wireCryptFlag = toWireCryptFlag(normalizedOptions.wireCrypt);
161
+ const authPlugin = normalizedOptions.pluginName;
162
+ const authPlugins = (_a = normalizedOptions.authPlugins) !== null && _a !== void 0 ? _a : DEFAULT_AUTH_PLUGIN_LIST;
163
+ (_b = this.accept) !== null && _b !== void 0 ? _b : (this.accept = { protocolMinimumType: 0, pluginName: authPlugin });
164
+ const blr = this._blr;
165
+ const originalAddBytes = blr === null || blr === void 0 ? void 0 : blr.addBytes;
166
+ const originalAddString = blr === null || blr === void 0 ? void 0 : blr.addString;
167
+ if (!blr || !originalAddBytes || !originalAddString) {
168
+ return originalConnect.call(this, normalizedOptions, callback);
169
+ }
170
+ const patchedOptions = authPlugin === "Srp256"
171
+ ? Object.assign(Object.assign({}, normalizedOptions), { pluginName: "Srp" }) : normalizedOptions;
172
+ blr.addBytes = function patchedAddBytes(bytes, ...args) {
173
+ if (Array.isArray(bytes) && bytes.length === 6 && bytes[0] === CNCT_CLIENT_CRYPT && bytes[1] === 4) {
174
+ return originalAddBytes.call(this, [bytes[0], bytes[1], wireCryptFlag, 0, 0, 0], ...args);
175
+ }
176
+ return originalAddBytes.call(this, bytes, ...args);
177
+ };
178
+ blr.addString = function patchedAddString(code, value, encoding) {
179
+ if (code === CNCT_PLUGIN_NAME) {
180
+ return originalAddString.call(this, code, authPlugin, encoding);
181
+ }
182
+ if (code === CNCT_PLUGIN_LIST) {
183
+ return originalAddString.call(this, code, authPlugins.join(","), encoding);
184
+ }
185
+ return originalAddString.call(this, code, value, encoding);
186
+ };
187
+ try {
188
+ return originalConnect.call(this, patchedOptions, callback);
189
+ }
190
+ finally {
191
+ blr.addBytes = originalAddBytes;
192
+ blr.addString = originalAddString;
193
+ }
194
+ };
195
+ connectionPrototype.__emilsoftwareWireCryptPatched = true;
196
+ }
197
+ ensureEsNodeFirebirdCompatibilityPatch();
198
+ //# sourceMappingURL=firebird-compat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firebird-compat.js","sourceRoot":"","sources":["../src/firebird-compat.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8FA,4DAQC;AAuBD,oFAgCC;AAED,4EAEC;AAED,oFAGC;AAED,wFA+DC;AAvOD,2DAA6C;AAc7C,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,wBAAwB,GAAyB,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;AAwBxF,SAAS,sBAAsB,CAAC,KAAc;IAC1C,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5D,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;QAC5B,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;QAC5B,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACvC,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE5D,IAAI,UAAU,KAAK,aAAa,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;QAC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AAI,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;YACpE,CAAC;YAED,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;gBAC5B,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;YAC/E,CAAC;YAED,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC/D,CAAC,CAAC;QAEF,IAAI,CAAC;YACD,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;QAChE,CAAC;gBAAS,CAAC;YACP,GAAG,CAAC,QAAQ,GAAG,gBAAgB,CAAC;YAChC,GAAG,CAAC,SAAS,GAAG,iBAAiB,CAAC;QACtC,CAAC;IACL,CAAC,CAAC;IAEF,mBAAmB,CAAC,8BAA8B,GAAG,IAAI,CAAC;AAC9D,CAAC;AAED,sCAAsC,EAAE,CAAC","sourcesContent":["import * as Firebird from \"es-node-firebird\";\nimport { Options } from \"es-node-firebird\";\n\nexport type FirebirdWireCryptMode = \"disabled\" | \"enabled\" | \"required\";\nexport type FirebirdAuthPlugin = \"Legacy_Auth\" | \"Srp\" | \"Srp256\";\n\nexport type FirebirdOptions = Options & {\n wireCrypt?: FirebirdWireCryptMode;\n pluginName?: FirebirdAuthPlugin;\n authPlugins?: FirebirdAuthPlugin[];\n connectTimeoutMs?: number;\n connectTimeout?: number;\n};\n\nconst CNCT_PLUGIN_NAME = 8;\nconst CNCT_PLUGIN_LIST = 10;\nconst CNCT_CLIENT_CRYPT = 11;\nconst WIRE_CRYPT_DISABLE = 0;\nconst WIRE_CRYPT_ENABLE = 1;\nconst WIRE_CRYPT_REQUIRED = 2;\nconst DEFAULT_AUTH_PLUGIN_LIST: FirebirdAuthPlugin[] = [\"Srp256\", \"Srp\", \"Legacy_Auth\"];\n\ntype BlrWriterLike = {\n addBytes: (bytes: number[], ...args: unknown[]) => unknown;\n addString: (code: number, value: string, encoding?: string) => unknown;\n};\n\ntype ConnectionLike = {\n _blr?: BlrWriterLike;\n accept?: {\n protocolMinimumType?: number;\n pluginName?: string;\n };\n};\n\ntype FirebirdModuleLike = {\n Connection?: {\n prototype?: {\n connect?: (this: ConnectionLike, options: FirebirdOptions, callback: unknown) => unknown;\n __emilsoftwareWireCryptPatched?: boolean;\n };\n };\n};\n\nfunction normalizeWireCryptMode(value: unknown): FirebirdWireCryptMode {\n const normalized = String(value ?? \"\").trim().toLowerCase();\n if (normalized === \"required\") {\n return \"required\";\n }\n\n if (normalized === \"disabled\") {\n return \"disabled\";\n }\n\n return \"enabled\";\n}\n\nfunction normalizeAuthPlugin(value: unknown): FirebirdAuthPlugin {\n const normalized = String(value ?? \"\").trim().toLowerCase();\n\n if (normalized === \"legacy_auth\" || normalized === \"legacy\") {\n return \"Legacy_Auth\";\n }\n\n if (normalized === \"srp256\") {\n return \"Srp256\";\n }\n\n return \"Srp\";\n}\n\nfunction toWireCryptFlag(mode: FirebirdWireCryptMode): number {\n switch (mode) {\n case \"required\":\n return WIRE_CRYPT_REQUIRED;\n case \"disabled\":\n return WIRE_CRYPT_DISABLE;\n default:\n return WIRE_CRYPT_ENABLE;\n }\n}\n\nfunction normalizeAuthPluginList(value: unknown): FirebirdAuthPlugin[] {\n if (!Array.isArray(value) || value.length === 0) {\n return [...DEFAULT_AUTH_PLUGIN_LIST];\n }\n\n const normalized = value\n .map((entry: unknown) => normalizeAuthPlugin(entry))\n .filter((entry: FirebirdAuthPlugin, index: number, source: FirebirdAuthPlugin[]) => source.indexOf(entry) === index);\n\n return normalized.length > 0 ? normalized : [...DEFAULT_AUTH_PLUGIN_LIST];\n}\n\nexport function normalizeFirebirdOptions(options: Options): FirebirdOptions {\n const compatibilityOptions = options as FirebirdOptions;\n return {\n ...options,\n wireCrypt: normalizeWireCryptMode(compatibilityOptions.wireCrypt),\n pluginName: normalizeAuthPlugin(compatibilityOptions.pluginName),\n authPlugins: normalizeAuthPluginList(compatibilityOptions.authPlugins),\n };\n}\n\nfunction isRetryableCompatibilityError(error: unknown): boolean {\n const message = String((error as { message?: unknown })?.message ?? error ?? \"\").toLowerCase();\n return message.includes(\"incompatible wire encryption\")\n || message.includes(\"no matching plugins on server\")\n || message.includes(\"unknown auth plugin\")\n || message.includes(\"unknow auth plugin\");\n}\n\nfunction pushUniqueCandidate(target: FirebirdOptions[], candidate: FirebirdOptions): void {\n const normalized = normalizeFirebirdOptions(candidate);\n const key = `${normalized.pluginName}|${normalized.wireCrypt}|${(normalized.authPlugins ?? []).join(\",\")}`;\n const alreadyPresent = target.some((entry) => {\n const normalizedEntry = normalizeFirebirdOptions(entry);\n return `${normalizedEntry.pluginName}|${normalizedEntry.wireCrypt}|${(normalizedEntry.authPlugins ?? []).join(\",\")}` === key;\n });\n\n if (!alreadyPresent) {\n target.push(normalized);\n }\n}\n\nexport function buildFirebirdCompatibilityCandidates(options: Options): FirebirdOptions[] {\n const normalized = normalizeFirebirdOptions(options);\n const compatibilityOptions = options as FirebirdOptions;\n const hasExplicitPlugin = compatibilityOptions.pluginName !== undefined;\n const hasExplicitWireCrypt = compatibilityOptions.wireCrypt !== undefined;\n const candidates: FirebirdOptions[] = [];\n\n pushUniqueCandidate(candidates, normalized);\n\n if (hasExplicitPlugin && hasExplicitWireCrypt) {\n return candidates;\n }\n\n if (hasExplicitPlugin) {\n pushUniqueCandidate(candidates, { ...normalized, wireCrypt: \"disabled\" });\n pushUniqueCandidate(candidates, { ...normalized, wireCrypt: \"enabled\" });\n return candidates;\n }\n\n if (hasExplicitWireCrypt) {\n pushUniqueCandidate(candidates, { ...normalized, pluginName: \"Srp256\" });\n pushUniqueCandidate(candidates, { ...normalized, pluginName: \"Srp\" });\n pushUniqueCandidate(candidates, { ...normalized, pluginName: \"Legacy_Auth\" });\n return candidates;\n }\n\n pushUniqueCandidate(candidates, { ...normalized, pluginName: \"Srp256\", wireCrypt: \"enabled\" });\n pushUniqueCandidate(candidates, { ...normalized, pluginName: \"Srp\", wireCrypt: \"enabled\" });\n pushUniqueCandidate(candidates, { ...normalized, pluginName: \"Srp256\", wireCrypt: \"disabled\" });\n pushUniqueCandidate(candidates, { ...normalized, pluginName: \"Srp\", wireCrypt: \"disabled\" });\n pushUniqueCandidate(candidates, { ...normalized, pluginName: \"Legacy_Auth\", wireCrypt: \"disabled\" });\n return candidates;\n}\n\nexport function shouldRetryFirebirdCompatibility(error: unknown): boolean {\n return isRetryableCompatibilityError(error);\n}\n\nexport function describeFirebirdCompatibilityOptions(options: Options): string {\n const normalized = normalizeFirebirdOptions(options);\n return `plugin=${normalized.pluginName}, wireCrypt=${normalized.wireCrypt}, authPlugins=${(normalized.authPlugins ?? []).join(\"/\")}`;\n}\n\nexport function ensureEsNodeFirebirdCompatibilityPatch(): void {\n const firebird = Firebird as FirebirdModuleLike;\n const connectionPrototype = firebird.Connection?.prototype;\n\n if (!connectionPrototype?.connect || connectionPrototype.__emilsoftwareWireCryptPatched) {\n return;\n }\n\n const originalConnect = connectionPrototype.connect;\n\n connectionPrototype.connect = function patchedConnect(\n this: ConnectionLike,\n options: FirebirdOptions,\n callback: unknown,\n ) {\n const normalizedOptions = normalizeFirebirdOptions(options);\n const wireCryptFlag = toWireCryptFlag(normalizedOptions.wireCrypt);\n const authPlugin = normalizedOptions.pluginName;\n const authPlugins = normalizedOptions.authPlugins ?? DEFAULT_AUTH_PLUGIN_LIST;\n\n this.accept ??= { protocolMinimumType: 0, pluginName: authPlugin };\n\n const blr = this._blr;\n const originalAddBytes = blr?.addBytes;\n const originalAddString = blr?.addString;\n\n if (!blr || !originalAddBytes || !originalAddString) {\n return originalConnect.call(this, normalizedOptions, callback);\n }\n\n const patchedOptions = authPlugin === \"Srp256\"\n ? { ...normalizedOptions, pluginName: \"Srp\" as FirebirdAuthPlugin }\n : normalizedOptions;\n\n blr.addBytes = function patchedAddBytes(bytes: number[], ...args: unknown[]) {\n if (Array.isArray(bytes) && bytes.length === 6 && bytes[0] === CNCT_CLIENT_CRYPT && bytes[1] === 4) {\n return originalAddBytes.call(this, [bytes[0], bytes[1], wireCryptFlag, 0, 0, 0], ...args);\n }\n\n return originalAddBytes.call(this, bytes, ...args);\n };\n\n blr.addString = function patchedAddString(code: number, value: string, encoding?: string) {\n if (code === CNCT_PLUGIN_NAME) {\n return originalAddString.call(this, code, authPlugin, encoding);\n }\n\n if (code === CNCT_PLUGIN_LIST) {\n return originalAddString.call(this, code, authPlugins.join(\",\"), encoding);\n }\n\n return originalAddString.call(this, code, value, encoding);\n };\n\n try {\n return originalConnect.call(this, patchedOptions, callback);\n } finally {\n blr.addBytes = originalAddBytes;\n blr.addString = originalAddString;\n }\n };\n\n connectionPrototype.__emilsoftwareWireCryptPatched = true;\n}\n\nensureEsNodeFirebirdCompatibilityPatch();\n"]}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { DatabaseUpdater } from "./DatabaseUpdater";
2
2
  import { ExecutionTimeLogger } from "./ExecutionTimeLogger";
3
+ import * as Firebird from "es-node-firebird";
3
4
  import { LogLevels, Logger } from "./Logger";
4
5
  import { Orm } from "./Orm";
5
6
  import { DateUtilities, RestUtilities, DatabaseUtilities, StatusCode } from "./Utilities";
6
7
  import { autobind } from "./autobind";
7
8
  import { DocumentGenerator } from "./ContractGenerator";
9
+ import "./firebird-compat";
8
10
  export * from "./Orm";
9
11
  export * from "./Utilities";
10
12
  export * from "./Logger";
@@ -13,9 +15,10 @@ export * from "./ExecutionTimeLogger";
13
15
  export * from "./RoutesLoggerMiddleware";
14
16
  export * from "./ContractGenerator";
15
17
  export * from "./DatabaseUpdater";
18
+ export * from "./firebird-compat";
16
19
  export * from "./accessi-module";
17
20
  export * from "./allegati-module";
18
21
  export * from "es-node-firebird";
19
- export { autobind, ExecutionTimeLogger, Logger, LogLevels, Orm, DateUtilities, RestUtilities, DatabaseUtilities, DatabaseUpdater, StatusCode, DocumentGenerator };
22
+ export { autobind, ExecutionTimeLogger, Logger, LogLevels, Orm, DateUtilities, RestUtilities, DatabaseUtilities, DatabaseUpdater, StatusCode, DocumentGenerator, Firebird };
20
23
  export * from "./swagger/SwaggerConfig";
21
24
  export * from "./initEmilsoftwareModule";
package/dist/index.js CHANGED
@@ -10,15 +10,39 @@ 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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
13
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
37
  };
16
38
  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;
39
+ exports.Firebird = 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
40
  const DatabaseUpdater_1 = require("./DatabaseUpdater");
19
41
  Object.defineProperty(exports, "DatabaseUpdater", { enumerable: true, get: function () { return DatabaseUpdater_1.DatabaseUpdater; } });
20
42
  const ExecutionTimeLogger_1 = require("./ExecutionTimeLogger");
21
43
  Object.defineProperty(exports, "ExecutionTimeLogger", { enumerable: true, get: function () { return ExecutionTimeLogger_1.ExecutionTimeLogger; } });
44
+ const Firebird = __importStar(require("es-node-firebird"));
45
+ exports.Firebird = Firebird;
22
46
  const Logger_1 = require("./Logger");
23
47
  Object.defineProperty(exports, "LogLevels", { enumerable: true, get: function () { return Logger_1.LogLevels; } });
24
48
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return Logger_1.Logger; } });
@@ -33,6 +57,7 @@ const autobind_1 = require("./autobind");
33
57
  Object.defineProperty(exports, "autobind", { enumerable: true, get: function () { return autobind_1.autobind; } });
34
58
  const ContractGenerator_1 = require("./ContractGenerator");
35
59
  Object.defineProperty(exports, "DocumentGenerator", { enumerable: true, get: function () { return ContractGenerator_1.DocumentGenerator; } });
60
+ require("./firebird-compat");
36
61
  __exportStar(require("./Orm"), exports);
37
62
  __exportStar(require("./Utilities"), exports);
38
63
  __exportStar(require("./Logger"), exports);
@@ -41,6 +66,7 @@ __exportStar(require("./ExecutionTimeLogger"), exports);
41
66
  __exportStar(require("./RoutesLoggerMiddleware"), exports);
42
67
  __exportStar(require("./ContractGenerator"), exports);
43
68
  __exportStar(require("./DatabaseUpdater"), exports);
69
+ __exportStar(require("./firebird-compat"), exports);
44
70
  __exportStar(require("./accessi-module"), exports);
45
71
  __exportStar(require("./allegati-module"), exports);
46
72
  __exportStar(require("es-node-firebird"), exports);