equipped 4.0.0-alpha-10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/lib/bull/index.d.ts +37 -0
  3. package/lib/bull/index.js +93 -0
  4. package/lib/cache/cache.d.ts +7 -0
  5. package/lib/cache/cache.js +6 -0
  6. package/lib/cache/types/redis-cache.d.ts +11 -0
  7. package/lib/cache/types/redis-cache.js +40 -0
  8. package/lib/emails/index.d.ts +14 -0
  9. package/lib/emails/index.js +13 -0
  10. package/lib/enums/index.d.ts +19 -0
  11. package/lib/enums/index.js +29 -0
  12. package/lib/enums/types.d.ts +36 -0
  13. package/lib/enums/types.js +22 -0
  14. package/lib/errors/customError.d.ts +14 -0
  15. package/lib/errors/customError.js +12 -0
  16. package/lib/errors/index.d.ts +10 -0
  17. package/lib/errors/index.js +26 -0
  18. package/lib/errors/types/accessTokenExpired.d.ts +5 -0
  19. package/lib/errors/types/accessTokenExpired.js +12 -0
  20. package/lib/errors/types/accountNotVerifiedError.d.ts +5 -0
  21. package/lib/errors/types/accountNotVerifiedError.js +12 -0
  22. package/lib/errors/types/badRequestError.d.ts +5 -0
  23. package/lib/errors/types/badRequestError.js +12 -0
  24. package/lib/errors/types/invalidToken.d.ts +5 -0
  25. package/lib/errors/types/invalidToken.js +12 -0
  26. package/lib/errors/types/notAuthenticatedError.d.ts +5 -0
  27. package/lib/errors/types/notAuthenticatedError.js +12 -0
  28. package/lib/errors/types/notAuthorizedError.d.ts +5 -0
  29. package/lib/errors/types/notAuthorizedError.js +12 -0
  30. package/lib/errors/types/notFoundError.d.ts +5 -0
  31. package/lib/errors/types/notFoundError.js +12 -0
  32. package/lib/errors/types/refreshTokenMisusedError.d.ts +5 -0
  33. package/lib/errors/types/refreshTokenMisusedError.js +12 -0
  34. package/lib/errors/types/validationError.d.ts +10 -0
  35. package/lib/errors/types/validationError.js +12 -0
  36. package/lib/events/events.d.ts +17 -0
  37. package/lib/events/events.js +26 -0
  38. package/lib/events/rabbit.d.ts +4 -0
  39. package/lib/events/rabbit.js +44 -0
  40. package/lib/exit.d.ts +1 -0
  41. package/lib/exit.js +25 -0
  42. package/lib/express/app.d.ts +16 -0
  43. package/lib/express/app.js +127 -0
  44. package/lib/express/controllers/index.d.ts +13 -0
  45. package/lib/express/controllers/index.js +76 -0
  46. package/lib/express/controllers/request.d.ts +31 -0
  47. package/lib/express/controllers/request.js +48 -0
  48. package/lib/express/index.d.ts +5 -0
  49. package/lib/express/index.js +20 -0
  50. package/lib/express/middlewares/errorHandler.d.ts +1 -0
  51. package/lib/express/middlewares/errorHandler.js +22 -0
  52. package/lib/express/middlewares/index.d.ts +4 -0
  53. package/lib/express/middlewares/index.js +20 -0
  54. package/lib/express/middlewares/notFoundHandler.d.ts +1 -0
  55. package/lib/express/middlewares/notFoundHandler.js +8 -0
  56. package/lib/express/middlewares/parseAuthUser.d.ts +1 -0
  57. package/lib/express/middlewares/parseAuthUser.js +15 -0
  58. package/lib/express/middlewares/requireAuthUser.d.ts +2 -0
  59. package/lib/express/middlewares/requireAuthUser.js +11 -0
  60. package/lib/express/middlewares/requireRefreshUser.d.ts +2 -0
  61. package/lib/express/middlewares/requireRefreshUser.js +14 -0
  62. package/lib/express/statusCodes.d.ts +16 -0
  63. package/lib/express/statusCodes.js +17 -0
  64. package/lib/index.d.ts +18 -0
  65. package/lib/index.js +45 -0
  66. package/lib/instance.d.ts +43 -0
  67. package/lib/instance.js +115 -0
  68. package/lib/listeners/emitter.d.ts +20 -0
  69. package/lib/listeners/emitter.js +132 -0
  70. package/lib/listeners/index.d.ts +1 -0
  71. package/lib/listeners/index.js +17 -0
  72. package/lib/logger/index.d.ts +16 -0
  73. package/lib/logger/index.js +25 -0
  74. package/lib/mongoose/changeStreams.d.ts +25 -0
  75. package/lib/mongoose/changeStreams.js +93 -0
  76. package/lib/mongoose/index.d.ts +4 -0
  77. package/lib/mongoose/index.js +24 -0
  78. package/lib/mongoose/query.d.ts +60 -0
  79. package/lib/mongoose/query.js +97 -0
  80. package/lib/storage/index.d.ts +18 -0
  81. package/lib/storage/index.js +2 -0
  82. package/lib/structure/baseEntity.d.ts +5 -0
  83. package/lib/structure/baseEntity.js +21 -0
  84. package/lib/structure/baseMapper.d.ts +4 -0
  85. package/lib/structure/baseMapper.js +6 -0
  86. package/lib/structure/index.d.ts +2 -0
  87. package/lib/structure/index.js +18 -0
  88. package/lib/utils/auth.d.ts +28 -0
  89. package/lib/utils/auth.js +65 -0
  90. package/lib/utils/authUser.d.ts +10 -0
  91. package/lib/utils/authUser.js +2 -0
  92. package/lib/utils/media.d.ts +2 -0
  93. package/lib/utils/media.js +14 -0
  94. package/lib/utils/tokens.d.ts +15 -0
  95. package/lib/utils/tokens.js +78 -0
  96. package/lib/utils/utils.d.ts +4 -0
  97. package/lib/utils/utils.js +16 -0
  98. package/lib/validations/index.d.ts +146 -0
  99. package/lib/validations/index.js +103 -0
  100. package/package.json +80 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ## [4.0.0-alpha-10](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.9...v4.0.0-alpha-10) (2023-02-16)
