equipped 5.0.0-beta.9 → 5.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +156 -0
  2. package/lib/bull/index.js +33 -44
  3. package/lib/cache/cache.d.ts +1 -0
  4. package/lib/cache/types/redis-cache.d.ts +1 -0
  5. package/lib/cache/types/redis-cache.js +8 -0
  6. package/lib/db/_instance.d.ts +2 -2
  7. package/lib/db/_instance.js +9 -25
  8. package/lib/db/mongoose/changes.d.ts +1 -26
  9. package/lib/db/mongoose/changes.js +7 -20
  10. package/lib/db/mongoose/index.d.ts +2 -27
  11. package/lib/db/mongoose/index.js +8 -24
  12. package/lib/db/mongoose/query.d.ts +0 -25
  13. package/lib/errors/customError.js +2 -0
  14. package/lib/errors/types/accessTokenExpired.js +1 -1
  15. package/lib/errors/types/badRequestError.js +1 -1
  16. package/lib/errors/types/notAuthenticatedError.js +1 -1
  17. package/lib/errors/types/notAuthorizedError.js +1 -1
  18. package/lib/errors/types/notFoundError.js +1 -1
  19. package/lib/errors/types/refreshTokenMisusedError.js +1 -1
  20. package/lib/errors/types/validationError.js +1 -1
  21. package/lib/events/index.js +1 -3
  22. package/lib/events/kafka.d.ts +1 -1
  23. package/lib/events/kafka.js +19 -25
  24. package/lib/events/rabbit.d.ts +1 -1
  25. package/lib/events/rabbit.js +9 -22
  26. package/lib/instance/index.d.ts +2 -1
  27. package/lib/instance/index.js +28 -41
  28. package/lib/instance/settings.d.ts +2 -2
  29. package/lib/instance/settings.js +4 -4
  30. package/lib/listeners/emitter.d.ts +6 -3
  31. package/lib/listeners/emitter.js +97 -109
  32. package/lib/scripts/json-schema.d.ts +2 -1
  33. package/lib/scripts/json-schema.js +29 -22
  34. package/lib/server/impls/base.d.ts +18 -7
  35. package/lib/server/impls/base.js +177 -80
  36. package/lib/server/impls/express.d.ts +0 -1
  37. package/lib/server/impls/express.js +16 -34
  38. package/lib/server/impls/fastify.d.ts +2 -4
  39. package/lib/server/impls/fastify.js +21 -39
  40. package/lib/server/middlewares/errorHandler.d.ts +2 -2
  41. package/lib/server/middlewares/notFoundHandler.d.ts +2 -2
  42. package/lib/server/middlewares/parseAuthUser.d.ts +2 -2
  43. package/lib/server/middlewares/requireAuthUser.d.ts +2 -2
  44. package/lib/server/middlewares/requireAuthUser.js +2 -2
  45. package/lib/server/middlewares/requireRefreshUser.d.ts +2 -2
  46. package/lib/server/middlewares/requireRefreshUser.js +2 -2
  47. package/lib/server/requests.d.ts +10 -7
  48. package/lib/server/requests.js +27 -21
  49. package/lib/server/routes.d.ts +4 -2
  50. package/lib/server/routes.js +33 -33
  51. package/lib/server/types.d.ts +19 -9
  52. package/lib/server/types.js +3 -0
  53. package/lib/storage/index.d.ts +0 -1
  54. package/lib/structure/baseEntity.js +7 -9
  55. package/lib/types/index.d.ts +2 -2
  56. package/lib/utils/auth.d.ts +5 -5
  57. package/lib/utils/authUser.d.ts +3 -2
  58. package/lib/utils/media.d.ts +0 -1
  59. package/lib/utils/utils.d.ts +1 -0
  60. package/lib/utils/utils.js +9 -0
  61. package/lib/validations/index.d.ts +79 -85
  62. package/lib/validations/index.js +4 -4
  63. package/package.json +24 -25
@@ -1,29 +1,32 @@
1
1
  import * as Validate from 'valleyed';
2
+ import { ExtractI } from 'valleyed/lib/api/base';
3
+ import { VCore } from 'valleyed/lib/api/core';
4
+ import { VObject } from 'valleyed/lib/api/objects';
2
5
  import { StorageFile } from '../storage';
