@resolveio/server-lib 3.2.12 → 4.0.1

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.
@@ -111,13 +111,26 @@ var schema = {
111
111
  type: String,
112
112
  optional: true
113
113
  },
114
- customer: {
115
- type: String,
114
+ customers: {
115
+ type: Array,
116
116
  optional: true,
117
117
  },
118
+ 'customers.$': {
119
+ type: Object
120
+ },
121
+ 'customers.$.id_customer': {
122
+ type: String
123
+ },
124
+ 'customers.$.customer': {
125
+ type: String
126
+ },
118
127
  id_customer: {
119
128
  type: String,
120
- optional: true,
129
+ optional: true
130
+ },
131
+ customer: {
132
+ type: String,
133
+ optional: true
121
134
  }
122
135
  };
123
136
  var DefaultSchema = new mongoose_1.Schema(schema, {
package/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare class ResolveIOServer {
8
8
  private static _clientDir;
9
9
  private static _dontRunSupport;
10
10
  constructor(serverConfig: any, client: string, clientDir: any, _dontRunSupport?: any);
11
- static connectAndRun(): Promise<unknown>;
11
+ static connectAndRun(): Promise<{}>;
12
12
  static getClientName(): string;
13
13
  static getMainServer(): ResolveIOMainServer;
14
14
  static getMainDB(): any;
@@ -16,13 +16,13 @@ export declare class MethodManager {
16
16
  getMainServer(): ResolveIOMainServer;
17
17
  methods(method: MethodModel): void;
18
18
  callMethodCron(method: string, ...methodData: any[]): void;
19
- callMethodQueue(update: QueueMethodModel): Promise<unknown>;
19
+ callMethodQueue(update: QueueMethodModel): Promise<{}>;
20
20
  callMethod(ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]): void;
21
21
  callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
22
22
  callSupportMethodInternal(supportMethod: any, ...methodData: any[]): Promise<any>;
23
23
  private sendWS;
24
24
  sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string): void;
25
25
  getAWS(): aws.S3;
26
- readFile(fileName: any): Promise<unknown>;
27
- readImage(fileName: any): Promise<unknown>;
26
+ readFile(fileName: any): Promise<{}>;
27
+ readImage(fileName: any): Promise<{}>;
28
28
  }
@@ -361,8 +361,8 @@ var MethodManager = /** @class */ (function () {
361
361
  };
362
362
  // Call/run method (Emit on Socket)
363
363
  MethodManager.prototype.callMethod = function (ws, messageDate, messageId, method) {
364
- var _a;
365
364
  var _this = this;
365
+ var _a;
366
366
  var methodData = [];
367
367
  for (var _i = 4; _i < arguments.length; _i++) {
368
368
  methodData[_i - 4] = arguments[_i];
@@ -137,8 +137,7 @@ var SubscriptionManager = /** @class */ (function () {
137
137
  subscriptionData[_i - 3] = arguments[_i];
138
138
  }
139
139
  return __awaiter(this, void 0, void 0, function () {
140
- var that, pub, valObj, valKeys, rootKeys, i, sub, _a, newActiveSub, begDate, endDate, billUser;
141
- var _b;
140
+ var _a, that, pub, valObj, valKeys, rootKeys, i, sub, _b, newActiveSub, begDate, endDate, billUser;
142
141
  return __generator(this, function (_c) {
143
142
  switch (_c.label) {
144
143
  case 0:
@@ -203,10 +202,10 @@ var SubscriptionManager = /** @class */ (function () {
203
202
  // Send pub data to client who just subscribed only, don't want to send to existing clients since nothing has changed
204
203
  that.sendPubDataOnce(ws, messageId, sub);
205
204
  if (!(that._publications[sub.publication].preFunction && !sub.preSubscriptionData)) return [3 /*break*/, 3];
206
- _a = sub;
207
- return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
205
+ _b = sub;
206
+ return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
208
207
  case 2:
209
- _a.preSubscriptionData = _c.sent();
208
+ _b.preSubscriptionData = _c.sent();
210
209
  _c.label = 3;
211
210
  case 3:
212
211
  newActiveSub = new active_subscription_collection_1.ActiveSubscriptions({
@@ -554,8 +553,7 @@ var SubscriptionManager = /** @class */ (function () {
554
553
  if (noFetchFunction === void 0) { noFetchFunction = false; }
555
554
  var that = this;
556
555
  that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
557
- var schemaErrors, _a, _b;
558
- var _c, _d;
556
+ var _a, _b, schemaErrors, _c, _d;
559
557
  return __generator(this, function (_e) {
560
558
  switch (_e.label) {
561
559
  case 0:
@@ -575,18 +573,18 @@ var SubscriptionManager = /** @class */ (function () {
575
573
  if (!sub.preSubscriptionData) return [3 /*break*/, 4];
576
574
  if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
577
575
  that.sendPubData(sub);
578
- _a = sub;
579
- return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
576
+ _c = sub;
577
+ return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
580
578
  case 3:
581
- _a.preSubscriptionData = _e.sent();
579
+ _c.preSubscriptionData = _e.sent();
582
580
  return [2 /*return*/];
583
581
  case 4:
584
582
  if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 7];
585
583
  if (!!noFetchFunction) return [3 /*break*/, 6];
586
- _b = sub;
584
+ _d = sub;
587
585
  return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
588
586
  case 5:
589
- _b.preSubscriptionData = _e.sent();
587
+ _d.preSubscriptionData = _e.sent();
590
588
  if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
591
589
  that.sendPubData(sub);
592
590
  }
@@ -619,7 +617,7 @@ var SubscriptionManager = /** @class */ (function () {
619
617
  else {
620
618
  if (that._publications[sub.publication].fetchFunction) {
621
619
  if (!noFetchFunction) {
622
- if ((_d = that._publications[sub.publication]).fetchFunction.apply(_d, [document].concat(sub.subscriptionData))) {
620
+ if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [document].concat(sub.subscriptionData))) {
623
621
  that.sendPubData(sub);
624
622
  }
625
623
  }
@@ -638,8 +636,7 @@ var SubscriptionManager = /** @class */ (function () {
638
636
  var _this = this;
639
637
  var that = this;
640
638
  that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
641
- var schemaErrors, _a, _b;
642
- var _c, _d, _e;
639
+ var _a, _b, _c, schemaErrors, _d, _e;
643
640
  return __generator(this, function (_f) {
644
641
  switch (_f.label) {
645
642
  case 0:
@@ -659,17 +656,17 @@ var SubscriptionManager = /** @class */ (function () {
659
656
  if (!sub.preSubscriptionData) return [3 /*break*/, 4];
660
657
  if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 4];
661
658
  that.sendPubData(sub);
662
- _a = sub;
663
- return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
659
+ _d = sub;
660
+ return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
664
661
  case 3:
665
- _a.preSubscriptionData = _f.sent();
662
+ _d.preSubscriptionData = _f.sent();
666
663
  return [2 /*return*/];
667
664
  case 4:
668
665
  if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 6];
669
- _b = sub;
670
- return [4 /*yield*/, (_d = that._publications[sub.publication]).preFunction.apply(_d, sub.subscriptionData)];
666
+ _e = sub;
667
+ return [4 /*yield*/, (_b = that._publications[sub.publication]).preFunction.apply(_b, sub.subscriptionData)];
671
668
  case 5:
672
- _b.preSubscriptionData = _f.sent();
669
+ _e.preSubscriptionData = _f.sent();
673
670
  if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
674
671
  that.sendPubData(sub);
675
672
  }
@@ -698,7 +695,7 @@ var SubscriptionManager = /** @class */ (function () {
698
695
  }
699
696
  else {
700
697
  if (that._publications[sub.publication].fetchFunction) {
701
- if ((_e = that._publications[sub.publication]).fetchFunction.apply(_e, [document].concat(sub.subscriptionData))) {
698
+ if ((_c = that._publications[sub.publication]).fetchFunction.apply(_c, [document].concat(sub.subscriptionData))) {
702
699
  that.sendPubData(sub);
703
700
  }
704
701
  }
@@ -715,8 +712,7 @@ var SubscriptionManager = /** @class */ (function () {
715
712
  // Fetch pub once, send to all clients linked to this pub
716
713
  SubscriptionManager.prototype.sendPubDataOnce = function (ws, messageId, subscription) {
717
714
  return __awaiter(this, void 0, void 0, function () {
718
- var that;
719
- var _a, _b;
715
+ var _a, _b, that;
720
716
  var _this = this;
721
717
  return __generator(this, function (_c) {
722
718
  that = this;
@@ -761,8 +757,7 @@ var SubscriptionManager = /** @class */ (function () {
761
757
  // Fetch pub once, send to all clients linked to this pub
762
758
  SubscriptionManager.prototype.sendPubData = function (subscription) {
763
759
  return __awaiter(this, void 0, void 0, function () {
764
- var that;
765
- var _a;
760
+ var _a, that;
766
761
  var _this = this;
767
762
  return __generator(this, function (_b) {
768
763
  that = this;
@@ -17,6 +17,6 @@ export declare class SupportManager {
17
17
  callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
18
18
  private sendWS;
19
19
  sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[]): void;
20
- readFile(fileName: any): Promise<unknown>;
21
- readImage(fileName: any): Promise<unknown>;
20
+ readFile(fileName: any): Promise<{}>;
21
+ readImage(fileName: any): Promise<{}>;
22
22
  }
@@ -102,8 +102,8 @@ var SupportManager = /** @class */ (function () {
102
102
  };
103
103
  // Call/run method (Emit on Socket)
104
104
  SupportManager.prototype.callSupportMethod = function (ws, messageId, supportMethod) {
105
- var _a;
106
105
  var _this = this;
106
+ var _a;
107
107
  var methodData = [];
108
108
  for (var _i = 3; _i < arguments.length; _i++) {
109
109
  methodData[_i - 3] = arguments[_i];
@@ -11,4 +11,11 @@ export interface UserModel extends CollectionDocument {
11
11
  readonly?: boolean;
12
12
  phonenumber?: string;
13
13
  other?: object;
14
+ id_customer?: string;
15
+ customer?: string;
16
+ customers: UserCustomersModel[];
17
+ }
18
+ export interface UserCustomersModel {
19
+ id_customer: string;
20
+ customer: string;
14
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "3.2.12",
3
+ "version": "4.0.1",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/server-app.js CHANGED
@@ -251,8 +251,7 @@ var ResolveIOMainServer = /** @class */ (function () {
251
251
  }, 10000);
252
252
  // On data received (message)
253
253
  ws.on('message', function (message) { return __awaiter(_this, void 0, void 0, function () {
254
- var socketData, data, messageDate, messageId, type, subType, pub;
255
- var _a, _b;
254
+ var _a, _b, socketData, data, messageDate, messageId, type, subType, pub;
256
255
  var _this = this;
257
256
  return __generator(this, function (_c) {
258
257
  socketData = JSON.parse(message, common_1.dateReviver);
@@ -327,8 +326,7 @@ var ResolveIOMainServer = /** @class */ (function () {
327
326
  if (!!this._msgQueueRunning) return [3 /*break*/, 5];
328
327
  this._msgQueueRunning = true;
329
328
  _loop_1 = function (i) {
330
- var msg, data, ws, messageDate, messageId, type, method, serverRes, query, methodCall, supportMethod, serverRes;
331
- var _a, _b;
329
+ var _a, _b, msg, data, ws, messageDate, messageId, type, method, serverRes, query, methodCall, supportMethod, serverRes;
332
330
  return __generator(this, function (_c) {
333
331
  switch (_c.label) {
334
332
  case 0: