@maioradv/nestjs-core 1.1.8 → 1.1.10
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/decorators/api-response-with-rels.decorator.d.ts +13 -0
- package/dist/dto/clauses/model.js +1 -0
- package/dist/providers/s3.service.js +9 -0
- package/dist/utils/path.helper.js +1 -1
- package/dist/utils/time.helper.d.ts +4 -0
- package/dist/utils/time.helper.js +4 -0
- package/package.json +1 -1
|
@@ -2,10 +2,23 @@ import { Type } from "@nestjs/common";
|
|
|
2
2
|
import { ApiResponseMetadata } from "@nestjs/swagger";
|
|
3
3
|
import { WithRequired } from "../utils/types.helper";
|
|
4
4
|
import { ReferenceObject, SchemaObject } from "@nestjs/swagger/dist/interfaces/open-api-spec.interface";
|
|
5
|
+
/** Entity Model as model itself or ['ModelName',Model] */
|
|
5
6
|
export type TModel = Type<any> | [string, Type<any>];
|
|
6
7
|
export type RelationDefs = {
|
|
8
|
+
/** Array of Relation Entity or ['RelationNameKey',Relation Entity]
|
|
9
|
+
* @example ProductAttribute
|
|
10
|
+
*/
|
|
7
11
|
oneToOne?: TModel[];
|
|
12
|
+
/** Array of Relation Entity or ['RelationNameKey',Relation Entity]
|
|
13
|
+
* @example ProductVariant
|
|
14
|
+
* @example ['variants',ProductVariant]
|
|
15
|
+
*/
|
|
8
16
|
oneToMany?: TModel[];
|
|
17
|
+
/** Array with Relation Entity and Parent Entity (or Entities)
|
|
18
|
+
* @example [CollectionImage,Image]
|
|
19
|
+
* @example [['images',CollectionImage],Image]
|
|
20
|
+
* @example [CollectionImage,[Image,Language]]
|
|
21
|
+
*/
|
|
9
22
|
manyToMany?: [TModel, TModel | TModel[]][];
|
|
10
23
|
};
|
|
11
24
|
export type ApiReponseWithRelsOptions = WithRequired<ApiResponseMetadata, 'type'>;
|
|
@@ -32,6 +32,15 @@ let S3Service = class S3Service {
|
|
|
32
32
|
}
|
|
33
33
|
async uploadImage(file) {
|
|
34
34
|
let fileName = `${this.randomString(6)}-${file.originalname}`;
|
|
35
|
+
/*try {
|
|
36
|
+
const check = await this.client.send(
|
|
37
|
+
new HeadObjectCommand({
|
|
38
|
+
Bucket: this.sdkConfigs.bucketName,
|
|
39
|
+
Key: `${this.sdkConfigs.folder}/${fileName}`,
|
|
40
|
+
})
|
|
41
|
+
)
|
|
42
|
+
if(check) fileName = `${this.randomString(5)}-${fileName}`
|
|
43
|
+
} catch(e) {}*/
|
|
35
44
|
const response = await this.client.send(new client_s3_1.PutObjectCommand({
|
|
36
45
|
Bucket: this.sdkConfigs.bucketName,
|
|
37
46
|
Key: `${this.sdkConfigs.folder}/${fileName}`,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.joinFromRoot = exports.ROOT_PATH = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
exports.ROOT_PATH = (0, path_1.join)(process.cwd());
|
|
5
|
+
exports.ROOT_PATH = (0, path_1.join)(process.cwd()); //join(__dirname,'..','../../','../../')
|
|
6
6
|
const joinFromRoot = (...paths) => (0, path_1.join)(exports.ROOT_PATH, ...paths);
|
|
7
7
|
exports.joinFromRoot = joinFromRoot;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toMs = void 0;
|
|
4
|
+
/** Transform a time string (s,m,h,d) to milliseconds
|
|
5
|
+
* @example toMs('1s') => 1 * 1000
|
|
6
|
+
* @example toMs('1m') => 1 * 60 * 1000
|
|
7
|
+
*/
|
|
4
8
|
function toMs(str) {
|
|
5
9
|
const matches = str.match(/(\d+)/);
|
|
6
10
|
const number = +matches[0] ?? 0;
|