connectfy-shared 0.0.71 → 0.0.74
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.cjs +23 -61
- package/dist/index.d.cts +5 -18
- package/dist/index.d.ts +5 -18
- package/dist/index.mjs +24 -65
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9455,7 +9455,6 @@ __export(index_exports, {
|
|
|
9455
9455
|
ENV: () => ENV,
|
|
9456
9456
|
EXPIRE_DATES: () => EXPIRE_DATES,
|
|
9457
9457
|
ExceptionMessages: () => ExceptionMessages,
|
|
9458
|
-
ExceptionTypes: () => ExceptionTypes,
|
|
9459
9458
|
FIELD_TRANSFORMER_REGISTRY: () => FIELD_TRANSFORMER_REGISTRY,
|
|
9460
9459
|
FIELD_TYPE: () => FIELD_TYPE,
|
|
9461
9460
|
FIELD_VALIDATOR_REGISTRY: () => FIELD_VALIDATOR_REGISTRY,
|
|
@@ -9517,9 +9516,9 @@ module.exports = __toCommonJS(index_exports);
|
|
|
9517
9516
|
// src/class/server/base.exception.ts
|
|
9518
9517
|
var import_microservices = require("@nestjs/microservices");
|
|
9519
9518
|
var BaseException = class extends import_microservices.RpcException {
|
|
9520
|
-
constructor(messageOrFunc = ExceptionMessages.INTERNAL_SERVER_ERROR_MESSAGE, statusCode = 500 /* INTERNAL_SERVER_ERROR */,
|
|
9519
|
+
constructor(messageOrFunc = ExceptionMessages.INTERNAL_SERVER_ERROR_MESSAGE, statusCode = 500 /* INTERNAL_SERVER_ERROR */, additional) {
|
|
9521
9520
|
const message = typeof messageOrFunc === "function" ? messageOrFunc() : messageOrFunc;
|
|
9522
|
-
super({ message, statusCode,
|
|
9521
|
+
super({ message, statusCode, additional });
|
|
9523
9522
|
}
|
|
9524
9523
|
};
|
|
9525
9524
|
|
|
@@ -9611,7 +9610,7 @@ var COLLECTIONS = {
|
|
|
9611
9610
|
}
|
|
9612
9611
|
},
|
|
9613
9612
|
ACCOUNT: {
|
|
9614
|
-
|
|
9613
|
+
PROFILES: "profiles",
|
|
9615
9614
|
SOCIAL_LINKS: "social_links",
|
|
9616
9615
|
SETTINGS: {
|
|
9617
9616
|
GENERAL: "general_settings",
|
|
@@ -9788,18 +9787,6 @@ var ExceptionMessages = {
|
|
|
9788
9787
|
}),
|
|
9789
9788
|
INVALID_LENGTH_MESSAGE: (field, lang = "en" /* EN */) => i18n_default.t("exception_messages.invalid_length", { field, lng: lang })
|
|
9790
9789
|
};
|
|
9791
|
-
var ExceptionTypes = {
|
|
9792
|
-
INTERNAL_SERVER_ERROR: "InternalServerError",
|
|
9793
|
-
BAD_REQUEST: "BadRequest",
|
|
9794
|
-
UNAUTHORIZED: "Unauthorized",
|
|
9795
|
-
FORBIDDEN: "Forbidden",
|
|
9796
|
-
NOT_FOUND: "NotFound",
|
|
9797
|
-
CONFLICT: "Conflict",
|
|
9798
|
-
UNPROCESSABLE_ENTITY: "UnprocessableEntity",
|
|
9799
|
-
GONE: "Gone",
|
|
9800
|
-
TOO_MANY_REQUESTS: "TooManyRequests",
|
|
9801
|
-
ALREADY_EXISTS: "AlreadyExists"
|
|
9802
|
-
};
|
|
9803
9790
|
|
|
9804
9791
|
// src/enums/enum.ts
|
|
9805
9792
|
var GENDER = /* @__PURE__ */ ((GENDER2) => {
|
|
@@ -11093,11 +11080,9 @@ var import_microservices2 = require("@nestjs/microservices");
|
|
|
11093
11080
|
var import_rxjs = __toESM(require_cjs(), 1);
|
|
11094
11081
|
var import_common3 = require("@nestjs/common");
|
|
11095
11082
|
var AllExceptionsFilter = class {
|
|
11096
|
-
|
|
11097
|
-
catch(exception, host) {
|
|
11083
|
+
catch(exception) {
|
|
11098
11084
|
let message = ExceptionMessages.INTERNAL_SERVER_ERROR_MESSAGE("en" /* EN */);
|
|
11099
11085
|
let statusCode = import_common3.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
11100
|
-
let errorType = ExceptionTypes.INTERNAL_SERVER_ERROR;
|
|
11101
11086
|
let additional;
|
|
11102
11087
|
const isRpcException = exception instanceof import_microservices2.RpcException || exception && typeof exception === "object" && "error" in exception && typeof exception.getError === "function" || exception && typeof exception === "object" && "error" in exception && typeof exception.error === "object";
|
|
11103
11088
|
if (isRpcException) {
|
|
@@ -11105,7 +11090,6 @@ var AllExceptionsFilter = class {
|
|
|
11105
11090
|
if (typeof errorObj === "object" && errorObj !== null) {
|
|
11106
11091
|
message = errorObj?.message || message;
|
|
11107
11092
|
statusCode = errorObj?.statusCode || statusCode;
|
|
11108
|
-
errorType = errorObj?.error || errorType;
|
|
11109
11093
|
additional = errorObj?.additional;
|
|
11110
11094
|
} else if (typeof errorObj === "string") {
|
|
11111
11095
|
message = errorObj;
|
|
@@ -11115,7 +11099,6 @@ var AllExceptionsFilter = class {
|
|
|
11115
11099
|
const resObj = typeof response === "string" ? { message: response } : response;
|
|
11116
11100
|
message = resObj.message || exception.message;
|
|
11117
11101
|
statusCode = exception.getStatus();
|
|
11118
|
-
errorType = resObj.error || exception.name;
|
|
11119
11102
|
additional = resObj?.additional;
|
|
11120
11103
|
} else if (exception instanceof Error) {
|
|
11121
11104
|
if (message === ExceptionMessages.INTERNAL_SERVER_ERROR_MESSAGE("en" /* EN */)) {
|
|
@@ -11127,7 +11110,6 @@ var AllExceptionsFilter = class {
|
|
|
11127
11110
|
message,
|
|
11128
11111
|
// This will now be the correct string from Step 1
|
|
11129
11112
|
statusCode,
|
|
11130
|
-
error: errorType,
|
|
11131
11113
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11132
11114
|
// Good practice to add
|
|
11133
11115
|
...additional ? { additional } : {}
|
|
@@ -11146,8 +11128,7 @@ function stringTransform({ value, key }) {
|
|
|
11146
11128
|
if (typeof value !== "string") {
|
|
11147
11129
|
throw new BaseException(
|
|
11148
11130
|
(lang) => ExceptionMessages.STRING_OR_NULL_MESSAGE(key, lang),
|
|
11149
|
-
400 /* BAD_REQUEST
|
|
11150
|
-
ExceptionTypes.BAD_REQUEST
|
|
11131
|
+
400 /* BAD_REQUEST */
|
|
11151
11132
|
);
|
|
11152
11133
|
}
|
|
11153
11134
|
const trimmedValue = value.trim();
|
|
@@ -11164,8 +11145,7 @@ function numberTransform({ value, key }) {
|
|
|
11164
11145
|
if (isNaN(value)) {
|
|
11165
11146
|
throw new BaseException(
|
|
11166
11147
|
(lang) => ExceptionMessages.NUMBER_OR_NULL_MESSAGE(key, lang),
|
|
11167
|
-
400 /* BAD_REQUEST
|
|
11168
|
-
ExceptionTypes.BAD_REQUEST
|
|
11148
|
+
400 /* BAD_REQUEST */
|
|
11169
11149
|
);
|
|
11170
11150
|
}
|
|
11171
11151
|
return value;
|
|
@@ -11177,16 +11157,14 @@ function numberTransform({ value, key }) {
|
|
|
11177
11157
|
if (isNaN(num)) {
|
|
11178
11158
|
throw new BaseException(
|
|
11179
11159
|
(lang) => ExceptionMessages.NUMBER_OR_NULL_MESSAGE(key, lang),
|
|
11180
|
-
400 /* BAD_REQUEST
|
|
11181
|
-
ExceptionTypes.BAD_REQUEST
|
|
11160
|
+
400 /* BAD_REQUEST */
|
|
11182
11161
|
);
|
|
11183
11162
|
}
|
|
11184
11163
|
return num;
|
|
11185
11164
|
}
|
|
11186
11165
|
throw new BaseException(
|
|
11187
11166
|
(lang) => ExceptionMessages.NUMBER_OR_NULL_MESSAGE(key, lang),
|
|
11188
|
-
400 /* BAD_REQUEST
|
|
11189
|
-
ExceptionTypes.BAD_REQUEST
|
|
11167
|
+
400 /* BAD_REQUEST */
|
|
11190
11168
|
);
|
|
11191
11169
|
}
|
|
11192
11170
|
function arrayTransform({ value, key }) {
|
|
@@ -11196,15 +11174,13 @@ function arrayTransform({ value, key }) {
|
|
|
11196
11174
|
if (!Array.isArray(value)) {
|
|
11197
11175
|
throw new BaseException(
|
|
11198
11176
|
(lang) => ExceptionMessages.ARRAY_TYPE_MESSAGE(key, lang),
|
|
11199
|
-
400 /* BAD_REQUEST
|
|
11200
|
-
ExceptionTypes.BAD_REQUEST
|
|
11177
|
+
400 /* BAD_REQUEST */
|
|
11201
11178
|
);
|
|
11202
11179
|
}
|
|
11203
11180
|
if (value.length === 0) {
|
|
11204
11181
|
throw new BaseException(
|
|
11205
11182
|
(lang) => ExceptionMessages.ARRAY_MIN_ONE_MESSAGE(key, lang),
|
|
11206
|
-
400 /* BAD_REQUEST
|
|
11207
|
-
ExceptionTypes.BAD_REQUEST
|
|
11183
|
+
400 /* BAD_REQUEST */
|
|
11208
11184
|
);
|
|
11209
11185
|
}
|
|
11210
11186
|
return value;
|
|
@@ -11216,15 +11192,13 @@ function objectTransform({ value, key }) {
|
|
|
11216
11192
|
if (typeof value !== "object" || Array.isArray(value)) {
|
|
11217
11193
|
throw new BaseException(
|
|
11218
11194
|
(lang) => ExceptionMessages.OBJECT_TYPE_MESSAGE(key, lang),
|
|
11219
|
-
400 /* BAD_REQUEST
|
|
11220
|
-
ExceptionTypes.BAD_REQUEST
|
|
11195
|
+
400 /* BAD_REQUEST */
|
|
11221
11196
|
);
|
|
11222
11197
|
}
|
|
11223
11198
|
if (Object.keys(value).length === 0) {
|
|
11224
11199
|
throw new BaseException(
|
|
11225
11200
|
(lang) => ExceptionMessages.OBJECT_MIN_ONE_PROPERTY_MESSAGE(key, lang),
|
|
11226
|
-
400 /* BAD_REQUEST
|
|
11227
|
-
ExceptionTypes.BAD_REQUEST
|
|
11201
|
+
400 /* BAD_REQUEST */
|
|
11228
11202
|
);
|
|
11229
11203
|
}
|
|
11230
11204
|
return value;
|
|
@@ -11237,8 +11211,7 @@ function dateTransform({ value, key }) {
|
|
|
11237
11211
|
if (isNaN(value.getTime())) {
|
|
11238
11212
|
throw new BaseException(
|
|
11239
11213
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11240
|
-
400 /* BAD_REQUEST
|
|
11241
|
-
ExceptionTypes.BAD_REQUEST
|
|
11214
|
+
400 /* BAD_REQUEST */
|
|
11242
11215
|
);
|
|
11243
11216
|
}
|
|
11244
11217
|
return value;
|
|
@@ -11247,8 +11220,7 @@ function dateTransform({ value, key }) {
|
|
|
11247
11220
|
if (parsedValue) {
|
|
11248
11221
|
throw new BaseException(
|
|
11249
11222
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11250
|
-
400 /* BAD_REQUEST
|
|
11251
|
-
ExceptionTypes.BAD_REQUEST
|
|
11223
|
+
400 /* BAD_REQUEST */
|
|
11252
11224
|
);
|
|
11253
11225
|
}
|
|
11254
11226
|
if (typeof value === "string") {
|
|
@@ -11257,32 +11229,28 @@ function dateTransform({ value, key }) {
|
|
|
11257
11229
|
if (!isNaN(Number(trimmed))) {
|
|
11258
11230
|
throw new BaseException(
|
|
11259
11231
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11260
|
-
400 /* BAD_REQUEST
|
|
11261
|
-
ExceptionTypes.BAD_REQUEST
|
|
11232
|
+
400 /* BAD_REQUEST */
|
|
11262
11233
|
);
|
|
11263
11234
|
}
|
|
11264
11235
|
const date = new Date(trimmed);
|
|
11265
11236
|
if (isNaN(date.getTime())) {
|
|
11266
11237
|
throw new BaseException(
|
|
11267
11238
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11268
|
-
400 /* BAD_REQUEST
|
|
11269
|
-
ExceptionTypes.BAD_REQUEST
|
|
11239
|
+
400 /* BAD_REQUEST */
|
|
11270
11240
|
);
|
|
11271
11241
|
}
|
|
11272
11242
|
return date;
|
|
11273
11243
|
}
|
|
11274
11244
|
throw new BaseException(
|
|
11275
11245
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11276
|
-
400 /* BAD_REQUEST
|
|
11277
|
-
ExceptionTypes.BAD_REQUEST
|
|
11246
|
+
400 /* BAD_REQUEST */
|
|
11278
11247
|
);
|
|
11279
11248
|
}
|
|
11280
11249
|
function booleanTransform({ value, key }) {
|
|
11281
11250
|
if (value === void 0 || value === null) {
|
|
11282
11251
|
throw new BaseException(
|
|
11283
11252
|
(lang) => ExceptionMessages.BOOLEAN_INVALID_MESSAGE(key, lang),
|
|
11284
|
-
400 /* BAD_REQUEST
|
|
11285
|
-
ExceptionTypes.BAD_REQUEST
|
|
11253
|
+
400 /* BAD_REQUEST */
|
|
11286
11254
|
);
|
|
11287
11255
|
}
|
|
11288
11256
|
if (typeof value === "boolean") {
|
|
@@ -11294,14 +11262,12 @@ function booleanTransform({ value, key }) {
|
|
|
11294
11262
|
if (trimmed === "false") return false;
|
|
11295
11263
|
throw new BaseException(
|
|
11296
11264
|
(lang) => ExceptionMessages.BOOLEAN_INVALID_MESSAGE(key, lang),
|
|
11297
|
-
400 /* BAD_REQUEST
|
|
11298
|
-
ExceptionTypes.BAD_REQUEST
|
|
11265
|
+
400 /* BAD_REQUEST */
|
|
11299
11266
|
);
|
|
11300
11267
|
}
|
|
11301
11268
|
throw new BaseException(
|
|
11302
11269
|
(lang) => ExceptionMessages.BOOLEAN_TYPE_MESSAGE(key, lang),
|
|
11303
|
-
400 /* BAD_REQUEST
|
|
11304
|
-
ExceptionTypes.BAD_REQUEST
|
|
11270
|
+
400 /* BAD_REQUEST */
|
|
11305
11271
|
);
|
|
11306
11272
|
}
|
|
11307
11273
|
function enumTransform({
|
|
@@ -11318,8 +11284,7 @@ function enumTransform({
|
|
|
11318
11284
|
}
|
|
11319
11285
|
throw new BaseException(
|
|
11320
11286
|
(lang) => ExceptionMessages.ENUM_INVALID_MESSAGE(key, enumValues, lang),
|
|
11321
|
-
400 /* BAD_REQUEST
|
|
11322
|
-
ExceptionTypes.BAD_REQUEST
|
|
11287
|
+
400 /* BAD_REQUEST */
|
|
11323
11288
|
);
|
|
11324
11289
|
}
|
|
11325
11290
|
function upperCaseTranform(value) {
|
|
@@ -11327,8 +11292,7 @@ function upperCaseTranform(value) {
|
|
|
11327
11292
|
if (typeof value !== "string")
|
|
11328
11293
|
throw new BaseException(
|
|
11329
11294
|
(lang) => ExceptionMessages.STRING_OR_NULL_MESSAGE(value, lang),
|
|
11330
|
-
400 /* BAD_REQUEST
|
|
11331
|
-
ExceptionTypes.BAD_REQUEST
|
|
11295
|
+
400 /* BAD_REQUEST */
|
|
11332
11296
|
);
|
|
11333
11297
|
return value.toUpperCase();
|
|
11334
11298
|
}
|
|
@@ -11337,8 +11301,7 @@ function lowerCaseTranform(value) {
|
|
|
11337
11301
|
if (typeof value !== "string")
|
|
11338
11302
|
throw new BaseException(
|
|
11339
11303
|
(lang) => ExceptionMessages.STRING_OR_NULL_MESSAGE(value, lang),
|
|
11340
|
-
400 /* BAD_REQUEST
|
|
11341
|
-
ExceptionTypes.BAD_REQUEST
|
|
11304
|
+
400 /* BAD_REQUEST */
|
|
11342
11305
|
);
|
|
11343
11306
|
return value.toLowerCase();
|
|
11344
11307
|
}
|
|
@@ -11555,7 +11518,6 @@ var BaseRepository = class {
|
|
|
11555
11518
|
ENV,
|
|
11556
11519
|
EXPIRE_DATES,
|
|
11557
11520
|
ExceptionMessages,
|
|
11558
|
-
ExceptionTypes,
|
|
11559
11521
|
FIELD_TRANSFORMER_REGISTRY,
|
|
11560
11522
|
FIELD_TYPE,
|
|
11561
11523
|
FIELD_VALIDATOR_REGISTRY,
|
package/dist/index.d.cts
CHANGED
|
@@ -3,12 +3,12 @@ import { PopulateOptions, Document, Model } from 'mongoose';
|
|
|
3
3
|
import { ClsService } from 'nestjs-cls';
|
|
4
4
|
import { ValidationArguments, ValidationOptions, IsIpVersion, IsNumberOptions } from 'class-validator';
|
|
5
5
|
import { ClassConstructor } from 'class-transformer';
|
|
6
|
-
import { ExceptionFilter
|
|
6
|
+
import { ExceptionFilter } from '@nestjs/common';
|
|
7
7
|
import * as rxjs from 'rxjs';
|
|
8
8
|
import { Observable } from 'rxjs';
|
|
9
9
|
|
|
10
10
|
declare class BaseException extends RpcException {
|
|
11
|
-
constructor(messageOrFunc?: string | string[] | ((...args: any[]) => string | string[]), statusCode?: HttpStatus,
|
|
11
|
+
constructor(messageOrFunc?: string | string[] | ((...args: any[]) => string | string[]), statusCode?: HttpStatus, additional?: Record<string, any>);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
interface ICountry {
|
|
@@ -133,7 +133,7 @@ declare const COLLECTIONS: {
|
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
135
|
ACCOUNT: {
|
|
136
|
-
|
|
136
|
+
PROFILES: string;
|
|
137
137
|
SOCIAL_LINKS: string;
|
|
138
138
|
SETTINGS: {
|
|
139
139
|
GENERAL: string;
|
|
@@ -191,18 +191,6 @@ declare const ExceptionMessages: {
|
|
|
191
191
|
ENUM_INVALID_MESSAGE: (field: string, validValues: any[], lang?: LANGUAGE) => string;
|
|
192
192
|
INVALID_LENGTH_MESSAGE: (field: string, lang?: LANGUAGE) => string;
|
|
193
193
|
};
|
|
194
|
-
declare const ExceptionTypes: {
|
|
195
|
-
INTERNAL_SERVER_ERROR: string;
|
|
196
|
-
BAD_REQUEST: string;
|
|
197
|
-
UNAUTHORIZED: string;
|
|
198
|
-
FORBIDDEN: string;
|
|
199
|
-
NOT_FOUND: string;
|
|
200
|
-
CONFLICT: string;
|
|
201
|
-
UNPROCESSABLE_ENTITY: string;
|
|
202
|
-
GONE: string;
|
|
203
|
-
TOO_MANY_REQUESTS: string;
|
|
204
|
-
ALREADY_EXISTS: string;
|
|
205
|
-
};
|
|
206
194
|
|
|
207
195
|
declare enum GENDER {
|
|
208
196
|
MALE = "MALE",
|
|
@@ -582,8 +570,7 @@ declare class BaseFindDto {
|
|
|
582
570
|
}
|
|
583
571
|
|
|
584
572
|
declare class AllExceptionsFilter implements ExceptionFilter {
|
|
585
|
-
|
|
586
|
-
catch(exception: any, host: ArgumentsHost): Observable<any>;
|
|
573
|
+
catch(exception: any): Observable<any>;
|
|
587
574
|
}
|
|
588
575
|
|
|
589
576
|
declare function stringTransform({ value, key }: {
|
|
@@ -800,4 +787,4 @@ declare abstract class BaseRepository<TDocument extends Document, TInterface ext
|
|
|
800
787
|
count(query: Record<string, any>): Promise<number>;
|
|
801
788
|
}
|
|
802
789
|
|
|
803
|
-
export { AllExceptionsFilter, BROWSER_TYPE, BaseException, BaseFindDto, BaseRemoveAllDto, BaseRemoveDto, BaseRepository, CACHE_KEYS, CHECK_UNIQUE_FIELD, CLS_KEYS, COLLECTIONS, COUNTRIES, DATE_FORMAT, DELETE_REASON, DEVICE_TYPE, ENV, EXPIRE_DATES, ExceptionMessages,
|
|
790
|
+
export { AllExceptionsFilter, BROWSER_TYPE, BaseException, BaseFindDto, BaseRemoveAllDto, BaseRemoveDto, BaseRepository, CACHE_KEYS, CHECK_UNIQUE_FIELD, CLS_KEYS, COLLECTIONS, COUNTRIES, DATE_FORMAT, DELETE_REASON, DEVICE_TYPE, ENV, EXPIRE_DATES, ExceptionMessages, FIELD_TRANSFORMER_REGISTRY, FIELD_TYPE, FIELD_VALIDATOR_REGISTRY, FORGOT_PASSWORD_IDENTIFIER_TYPE, FRIENDSHIP_STATUS, FieldValidator, type FieldValidatorOptions, GENDER, GOOGLE_AUTH_LOGIN_TYPE, HttpStatus, type IAccount, type IArrayFieldOptions, type IBaseFieldOptions, type IBooleanFieldOptions, IDENTIFIER_TYPE, type IDateFieldOptions, type IEnumFieldOptions, type IGeneralSettings, type ILoggedUser, type INotificationSettings, type INumberFieldOptions, type IObjectFieldOptions, type IPhoneNumber, type IPrivacySettings, type IRemoveAllResponse, type IStringFieldOptions, type ITimeZone, type IUser, type IValidateMessageOptions, LANGUAGE, LOCAL_STORAGE_KEYS, MICROSERVICE_NAMES, NOTIFICATION_CONTENT_MODE, NOTIFICATION_SOUND_MODE, OS_TYPE, PHONE_NUMBER_ACTION, PRIVACY_SETTINGS_CHOICE, PROVIDER, PopulateOption, REDUCER_PATH, RESOURCE, ROLE, SOCIAL_LINK_PLATFORM, STARTUP_PAGE, TAG_TYPES, THEME, TIME_DIFFERENCE_TYPE, TIME_FORMAT, TOKEN_TYPE, USER_STATUS, VALIDATION_TYPE, accountDeletedMessage, arrayTransform, booleanTransform, changeEmailMessage, dateTransform, decryptPayload, deleteAccountMessage, emailNotFoundMessage, emitWithContext, encryptPayload, enumTransform, forgotPasswordMessage, getLang, googleSignInMessage, lowerCaseTranform, numberTransform, objectTransform, sendWithContext, signupVerifyMessage, stringTransform, upperCaseTranform, validationMessage, verifyYourselfMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { PopulateOptions, Document, Model } from 'mongoose';
|
|
|
3
3
|
import { ClsService } from 'nestjs-cls';
|
|
4
4
|
import { ValidationArguments, ValidationOptions, IsIpVersion, IsNumberOptions } from 'class-validator';
|
|
5
5
|
import { ClassConstructor } from 'class-transformer';
|
|
6
|
-
import { ExceptionFilter
|
|
6
|
+
import { ExceptionFilter } from '@nestjs/common';
|
|
7
7
|
import * as rxjs from 'rxjs';
|
|
8
8
|
import { Observable } from 'rxjs';
|
|
9
9
|
|
|
10
10
|
declare class BaseException extends RpcException {
|
|
11
|
-
constructor(messageOrFunc?: string | string[] | ((...args: any[]) => string | string[]), statusCode?: HttpStatus,
|
|
11
|
+
constructor(messageOrFunc?: string | string[] | ((...args: any[]) => string | string[]), statusCode?: HttpStatus, additional?: Record<string, any>);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
interface ICountry {
|
|
@@ -133,7 +133,7 @@ declare const COLLECTIONS: {
|
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
135
|
ACCOUNT: {
|
|
136
|
-
|
|
136
|
+
PROFILES: string;
|
|
137
137
|
SOCIAL_LINKS: string;
|
|
138
138
|
SETTINGS: {
|
|
139
139
|
GENERAL: string;
|
|
@@ -191,18 +191,6 @@ declare const ExceptionMessages: {
|
|
|
191
191
|
ENUM_INVALID_MESSAGE: (field: string, validValues: any[], lang?: LANGUAGE) => string;
|
|
192
192
|
INVALID_LENGTH_MESSAGE: (field: string, lang?: LANGUAGE) => string;
|
|
193
193
|
};
|
|
194
|
-
declare const ExceptionTypes: {
|
|
195
|
-
INTERNAL_SERVER_ERROR: string;
|
|
196
|
-
BAD_REQUEST: string;
|
|
197
|
-
UNAUTHORIZED: string;
|
|
198
|
-
FORBIDDEN: string;
|
|
199
|
-
NOT_FOUND: string;
|
|
200
|
-
CONFLICT: string;
|
|
201
|
-
UNPROCESSABLE_ENTITY: string;
|
|
202
|
-
GONE: string;
|
|
203
|
-
TOO_MANY_REQUESTS: string;
|
|
204
|
-
ALREADY_EXISTS: string;
|
|
205
|
-
};
|
|
206
194
|
|
|
207
195
|
declare enum GENDER {
|
|
208
196
|
MALE = "MALE",
|
|
@@ -582,8 +570,7 @@ declare class BaseFindDto {
|
|
|
582
570
|
}
|
|
583
571
|
|
|
584
572
|
declare class AllExceptionsFilter implements ExceptionFilter {
|
|
585
|
-
|
|
586
|
-
catch(exception: any, host: ArgumentsHost): Observable<any>;
|
|
573
|
+
catch(exception: any): Observable<any>;
|
|
587
574
|
}
|
|
588
575
|
|
|
589
576
|
declare function stringTransform({ value, key }: {
|
|
@@ -800,4 +787,4 @@ declare abstract class BaseRepository<TDocument extends Document, TInterface ext
|
|
|
800
787
|
count(query: Record<string, any>): Promise<number>;
|
|
801
788
|
}
|
|
802
789
|
|
|
803
|
-
export { AllExceptionsFilter, BROWSER_TYPE, BaseException, BaseFindDto, BaseRemoveAllDto, BaseRemoveDto, BaseRepository, CACHE_KEYS, CHECK_UNIQUE_FIELD, CLS_KEYS, COLLECTIONS, COUNTRIES, DATE_FORMAT, DELETE_REASON, DEVICE_TYPE, ENV, EXPIRE_DATES, ExceptionMessages,
|
|
790
|
+
export { AllExceptionsFilter, BROWSER_TYPE, BaseException, BaseFindDto, BaseRemoveAllDto, BaseRemoveDto, BaseRepository, CACHE_KEYS, CHECK_UNIQUE_FIELD, CLS_KEYS, COLLECTIONS, COUNTRIES, DATE_FORMAT, DELETE_REASON, DEVICE_TYPE, ENV, EXPIRE_DATES, ExceptionMessages, FIELD_TRANSFORMER_REGISTRY, FIELD_TYPE, FIELD_VALIDATOR_REGISTRY, FORGOT_PASSWORD_IDENTIFIER_TYPE, FRIENDSHIP_STATUS, FieldValidator, type FieldValidatorOptions, GENDER, GOOGLE_AUTH_LOGIN_TYPE, HttpStatus, type IAccount, type IArrayFieldOptions, type IBaseFieldOptions, type IBooleanFieldOptions, IDENTIFIER_TYPE, type IDateFieldOptions, type IEnumFieldOptions, type IGeneralSettings, type ILoggedUser, type INotificationSettings, type INumberFieldOptions, type IObjectFieldOptions, type IPhoneNumber, type IPrivacySettings, type IRemoveAllResponse, type IStringFieldOptions, type ITimeZone, type IUser, type IValidateMessageOptions, LANGUAGE, LOCAL_STORAGE_KEYS, MICROSERVICE_NAMES, NOTIFICATION_CONTENT_MODE, NOTIFICATION_SOUND_MODE, OS_TYPE, PHONE_NUMBER_ACTION, PRIVACY_SETTINGS_CHOICE, PROVIDER, PopulateOption, REDUCER_PATH, RESOURCE, ROLE, SOCIAL_LINK_PLATFORM, STARTUP_PAGE, TAG_TYPES, THEME, TIME_DIFFERENCE_TYPE, TIME_FORMAT, TOKEN_TYPE, USER_STATUS, VALIDATION_TYPE, accountDeletedMessage, arrayTransform, booleanTransform, changeEmailMessage, dateTransform, decryptPayload, deleteAccountMessage, emailNotFoundMessage, emitWithContext, encryptPayload, enumTransform, forgotPasswordMessage, getLang, googleSignInMessage, lowerCaseTranform, numberTransform, objectTransform, sendWithContext, signupVerifyMessage, stringTransform, upperCaseTranform, validationMessage, verifyYourselfMessage };
|
package/dist/index.mjs
CHANGED
|
@@ -9432,9 +9432,9 @@ var require_cjs = __commonJS({
|
|
|
9432
9432
|
// src/class/server/base.exception.ts
|
|
9433
9433
|
import { RpcException } from "@nestjs/microservices";
|
|
9434
9434
|
var BaseException = class extends RpcException {
|
|
9435
|
-
constructor(messageOrFunc = ExceptionMessages.INTERNAL_SERVER_ERROR_MESSAGE, statusCode = 500 /* INTERNAL_SERVER_ERROR */,
|
|
9435
|
+
constructor(messageOrFunc = ExceptionMessages.INTERNAL_SERVER_ERROR_MESSAGE, statusCode = 500 /* INTERNAL_SERVER_ERROR */, additional) {
|
|
9436
9436
|
const message = typeof messageOrFunc === "function" ? messageOrFunc() : messageOrFunc;
|
|
9437
|
-
super({ message, statusCode,
|
|
9437
|
+
super({ message, statusCode, additional });
|
|
9438
9438
|
}
|
|
9439
9439
|
};
|
|
9440
9440
|
|
|
@@ -9526,7 +9526,7 @@ var COLLECTIONS = {
|
|
|
9526
9526
|
}
|
|
9527
9527
|
},
|
|
9528
9528
|
ACCOUNT: {
|
|
9529
|
-
|
|
9529
|
+
PROFILES: "profiles",
|
|
9530
9530
|
SOCIAL_LINKS: "social_links",
|
|
9531
9531
|
SETTINGS: {
|
|
9532
9532
|
GENERAL: "general_settings",
|
|
@@ -9703,18 +9703,6 @@ var ExceptionMessages = {
|
|
|
9703
9703
|
}),
|
|
9704
9704
|
INVALID_LENGTH_MESSAGE: (field, lang = "en" /* EN */) => i18n_default.t("exception_messages.invalid_length", { field, lng: lang })
|
|
9705
9705
|
};
|
|
9706
|
-
var ExceptionTypes = {
|
|
9707
|
-
INTERNAL_SERVER_ERROR: "InternalServerError",
|
|
9708
|
-
BAD_REQUEST: "BadRequest",
|
|
9709
|
-
UNAUTHORIZED: "Unauthorized",
|
|
9710
|
-
FORBIDDEN: "Forbidden",
|
|
9711
|
-
NOT_FOUND: "NotFound",
|
|
9712
|
-
CONFLICT: "Conflict",
|
|
9713
|
-
UNPROCESSABLE_ENTITY: "UnprocessableEntity",
|
|
9714
|
-
GONE: "Gone",
|
|
9715
|
-
TOO_MANY_REQUESTS: "TooManyRequests",
|
|
9716
|
-
ALREADY_EXISTS: "AlreadyExists"
|
|
9717
|
-
};
|
|
9718
9706
|
|
|
9719
9707
|
// src/enums/enum.ts
|
|
9720
9708
|
var GENDER = /* @__PURE__ */ ((GENDER2) => {
|
|
@@ -11046,19 +11034,13 @@ __decorateClass([
|
|
|
11046
11034
|
|
|
11047
11035
|
// src/exception-filters/server/all.filter.ts
|
|
11048
11036
|
var import_rxjs = __toESM(require_cjs(), 1);
|
|
11049
|
-
import {
|
|
11050
|
-
Catch,
|
|
11051
|
-
HttpException,
|
|
11052
|
-
Logger
|
|
11053
|
-
} from "@nestjs/common";
|
|
11037
|
+
import { Catch, HttpException } from "@nestjs/common";
|
|
11054
11038
|
import { RpcException as RpcException2 } from "@nestjs/microservices";
|
|
11055
11039
|
import { HttpStatus as HttpStatus2 } from "@nestjs/common";
|
|
11056
11040
|
var AllExceptionsFilter = class {
|
|
11057
|
-
|
|
11058
|
-
catch(exception, host) {
|
|
11041
|
+
catch(exception) {
|
|
11059
11042
|
let message = ExceptionMessages.INTERNAL_SERVER_ERROR_MESSAGE("en" /* EN */);
|
|
11060
11043
|
let statusCode = HttpStatus2.INTERNAL_SERVER_ERROR;
|
|
11061
|
-
let errorType = ExceptionTypes.INTERNAL_SERVER_ERROR;
|
|
11062
11044
|
let additional;
|
|
11063
11045
|
const isRpcException = exception instanceof RpcException2 || exception && typeof exception === "object" && "error" in exception && typeof exception.getError === "function" || exception && typeof exception === "object" && "error" in exception && typeof exception.error === "object";
|
|
11064
11046
|
if (isRpcException) {
|
|
@@ -11066,7 +11048,6 @@ var AllExceptionsFilter = class {
|
|
|
11066
11048
|
if (typeof errorObj === "object" && errorObj !== null) {
|
|
11067
11049
|
message = errorObj?.message || message;
|
|
11068
11050
|
statusCode = errorObj?.statusCode || statusCode;
|
|
11069
|
-
errorType = errorObj?.error || errorType;
|
|
11070
11051
|
additional = errorObj?.additional;
|
|
11071
11052
|
} else if (typeof errorObj === "string") {
|
|
11072
11053
|
message = errorObj;
|
|
@@ -11076,7 +11057,6 @@ var AllExceptionsFilter = class {
|
|
|
11076
11057
|
const resObj = typeof response === "string" ? { message: response } : response;
|
|
11077
11058
|
message = resObj.message || exception.message;
|
|
11078
11059
|
statusCode = exception.getStatus();
|
|
11079
|
-
errorType = resObj.error || exception.name;
|
|
11080
11060
|
additional = resObj?.additional;
|
|
11081
11061
|
} else if (exception instanceof Error) {
|
|
11082
11062
|
if (message === ExceptionMessages.INTERNAL_SERVER_ERROR_MESSAGE("en" /* EN */)) {
|
|
@@ -11088,7 +11068,6 @@ var AllExceptionsFilter = class {
|
|
|
11088
11068
|
message,
|
|
11089
11069
|
// This will now be the correct string from Step 1
|
|
11090
11070
|
statusCode,
|
|
11091
|
-
error: errorType,
|
|
11092
11071
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11093
11072
|
// Good practice to add
|
|
11094
11073
|
...additional ? { additional } : {}
|
|
@@ -11107,8 +11086,7 @@ function stringTransform({ value, key }) {
|
|
|
11107
11086
|
if (typeof value !== "string") {
|
|
11108
11087
|
throw new BaseException(
|
|
11109
11088
|
(lang) => ExceptionMessages.STRING_OR_NULL_MESSAGE(key, lang),
|
|
11110
|
-
400 /* BAD_REQUEST
|
|
11111
|
-
ExceptionTypes.BAD_REQUEST
|
|
11089
|
+
400 /* BAD_REQUEST */
|
|
11112
11090
|
);
|
|
11113
11091
|
}
|
|
11114
11092
|
const trimmedValue = value.trim();
|
|
@@ -11125,8 +11103,7 @@ function numberTransform({ value, key }) {
|
|
|
11125
11103
|
if (isNaN(value)) {
|
|
11126
11104
|
throw new BaseException(
|
|
11127
11105
|
(lang) => ExceptionMessages.NUMBER_OR_NULL_MESSAGE(key, lang),
|
|
11128
|
-
400 /* BAD_REQUEST
|
|
11129
|
-
ExceptionTypes.BAD_REQUEST
|
|
11106
|
+
400 /* BAD_REQUEST */
|
|
11130
11107
|
);
|
|
11131
11108
|
}
|
|
11132
11109
|
return value;
|
|
@@ -11138,16 +11115,14 @@ function numberTransform({ value, key }) {
|
|
|
11138
11115
|
if (isNaN(num)) {
|
|
11139
11116
|
throw new BaseException(
|
|
11140
11117
|
(lang) => ExceptionMessages.NUMBER_OR_NULL_MESSAGE(key, lang),
|
|
11141
|
-
400 /* BAD_REQUEST
|
|
11142
|
-
ExceptionTypes.BAD_REQUEST
|
|
11118
|
+
400 /* BAD_REQUEST */
|
|
11143
11119
|
);
|
|
11144
11120
|
}
|
|
11145
11121
|
return num;
|
|
11146
11122
|
}
|
|
11147
11123
|
throw new BaseException(
|
|
11148
11124
|
(lang) => ExceptionMessages.NUMBER_OR_NULL_MESSAGE(key, lang),
|
|
11149
|
-
400 /* BAD_REQUEST
|
|
11150
|
-
ExceptionTypes.BAD_REQUEST
|
|
11125
|
+
400 /* BAD_REQUEST */
|
|
11151
11126
|
);
|
|
11152
11127
|
}
|
|
11153
11128
|
function arrayTransform({ value, key }) {
|
|
@@ -11157,15 +11132,13 @@ function arrayTransform({ value, key }) {
|
|
|
11157
11132
|
if (!Array.isArray(value)) {
|
|
11158
11133
|
throw new BaseException(
|
|
11159
11134
|
(lang) => ExceptionMessages.ARRAY_TYPE_MESSAGE(key, lang),
|
|
11160
|
-
400 /* BAD_REQUEST
|
|
11161
|
-
ExceptionTypes.BAD_REQUEST
|
|
11135
|
+
400 /* BAD_REQUEST */
|
|
11162
11136
|
);
|
|
11163
11137
|
}
|
|
11164
11138
|
if (value.length === 0) {
|
|
11165
11139
|
throw new BaseException(
|
|
11166
11140
|
(lang) => ExceptionMessages.ARRAY_MIN_ONE_MESSAGE(key, lang),
|
|
11167
|
-
400 /* BAD_REQUEST
|
|
11168
|
-
ExceptionTypes.BAD_REQUEST
|
|
11141
|
+
400 /* BAD_REQUEST */
|
|
11169
11142
|
);
|
|
11170
11143
|
}
|
|
11171
11144
|
return value;
|
|
@@ -11177,15 +11150,13 @@ function objectTransform({ value, key }) {
|
|
|
11177
11150
|
if (typeof value !== "object" || Array.isArray(value)) {
|
|
11178
11151
|
throw new BaseException(
|
|
11179
11152
|
(lang) => ExceptionMessages.OBJECT_TYPE_MESSAGE(key, lang),
|
|
11180
|
-
400 /* BAD_REQUEST
|
|
11181
|
-
ExceptionTypes.BAD_REQUEST
|
|
11153
|
+
400 /* BAD_REQUEST */
|
|
11182
11154
|
);
|
|
11183
11155
|
}
|
|
11184
11156
|
if (Object.keys(value).length === 0) {
|
|
11185
11157
|
throw new BaseException(
|
|
11186
11158
|
(lang) => ExceptionMessages.OBJECT_MIN_ONE_PROPERTY_MESSAGE(key, lang),
|
|
11187
|
-
400 /* BAD_REQUEST
|
|
11188
|
-
ExceptionTypes.BAD_REQUEST
|
|
11159
|
+
400 /* BAD_REQUEST */
|
|
11189
11160
|
);
|
|
11190
11161
|
}
|
|
11191
11162
|
return value;
|
|
@@ -11198,8 +11169,7 @@ function dateTransform({ value, key }) {
|
|
|
11198
11169
|
if (isNaN(value.getTime())) {
|
|
11199
11170
|
throw new BaseException(
|
|
11200
11171
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11201
|
-
400 /* BAD_REQUEST
|
|
11202
|
-
ExceptionTypes.BAD_REQUEST
|
|
11172
|
+
400 /* BAD_REQUEST */
|
|
11203
11173
|
);
|
|
11204
11174
|
}
|
|
11205
11175
|
return value;
|
|
@@ -11208,8 +11178,7 @@ function dateTransform({ value, key }) {
|
|
|
11208
11178
|
if (parsedValue) {
|
|
11209
11179
|
throw new BaseException(
|
|
11210
11180
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11211
|
-
400 /* BAD_REQUEST
|
|
11212
|
-
ExceptionTypes.BAD_REQUEST
|
|
11181
|
+
400 /* BAD_REQUEST */
|
|
11213
11182
|
);
|
|
11214
11183
|
}
|
|
11215
11184
|
if (typeof value === "string") {
|
|
@@ -11218,32 +11187,28 @@ function dateTransform({ value, key }) {
|
|
|
11218
11187
|
if (!isNaN(Number(trimmed))) {
|
|
11219
11188
|
throw new BaseException(
|
|
11220
11189
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11221
|
-
400 /* BAD_REQUEST
|
|
11222
|
-
ExceptionTypes.BAD_REQUEST
|
|
11190
|
+
400 /* BAD_REQUEST */
|
|
11223
11191
|
);
|
|
11224
11192
|
}
|
|
11225
11193
|
const date = new Date(trimmed);
|
|
11226
11194
|
if (isNaN(date.getTime())) {
|
|
11227
11195
|
throw new BaseException(
|
|
11228
11196
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11229
|
-
400 /* BAD_REQUEST
|
|
11230
|
-
ExceptionTypes.BAD_REQUEST
|
|
11197
|
+
400 /* BAD_REQUEST */
|
|
11231
11198
|
);
|
|
11232
11199
|
}
|
|
11233
11200
|
return date;
|
|
11234
11201
|
}
|
|
11235
11202
|
throw new BaseException(
|
|
11236
11203
|
(lang) => ExceptionMessages.DATE_OR_NULL_MESSAGE(key, lang),
|
|
11237
|
-
400 /* BAD_REQUEST
|
|
11238
|
-
ExceptionTypes.BAD_REQUEST
|
|
11204
|
+
400 /* BAD_REQUEST */
|
|
11239
11205
|
);
|
|
11240
11206
|
}
|
|
11241
11207
|
function booleanTransform({ value, key }) {
|
|
11242
11208
|
if (value === void 0 || value === null) {
|
|
11243
11209
|
throw new BaseException(
|
|
11244
11210
|
(lang) => ExceptionMessages.BOOLEAN_INVALID_MESSAGE(key, lang),
|
|
11245
|
-
400 /* BAD_REQUEST
|
|
11246
|
-
ExceptionTypes.BAD_REQUEST
|
|
11211
|
+
400 /* BAD_REQUEST */
|
|
11247
11212
|
);
|
|
11248
11213
|
}
|
|
11249
11214
|
if (typeof value === "boolean") {
|
|
@@ -11255,14 +11220,12 @@ function booleanTransform({ value, key }) {
|
|
|
11255
11220
|
if (trimmed === "false") return false;
|
|
11256
11221
|
throw new BaseException(
|
|
11257
11222
|
(lang) => ExceptionMessages.BOOLEAN_INVALID_MESSAGE(key, lang),
|
|
11258
|
-
400 /* BAD_REQUEST
|
|
11259
|
-
ExceptionTypes.BAD_REQUEST
|
|
11223
|
+
400 /* BAD_REQUEST */
|
|
11260
11224
|
);
|
|
11261
11225
|
}
|
|
11262
11226
|
throw new BaseException(
|
|
11263
11227
|
(lang) => ExceptionMessages.BOOLEAN_TYPE_MESSAGE(key, lang),
|
|
11264
|
-
400 /* BAD_REQUEST
|
|
11265
|
-
ExceptionTypes.BAD_REQUEST
|
|
11228
|
+
400 /* BAD_REQUEST */
|
|
11266
11229
|
);
|
|
11267
11230
|
}
|
|
11268
11231
|
function enumTransform({
|
|
@@ -11279,8 +11242,7 @@ function enumTransform({
|
|
|
11279
11242
|
}
|
|
11280
11243
|
throw new BaseException(
|
|
11281
11244
|
(lang) => ExceptionMessages.ENUM_INVALID_MESSAGE(key, enumValues, lang),
|
|
11282
|
-
400 /* BAD_REQUEST
|
|
11283
|
-
ExceptionTypes.BAD_REQUEST
|
|
11245
|
+
400 /* BAD_REQUEST */
|
|
11284
11246
|
);
|
|
11285
11247
|
}
|
|
11286
11248
|
function upperCaseTranform(value) {
|
|
@@ -11288,8 +11250,7 @@ function upperCaseTranform(value) {
|
|
|
11288
11250
|
if (typeof value !== "string")
|
|
11289
11251
|
throw new BaseException(
|
|
11290
11252
|
(lang) => ExceptionMessages.STRING_OR_NULL_MESSAGE(value, lang),
|
|
11291
|
-
400 /* BAD_REQUEST
|
|
11292
|
-
ExceptionTypes.BAD_REQUEST
|
|
11253
|
+
400 /* BAD_REQUEST */
|
|
11293
11254
|
);
|
|
11294
11255
|
return value.toUpperCase();
|
|
11295
11256
|
}
|
|
@@ -11298,8 +11259,7 @@ function lowerCaseTranform(value) {
|
|
|
11298
11259
|
if (typeof value !== "string")
|
|
11299
11260
|
throw new BaseException(
|
|
11300
11261
|
(lang) => ExceptionMessages.STRING_OR_NULL_MESSAGE(value, lang),
|
|
11301
|
-
400 /* BAD_REQUEST
|
|
11302
|
-
ExceptionTypes.BAD_REQUEST
|
|
11262
|
+
400 /* BAD_REQUEST */
|
|
11303
11263
|
);
|
|
11304
11264
|
return value.toLowerCase();
|
|
11305
11265
|
}
|
|
@@ -11515,7 +11475,6 @@ export {
|
|
|
11515
11475
|
ENV,
|
|
11516
11476
|
EXPIRE_DATES,
|
|
11517
11477
|
ExceptionMessages,
|
|
11518
|
-
ExceptionTypes,
|
|
11519
11478
|
FIELD_TRANSFORMER_REGISTRY,
|
|
11520
11479
|
FIELD_TYPE,
|
|
11521
11480
|
FIELD_VALIDATOR_REGISTRY,
|