@modular-rest/server 1.11.6 → 1.11.8

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 (37) hide show
  1. package/package-lock.json +1373 -0
  2. package/package.json +5 -5
  3. package/types/src/application.d.ts +97 -0
  4. package/types/src/class/cms_trigger.d.ts +24 -0
  5. package/types/src/class/collection_definition.d.ts +36 -0
  6. package/types/src/class/combinator.d.ts +30 -0
  7. package/types/src/class/database_trigger.d.ts +24 -0
  8. package/types/src/class/db_schemas.d.ts +2 -0
  9. package/types/src/class/directory.d.ts +2 -0
  10. package/types/src/class/paginator.d.ts +8 -0
  11. package/types/src/class/reply.d.ts +8 -0
  12. package/types/src/class/security.d.ts +109 -0
  13. package/types/src/class/trigger_operator.d.ts +19 -0
  14. package/types/src/class/user.d.ts +24 -0
  15. package/types/src/class/validator.d.ts +9 -0
  16. package/types/src/config.d.ts +101 -0
  17. package/types/src/events.d.ts +7 -0
  18. package/types/src/helper/data_insertion.d.ts +4 -0
  19. package/types/src/helper/presetup_services.d.ts +5 -0
  20. package/types/src/index.d.ts +72 -0
  21. package/types/src/middlewares.d.ts +9 -0
  22. package/types/src/services/data_provider/router.d.ts +3 -0
  23. package/types/src/services/data_provider/service.d.ts +40 -0
  24. package/types/src/services/data_provider/typeCasters.d.ts +3 -0
  25. package/types/src/services/file/db.d.ts +3 -0
  26. package/types/src/services/file/router.d.ts +3 -0
  27. package/types/src/services/file/service.d.ts +81 -0
  28. package/types/src/services/functions/router.d.ts +3 -0
  29. package/types/src/services/functions/service.d.ts +23 -0
  30. package/types/src/services/jwt/router.d.ts +3 -0
  31. package/types/src/services/jwt/service.d.ts +10 -0
  32. package/types/src/services/user_manager/db.d.ts +3 -0
  33. package/types/src/services/user_manager/permissionManager.d.ts +3 -0
  34. package/types/src/services/user_manager/router.d.ts +3 -0
  35. package/types/src/services/user_manager/service.d.ts +131 -0
  36. package/types/test.d.ts +1 -0
  37. package/test.js +0 -10
