@takentrade/takentrade-libs 1.2.1 → 1.2.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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/interfaces/config.interface.d.ts +3 -4
- package/dist/utils/utils/configuration.js +3 -4
- package/package.json +11 -11
- package/dist/storage/cloudinary.config.d.ts +0 -10
- package/dist/storage/cloudinary.config.js +0 -22
- package/dist/storage/index.d.ts +0 -4
- package/dist/storage/index.js +0 -20
- package/dist/storage/storage.interface.d.ts +0 -23
- package/dist/storage/storage.interface.js +0 -2
- package/dist/storage/storage.module.d.ts +0 -4
- package/dist/storage/storage.module.js +0 -38
- package/dist/storage/storage.service.d.ts +0 -21
- package/dist/storage/storage.service.js +0 -65
|
@@ -24,10 +24,9 @@ export interface Configuration {
|
|
|
24
24
|
VTPASS_PUBLIC_KEY: string;
|
|
25
25
|
VTPASS_SECRET_KEY: string;
|
|
26
26
|
CREDITSWITCH_BASE_URL: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
CREDITSWITCH_PASSWORD: string;
|
|
27
|
+
CREDITSWITCH_LOGIN_ID: string;
|
|
28
|
+
CREDITSWITCH_PUBLIC_KEY: string;
|
|
29
|
+
CREDITSWITCH_PRIVATE_KEY: string;
|
|
31
30
|
RELOADLY_BASE_URL: string;
|
|
32
31
|
RELOADLY_CLIENT_ID: string;
|
|
33
32
|
RELOADLY_CLIENT_SECRET: string;
|
|
@@ -71,10 +71,9 @@ exports.config = Joi.object({
|
|
|
71
71
|
VTPASS_SECRET_KEY: Joi.string().required(),
|
|
72
72
|
// CreditSwitch
|
|
73
73
|
CREDITSWITCH_BASE_URL: Joi.string().uri().required(),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
CREDITSWITCH_PASSWORD: Joi.string().required(),
|
|
74
|
+
CREDITSWITCH_LOGIN_ID: Joi.string().required(),
|
|
75
|
+
CREDITSWITCH_PUBLIC_KEY: Joi.string().required(),
|
|
76
|
+
CREDITSWITCH_PRIVATE_KEY: Joi.string().required(),
|
|
78
77
|
// Reloadly
|
|
79
78
|
RELOADLY_BASE_URL: Joi.string().uri().required(),
|
|
80
79
|
RELOADLY_CLIENT_ID: Joi.string().required(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takentrade/takentrade-libs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "TakeNTrade shared libraries",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@nestjs/axios": "^4.0.1",
|
|
33
33
|
"@nestjs/bullmq": "^11.0.3",
|
|
34
|
-
"@nestjs/common": "^11.1.
|
|
34
|
+
"@nestjs/common": "^11.1.6",
|
|
35
35
|
"@nestjs/config": "^4.0.2",
|
|
36
36
|
"@nestjs/jwt": "^11.0.0",
|
|
37
|
-
"@nestjs/microservices": "^11.1.
|
|
37
|
+
"@nestjs/microservices": "^11.1.6",
|
|
38
38
|
"@nestjs/passport": "^11.0.5",
|
|
39
39
|
"@nestjs/swagger": "^11.2.0",
|
|
40
40
|
"@nestjs/terminus": "^11.0.0",
|
|
41
|
-
"@prisma/client": "^6.
|
|
41
|
+
"@prisma/client": "^6.14.0",
|
|
42
42
|
"class-transformer": "^0.5.1",
|
|
43
43
|
"class-validator": "^0.14.2",
|
|
44
44
|
"cloudinary": "^2.7.0",
|
|
45
45
|
"country-codes-list": "^2.0.0",
|
|
46
|
-
"ioredis": "^5.
|
|
47
|
-
"joi": "^
|
|
46
|
+
"ioredis": "^5.7.0",
|
|
47
|
+
"joi": "^18.0.0",
|
|
48
48
|
"jsonwebtoken": "^9.0.2",
|
|
49
49
|
"object-hash": "^3.0.0",
|
|
50
50
|
"rxjs": "^7.8.2",
|
|
@@ -52,17 +52,17 @@
|
|
|
52
52
|
"uuid": "^11.1.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@nestjs/core": "^11.1.
|
|
56
|
-
"@nestjs/testing": "^11.1.
|
|
55
|
+
"@nestjs/core": "^11.1.6",
|
|
56
|
+
"@nestjs/testing": "^11.1.6",
|
|
57
57
|
"@types/jest": "^30.0.0",
|
|
58
58
|
"@types/multer": "^2.0.0",
|
|
59
|
-
"@types/node": "^24.
|
|
59
|
+
"@types/node": "^24.3.0",
|
|
60
60
|
"@types/object-hash": "^3.0.6",
|
|
61
61
|
"@types/passport": "^1.0.17",
|
|
62
62
|
"jest": "^30.0.5",
|
|
63
63
|
"prettier": "^3.6.2",
|
|
64
|
-
"ts-jest": "^29.4.
|
|
65
|
-
"typescript": "^5.
|
|
64
|
+
"ts-jest": "^29.4.1",
|
|
65
|
+
"typescript": "^5.9.2"
|
|
66
66
|
},
|
|
67
67
|
"exports": {
|
|
68
68
|
".": "./dist/index.js",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
2
|
-
export declare class CloudinaryConfig {
|
|
3
|
-
private readonly configService;
|
|
4
|
-
constructor(configService: ConfigService);
|
|
5
|
-
createSharedConfiguration(): {
|
|
6
|
-
cloud_name: string;
|
|
7
|
-
api_key: string;
|
|
8
|
-
api_secret: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CloudinaryConfig = void 0;
|
|
4
|
-
const cloudinary_1 = require("cloudinary");
|
|
5
|
-
class CloudinaryConfig {
|
|
6
|
-
configService;
|
|
7
|
-
constructor(configService) {
|
|
8
|
-
this.configService = configService;
|
|
9
|
-
}
|
|
10
|
-
createSharedConfiguration() {
|
|
11
|
-
const cloud_name = this.configService.get('CLOUDINARY_CLOUD_NAME');
|
|
12
|
-
const api_key = this.configService.get('CLOUDINARY_API_KEY');
|
|
13
|
-
const api_secret = this.configService.get('CLOUDINARY_API_SECRET');
|
|
14
|
-
if (!cloud_name || !api_key || !api_secret) {
|
|
15
|
-
throw new Error('Cloudinary configuration is missing. Ensure CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, and CLOUDINARY_API_SECRET are set in the environment variables.');
|
|
16
|
-
}
|
|
17
|
-
const config = { cloud_name, api_key, api_secret };
|
|
18
|
-
cloudinary_1.v2.config(config);
|
|
19
|
-
return config;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.CloudinaryConfig = CloudinaryConfig;
|
package/dist/storage/index.d.ts
DELETED
package/dist/storage/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./cloudinary.config"), exports);
|
|
18
|
-
__exportStar(require("./storage.interface"), exports);
|
|
19
|
-
__exportStar(require("./storage.module"), exports);
|
|
20
|
-
__exportStar(require("./storage.service"), exports);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface FileUpload {
|
|
2
|
-
buffer: Buffer;
|
|
3
|
-
originalname?: string;
|
|
4
|
-
mimetype?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface UploadResponse {
|
|
7
|
-
public_id: string;
|
|
8
|
-
url: string;
|
|
9
|
-
secure_url: string;
|
|
10
|
-
format: string;
|
|
11
|
-
resource_type: string;
|
|
12
|
-
created_at: string;
|
|
13
|
-
}
|
|
14
|
-
export interface DeleteResponse {
|
|
15
|
-
result: string;
|
|
16
|
-
}
|
|
17
|
-
export interface IStorageService {
|
|
18
|
-
uploadFile(file: FileUpload, options?: {
|
|
19
|
-
folder?: string;
|
|
20
|
-
tags?: string[];
|
|
21
|
-
}): Promise<UploadResponse>;
|
|
22
|
-
deleteFile(publicId: string): Promise<DeleteResponse>;
|
|
23
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var StorageModule_1;
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.StorageModule = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const config_1 = require("@nestjs/config");
|
|
13
|
-
const storage_service_1 = require("./storage.service");
|
|
14
|
-
const cloudinary_config_1 = require("./cloudinary.config");
|
|
15
|
-
let StorageModule = StorageModule_1 = class StorageModule {
|
|
16
|
-
static forRoot() {
|
|
17
|
-
return {
|
|
18
|
-
module: StorageModule_1,
|
|
19
|
-
imports: [config_1.ConfigModule],
|
|
20
|
-
providers: [
|
|
21
|
-
cloudinary_config_1.CloudinaryConfig,
|
|
22
|
-
{
|
|
23
|
-
provide: 'CLOUDINARY_CONFIG',
|
|
24
|
-
useFactory: (cloudinaryConfig) => {
|
|
25
|
-
return cloudinaryConfig.createSharedConfiguration();
|
|
26
|
-
},
|
|
27
|
-
inject: [cloudinary_config_1.CloudinaryConfig],
|
|
28
|
-
},
|
|
29
|
-
storage_service_1.StorageService,
|
|
30
|
-
],
|
|
31
|
-
exports: [storage_service_1.StorageService],
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
exports.StorageModule = StorageModule;
|
|
36
|
-
exports.StorageModule = StorageModule = StorageModule_1 = __decorate([
|
|
37
|
-
(0, common_1.Module)({})
|
|
38
|
-
], StorageModule);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { IStorageService, UploadResponse, DeleteResponse, FileUpload } from './storage.interface';
|
|
2
|
-
export declare class StorageService implements IStorageService {
|
|
3
|
-
/**
|
|
4
|
-
* Uploads a file to Cloudinary using a stream.
|
|
5
|
-
* @param file - The file to upload, provided as a FileUpload object.
|
|
6
|
-
* @param options - Optional Cloudinary upload options (e.g., folder, tags).
|
|
7
|
-
* @returns A promise resolving to the upload response containing file details.
|
|
8
|
-
* @throws Error if the upload fails or no result is returned from Cloudinary.
|
|
9
|
-
*/
|
|
10
|
-
uploadFile(file: FileUpload, options?: {
|
|
11
|
-
folder?: string;
|
|
12
|
-
tags?: string[];
|
|
13
|
-
}): Promise<UploadResponse>;
|
|
14
|
-
/**
|
|
15
|
-
* Deletes a file from Cloudinary using its public ID.
|
|
16
|
-
* @param publicId - The public ID of the file to delete.
|
|
17
|
-
* @returns A promise resolving to the deletion response.
|
|
18
|
-
* @throws Error if the deletion fails.
|
|
19
|
-
*/
|
|
20
|
-
deleteFile(publicId: string): Promise<DeleteResponse>;
|
|
21
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
const cloudinary_1 = require("cloudinary");
|
|
12
|
-
let StorageService = class StorageService {
|
|
13
|
-
/**
|
|
14
|
-
* Uploads a file to Cloudinary using a stream.
|
|
15
|
-
* @param file - The file to upload, provided as a FileUpload object.
|
|
16
|
-
* @param options - Optional Cloudinary upload options (e.g., folder, tags).
|
|
17
|
-
* @returns A promise resolving to the upload response containing file details.
|
|
18
|
-
* @throws Error if the upload fails or no result is returned from Cloudinary.
|
|
19
|
-
*/
|
|
20
|
-
async uploadFile(file, options) {
|
|
21
|
-
try {
|
|
22
|
-
const result = await new Promise((resolve, reject) => {
|
|
23
|
-
cloudinary_1.v2.uploader
|
|
24
|
-
.upload_stream({ resource_type: 'auto', ...options }, (error, result) => {
|
|
25
|
-
if (error)
|
|
26
|
-
return reject(error);
|
|
27
|
-
if (!result)
|
|
28
|
-
return reject(new Error('No result from Cloudinary'));
|
|
29
|
-
resolve(result);
|
|
30
|
-
})
|
|
31
|
-
.end(file.buffer);
|
|
32
|
-
});
|
|
33
|
-
return {
|
|
34
|
-
public_id: result.public_id,
|
|
35
|
-
url: result.url,
|
|
36
|
-
secure_url: result.secure_url,
|
|
37
|
-
format: result.format,
|
|
38
|
-
resource_type: result.resource_type,
|
|
39
|
-
created_at: result.created_at,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
throw new Error(`Upload failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Deletes a file from Cloudinary using its public ID.
|
|
48
|
-
* @param publicId - The public ID of the file to delete.
|
|
49
|
-
* @returns A promise resolving to the deletion response.
|
|
50
|
-
* @throws Error if the deletion fails.
|
|
51
|
-
*/
|
|
52
|
-
async deleteFile(publicId) {
|
|
53
|
-
try {
|
|
54
|
-
const result = await cloudinary_1.v2.uploader.destroy(publicId);
|
|
55
|
-
return { result: result.result };
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
throw new Error(`Deletion failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
exports.StorageService = StorageService;
|
|
63
|
-
exports.StorageService = StorageService = __decorate([
|
|
64
|
-
(0, common_1.Injectable)()
|
|
65
|
-
], StorageService);
|