denwa-nest-shared 1.2.5 → 1.2.7

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/cjs/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FindOptionsOrder, FindOptionsWhere } from 'typeorm';
1
+ import { FindOptionsOrder, FindOptionsSelect, FindOptionsWhere } from 'typeorm';
2
2
  export declare enum LANG {
3
3
  RU = "ru",
4
4
  EN = "en",
@@ -11,6 +11,13 @@ export interface IResponse<StatusCode, Data = object> {
11
11
  error?: string;
12
12
  data?: Data;
13
13
  }
14
+ export interface ICursorPagination {
15
+ id: string | number;
16
+ sortValue?: unknown;
17
+ sortValues?: Record<string, unknown>;
18
+ order?: string;
19
+ field?: string;
20
+ }
14
21
  export interface IPaginate {
15
22
  page: number;
16
23
  pages: number;
@@ -18,10 +25,13 @@ export interface IPaginate {
18
25
  next?: number;
19
26
  count: number;
20
27
  limit: number;
28
+ cursor?: string;
29
+ hasNextPage?: boolean;
21
30
  }
22
31
  export type QueryDataType<Entity> = {
23
32
  skip: number;
24
33
  take: number;
34
+ select?: (keyof Entity)[] | FindOptionsSelect<Entity>;
25
35
  order?: FindOptionsOrder<Entity>;
26
36
  where?: FindOptionsWhere<Entity>[] | FindOptionsWhere<Entity>;
27
37
  relations?: string[];
@@ -65,6 +75,7 @@ export interface IGetQuery {
65
75
  filterType?: FilterType;
66
76
  filter?: object;
67
77
  search?: object;
78
+ cursor?: string | ICursorPagination;
68
79
  }
69
80
  export declare enum ImageContentTypeEnum {
70
81
  'image/avif' = "image/avif",
package/cjs/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,IAIX;AAJD,WAAY,IAAI;IACd,iBAAS,CAAA;IACT,iBAAS,CAAA;IACT,iBAAS,CAAA;AACX,CAAC,EAJW,IAAI,oBAAJ,IAAI,QAIf;AAyED,IAAY,oBAMX;AAND,WAAY,oBAAoB;IAC9B,iDAA2B,CAAA;IAC3B,iDAA2B,CAAA;IAC3B,iDAA2B,CAAA;IAC3B,+CAAyB,CAAA;IACzB,6EAAuD,CAAA;AACzD,CAAC,EANW,oBAAoB,oCAApB,oBAAoB,QAM/B","sourcesContent":["import { FindOptionsOrder, FindOptionsWhere } from 'typeorm';\n\nexport enum LANG {\n RU = 'ru',\n EN = 'en',\n AR = 'ar',\n}\n\nexport interface IResponse<StatusCode, Data = object> {\n statusCode: StatusCode;\n messages?: string[];\n message?: string;\n error?: string;\n data?: Data;\n}\nexport interface IPaginate {\n page: number;\n pages: number;\n previous?: number;\n next?: number;\n count: number;\n limit: number;\n}\n\nexport type QueryDataType<Entity> = {\n skip: number;\n take: number;\n order?: FindOptionsOrder<Entity>;\n where?: FindOptionsWhere<Entity>[] | FindOptionsWhere<Entity>;\n relations?: string[];\n};\n\nexport type OkNotFoundType = IResponse<404 | 200>;\nexport type OkNotFoundBadRequestType = IResponse<404 | 400 | 200>;\nexport type OkNotFoundForbiddenType = IResponse<404 | 403 | 200>;\n\nexport type FilterType = 'and' | 'or';\nexport type SortOrderType = 'asc' | 'desc' | 'ASC' | 'DESC';\n\nexport interface IPreparedImage {\n name: string;\n fileExtensions?: string[];\n prefixes?: string[];\n originalFileExtension: string;\n entityId: string;\n folder?: string;\n fullPathExample: string;\n altRU?: string;\n altEN?: string;\n altAR?: string;\n}\n\nexport interface IPreparedFile {\n name: string;\n fullName: string;\n extension: string;\n entityId: string;\n fullPathExample: string;\n folder?: string;\n}\n\nexport interface IPreparedImageAndOrder extends IPreparedImage {\n order: number;\n}\n\nexport interface IPreparedFileAndOrder extends IPreparedFile {\n order: number;\n}\n\nexport interface IGetQuery {\n page?: number;\n limit?: number;\n sortField?: string;\n sortOrder?: SortOrderType;\n filterType?: FilterType;\n filter?: object;\n search?: object;\n}\n\nexport enum ImageContentTypeEnum {\n 'image/avif' = 'image/avif',\n 'image/webp' = 'image/webp',\n 'image/jpeg' = 'image/jpeg',\n 'image/png' = 'image/png',\n 'application/octet-stream' = 'application/octet-stream',\n}\n\nexport type NullToUndefined<T> = T extends null\n ? undefined\n : T extends (infer U)[]\n ? NullToUndefined<U>[]\n : T extends object\n ? { [K in keyof T]: NullToUndefined<T[K]> }\n : T;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,IAIX;AAJD,WAAY,IAAI;IACd,iBAAS,CAAA;IACT,iBAAS,CAAA;IACT,iBAAS,CAAA;AACX,CAAC,EAJW,IAAI,oBAAJ,IAAI,QAIf;AAsFD,IAAY,oBAMX;AAND,WAAY,oBAAoB;IAC9B,iDAA2B,CAAA;IAC3B,iDAA2B,CAAA;IAC3B,iDAA2B,CAAA;IAC3B,+CAAyB,CAAA;IACzB,6EAAuD,CAAA;AACzD,CAAC,EANW,oBAAoB,oCAApB,oBAAoB,QAM/B","sourcesContent":["import { FindOptionsOrder, FindOptionsSelect, FindOptionsWhere } from 'typeorm';\n\nexport enum LANG {\n RU = 'ru',\n EN = 'en',\n AR = 'ar',\n}\n\nexport interface IResponse<StatusCode, Data = object> {\n statusCode: StatusCode;\n messages?: string[];\n message?: string;\n error?: string;\n data?: Data;\n}\n\nexport interface ICursorPagination {\n id: string | number;\n sortValue?: unknown;\n sortValues?: Record<string, unknown>;\n order?: string;\n field?: string;\n}\n\nexport interface IPaginate {\n page: number;\n pages: number;\n previous?: number;\n next?: number;\n count: number;\n limit: number;\n cursor?: string;\n hasNextPage?: boolean;\n}\n\nexport type QueryDataType<Entity> = {\n skip: number;\n take: number;\n select?: (keyof Entity)[] | FindOptionsSelect<Entity>;\n order?: FindOptionsOrder<Entity>;\n where?: FindOptionsWhere<Entity>[] | FindOptionsWhere<Entity>;\n relations?: string[];\n};\n\nexport type OkNotFoundType = IResponse<404 | 200>;\nexport type OkNotFoundBadRequestType = IResponse<404 | 400 | 200>;\nexport type OkNotFoundForbiddenType = IResponse<404 | 403 | 200>;\n\nexport type FilterType = 'and' | 'or';\nexport type SortOrderType = 'asc' | 'desc' | 'ASC' | 'DESC';\n\nexport interface IPreparedImage {\n name: string;\n fileExtensions?: string[];\n prefixes?: string[];\n originalFileExtension: string;\n entityId: string;\n folder?: string;\n fullPathExample: string;\n altRU?: string;\n altEN?: string;\n altAR?: string;\n}\n\nexport interface IPreparedFile {\n name: string;\n fullName: string;\n extension: string;\n entityId: string;\n fullPathExample: string;\n folder?: string;\n}\n\nexport interface IPreparedImageAndOrder extends IPreparedImage {\n order: number;\n}\n\nexport interface IPreparedFileAndOrder extends IPreparedFile {\n order: number;\n}\n\nexport interface IGetQuery {\n page?: number;\n limit?: number;\n sortField?: string;\n sortOrder?: SortOrderType;\n filterType?: FilterType;\n filter?: object;\n search?: object;\n cursor?: string | ICursorPagination;\n}\n\nexport enum ImageContentTypeEnum {\n 'image/avif' = 'image/avif',\n 'image/webp' = 'image/webp',\n 'image/jpeg' = 'image/jpeg',\n 'image/png' = 'image/png',\n 'application/octet-stream' = 'application/octet-stream',\n}\n\nexport type NullToUndefined<T> = T extends null\n ? undefined\n : T extends (infer U)[]\n ? NullToUndefined<U>[]\n : T extends object\n ? { [K in keyof T]: NullToUndefined<T[K]> }\n : T;\n"]}
@@ -1,8 +1,10 @@
1
1
  import { CustomDecorator } from '@nestjs/common';
2
- export declare const ApiValidationProperty: ({ type, enumObject, swaggerType, min, max, arrayMinSize, arrayMaxSize, divisibleBy, example, description, isSwaggerArray, isOptional, isUUID, isArray, isJson, isJWT, isUrl, isPositive, isNegative, isEmail, isMobilePhone, isPhoneNumber, isLatitude, isLongitude, isStrongPassword, isArrayNotEmpty, isArrayUnique, isDateString, }: {
3
- type: "string" | "int" | "float" | "date" | "boolean";
2
+ export type ClassRef = new (...args: never[]) => unknown;
3
+ export declare const ApiValidationProperty: ({ type, enumObject, swaggerType, objectType, min, max, arrayMinSize, arrayMaxSize, divisibleBy, example, description, isSwaggerArray, isOptional, isUUID, isArray, isJson, isJWT, isUrl, isPositive, isNegative, isEmail, isMobilePhone, isPhoneNumber, isLatitude, isLongitude, isStrongPassword, isArrayNotEmpty, isArrayUnique, isDateString, }: {
4
+ type: "string" | "int" | "float" | "date" | "boolean" | "object";
4
5
  enumObject?: object;
5
6
  swaggerType?: any;
7
+ objectType?: ClassRef;
6
8
  min?: number;
7
9
  max?: number;
8
10
  arrayMinSize?: number;
@@ -1,18 +1,26 @@
1
1
  import { applyDecorators, createParamDecorator, SetMetadata, } from '@nestjs/common';
2
2
  import { Field, Float, Int } from '@nestjs/graphql';
3
3
  import { ApiProperty as SwaggerApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
4
- import { ArrayMaxSize, ArrayMinSize, ArrayNotEmpty, ArrayUnique, IsArray, IsBoolean, IsDate, IsEmail, IsEnum, IsInt, IsJSON, IsJWT, IsLatitude, IsLongitude, IsMobilePhone, IsNegative, IsNumber, IsOptional, IsPhoneNumber, IsPositive, IsString, IsStrongPassword, IsUrl, IsUUID, Max, MaxLength, Min, MinLength, IsDivisibleBy, IsDateString, } from 'class-validator';
4
+ import { ArrayMaxSize, ArrayMinSize, ArrayNotEmpty, ArrayUnique, IsArray, IsBoolean, IsDate, IsEmail, IsEnum, IsInt, IsJSON, IsJWT, IsLatitude, IsLongitude, IsMobilePhone, IsNegative, IsNumber, IsOptional, IsPhoneNumber, IsPositive, IsString, IsStrongPassword, IsUrl, IsUUID, Max, MaxLength, Min, MinLength, IsDivisibleBy, IsDateString, ValidateNested, } from 'class-validator';
5
5
  import { Type } from 'class-transformer';
6
6
  import { ROLES_KEY } from './const';
7
7
  import { prepareRequestContext } from './lib';
8
- export const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayMinSize, arrayMaxSize, divisibleBy, example, description, isSwaggerArray, isOptional = false, isUUID = false, isArray = false, isJson = false, isJWT = false, isUrl = false, isPositive = false, isNegative = false, isEmail = false, isMobilePhone = false, isPhoneNumber = false, isLatitude = false, isLongitude = false, isStrongPassword = false, isArrayNotEmpty = false, isArrayUnique = false, isDateString = false, }) => {
8
+ const BUILT_IN_TYPES = new Set([String, Number, Boolean, Object, Date, Array, Function]);
9
+ const isClassRef = (value) => typeof value === 'function' && !BUILT_IN_TYPES.has(value);
10
+ const resolveObjectType = (objectType, swaggerType) => {
11
+ const raw = objectType ?? swaggerType;
12
+ const candidate = Array.isArray(raw) ? raw[0] : raw;
13
+ return isClassRef(candidate) ? candidate : null;
14
+ };
15
+ export const ApiValidationProperty = ({ type, enumObject, swaggerType, objectType, min, max, arrayMinSize, arrayMaxSize, divisibleBy, example, description, isSwaggerArray, isOptional = false, isUUID = false, isArray = false, isJson = false, isJWT = false, isUrl = false, isPositive = false, isNegative = false, isEmail = false, isMobilePhone = false, isPhoneNumber = false, isLatitude = false, isLongitude = false, isStrongPassword = false, isArrayNotEmpty = false, isArrayUnique = false, isDateString = false, }) => {
9
16
  const decorators = [];
17
+ const schemaType = swaggerType ?? (objectType ? (isArray ? [objectType] : objectType) : undefined);
10
18
  const swaggerData = {
11
19
  example,
12
20
  description,
13
21
  enum: enumObject,
14
22
  isArray: isSwaggerArray,
15
- type: swaggerType,
23
+ type: schemaType,
16
24
  };
17
25
  if (!enumObject) {
18
26
  delete swaggerData.enum;
@@ -20,7 +28,7 @@ export const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max,
20
28
  if (!isSwaggerArray) {
21
29
  delete swaggerData.isArray;
22
30
  }
23
- if (!swaggerType) {
31
+ if (!schemaType) {
24
32
  delete swaggerData.type;
25
33
  }
26
34
  if (isOptional) {
@@ -29,6 +37,29 @@ export const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max,
29
37
  else {
30
38
  decorators.push(SwaggerApiProperty(swaggerData));
31
39
  }
40
+ const nestedType = resolveObjectType(objectType, swaggerType);
41
+ if (nestedType) {
42
+ decorators.push(Field(() => (isArray ? [nestedType] : nestedType), { nullable: isOptional }));
43
+ if (isOptional)
44
+ decorators.push(IsOptional());
45
+ if (isArray) {
46
+ decorators.push(IsArray());
47
+ if (isArrayNotEmpty)
48
+ decorators.push(ArrayNotEmpty());
49
+ if (isArrayUnique)
50
+ decorators.push(ArrayUnique());
51
+ if (arrayMinSize !== undefined)
52
+ decorators.push(ArrayMinSize(arrayMinSize));
53
+ if (arrayMaxSize !== undefined)
54
+ decorators.push(ArrayMaxSize(arrayMaxSize));
55
+ }
56
+ decorators.push(ValidateNested({ each: isArray }));
57
+ decorators.push(Type(() => nestedType));
58
+ return applyDecorators(...decorators);
59
+ }
60
+ if (type === 'object') {
61
+ throw new Error('ApiValidationProperty: `type: "object"` requires a nested DTO class in `objectType` or `swaggerType`');
62
+ }
32
63
  switch (type) {
33
64
  case 'int':
34
65
  decorators.push(Field(() => (isArray ? [Int] : Int), { nullable: isOptional }));
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EAGpB,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,EACL,UAAU,EACV,WAAW,EACX,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,aAAa,EACb,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,GAAG,EACH,SAAS,EACT,GAAG,EACH,SAAS,EACT,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,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AAC,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QAC9D,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n applyDecorators,\n createParamDecorator,\n CustomDecorator,\n ExecutionContext,\n SetMetadata,\n} from '@nestjs/common';\nimport { Field, Float, Int } from '@nestjs/graphql';\nimport { ApiProperty as SwaggerApiProperty, ApiPropertyOptional } from '@nestjs/swagger';\nimport {\n ArrayMaxSize,\n ArrayMinSize,\n ArrayNotEmpty,\n ArrayUnique,\n IsArray,\n IsBoolean,\n IsDate,\n IsEmail,\n IsEnum,\n IsInt,\n IsJSON,\n IsJWT,\n IsLatitude,\n IsLongitude,\n IsMobilePhone,\n IsNegative,\n IsNumber,\n IsOptional,\n IsPhoneNumber,\n IsPositive,\n IsString,\n IsStrongPassword,\n IsUrl,\n IsUUID,\n Max,\n MaxLength,\n Min,\n MinLength,\n IsDivisibleBy,\n IsDateString,\n} from 'class-validator';\nimport { Type } from 'class-transformer';\nimport { ROLES_KEY } from './const';\nimport { prepareRequestContext } from './lib';\n\nexport const ApiValidationProperty = ({\n type,\n enumObject,\n swaggerType,\n min,\n max,\n arrayMinSize,\n arrayMaxSize,\n divisibleBy,\n example,\n description,\n isSwaggerArray,\n isOptional = false,\n isUUID = false,\n isArray = false,\n isJson = false,\n isJWT = false,\n isUrl = false,\n isPositive = false,\n isNegative = false,\n isEmail = false,\n isMobilePhone = false,\n isPhoneNumber = false,\n isLatitude = false,\n isLongitude = false,\n isStrongPassword = false,\n isArrayNotEmpty = false,\n isArrayUnique = false,\n isDateString = false,\n}: {\n type: 'string' | 'int' | 'float' | 'date' | 'boolean';\n enumObject?: object;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n swaggerType?: any;\n min?: number;\n max?: number;\n arrayMinSize?: number;\n arrayMaxSize?: number;\n divisibleBy?: number;\n example?: string;\n description?: string;\n isOptional?: boolean;\n isUUID?: boolean;\n isArray?: boolean;\n isSwaggerArray?: boolean;\n isJson?: boolean;\n isJWT?: boolean;\n isUrl?: boolean;\n isPositive?: boolean;\n isNegative?: boolean;\n isEmail?: boolean;\n isMobilePhone?: boolean;\n isPhoneNumber?: boolean;\n isLatitude?: boolean;\n isLongitude?: boolean;\n isStrongPassword?: boolean;\n isArrayNotEmpty?: boolean;\n isArrayUnique?: boolean;\n isDateString?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n}): (<TFunction extends Function, Y>(\n target: TFunction | object,\n propertyKey?: string | symbol,\n descriptor?: TypedPropertyDescriptor<Y>,\n) => void) => {\n const decorators = [];\n\n const swaggerData = {\n example,\n description,\n enum: enumObject,\n isArray: isSwaggerArray,\n type: swaggerType,\n };\n\n if (!enumObject) {\n delete swaggerData.enum;\n }\n\n if (!isSwaggerArray) {\n delete swaggerData.isArray;\n }\n\n if (!swaggerType) {\n delete swaggerData.type;\n }\n\n if (isOptional) {\n decorators.push(ApiPropertyOptional(swaggerData));\n } else {\n decorators.push(SwaggerApiProperty(swaggerData));\n }\n\n switch (type) {\n case 'int':\n decorators.push(Field(() => (isArray ? [Int] : Int), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsNumber({}, { each: isArray }));\n decorators.push(IsInt({ each: isArray }));\n\n if (min !== undefined) decorators.push(Min(min, { each: isArray }));\n if (max !== undefined) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy !== undefined) decorators.push(IsDivisibleBy(divisibleBy, { each: isArray }));\n\n break;\n case 'float':\n decorators.push(Field(() => (isArray ? [Float] : Float), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsNumber({}, { each: isArray }));\n\n if (min !== undefined) decorators.push(Min(min, { each: isArray }));\n if (max !== undefined) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy !== undefined) decorators.push(IsDivisibleBy(divisibleBy, { each: isArray }));\n\n break;\n case 'date':\n decorators.push(Field(() => (isArray ? [Date] : Date), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsDate({ each: isArray }));\n decorators.push(Type(() => Date));\n break;\n case 'boolean':\n decorators.push(Field({ nullable: isOptional }));\n if (isOptional) decorators.push(IsOptional());\n decorators.push(IsBoolean());\n break;\n case 'string':\n default:\n if (enumObject) {\n decorators.push(\n Field(() => (isArray ? [enumObject] : enumObject), { nullable: isOptional }),\n );\n } else {\n decorators.push(Field(() => (isArray ? [String] : String), { nullable: isOptional }));\n }\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsString({ each: isArray }));\n\n if (isUUID) decorators.push(IsUUID(undefined, { each: isArray }));\n if (isEmail) decorators.push(IsEmail(undefined, { each: isArray }));\n if (isMobilePhone) decorators.push(IsMobilePhone(undefined, undefined, { each: isArray }));\n if (isPhoneNumber) decorators.push(IsPhoneNumber(undefined, { each: isArray }));\n if (isPositive) decorators.push(IsPositive({ each: isArray }));\n if (isNegative) decorators.push(IsNegative({ each: isArray }));\n if (min !== undefined) decorators.push(MinLength(min, { each: isArray }));\n if (max !== undefined) decorators.push(MaxLength(max, { each: isArray }));\n if (enumObject) decorators.push(IsEnum(enumObject, { each: isArray }));\n if (isJson) decorators.push(IsJSON({ each: isArray }));\n if (isJWT) decorators.push(IsJWT({ each: isArray }));\n if (isUrl) decorators.push(IsUrl(undefined, { each: isArray }));\n if (isLatitude) decorators.push(IsLatitude({ each: isArray }));\n if (isLongitude) decorators.push(IsLongitude({ each: isArray }));\n if (isStrongPassword) decorators.push(IsStrongPassword(undefined, { each: isArray }));\n if (isDateString) decorators.push(IsDateString(undefined, { each: isArray }));\n }\n\n return applyDecorators(...decorators);\n};\n\nexport const Roles = (roles: string[]): CustomDecorator<string[]> => SetMetadata(ROLES_KEY, roles);\n\nexport const GetCurrentUserId = createParamDecorator(\n (_data: undefined, context: ExecutionContext): string | undefined => {\n const request = prepareRequestContext(context);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return request?.user?.['id'];\n },\n);\n\nexport const GetCurrentRoles = createParamDecorator(\n (_data: undefined, context: ExecutionContext): string[] => {\n const request = prepareRequestContext(context);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (\n request?.user?.['roles']?.map((item: { value: string } | string) => {\n if (typeof item === 'string') return item;\n return item.value;\n }) ?? []\n );\n },\n);\n\nexport const GetCurrentUser = createParamDecorator(\n (data: string | undefined, context: ExecutionContext) => {\n const request = prepareRequestContext(context);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n if (!data) return request?.user;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return request?.user?.[data];\n },\n);\n\nexport const Public = (): CustomDecorator<string> => SetMetadata('isPublic', true);\n\nexport const CHECK_FIELDS_ROLES_KEY = 'checkFieldsRoles';\nexport const CheckFieldsRoles = (fieldsRolesMap: {\n [field: string]: string[];\n}): CustomDecorator<string> => SetMetadata(CHECK_FIELDS_ROLES_KEY, fieldsRolesMap);\n\n/**\n * Metadata key for `@MutableBy()` — marks a DTO field as editable only by specific roles.\n * Fields without this decorator are editable by anyone.\n */\nexport const MUTABLE_BY_KEY = 'mutableBy';\n\n/**\n * Property decorator that marks an input DTO field as restricted to specific roles.\n * The `sanitizeDto()` utility reads this metadata and strips the field if the\n * current user lacks the required role.\n *\n * @example\n * ```ts\n * class CreateProductDto {\n * \\@MutableBy([ROLES.super_admin, ROLES.admin])\n * priority?: number;\n *\n * nameRU: string; // no decorator — anyone can set\n * }\n * ```\n */\n\nexport function MutableBy(roles: string[]): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const proto: object = (target.constructor?.prototype ?? target) as object;\n const existing: Record<string, string[]> =\n (Reflect.getMetadata(MUTABLE_BY_KEY, proto) as Record<string, string[]> | undefined) ?? {};\n const updated = { ...existing, [String(propertyKey)]: roles };\n Reflect.defineMetadata(MUTABLE_BY_KEY, updated, proto);\n };\n}\n"]}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EAGpB,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,E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amDecorator,\n CustomDecorator,\n ExecutionContext,\n SetMetadata,\n} from '@nestjs/common';\nimport { Field, Float, Int } from '@nestjs/graphql';\nimport { ApiProperty as SwaggerApiProperty, ApiPropertyOptional } from '@nestjs/swagger';\nimport {\n ArrayMaxSize,\n ArrayMinSize,\n ArrayNotEmpty,\n ArrayUnique,\n IsArray,\n IsBoolean,\n IsDate,\n IsEmail,\n IsEnum,\n IsInt,\n IsJSON,\n IsJWT,\n IsLatitude,\n IsLongitude,\n IsMobilePhone,\n IsNegative,\n IsNumber,\n IsOptional,\n IsPhoneNumber,\n IsPositive,\n IsString,\n IsStrongPassword,\n IsUrl,\n IsUUID,\n Max,\n MaxLength,\n Min,\n MinLength,\n IsDivisibleBy,\n IsDateString,\n ValidateNested,\n} from 'class-validator';\nimport { Type } from 'class-transformer';\nimport { ROLES_KEY } from './const';\nimport { prepareRequestContext } from './lib';\n\n/** Конструктор класса вложенного DTO. */\nexport type ClassRef = new (...args: never[]) => unknown;\n\n/** Встроенные конструкторы, которые не считаются вложенным DTO. */\nconst BUILT_IN_TYPES = new Set<unknown>([String, Number, Boolean, Object, Date, Array, Function]);\n\nconst isClassRef = (value: unknown): value is ClassRef =>\n typeof value === 'function' && !BUILT_IN_TYPES.has(value);\n\n/**\n * Достаёт класс вложенного DTO из `objectType` или `swaggerType`.\n * Поддерживает как одиночный класс (`SomeDto`), так и массив из одного класса (`[SomeDto]`).\n */\nconst resolveObjectType = (\n objectType: ClassRef | undefined,\n swaggerType: unknown,\n): ClassRef | null => {\n const raw: unknown = objectType ?? swaggerType;\n const candidate = Array.isArray(raw) ? raw[0] : raw;\n\n return isClassRef(candidate) ? candidate : null;\n};\n\n/**\n * Единый декоратор для GraphQL, Swagger и class-validator.\n *\n * Для вложенных DTO передавайте класс в `objectType` (предпочтительно) или в `swaggerType`\n * (обратная совместимость, в т.ч. массив `[SomeDto]`). Тогда вместо `IsString` эмитятся\n * `@Field(() => SomeDto)`, `@ValidateNested()` и `@Type(() => SomeDto)`.\n */\nexport const ApiValidationProperty = ({\n type,\n enumObject,\n swaggerType,\n objectType,\n min,\n max,\n arrayMinSize,\n arrayMaxSize,\n divisibleBy,\n example,\n description,\n isSwaggerArray,\n isOptional = false,\n isUUID = false,\n isArray = false,\n isJson = false,\n isJWT = false,\n isUrl = false,\n isPositive = false,\n isNegative = false,\n isEmail = false,\n isMobilePhone = false,\n isPhoneNumber = false,\n isLatitude = false,\n isLongitude = false,\n isStrongPassword = false,\n isArrayNotEmpty = false,\n isArrayUnique = false,\n isDateString = false,\n}: {\n type: 'string' | 'int' | 'float' | 'date' | 'boolean' | 'object';\n enumObject?: object;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n swaggerType?: any;\n objectType?: ClassRef;\n min?: number;\n max?: number;\n arrayMinSize?: number;\n arrayMaxSize?: number;\n divisibleBy?: number;\n example?: string;\n description?: string;\n isOptional?: boolean;\n isUUID?: boolean;\n isArray?: boolean;\n isSwaggerArray?: boolean;\n isJson?: boolean;\n isJWT?: boolean;\n isUrl?: boolean;\n isPositive?: boolean;\n isNegative?: boolean;\n isEmail?: boolean;\n isMobilePhone?: boolean;\n isPhoneNumber?: boolean;\n isLatitude?: boolean;\n isLongitude?: boolean;\n isStrongPassword?: boolean;\n isArrayNotEmpty?: boolean;\n isArrayUnique?: boolean;\n isDateString?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n}): (<TFunction extends Function, Y>(\n target: TFunction | object,\n propertyKey?: string | symbol,\n descriptor?: TypedPropertyDescriptor<Y>,\n) => void) => {\n const decorators = [];\n\n const schemaType =\n swaggerType ?? (objectType ? (isArray ? [objectType] : objectType) : undefined);\n\n const swaggerData = {\n example,\n description,\n enum: enumObject,\n isArray: isSwaggerArray,\n type: schemaType,\n };\n\n if (!enumObject) {\n delete swaggerData.enum;\n }\n\n if (!isSwaggerArray) {\n delete swaggerData.isArray;\n }\n\n if (!schemaType) {\n delete swaggerData.type;\n }\n\n if (isOptional) {\n decorators.push(ApiPropertyOptional(swaggerData));\n } else {\n decorators.push(SwaggerApiProperty(swaggerData));\n }\n\n const nestedType = resolveObjectType(objectType, swaggerType);\n\n if (nestedType) {\n decorators.push(Field(() => (isArray ? [nestedType] : nestedType), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(ValidateNested({ each: isArray }));\n decorators.push(Type(() => nestedType));\n\n return applyDecorators(...decorators);\n }\n\n if (type === 'object') {\n throw new Error(\n 'ApiValidationProperty: `type: \"object\"` requires a nested DTO class in `objectType` or `swaggerType`',\n );\n }\n\n switch (type) {\n case 'int':\n decorators.push(Field(() => (isArray ? [Int] : Int), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsNumber({}, { each: isArray }));\n decorators.push(IsInt({ each: isArray }));\n\n if (min !== undefined) decorators.push(Min(min, { each: isArray }));\n if (max !== undefined) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy !== undefined) decorators.push(IsDivisibleBy(divisibleBy, { each: isArray }));\n\n break;\n case 'float':\n decorators.push(Field(() => (isArray ? [Float] : Float), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsNumber({}, { each: isArray }));\n\n if (min !== undefined) decorators.push(Min(min, { each: isArray }));\n if (max !== undefined) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy !== undefined) decorators.push(IsDivisibleBy(divisibleBy, { each: isArray }));\n\n break;\n case 'date':\n decorators.push(Field(() => (isArray ? [Date] : Date), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsDate({ each: isArray }));\n decorators.push(Type(() => Date));\n break;\n case 'boolean':\n decorators.push(Field({ nullable: isOptional }));\n if (isOptional) decorators.push(IsOptional());\n decorators.push(IsBoolean());\n break;\n case 'string':\n default:\n if (enumObject) {\n decorators.push(\n Field(() => (isArray ? [enumObject] : enumObject), { nullable: isOptional }),\n );\n } else {\n decorators.push(Field(() => (isArray ? [String] : String), { nullable: isOptional }));\n }\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsString({ each: isArray }));\n\n if (isUUID) decorators.push(IsUUID(undefined, { each: isArray }));\n if (isEmail) decorators.push(IsEmail(undefined, { each: isArray }));\n if (isMobilePhone) decorators.push(IsMobilePhone(undefined, undefined, { each: isArray }));\n if (isPhoneNumber) decorators.push(IsPhoneNumber(undefined, { each: isArray }));\n if (isPositive) decorators.push(IsPositive({ each: isArray }));\n if (isNegative) decorators.push(IsNegative({ each: isArray }));\n if (min !== undefined) decorators.push(MinLength(min, { each: isArray }));\n if (max !== undefined) decorators.push(MaxLength(max, { each: isArray }));\n if (enumObject) decorators.push(IsEnum(enumObject, { each: isArray }));\n if (isJson) decorators.push(IsJSON({ each: isArray }));\n if (isJWT) decorators.push(IsJWT({ each: isArray }));\n if (isUrl) decorators.push(IsUrl(undefined, { each: isArray }));\n if (isLatitude) decorators.push(IsLatitude({ each: isArray }));\n if (isLongitude) decorators.push(IsLongitude({ each: isArray }));\n if (isStrongPassword) decorators.push(IsStrongPassword(undefined, { each: isArray }));\n if (isDateString) decorators.push(IsDateString(undefined, { each: isArray }));\n }\n\n return applyDecorators(...decorators);\n};\n\nexport const Roles = (roles: string[]): CustomDecorator<string[]> => SetMetadata(ROLES_KEY, roles);\n\nexport const GetCurrentUserId = createParamDecorator(\n (_data: undefined, context: ExecutionContext): string | undefined => {\n const request = prepareRequestContext(context);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return request?.user?.['id'];\n },\n);\n\nexport const GetCurrentRoles = createParamDecorator(\n (_data: undefined, context: ExecutionContext): string[] => {\n const request = prepareRequestContext(context);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (\n request?.user?.['roles']?.map((item: { value: string } | string) => {\n if (typeof item === 'string') return item;\n return item.value;\n }) ?? []\n );\n },\n);\n\nexport const GetCurrentUser = createParamDecorator(\n (data: string | undefined, context: ExecutionContext) => {\n const request = prepareRequestContext(context);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n if (!data) return request?.user;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return request?.user?.[data];\n },\n);\n\nexport const Public = (): CustomDecorator<string> => SetMetadata('isPublic', true);\n\nexport const CHECK_FIELDS_ROLES_KEY = 'checkFieldsRoles';\nexport const CheckFieldsRoles = (fieldsRolesMap: {\n [field: string]: string[];\n}): CustomDecorator<string> => SetMetadata(CHECK_FIELDS_ROLES_KEY, fieldsRolesMap);\n\n/**\n * Metadata key for `@MutableBy()` — marks a DTO field as editable only by specific roles.\n * Fields without this decorator are editable by anyone.\n */\nexport const MUTABLE_BY_KEY = 'mutableBy';\n\n/**\n * Property decorator that marks an input DTO field as restricted to specific roles.\n * The `sanitizeDto()` utility reads this metadata and strips the field if the\n * current user lacks the required role.\n *\n * @example\n * ```ts\n * class CreateProductDto {\n * \\@MutableBy([ROLES.super_admin, ROLES.admin])\n * priority?: number;\n *\n * nameRU: string; // no decorator — anyone can set\n * }\n * ```\n */\n\nexport function MutableBy(roles: string[]): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const proto: object = (target.constructor?.prototype ?? target) as object;\n const existing: Record<string, string[]> =\n (Reflect.getMetadata(MUTABLE_BY_KEY, proto) as Record<string, string[]> | undefined) ?? {};\n const updated = { ...existing, [String(propertyKey)]: roles };\n Reflect.defineMetadata(MUTABLE_BY_KEY, updated, proto);\n };\n}\n"]}
package/dist/lib.d.ts CHANGED
@@ -1,12 +1,18 @@
1
+ import { FindOptionsSelect } from 'typeorm';
1
2
  import { GraphQLResolveInfo } from 'graphql';
2
- import { IPaginate, IPreparedFile, IPreparedImage, QueryDataType } from './types';
3
+ import { ICursorPagination, IPaginate, IPreparedFile, IPreparedImage, QueryDataType } from './types';
3
4
  import { AllFilesDto, AllImagesDto, FileDto, ImageFileDto, TempFilesDto, TempImagesDto } from './dto';
4
5
  import { ExecutionContext } from '@nestjs/common';
5
6
  export declare const getError: ({ error, message }: {
6
7
  error?: unknown;
7
8
  message?: string;
8
9
  }) => void;
9
- export declare const createPaginate: (page: number, count: number, limit: number, modelsNumber?: number) => IPaginate;
10
+ export declare const createPaginate: (page: number, count: number, limit: number, modelsNumber?: number, options?: {
11
+ cursor?: string;
12
+ hasNextPage?: boolean;
13
+ }) => IPaginate;
14
+ export declare const encodeCursor: (data: ICursorPagination) => string;
15
+ export declare const decodeCursor: (cursor: string) => ICursorPagination | null;
10
16
  export declare const getPaginateSkip: (page: number, limit: number) => number;
11
17
  export declare const formatPhone: (phone: string) => string;
12
18
  export declare const concatenateTwo32BitNumbers: (low: number, high: number) => number;
@@ -20,21 +26,21 @@ export declare const prepareTokenExp: (accessExp: number | {
20
26
  access: number;
21
27
  refresh: number;
22
28
  };
23
- export declare const checkPageAndLimit: (page: number, limit: number, maxLimit?: number) => {
29
+ export declare const checkPageAndLimit: (page: number, limit: number, maxLimit?: number, maxPage?: number) => {
24
30
  checkedPage: number;
25
31
  checkedLimit: number;
26
32
  };
27
33
  export declare const isCorrectOrder: (order: string) => boolean;
28
- export declare const createQueryData: <Entity>({ page, limit, sortField, sortFields, sortOrder, filterType, searchType, filter, filters, search, fromToFields, oneEntryArrayFields, fields, relationsMap, searchFields, }: {
34
+ export declare const createQueryData: <Entity>({ page, limit, sortField, sortFields, sortOrder, filterType, searchType, filter, filters, search, fromToFields, oneEntryArrayFields, fields, relationsMap, searchFields, cursor, select, extraRow, maxPage, }: {
29
35
  page: number;
30
36
  limit: number;
31
- sortField: string;
32
- sortOrder: string;
37
+ sortField?: string;
38
+ sortOrder?: string;
33
39
  sortFields?: {
34
40
  field: string;
35
41
  order: string;
36
42
  }[];
37
- filterType: string;
43
+ filterType?: string;
38
44
  searchType?: string;
39
45
  filter?: object;
40
46
  filters?: object[];
@@ -51,6 +57,10 @@ export declare const createQueryData: <Entity>({ page, limit, sortField, sortFie
51
57
  fields?: string[];
52
58
  relationsMap?: Record<string, string | string[]>;
53
59
  searchFields?: string[];
60
+ cursor?: string | ICursorPagination;
61
+ select?: (keyof Entity)[] | FindOptionsSelect<Entity>;
62
+ extraRow?: boolean;
63
+ maxPage?: number;
54
64
  }) => QueryDataType<Entity>;
55
65
  export declare const extractGraphqlFields: (info: GraphQLResolveInfo) => string[];
56
66
  export declare const prepareTempImages: (files: ImageFileDto[], tempImages: TempImagesDto[]) => IPreparedImage[];
package/dist/lib.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import parsePhoneNumber from 'libphonenumber-js';
2
- import { And, ArrayOverlap, ILike, In, LessThanOrEqual, MoreThanOrEqual, } from 'typeorm';
2
+ import { And, ArrayOverlap, ILike, In, LessThan, LessThanOrEqual, MoreThan, MoreThanOrEqual, } from 'typeorm';
3
3
  import { JSDOM } from 'jsdom';
4
4
  import { z } from 'zod';
5
5
  import { GqlExecutionContext } from '@nestjs/graphql';
@@ -9,7 +9,7 @@ export const getError = ({ error, message }) => {
9
9
  if (message)
10
10
  console.error(message);
11
11
  };
12
- export const createPaginate = (page, count, limit, modelsNumber = 1) => {
12
+ export const createPaginate = (page, count, limit, modelsNumber = 1, options) => {
13
13
  const pages = Math.ceil(count / (limit * modelsNumber));
14
14
  const paginate = {
15
15
  page,
@@ -18,9 +18,33 @@ export const createPaginate = (page, count, limit, modelsNumber = 1) => {
18
18
  next: page <= pages - 1 ? page + 1 : undefined,
19
19
  count,
20
20
  limit,
21
+ ...(options?.cursor ? { cursor: options.cursor } : {}),
22
+ ...(options?.hasNextPage !== undefined ? { hasNextPage: options.hasNextPage } : {}),
21
23
  };
22
24
  return paginate;
23
25
  };
26
+ export const encodeCursor = (data) => {
27
+ return Buffer.from(JSON.stringify(data)).toString('base64url');
28
+ };
29
+ export const decodeCursor = (cursor) => {
30
+ try {
31
+ const json = Buffer.from(cursor, 'base64url').toString('utf8');
32
+ const parsed = JSON.parse(json);
33
+ if (parsed && (typeof parsed.id === 'string' || typeof parsed.id === 'number')) {
34
+ return {
35
+ id: parsed.id,
36
+ sortValue: parsed.sortValue,
37
+ sortValues: parsed.sortValues,
38
+ order: parsed.order,
39
+ field: parsed.field,
40
+ };
41
+ }
42
+ return null;
43
+ }
44
+ catch {
45
+ return null;
46
+ }
47
+ };
24
48
  export const getPaginateSkip = (page, limit) => {
25
49
  return (page - 1) * limit;
26
50
  };
@@ -44,7 +68,7 @@ export const prepareTokenExp = (accessExp, refreshExp) => {
44
68
  }
45
69
  return { access, refresh };
46
70
  };
47
- export const checkPageAndLimit = (page, limit, maxLimit = 500) => {
71
+ export const checkPageAndLimit = (page, limit, maxLimit = 500, maxPage) => {
48
72
  const paginationData = {
49
73
  checkedPage: page,
50
74
  checkedLimit: limit,
@@ -52,6 +76,9 @@ export const checkPageAndLimit = (page, limit, maxLimit = 500) => {
52
76
  if (page < 1) {
53
77
  paginationData.checkedPage = 1;
54
78
  }
79
+ if (maxPage && page > maxPage) {
80
+ paginationData.checkedPage = maxPage;
81
+ }
55
82
  if (limit < 1) {
56
83
  paginationData.checkedLimit = 1;
57
84
  }
@@ -63,7 +90,7 @@ export const checkPageAndLimit = (page, limit, maxLimit = 500) => {
63
90
  export const isCorrectOrder = (order) => {
64
91
  return order.toLocaleLowerCase() === 'asc' || order.toLocaleLowerCase() === 'desc';
65
92
  };
66
- export const createQueryData = ({ page, limit, sortField, sortFields, sortOrder, filterType, searchType = 'or', filter, filters, search, fromToFields, oneEntryArrayFields, fields, relationsMap, searchFields, }) => {
93
+ export const createQueryData = ({ page, limit, sortField, sortFields, sortOrder, filterType = 'and', searchType = 'or', filter, filters, search, fromToFields, oneEntryArrayFields, fields, relationsMap, searchFields, cursor, select, extraRow = false, maxPage, }) => {
67
94
  const getFromToFields = (key, value, fromToMap) => {
68
95
  if (fromToFields) {
69
96
  const found = fromToFields.find((item) => {
@@ -122,24 +149,66 @@ export const createQueryData = ({ page, limit, sortField, sortFields, sortOrder,
122
149
  value: In(value),
123
150
  };
124
151
  };
152
+ const { checkedPage, checkedLimit } = checkPageAndLimit(page, limit, 500, maxPage);
153
+ let parsedCursor = null;
154
+ if (typeof cursor === 'string') {
155
+ parsedCursor = decodeCursor(cursor);
156
+ }
157
+ else if (cursor &&
158
+ typeof cursor === 'object' &&
159
+ cursor.id !== undefined &&
160
+ cursor.id !== null) {
161
+ parsedCursor = cursor;
162
+ }
125
163
  const queryData = {
126
- skip: getPaginateSkip(page, limit),
127
- take: limit,
164
+ skip: parsedCursor ? 0 : getPaginateSkip(checkedPage, checkedLimit),
165
+ take: extraRow ? checkedLimit + 1 : checkedLimit,
128
166
  };
167
+ if (select) {
168
+ queryData.select = select;
169
+ }
170
+ let effectiveSortFields = [];
129
171
  if (sortFields && sortFields.length > 0) {
130
- const order = {};
131
- sortFields.forEach((sortItem) => {
132
- if (!isCorrectOrder(sortItem.order)) {
133
- return;
134
- }
135
- order[sortItem.field] = sortItem.order;
136
- });
137
- queryData.order = order;
172
+ effectiveSortFields = sortFields
173
+ .filter((sortItem) => isCorrectOrder(sortItem.order))
174
+ .map((sortItem) => ({
175
+ field: sortItem.field,
176
+ order: sortItem.order.toLowerCase(),
177
+ }));
138
178
  }
139
- else if (sortField && sortOrder) {
140
- queryData.order = {
141
- [sortField]: isCorrectOrder(sortOrder) ? sortOrder : 'desc',
142
- };
179
+ else if (sortField) {
180
+ const orderStr = sortOrder || parsedCursor?.order || 'desc';
181
+ effectiveSortFields = [
182
+ {
183
+ field: sortField,
184
+ order: isCorrectOrder(orderStr) ? orderStr.toLowerCase() : 'desc',
185
+ },
186
+ ];
187
+ }
188
+ else if (parsedCursor?.field) {
189
+ const orderStr = sortOrder || parsedCursor.order || 'desc';
190
+ effectiveSortFields = [
191
+ {
192
+ field: parsedCursor.field,
193
+ order: isCorrectOrder(orderStr) ? orderStr.toLowerCase() : 'desc',
194
+ },
195
+ ];
196
+ }
197
+ if (parsedCursor) {
198
+ const hasId = effectiveSortFields.some((item) => item.field === 'id');
199
+ if (!hasId) {
200
+ const lastOrder = effectiveSortFields.length > 0
201
+ ? effectiveSortFields[effectiveSortFields.length - 1].order
202
+ : 'desc';
203
+ effectiveSortFields.push({ field: 'id', order: lastOrder });
204
+ }
205
+ }
206
+ if (effectiveSortFields.length > 0) {
207
+ const orderObj = {};
208
+ for (const item of effectiveSortFields) {
209
+ orderObj[item.field] = item.order;
210
+ }
211
+ queryData.order = orderObj;
143
212
  }
144
213
  if (filters && filters.length > 0) {
145
214
  const where = filters.map((item) => {
@@ -332,11 +401,79 @@ export const createQueryData = ({ page, limit, sortField, sortFields, sortOrder,
332
401
  whereOr = [...whereOr, { [key]: LessThanOrEqual(item.toFieldValue) }];
333
402
  }
334
403
  });
335
- if (filterType.toLowerCase() === 'or')
404
+ if (filterType?.toLowerCase() === 'or')
336
405
  return whereOr;
337
406
  else
338
407
  return whereAnd;
339
408
  }
409
+ if (parsedCursor) {
410
+ const getCursorVal = (fieldName, index) => {
411
+ if (fieldName === 'id') {
412
+ return parsedCursor.id;
413
+ }
414
+ if (parsedCursor.sortValues && parsedCursor.sortValues[fieldName] !== undefined) {
415
+ return parsedCursor.sortValues[fieldName];
416
+ }
417
+ if (index === 0 && parsedCursor.sortValue !== undefined) {
418
+ return parsedCursor.sortValue;
419
+ }
420
+ return undefined;
421
+ };
422
+ const cursorConditions = [];
423
+ const entriesWithValues = [];
424
+ effectiveSortFields.forEach((item, idx) => {
425
+ const val = getCursorVal(item.field, idx);
426
+ if (val !== undefined && val !== null) {
427
+ entriesWithValues.push({ field: item.field, order: item.order, value: val });
428
+ }
429
+ });
430
+ if (entriesWithValues.length === 0) {
431
+ entriesWithValues.push({
432
+ field: 'id',
433
+ order: (sortOrder || parsedCursor.order || 'desc').toLowerCase() === 'desc' ? 'desc' : 'asc',
434
+ value: parsedCursor.id,
435
+ });
436
+ }
437
+ for (let i = 0; i < entriesWithValues.length; i++) {
438
+ const branch = {};
439
+ for (let j = 0; j < i; j++) {
440
+ branch[entriesWithValues[j].field] = entriesWithValues[j].value;
441
+ }
442
+ const current = entriesWithValues[i];
443
+ branch[current.field] =
444
+ current.order === 'desc' ? LessThan(current.value) : MoreThan(current.value);
445
+ cursorConditions.push(branch);
446
+ }
447
+ if (!queryData.where) {
448
+ queryData.where = cursorConditions.length === 1 ? cursorConditions[0] : cursorConditions;
449
+ }
450
+ else if (Array.isArray(queryData.where)) {
451
+ const combined = [];
452
+ for (const whereCond of queryData.where) {
453
+ for (const cursorCond of cursorConditions) {
454
+ combined.push({
455
+ ...whereCond,
456
+ ...cursorCond,
457
+ });
458
+ }
459
+ }
460
+ queryData.where = combined;
461
+ }
462
+ else {
463
+ if (cursorConditions.length === 1) {
464
+ queryData.where = {
465
+ ...queryData.where,
466
+ ...cursorConditions[0],
467
+ };
468
+ }
469
+ else {
470
+ queryData.where = cursorConditions.map((cond) => ({
471
+ ...queryData.where,
472
+ ...cond,
473
+ }));
474
+ }
475
+ }
476
+ }
340
477
  if (fields && relationsMap) {
341
478
  const filterKeys = filter ? Object.keys(filter) : [];
342
479
  const extraFilterKeys = filters?.flatMap((f) => Object.keys(f)) ?? [];