@resolveio/server-lib 9.2.19 → 9.2.20

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 (221) hide show
  1. package/client-server-app.js +55 -1
  2. package/client-server-app.js.map +1 -1
  3. package/collections/app-status.collection.js +40 -1
  4. package/collections/app-status.collection.js.map +1 -1
  5. package/collections/app-version.collection.js +40 -1
  6. package/collections/app-version.collection.js.map +1 -1
  7. package/collections/counter.collection.js +43 -1
  8. package/collections/counter.collection.js.map +1 -1
  9. package/collections/cron-job-history.collection.js +71 -1
  10. package/collections/cron-job-history.collection.js.map +1 -1
  11. package/collections/cron-job.collection.js +74 -1
  12. package/collections/cron-job.collection.js.map +1 -1
  13. package/collections/email-history.collection.js +55 -1
  14. package/collections/email-history.collection.js.map +1 -1
  15. package/collections/email-verified.collection.js +50 -1
  16. package/collections/email-verified.collection.js.map +1 -1
  17. package/collections/file.collection.js +62 -1
  18. package/collections/file.collection.js.map +1 -1
  19. package/collections/flag.collection.js +44 -1
  20. package/collections/flag.collection.js.map +1 -1
  21. package/collections/log-method-latency.collection.js +53 -1
  22. package/collections/log-method-latency.collection.js.map +1 -1
  23. package/collections/log-subscription.collection.js +57 -1
  24. package/collections/log-subscription.collection.js.map +1 -1
  25. package/collections/log.collection.js +72 -1
  26. package/collections/log.collection.js.map +1 -1
  27. package/collections/logged-in-users.collection.js +58 -1
  28. package/collections/logged-in-users.collection.js.map +1 -1
  29. package/collections/method-call.collection.js +51 -1
  30. package/collections/method-call.collection.js.map +1 -1
  31. package/collections/method-response.collection.js +55 -1
  32. package/collections/method-response.collection.js.map +1 -1
  33. package/collections/monitor-cpu.collection.js +57 -1
  34. package/collections/monitor-cpu.collection.js.map +1 -1
  35. package/collections/monitor-https-inbound.collection.js +66 -1
  36. package/collections/monitor-https-inbound.collection.js.map +1 -1
  37. package/collections/monitor-https-outbound.collection.js +74 -1
  38. package/collections/monitor-https-outbound.collection.js.map +1 -1
  39. package/collections/monitor-memory.collection.js +68 -1
  40. package/collections/monitor-memory.collection.js.map +1 -1
  41. package/collections/monitor-mongo.collection.js +62 -1
  42. package/collections/monitor-mongo.collection.js.map +1 -1
  43. package/collections/notification.collection.js +40 -1
  44. package/collections/notification.collection.js.map +1 -1
  45. package/collections/report-builder-dashboard-builder.collection.js +93 -1
  46. package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
  47. package/collections/report-builder-library.collection.js +76 -1
  48. package/collections/report-builder-library.collection.js.map +1 -1
  49. package/collections/report-builder-report.collection.js +138 -1
  50. package/collections/report-builder-report.collection.js.map +1 -1
  51. package/collections/user-group.collection.js +79 -1
  52. package/collections/user-group.collection.js.map +1 -1
  53. package/collections/user-guide.collection.js +46 -1
  54. package/collections/user-guide.collection.js.map +1 -1
  55. package/collections/user.collection.js +248 -1
  56. package/collections/user.collection.js.map +1 -1
  57. package/cron/cron.js +161 -1
  58. package/cron/cron.js.map +1 -1
  59. package/fixtures/cron-jobs.js +72 -1
  60. package/fixtures/cron-jobs.js.map +1 -1
  61. package/fixtures/init.js +62 -1
  62. package/fixtures/init.js.map +1 -1
  63. package/http/auth.js +697 -1
  64. package/http/auth.js.map +1 -1
  65. package/http/health.js +10 -1
  66. package/http/health.js.map +1 -1
  67. package/http/home.js +64 -1
  68. package/http/home.js.map +1 -1
  69. package/index.js +123 -1
  70. package/index.js.map +1 -1
  71. package/managers/cron.manager.js +205 -1
  72. package/managers/cron.manager.js.map +1 -1
  73. package/managers/method.manager.js +599 -1
  74. package/managers/method.manager.js.map +1 -1
  75. package/managers/mongo.manager.js +1682 -1
  76. package/managers/mongo.manager.js.map +1 -1
  77. package/managers/monitor.manager.js +334 -1
  78. package/managers/monitor.manager.js.map +1 -1
  79. package/managers/subscription.manager.js +867 -1
  80. package/managers/subscription.manager.js.map +1 -1
  81. package/managers/subscription.performance.js +100 -1
  82. package/managers/subscription.performance.js.map +1 -1
  83. package/methods/accounts.js +224 -1
  84. package/methods/accounts.js.map +1 -1
  85. package/methods/aws.js +449 -1
  86. package/methods/aws.js.map +1 -1
  87. package/methods/cloudconvert.js +214 -1
  88. package/methods/cloudconvert.js.map +1 -1
  89. package/methods/collections.js +526 -1
  90. package/methods/collections.js.map +1 -1
  91. package/methods/counters.js +121 -1
  92. package/methods/counters.js.map +1 -1
  93. package/methods/cron-jobs.js +1284 -1
  94. package/methods/cron-jobs.js.map +1 -1
  95. package/methods/flags.js +8 -1
  96. package/methods/flags.js.map +1 -1
  97. package/methods/logs.js +370 -1
  98. package/methods/logs.js.map +1 -1
  99. package/methods/monitor.js +384 -1
  100. package/methods/monitor.js.map +1 -1
  101. package/methods/pdf.js +685 -1
  102. package/methods/pdf.js.map +1 -1
  103. package/methods/report-builder.js +826 -1
  104. package/methods/report-builder.js.map +1 -1
  105. package/methods/support.js +263 -1
  106. package/methods/support.js.map +1 -1
  107. package/models/app-status.model.js +3 -1
  108. package/models/app-status.model.js.map +1 -1
  109. package/models/app-version.model.js +3 -1
  110. package/models/app-version.model.js.map +1 -1
  111. package/models/billing-logged-in-users.model.js +3 -1
  112. package/models/billing-logged-in-users.model.js.map +1 -1
  113. package/models/collection-document.model.js +3 -1
  114. package/models/collection-document.model.js.map +1 -1
  115. package/models/counter.model.js +3 -1
  116. package/models/counter.model.js.map +1 -1
  117. package/models/cron-job-history.model.js +3 -1
  118. package/models/cron-job-history.model.js.map +1 -1
  119. package/models/cron-job.model.js +3 -1
  120. package/models/cron-job.model.js.map +1 -1
  121. package/models/dialog.model.js +3 -1
  122. package/models/dialog.model.js.map +1 -1
  123. package/models/email-history.model.js +3 -1
  124. package/models/email-history.model.js.map +1 -1
  125. package/models/email-verified.model.js +3 -1
  126. package/models/email-verified.model.js.map +1 -1
  127. package/models/file.model.js +3 -1
  128. package/models/file.model.js.map +1 -1
  129. package/models/flag.model.js +3 -1
  130. package/models/flag.model.js.map +1 -1
  131. package/models/log-method-latency.model.js +3 -1
  132. package/models/log-method-latency.model.js.map +1 -1
  133. package/models/log-subscription.model.js +3 -1
  134. package/models/log-subscription.model.js.map +1 -1
  135. package/models/log.model.js +3 -1
  136. package/models/log.model.js.map +1 -1
  137. package/models/logged-in-users.model.js +3 -1
  138. package/models/logged-in-users.model.js.map +1 -1
  139. package/models/method-call.model.js +3 -1
  140. package/models/method-call.model.js.map +1 -1
  141. package/models/method-response.model.js +3 -1
  142. package/models/method-response.model.js.map +1 -1
  143. package/models/method.model.js +3 -1
  144. package/models/method.model.js.map +1 -1
  145. package/models/monitor-cpu.model.js +3 -1
  146. package/models/monitor-cpu.model.js.map +1 -1
  147. package/models/monitor-https-inbound.model.js +3 -1
  148. package/models/monitor-https-inbound.model.js.map +1 -1
  149. package/models/monitor-https-outbound.model.js +3 -1
  150. package/models/monitor-https-outbound.model.js.map +1 -1
  151. package/models/monitor-memory.model.js +3 -1
  152. package/models/monitor-memory.model.js.map +1 -1
  153. package/models/monitor-mongo.model.js +3 -1
  154. package/models/monitor-mongo.model.js.map +1 -1
  155. package/models/notification.model.js +3 -1
  156. package/models/notification.model.js.map +1 -1
  157. package/models/pagination.model.js +23 -1
  158. package/models/pagination.model.js.map +1 -1
  159. package/models/permission.model.js +3 -1
  160. package/models/permission.model.js.map +1 -1
  161. package/models/report-builder-dashboard-builder.model.js +3 -1
  162. package/models/report-builder-dashboard-builder.model.js.map +1 -1
  163. package/models/report-builder-library.model.js +3 -1
  164. package/models/report-builder-library.model.js.map +1 -1
  165. package/models/report-builder-report.model.js +3 -1
  166. package/models/report-builder-report.model.js.map +1 -1
  167. package/models/report-builder.model.js +3 -1
  168. package/models/report-builder.model.js.map +1 -1
  169. package/models/select-data-label.model.js +3 -1
  170. package/models/select-data-label.model.js.map +1 -1
  171. package/models/server-response.model.js +3 -1
  172. package/models/server-response.model.js.map +1 -1
  173. package/models/subscription.model.js +3 -1
  174. package/models/subscription.model.js.map +1 -1
  175. package/models/support-ticket.model.js +3 -1
  176. package/models/support-ticket.model.js.map +1 -1
  177. package/models/user-group.model.js +3 -1
  178. package/models/user-group.model.js.map +1 -1
  179. package/models/user-guide.model.js +3 -1
  180. package/models/user-guide.model.js.map +1 -1
  181. package/models/user.model.js +3 -1
  182. package/models/user.model.js.map +1 -1
  183. package/package.json +1 -2
  184. package/public_api.js +78 -1
  185. package/public_api.js.map +1 -1
  186. package/publications/app-status.js +16 -1
  187. package/publications/app-status.js.map +1 -1
  188. package/publications/app-version.js +16 -1
  189. package/publications/app-version.js.map +1 -1
  190. package/publications/cron-jobs.js +32 -1
  191. package/publications/cron-jobs.js.map +1 -1
  192. package/publications/files.js +36 -1
  193. package/publications/files.js.map +1 -1
  194. package/publications/flags.js +22 -1
  195. package/publications/flags.js.map +1 -1
  196. package/publications/logs.js +90 -1
  197. package/publications/logs.js.map +1 -1
  198. package/publications/method-calls.js +16 -1
  199. package/publications/method-calls.js.map +1 -1
  200. package/publications/method-responses.js +16 -1
  201. package/publications/method-responses.js.map +1 -1
  202. package/publications/notifications.js +16 -1
  203. package/publications/notifications.js.map +1 -1
  204. package/publications/report-builder-dashboard-builders.js +42 -1
  205. package/publications/report-builder-dashboard-builders.js.map +1 -1
  206. package/publications/report-builder-libraries.js +89 -1
  207. package/publications/report-builder-libraries.js.map +1 -1
  208. package/publications/report-builder-reports.js +50 -1
  209. package/publications/report-builder-reports.js.map +1 -1
  210. package/publications/super-admin.js +16 -1
  211. package/publications/super-admin.js.map +1 -1
  212. package/publications/user-groups.js +16 -1
  213. package/publications/user-groups.js.map +1 -1
  214. package/publications/user-guides.js +16 -1
  215. package/publications/user-guides.js.map +1 -1
  216. package/server-app.js +682 -1
  217. package/server-app.js.map +1 -1
  218. package/util/common.js +498 -1
  219. package/util/common.js.map +1 -1
  220. package/util/schema-report-builder.js +452 -1
  221. package/util/schema-report-builder.js.map +1 -1
