pg-mvc-service 1.0.0 → 1.0.2
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/Service.js +8 -8
- package/dist/clients/AwsS3Client.js +5 -7
- package/dist/clients/Base64Client.js +2 -1
- package/dist/clients/EncryptClient.js +2 -1
- package/dist/clients/StringClient.js +2 -1
- package/dist/index.js +21 -1
- package/index.d.ts +5 -5
- package/package.json +1 -1
- package/src/Service.ts +4 -4
- package/src/clients/AwsS3Client.ts +2 -2
- package/src/clients/Base64Client.ts +1 -1
- package/src/clients/EncryptClient.ts +1 -1
- package/src/clients/StringClient.ts +1 -1
- package/src/index.ts +12 -1
package/dist/Service.js
CHANGED
|
@@ -17,10 +17,10 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
17
17
|
const Exception_1 = require("./exceptions/Exception");
|
|
18
18
|
const RequestType_1 = require("./reqestResponse/RequestType");
|
|
19
19
|
const ResponseType_1 = require("./reqestResponse/ResponseType");
|
|
20
|
-
const AwsS3Client_1 =
|
|
21
|
-
const Base64Client_1 =
|
|
22
|
-
const StringClient_1 =
|
|
23
|
-
const EncryptClient_1 =
|
|
20
|
+
const AwsS3Client_1 = require("./clients/AwsS3Client");
|
|
21
|
+
const Base64Client_1 = require("./clients/Base64Client");
|
|
22
|
+
const StringClient_1 = require("./clients/StringClient");
|
|
23
|
+
const EncryptClient_1 = require("./clients/EncryptClient");
|
|
24
24
|
const PoolManager_1 = __importDefault(require("./PoolManager"));
|
|
25
25
|
class Service {
|
|
26
26
|
get Method() { return this.method; }
|
|
@@ -180,7 +180,7 @@ class Service {
|
|
|
180
180
|
}
|
|
181
181
|
get S3Client() {
|
|
182
182
|
if (this.s3Client === undefined) {
|
|
183
|
-
this.s3Client = new AwsS3Client_1.
|
|
183
|
+
this.s3Client = new AwsS3Client_1.AwsS3Client({
|
|
184
184
|
bucketName: process.env.S3_BUCKET_NAME,
|
|
185
185
|
region: process.env.S3_REGION,
|
|
186
186
|
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
@@ -191,19 +191,19 @@ class Service {
|
|
|
191
191
|
}
|
|
192
192
|
get Base64Client() {
|
|
193
193
|
if (this.base64Client === undefined) {
|
|
194
|
-
this.base64Client = new Base64Client_1.
|
|
194
|
+
this.base64Client = new Base64Client_1.Base64Client();
|
|
195
195
|
}
|
|
196
196
|
return this.base64Client;
|
|
197
197
|
}
|
|
198
198
|
get StringClient() {
|
|
199
199
|
if (this.stringClient === undefined) {
|
|
200
|
-
this.stringClient = new StringClient_1.
|
|
200
|
+
this.stringClient = new StringClient_1.StringClient();
|
|
201
201
|
}
|
|
202
202
|
return this.stringClient;
|
|
203
203
|
}
|
|
204
204
|
get EncryptClient() {
|
|
205
205
|
if (this.encryptClient === undefined) {
|
|
206
|
-
this.encryptClient = new EncryptClient_1.
|
|
206
|
+
this.encryptClient = new EncryptClient_1.EncryptClient({
|
|
207
207
|
secretKeyHex: process.env.SECRET_KEY_HEX,
|
|
208
208
|
hmacKeyBase64: process.env.HMAC_KEY_BASE64
|
|
209
209
|
});
|
|
@@ -15,12 +15,10 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
15
15
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
16
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
17
|
};
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.AwsS3Client = void 0;
|
|
22
20
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
23
|
-
const Base64Client_1 =
|
|
21
|
+
const Base64Client_1 = require("./Base64Client");
|
|
24
22
|
class AwsS3Client {
|
|
25
23
|
get urlPrefix() {
|
|
26
24
|
return `https://${this.bucketName}.s3.${this.region}.amazonaws.com`;
|
|
@@ -79,7 +77,7 @@ class AwsS3Client {
|
|
|
79
77
|
}
|
|
80
78
|
uploadToPdf(path, fileName, base64Datas) {
|
|
81
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const base64Client = new Base64Client_1.
|
|
80
|
+
const base64Client = new Base64Client_1.Base64Client();
|
|
83
81
|
const mergedPdfBase64 = yield base64Client.mergeToPdfBase64(base64Datas);
|
|
84
82
|
const command = new client_s3_1.PutObjectCommand({
|
|
85
83
|
Bucket: this.bucketName,
|
|
@@ -104,7 +102,7 @@ class AwsS3Client {
|
|
|
104
102
|
}
|
|
105
103
|
uploadBase64Data(path, fileName, base64Data) {
|
|
106
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
const base64Client = new Base64Client_1.
|
|
105
|
+
const base64Client = new Base64Client_1.Base64Client();
|
|
108
106
|
const type = base64Client.getMimeType(base64Data);
|
|
109
107
|
const extension = {
|
|
110
108
|
'image/png': '.png',
|
|
@@ -246,4 +244,4 @@ class AwsS3Client {
|
|
|
246
244
|
});
|
|
247
245
|
}
|
|
248
246
|
}
|
|
249
|
-
exports.
|
|
247
|
+
exports.AwsS3Client = AwsS3Client;
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Base64Client = void 0;
|
|
15
16
|
const pdf_lib_1 = require("pdf-lib");
|
|
16
17
|
const sharp_1 = __importDefault(require("sharp"));
|
|
17
18
|
class Base64Client {
|
|
@@ -150,4 +151,4 @@ class Base64Client {
|
|
|
150
151
|
});
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
|
-
exports.
|
|
154
|
+
exports.Base64Client = Base64Client;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EncryptClient = void 0;
|
|
6
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
7
8
|
class EncryptClient {
|
|
8
9
|
get SecretKey() {
|
|
@@ -82,4 +83,4 @@ class EncryptClient {
|
|
|
82
83
|
return Buffer.from(str, 'base64');
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
|
-
exports.
|
|
86
|
+
exports.EncryptClient = EncryptClient;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringClient = void 0;
|
|
3
4
|
const crypto_1 = require("crypto");
|
|
4
5
|
class StringClient {
|
|
5
6
|
constructor() { }
|
|
@@ -10,4 +11,4 @@ class StringClient {
|
|
|
10
11
|
return `${timeHex.slice(0, 8)}-${timeHex.slice(8, 12)}-7${timeHex.slice(13, 16)}-${randomHex.slice(0, 4)}-${randomHex.slice(4)}`;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
exports.
|
|
14
|
+
exports.StringClient = StringClient;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResponseType = exports.RequestType = exports.createSwagger = exports.ForbiddenException = exports.InputErrorException = exports.AuthException = exports.MaintenanceException = exports.Service = void 0;
|
|
3
|
+
exports.rollback = exports.migrate = exports.MigrateDatabase = exports.MigrateTable = exports.createTableDoc = exports.TableModel = exports.ResponseType = exports.RequestType = exports.EncryptClient = exports.StringClient = exports.Base64Client = exports.AwsS3Client = exports.createSwagger = exports.ForbiddenException = exports.InputErrorException = exports.AuthException = exports.MaintenanceException = exports.Service = void 0;
|
|
4
4
|
var Service_1 = require("./Service");
|
|
5
5
|
Object.defineProperty(exports, "Service", { enumerable: true, get: function () { return Service_1.Service; } });
|
|
6
6
|
var Exception_1 = require("./exceptions/Exception");
|
|
@@ -10,7 +10,27 @@ Object.defineProperty(exports, "InputErrorException", { enumerable: true, get: f
|
|
|
10
10
|
Object.defineProperty(exports, "ForbiddenException", { enumerable: true, get: function () { return Exception_1.ForbiddenException; } });
|
|
11
11
|
var Swagger_1 = require("./documents/Swagger");
|
|
12
12
|
Object.defineProperty(exports, "createSwagger", { enumerable: true, get: function () { return Swagger_1.createSwagger; } });
|
|
13
|
+
var AwsS3Client_1 = require("./clients/AwsS3Client");
|
|
14
|
+
Object.defineProperty(exports, "AwsS3Client", { enumerable: true, get: function () { return AwsS3Client_1.AwsS3Client; } });
|
|
15
|
+
var Base64Client_1 = require("./clients/Base64Client");
|
|
16
|
+
Object.defineProperty(exports, "Base64Client", { enumerable: true, get: function () { return Base64Client_1.Base64Client; } });
|
|
17
|
+
var StringClient_1 = require("./clients/StringClient");
|
|
18
|
+
Object.defineProperty(exports, "StringClient", { enumerable: true, get: function () { return StringClient_1.StringClient; } });
|
|
19
|
+
var EncryptClient_1 = require("./clients/EncryptClient");
|
|
20
|
+
Object.defineProperty(exports, "EncryptClient", { enumerable: true, get: function () { return EncryptClient_1.EncryptClient; } });
|
|
13
21
|
var RequestType_1 = require("./reqestResponse/RequestType");
|
|
14
22
|
Object.defineProperty(exports, "RequestType", { enumerable: true, get: function () { return RequestType_1.RequestType; } });
|
|
15
23
|
var ResponseType_1 = require("./reqestResponse/ResponseType");
|
|
16
24
|
Object.defineProperty(exports, "ResponseType", { enumerable: true, get: function () { return ResponseType_1.ResponseType; } });
|
|
25
|
+
// models
|
|
26
|
+
var TableModel_1 = require("./models/TableModel");
|
|
27
|
+
Object.defineProperty(exports, "TableModel", { enumerable: true, get: function () { return TableModel_1.TableModel; } });
|
|
28
|
+
var TableDoc_1 = require("./models/TableDoc");
|
|
29
|
+
Object.defineProperty(exports, "createTableDoc", { enumerable: true, get: function () { return TableDoc_1.createTableDoc; } });
|
|
30
|
+
var MigrateTable_1 = require("./models/MigrateTable");
|
|
31
|
+
Object.defineProperty(exports, "MigrateTable", { enumerable: true, get: function () { return MigrateTable_1.MigrateTable; } });
|
|
32
|
+
var MigrateDatabase_1 = require("./models/MigrateDatabase");
|
|
33
|
+
Object.defineProperty(exports, "MigrateDatabase", { enumerable: true, get: function () { return MigrateDatabase_1.MigrateDatabase; } });
|
|
34
|
+
var MigrateRollback_1 = require("./models/MigrateRollback");
|
|
35
|
+
Object.defineProperty(exports, "migrate", { enumerable: true, get: function () { return MigrateRollback_1.migrate; } });
|
|
36
|
+
Object.defineProperty(exports, "rollback", { enumerable: true, get: function () { return MigrateRollback_1.rollback; } });
|
package/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { Request, Response } from 'express';
|
|
|
3
3
|
import { Pool, PoolClient } from 'pg';
|
|
4
4
|
import { IncomingHttpHeaders } from './src/reqestResponse/RequestType';
|
|
5
5
|
import { ArrayType, EnumType, ObjectType, PrimitiveType } from './src/reqestResponse/ReqResType';
|
|
6
|
-
import
|
|
7
|
-
import Base64Client from './src/clients/Base64Client';
|
|
8
|
-
import StringClient from './src/clients/StringClient';
|
|
9
|
-
import EncryptClient from './src/clients/EncryptClient';
|
|
6
|
+
import { AwsS3Client } from './src/clients/AwsS3Client';
|
|
7
|
+
import { Base64Client } from './src/clients/Base64Client';
|
|
8
|
+
import { StringClient } from './src/clients/StringClient';
|
|
9
|
+
import { EncryptClient } from './src/clients/EncryptClient';
|
|
10
10
|
|
|
11
11
|
// models class
|
|
12
12
|
import ValidateClient from './src/models/ValidateClient';
|
|
@@ -59,7 +59,7 @@ declare module 'pg-mvc-service' {
|
|
|
59
59
|
public rollback(): Promise<void>;
|
|
60
60
|
public release(): Promise<void>;
|
|
61
61
|
|
|
62
|
-
get S3Client():
|
|
62
|
+
get S3Client(): AwsS3Client;
|
|
63
63
|
get Base64Client(): Base64Client;
|
|
64
64
|
get StringClient(): StringClient;
|
|
65
65
|
get EncryptClient(): EncryptClient;
|
package/package.json
CHANGED
package/src/Service.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { Pool, type PoolClient } from 'pg';
|
|
|
4
4
|
import { MaintenanceException, AuthException, InputErrorException, ForbiddenException } from './exceptions/Exception';
|
|
5
5
|
import { RequestType } from './reqestResponse/RequestType';
|
|
6
6
|
import { ResponseType } from './reqestResponse/ResponseType';
|
|
7
|
-
import AwsS3Client from './clients/AwsS3Client';
|
|
8
|
-
import Base64Client from './clients/Base64Client';
|
|
9
|
-
import StringClient from './clients/StringClient';
|
|
10
|
-
import EncryptClient from './clients/EncryptClient';
|
|
7
|
+
import { AwsS3Client } from './clients/AwsS3Client';
|
|
8
|
+
import { Base64Client } from './clients/Base64Client';
|
|
9
|
+
import { StringClient } from './clients/StringClient';
|
|
10
|
+
import { EncryptClient } from './clients/EncryptClient';
|
|
11
11
|
import PoolManager from './PoolManager';
|
|
12
12
|
|
|
13
13
|
export type MethodType = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _Object, DeleteObjectsCommand, GetObjectCommand, ListObjectsV2Command, PutObjectCommand, S3Client, ScanRange } from '@aws-sdk/client-s3';
|
|
2
|
-
import Base64Client from './Base64Client';
|
|
2
|
+
import { Base64Client } from './Base64Client';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export class AwsS3Client {
|
|
5
5
|
private client: S3Client;
|
|
6
6
|
|
|
7
7
|
private readonly bucketName;
|
|
@@ -9,7 +9,7 @@ export type TImage = TPng | TJpeg | TGif;
|
|
|
9
9
|
export type TPdf = 'application/pdf';
|
|
10
10
|
export type TJson = 'application/json';
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export class Base64Client {
|
|
13
13
|
constructor() { }
|
|
14
14
|
|
|
15
15
|
// public encode(text: string): string {
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
export { Service } from './Service';
|
|
2
2
|
export { MaintenanceException, AuthException, InputErrorException, ForbiddenException } from './exceptions/Exception';
|
|
3
3
|
export { createSwagger } from './documents/Swagger';
|
|
4
|
+
export { AwsS3Client } from './clients/AwsS3Client';
|
|
5
|
+
export { Base64Client } from './clients/Base64Client';
|
|
6
|
+
export { StringClient } from './clients/StringClient';
|
|
7
|
+
export { EncryptClient } from './clients/EncryptClient';
|
|
4
8
|
|
|
5
9
|
export { RequestType } from './reqestResponse/RequestType';
|
|
6
10
|
export { ResponseType } from './reqestResponse/ResponseType';
|
|
7
|
-
export { PropertyType } from './reqestResponse/ReqResType';
|
|
11
|
+
export { PropertyType } from './reqestResponse/ReqResType';
|
|
12
|
+
|
|
13
|
+
// models
|
|
14
|
+
export { TableModel } from './models/TableModel';
|
|
15
|
+
export { createTableDoc } from './models/TableDoc';
|
|
16
|
+
export { MigrateTable } from './models/MigrateTable';
|
|
17
|
+
export { MigrateDatabase } from './models/MigrateDatabase';
|
|
18
|
+
export { migrate, rollback } from './models/MigrateRollback';
|