@maioradv/nestjs-core 1.7.3 → 1.8.1
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 +1 -1
- package/dist/decorators/api-response-with-rels.decorator.js +2 -2
- package/dist/decorators/boolean.transform.d.ts +1 -1
- package/dist/dto/clauses/standard-clauses.decorator.d.ts +5 -5
- package/dist/dto/pagination/cursor-paginated.dto.d.ts +2 -1
- package/dist/dto/pagination/cursor-paginated.dto.js +9 -8
- package/dist/dto/pagination/cursor-query.dto.d.ts +4 -1
- package/dist/dto/pagination/cursor-query.dto.js +27 -2
- package/dist/dto/pagination/paginated-response.decorator.d.ts +1 -1
- package/dist/dto/pagination/pagination-params.decorator.d.ts +1 -1
- package/dist/dto/sorting/sorting-params.decorator.d.ts +2 -2
- package/dist/pipes/image-compression.pipe.d.ts +0 -1
- package/dist/providers/crypt.service.js +17 -7
- package/dist/providers/s3.service.d.ts +0 -1
- package/dist/providers/storage.service.d.ts +0 -4
- package/dist/utils/image.helper.d.ts +0 -1
- package/dist/utils/image.helper.js +1 -2
- package/dist/utils/price.helper.js +1 -2
- package/dist/utils/time.helper.js +1 -2
- package/package.json +24 -25
|
@@ -22,7 +22,7 @@ export type RelationDefs = {
|
|
|
22
22
|
manyToMany?: [TModel, TModel | TModel[]][];
|
|
23
23
|
};
|
|
24
24
|
export type ApiReponseWithRelsOptions = WithRequired<ApiResponseMetadata, 'type'>;
|
|
25
|
-
export declare const ApiResponseWithRels: (options: ApiReponseWithRelsOptions, relations: RelationDefs) => <TFunction extends Function, Y>(target:
|
|
25
|
+
export declare const ApiResponseWithRels: (options: ApiReponseWithRelsOptions, relations: RelationDefs) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
26
26
|
export declare function handleRelationsForSwagger(relations: RelationDefs): {
|
|
27
27
|
properties: Record<string, SchemaObject | ReferenceObject>;
|
|
28
28
|
extraModels: Type<any>[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ApiResponseWithRels = void 0;
|
|
4
|
+
exports.handleRelationsForSwagger = handleRelationsForSwagger;
|
|
4
5
|
const common_1 = require("@nestjs/common");
|
|
5
6
|
const swagger_1 = require("@nestjs/swagger");
|
|
6
7
|
const ApiResponseWithRels = (options, relations) => {
|
|
@@ -66,4 +67,3 @@ function handleRelationsForSwagger(relations) {
|
|
|
66
67
|
});
|
|
67
68
|
return { properties, extraModels };
|
|
68
69
|
}
|
|
69
|
-
exports.handleRelationsForSwagger = handleRelationsForSwagger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const BooleanTransform: () => <TFunction extends Function, Y>(target:
|
|
1
|
+
export declare const BooleanTransform: () => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const IsStringClause: (options?: {
|
|
2
2
|
isArray?: boolean;
|
|
3
|
-
}) => <TFunction extends Function, Y>(target:
|
|
4
|
-
export declare const IsEnumClause: (model: object) => <TFunction extends Function, Y>(target:
|
|
5
|
-
export declare const IsNumberClause: () => <TFunction extends Function, Y>(target:
|
|
6
|
-
export declare const IsBooleanClause: () => <TFunction extends Function, Y>(target:
|
|
7
|
-
export declare const IsDateStringClause: () => <TFunction extends Function, Y>(target:
|
|
3
|
+
}) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
4
|
+
export declare const IsEnumClause: (model: object) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
5
|
+
export declare const IsNumberClause: () => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
6
|
+
export declare const IsBooleanClause: () => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
7
|
+
export declare const IsDateStringClause: () => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Type } from '@nestjs/common';
|
|
2
2
|
import CursorMetaDto from './cursor-meta.dto';
|
|
3
|
+
import CursorQueryDto from './cursor-query.dto';
|
|
3
4
|
interface IEdgeType<T> {
|
|
4
5
|
cursor: string;
|
|
5
6
|
node: T;
|
|
@@ -18,7 +19,7 @@ export declare class PaginatedGQLDto<T> implements IPaginatedType<T> {
|
|
|
18
19
|
readonly edges: IEdgeType<T>[];
|
|
19
20
|
readonly nodes: T[];
|
|
20
21
|
readonly meta: CursorMetaDto;
|
|
21
|
-
constructor(data: T[], meta: CursorMeta);
|
|
22
|
+
constructor(data: T[], meta: CursorMeta, query: CursorQueryDto);
|
|
22
23
|
private getEdges;
|
|
23
24
|
}
|
|
24
25
|
export {};
|
|
@@ -12,7 +12,8 @@ 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.PaginatedGQLDto =
|
|
15
|
+
exports.PaginatedGQLDto = void 0;
|
|
16
|
+
exports.PaginatedGQL = PaginatedGQL;
|
|
16
17
|
const graphql_1 = require("@nestjs/graphql");
|
|
17
18
|
const cursor_meta_dto_1 = __importDefault(require("./cursor-meta.dto"));
|
|
18
19
|
function PaginatedGQL(classRef) {
|
|
@@ -48,22 +49,22 @@ function PaginatedGQL(classRef) {
|
|
|
48
49
|
], PaginatedType);
|
|
49
50
|
return PaginatedType;
|
|
50
51
|
}
|
|
51
|
-
exports.PaginatedGQL = PaginatedGQL;
|
|
52
52
|
class PaginatedGQLDto {
|
|
53
|
-
constructor(data, meta) {
|
|
54
|
-
this.edges = this.getEdges(data);
|
|
53
|
+
constructor(data, meta, query) {
|
|
54
|
+
this.edges = this.getEdges(data, query.cursorField);
|
|
55
55
|
this.nodes = data;
|
|
56
|
+
const [firstIndex, lastIndex] = query.cursorOrder == 'asc' ? [0, this.edges.length - 1] : [this.edges.length - 1, 0];
|
|
56
57
|
this.meta = new cursor_meta_dto_1.default({
|
|
57
58
|
...meta,
|
|
58
|
-
start: +this.edges[
|
|
59
|
-
end: +this.edges[
|
|
59
|
+
start: +this.edges[firstIndex]?.cursor,
|
|
60
|
+
end: +this.edges[lastIndex]?.cursor
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
getEdges(data) {
|
|
63
|
+
getEdges(data, cursor) {
|
|
63
64
|
return data.map((value) => {
|
|
64
65
|
return {
|
|
65
66
|
node: value,
|
|
66
|
-
cursor: value
|
|
67
|
+
cursor: value[cursor],
|
|
67
68
|
};
|
|
68
69
|
});
|
|
69
70
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { Sorting } from "../sorting";
|
|
1
2
|
export default class CursorQueryDto {
|
|
2
3
|
readonly after?: number;
|
|
3
4
|
readonly before?: number;
|
|
4
5
|
readonly limit?: number;
|
|
6
|
+
readonly cursorField?: string;
|
|
7
|
+
readonly cursorOrder?: Sorting;
|
|
5
8
|
get skip(): number;
|
|
6
9
|
get take(): number;
|
|
7
10
|
get order(): Record<string, any>;
|
|
8
11
|
get cursor(): {
|
|
9
|
-
|
|
12
|
+
[x: string]: number;
|
|
10
13
|
};
|
|
11
14
|
}
|
|
@@ -13,9 +13,12 @@ const swagger_1 = require("@nestjs/swagger");
|
|
|
13
13
|
const class_transformer_1 = require("class-transformer");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
15
|
const graphql_1 = require("@nestjs/graphql");
|
|
16
|
+
const sorting_1 = require("../sorting");
|
|
16
17
|
let CursorQueryDto = class CursorQueryDto {
|
|
17
18
|
constructor() {
|
|
18
19
|
this.limit = 50;
|
|
20
|
+
this.cursorField = 'id';
|
|
21
|
+
this.cursorOrder = sorting_1.Sorting.asc;
|
|
19
22
|
}
|
|
20
23
|
get skip() {
|
|
21
24
|
if (this.after || this.before)
|
|
@@ -29,12 +32,12 @@ let CursorQueryDto = class CursorQueryDto {
|
|
|
29
32
|
}
|
|
30
33
|
get order() {
|
|
31
34
|
return {
|
|
32
|
-
|
|
35
|
+
[this.cursorField]: this.cursorOrder
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
get cursor() {
|
|
36
39
|
return this.after || this.before ? {
|
|
37
|
-
|
|
40
|
+
[this.cursorField]: this.after ?? this.before
|
|
38
41
|
} : undefined;
|
|
39
42
|
}
|
|
40
43
|
};
|
|
@@ -76,6 +79,28 @@ __decorate([
|
|
|
76
79
|
(0, class_transformer_1.Type)(() => Number),
|
|
77
80
|
__metadata("design:type", Number)
|
|
78
81
|
], CursorQueryDto.prototype, "limit", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, swagger_1.ApiProperty)({
|
|
84
|
+
required: false,
|
|
85
|
+
default: 'id',
|
|
86
|
+
}),
|
|
87
|
+
(0, graphql_1.Field)({ nullable: true }),
|
|
88
|
+
(0, class_validator_1.IsString)(),
|
|
89
|
+
(0, class_validator_1.IsOptional)(),
|
|
90
|
+
__metadata("design:type", String)
|
|
91
|
+
], CursorQueryDto.prototype, "cursorField", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, swagger_1.ApiProperty)({
|
|
94
|
+
required: false,
|
|
95
|
+
enum: sorting_1.Sorting,
|
|
96
|
+
default: sorting_1.Sorting.asc,
|
|
97
|
+
}),
|
|
98
|
+
(0, graphql_1.Field)({ nullable: true }),
|
|
99
|
+
(0, class_validator_1.IsString)(),
|
|
100
|
+
(0, class_validator_1.IsEnum)(sorting_1.Sorting),
|
|
101
|
+
(0, class_validator_1.IsOptional)(),
|
|
102
|
+
__metadata("design:type", String)
|
|
103
|
+
], CursorQueryDto.prototype, "cursorOrder", void 0);
|
|
79
104
|
CursorQueryDto = __decorate([
|
|
80
105
|
(0, graphql_1.ArgsType)()
|
|
81
106
|
], CursorQueryDto);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from "@nestjs/common";
|
|
2
2
|
import { ApiResponseOptions } from "@nestjs/swagger";
|
|
3
3
|
import { RelationDefs } from "../../decorators";
|
|
4
|
-
declare const ApiPaginatedResponse: <TModel extends Type<any>>(model: TModel, relations?: RelationDefs, options?: ApiResponseOptions) => <TFunction extends Function, Y>(target:
|
|
4
|
+
declare const ApiPaginatedResponse: <TModel extends Type<any>>(model: TModel, relations?: RelationDefs, options?: ApiResponseOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
5
5
|
export default ApiPaginatedResponse;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Type } from "@nestjs/common";
|
|
2
|
-
declare const ApiPaginationParams: <TModel extends Type<any>>() => <TFunction extends Function, Y>(target:
|
|
2
|
+
declare const ApiPaginationParams: <TModel extends Type<any>>() => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
3
3
|
export default ApiPaginationParams;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Type as TypeI } from "@nestjs/common";
|
|
2
|
-
export declare const ApiSortingParams: <TModel extends TypeI<any>>(model: TModel) => <TFunction extends Function, Y>(target:
|
|
3
|
-
export declare const IsSortingObject: <TModel extends TypeI<any>>(model: TModel) => <TFunction extends Function, Y>(target:
|
|
2
|
+
export declare const ApiSortingParams: <TModel extends TypeI<any>>(model: TModel) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
3
|
+
export declare const IsSortingObject: <TModel extends TypeI<any>>(model: TModel) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -21,13 +21,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
21
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
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
23
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
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
|
+
})();
|
|
31
41
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
43
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checksumFromBuffer =
|
|
3
|
+
exports.checksumFromBuffer = checksumFromBuffer;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
5
|
function checksumFromBuffer(buffer) {
|
|
6
6
|
return (0, crypto_1.createHash)('md5').update(buffer).digest("base64");
|
|
7
7
|
}
|
|
8
|
-
exports.checksumFromBuffer = checksumFromBuffer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.priceFormat =
|
|
3
|
+
exports.priceFormat = priceFormat;
|
|
4
4
|
const formatter = new Intl.NumberFormat('it-IT', {
|
|
5
5
|
style: 'currency',
|
|
6
6
|
currency: 'EUR',
|
|
@@ -10,4 +10,3 @@ const formatter = new Intl.NumberFormat('it-IT', {
|
|
|
10
10
|
function priceFormat(n) {
|
|
11
11
|
return formatter.format(n);
|
|
12
12
|
}
|
|
13
|
-
exports.priceFormat = priceFormat;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toMs =
|
|
3
|
+
exports.toMs = toMs;
|
|
4
4
|
/** Transform a time string (s,m,h,d) to milliseconds
|
|
5
5
|
* @example toMs('1s') => 1 * 1000
|
|
6
6
|
* @example toMs('1m') => 1 * 60 * 1000
|
|
@@ -18,4 +18,3 @@ function toMs(str) {
|
|
|
18
18
|
};
|
|
19
19
|
return (conversion[mode] ?? 0) * number;
|
|
20
20
|
}
|
|
21
|
-
exports.toMs = toMs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maioradv/nestjs-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "NestJS helpers by MaiorADV",
|
|
5
5
|
"repository": "https://github.com/maioradv/nestjs-core.git",
|
|
6
6
|
"author": "Maior ADV Srl",
|
|
@@ -18,54 +18,53 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@aws-sdk/client-s3": "^3.608.0",
|
|
21
|
-
"@maioradv/accounts-lib": "^1.2.
|
|
22
|
-
"@nestjs/cache-manager": "^
|
|
23
|
-
"@nestjs/common": "^
|
|
24
|
-
"@nestjs/config": "^
|
|
25
|
-
"@nestjs/graphql": "^
|
|
26
|
-
"@nestjs/platform-express": "^
|
|
27
|
-
"@nestjs/swagger": "^
|
|
28
|
-
"@nestjs/throttler": "^
|
|
21
|
+
"@maioradv/accounts-lib": "^1.2.4",
|
|
22
|
+
"@nestjs/cache-manager": "^3.0.0",
|
|
23
|
+
"@nestjs/common": "^11.0.4",
|
|
24
|
+
"@nestjs/config": "^4.0.0",
|
|
25
|
+
"@nestjs/graphql": "^13.0.2",
|
|
26
|
+
"@nestjs/platform-express": "^11.0.4",
|
|
27
|
+
"@nestjs/swagger": "^11.0.2",
|
|
28
|
+
"@nestjs/throttler": "^6.3.0",
|
|
29
29
|
"bcrypt": "^5.1.1",
|
|
30
30
|
"class-transformer": "^0.5.1",
|
|
31
31
|
"class-validator": "^0.14.1",
|
|
32
32
|
"handlebars": "^4.7.8",
|
|
33
33
|
"image-size": "^1.1.1",
|
|
34
|
-
"nest-winston": "^1.10.
|
|
34
|
+
"nest-winston": "^1.10.2",
|
|
35
35
|
"nodemailer": "^6.9.14",
|
|
36
36
|
"request-ip": "^3.3.0",
|
|
37
37
|
"sharp": "^0.33.5",
|
|
38
|
-
"winston": "^3.
|
|
38
|
+
"winston": "^3.17.0",
|
|
39
39
|
"winston-daily-rotate-file": "^5.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/multer": "^1.4.
|
|
43
|
-
"@types/node": "^
|
|
42
|
+
"@types/multer": "^1.4.12",
|
|
43
|
+
"@types/node": "^22.10.7",
|
|
44
44
|
"@types/nodemailer": "^6.4.15",
|
|
45
45
|
"@types/request-ip": "^0.0.41",
|
|
46
46
|
"ts-node": "^10.9.2",
|
|
47
|
-
"typescript": "^5.
|
|
47
|
+
"typescript": "^5.7.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@aws-sdk/client-s3": "^3.608.0",
|
|
51
|
-
"@maioradv/accounts-lib": "^1.2.
|
|
52
|
-
"@nestjs/cache-manager": "^
|
|
53
|
-
"@nestjs/common": "^
|
|
54
|
-
"@nestjs/config": "^
|
|
55
|
-
"@nestjs/graphql": "^
|
|
56
|
-
"@nestjs/platform-express": "^
|
|
57
|
-
"@nestjs/swagger": "^
|
|
58
|
-
"@
|
|
59
|
-
"@types/nodemailer": "^6.4.15",
|
|
51
|
+
"@maioradv/accounts-lib": "^1.2.4",
|
|
52
|
+
"@nestjs/cache-manager": "^3.0.0",
|
|
53
|
+
"@nestjs/common": "^11.0.4",
|
|
54
|
+
"@nestjs/config": "^4.0.0",
|
|
55
|
+
"@nestjs/graphql": "^13.0.2",
|
|
56
|
+
"@nestjs/platform-express": "^11.0.4",
|
|
57
|
+
"@nestjs/swagger": "^11.0.2",
|
|
58
|
+
"@nestjs/throttler": "^6.3.0",
|
|
60
59
|
"bcrypt": "^5.1.1",
|
|
61
60
|
"class-transformer": "^0.5.1",
|
|
62
61
|
"class-validator": "^0.14.1",
|
|
63
62
|
"handlebars": "^4.7.8",
|
|
64
63
|
"image-size": "^1.1.1",
|
|
65
|
-
"nest-winston": "^1.10.
|
|
64
|
+
"nest-winston": "^1.10.2",
|
|
66
65
|
"nodemailer": "^6.9.14",
|
|
67
66
|
"sharp": "^0.33.5",
|
|
68
|
-
"winston": "^3.
|
|
67
|
+
"winston": "^3.17.0",
|
|
69
68
|
"winston-daily-rotate-file": "^5.0.0"
|
|
70
69
|
},
|
|
71
70
|
"keywords": [
|