@modular-rest/server 1.11.14 → 1.11.15

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 (79) hide show
  1. package/dist/application.d.ts +29 -0
  2. package/dist/application.js +217 -0
  3. package/dist/class/cms_trigger.d.ts +52 -0
  4. package/dist/class/cms_trigger.js +47 -0
  5. package/dist/class/collection_definition.d.ts +112 -0
  6. package/dist/class/collection_definition.js +87 -0
  7. package/dist/class/combinator.d.ts +43 -0
  8. package/dist/class/combinator.js +174 -0
  9. package/dist/class/database_trigger.d.ts +90 -0
  10. package/dist/class/database_trigger.js +64 -0
  11. package/dist/class/db_schemas.d.ts +25 -0
  12. package/dist/class/db_schemas.js +28 -0
  13. package/dist/class/directory.d.ts +20 -0
  14. package/dist/class/directory.js +87 -0
  15. package/dist/class/paginator.d.ts +31 -0
  16. package/dist/class/paginator.js +43 -0
  17. package/dist/class/reply.d.ts +29 -0
  18. package/dist/class/reply.js +44 -0
  19. package/dist/class/security.d.ts +186 -0
  20. package/dist/class/security.js +178 -0
  21. package/dist/class/trigger_operator.d.ts +92 -0
  22. package/dist/class/trigger_operator.js +99 -0
  23. package/dist/class/user.d.ts +81 -0
  24. package/dist/class/user.js +151 -0
  25. package/dist/class/validator.d.ts +19 -0
  26. package/dist/class/validator.js +101 -0
  27. package/dist/config.d.ts +113 -0
  28. package/dist/config.js +26 -0
  29. package/dist/defult-permissions.d.ts +2 -0
  30. package/dist/defult-permissions.js +31 -0
  31. package/dist/events.d.ts +23 -0
  32. package/dist/events.js +47 -0
  33. package/dist/helper/data_insertion.d.ts +38 -0
  34. package/dist/helper/data_insertion.js +110 -0
  35. package/dist/helper/presetup_services.d.ts +60 -0
  36. package/dist/helper/presetup_services.js +108 -0
  37. package/dist/index.d.ts +118 -0
  38. package/dist/middlewares.d.ts +53 -0
  39. package/dist/middlewares.js +106 -0
  40. package/dist/play-test.d.ts +1 -0
  41. package/dist/play-test.js +9 -0
  42. package/dist/services/data_provider/router.d.ts +4 -0
  43. package/dist/services/data_provider/router.js +412 -0
  44. package/dist/services/data_provider/service.d.ts +132 -0
  45. package/dist/services/data_provider/service.js +253 -0
  46. package/dist/services/data_provider/typeCasters.d.ts +9 -0
  47. package/dist/services/data_provider/typeCasters.js +18 -0
  48. package/dist/services/file/db.d.ts +1 -0
  49. package/dist/services/file/db.js +31 -0
  50. package/dist/services/file/router.d.ts +4 -0
  51. package/dist/services/file/router.js +115 -0
  52. package/dist/services/file/service.d.ts +204 -0
  53. package/dist/services/file/service.js +341 -0
  54. package/dist/services/functions/router.d.ts +4 -0
  55. package/dist/services/functions/router.js +68 -0
  56. package/dist/services/functions/service.d.ts +132 -0
  57. package/dist/services/functions/service.js +159 -0
  58. package/dist/services/jwt/router.d.ts +4 -0
  59. package/dist/services/jwt/router.js +99 -0
  60. package/dist/services/jwt/service.d.ts +97 -0
  61. package/dist/services/jwt/service.js +135 -0
  62. package/dist/services/user_manager/db.d.ts +1 -0
  63. package/dist/services/user_manager/db.js +75 -0
  64. package/dist/services/user_manager/permissionManager.d.ts +19 -0
  65. package/dist/services/user_manager/permissionManager.js +42 -0
  66. package/dist/services/user_manager/router.d.ts +4 -0
  67. package/dist/services/user_manager/router.js +195 -0
  68. package/dist/services/user_manager/service.d.ts +317 -0
  69. package/dist/services/user_manager/service.js +632 -0
  70. package/package.json +3 -3
  71. package/src/application.ts +1 -1
  72. package/src/class/cms_trigger.ts +8 -14
  73. package/src/class/database_trigger.ts +10 -4
  74. package/src/class/user.ts +1 -1
  75. package/src/services/data_provider/router.ts +293 -0
  76. package/src/services/data_provider/service.ts +2 -1
  77. package/src/services/functions/router.ts +3 -2
  78. package/src/services/user_manager/db.ts +5 -5
  79. package/src/services/user_manager/service.ts +20 -15
