@resolveio/server-lib 1.0.16 → 1.0.18

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.
@@ -12,6 +12,8 @@ export declare class SupportManager {
12
12
  getMainServer(): ResolveIOMainServer;
13
13
  supportMethods(supportMethod: SupportMethodModel): void;
14
14
  callSupportMethod(ws: WebSocket, messageId: any, supportMethod: any, ...methodData: any[]): void;
15
+ callSupportMethodInternal(supportMethod: any, ...methodData: any[]): Promise<any>;
16
+ callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
15
17
  private sendWS;
16
18
  sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[]): void;
17
19
  }
@@ -8,6 +8,7 @@ var counters_1 = require("../support-methods/counters");
8
8
  var mongoose_1 = require("mongoose");
9
9
  var common_1 = require("../util/common");
10
10
  var log_collection_1 = require("../collections/log.collection");
11
+ var method_manager_1 = require("./method.manager");
11
12
  var SupportManager = /** @class */ (function () {
12
13
  function SupportManager(mainServer, serverConfig) {
13
14
  var _this = this;
@@ -180,6 +181,60 @@ var SupportManager = /** @class */ (function () {
180
181
  _this.sendWS(ws, supportMethod, methodData, serverRes);
181
182
  });
182
183
  };
184
+ SupportManager.prototype.callSupportMethodInternal = function (supportMethod) {
185
+ var methodData = [];
186
+ for (var _i = 1; _i < arguments.length; _i++) {
187
+ methodData[_i - 1] = arguments[_i];
188
+ }
189
+ var _a;
190
+ var that = this;
191
+ if (!that._supportMethods[supportMethod]) {
192
+ console.log('No Support Method: ' + supportMethod);
193
+ return;
194
+ }
195
+ if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !that._supportMethods[supportMethod].skipValidation) {
196
+ if (!that._supportMethods[supportMethod].check) {
197
+ console.error('No Check Function For Method ' + supportMethod);
198
+ return;
199
+ }
200
+ else if (!that._supportMethods[supportMethod].check._schema) {
201
+ console.error('No Check Schema For Method ' + supportMethod);
202
+ return;
203
+ }
204
+ }
205
+ var promise = (_a = that._supportMethods[supportMethod].function).call.apply(_a, [Object.assign({}, that, SupportManager.prototype)].concat(methodData));
206
+ if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
207
+ promise.then(function (res) { return methodData[methodData.length - 1](null, res); }, function (err) { return methodData[methodData.length - 1](err, null); });
208
+ }
209
+ return promise;
210
+ };
211
+ SupportManager.prototype.callMethodInternal = function (method) {
212
+ var methodData = [];
213
+ for (var _i = 1; _i < arguments.length; _i++) {
214
+ methodData[_i - 1] = arguments[_i];
215
+ }
216
+ var _a;
217
+ var that = this;
218
+ if (!that._mainServer.getMethodManager()._methods[method]) {
219
+ console.log('No Method: ' + method);
220
+ return;
221
+ }
222
+ if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !that._mainServer.getMethodManager()._methods[method].skipValidation) {
223
+ if (!that._mainServer.getMethodManager()._methods[method].check) {
224
+ console.error('No Check Function For Method ' + method);
225
+ return;
226
+ }
227
+ else if (!that._mainServer.getMethodManager()._methods[method].check._schema) {
228
+ console.error('No Check Schema For Method ' + method);
229
+ return;
230
+ }
231
+ }
232
+ var promise = (_a = that._mainServer.getMethodManager()._methods[method].function).call.apply(_a, [Object.assign({}, that, method_manager_1.MethodManager.prototype)].concat(methodData));
233
+ if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
234
+ promise.then(function (res) { return methodData[methodData.length - 1](null, res); }, function (err) { return methodData[methodData.length - 1](err, null); });
235
+ }
236
+ return promise;
237
+ };
183
238
  SupportManager.prototype.sendWS = function (ws, method, methodData, data) {
184
239
  this._sendQueue.splice(0, 0, {
185
240
  id_ws: ws['id_socket'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -59,7 +59,7 @@ function loadSupportCronJobMethods(methodManager) {
59
59
  count = 0;
60
60
  interval = setInterval(function () {
61
61
  var updateChunk = users.slice(count * 10, Math.min(users.length, (count + 1) * 10));
62
- _this.callMethodInternal.call(_this, 'updateClientUserChunk', updateChunk);
62
+ _this.callSupportMethodInternal.call(_this, 'updateClientUserChunk', updateChunk);
63
63
  count++;
64
64
  if (count * 10 > users.length) {
65
65
  clearInterval(interval);