package/methods/logs.js CHANGED
@@ -1,2 +1,371 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(r,a){function fulfilled(e){try{step(n.next(e))}catch(e){a(e)}}function rejected(e){try{step(n.throw(e))}catch(e){a(e)}}function step(e){e.done?r(e.value):function adopt(e){return e instanceof o?e:new o((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var o,n,r,a,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function verb(a){return function(c){return function step(a){if(o)throw new TypeError("Generator is already executing.");for(;i;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){i.label=a[1];break}if(6===a[0]&&i.label<r[1]){i.label=r[1],r=a;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(a);break}r[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadLogMethods=void 0;var log_collection_1=require("../collections/log.collection"),log_subscription_collection_1=require("../collections/log-subscription.collection"),index_1=require("../index"),log_method_latency_collection_1=require("../collections/log-method-latency.collection"),mongo_manager_1=require("../managers/mongo.manager");function loadLogMethods(e){e.methods({insertErrorLog:{function:function(e,t){return this.sendEmail("dev@resolveio.com","Error Detected - "+index_1.ResolveIOServer.getClientName(),this.user+"\n"+e+"\n"+JSON.stringify(t,null,2)),log_collection_1.Logs.insertOne({_id:mongo_manager_1.objectIdHexString(),type:"error",collection:"",id_document:"",payload:JSON.stringify(t,null,2),method:"",id_user:this.id_user||"",user:this.user||"",messageId:0,route:""})},skipValidation:!0},insertSubscriptionLog:{function:function(e,t,o,n){return log_subscription_collection_1.LogSubscriptions.create({_id:mongo_manager_1.objectIdHexString(),__v:0,date:new Date,type:e,subscription:t,collection_name:o,subData:n})},skipValidation:!0},insertMethodLatencyLog:{function:function(e){return log_method_latency_collection_1.LogMethodLatencies.create({_id:mongo_manager_1.objectIdHexString(),__v:0,date_start:new Date,date_end:null,latency_ms:0,method:e})},skipValidation:!0},superadminAPM:{function:function(e,t,o){var n=this;return new Promise((function(r,a){return __awaiter(n,void 0,void 0,(function(){var n,a,i,c,d,s;return __generator(this,(function(l){switch(l.label){case 0:return[4,log_method_latency_collection_1.LogMethodLatencies.aggregate([{$match:{$and:[{createdAt:{$gte:e}},{createdAt:{$lte:t}}]}},{$group:{_id:"$method",method:{$first:"$method"},count:{$sum:1},latency_min:{$min:"$latency_ms"},latency_avg:{$avg:"$latency_ms"},latency_max:{$max:"$latency_ms"}}}],{allowDiskUse:!0,readPreference:"secondary"})];case 1:return n=l.sent(),[4,log_subscription_collection_1.LogSubscriptions.aggregate([{$match:{$and:[{createdAt:{$gte:e}},{createdAt:{$lte:t}}]}},{$group:{_id:"$subscription",subscription:{$first:"$subscription"},count:{$sum:1}}}],{allowDiskUse:!0,readPreference:"secondary"})];case 2:return a=l.sent(),i={},c={},"seconds"===o?(i={second:{$second:{date:"$createdAt",timezone:"America/Chicago"}},minute:{$minute:{date:"$createdAt",timezone:"America/Chicago"}},hour:{$hour:{date:"$createdAt",timezone:"America/Chicago"}},day:{$dayOfMonth:{date:"$createdAt",timezone:"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:"America/Chicago"}}},c={"_id.year":1,"_id.month":1,"_id.day":1,"_id.hour":1,"_id.minute":1,"_id.second":1}):"minutes"===o?(i={minute:{$minute:{date:"$createdAt",timezone:"America/Chicago"}},hour:{$hour:{date:"$createdAt",timezone:"America/Chicago"}},day:{$dayOfMonth:{date:"$createdAt",timezone:"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:"America/Chicago"}}},c={"_id.year":1,"_id.month":1,"_id.day":1,"_id.hour":1,"_id.minute":1}):"hours"===o?(i={hour:{$hour:{date:"$createdAt",timezone:"America/Chicago"}},day:{$dayOfMonth:{date:"$createdAt",timezone:"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:"America/Chicago"}}},c={"_id.year":1,"_id.month":1,"_id.day":1,"_id.hour":1}):(i={day:{$dayOfMonth:{date:"$createdAt",timezone:"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:"America/Chicago"}}},c={"_id.year":1,"_id.month":1,"_id.day":1}),[4,log_method_latency_collection_1.LogMethodLatencies.aggregate([{$match:{$and:[{createdAt:{$gte:e}},{createdAt:{$lte:t}}]}},{$group:{_id:i,count:{$sum:1}}},{$sort:c}],{allowDiskUse:!0,readPreference:"secondary"})];case 3:return d=l.sent(),[4,log_subscription_collection_1.LogSubscriptions.aggregate([{$match:{$and:[{createdAt:{$gte:e}},{createdAt:{$lte:t}}]}},{$group:{_id:i,count:{$sum:1}}},{$sort:c}],{allowDiskUse:!0,readPreference:"secondary"})];case 4:return s=l.sent(),r({methods:n,subscriptions:a,methodGraphData:d,subGraphData:s}),[2]}}))}))}))},skipValidation:!0}})}exports.loadLogMethods=loadLogMethods;
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.loadLogMethods = void 0;
40
+ var log_collection_1 = require("../collections/log.collection");
41
+ var log_subscription_collection_1 = require("../collections/log-subscription.collection");
42
+ var index_1 = require("../index");
43
+ var log_method_latency_collection_1 = require("../collections/log-method-latency.collection");
44
+ var mongo_manager_1 = require("../managers/mongo.manager");
45
+ function loadLogMethods(methodManager) {
46
+ methodManager.methods({
47
+ insertErrorLog: {
48
+ function: function (message, data) {
49
+ this.sendEmail('dev@resolveio.com', 'Error Detected - ' + index_1.ResolveIOServer.getClientName(), this.user + '\n' + message + '\n' + JSON.stringify(data, null, 2));
50
+ return log_collection_1.Logs.insertOne({
51
+ _id: mongo_manager_1.objectIdHexString(),
52
+ type: 'error',
53
+ collection: '',
54
+ id_document: '',
55
+ payload: JSON.stringify(data, null, 2),
56
+ method: '',
57
+ id_user: this.id_user || '',
58
+ user: this.user || '',
59
+ messageId: 0,
60
+ route: ''
61
+ });
62
+ },
63
+ skipValidation: true
64
+ },
65
+ insertSubscriptionLog: {
66
+ function: function (type, subscription, collection_name, subData) {
67
+ return log_subscription_collection_1.LogSubscriptions.create({
68
+ _id: mongo_manager_1.objectIdHexString(),
69
+ __v: 0,
70
+ date: new Date(),
71
+ type: type,
72
+ subscription: subscription,
73
+ collection_name: collection_name,
74
+ subData: subData
75
+ });
76
+ },
77
+ skipValidation: true
78
+ },
79
+ insertMethodLatencyLog: {
80
+ function: function (method) {
81
+ return log_method_latency_collection_1.LogMethodLatencies.create({
82
+ _id: mongo_manager_1.objectIdHexString(),
83
+ __v: 0,
84
+ date_start: new Date(),
85
+ date_end: null,
86
+ latency_ms: 0,
87
+ method: method
88
+ });
89
+ },
90
+ skipValidation: true
91
+ },
92
+ superadminAPM: {
93
+ function: function (date_start, date_end, graphInterval) {
94
+ var _this = this;
95
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
96
+ var latencies, subscriptions, groupId, groupSort, methodGraphData, subGraphData;
97
+ return __generator(this, function (_a) {
98
+ switch (_a.label) {
99
+ case 0: return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
100
+ {
101
+ $match: {
102
+ $and: [
103
+ {
104
+ createdAt: { $gte: date_start }
105
+ },
106
+ {
107
+ createdAt: { $lte: date_end }
108
+ }
109
+ ]
110
+ }
111
+ },
112
+ {
113
+ $group: {
114
+ _id: '$method',
115
+ method: { $first: '$method' },
116
+ count: { $sum: 1 },
117
+ latency_min: { $min: '$latency_ms' },
118
+ latency_avg: { $avg: '$latency_ms' },
119
+ latency_max: { $max: '$latency_ms' }
120
+ }
121
+ }
122
+ ], { allowDiskUse: true, readPreference: 'secondary' })];
123
+ case 1:
124
+ latencies = _a.sent();
125
+ return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
126
+ {
127
+ $match: {
128
+ $and: [
129
+ {
130
+ createdAt: { $gte: date_start }
131
+ },
132
+ {
133
+ createdAt: { $lte: date_end }
134
+ }
135
+ ]
136
+ }
137
+ },
138
+ {
139
+ $group: {
140
+ _id: '$subscription',
141
+ subscription: { $first: '$subscription' },
142
+ count: { $sum: 1 }
143
+ }
144
+ }
145
+ ], { allowDiskUse: true, readPreference: 'secondary' })];
146
+ case 2:
147
+ subscriptions = _a.sent();
148
+ groupId = {};
149
+ groupSort = {};
150
+ if (graphInterval === 'seconds') {
151
+ groupId = {
152
+ second: {
153
+ $second: {
154
+ date: '$createdAt',
155
+ timezone: "America/Chicago"
156
+ }
157
+ },
158
+ minute: {
159
+ $minute: {
160
+ date: '$createdAt',
161
+ timezone: "America/Chicago"
162
+ }
163
+ },
164
+ hour: {
165
+ $hour: {
166
+ date: '$createdAt',
167
+ timezone: "America/Chicago"
168
+ }
169
+ },
170
+ day: {
171
+ $dayOfMonth: {
172
+ date: '$createdAt',
173
+ timezone: "America/Chicago"
174
+ }
175
+ },
176
+ month: {
177
+ $month: {
178
+ date: '$createdAt',
179
+ timezone: "America/Chicago"
180
+ }
181
+ },
182
+ year: {
183
+ $year: {
184
+ date: '$createdAt',
185
+ timezone: "America/Chicago"
186
+ }
187
+ }
188
+ };
189
+ groupSort = {
190
+ '_id.year': 1,
191
+ '_id.month': 1,
192
+ '_id.day': 1,
193
+ '_id.hour': 1,
194
+ '_id.minute': 1,
195
+ '_id.second': 1
196
+ };
197
+ }
198
+ else if (graphInterval === 'minutes') {
199
+ groupId = {
200
+ minute: {
201
+ $minute: {
202
+ date: '$createdAt',
203
+ timezone: "America/Chicago"
204
+ }
205
+ },
206
+ hour: {
207
+ $hour: {
208
+ date: '$createdAt',
209
+ timezone: "America/Chicago"
210
+ }
211
+ },
212
+ day: {
213
+ $dayOfMonth: {
214
+ date: '$createdAt',
215
+ timezone: "America/Chicago"
216
+ }
217
+ },
218
+ month: {
219
+ $month: {
220
+ date: '$createdAt',
221
+ timezone: "America/Chicago"
222
+ }
223
+ },
224
+ year: {
225
+ $year: {
226
+ date: '$createdAt',
227
+ timezone: "America/Chicago"
228
+ }
229
+ }
230
+ };
231
+ groupSort = {
232
+ '_id.year': 1,
233
+ '_id.month': 1,
234
+ '_id.day': 1,
235
+ '_id.hour': 1,
236
+ '_id.minute': 1
237
+ };
238
+ }
239
+ else if (graphInterval === 'hours') {
240
+ groupId = {
241
+ hour: {
242
+ $hour: {
243
+ date: '$createdAt',
244
+ timezone: "America/Chicago"
245
+ }
246
+ },
247
+ day: {
248
+ $dayOfMonth: {
249
+ date: '$createdAt',
250
+ timezone: "America/Chicago"
251
+ }
252
+ },
253
+ month: {
254
+ $month: {
255
+ date: '$createdAt',
256
+ timezone: "America/Chicago"
257
+ }
258
+ },
259
+ year: {
260
+ $year: {
261
+ date: '$createdAt',
262
+ timezone: "America/Chicago"
263
+ }
264
+ }
265
+ };
266
+ groupSort = {
267
+ '_id.year': 1,
268
+ '_id.month': 1,
269
+ '_id.day': 1,
270
+ '_id.hour': 1
271
+ };
272
+ }
273
+ else {
274
+ groupId = {
275
+ day: {
276
+ $dayOfMonth: {
277
+ date: '$createdAt',
278
+ timezone: "America/Chicago"
279
+ }
280
+ },
281
+ month: {
282
+ $month: {
283
+ date: '$createdAt',
284
+ timezone: "America/Chicago"
285
+ }
286
+ },
287
+ year: {
288
+ $year: {
289
+ date: '$createdAt',
290
+ timezone: "America/Chicago"
291
+ }
292
+ }
293
+ };
294
+ groupSort = {
295
+ '_id.year': 1,
296
+ '_id.month': 1,
297
+ '_id.day': 1
298
+ };
299
+ }
300
+ return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
301
+ {
302
+ $match: {
303
+ $and: [
304
+ {
305
+ createdAt: { $gte: date_start }
306
+ },
307
+ {
308
+ createdAt: { $lte: date_end }
309
+ }
310
+ ]
311
+ }
312
+ },
313
+ {
314
+ $group: {
315
+ _id: groupId,
316
+ count: {
317
+ $sum: 1
318
+ }
319
+ }
320
+ },
321
+ {
322
+ $sort: groupSort
323
+ }
324
+ ], { allowDiskUse: true, readPreference: 'secondary' })];
325
+ case 3:
326
+ methodGraphData = _a.sent();
327
+ return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
328
+ {
329
+ $match: {
330
+ $and: [
331
+ {
332
+ createdAt: { $gte: date_start }
333
+ },
334
+ {
335
+ createdAt: { $lte: date_end }
336
+ }
337
+ ]
338
+ }
339
+ },
340
+ {
341
+ $group: {
342
+ _id: groupId,
343
+ count: {
344
+ $sum: 1
345
+ }
346
+ }
347
+ },
348
+ {
349
+ $sort: groupSort
350
+ }
351
+ ], { allowDiskUse: true, readPreference: 'secondary' })];
352
+ case 4:
353
+ subGraphData = _a.sent();
354
+ resolve({
355
+ methods: latencies,
356
+ subscriptions: subscriptions,
357
+ methodGraphData: methodGraphData,
358
+ subGraphData: subGraphData
359
+ });
360
+ return [2 /*return*/];
361
+ }
362
+ });
363
+ }); });
364
+ },
365
+ skipValidation: true
366
+ }
367
+ });
368
+ }
369
+ exports.loadLogMethods = loadLogMethods;
370
+
2
371
  //# sourceMappingURL=logs.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/logs.ts"],"names":["log_collection_1","require","log_subscription_collection_1","index_1","log_method_latency_collection_1","mongo_manager_1","loadLogMethods","methodManager","methods","insertErrorLog","function","message","data","this","sendEmail","ResolveIOServer","getClientName","user","JSON","stringify","Logs","insertOne","_id","objectIdHexString","type","collection","id_document","payload","method","id_user","messageId","route","skipValidation","insertSubscriptionLog","subscription","collection_name","subData","LogSubscriptions","create","__v","date","Date","insertMethodLatencyLog","LogMethodLatencies","date_start","date_end","latency_ms","superadminAPM","graphInterval","_this","Promise","resolve","reject","__awaiter","aggregate","$match","$and","createdAt","$gte","$lte","$group","$first","count","$sum","latency_min","$min","latency_avg","$avg","latency_max","$max","allowDiskUse","readPreference","latencies","_a","sent","subscriptions","groupId","groupSort","second","$second","timezone","minute","$minute","hour","$hour","day","$dayOfMonth","month","$month","year","$year","_id.year","_id.month","_id.day","_id.hour","_id.minute","_id.second","$sort","methodGraphData","subGraphData","exports"],"mappings":"+jDACA,IAAAA,iBAAAC,QAAA,iCACAC,8BAAAD,QAAA,8CACAE,QAAAF,QAAA,YACAG,gCAAAH,QAAA,gDACAI,gBAAAJ,QAAA,6BAEA,SAAgBK,eAAeC,GAC9BA,EAAcC,QAAQ,CACrBC,eAAgB,CACfC,SAAU,SAASC,EAASC,GAG3B,OAFAC,KAAKC,UAAU,oBAAqB,oBAAsBX,QAAAY,gBAAgBC,gBAAiBH,KAAKI,KAAO,KAAON,EAAU,KAAOO,KAAKC,UAAUP,EAAM,KAAM,IAEnJZ,iBAAAoB,KAAKC,UAAU,CACrBC,IAAKjB,gBAAAkB,oBACLC,KAAM,QACNC,WAAY,GACZC,YAAa,GACbC,QAAST,KAAKC,UAAUP,EAAM,KAAM,GACpCgB,OAAQ,GACRC,QAAShB,KAAKgB,SAAW,GACzBZ,KAAMJ,KAAKI,MAAQ,GACnBa,UAAW,EACXC,MAAO,MAGTC,gBAAgB,GAEjBC,sBAAuB,CACtBvB,SAAU,SAASc,EAAMU,EAAcC,EAAiBC,GACvD,OAAOlC,8BAAAmC,iBAAiBC,OAAO,CAC9BhB,IA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ACXc,WAAY,EACZC,YAAa,EACbC,UAAW,IAIS,CAAA,EAAMzF,gCAAAuC,mBAAmBW,UAAU,CACxD,CACCC,OAAQ,CACPC,KAAM,CACL,CACCC,UAAW,CAACC,KAAMd,IAEnB,CACCa,UAAW,CAACE,KAAMd,OAKtB,CACCe,OAAQ,CACPtC,IAAKsD,EACLd,MAAO,CACNC,KAAM,KAIT,CACCkC,MAAOpB,IAEN,CAACP,cAAc,EAAMC,eAAgB,sBAErB,OA1Bf2B,EAAkBzB,EAAAC,OA0BH,CAAA,EAAMxE,8BAAAmC,iBAAiBiB,UAAU,CACnD,CACCC,OAAQ,CACPC,KAAM,CACL,CACCC,UAAW,CAACC,KAAMd,IAEnB,CACCa,UAAW,CAACE,KAAMd,OAKtB,CACCe,OAAQ,CACPtC,IAAKsD,EACLd,MAAO,CACNC,KAAM,KAIT,CACCkC,MAAOpB,IAEN,CAACP,cAAc,EAAMC,eAAgB,6BAxBpC4B,EAAe1B,EAAAC,OA0BnBvB,EAAQ,CACP3C,QAASgE,EACTG,cAAeA,EACfuB,gBAAiBA,EACjBC,aAAcA,mBAIjBnE,gBAAgB,KA5TnBoE,QAAA9F,eAAAA","file":"logs.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { Logs } from '../collections/log.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { ResolveIOServer } from '../index';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tinsertErrorLog: {\n\t\t\tfunction: function(message, data) {\n\t\t\t\tthis.sendEmail('dev@resolveio.com', 'Error Detected - ' + ResolveIOServer.getClientName(), this.user + '\\n' + message + '\\n' + JSON.stringify(data, null, 2));\n\n\t\t\t\treturn Logs.insertOne({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\ttype: 'error',\n\t\t\t\t\tcollection: '',\n\t\t\t\t\tid_document: '',\n\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\tmethod: '',\n\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\tmessageId: 0,\n\t\t\t\t\troute: ''\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: function(type, subscription, collection_name, subData) {\n\t\t\t\treturn LogSubscriptions.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\ttype: type,\n\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\tsubData: subData\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertMethodLatencyLog: {\n\t\t\tfunction: function(method) {\n\t\t\t\treturn LogMethodLatencies.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\tdate_end: null,\n\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\tmethod: method\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupSort = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tmethods: latencies,\n\t\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}"]}
