@resolveio/server-lib 9.0.32 → 9.0.34

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 (193) hide show
  1. package/client-server-app.js +7 -48
  2. package/client-server-app.js.map +1 -1
  3. package/collections/app-status.collection.js +8 -11
  4. package/collections/app-status.collection.js.map +1 -1
  5. package/collections/app-version.collection.js +8 -11
  6. package/collections/app-version.collection.js.map +1 -1
  7. package/collections/counter.collection.js +8 -11
  8. package/collections/counter.collection.js.map +1 -1
  9. package/collections/cron-job-history.collection.js +9 -12
  10. package/collections/cron-job-history.collection.js.map +1 -1
  11. package/collections/cron-job.collection.js +8 -11
  12. package/collections/cron-job.collection.js.map +1 -1
  13. package/collections/email-history.collection.js +8 -11
  14. package/collections/email-history.collection.js.map +1 -1
  15. package/collections/email-verified.collection.js +9 -12
  16. package/collections/email-verified.collection.js.map +1 -1
  17. package/collections/file.collection.js +8 -11
  18. package/collections/file.collection.js.map +1 -1
  19. package/collections/flag.collection.js +8 -11
  20. package/collections/flag.collection.js.map +1 -1
  21. package/collections/log-method-latency.collection.js +11 -14
  22. package/collections/log-method-latency.collection.js.map +1 -1
  23. package/collections/log-subscription.collection.js +13 -16
  24. package/collections/log-subscription.collection.js.map +1 -1
  25. package/collections/log.collection.js +16 -19
  26. package/collections/log.collection.js.map +1 -1
  27. package/collections/logged-in-users.collection.js +9 -12
  28. package/collections/logged-in-users.collection.js.map +1 -1
  29. package/collections/method-call.collection.js +10 -13
  30. package/collections/method-call.collection.js.map +1 -1
  31. package/collections/method-response.collection.js +10 -13
  32. package/collections/method-response.collection.js.map +1 -1
  33. package/collections/monitor-cpu.collection.js +13 -16
  34. package/collections/monitor-cpu.collection.js.map +1 -1
  35. package/collections/monitor-https-inbound.collection.js +13 -16
  36. package/collections/monitor-https-inbound.collection.js.map +1 -1
  37. package/collections/monitor-https-outbound.collection.js +15 -18
  38. package/collections/monitor-https-outbound.collection.js.map +1 -1
  39. package/collections/monitor-memory.collection.js +12 -15
  40. package/collections/monitor-memory.collection.js.map +1 -1
  41. package/collections/monitor-mongo.collection.js +12 -15
  42. package/collections/monitor-mongo.collection.js.map +1 -1
  43. package/collections/notification.collection.js +8 -11
  44. package/collections/notification.collection.js.map +1 -1
  45. package/collections/queue-flag.collection.js +9 -12
  46. package/collections/queue-flag.collection.js.map +1 -1
  47. package/collections/queue-method.collection.js +9 -12
  48. package/collections/queue-method.collection.js.map +1 -1
  49. package/collections/queue-response.collection.js +9 -12
  50. package/collections/queue-response.collection.js.map +1 -1
  51. package/collections/report-builder-dashboard-builder.collection.js +10 -13
  52. package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
  53. package/collections/report-builder-library.collection.js +11 -14
  54. package/collections/report-builder-library.collection.js.map +1 -1
  55. package/collections/report-builder-report.collection.js +11 -14
  56. package/collections/report-builder-report.collection.js.map +1 -1
  57. package/collections/user-group.collection.js +11 -14
  58. package/collections/user-group.collection.js.map +1 -1
  59. package/collections/user-guide.collection.js +8 -11
  60. package/collections/user-guide.collection.js.map +1 -1
  61. package/collections/user.collection.js +12 -15
  62. package/collections/user.collection.js.map +1 -1
  63. package/cron/cron.js +25 -25
  64. package/cron/cron.js.map +1 -1
  65. package/fixtures/cron-jobs.js +30 -80
  66. package/fixtures/cron-jobs.js.map +1 -1
  67. package/fixtures/init.js +9 -59
  68. package/fixtures/init.js.map +1 -1
  69. package/http/auth.js +344 -460
  70. package/http/auth.js.map +1 -1
  71. package/http/health.js +1 -5
  72. package/http/health.js.map +1 -1
  73. package/http/home.js +7 -11
  74. package/http/home.js.map +1 -1
  75. package/index.js +36 -98
  76. package/index.js.map +1 -1
  77. package/managers/cron.manager.js +78 -157
  78. package/managers/cron.manager.js.map +1 -1
  79. package/managers/method.manager.js +323 -303
  80. package/managers/method.manager.js.map +1 -1
  81. package/managers/mongo.manager.d.ts +14 -14
  82. package/managers/mongo.manager.js +794 -865
  83. package/managers/mongo.manager.js.map +1 -1
  84. package/managers/monitor.manager.js +171 -254
  85. package/managers/monitor.manager.js.map +1 -1
  86. package/managers/queue-method.manager.js +69 -166
  87. package/managers/queue-method.manager.js.map +1 -1
  88. package/managers/subscription.manager.js +515 -708
  89. package/managers/subscription.manager.js.map +1 -1
  90. package/methods/accounts.js +111 -183
  91. package/methods/accounts.js.map +1 -1
  92. package/methods/aws.js +156 -262
  93. package/methods/aws.js.map +1 -1
  94. package/methods/cloudconvert.js +100 -180
  95. package/methods/cloudconvert.js.map +1 -1
  96. package/methods/collections.js +114 -530
  97. package/methods/collections.js.map +1 -1
  98. package/methods/counters.js +29 -79
  99. package/methods/counters.js.map +1 -1
  100. package/methods/cron-jobs.js +819 -884
  101. package/methods/cron-jobs.js.map +1 -1
  102. package/methods/flags.js +1 -5
  103. package/methods/flags.js.map +1 -1
  104. package/methods/logs.js +258 -313
  105. package/methods/logs.js.map +1 -1
  106. package/methods/monitor.js +289 -348
  107. package/methods/monitor.js.map +1 -1
  108. package/methods/pdf.js +341 -340
  109. package/methods/pdf.js.map +1 -1
  110. package/methods/report-builder.js +565 -657
  111. package/methods/report-builder.js.map +1 -1
  112. package/methods/support.js +67 -185
  113. package/methods/support.js.map +1 -1
  114. package/models/app-status.model.js +1 -2
  115. package/models/app-version.model.js +1 -2
  116. package/models/billing-logged-in-users.model.js +1 -2
  117. package/models/collection-document.model.js +1 -2
  118. package/models/counter.model.js +1 -2
  119. package/models/cron-job-history.model.js +1 -2
  120. package/models/cron-job.model.js +1 -2
  121. package/models/dialog.model.js +1 -2
  122. package/models/email-history.model.js +1 -2
  123. package/models/email-verified.model.js +1 -2
  124. package/models/file.model.js +1 -2
  125. package/models/flag.model.js +1 -2
  126. package/models/log-method-latency.model.js +1 -2
  127. package/models/log-subscription.model.js +1 -2
  128. package/models/log.model.js +1 -2
  129. package/models/logged-in-users.model.js +1 -2
  130. package/models/method-call.model.js +1 -2
  131. package/models/method-response.model.js +1 -2
  132. package/models/method.model.js +1 -2
  133. package/models/monitor-cpu.model.js +1 -2
  134. package/models/monitor-https-inbound.model.js +1 -2
  135. package/models/monitor-https-outbound.model.js +1 -2
  136. package/models/monitor-memory.model.js +1 -2
  137. package/models/monitor-mongo.model.js +1 -2
  138. package/models/notification.model.js +1 -2
  139. package/models/pagination.model.js +2 -5
  140. package/models/pagination.model.js.map +1 -1
  141. package/models/permission.model.js +1 -2
  142. package/models/queue-method.model.js +1 -2
  143. package/models/queue-response.model.js +1 -2
  144. package/models/report-builder-dashboard-builder.model.js +1 -2
  145. package/models/report-builder-library.model.js +1 -2
  146. package/models/report-builder-report.model.js +1 -2
  147. package/models/report-builder.model.js +1 -2
  148. package/models/select-data-label.model.js +1 -2
  149. package/models/server-response.model.js +1 -2
  150. package/models/subscription.model.js +1 -2
  151. package/models/support-ticket.model.js +1 -2
  152. package/models/user-group.model.js +1 -2
  153. package/models/user-guide.model.js +1 -2
  154. package/models/user.model.js +1 -2
  155. package/package.json +1 -1
  156. package/public_api.js +70 -82
  157. package/public_api.js.map +1 -1
  158. package/publications/app-status.js +4 -8
  159. package/publications/app-status.js.map +1 -1
  160. package/publications/app-version.js +4 -8
  161. package/publications/app-version.js.map +1 -1
  162. package/publications/cron-jobs.js +9 -13
  163. package/publications/cron-jobs.js.map +1 -1
  164. package/publications/files.js +11 -15
  165. package/publications/files.js.map +1 -1
  166. package/publications/flags.js +7 -11
  167. package/publications/flags.js.map +1 -1
  168. package/publications/logs.js +31 -35
  169. package/publications/logs.js.map +1 -1
  170. package/publications/method-calls.js +4 -8
  171. package/publications/method-calls.js.map +1 -1
  172. package/publications/method-responses.js +4 -8
  173. package/publications/method-responses.js.map +1 -1
  174. package/publications/notifications.js +4 -8
  175. package/publications/notifications.js.map +1 -1
  176. package/publications/report-builder-dashboard-builders.js +8 -12
  177. package/publications/report-builder-dashboard-builders.js.map +1 -1
  178. package/publications/report-builder-libraries.js +16 -66
  179. package/publications/report-builder-libraries.js.map +1 -1
  180. package/publications/report-builder-reports.js +17 -21
  181. package/publications/report-builder-reports.js.map +1 -1
  182. package/publications/super-admin.js +3 -7
  183. package/publications/super-admin.js.map +1 -1
  184. package/publications/user-groups.js +4 -8
  185. package/publications/user-groups.js.map +1 -1
  186. package/publications/user-guides.js +4 -8
  187. package/publications/user-guides.js.map +1 -1
  188. package/server-app.js +393 -534
  189. package/server-app.js.map +1 -1
  190. package/util/common.js +55 -92
  191. package/util/common.js.map +1 -1
  192. package/util/schema-report-builder.js +76 -134
  193. package/util/schema-report-builder.js.map +1 -1
