@viardex/viardex-libs 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +179 -0
- package/dist/argon/argon.module.d.ts +2 -0
- package/dist/{notification/notification.module.js → argon/argon.module.js} +9 -8
- package/dist/argon/argon.service.d.ts +6 -0
- package/dist/argon/argon.service.js +74 -0
- package/dist/argon/index.d.ts +2 -0
- package/dist/{notification → argon}/index.js +2 -4
- package/dist/auth/auth.constants.d.ts +4 -0
- package/dist/auth/auth.constants.js +7 -0
- package/dist/auth/auth.interfaces.d.ts +19 -0
- package/dist/auth/auth.module.d.ts +2 -0
- package/dist/auth/auth.module.js +30 -0
- package/dist/auth/auth.service.d.ts +13 -0
- package/dist/auth/auth.service.js +99 -0
- package/dist/auth/decorators/auth-token-types.decorator.d.ts +2 -0
- package/dist/auth/decorators/auth-token-types.decorator.js +7 -0
- package/dist/auth/decorators/current-auth.decorator.d.ts +1 -0
- package/dist/auth/decorators/current-auth.decorator.js +10 -0
- package/dist/auth/decorators/index.d.ts +5 -0
- package/dist/auth/decorators/index.js +21 -0
- package/dist/auth/decorators/permissions.decorator.d.ts +1 -0
- package/dist/auth/decorators/permissions.decorator.js +7 -0
- package/dist/auth/decorators/public.decorator.d.ts +1 -0
- package/dist/auth/decorators/public.decorator.js +7 -0
- package/dist/auth/decorators/roles.decorator.d.ts +1 -0
- package/dist/auth/decorators/roles.decorator.js +7 -0
- package/dist/auth/guards/auth.guard.d.ts +10 -0
- package/dist/auth/guards/auth.guard.js +58 -0
- package/dist/auth/guards/index.d.ts +3 -0
- package/dist/auth/guards/index.js +19 -0
- package/dist/auth/guards/permissions.guard.d.ts +7 -0
- package/dist/auth/guards/permissions.guard.js +47 -0
- package/dist/auth/guards/roles.guard.d.ts +7 -0
- package/dist/auth/guards/roles.guard.js +48 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.js +22 -0
- package/dist/cache/cache.constants.d.ts +1 -0
- package/dist/cache/cache.constants.js +4 -0
- package/dist/cache/cache.module.js +5 -1
- package/dist/cache/cache.service.d.ts +5 -0
- package/dist/cache/cache.service.js +28 -1
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.js +1 -0
- package/dist/common/config/nats.config.d.ts +7 -8
- package/dist/common/config/nats.config.js +25 -4
- package/dist/common/constants/queues.constants.d.ts +7 -15
- package/dist/common/constants/queues.constants.js +8 -16
- package/dist/common/enums/index.d.ts +0 -2
- package/dist/common/enums/index.js +0 -2
- package/dist/health/health.controller.d.ts +19 -0
- package/dist/health/health.controller.js +88 -0
- package/dist/health/health.module.d.ts +2 -0
- package/dist/health/health.module.js +21 -0
- package/dist/health/index.d.ts +2 -0
- package/dist/health/index.js +18 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.js +18 -0
- package/dist/logger/logger.module.d.ts +2 -0
- package/dist/logger/logger.module.js +58 -0
- package/dist/logger/logging.interceptor.d.ts +8 -0
- package/dist/logger/logging.interceptor.js +62 -0
- package/dist/rpc/index.d.ts +0 -36
- package/dist/rpc/index.js +3 -73
- package/dist/storage/index.d.ts +5 -0
- package/dist/storage/index.js +21 -0
- package/dist/storage/r2.service.d.ts +20 -0
- package/dist/storage/r2.service.js +208 -0
- package/dist/storage/s3.service.d.ts +20 -0
- package/dist/storage/s3.service.js +204 -0
- package/dist/storage/storage.interface.d.ts +29 -0
- package/dist/storage/storage.interface.js +2 -0
- package/dist/storage/storage.module.d.ts +2 -0
- package/dist/storage/storage.module.js +24 -0
- package/dist/storage/storage.service.d.ts +22 -0
- package/dist/storage/storage.service.js +54 -0
- package/package.json +80 -27
- package/dist/common/enums/support-action.enum.d.ts +0 -7
- package/dist/common/enums/support-action.enum.js +0 -11
- package/dist/common/enums/ticket.enum.d.ts +0 -19
- package/dist/common/enums/ticket.enum.js +0 -25
- package/dist/notification/index.d.ts +0 -4
- package/dist/notification/notification.client.d.ts +0 -76
- package/dist/notification/notification.client.js +0 -325
- package/dist/notification/notification.enum.d.ts +0 -54
- package/dist/notification/notification.enum.js +0 -73
- package/dist/notification/notification.interface.d.ts +0 -285
- package/dist/notification/notification.module.d.ts +0 -2
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/{notification/notification.interface.js → auth/auth.interfaces.js} +0 -0
|
@@ -0,0 +1,204 @@
|
|
|
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.S3Service = void 0;
|
|
43
|
+
const common_1 = require("@nestjs/common");
|
|
44
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
45
|
+
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
46
|
+
const crypto = __importStar(require("crypto"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
let S3Service = class S3Service {
|
|
49
|
+
configService;
|
|
50
|
+
s3Client;
|
|
51
|
+
bucketName;
|
|
52
|
+
publicUrl;
|
|
53
|
+
cloudfrontUrl;
|
|
54
|
+
constructor(configService) {
|
|
55
|
+
this.configService = configService;
|
|
56
|
+
const s3Config = {
|
|
57
|
+
accessKeyId: this.configService.get('s3.accessKeyId'),
|
|
58
|
+
secretAccessKey: this.configService.get('s3.secretAccessKey'),
|
|
59
|
+
region: this.configService.get('s3.region'),
|
|
60
|
+
bucketName: this.configService.get('s3.bucketName'),
|
|
61
|
+
cloudfrontUrl: this.configService.get('s3.cloudfrontUrl'),
|
|
62
|
+
publicUrl: this.configService.get('s3.publicUrl'),
|
|
63
|
+
};
|
|
64
|
+
if (!s3Config.accessKeyId ||
|
|
65
|
+
!s3Config.secretAccessKey ||
|
|
66
|
+
!s3Config.bucketName ||
|
|
67
|
+
!s3Config.region) {
|
|
68
|
+
throw new Error('S3 configuration is incomplete. Please check your environment variables.');
|
|
69
|
+
}
|
|
70
|
+
this.bucketName = s3Config.bucketName;
|
|
71
|
+
this.cloudfrontUrl = s3Config.cloudfrontUrl;
|
|
72
|
+
this.publicUrl =
|
|
73
|
+
s3Config.cloudfrontUrl ||
|
|
74
|
+
s3Config.publicUrl ||
|
|
75
|
+
`https://${s3Config.bucketName}.s3.${s3Config.region}.amazonaws.com`;
|
|
76
|
+
this.s3Client = new client_s3_1.S3Client({
|
|
77
|
+
region: s3Config.region,
|
|
78
|
+
credentials: {
|
|
79
|
+
accessKeyId: s3Config.accessKeyId,
|
|
80
|
+
secretAccessKey: s3Config.secretAccessKey,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async uploadFile(file, options = {}) {
|
|
85
|
+
try {
|
|
86
|
+
const fileName = options.fileName || this.generateFileName();
|
|
87
|
+
const folder = options.folder ? `${options.folder}/` : '';
|
|
88
|
+
const key = `${folder}${fileName}`;
|
|
89
|
+
const contentType = options.contentType || 'application/octet-stream';
|
|
90
|
+
const body = file instanceof Buffer
|
|
91
|
+
? file
|
|
92
|
+
: await this.streamToBuffer(file);
|
|
93
|
+
await this.s3Client.send(new client_s3_1.PutObjectCommand({
|
|
94
|
+
Bucket: this.bucketName,
|
|
95
|
+
Key: key,
|
|
96
|
+
Body: body,
|
|
97
|
+
ContentType: contentType,
|
|
98
|
+
}));
|
|
99
|
+
return {
|
|
100
|
+
key,
|
|
101
|
+
url: this.getPublicUrl(key),
|
|
102
|
+
fileName,
|
|
103
|
+
size: body.length,
|
|
104
|
+
contentType,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
throw new common_1.InternalServerErrorException(`Failed to upload file: ${error?.message || 'Unknown error'}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async uploadMultipartFile(file, options = {}) {
|
|
112
|
+
const allowedMimeTypes = [
|
|
113
|
+
'image/jpeg',
|
|
114
|
+
'image/png',
|
|
115
|
+
'image/webp',
|
|
116
|
+
'image/gif',
|
|
117
|
+
'application/pdf',
|
|
118
|
+
'application/msword',
|
|
119
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
120
|
+
];
|
|
121
|
+
if (!allowedMimeTypes.includes(file.mimetype)) {
|
|
122
|
+
throw new common_1.BadRequestException(`File type ${file.mimetype} is not allowed`);
|
|
123
|
+
}
|
|
124
|
+
const maxSize = 5 * 1024 * 1024;
|
|
125
|
+
if (file.data.length > maxSize) {
|
|
126
|
+
throw new common_1.BadRequestException('File size exceeds 5MB limit');
|
|
127
|
+
}
|
|
128
|
+
const fileExtension = path.extname(file.filename);
|
|
129
|
+
const fileName = options.fileName || `${this.generateFileName()}${fileExtension}`;
|
|
130
|
+
return this.uploadFile(file.data, {
|
|
131
|
+
...options,
|
|
132
|
+
fileName,
|
|
133
|
+
contentType: file.mimetype,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async getPresignedUploadUrl(key, contentType, expiresIn = 3600) {
|
|
137
|
+
try {
|
|
138
|
+
return await (0, s3_request_presigner_1.getSignedUrl)(this.s3Client, new client_s3_1.PutObjectCommand({
|
|
139
|
+
Bucket: this.bucketName,
|
|
140
|
+
Key: key,
|
|
141
|
+
ContentType: contentType,
|
|
142
|
+
}), { expiresIn });
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
throw new common_1.InternalServerErrorException(`Failed to generate presigned URL: ${error?.message || 'Unknown error'}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async getPresignedDownloadUrl(key, expiresIn = 3600) {
|
|
149
|
+
try {
|
|
150
|
+
return await (0, s3_request_presigner_1.getSignedUrl)(this.s3Client, new client_s3_1.GetObjectCommand({
|
|
151
|
+
Bucket: this.bucketName,
|
|
152
|
+
Key: key,
|
|
153
|
+
}), { expiresIn });
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
throw new common_1.InternalServerErrorException(`Failed to generate presigned URL: ${error?.message || 'Unknown error'}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async deleteFile(key) {
|
|
160
|
+
try {
|
|
161
|
+
await this.s3Client.send(new client_s3_1.DeleteObjectCommand({
|
|
162
|
+
Bucket: this.bucketName,
|
|
163
|
+
Key: key,
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
throw new common_1.InternalServerErrorException(`Failed to delete file: ${error?.message || 'Unknown error'}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async fileExists(key) {
|
|
171
|
+
try {
|
|
172
|
+
await this.s3Client.send(new client_s3_1.HeadObjectCommand({
|
|
173
|
+
Bucket: this.bucketName,
|
|
174
|
+
Key: key,
|
|
175
|
+
}));
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
if (error?.name === 'NotFound' ||
|
|
180
|
+
error?.$metadata?.httpStatusCode === 404) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
throw new common_1.InternalServerErrorException(`Failed to check file existence: ${error?.message || 'Unknown error'}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
getPublicUrl(key) {
|
|
187
|
+
const baseUrl = this.cloudfrontUrl || this.publicUrl;
|
|
188
|
+
return baseUrl.endsWith('/') ? `${baseUrl}${key}` : `${baseUrl}/${key}`;
|
|
189
|
+
}
|
|
190
|
+
generateFileName() {
|
|
191
|
+
return `${Date.now()}-${crypto.randomBytes(16).toString('hex')}`;
|
|
192
|
+
}
|
|
193
|
+
async streamToBuffer(stream) {
|
|
194
|
+
const chunks = [];
|
|
195
|
+
for await (const chunk of stream) {
|
|
196
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
197
|
+
}
|
|
198
|
+
return Buffer.concat(chunks);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
exports.S3Service = S3Service;
|
|
202
|
+
exports.S3Service = S3Service = __decorate([
|
|
203
|
+
(0, common_1.Injectable)()
|
|
204
|
+
], S3Service);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
export interface UploadFileOptions {
|
|
3
|
+
folder?: string;
|
|
4
|
+
fileName?: string;
|
|
5
|
+
contentType?: string;
|
|
6
|
+
makePublic?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UploadResult {
|
|
9
|
+
key: string;
|
|
10
|
+
url: string;
|
|
11
|
+
fileName: string;
|
|
12
|
+
size: number;
|
|
13
|
+
contentType: string;
|
|
14
|
+
}
|
|
15
|
+
export interface MultipartFile {
|
|
16
|
+
filename: string;
|
|
17
|
+
mimetype: string;
|
|
18
|
+
encoding: string;
|
|
19
|
+
data: Buffer;
|
|
20
|
+
}
|
|
21
|
+
export interface IStorageService {
|
|
22
|
+
uploadFile(file: Buffer | Readable, options?: UploadFileOptions): Promise<UploadResult>;
|
|
23
|
+
uploadMultipartFile(file: MultipartFile, options?: UploadFileOptions): Promise<UploadResult>;
|
|
24
|
+
getPresignedUploadUrl(key: string, contentType: string, expiresIn?: number): Promise<string>;
|
|
25
|
+
getPresignedDownloadUrl(key: string, expiresIn?: number): Promise<string>;
|
|
26
|
+
deleteFile(key: string): Promise<void>;
|
|
27
|
+
fileExists(key: string): Promise<boolean>;
|
|
28
|
+
getPublicUrl(key: string): string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.StorageModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const config_1 = require("@nestjs/config");
|
|
12
|
+
const r2_service_1 = require("./r2.service");
|
|
13
|
+
const s3_service_1 = require("./s3.service");
|
|
14
|
+
const storage_service_1 = require("./storage.service");
|
|
15
|
+
let StorageModule = class StorageModule {
|
|
16
|
+
};
|
|
17
|
+
exports.StorageModule = StorageModule;
|
|
18
|
+
exports.StorageModule = StorageModule = __decorate([
|
|
19
|
+
(0, common_1.Module)({
|
|
20
|
+
imports: [config_1.ConfigModule],
|
|
21
|
+
providers: [r2_service_1.R2Service, s3_service_1.S3Service, storage_service_1.StorageService],
|
|
22
|
+
exports: [r2_service_1.R2Service, s3_service_1.S3Service, storage_service_1.StorageService],
|
|
23
|
+
})
|
|
24
|
+
], StorageModule);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import { IStorageService, MultipartFile, UploadFileOptions, UploadResult } from './storage.interface';
|
|
4
|
+
import { R2Service } from './r2.service';
|
|
5
|
+
import { S3Service } from './s3.service';
|
|
6
|
+
export type StorageProvider = 'r2' | 's3';
|
|
7
|
+
export declare class StorageService implements IStorageService {
|
|
8
|
+
private readonly configService;
|
|
9
|
+
private readonly r2Service;
|
|
10
|
+
private readonly s3Service;
|
|
11
|
+
private readonly provider;
|
|
12
|
+
constructor(configService: ConfigService, r2Service: R2Service, s3Service: S3Service);
|
|
13
|
+
getProvider(): StorageProvider;
|
|
14
|
+
useProvider(provider: StorageProvider): IStorageService;
|
|
15
|
+
uploadFile(file: Buffer | Readable, options?: UploadFileOptions): Promise<UploadResult>;
|
|
16
|
+
uploadMultipartFile(file: MultipartFile, options?: UploadFileOptions): Promise<UploadResult>;
|
|
17
|
+
getPresignedUploadUrl(key: string, contentType: string, expiresIn?: number): Promise<string>;
|
|
18
|
+
getPresignedDownloadUrl(key: string, expiresIn?: number): Promise<string>;
|
|
19
|
+
deleteFile(key: string): Promise<void>;
|
|
20
|
+
fileExists(key: string): Promise<boolean>;
|
|
21
|
+
getPublicUrl(key: string): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.StorageService = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
let StorageService = class StorageService {
|
|
12
|
+
configService;
|
|
13
|
+
r2Service;
|
|
14
|
+
s3Service;
|
|
15
|
+
provider;
|
|
16
|
+
constructor(configService, r2Service, s3Service) {
|
|
17
|
+
this.configService = configService;
|
|
18
|
+
this.r2Service = r2Service;
|
|
19
|
+
this.s3Service = s3Service;
|
|
20
|
+
this.provider =
|
|
21
|
+
this.getProvider() === 's3' ? this.s3Service : this.r2Service;
|
|
22
|
+
}
|
|
23
|
+
getProvider() {
|
|
24
|
+
return (this.configService.get('storage.provider', 'r2') ?? 'r2');
|
|
25
|
+
}
|
|
26
|
+
useProvider(provider) {
|
|
27
|
+
return provider === 's3' ? this.s3Service : this.r2Service;
|
|
28
|
+
}
|
|
29
|
+
async uploadFile(file, options) {
|
|
30
|
+
return this.provider.uploadFile(file, options);
|
|
31
|
+
}
|
|
32
|
+
async uploadMultipartFile(file, options) {
|
|
33
|
+
return this.provider.uploadMultipartFile(file, options);
|
|
34
|
+
}
|
|
35
|
+
async getPresignedUploadUrl(key, contentType, expiresIn) {
|
|
36
|
+
return this.provider.getPresignedUploadUrl(key, contentType, expiresIn);
|
|
37
|
+
}
|
|
38
|
+
async getPresignedDownloadUrl(key, expiresIn) {
|
|
39
|
+
return this.provider.getPresignedDownloadUrl(key, expiresIn);
|
|
40
|
+
}
|
|
41
|
+
async deleteFile(key) {
|
|
42
|
+
return this.provider.deleteFile(key);
|
|
43
|
+
}
|
|
44
|
+
async fileExists(key) {
|
|
45
|
+
return this.provider.fileExists(key);
|
|
46
|
+
}
|
|
47
|
+
getPublicUrl(key) {
|
|
48
|
+
return this.provider.getPublicUrl(key);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.StorageService = StorageService;
|
|
52
|
+
exports.StorageService = StorageService = __decorate([
|
|
53
|
+
(0, common_1.Injectable)()
|
|
54
|
+
], StorageService);
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viardex/viardex-libs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Viardex shared libraries",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist/"
|
|
@@ -12,57 +12,110 @@
|
|
|
12
12
|
"test": "jest",
|
|
13
13
|
"test:watch": "jest --watch",
|
|
14
14
|
"test:cov": "jest --coverage",
|
|
15
|
-
"build": "rm -rf dist && tsc",
|
|
15
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc",
|
|
16
16
|
"lint": "eslint src --ext .ts",
|
|
17
|
-
"prettier": "prettier --write ."
|
|
17
|
+
"prettier": "prettier --write .",
|
|
18
|
+
"format": "prettier --write ."
|
|
18
19
|
},
|
|
19
20
|
"author": "Viardex",
|
|
20
21
|
"license": "MIT",
|
|
21
22
|
"dependencies": {
|
|
23
|
+
"@aws-sdk/client-s3": "^3.916.0",
|
|
24
|
+
"@aws-sdk/s3-request-presigner": "^3.916.0",
|
|
22
25
|
"@nestjs/axios": "^4.0.1",
|
|
23
26
|
"@nestjs/bullmq": "^11.0.4",
|
|
24
|
-
"@nestjs/common": "^11.1.
|
|
25
|
-
"@nestjs/config": "^4.0.
|
|
27
|
+
"@nestjs/common": "^11.1.21",
|
|
28
|
+
"@nestjs/config": "^4.0.4",
|
|
29
|
+
"@nestjs/core": "^11.1.21",
|
|
26
30
|
"@nestjs/jwt": "^11.0.2",
|
|
27
|
-
"@nestjs/microservices": "^11.1.
|
|
31
|
+
"@nestjs/microservices": "^11.1.21",
|
|
28
32
|
"@nestjs/passport": "^11.0.5",
|
|
29
|
-
"@nestjs/terminus": "^11.
|
|
30
|
-
"@sentry/node": "^10.
|
|
33
|
+
"@nestjs/terminus": "^11.1.1",
|
|
34
|
+
"@sentry/node": "^10.53.1",
|
|
31
35
|
"@sentry/tracing": "^7.120.4",
|
|
36
|
+
"argon2": "^0.44.0",
|
|
32
37
|
"class-transformer": "^0.5.1",
|
|
33
|
-
"class-validator": "^0.
|
|
38
|
+
"class-validator": "^0.15.1",
|
|
34
39
|
"cockatiel": "^3.2.1",
|
|
35
40
|
"country-codes-list": "^2.0.0",
|
|
36
41
|
"decimal.js": "^10.6.0",
|
|
37
|
-
"ioredis": "^5.
|
|
38
|
-
"joi": "^18.
|
|
42
|
+
"ioredis": "^5.10.1",
|
|
43
|
+
"joi": "^18.2.1",
|
|
39
44
|
"jsonwebtoken": "^9.0.3",
|
|
40
45
|
"object-hash": "^3.0.0",
|
|
41
46
|
"opossum": "^9.0.0",
|
|
42
47
|
"prom-client": "^15.1.3",
|
|
43
48
|
"rxjs": "^7.8.2",
|
|
44
49
|
"tsup": "^8.5.1",
|
|
45
|
-
"uuid": "^
|
|
50
|
+
"uuid": "^14.0.0",
|
|
51
|
+
"nestjs-pino": "^4.6.1",
|
|
52
|
+
"pino": "^10.3.1",
|
|
53
|
+
"pino-pretty": "^13.1.3"
|
|
46
54
|
},
|
|
47
55
|
"devDependencies": {
|
|
48
|
-
"@nestjs/core": "^11.1.
|
|
49
|
-
"@nestjs/testing": "^11.1.
|
|
56
|
+
"@nestjs/core": "^11.1.21",
|
|
57
|
+
"@nestjs/testing": "^11.1.21",
|
|
50
58
|
"@types/jest": "^30.0.0",
|
|
51
|
-
"@types/
|
|
52
|
-
"@types/
|
|
59
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
60
|
+
"@types/multer": "^2.1.0",
|
|
61
|
+
"@types/node": "^25.8.0",
|
|
53
62
|
"@types/object-hash": "^3.0.6",
|
|
54
63
|
"@types/opossum": "^8.1.9",
|
|
55
64
|
"@types/passport": "^1.0.17",
|
|
56
|
-
"jest": "^30.2
|
|
57
|
-
"prettier": "^3.
|
|
58
|
-
"ts-jest": "^29.4.
|
|
59
|
-
"typescript": "^
|
|
65
|
+
"jest": "^30.4.2",
|
|
66
|
+
"prettier": "^3.8.3",
|
|
67
|
+
"ts-jest": "^29.4.9",
|
|
68
|
+
"typescript": "^6.0.3"
|
|
60
69
|
},
|
|
61
70
|
"exports": {
|
|
62
|
-
".":
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"./
|
|
67
|
-
|
|
71
|
+
".": {
|
|
72
|
+
"types": "./dist/index.d.ts",
|
|
73
|
+
"default": "./dist/index.js"
|
|
74
|
+
},
|
|
75
|
+
"./bullmq": {
|
|
76
|
+
"types": "./dist/bullmq/index.d.ts",
|
|
77
|
+
"default": "./dist/bullmq/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./cache": {
|
|
80
|
+
"types": "./dist/cache/index.d.ts",
|
|
81
|
+
"default": "./dist/cache/index.js"
|
|
82
|
+
},
|
|
83
|
+
"./common": {
|
|
84
|
+
"types": "./dist/common/index.d.ts",
|
|
85
|
+
"default": "./dist/common/index.js"
|
|
86
|
+
},
|
|
87
|
+
"./nats": {
|
|
88
|
+
"types": "./dist/nats/index.d.ts",
|
|
89
|
+
"default": "./dist/nats/index.js"
|
|
90
|
+
},
|
|
91
|
+
"./logger": {
|
|
92
|
+
"types": "./dist/logger/index.d.ts",
|
|
93
|
+
"default": "./dist/logger/index.js"
|
|
94
|
+
},
|
|
95
|
+
"./health": {
|
|
96
|
+
"types": "./dist/health/index.d.ts",
|
|
97
|
+
"default": "./dist/health/index.js"
|
|
98
|
+
},
|
|
99
|
+
"./auth": {
|
|
100
|
+
"types": "./dist/auth/index.d.ts",
|
|
101
|
+
"default": "./dist/auth/index.js"
|
|
102
|
+
},
|
|
103
|
+
"./auth/decorators": {
|
|
104
|
+
"types": "./dist/auth/decorators/index.d.ts",
|
|
105
|
+
"default": "./dist/auth/decorators/index.js"
|
|
106
|
+
},
|
|
107
|
+
"./auth/guards": {
|
|
108
|
+
"types": "./dist/auth/guards/index.d.ts",
|
|
109
|
+
"default": "./dist/auth/guards/index.js"
|
|
110
|
+
},
|
|
111
|
+
"./argon": {
|
|
112
|
+
"types": "./dist/argon/index.d.ts",
|
|
113
|
+
"default": "./dist/argon/index.js"
|
|
114
|
+
},
|
|
115
|
+
"./storage": {
|
|
116
|
+
"types": "./dist/storage/index.d.ts",
|
|
117
|
+
"default": "./dist/storage/index.js"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"packageManager": "pnpm@11.1.2"
|
|
68
121
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SupportAction = void 0;
|
|
4
|
-
var SupportAction;
|
|
5
|
-
(function (SupportAction) {
|
|
6
|
-
SupportAction["CREATE_TICKET"] = "createTicket";
|
|
7
|
-
SupportAction["GET_TICKETS"] = "getTickets";
|
|
8
|
-
SupportAction["GET_TICKET"] = "getTicket";
|
|
9
|
-
SupportAction["UPDATE_TICKET"] = "updateTicket";
|
|
10
|
-
SupportAction["ADD_MESSAGE"] = "addMessage";
|
|
11
|
-
})(SupportAction || (exports.SupportAction = SupportAction = {}));
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare enum TicketStatus {
|
|
2
|
-
OPEN = "OPEN",
|
|
3
|
-
IN_PROGRESS = "IN_PROGRESS",
|
|
4
|
-
RESOLVED = "RESOLVED",
|
|
5
|
-
CLOSED = "CLOSED"
|
|
6
|
-
}
|
|
7
|
-
export declare enum TicketPriority {
|
|
8
|
-
LOW = "LOW",
|
|
9
|
-
MEDIUM = "MEDIUM",
|
|
10
|
-
HIGH = "HIGH",
|
|
11
|
-
URGENT = "URGENT"
|
|
12
|
-
}
|
|
13
|
-
export declare enum TicketCategory {
|
|
14
|
-
GENERAL = "GENERAL",
|
|
15
|
-
TECHNICAL = "TECHNICAL",
|
|
16
|
-
BILLING = "BILLING",
|
|
17
|
-
FEATURE_REQUEST = "FEATURE_REQUEST",
|
|
18
|
-
BUG = "BUG"
|
|
19
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TicketCategory = exports.TicketPriority = exports.TicketStatus = void 0;
|
|
4
|
-
var TicketStatus;
|
|
5
|
-
(function (TicketStatus) {
|
|
6
|
-
TicketStatus["OPEN"] = "OPEN";
|
|
7
|
-
TicketStatus["IN_PROGRESS"] = "IN_PROGRESS";
|
|
8
|
-
TicketStatus["RESOLVED"] = "RESOLVED";
|
|
9
|
-
TicketStatus["CLOSED"] = "CLOSED";
|
|
10
|
-
})(TicketStatus || (exports.TicketStatus = TicketStatus = {}));
|
|
11
|
-
var TicketPriority;
|
|
12
|
-
(function (TicketPriority) {
|
|
13
|
-
TicketPriority["LOW"] = "LOW";
|
|
14
|
-
TicketPriority["MEDIUM"] = "MEDIUM";
|
|
15
|
-
TicketPriority["HIGH"] = "HIGH";
|
|
16
|
-
TicketPriority["URGENT"] = "URGENT";
|
|
17
|
-
})(TicketPriority || (exports.TicketPriority = TicketPriority = {}));
|
|
18
|
-
var TicketCategory;
|
|
19
|
-
(function (TicketCategory) {
|
|
20
|
-
TicketCategory["GENERAL"] = "GENERAL";
|
|
21
|
-
TicketCategory["TECHNICAL"] = "TECHNICAL";
|
|
22
|
-
TicketCategory["BILLING"] = "BILLING";
|
|
23
|
-
TicketCategory["FEATURE_REQUEST"] = "FEATURE_REQUEST";
|
|
24
|
-
TicketCategory["BUG"] = "BUG";
|
|
25
|
-
})(TicketCategory || (exports.TicketCategory = TicketCategory = {}));
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { ClientProxy } from '@nestjs/microservices';
|
|
2
|
-
import { OTPMail, ResetTransactionPinEmail, PasswordResetMail, EmailVerificationMail, DeviceVerificationMail, BulkEmail, BaseEmail, TransactionSuccessMail, AccountSuspendedMail, VirtualAccountCreatedMail, CardCreatedMail, CardFrozenMail, CardUnfrozenMail, CardTransactionMail, CardPinActivatedMail, CryptoTransactionMail, CryptoExchangeRateAlertMail, CashbackEarnedMail, CashbackWithdrawalMail, ReferralBonusEarnedMail, NewReferralSignupMail, GiftCardOrderPlacedMail, GiftCardOrderCompletedMail, GiftCardOrderFailedMail, ESIMOrderPlacedMail, ESIMOrderCompletedMail, ESIMOrderFailedMail, KYCApplicationSubmittedMail, KYCApplicationApprovedMail, KYCApplicationRejectedMail, KYCRequiresMoreInfoMail, LoginFromNewDeviceMail, PasswordChangedMail, TransactionPinChangedMail, SuspiciousActivityAlertMail, AccountLockedMail, TicketCreatedMail, TicketUpdatedMail, TicketResolvedMail, CardSavedMail, CardRemovedMail, PushNotification } from './notification.interface';
|
|
3
|
-
export declare class Notification {
|
|
4
|
-
private readonly natsClient;
|
|
5
|
-
constructor(natsClient: ClientProxy);
|
|
6
|
-
private validatePhoneNumber;
|
|
7
|
-
private validateEmailAddress;
|
|
8
|
-
private emitEmailNotification;
|
|
9
|
-
sendBulkEmail(data: BulkEmail): Promise<void>;
|
|
10
|
-
sendForgetPinOTPMail(to: string, data: ResetTransactionPinEmail): Promise<void>;
|
|
11
|
-
sendPasswordResetMail(to: string, data: PasswordResetMail): Promise<void>;
|
|
12
|
-
sendEmailVerificationMail(to: string, data: EmailVerificationMail): Promise<void>;
|
|
13
|
-
sendDeviceVerificationEmail(to: string, data: Omit<DeviceVerificationMail, keyof BaseEmail>): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Sends generated OTP via email
|
|
16
|
-
* @param to - recipient email address
|
|
17
|
-
* @param data - OTP data
|
|
18
|
-
*/
|
|
19
|
-
sendOTPByMail(to: string, data: OTPMail): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Sends generated OTP via SMS
|
|
22
|
-
* @param to - recipient phone number
|
|
23
|
-
* @param data - OTP data
|
|
24
|
-
*/
|
|
25
|
-
sendOTPBySms(to: string, data: OTPMail): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Sends generated OTP via voice call
|
|
28
|
-
* @param to - recipient phone number
|
|
29
|
-
* @param data - OTP data
|
|
30
|
-
*/
|
|
31
|
-
sendOTPByVoice(to: string, data: OTPMail): Promise<void>;
|
|
32
|
-
sendTransactionSuccessMail(to: string, data: TransactionSuccessMail): Promise<void>;
|
|
33
|
-
sendTransactionSuccessSms(to: string, data: Omit<TransactionSuccessMail, keyof BaseEmail>): Promise<void>;
|
|
34
|
-
sendAccountSuspendedMail(to: string, data: AccountSuspendedMail): Promise<void>;
|
|
35
|
-
sendVirtualAccountCreatedMail(to: string, data: VirtualAccountCreatedMail): Promise<void>;
|
|
36
|
-
sendVirtualAccountCreditSms(to: string, data: Omit<TransactionSuccessMail, keyof BaseEmail>): Promise<void>;
|
|
37
|
-
sendCardCreatedMail(to: string, data: CardCreatedMail): Promise<void>;
|
|
38
|
-
sendCardFrozenMail(to: string, data: CardFrozenMail): Promise<void>;
|
|
39
|
-
sendCardUnfrozenMail(to: string, data: CardUnfrozenMail): Promise<void>;
|
|
40
|
-
sendCardTransactionMail(to: string, data: CardTransactionMail): Promise<void>;
|
|
41
|
-
sendCardTransactionSms(to: string, data: Omit<CardTransactionMail, keyof BaseEmail>): Promise<void>;
|
|
42
|
-
sendCardPinActivatedMail(to: string, data: CardPinActivatedMail): Promise<void>;
|
|
43
|
-
sendCryptoTransactionMail(to: string, data: CryptoTransactionMail): Promise<void>;
|
|
44
|
-
sendCryptoTransactionSms(to: string, data: Omit<CryptoTransactionMail, keyof BaseEmail>): Promise<void>;
|
|
45
|
-
sendCryptoExchangeRateAlertMail(to: string, data: CryptoExchangeRateAlertMail): Promise<void>;
|
|
46
|
-
sendCashbackEarnedMail(to: string, data: CashbackEarnedMail): Promise<void>;
|
|
47
|
-
sendCashbackEarnedSms(to: string, data: Omit<CashbackEarnedMail, keyof BaseEmail>): Promise<void>;
|
|
48
|
-
sendCashbackWithdrawalMail(to: string, data: CashbackWithdrawalMail): Promise<void>;
|
|
49
|
-
sendReferralBonusEarnedMail(to: string, data: ReferralBonusEarnedMail): Promise<void>;
|
|
50
|
-
sendReferralBonusEarnedSms(to: string, data: Omit<ReferralBonusEarnedMail, keyof BaseEmail>): Promise<void>;
|
|
51
|
-
sendNewReferralSignupMail(to: string, data: NewReferralSignupMail): Promise<void>;
|
|
52
|
-
sendGiftCardOrderPlacedMail(to: string, data: GiftCardOrderPlacedMail): Promise<void>;
|
|
53
|
-
sendGiftCardOrderCompletedMail(to: string, data: GiftCardOrderCompletedMail): Promise<void>;
|
|
54
|
-
sendGiftCardOrderFailedMail(to: string, data: GiftCardOrderFailedMail): Promise<void>;
|
|
55
|
-
sendESIMOrderPlacedMail(to: string, data: ESIMOrderPlacedMail): Promise<void>;
|
|
56
|
-
sendESIMOrderCompletedMail(to: string, data: ESIMOrderCompletedMail): Promise<void>;
|
|
57
|
-
sendESIMOrderFailedMail(to: string, data: ESIMOrderFailedMail): Promise<void>;
|
|
58
|
-
sendKYCApplicationSubmittedMail(to: string, data: KYCApplicationSubmittedMail): Promise<void>;
|
|
59
|
-
sendKYCApplicationApprovedMail(to: string, data: KYCApplicationApprovedMail): Promise<void>;
|
|
60
|
-
sendKYCApplicationRejectedMail(to: string, data: KYCApplicationRejectedMail): Promise<void>;
|
|
61
|
-
sendKYCRequiresMoreInfoMail(to: string, data: KYCRequiresMoreInfoMail): Promise<void>;
|
|
62
|
-
sendLoginFromNewDeviceMail(to: string, data: LoginFromNewDeviceMail): Promise<void>;
|
|
63
|
-
sendLoginFromNewDeviceSms(to: string, data: Omit<LoginFromNewDeviceMail, keyof BaseEmail>): Promise<void>;
|
|
64
|
-
sendPasswordChangedMail(to: string, data: PasswordChangedMail): Promise<void>;
|
|
65
|
-
sendTransactionPinChangedMail(to: string, data: TransactionPinChangedMail): Promise<void>;
|
|
66
|
-
sendSuspiciousActivityAlertMail(to: string, data: SuspiciousActivityAlertMail): Promise<void>;
|
|
67
|
-
sendSuspiciousActivityAlertSms(to: string, data: Omit<SuspiciousActivityAlertMail, keyof BaseEmail>): Promise<void>;
|
|
68
|
-
sendAccountLockedMail(to: string, data: AccountLockedMail): Promise<void>;
|
|
69
|
-
sendAccountLockedSms(to: string, data: Omit<AccountLockedMail, keyof BaseEmail>): Promise<void>;
|
|
70
|
-
sendTicketCreatedMail(to: string, data: TicketCreatedMail): Promise<void>;
|
|
71
|
-
sendTicketUpdatedMail(to: string, data: TicketUpdatedMail): Promise<void>;
|
|
72
|
-
sendTicketResolvedMail(to: string, data: TicketResolvedMail): Promise<void>;
|
|
73
|
-
sendCardSavedMail(to: string, data: CardSavedMail): Promise<void>;
|
|
74
|
-
sendCardRemovedMail(to: string, data: CardRemovedMail): Promise<void>;
|
|
75
|
-
sendPushNotification(data: PushNotification): Promise<void>;
|
|
76
|
-
}
|