@modular-rest/server 1.11.12 → 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.
- package/.nvmrc +1 -0
- package/.prettierrc.json +9 -0
- package/.releaserc.json +24 -0
- package/README.md +79 -94
- package/dist/index.js +79 -0
- package/docs/.keep +0 -0
- package/docs/system-access-type.md +26 -0
- package/package.json +58 -45
- package/src/application.ts +206 -0
- package/src/class/cms_trigger.ts +68 -0
- package/src/class/collection_definition.ts +134 -0
- package/src/class/combinator.ts +176 -0
- package/src/class/database_trigger.ts +99 -0
- package/src/class/db_schemas.ts +44 -0
- package/src/class/{directory.js → directory.ts} +40 -18
- package/src/class/paginator.ts +51 -0
- package/src/class/reply.ts +59 -0
- package/src/class/security.ts +250 -0
- package/src/class/trigger_operator.ts +142 -0
- package/src/class/user.ts +199 -0
- package/src/class/validator.ts +123 -0
- package/src/config.ts +122 -0
- package/src/defult-permissions.ts +31 -0
- package/src/events.ts +59 -0
- package/src/helper/data_insertion.ts +94 -0
- package/src/helper/presetup_services.ts +96 -0
- package/src/index.ts +146 -0
- package/src/middlewares.ts +75 -0
- package/src/play-test.ts +8 -0
- package/src/services/data_provider/router.ts +191 -0
- package/src/services/data_provider/service.ts +305 -0
- package/src/services/data_provider/typeCasters.ts +15 -0
- package/src/services/file/db.ts +29 -0
- package/src/services/file/router.ts +88 -0
- package/src/services/file/service.ts +387 -0
- package/src/services/functions/router.ts +34 -0
- package/src/services/functions/service.ts +203 -0
- package/src/services/jwt/router.ts +73 -0
- package/src/services/jwt/service.ts +139 -0
- package/src/services/user_manager/db.ts +87 -0
- package/src/services/user_manager/permissionManager.ts +49 -0
- package/src/services/user_manager/router.ts +193 -0
- package/src/services/user_manager/service.ts +698 -0
- package/tsconfig.json +16 -9
- package/typedoc.mjs +41 -0
- package/LICENSE +0 -21
- package/package-lock.json +0 -1373
- package/src/application.js +0 -239
- package/src/class/cms_trigger.js +0 -20
- package/src/class/collection_definition.js +0 -33
- package/src/class/combinator.js +0 -133
- package/src/class/database_trigger.js +0 -20
- package/src/class/db_schemas.js +0 -18
- package/src/class/paginator.js +0 -31
- package/src/class/reply.js +0 -37
- package/src/class/security.js +0 -141
- package/src/class/trigger_operator.js +0 -39
- package/src/class/user.js +0 -112
- package/src/class/validator.js +0 -91
- package/src/config.js +0 -67
- package/src/events.js +0 -15
- package/src/helper/data_insertion.js +0 -64
- package/src/helper/presetup_services.js +0 -31
- package/src/index.js +0 -66
- package/src/middlewares.js +0 -44
- package/src/services/data_provider/router.js +0 -552
- package/src/services/data_provider/service.js +0 -262
- package/src/services/data_provider/typeCasters.js +0 -10
- package/src/services/file/db.js +0 -29
- package/src/services/file/router.js +0 -92
- package/src/services/file/service.js +0 -231
- package/src/services/functions/router.js +0 -37
- package/src/services/functions/service.js +0 -74
- package/src/services/jwt/router.js +0 -70
- package/src/services/jwt/service.js +0 -37
- package/src/services/user_manager/db.js +0 -83
- package/src/services/user_manager/permissionManager.js +0 -43
- package/src/services/user_manager/router.js +0 -176
- package/src/services/user_manager/service.js +0 -377
- package/types/application.d.ts +0 -97
- package/types/class/cms_trigger.d.ts +0 -24
- package/types/class/collection_definition.d.ts +0 -36
- package/types/class/combinator.d.ts +0 -30
- package/types/class/database_trigger.d.ts +0 -28
- package/types/class/db_schemas.d.ts +0 -2
- package/types/class/directory.d.ts +0 -2
- package/types/class/paginator.d.ts +0 -8
- package/types/class/reply.d.ts +0 -8
- package/types/class/security.d.ts +0 -109
- package/types/class/trigger_operator.d.ts +0 -19
- package/types/class/user.d.ts +0 -24
- package/types/class/validator.d.ts +0 -9
- package/types/config.d.ts +0 -101
- package/types/events.d.ts +0 -7
- package/types/helper/data_insertion.d.ts +0 -4
- package/types/helper/presetup_services.d.ts +0 -5
- package/types/index.d.ts +0 -72
- package/types/middlewares.d.ts +0 -9
- package/types/services/data_provider/router.d.ts +0 -3
- package/types/services/data_provider/service.d.ts +0 -40
- package/types/services/data_provider/typeCasters.d.ts +0 -3
- package/types/services/file/db.d.ts +0 -3
- package/types/services/file/router.d.ts +0 -3
- package/types/services/file/service.d.ts +0 -81
- package/types/services/functions/router.d.ts +0 -3
- package/types/services/functions/service.d.ts +0 -23
- package/types/services/jwt/router.d.ts +0 -3
- package/types/services/jwt/service.d.ts +0 -10
- package/types/services/user_manager/db.d.ts +0 -3
- package/types/services/user_manager/permissionManager.d.ts +0 -3
- package/types/services/user_manager/router.d.ts +0 -3
- package/types/services/user_manager/service.d.ts +0 -131
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
export type PermissionType = ('god_access' | 'user_access' | 'upload_file_access' | 'remove_file_access' | 'anonymous_access' | 'advanced_settings' | string);
|
|
2
|
-
/**
|
|
3
|
-
* Class representing an access definition.
|
|
4
|
-
*/
|
|
5
|
-
export class AccessDefinition {
|
|
6
|
-
/**
|
|
7
|
-
* Create an access definition.
|
|
8
|
-
* @param {Object} options - The options for the access definition.
|
|
9
|
-
* @param {string} options.database - The name of the database.
|
|
10
|
-
* @param {string} options.collection - The name of the collection.
|
|
11
|
-
* @param {Array.<Permission>} options.permissionList - The list of permissions.
|
|
12
|
-
*/
|
|
13
|
-
constructor({ database, collection, permissionList }: {
|
|
14
|
-
database: string;
|
|
15
|
-
collection: string;
|
|
16
|
-
permissionList: Array<Permission>;
|
|
17
|
-
});
|
|
18
|
-
database: string;
|
|
19
|
-
collection: string;
|
|
20
|
-
permissionList: Permission[];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {('god_access'|'user_access'|'upload_file_access'|'remove_file_access'|'anonymous_access'|'advanced_settings'|string)} PermissionType
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* Class representing a permission.
|
|
27
|
-
*/
|
|
28
|
-
export class Permission {
|
|
29
|
-
/**
|
|
30
|
-
* Create a permission.
|
|
31
|
-
* @param {Object} options - The options for the permission.
|
|
32
|
-
* @param {PermissionType} options.type - The type of the permission.
|
|
33
|
-
* @param {boolean} [options.read=false] - The read access of the permission.
|
|
34
|
-
* @param {boolean} [options.write=false] - The write access of the permission.
|
|
35
|
-
* @param {boolean} [options.onlyOwnData=false] - If true, users can perform CRUD on documents that they created already.
|
|
36
|
-
* @param {string} [options.ownerIdField='refId'] - The name of the field that contains the owner's id of the document.
|
|
37
|
-
*/
|
|
38
|
-
constructor({ type, read, write, onlyOwnData, ownerIdField, }: {
|
|
39
|
-
type: PermissionType;
|
|
40
|
-
read?: boolean;
|
|
41
|
-
write?: boolean;
|
|
42
|
-
onlyOwnData?: boolean;
|
|
43
|
-
ownerIdField?: string;
|
|
44
|
-
});
|
|
45
|
-
type: string;
|
|
46
|
-
read: boolean;
|
|
47
|
-
write: boolean;
|
|
48
|
-
onlyOwnData: boolean;
|
|
49
|
-
ownerIdField: string;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Class representing different types of permissions.
|
|
53
|
-
* Each static getter returns a string that represents a specific type of permission.
|
|
54
|
-
*/
|
|
55
|
-
export class PermissionTypes {
|
|
56
|
-
/**
|
|
57
|
-
* Get the string representing god access permission type.
|
|
58
|
-
* @return {string} The god access permission type.
|
|
59
|
-
*/
|
|
60
|
-
static get god_access(): string;
|
|
61
|
-
/**
|
|
62
|
-
* Get the string representing advanced settings permission type.
|
|
63
|
-
* @return {string} The advanced settings permission type.
|
|
64
|
-
*/
|
|
65
|
-
static get advanced_settings(): string;
|
|
66
|
-
/**
|
|
67
|
-
* Get the string representing user access permission type.
|
|
68
|
-
* @return {string} The user access permission type.
|
|
69
|
-
*/
|
|
70
|
-
static get user_access(): string;
|
|
71
|
-
/**
|
|
72
|
-
* Get the string representing upload file access permission type.
|
|
73
|
-
* @return {string} The upload file access permission type.
|
|
74
|
-
*/
|
|
75
|
-
static get upload_file_access(): string;
|
|
76
|
-
/**
|
|
77
|
-
* Get the string representing remove file access permission type.
|
|
78
|
-
* @return {string} The remove file access permission type.
|
|
79
|
-
*/
|
|
80
|
-
static get remove_file_access(): string;
|
|
81
|
-
}
|
|
82
|
-
export class PermissionGroup {
|
|
83
|
-
/**
|
|
84
|
-
* Create a permission group.
|
|
85
|
-
* @param {Object} options - The options for the permission group.
|
|
86
|
-
* @param {string} options.title - The title of the permission group.
|
|
87
|
-
* @param {boolean} [options.isDefault=false] - If true, the permission group is the default permission group.
|
|
88
|
-
* @param {boolean} [options.isAnonymous=false] - If true, the permission group is the anonymous permission group.
|
|
89
|
-
* @param {Array.<PermissionType>} [options.validPermissionTypes=[]] - The valid permission types of the permission group.
|
|
90
|
-
* @return {PermissionGroup} The created permission group.
|
|
91
|
-
*/
|
|
92
|
-
constructor({ title, isDefault, isAnonymous, validPermissionTypes, }: {
|
|
93
|
-
title: string;
|
|
94
|
-
isDefault?: boolean;
|
|
95
|
-
isAnonymous?: boolean;
|
|
96
|
-
validPermissionTypes?: Array<PermissionType>;
|
|
97
|
-
});
|
|
98
|
-
title: string;
|
|
99
|
-
isDefault: boolean;
|
|
100
|
-
isAnonymous: boolean;
|
|
101
|
-
validPermissionTypes: string[];
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Class representing access types.
|
|
105
|
-
*/
|
|
106
|
-
export class AccessTypes {
|
|
107
|
-
static get read(): string;
|
|
108
|
-
static get write(): string;
|
|
109
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export = TriggerOperator.instance;
|
|
2
|
-
declare var instance: TriggerOperator;
|
|
3
|
-
declare class TriggerOperator {
|
|
4
|
-
static get instance(): TriggerOperator;
|
|
5
|
-
triggers: any[];
|
|
6
|
-
/**
|
|
7
|
-
* add a collection trigger
|
|
8
|
-
* @param {object} trigger DatabaseTrigger object
|
|
9
|
-
*/
|
|
10
|
-
addTrigger(trigger: object): void;
|
|
11
|
-
/**
|
|
12
|
-
* Call a trigger
|
|
13
|
-
* @param {'find' | 'find-one' | 'count' | 'update-one' | 'insert-one' | 'remove-one' | 'aggregate'} operation operation name
|
|
14
|
-
* @param {string} database database name
|
|
15
|
-
* @param {string} collection collection name
|
|
16
|
-
* @param {string} data
|
|
17
|
-
*/
|
|
18
|
-
call(operation: 'find' | 'find-one' | 'count' | 'update-one' | 'insert-one' | 'remove-one' | 'aggregate', database: string, collection: string, data: string): void;
|
|
19
|
-
}
|
package/types/class/user.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export = User;
|
|
2
|
-
declare class User {
|
|
3
|
-
static loadFromModel(model: any): Promise<any>;
|
|
4
|
-
static createFromModel(model: any, detail: any): Promise<any>;
|
|
5
|
-
static notValid(object: any): string;
|
|
6
|
-
constructor(id: any, permissionGroup: any, phone: any, email: any, password: any, type: any, model: any);
|
|
7
|
-
id: any;
|
|
8
|
-
permissionGroup: any;
|
|
9
|
-
email: any;
|
|
10
|
-
phone: any;
|
|
11
|
-
password: any;
|
|
12
|
-
type: any;
|
|
13
|
-
dbModel: any;
|
|
14
|
-
getBrief(): {
|
|
15
|
-
id: any;
|
|
16
|
-
permissionGroup: import("./security").PermissionGroup;
|
|
17
|
-
phone: any;
|
|
18
|
-
email: any;
|
|
19
|
-
type: any;
|
|
20
|
-
};
|
|
21
|
-
setNewDetail(detail: any): void;
|
|
22
|
-
hasPermission(permissionField: any): boolean;
|
|
23
|
-
save(): Promise<void>;
|
|
24
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export = validate;
|
|
2
|
-
/**
|
|
3
|
-
* Validates an object by checking if it contains all the required fields.
|
|
4
|
-
* @param {Object} obj - The object to be validated.
|
|
5
|
-
* @param {string|Object} requiredFields - The list of required fields. If it's a string, it should contain keys separated by spaces. If it's an object, it should contain key-value pairs where the key is the field name and the value is a boolean indicating whether the field is required or not.
|
|
6
|
-
* @returns {boolean} - Returns true if the object contains all the required fields, otherwise returns false.
|
|
7
|
-
* @throws {string} - Throws an error if the requiredFields parameter is not a string or an object.
|
|
8
|
-
*/
|
|
9
|
-
declare function validate(obj: any, requiredFields: string | any): boolean;
|
package/types/config.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
export type Koa = import('koa');
|
|
2
|
-
export type Cors = import('@koa/cors').Options;
|
|
3
|
-
export type CollectionDefinition = import('./class/collection_definition.js');
|
|
4
|
-
export type PermissionGroup = import('./class/security.js').PermissionGroup;
|
|
5
|
-
export type CmsTrigger = import('./class/cms_trigger.js');
|
|
6
|
-
export type Config = {
|
|
7
|
-
cors?: Cors;
|
|
8
|
-
modulesPath?: string;
|
|
9
|
-
koaBodyOptions?: object;
|
|
10
|
-
staticPath?: {
|
|
11
|
-
rootDir: string;
|
|
12
|
-
rootPath: string;
|
|
13
|
-
maxage?: number;
|
|
14
|
-
hidden?: boolean;
|
|
15
|
-
index?: string;
|
|
16
|
-
defer?: boolean;
|
|
17
|
-
gzip?: boolean;
|
|
18
|
-
br?: boolean;
|
|
19
|
-
setHeaders?: Function;
|
|
20
|
-
extensions?: boolean | any[];
|
|
21
|
-
};
|
|
22
|
-
onBeforeInit?: (koaApp: Koa) => void;
|
|
23
|
-
onAfterInit?: (koaApp: Koa) => void;
|
|
24
|
-
port?: number;
|
|
25
|
-
dontListen?: boolean;
|
|
26
|
-
mongo?: {
|
|
27
|
-
dbPrefix: string;
|
|
28
|
-
mongoBaseAddress: string;
|
|
29
|
-
addressMap?: string;
|
|
30
|
-
};
|
|
31
|
-
keypair?: {
|
|
32
|
-
private: string;
|
|
33
|
-
public: string;
|
|
34
|
-
};
|
|
35
|
-
adminUser?: {
|
|
36
|
-
email: string;
|
|
37
|
-
password: string;
|
|
38
|
-
};
|
|
39
|
-
verificationCodeGeneratorMethod: () => string;
|
|
40
|
-
collectionDefinitions?: CollectionDefinition[];
|
|
41
|
-
permissionGroups?: PermissionGroup[];
|
|
42
|
-
authTriggers?: DatabaseTrigger[];
|
|
43
|
-
fileTriggers?: CmsTrigger[];
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* @param {Config} options
|
|
47
|
-
*/
|
|
48
|
-
export function setConfig(options: Config): void;
|
|
49
|
-
/**
|
|
50
|
-
* @typedef {import('koa')} Koa
|
|
51
|
-
* @typedef {import('@koa/cors').Options} Cors
|
|
52
|
-
* @typedef {import('./class/collection_definition.js')} CollectionDefinition
|
|
53
|
-
* @typedef {import('./class/security.js').PermissionGroup} PermissionGroup
|
|
54
|
-
* @typedef {import('./class/cms_trigger.js')} CmsTrigger
|
|
55
|
-
*/
|
|
56
|
-
/**
|
|
57
|
-
* @typedef {{
|
|
58
|
-
* cors?: Cors; // CORS options.
|
|
59
|
-
* modulesPath?: string; // Root directory of your router.js/db.js files.
|
|
60
|
-
* koaBodyOptions?: object; // Options for koa-body.
|
|
61
|
-
* staticPath?: {
|
|
62
|
-
* rootDir: string; // Root directory of your static files.
|
|
63
|
-
* rootPath: string; // Root path of your static files, defaults to '/assets'.
|
|
64
|
-
* maxage?: number; // Browser cache max-age in milliseconds. Defaults to 0.
|
|
65
|
-
* hidden?: boolean; // Allow transfer of hidden files. Defaults to false.
|
|
66
|
-
* index?: string; // Default file name. Defaults to 'index.html'.
|
|
67
|
-
* defer?: boolean; // If true, serves after return next(), allowing any downstream middleware to respond first. Defaults to false.
|
|
68
|
-
* 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.
|
|
69
|
-
* 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.
|
|
70
|
-
* setHeaders?: Function; // Function to set custom headers on response.
|
|
71
|
-
* 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.
|
|
72
|
-
* };
|
|
73
|
-
* onBeforeInit?: (koaApp:Koa) => void; // A callback called before initializing the Koa server.
|
|
74
|
-
* onAfterInit?: (koaApp:Koa) => void; // A callback called after server initialization.
|
|
75
|
-
* port?: number; // Server port.
|
|
76
|
-
* dontListen?: boolean; // If true, the server will not run and will only return the Koa app object.
|
|
77
|
-
* mongo?: {
|
|
78
|
-
* dbPrefix: string; // A prefix for your database name.
|
|
79
|
-
* mongoBaseAddress: string; // The address of your MongoDB server without any database specification.
|
|
80
|
-
* addressMap?: string; // Specific addresses for each database.
|
|
81
|
-
* };
|
|
82
|
-
* keypair?: {
|
|
83
|
-
* private: string; // Private key for RSA authentication.
|
|
84
|
-
* public: string; // Public key for RSA authentication.
|
|
85
|
-
* };
|
|
86
|
-
* adminUser?: {
|
|
87
|
-
* email: string; // Admin user email.
|
|
88
|
-
* password: string; // Admin user password.
|
|
89
|
-
* };
|
|
90
|
-
* verificationCodeGeneratorMethod: () => string; // A method to return a verification code when registering a new user.
|
|
91
|
-
* collectionDefinitions?: CollectionDefinition[]; // An array of additional collection definitions.
|
|
92
|
-
* permissionGroups?: PermissionGroup[]; // An array of additional permission groups.
|
|
93
|
-
* authTriggers?: DatabaseTrigger[]; // An array of additional database triggers for the auth collection.
|
|
94
|
-
* fileTriggers?: CmsTrigger[]; // An array of additional database triggers for the auth collection.
|
|
95
|
-
* }} Config
|
|
96
|
-
* @exports Config
|
|
97
|
-
*/
|
|
98
|
-
/**
|
|
99
|
-
* @type {Config}
|
|
100
|
-
*/
|
|
101
|
-
export const config: Config;
|
package/types/events.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* onBeforeInit: (koaApp:Koa) => void; // A callback called before initializing the Koa server.
|
|
3
|
-
* onAfterInit: (koaApp:Koa) => void; // A callback called after server initialization.
|
|
4
|
-
* onNewUser:
|
|
5
|
-
*/
|
|
6
|
-
declare function registerEventCallback(event: any, callback: any): void;
|
|
7
|
-
declare const eventCallbacks: any[];
|
package/types/index.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
declare const _exports: {
|
|
2
|
-
defineFunction: typeof defineFunction;
|
|
3
|
-
TypeCasters: {
|
|
4
|
-
ObjectId: import("mongoose").Types.ObjectIdConstructor;
|
|
5
|
-
Date: (dateValue: any) => Date;
|
|
6
|
-
};
|
|
7
|
-
validator: typeof validator;
|
|
8
|
-
reply: typeof reply;
|
|
9
|
-
paginator: typeof paginator;
|
|
10
|
-
getCollection: typeof getCollection;
|
|
11
|
-
getFile: (fileId: string) => Promise<any>;
|
|
12
|
-
getFileLink: (fileId: string) => Promise<any>;
|
|
13
|
-
getFilePath: (fileId: any) => Promise<string>;
|
|
14
|
-
removeFile: (fileId: string) => Promise<any>;
|
|
15
|
-
storeFile: ({ file, ownerId, tag, removeFileAfterStore }: {
|
|
16
|
-
file: {
|
|
17
|
-
path: string;
|
|
18
|
-
type: string;
|
|
19
|
-
name: string;
|
|
20
|
-
size: number;
|
|
21
|
-
};
|
|
22
|
-
ownerId: string;
|
|
23
|
-
tag: string;
|
|
24
|
-
removeFileAfterStore?: boolean;
|
|
25
|
-
}) => Promise<any>;
|
|
26
|
-
middleware: typeof middleware;
|
|
27
|
-
userManager: {
|
|
28
|
-
tempIds: {};
|
|
29
|
-
setCustomVerificationCodeGeneratorMethod(generatorMethod: Function): void;
|
|
30
|
-
verificationCodeGeneratorMethod: Function;
|
|
31
|
-
generateVerificationCode(id: string, idType: any): Promise<import("./class/user")>;
|
|
32
|
-
getUserById(id: string): Promise<import("./class/user")>;
|
|
33
|
-
getUserByIdentity(id: string, idType: string): Promise<import("./class/user")>;
|
|
34
|
-
getUserByToken(token: string): Promise<import("./class/user")>;
|
|
35
|
-
isCodeValid(id: string, code: string): boolean;
|
|
36
|
-
loginUser(id?: string, idType?: string, password?: string): Promise<string>;
|
|
37
|
-
issueTokenForUser(email: string): Promise<string>;
|
|
38
|
-
loginAnonymous(): Promise<string>;
|
|
39
|
-
registerTemporaryID(id: string, type: string, code: string): void;
|
|
40
|
-
submitPasswordForTemporaryID(id: string, password: string, code: string): Promise<boolean>;
|
|
41
|
-
changePasswordForTemporaryID(id: string, password: string, code: string): Promise<boolean>;
|
|
42
|
-
registerUser(detail: any): Promise<string>;
|
|
43
|
-
changePassword(query: any, newPass: string): Promise<void>;
|
|
44
|
-
};
|
|
45
|
-
AccessDefinition: typeof SecurityClass.AccessDefinition;
|
|
46
|
-
Permission: typeof SecurityClass.Permission;
|
|
47
|
-
PermissionTypes: typeof SecurityClass.PermissionTypes;
|
|
48
|
-
PermissionGroup: typeof SecurityClass.PermissionGroup;
|
|
49
|
-
AccessTypes: typeof SecurityClass.AccessTypes;
|
|
50
|
-
createRest: typeof createRest;
|
|
51
|
-
CollectionDefinition: typeof CollectionDefinition;
|
|
52
|
-
Schemas: {
|
|
53
|
-
file: Schema<import("mongoose").Document<any, any, any>, import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>, undefined, {}>;
|
|
54
|
-
};
|
|
55
|
-
Schema: typeof Schema;
|
|
56
|
-
DatabaseTrigger: typeof DatabaseTrigger;
|
|
57
|
-
CmsTrigger: typeof CmsTrigger;
|
|
58
|
-
};
|
|
59
|
-
export = _exports;
|
|
60
|
-
import { defineFunction } from "./services/functions/service";
|
|
61
|
-
import validator = require("./class/validator");
|
|
62
|
-
import reply = require("./class/reply");
|
|
63
|
-
import paginator = require("./class/paginator");
|
|
64
|
-
import { getCollection } from "./services/data_provider/service";
|
|
65
|
-
import middleware = require("./middlewares");
|
|
66
|
-
import SecurityClass = require("./class/security");
|
|
67
|
-
import createRest = require("./application");
|
|
68
|
-
import CollectionDefinition = require("./class/collection_definition");
|
|
69
|
-
import Schema_1 = require("mongoose");
|
|
70
|
-
import Schema = Schema_1.Schema;
|
|
71
|
-
import DatabaseTrigger = require("./class/database_trigger");
|
|
72
|
-
import CmsTrigger = require("./class/cms_trigger");
|
package/types/middlewares.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication middleware
|
|
3
|
-
* It checks if incoming request has a valid token in header.authorization
|
|
4
|
-
*
|
|
5
|
-
* @param {Object} ctx - Koa context
|
|
6
|
-
* @param {Function} next - Koa next function
|
|
7
|
-
* @returns {Promise<void>}
|
|
8
|
-
*/
|
|
9
|
-
export function auth(ctx: any, next: Function): Promise<void>;
|
|
@@ -1,40 +0,0 @@
|
|
|
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 };
|
|
@@ -1,81 +0,0 @@
|
|
|
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 { }
|
|
@@ -1,23 +0,0 @@
|
|
|
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: [string];
|
|
20
|
-
callback: Function;
|
|
21
|
-
};
|
|
22
|
-
export function runFunction(name: any, args: any, user: any): Promise<any>;
|
|
23
|
-
export function addFunction(func: any): void;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export function getDefaultPermissionGroups(): import("../../class/security").PermissionGroup;
|
|
2
|
-
export function getDefaultAnonymousPermissionGroup(): import("../../class/security").PermissionGroup;
|
|
3
|
-
export function getDefaultAdministratorPermissionGroup(): import("../../class/security").PermissionGroup;
|