@modular-rest/server 1.11.13 → 1.11.14

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 (112) hide show
  1. package/.nvmrc +1 -0
  2. package/.prettierrc.json +9 -0
  3. package/.releaserc.json +24 -0
  4. package/README.md +79 -94
  5. package/dist/index.js +79 -0
  6. package/docs/.keep +0 -0
  7. package/docs/system-access-type.md +26 -0
  8. package/package.json +58 -45
  9. package/src/application.ts +206 -0
  10. package/src/class/cms_trigger.ts +68 -0
  11. package/src/class/collection_definition.ts +134 -0
  12. package/src/class/combinator.ts +176 -0
  13. package/src/class/database_trigger.ts +99 -0
  14. package/src/class/db_schemas.ts +44 -0
  15. package/src/class/{directory.js → directory.ts} +40 -18
  16. package/src/class/paginator.ts +51 -0
  17. package/src/class/reply.ts +59 -0
  18. package/src/class/security.ts +250 -0
  19. package/src/class/trigger_operator.ts +142 -0
  20. package/src/class/user.ts +199 -0
  21. package/src/class/validator.ts +123 -0
  22. package/src/config.ts +122 -0
  23. package/src/defult-permissions.ts +31 -0
  24. package/src/events.ts +59 -0
  25. package/src/helper/data_insertion.ts +94 -0
  26. package/src/helper/presetup_services.ts +96 -0
  27. package/src/index.ts +146 -0
  28. package/src/middlewares.ts +75 -0
  29. package/src/play-test.ts +8 -0
  30. package/src/services/data_provider/router.ts +191 -0
  31. package/src/services/data_provider/service.ts +305 -0
  32. package/src/services/data_provider/typeCasters.ts +15 -0
  33. package/src/services/file/db.ts +29 -0
  34. package/src/services/file/router.ts +88 -0
  35. package/src/services/file/service.ts +387 -0
  36. package/src/services/functions/router.ts +34 -0
  37. package/src/services/functions/service.ts +203 -0
  38. package/src/services/jwt/router.ts +73 -0
  39. package/src/services/jwt/service.ts +139 -0
  40. package/src/services/user_manager/db.ts +87 -0
  41. package/src/services/user_manager/permissionManager.ts +49 -0
  42. package/src/services/user_manager/router.ts +193 -0
  43. package/src/services/user_manager/service.ts +698 -0
  44. package/tsconfig.json +16 -9
  45. package/typedoc.mjs +41 -0
  46. package/LICENSE +0 -21
  47. package/package-lock.json +0 -1373
  48. package/src/application.js +0 -239
  49. package/src/class/cms_trigger.js +0 -20
  50. package/src/class/collection_definition.js +0 -33
  51. package/src/class/combinator.js +0 -133
  52. package/src/class/database_trigger.js +0 -20
  53. package/src/class/db_schemas.js +0 -18
  54. package/src/class/paginator.js +0 -31
  55. package/src/class/reply.js +0 -37
  56. package/src/class/security.js +0 -141
  57. package/src/class/trigger_operator.js +0 -39
  58. package/src/class/user.js +0 -112
  59. package/src/class/validator.js +0 -91
  60. package/src/config.js +0 -67
  61. package/src/events.js +0 -15
  62. package/src/helper/data_insertion.js +0 -64
  63. package/src/helper/presetup_services.js +0 -31
  64. package/src/index.js +0 -66
  65. package/src/middlewares.js +0 -44
  66. package/src/services/data_provider/router.js +0 -552
  67. package/src/services/data_provider/service.js +0 -262
  68. package/src/services/data_provider/typeCasters.js +0 -10
  69. package/src/services/file/db.js +0 -29
  70. package/src/services/file/router.js +0 -92
  71. package/src/services/file/service.js +0 -231
  72. package/src/services/functions/router.js +0 -37
  73. package/src/services/functions/service.js +0 -74
  74. package/src/services/jwt/router.js +0 -82
  75. package/src/services/jwt/service.js +0 -37
  76. package/src/services/user_manager/db.js +0 -83
  77. package/src/services/user_manager/permissionManager.js +0 -43
  78. package/src/services/user_manager/router.js +0 -176
  79. package/src/services/user_manager/service.js +0 -377
  80. package/types/application.d.ts +0 -97
  81. package/types/class/cms_trigger.d.ts +0 -24
  82. package/types/class/collection_definition.d.ts +0 -36
  83. package/types/class/combinator.d.ts +0 -30
  84. package/types/class/database_trigger.d.ts +0 -28
  85. package/types/class/db_schemas.d.ts +0 -2
  86. package/types/class/directory.d.ts +0 -2
  87. package/types/class/paginator.d.ts +0 -8
  88. package/types/class/reply.d.ts +0 -8
  89. package/types/class/security.d.ts +0 -109
  90. package/types/class/trigger_operator.d.ts +0 -19
  91. package/types/class/user.d.ts +0 -24
  92. package/types/class/validator.d.ts +0 -9
  93. package/types/config.d.ts +0 -101
  94. package/types/events.d.ts +0 -7
  95. package/types/helper/data_insertion.d.ts +0 -4
  96. package/types/helper/presetup_services.d.ts +0 -5
  97. package/types/index.d.ts +0 -72
  98. package/types/middlewares.d.ts +0 -10
  99. package/types/services/data_provider/router.d.ts +0 -3
  100. package/types/services/data_provider/service.d.ts +0 -40
  101. package/types/services/data_provider/typeCasters.d.ts +0 -3
  102. package/types/services/file/db.d.ts +0 -3
  103. package/types/services/file/router.d.ts +0 -3
  104. package/types/services/file/service.d.ts +0 -81
  105. package/types/services/functions/router.d.ts +0 -3
  106. package/types/services/functions/service.d.ts +0 -23
  107. package/types/services/jwt/router.d.ts +0 -3
  108. package/types/services/jwt/service.d.ts +0 -10
  109. package/types/services/user_manager/db.d.ts +0 -3
  110. package/types/services/user_manager/permissionManager.d.ts +0 -3
  111. package/types/services/user_manager/router.d.ts +0 -3
  112. package/types/services/user_manager/service.d.ts +0 -131