@@ -0,0 +1,29 @@
1
+ import Koa from 'koa';
2
+ import { Server } from 'http';
3
+ import { RestOptions } from './config';
4
+ /**
5
+ * Create a modular REST instance with Koa and MongoDB support.
6
+ *
7
+ * @param {RestOptions} options - Options for the REST instance
8
+ * @expandType RestOptions
9
+ *
10
+ * @returns {Promise<{ app: Koa; server?: Server }>} - A promise that resolves to the Koa app and server
11
+ *
12
+ * @example
13
+ * import { createRest } from '@modular-rest/server';
14
+ *
15
+ * const app = createRest({
16
+ * port: '80',
17
+ * mongo: {
18
+ * mongoBaseAddress: 'mongodb://localhost:27017',
19
+ * dbPrefix: 'mrest_'
20
+ * },
21
+ * onBeforeInit: (koaApp) => {
22
+ * // do something before init with the koa app
23
+ * }
24
+ * })
25
+ */
26
+ export declare function createRest(options: RestOptions): Promise<{
27
+ app: Koa;
28
+ server?: Server;
29
+ }>;
@@ -0,0 +1,217 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.createRest = createRest;
40
+ const koa_1 = __importDefault(require("koa"));
41
+ const cors_1 = __importDefault(require("@koa/cors"));
42
+ const koa_body_1 = __importDefault(require("koa-body"));
43
+ const koa_static_1 = __importDefault(require("koa-static"));
44
+ const koa_mount_1 = __importDefault(require("koa-mount"));
45
+ const path_1 = __importDefault(require("path"));
46
+ const combinator_1 = __importDefault(require("./class/combinator"));
47
+ const DataProvider = __importStar(require("./services/data_provider/service"));
48
+ const UserService = __importStar(require("./services/user_manager/service"));
49
+ const config_1 = require("./config");
50
+ const defult_permissions_1 = require("./defult-permissions");
51
+ const defaultServiceRoot = __dirname + '/services';
52
+ /**
53
+ * Create a modular REST instance with Koa and MongoDB support.
54
+ *
55
+ * @param {RestOptions} options - Options for the REST instance
56
+ * @expandType RestOptions
57
+ *
58
+ * @returns {Promise<{ app: Koa; server?: Server }>} - A promise that resolves to the Koa app and server
59
+ *
60
+ * @example
61
+ * import { createRest } from '@modular-rest/server';
62
+ *
63
+ * const app = createRest({
64
+ * port: '80',
65
+ * mongo: {
66
+ * mongoBaseAddress: 'mongodb://localhost:27017',
67
+ * dbPrefix: 'mrest_'
68
+ * },
69
+ * onBeforeInit: (koaApp) => {
70
+ * // do something before init with the koa app
71
+ * }
72
+ * })
73
+ */
74
+ async function createRest(options) {
75
+ (0, config_1.setConfig)({
76
+ port: 3000,
77
+ dontListen: false,
78
+ mongo: {
79
+ mongoBaseAddress: 'mongodb://localhost:27017',
80
+ dbPrefix: 'mrest_',
81
+ },
82
+ adminUser: {
83
+ email: 'admin@email.com',
84
+ password: '@dmin',
85
+ },
86
+ ...options,
87
+ });
88
+ if (config_1.config.permissionGroups === undefined) {
89
+ config_1.config.permissionGroups = defult_permissions_1.permissionGroups;
90
+ }
91
+ const app = new koa_1.default();
92
+ /**
93
+ * Plug in Cors
94
+ */
95
+ app.use((0, cors_1.default)(config_1.config.cors || {}));
96
+ /**
97
+ * Plug in BodyParser
98
+ */
99
+ const bodyParserOptions = {
100
+ multipart: true,
101
+ ...(config_1.config.koaBodyOptions || {}),
102
+ };
103
+ app.use((0, koa_body_1.default)(bodyParserOptions));
104
+ /**
105
+ * Plug In KoaStatic
106
+ */
107
+ if (config_1.config.staticPath) {
108
+ const defaultStaticPath = config_1.config.staticPath.actualPath || '';
109
+ const defaultStaticRootPath = config_1.config.staticPath.path || '/assets';
110
+ const staticOptions = { ...config_1.config.staticPath, defer: true };
111
+ delete staticOptions.actualPath;
112
+ delete staticOptions.path;
113
+ app.use((0, koa_mount_1.default)(defaultStaticRootPath, (0, koa_static_1.default)(defaultStaticPath, staticOptions)));
114
+ }
115
+ /**
116
+ * Run before hook
117
+ */
118
+ if (config_1.config.onBeforeInit)
119
+ config_1.config.onBeforeInit(app);
120
+ /**
121
+ * Setup default services
122
+ *
123
+ * - Collect and plug in router.js/db.js of default services
124
+ * - Setting up default services
125
+ */
126
+ // 1. Plug in default routes
127
+ await combinator_1.default.combineRoutesByFilePath(path_1.default.join(defaultServiceRoot), app);
128
+ // Collect default databaseDefinitions
129
+ const defaultDatabaseDefinitionList = await combinator_1.default.combineModulesByFilePath({
130
+ rootDirectory: defaultServiceRoot,
131
+ filename: {
132
+ name: 'db',
133
+ extension: '.js',
134
+ },
135
+ combineWithRoot: true,
136
+ });
137
+ // 2. Plug in default databaseDefinitions
138
+ await DataProvider.addCollectionDefinitionByList({
139
+ list: defaultDatabaseDefinitionList,
140
+ mongoOption: config_1.config.mongo,
141
+ });
142
+ /**
143
+ * User Services
144
+ *
145
+ * 3. Plug in routes and database
146
+ */
147
+ if (config_1.config.modulesPath) {
148
+ // Plug in user routes
149
+ await combinator_1.default.combineRoutesByFilePath(config_1.config.modulesPath, app);
150
+ // Collect user CollectionDefinitions (db.js files)
151
+ let userDatabaseDetail = [];
152
+ userDatabaseDetail = await combinator_1.default.combineModulesByFilePath({
153
+ rootDirectory: config_1.config.modulesPath,
154
+ filename: {
155
+ name: 'db',
156
+ extension: '.js',
157
+ },
158
+ combineWithRoot: true,
159
+ });
160
+ // Combine additional CollectionDefinitions
161
+ if (config_1.config.collectionDefinitions) {
162
+ userDatabaseDetail = userDatabaseDetail.concat(config_1.config.collectionDefinitions);
163
+ }
164
+ // Plug in user CollectionDefinitions
165
+ await DataProvider.addCollectionDefinitionByList({
166
+ list: userDatabaseDetail || [],
167
+ mongoOption: config_1.config.mongo,
168
+ });
169
+ // Plug in Verification method
170
+ if (typeof config_1.config.verificationCodeGeneratorMethod === 'function') {
171
+ UserService.main.setCustomVerificationCodeGeneratorMethod(config_1.config.verificationCodeGeneratorMethod);
172
+ }
173
+ // 4. plug in modular functions
174
+ await combinator_1.default.combineFunctionsByFilePath({
175
+ rootDirectory: config_1.config.modulesPath,
176
+ filename: {
177
+ name: 'functions',
178
+ extension: '.js',
179
+ },
180
+ });
181
+ // 5. Plug in additional defined functions
182
+ if (config_1.config.functions) {
183
+ combinator_1.default.addFunctionsByArray(config_1.config.functions);
184
+ }
185
+ }
186
+ // 4. Setting up default services
187
+ try {
188
+ await require('./helper/presetup_services').setup(options);
189
+ }
190
+ catch (e) {
191
+ return Promise.reject(e);
192
+ }
193
+ /**
194
+ * Run the server
195
+ *
196
+ * return KOA app object
197
+ */
198
+ return new Promise((done, reject) => {
199
+ try {
200
+ let server;
201
+ if (!config_1.config.dontListen) {
202
+ server = app.listen(config_1.config.port);
203
+ console.log('\x1b[35m', `KOAS has been launched on: localhost:${config_1.config.port}`);
204
+ }
205
+ // on after init
206
+ if (config_1.config.onAfterInit)
207
+ config_1.config.onAfterInit(app);
208
+ done({
209
+ app,
210
+ server,
211
+ });
212
+ }
213
+ catch (err) {
214
+ reject(err);
215
+ }
216
+ });
217
+ }
@@ -0,0 +1,52 @@
1
+ import { DatabaseTriggerContext } from './database_trigger';
2
+ /**
3
+ * Type for CMS operations that can trigger a callback
4
+ * @typedef {('update-one' | 'insert-one' | 'remove-one')} CmsOperation
5
+ * @description Supported CMS operations:
6
+ * - 'update-one': Triggered when updating a single document in the CMS
7
+ * - 'insert-one': Triggered when inserting a new document in the CMS
8
+ * - 'remove-one': Triggered when removing a document from the CMS
9
+ */
10
+ export type CmsOperation = 'update-one' | 'insert-one' | 'remove-one';
11
+ /**
12
+ * Defines a callback to be executed on specific CMS operations
13
+ * @class CmsTrigger
14
+ * @property {CmsOperation} operation - The CMS operation that triggers the callback
15
+ * @property {Function} callback - The callback function to be executed
16
+ * @example
17
+ * ```typescript
18
+ * const trigger = new CmsTrigger('insert-one', (context) => {
19
+ * console.log('New CMS document inserted:', context.queryResult);
20
+ * // Perform additional actions after CMS document insertion.
21
+ * });
22
+ *
23
+ * // Use the trigger in RestOptions
24
+ * const { app } = await createRest({
25
+ * authTriggers: [trigger],
26
+ * // ... other options
27
+ * });
28
+ * ```
29
+ */
30
+ export declare class CmsTrigger {
31
+ operation: CmsOperation;
32
+ callback: (context: DatabaseTriggerContext) => void;
33
+ /**
34
+ * Creates a new CmsTrigger instance
35
+ * @param {CmsOperation} operation - The CMS operation to trigger on
36
+ * @param {Function} [callback=() => {}] - The callback function to execute
37
+ * @example
38
+ * ```typescript
39
+ * // Log all CMS updates
40
+ * const updateTrigger = new CmsTrigger('update-one', (context) => {
41
+ * console.log('CMS document updated:', context.queryResult);
42
+ * });
43
+ *
44
+ * // Track CMS document removals
45
+ * const removeTrigger = new CmsTrigger('remove-one', (context) => {
46
+ * console.log('CMS document removed:', context.queryResult);
47
+ * });
48
+ * ```
49
+ */
50
+ constructor(operation: CmsOperation, callback?: (context: DatabaseTriggerContext) => void);
51
+ }
52
+ export default CmsTrigger;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CmsTrigger = void 0;
4
+ /**
5
+ * Defines a callback to be executed on specific CMS operations
6
+ * @class CmsTrigger
7
+ * @property {CmsOperation} operation - The CMS operation that triggers the callback
8
+ * @property {Function} callback - The callback function to be executed
9
+ * @example
10
+ * ```typescript
11
+ * const trigger = new CmsTrigger('insert-one', (context) => {
12
+ * console.log('New CMS document inserted:', context.queryResult);
13
+ * // Perform additional actions after CMS document insertion.
14
+ * });
15
+ *
16
+ * // Use the trigger in RestOptions
17
+ * const { app } = await createRest({
18
+ * authTriggers: [trigger],
19
+ * // ... other options
20
+ * });
21
+ * ```
22
+ */
23
+ class CmsTrigger {
24
+ /**
25
+ * Creates a new CmsTrigger instance
26
+ * @param {CmsOperation} operation - The CMS operation to trigger on
27
+ * @param {Function} [callback=() => {}] - The callback function to execute
28
+ * @example
29
+ * ```typescript
30
+ * // Log all CMS updates
31
+ * const updateTrigger = new CmsTrigger('update-one', (context) => {
32
+ * console.log('CMS document updated:', context.queryResult);
33
+ * });
34
+ *
35
+ * // Track CMS document removals
36
+ * const removeTrigger = new CmsTrigger('remove-one', (context) => {
37
+ * console.log('CMS document removed:', context.queryResult);
38
+ * });
39
+ * ```
40
+ */
41
+ constructor(operation, callback = () => { }) {
42
+ this.operation = operation;
43
+ this.callback = callback;
44
+ }
45
+ }
46
+ exports.CmsTrigger = CmsTrigger;
47
+ exports.default = CmsTrigger;
@@ -0,0 +1,112 @@
1
+ import { Schema } from 'mongoose';
2
+ import { Permission } from './security';
3
+ import { DatabaseTrigger } from './database_trigger';
4
+ /**
5
+ * Configuration options for creating a collection definition.
6
+ * This interface defines the structure for configuring MongoDB collections with their associated
7
+ * schemas, permissions, and triggers.
8
+ *
9
+ * @inline
10
+ *
11
+ */
12
+ interface CollectionDefinitionOptions {
13
+ /** The name of the database where the collection resides */
14
+ database: string;
15
+ /** The name of the collection to be configured */
16
+ collection: string;
17
+ /** List of permissions controlling access to the collection */
18
+ permissions: Permission[];
19
+ /** Optional database triggers for custom operations */
20
+ triggers?: DatabaseTrigger[];
21
+ /**
22
+ * Mongoose schema definition for the collection
23
+ * @type {Schema}
24
+ * @see https://mongoosejs.com/docs/5.x/docs/guide.html
25
+ */
26
+ schema: Schema<any>;
27
+ }
28
+ /**
29
+ * To have define any collection in your database you haveto use below method in your `db.[js|ts]` file and export an array of CollectionDefinition instances.
30
+ *
31
+ * @param {CollectionDefinitionOptions} options - The options for the collection
32
+ * @expandType CollectionDefinitionOptions
33
+ *
34
+ * @returns A new instance of CollectionDefinition
35
+ *
36
+ * @public
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * import { defineCollection } from '@modular-rest/server';
41
+ *
42
+ * export default [
43
+ * defineCollection({
44
+ * database: 'users',
45
+ * collection: 'info',
46
+ * // schema: Schema,
47
+ * // permissions: Permission[]
48
+ * // trigger: DatabaseTrigger[]
49
+ * })
50
+ * ]
51
+ * ```
52
+ */
53
+ export declare function defineCollection(options: CollectionDefinitionOptions): CollectionDefinition;
54
+ /**
55
+ * A class that represents a MongoDB collection configuration. Provides full support for schema validation, access control through permissions,
56
+ * and custom triggers for various database operations.
57
+ *
58
+ * @hideconstructor
59
+ *
60
+ * @deprecated Use `defineCollection` instead.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const userSchema = new Schema({
65
+ * name: String,
66
+ * email: String,
67
+ * age: Number
68
+ * });
69
+ *
70
+ * const collection = new CollectionDefinition({
71
+ * database: 'myapp',
72
+ * collection: 'users',
73
+ * schema: userSchema,
74
+ * permissions: [
75
+ * new Permission({
76
+ * type: 'user_access',
77
+ * read: true,
78
+ * write: true
79
+ * })
80
+ * ],
81
+ * triggers: [
82
+ * new DatabaseTrigger('insert-one', (data) => {
83
+ * console.log('New user created:', data);
84
+ * })
85
+ * ]
86
+ * });
87
+ * ```
88
+ *
89
+ * @private
90
+ */
91
+ export declare class CollectionDefinition {
92
+ /** @readonly The name of the database */
93
+ database: string;
94
+ /** @readonly The name of the collection */
95
+ collection: string;
96
+ /** @readonly Mongoose schema definition */
97
+ schema: Schema<any>;
98
+ /** @readonly List of permissions for the collection */
99
+ permissions: Permission[];
100
+ /** @readonly Optional database triggers */
101
+ triggers?: DatabaseTrigger[];
102
+ /**
103
+ * Creates a new CollectionDefinition instance
104
+ *
105
+ * @param options - Configuration options for the collection
106
+ * @returns A new instance of CollectionDefinition
107
+ *
108
+ * @beta
109
+ */
110
+ constructor({ database, collection, schema, permissions, triggers, }: CollectionDefinitionOptions);
111
+ }
112
+ export {};
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CollectionDefinition = void 0;
4
+ exports.defineCollection = defineCollection;
5
+ /**
6
+ * To have define any collection in your database you haveto use below method in your `db.[js|ts]` file and export an array of CollectionDefinition instances.
7
+ *
8
+ * @param {CollectionDefinitionOptions} options - The options for the collection
9
+ * @expandType CollectionDefinitionOptions
10
+ *
11
+ * @returns A new instance of CollectionDefinition
12
+ *
13
+ * @public
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { defineCollection } from '@modular-rest/server';
18
+ *
19
+ * export default [
20
+ * defineCollection({
21
+ * database: 'users',
22
+ * collection: 'info',
23
+ * // schema: Schema,
24
+ * // permissions: Permission[]
25
+ * // trigger: DatabaseTrigger[]
26
+ * })
27
+ * ]
28
+ * ```
29
+ */
30
+ function defineCollection(options) {
31
+ return new CollectionDefinition(options);
32
+ }
33
+ /**
34
+ * A class that represents a MongoDB collection configuration. Provides full support for schema validation, access control through permissions,
35
+ * and custom triggers for various database operations.
36
+ *
37
+ * @hideconstructor
38
+ *
39
+ * @deprecated Use `defineCollection` instead.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const userSchema = new Schema({
44
+ * name: String,
45
+ * email: String,
46
+ * age: Number
47
+ * });
48
+ *
49
+ * const collection = new CollectionDefinition({
50
+ * database: 'myapp',
51
+ * collection: 'users',
52
+ * schema: userSchema,
53
+ * permissions: [
54
+ * new Permission({
55
+ * type: 'user_access',
56
+ * read: true,
57
+ * write: true
58
+ * })
59
+ * ],
60
+ * triggers: [
61
+ * new DatabaseTrigger('insert-one', (data) => {
62
+ * console.log('New user created:', data);
63
+ * })
64
+ * ]
65
+ * });
66
+ * ```
67
+ *
68
+ * @private
69
+ */
70
+ class CollectionDefinition {
71
+ /**
72
+ * Creates a new CollectionDefinition instance
73
+ *
74
+ * @param options - Configuration options for the collection
75
+ * @returns A new instance of CollectionDefinition
76
+ *
77
+ * @beta
78
+ */
79
+ constructor({ database, collection, schema, permissions, triggers, }) {
80
+ this.database = database;
81
+ this.collection = collection;
82
+ this.schema = schema;
83
+ this.permissions = permissions;
84
+ this.triggers = triggers;
85
+ }
86
+ }
87
+ exports.CollectionDefinition = CollectionDefinition;
@@ -0,0 +1,43 @@
1
+ import Koa from 'koa';
2
+ interface FilenameOption {
3
+ name: string;
4
+ extension: string;
5
+ }
6
+ interface ModuleOptions {
7
+ rootDirectory: string;
8
+ filename: FilenameOption;
9
+ combineWithRoot?: boolean;
10
+ convertToArray?: boolean;
11
+ }
12
+ interface FunctionOptions {
13
+ rootDirectory: string;
14
+ filename: FilenameOption;
15
+ }
16
+ declare class Combinator {
17
+ combineRoutesByFilePath(rootDirectory: string, app: Koa): Promise<void>;
18
+ /**
19
+ * Combine modules from files in a directory
20
+ * @param options - Configuration options
21
+ */
22
+ combineModulesByFilePath({ rootDirectory, filename, combineWithRoot, convertToArray, }: ModuleOptions): Promise<any>;
23
+ /**
24
+ * Combine functions from files in a directory
25
+ * @param options - Function options
26
+ */
27
+ combineFunctionsByFilePath({ rootDirectory, filename }: FunctionOptions): Promise<void>;
28
+ /**
29
+ * Add functions from an array
30
+ * @param functionList - List of functions to add
31
+ */
32
+ addFunctionsByArray(functionList: any[]): void;
33
+ /**
34
+ * Extend an object with properties from another
35
+ * @param obj - Target object
36
+ * @param src - Source object
37
+ * @returns Extended object
38
+ */
39
+ extendObj(obj: any, src: any): any;
40
+ static get instance(): Combinator;
41
+ }
42
+ declare const instance: Combinator;
43
+ export = instance;