@@ -0,0 +1,40 @@
1
+ export let name: string;
2
+ /**
3
+ * Get a collection from a database.
4
+ * @param {string} db - The database name.
5
+ * @param {string} collection - The collection name.
6
+ * @returns {import('mongoose').Model} The found collection.
7
+ */
8
+ export function getCollection(db: string, collection: string): Mongoose.Model<any, any, any>;
9
+ /**
10
+ *
11
+ * @param {object} option
12
+ * @param {array} option.list an array of CollectionDefinition instance
13
+ * @param {object} option.mongoOption
14
+ * @param {string} option.mongoOption.dbPrefix
15
+ * @param {string} option.mongoOption.mongoBaseAddress
16
+ */
17
+ export function addCollectionDefinitionByList({ list, mongoOption }: {
18
+ list: any[];
19
+ mongoOption: {
20
+ dbPrefix: string;
21
+ mongoBaseAddress: string;
22
+ };
23
+ }): Promise<void>;
24
+ /**
25
+ * Check access to a collection.
26
+ * @param {string} db - The database name.
27
+ * @param {string} collection - The collection name.
28
+ * @param {string} operationType - The operation type.
29
+ * @param {object} queryOrDoc - The query or document.
30
+ * @param {import('../../class/user')} user - The user.
31
+ * @returns {boolean} The access result.
32
+ */
33
+ export function checkAccess(db: string, collection: string, operationType: string, queryOrDoc: object, user: import('../../class/user')): boolean;
34
+ export function getAsID(strId: any): Mongoose.Types.ObjectId;
35
+ export function performPopulateToQueryObject(queryObj: any, popArr?: any[]): any;
36
+ export function performAdditionalOptionsToQueryObject(queryObj: any, options: any): any;
37
+ import triggers = require("../../class/trigger_operator");
38
+ import TypeCasters = require("./typeCasters");
39
+ import Mongoose = require("mongoose");
40
+ export { triggers, TypeCasters };
@@ -0,0 +1,3 @@
1
+ import Mongoose = require("mongoose");
2
+ export let ObjectId: Mongoose.Types.ObjectIdConstructor;
3
+ export function Date(dateValue: any): Date;
@@ -0,0 +1,3 @@
1
+ declare const _exports: CollectionDefinition[];
2
+ export = _exports;
3
+ import CollectionDefinition = require("../../class/collection_definition");
@@ -0,0 +1,3 @@
1
+ export let name: string;
2
+ declare let fileRouter: any;
3
+ export { fileRouter as main };
@@ -0,0 +1,81 @@
1
+ export = FileService.instance;
2
+ declare var instance: FileService;
3
+ declare class FileService {
4
+ directory: any;
5
+ setUploadDirectory(directory: any): void;
6
+ /**
7
+ *
8
+ * @param {string} fileType
9
+ * @param {string} tag
10
+ *
11
+ * @returns storedFile
12
+ * @returns storedFile.fileName
13
+ * @returns storedFile.directory
14
+ * @returns storedFile.fullPath
15
+ * @returns storedFile.fileFormat
16
+ */
17
+ createStoredDetail(fileType: string, tag: string): {
18
+ fileName: string;
19
+ fullPath: string;
20
+ fileFormat: string;
21
+ };
22
+ /**
23
+ * Stores a file, removes the given temporary file, and submits file details into the database.
24
+ *
25
+ * @param {Object} options - The options for storing the file.
26
+ * @param {Object} options.file - The file to be stored.
27
+ * @param {string} options.file.path - The path of the file.
28
+ * @param {string} options.file.type - The type of the file.
29
+ * @param {string} options.file.name - The original name of the file.
30
+ * @param {number} options.file.size - The size of the file.
31
+ * @param {string} options.ownerId - The ID of the owner of the file.
32
+ * @param {string} options.tag - The tag associated with the file.
33
+ * @param {boolean} [options.removeFileAfterStore=true] - Whether to remove the file after storing it.
34
+ *
35
+ * @returns {Promise} A promise that resolves with the document of the stored file.
36
+ *
37
+ * @throws {string} If the upload directory has not been set.
38
+ */
39
+ storeFile({ file, ownerId, tag, removeFileAfterStore }: {
40
+ file: {
41
+ path: string;
42
+ type: string;
43
+ name: string;
44
+ size: number;
45
+ };
46
+ ownerId: string;
47
+ tag: string;
48
+ removeFileAfterStore?: boolean;
49
+ }): Promise<any>;
50
+ /**
51
+ * Removes a file from the disk.
52
+ *
53
+ * @param {string} path - The path of the file to be removed.
54
+ * @returns {Promise} A promise that resolves if the file is successfully removed, and rejects if an error occurs.
55
+ */
56
+ removeFromDisc(path: string): Promise<any>;
57
+ /**
58
+ * Removes a file from the database and the disk.
59
+ *
60
+ * @param {string} fileId - The ID of the file to be removed.
61
+ * @returns {Promise} A promise that resolves if the file is successfully removed, and rejects if an error occurs.
62
+ * @throws Will throw an error if upload directory has not been set.
63
+ */
64
+ removeFile(fileId: string): Promise<any>;
65
+ /**
66
+ * Retrieves a file from the database.
67
+ *
68
+ * @param {string} fileId - The ID of the file to be retrieved.
69
+ * @returns {Promise} A promise that resolves with the file document, or rejects if an error occurs.
70
+ */
71
+ getFile(fileId: string): Promise<any>;
72
+ /**
73
+ * Retrieves the link of a file.
74
+ *
75
+ * @param {string} fileId - The ID of the file to get the link for.
76
+ * @returns {Promise} A promise that resolves with the file link, or rejects if an error occurs.
77
+ */
78
+ getFileLink(fileId: string): Promise<any>;
79
+ getFilePath(fileId: any): Promise<string>;
80
+ }
81
+ declare namespace FileService { }
@@ -0,0 +1,3 @@
1
+ export const name: "function";
2
+ declare const functionRouter: any;
3
+ export { functionRouter as main };
@@ -0,0 +1,23 @@
1
+ export type PermissionType = import('../../class/security.js').PermissionType;
2
+ /**
3
+ * @typedef {import('../../class/security.js').PermissionType} PermissionType
4
+ */
5
+ /**
6
+ * Defines a function with a given name, permission types, and callback.
7
+ *
8
+ * @param {Object} params - The parameters for the function.
9
+ * @param {string} params.name - The name of the function.
10
+ * @param {[PermissionType]} params.permissionTypes - The permission types for the function.
11
+ * @param {Function} params.callback - The callback to be executed by the function.
12
+ */
13
+ export function defineFunction({ name, permissionTypes, callback }: {
14
+ name: string;
15
+ permissionTypes: [PermissionType];
16
+ callback: Function;
17
+ }): {
18
+ name: string;
19
+ permissionTypes: [import("../../class/security.js").PermissionType];
20
+ callback: Function;
21
+ };
22
+ export function runFunction(name: any, args: any, user: any): Promise<any>;
23
+ export function addFunction(func: any): void;
@@ -0,0 +1,3 @@
1
+ export let name: string;
2
+ declare let verify: any;
3
+ export { verify as main };
@@ -0,0 +1,10 @@
1
+ export const name: "jwt";
2
+ export const main: JWT;
3
+ declare class JWT {
4
+ setKies(privateKey: any, publicKey: any): void;
5
+ privateKey: any;
6
+ publicKey: any;
7
+ sign(payload: any): Promise<any>;
8
+ verify(token: any): Promise<any>;
9
+ }
10
+ export {};
@@ -0,0 +1,3 @@
1
+ declare const _exports: CollectionDefinition[];
2
+ export = _exports;
3
+ import CollectionDefinition = require("../../class/collection_definition");
@@ -0,0 +1,3 @@
1
+ export function getDefaultPermissionGroups(): import("../../class/security").PermissionGroup;
2
+ export function getDefaultAnonymousPermissionGroup(): import("../../class/security").PermissionGroup;
3
+ export function getDefaultAdministratorPermissionGroup(): import("../../class/security").PermissionGroup;
@@ -0,0 +1,3 @@
1
+ export let name: string;
2
+ declare let userManager: any;
3
+ export { userManager as main };
@@ -0,0 +1,131 @@
1
+ export const name: "userManager";
2
+ export { instance as main };
3
+ /**
4
+ * import user type
5
+ */
6
+ export type User = import('../../class/user');
7
+ declare var instance: UserManager;
8
+ /**
9
+ * import user type
10
+ * @typedef {import('../../class/user')} User
11
+ */
12
+ declare class UserManager {
13
+ static get instance(): UserManager;
14
+ tempIds: {};
15
+ /**
16
+ * Sets a custom method for generating verification codes.
17
+ *
18
+ * @param {Function} generatorMethod - A function that returns a random verification code.
19
+ * @returns {void}
20
+ */
21
+ setCustomVerificationCodeGeneratorMethod(generatorMethod: Function): void;
22
+ verificationCodeGeneratorMethod: Function;
23
+ /**
24
+ * Get a user by their ID.
25
+ *
26
+ * @param {string} id - The ID of the user.
27
+ * @returns {Promise<User>} A promise that resolves to the user.
28
+ * @throws {Error} If the user is not found.
29
+ */
30
+ generateVerificationCode(id: string, idType: any): Promise<User>;
31
+ /**
32
+ * Get a user by their ID.
33
+ *
34
+ * @param {string} id - The ID of the user.
35
+ * @returns {Promise<User>} A promise that resolves to the user.
36
+ * @throws {string} If the user is not found.
37
+ */
38
+ getUserById(id: string): Promise<User>;
39
+ /**
40
+ * Get a user by their identity.
41
+ *
42
+ * @param {string} id - The identity of the user.
43
+ * @param {string} idType - The type of the identity (phone or email).
44
+ * @returns {Promise<User>} A promise that resolves to the user.
45
+ * @throws {string} If the user is not found.
46
+ */
47
+ getUserByIdentity(id: string, idType: string): Promise<User>;
48
+ /**
49
+ * Get a user by their token.
50
+ *
51
+ * @param {string} token - The token of the user.
52
+ * @returns {Promise<User>} A promise that resolves to the user.
53
+ */
54
+ getUserByToken(token: string): Promise<User>;
55
+ /**
56
+ * Check if a verification code is valid.
57
+ *
58
+ * @param {string} id - The ID of the user.
59
+ * @param {string} code - The verification code.
60
+ * @returns {boolean} Whether the verification code is valid.
61
+ */
62
+ isCodeValid(id: string, code: string): boolean;
63
+ /**
64
+ * Login a user and return their token.
65
+ *
66
+ * @param {string} id - The ID of the user.
67
+ * @param {string} idType - The type of the ID (phone or email).
68
+ * @param {string} password - The password of the user.
69
+ * @returns {Promise<string>} A promise that resolves to the token of the user.
70
+ * @throws {string} If the user is not found.
71
+ */
72
+ loginUser(id?: string, idType?: string, password?: string): Promise<string>;
73
+ /**
74
+ * Issue a token for a user.
75
+ *
76
+ * @param {string} email - The email of the user.
77
+ * @returns {Promise<string>} A promise that resolves to the token of the user.
78
+ * @throws {string} If the user is not found.
79
+ */
80
+ issueTokenForUser(email: string): Promise<string>;
81
+ /**
82
+ * Login as an anonymous user.
83
+ *
84
+ * @returns {Promise<string>} A promise that resolves to the token of the anonymous user.
85
+ * @throws {string} If the anonymous user is not found.
86
+ */
87
+ loginAnonymous(): Promise<string>;
88
+ /**
89
+ * Register a temporary ID.
90
+ *
91
+ * @param {string} id - The ID to register.
92
+ * @param {string} type - The type of the ID.
93
+ * @param {string} code - The verification code.
94
+ */
95
+ registerTemporaryID(id: string, type: string, code: string): void;
96
+ /**
97
+ * Submit a password for a temporary ID.
98
+ *
99
+ * @param {string} id - The ID.
100
+ * @param {string} password - The password.
101
+ * @param {string} code - The verification code.
102
+ * @returns {Promise<boolean>} A promise that resolves to whether the operation was successful.
103
+ */
104
+ submitPasswordForTemporaryID(id: string, password: string, code: string): Promise<boolean>;
105
+ /**
106
+ * Change the password for a temporary ID.
107
+ *
108
+ * @param {string} id - The ID.
109
+ * @param {string} password - The new password.
110
+ * @param {string} code - The verification code.
111
+ * @returns {Promise<boolean>} A promise that resolves to whether the operation was successful.
112
+ */
113
+ changePasswordForTemporaryID(id: string, password: string, code: string): Promise<boolean>;
114
+ /**
115
+ * Register a user.
116
+ *
117
+ * @param {Object} detail - The details of the user.
118
+ * @returns {Promise<string>} A promise that resolves to the ID of the new user.
119
+ * @throws {string} If the user could not be registered.
120
+ */
121
+ registerUser(detail: any): Promise<string>;
122
+ /**
123
+ * Change the password of a user.
124
+ *
125
+ * @param {Object} query - The query to find the user.
126
+ * @param {string} newPass - The new password.
127
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
128
+ */
129
+ changePassword(query: any, newPass: string): Promise<void>;
130
+ }
131
+ import User = require("../../class/user");
@@ -0,0 +1 @@
1
+ export {};
package/test.js DELETED
@@ -1,10 +0,0 @@
1
- const { createRest } = require('.');
2
- const { PermissionTypes } = require('./src/class/security');
3
-
4
- { createRest } require('./src/application');
5
- {PermissionTypes} require('./src/class/security');
6
-
7
- createRest({
8
- uploadDirectory: 'uploads',
9
- port: '3001'
10
- });