3
6
  type Phone = {
4
7
  code: string;
5
8
  number: string;
6
9
  };
7
10
  export declare const Schema: {
8
- is: <T>(value: T) => Validate.VCore<T>;
9
- in: <T_1>(values: readonly T_1[], comparer?: ((val: any, arrayItem: T_1) => boolean) | undefined) => Validate.VCore<T_1>;
10
- or: <T_2 extends Validate.VCore<any>[]>(options: T_2, err?: string | undefined) => import("valleyed/lib/api/junctions").VOr<T_2>;
11
+ is: <T>(value: T, comparer?: (val: any, comp: T) => boolean, err?: string) => Validate.VCore<T>;
12
+ in: <T>(values: Readonly<T[]>, comparer?: (val: any, arrayItem: T) => boolean, err?: string) => Validate.VCore<T>;
13
+ or: <T extends Validate.VCore<any>[]>(options: T, err?: string | undefined) => import("valleyed/lib/api/junctions").VOr<T>;
11
14
  and: <I>(options: Validate.VCore<I>[], err?: string | undefined) => import("valleyed/lib/api/junctions").VAnd<I>;
12
15
  string: (err?: string | undefined) => import("valleyed/lib/api/strings").VString;
13
16
  discriminate: <D extends Record<string, Validate.VCore<any>>>(discriminator: (val: import("valleyed/lib/api/base").ExtractI<D[keyof D]>) => string, schemas: D, err?: string | undefined) => import("valleyed/lib/api/junctions").VDiscriminator<D>;
14
17
  number: (err?: string | undefined) => import("valleyed/lib/api/numbers").VNumber;
15
18
  boolean: (err?: string | undefined) => import("valleyed/lib/api/booleans").VBoolean;
16
- time: <T_3 extends Validate.Timeable = Validate.Timeable>(err?: string | undefined) => import("valleyed/lib/api/times").VTime<T_3>;
19
+ time: <T extends import("valleyed/lib/api/times").Timeable = import("valleyed/lib/api/times").Timeable>(err?: string | undefined) => import("valleyed/lib/api/times").VTime<T>;
17
20
  file: (err?: string | undefined) => import("valleyed/lib/api/files").VFile;
18
- array: <I_1>(comparer: Validate.VCore<I_1>, err?: string | undefined) => import("valleyed/lib/api/arrays").VArray<I_1>;
19
- tuple: <T_4 extends readonly Validate.VCore<any>[]>(schema: readonly [...T_4], err?: string | undefined) => import("valleyed/lib/api/tuples").VTuple<T_4>;
20
- object: <T_5 extends Record<string, Validate.VCore<any>>>(schema: T_5, trim?: boolean | undefined, err?: string | undefined) => import("valleyed/lib/api/objects").VObject<T_5>;
21
+ array: <I>(comparer: Validate.VCore<I>, err?: string | undefined) => import("valleyed/lib/api/arrays").VArray<I>;
22
+ tuple: <T extends ReadonlyArray<Validate.VCore<any>>>(schema: readonly [...T], err?: string | undefined) => import("valleyed/lib/api/tuples").VTuple<T>;
23
+ object: <T extends Record<string, Validate.VCore<any>>>(schema: T, trim?: boolean | undefined, err?: string | undefined) => VObject<T>;
21
24
  record: <VI>(vCom: Validate.VCore<VI>, err?: string | undefined) => import("valleyed/lib/api/records").VRecord<VI>;
22
- map: <KI, VI_1>(kCom: Validate.VCore<KI>, vCom: Validate.VCore<VI_1>, err?: string | undefined) => import("valleyed/lib/api/records").VMap<KI, VI_1>;
23
- null: (err?: string | undefined) => Validate.VCore<null>;
24
- undefined: (err?: string | undefined) => Validate.VCore<undefined>;
25
- instanceof: <T_6>(classDef: new () => T_6, err?: string | undefined) => Validate.VCore<T_6>;
26
- any: <T_7 = any>() => Validate.VCore<T_7>;
25
+ map: <KI, VI>(kCom: Validate.VCore<KI>, vCom: Validate.VCore<VI>, err?: string | undefined) => import("valleyed/lib/api/records").VMap<KI, VI>;
26
+ null: (err?: string) => Validate.VCore<null>;
27
+ undefined: (err?: string) => Validate.VCore<undefined>;
28
+ instanceof: <T>(classDef: new () => T, err?: string) => Validate.VCore<T>;
29
+ any: <T = any>() => Validate.VCore<T>;
27
30
  force: {
28
31
  string: (err?: string | undefined) => import("valleyed/lib/api/strings").VString;
29
32
  number: (err?: string | undefined) => import("valleyed/lib/api/numbers").VNumber;
@@ -37,25 +40,25 @@ export declare const Validation: {
37
40
  Validator: typeof Validate.Validator;
38
41
  VCore: typeof Validate.VCore;
39
42
  v: {
40
- is: <T>(value: T) => Validate.VCore<T>;
41
- in: <T_1>(values: readonly T_1[], comparer?: ((val: any, arrayItem: T_1) => boolean) | undefined) => Validate.VCore<T_1>;
42
- or: <T_2 extends Validate.VCore<any>[]>(options: T_2, err?: string | undefined) => import("valleyed/lib/api/junctions").VOr<T_2>;
43
+ is: <T>(value: T, comparer?: (val: any, comp: T) => boolean, err?: string) => Validate.VCore<T>;
44
+ in: <T>(values: Readonly<T[]>, comparer?: (val: any, arrayItem: T) => boolean, err?: string) => Validate.VCore<T>;
45
+ or: <T extends Validate.VCore<any>[]>(options: T, err?: string | undefined) => import("valleyed/lib/api/junctions").VOr<T>;
43
46
  and: <I>(options: Validate.VCore<I>[], err?: string | undefined) => import("valleyed/lib/api/junctions").VAnd<I>;
44
47
  string: (err?: string | undefined) => import("valleyed/lib/api/strings").VString;
45
48
  discriminate: <D extends Record<string, Validate.VCore<any>>>(discriminator: (val: import("valleyed/lib/api/base").ExtractI<D[keyof D]>) => string, schemas: D, err?: string | undefined) => import("valleyed/lib/api/junctions").VDiscriminator<D>;
46
49
  number: (err?: string | undefined) => import("valleyed/lib/api/numbers").VNumber;
47
50
  boolean: (err?: string | undefined) => import("valleyed/lib/api/booleans").VBoolean;
48
- time: <T_3 extends Validate.Timeable = Validate.Timeable>(err?: string | undefined) => import("valleyed/lib/api/times").VTime<T_3>;
51
+ time: <T extends import("valleyed/lib/api/times").Timeable = import("valleyed/lib/api/times").Timeable>(err?: string | undefined) => import("valleyed/lib/api/times").VTime<T>;
49
52
  file: (err?: string | undefined) => import("valleyed/lib/api/files").VFile;
50
- array: <I_1>(comparer: Validate.VCore<I_1>, err?: string | undefined) => import("valleyed/lib/api/arrays").VArray<I_1>;
51
- tuple: <T_4 extends readonly Validate.VCore<any>[]>(schema: readonly [...T_4], err?: string | undefined) => import("valleyed/lib/api/tuples").VTuple<T_4>;
52
- object: <T_5 extends Record<string, Validate.VCore<any>>>(schema: T_5, trim?: boolean | undefined, err?: string | undefined) => import("valleyed/lib/api/objects").VObject<T_5>;
53
+ array: <I>(comparer: Validate.VCore<I>, err?: string | undefined) => import("valleyed/lib/api/arrays").VArray<I>;
54
+ tuple: <T extends ReadonlyArray<Validate.VCore<any>>>(schema: readonly [...T], err?: string | undefined) => import("valleyed/lib/api/tuples").VTuple<T>;
55
+ object: <T extends Record<string, Validate.VCore<any>>>(schema: T, trim?: boolean | undefined, err?: string | undefined) => VObject<T>;
53
56
  record: <VI>(vCom: Validate.VCore<VI>, err?: string | undefined) => import("valleyed/lib/api/records").VRecord<VI>;
54
- map: <KI, VI_1>(kCom: Validate.VCore<KI>, vCom: Validate.VCore<VI_1>, err?: string | undefined) => import("valleyed/lib/api/records").VMap<KI, VI_1>;
55
- null: (err?: string | undefined) => Validate.VCore<null>;
56
- undefined: (err?: string | undefined) => Validate.VCore<undefined>;
57
- instanceof: <T_6>(classDef: new () => T_6, err?: string | undefined) => Validate.VCore<T_6>;
58
- any: <T_7 = any>() => Validate.VCore<T_7>;
57
+ map: <KI, VI>(kCom: Validate.VCore<KI>, vCom: Validate.VCore<VI>, err?: string | undefined) => import("valleyed/lib/api/records").VMap<KI, VI>;
58
+ null: (err?: string) => Validate.VCore<null>;
59
+ undefined: (err?: string) => Validate.VCore<undefined>;
60
+ instanceof: <T>(classDef: new () => T, err?: string) => Validate.VCore<T>;
61
+ any: <T = any>() => Validate.VCore<T>;
59
62
  force: {
60
63
  string: (err?: string | undefined) => import("valleyed/lib/api/strings").VString;
61
64
  number: (err?: string | undefined) => import("valleyed/lib/api/numbers").VNumber;
@@ -63,48 +66,47 @@ export declare const Validation: {
63
66
  time: (err?: string | undefined) => import("valleyed/lib/api/times").VTime<Date>;
64
67
  };
65
68
  };
66
- isEqualTo: <Type>(compare: Type, comparer?: ((val: any, compare: Type) => boolean) | undefined, error?: string | undefined) => Validate.Rule<Type>;
67
- isNotEqualTo: <Compare, Type_1>(compare: Compare, comparer?: ((val: Type_1, compare: Compare) => boolean) | undefined, error?: string | undefined) => Validate.Rule<Type_1>;
68
- arrayContains: <Type_2>(array: readonly Type_2[], comparer?: ((val: any, arrayItem: Type_2) => boolean) | undefined, error?: string | undefined) => Validate.Rule<Type_2>;
69
- arrayNotContains: <Compare_1, Type_3>(array: readonly Compare_1[], comparer?: ((val: Type_3, arrayItem: Compare_1) => boolean) | undefined, error?: string | undefined) => Validate.Rule<Type_3>;
70
- isString: (error?: string | undefined) => Validate.Rule<any>;
71
- isLengthOf: (length: number, stripHTMLTags?: boolean | undefined, error?: string | undefined) => Validate.Rule<string>;
72
- isMinOf: (length: number, stripHTMLTags?: boolean | undefined, error?: string | undefined) => Validate.Rule<string>;
73
- isMaxOf: (length: number, stripHTMLTags?: boolean | undefined, error?: string | undefined) => Validate.Rule<string>;
74
- isEmail: (error?: string | undefined) => Validate.Rule<string>;
75
- isUrl: (error?: string | undefined) => Validate.Rule<string>;
76
- isNumber: (error?: string | undefined) => Validate.Rule<any>;
77
- isInt: (error?: string | undefined) => Validate.Rule<any>;
78
- isMoreThan: (compare: number, error?: string | undefined) => Validate.Rule<number>;
79
- isMoreThanOrEqualTo: (compare: number, error?: string | undefined) => Validate.Rule<number>;
80
- isLessThan: (compare: number, error?: string | undefined) => Validate.Rule<number>;
81
- isLessThanOrEqualTo: (compare: number, error?: string | undefined) => Validate.Rule<number>;
82
- isArray: (error?: string | undefined) => Validate.Rule<any>;
83
- hasLengthOf: <Type_4>(length: number, error?: string | undefined) => Validate.Rule<Type_4[]>;
84
- hasMinOf: <Type_5>(length: number, error?: string | undefined) => Validate.Rule<Type_5[]>;
85
- hasMaxOf: <Type_6>(length: number, error?: string | undefined) => Validate.Rule<Type_6[]>;
86
- isArrayOf: <Type_7>(comparer: (cur: Type_7, idx: number) => boolean, error?: string | undefined) => Validate.Rule<Type_7[]>;
87
- isUndefined: (error?: string | undefined) => Validate.Rule<undefined>;
88
- isNull: (error?: string | undefined) => Validate.Rule<null>;
89
- isBoolean: (error?: string | undefined) => Validate.Rule<boolean>;
90
- isInstanceOf: <T>(classDef: new () => T, error?: string | undefined) => Validate.Rule<T>;
69
+ isEqualTo: <Type>(compare: Type, comparer?: (val: any, compare: Type) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type>;
70
+ isNotEqualTo: <Compare, Type>(compare: Compare, comparer?: (val: Type, compare: Compare) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type>;
71
+ arrayContains: <Type>(array: Readonly<Type[]>, comparer?: (val: any, arrayItem: Type) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type>;
72
+ arrayNotContains: <Compare, Type>(array: Readonly<Compare[]>, comparer?: (val: Type, arrayItem: Compare) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type>;
73
+ isString: (error?: string) => import("valleyed/lib/utils/rules").Rule<any>;
74
+ isLengthOf: (length: number, stripHTMLTags?: boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
75
+ isMinOf: (length: number, stripHTMLTags?: boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
76
+ isMaxOf: (length: number, stripHTMLTags?: boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
77
+ isEmail: (error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
78
+ isUrl: (error?: string) => import("valleyed/lib/utils/rules").Rule<string>;
79
+ isNumber: (error?: string) => import("valleyed/lib/utils/rules").Rule<any>;
80
+ isInt: (error?: string) => import("valleyed/lib/utils/rules").Rule<any>;
81
+ isMoreThan: (compare: number, error?: string) => import("valleyed/lib/utils/rules").Rule<number>;
82
+ isMoreThanOrEqualTo: (compare: number, error?: string) => import("valleyed/lib/utils/rules").Rule<number>;
83
+ isLessThan: (compare: number, error?: string) => import("valleyed/lib/utils/rules").Rule<number>;
84
+ isLessThanOrEqualTo: (compare: number, error?: string) => import("valleyed/lib/utils/rules").Rule<number>;
85
+ isArray: (error?: string) => import("valleyed/lib/utils/rules").Rule<any>;
86
+ hasLengthOf: <Type>(length: number, error?: string) => import("valleyed/lib/utils/rules").Rule<Type[]>;
87
+ hasMinOf: <Type>(length: number, error?: string) => import("valleyed/lib/utils/rules").Rule<Type[]>;
88
+ hasMaxOf: <Type>(length: number, error?: string) => import("valleyed/lib/utils/rules").Rule<Type[]>;
89
+ isArrayOf: <Type>(comparer: (cur: Type, idx: number) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Type[]>;
90
+ isUndefined: (error?: string) => import("valleyed/lib/utils/rules").Rule<undefined>;
91
+ isNull: (error?: string) => import("valleyed/lib/utils/rules").Rule<null>;
92
+ isBoolean: (error?: string) => import("valleyed/lib/utils/rules").Rule<boolean>;
93
+ isInstanceOf: <T>(classDef: new () => T, error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
91
94
  fileMimeTypes: string[];
92
95
  videoMimeTypes: string[];
93
96
  audioMimeTypes: string[];
94
97
  imageMimeTypes: string[];
95
- isImage: (error?: string | undefined) => Validate.Rule<import("valleyed/lib/types").File>;
96
- isAudio: (error?: string | undefined) => Validate.Rule<import("valleyed/lib/types").File>;
97
- isVideo: (error?: string | undefined) => Validate.Rule<import("valleyed/lib/types").File>;
98
- isFile: (error?: string | undefined) => Validate.Rule<import("valleyed/lib/types").File>;
99
- isTuple: <T_1 extends readonly ((v: any, idx: number) => boolean)[]>(comparer: readonly [...T_1], error?: string | undefined) => Validate.Rule<{ [K in keyof T_1]: T_1[K] extends (v: infer V, idx: number) => boolean ? V : never; }>;
100
- isRecord: <V_1>(com: (cur: V_1) => boolean, error?: string | undefined) => Validate.Rule<Record<string, V_1>>;
101
- isMap: <K_1, V_2>(kCom: (cur: K_1) => boolean, vCom: (cur: V_2) => boolean, error?: string | undefined) => Validate.Rule<Map<K_1, V_2>>;
102
- isCustom: <T_8>(validity: (v: T_8) => boolean, error?: string | undefined) => Validate.Rule<T_8>;
103
- isTime: <T_9 extends Validate.Timeable>(error?: string | undefined) => Validate.Rule<T_9>;
104
- isLaterThan: <T_10 extends Validate.Timeable>(compare: Validate.Timeable, error?: string | undefined) => Validate.Rule<T_10>;
105
- isEarlierThan: <T_11 extends Validate.Timeable>(compare: Validate.Timeable, error?: string | undefined) => Validate.Rule<T_11>;
98
+ isImage: (error?: string) => import("valleyed/lib/utils/rules").Rule<import("valleyed/lib/types").File>;
99
+ isAudio: (error?: string) => import("valleyed/lib/utils/rules").Rule<import("valleyed/lib/types").File>;
100
+ isVideo: (error?: string) => import("valleyed/lib/utils/rules").Rule<import("valleyed/lib/types").File>;
101
+ isFile: (error?: string) => import("valleyed/lib/utils/rules").Rule<import("valleyed/lib/types").File>;
102
+ isTuple: <T extends ReadonlyArray<(v: any, idx: number) => boolean>>(comparer: Validate.GetMap<T>, error?: string) => import("valleyed/lib/utils/rules").Rule<{ [K in keyof T]: T[K] extends (v: infer V, idx: number) => boolean ? V : never; }>;
103
+ isRecord: <V>(com: (cur: V) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Record<string, V>>;
104
+ isMap: <K, V>(kCom: (cur: K) => boolean, vCom: (cur: V) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<Map<K, V>>;
105
+ isCustom: <T>(validity: (v: T) => boolean, error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
106
+ isTime: <T extends Validate.Timeable>(error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
107
+ isLaterThan: <T extends Validate.Timeable>(compare: Validate.Timeable, error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
108
+ isEarlierThan: <T extends Validate.Timeable>(compare: Validate.Timeable, error?: string) => import("valleyed/lib/utils/rules").Rule<T>;
106
109
  ClassPropertiesWrapper: typeof Validate.ClassPropertiesWrapper;
107
- A: typeof Validate.A;
108
110
  Differ: typeof Validate.Differ;
109
111
  capitalize: (text: string) => string;
110
112
  stripHTML: (html: string) => string;
@@ -113,48 +115,40 @@ export declare const Validation: {
113
115
  original: string;
114
116
  normalized: string;
115
117
  }[];
116
- formatNumber: (num: number, dp?: number | undefined) => string;
118
+ formatNumber: (num: number, dp?: number) => string;
117
119
  pluralize: (count: number, singular: string, plural: string) => string;
118
120
  getRandomValue: () => string;
119
- groupBy: <Type_8, Unique extends string | number>(array: Type_8[], func: (item: Type_8) => Unique) => {
121
+ groupBy: <Type, Unique extends string | number>(array: Array<Type>, func: (item: Type) => Unique) => {
120
122
  key: Unique;
121
- values: Type_8[];
123
+ values: Type[];
122
124
  }[];
123
125
  getAlphabet: (num: number) => string;
124
- addToArray: <T_12>(array: T_12[], item: T_12, getKey: (a: T_12) => any, getComparer: (a: T_12) => string | number, asc?: boolean | undefined) => T_12[];
126
+ addToArray: <T>(array: T[], item: T, getKey: (a: T) => any, getComparer: (a: T) => number | string, asc?: boolean) => T[];
125
127
  divideByZero: (num: number, den: number) => number;
126
128
  getPercentage: (num: number, den: number) => number;
127
- getRandomSample: <Type_9>(population: Type_9[], n: number) => Type_9[];
128
- shuffleArray: <Type_10>(array: Type_10[]) => Type_10[];
129
- chunkArray: <T_13>(arr: T_13[], size: number) => T_13[][];
129
+ getRandomSample: <Type>(population: Array<Type>, n: number) => Type[];
130
+ shuffleArray: <Type>(array: Array<Type>) => Type[];
131
+ chunkArray: <T>(arr: T[], size: number) => T[][];
132
+ wrapInTryCatch: <T>(fn: () => T, defaultValue?: T) => T | undefined;
130
133
  Geohash: typeof Validate.Geohash;
131
- isValid: <T_14>(value: T_14, ignored?: boolean | undefined) => {
134
+ isValid: <T>(value: T, ignored?: boolean) => {
132
135
  valid: true;
133
136
  errors: string[];
134
- value: T_14;
137
+ value: T;
135
138
  ignored: boolean;
136
139
  };
137
- isInvalid: <T_15>(errors: string[], value: T_15) => {
140
+ isInvalid: <T>(errors: string[], value: T) => {
138
141
  valid: false;
139
142
  errors: string[];
140
143
  value: unknown;
141
144
  ignored: boolean;
142
145
  };
143
- makeRule: <T_16>(func: Validate.Rule<T_16>) => Validate.Rule<T_16>;
144
- makeSanitizer: <T_17>(func: Validate.Sanitizer<T_17>) => (val: T_17) => T_17;
145
- check: <T_18>(value: T_18, rules: Validate.Rule<T_18>[], options?: Partial<Validate.Options> | undefined) => {
146
- valid: false;
147
- errors: string[];
148
- value: unknown;
149
- ignored: boolean;
150
- } | {
151
- valid: true;
152
- errors: string[];
153
- value: T_18;
154
- ignored: boolean;
155
- };
146
+ makeRule: <T>(func: Validate.Rule<T>) => Validate.Rule<T>;
147
+ makeSanitizer: <T>(func: Validate.Sanitizer<T>) => (val: T) => T;
148
+ check: <T>(value: T, rules: Validate.Rule<T>[], options?: Partial<Validate.Options>) => ReturnType<Validate.Rule<T>>;
156
149
  };
157
- export declare const validate: <T extends Record<string, Validate.VCore<any>>, S extends Validate.VCore<any> = Validate.VCore<any>>(schema: T | S, value: unknown) => any;
150
+ export declare function validate<T extends Record<string, VCore<any>>>(schema: T, value: unknown): ExtractI<VObject<T>>;
151
+ export declare function validate<T extends VCore<any>>(schema: T, value: unknown): ExtractI<T>;
158
152
  export declare const Hash: {
159
153
  hash: (password: string) => Promise<string>;
160
154
  compare: (plainPassword: string, hashed: string) => Promise<boolean>;
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Hash = exports.validate = exports.Validation = exports.Schema = void 0;
26
+ exports.Hash = exports.Validation = exports.Schema = void 0;
27
+ exports.validate = validate;
27
28
  const bcrypt = __importStar(require("bcryptjs"));
28
29
  const Validate = __importStar(require("valleyed"));
29
30
  const errors_1 = require("../errors");
@@ -47,7 +48,7 @@ const file = Validate.v.file;
47
48
  Validate.v.file = (...args) => file(...args).addRule(isNotTruncated());
48
49
  exports.Schema = Validate.v;
49
50
  exports.Validation = { ...Validate, isNotTruncated, isValidPhone };
50
- const validate = (schema, value) => {
51
+ function validate(schema, value) {
51
52
  const validator = schema instanceof Validate.VCore ? schema : Validate.v.object(schema);
52
53
  const validity = validator.parse(value);
53
54
  if (validity.valid)
@@ -66,8 +67,7 @@ const validate = (schema, value) => {
66
67
  }), {});
67
68
  throw new errors_1.ValidationError(Object.entries(errorsObject)
68
69
  .map(([key, value]) => ({ field: key, messages: value })));
69
- };
70
- exports.validate = validate;
70
+ }
71
71
  const hash = async (password) => {
72
72
  password = password.trim();
73
73
  if (!password)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "equipped",
3
- "version": "5.0.0-beta.9",
3
+ "version": "5.0.0-rc.2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "main": "lib/index.js",
@@ -18,7 +18,7 @@
18
18
  "devDependencies": {
19
19
  "@commitlint/cli": "^19.3.0",
20
20
  "@commitlint/config-conventional": "^19.2.2",
21
- "@stylistic/eslint-plugin": "^2.1.0",
21
+ "@stylistic/eslint-plugin": "^2.4.0",
22
22
  "@types/amqplib": "^0.10.5",
23
23
  "@types/bcryptjs": "^2.4.6",
24
24
  "@types/bull": "^3.15.9",
@@ -26,63 +26,62 @@
26
26
  "@types/express": "^4.17.21",
27
27
  "@types/express-fileupload": "^1.5.0",
28
28
  "@types/jsonwebtoken": "^9.0.6",
29
- "@types/node": "^20.12.12",
29
+ "@types/node": "^22.0.0",
30
30
  "@types/pug": "^2.0.10",
31
31
  "@types/supertest": "^6.0.2",
32
- "@typescript-eslint/eslint-plugin": "^7.10.0",
33
- "@typescript-eslint/parser": "^7.10.0",
34
- "eslint": "^9.3.0",
35
- "eslint-plugin-promise": "^6.1.1",
36
- "husky": "^9.0.11",
32
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
33
+ "@typescript-eslint/parser": "^7.18.0",
34
+ "eslint": "^9.8.0",
35
+ "eslint-plugin-promise": "^7.0.0",
36
+ "husky": "^9.1.4",
37
37
  "standard-version": "^9.5.0",
38
- "typescript": "^5.4.5"
38
+ "typescript": "^5.5.4"
39
39
  },
40
40
  "dependencies": {
41
41
  "@fastify/cookie": "^9.3.1",
42
42
  "@fastify/cors": "^9.0.1",
43
43
  "@fastify/formbody": "^7.4.0",
44
44
  "@fastify/helmet": "^11.1.1",
45
- "@fastify/multipart": "^8.2.0",
45
+ "@fastify/multipart": "^8.3.0",
46
46
  "@fastify/rate-limit": "^9.1.0",
47
47
  "@fastify/static": "^7.0.4",
48
- "@fastify/swagger": "^8.14.0",
49
- "@fastify/swagger-ui": "^3.0.0",
50
- "@wesleytodd/openapi": "^1.0.0",
48
+ "@fastify/swagger": "^8.15.0",
49
+ "@wesleytodd/openapi": "^1.1.0",
51
50
  "amqp-connection-manager": "^4.1.14",
52
51
  "amqplib": "^0.10.4",
53
52
  "axios": "^1.7.2",
54
53
  "bcryptjs": "^2.4.3",
55
- "bull": "^4.12.9",
54
+ "bull": "^4.16.0",
56
55
  "cookie-parser": "^1.4.6",
57
56
  "cors": "^2.8.5",
58
57
  "dotenv": "^16.4.5",
59
58
  "express": "^4.19.2",
60
- "express-fileupload": "^1.5.0",
61
- "express-rate-limit": "^7.2.0",
59
+ "express-fileupload": "^1.5.1",
60
+ "express-rate-limit": "^7.4.0",
62
61
  "express-slow-down": "^2.0.3",
63
- "fastify": "^4.27.0",
62
+ "fastify": "^4.28.1",
64
63
  "fastify-slow-down": "^1.2.2",
65
64
  "helmet": "^7.1.0",
66
65
  "json-schema-resolver": "^2.0.0",
67
66
  "jsonwebtoken": "^9.0.2",
68
67
  "jwks-rsa": "^3.1.0",
69
68
  "kafkajs": "^2.2.4",
70
- "mongoose": "^8.4.0",
69
+ "mongoose": "^8.5.2",
71
70
  "mongoose-lean-defaults": "^2.2.1",
72
71
  "mongoose-lean-getters": "^2.1.0",
73
72
  "mongoose-lean-virtuals": "^0.9.1",
74
73
  "music-metadata": "^7.14.0",
75
74
  "openapi-types": "^12.1.3",
76
- "path-to-regexp": "^6.2.2",
77
- "pino": "^9.1.0",
78
- "pino-http": "^10.1.0",
75
+ "path-to-regexp": "^7.1.0",
76
+ "pino": "^9.3.2",
77
+ "pino-http": "^10.2.0",
79
78
  "pug": "^3.0.3",
80
- "qs": "^6.12.1",
81
- "redis": "^4.6.14",
79
+ "qs": "^6.12.3",
80
+ "redis": "^4.7.0",
82
81
  "socket.io": "4.7.5",
83
82
  "supertest": "^7.0.0",
84
- "ts-oas": "^0.4.1",
85
- "valleyed": "4.2.11"
83
+ "ts-oas": "^0.4.4",
84
+ "valleyed": "4.3.1"
86
85
  },
87
86
  "repository": {
88
87
  "url": "git://github.com/kevinand11/equipped.git"