@resolveio/server-lib 1.0.0-rc9 → 1.0.0
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/http/auth.d.ts +1 -1
- package/http/auth.js +1 -1
- package/index.d.ts +5 -43
- package/index.js +60 -59
- package/managers/method.manager.d.ts +3 -2
- package/managers/method.manager.js +50 -19
- package/managers/subscription.manager.js +3 -3
- package/managers/support.manager.d.ts +1 -1
- package/managers/support.manager.js +1 -1
- package/methods/aws.js +22 -0
- package/methods/counters.js +0 -297
- package/models/notification.model.d.ts +5 -0
- package/models/notification.model.js +2 -0
- package/package.json +2 -2
- package/server-app.d.ts +3 -2
- package/server-app.js +46 -3
package/http/auth.d.ts
CHANGED
package/http/auth.js
CHANGED
|
@@ -74,7 +74,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
74
74
|
var emailData_1 = {
|
|
75
75
|
userToChangePassword: user_1.fullname,
|
|
76
76
|
userWhoResetPassword: __1.ResolveIOServer.getClientName() + ' System',
|
|
77
|
-
url: serverConfig['ROOT_URL'] + '/forgot-password
|
|
77
|
+
url: serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user_1.services.forgot_password
|
|
78
78
|
};
|
|
79
79
|
user_collection_1.Users.updateOne({ _id: user_1._id }, { $set: { services: user_1.services } }).exec(function (errUp, resUp) {
|
|
80
80
|
mainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(function (html) {
|
package/index.d.ts
CHANGED
|
@@ -1,55 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ResolveIOMainServer from './server-app';
|
|
2
2
|
export declare class ResolveIOServer {
|
|
3
3
|
private static _serverConfig;
|
|
4
4
|
private static _mainDB;
|
|
5
5
|
private static _supportDB;
|
|
6
6
|
private static _mainServer;
|
|
7
7
|
private static _client;
|
|
8
|
-
|
|
8
|
+
private static _clientDir;
|
|
9
|
+
private static _dontRunSupport;
|
|
10
|
+
constructor(serverConfig: any, client: string, clientDir: any, _dontRunSupport?: any);
|
|
11
|
+
static connectAndRun(): Promise<{}>;
|
|
9
12
|
static getClientName(): string;
|
|
10
13
|
static getMainServer(): ResolveIOMainServer;
|
|
11
14
|
static getMainDB(): any;
|
|
12
15
|
static getSupportDB(): any;
|
|
13
16
|
}
|
|
14
|
-
export * from './collections/active-subscription.collection';
|
|
15
|
-
export * from './collections/app-status.collection';
|
|
16
|
-
export * from './collections/app-version.collection';
|
|
17
|
-
export * from './collections/counter.collection';
|
|
18
|
-
export * from './collections/cron-job-history.collection';
|
|
19
|
-
export * from './collections/cron-job.collection';
|
|
20
|
-
export * from './collections/file.collection';
|
|
21
|
-
export * from './collections/flag.collection';
|
|
22
|
-
export * from './collections/log.collection';
|
|
23
|
-
export * from './collections/logged-in-users.collection';
|
|
24
|
-
export * from './collections/method-call.collection';
|
|
25
|
-
export * from './collections/method-response.collection';
|
|
26
|
-
export * from './collections/queue-flag.collection';
|
|
27
|
-
export * from './collections/queue-method.collection';
|
|
28
|
-
export * from './collections/queue-response.collection';
|
|
29
|
-
export * from './collections/support-ticket.collection';
|
|
30
|
-
export * from './collections/user.collection';
|
|
31
|
-
export * from './managers/cron.manager';
|
|
32
|
-
export * from './managers/method.manager';
|
|
33
|
-
export * from './managers/queue-method.manager';
|
|
34
|
-
export * from './managers/subscription.manager';
|
|
35
|
-
export * from './managers/support.manager';
|
|
36
|
-
export * from './models/active-subscription.model';
|
|
37
|
-
export * from './models/app-status.model';
|
|
38
|
-
export * from './models/app-version.model';
|
|
39
|
-
export * from './models/collection-document.model';
|
|
40
|
-
export * from './models/counter.model';
|
|
41
|
-
export * from './models/cron-job.model';
|
|
42
|
-
export * from './models/dialog.model';
|
|
43
|
-
export * from './models/file.model';
|
|
44
|
-
export * from './models/flag.model';
|
|
45
|
-
export * from './models/log.model';
|
|
46
|
-
export * from './models/method.model';
|
|
47
|
-
export * from './models/pagination.model';
|
|
48
|
-
export * from './models/permission.model';
|
|
49
|
-
export * from './models/select-data-label.model';
|
|
50
|
-
export * from './models/server-response.model';
|
|
51
|
-
export * from './models/support-method.model';
|
|
52
|
-
export * from './models/support-ticket.model';
|
|
53
|
-
export * from './models/user.model';
|
|
54
|
-
export * from './util/common';
|
|
55
17
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -34,50 +34,73 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
function __export(m) {
|
|
38
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
39
|
-
}
|
|
40
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
38
|
var mongoose = require("mongoose");
|
|
42
|
-
var server_app_1 = require("./server-app");
|
|
43
39
|
var ResolveIOServer = /** @class */ (function () {
|
|
44
|
-
function ResolveIOServer(serverConfig, client) {
|
|
45
|
-
var _this = this;
|
|
40
|
+
function ResolveIOServer(serverConfig, client, clientDir, _dontRunSupport) {
|
|
46
41
|
ResolveIOServer._serverConfig = serverConfig;
|
|
47
42
|
ResolveIOServer._client = client;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
ResolveIOServer._clientDir = clientDir;
|
|
44
|
+
if (_dontRunSupport) {
|
|
45
|
+
ResolveIOServer._dontRunSupport = _dontRunSupport;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
ResolveIOServer.connectAndRun = function () {
|
|
49
|
+
var _this = this;
|
|
50
|
+
return new Promise(function (resolve, reject) {
|
|
51
|
+
if (ResolveIOServer._serverConfig['ROOT_URL'] !== 'http://localhost:4200' && !_this._dontRunSupport) {
|
|
52
|
+
mongoose.createConnection(ResolveIOServer._serverConfig['RESOLVEIO_SUPPORT_MONGO_URL'], { useNewUrlParser: true }).then(function (db) { return __awaiter(_this, void 0, void 0, function () {
|
|
53
|
+
var _this = this;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
ResolveIOServer._supportDB = db;
|
|
56
|
+
mongoose.createConnection(ResolveIOServer._serverConfig['MONGO_URL'], { useNewUrlParser: true }).then(function (dbMain) { return __awaiter(_this, void 0, void 0, function () {
|
|
57
|
+
var serverApp;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
ResolveIOServer._mainDB = dbMain;
|
|
62
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return require('./server-app'); })];
|
|
63
|
+
case 1:
|
|
64
|
+
serverApp = (_a.sent()).default;
|
|
65
|
+
ResolveIOServer._mainServer = new serverApp(this, ResolveIOServer._serverConfig, this._clientDir);
|
|
66
|
+
resolve();
|
|
67
|
+
return [2 /*return*/];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}); }, function (err) {
|
|
71
|
+
process.exit();
|
|
72
|
+
reject();
|
|
58
73
|
});
|
|
59
|
-
|
|
60
|
-
process.exit();
|
|
74
|
+
return [2 /*return*/];
|
|
61
75
|
});
|
|
62
|
-
|
|
76
|
+
}); }, function (err) {
|
|
77
|
+
process.exit();
|
|
78
|
+
reject();
|
|
63
79
|
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
ResolveIOServer._supportDB = null;
|
|
83
|
+
mongoose.createConnection(ResolveIOServer._serverConfig['MONGO_URL'], { useNewUrlParser: true }).then(function (dbMain) { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
var serverApp;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
ResolveIOServer._mainDB = dbMain;
|
|
89
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return require('./server-app'); })];
|
|
90
|
+
case 1:
|
|
91
|
+
serverApp = (_a.sent()).default;
|
|
92
|
+
ResolveIOServer._mainServer = new serverApp(this, ResolveIOServer._serverConfig, this._clientDir);
|
|
93
|
+
resolve();
|
|
94
|
+
return [2 /*return*/];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}); }, function (err) {
|
|
98
|
+
process.exit();
|
|
99
|
+
reject();
|
|
75
100
|
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
};
|
|
81
104
|
ResolveIOServer.getClientName = function () {
|
|
82
105
|
return this._client;
|
|
83
106
|
};
|
|
@@ -95,30 +118,8 @@ var ResolveIOServer = /** @class */ (function () {
|
|
|
95
118
|
ResolveIOServer._supportDB = null;
|
|
96
119
|
ResolveIOServer._mainServer = null;
|
|
97
120
|
ResolveIOServer._client = '';
|
|
121
|
+
ResolveIOServer._clientDir = '';
|
|
122
|
+
ResolveIOServer._dontRunSupport = false;
|
|
98
123
|
return ResolveIOServer;
|
|
99
124
|
}());
|
|
100
125
|
exports.ResolveIOServer = ResolveIOServer;
|
|
101
|
-
__export(require("./collections/active-subscription.collection"));
|
|
102
|
-
__export(require("./collections/app-status.collection"));
|
|
103
|
-
__export(require("./collections/app-version.collection"));
|
|
104
|
-
__export(require("./collections/counter.collection"));
|
|
105
|
-
__export(require("./collections/cron-job-history.collection"));
|
|
106
|
-
__export(require("./collections/cron-job.collection"));
|
|
107
|
-
__export(require("./collections/file.collection"));
|
|
108
|
-
__export(require("./collections/flag.collection"));
|
|
109
|
-
__export(require("./collections/log.collection"));
|
|
110
|
-
__export(require("./collections/logged-in-users.collection"));
|
|
111
|
-
__export(require("./collections/method-call.collection"));
|
|
112
|
-
__export(require("./collections/method-response.collection"));
|
|
113
|
-
__export(require("./collections/queue-flag.collection"));
|
|
114
|
-
__export(require("./collections/queue-method.collection"));
|
|
115
|
-
__export(require("./collections/queue-response.collection"));
|
|
116
|
-
__export(require("./collections/support-ticket.collection"));
|
|
117
|
-
__export(require("./collections/user.collection"));
|
|
118
|
-
__export(require("./managers/cron.manager"));
|
|
119
|
-
__export(require("./managers/method.manager"));
|
|
120
|
-
__export(require("./managers/queue-method.manager"));
|
|
121
|
-
__export(require("./managers/subscription.manager"));
|
|
122
|
-
__export(require("./managers/support.manager"));
|
|
123
|
-
__export(require("./models/pagination.model"));
|
|
124
|
-
__export(require("./util/common"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MethodModel } from '../models/method.model';
|
|
2
2
|
import * as aws from 'aws-sdk';
|
|
3
3
|
import { QueueMethodModel } from '../models/queue-method.model';
|
|
4
|
-
import
|
|
4
|
+
import ResolveIOMainServer from '../server-app';
|
|
5
5
|
export declare class MethodManager {
|
|
6
6
|
private _mainServer;
|
|
7
7
|
_methods: MethodModel;
|
|
@@ -9,9 +9,10 @@ export declare class MethodManager {
|
|
|
9
9
|
private _imap;
|
|
10
10
|
private _aws;
|
|
11
11
|
private serverConfig;
|
|
12
|
+
private clientDir;
|
|
12
13
|
private _sendQueue;
|
|
13
14
|
private _runningQueue;
|
|
14
|
-
constructor(mainServer: any, serverConfig: any);
|
|
15
|
+
constructor(mainServer: any, serverConfig: any, clientDir: any);
|
|
15
16
|
getMainServer(): ResolveIOMainServer;
|
|
16
17
|
methods(method: MethodModel): void;
|
|
17
18
|
callMethodCron(method: string, ...methodData: any[]): void;
|
|
@@ -20,13 +20,14 @@ var mongoose_1 = require("mongoose");
|
|
|
20
20
|
var common_1 = require("../util/common");
|
|
21
21
|
var log_collection_1 = require("../collections/log.collection");
|
|
22
22
|
var MethodManager = /** @class */ (function () {
|
|
23
|
-
function MethodManager(mainServer, serverConfig) {
|
|
23
|
+
function MethodManager(mainServer, serverConfig, clientDir) {
|
|
24
24
|
var _this = this;
|
|
25
25
|
this._methods = {};
|
|
26
26
|
this._sendQueue = [];
|
|
27
27
|
this._runningQueue = false;
|
|
28
28
|
this._mainServer = mainServer;
|
|
29
29
|
this.serverConfig = serverConfig;
|
|
30
|
+
this.clientDir = clientDir;
|
|
30
31
|
// Fixtures
|
|
31
32
|
init_1.loadServerInit();
|
|
32
33
|
cron_jobs_1.loadServerCronJobs();
|
|
@@ -262,7 +263,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
262
263
|
}
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
|
-
(_a = that._methods[method].function).call.apply(_a, [Object.assign({}, that, { id_user: '', user: '', id_ws: '' })].concat(methodData));
|
|
266
|
+
(_a = that._methods[method].function).call.apply(_a, [Object.assign({}, that, MethodManager.prototype, { id_user: '', user: '', id_ws: '' })].concat(methodData));
|
|
266
267
|
};
|
|
267
268
|
MethodManager.prototype.callMethodQueue = function (update) {
|
|
268
269
|
// console.log('Call Method Queue', update);
|
|
@@ -330,7 +331,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
330
331
|
}
|
|
331
332
|
}
|
|
332
333
|
// console.log('Run Method', update.method);
|
|
333
|
-
(_a = that._methods[update.method].function).call.apply(_a, [Object.assign({}, that, { id_user: update.id_user, user: update.user, id_ws: update.id_ws })].concat(update.method_data)).then(function (res) {
|
|
334
|
+
(_a = that._methods[update.method].function).call.apply(_a, [Object.assign({}, that, MethodManager.prototype, { id_user: update.id_user, user: update.user, id_ws: update.id_ws })].concat(update.method_data)).then(function (res) {
|
|
334
335
|
var serverRes = {
|
|
335
336
|
messageId: update.messageId,
|
|
336
337
|
hasError: false,
|
|
@@ -414,7 +415,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
414
415
|
}
|
|
415
416
|
}
|
|
416
417
|
}
|
|
417
|
-
(_a = that._methods[method].function).call.apply(_a, [Object.assign({}, that, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] })].concat(methodData)).then(function (res) {
|
|
418
|
+
(_a = that._methods[method].function).call.apply(_a, [Object.assign({}, that, MethodManager.prototype, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] })].concat(methodData)).then(function (res) {
|
|
418
419
|
var serverRes = {
|
|
419
420
|
messageId: messageId,
|
|
420
421
|
hasError: false,
|
|
@@ -452,7 +453,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
452
453
|
return;
|
|
453
454
|
}
|
|
454
455
|
}
|
|
455
|
-
var promise = (_a = that._methods[method].function).call.apply(_a, [that].concat(methodData));
|
|
456
|
+
var promise = (_a = that._methods[method].function).call.apply(_a, [Object.assign({}, that, MethodManager.prototype)].concat(methodData));
|
|
456
457
|
if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
|
|
457
458
|
promise.then(function (res) { return methodData[methodData.length - 1](null, res); }, function (err) { return methodData[methodData.length - 1](err, null); });
|
|
458
459
|
}
|
|
@@ -485,27 +486,57 @@ var MethodManager = /** @class */ (function () {
|
|
|
485
486
|
return this._aws;
|
|
486
487
|
};
|
|
487
488
|
MethodManager.prototype.readFile = function (fileName) {
|
|
489
|
+
var _this = this;
|
|
488
490
|
return new Promise(function (resolve, reject) {
|
|
489
|
-
fs.
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
491
|
+
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
492
|
+
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', function (err, res) {
|
|
493
|
+
if (err) {
|
|
494
|
+
reject(err);
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
resolve(res);
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
|
|
503
|
+
fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'utf-8', function (err, res) {
|
|
504
|
+
if (err) {
|
|
505
|
+
reject(err);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
resolve(res);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
495
511
|
}
|
|
496
|
-
}
|
|
512
|
+
}
|
|
497
513
|
});
|
|
498
514
|
};
|
|
499
515
|
MethodManager.prototype.readImage = function (fileName) {
|
|
516
|
+
var _this = this;
|
|
500
517
|
return new Promise(function (resolve, reject) {
|
|
501
|
-
fs.
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
518
|
+
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
519
|
+
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', function (err, res) {
|
|
520
|
+
if (err) {
|
|
521
|
+
reject(err);
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
resolve(res);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
|
|
530
|
+
fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'base64', function (err, res) {
|
|
531
|
+
if (err) {
|
|
532
|
+
reject(err);
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
resolve(res);
|
|
536
|
+
}
|
|
537
|
+
});
|
|
507
538
|
}
|
|
508
|
-
}
|
|
539
|
+
}
|
|
509
540
|
});
|
|
510
541
|
};
|
|
511
542
|
return MethodManager;
|
|
@@ -614,7 +614,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
614
614
|
return __generator(this, function (_c) {
|
|
615
615
|
that = this;
|
|
616
616
|
if (!that._publications[subscription.publication].ws_specific) { // Same pub for all users
|
|
617
|
-
(_a = that._publications[subscription.publication].function).call.apply(_a, [that].concat(subscription.subscriptionData)).then(function (res) {
|
|
617
|
+
(_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
|
|
618
618
|
var serverRes = {
|
|
619
619
|
messageId: messageId,
|
|
620
620
|
hasError: false,
|
|
@@ -631,7 +631,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
631
631
|
});
|
|
632
632
|
}
|
|
633
633
|
else { // Pub is different for each user (Look at users publication) [MUCH SLOWER, RE-RUNS FOR EACH USER]
|
|
634
|
-
(_b = that._publications[subscription.publication].function).call.apply(_b, [that, ws['id_user']].concat(subscription.subscriptionData)).then(function (res) {
|
|
634
|
+
(_b = that._publications[subscription.publication].function).call.apply(_b, [Object.assign({}, that, SubscriptionManager.prototype), ws['id_user']].concat(subscription.subscriptionData)).then(function (res) {
|
|
635
635
|
var serverRes = {
|
|
636
636
|
messageId: messageId,
|
|
637
637
|
hasError: false,
|
|
@@ -658,7 +658,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
658
658
|
var _this = this;
|
|
659
659
|
return __generator(this, function (_b) {
|
|
660
660
|
that = this;
|
|
661
|
-
(_a = that._publications[subscription.publication].function).call.apply(_a, [that].concat(subscription.subscriptionData)).then(function (res) {
|
|
661
|
+
(_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
|
|
662
662
|
subscription.clients.forEach(function (client) {
|
|
663
663
|
that._wss.clients.forEach(function (ws) {
|
|
664
664
|
if (ws['id_socket'] === client.id_socket) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SupportMethodModel } from '../models/support-method.model';
|
|
2
|
-
import
|
|
2
|
+
import ResolveIOMainServer from '../server-app';
|
|
3
3
|
export declare class SupportManager {
|
|
4
4
|
private _mainServer;
|
|
5
5
|
_supportMethods: SupportMethodModel;
|
|
@@ -164,7 +164,7 @@ var SupportManager = /** @class */ (function () {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
(_a = that._supportMethods[supportMethod].function).call.apply(_a, [Object.assign({}, that, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] })].concat(methodData)).then(function (res) {
|
|
167
|
+
(_a = that._supportMethods[supportMethod].function).call.apply(_a, [Object.assign({}, that, SupportManager.prototype, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] })].concat(methodData)).then(function (res) {
|
|
168
168
|
var serverRes = {
|
|
169
169
|
messageId: messageId,
|
|
170
170
|
hasError: false,
|
package/methods/aws.js
CHANGED
|
@@ -39,6 +39,7 @@ var file_collection_1 = require("../collections/file.collection");
|
|
|
39
39
|
var mongoose_1 = require("mongoose");
|
|
40
40
|
var simpl_schema_1 = require("simpl-schema");
|
|
41
41
|
var index_1 = require("../index");
|
|
42
|
+
var request = require('request').defaults({ encoding: null });
|
|
42
43
|
var pdfCnt = 1000000;
|
|
43
44
|
function loadAWSMethods(methodManager) {
|
|
44
45
|
methodManager.methods({
|
|
@@ -276,6 +277,27 @@ function loadAWSMethods(methodManager) {
|
|
|
276
277
|
});
|
|
277
278
|
}
|
|
278
279
|
},
|
|
280
|
+
getDataURIfromURL: {
|
|
281
|
+
skipQueue: true,
|
|
282
|
+
check: new simpl_schema_1.default({
|
|
283
|
+
url: {
|
|
284
|
+
type: String
|
|
285
|
+
}
|
|
286
|
+
}),
|
|
287
|
+
function: function (url) {
|
|
288
|
+
return new Promise(function (resolve, reject) {
|
|
289
|
+
request.get(url, function (error, response, body) {
|
|
290
|
+
if (!error && response.statusCode === 200) {
|
|
291
|
+
var data = 'data:' + response.headers['content-type'] + ';base64,' + new Buffer(body).toString('base64');
|
|
292
|
+
resolve(data);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
reject(error);
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
},
|
|
279
301
|
emailFile: {
|
|
280
302
|
skipQueue: true,
|
|
281
303
|
check: new simpl_schema_1.default({
|
package/methods/counters.js
CHANGED
|
@@ -91,303 +91,6 @@ function loadCounterMethods(methodManager) {
|
|
|
91
91
|
return __1.ResolveIOServer.getMainDB().model(collectionType).collection.countDocuments(query);
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
|
-
countQuery: {
|
|
95
|
-
skipQueue: true,
|
|
96
|
-
check: new simpl_schema_1.default({
|
|
97
|
-
collectionType: {
|
|
98
|
-
type: String
|
|
99
|
-
},
|
|
100
|
-
search: {
|
|
101
|
-
type: String,
|
|
102
|
-
optional: true
|
|
103
|
-
},
|
|
104
|
-
filters: simpl_schema_1.default.oneOf({
|
|
105
|
-
type: Array,
|
|
106
|
-
optional: true
|
|
107
|
-
}, {
|
|
108
|
-
type: Object,
|
|
109
|
-
blackbox: true,
|
|
110
|
-
optional: true
|
|
111
|
-
}),
|
|
112
|
-
'filters.$': {
|
|
113
|
-
type: Object,
|
|
114
|
-
optional: true,
|
|
115
|
-
blackbox: true
|
|
116
|
-
},
|
|
117
|
-
subType: {
|
|
118
|
-
type: String,
|
|
119
|
-
optional: true
|
|
120
|
-
}
|
|
121
|
-
}),
|
|
122
|
-
function: function (collectionType, search, filters) {
|
|
123
|
-
if (search === void 0) { search = ''; }
|
|
124
|
-
if (filters === void 0) { filters = []; }
|
|
125
|
-
var query = {};
|
|
126
|
-
if (!search && (!filters || !filters.length)) {
|
|
127
|
-
query = {};
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
if (filters && filters.length) {
|
|
131
|
-
query['$and'] = [];
|
|
132
|
-
filters.forEach(function (filter) {
|
|
133
|
-
var _a;
|
|
134
|
-
if (filters.filter(function (a) { return a.prop === 'job'; }).length) {
|
|
135
|
-
if (filters.filter(function (a) { return a.prop === 'job'; })[0].data) {
|
|
136
|
-
query['$and'].push({
|
|
137
|
-
$or: [
|
|
138
|
-
{ type: 'request' },
|
|
139
|
-
{ type: 'initIso' },
|
|
140
|
-
{ type: 'return' },
|
|
141
|
-
{ type: 'returnIso' },
|
|
142
|
-
{ type: 'transferOut' },
|
|
143
|
-
{ type: 'transferIn' }
|
|
144
|
-
]
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
query['$and'].push({
|
|
149
|
-
$or: [
|
|
150
|
-
{ type: 'Customer Pickup' },
|
|
151
|
-
{ type: 'Direct Sale' },
|
|
152
|
-
{ type: 'Third Party' },
|
|
153
|
-
{ type: 'Sale Return' },
|
|
154
|
-
{ type: 'transferYard' }
|
|
155
|
-
]
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
filters.splice(filters.map(function (a) { return a.prop; }).indexOf('job'), 1);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
query['$and'].push((_a = {}, _a[filter['prop']] = filter['data'], _a));
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
if (search && collectionType === 'jobs') {
|
|
166
|
-
var searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };
|
|
167
|
-
if (query['$and']) {
|
|
168
|
-
query['$and'].push({
|
|
169
|
-
$or: [
|
|
170
|
-
{
|
|
171
|
-
status: searchRegEx
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
operator: searchRegEx
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
pumping_company: searchRegEx
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
afe: searchRegEx
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
po: searchRegEx
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
county: searchRegEx
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
state: searchRegEx
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
well: searchRegEx
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
query = {
|
|
199
|
-
$or: [
|
|
200
|
-
{
|
|
201
|
-
status: searchRegEx
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
operator: searchRegEx
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
pumping_company: searchRegEx
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
afe: searchRegEx
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
po: searchRegEx
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
county: searchRegEx
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
state: searchRegEx
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
well: searchRegEx
|
|
223
|
-
}
|
|
224
|
-
]
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
else if (search && collectionType === 'chemicals') {
|
|
229
|
-
var searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };
|
|
230
|
-
if (query['$and']) {
|
|
231
|
-
query['$and'].push({
|
|
232
|
-
$or: [
|
|
233
|
-
{
|
|
234
|
-
chemical_category: searchRegEx
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
container: searchRegEx
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
type: searchRegEx
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
description: searchRegEx
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
quantity_string: searchRegEx
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
unit: searchRegEx
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
min_stock_string: searchRegEx
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
max_stock_string: searchRegEx
|
|
256
|
-
}
|
|
257
|
-
]
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
query = {
|
|
262
|
-
$or: [
|
|
263
|
-
{
|
|
264
|
-
chemical_category: searchRegEx
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
container: searchRegEx
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
type: searchRegEx
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
description: searchRegEx
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
quantity_string: searchRegEx
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
unit: searchRegEx
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
min_stock_string: searchRegEx
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
max_stock_string: searchRegEx
|
|
286
|
-
}
|
|
287
|
-
]
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
else if (search && collectionType === 'bols') {
|
|
292
|
-
var searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };
|
|
293
|
-
if (query['$and']) {
|
|
294
|
-
query['$and'].push({
|
|
295
|
-
$or: [
|
|
296
|
-
{
|
|
297
|
-
date_string: searchRegEx
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
bol_string: searchRegEx
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
chemical: searchRegEx
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
locTo: searchRegEx
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
locFrom: searchRegEx
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
quantity_string: searchRegEx
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
file_status: searchRegEx
|
|
316
|
-
}
|
|
317
|
-
]
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
query = {
|
|
322
|
-
$or: [
|
|
323
|
-
{
|
|
324
|
-
date_string: searchRegEx
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
bol_string: searchRegEx
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
chemical: searchRegEx
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
locTo: searchRegEx
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
locFrom: searchRegEx
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
quantity_string: searchRegEx
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
file_status: searchRegEx
|
|
343
|
-
}
|
|
344
|
-
]
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
else if (search && collectionType === 'isotanks') {
|
|
349
|
-
var searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };
|
|
350
|
-
if (query['$and']) {
|
|
351
|
-
query['$and'].push({
|
|
352
|
-
$or: [
|
|
353
|
-
{
|
|
354
|
-
tank_number: searchRegEx
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
quantity_string: searchRegEx
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
current_location: searchRegEx
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
current_chemical: searchRegEx
|
|
364
|
-
}
|
|
365
|
-
]
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
query = {
|
|
370
|
-
$or: [
|
|
371
|
-
{
|
|
372
|
-
tank_number: searchRegEx
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
quantity_string: searchRegEx
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
current_location: searchRegEx
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
current_chemical: searchRegEx
|
|
382
|
-
}
|
|
383
|
-
]
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return __1.ResolveIOServer.getMainDB().model(collectionType).collection.countDocuments(query);
|
|
389
|
-
}
|
|
390
|
-
},
|
|
391
94
|
countCollection: {
|
|
392
95
|
skipQueue: true,
|
|
393
96
|
check: new simpl_schema_1.default({
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resolveio/server-lib",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"package": "npm pack ./dist",
|
|
7
|
+
"package": "npm run build-prod && npm pack ./dist",
|
|
8
8
|
"start": "node_modules/.bin/forever -c node --max-old-space-size=800 index.js",
|
|
9
9
|
"server": "node_modules/gulp/bin/gulp.js mongo-start && node_modules/gulp/bin/gulp.js",
|
|
10
10
|
"postserver": "node_modules/gulp/bin/gulp.js mongo-stop",
|
package/server-app.d.ts
CHANGED
|
@@ -4,19 +4,20 @@ import { MethodManager } from './managers/method.manager';
|
|
|
4
4
|
import { SubscriptionManager } from './managers/subscription.manager';
|
|
5
5
|
import { SupportManager } from './managers/support.manager';
|
|
6
6
|
import { QueueMethodManager } from './managers/queue-method.manager';
|
|
7
|
-
export
|
|
7
|
+
export default class ResolveIOMainServer {
|
|
8
8
|
private _app;
|
|
9
9
|
private _server;
|
|
10
10
|
private _port;
|
|
11
11
|
private _wss;
|
|
12
12
|
private _serverConfig;
|
|
13
|
+
private _clientDir;
|
|
13
14
|
private _resolveioServer;
|
|
14
15
|
private _subscriptionManager;
|
|
15
16
|
private _methodManager;
|
|
16
17
|
private _queueManager;
|
|
17
18
|
private _cronManager;
|
|
18
19
|
private _supportManager;
|
|
19
|
-
constructor(mainServer: any, serverConfig: any);
|
|
20
|
+
constructor(mainServer: any, serverConfig: any, clientDir: any);
|
|
20
21
|
getWS(id_ws: string): any;
|
|
21
22
|
getWSList(): any[];
|
|
22
23
|
getCronManager(): CronManager;
|
package/server-app.js
CHANGED
|
@@ -59,9 +59,10 @@ var subscription_manager_1 = require("./managers/subscription.manager");
|
|
|
59
59
|
var support_manager_1 = require("./managers/support.manager");
|
|
60
60
|
var queue_method_manager_1 = require("./managers/queue-method.manager");
|
|
61
61
|
var ResolveIOMainServer = /** @class */ (function () {
|
|
62
|
-
function ResolveIOMainServer(mainServer, serverConfig) {
|
|
62
|
+
function ResolveIOMainServer(mainServer, serverConfig, clientDir) {
|
|
63
63
|
this._resolveioServer = mainServer;
|
|
64
64
|
this._serverConfig = serverConfig;
|
|
65
|
+
this._clientDir = clientDir;
|
|
65
66
|
// process.on('unhandledException').
|
|
66
67
|
// Start express app
|
|
67
68
|
this._app = express();
|
|
@@ -204,7 +205,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
204
205
|
};
|
|
205
206
|
// Start Managers
|
|
206
207
|
this._subscriptionManager = new subscription_manager_1.SubscriptionManager(this, this._wss, this._serverConfig);
|
|
207
|
-
this._methodManager = new method_manager_1.MethodManager(this, this._serverConfig);
|
|
208
|
+
this._methodManager = new method_manager_1.MethodManager(this, this._serverConfig, this._clientDir);
|
|
208
209
|
this._supportManager = new support_manager_1.SupportManager(this, this._serverConfig);
|
|
209
210
|
this._cronManager = new cron_manager_1.CronManager(this);
|
|
210
211
|
this._queueManager = new queue_method_manager_1.QueueMethodManager(this);
|
|
@@ -595,4 +596,46 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
595
596
|
};
|
|
596
597
|
return ResolveIOMainServer;
|
|
597
598
|
}());
|
|
598
|
-
exports.
|
|
599
|
+
exports.default = ResolveIOMainServer;
|
|
600
|
+
// export * from './collections/active-subscription.collection';
|
|
601
|
+
// export * from './collections/app-status.collection';
|
|
602
|
+
// export * from './collections/app-version.collection';
|
|
603
|
+
// export * from './collections/counter.collection';
|
|
604
|
+
// export * from './collections/cron-job-history.collection';
|
|
605
|
+
// export * from './collections/cron-job.collection';
|
|
606
|
+
// export * from './collections/file.collection';
|
|
607
|
+
// export * from './collections/flag.collection';
|
|
608
|
+
// export * from './collections/log.collection';
|
|
609
|
+
// export * from './collections/logged-in-users.collection';
|
|
610
|
+
// export * from './collections/method-call.collection';
|
|
611
|
+
// export * from './collections/method-response.collection';
|
|
612
|
+
// export * from './collections/queue-flag.collection';
|
|
613
|
+
// export * from './collections/queue-method.collection';
|
|
614
|
+
// export * from './collections/queue-response.collection';
|
|
615
|
+
// export * from './collections/support-ticket.collection';
|
|
616
|
+
// export * from './collections/user.collection';
|
|
617
|
+
// export * from './managers/cron.manager';
|
|
618
|
+
// export * from './managers/method.manager';
|
|
619
|
+
// export * from './managers/queue-method.manager';
|
|
620
|
+
// export * from './managers/subscription.manager';
|
|
621
|
+
// export * from './managers/support.manager';
|
|
622
|
+
// export * from './models/active-subscription.model';
|
|
623
|
+
// export * from './models/app-status.model';
|
|
624
|
+
// export * from './models/app-version.model';
|
|
625
|
+
// export * from './models/collection-document.model';
|
|
626
|
+
// export * from './models/counter.model';
|
|
627
|
+
// // export * from './models/cron-job-history.model';
|
|
628
|
+
// export * from './models/cron-job.model';
|
|
629
|
+
// export * from './models/dialog.model';
|
|
630
|
+
// export * from './models/file.model';
|
|
631
|
+
// export * from './models/flag.model';
|
|
632
|
+
// export * from './models/log.model';
|
|
633
|
+
// export * from './models/method.model';
|
|
634
|
+
// export * from './models/pagination.model';
|
|
635
|
+
// export * from './models/permission.model';
|
|
636
|
+
// export * from './models/select-data-label.model';
|
|
637
|
+
// export * from './models/server-response.model';
|
|
638
|
+
// export * from './models/support-method.model';
|
|
639
|
+
// export * from './models/support-ticket.model';
|
|
640
|
+
// export * from './models/user.model';
|
|
641
|
+
// export * from './util/common';
|