@uniorganization/uni-lib 5.0.1 → 5.0.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.
- package/dist/entities/dispute-request.entity.d.ts +2 -1
- package/dist/entities/dispute-request.entity.js +10 -1
- package/dist/modules/file-storage/constants.js +1 -1
- package/dist/modules/file-storage/constants.spec.d.ts +1 -0
- package/dist/modules/file-storage/constants.spec.js +40 -0
- package/dist/modules/file-storage/file-storage.service.js +4 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Evaluations } from './evaluations.entity';
|
|
2
2
|
import { Users } from './usr.entity';
|
|
3
3
|
export type SupervisorOutcome = 'APPROVED' | 'REJECTED';
|
|
4
|
-
export
|
|
4
|
+
export declare const REQUEST_STATUSES: readonly ["NEW", "OPS APPROVED", "OPS REJECTED", "QA REJECTED", "QA APPROVED", "DISPUTED", "COMPLETED"];
|
|
5
|
+
export type RequestStatus = (typeof REQUEST_STATUSES)[number];
|
|
5
6
|
export declare class DisputeRequest {
|
|
6
7
|
clientId: number;
|
|
7
8
|
id: number;
|
|
@@ -9,10 +9,19 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DisputeRequest = void 0;
|
|
12
|
+
exports.DisputeRequest = exports.REQUEST_STATUSES = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const evaluations_entity_1 = require("./evaluations.entity");
|
|
15
15
|
const usr_entity_1 = require("./usr.entity");
|
|
16
|
+
exports.REQUEST_STATUSES = [
|
|
17
|
+
'NEW',
|
|
18
|
+
'OPS APPROVED',
|
|
19
|
+
'OPS REJECTED',
|
|
20
|
+
'QA REJECTED',
|
|
21
|
+
'QA APPROVED',
|
|
22
|
+
'DISPUTED',
|
|
23
|
+
'COMPLETED',
|
|
24
|
+
];
|
|
16
25
|
let DisputeRequest = class DisputeRequest {
|
|
17
26
|
};
|
|
18
27
|
exports.DisputeRequest = DisputeRequest;
|
|
@@ -36,7 +36,7 @@ const normalizeBucketPrefix = (prefix) => {
|
|
|
36
36
|
if (!prefix) {
|
|
37
37
|
return exports.FILE_STORAGE_DEFAULT_BUCKET_PREFIX;
|
|
38
38
|
}
|
|
39
|
-
return prefix.replace(/^\/+|\/+$/g, '');
|
|
39
|
+
return prefix.replace(/\/{2,}/g, '/').replace(/^\/+|\/+$/g, '');
|
|
40
40
|
};
|
|
41
41
|
exports.normalizeBucketPrefix = normalizeBucketPrefix;
|
|
42
42
|
const extractFileExtension = (originalName) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("./constants");
|
|
4
|
+
describe('normalizeBucketPrefix', () => {
|
|
5
|
+
it('colapsa dobles slashes internos', () => {
|
|
6
|
+
expect((0, constants_1.normalizeBucketPrefix)('development//client-2')).toBe('development/client-2');
|
|
7
|
+
});
|
|
8
|
+
it('recorta slashes iniciales y finales', () => {
|
|
9
|
+
expect((0, constants_1.normalizeBucketPrefix)('/development/')).toBe('development');
|
|
10
|
+
expect((0, constants_1.normalizeBucketPrefix)('//development///')).toBe('development');
|
|
11
|
+
});
|
|
12
|
+
it('devuelve cadena vacía para null o undefined', () => {
|
|
13
|
+
expect((0, constants_1.normalizeBucketPrefix)(null)).toBe('');
|
|
14
|
+
expect((0, constants_1.normalizeBucketPrefix)(undefined)).toBe('');
|
|
15
|
+
});
|
|
16
|
+
it('devuelve vacío para cadena vacía', () => {
|
|
17
|
+
expect((0, constants_1.normalizeBucketPrefix)('')).toBe('');
|
|
18
|
+
});
|
|
19
|
+
it('deja intacto un prefijo ya normalizado', () => {
|
|
20
|
+
expect((0, constants_1.normalizeBucketPrefix)('production')).toBe('production');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('sanitizeFileName', () => {
|
|
24
|
+
it('sanitiza caracteres inválidos a underscore', () => {
|
|
25
|
+
expect((0, constants_1.sanitizeFileName)('ticket match template (1).xlsx')).toBe('ticket_match_template_1_.xlsx');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe('buildBucketPath', () => {
|
|
29
|
+
it('construye el key con prefijo normalizado', () => {
|
|
30
|
+
expect((0, constants_1.buildBucketPath)('development/', 'SERVICE_CENTER_TICKET_MATCH_SOURCE', '9d9e6566-406b-4c3c-9fe0-4f0d72080c25', 'ticket_match_template_1_1_.xlsx')).toBe('development/SERVICE_CENTER_TICKET_MATCH_SOURCE/9d9e6566-406b-4c3c-9fe0-4f0d72080c25-ticket_match_template_1_1_.xlsx');
|
|
31
|
+
});
|
|
32
|
+
it('no duplica slashes cuando el prefijo ya tiene uno final', () => {
|
|
33
|
+
expect((0, constants_1.buildBucketPath)('development/', 'INBOUND_AUDIO', 'uuid', 'call.wav')).toBe('development/INBOUND_AUDIO/uuid-call.wav');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe('extractFileExtension', () => {
|
|
37
|
+
it('extrae la extensión en minúsculas', () => {
|
|
38
|
+
expect((0, constants_1.extractFileExtension)('TEMPLATE.XLSX')).toBe('xlsx');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -61,7 +61,10 @@ let FileStorageService = FileStorageService_1 = class FileStorageService {
|
|
|
61
61
|
const uniqueId = (0, node_crypto_1.randomUUID)();
|
|
62
62
|
const bucketPrefix = process.env[constants_1.FILE_STORAGE_BUCKET_PREFIX_ENV];
|
|
63
63
|
const clientId = this.getClientId();
|
|
64
|
-
const tenantBucketPrefix = [
|
|
64
|
+
const tenantBucketPrefix = [
|
|
65
|
+
(0, constants_1.normalizeBucketPrefix)(bucketPrefix),
|
|
66
|
+
`client-${clientId}`,
|
|
67
|
+
]
|
|
65
68
|
.filter(Boolean)
|
|
66
69
|
.join('/');
|
|
67
70
|
const bucketName = this.getRequiredEnv(constants_1.FILE_STORAGE_BUCKET_NAME_ENV);
|