@resolveio/server-lib 20.7.120 → 20.7.122

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 (216) hide show
  1. package/client-server-app.js +51 -1
  2. package/client-server-app.js.map +1 -1
  3. package/collections/app-status.collection.js +51 -1
  4. package/collections/app-status.collection.js.map +1 -1
  5. package/collections/counter.collection.js +55 -1
  6. package/collections/counter.collection.js.map +1 -1
  7. package/collections/cron-job-history.collection.js +136 -1
  8. package/collections/cron-job-history.collection.js.map +1 -1
  9. package/collections/cron-job.collection.js +87 -1
  10. package/collections/cron-job.collection.js.map +1 -1
  11. package/collections/email-history.collection.js +98 -1
  12. package/collections/email-history.collection.js.map +1 -1
  13. package/collections/email-verified.collection.js +60 -1
  14. package/collections/email-verified.collection.js.map +1 -1
  15. package/collections/file.collection.js +73 -1
  16. package/collections/file.collection.js.map +1 -1
  17. package/collections/flag-update.collection.js +56 -1
  18. package/collections/flag-update.collection.js.map +1 -1
  19. package/collections/flag.collection.js +56 -1
  20. package/collections/flag.collection.js.map +1 -1
  21. package/collections/log-method-latency.collection.js +72 -1
  22. package/collections/log-method-latency.collection.js.map +1 -1
  23. package/collections/log-subscription.collection.js +75 -1
  24. package/collections/log-subscription.collection.js.map +1 -1
  25. package/collections/log.collection.js +87 -1
  26. package/collections/log.collection.js.map +1 -1
  27. package/collections/logged-in-users.collection.js +66 -1
  28. package/collections/logged-in-users.collection.js.map +1 -1
  29. package/collections/monitor-cpu.collection.js +64 -1
  30. package/collections/monitor-cpu.collection.js.map +1 -1
  31. package/collections/monitor-function.collection.js +73 -1
  32. package/collections/monitor-function.collection.js.map +1 -1
  33. package/collections/monitor-memory.collection.js +76 -1
  34. package/collections/monitor-memory.collection.js.map +1 -1
  35. package/collections/monitor-mongo.collection.js +70 -1
  36. package/collections/monitor-mongo.collection.js.map +1 -1
  37. package/collections/notification.collection.js +56 -1
  38. package/collections/notification.collection.js.map +1 -1
  39. package/collections/report-builder-dashboard-builder.collection.js +108 -1
  40. package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
  41. package/collections/report-builder-library.collection.js +86 -1
  42. package/collections/report-builder-library.collection.js.map +1 -1
  43. package/collections/report-builder-report.collection.js +148 -1
  44. package/collections/report-builder-report.collection.js.map +1 -1
  45. package/collections/user-group.collection.js +88 -1
  46. package/collections/user-group.collection.js.map +1 -1
  47. package/collections/user-guide.collection.js +56 -1
  48. package/collections/user-guide.collection.js.map +1 -1
  49. package/collections/user.collection.js +265 -1
  50. package/collections/user.collection.js.map +1 -1
  51. package/cron/cron.js +97 -1
  52. package/cron/cron.js.map +1 -1
  53. package/fixtures/cron-jobs.js +95 -1
  54. package/fixtures/cron-jobs.js.map +1 -1
  55. package/fixtures/init.js +78 -1
  56. package/fixtures/init.js.map +1 -1
  57. package/http/auth.js +869 -1
  58. package/http/auth.js.map +1 -1
  59. package/http/health.js +11 -1
  60. package/http/health.js.map +1 -1
  61. package/http/home.js +114 -1
  62. package/http/home.js.map +1 -1
  63. package/index.js +18 -1
  64. package/index.js.map +1 -1
  65. package/managers/cron.manager.js +461 -1
  66. package/managers/cron.manager.js.map +1 -1
  67. package/managers/local-log.manager.js +79 -1
  68. package/managers/local-log.manager.js.map +1 -1
  69. package/managers/method.manager.js +1025 -1
  70. package/managers/method.manager.js.map +1 -1
  71. package/managers/mongo.manager.js +4231 -1
  72. package/managers/mongo.manager.js.map +1 -1
  73. package/managers/monitor.manager.js +534 -1
  74. package/managers/monitor.manager.js.map +1 -1
  75. package/managers/subscription.manager.js +1292 -1
  76. package/managers/subscription.manager.js.map +1 -1
  77. package/managers/websocket.manager.js +165 -1
  78. package/managers/websocket.manager.js.map +1 -1
  79. package/managers/worker-dispatcher.manager.js +335 -1
  80. package/managers/worker-dispatcher.manager.js.map +1 -1
  81. package/managers/worker-server.manager.js +292 -1
  82. package/managers/worker-server.manager.js.map +1 -1
  83. package/methods/accounts.js +302 -1
  84. package/methods/accounts.js.map +1 -1
  85. package/methods/aws.js +748 -1
  86. package/methods/aws.js.map +1 -1
  87. package/methods/collections.js +542 -1
  88. package/methods/collections.js.map +1 -1
  89. package/methods/counters.js +111 -1
  90. package/methods/counters.js.map +1 -1
  91. package/methods/cron-jobs.js +1476 -1
  92. package/methods/cron-jobs.js.map +1 -1
  93. package/methods/flag-updates.js +8 -1
  94. package/methods/flag-updates.js.map +1 -1
  95. package/methods/flags.js +8 -1
  96. package/methods/flags.js.map +1 -1
  97. package/methods/logs.js +417 -1
  98. package/methods/logs.js.map +1 -1
  99. package/methods/monitor.js +543 -1
  100. package/methods/monitor.js.map +1 -1
  101. package/methods/pdf.js +742 -1
  102. package/methods/pdf.js.map +1 -1
  103. package/methods/report-builder.js +840 -1
  104. package/methods/report-builder.js.map +1 -1
  105. package/methods/support.js +232 -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/billing-logged-in-users.model.js +3 -1
  110. package/models/billing-logged-in-users.model.js.map +1 -1
  111. package/models/collection-document.model.js +3 -1
  112. package/models/collection-document.model.js.map +1 -1
  113. package/models/counter.model.js +3 -1
  114. package/models/counter.model.js.map +1 -1
  115. package/models/cron-job-history.model.js +3 -1
  116. package/models/cron-job-history.model.js.map +1 -1
  117. package/models/cron-job.model.js +3 -1
  118. package/models/cron-job.model.js.map +1 -1
  119. package/models/dialog.model.js +3 -1
  120. package/models/dialog.model.js.map +1 -1
  121. package/models/email-history.model.js +15 -1
  122. package/models/email-history.model.js.map +1 -1
  123. package/models/email-verified.model.js +3 -1
  124. package/models/email-verified.model.js.map +1 -1
  125. package/models/file.model.js +3 -1
  126. package/models/file.model.js.map +1 -1
  127. package/models/flag-update.model.js +3 -1
  128. package/models/flag-update.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-response.model.js +3 -1
  140. package/models/method-response.model.js.map +1 -1
  141. package/models/method.model.d.ts +0 -1
  142. package/models/method.model.js +3 -1
  143. package/models/method.model.js.map +1 -1
  144. package/models/monitor-cpu.model.js +3 -1
  145. package/models/monitor-cpu.model.js.map +1 -1
  146. package/models/monitor-function.model.js +3 -1
  147. package/models/monitor-function.model.js.map +1 -1
  148. package/models/monitor-memory.model.js +3 -1
  149. package/models/monitor-memory.model.js.map +1 -1
  150. package/models/monitor-mongo.model.js +3 -1
  151. package/models/monitor-mongo.model.js.map +1 -1
  152. package/models/notification.model.js +3 -1
  153. package/models/notification.model.js.map +1 -1
  154. package/models/pagination.model.js +23 -1
  155. package/models/pagination.model.js.map +1 -1
  156. package/models/permission.model.js +3 -1
  157. package/models/permission.model.js.map +1 -1
  158. package/models/report-builder-dashboard-builder.model.js +3 -1
  159. package/models/report-builder-dashboard-builder.model.js.map +1 -1
  160. package/models/report-builder-library.model.js +3 -1
  161. package/models/report-builder-library.model.js.map +1 -1
  162. package/models/report-builder-report.model.js +3 -1
  163. package/models/report-builder-report.model.js.map +1 -1
  164. package/models/report-builder.model.js +3 -1
  165. package/models/report-builder.model.js.map +1 -1
  166. package/models/select-data-label.model.js +3 -1
  167. package/models/select-data-label.model.js.map +1 -1
  168. package/models/server-message.model.js +3 -1
  169. package/models/server-message.model.js.map +1 -1
  170. package/models/subscription.model.js +3 -1
  171. package/models/subscription.model.js.map +1 -1
  172. package/models/support-ticket.model.js +3 -1
  173. package/models/support-ticket.model.js.map +1 -1
  174. package/models/user-group.model.js +3 -1
  175. package/models/user-group.model.js.map +1 -1
  176. package/models/user-guide.model.js +3 -1
  177. package/models/user-guide.model.js.map +1 -1
  178. package/models/user.model.js +3 -1
  179. package/models/user.model.js.map +1 -1
  180. package/package.json +1 -1
  181. package/public_api.js +77 -1
  182. package/public_api.js.map +1 -1
  183. package/publications/app-status.js +16 -1
  184. package/publications/app-status.js.map +1 -1
  185. package/publications/cron-jobs.js +32 -1
  186. package/publications/cron-jobs.js.map +1 -1
  187. package/publications/files.js +36 -1
  188. package/publications/files.js.map +1 -1
  189. package/publications/flags-update.js +22 -1
  190. package/publications/flags-update.js.map +1 -1
  191. package/publications/flags.js +22 -1
  192. package/publications/flags.js.map +1 -1
  193. package/publications/logs.js +164 -1
  194. package/publications/logs.js.map +1 -1
  195. package/publications/notifications.js +16 -1
  196. package/publications/notifications.js.map +1 -1
  197. package/publications/report-builder-dashboard-builders.js +42 -1
  198. package/publications/report-builder-dashboard-builders.js.map +1 -1
  199. package/publications/report-builder-libraries.js +90 -1
  200. package/publications/report-builder-libraries.js.map +1 -1
  201. package/publications/report-builder-reports.js +50 -1
  202. package/publications/report-builder-reports.js.map +1 -1
  203. package/publications/super-admin.js +16 -1
  204. package/publications/super-admin.js.map +1 -1
  205. package/publications/user-groups.js +16 -1
  206. package/publications/user-groups.js.map +1 -1
  207. package/publications/user-guides.js +16 -1
  208. package/publications/user-guides.js.map +1 -1
  209. package/resolveio-server-app.js +176 -1
  210. package/resolveio-server-app.js.map +1 -1
  211. package/server-app.js +1159 -1
  212. package/server-app.js.map +1 -1
  213. package/util/common.js +632 -1
  214. package/util/common.js.map +1 -1
  215. package/util/schema-report-builder.js +454 -1
  216. package/util/schema-report-builder.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/flag-updates.ts"],"names":["loadFlagUpdatesMethods","methodManager","methods","exports"],"mappings":"aAEA,SAAgBA,uBAAuBC,GACtCA,EAAcC,QAAQ,EAErB,CACF,C,6FAJAC,QAAAH,uBAAAA","file":"flag-updates.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\n\nexport function loadFlagUpdatesMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\t\n\t});\n}"]}