@@ -1,377 +0,0 @@
1
- const User = require("../../class/user");
2
- const DataProvider = require("../data_provider/service");
3
- const JWT = require("../jwt/service");
4
- const { getDefaultPermissionGroups } = require("./permissionManager");
5
-
6
- /**
7
- * import user type
8
- * @typedef {import('../../class/user')} User
9
- */
10
-
11
- class UserManager {
12
- constructor() {
13
- this.tempIds = {};
14
- }
15
-
16
- /**
17
- * Sets a custom method for generating verification codes.
18
- *
19
- * @param {Function} generatorMethod - A function that returns a random verification code.
20
- * @returns {void}
21
- */
22
- setCustomVerificationCodeGeneratorMethod(generatorMethod) {
23
- this.verificationCodeGeneratorMethod = generatorMethod;
24
- }
25
-
26
- /**
27
- * Get a user by their ID.
28
- *
29
- * @param {string} id - The ID of the user.
30
- * @returns {Promise<User>} A promise that resolves to the user.
31
- * @throws {Error} If the user is not found.
32
- */
33
- generateVerificationCode(id, idType) {
34
- if (this.verificationCodeGeneratorMethod)
35
- return this.verificationCodeGeneratorMethod(id, idType);
36
-
37
- // this is default code
38
- return "123";
39
- }
40
-
41
- /**
42
- * Get a user by their ID.
43
- *
44
- * @param {string} id - The ID of the user.
45
- * @returns {Promise<User>} A promise that resolves to the user.
46
- * @throws {string} If the user is not found.
47
- */
48
- getUserById(id) {
49
- return new Promise(async (done, reject) => {
50
- let userModel = DataProvider.getCollection("cms", "auth");
51
-
52
- let userDoc = await userModel
53
- .findOne({ _id: id })
54
- .select({ password: 0 })
55
- .exec()
56
- .catch(reject);
57
-
58
- if (!userDoc) {
59
- reject("user not found");
60
- return;
61
- }
62
-
63
- let user = User.loadFromModel(userDoc);
64
- done(user);
65
- });
66
- }
67
-
68
- /**
69
- * Get a user by their identity.
70
- *
71
- * @param {string} id - The identity of the user.
72
- * @param {string} idType - The type of the identity (phone or email).
73
- * @returns {Promise<User>} A promise that resolves to the user.
74
- * @throws {string} If the user is not found.
75
- */
76
- getUserByIdentity(id, idType) {
77
- return new Promise(async (done, reject) => {
78
- let userModel = DataProvider.getCollection("cms", "auth");
79
-
80
- let query = {};
81
-
82
- if (idType == "phone") query["phone"] = id;
83
- else if (idType == "email") query["email"] = id;
84
-
85
- let userDoc = await userModel
86
- .findOne(query)
87
- .select({ password: 0 })
88
- .exec()
89
- .catch(reject);
90
-
91
- if (!userDoc) {
92
- reject("user not found");
93
- return;
94
- }
95
-
96
- let user = User.loadFromModel(userDoc);
97
- done(user);
98
- });
99
- }
100
-
101
- /**
102
- * Get a user by their token.
103
- *
104
- * @param {string} token - The token of the user.
105
- * @returns {Promise<User>} A promise that resolves to the user.
106
- */
107
- async getUserByToken(token) {
108
- const { id } = await JWT.main.verify(token);
109
- return this.getUserById(id);
110
- }
111
-
112
- /**
113
- * Check if a verification code is valid.
114
- *
115
- * @param {string} id - The ID of the user.
116
- * @param {string} code - The verification code.
117
- * @returns {boolean} Whether the verification code is valid.
118
- */
119
- isCodeValid(id, code) {
120
- let key = false;
121
-
122
- if (
123
- this.tempIds.hasOwnProperty(id) &&
124
- this.tempIds[id].code.toString() === code.toString()
125
- )
126
- key = true;
127
-
128
- return key;
129
- }
130
-
131
- /**
132
- * Login a user and return their token.
133
- *
134
- * @param {string} id - The ID of the user.
135
- * @param {string} idType - The type of the ID (phone or email).
136
- * @param {string} password - The password of the user.
137
- * @returns {Promise<string>} A promise that resolves to the token of the user.
138
- * @throws {string} If the user is not found.
139
- */
140
- loginUser(id = "", idType = "", password = "") {
141
- let token;
142
-
143
- return new Promise(async (done, reject) => {
144
- // Get user model
145
- const userModel = DataProvider.getCollection("cms", "auth");
146
-
147
- /**
148
- * Setup query to find by phone or email
149
- */
150
- const query = {
151
- password: Buffer.from(password).toString("base64"),
152
- type: "user",
153
- };
154
-
155
- if (idType == "phone") query["phone"] = id;
156
- else if (idType == "email") query["email"] = id;
157
-
158
- // Get from database
159
- const gottenFromDB = await userModel.findOne(query).exec().catch(reject);
160
-
161
- if (!gottenFromDB) reject("user not found");
162
- // Token
163
- else {
164
- // Load user
165
- const user = await User.loadFromModel(gottenFromDB)
166
- .then()
167
- .catch(reject);
168
-
169
- // Get token payload
170
- // This is some information about the user.
171
- const payload = user.getBrief();
172
-
173
- // Generate json web token
174
- token = await JWT.main.sign(payload).then().catch(reject);
175
-
176
- done(token);
177
- }
178
- });
179
- }
180
-
181
- /**
182
- * Issue a token for a user.
183
- *
184
- * @param {string} email - The email of the user.
185
- * @returns {Promise<string>} A promise that resolves to the token of the user.
186
- * @throws {string} If the user is not found.
187
- */
188
- issueTokenForUser(email) {
189
- return new Promise(async (done, reject) => {
190
- const userModel = DataProvider.getCollection("cms", "auth");
191
- const query = { email: email };
192
-
193
- // Get from database
194
- const gottenFromDB = await userModel.findOne(query).exec().catch(reject);
195
-
196
- if (!gottenFromDB) reject("user not found");
197
-
198
- const user = await User.loadFromModel(gottenFromDB).then().catch(reject);
199
-
200
- // Get token payload
201
- // This is some information about the user.
202
- const payload = user.getBrief();
203
-
204
- // Generate json web token
205
- await JWT.main.sign(payload).then(done).catch(reject);
206
- });
207
- }
208
-
209
- /**
210
- * Login as an anonymous user.
211
- *
212
- * @returns {Promise<string>} A promise that resolves to the token of the anonymous user.
213
- * @throws {string} If the anonymous user is not found.
214
- */
215
- loginAnonymous() {
216
- let token;
217
-
218
- return new Promise(async (done, reject) => {
219
- // Get user model
220
- let userModel = DataProvider.getCollection("cms", "auth");
221
-
222
- // Setup query
223
- let query = { type: "anonymous" };
224
-
225
- // Get from database
226
- let gottenFromDB = await userModel
227
- .findOne(query)
228
- .exec()
229
- .then()
230
- .catch(reject);
231
-
232
- // Create a new anonymous user if it doesn't exist.
233
- // There are only one anonymous user in the database
234
- // and every guest token being generated from it.
235
- if (!gottenFromDB) {
236
- let newUserId = await this.registerUser({ type: "anonymous" }).catch(
237
- reject
238
- );
239
- gottenFromDB = await this.getUserById(newUserId).catch(reject);
240
- }
241
-
242
- // load User
243
- let user = await User.loadFromModel(gottenFromDB).then().catch(reject);
244
-
245
- // Get token payload
246
- // This is some information about the user.
247
- let payload = user.getBrief();
248
-
249
- // Generate json web token
250
- token = await JWT.main.sign(payload).then().catch(reject);
251
-
252
- done(token);
253
- });
254
- }
255
-
256
- /**
257
- * Register a temporary ID.
258
- *
259
- * @param {string} id - The ID to register.
260
- * @param {string} type - The type of the ID.
261
- * @param {string} code - The verification code.
262
- */
263
- registerTemporaryID(id, type, code) {
264
- this.tempIds[id] = { id: id, type: type, code: code };
265
- }
266
-
267
- /**
268
- * Submit a password for a temporary ID.
269
- *
270
- * @param {string} id - The ID.
271
- * @param {string} password - The password.
272
- * @param {string} code - The verification code.
273
- * @returns {Promise<boolean>} A promise that resolves to whether the operation was successful.
274
- */
275
- async submitPasswordForTemporaryID(id, password, code) {
276
- let key = false;
277
-
278
- // If user email|phone has already stored
279
- // a new user being created
280
- if (
281
- this.tempIds.hasOwnProperty(id) &&
282
- this.tempIds[id].code.toString() == code.toString()
283
- ) {
284
- let authDetail = { password: password };
285
-
286
- if (this.tempIds[id].type == "phone") authDetail["phone"] = id;
287
- else if (this.tempIds[id].type == "email") authDetail["email"] = id;
288
-
289
- await this.registerUser(authDetail)
290
- .then(() => (key = true))
291
- .catch((e) => console.log(e));
292
- }
293
-
294
- delete this.tempIds[id];
295
- return key;
296
- }
297
-
298
- /**
299
- * Change the password for a temporary ID.
300
- *
301
- * @param {string} id - The ID.
302
- * @param {string} password - The new password.
303
- * @param {string} code - The verification code.
304
- * @returns {Promise<boolean>} A promise that resolves to whether the operation was successful.
305
- */
306
- async changePasswordForTemporaryID(id, password, code) {
307
- let key = false;
308
-
309
- if (this.tempIds.hasOwnProperty(id) && this.tempIds[id].code == code) {
310
- let query = {};
311
-
312
- if (this.tempIds[id].type == "phone") query["phone"] = id;
313
- else if (this.tempIds[id].type == "email") query["email"] = id;
314
-
315
- await this.changePassword(query, password)
316
- .then(() => (key = true))
317
- .catch((e) => console.log(e));
318
- }
319
-
320
- delete this.tempIds[id];
321
- return key;
322
- }
323
-
324
- /**
325
- * Register a user.
326
- *
327
- * @param {Object} detail - The details of the user.
328
- * @returns {Promise<string>} A promise that resolves to the ID of the new user.
329
- * @throws {string} If the user could not be registered.
330
- */
331
- registerUser(detail) {
332
- return new Promise(async (done, reject) => {
333
- // get default permission
334
- if (!detail.permissionGroup) {
335
- detail.permissionGroup = getDefaultPermissionGroups().title;
336
- }
337
-
338
- if (!detail.permissionGroup) {
339
- reject("default permission group not found");
340
- return;
341
- }
342
-
343
- let authM = DataProvider.getCollection("cms", "auth");
344
- return User.createFromModel(authM, detail)
345
- .then((newUser) => {
346
- DataProvider.triggers.call("insertOne", "cms", "auth", {
347
- input: detail,
348
- output: newUser.dbModel,
349
- });
350
-
351
- done(newUser.id);
352
- })
353
- .catch(reject);
354
- });
355
- }
356
-
357
- /**
358
- * Change the password of a user.
359
- *
360
- * @param {Object} query - The query to find the user.
361
- * @param {string} newPass - The new password.
362
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
363
- */
364
- changePassword(query, newPass) {
365
- let update = { $set: { password: newPass } };
366
- let authM = DataProvider.getCollection("cms", "auth");
367
- return authM.updateOne(query, update).exec().then();
368
- }
369
-
370
- static get instance() {
371
- return instance;
372
- }
373
- }
374
-
375
- const instance = new UserManager();
376
- module.exports.name = "userManager";
377
- module.exports.main = UserManager.instance;
@@ -1,97 +0,0 @@
1
- export = createRest;
2
- /**
3
- * Create a modular REST instance with Koa and MongoDB support.
4
- * @param {{
5
- * cors?: Cors; // CORS options.
6
- * modulesPath?: string; // Root directory of your router.js/db.js files.
7
- * uploadDirectory?: string; // Root directory of your uploaded files.
8
- * koaBodyOptions?: object; // Options for koa-body.
9
- * staticPath?: {
10
- * rootDir: string; // Root directory of your static files.
11
- * rootPath: string; // Root path of your static files, defaults to '/assets'.
12
- * maxage?: number; // Browser cache max-age in milliseconds. Defaults to 0.
13
- * hidden?: boolean; // Allow transfer of hidden files. Defaults to false.
14
- * index?: string; // Default file name. Defaults to 'index.html'.
15
- * defer?: boolean; // If true, serves after return next(), allowing any downstream middleware to respond first. Defaults to false.
16
- * gzip?: boolean; // Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. Defaults to true.
17
- * br?: boolean; // Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists. Note that brotli is only accepted over https. Defaults to false.
18
- * setHeaders?: Function; // Function to set custom headers on response.
19
- * extensions?: boolean|Array; // Try to match extensions from passed array to search for file when no extension is suffixed in URL. First found is served. Defaults to false.
20
- * };
21
- * onBeforeInit?: (koaApp:Koa) => void; // A callback called before initializing the Koa server.
22
- * onAfterInit?: (koaApp:Koa) => void; // A callback called after server initialization.
23
- * port?: number; // Server port.
24
- * dontListen?: boolean; // If true, the server will not run and will only return the Koa app object.
25
- * mongo?: {
26
- * dbPrefix: string; // A prefix for your database name.
27
- * mongoBaseAddress: string; // The address of your MongoDB server without any database specification.
28
- * addressMap?: string; // Specific addresses for each database.
29
- * };
30
- * keypair?: {
31
- * private: string; // Private key for RSA authentication.
32
- * public: string; // Public key for RSA authentication.
33
- * };
34
- * adminUser?: {
35
- * email: string; // Admin user email.
36
- * password: string; // Admin user password.
37
- * };
38
- * verificationCodeGeneratorMethod: () => string; // A method to return a verification code when registering a new user.
39
- * collectionDefinitions?: CollectionDefinition[]; // An array of additional collection definitions.
40
- * permissionGroups?: PermissionGroup[]; // An array of additional permission groups.
41
- * authTriggers?: CmsTrigger[]; // An array of additional database triggers for the auth collection.
42
- * fileTriggers?: CmsTrigger[]; // An array of additional database triggers for the auth collection.
43
- * }} options
44
- * @returns {Promise<{app: Koa, server: Server}>}
45
- */
46
- declare function createRest(options: {
47
- cors?: Cors;
48
- modulesPath?: string;
49
- uploadDirectory?: string;
50
- koaBodyOptions?: object;
51
- staticPath?: {
52
- rootDir: string;
53
- rootPath: string;
54
- maxage?: number;
55
- hidden?: boolean;
56
- index?: string;
57
- defer?: boolean;
58
- gzip?: boolean;
59
- br?: boolean;
60
- setHeaders?: Function;
61
- extensions?: boolean | any[];
62
- };
63
- onBeforeInit?: (koaApp: Koa) => void;
64
- onAfterInit?: (koaApp: Koa) => void;
65
- port?: number;
66
- dontListen?: boolean;
67
- mongo?: {
68
- dbPrefix: string;
69
- mongoBaseAddress: string;
70
- addressMap?: string;
71
- };
72
- keypair?: {
73
- private: string;
74
- public: string;
75
- };
76
- adminUser?: {
77
- email: string;
78
- password: string;
79
- };
80
- verificationCodeGeneratorMethod: () => string;
81
- collectionDefinitions?: CollectionDefinition[];
82
- permissionGroups?: PermissionGroup[];
83
- authTriggers?: CmsTrigger[];
84
- fileTriggers?: CmsTrigger[];
85
- }): Promise<{
86
- app: Koa;
87
- server: Server;
88
- }>;
89
- declare namespace createRest {
90
- export { Koa, server, Cors, PermissionGroup, CmsTrigger };
91
- }
92
- import cors = require("@koa/cors");
93
- type Cors = import('@koa/cors').Options;
94
- type Koa = import('koa');
95
- type PermissionGroup = import('./class/security.js').PermissionGroup;
96
- type CmsTrigger = import('./class/cms_trigger.js');
97
- type server = import('http').Server;
@@ -1,24 +0,0 @@
1
- export = CmsTrigger;
2
- /**
3
- * `CmsTrigger` is a class that defines a callback to be called on a specific database transaction.
4
- *
5
- * @class
6
- */
7
- declare class CmsTrigger {
8
- /**
9
- * Creates a new instance of `CmsTrigger`.
10
- *
11
- * @param {'update-one' | 'insert-one' | 'remove-one' } operation - The operation to be triggered.
12
- * @param {function({query: any, queryResult: any}): void} [callback=(context) => {}] - The callback to be called when the operation is executed. The callback function takes an object as parameter with two properties: 'query' and 'queryResult'.
13
- * @constructor
14
- */
15
- constructor(operation: 'update-one' | 'insert-one' | 'remove-one', callback?: (arg0: {
16
- query: any;
17
- queryResult: any;
18
- }) => void);
19
- operation: "update-one" | "insert-one" | "remove-one";
20
- callback: (arg0: {
21
- query: any;
22
- queryResult: any;
23
- }) => void;
24
- }
@@ -1,36 +0,0 @@
1
- export = CollectionDefinition;
2
- /**
3
- * @typedef {import('./security.js').Permission} Permission
4
- * @typedef {import('./database_trigger.js')} DatabaseTrigger
5
- */
6
- declare class CollectionDefinition {
7
- /**
8
- * This class helps to create a mongoose collection
9
- * associated with permissions and triggers.
10
- *
11
- * @class
12
- * @param {Object} option
13
- * @param {string} option.db - Database name
14
- * @param {string} option.collection - Collection name
15
- * @param {Object} option.schema - Mongoose schema
16
- * @param {Array<Permission>} option.permissions - A list of permissions for this collection
17
- * @param {Array<DatabaseTrigger>=} option.triggers - A database trigger
18
- */
19
- constructor({ db, collection, schema, permissions, triggers }: {
20
- db: string;
21
- collection: string;
22
- schema: any;
23
- permissions: Array<Permission>;
24
- triggers?: Array<DatabaseTrigger> | undefined;
25
- });
26
- database: string;
27
- collection: string;
28
- schema: any;
29
- permissions: import("./security.js").Permission[];
30
- triggers: import("./database_trigger.js")[];
31
- }
32
- declare namespace CollectionDefinition {
33
- export { Permission, DatabaseTrigger };
34
- }
35
- type Permission = import('./security.js').Permission;
36
- type DatabaseTrigger = import('./database_trigger.js');
@@ -1,30 +0,0 @@
1
- export = Combinator.instance;
2
- declare var instance: Combinator;
3
- declare class Combinator {
4
- static get instance(): Combinator;
5
- combineRoutesByFilePath(rootDirectory: any, app: any): Promise<void>;
6
- /**
7
- *
8
- * @param {object} option
9
- * @param {string} option.rootDirectory root directory of files
10
- * @param {object} option.filename an object of {name, extension}
11
- * @param {string} option.filename.name name of file
12
- * @param {string} option.filename.extension the extension of the file
13
- * @param {boolean} option.combineWithRoot combine all file content and return theme as a object
14
- * @param {boolean} option.convertToArray return file content as an array instead an object
15
- */
16
- combineModulesByFilePath({ rootDirectory, filename, combineWithRoot, convertToArray, }: {
17
- rootDirectory: string;
18
- filename: {
19
- name: string;
20
- extension: string;
21
- };
22
- combineWithRoot: boolean;
23
- convertToArray: boolean;
24
- }): Promise<any>;
25
- combineFunctionsByFilePath({ rootDirectory, filename }: {
26
- rootDirectory: any;
27
- filename: any;
28
- }): Promise<void>;
29
- extendObj(obj: any, src: any): any;
30
- }
@@ -1,28 +0,0 @@
1
- export = DatabaseTrigger;
2
- /**
3
- * `DatabaseTrigger` is a class that defines a callback to be called on a specific database transaction.
4
- *
5
- * @class
6
- */
7
- declare class DatabaseTrigger {
8
- /**
9
- * Creates a new instance of `DatabaseTrigger`.
10
- *
11
- * @param {'find' | 'find-one' | 'count' | 'update-one' | 'insert-one' | 'remove-one' | 'aggregate'} operation - The operation to be triggered. Supported operations are: 'find', 'find-one', 'count', 'update-one', 'insert-one', 'remove-one', 'aggregate'.
12
- * @param {function({query: Object.<string, any>, queryResult: any | any[]}): void} [callback=(context) => {}] - The callback to be called when the operation is executed. The callback function takes an object as parameter with two properties: 'query' and 'queryResult'.
13
- * @constructor
14
- */
15
- constructor(operation: 'find' | 'find-one' | 'count' | 'update-one' | 'insert-one' | 'remove-one' | 'aggregate', callback?: (arg0: {
16
- query: {
17
- [x: string]: any;
18
- };
19
- queryResult: any | any[];
20
- }) => void);
21
- operation: "find" | "count" | "aggregate" | "find-one" | "update-one" | "insert-one" | "remove-one";
22
- callback: (arg0: {
23
- query: {
24
- [x: string]: any;
25
- };
26
- queryResult: any | any[];
27
- }) => void;
28
- }
@@ -1,2 +0,0 @@
1
- import mongoose = require("mongoose");
2
- export let file: mongoose.Schema<mongoose.Document<any, any, any>, mongoose.Model<mongoose.Document<any, any, any>, any, any>, undefined, {}>;
@@ -1,2 +0,0 @@
1
- export function walk(dir: any, settings: any, done: any): void;
2
- export function find(dir: any, settings: any): Promise<any>;
@@ -1,8 +0,0 @@
1
- /**
2
- * Creates a pagination object based on the given parameters.
3
- * @param {number} count - The total number of items to paginate.
4
- * @param {number} perPage - The number of items to display per page.
5
- * @param {number} page - The current page number.
6
- * @returns {Object} - An object containing pagination information.
7
- */
8
- export function create(count: number, perPage: number, page: number): any;
@@ -1,8 +0,0 @@
1
- /**
2
- * Creates a response object with the given status and detail.
3
- *
4
- * @param {string} status - The status of the response. Can be "s" for success, "f" for fail, or "e" for error.
5
- * @param {Object} [detail={}] - The detail of the response. Can contain any additional information about the response.
6
- * @returns {Object} - The response object with the given status and detail.
7
- */
8
- export function create(status: string, detail?: any): any;