6
+
7
+ ## [4.0.0-alpha.9](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.8...v4.0.0-alpha.9) (2023-02-15)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * remove file type from validation ([5511b44](https://github.com/kevinand11/equipped/commit/5511b447a2d80af6cd65af7d222ea1b9126d3bc5))
13
+
14
+ ## [4.0.0-alpha.8](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.7...v4.0.0-alpha.8) (2023-02-14)
15
+
16
+
17
+ ### Features
18
+
19
+ * add isNotTruncated to file types ([4d013e1](https://github.com/kevinand11/equipped/commit/4d013e142301df7e98bbe96a8bf18d5fc3a10dc6))
20
+
21
+ ## [4.0.0-alpha.7](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.6...v4.0.0-alpha.7) (2023-02-14)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * update valleyed version ([638ea0a](https://github.com/kevinand11/equipped/commit/638ea0a2c91967ae897f83b8ea9da480dcd1a7bf))
27
+
28
+ ## [4.0.0-alpha.6](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.5...v4.0.0-alpha.6) (2023-02-14)
29
+
30
+ ## [4.0.0-alpha.5](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.4...v4.0.0-alpha.5) (2023-02-14)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * controllers undefined ([f5b77aa](https://github.com/kevinand11/equipped/commit/f5b77aa7ca0d93eed57b474c2e9dd729b3faa7aa))
36
+
37
+ ## [4.0.0-alpha.4](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.3...v4.0.0-alpha.4) (2023-02-14)
38
+
39
+ ## [4.0.0-alpha.3](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2023-02-14)
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * rules types ([2d332c8](https://github.com/kevinand11/equipped/commit/2d332c8ce33caf9962c80ba1984f9c04be8148cf))
45
+
46
+ ## [4.0.0-alpha.2](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.1...v4.0.0-alpha.2) (2023-02-14)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * add test command ([4782e3e](https://github.com/kevinand11/equipped/commit/4782e3ec5be379885724404a3146a7f060086431))
52
+
53
+ ## 4.0.0-alpha.1 (2023-02-14)
54
+
55
+
56
+ ### Features
57
+
58
+ * init repo ([6d1d857](https://github.com/kevinand11/equipped/commit/6d1d857947267830f7b2228864ca3032b7bc0a72))
59
+
60
+
61
+ ### Bug Fixes
62
+
63
+ * change build command ([434b079](https://github.com/kevinand11/equipped/commit/434b0791d81077e2498d23455b10e89ee2f7d299))
64
+ * validation ([07c66b6](https://github.com/kevinand11/equipped/commit/07c66b63c39c337f18d152832bc886774e2071b6))
@@ -0,0 +1,37 @@
1
+ import { Enum, ICronLikeJobs, ICronTypes, IDelayedJobs } from '../enums/types';
2
+ type Cron = Enum<ICronTypes>;
3
+ type Delayed = Enum<IDelayedJobs>;
4
+ type CronLike = Enum<ICronLikeJobs>;
5
+ interface DelayedJobEvents extends Record<Delayed, {
6
+ type: Delayed;
7
+ data: any;
8
+ }> {
9
+ }
10
+ interface CronLikeJobsEvents extends Record<CronLike, {
11
+ type: CronLike;
12
+ data: any;
13
+ }> {
14
+ }
15
+ type DelayedJobEvent = DelayedJobEvents[keyof DelayedJobEvents];
16
+ type CronLikeJobEvent = CronLikeJobsEvents[keyof CronLikeJobsEvents];
17
+ type DelayedJobCallback = (data: DelayedJobEvent) => Promise<void>;
18
+ type CronCallback = (name: ICronTypes[keyof ICronTypes]) => Promise<void>;
19
+ type CronLikeCallback = (data: CronLikeJobEvent) => Promise<void>;
20
+ export declare class BullJob {
21
+ #private;
22
+ constructor();
23
+ addDelayedJob(data: DelayedJobEvent, delayInMs: number): Promise<string>;
24
+ addCronLikeJob(data: CronLikeJobEvent, cron: string, tz?: string): Promise<string>;
25
+ removeDelayedJob(jobId: string): Promise<void>;
26
+ removeCronLikeJob(jobKey: string): Promise<void>;
27
+ retryAllFailedJobs(): Promise<void>;
28
+ startProcessingQueues(crons: {
29
+ name: Cron | string;
30
+ cron: string;
31
+ }[], callbacks: {
32
+ onDelayed?: DelayedJobCallback;
33
+ onCron?: CronCallback;
34
+ onCronLike?: CronLikeCallback;
35
+ }): Promise<void>;
36
+ }
37
+ export {};
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ var _BullJob_instances, _a, _BullJob_queue, _BullJob_getNewId, _BullJob_addCronJob, _BullJob_cleanup;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.BullJob = void 0;
19
+ const bull_1 = __importDefault(require("bull"));
20
+ const instance_1 = require("../instance");
21
+ const utils_1 = require("../utils/utils");
22
+ var JobNames;
23
+ (function (JobNames) {
24
+ JobNames["CronJob"] = "CronJob";
25
+ JobNames["CronLikeJob"] = "CronLikeJob";
26
+ JobNames["DelayedJob"] = "DelayedJob";
27
+ })(JobNames || (JobNames = {}));
28
+ class BullJob {
29
+ constructor() {
30
+ _BullJob_instances.add(this);
31
+ _BullJob_queue.set(this, void 0);
32
+ __classPrivateFieldSet(this, _BullJob_queue, new bull_1.default(instance_1.Instance.get().settings.bullQueueName, instance_1.Instance.get().settings.redisURI), "f");
33
+ }
34
+ async addDelayedJob(data, delayInMs) {
35
+ const job = await __classPrivateFieldGet(this, _BullJob_queue, "f").add(JobNames.DelayedJob, data, {
36
+ jobId: __classPrivateFieldGet(BullJob, _a, "m", _BullJob_getNewId).call(BullJob),
37
+ delay: delayInMs,
38
+ removeOnComplete: true,
39
+ backoff: 1000,
40
+ attempts: 3
41
+ });
42
+ return job.id.toString();
43
+ }
44
+ async addCronLikeJob(data, cron, tz) {
45
+ const job = await __classPrivateFieldGet(this, _BullJob_queue, "f").add(JobNames.CronLikeJob, data, {
46
+ jobId: __classPrivateFieldGet(BullJob, _a, "m", _BullJob_getNewId).call(BullJob),
47
+ repeat: { cron, ...(tz ? { tz } : {}) },
48
+ removeOnComplete: true,
49
+ backoff: 1000,
50
+ attempts: 3
51
+ });
52
+ return job.opts?.repeat?.key ?? '';
53
+ }
54
+ async removeDelayedJob(jobId) {
55
+ const job = await __classPrivateFieldGet(this, _BullJob_queue, "f").getJob(jobId);
56
+ if (job)
57
+ await job.discard();
58
+ }
59
+ async removeCronLikeJob(jobKey) {
60
+ await __classPrivateFieldGet(this, _BullJob_queue, "f").removeRepeatableByKey(jobKey);
61
+ }
62
+ async retryAllFailedJobs() {
63
+ const failedJobs = await __classPrivateFieldGet(this, _BullJob_queue, "f").getFailed();
64
+ await Promise.all(failedJobs.map((job) => job.retry()));
65
+ }
66
+ async startProcessingQueues(crons, callbacks) {
67
+ await __classPrivateFieldGet(this, _BullJob_instances, "m", _BullJob_cleanup).call(this);
68
+ await Promise.all(crons.map(({ cron, name }) => __classPrivateFieldGet(this, _BullJob_instances, "m", _BullJob_addCronJob).call(this, name, cron)));
69
+ await Promise.all([
70
+ __classPrivateFieldGet(this, _BullJob_queue, "f").process(JobNames.DelayedJob, async (job) => await callbacks.onDelayed?.(job.data)),
71
+ __classPrivateFieldGet(this, _BullJob_queue, "f").process(JobNames.CronJob, async (job) => await callbacks.onCron?.(job.data.type)),
72
+ __classPrivateFieldGet(this, _BullJob_queue, "f").process(JobNames.CronLikeJob, async (job) => await callbacks.onCronLike?.(job.data))
73
+ ]);
74
+ }
75
+ }
76
+ exports.BullJob = BullJob;
77
+ _a = BullJob, _BullJob_queue = new WeakMap(), _BullJob_instances = new WeakSet(), _BullJob_getNewId = function _BullJob_getNewId() {
78
+ return [Date.now(), utils_1.Random.string()].join(':');
79
+ }, _BullJob_addCronJob = async function _BullJob_addCronJob(type, cron) {
80
+ const job = await __classPrivateFieldGet(this, _BullJob_queue, "f").add(JobNames.CronJob, { type }, {
81
+ repeat: { cron },
82
+ removeOnComplete: true,
83
+ backoff: 1000,
84
+ attempts: 3
85
+ });
86
+ return job.id.toString();
87
+ }, _BullJob_cleanup = async function _BullJob_cleanup() {
88
+ await this.retryAllFailedJobs();
89
+ const repeatableJobs = await __classPrivateFieldGet(this, _BullJob_queue, "f").getRepeatableJobs();
90
+ await Promise.all(repeatableJobs
91
+ .filter((job) => job.name === JobNames.CronJob)
92
+ .map((job) => __classPrivateFieldGet(this, _BullJob_queue, "f").removeRepeatableByKey(job.key)));
93
+ };
@@ -0,0 +1,7 @@
1
+ export declare abstract class Cache {
2
+ abstract connect(): Promise<void>;
3
+ abstract set(key: string, data: string, ttlInSecs: number): Promise<void>;
4
+ abstract setInTransaction(key: string, data: string, ttlInSecs: number): Promise<[string, string]>;
5
+ abstract get(key: string): Promise<string | null>;
6
+ abstract delete(key: string): Promise<void>;
7
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Cache = void 0;
4
+ class Cache {
5
+ }
6
+ exports.Cache = Cache;
@@ -0,0 +1,11 @@
1
+ import { createClient } from 'redis';
2
+ import { Cache } from '../cache';
3
+ export declare class RedisCache extends Cache {
4
+ client: ReturnType<typeof createClient>;
5
+ constructor(connection: string);
6
+ connect(): Promise<void>;
7
+ delete(key: string): Promise<void>;
8
+ get(key: string): Promise<string | null>;
9
+ set(key: string, data: string, ttlInSecs: number): Promise<void>;
10
+ setInTransaction(key: string, data: string, ttlInSecs: number): Promise<[string, string]>;
11
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RedisCache = void 0;
4
+ const redis_1 = require("redis");
5
+ const exit_1 = require("../../exit");
6
+ const instance_1 = require("../../instance");
7
+ const cache_1 = require("../cache");
8
+ class RedisCache extends cache_1.Cache {
9
+ constructor(connection) {
10
+ super();
11
+ this.client = (0, redis_1.createClient)({ url: connection });
12
+ this.client.on('error', async (error) => {
13
+ await instance_1.Instance.get().logger.error('Redis failed with error:', error);
14
+ process.exit(1);
15
+ });
16
+ (0, exit_1.addWaitBeforeExit)(() => this.client.quit());
17
+ }
18
+ async connect() {
19
+ await this.client.connect();
20
+ }
21
+ async delete(key) {
22
+ await this.client.del(key);
23
+ }
24
+ async get(key) {
25
+ return await this.client.get(key);
26
+ }
27
+ async set(key, data, ttlInSecs) {
28
+ if (ttlInSecs > 0)
29
+ await this.client.setEx(key, ttlInSecs, data);
30
+ else
31
+ this.client.set(key, data);
32
+ }
33
+ async setInTransaction(key, data, ttlInSecs) {
34
+ return await this.client.multi()
35
+ .get(key)
36
+ .setEx(key, ttlInSecs, data)
37
+ .exec();
38
+ }
39
+ }
40
+ exports.RedisCache = RedisCache;
@@ -0,0 +1,14 @@
1
+ import { Enum, IEmailsList } from '../enums/types';
2
+ export type PhoneText = {
3
+ to: string;
4
+ from: string;
5
+ content: string;
6
+ };
7
+ export type Email = {
8
+ to: string;
9
+ subject: string;
10
+ content: string;
11
+ from: Enum<IEmailsList>;
12
+ data: {};
13
+ };
14
+ export declare const readEmailFromPug: (filePath: string, data: Record<string, any>) => Promise<string>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.readEmailFromPug = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const pug_1 = __importDefault(require("pug"));
9
+ const readEmailFromPug = async (filePath, data) => {
10
+ const file = path_1.default.join('./', filePath);
11
+ return pug_1.default.renderFile(file, data);
12
+ };
13
+ exports.readEmailFromPug = readEmailFromPug;
@@ -0,0 +1,19 @@
1
+ import { IAuthRole, IAuthTypes, ICronLikeJobs, ICronTypes, IDelayedJobs, IEmailsList, IEventTypes } from './types';
2
+ type Keys = keyof {
3
+ AuthRole: IAuthRole;
4
+ AuthTypes: IAuthTypes;
5
+ EmailsList: IEmailsList;
6
+ EventTypes: IEventTypes;
7
+ DelayedJobs: IDelayedJobs;
8
+ CronLikeJobs: ICronLikeJobs;
9
+ CronTypes: ICronTypes;
10
+ };
11
+ export declare let AuthRole: IAuthRole;
12
+ export declare let AuthTypes: IAuthTypes;
13
+ export declare let EmailsList: IEmailsList;
14
+ export declare let EventTypes: IEventTypes;
15
+ export declare let DelayedJobs: IDelayedJobs;
16
+ export declare let CronLikeJobs: ICronLikeJobs;
17
+ export declare let CronTypes: ICronTypes;
18
+ export declare const makeEnum: <T extends Record<string, any>>(key: Keys, obj: T) => Readonly<T>;
19
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeEnum = exports.CronTypes = exports.CronLikeJobs = exports.DelayedJobs = exports.EventTypes = exports.EmailsList = exports.AuthTypes = exports.AuthRole = void 0;
4
+ const types_1 = require("./types");
5
+ exports.AuthRole = types_1.DefaultAuthRole;
6
+ exports.AuthTypes = types_1.DefaultAuthTypes;
7
+ exports.EmailsList = types_1.DefaultEmailsList;
8
+ exports.EventTypes = types_1.DefaultEventTypes;
9
+ exports.DelayedJobs = types_1.DefaultDelayedJobs;
10
+ exports.CronLikeJobs = types_1.DefaultCronLikeJobs;
11
+ exports.CronTypes = types_1.DefaultCronTypes;
12
+ const makeEnum = (key, obj) => {
13
+ if (key === 'AuthRole')
14
+ return exports.AuthRole = { ...exports.AuthRole, ...obj };
15
+ if (key === 'AuthTypes')
16
+ return exports.AuthTypes = { ...exports.AuthTypes, ...obj };
17
+ if (key === 'EmailsList')
18
+ return exports.EmailsList = { ...exports.EmailsList, ...obj };
19
+ if (key === 'EventTypes')
20
+ return exports.EventTypes = { ...exports.EventTypes, ...obj };
21
+ if (key === 'DelayedJobs')
22
+ return exports.DelayedJobs = { ...exports.DelayedJobs, ...obj };
23
+ if (key === 'CronLikeJobs')
24
+ return exports.CronLikeJobs = { ...exports.CronLikeJobs, ...obj };
25
+ if (key === 'CronTypes')
26
+ return exports.CronTypes = { ...exports.CronTypes, ...obj };
27
+ return obj;
28
+ };
29
+ exports.makeEnum = makeEnum;
@@ -0,0 +1,36 @@
1
+ type Rc<T> = T;
2
+ export declare const DefaultAuthRole: {};
3
+ export interface IAuthRole extends Rc<typeof DefaultAuthRole> {
4
+ }
5
+ export declare const DefaultAuthTypes: {
6
+ readonly google: "google";
7
+ readonly apple: "apple";
8
+ readonly email: "email";
9
+ readonly facebook: "facebook";
10
+ readonly twitter: "twitter";
11
+ readonly github: "github";
12
+ };
13
+ export interface IAuthTypes extends Rc<typeof DefaultAuthTypes> {
14
+ }
15
+ export declare const DefaultEmailsList: {};
16
+ export interface IEmailsList extends Rc<typeof DefaultEmailsList> {
17
+ }
18
+ export declare const DefaultEventTypes: {};
19
+ export interface IEventTypes extends Rc<typeof DefaultEventTypes> {
20
+ }
21
+ export declare const DefaultDelayedJobs: {};
22
+ export interface IDelayedJobs extends Rc<typeof DefaultDelayedJobs> {
23
+ }
24
+ export declare const DefaultCronLikeJobs: {};
25
+ export interface ICronLikeJobs extends Rc<typeof DefaultCronLikeJobs> {
26
+ }
27
+ export declare const DefaultCronTypes: {
28
+ readonly hourly: "hourly";
29
+ readonly daily: "daily";
30
+ readonly weekly: "weekly";
31
+ readonly monthly: "monthly";
32
+ };
33
+ export interface ICronTypes extends Rc<typeof DefaultCronTypes> {
34
+ }
35
+ export type Enum<T> = T[keyof T];
36
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultCronTypes = exports.DefaultCronLikeJobs = exports.DefaultDelayedJobs = exports.DefaultEventTypes = exports.DefaultEmailsList = exports.DefaultAuthTypes = exports.DefaultAuthRole = void 0;
4
+ exports.DefaultAuthRole = {};
5
+ exports.DefaultAuthTypes = {
6
+ google: 'google',
7
+ apple: 'apple',
8
+ email: 'email',
9
+ facebook: 'facebook',
10
+ twitter: 'twitter',
11
+ github: 'github'
12
+ };
13
+ exports.DefaultEmailsList = {};
14
+ exports.DefaultEventTypes = {};
15
+ exports.DefaultDelayedJobs = {};
16
+ exports.DefaultCronLikeJobs = {};
17
+ exports.DefaultCronTypes = {
18
+ hourly: 'hourly',
19
+ daily: 'daily',
20
+ weekly: 'weekly',
21
+ monthly: 'monthly'
22
+ };
@@ -0,0 +1,14 @@
1
+ import { SupportedStatusCodes } from '../express';
2
+ export declare abstract class CustomError extends Error {
3
+ abstract readonly statusCode: SupportedStatusCodes;
4
+ readonly message: string;
5
+ readonly serializedErrors: {
6
+ message: string;
7
+ field?: string;
8
+ }[];
9
+ isCustomError: boolean;
10
+ protected constructor(message: string, serializedErrors: {
11
+ message: string;
12
+ field?: string;
13
+ }[]);
14
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomError = void 0;
4
+ class CustomError extends Error {
5
+ constructor(message, serializedErrors) {
6
+ super(message);
7
+ this.isCustomError = true;
8
+ this.message = message;
9
+ this.serializedErrors = serializedErrors;
10
+ }
11
+ }
12
+ exports.CustomError = CustomError;
@@ -0,0 +1,10 @@
1
+ export * from './customError';
2
+ export * from './types/badRequestError';
3
+ export * from './types/notAuthenticatedError';
4
+ export * from './types/notAuthorizedError';
5
+ export * from './types/accountNotVerifiedError';
6
+ export * from './types/accessTokenExpired';
7
+ export * from './types/refreshTokenMisusedError';
8
+ export * from './types/invalidToken';
9
+ export * from './types/notFoundError';
10
+ export * from './types/validationError';
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./customError"), exports);
18
+ __exportStar(require("./types/badRequestError"), exports);
19
+ __exportStar(require("./types/notAuthenticatedError"), exports);
20
+ __exportStar(require("./types/notAuthorizedError"), exports);
21
+ __exportStar(require("./types/accountNotVerifiedError"), exports);
22
+ __exportStar(require("./types/accessTokenExpired"), exports);
23
+ __exportStar(require("./types/refreshTokenMisusedError"), exports);
24
+ __exportStar(require("./types/invalidToken"), exports);
25
+ __exportStar(require("./types/notFoundError"), exports);
26
+ __exportStar(require("./types/validationError"), exports);
@@ -0,0 +1,5 @@
1
+ import { CustomError } from '../customError';
2
+ export declare class AccessTokenExpired extends CustomError {
3
+ statusCode: 461;
4
+ constructor(message?: string);
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccessTokenExpired = void 0;
4
+ const customError_1 = require("../customError");
5
+ const express_1 = require("../../express");
6
+ class AccessTokenExpired extends customError_1.CustomError {
7
+ constructor(message = 'Access token expired') {
8
+ super(message, [{ message }]);
9
+ this.statusCode = express_1.StatusCodes.AccessTokenExpired;
10
+ }
11
+ }
12
+ exports.AccessTokenExpired = AccessTokenExpired;
@@ -0,0 +1,5 @@
1
+ import { CustomError } from '../customError';
2
+ export declare class AccountNotVerifiedError extends CustomError {
3
+ statusCode: 460;
4
+ constructor(message?: string);
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountNotVerifiedError = void 0;
4
+ const customError_1 = require("../customError");
5
+ const express_1 = require("../../express");
6
+ class AccountNotVerifiedError extends customError_1.CustomError {
7
+ constructor(message = 'Account not verified') {
8
+ super(message, [{ message }]);
9
+ this.statusCode = express_1.StatusCodes.AccountNotVerified;
10
+ }
11
+ }
12
+ exports.AccountNotVerifiedError = AccountNotVerifiedError;
@@ -0,0 +1,5 @@
1
+ import { CustomError } from '../customError';
2
+ export declare class BadRequestError extends CustomError {
3
+ statusCode: 400;
4
+ constructor(message: string);
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BadRequestError = void 0;
4
+ const customError_1 = require("../customError");
5
+ const express_1 = require("../../express");
6
+ class BadRequestError extends customError_1.CustomError {
7
+ constructor(message) {
8
+ super(message, [{ message }]);
9
+ this.statusCode = express_1.StatusCodes.BadRequest;
10
+ }
11
+ }
12
+ exports.BadRequestError = BadRequestError;
@@ -0,0 +1,5 @@
1
+ import { CustomError } from '../customError';
2
+ export declare class InvalidToken extends CustomError {
3
+ statusCode: 461;
4
+ constructor(message?: string);
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvalidToken = void 0;
4
+ const customError_1 = require("../customError");
5
+ const express_1 = require("../../express");
6
+ class InvalidToken extends customError_1.CustomError {
7
+ constructor(message = 'Token is either expired or invalid') {
8
+ super(message, [{ message }]);
9
+ this.statusCode = express_1.StatusCodes.AccessTokenExpired;
10
+ }
11
+ }
12
+ exports.InvalidToken = InvalidToken;
@@ -0,0 +1,5 @@
1
+ import { CustomError } from '../customError';
2
+ export declare class NotAuthenticatedError extends CustomError {
3
+ statusCode: 401;
4
+ constructor(message?: string);
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotAuthenticatedError = void 0;
4
+ const customError_1 = require("../customError");
5
+ const express_1 = require("../../express");
6
+ class NotAuthenticatedError extends customError_1.CustomError {
7
+ constructor(message = 'Not authenticated') {
8
+ super(message, [{ message }]);
9
+ this.statusCode = express_1.StatusCodes.NotAuthenticated;
10
+ }
11
+ }
12
+ exports.NotAuthenticatedError = NotAuthenticatedError;
@@ -0,0 +1,5 @@
1
+ import { CustomError } from '../customError';
2
+ export declare class NotAuthorizedError extends CustomError {
3
+ statusCode: 403;
4
+ constructor(message?: string);
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotAuthorizedError = void 0;
4
+ const customError_1 = require("../customError");
5
+ const express_1 = require("../../express");
6
+ class NotAuthorizedError extends customError_1.CustomError {
7
+ constructor(message = 'Not authorized') {
8
+ super(message, [{ message }]);
9
+ this.statusCode = express_1.StatusCodes.NotAuthorized;
10
+ }
11
+ }
12
+ exports.NotAuthorizedError = NotAuthorizedError;
@@ -0,0 +1,5 @@
1
+ import { CustomError } from '../customError';
2
+ export declare class NotFoundError extends CustomError {
3
+ statusCode: 404;
4
+ constructor(message?: string);
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotFoundError = void 0;
4
+ const customError_1 = require("../customError");
5
+ const express_1 = require("../../express");
6
+ class NotFoundError extends customError_1.CustomError {
7
+ constructor(message = 'Not found') {
8
+ super(message, [{ message }]);
9
+ this.statusCode = express_1.StatusCodes.NotFound;
10
+ }
11
+ }
12
+ exports.NotFoundError = NotFoundError;
@@ -0,0 +1,5 @@
1
+ import { CustomError } from '../customError';
2
+ export declare class RefreshTokenMisusedError extends CustomError {
3
+ statusCode: 462;
4
+ constructor(message?: string);
5
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RefreshTokenMisusedError = void 0;
4
+ const customError_1 = require("../customError");
5
+ const express_1 = require("../../express");
6
+ class RefreshTokenMisusedError extends customError_1.CustomError {
7
+ constructor(message = 'Refresh token misused') {
8
+ super(message, [{ message }]);
9
+ this.statusCode = express_1.StatusCodes.RefreshTokenMisused;
10
+ }
11
+ }
12
+ exports.RefreshTokenMisusedError = RefreshTokenMisusedError;
@@ -0,0 +1,10 @@
1
+ import { CustomError } from '../customError';
2
+ type Error = {
3
+ messages: string[];
4
+ field: string;
5
+ };
6
+ export declare class ValidationError extends CustomError {
7
+ statusCode: 422;
8
+ constructor(errors: Error[]);
9
+ }
10
+ export {};