1
+ {"version":3,"sources":["../../src/methods/flag-updates.ts"],"names":[],"mappings":";;;AAEA,SAAgB,sBAAsB,CAAC,aAA4B;IAClE,aAAa,CAAC,OAAO,CAAC,EAErB,CAAC,CAAC;AACJ,CAAC;AAJD,wDAIC","file":"flag-updates.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\n\nexport function loadFlagUpdatesMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\t\n\t});\n}"]}
package/methods/flags.js CHANGED
@@ -1,2 +1,9 @@
1
- "use strict";function loadFlagMethods(e){e.methods({})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadFlagMethods=void 0,exports.loadFlagMethods=loadFlagMethods;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadFlagMethods = void 0;
4
+ function loadFlagMethods(methodManager) {
5
+ methodManager.methods({});
6
+ }
7
+ exports.loadFlagMethods = loadFlagMethods;
8
+
2
9
  //# sourceMappingURL=flags.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/flags.ts"],"names":["loadFlagMethods","methodManager","methods","exports"],"mappings":"aAEA,SAAgBA,gBAAgBC,GAC/BA,EAAcC,QAAQ,EAErB,CACF,C,sFAJAC,QAAAH,gBAAAA","file":"flags.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\n\nexport function loadFlagMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\t\n\t});\n}"]}
1
+ {"version":3,"sources":["../../src/methods/flags.ts"],"names":[],"mappings":";;;AAEA,SAAgB,eAAe,CAAC,aAA4B;IAC3D,aAAa,CAAC,OAAO,CAAC,EAErB,CAAC,CAAC;AACJ,CAAC;AAJD,0CAIC","file":"flags.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\n\nexport function loadFlagMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\t\n\t});\n}"]}
package/methods/logs.js CHANGED
@@ -1,2 +1,418 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(e,r,n,i){return new(n=n||Promise)(function(o,t){function fulfilled(e){try{step(i.next(e))}catch(e){t(e)}}function rejected(e){try{step(i.throw(e))}catch(e){t(e)}}function step(e){var t;e.done?o(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(fulfilled,rejected)}step((i=i.apply(e,r||[])).next())})},__generator=this&&this.__generator||function(r,n){var i,a,c,s={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]},l={next:verb(0),throw:verb(1),return:verb(2)};return"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function verb(o){return function(e){var t=[o,e];if(i)throw new TypeError("Generator is already executing.");for(;s=l&&t[l=0]?0:s;)try{if(i=1,a&&(c=2&t[0]?a.return:t[0]?a.throw||((c=a.return)&&c.call(a),0):a.next)&&!(c=c.call(a,t[1])).done)return c;switch(a=0,(t=c?[2&t[0],c.value]:t)[0]){case 0:case 1:c=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,a=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(c=0<(c=s.trys).length&&c[c.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!c||t[1]>c[0]&&t[1]<c[3]))s.label=t[1];else if(6===t[0]&&s.label<c[1])s.label=c[1],c=t;else{if(!(c&&s.label<c[2])){c[2]&&s.ops.pop(),s.trys.pop();continue}s.label=c[2],s.ops.push(t)}}t=n.call(r,s)}catch(e){t=[6,e],a=0}finally{i=c=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}},log_method_latency_collection_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadLogMethods=void 0,require("../collections/log-method-latency.collection")),log_subscription_collection_1=require("../collections/log-subscription.collection"),log_collection_1=require("../collections/log.collection"),resolveio_server_app_1=require("../resolveio-server-app"),common_1=require("../util/common");function loadLogMethods(e){e.methods({insertErrorLog:{function:function(t,o){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,this.sendEmail("dev@resolveio.com","Error Detected - "+resolveio_server_app_1.ResolveIOServer.getClientName(),this.user+"\n"+t+"\n"+JSON.stringify(o,null,2))];case 1:return(e.sent(),"https://resolveio.com"===resolveio_server_app_1.ResolveIOServer.getServerConfig().ROOT_URL||"http://localhost:4200"===resolveio_server_app_1.ResolveIOServer.getServerConfig().ROOT_URL)?[3,2]:(resolveio_server_app_1.ResolveIOServer.getLocalLogManager().writeLog({type:"log",data:{_id:(0,common_1.objectIdHexString)(),createdAt:new Date,type:"error",collection:"",id_document:"",payload:JSON.stringify([o],null,2),method:"",id_user:this.id_user||"",user:this.user||"",messageId:0,route:""}}),[3,4]);case 2:return[4,log_collection_1.Logs.insertOne({_id:(0,common_1.objectIdHexString)(),type:"error",collection:"",id_document:"",payload:JSON.stringify([o],null,2),method:"",id_user:this.id_user||"",user:this.user||"",messageId:0,route:"",client:"ResolveIO",instance:"backend.resolveio.com",instance_index:process.env.NODE_APP_INSTANCE||""})];case 3:e.sent(),e.label=4;case 4:return[2,!0]}})})},skipValidation:!0},insertSubscriptionLog:{function:function(t,o,r,n){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return"https://resolveio.com"===resolveio_server_app_1.ResolveIOServer.getServerConfig().ROOT_URL||"http://localhost:4200"===resolveio_server_app_1.ResolveIOServer.getServerConfig().ROOT_URL?[3,1]:(resolveio_server_app_1.ResolveIOServer.getLocalLogManager().writeLog({type:"log-subscription",data:{_id:(0,common_1.objectIdHexString)(),__v:0,date:new Date,type:t,subscription:o,collection_name:r,subData:n}}),[3,3]);case 1:return[4,log_subscription_collection_1.LogSubscriptions.create({_id:(0,common_1.objectIdHexString)(),__v:0,date:new Date,type:t,subscription:o,collection_name:r,subData:n,client:"ResolveIO",instance:"backend.resolveio.com"})];case 2:e.sent(),e.label=3;case 3:return[2,!0]}})})},skipValidation:!0},superadminAPM:{function:function(c,s,l){return __awaiter(this,void 0,void 0,function(){var t,o,r,n,i,a;return __generator(this,function(e){switch(e.label){case 0:return[4,log_method_latency_collection_1.LogMethodLatencies.aggregate([{$match:{$and:[{createdAt:{$gte:c}},{createdAt:{$lte:s}}]}},{$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:"http://localhost:4200"!==this.serverConfig.ROOT_URL?"secondary":"primary"},!0)];case 1:return t=e.sent(),[4,log_subscription_collection_1.LogSubscriptions.aggregate([{$match:{$and:[{createdAt:{$gte:c}},{createdAt:{$lte:s}}]}},{$group:{_id:"$subscription",subscription:{$first:"$subscription"},count:{$sum:1}}}],{allowDiskUse:!0,readPreference:"http://localhost:4200"!==this.serverConfig.ROOT_URL?"secondary":"primary"},!0)];case 2:return o=e.sent(),r={},n={},n="seconds"===l?(r={second:{$second:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},minute:{$minute:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},hour:{$hour:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},day:{$dayOfMonth:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}}},{"_id.year":1,"_id.month":1,"_id.day":1,"_id.hour":1,"_id.minute":1,"_id.second":1}):"minutes"===l?(r={minute:{$minute:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},hour:{$hour:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},day:{$dayOfMonth:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}}},{"_id.year":1,"_id.month":1,"_id.day":1,"_id.hour":1,"_id.minute":1}):"hours"===l?(r={hour:{$hour:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},day:{$dayOfMonth:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}}},{"_id.year":1,"_id.month":1,"_id.day":1,"_id.hour":1}):(r={day:{$dayOfMonth:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:process.env.TZ_CLIENT||"America/Chicago"}}},{"_id.year":1,"_id.month":1,"_id.day":1}),[4,log_method_latency_collection_1.LogMethodLatencies.aggregate([{$match:{$and:[{createdAt:{$gte:c}},{createdAt:{$lte:s}}]}},{$group:{_id:r,count:{$sum:1}}},{$sort:n}],{allowDiskUse:!0,readPreference:"http://localhost:4200"!==this.serverConfig.ROOT_URL?"secondary":"primary"},!0)];case 3:return i=e.sent(),[4,log_subscription_collection_1.LogSubscriptions.aggregate([{$match:{$and:[{createdAt:{$gte:c}},{createdAt:{$lte:s}}]}},{$group:{_id:r,count:{$sum:1}}},{$sort:n}],{allowDiskUse:!0,readPreference:"http://localhost:4200"!==this.serverConfig.ROOT_URL?"secondary":"primary"},!0)];case 4:return a=e.sent(),[2,{methods:t,subscriptions:o,methodGraphData:i,subGraphData:a}]}})})},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 (g && (g = 0, op[0] && (_ = 0)), _) 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_method_latency_collection_1 = require("../collections/log-method-latency.collection");
41
+ var log_subscription_collection_1 = require("../collections/log-subscription.collection");
42
+ var log_collection_1 = require("../collections/log.collection");
43
+ var resolveio_server_app_1 = require("../resolveio-server-app");
44
+ var common_1 = require("../util/common");
45
+ function loadLogMethods(methodManager) {
46
+ methodManager.methods({
47
+ insertErrorLog: {
48
+ function: function (message, data) {
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ return __generator(this, function (_a) {
51
+ switch (_a.label) {
52
+ case 0: return [4 /*yield*/, this.sendEmail('dev@resolveio.com', 'Error Detected - ' + resolveio_server_app_1.ResolveIOServer.getClientName(), this.user + '\n' + message + '\n' + JSON.stringify(data, null, 2))];
53
+ case 1:
54
+ _a.sent();
55
+ if (!(resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'
56
+ && resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200')) return [3 /*break*/, 2];
57
+ resolveio_server_app_1.ResolveIOServer.getLocalLogManager().writeLog({
58
+ type: 'log',
59
+ data: {
60
+ _id: (0, common_1.objectIdHexString)(),
61
+ createdAt: new Date(),
62
+ type: 'error',
63
+ collection: '',
64
+ id_document: '',
65
+ payload: JSON.stringify([data], null, 2),
66
+ method: '',
67
+ id_user: this.id_user || '',
68
+ user: this.user || '',
69
+ messageId: 0,
70
+ route: '',
71
+ }
72
+ });
73
+ return [3 /*break*/, 4];
74
+ case 2: return [4 /*yield*/, log_collection_1.Logs.insertOne({
75
+ _id: (0, common_1.objectIdHexString)(),
76
+ type: 'error',
77
+ collection: '',
78
+ id_document: '',
79
+ payload: JSON.stringify([data], null, 2),
80
+ method: '',
81
+ id_user: this.id_user || '',
82
+ user: this.user || '',
83
+ messageId: 0,
84
+ route: '',
85
+ client: 'ResolveIO',
86
+ instance: 'backend.resolveio.com',
87
+ instance_index: process.env.NODE_APP_INSTANCE || ''
88
+ })];
89
+ case 3:
90
+ _a.sent();
91
+ _a.label = 4;
92
+ case 4: return [2 /*return*/, true];
93
+ }
94
+ });
95
+ });
96
+ },
97
+ skipValidation: true
98
+ },
99
+ insertSubscriptionLog: {
100
+ function: function (type, subscription, collection_name, subData) {
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ return __generator(this, function (_a) {
103
+ switch (_a.label) {
104
+ case 0:
105
+ if (!(resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'
106
+ && resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200')) return [3 /*break*/, 1];
107
+ resolveio_server_app_1.ResolveIOServer.getLocalLogManager().writeLog({
108
+ type: 'log-subscription',
109
+ data: {
110
+ _id: (0, common_1.objectIdHexString)(),
111
+ __v: 0,
112
+ date: new Date(),
113
+ type: type,
114
+ subscription: subscription,
115
+ collection_name: collection_name,
116
+ subData: subData
117
+ }
118
+ });
119
+ return [3 /*break*/, 3];
120
+ case 1: return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.create({
121
+ _id: (0, common_1.objectIdHexString)(),
122
+ __v: 0,
123
+ date: new Date(),
124
+ type: type,
125
+ subscription: subscription,
126
+ collection_name: collection_name,
127
+ subData: subData,
128
+ client: 'ResolveIO',
129
+ instance: 'backend.resolveio.com'
130
+ })];
131
+ case 2:
132
+ _a.sent();
133
+ _a.label = 3;
134
+ case 3: return [2 /*return*/, true];
135
+ }
136
+ });
137
+ });
138
+ },
139
+ skipValidation: true
140
+ },
141
+ superadminAPM: {
142
+ function: function (date_start, date_end, graphInterval) {
143
+ return __awaiter(this, void 0, void 0, function () {
144
+ var latencies, subscriptions, groupId, groupSort, methodGraphData, subGraphData;
145
+ return __generator(this, function (_a) {
146
+ switch (_a.label) {
147
+ case 0: return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
148
+ {
149
+ $match: {
150
+ $and: [
151
+ {
152
+ createdAt: { $gte: date_start }
153
+ },
154
+ {
155
+ createdAt: { $lte: date_end }
156
+ }
157
+ ]
158
+ }
159
+ },
160
+ {
161
+ $group: {
162
+ _id: '$method',
163
+ method: { $first: '$method' },
164
+ count: { $sum: 1 },
165
+ latency_min: { $min: '$latency_ms' },
166
+ latency_avg: { $avg: '$latency_ms' },
167
+ latency_max: { $max: '$latency_ms' }
168
+ }
169
+ }
170
+ ], { allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary' }, true)];
171
+ case 1:
172
+ latencies = _a.sent();
173
+ return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
174
+ {
175
+ $match: {
176
+ $and: [
177
+ {
178
+ createdAt: { $gte: date_start }
179
+ },
180
+ {
181
+ createdAt: { $lte: date_end }
182
+ }
183
+ ]
184
+ }
185
+ },
186
+ {
187
+ $group: {
188
+ _id: '$subscription',
189
+ subscription: { $first: '$subscription' },
190
+ count: { $sum: 1 }
191
+ }
192
+ }
193
+ ], { allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary' }, true)];
194
+ case 2:
195
+ subscriptions = _a.sent();
196
+ groupId = {};
197
+ groupSort = {};
198
+ if (graphInterval === 'seconds') {
199
+ groupId = {
200
+ second: {
201
+ $second: {
202
+ date: '$createdAt',
203
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
204
+ }
205
+ },
206
+ minute: {
207
+ $minute: {
208
+ date: '$createdAt',
209
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
210
+ }
211
+ },
212
+ hour: {
213
+ $hour: {
214
+ date: '$createdAt',
215
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
216
+ }
217
+ },
218
+ day: {
219
+ $dayOfMonth: {
220
+ date: '$createdAt',
221
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
222
+ }
223
+ },
224
+ month: {
225
+ $month: {
226
+ date: '$createdAt',
227
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
228
+ }
229
+ },
230
+ year: {
231
+ $year: {
232
+ date: '$createdAt',
233
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
234
+ }
235
+ }
236
+ };
237
+ groupSort = {
238
+ '_id.year': 1,
239
+ '_id.month': 1,
240
+ '_id.day': 1,
241
+ '_id.hour': 1,
242
+ '_id.minute': 1,
243
+ '_id.second': 1
244
+ };
245
+ }
246
+ else if (graphInterval === 'minutes') {
247
+ groupId = {
248
+ minute: {
249
+ $minute: {
250
+ date: '$createdAt',
251
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
252
+ }
253
+ },
254
+ hour: {
255
+ $hour: {
256
+ date: '$createdAt',
257
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
258
+ }
259
+ },
260
+ day: {
261
+ $dayOfMonth: {
262
+ date: '$createdAt',
263
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
264
+ }
265
+ },
266
+ month: {
267
+ $month: {
268
+ date: '$createdAt',
269
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
270
+ }
271
+ },
272
+ year: {
273
+ $year: {
274
+ date: '$createdAt',
275
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
276
+ }
277
+ }
278
+ };
279
+ groupSort = {
280
+ '_id.year': 1,
281
+ '_id.month': 1,
282
+ '_id.day': 1,
283
+ '_id.hour': 1,
284
+ '_id.minute': 1
285
+ };
286
+ }
287
+ else if (graphInterval === 'hours') {
288
+ groupId = {
289
+ hour: {
290
+ $hour: {
291
+ date: '$createdAt',
292
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
293
+ }
294
+ },
295
+ day: {
296
+ $dayOfMonth: {
297
+ date: '$createdAt',
298
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
299
+ }
300
+ },
301
+ month: {
302
+ $month: {
303
+ date: '$createdAt',
304
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
305
+ }
306
+ },
307
+ year: {
308
+ $year: {
309
+ date: '$createdAt',
310
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
311
+ }
312
+ }
313
+ };
314
+ groupSort = {
315
+ '_id.year': 1,
316
+ '_id.month': 1,
317
+ '_id.day': 1,
318
+ '_id.hour': 1
319
+ };
320
+ }
321
+ else {
322
+ groupId = {
323
+ day: {
324
+ $dayOfMonth: {
325
+ date: '$createdAt',
326
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
327
+ }
328
+ },
329
+ month: {
330
+ $month: {
331
+ date: '$createdAt',
332
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
333
+ }
334
+ },
335
+ year: {
336
+ $year: {
337
+ date: '$createdAt',
338
+ timezone: process.env.TZ_CLIENT || 'America/Chicago'
339
+ }
340
+ }
341
+ };
342
+ groupSort = {
343
+ '_id.year': 1,
344
+ '_id.month': 1,
345
+ '_id.day': 1
346
+ };
347
+ }
348
+ return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
349
+ {
350
+ $match: {
351
+ $and: [
352
+ {
353
+ createdAt: { $gte: date_start }
354
+ },
355
+ {
356
+ createdAt: { $lte: date_end }
357
+ }
358
+ ]
359
+ }
360
+ },
361
+ {
362
+ $group: {
363
+ _id: groupId,
364
+ count: {
365
+ $sum: 1
366
+ }
367
+ }
368
+ },
369
+ {
370
+ $sort: groupSort
371
+ }
372
+ ], { allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary' }, true)];
373
+ case 3:
374
+ methodGraphData = _a.sent();
375
+ return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
376
+ {
377
+ $match: {
378
+ $and: [
379
+ {
380
+ createdAt: { $gte: date_start }
381
+ },
382
+ {
383
+ createdAt: { $lte: date_end }
384
+ }
385
+ ]
386
+ }
387
+ },
388
+ {
389
+ $group: {
390
+ _id: groupId,
391
+ count: {
392
+ $sum: 1
393
+ }
394
+ }
395
+ },
396
+ {
397
+ $sort: groupSort
398
+ }
399
+ ], { allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary' }, true)];
400
+ case 4:
401
+ subGraphData = _a.sent();
402
+ return [2 /*return*/, {
403
+ methods: latencies,
404
+ subscriptions: subscriptions,
405
+ methodGraphData: methodGraphData,
406
+ subGraphData: subGraphData
407
+ }];
408
+ }
409
+ });
410
+ });
411
+ },
412
+ skipValidation: true
413
+ }
414
+ });
415
+ }
416
+ exports.loadLogMethods = loadLogMethods;
417
+
2
418
  //# sourceMappingURL=logs.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/logs.ts"],"names":["log_method_latency_collection_1","require","log_subscription_collection_1","log_collection_1","resolveio_server_app_1","common_1","loadLogMethods","methodManager","methods","insertErrorLog","function","message","data","this","sendEmail","ResolveIOServer","getClientName","user","JSON","stringify","_a","sent","getServerConfig","getLocalLogManager","writeLog","type","_id","objectIdHexString","createdAt","Date","collection","id_document","payload","method","id_user","messageId","route","Logs","insertOne","client","instance","instance_index","process","env","NODE_APP_INSTANCE","skipValidation","insertSubscriptionLog","subscription","collection_name","subData","__v","date","LogSubscriptions","create","superadminAPM","date_start","date_end","graphInterval","LogMethodLatencies","aggregate","$match","$and","$gte","$lte","$group","$first","count","$sum","latency_min","$min","latency_avg","$avg","latency_max","$max","allowDiskUse","readPreference","serverConfig","latencies","subscriptions","groupId","groupSort","second","$second","timezone","TZ_CLIENT","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":"k8CAAAA,iC,qFAAAC,QAAA,8CAAA,GACAC,8BAAAD,QAAA,4CAAA,EACAE,iBAAAF,QAAA,+BAAA,EAEAG,uBAAAH,QAAA,yBAAA,EACAI,SAAAJ,QAAA,gBAAA,EAEA,SAAgBK,eAAeC,GAC9BA,EAAcC,QAAQ,CACrBC,eAAgB,CACfC,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YAAc,SAAS,EAAG,CAAA,CAAI,G,OAE/G,OA1Bf0B,EAAkBlF,EAAAC,KAAA,EA0BH,CAAA,EAAMnB,8BAAAkD,iBAAiBO,UAAU,CACnD,CACCC,OAAQ,CACPC,KAAM,CACL,CACCjC,UAAW,CAACkC,KAAMP,CAAU,C,EAE7B,CACC3B,UAAW,CAACmC,KAAMP,CAAQ,C,KAK9B,CACCQ,OAAQ,CACPtC,IAAKqD,EACLb,MAAO,CACNC,KAAM,C,IAIT,CACCkC,MAAOrB,C,GAEN,CAACN,aAAc,CAAA,EAAMC,eAAkD,0BAAlC9D,KAAK+D,aAAuB,SAAgC,YAAc,SAAS,EAAG,CAAA,CAAI,G,OAElI,OA1BI2B,EAAenF,EAAAC,KAAA,EA0BnB,CAAA,EAAO,CACNb,QAASqE,EACTC,cAAeA,EACfwB,gBAAiBA,EACjBC,aAAcA,C,SAGhB1D,eAAgB,CAAA,C,EAEjB,CACF,CAnWA2D,QAAAlG,eAAAA","file":"logs.js","sourcesContent":["import { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { Logs } from '../collections/log.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tinsertErrorLog: {\n\t\t\tfunction: async function(message, data) {\n\t\t\t\tawait this.sendEmail('dev@resolveio.com', 'Error Detected - ' + ResolveIOServer.getClientName(), this.user + '\\n' + message + '\\n' + JSON.stringify(data, null, 2));\n\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: JSON.stringify([data], null, 2),\n\t\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\troute: '',\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\tpayload: JSON.stringify([data], null, 2),\n\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\troute: '',\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || ''\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: async function(type, subscription, collection_name, subData) {\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log-subscription',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\t\tsubData: subData\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait LogSubscriptions.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\tsubData: subData,\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com'\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: async function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet groupId = {};\n\t\t\t\tlet groupSort = {};\n\n\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\treturn {\n\t\t\t\t\tmethods: latencies,\n\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\tsubGraphData: subGraphData\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAAkF;AAClF,0FAA8E;AAC9E,gEAAqD;AAErD,gEAA0D;AAC1D,yCAAmD;AAEnD,SAAgB,cAAc,CAAC,aAA4B;IAC1D,aAAa,CAAC,OAAO,CAAC;QACrB,cAAc,EAAE;YACf,QAAQ,EAAE,UAAe,OAAO,EAAE,IAAI;;;;oCACrC,qBAAM,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,sCAAe,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,EAAA;;gCAAnK,SAAmK,CAAC;qCAGnK,CAAA,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,KAAK,uBAAuB;uCACvE,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,KAAK,uBAAuB,CAAA,EAD3E,wBAC2E;gCAE3E,sCAAe,CAAC,kBAAkB,EAAE,CAAC,QAAQ,CAAC;oCAC7C,IAAI,EAAE,KAAK;oCACX,IAAI,EAAE;wCACL,GAAG,EAAE,IAAA,0BAAiB,GAAE;wCACxB,SAAS,EAAE,IAAI,IAAI,EAAE;wCACrB,IAAI,EAAE,OAAO;wCACb,UAAU,EAAE,EAAE;wCACd,WAAW,EA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ACC,MAAM,EAAE;gDACP,IAAI,EAAE;oDACL;wDACC,SAAS,EAAE,EAAC,IAAI,EAAE,UAAU,EAAC;qDAC7B;oDACD;wDACC,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;qDAC3B;iDACD;6CACD;yCACD;wCACD;4CACC,MAAM,EAAE;gDACP,GAAG,EAAE,OAAO;gDACZ,KAAK,EAAE;oDACN,IAAI,EAAE,CAAC;iDACP;6CACD;yCACD;wCACD;4CACC,KAAK,EAAE,SAAS;yCAChB;qCACD,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,uBAAuB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAC,EAAE,IAAI,CAAC,EAAA;;gCAxB/H,YAAY,GAAG,SAwBgH;gCAEnI,sBAAO;wCACN,OAAO,EAAE,SAAS;wCAClB,aAAa,EAAE,aAAa;wCAC5B,eAAe,EAAE,eAAe;wCAChC,YAAY,EAAE,YAAY;qCAC1B,EAAC;;;;aACF;YACD,cAAc,EAAE,IAAI;SACpB;KACD,CAAC,CAAC;AACJ,CAAC;AAnWD,wCAmWC","file":"logs.js","sourcesContent":["import { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { Logs } from '../collections/log.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tinsertErrorLog: {\n\t\t\tfunction: async function(message, data) {\n\t\t\t\tawait this.sendEmail('dev@resolveio.com', 'Error Detected - ' + ResolveIOServer.getClientName(), this.user + '\\n' + message + '\\n' + JSON.stringify(data, null, 2));\n\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: JSON.stringify([data], null, 2),\n\t\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\troute: '',\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\tpayload: JSON.stringify([data], null, 2),\n\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\troute: '',\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || ''\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: async function(type, subscription, collection_name, subData) {\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log-subscription',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\t\tsubData: subData\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait LogSubscriptions.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\tsubData: subData,\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com'\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: async function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet groupId = {};\n\t\t\t\tlet groupSort = {};\n\n\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\treturn {\n\t\t\t\t\tmethods: latencies,\n\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t};\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}"]}