@@ -1,392 +1,333 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.loadMonitorMethods = void 0;
40
- var monitor_mongo_collection_1 = require("../collections/monitor-mongo.collection");
41
- var monitor_cpu_collection_1 = require("../collections/monitor-cpu.collection");
42
- var monitor_https_outbound_collection_1 = require("../collections/monitor-https-outbound.collection");
43
- var monitor_https_inbound_collection_1 = require("../collections/monitor-https-inbound.collection");
44
- var monitor_memory_collection_1 = require("../collections/monitor-memory.collection");
45
- var __1 = require("..");
46
- var common_1 = require("../util/common");
47
- function loadMonitorMethods(methodManager) {
1
+ import { MonitorMongos } from '../collections/monitor-mongo.collection';
2
+ import { MonitorCPUs } from '../collections/monitor-cpu.collection';
3
+ import { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';
4
+ import { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';
5
+ import { MonitorMemorys } from '../collections/monitor-memory.collection';
6
+ import { ResolveIOServer } from '..';
7
+ import { deepCopy } from '../util/common';
8
+ export function loadMonitorMethods(methodManager) {
48
9
  methodManager.methods({
49
10
  superadminMonitor: {
50
11
  skipQueue: true,
51
12
  function: function (date_start, date_end, collection, instance, client, graphInterval, variable, variableType) {
52
- var _this = this;
53
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
54
- var groupId, groupDate, query, firstGroupId, graphData;
55
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
56
- return __generator(this, function (_p) {
57
- switch (_p.label) {
58
- case 0:
59
- groupId = {};
60
- groupDate = {};
61
- if (graphInterval === 'seconds') {
62
- groupId = {
63
- second: {
64
- $second: {
65
- date: '$date',
66
- timezone: "America/Chicago"
67
- }
68
- },
69
- minute: {
70
- $minute: {
71
- date: '$date',
72
- timezone: "America/Chicago"
73
- }
74
- },
75
- hour: {
76
- $hour: {
77
- date: '$date',
78
- timezone: "America/Chicago"
79
- }
80
- },
81
- day: {
82
- $dayOfMonth: {
83
- date: '$date',
84
- timezone: "America/Chicago"
85
- }
86
- },
87
- month: {
88
- $month: {
89
- date: '$date',
90
- timezone: "America/Chicago"
91
- }
92
- },
93
- year: {
94
- $year: {
95
- date: '$date',
96
- timezone: "America/Chicago"
97
- }
98
- },
99
- client: '$client',
100
- instance: '$instance'
101
- };
102
- groupDate = (_a = {
103
- 'year': '$_id.year',
104
- 'month': '$_id.month',
105
- 'day': '$_id.day',
106
- 'hour': '$_id.hour',
107
- 'minute': '$_id.minute',
108
- 'second': '$_id.second'
109
- },
110
- _a[variable] = '$' + variable,
111
- _a);
13
+ return new Promise(async (resolve, reject) => {
14
+ let groupId = {};
15
+ let groupDate = {};
16
+ if (graphInterval === 'seconds') {
17
+ groupId = {
18
+ second: {
19
+ $second: {
20
+ date: '$date',
21
+ timezone: "America/Chicago"
22
+ }
23
+ },
24
+ minute: {
25
+ $minute: {
26
+ date: '$date',
27
+ timezone: "America/Chicago"
28
+ }
29
+ },
30
+ hour: {
31
+ $hour: {
32
+ date: '$date',
33
+ timezone: "America/Chicago"
34
+ }
35
+ },
36
+ day: {
37
+ $dayOfMonth: {
38
+ date: '$date',
39
+ timezone: "America/Chicago"
40
+ }
41
+ },
42
+ month: {
43
+ $month: {
44
+ date: '$date',
45
+ timezone: "America/Chicago"
46
+ }
47
+ },
48
+ year: {
49
+ $year: {
50
+ date: '$date',
51
+ timezone: "America/Chicago"
52
+ }
53
+ },
54
+ client: '$client',
55
+ instance: '$instance'
56
+ };
57
+ groupDate = {
58
+ 'year': '$_id.year',
59
+ 'month': '$_id.month',
60
+ 'day': '$_id.day',
61
+ 'hour': '$_id.hour',
62
+ 'minute': '$_id.minute',
63
+ 'second': '$_id.second',
64
+ [variable]: '$' + variable
65
+ };
66
+ }
67
+ else if (graphInterval === 'minutes') {
68
+ groupId = {
69
+ minute: {
70
+ $minute: {
71
+ date: '$date',
72
+ timezone: "America/Chicago"
73
+ }
74
+ },
75
+ hour: {
76
+ $hour: {
77
+ date: '$date',
78
+ timezone: "America/Chicago"
79
+ }
80
+ },
81
+ day: {
82
+ $dayOfMonth: {
83
+ date: '$date',
84
+ timezone: "America/Chicago"
112
85
  }
113
- else if (graphInterval === 'minutes') {
114
- groupId = {
115
- minute: {
116
- $minute: {
117
- date: '$date',
118
- timezone: "America/Chicago"
119
- }
120
- },
121
- hour: {
122
- $hour: {
123
- date: '$date',
124
- timezone: "America/Chicago"
125
- }
126
- },
127
- day: {
128
- $dayOfMonth: {
129
- date: '$date',
130
- timezone: "America/Chicago"
131
- }
132
- },
133
- month: {
134
- $month: {
135
- date: '$date',
136
- timezone: "America/Chicago"
137
- }
138
- },
139
- year: {
140
- $year: {
141
- date: '$date',
142
- timezone: "America/Chicago"
143
- }
144
- },
145
- client: '$client',
146
- instance: '$instance'
147
- };
148
- groupDate = (_b = {
149
- 'year': '$_id.year',
150
- 'month': '$_id.month',
151
- 'day': '$_id.day',
152
- 'hour': '$_id.hour',
153
- 'minute': '$_id.minute'
154
- },
155
- _b[variable] = '$' + variable,
156
- _b);
86
+ },
87
+ month: {
88
+ $month: {
89
+ date: '$date',
90
+ timezone: "America/Chicago"
157
91
  }
158
- else if (graphInterval === 'hours') {
159
- groupId = {
160
- hour: {
161
- $hour: {
162
- date: '$date',
163
- timezone: "America/Chicago"
164
- }
165
- },
166
- day: {
167
- $dayOfMonth: {
168
- date: '$date',
169
- timezone: "America/Chicago"
170
- }
171
- },
172
- month: {
173
- $month: {
174
- date: '$date',
175
- timezone: "America/Chicago"
176
- }
177
- },
178
- year: {
179
- $year: {
180
- date: '$date',
181
- timezone: "America/Chicago"
182
- }
183
- },
184
- client: '$client',
185
- instance: '$instance'
186
- };
187
- groupDate = (_c = {
188
- 'year': '$_id.year',
189
- 'month': '$_id.month',
190
- 'day': '$_id.day',
191
- 'hour': '$_id.hour'
192
- },
193
- _c[variable] = '$' + variable,
194
- _c);
92
+ },
93
+ year: {
94
+ $year: {
95
+ date: '$date',
96
+ timezone: "America/Chicago"
195
97
  }
196
- else {
197
- groupId = {
198
- day: {
199
- $dayOfMonth: {
200
- date: '$date',
201
- timezone: "America/Chicago"
202
- }
203
- },
204
- month: {
205
- $month: {
206
- date: '$date',
207
- timezone: "America/Chicago"
208
- }
209
- },
210
- year: {
211
- $year: {
212
- date: '$date',
213
- timezone: "America/Chicago"
214
- }
215
- },
216
- client: '$client',
217
- instance: '$instance'
218
- };
219
- groupDate = (_d = {
220
- 'year': '$_id.year',
221
- 'month': '$_id.month',
222
- 'day': '$_id.day'
223
- },
224
- _d[variable] = '$' + variable,
225
- _d);
98
+ },
99
+ client: '$client',
100
+ instance: '$instance'
101
+ };
102
+ groupDate = {
103
+ 'year': '$_id.year',
104
+ 'month': '$_id.month',
105
+ 'day': '$_id.day',
106
+ 'hour': '$_id.hour',
107
+ 'minute': '$_id.minute',
108
+ [variable]: '$' + variable
109
+ };
110
+ }
111
+ else if (graphInterval === 'hours') {
112
+ groupId = {
113
+ hour: {
114
+ $hour: {
115
+ date: '$date',
116
+ timezone: "America/Chicago"
226
117
  }
227
- query = [
118
+ },
119
+ day: {
120
+ $dayOfMonth: {
121
+ date: '$date',
122
+ timezone: "America/Chicago"
123
+ }
124
+ },
125
+ month: {
126
+ $month: {
127
+ date: '$date',
128
+ timezone: "America/Chicago"
129
+ }
130
+ },
131
+ year: {
132
+ $year: {
133
+ date: '$date',
134
+ timezone: "America/Chicago"
135
+ }
136
+ },
137
+ client: '$client',
138
+ instance: '$instance'
139
+ };
140
+ groupDate = {
141
+ 'year': '$_id.year',
142
+ 'month': '$_id.month',
143
+ 'day': '$_id.day',
144
+ 'hour': '$_id.hour',
145
+ [variable]: '$' + variable
146
+ };
147
+ }
148
+ else {
149
+ groupId = {
150
+ day: {
151
+ $dayOfMonth: {
152
+ date: '$date',
153
+ timezone: "America/Chicago"
154
+ }
155
+ },
156
+ month: {
157
+ $month: {
158
+ date: '$date',
159
+ timezone: "America/Chicago"
160
+ }
161
+ },
162
+ year: {
163
+ $year: {
164
+ date: '$date',
165
+ timezone: "America/Chicago"
166
+ }
167
+ },
168
+ client: '$client',
169
+ instance: '$instance'
170
+ };
171
+ groupDate = {
172
+ 'year': '$_id.year',
173
+ 'month': '$_id.month',
174
+ 'day': '$_id.day',
175
+ [variable]: '$' + variable
176
+ };
177
+ }
178
+ let query = [
179
+ {
180
+ $match: {
181
+ $and: [
182
+ {
183
+ date: { $gte: date_start }
184
+ },
228
185
  {
229
- $match: {
230
- $and: [
231
- {
232
- date: { $gte: date_start }
233
- },
234
- {
235
- date: { $lte: date_end }
236
- }
237
- ]
238
- }
186
+ date: { $lte: date_end }
239
187
  }
240
- ];
241
- if (client) {
242
- query[0]['$match'].$and.push({ client: client });
188
+ ]
189
+ }
190
+ }
191
+ ];
192
+ if (client) {
193
+ query[0]['$match'].$and.push({ client: client });
194
+ }
195
+ if (instance) {
196
+ query[0]['$match'].$and.push({ instance: instance });
197
+ }
198
+ let firstGroupId = deepCopy(groupId);
199
+ if (collection === 'monitor-mongos') {
200
+ firstGroupId[variable] = '$' + variable;
201
+ groupDate['data'] = '$data';
202
+ }
203
+ if (collection === 'monitor-mongos') {
204
+ query.push({
205
+ $group: {
206
+ _id: firstGroupId,
207
+ [variable]: {
208
+ '$sum': 1
209
+ },
210
+ [variable + '_name']: {
211
+ $first: '$' + [variable]
212
+ },
213
+ date: {
214
+ $first: '$date'
215
+ },
216
+ client: {
217
+ $first: '$client'
218
+ },
219
+ instance: {
220
+ $first: '$instance'
243
221
  }
244
- if (instance) {
245
- query[0]['$match'].$and.push({ instance: instance });
222
+ }
223
+ });
224
+ query.push({
225
+ $addFields: {
226
+ data: {
227
+ [variable]: '$' + variable,
228
+ [variable + '_name']: '$' + variable + '_name'
246
229
  }
247
- firstGroupId = common_1.deepCopy(groupId);
248
- if (collection === 'monitor-mongos') {
249
- firstGroupId[variable] = '$' + variable;
250
- groupDate['data'] = '$data';
230
+ }
231
+ });
232
+ query.push({
233
+ $group: {
234
+ _id: groupId,
235
+ [variable]: {
236
+ '$sum': '$data.' + variable
237
+ },
238
+ data: {
239
+ $push: '$data'
251
240
  }
252
- if (collection === 'monitor-mongos') {
253
- query.push({
254
- $group: (_e = {
255
- _id: firstGroupId
256
- },
257
- _e[variable] = {
258
- '$sum': 1
259
- },
260
- _e[variable + '_name'] = {
261
- $first: '$' + [variable]
262
- },
263
- _e.date = {
264
- $first: '$date'
265
- },
266
- _e.client = {
267
- $first: '$client'
268
- },
269
- _e.instance = {
270
- $first: '$instance'
271
- },
272
- _e)
273
- });
274
- query.push({
275
- $addFields: {
276
- data: (_f = {},
277
- _f[variable] = '$' + variable,
278
- _f[variable + '_name'] = '$' + variable + '_name',
279
- _f)
280
- }
281
- });
282
- query.push({
283
- $group: (_g = {
284
- _id: groupId
285
- },
286
- _g[variable] = {
287
- '$sum': '$data.' + variable
288
- },
289
- _g.data = {
290
- $push: '$data'
291
- },
292
- _g)
293
- });
294
- query.push({
295
- $addFields: (_h = {},
296
- _h[variable] = groupDate,
297
- _h)
298
- });
299
- query.push({
300
- $group: (_j = {
301
- _id: {
302
- client: '$_id.client',
303
- instance: '$_id.instance'
304
- },
305
- data: {
306
- $push: '$' + variable
307
- }
308
- },
309
- _j[variable] = {
310
- $sum: '$' + variable + '.' + variable
311
- },
312
- _j)
313
- });
241
+ }
242
+ });
243
+ query.push({
244
+ $addFields: {
245
+ [variable]: groupDate
246
+ }
247
+ });
248
+ query.push({
249
+ $group: {
250
+ _id: {
251
+ client: '$_id.client',
252
+ instance: '$_id.instance'
253
+ },
254
+ data: {
255
+ $push: '$' + variable
256
+ },
257
+ [variable]: {
258
+ $sum: '$' + variable + '.' + variable
314
259
  }
315
- else {
316
- query.push({
317
- $group: (_k = {
318
- _id: groupId
319
- },
320
- _k[variable] = (_l = {},
321
- _l['$' + variableType] = '$' + variable,
322
- _l),
323
- _k)
324
- });
325
- query.push({
326
- $addFields: (_m = {},
327
- _m[variable] = groupDate,
328
- _m)
329
- });
330
- query.push({
331
- $group: (_o = {
332
- _id: {
333
- client: '$_id.client',
334
- instance: '$_id.instance'
335
- },
336
- data: {
337
- $push: '$' + variable
338
- }
339
- },
340
- _o[variable] = {
341
- $sum: '$' + variable + '.' + variable
342
- },
343
- _o)
344
- });
260
+ }
261
+ });
262
+ }
263
+ else {
264
+ query.push({
265
+ $group: {
266
+ _id: groupId,
267
+ [variable]: {
268
+ ['$' + variableType]: '$' + variable
345
269
  }
346
- query.push({
347
- $sort: {
348
- '_id.client': 1,
349
- '_id.instance': 1
350
- }
351
- });
352
- return [4 /*yield*/, __1.ResolveIOServer.getMongoManager().collection(collection).aggregate(query, { allowDiskUse: true })];
353
- case 1:
354
- graphData = _p.sent();
355
- resolve(graphData);
356
- return [2 /*return*/];
270
+ }
271
+ });
272
+ query.push({
273
+ $addFields: {
274
+ [variable]: groupDate
275
+ }
276
+ });
277
+ query.push({
278
+ $group: {
279
+ _id: {
280
+ client: '$_id.client',
281
+ instance: '$_id.instance'
282
+ },
283
+ data: {
284
+ $push: '$' + variable
285
+ },
286
+ [variable]: {
287
+ $sum: '$' + variable + '.' + variable
288
+ }
289
+ }
290
+ });
291
+ }
292
+ query.push({
293
+ $sort: {
294
+ '_id.client': 1,
295
+ '_id.instance': 1
357
296
  }
358
297
  });
359
- }); });
298
+ // console.log(JSON.stringify(query, null, 2));
299
+ let graphData = await ResolveIOServer.getMongoManager().collection(collection).aggregate(query, { allowDiskUse: true });
300
+ resolve(graphData);
301
+ });
360
302
  },
361
303
  skipValidation: true
362
304
  },
363
305
  monitorMongos: {
364
306
  function: function () {
365
- return monitor_mongo_collection_1.MonitorMongos.find();
307
+ return MonitorMongos.find();
366
308
  }
367
309
  },
368
310
  monitorCPUs: {
369
311
  function: function () {
370
- return monitor_cpu_collection_1.MonitorCPUs.find();
312
+ return MonitorCPUs.find();
371
313
  }
372
314
  },
373
315
  monitorMemorys: {
374
316
  function: function () {
375
- return monitor_memory_collection_1.MonitorMemorys.find();
317
+ return MonitorMemorys.find();
376
318
  }
377
319
  },
378
320
  monitorHTTPSOutbounds: {
379
321
  function: function () {
380
- return monitor_https_outbound_collection_1.MonitorHTTPSOutbounds.find();
322
+ return MonitorHTTPSOutbounds.find();
381
323
  }
382
324
  },
383
325
  monitorHTTPSInbounds: {
384
326
  function: function () {
385
- return monitor_https_inbound_collection_1.MonitorHTTPSInbounds.find();
327
+ return MonitorHTTPSInbounds.find();
386
328
  }
387
329
  },
388
330
  });
389
331
  }
390
- exports.loadMonitorMethods = loadMonitorMethods;
391
332
 
392
333
  //# sourceMappingURL=monitor.js.map