@common-stack/server-core 0.1.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.
- package/CHANGELOG.md +160 -0
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/lib/connector/connector.d.ts +381 -0
- package/lib/connector/index.d.ts +1 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/types.d.ts +8 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +759 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/connector.d.ts +44 -0
- package/lib/interfaces/index.d.ts +6 -0
- package/lib/interfaces/mongo-migration.d.ts +4 -0
- package/lib/interfaces/permissions.d.ts +5 -0
- package/lib/interfaces/policies.d.ts +5 -0
- package/lib/interfaces/roles.d.ts +8 -0
- package/lib/interfaces/rules.d.ts +12 -0
- package/lib/logger/index.d.ts +1 -0
- package/lib/logger/logger.d.ts +2 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/preferences.d.ts +53 -0
- package/package.json +53 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
module.exports =
|
|
2
|
+
/******/ (function(modules) { // webpackBootstrap
|
|
3
|
+
/******/ // The module cache
|
|
4
|
+
/******/ var installedModules = {};
|
|
5
|
+
/******/
|
|
6
|
+
/******/ // The require function
|
|
7
|
+
/******/ function __webpack_require__(moduleId) {
|
|
8
|
+
/******/
|
|
9
|
+
/******/ // Check if module is in cache
|
|
10
|
+
/******/ if(installedModules[moduleId]) {
|
|
11
|
+
/******/ return installedModules[moduleId].exports;
|
|
12
|
+
/******/ }
|
|
13
|
+
/******/ // Create a new module (and put it into the cache)
|
|
14
|
+
/******/ var module = installedModules[moduleId] = {
|
|
15
|
+
/******/ i: moduleId,
|
|
16
|
+
/******/ l: false,
|
|
17
|
+
/******/ exports: {}
|
|
18
|
+
/******/ };
|
|
19
|
+
/******/
|
|
20
|
+
/******/ // Execute the module function
|
|
21
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22
|
+
/******/
|
|
23
|
+
/******/ // Flag the module as loaded
|
|
24
|
+
/******/ module.l = true;
|
|
25
|
+
/******/
|
|
26
|
+
/******/ // Return the exports of the module
|
|
27
|
+
/******/ return module.exports;
|
|
28
|
+
/******/ }
|
|
29
|
+
/******/
|
|
30
|
+
/******/
|
|
31
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
32
|
+
/******/ __webpack_require__.m = modules;
|
|
33
|
+
/******/
|
|
34
|
+
/******/ // expose the module cache
|
|
35
|
+
/******/ __webpack_require__.c = installedModules;
|
|
36
|
+
/******/
|
|
37
|
+
/******/ // define getter function for harmony exports
|
|
38
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ };
|
|
43
|
+
/******/
|
|
44
|
+
/******/ // define __esModule on exports
|
|
45
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
46
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
+
/******/ }
|
|
49
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
/******/ };
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // create a fake namespace object
|
|
53
|
+
/******/ // mode & 1: value is a module id, require it
|
|
54
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
55
|
+
/******/ // mode & 4: return value when already ns object
|
|
56
|
+
/******/ // mode & 8|1: behave like require
|
|
57
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
58
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59
|
+
/******/ if(mode & 8) return value;
|
|
60
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61
|
+
/******/ var ns = Object.create(null);
|
|
62
|
+
/******/ __webpack_require__.r(ns);
|
|
63
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
64
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
65
|
+
/******/ return ns;
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/
|
|
68
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69
|
+
/******/ __webpack_require__.n = function(module) {
|
|
70
|
+
/******/ var getter = module && module.__esModule ?
|
|
71
|
+
/******/ function getDefault() { return module['default']; } :
|
|
72
|
+
/******/ function getModuleExports() { return module; };
|
|
73
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74
|
+
/******/ return getter;
|
|
75
|
+
/******/ };
|
|
76
|
+
/******/
|
|
77
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
|
78
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79
|
+
/******/
|
|
80
|
+
/******/ // __webpack_public_path__
|
|
81
|
+
/******/ __webpack_require__.p = "";
|
|
82
|
+
/******/
|
|
83
|
+
/******/
|
|
84
|
+
/******/ // Load entry module and return exports
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.ts");
|
|
86
|
+
/******/ })
|
|
87
|
+
/************************************************************************/
|
|
88
|
+
/******/ ({
|
|
89
|
+
|
|
90
|
+
/***/ "./src/connector/connector.ts":
|
|
91
|
+
/*!************************************!*\
|
|
92
|
+
!*** ./src/connector/connector.ts ***!
|
|
93
|
+
\************************************/
|
|
94
|
+
/*! no static exports found */
|
|
95
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
96
|
+
|
|
97
|
+
"use strict";
|
|
98
|
+
|
|
99
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100
|
+
exports.Feature = exports.featureCatalog = void 0;
|
|
101
|
+
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
102
|
+
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
|
103
|
+
const utils_1 = __webpack_require__(/*! ../utils */ "./src/utils/index.ts");
|
|
104
|
+
exports.featureCatalog = {};
|
|
105
|
+
const combine = (features, extractor) => lodash_1.without(lodash_1.union(...lodash_1.map(features, (res) => lodash_1.castArray(extractor(res)))), undefined);
|
|
106
|
+
class Feature {
|
|
107
|
+
constructor(feature, ...features) {
|
|
108
|
+
const args = [feature, ...features];
|
|
109
|
+
combine(args, arg => arg.catalogInfo).forEach(info => Object.keys(info).forEach(key => (exports.featureCatalog[key] = info[key])));
|
|
110
|
+
this.schema = combine(args, (arg) => arg.schema);
|
|
111
|
+
this.createDirectivesFunc = combine(args, (arg) => arg.createDirectivesFunc);
|
|
112
|
+
this.createResolversFunc = combine(args, (arg) => arg.createResolversFunc);
|
|
113
|
+
this.createContextFunc = combine(args, (arg) => arg.createContextFunc);
|
|
114
|
+
this.createServiceFunc = combine(args, (arg) => arg.createServiceFunc);
|
|
115
|
+
this.preCreateServiceFunc = combine(args, (arg) => arg.preCreateServiceFunc);
|
|
116
|
+
this.postCreateServiceFunc = combine(args, (arg) => arg.postCreateServiceFunc);
|
|
117
|
+
this.preStartFunc = combine(args, (arg) => arg.preStartFunc);
|
|
118
|
+
this.postStartFunc = combine(args, (arg) => arg.postStartFunc);
|
|
119
|
+
this.microservicePreStartFunc = combine(args, (arg) => arg.microservicePreStartFunc);
|
|
120
|
+
this.microservicePostStartFunc = combine(args, (arg) => arg.microservicePostStartFunc);
|
|
121
|
+
this.addBrokerMainServiceClass = combine(args, (arg) => arg.addBrokerMainServiceClass);
|
|
122
|
+
this.addBrokerClientServiceClass = combine(args, (arg) => arg.addBrokerClientServiceClass);
|
|
123
|
+
this.disposeFunc = combine(args, (arg) => arg.disposeFunc);
|
|
124
|
+
this.federation = combine(args, (arg) => arg.federation);
|
|
125
|
+
this.migrations = combine(args, (arg) => arg);
|
|
126
|
+
this.createContainerFunc = combine(args, (arg) => arg.createContainerFunc);
|
|
127
|
+
this.createHemeraContainerFunc = combine(args, (arg) => arg.createHemeraContainerFunc);
|
|
128
|
+
this.createAsyncContainerFunc = combine(args, (arg) => arg.createAsyncContainerFunc);
|
|
129
|
+
this.createAsyncHemeraContainerFunc = combine(args, (arg) => arg.createAsyncHemeraContainerFunc);
|
|
130
|
+
this.updateContainerFunc = combine(args, (arg) => arg.updateContainerFunc);
|
|
131
|
+
this.createDataSourceFunc = combine(args, (arg) => arg.createDataSourceFunc);
|
|
132
|
+
this.beforeware = combine(args, (arg) => arg.beforeware);
|
|
133
|
+
this.middleware = combine(args, (arg) => arg.middleware);
|
|
134
|
+
this.createWebsocketConfig = combine(args, (arg) => arg.createWebsocketConfig);
|
|
135
|
+
this.createPreference = combine(args, (arg) => arg.createPreference);
|
|
136
|
+
this.addPermissions = {
|
|
137
|
+
createPermissions: combine(args, (arg) => arg.addPermissions &&
|
|
138
|
+
arg.addPermissions.createPermissions),
|
|
139
|
+
overwritePermissions: combine(args, (arg) => arg.addPermissions &&
|
|
140
|
+
arg.addPermissions.overwritePermissions),
|
|
141
|
+
};
|
|
142
|
+
this.addPolicies = {
|
|
143
|
+
createPolicies: combine(args, (arg) => arg.addPolicies &&
|
|
144
|
+
arg.addPolicies.createPolicies),
|
|
145
|
+
overwritePolicies: combine(args, (arg) => arg.addPolicies &&
|
|
146
|
+
arg.addPolicies.overwritePolicies),
|
|
147
|
+
};
|
|
148
|
+
this.rolesUpdate = {
|
|
149
|
+
createRoles: combine(args, (arg) => arg.rolesUpdate &&
|
|
150
|
+
arg.rolesUpdate.createRoles),
|
|
151
|
+
overwriteRolesPermissions: combine(args, (arg) => arg.rolesUpdate &&
|
|
152
|
+
arg.rolesUpdate.overwriteRolesPermissions),
|
|
153
|
+
};
|
|
154
|
+
this.overwritePreference = combine(args, (arg) => arg.overwritePreference);
|
|
155
|
+
this._rules = combine(args, (arg) => arg.rules);
|
|
156
|
+
}
|
|
157
|
+
get rules() {
|
|
158
|
+
return this._rules.reduce((acc, curr) => {
|
|
159
|
+
return lodash_1.merge(acc, curr);
|
|
160
|
+
}, {});
|
|
161
|
+
}
|
|
162
|
+
get schemas() {
|
|
163
|
+
return this.schema;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Creates context
|
|
167
|
+
* @param req
|
|
168
|
+
* @param connectionParams
|
|
169
|
+
* @param webSocket
|
|
170
|
+
* @deprecated
|
|
171
|
+
*/
|
|
172
|
+
async createContext(req, connectionParams, webSocket) {
|
|
173
|
+
const results = await Promise.all(this.createContextFunc.map(createContext => createContext(req, connectionParams, webSocket)));
|
|
174
|
+
return lodash_1.merge({}, ...results);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* If you need to attach service to Graphql Context, you can use this function.
|
|
178
|
+
* It should be called twice to get the context.
|
|
179
|
+
*/
|
|
180
|
+
createServiceContext(options, updateOptions) {
|
|
181
|
+
return async (req, connectionParams, webSocket) => {
|
|
182
|
+
await this.createService(options, updateOptions);
|
|
183
|
+
const results = await Promise.all(this.createContextFunc.map(createContext => createContext(req, connectionParams, webSocket)));
|
|
184
|
+
return lodash_1.merge({}, ...results, Object.assign({}, this.services));
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Its wrapper to container to get services
|
|
189
|
+
* @param container
|
|
190
|
+
*/
|
|
191
|
+
async createService(options, updateOptions) {
|
|
192
|
+
try {
|
|
193
|
+
if (this.container) {
|
|
194
|
+
this.updateContainers(options, updateOptions);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
await this.createContainers(options);
|
|
198
|
+
await Promise.all(this.preCreateServiceFunc.map(async (createService) => await createService(this.container)));
|
|
199
|
+
}
|
|
200
|
+
this.services = lodash_1.merge({}, ...this.createServiceFunc.map(createService => createService(this.container)));
|
|
201
|
+
await Promise.all(this.postCreateServiceFunc.map(async (createService) => await createService(this.container)));
|
|
202
|
+
return this.services;
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
throw err;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Pre start action will be executed there.
|
|
210
|
+
*
|
|
211
|
+
*/
|
|
212
|
+
async preStart(options) {
|
|
213
|
+
return await Promise.all(this.preStartFunc.map(async (preStart) => await preStart(this.container, options)));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Post start actions will be executed here.
|
|
217
|
+
*/
|
|
218
|
+
async postStart(options) {
|
|
219
|
+
return await Promise.all(this.postStartFunc.map(async (postStart) => await postStart(this.container, options)));
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Pre start action will be executed there.
|
|
223
|
+
*
|
|
224
|
+
*/
|
|
225
|
+
async microservicePreStart(options) {
|
|
226
|
+
return await Promise.all(this.microservicePreStartFunc.map(async (preStart) => await preStart(this.container, options)));
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Post start actions will be executed here.
|
|
230
|
+
*/
|
|
231
|
+
async microservicePostStart(options) {
|
|
232
|
+
return await Promise.all(this.microservicePostStartFunc.map(async (postStart) => await postStart(this.container, options)));
|
|
233
|
+
}
|
|
234
|
+
createDataSource(options) {
|
|
235
|
+
return this.dataSources = lodash_1.merge({}, ...this.createDataSourceFunc.map(createDataSource => createDataSource(this.container)));
|
|
236
|
+
}
|
|
237
|
+
createResolvers(options) {
|
|
238
|
+
return lodash_1.merge({}, ...this.createResolversFunc.map(createResolvers => createResolvers(options)));
|
|
239
|
+
}
|
|
240
|
+
createDirectives(options) {
|
|
241
|
+
return lodash_1.merge({}, ...this.createDirectivesFunc.map(createDirectives => createDirectives(options)));
|
|
242
|
+
}
|
|
243
|
+
async createContainers(options, containerOptions = { skipBaseClassChecks: true }) {
|
|
244
|
+
this.container = new inversify_1.Container(containerOptions);
|
|
245
|
+
this.createContainerFunc.map(createModule => {
|
|
246
|
+
this.container.load(createModule(options));
|
|
247
|
+
});
|
|
248
|
+
await Promise.all(this.createAsyncContainerFunc
|
|
249
|
+
.map(async (asyncCreateModule) => {
|
|
250
|
+
await this.container.loadAsync(asyncCreateModule(options));
|
|
251
|
+
}));
|
|
252
|
+
this.container.bind('IDefaultSettings').toConstantValue(this.getPreferences());
|
|
253
|
+
this.container.bind('IDefaultSettingsObj').toConstantValue(this.getPreferencesObj());
|
|
254
|
+
// permissions
|
|
255
|
+
this.container.bind('IDefaultPermissions').toConstantValue(this.getPermissionPreferences());
|
|
256
|
+
this.container.bind('IDefaultPermissionsObj').toConstantValue(this.getPermissionPreferencesObj());
|
|
257
|
+
this.container.bind('IDefaultRoles').toConstantValue(this.getRoles());
|
|
258
|
+
this.container.bind('IDefaultPoliciesObj').toConstantValue(this.getPolicyPreferencesObj());
|
|
259
|
+
return this.container;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Use createMicroserviceContainer
|
|
263
|
+
* @param options
|
|
264
|
+
* @deprecated
|
|
265
|
+
*/
|
|
266
|
+
async createHemeraContainers(options) {
|
|
267
|
+
return this.createMicroserviceContainers(options);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates container for the microservice
|
|
271
|
+
*
|
|
272
|
+
* @param options
|
|
273
|
+
*/
|
|
274
|
+
async createMicroserviceContainers(options) {
|
|
275
|
+
this.hemeraContainer = new inversify_1.Container();
|
|
276
|
+
this.createHemeraContainerFunc.map(createModule => {
|
|
277
|
+
this.hemeraContainer.load(createModule(options));
|
|
278
|
+
});
|
|
279
|
+
await Promise.all(this.createAsyncHemeraContainerFunc
|
|
280
|
+
.map(async (asyncCreateModule) => {
|
|
281
|
+
await this.hemeraContainer.loadAsync(asyncCreateModule(options));
|
|
282
|
+
}));
|
|
283
|
+
return this.hemeraContainer;
|
|
284
|
+
}
|
|
285
|
+
updateContainers(options, updateOptions) {
|
|
286
|
+
let mergedModules = lodash_1.merge({}, ...this.updateContainerFunc);
|
|
287
|
+
const matchingModules = [];
|
|
288
|
+
if (updateOptions) {
|
|
289
|
+
updateOptions.forEach(option => {
|
|
290
|
+
const dispose = this.disposeFunc.find(el => el.container === option);
|
|
291
|
+
if (dispose) {
|
|
292
|
+
this.services[dispose.ctx].dispose();
|
|
293
|
+
}
|
|
294
|
+
const searchModule = mergedModules[option];
|
|
295
|
+
if (searchModule) {
|
|
296
|
+
matchingModules.push(searchModule);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
matchingModules.map(createModule => this.container.load(createModule(options)));
|
|
301
|
+
}
|
|
302
|
+
loadMainMoleculerService({ container, broker, settings }) {
|
|
303
|
+
this.addBrokerMainServiceClass.map(serviceClass => broker.createService(serviceClass, { container, settings }));
|
|
304
|
+
}
|
|
305
|
+
loadClientMoleculerService({ container, broker, settings }) {
|
|
306
|
+
this.addBrokerClientServiceClass.map(serviceClass => broker.createService(serviceClass, { container, settings }));
|
|
307
|
+
}
|
|
308
|
+
createDefaultPreferences() {
|
|
309
|
+
return utils_1.transformPrefsToArray(lodash_1.merge([], ...this.createPreference));
|
|
310
|
+
}
|
|
311
|
+
get beforewares() {
|
|
312
|
+
return this.beforeware;
|
|
313
|
+
}
|
|
314
|
+
get middlewares() {
|
|
315
|
+
return this.middleware;
|
|
316
|
+
}
|
|
317
|
+
getPreferences() {
|
|
318
|
+
return utils_1.transformPrefsToArray(this.getPreferencesObj());
|
|
319
|
+
}
|
|
320
|
+
getPreferencesObj() {
|
|
321
|
+
const defaultPrefs = lodash_1.merge([], ...this.createPreference);
|
|
322
|
+
const overwritePrefs = lodash_1.merge([], ...this.overwritePreference);
|
|
323
|
+
return utils_1.getCurrentPreferences(defaultPrefs, overwritePrefs);
|
|
324
|
+
}
|
|
325
|
+
getPermissionPreferences() {
|
|
326
|
+
return utils_1.transformPrefsToArray(this.getPermissionPreferencesObj());
|
|
327
|
+
}
|
|
328
|
+
getPermissionPreferencesObj() {
|
|
329
|
+
const { createPermissions = [], overwritePermissions = [] } = this.addPermissions;
|
|
330
|
+
const defaultPrefs = lodash_1.merge([], ...lodash_1.castArray(createPermissions));
|
|
331
|
+
const overwritePrefs = lodash_1.merge([], ...lodash_1.castArray(overwritePermissions));
|
|
332
|
+
return utils_1.getCurrentPreferences(defaultPrefs, overwritePrefs);
|
|
333
|
+
}
|
|
334
|
+
getPolicyPreferences() {
|
|
335
|
+
return utils_1.transformPrefsToArray(this.getPolicyPreferencesObj());
|
|
336
|
+
}
|
|
337
|
+
getPolicyPreferencesObj() {
|
|
338
|
+
const { createPolicies = [], overwritePolicies = [] } = this.addPolicies;
|
|
339
|
+
const defaultPrefs = lodash_1.merge([], ...lodash_1.castArray(createPolicies));
|
|
340
|
+
const overwritePrefs = lodash_1.merge([], ...lodash_1.castArray(overwritePolicies));
|
|
341
|
+
return utils_1.getCurrentPreferences(defaultPrefs, overwritePrefs);
|
|
342
|
+
}
|
|
343
|
+
getRoles() {
|
|
344
|
+
const { createRoles, overwriteRolesPermissions } = this.rolesUpdate;
|
|
345
|
+
const mergedRoles = lodash_1.merge({}, ...lodash_1.castArray(createRoles));
|
|
346
|
+
const mergedOverwriteRolesPermissions = lodash_1.merge({}, ...lodash_1.castArray(overwriteRolesPermissions));
|
|
347
|
+
let result = {};
|
|
348
|
+
for (const role in mergedRoles) {
|
|
349
|
+
const rolePermission = mergedOverwriteRolesPermissions[role] ? lodash_1.merge({}, mergedRoles[role].permissions, mergedOverwriteRolesPermissions[role]) : mergedRoles[role].permissions;
|
|
350
|
+
const mmm = Object.assign(Object.assign({}, mergedRoles[role]), { permissions: Object.assign({}, rolePermission) });
|
|
351
|
+
result = lodash_1.merge({}, result, { [role]: mmm });
|
|
352
|
+
}
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
getRolesObj() {
|
|
356
|
+
const { createRoles } = this.rolesUpdate;
|
|
357
|
+
const defaultPrefs = lodash_1.merge([], ...lodash_1.castArray(createRoles));
|
|
358
|
+
const overwritePrefs = lodash_1.merge([], ...lodash_1.castArray(createRoles));
|
|
359
|
+
return utils_1.getCurrentPreferences(defaultPrefs, overwritePrefs);
|
|
360
|
+
}
|
|
361
|
+
getWebsocketConfig() {
|
|
362
|
+
return this.createWebsocketConfig.reduce((pre, curr) => {
|
|
363
|
+
return lodash_1.merge(pre, curr);
|
|
364
|
+
}, {});
|
|
365
|
+
}
|
|
366
|
+
convertArrayToObject(arrayObject) {
|
|
367
|
+
return arrayObject.reduce((pre, curr) => {
|
|
368
|
+
return lodash_1.merge(pre, curr);
|
|
369
|
+
}, {});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
exports.Feature = Feature;
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
/***/ }),
|
|
376
|
+
|
|
377
|
+
/***/ "./src/connector/index.ts":
|
|
378
|
+
/*!********************************!*\
|
|
379
|
+
!*** ./src/connector/index.ts ***!
|
|
380
|
+
\********************************/
|
|
381
|
+
/*! no static exports found */
|
|
382
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
383
|
+
|
|
384
|
+
"use strict";
|
|
385
|
+
|
|
386
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
387
|
+
if (k2 === undefined) k2 = k;
|
|
388
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
389
|
+
}) : (function(o, m, k, k2) {
|
|
390
|
+
if (k2 === undefined) k2 = k;
|
|
391
|
+
o[k2] = m[k];
|
|
392
|
+
}));
|
|
393
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
394
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
395
|
+
};
|
|
396
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
397
|
+
__exportStar(__webpack_require__(/*! ./connector */ "./src/connector/connector.ts"), exports);
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
/***/ }),
|
|
401
|
+
|
|
402
|
+
/***/ "./src/constants/index.ts":
|
|
403
|
+
/*!********************************!*\
|
|
404
|
+
!*** ./src/constants/index.ts ***!
|
|
405
|
+
\********************************/
|
|
406
|
+
/*! no static exports found */
|
|
407
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
408
|
+
|
|
409
|
+
"use strict";
|
|
410
|
+
|
|
411
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
412
|
+
if (k2 === undefined) k2 = k;
|
|
413
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
414
|
+
}) : (function(o, m, k, k2) {
|
|
415
|
+
if (k2 === undefined) k2 = k;
|
|
416
|
+
o[k2] = m[k];
|
|
417
|
+
}));
|
|
418
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
419
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
420
|
+
};
|
|
421
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
422
|
+
__exportStar(__webpack_require__(/*! ./types */ "./src/constants/types.ts"), exports);
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
/***/ }),
|
|
426
|
+
|
|
427
|
+
/***/ "./src/constants/types.ts":
|
|
428
|
+
/*!********************************!*\
|
|
429
|
+
!*** ./src/constants/types.ts ***!
|
|
430
|
+
\********************************/
|
|
431
|
+
/*! no static exports found */
|
|
432
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
433
|
+
|
|
434
|
+
"use strict";
|
|
435
|
+
|
|
436
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
437
|
+
exports.TYPES = void 0;
|
|
438
|
+
exports.TYPES = {
|
|
439
|
+
IHemeraSettings: Symbol.for('IHemeraSettings'),
|
|
440
|
+
IDefaultSettings: Symbol.for('IDefaultSettings'),
|
|
441
|
+
IDefaultSettingsObj: Symbol.for('IDefaultSettingsObj'),
|
|
442
|
+
IDefaultPermissions: Symbol.for('IDefaultPermissions'),
|
|
443
|
+
IDefaultPermissionsObj: Symbol.for('IDefaultPermissionsObj'),
|
|
444
|
+
IDefaultRolesObj: Symbol.for('IDefaultRolesObj'),
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
/***/ }),
|
|
449
|
+
|
|
450
|
+
/***/ "./src/index.ts":
|
|
451
|
+
/*!**********************!*\
|
|
452
|
+
!*** ./src/index.ts ***!
|
|
453
|
+
\**********************/
|
|
454
|
+
/*! no static exports found */
|
|
455
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
456
|
+
|
|
457
|
+
"use strict";
|
|
458
|
+
|
|
459
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
460
|
+
if (k2 === undefined) k2 = k;
|
|
461
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
462
|
+
}) : (function(o, m, k, k2) {
|
|
463
|
+
if (k2 === undefined) k2 = k;
|
|
464
|
+
o[k2] = m[k];
|
|
465
|
+
}));
|
|
466
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
467
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
468
|
+
};
|
|
469
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
470
|
+
__exportStar(__webpack_require__(/*! ./connector */ "./src/connector/index.ts"), exports);
|
|
471
|
+
__exportStar(__webpack_require__(/*! ./interfaces */ "./src/interfaces/index.ts"), exports);
|
|
472
|
+
__exportStar(__webpack_require__(/*! ./constants */ "./src/constants/index.ts"), exports);
|
|
473
|
+
__exportStar(__webpack_require__(/*! ./logger */ "./src/logger/index.ts"), exports);
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
/***/ }),
|
|
477
|
+
|
|
478
|
+
/***/ "./src/interfaces/connector.ts":
|
|
479
|
+
/*!*************************************!*\
|
|
480
|
+
!*** ./src/interfaces/connector.ts ***!
|
|
481
|
+
\*************************************/
|
|
482
|
+
/*! no static exports found */
|
|
483
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
484
|
+
|
|
485
|
+
"use strict";
|
|
486
|
+
|
|
487
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
488
|
+
exports.ConfigurationScope = void 0;
|
|
489
|
+
var ConfigurationScope;
|
|
490
|
+
(function (ConfigurationScope) {
|
|
491
|
+
ConfigurationScope[ConfigurationScope["WINDOW"] = 1] = "WINDOW";
|
|
492
|
+
ConfigurationScope[ConfigurationScope["RESOURCE"] = 2] = "RESOURCE";
|
|
493
|
+
})(ConfigurationScope = exports.ConfigurationScope || (exports.ConfigurationScope = {}));
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
/***/ }),
|
|
497
|
+
|
|
498
|
+
/***/ "./src/interfaces/index.ts":
|
|
499
|
+
/*!*********************************!*\
|
|
500
|
+
!*** ./src/interfaces/index.ts ***!
|
|
501
|
+
\*********************************/
|
|
502
|
+
/*! no static exports found */
|
|
503
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
504
|
+
|
|
505
|
+
"use strict";
|
|
506
|
+
|
|
507
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
508
|
+
if (k2 === undefined) k2 = k;
|
|
509
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
510
|
+
}) : (function(o, m, k, k2) {
|
|
511
|
+
if (k2 === undefined) k2 = k;
|
|
512
|
+
o[k2] = m[k];
|
|
513
|
+
}));
|
|
514
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
515
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
516
|
+
};
|
|
517
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
518
|
+
__exportStar(__webpack_require__(/*! ./connector */ "./src/interfaces/connector.ts"), exports);
|
|
519
|
+
__exportStar(__webpack_require__(/*! ./mongo-migration */ "./src/interfaces/mongo-migration.ts"), exports);
|
|
520
|
+
__exportStar(__webpack_require__(/*! ./rules */ "./src/interfaces/rules.ts"), exports);
|
|
521
|
+
__exportStar(__webpack_require__(/*! ./roles */ "./src/interfaces/roles.ts"), exports);
|
|
522
|
+
__exportStar(__webpack_require__(/*! ./permissions */ "./src/interfaces/permissions.ts"), exports);
|
|
523
|
+
__exportStar(__webpack_require__(/*! ./policies */ "./src/interfaces/policies.ts"), exports);
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
/***/ }),
|
|
527
|
+
|
|
528
|
+
/***/ "./src/interfaces/mongo-migration.ts":
|
|
529
|
+
/*!*******************************************!*\
|
|
530
|
+
!*** ./src/interfaces/mongo-migration.ts ***!
|
|
531
|
+
\*******************************************/
|
|
532
|
+
/*! no static exports found */
|
|
533
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
534
|
+
|
|
535
|
+
"use strict";
|
|
536
|
+
|
|
537
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
/***/ }),
|
|
541
|
+
|
|
542
|
+
/***/ "./src/interfaces/permissions.ts":
|
|
543
|
+
/*!***************************************!*\
|
|
544
|
+
!*** ./src/interfaces/permissions.ts ***!
|
|
545
|
+
\***************************************/
|
|
546
|
+
/*! no static exports found */
|
|
547
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
548
|
+
|
|
549
|
+
"use strict";
|
|
550
|
+
|
|
551
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
/***/ }),
|
|
555
|
+
|
|
556
|
+
/***/ "./src/interfaces/policies.ts":
|
|
557
|
+
/*!************************************!*\
|
|
558
|
+
!*** ./src/interfaces/policies.ts ***!
|
|
559
|
+
\************************************/
|
|
560
|
+
/*! no static exports found */
|
|
561
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
562
|
+
|
|
563
|
+
"use strict";
|
|
564
|
+
|
|
565
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
/***/ }),
|
|
569
|
+
|
|
570
|
+
/***/ "./src/interfaces/roles.ts":
|
|
571
|
+
/*!*********************************!*\
|
|
572
|
+
!*** ./src/interfaces/roles.ts ***!
|
|
573
|
+
\*********************************/
|
|
574
|
+
/*! no static exports found */
|
|
575
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
576
|
+
|
|
577
|
+
"use strict";
|
|
578
|
+
|
|
579
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
/***/ }),
|
|
583
|
+
|
|
584
|
+
/***/ "./src/interfaces/rules.ts":
|
|
585
|
+
/*!*********************************!*\
|
|
586
|
+
!*** ./src/interfaces/rules.ts ***!
|
|
587
|
+
\*********************************/
|
|
588
|
+
/*! no static exports found */
|
|
589
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
590
|
+
|
|
591
|
+
"use strict";
|
|
592
|
+
|
|
593
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
594
|
+
exports.GraphqlRootType = void 0;
|
|
595
|
+
var GraphqlRootType;
|
|
596
|
+
(function (GraphqlRootType) {
|
|
597
|
+
GraphqlRootType["Query"] = "Query";
|
|
598
|
+
GraphqlRootType["Mutation"] = "Mutation";
|
|
599
|
+
GraphqlRootType["Subscription"] = "Subscription";
|
|
600
|
+
})(GraphqlRootType = exports.GraphqlRootType || (exports.GraphqlRootType = {}));
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
/***/ }),
|
|
604
|
+
|
|
605
|
+
/***/ "./src/logger/index.ts":
|
|
606
|
+
/*!*****************************!*\
|
|
607
|
+
!*** ./src/logger/index.ts ***!
|
|
608
|
+
\*****************************/
|
|
609
|
+
/*! no static exports found */
|
|
610
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
611
|
+
|
|
612
|
+
"use strict";
|
|
613
|
+
|
|
614
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
615
|
+
if (k2 === undefined) k2 = k;
|
|
616
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
617
|
+
}) : (function(o, m, k, k2) {
|
|
618
|
+
if (k2 === undefined) k2 = k;
|
|
619
|
+
o[k2] = m[k];
|
|
620
|
+
}));
|
|
621
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
622
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
623
|
+
};
|
|
624
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
625
|
+
__exportStar(__webpack_require__(/*! ./logger */ "./src/logger/logger.ts"), exports);
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
/***/ }),
|
|
629
|
+
|
|
630
|
+
/***/ "./src/logger/logger.ts":
|
|
631
|
+
/*!******************************!*\
|
|
632
|
+
!*** ./src/logger/logger.ts ***!
|
|
633
|
+
\******************************/
|
|
634
|
+
/*! no static exports found */
|
|
635
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
636
|
+
|
|
637
|
+
"use strict";
|
|
638
|
+
|
|
639
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
640
|
+
exports.logger = void 0;
|
|
641
|
+
const server_1 = __webpack_require__(/*! @cdm-logger/server */ "@cdm-logger/server");
|
|
642
|
+
const settings = {
|
|
643
|
+
level: process.env.LOG_LEVEL || 'trace',
|
|
644
|
+
};
|
|
645
|
+
const appName = process.env.APP_NAME || 'CDMBASE_APP';
|
|
646
|
+
exports.logger = server_1.ConsoleLogger.create(appName, settings);
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
/***/ }),
|
|
650
|
+
|
|
651
|
+
/***/ "./src/utils/index.ts":
|
|
652
|
+
/*!****************************!*\
|
|
653
|
+
!*** ./src/utils/index.ts ***!
|
|
654
|
+
\****************************/
|
|
655
|
+
/*! no static exports found */
|
|
656
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
657
|
+
|
|
658
|
+
"use strict";
|
|
659
|
+
|
|
660
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
661
|
+
if (k2 === undefined) k2 = k;
|
|
662
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
663
|
+
}) : (function(o, m, k, k2) {
|
|
664
|
+
if (k2 === undefined) k2 = k;
|
|
665
|
+
o[k2] = m[k];
|
|
666
|
+
}));
|
|
667
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
668
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
669
|
+
};
|
|
670
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
671
|
+
__exportStar(__webpack_require__(/*! ./preferences */ "./src/utils/preferences.ts"), exports);
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
/***/ }),
|
|
675
|
+
|
|
676
|
+
/***/ "./src/utils/preferences.ts":
|
|
677
|
+
/*!**********************************!*\
|
|
678
|
+
!*** ./src/utils/preferences.ts ***!
|
|
679
|
+
\**********************************/
|
|
680
|
+
/*! no static exports found */
|
|
681
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
682
|
+
|
|
683
|
+
"use strict";
|
|
684
|
+
|
|
685
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
686
|
+
exports.transformPrefsToArray = exports.getCurrentPreferences = void 0;
|
|
687
|
+
function getCurrentPreferences(preferencesDefaultArr, overwritePreferences) {
|
|
688
|
+
const preferencesArr = Object.assign({}, preferencesDefaultArr);
|
|
689
|
+
Object.keys(preferencesDefaultArr).forEach(key => {
|
|
690
|
+
if (preferencesDefaultArr[key].overridable) {
|
|
691
|
+
const overwritesSettings = Object.keys(overwritePreferences).filter(el => el.indexOf(key) !== -1);
|
|
692
|
+
let newValues = {};
|
|
693
|
+
overwritesSettings.forEach(item => {
|
|
694
|
+
const overwriteKey = item.split('.').pop();
|
|
695
|
+
newValues[overwriteKey] = overwritePreferences[item];
|
|
696
|
+
});
|
|
697
|
+
preferencesArr[key] = Object.assign(Object.assign({}, preferencesDefaultArr[key]), newValues);
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
return preferencesArr;
|
|
701
|
+
}
|
|
702
|
+
exports.getCurrentPreferences = getCurrentPreferences;
|
|
703
|
+
function transformPrefsToArray(preferences) {
|
|
704
|
+
const resultArr = [];
|
|
705
|
+
Object.keys(preferences).forEach(key => {
|
|
706
|
+
const type = key.split('.')[0];
|
|
707
|
+
const findType = resultArr.find(el => el.type === type);
|
|
708
|
+
if (!findType) {
|
|
709
|
+
resultArr.push({
|
|
710
|
+
type,
|
|
711
|
+
data: [Object.assign({ name: key }, preferences[key])],
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
findType['data'].push(Object.assign({ name: key }, preferences[key]));
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
return resultArr;
|
|
719
|
+
}
|
|
720
|
+
exports.transformPrefsToArray = transformPrefsToArray;
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
/***/ }),
|
|
724
|
+
|
|
725
|
+
/***/ "@cdm-logger/server":
|
|
726
|
+
/*!*************************************!*\
|
|
727
|
+
!*** external "@cdm-logger/server" ***!
|
|
728
|
+
\*************************************/
|
|
729
|
+
/*! no static exports found */
|
|
730
|
+
/***/ (function(module, exports) {
|
|
731
|
+
|
|
732
|
+
module.exports = require("@cdm-logger/server");
|
|
733
|
+
|
|
734
|
+
/***/ }),
|
|
735
|
+
|
|
736
|
+
/***/ "inversify":
|
|
737
|
+
/*!****************************!*\
|
|
738
|
+
!*** external "inversify" ***!
|
|
739
|
+
\****************************/
|
|
740
|
+
/*! no static exports found */
|
|
741
|
+
/***/ (function(module, exports) {
|
|
742
|
+
|
|
743
|
+
module.exports = require("inversify");
|
|
744
|
+
|
|
745
|
+
/***/ }),
|
|
746
|
+
|
|
747
|
+
/***/ "lodash":
|
|
748
|
+
/*!*************************!*\
|
|
749
|
+
!*** external "lodash" ***!
|
|
750
|
+
\*************************/
|
|
751
|
+
/*! no static exports found */
|
|
752
|
+
/***/ (function(module, exports) {
|
|
753
|
+
|
|
754
|
+
module.exports = require("lodash");
|
|
755
|
+
|
|
756
|
+
/***/ })
|
|
757
|
+
|
|
758
|
+
/******/ });
|
|
759
|
+
//# sourceMappingURL=index.js.map
|