1
+ {"version":3,"sources":["../../src/methods/logs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gEAAqD;AACrD,0FAA8E;AAC9E,kCAA2C;AAC3C,8FAAkF;AAClF,2DAA8D;AAE9D,SAAgB,cAAc,CAAC,aAA4B;IAC1D,aAAa,CAAC,OAAO,CAAC;QACrB,cAAc,EAAE;YACf,QAAQ,EAAE,UAAS,OAAO,EAAE,IAAI;gBAC/B,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,uBAAe,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBAE9J,OAAO,qBAAI,CAAC,SAAS,CAAC;oBACrB,GAAG,EAAE,iCAAiB,EAAE;oB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AClB,aAAa,EAAE,aAAa;oCAC5B,eAAe,EAAE,eAAe;oCAChC,YAAY,EAAE,YAAY;iCAC1B,CAAC,CAAC;;;;qBACH,CAAC,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,IAAI;SACpB;KACD,CAAC,CAAC;AACJ,CAAC;AA/TD,wCA+TC","file":"logs.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { Logs } from '../collections/log.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { ResolveIOServer } from '../index';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tinsertErrorLog: {\n\t\t\tfunction: function(message, data) {\n\t\t\t\tthis.sendEmail('dev@resolveio.com', 'Error Detected - ' + ResolveIOServer.getClientName(), this.user + '\\n' + message + '\\n' + JSON.stringify(data, null, 2));\n\n\t\t\t\treturn Logs.insertOne({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\ttype: 'error',\n\t\t\t\t\tcollection: '',\n\t\t\t\t\tid_document: '',\n\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\tmethod: '',\n\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\tmessageId: 0,\n\t\t\t\t\troute: ''\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: function(type, subscription, collection_name, subData) {\n\t\t\t\treturn LogSubscriptions.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\ttype: type,\n\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\tsubData: subData\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertMethodLatencyLog: {\n\t\t\tfunction: function(method) {\n\t\t\t\treturn LogMethodLatencies.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\tdate_end: null,\n\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\tmethod: method\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupSort = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tmethods: latencies,\n\t\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}"]}