@resolveio/server-lib 20.7.27 → 20.7.29
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.
- package/collections/app-status.collection.js +1 -1
- package/collections/app-status.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +1 -1
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +1 -1
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/file.collection.js +1 -1
- package/collections/file.collection.js.map +1 -1
- package/collections/flag-update.collection.js +1 -1
- package/collections/flag-update.collection.js.map +1 -1
- package/managers/subscription.manager.js +1 -1
- package/managers/subscription.manager.js.map +1 -1
- package/methods/collections.js +1 -1
- package/methods/collections.js.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +0 -1
- package/public_api.js +1 -1
- package/public_api.js.map +1 -1
- package/publications.ts +0 -3
- package/collections/method-response.collection.d.ts +0 -3
- package/collections/method-response.collection.js +0 -2
- package/collections/method-response.collection.js.map +0 -1
- package/publications/method-responses.d.ts +0 -2
- package/publications/method-responses.js +0 -2
- package/publications/method-responses.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppStatus=void 0;var mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},message:{type:String}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"app-statuses",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.AppStatus=e.collection_main):setImmediate(function(){initializeCollection()})}exports.AppStatus=null,initializeCollection();
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppStatus=void 0;var mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},message:{type:String}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"app-statuses",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null,bypassSession:!0}),exports.AppStatus=e.collection_main):setImmediate(function(){initializeCollection()})}exports.AppStatus=null,initializeCollection();
|
|
2
2
|
//# sourceMappingURL=app-status.collection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/app-status.collection.ts"],"names":["mongo_manager_1","require","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","message","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","AppStatus","collection_main","setImmediate"],"mappings":"6FACA,IAAAA,gBAAAC,QAAA,2BAAA,EAEAC,uBAAAD,QAAA,yBAAA,EAEIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,QAAS,CACRR,KAAMC,M,GAQR,SAASQ,uBACR,IACOC,EADHb,uBAAAc,iBAAmBd,uBAAAc,gBAAgBC,UAAS,GAAMjB,gBAAAkB,mBAC/CH,EAAQf,gBAAAkB,kBAAkBC,OAAuB,CACtDC,eAAgB,eAChBjB,OAAQA,OACRkB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,
|
|
1
|
+
{"version":3,"sources":["../../src/collections/app-status.collection.ts"],"names":["mongo_manager_1","require","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","message","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","bypassSession","exports","AppStatus","collection_main","setImmediate"],"mappings":"6FACA,IAAAA,gBAAAC,QAAA,2BAAA,EAEAC,uBAAAD,QAAA,yBAAA,EAEIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,QAAS,CACRR,KAAMC,M,GAQR,SAASQ,uBACR,IACOC,EADHb,uBAAAc,iBAAmBd,uBAAAc,gBAAgBC,UAAS,GAAMjB,gBAAAkB,mBAC/CH,EAAQf,gBAAAkB,kBAAkBC,OAAuB,CACtDC,eAAgB,eAChBjB,OAAQA,OACRkB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,KACnBC,cAAe,CAAA,C,CACf,EACDC,QAAAC,UAAYf,EAAMgB,iBAGlBC,aAAa,WACZlB,qBAAoB,CACrB,CAAC,CAEH,CAzBWe,QAAAC,UAAoD,KAE/DhB,qBAAoB","file":"app-status.collection.js","sourcesContent":[" \nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { AppStatusModel } from '../models/app-status.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tmessage: {\n\t\ttype: String\n\t}\n};\n\nexport let AppStatus: MongoManagerCollection<AppStatusModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB() && MongoManagerModel) {\n\t\tconst model = MongoManagerModel.create<AppStatusModel>({\n\t\t\tcollectionName: 'app-statuses',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null,\n\t\t\tbypassSession: true\n\t\t});\n\t\tAppStatus = model.collection_main;\n\t}\n\telse {\n\t\tsetImmediate(() => {\n\t\t\tinitializeCollection();\n\t\t});\n\t}\n}"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(e,o,n,i){return new(n=n||Promise)(function(r,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?r(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(fulfilled,rejected)}step((i=i.apply(e,o||[])).next())})},__generator=this&&this.__generator||function(o,n){var i,a,l
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,o,n,i){return new(n=n||Promise)(function(r,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?r(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(fulfilled,rejected)}step((i=i.apply(e,o||[])).next())})},__generator=this&&this.__generator||function(o,n){var i,a,s,l={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},c={next:verb(0),throw:verb(1),return:verb(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function verb(r){return function(e){var t=[r,e];if(i)throw new TypeError("Generator is already executing.");for(;l=c&&t[c=0]?0:l;)try{if(i=1,a&&(s=2&t[0]?a.return:t[0]?a.throw||((s=a.return)&&s.call(a),0):a.next)&&!(s=s.call(a,t[1])).done)return s;switch(a=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return l.label++,{value:t[1],done:!1};case 5:l.label++,a=t[1],t=[0];continue;case 7:t=l.ops.pop(),l.trys.pop();continue;default:if(!(s=0<(s=l.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){l=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3]))l.label=t[1];else if(6===t[0]&&l.label<s[1])l.label=s[1],s=t;else{if(!(s&&l.label<s[2])){s[2]&&l.ops.pop(),l.trys.pop();continue}l.label=s[2],l.ops.push(t)}}t=n.call(o,l)}catch(e){t=[6,e],a=0}finally{i=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}},simpl_schema_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.CronJobHistories=void 0,require("simpl-schema")),mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},name:{type:String},reoccuring:{type:Boolean},time_to_run:{type:simpl_schema_1.default.oneOf(String,Date)},method_name:{type:String},server_restart:{type:Boolean},id_cronjob:{type:String},passed:{type:Boolean},error:{type:String},date_scheduled:{type:Date,optional:!0},date_start:{type:Date},date_end:{type:Date,optional:!0},date_next:{type:Date,optional:!0}};function initializeCollection(){var e,t=this;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"cron-job-histories",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null,skipCache:!0,bypassSession:!0}),exports.CronJobHistories=e.collection_main,setImmediate(function(){return __awaiter(t,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,exports.CronJobHistories.createIndex({createdAt:1},{expireAfterSeconds:604800})];case 1:return e.sent(),[2]}})})})):setImmediate(function(){initializeCollection()})}exports.CronJobHistories=null,initializeCollection();
|
|
2
2
|
//# sourceMappingURL=cron-job-history.collection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/cron-job-history.collection.ts"],"names":["simpl_schema_1","require","mongo_manager_1","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","name","reoccuring","Boolean","time_to_run","default","oneOf","method_name","server_restart","id_cronjob","passed","error","date_scheduled","date_start","date_end","date_next","initializeCollection","model","_this","this","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","skipCache","exports","CronJobHistories","collection_main","setImmediate","__awaiter","createIndex","expireAfterSeconds","_a","sent"],"mappings":"k8CAAAA,gB,uFAAAC,QAAA,cAAA,GACAC,gBAAAD,QAAA,2BAAA,EAEAE,uBAAAF,QAAA,yBAAA,EAEIG,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,KAAM,CACLR,KAAMC,M,EAEPQ,WAAY,CACXT,KAAMU,O,EAEPC,YAAa,CACZX,KAAMN,eAAAkB,QAAaC,MAAMZ,OAAQK,IAAI,C,EAEtCQ,YAAa,CACZd,KAAMC,M,EAEPc,eAAgB,CACff,KAAMU,O,EAEPM,WAAY,CACXhB,KAAMC,M,EAEPgB,OAAQ,CACPjB,KAAMU,O,EAEPQ,MAAO,CACNlB,KAAMC,M,EAEPkB,eAAgB,CACfnB,KAAMM,KACNJ,SAAU,CAAA,C,EAEXkB,WAAY,CACXpB,KAAMM,I,EAEPe,SAAU,CACTrB,KAAMM,KACNJ,SAAU,CAAA,C,EAEXoB,UAAW,CACVtB,KAAMM,KACNJ,SAAU,CAAA,C,GAQZ,SAASqB,uBAAT,IAEQC,EAFRC,EAAAC,KACK7B,uBAAA8B,iBAAmB9B,uBAAA8B,gBAAgBC,UAAS,GAAMhC,gBAAAiC,mBAC/CL,EAAQ5B,gBAAAiC,kBAAkBC,OAA4B,CAC3DC,eAAgB,qBAChBjC,OAAQA,OACRkC,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,KACnBC,UAAW,CAAA,C,
|
|
1
|
+
{"version":3,"sources":["../../src/collections/cron-job-history.collection.ts"],"names":["simpl_schema_1","require","mongo_manager_1","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","name","reoccuring","Boolean","time_to_run","default","oneOf","method_name","server_restart","id_cronjob","passed","error","date_scheduled","date_start","date_end","date_next","initializeCollection","model","_this","this","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","skipCache","bypassSession","exports","CronJobHistories","collection_main","setImmediate","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EAAA,KAAA,EAAA,KAAA,EAAA,W,2DACZ,MAAA,CAAA,EAAMgB,QAAAC,iBAAiBI,YAAY,CAACvC,UAAW,CAAC,EAAG,CAACwC,mBAAoB,MAAgB,CAAC,G,cAAzFC,EAAAC,KAAA,E,SACA,GAGDL,aAAa,WACZrB,qBAAoB,CACrB,CAAC,CAEH,CA9BWkB,QAAAC,iBAAgE,KAE3EnB,qBAAoB","file":"cron-job-history.collection.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { CronJobHistoryModel } from '../models/cron-job-history.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tname: {\n\t\ttype: String\n\t},\n\treoccuring: {\n\t\ttype: Boolean\n\t},\n\ttime_to_run: {\n\t\ttype: SimpleSchema.oneOf(String, Date)\n\t},\n\tmethod_name: {\n\t\ttype: String\n\t},\n\tserver_restart: {\n\t\ttype: Boolean\n\t},\n\tid_cronjob: {\n\t\ttype: String\n\t},\n\tpassed: {\n\t\ttype: Boolean\n\t},\n\terror: {\n\t\ttype: String\n\t},\n\tdate_scheduled: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tdate_start: {\n\t\ttype: Date\n\t},\n\tdate_end: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tdate_next: {\n\t\ttype: Date,\n\t\toptional: true\n\t}\n};\n\nexport let CronJobHistories: MongoManagerCollection<CronJobHistoryModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB() && MongoManagerModel) {\n\t\tconst model = MongoManagerModel.create<CronJobHistoryModel>({\n\t\t\tcollectionName: 'cron-job-histories',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null,\n\t\t\tskipCache: true,\n\t\t\tbypassSession: true\n\t\t});\n\t\tCronJobHistories = model.collection_main;\n\n\t\tsetImmediate(async () => {\n\t\t\tawait CronJobHistories.createIndex({createdAt: 1}, {expireAfterSeconds: 60 * 60 * 24 * 7});\n\t\t});\n\t}\n\telse {\n\t\tsetImmediate(() => {\n\t\t\tinitializeCollection();\n\t\t});\n\t}\n}"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CronJobs=void 0;var simpl_schema_1=require("simpl-schema"),mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},name:{type:String},repeat:{type:Boolean},time_to_run:{type:simpl_schema_1.default.oneOf(String,Date)},method_run:{type:String},method_run_data:{type:Object,blackbox:!0,optional:!0},method_complete:{type:String,optional:!0},method_complete_data:{type:Object,blackbox:!0,optional:!0},running:{type:Boolean},timezone:{type:String},next_run:{type:Date,optional:!0}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"cron-jobs",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null,skipCache:!0}),exports.CronJobs=e.collection_main,exports.CronJobs.createIndex({running:1})):setImmediate(function(){initializeCollection()})}exports.CronJobs=null,initializeCollection();
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CronJobs=void 0;var simpl_schema_1=require("simpl-schema"),mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},name:{type:String},repeat:{type:Boolean},time_to_run:{type:simpl_schema_1.default.oneOf(String,Date)},method_run:{type:String},method_run_data:{type:Object,blackbox:!0,optional:!0},method_complete:{type:String,optional:!0},method_complete_data:{type:Object,blackbox:!0,optional:!0},running:{type:Boolean},timezone:{type:String},next_run:{type:Date,optional:!0}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"cron-jobs",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null,skipCache:!0,bypassSession:!0}),exports.CronJobs=e.collection_main,exports.CronJobs.createIndex({running:1})):setImmediate(function(){initializeCollection()})}exports.CronJobs=null,initializeCollection();
|
|
2
2
|
//# sourceMappingURL=cron-job.collection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/cron-job.collection.ts"],"names":["simpl_schema_1","require","mongo_manager_1","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","name","repeat","Boolean","time_to_run","default","oneOf","method_run","method_run_data","Object","blackbox","method_complete","method_complete_data","running","timezone","next_run","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","skipCache","exports","CronJobs","collection_main","createIndex","setImmediate"],"mappings":"4FAAA,IAAAA,eAAAC,QAAA,cAAA,EACAC,gBAAAD,QAAA,2BAAA,EAEAE,uBAAAF,QAAA,yBAAA,EAEIG,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,KAAM,CACLR,KAAMC,M,EAEPQ,OAAQ,CACPT,KAAMU,O,EAEPC,YAAa,CACZX,KAAMN,eAAAkB,QAAaC,MAAMZ,OAAQK,IAAI,C,EAEtCQ,WAAY,CACXd,KAAMC,M,EAEPc,gBAAiB,CAChBf,KAAMgB,OACNC,SAAU,CAAA,EACVf,SAAU,CAAA,C,EAEXgB,gBAAiB,CAChBlB,KAAMC,OACNC,SAAU,CAAA,C,EAEXiB,qBAAsB,CACrBnB,KAAMgB,OACNC,SAAU,CAAA,EACVf,SAAU,CAAA,C,EAEXkB,QAAS,CACRpB,KAAMU,O,EAEPW,SAAU,CACTrB,KAAMC,M,EAEPqB,SAAU,CACTtB,KAAMM,KACNJ,SAAU,CAAA,C,GAQZ,SAASqB,uBACR,IACOC,EADH3B,uBAAA4B,iBAAmB5B,uBAAA4B,gBAAgBC,UAAS,GAAM9B,gBAAA+B,mBAC/CH,EAAQ5B,gBAAA+B,kBAAkBC,OAAqB,CACpDC,eAAgB,YAChB/B,OAAQA,OACRgC,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,KACnBC,UAAW,CAAA,C,
|
|
1
|
+
{"version":3,"sources":["../../src/collections/cron-job.collection.ts"],"names":["simpl_schema_1","require","mongo_manager_1","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","name","repeat","Boolean","time_to_run","default","oneOf","method_run","method_run_data","Object","blackbox","method_complete","method_complete_data","running","timezone","next_run","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","skipCache","bypassSession","exports","CronJobs","collection_main","createIndex","setImmediate"],"mappings":"4FAAA,IAAAA,eAAAC,QAAA,cAAA,EACAC,gBAAAD,QAAA,2BAAA,EAEAE,uBAAAF,QAAA,yBAAA,EAEIG,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,KAAM,CACLR,KAAMC,M,EAEPQ,OAAQ,CACPT,KAAMU,O,EAEPC,YAAa,CACZX,KAAMN,eAAAkB,QAAaC,MAAMZ,OAAQK,IAAI,C,EAEtCQ,WAAY,CACXd,KAAMC,M,EAEPc,gBAAiB,CAChBf,KAAMgB,OACNC,SAAU,CAAA,EACVf,SAAU,CAAA,C,EAEXgB,gBAAiB,CAChBlB,KAAMC,OACNC,SAAU,CAAA,C,EAEXiB,qBAAsB,CACrBnB,KAAMgB,OACNC,SAAU,CAAA,EACVf,SAAU,CAAA,C,EAEXkB,QAAS,CACRpB,KAAMU,O,EAEPW,SAAU,CACTrB,KAAMC,M,EAEPqB,SAAU,CACTtB,KAAMM,KACNJ,SAAU,CAAA,C,GAQZ,SAASqB,uBACR,IACOC,EADH3B,uBAAA4B,iBAAmB5B,uBAAA4B,gBAAgBC,UAAS,GAAM9B,gBAAA+B,mBAC/CH,EAAQ5B,gBAAA+B,kBAAkBC,OAAqB,CACpDC,eAAgB,YAChB/B,OAAQA,OACRgC,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,KACnBC,UAAW,CAAA,EACXC,cAAe,CAAA,C,CACf,EACDC,QAAAC,SAAWhB,EAAMiB,gBACjBF,QAAAC,SAASE,YAAY,CAACtB,QAAS,CAAC,CAAC,GAGjCuB,aAAa,WACZpB,qBAAoB,CACrB,CAAC,CAEH,CA3BWgB,QAAAC,SAAiD,KAE5DjB,qBAAoB","file":"cron-job.collection.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { CronJobModel } from '../models/cron-job.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tname: {\n\t\ttype: String\n\t},\n\trepeat: {\n\t\ttype: Boolean\n\t},\n\ttime_to_run: {\n\t\ttype: SimpleSchema.oneOf(String, Date)\n\t},\n\tmethod_run: {\n\t\ttype: String\n\t},\n\tmethod_run_data: {\n\t\ttype: Object,\n\t\tblackbox: true,\n\t\toptional: true\n\t},\n\tmethod_complete: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tmethod_complete_data: {\n\t\ttype: Object,\n\t\tblackbox: true,\n\t\toptional: true\n\t},\n\trunning: {\n\t\ttype: Boolean\n\t},\n\ttimezone: {\n\t\ttype: String\n\t},\n\tnext_run: {\n\t\ttype: Date,\n\t\toptional: true\n\t}\n};\n\nexport let CronJobs: MongoManagerCollection<CronJobModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB() && MongoManagerModel) {\n\t\tconst model = MongoManagerModel.create<CronJobModel>({\n\t\t\tcollectionName: 'cron-jobs',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null,\n\t\t\tskipCache: true,\n\t\t\tbypassSession: true\n\t\t});\n\t\tCronJobs = model.collection_main;\n\t\tCronJobs.createIndex({running: 1});\n\t}\n\telse {\n\t\tsetImmediate(() => {\n\t\t\tinitializeCollection();\n\t\t});\n\t}\n}"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Files=void 0;var mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},name:{type:String},size:{type:Number},key:{type:String},type:{type:String},order:{type:Number},status:{type:String,optional:!0},default:{type:Boolean,optional:!0}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"files",schema:schema,useVersionCollection:!1,useReportBuilder:!0,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.Files=e.collection_main,exports.Files.createIndex({type:1,createdAt:1}),exports.Files.createIndex({key:1})):setImmediate(function(){initializeCollection()})}exports.Files=null,initializeCollection();
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Files=void 0;var mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},name:{type:String},size:{type:Number},key:{type:String},type:{type:String},order:{type:Number},status:{type:String,optional:!0},default:{type:Boolean,optional:!0}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"files",schema:schema,useVersionCollection:!1,useReportBuilder:!0,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null,bypassSession:!0}),exports.Files=e.collection_main,exports.Files.createIndex({type:1,createdAt:1}),exports.Files.createIndex({key:1})):setImmediate(function(){initializeCollection()})}exports.Files=null,initializeCollection();
|
|
2
2
|
//# sourceMappingURL=file.collection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/file.collection.ts"],"names":["mongo_manager_1","require","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","name","size","key","order","status","default","Boolean","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","Files","collection_main","createIndex","setImmediate"],"mappings":"yFAAA,IAAAA,gBAAAC,QAAA,2BAAA,EAEAC,uBAAAD,QAAA,yBAAA,EAEIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,KAAM,CACLR,KAAMC,M,EAEPQ,KAAM,CACLT,KAAMI,M,EAEPM,IAAK,CACJV,KAAMC,M,EAEPD,KAAM,CACLA,KAAMC,M,EAEPU,MAAO,CACNX,KAAMI,M,EAEPQ,OAAQ,CACPZ,KAAMC,OACNC,SAAU,CAAA,C,EAEXW,QAAS,CACRb,KAAMc,QACNZ,SAAU,CAAA,C,GAQZ,SAASa,uBACR,IACOC,EADHnB,uBAAAoB,iBAAmBpB,uBAAAoB,gBAAgBC,UAAS,GAAMvB,gBAAAwB,mBAC/CH,EAAQrB,gBAAAwB,kBAAkBC,OAAkB,CACjDC,eAAgB,QAChBvB,OAAQA,OACRwB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,
|
|
1
|
+
{"version":3,"sources":["../../src/collections/file.collection.ts"],"names":["mongo_manager_1","require","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","name","size","key","order","status","default","Boolean","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","bypassSession","exports","Files","collection_main","createIndex","setImmediate"],"mappings":"yFAAA,IAAAA,gBAAAC,QAAA,2BAAA,EAEAC,uBAAAD,QAAA,yBAAA,EAEIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,KAAM,CACLR,KAAMC,M,EAEPQ,KAAM,CACLT,KAAMI,M,EAEPM,IAAK,CACJV,KAAMC,M,EAEPD,KAAM,CACLA,KAAMC,M,EAEPU,MAAO,CACNX,KAAMI,M,EAEPQ,OAAQ,CACPZ,KAAMC,OACNC,SAAU,CAAA,C,EAEXW,QAAS,CACRb,KAAMc,QACNZ,SAAU,CAAA,C,GAQZ,SAASa,uBACR,IACOC,EADHnB,uBAAAoB,iBAAmBpB,uBAAAoB,gBAAgBC,UAAS,GAAMvB,gBAAAwB,mBAC/CH,EAAQrB,gBAAAwB,kBAAkBC,OAAkB,CACjDC,eAAgB,QAChBvB,OAAQA,OACRwB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,KACnBC,cAAe,CAAA,C,CACf,EACDC,QAAAC,MAAQf,EAAMgB,gBACdF,QAAAC,MAAME,YAAY,CAACjC,KAAM,EAAGO,UAAW,CAAC,CAAC,EACzCuB,QAAAC,MAAME,YAAY,CAACvB,IAAK,CAAC,CAAC,GAG1BwB,aAAa,WACZnB,qBAAoB,CACrB,CAAC,CAEH,CA3BWe,QAAAC,MAA2C,KAEtDhB,qBAAoB","file":"file.collection.js","sourcesContent":["import { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { FileModel } from '../models/file.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tname: {\n\t\ttype: String\n\t},\n\tsize: {\n\t\ttype: Number\n\t},\n\tkey: {\n\t\ttype: String\n\t},\n\ttype: {\n\t\ttype: String\n\t},\n\torder: {\n\t\ttype: Number\n\t},\n\tstatus: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tdefault: {\n\t\ttype: Boolean,\n\t\toptional: true\n\t}\n};\n\nexport let Files: MongoManagerCollection<FileModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB() && MongoManagerModel) {\n\t\tconst model = MongoManagerModel.create<FileModel>({\n\t\t\tcollectionName: 'files',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: true,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null,\n\t\t\tbypassSession: true\n\t\t});\n\t\tFiles = model.collection_main;\n\t\tFiles.createIndex({type: 1, createdAt: 1});\n\t\tFiles.createIndex({key: 1});\n\t}\n\telse {\n\t\tsetImmediate(() => {\n\t\t\tinitializeCollection();\n\t\t});\n\t}\n}"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FlagUpdates=void 0;var mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},type:{type:String},value:{type:Boolean,optional:!0}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"flag-updates",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.FlagUpdates=e.collection_main,exports.FlagUpdates.createIndex({type:1},{unique:!0})):setImmediate(function(){initializeCollection()})}exports.FlagUpdates=null,initializeCollection();
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FlagUpdates=void 0;var mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},type:{type:String},value:{type:Boolean,optional:!0}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"flag-updates",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null,bypassSession:!0}),exports.FlagUpdates=e.collection_main,exports.FlagUpdates.createIndex({type:1},{unique:!0})):setImmediate(function(){initializeCollection()})}exports.FlagUpdates=null,initializeCollection();
|
|
2
2
|
//# sourceMappingURL=flag-update.collection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/flag-update.collection.ts"],"names":["mongo_manager_1","require","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","value","Boolean","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","FlagUpdates","collection_main","createIndex","unique","setImmediate"],"mappings":"+FAAA,IAAAA,gBAAAC,QAAA,2BAAA,EAEAC,uBAAAD,QAAA,yBAAA,EAEIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXF,KAAM,CACLA,KAAMC,M,EAEPO,MAAO,CACNR,KAAMS,QACNP,SAAU,CAAA,C,GAQZ,SAASQ,uBACR,IACOC,EADHd,uBAAAe,iBAAmBf,uBAAAe,gBAAgBC,UAAS,GAAMlB,gBAAAmB,mBAC/CH,EAAQhB,gBAAAmB,kBAAkBC,OAAwB,CACvDC,eAAgB,eAChBlB,OAAQA,OACRmB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,
|
|
1
|
+
{"version":3,"sources":["../../src/collections/flag-update.collection.ts"],"names":["mongo_manager_1","require","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","value","Boolean","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","bypassSession","exports","FlagUpdates","collection_main","createIndex","unique","setImmediate"],"mappings":"+FAAA,IAAAA,gBAAAC,QAAA,2BAAA,EAEAC,uBAAAD,QAAA,yBAAA,EAEIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXF,KAAM,CACLA,KAAMC,M,EAEPO,MAAO,CACNR,KAAMS,QACNP,SAAU,CAAA,C,GAQZ,SAASQ,uBACR,IACOC,EADHd,uBAAAe,iBAAmBf,uBAAAe,gBAAgBC,UAAS,GAAMlB,gBAAAmB,mBAC/CH,EAAQhB,gBAAAmB,kBAAkBC,OAAwB,CACvDC,eAAgB,eAChBlB,OAAQA,OACRmB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,KACnBC,cAAe,CAAA,C,CACf,EACDC,QAAAC,YAAcf,EAAMgB,gBACpBF,QAAAC,YAAYE,YAAY,CAAC5B,KAAM,CAAC,EAAG,CAAC6B,OAAQ,CAAA,CAAI,CAAC,GAGjDC,aAAa,WACZpB,qBAAoB,CACrB,CAAC,CAEH,CA1BWe,QAAAC,YAAuD,KAElEhB,qBAAoB","file":"flag-update.collection.js","sourcesContent":["import { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { FlagUpdateModel } from '../models/flag-update.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\ttype: {\n\t\ttype: String\n\t},\n\tvalue: {\n\t\ttype: Boolean,\n\t\toptional: true\n\t}\n};\n\nexport let FlagUpdates: MongoManagerCollection<FlagUpdateModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB() && MongoManagerModel) {\n\t\tconst model = MongoManagerModel.create<FlagUpdateModel>({\n\t\t\tcollectionName: 'flag-updates',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null,\n\t\t\tbypassSession: true\n\t\t});\n\t\tFlagUpdates = model.collection_main;\n\t\tFlagUpdates.createIndex({type: 1}, {unique: true});\n\t}\n\telse {\n\t\tsetImmediate(() => {\n\t\t\tinitializeCollection();\n\t\t});\n\t}\n}"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(e,i,s,r){return new(s=s||Promise)(function(n,t){function fulfilled(e){try{step(r.next(e))}catch(e){t(e)}}function rejected(e){try{step(r.throw(e))}catch(e){t(e)}}function step(e){var t;e.done?n(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(fulfilled,rejected)}step((r=r.apply(e,i||[])).next())})},__generator=this&&this.__generator||function(i,s){var r,o,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},u={next:verb(0),throw:verb(1),return:verb(2)};return"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function verb(n){return function(e){var t=[n,e];if(r)throw new TypeError("Generator is already executing.");for(;c=u&&t[u=0]?0:c;)try{if(r=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,o=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))c.label=t[1];else if(6===t[0]&&c.label<a[1])c.label=a[1],a=t;else{if(!(a&&c.label<a[2])){a[2]&&c.ops.pop(),c.trys.pop();continue}c.label=a[2],c.ops.push(t)}}t=s.call(i,c)}catch(e){t=[6,e],o=0}finally{r=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}},__values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return{value:(e=e&&i>=e.length?void 0:e)&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,s,r=n.call(e),o=[];try{for(;(void 0===t||0<t--)&&!(i=r.next()).done;)o.push(i.value)}catch(e){s={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o},__spreadArray=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var i,s=0,r=t.length;s<r;s++)!i&&s in t||((i=i||Array.prototype.slice.call(t,0,s))[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))},logged_in_users_collection_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.SubscriptionManager=void 0,require("../collections/logged-in-users.collection")),app_status_1=require("../publications/app-status"),cron_jobs_1=require("../publications/cron-jobs"),files_1=require("../publications/files"),flags_1=require("../publications/flags"),logs_1=require("../publications/logs"),method_responses_1=require("../publications/method-responses"),notifications_1=require("../publications/notifications"),report_builder_reports_1=require("../publications/report-builder-reports"),super_admin_1=require("../publications/super-admin"),resolveio_server_app_1=require("../resolveio-server-app"),NodeCache=require("node-cache"),os_1=require("os"),flag_collection_1=require("../collections/flag.collection"),flags_update_1=require("../publications/flags-update"),report_builder_dashboard_builders_1=require("../publications/report-builder-dashboard-builders"),report_builder_libraries_1=require("../publications/report-builder-libraries"),user_groups_1=require("../publications/user-groups"),user_guides_1=require("../publications/user-guides"),common_1=require("../util/common"),numCPUs=(0,os_1.cpus)().length,v8=require("v8"),SubscriptionManager=function(){function SubscriptionManager(){this._publications={},this._subscriptions=[],this._loggedInUsers=[],this._mongoQueue=[],this._mongoQueueId=0,this._cacheId=1,this._heapSize=v8.getHeapStatistics()/numCPUs,this._enableDebug=!1,this._debugOplogCollections=[],this._debugOplogHits=0,this._debugSubCollections=[],this._debugSubHits=0,this._debugUnSubHits=0,this._debugUnSubAllHits=0,this._debugMongoQueueHits=0,this._debugMongoQueueCollections=[],this._debugSendQueueHits=0,this._debugRemoveCacheHits=0,this._oplogRetryCount=0,this.latencyBuffer=new Map,this.LATENCY_UPDATE_INTERVAL=6e4,this.LATENCY_UPDATE_THRESHOLD_MS=3e4,this._invalidationDebounceTimers=new Map,this._invalidationPendingTimestamps=new Map,this.DEBOUNCE_DELAY=100,this.MAX_WAIT_TIME=500}return SubscriptionManager.create=function(t,n,i){var e=this,s=new SubscriptionManager;return setImmediate(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,s.initialize(t,n,i)];case 1:return e.sent(),[2]}})})}),s},SubscriptionManager.prototype.initialize=function(i,s,r){return __awaiter(this,void 0,void 0,function(){var t,n=this;return __generator(this,function(e){switch(e.label){case 0:return this._websocketManager=resolveio_server_app_1.ResolveIOServer.getMainServer().getWebSocketManager(),this._monitorManagerFunction=r,this._nodeCache=new NodeCache({stdTTL:0,checkperiod:0}),setInterval(function(){return n.flushThrottledLatencyUpdates()},this.LATENCY_UPDATE_INTERVAL),this.serverConfig=s,this._wss=i,(0,super_admin_1.loadSuperAdminPublications)(this),(0,app_status_1.loadAppStatusPublications)(this),(0,logs_1.loadLogPublications)(this),(0,files_1.loadFilePublications)(this),(0,cron_jobs_1.loadCronJobPublications)(this),(0,flags_update_1.loadFlagsUpdatePublications)(this),(0,flags_1.loadFlagsPublications)(this),(0,method_responses_1.loadMethodResponsePublications)(this),(0,notifications_1.loadNotificationPublications)(this),(0,report_builder_reports_1.loadReportBuilderReportPublications)(this),(0,report_builder_libraries_1.loadReportBuilderLibraryPublications)(this),(0,user_groups_1.loadUserGroupPublications)(this),(0,user_guides_1.loadUserGuidePublications)(this),(0,report_builder_dashboard_builders_1.loadReportBuilderDashboardBuilderPublications)(this),[4,this.tailOpLog()];case 1:return e.sent(),setInterval(function(){n._oplogRetryCount=0},15e3),setInterval(function(){n.getEnableDebug()&&(console.log(new Date,"Sub Manager","Subs",n._subscriptions.length),console.log(new Date,"Sub Manager","Logged In Users",n._loggedInUsers.length),console.log(new Date,"Sub Manager","Mongo Queue",n._mongoQueue.length),console.log(new Date,"Sub Manager","Mongo Queue Hits",n._debugMongoQueueHits),console.log(new Date,"Sub Manager","Mongo Queue Collections",JSON.stringify(n._debugMongoQueueCollections.sort(function(e,t){return e.collection.localeCompare(t.collection)||e.publication.localeCompare(t.publication)}),null,2)),console.log(new Date,"Sub Manager","Oplog Hits",n._debugOplogHits),console.log(new Date,"Sub Manager","Oplog Collections",JSON.stringify(n._debugOplogCollections.sort(function(e,t){return e.collection.localeCompare(t.collection)||e.type.localeCompare(t.type)}),null,2)),console.log(new Date,"Sub Manager","Send Queue Hits",n._debugSendQueueHits),console.log(new Date,"Sub Manager","Sub Hits",n._debugSubHits),console.log(new Date,"Sub Manager","Sub Collections",JSON.stringify(n._debugSubCollections.sort(function(e,t){return e.publication.localeCompare(t.publication)}),null,2)),console.log(new Date,"Sub Manager","Unsub Hits",n._debugUnSubHits),console.log(new Date,"Sub Manager","Unsub All Hits",n._debugUnSubAllHits),console.log(new Date,"Sub Manager","Cache Cleanup Hits",n._debugRemoveCacheHits)),n._debugOplogHits=0,n._debugOplogCollections=[],n._debugSubCollections=[],n._debugMongoQueueHits=0,n._debugMongoQueueCollections=[],n._debugSendQueueHits=0,n._debugSubHits=0,n._debugUnSubHits=0,n._debugUnSubAllHits=0,n._debugRemoveCacheHits=0},6e4),setInterval(function(){return __awaiter(n,void 0,void 0,function(){var t,i,n,s,r,o,a,c,u;return __generator(this,function(e){switch(e.label){case 0:return t=this,[4,logged_in_users_collection_1.LoggedInUsers.find()];case 1:t._loggedInUsers=e.sent(),i=(0,common_1.deepCopy)(this._loggedInUsers),n=function(t){var n;return __generator(this,function(e){switch(e.label){case 0:return!(n=i[t]).date||12e4<Date.now()-n.date.getTime()?s._websocketManager.getWebSocket(n.id_ws)?(s.getEnableDebug()&&console.log(new Date,"Sub Manager","Unsub WS",s._websocketManager.getWebSocket(n.id_ws).user,s._websocketManager.getWebSocket(n.id_ws).id_socket,2),[4,s.unsubscribeAll(s._websocketManager.getWebSocket(n.id_ws))]):[3,2]:[3,4];case 1:return e.sent(),[3,4];case 2:return s._subscriptions.forEach(function(e){for(var t=e.clients.length-1;0<=t;t--)e.clients[t].id_socket===n.id_ws&&e.clients.splice(t,1)}),[4,logged_in_users_collection_1.LoggedInUsers.deleteOne({_id:n._id})];case 3:e.sent(),0<=s._loggedInUsers.findIndex(function(e){return e._id===n._id})&&s._loggedInUsers.splice(s._loggedInUsers.findIndex(function(e){return e._id===n._id}),1),e.label=4;case 4:return[2]}})},r=(s=this)._loggedInUsers.length-1,e.label=2;case 2:return 0<=r?[5,n(r)]:[3,5];case 3:e.sent(),e.label=4;case 4:return r--,[3,2];case 5:for(r=0;r<this._subscriptions.length;r++)for(o=this._subscriptions[r],a=function(e){var t=o.clients[e];c._loggedInUsers.some(function(e){return e.id_ws===t.id_socket})||o.clients.splice(e,1)},c=this,u=o.clients.length-1;0<=u;u--)a(u);return[2]}})})},3e4),[4,flag_collection_1.Flags.findOne({type:"Enable Debug"})];case 2:return(t=e.sent())&&t.value?this._enableDebug=!0:this._enableDebug=!1,this.setCacheLimit(),[2]}})})},SubscriptionManager.prototype.setCacheLimit=function(){"true"===process.env.IS_WORKERS_ENABLED?this._heapLimit=.4*this._heapSize:this._heapLimit=.3*this._heapSize},SubscriptionManager.prototype.invalidatePubsCache=function(r,o){return __awaiter(this,void 0,void 0,function(){var t,n,i,s=this;return __generator(this,function(e){switch(e.label){case 0:return(t=r,n=Date.now(),i=this._invalidationPendingTimestamps.get(t)||n,this._invalidationPendingTimestamps.set(t,i),this._invalidationDebounceTimers.has(t)&&clearTimeout(this._invalidationDebounceTimers.get(t)),n-i>=this.MAX_WAIT_TIME)?(this._invalidationPendingTimestamps.delete(t),[4,this._executeInvalidation(r,o)]):[3,2];case 1:return e.sent(),[3,3];case 2:this._invalidationDebounceTimers.set(t,setTimeout(function(){return __awaiter(s,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return this._invalidationPendingTimestamps.delete(t),[4,this._executeInvalidation(r,o)];case 1:return e.sent(),[2]}})})},this.DEBOUNCE_DELAY)),e.label=3;case 3:return[2]}})})},SubscriptionManager.prototype._executeInvalidation=function(h,b){return __awaiter(this,void 0,void 0,function(){var t,n,i,s,r,o,a,c,u,l,_,g,d;return __generator(this,function(e){switch(e.label){case 0:this._invalidationDebounceTimers.has(h)&&(clearTimeout(this._invalidationDebounceTimers.get(h)),this._invalidationDebounceTimers.delete(h)),resolveio_server_app_1.ResolveIOServer.getMongoManager().invalidateQueryCache(h),t=this._subscriptions.filter(function(e){return e.collections.includes(h)}),e.label=1;case 1:e.trys.push([1,17,18,19]),n=__values(t),i=n.next(),e.label=2;case 2:if(i.done)return[3,16];if(s=i.value,this._enableDebug&&console.log(new Date,"Invalidate Sub",s.publication,s.running,s.runAgain),s.running)return s.runAgain=!0,[3,15];if(!this._publications[s.publication].user_specific)return[3,13];e.label=3;case 3:e.trys.push([3,10,11,12]),g=void 0,r=__values(s.clients),o=r.next(),e.label=4;case 4:if(o.done)return[3,9];if(a=o.value,(null==(c=this._websocketManager.getWebSocket(a.id_socket))?void 0:c.readyState)!==c.OPEN)return[3,8];e.label=5;case 5:return e.trys.push([5,7,,8]),[4,this.sendDataToOneWithRetry(c,a.messageId,s,h,b)];case 6:return e.sent(),[3,8];case 7:return e.sent(),[3,8];case 8:return o=r.next(),[3,4];case 9:return[3,12];case 10:return u=e.sent(),g={error:u},[3,12];case 11:try{o&&!o.done&&(d=r.return)&&d.call(r)}finally{if(g)throw g.error}return[7];case 12:return[3,15];case 13:return[4,this.sendDataToAllWithRetry(s,h,b)];case 14:e.sent(),e.label=15;case 15:return i=n.next(),[3,2];case 16:return[3,19];case 17:return u=e.sent(),l={error:u},[3,19];case 18:try{i&&!i.done&&(_=n.return)&&_.call(n)}finally{if(l)throw l.error}return[7];case 19:return[2]}})})},SubscriptionManager.prototype.delay=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,new Promise(function(e){return setTimeout(e,t)})]})})},SubscriptionManager.prototype.sendDataToAllWithRetry=function(t,n,i){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:t.running=!0,e.label=1;case 1:return this._enableDebug&&console.log(new Date,"Running sendDataToAll Sub",t.publication),t.runAgain=!1,[4,this.sendDataToAll(t,n,i)];case 2:return(e.sent(),this._enableDebug&&console.log(new Date,"Done sendDataToAll Sub",t.publication,t.runAgain),t.runAgain)?[4,this.delay(500)]:[3,4];case 3:e.sent(),e.label=4;case 4:if(t.runAgain)return[3,1];e.label=5;case 5:return t.running=!1,[2]}})})},SubscriptionManager.prototype.sendDataToOneWithRetry=function(t,n,i,s,r){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:i.running=!0,e.label=1;case 1:return this._enableDebug&&console.log(new Date,"Running sendDataToOne Sub",i.publication),i.runAgain=!1,[4,this.sendDataToOne(t,n,i,s,r)];case 2:return(e.sent(),this._enableDebug&&console.log(new Date,"Done sendDataToOne Sub",i.publication,i.runAgain),i.runAgain)?[4,this.delay(500)]:[3,4];case 3:e.sent(),e.label=4;case 4:if(i.runAgain)return[3,1];e.label=5;case 5:return i.running=!1,[2]}})})},SubscriptionManager.prototype.publications=function(e){this._publications=Object.assign(this._publications,e)},SubscriptionManager.prototype.loggedInLatency=function(t){var e,n,i,s=this._loggedInUsers.find(function(e){return e.id_ws===t.id_socket});s&&(e=new Date,n=this.latencyBuffer.get(t.id_socket),i=t.latency,!n||e.getTime()-n.lastUpdate.getTime()>=this.LATENCY_UPDATE_THRESHOLD_MS||100<Math.abs(i-n.latency))&&(s.date=e,this.latencyBuffer.set(t.id_socket,{latency:i,lastUpdate:e}))},SubscriptionManager.prototype.flushThrottledLatencyUpdates=function(){return __awaiter(this,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:if(0===this.latencyBuffer.size)return[2];t=Array.from(this.latencyBuffer.entries()).map(function(e){var e=__read(e,2),t=e[0],e=e[1];return{updateOne:{filter:{id_ws:t},update:{$set:{latency:e.latency,date:e.lastUpdate}}}}}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,logged_in_users_collection_1.LoggedInUsers.bulkWrite(t)];case 2:return e.sent(),this.latencyBuffer.clear(),this.getEnableDebug()&&console.log(new Date,"Sub Manager","Throttled latency batch update successful",t.length),[3,4];case 3:return n=e.sent(),console.error(new Date,"Sub Manager","Throttled latency batch update failed",n),[3,4];case 4:return[2]}})})},SubscriptionManager.prototype.subscribe=function(u,e,l,_,g,d){return __awaiter(this,void 0,void 0,function(){var t,n,i,s,r,o,a,c=this;return __generator(this,function(e){switch(e.label){case 0:return(this._debugSubHits+=1,this._debugSubCollections.some(function(e){return e.publication===g})?this._debugSubCollections.find(function(e){return e.publication===g}).hits+=1:this._debugSubCollections.push({publication:g,hits:1}),t=this._publications[g])?[3,1]:(console.error(new Date,"No Publication: "+g),[2]);case 1:if(1<d.length||d[0]){if(!t.check)return console.error(new Date,"No Check Function For Pub "+g),[2];if(!t.check._schema)return console.error(new Date,"No Check Schema For Pub "+g),[2];for(n={},r=Object.keys(t.check._schema),i=r.filter(function(e){return!e.includes(".")}),s=0;s<d.length;s++)n[i[s]]=d[s];try{t.check.validate(n)}catch(e){if(e)return console.error(new Date,"Error in Pub Check ("+g+")",e),[2]}}return"Bypass"!==u&&(r=u.split("/"),o="",a=r[0],""===r[0]&&(o="/",a=r[1]),o+=a,1<r.length&&(o+="/"),(a=this._subscriptions.filter(function(e){return e.clients.some(function(e){return e.id_socket===l.id_socket&&"Bypass"!==e.messageRoute&&"/"!==e.messageRoute&&e.messageRoute!==u&&!e.messageRoute.startsWith(o)})})).length)&&a.forEach(function(t){t.clients.filter(function(e){return e.id_socket===l.id_socket}).forEach(function(e){c.unsubscribe(e.messageRoute,new Date,l,e.messageId,t.publication,t.subscriptionData)})}),(a=this._subscriptions.find(function(e){return e.publication===g&&JSON.stringify(e.subscriptionData)===JSON.stringify(d)}))?a.clients.some(function(e){return e.id_socket===l.id_socket&&e.messageId===_})||a.clients.push({id_user:l.id_user,messageId:_,id_socket:l.id_socket,messageRoute:u}):this._subscriptions.push({publication:g,subscriptionData:d,collections:this.getPublicationCollections(g),clients:[{id_user:l.id_user,messageId:_,id_socket:l.id_socket,messageRoute:u}],cacheId:0,running:!1,runAgain:!1}),a=a||this._subscriptions.find(function(e){return e.publication===g&&JSON.stringify(e.subscriptionData)===JSON.stringify(d)}),this._enableDebug&&console.log(new Date,"New Sub",a.publication,a.running,a.runAgain,a.clients.length),[4,this.processSubscription(a,l,_)];case 2:e.sent(),e.label=3;case 3:return[2]}})})},SubscriptionManager.prototype.createLoggedInUser=function(i){return __awaiter(this,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:return(t=this._websocketManager.getWebSocket(i))?(n={_id:(0,common_1.objectIdHexString)(),__v:0,date:new Date,id_user:t.id_user,user:t.user,id_ws:t.id_socket},this._loggedInUsers.push(n),[4,logged_in_users_collection_1.LoggedInUsers.insertOne(n)]):[3,2];case 1:return e.sent(),[2,n];case 2:throw new Error("Error in Create Logged In User: No WS")}})})},SubscriptionManager.prototype.unsubscribe=function(e,t,n,i,s,r){if(this._debugUnSubHits+=1,this._publications[s]){var o=this._subscriptions.find(function(e){return e.publication===s&&JSON.stringify(e.subscriptionData)===JSON.stringify(r)});if(o){for(var a=o.clients.length-1;0<=a;a--)o.clients[a].id_user===n.id_user&&o.clients[a].messageId===i&&o.clients[a].id_socket===n.id_socket&&o.clients.splice(a,1);this._enableDebug&&console.log(new Date,"Unsub",o.publication,o.running,o.runAgain,o.clients.length)}}else console.log("No Publication: "+s)},SubscriptionManager.prototype.unsubscribeAll=function(r){return __awaiter(this,void 0,void 0,function(){var t,n,i,s;return __generator(this,function(e){switch(e.label){case 0:return(this._debugUnSubAllHits+=1,r)?r.isUnsubscribed?[2]:(r.isUnsubscribed=!0,0<=this._loggedInUsers.map(function(e){return e.id_ws}).indexOf(r.id_socket)&&this._loggedInUsers.splice(this._loggedInUsers.map(function(e){return e.id_ws}).indexOf(r.id_socket),1),[4,logged_in_users_collection_1.LoggedInUsers.deleteOne({id_ws:r.id_socket})]):[3,2];case 1:for(e.sent(),t=this._subscriptions.filter(function(e){return e.clients.some(function(e){return e.id_user===r.id_user&&e.id_socket===r.id_socket})}),n=t.length-1;0<=n;n--)for(i=t[n],s=i.clients.length-1;0<=s;s--)i.clients[s].id_socket===r.id_socket&&i.clients.splice(s,1);this._websocketManager.removeWebSocket(r),e.label=2;case 2:return[2]}})})},SubscriptionManager.prototype.getActiveSubscriptions=function(){return this._subscriptions},SubscriptionManager.prototype.getPublicationCollections=function(e){return this._publications[e].collections},SubscriptionManager.prototype.tailOpLog=function(i){return __awaiter(this,void 0,void 0,function(){var t,s,n=this;return __generator(this,function(e){switch(e.label){case 0:return!this._oplog$||this._oplog$.closed?[3,2]:(this._oplog$.removeAllListeners(),[4,this._oplog$.close()]);case 1:e.sent(),this._oplog$=null,e.label=2;case 2:return[4,new Promise(function(e){return setTimeout(e,1e3)})];case 3:if(e.sent(),this._oplog$&&!this._oplog$.closed)return[3,12];if(this._oplogRetryCount+=1,5<this._oplogRetryCount&&(console.error("****************** TAIL OPLOG ERROR, RETRYING A BUNCH OF TIMES, KILLING PROCESS **************************"),process.exit(1)),t=[{$match:{$and:[{"ns.coll":{$nin:["log-method-latencies","log-subscriptions","logs","counters","cron-job-histories","email-histories","qb-soap-request-histories","qb-soap-request-responses","qb-soap-requests","qb-soap-retries"]}},{"ns.coll":{$not:/.*\.versions$/}},{"ns.coll":{$not:/^monitor-/}}]}}],!i)return[3,10];s=i,e.label=4;case 4:return e.trys.push([4,5,,9]),this._oplog$=resolveio_server_app_1.ResolveIOServer.getMainDB().watch(t,{resumeAfter:i}),[3,9];case 5:return(e.sent(),this._oplog$)?(this._oplog$.removeAllListeners(),[4,this._oplog$.close()]):[3,7];case 6:e.sent(),this._oplog$=null,e.label=7;case 7:return[4,this.tailOpLog(i)];case 8:return e.sent(),[2];case 9:return[3,11];case 10:this._oplog$=resolveio_server_app_1.ResolveIOServer.getMainDB().watch(t),e.label=11;case 11:console.log(new Date,"oplog started"),this._oplog$.on("change",function(i){return __awaiter(n,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:return i.ns?(this._enableDebug&&console.log(new Date,"Oplog Hit",i.ns),t=i.ns.coll,this._debugOplogCollections.some(function(e){return e.collection===i.ns.coll&&e.type===i.operationType})?this._debugOplogCollections.find(function(e){return e.collection===i.ns.coll&&e.type===i.operationType}).hits+=1:this._debugOplogCollections.push({collection:i.ns.coll,type:i.operationType,hits:1}),t?(this._debugOplogHits+=1,"insert"!==i.operationType?[3,5]:"support-tickets"!==t||"https://resolveio.com"!==this.serverConfig.ROOT_URL?[3,2]:(resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().callMethod.call(resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager(),"sendSupportTicketEmail",i.documentKey._id),[4,this.invalidatePubsCache(t,"insert")])):[3,10]):[3,13];case 1:e.sent(),e.label=2;case 2:return"method-responses"===t?[3,4]:[4,this.invalidatePubsCache(t,"insert")];case 3:e.sent(),e.label=4;case 4:return[3,10];case 5:return"update"!==i.operationType&&"replace"!==i.operationType?[3,8]:"method-responses"===t?[3,7]:[4,this.invalidatePubsCache(t,"update")];case 6:e.sent(),e.label=7;case 7:return[3,10];case 8:return"delete"!==i.operationType?[3,10]:"method-responses"===t?[3,10]:[4,this.invalidatePubsCache(t,"delete")];case 9:e.sent(),e.label=10;case 10:return"flags"!==t?[3,12]:[4,flag_collection_1.Flags.findOne({type:"Enable Debug"})];case 11:(n=e.sent())&&n.value?this._enableDebug=!0:this._enableDebug=!1,e.label=12;case 12:s=i._id,process.env.NODE_APP_INSTANCE&&"0"!==process.env.NODE_APP_INSTANCE||"false"!==process.env.IS_WORKERS_ENABLED&&"true"===process.env.IS_WORKER_INSTANCE&&process.env.WORKER_INDEX,e.label=13;case 13:return[2]}})})}),this._oplog$.on("error",function(t){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return console.log(new Date,"oplog error",t),[4,this._oplog$.close()];case 1:return e.sent(),[2]}})})}),this._oplog$.on("end",function(){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return console.log(new Date,"oplog end"),[4,this._oplog$.close()];case 1:return e.sent(),[2]}})})}),this._oplog$.on("close",function(){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return console.log(new Date,"oplog close"),this._oplog$.removeAllListeners(),this._oplog$=null,[4,this.tailOpLog(s)];case 1:return e.sent(),[2]}})})}),e.label=12;case 12:return[2]}})})},SubscriptionManager.prototype.processSubscription=function(n,i,s){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:if(this._publications[n.publication].user_specific)return[3,8];if(!n.cacheId)return[3,5];e.label=1;case 1:return e.trys.push([1,2,,4]),t=JSON.parse(this._nodeCache.get(n.cacheId),common_1.dateReviver),t={messageId:s,hasError:!1,data:t},this._enableDebug&&console.log(new Date,"Process Sub, Cache",n.publication),this.sendWS(i,t),[3,4];case 2:return e.sent(),this._nodeCache.del(n.cacheId),n.cacheId=0,[4,this.sendDataToAllWithRetry(n,"","newSub")];case 3:return e.sent(),[3,4];case 4:return[3,7];case 5:return this._enableDebug&&console.log(new Date,"Process Sub, Non - Cache",n.publication,n.running),n.running?[2]:[4,this.sendDataToAllWithRetry(n,"","newSub")];case 6:e.sent(),e.label=7;case 7:return[3,10];case 8:return this._enableDebug&&console.log(new Date,"Process Sub Specific, Non - Cache",n.publication,n.running),n.running?[2]:[4,this.sendDataToOneWithRetry(i,s,n,"","newSub")];case 9:e.sent(),e.label=10;case 10:return[2]}})})},SubscriptionManager.prototype.sendDataToOne=function(r,o,a,c,u){return __awaiter(this,void 0,void 0,function(){var t,n,i,s;return __generator(this,function(e){switch(e.label){case 0:t=this._monitorManagerFunction.startMonitorFunction("User Specific Publication",a.publication,"","",a.subscriptionData),e.label=1;case 1:return e.trys.push([1,3,5,7]),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().callMethod.call(resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager(),"insertSubscriptionLog",u,a.publication,c,JSON.stringify(a.subscriptionData)),[4,(s=this._publications[a.publication].function).call.apply(s,__spreadArray([Object.assign({},this,SubscriptionManager.prototype),r.id_user],__read(a.subscriptionData),!1))];case 2:return s=e.sent(),i={messageId:o,hasError:!1,data:s},this.sendWS(r,i),[3,7];case 3:return n=e.sent(),i={messageId:o,hasError:!0,data:n},this.sendWS(r,i),[4,resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com","SERVER - Error Detected - "+this.serverConfig.CLIENT_NAME,"Error Detected During Subscription "+a.publication+" - (sendDataToOne - WS)\n\nData \n"+JSON.stringify(a.subscriptionData,null,2)+"\n\nErrors\n"+JSON.stringify(n,null,2))];case 4:return e.sent(),[3,7];case 5:return[4,this._monitorManagerFunction.finishMonitorFunction(t)];case 6:return e.sent(),[7];case 7:return[2]}})})},SubscriptionManager.prototype.sendDataToAll=function(O,C,E){return __awaiter(this,void 0,void 0,function(){var t,n,i,s,r,o,a,c,u,l,_,g,d,h,b,p,f,v,S,y,m,w,D,M,I=this;return __generator(this,function(e){switch(e.label){case 0:return O.clients.length?[3,1]:(O.cacheId&&(this._nodeCache.del(O.cacheId),O.cacheId=0),0<=(v=this._subscriptions.findIndex(function(e){return e.publication===O.publication&&JSON.stringify(e.subscriptionData)===JSON.stringify(O.subscriptionData)}))&&this._subscriptions.splice(v,1),[2]);case 1:t=this._monitorManagerFunction.startMonitorFunction("Publication",O.publication,"","",O.subscriptionData),e.label=2;case 2:return e.trys.push([2,4,6,8]),"superadminAPM"!==O.publication&&"loggedInUsers"!==O.publication&&resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().callMethod.call(resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager(),"insertSubscriptionLog",E,O.publication,C,JSON.stringify(O.subscriptionData)),[4,(v=this._publications[O.publication].function).call.apply(v,__spreadArray([Object.assign({},this,SubscriptionManager.prototype)],__read(O.subscriptionData),!1))];case 3:if(n=e.sent(),O.cacheId)try{if(i=JSON.parse(this._nodeCache.get(O.cacheId),common_1.dateReviver),JSON.stringify(i)!==JSON.stringify(n)){try{for(s=__values(O.clients),r=s.next();!r.done;r=s.next())b=r.value,(p=this._websocketManager.getWebSocket(b.id_socket))&&p.readyState===p.OPEN&&(f={messageId:b.messageId,hasError:!1,data:n},this.sendWS(p,f))}catch(e){S={error:e}}finally{try{r&&!r.done&&(y=s.return)&&y.call(s)}finally{if(S)throw S.error}}this._nodeCache.del(O.cacheId),(0,common_1.getBinarySize)(JSON.stringify(n))<1e6&&!O.collections.includes("logs")&&!O.collections.find(function(e){return e.endsWith(".versions")})&&!O.collections.find(function(e){return e.startsWith("monitor-")})?this._nodeCache.set(O.cacheId,JSON.stringify(n)):O.cacheId=0}}catch(e){O.clients.map(function(e){var t=I._websocketManager.getWebSocket(e.id_socket);t&&t.readyState===t.OPEN&&(e={messageId:e.messageId,hasError:!1,data:n},I.sendWS(t,e))}),this._nodeCache.del(O.cacheId),(0,common_1.getBinarySize)(JSON.stringify(n))<1e6&&!O.collections.includes("logs")&&!O.collections.find(function(e){return e.endsWith(".versions")})&&!O.collections.find(function(e){return e.startsWith("monitor-")})?this._nodeCache.set(O.cacheId,JSON.stringify(n)):O.cacheId=0}else{try{for(o=__values(O.clients),a=o.next();!a.done;a=o.next())b=a.value,(p=this._websocketManager.getWebSocket(b.id_socket))&&p.readyState===p.OPEN&&(f={messageId:b.messageId,hasError:!1,data:n},this.sendWS(p,f))}catch(e){m={error:e}}finally{try{a&&!a.done&&(w=o.return)&&w.call(o)}finally{if(m)throw m.error}}if((0,common_1.getBinarySize)(JSON.stringify(n))<1e6&&!O.collections.includes("logs")&&!O.collections.find(function(e){return e.endsWith(".versions")})&&!O.collections.find(function(e){return e.startsWith("monitor-")})){if(O.cacheId=this._cacheId++,this._nodeCache.set(O.cacheId,JSON.stringify(n)),(c=this._nodeCache.getStats().vsize)>this._heapLimit){for(u=0,l=this._subscriptions.filter(function(e){return e.cacheId&&!e.clients.length}),_=0;_<l.length&&(this._debugRemoveCacheHits+=1,this._nodeCache.del(l[_].cacheId),l[_].cacheId=0,u+=1,!(this._nodeCache.getStats().vsize<.75*this._heapLimit));_++);this._enableDebug&&console.log("Sub Cache: Too Big - "+O.publication+" - Deleted: "+u+" - "+c)}}else O.cacheId=0}return[3,8];case 4:g=e.sent();try{for(d=__values(O.clients),h=d.next();!h.done;h=d.next())b=h.value,(p=this._websocketManager.getWebSocket(b.id_socket))&&p.readyState===p.OPEN&&(f={messageId:b.messageId,hasError:!0,data:g},this.sendWS(p,f))}catch(e){D={error:e}}finally{try{h&&!h.done&&(M=d.return)&&M.call(d)}finally{if(D)throw D.error}}return[4,resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com","SERVER - Error Detected - "+this.serverConfig.CLIENT_NAME,"Error Detected During Subscription "+O.publication+" - (sendPubData)\n\nData \n"+JSON.stringify(O.subscriptionData,null,2)+"\n\nErrors\n"+JSON.stringify(g,null,2))];case 5:return e.sent(),[3,8];case 6:return[4,this._monitorManagerFunction.finishMonitorFunction(t)];case 7:return e.sent(),[7];case 8:return[2]}})})},SubscriptionManager.prototype.sendWS=function(e,t){this._websocketManager.send(e,t)},SubscriptionManager.prototype.getEnableDebug=function(){return this._enableDebug},SubscriptionManager}();exports.SubscriptionManager=SubscriptionManager;
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,i,s,r){return new(s=s||Promise)(function(n,t){function fulfilled(e){try{step(r.next(e))}catch(e){t(e)}}function rejected(e){try{step(r.throw(e))}catch(e){t(e)}}function step(e){var t;e.done?n(e.value):((t=e.value)instanceof s?t:new s(function(e){e(t)})).then(fulfilled,rejected)}step((r=r.apply(e,i||[])).next())})},__generator=this&&this.__generator||function(i,s){var r,o,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},u={next:verb(0),throw:verb(1),return:verb(2)};return"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function verb(n){return function(e){var t=[n,e];if(r)throw new TypeError("Generator is already executing.");for(;c=u&&t[u=0]?0:c;)try{if(r=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,o=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))c.label=t[1];else if(6===t[0]&&c.label<a[1])c.label=a[1],a=t;else{if(!(a&&c.label<a[2])){a[2]&&c.ops.pop(),c.trys.pop();continue}c.label=a[2],c.ops.push(t)}}t=s.call(i,c)}catch(e){t=[6,e],o=0}finally{r=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}},__values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return{value:(e=e&&i>=e.length?void 0:e)&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,s,r=n.call(e),o=[];try{for(;(void 0===t||0<t--)&&!(i=r.next()).done;)o.push(i.value)}catch(e){s={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o},__spreadArray=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var i,s=0,r=t.length;s<r;s++)!i&&s in t||((i=i||Array.prototype.slice.call(t,0,s))[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))},NodeCache=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.SubscriptionManager=void 0,require("node-cache")),os_1=require("os"),flag_collection_1=require("../collections/flag.collection"),logged_in_users_collection_1=require("../collections/logged-in-users.collection"),app_status_1=require("../publications/app-status"),cron_jobs_1=require("../publications/cron-jobs"),files_1=require("../publications/files"),flags_1=require("../publications/flags"),flags_update_1=require("../publications/flags-update"),logs_1=require("../publications/logs"),notifications_1=require("../publications/notifications"),report_builder_dashboard_builders_1=require("../publications/report-builder-dashboard-builders"),report_builder_libraries_1=require("../publications/report-builder-libraries"),report_builder_reports_1=require("../publications/report-builder-reports"),super_admin_1=require("../publications/super-admin"),user_groups_1=require("../publications/user-groups"),user_guides_1=require("../publications/user-guides"),resolveio_server_app_1=require("../resolveio-server-app"),common_1=require("../util/common"),numCPUs=(0,os_1.cpus)().length,v8=require("v8"),SubscriptionManager=function(){function SubscriptionManager(){this._publications={},this._subscriptions=[],this._loggedInUsers=[],this._mongoQueue=[],this._mongoQueueId=0,this._cacheId=1,this._heapSize=v8.getHeapStatistics()/numCPUs,this._enableDebug=!1,this._debugOplogCollections=[],this._debugOplogHits=0,this._debugSubCollections=[],this._debugSubHits=0,this._debugUnSubHits=0,this._debugUnSubAllHits=0,this._debugMongoQueueHits=0,this._debugMongoQueueCollections=[],this._debugSendQueueHits=0,this._debugRemoveCacheHits=0,this._oplogRetryCount=0,this.latencyBuffer=new Map,this.LATENCY_UPDATE_INTERVAL=6e4,this.LATENCY_UPDATE_THRESHOLD_MS=3e4,this._invalidationDebounceTimers=new Map,this._invalidationPendingTimestamps=new Map,this.DEBOUNCE_DELAY=100,this.MAX_WAIT_TIME=500}return SubscriptionManager.create=function(t,n,i){var e=this,s=new SubscriptionManager;return setImmediate(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,s.initialize(t,n,i)];case 1:return e.sent(),[2]}})})}),s},SubscriptionManager.prototype.initialize=function(i,s,r){return __awaiter(this,void 0,void 0,function(){var t,n=this;return __generator(this,function(e){switch(e.label){case 0:return this._websocketManager=resolveio_server_app_1.ResolveIOServer.getMainServer().getWebSocketManager(),this._monitorManagerFunction=r,this._nodeCache=new NodeCache({stdTTL:0,checkperiod:0}),setInterval(function(){return n.flushThrottledLatencyUpdates()},this.LATENCY_UPDATE_INTERVAL),this.serverConfig=s,this._wss=i,(0,super_admin_1.loadSuperAdminPublications)(this),(0,app_status_1.loadAppStatusPublications)(this),(0,logs_1.loadLogPublications)(this),(0,files_1.loadFilePublications)(this),(0,cron_jobs_1.loadCronJobPublications)(this),(0,flags_update_1.loadFlagsUpdatePublications)(this),(0,flags_1.loadFlagsPublications)(this),(0,notifications_1.loadNotificationPublications)(this),(0,report_builder_reports_1.loadReportBuilderReportPublications)(this),(0,report_builder_libraries_1.loadReportBuilderLibraryPublications)(this),(0,user_groups_1.loadUserGroupPublications)(this),(0,user_guides_1.loadUserGuidePublications)(this),(0,report_builder_dashboard_builders_1.loadReportBuilderDashboardBuilderPublications)(this),[4,this.tailOpLog()];case 1:return e.sent(),setInterval(function(){n._oplogRetryCount=0},15e3),setInterval(function(){n.getEnableDebug()&&(console.log(new Date,"Sub Manager","Subs",n._subscriptions.length),console.log(new Date,"Sub Manager","Logged In Users",n._loggedInUsers.length),console.log(new Date,"Sub Manager","Mongo Queue",n._mongoQueue.length),console.log(new Date,"Sub Manager","Mongo Queue Hits",n._debugMongoQueueHits),console.log(new Date,"Sub Manager","Mongo Queue Collections",JSON.stringify(n._debugMongoQueueCollections.sort(function(e,t){return e.collection.localeCompare(t.collection)||e.publication.localeCompare(t.publication)}),null,2)),console.log(new Date,"Sub Manager","Oplog Hits",n._debugOplogHits),console.log(new Date,"Sub Manager","Oplog Collections",JSON.stringify(n._debugOplogCollections.sort(function(e,t){return e.collection.localeCompare(t.collection)||e.type.localeCompare(t.type)}),null,2)),console.log(new Date,"Sub Manager","Send Queue Hits",n._debugSendQueueHits),console.log(new Date,"Sub Manager","Sub Hits",n._debugSubHits),console.log(new Date,"Sub Manager","Sub Collections",JSON.stringify(n._debugSubCollections.sort(function(e,t){return e.publication.localeCompare(t.publication)}),null,2)),console.log(new Date,"Sub Manager","Unsub Hits",n._debugUnSubHits),console.log(new Date,"Sub Manager","Unsub All Hits",n._debugUnSubAllHits),console.log(new Date,"Sub Manager","Cache Cleanup Hits",n._debugRemoveCacheHits)),n._debugOplogHits=0,n._debugOplogCollections=[],n._debugSubCollections=[],n._debugMongoQueueHits=0,n._debugMongoQueueCollections=[],n._debugSendQueueHits=0,n._debugSubHits=0,n._debugUnSubHits=0,n._debugUnSubAllHits=0,n._debugRemoveCacheHits=0},6e4),setInterval(function(){return __awaiter(n,void 0,void 0,function(){var t,i,n,s,r,o,a,c,u;return __generator(this,function(e){switch(e.label){case 0:return t=this,[4,logged_in_users_collection_1.LoggedInUsers.find()];case 1:t._loggedInUsers=e.sent(),i=(0,common_1.deepCopy)(this._loggedInUsers),n=function(t){var n;return __generator(this,function(e){switch(e.label){case 0:return!(n=i[t]).date||12e4<Date.now()-n.date.getTime()?s._websocketManager.getWebSocket(n.id_ws)?(s.getEnableDebug()&&console.log(new Date,"Sub Manager","Unsub WS",s._websocketManager.getWebSocket(n.id_ws).user,s._websocketManager.getWebSocket(n.id_ws).id_socket,2),[4,s.unsubscribeAll(s._websocketManager.getWebSocket(n.id_ws))]):[3,2]:[3,4];case 1:return e.sent(),[3,4];case 2:return s._subscriptions.forEach(function(e){for(var t=e.clients.length-1;0<=t;t--)e.clients[t].id_socket===n.id_ws&&e.clients.splice(t,1)}),[4,logged_in_users_collection_1.LoggedInUsers.deleteOne({_id:n._id})];case 3:e.sent(),0<=s._loggedInUsers.findIndex(function(e){return e._id===n._id})&&s._loggedInUsers.splice(s._loggedInUsers.findIndex(function(e){return e._id===n._id}),1),e.label=4;case 4:return[2]}})},r=(s=this)._loggedInUsers.length-1,e.label=2;case 2:return 0<=r?[5,n(r)]:[3,5];case 3:e.sent(),e.label=4;case 4:return r--,[3,2];case 5:for(r=0;r<this._subscriptions.length;r++)for(o=this._subscriptions[r],a=function(e){var t=o.clients[e];c._loggedInUsers.some(function(e){return e.id_ws===t.id_socket})||o.clients.splice(e,1)},c=this,u=o.clients.length-1;0<=u;u--)a(u);return[2]}})})},3e4),[4,flag_collection_1.Flags.findOne({type:"Enable Debug"})];case 2:return(t=e.sent())&&t.value?this._enableDebug=!0:this._enableDebug=!1,this.setCacheLimit(),[2]}})})},SubscriptionManager.prototype.setCacheLimit=function(){"true"===process.env.IS_WORKERS_ENABLED?this._heapLimit=.4*this._heapSize:this._heapLimit=.3*this._heapSize},SubscriptionManager.prototype.invalidatePubsCache=function(r,o){return __awaiter(this,void 0,void 0,function(){var t,n,i,s=this;return __generator(this,function(e){switch(e.label){case 0:return(t=r,n=Date.now(),i=this._invalidationPendingTimestamps.get(t)||n,this._invalidationPendingTimestamps.set(t,i),this._invalidationDebounceTimers.has(t)&&clearTimeout(this._invalidationDebounceTimers.get(t)),n-i>=this.MAX_WAIT_TIME)?(this._invalidationPendingTimestamps.delete(t),[4,this._executeInvalidation(r,o)]):[3,2];case 1:return e.sent(),[3,3];case 2:this._invalidationDebounceTimers.set(t,setTimeout(function(){return __awaiter(s,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return this._invalidationPendingTimestamps.delete(t),[4,this._executeInvalidation(r,o)];case 1:return e.sent(),[2]}})})},this.DEBOUNCE_DELAY)),e.label=3;case 3:return[2]}})})},SubscriptionManager.prototype._executeInvalidation=function(h,b){return __awaiter(this,void 0,void 0,function(){var t,n,i,s,r,o,a,c,u,l,_,g,d;return __generator(this,function(e){switch(e.label){case 0:this._invalidationDebounceTimers.has(h)&&(clearTimeout(this._invalidationDebounceTimers.get(h)),this._invalidationDebounceTimers.delete(h)),resolveio_server_app_1.ResolveIOServer.getMongoManager().invalidateQueryCache(h),t=this._subscriptions.filter(function(e){return e.collections.includes(h)}),e.label=1;case 1:e.trys.push([1,17,18,19]),n=__values(t),i=n.next(),e.label=2;case 2:if(i.done)return[3,16];if(s=i.value,this._enableDebug&&console.log(new Date,"Invalidate Sub",s.publication,s.running,s.runAgain),s.running)return s.runAgain=!0,[3,15];if(!this._publications[s.publication].user_specific)return[3,13];e.label=3;case 3:e.trys.push([3,10,11,12]),g=void 0,r=__values(s.clients),o=r.next(),e.label=4;case 4:if(o.done)return[3,9];if(a=o.value,(null==(c=this._websocketManager.getWebSocket(a.id_socket))?void 0:c.readyState)!==c.OPEN)return[3,8];e.label=5;case 5:return e.trys.push([5,7,,8]),[4,this.sendDataToOneWithRetry(c,a.messageId,s,h,b)];case 6:return e.sent(),[3,8];case 7:return e.sent(),[3,8];case 8:return o=r.next(),[3,4];case 9:return[3,12];case 10:return u=e.sent(),g={error:u},[3,12];case 11:try{o&&!o.done&&(d=r.return)&&d.call(r)}finally{if(g)throw g.error}return[7];case 12:return[3,15];case 13:return[4,this.sendDataToAllWithRetry(s,h,b)];case 14:e.sent(),e.label=15;case 15:return i=n.next(),[3,2];case 16:return[3,19];case 17:return u=e.sent(),l={error:u},[3,19];case 18:try{i&&!i.done&&(_=n.return)&&_.call(n)}finally{if(l)throw l.error}return[7];case 19:return[2]}})})},SubscriptionManager.prototype.delay=function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,new Promise(function(e){return setTimeout(e,t)})]})})},SubscriptionManager.prototype.sendDataToAllWithRetry=function(t,n,i){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:t.running=!0,e.label=1;case 1:return this._enableDebug&&console.log(new Date,"Running sendDataToAll Sub",t.publication),t.runAgain=!1,[4,this.sendDataToAll(t,n,i)];case 2:return(e.sent(),this._enableDebug&&console.log(new Date,"Done sendDataToAll Sub",t.publication,t.runAgain),t.runAgain)?[4,this.delay(500)]:[3,4];case 3:e.sent(),e.label=4;case 4:if(t.runAgain)return[3,1];e.label=5;case 5:return t.running=!1,[2]}})})},SubscriptionManager.prototype.sendDataToOneWithRetry=function(t,n,i,s,r){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:i.running=!0,e.label=1;case 1:return this._enableDebug&&console.log(new Date,"Running sendDataToOne Sub",i.publication),i.runAgain=!1,[4,this.sendDataToOne(t,n,i,s,r)];case 2:return(e.sent(),this._enableDebug&&console.log(new Date,"Done sendDataToOne Sub",i.publication,i.runAgain),i.runAgain)?[4,this.delay(500)]:[3,4];case 3:e.sent(),e.label=4;case 4:if(i.runAgain)return[3,1];e.label=5;case 5:return i.running=!1,[2]}})})},SubscriptionManager.prototype.publications=function(e){this._publications=Object.assign(this._publications,e)},SubscriptionManager.prototype.loggedInLatency=function(t){var e,n,i,s=this._loggedInUsers.find(function(e){return e.id_ws===t.id_socket});s&&(e=new Date,n=this.latencyBuffer.get(t.id_socket),i=t.latency,!n||e.getTime()-n.lastUpdate.getTime()>=this.LATENCY_UPDATE_THRESHOLD_MS||100<Math.abs(i-n.latency))&&(s.date=e,this.latencyBuffer.set(t.id_socket,{latency:i,lastUpdate:e}))},SubscriptionManager.prototype.flushThrottledLatencyUpdates=function(){return __awaiter(this,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:if(0===this.latencyBuffer.size)return[2];t=Array.from(this.latencyBuffer.entries()).map(function(e){var e=__read(e,2),t=e[0],e=e[1];return{updateOne:{filter:{id_ws:t},update:{$set:{latency:e.latency,date:e.lastUpdate}}}}}),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,logged_in_users_collection_1.LoggedInUsers.bulkWrite(t)];case 2:return e.sent(),this.latencyBuffer.clear(),this.getEnableDebug()&&console.log(new Date,"Sub Manager","Throttled latency batch update successful",t.length),[3,4];case 3:return n=e.sent(),console.error(new Date,"Sub Manager","Throttled latency batch update failed",n),[3,4];case 4:return[2]}})})},SubscriptionManager.prototype.subscribe=function(u,e,l,_,g,d){return __awaiter(this,void 0,void 0,function(){var t,n,i,s,r,o,a,c=this;return __generator(this,function(e){switch(e.label){case 0:return(this._debugSubHits+=1,this._debugSubCollections.some(function(e){return e.publication===g})?this._debugSubCollections.find(function(e){return e.publication===g}).hits+=1:this._debugSubCollections.push({publication:g,hits:1}),t=this._publications[g])?[3,1]:(console.error(new Date,"No Publication: "+g),[2]);case 1:if(1<d.length||d[0]){if(!t.check)return console.error(new Date,"No Check Function For Pub "+g),[2];if(!t.check._schema)return console.error(new Date,"No Check Schema For Pub "+g),[2];for(n={},r=Object.keys(t.check._schema),i=r.filter(function(e){return!e.includes(".")}),s=0;s<d.length;s++)n[i[s]]=d[s];try{t.check.validate(n)}catch(e){if(e)return console.error(new Date,"Error in Pub Check ("+g+")",e),[2]}}return"Bypass"!==u&&(r=u.split("/"),o="",a=r[0],""===r[0]&&(o="/",a=r[1]),o+=a,1<r.length&&(o+="/"),(a=this._subscriptions.filter(function(e){return e.clients.some(function(e){return e.id_socket===l.id_socket&&"Bypass"!==e.messageRoute&&"/"!==e.messageRoute&&e.messageRoute!==u&&!e.messageRoute.startsWith(o)})})).length)&&a.forEach(function(t){t.clients.filter(function(e){return e.id_socket===l.id_socket}).forEach(function(e){c.unsubscribe(e.messageRoute,new Date,l,e.messageId,t.publication,t.subscriptionData)})}),(a=this._subscriptions.find(function(e){return e.publication===g&&JSON.stringify(e.subscriptionData)===JSON.stringify(d)}))?a.clients.some(function(e){return e.id_socket===l.id_socket&&e.messageId===_})||a.clients.push({id_user:l.id_user,messageId:_,id_socket:l.id_socket,messageRoute:u}):this._subscriptions.push({publication:g,subscriptionData:d,collections:this.getPublicationCollections(g),clients:[{id_user:l.id_user,messageId:_,id_socket:l.id_socket,messageRoute:u}],cacheId:0,running:!1,runAgain:!1}),a=a||this._subscriptions.find(function(e){return e.publication===g&&JSON.stringify(e.subscriptionData)===JSON.stringify(d)}),this._enableDebug&&console.log(new Date,"New Sub",a.publication,a.running,a.runAgain,a.clients.length),[4,this.processSubscription(a,l,_)];case 2:e.sent(),e.label=3;case 3:return[2]}})})},SubscriptionManager.prototype.createLoggedInUser=function(i){return __awaiter(this,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:return(t=this._websocketManager.getWebSocket(i))?(n={_id:(0,common_1.objectIdHexString)(),__v:0,date:new Date,id_user:t.id_user,user:t.user,id_ws:t.id_socket},this._loggedInUsers.push(n),[4,logged_in_users_collection_1.LoggedInUsers.insertOne(n)]):[3,2];case 1:return e.sent(),[2,n];case 2:throw new Error("Error in Create Logged In User: No WS")}})})},SubscriptionManager.prototype.unsubscribe=function(e,t,n,i,s,r){if(this._debugUnSubHits+=1,this._publications[s]){var o=this._subscriptions.find(function(e){return e.publication===s&&JSON.stringify(e.subscriptionData)===JSON.stringify(r)});if(o){for(var a=o.clients.length-1;0<=a;a--)o.clients[a].id_user===n.id_user&&o.clients[a].messageId===i&&o.clients[a].id_socket===n.id_socket&&o.clients.splice(a,1);this._enableDebug&&console.log(new Date,"Unsub",o.publication,o.running,o.runAgain,o.clients.length)}}else console.log("No Publication: "+s)},SubscriptionManager.prototype.unsubscribeAll=function(r){return __awaiter(this,void 0,void 0,function(){var t,n,i,s;return __generator(this,function(e){switch(e.label){case 0:return(this._debugUnSubAllHits+=1,r)?r.isUnsubscribed?[2]:(r.isUnsubscribed=!0,0<=this._loggedInUsers.map(function(e){return e.id_ws}).indexOf(r.id_socket)&&this._loggedInUsers.splice(this._loggedInUsers.map(function(e){return e.id_ws}).indexOf(r.id_socket),1),[4,logged_in_users_collection_1.LoggedInUsers.deleteOne({id_ws:r.id_socket})]):[3,2];case 1:for(e.sent(),t=this._subscriptions.filter(function(e){return e.clients.some(function(e){return e.id_user===r.id_user&&e.id_socket===r.id_socket})}),n=t.length-1;0<=n;n--)for(i=t[n],s=i.clients.length-1;0<=s;s--)i.clients[s].id_socket===r.id_socket&&i.clients.splice(s,1);this._websocketManager.removeWebSocket(r),e.label=2;case 2:return[2]}})})},SubscriptionManager.prototype.getActiveSubscriptions=function(){return this._subscriptions},SubscriptionManager.prototype.getPublicationCollections=function(e){return this._publications[e].collections},SubscriptionManager.prototype.tailOpLog=function(i){return __awaiter(this,void 0,void 0,function(){var t,s,n=this;return __generator(this,function(e){switch(e.label){case 0:return!this._oplog$||this._oplog$.closed?[3,2]:(this._oplog$.removeAllListeners(),[4,this._oplog$.close()]);case 1:e.sent(),this._oplog$=null,e.label=2;case 2:return[4,new Promise(function(e){return setTimeout(e,1e3)})];case 3:if(e.sent(),this._oplog$&&!this._oplog$.closed)return[3,12];if(this._oplogRetryCount+=1,5<this._oplogRetryCount&&(console.error("****************** TAIL OPLOG ERROR, RETRYING A BUNCH OF TIMES, KILLING PROCESS **************************"),process.exit(1)),t=[{$match:{$and:[{"ns.coll":{$nin:["log-method-latencies","log-subscriptions","logs","counters","cron-job-histories","email-histories","qb-soap-request-histories","qb-soap-request-responses","qb-soap-requests","qb-soap-retries"]}},{"ns.coll":{$not:/.*\.versions$/}},{"ns.coll":{$not:/^monitor-/}}]}}],!i)return[3,10];s=i,e.label=4;case 4:return e.trys.push([4,5,,9]),this._oplog$=resolveio_server_app_1.ResolveIOServer.getMainDB().watch(t,{resumeAfter:i}),[3,9];case 5:return(e.sent(),this._oplog$)?(this._oplog$.removeAllListeners(),[4,this._oplog$.close()]):[3,7];case 6:e.sent(),this._oplog$=null,e.label=7;case 7:return[4,this.tailOpLog(i)];case 8:return e.sent(),[2];case 9:return[3,11];case 10:this._oplog$=resolveio_server_app_1.ResolveIOServer.getMainDB().watch(t),e.label=11;case 11:console.log(new Date,"oplog started"),this._oplog$.on("change",function(i){return __awaiter(n,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:return i.ns?(this._enableDebug&&console.log(new Date,"Oplog Hit",i.ns),t=i.ns.coll,this._debugOplogCollections.some(function(e){return e.collection===i.ns.coll&&e.type===i.operationType})?this._debugOplogCollections.find(function(e){return e.collection===i.ns.coll&&e.type===i.operationType}).hits+=1:this._debugOplogCollections.push({collection:i.ns.coll,type:i.operationType,hits:1}),t?(this._debugOplogHits+=1,"insert"!==i.operationType?[3,5]:"support-tickets"!==t||"https://resolveio.com"!==this.serverConfig.ROOT_URL?[3,2]:(resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().callMethod.call(resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager(),"sendSupportTicketEmail",i.documentKey._id),[4,this.invalidatePubsCache(t,"insert")])):[3,10]):[3,13];case 1:e.sent(),e.label=2;case 2:return"method-responses"===t?[3,4]:[4,this.invalidatePubsCache(t,"insert")];case 3:e.sent(),e.label=4;case 4:return[3,10];case 5:return"update"!==i.operationType&&"replace"!==i.operationType?[3,8]:"method-responses"===t?[3,7]:[4,this.invalidatePubsCache(t,"update")];case 6:e.sent(),e.label=7;case 7:return[3,10];case 8:return"delete"!==i.operationType?[3,10]:"method-responses"===t?[3,10]:[4,this.invalidatePubsCache(t,"delete")];case 9:e.sent(),e.label=10;case 10:return"flags"!==t?[3,12]:[4,flag_collection_1.Flags.findOne({type:"Enable Debug"})];case 11:(n=e.sent())&&n.value?this._enableDebug=!0:this._enableDebug=!1,e.label=12;case 12:s=i._id,process.env.NODE_APP_INSTANCE&&"0"!==process.env.NODE_APP_INSTANCE||"false"!==process.env.IS_WORKERS_ENABLED&&"true"===process.env.IS_WORKER_INSTANCE&&process.env.WORKER_INDEX,e.label=13;case 13:return[2]}})})}),this._oplog$.on("error",function(t){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return console.log(new Date,"oplog error",t),[4,this._oplog$.close()];case 1:return e.sent(),[2]}})})}),this._oplog$.on("end",function(){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return console.log(new Date,"oplog end"),[4,this._oplog$.close()];case 1:return e.sent(),[2]}})})}),this._oplog$.on("close",function(){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return console.log(new Date,"oplog close"),this._oplog$.removeAllListeners(),this._oplog$=null,[4,this.tailOpLog(s)];case 1:return e.sent(),[2]}})})}),e.label=12;case 12:return[2]}})})},SubscriptionManager.prototype.processSubscription=function(n,i,s){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:if(this._publications[n.publication].user_specific)return[3,8];if(!n.cacheId)return[3,5];e.label=1;case 1:return e.trys.push([1,2,,4]),t=JSON.parse(this._nodeCache.get(n.cacheId),common_1.dateReviver),t={messageId:s,hasError:!1,data:t},this._enableDebug&&console.log(new Date,"Process Sub, Cache",n.publication),this.sendWS(i,t),[3,4];case 2:return e.sent(),this._nodeCache.del(n.cacheId),n.cacheId=0,[4,this.sendDataToAllWithRetry(n,"","newSub")];case 3:return e.sent(),[3,4];case 4:return[3,7];case 5:return this._enableDebug&&console.log(new Date,"Process Sub, Non - Cache",n.publication,n.running),n.running?[2]:[4,this.sendDataToAllWithRetry(n,"","newSub")];case 6:e.sent(),e.label=7;case 7:return[3,10];case 8:return this._enableDebug&&console.log(new Date,"Process Sub Specific, Non - Cache",n.publication,n.running),n.running?[2]:[4,this.sendDataToOneWithRetry(i,s,n,"","newSub")];case 9:e.sent(),e.label=10;case 10:return[2]}})})},SubscriptionManager.prototype.sendDataToOne=function(r,o,a,c,u){return __awaiter(this,void 0,void 0,function(){var t,n,i,s;return __generator(this,function(e){switch(e.label){case 0:t=this._monitorManagerFunction.startMonitorFunction("User Specific Publication",a.publication,"","",a.subscriptionData),e.label=1;case 1:return e.trys.push([1,3,5,7]),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().callMethod.call(resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager(),"insertSubscriptionLog",u,a.publication,c,JSON.stringify(a.subscriptionData)),[4,(s=this._publications[a.publication].function).call.apply(s,__spreadArray([Object.assign({},this,SubscriptionManager.prototype),r.id_user],__read(a.subscriptionData),!1))];case 2:return s=e.sent(),i={messageId:o,hasError:!1,data:s},this.sendWS(r,i),[3,7];case 3:return n=e.sent(),i={messageId:o,hasError:!0,data:n},this.sendWS(r,i),[4,resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com","SERVER - Error Detected - "+this.serverConfig.CLIENT_NAME,"Error Detected During Subscription "+a.publication+" - (sendDataToOne - WS)\n\nData \n"+JSON.stringify(a.subscriptionData,null,2)+"\n\nErrors\n"+JSON.stringify(n,null,2))];case 4:return e.sent(),[3,7];case 5:return[4,this._monitorManagerFunction.finishMonitorFunction(t)];case 6:return e.sent(),[7];case 7:return[2]}})})},SubscriptionManager.prototype.sendDataToAll=function(O,C,E){return __awaiter(this,void 0,void 0,function(){var t,n,i,s,r,o,a,c,u,l,_,g,d,h,b,p,f,v,S,y,m,w,D,M,I=this;return __generator(this,function(e){switch(e.label){case 0:return O.clients.length?[3,1]:(O.cacheId&&(this._nodeCache.del(O.cacheId),O.cacheId=0),0<=(v=this._subscriptions.findIndex(function(e){return e.publication===O.publication&&JSON.stringify(e.subscriptionData)===JSON.stringify(O.subscriptionData)}))&&this._subscriptions.splice(v,1),[2]);case 1:t=this._monitorManagerFunction.startMonitorFunction("Publication",O.publication,"","",O.subscriptionData),e.label=2;case 2:return e.trys.push([2,4,6,8]),"superadminAPM"!==O.publication&&"loggedInUsers"!==O.publication&&resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().callMethod.call(resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager(),"insertSubscriptionLog",E,O.publication,C,JSON.stringify(O.subscriptionData)),[4,(v=this._publications[O.publication].function).call.apply(v,__spreadArray([Object.assign({},this,SubscriptionManager.prototype)],__read(O.subscriptionData),!1))];case 3:if(n=e.sent(),O.cacheId)try{if(i=JSON.parse(this._nodeCache.get(O.cacheId),common_1.dateReviver),JSON.stringify(i)!==JSON.stringify(n)){try{for(s=__values(O.clients),r=s.next();!r.done;r=s.next())b=r.value,(p=this._websocketManager.getWebSocket(b.id_socket))&&p.readyState===p.OPEN&&(f={messageId:b.messageId,hasError:!1,data:n},this.sendWS(p,f))}catch(e){S={error:e}}finally{try{r&&!r.done&&(y=s.return)&&y.call(s)}finally{if(S)throw S.error}}this._nodeCache.del(O.cacheId),(0,common_1.getBinarySize)(JSON.stringify(n))<1e6&&!O.collections.includes("logs")&&!O.collections.find(function(e){return e.endsWith(".versions")})&&!O.collections.find(function(e){return e.startsWith("monitor-")})?this._nodeCache.set(O.cacheId,JSON.stringify(n)):O.cacheId=0}}catch(e){O.clients.map(function(e){var t=I._websocketManager.getWebSocket(e.id_socket);t&&t.readyState===t.OPEN&&(e={messageId:e.messageId,hasError:!1,data:n},I.sendWS(t,e))}),this._nodeCache.del(O.cacheId),(0,common_1.getBinarySize)(JSON.stringify(n))<1e6&&!O.collections.includes("logs")&&!O.collections.find(function(e){return e.endsWith(".versions")})&&!O.collections.find(function(e){return e.startsWith("monitor-")})?this._nodeCache.set(O.cacheId,JSON.stringify(n)):O.cacheId=0}else{try{for(o=__values(O.clients),a=o.next();!a.done;a=o.next())b=a.value,(p=this._websocketManager.getWebSocket(b.id_socket))&&p.readyState===p.OPEN&&(f={messageId:b.messageId,hasError:!1,data:n},this.sendWS(p,f))}catch(e){m={error:e}}finally{try{a&&!a.done&&(w=o.return)&&w.call(o)}finally{if(m)throw m.error}}if((0,common_1.getBinarySize)(JSON.stringify(n))<1e6&&!O.collections.includes("logs")&&!O.collections.find(function(e){return e.endsWith(".versions")})&&!O.collections.find(function(e){return e.startsWith("monitor-")})){if(O.cacheId=this._cacheId++,this._nodeCache.set(O.cacheId,JSON.stringify(n)),(c=this._nodeCache.getStats().vsize)>this._heapLimit){for(u=0,l=this._subscriptions.filter(function(e){return e.cacheId&&!e.clients.length}),_=0;_<l.length&&(this._debugRemoveCacheHits+=1,this._nodeCache.del(l[_].cacheId),l[_].cacheId=0,u+=1,!(this._nodeCache.getStats().vsize<.75*this._heapLimit));_++);this._enableDebug&&console.log("Sub Cache: Too Big - "+O.publication+" - Deleted: "+u+" - "+c)}}else O.cacheId=0}return[3,8];case 4:g=e.sent();try{for(d=__values(O.clients),h=d.next();!h.done;h=d.next())b=h.value,(p=this._websocketManager.getWebSocket(b.id_socket))&&p.readyState===p.OPEN&&(f={messageId:b.messageId,hasError:!0,data:g},this.sendWS(p,f))}catch(e){D={error:e}}finally{try{h&&!h.done&&(M=d.return)&&M.call(d)}finally{if(D)throw D.error}}return[4,resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com","SERVER - Error Detected - "+this.serverConfig.CLIENT_NAME,"Error Detected During Subscription "+O.publication+" - (sendPubData)\n\nData \n"+JSON.stringify(O.subscriptionData,null,2)+"\n\nErrors\n"+JSON.stringify(g,null,2))];case 5:return e.sent(),[3,8];case 6:return[4,this._monitorManagerFunction.finishMonitorFunction(t)];case 7:return e.sent(),[7];case 8:return[2]}})})},SubscriptionManager.prototype.sendWS=function(e,t){this._websocketManager.send(e,t)},SubscriptionManager.prototype.getEnableDebug=function(){return this._enableDebug},SubscriptionManager}();exports.SubscriptionManager=SubscriptionManager;
|
|
2
2
|
//# sourceMappingURL=subscription.manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/subscription.manager.ts"],"names":["logged_in_users_collection_1","require","app_status_1","cron_jobs_1","files_1","flags_1","logs_1","method_responses_1","notifications_1","report_builder_reports_1","super_admin_1","resolveio_server_app_1","NodeCache","os_1","flag_collection_1","flags_update_1","report_builder_dashboard_builders_1","report_builder_libraries_1","user_groups_1","user_guides_1","common_1","numCPUs","cpus","length","v8","SubscriptionManager","this","_publications","_subscriptions","_loggedInUsers","_mongoQueue","_mongoQueueId","_cacheId","_heapSize","getHeapStatistics","_enableDebug","_debugOplogCollections","_debugOplogHits","_debugSubCollections","_debugSubHits","_debugUnSubHits","_debugUnSubAllHits","_debugMongoQueueHits","_debugMongoQueueCollections","_debugSendQueueHits","_debugRemoveCacheHits","_oplogRetryCount","latencyBuffer","Map","LATENCY_UPDATE_INTERVAL","LATENCY_UPDATE_THRESHOLD_MS","_invalidationDebounceTimers","_invalidationPendingTimestamps","DEBOUNCE_DELAY","MAX_WAIT_TIME","create","wss","serverConfig","monitorManagerFunction","_this","subscriptionManager","setImmediate","__awaiter","initialize","_a","sent","prototype","_websocketManager","ResolveIOServer","getMainServer","getWebSocketManager","_monitorManagerFunction","_nodeCache","stdTTL","checkperiod","setInterval","flushThrottledLatencyUpdates","_wss","loadSuperAdminPublications","loadAppStatusPublications","loadLogPublications","loadFilePublications","loadCronJobPublications","loadFlagsUpdatePublications","loadFlagsPublications","loadMethodResponsePublications","loadNotificationPublications","loadReportBuilderReportPublications","loadReportBuilderLibraryPublications","loadUserGroupPublications","loadUserGuidePublications","loadReportBuilderDashboardBuilderPublications","tailOpLog","getEnableDebug","console","log","Date","JSON","stringify","sort","a","b","collection","localeCompare","publication","type","LoggedInUsers","find","_b","userCopy","deepCopy","i","loggedInUser","date","now","getTime","this_1","getWebSocket","id_ws","unsubscribeAll","_c","forEach","sub","j","clients","id_socket","splice","deleteOne","_id","findIndex","client","this_2","some","Flags","findOne","flag","value","setCacheLimit","process","env","IS_WORKERS_ENABLED","_heapLimit","invalidatePubsCache","debounceKey","firstInvalidationTime","get","set","has","clearTimeout","delete","_executeInvalidation","setTimeout","getMongoManager","invalidateQueryCache","collSubs","filter","collections","includes","collSubs_1","__values","collSubs_1_1","next","running","runAgain","user_specific","e_1","ws","readyState","OPEN","sendDataToOneWithRetry","messageId","_f","sendDataToAllWithRetry","delay","ms","Promise","resolve","sendDataToAll","sendDataToOne","publications","method","Object","assign","loggedInLatency","existingEntry","newLatency","lastUpdate","Math","abs","latency","size","updates","Array","from","entries","map","__read","updateOne","update","$set","bulkWrite","clear","error","error_1","subscribe","messageRoute","messageDate","subscriptionData","hits","push","pub","check","_schema","valObj","valKeys","keys","rootKeys","validate","errors","urlData","split","urlModule_1","urlNext","otherRouteSubs","startsWith","otherSub","unsubscribe","id_user","getPublicationCollections","cacheId","processSubscription","createLoggedInUser","user","objectIdHexString","__v","insertOne","Error","indexOf","userSubs","removeWebSocket","getActiveSubscriptions","resumeToken","_oplog$","closed","removeAllListeners","close","exit","pipeline","$match","$and","ns.coll","$nin","$not","lastResumeToken_1","getMainDB","watch","resumeAfter","on","doc","ns","coll","operationType","getMethodManager","callMethod","call","documentKey","NODE_APP_INSTANCE","IS_WORKER_INSTANCE","WORKER_INDEX","cacheData","parse","dateReviver","serverRes","hasError","data","sendWS","del","monitor","startMonitorFunction","function","apply","__spreadArray","res","err_1","sendEmail","finishMonitorFunction","subIndex","_g","res_1","_l","done","getBinarySize","endsWith","_m","_d","nodeCacheSize","getStats","vsize","deleteCount","subArr","zz","_e","err_2","send","exports"],"mappings":"+xEACAA,8B,0FAAAC,QAAA,2CAAA,GAIAC,aAAAD,QAAA,4BAAA,EACAE,YAAAF,QAAA,2BAAA,EACAG,QAAAH,QAAA,uBAAA,EACAI,QAAAJ,QAAA,uBAAA,EACAK,OAAAL,QAAA,sBAAA,EACAM,mBAAAN,QAAA,kCAAA,EACAO,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hO,KAAA,E,aAGA,MAAA,CAAA,EAAMvC,KAAK6C,wBAAwBsN,sBAAsBR,CAAO,G,cAAhEY,EAAAhO,KAAA,E,2BAKKxC,oBAAAyC,UAAAiN,OAAR,SAAe7G,EAAe4G,GAC7BxP,KAAKyC,kBAAkB4O,KAAKzI,EAAI4G,CAAI,CACrC,EAEOzP,oBAAAyC,UAAA2B,eAAP,WACC,OAAOnE,KAAKS,YACb,EACDV,mBAAA,EAAC,EAj/BYuR,QAAAvR,oBAAAA","file":"subscription.manager.js","sourcesContent":["import * as WebSocket from 'ws';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { LoggedInUserModel } from '../models/logged-in-users.model';\nimport { ServerResponseModel } from '../models/server-response.model';\nimport { ActiveSubscriptionModel, SubscriptionModel } from '../models/subscription.model';\nimport { loadAppStatusPublications } from '../publications/app-status';\nimport { loadCronJobPublications } from '../publications/cron-jobs';\nimport { loadFilePublications } from '../publications/files';\nimport { loadFlagsPublications } from '../publications/flags';\nimport { loadLogPublications } from '../publications/logs';\nimport { loadMethodResponsePublications } from '../publications/method-responses';\nimport { loadNotificationPublications } from '../publications/notifications';\nimport { loadReportBuilderReportPublications } from '../publications/report-builder-reports';\nimport { loadSuperAdminPublications } from '../publications/super-admin';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nimport { ChangeStream, ChangeStreamDeleteDocument, ChangeStreamInsertDocument, ChangeStreamReplaceDocument, ChangeStreamUpdateDocument, ResumeToken } from 'mongodb';\nimport * as NodeCache from 'node-cache';\nimport { cpus } from 'os';\nimport { Flags } from '../collections/flag.collection';\nimport { loadFlagsUpdatePublications } from '../publications/flags-update';\nimport { loadReportBuilderDashboardBuilderPublications } from '../publications/report-builder-dashboard-builders';\nimport { loadReportBuilderLibraryPublications } from '../publications/report-builder-libraries';\nimport { loadUserGroupPublications } from '../publications/user-groups';\nimport { loadUserGuidePublications } from '../publications/user-guides';\nimport { dateReviver, deepCopy, getBinarySize, objectIdHexString } from '../util/common';\nimport { MonitorManagerFunction } from './monitor.manager';\nimport { WebSocketManager } from './websocket.manager';\nconst numCPUs = cpus().length;\nconst v8 = require('v8');\n\n// Performance Dependencies\n// import * as path from 'path';\n// import { Worker } from 'worker_threads';\n\ninterface MongoQueueModel {\n\t_id: number,\n\ttype: string;\n\tcollection: string;\n\tsubscription: ActiveSubscriptionModel;\n\trunning: boolean;\n\trun_again: boolean;\n}\n\n// interface CurrentPerformanceMonitor {\n// \t_id: number;\n// \tfunction: string;\n// \tpublication: string;\n// \tsubscriptionData: any[];\n// \tdate_start: Date;\n// \tdate_end: Date;\n// \tduration: number;\n// \tresult: string;\n// }\n\nexport class SubscriptionManager {\n\tprivate _websocketManager: WebSocketManager;\n\tprivate _publications: SubscriptionModel = {};\n\tprivate _subscriptions: ActiveSubscriptionModel[] = [];\n\tprivate _wss: WebSocket.Server;\n\tprivate _loggedInUsers: LoggedInUserModel[] = [];\n\n\tprivate _mongoQueue: MongoQueueModel[] = [];\n\tprivate _mongoQueueId = 0;\n\t\n\tprivate _oplog$: ChangeStream;\n\n\tprivate _nodeCache;\n\tprivate _cacheId = 1;\n\n\tprivate _heapSize = v8.getHeapStatistics() / numCPUs;\n\tprivate _heapLimit: number;\n\n\tprivate serverConfig;\n\n\tprivate _monitorManagerFunction: MonitorManagerFunction;\n\n\tprivate _enableDebug = false;\n\tprivate _debugOplogCollections = [];\n\tprivate _debugOplogHits = 0;\n\tprivate _debugSubCollections = [];\n\tprivate _debugSubHits = 0;\n\tprivate _debugUnSubHits = 0;\n\tprivate _debugUnSubAllHits = 0;\n\tprivate _debugMongoQueueHits = 0;\n\tprivate _debugMongoQueueCollections = [];\n\tprivate _debugSendQueueHits = 0;\n\tprivate _debugRemoveCacheHits = 0;\n\n\tprivate _oplogRetryCount = 0;\n\n\t// Buffer to store throttled latency updates with timestamps\n\tprivate latencyBuffer = new Map<string, { latency: number, lastUpdate: Date }>();\n\n\t// Interval to flush latency updates in MongoDB\n\tprivate readonly LATENCY_UPDATE_INTERVAL = 60000;\n\n\t// Minimum time difference between two latency updates for the same user\n\tprivate readonly LATENCY_UPDATE_THRESHOLD_MS = 30000;\n\n\t// private currentPerfomanceMonitor: CurrentPerformanceMonitor[] = [];\n\t// private idPerformance: number = 0;\n\t// private performanceThread;\n\n\tprivate _invalidationDebounceTimers = new Map<string, NodeJS.Timeout>();\n\tprivate _invalidationPendingTimestamps = new Map<string, number>();\n\tprivate readonly DEBOUNCE_DELAY = 100; // 100ms debounce window\n\tprivate readonly MAX_WAIT_TIME = 500; // 500ms maximum delay\n\n\n\tconstructor() {}\n\t\n\tstatic create(wss: WebSocket.Server, serverConfig, monitorManagerFunction: MonitorManagerFunction) {\n\t\tconst subscriptionManager = new SubscriptionManager();\n\t\tsetImmediate(async () => {\n\t\t\tawait subscriptionManager.initialize(wss, serverConfig, monitorManagerFunction);\n\t\t});\n\t\treturn subscriptionManager;\n\t}\n\t\n\tprivate async initialize(wss: WebSocket.Server, serverConfig, monitorManagerFunction: MonitorManagerFunction) {\n\t\tthis._websocketManager = ResolveIOServer.getMainServer().getWebSocketManager();\n\t\tthis._monitorManagerFunction = monitorManagerFunction;\n\n\t\tthis._nodeCache = new NodeCache( { stdTTL: 0, checkperiod: 0 } );\n\n\t\tsetInterval(() => this.flushThrottledLatencyUpdates(), this.LATENCY_UPDATE_INTERVAL);\n\n\t\t// setTimeout(() => {\n\t\t// \tconsole.log('Setting up performance thread');\n\n\t\t// \tthis.performanceThread = new Worker(path.join(__dirname, './subscription.performance.js'));\n\n\t\t// \tthis.performanceThread.on('exit', code => {\n\t\t// \t\tconsole.error(new Date(), 'THREAD EXITED!!!!!!!!!!!!!!!!!!', code);\n\t\t// \t});\n\n\t\t// \tthis.performanceThread.on('error', code => {\n\t\t// \t\tconsole.error(new Date(), 'THREAD RECV ERROR !!!!!!!!!!!!!!!!!!', code);\n\t\t// \t});\n\t\t// }, 5000);\n\n\t\t// setInterval(() => {\n\t\t// \tconsole.log('Post thread msg');\n\t\t// \tthis.performanceThread.postMessage(this.currentPerfomanceMonitor);\n\t\t// \tthis.currentPerfomanceMonitor = [];\n\t\t// }, 10000);\n\n\t\tthis.serverConfig = serverConfig;\n\t\tthis._wss = wss;\n\n\t\t// Publications\n\t\tloadSuperAdminPublications(this);\n\t\tloadAppStatusPublications(this);\n\t\tloadLogPublications(this);\n\t\tloadFilePublications(this);\n\t\tloadCronJobPublications(this);\n\t\tloadFlagsUpdatePublications(this);\n\t\tloadFlagsPublications(this);\n\t\tloadMethodResponsePublications(this);\n\t\tloadNotificationPublications(this);\n\t\tloadReportBuilderReportPublications(this);\n\t\tloadReportBuilderLibraryPublications(this);\n\t\tloadUserGroupPublications(this);\n\t\tloadUserGuidePublications(this);\n\t\tloadReportBuilderDashboardBuilderPublications(this);\n\n\t\tawait this.tailOpLog();\n\n\t\tsetInterval(() => {\n\t\t\tthis._oplogRetryCount = 0;\n\t\t}, 15000);\n\n\t\tsetInterval(() => {\n\t\t\tif (this.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Subs', this._subscriptions.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Logged In Users', this._loggedInUsers.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue', this._mongoQueue.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue Hits', this._debugMongoQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue Collections', JSON.stringify(this._debugMongoQueueCollections.sort((a, b) => a.collection.localeCompare(b.collection) || a.publication.localeCompare(b.publication)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Oplog Hits', this._debugOplogHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Oplog Collections', JSON.stringify(this._debugOplogCollections.sort((a, b) => a.collection.localeCompare(b.collection) || a.type.localeCompare(b.type)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Send Queue Hits', this._debugSendQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Sub Hits', this._debugSubHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Sub Collections', JSON.stringify(this._debugSubCollections.sort((a, b) => a.publication.localeCompare(b.publication)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub Hits', this._debugUnSubHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub All Hits', this._debugUnSubAllHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Cache Cleanup Hits', this._debugRemoveCacheHits);\n\t\t\t}\n\t\t\t\n\t\t\tthis._debugOplogHits = 0;\n\t\t\tthis._debugOplogCollections = [];\n\t\t\tthis._debugSubCollections = [];\n\t\t\tthis._debugMongoQueueHits = 0;\n\t\t\tthis._debugMongoQueueCollections = [];\n\t\t\tthis._debugSendQueueHits = 0;\n\t\t\tthis._debugSubHits = 0;\n\t\t\tthis._debugUnSubHits = 0;\n\t\t\tthis._debugUnSubAllHits = 0;\n\t\t\tthis._debugRemoveCacheHits = 0;\n\t\t}, 60000);\n\n\t\tsetInterval(async () => {\n\t\t\tthis._loggedInUsers = await LoggedInUsers.find();\n\t\n\t\t\tlet userCopy = deepCopy(this._loggedInUsers);\n\t\t\tfor (let i = this._loggedInUsers.length - 1; i >= 0; i--) {\n\t\t\t\tlet loggedInUser = userCopy[i];\n\n\t\t\t\tif (!loggedInUser.date || Date.now() - loggedInUser.date.getTime() > 120000) {\n\t\t\t\t\tif (this._websocketManager.getWebSocket(loggedInUser.id_ws)) {\n\t\t\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', this._websocketManager.getWebSocket(loggedInUser.id_ws)['user'], this._websocketManager.getWebSocket(loggedInUser.id_ws)['id_socket'], 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait this.unsubscribeAll(this._websocketManager.getWebSocket(loggedInUser.id_ws));\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._subscriptions.forEach(sub => {\n\t\t\t\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\t\t\t\tif (client.id_socket === loggedInUser.id_ws) {\n\t\t\t\t\t\t\t\t\tsub.clients.splice(j, 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\n\t\t\t\t\t\tawait LoggedInUsers.deleteOne({_id: loggedInUser._id});\n\n\t\t\t\t\t\tif (this._loggedInUsers.findIndex(a => a._id === loggedInUser._id) >= 0) {\n\t\t\t\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.findIndex(a => a._id === loggedInUser._id), 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < this._subscriptions.length; i++) {\n\t\t\t\tlet sub = this._subscriptions[i];\n\n\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\tif (!this._loggedInUsers.some(a => a.id_ws === client.id_socket)) {\n\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, 30000);\n\n\t\tlet flag = await Flags.findOne({type: 'Enable Debug'});\n\n\t\tif (flag && flag.value) {\n\t\t\tthis._enableDebug = true;\n\t\t}\n\t\telse {\n\t\t\tthis._enableDebug = false;\n\t\t}\n\n\t\tthis.setCacheLimit();\n\t}\n\n\tprivate setCacheLimit() {\t\n\t\tif (process.env.IS_WORKERS_ENABLED === 'true') {\n\t\t\tthis._heapLimit = this._heapSize * 0.4;\n\t\t}\n\t\telse {\n\t\t\tthis._heapLimit = this._heapSize * 0.3; // Use 50% of total heap size\n\t\t}\n\t}\n\n\tpublic async invalidatePubsCache(collection: string, type: string) {\n\t\tconst debounceKey = collection;\n\t\tconst now = Date.now();\n\t\n\t\t// Initialize or get existing timestamp\n\t\tconst firstInvalidationTime = this._invalidationPendingTimestamps.get(debounceKey) || now;\n\t\tthis._invalidationPendingTimestamps.set(debounceKey, firstInvalidationTime);\n\t\n\t\t// Clear any existing timer\n\t\tif (this._invalidationDebounceTimers.has(debounceKey)) {\n\t\t\tclearTimeout(this._invalidationDebounceTimers.get(debounceKey));\n\t\t}\n\t\n\t\t// Check if we've waited too long\n\t\tconst waitedTooLong = (now - firstInvalidationTime) >= this.MAX_WAIT_TIME;\n\t\t\n\t\tif (waitedTooLong) {\n\t\t\t// Immediate execution path\n\t\t\tthis._invalidationPendingTimestamps.delete(debounceKey);\n\t\t\tawait this._executeInvalidation(collection, type);\n\t\t} else {\n\t\t\t// Normal debounce path\n\t\t\tthis._invalidationDebounceTimers.set(\n\t\t\t\tdebounceKey,\n\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\tthis._invalidationPendingTimestamps.delete(debounceKey);\n\t\t\t\t\tawait this._executeInvalidation(collection, type);\n\t\t\t\t}, this.DEBOUNCE_DELAY)\n\t\t\t);\n\t\t}\n\t}\n\t\n\tprivate async _executeInvalidation(collection: string, type: string) {\n\t\t// Clean up any existing timer (defensive)\n\t\tif (this._invalidationDebounceTimers.has(collection)) {\n\t\t\tclearTimeout(this._invalidationDebounceTimers.get(collection));\n\t\t\tthis._invalidationDebounceTimers.delete(collection);\n\t\t}\n\t\n\t\t// Original invalidation logic\n\t\tResolveIOServer.getMongoManager().invalidateQueryCache(collection);\n\t\n\t\tconst collSubs = this._subscriptions.filter(a => a.collections.includes(collection));\n\t\n\t\tfor (const sub of collSubs) {\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Invalidate Sub', sub.publication, sub.running, sub.runAgain);\n\t\t\t}\n\t\n\t\t\tif (sub.running) {\n\t\t\t\tsub.runAgain = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\n\t\t\tif (this._publications[sub.publication].user_specific) {\n\t\t\t\tfor (let client of sub.clients) {\n\t\t\t\t\tconst ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\tif (ws?.readyState === ws.OPEN) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait this.sendDataToOneWithRetry(ws, client.messageId, sub, collection, type);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\t// Error handling\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tawait this.sendDataToAllWithRetry(sub, collection, type);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async delay(ms: number) {\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn new Promise(resolve => setTimeout(resolve, ms));\n\t}\n\n\tprivate async sendDataToAllWithRetry(sub: ActiveSubscriptionModel, collection: string, type: string) {\n\t\tsub.running = true;\n\n\t\tdo {\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Running sendDataToAll Sub', sub.publication);\n\t\t\t}\n\n\t\t\tsub.runAgain = false;\n\t\t\tawait this.sendDataToAll(sub, collection, type);\n\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Done sendDataToAll Sub', sub.publication, sub.runAgain);\n\t\t\t}\n\n\t\t\tif (sub.runAgain) {\n\t\t\t\tawait this.delay(500); // delay, adjust as needed\n\t\t\t}\n\t\t} while (sub.runAgain);\n\n\t\tsub.running = false;\n\t}\n\n\tprivate async sendDataToOneWithRetry(ws: WebSocket, messageId: number, sub: ActiveSubscriptionModel, collection: string, type: string) {\n\t\tsub.running = true;\n\n\t\tdo {\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Running sendDataToOne Sub', sub.publication);\n\t\t\t}\n\n\t\t\tsub.runAgain = false;\n\t\t\tawait this.sendDataToOne(ws, messageId, sub, collection, type);\n\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Done sendDataToOne Sub', sub.publication, sub.runAgain);\n\t\t\t}\n\n\t\t\tif (sub.runAgain) {\n\t\t\t\tawait this.delay(500); // delay, adjust as needed\n\t\t\t}\n\t\t} while (sub.runAgain);\n\t\tsub.running = false;\n\t}\n\n\t// Add all files to publications private object\n\tpublic publications(method: SubscriptionModel) {\n\t\tthis._publications = Object.assign(this._publications, method);\n\t}\n\n\t// Throttled `loggedInLatency` method\n\tpublic loggedInLatency(ws: WebSocket) {\n\t\tlet loggedInUser = this._loggedInUsers.find(a => a.id_ws === ws['id_socket']);\n\t\tif (!loggedInUser) return;\n\n\t\tconst now = new Date();\n\t\tconst existingEntry = this.latencyBuffer.get(ws['id_socket']);\n\t\tconst newLatency = ws['latency'];\n\n\t\t// Throttle updates: only update if time threshold has passed or latency has significantly changed\n\t\tif (\n\t\t\t!existingEntry || \n\t\t\t(now.getTime() - existingEntry.lastUpdate.getTime() >= this.LATENCY_UPDATE_THRESHOLD_MS) || \n\t\t\t(Math.abs(newLatency - existingEntry.latency) > 100) // Optional: log only significant changes\n\t\t) {\n\t\t\t// Update in-memory and buffer\n\t\t\tloggedInUser.date = now;\n\t\t\tthis.latencyBuffer.set(ws['id_socket'], { latency: newLatency, lastUpdate: now });\n\t\t}\n\t}\n\n\t// Method to flush buffered latency updates in bulk\n\tprivate async flushThrottledLatencyUpdates() {\n\t\tif (this.latencyBuffer.size === 0) return; // No updates to flush\n\n\t\tconst updates = Array.from(this.latencyBuffer.entries()).map(([id_ws, { latency, lastUpdate }]) => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { id_ws },\n\t\t\t\tupdate: { $set: { latency, date: lastUpdate } }\n\t\t\t}\n\t\t}));\n\n\t\ttry {\n\t\t\tawait LoggedInUsers.bulkWrite(updates);\n\t\t\tthis.latencyBuffer.clear(); // Clear buffer after successful update\n\n\t\t\tif (this.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Throttled latency batch update successful', updates.length);\n\t\t\t}\n\t\t}\n\t\tcatch (error) {\n\t\t\tconsole.error(new Date(), 'Sub Manager', 'Throttled latency batch update failed', error);\n\t\t\t// Optional: implement retry logic or logging for failed updates\n\t\t}\n\t}\n\n\t// Subscribe to publication\n\tpublic async subscribe(messageRoute: string, messageDate: Date, ws: WebSocket, messageId: number, publication: string, subscriptionData: any[]) {\n\t\tthis._debugSubHits += 1;\n\n\t\tif (!this._debugSubCollections.some(a => a.publication === publication)) {\n\t\t\tthis._debugSubCollections.push({\n\t\t\t\tpublication: publication,\n\t\t\t\thits: 1\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tthis._debugSubCollections.find(a => a.publication === publication).hits += 1;\n\t\t}\n\n\t\tlet pub = this._publications[publication];\n\n\t\tif (!pub) {\n\t\t\tconsole.error(new Date(), 'No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tif (subscriptionData.length > 1 || subscriptionData[0]) {\n\t\t\t\tif (!pub.check) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Function For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse if (!pub.check._schema) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Schema For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(pub.check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\n\t\t\t\t\tfor (let i = 0; i < subscriptionData.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = subscriptionData[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpub.check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error(new Date(), 'Error in Pub Check (' + publication + ')', errors);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (messageRoute !== 'Bypass') {\n\t\t\t\tlet urlData = messageRoute.split('/');\n\t\t\t\tlet urlModule = '';\n\t\t\t\tlet urlNext = urlData[0];\n\n\t\t\t\tif (urlData[0] === '') {\n\t\t\t\t\turlModule = '/';\n\t\t\t\t\turlNext = urlData[1];\n\t\t\t\t}\n\n\t\t\t\turlModule += urlNext;\n\n\t\t\t\tif (urlData.length > 1) {\n\t\t\t\t\turlModule += '/';\n\t\t\t\t}\n\n\t\t\t\tlet otherRouteSubs = this._subscriptions.filter(a => a.clients.some(b => b.id_socket === ws['id_socket'] && b.messageRoute !== 'Bypass' && b.messageRoute !== '/' && b.messageRoute !== messageRoute && !b.messageRoute.startsWith(urlModule)));\n\n\t\t\t\tif (otherRouteSubs.length) {\n\t\t\t\t\t// ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Detected Undestroyed Subscription - ' + this.serverConfig['CLIENT_NAME'], 'USER: ' + ws['user'] + ' (Socket: ' + ws['id_socket'] + ') ' + ' is on route: ' + messageRoute + ' but has the following subscriptions on other routes:' + JSON.stringify(otherRouteSubs, null, 2));\n\n\t\t\t\t\totherRouteSubs.forEach(otherSub => {\n\t\t\t\t\t\totherSub.clients.filter(a => a.id_socket === ws['id_socket']).forEach(client => {\n\t\t\t\t\t\t\tthis.unsubscribe(client.messageRoute, new Date(), ws, client.messageId, otherSub.publication, otherSub.subscriptionData);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet sub = this._subscriptions.find(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData));\n\n\t\t\t// If sub found (another user watching same data), add client to same sub\n\t\t\tif (sub) {\n\t\t\t\tif (!sub.clients.some(a => a.id_socket === ws['id_socket'] && a.messageId === messageId)) {\n\t\t\t\t\tsub.clients.push({\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket'],\n\t\t\t\t\t\tmessageRoute: messageRoute\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If sub not found, create new sub\n\t\t\telse {\n\t\t\t\tthis._subscriptions.push({\n\t\t\t\t\tpublication: publication,\n\t\t\t\t\tsubscriptionData: subscriptionData,\n\t\t\t\t\tcollections: this.getPublicationCollections(publication),\n\t\t\t\t\tclients: [{\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket'],\n\t\t\t\t\t\tmessageRoute: messageRoute,\n\t\t\t\t\t}],\n\t\t\t\t\tcacheId: 0,\n\t\t\t\t\trunning: false,\n\t\t\t\t\trunAgain: false\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (!sub) {\n\t\t\t\tsub = this._subscriptions.find(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData));\n\t\t\t}\n\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'New Sub', sub.publication, sub.running, sub.runAgain, sub.clients.length);\n\t\t\t}\n\n\t\t\t// Immediately send data to the new client\n\t\t\tawait this.processSubscription(sub, ws, messageId);\n\t\t}\n\t}\n\n\tpublic async createLoggedInUser(id_ws: string): Promise<LoggedInUserModel> {\n\t\tlet ws = this._websocketManager.getWebSocket(id_ws);\n\n\t\tif (ws) {\n\t\t\tlet user = {\n\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t__v: 0,\n\t\t\t\tdate: new Date(),\n\t\t\t\tid_user: ws['id_user'],\n\t\t\t\tuser: ws['user'],\n\t\t\t\tid_ws: ws['id_socket']\n\t\t\t};\n\t\t\t\n\t\t\tthis._loggedInUsers.push(user);\n\t\t\tawait LoggedInUsers.insertOne(user);\n\t\t\t\n\t\t\treturn user;\n\t\t}\n\t\telse {\n\t\t\tthrow new Error('Error in Create Logged In User: No WS');\n\t\t}\n\t}\n\n\t// Unsubscribe from publication \n\tpublic unsubscribe(messageRoute: string, messageDate: Date, ws: WebSocket, messageId: number, publication: string, subscriptionData: any[]) {\t\t\n\t\tthis._debugUnSubHits += 1;\n\n\t\tif (!this._publications[publication]) {\n\t\t\tconsole.log('No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tlet sub = this._subscriptions.find(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData));\n\n\t\t\tif (sub) {\n\t\t\t\tfor (let i = sub.clients.length - 1; i >= 0; i--) {\n\t\t\t\t\tif (sub.clients[i].id_user === ws['id_user'] && sub.clients[i].messageId === messageId && sub.clients[i].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\tconsole.log(new Date(), 'Unsub', sub.publication, sub.running, sub.runAgain, sub.clients.length);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\t// Unsubscribe from publication\n\tpublic async unsubscribeAll(ws: WebSocket) {\n\t\tthis._debugUnSubAllHits += 1;\n\n\t\tif (ws) {\n\t\t\t// Check if WebSocket has already been unsubscribed\n\t\t\tif (ws['isUnsubscribed']) {\n\t\t\t\treturn; // Skip if already unsubscribed\n\t\t\t}\n\t\t\t\n\t\t\t// Mark the WebSocket as unsubscribed to prevent further calls\n\t\t\tws['isUnsubscribed'] = true;\n\t\t\t\n\t\t\tif (this._loggedInUsers.map(a => a.id_ws).indexOf(ws['id_socket']) >= 0) {\n\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.map(a => a.id_ws).indexOf(ws['id_socket']), 1);\n\t\t\t}\n\t\t\t\n\t\t\tawait LoggedInUsers.deleteOne({ id_ws: ws['id_socket'] });\n\n\t\t\tlet userSubs = this._subscriptions.filter(a => a.clients.some(b => b.id_user === ws['id_user'] && b.id_socket === ws['id_socket']));\n\n\t\t\tfor (let i = userSubs.length - 1; i >= 0; i--) {\n\t\t\t\tlet sub = userSubs[i];\n\n\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._websocketManager.removeWebSocket(ws);\n\t\t}\n\t}\n\n\tpublic getActiveSubscriptions() {\n\t\treturn this._subscriptions;\n\t}\n\n\t// Get publication collection\n\tprivate getPublicationCollections(publication: string) {\n\t\treturn this._publications[publication].collections;\n\t}\n\n\t// Watch (tail) Mongo's operation log on the entire database (all insert/modify/delete will trigger this function)\n\tprivate async tailOpLog(resumeToken?: ResumeToken) {\n\t\tif (this._oplog$ && !this._oplog$.closed) {\n\t\t\tthis._oplog$.removeAllListeners();\n\t\t\tawait this._oplog$.close();\n\t\t\tthis._oplog$ = null;\n\t\t}\n\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\tawait new Promise(resolve => setTimeout(resolve, 1000));\n\n\t\tif (!this._oplog$ || this._oplog$.closed) {\n\t\t\tthis._oplogRetryCount += 1;\n\n\t\t\tif (this._oplogRetryCount > 5) {\n\t\t\t\tconsole.error('****************** TAIL OPLOG ERROR, RETRYING A BUNCH OF TIMES, KILLING PROCESS **************************');\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconst pipeline = [\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{'ns.coll': { $nin: [\n\t\t\t\t\t\t\t\t'log-method-latencies', \n\t\t\t\t\t\t\t\t'log-subscriptions', \n\t\t\t\t\t\t\t\t'logs', \n\t\t\t\t\t\t\t\t'counters', \n\t\t\t\t\t\t\t\t'cron-job-histories', \n\t\t\t\t\t\t\t\t'email-histories',\n\t\t\t\t\t\t\t\t'qb-soap-request-histories', \n\t\t\t\t\t\t\t\t'qb-soap-request-responses', \n\t\t\t\t\t\t\t\t'qb-soap-requests',\n\t\t\t\t\t\t\t\t'qb-soap-retries'\n\t\t\t\t\t\t\t] }},\n\t\t\t\t\t\t\t{'ns.coll': { $not: /.*\\.versions$/ }},\n\t\t\t\t\t\t\t{'ns.coll': { $not: /^monitor-/ }},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\n\t\t\tlet lastResumeToken: ResumeToken;\n\n\t\t\tif (resumeToken) {\n\t\t\t\tlastResumeToken = resumeToken;\n\t\t\t\ttry {\n\t\t\t\t\tthis._oplog$ = ResolveIOServer.getMainDB().watch(pipeline, { resumeAfter: resumeToken });\n\t\t\t\t}\n\t\t\t\tcatch {\n\t\t\t\t\tif (this._oplog$) {\n\t\t\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\t\t\tawait this._oplog$.close();\n\t\t\t\t\t\tthis._oplog$ = null;\n\t\t\t\t\t}\n\n\t\t\t\t\tawait this.tailOpLog(resumeToken);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._oplog$ = ResolveIOServer.getMainDB().watch(pipeline);\n\t\t\t}\n\n\t\t\tconsole.log(new Date(), 'oplog started');\n\n\t\t\tthis._oplog$.on('change', async (doc: ChangeStreamInsertDocument | ChangeStreamUpdateDocument | ChangeStreamReplaceDocument | ChangeStreamDeleteDocument) => {\n\t\t\t\tif (doc.ns) {\n\t\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Oplog Hit', doc.ns);\n\t\t\t\t\t}\n\n\t\t\t\t\tlet collection = doc.ns.coll;\n\n\t\t\t\t\tif (!this._debugOplogCollections.some(a => a.collection === doc.ns.coll && a.type === doc.operationType)) {\n\t\t\t\t\t\tthis._debugOplogCollections.push({\n\t\t\t\t\t\t\tcollection: doc.ns.coll,\n\t\t\t\t\t\t\ttype: doc.operationType,\n\t\t\t\t\t\t\thits: 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\tthis._debugOplogCollections.find(a => a.collection === doc.ns.coll && a.type === doc.operationType).hits += 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (collection) {\n\t\t\t\t\t\tthis._debugOplogHits += 1;\n\n\t\t\t\t\t\tif (doc.operationType === 'insert') {\n\t\t\t\t\t\t\tif (collection === 'support-tickets') {\n\t\t\t\t\t\t\t\tif (this.serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().callMethod.call(ResolveIOServer.getMainServer().getMethodManager(), 'sendSupportTicketEmail', doc.documentKey['_id']);\n\t\t\t\t\t\t\t\t\tawait this.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tawait this.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (doc.operationType === 'update' || doc.operationType === 'replace') {\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tawait this.invalidatePubsCache(collection, 'update');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (doc.operationType === 'delete') {\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tawait this.invalidatePubsCache(collection, 'delete');\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\tif (collection === 'flags') {\n\t\t\t\t\t\tlet flag = await Flags.findOne({ type: 'Enable Debug' });\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (flag && flag.value) {\n\t\t\t\t\t\t\tthis._enableDebug = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._enableDebug = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlastResumeToken = doc._id;\n\n\t\t\t\t\tif ((!process.env.NODE_APP_INSTANCE || process.env.NODE_APP_INSTANCE === '0') && (process.env.IS_WORKERS_ENABLED === 'false' || (process.env.IS_WORKER_INSTANCE === 'true' && process.env.WORKER_INDEX === '0'))) {\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthis._oplog$.on('error', async error => {\n\t\t\t\tconsole.log(new Date(), 'oplog error', error);\n\t\t\t\tawait this._oplog$.close();\n\t\t\t});\n\n\t\t\tthis._oplog$.on('end', async () => {\n\t\t\t\tconsole.log(new Date(), 'oplog end');\n\t\t\t\tawait this._oplog$.close();\n\t\t\t});\n\n\t\t\tthis._oplog$.on('close', async () => {\n\t\t\t\tconsole.log(new Date(), 'oplog close');\n\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\tthis._oplog$ = null;\n\t\t\t\tawait this.tailOpLog(lastResumeToken);\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async processSubscription(sub: ActiveSubscriptionModel, ws: WebSocket, messageId: number) {\n\t\tif (!this._publications[sub.publication].user_specific) {\t\t\t\n\t\t\tif (sub.cacheId) {\n\t\t\t\ttry {\n\t\t\t\t\tlet cacheData = JSON.parse(this._nodeCache.get(sub.cacheId), dateReviver);\n\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\tdata: cacheData\n\t\t\t\t\t};\n\n\t\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Process Sub, Cache', sub.publication);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t}\n\t\t\t\tcatch {\n\t\t\t\t\tthis._nodeCache.del(sub.cacheId);\n\t\t\t\t\tsub.cacheId = 0;\n\n\t\t\t\t\tawait this.sendDataToAllWithRetry(sub, '', 'newSub');\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\tconsole.log(new Date(), 'Process Sub, Non - Cache', sub.publication, sub.running);\n\t\t\t\t}\n\n\t\t\t\tif (sub.running) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait this.sendDataToAllWithRetry(sub, '', 'newSub');\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Process Sub Specific, Non - Cache', sub.publication, sub.running);\n\t\t\t}\n\n\t\t\tif (sub.running) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tawait this.sendDataToOneWithRetry(ws, messageId, sub, '', 'newSub');\n\t\t}\n\t}\n\n\tprivate async sendDataToOne(ws: WebSocket, messageId: number, sub: ActiveSubscriptionModel, collection: string, type: string) {\n\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('User Specific Publication', sub.publication, '', '', sub.subscriptionData);\n\t\ttry {\n\t\t\tResolveIOServer.getMainServer().getMethodManager().callMethod.call(ResolveIOServer.getMainServer().getMethodManager(), 'insertSubscriptionLog', type, sub.publication, collection, JSON.stringify(sub.subscriptionData));\n\n\t\t\tlet res = await this._publications[sub.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ws['id_user'], ...sub.subscriptionData);\n\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: false,\n\t\t\t\tdata: res\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, serverRes);\n\t\t}\n\t\tcatch (err) {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: err\n\t\t\t};\n\t\t\t\n\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\n\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + sub.publication + ' - (sendDataToOne - WS)\\n\\nData \\n' + JSON.stringify(sub.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(err, null, 2));\n\t\t}\n\t\tfinally {\n\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t}\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate async sendDataToAll(sub: ActiveSubscriptionModel, collection: string, type: string) {\n\t\tif (!sub.clients.length) {\n\t\t\tif (sub.cacheId) {\n\t\t\t\tthis._nodeCache.del(sub.cacheId);\n\t\t\t\tsub.cacheId = 0;\n\t\t\t}\n\n\t\t\tlet subIndex = this._subscriptions.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData));\n\t\t\tif (subIndex >= 0) {\n\t\t\t\tthis._subscriptions.splice(subIndex, 1);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('Publication', sub.publication, '', '', sub.subscriptionData);\n\n\t\t\ttry {\n\t\t\t\tif (sub.publication !== 'superadminAPM' && sub.publication !== 'loggedInUsers') {\n\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().callMethod.call(ResolveIOServer.getMainServer().getMethodManager(), 'insertSubscriptionLog', type, sub.publication, collection, JSON.stringify(sub.subscriptionData));\n\t\t\t\t}\n\n\t\t\t\tlet res = await this._publications[sub.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ...sub.subscriptionData);\n\n\t\t\t\tif (sub.cacheId) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet cacheData = JSON.parse(this._nodeCache.get(sub.cacheId), dateReviver);\n\t\n\t\t\t\t\t\tif (JSON.stringify(cacheData) !== JSON.stringify(res)) {\n\t\t\t\t\t\t\tfor (let client of sub.clients) {\n\t\t\t\t\t\t\t\tlet ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthis._nodeCache.del(sub.cacheId);\n\n\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(res)) < 1000000 && \n\t\t\t\t\t\t\t\t!sub.collections.includes('logs') &&\n\t\t\t\t\t\t\t\t!sub.collections.find(a => a.endsWith('.versions')) &&\n\t\t\t\t\t\t\t\t!sub.collections.find(a => a.startsWith('monitor-'))\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis._nodeCache.set(sub.cacheId, JSON.stringify(res));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tsub.cacheId = 0;\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\tcatch {\n\t\t\t\t\t\tsub.clients.map(client => {\n\t\t\t\t\t\t\tlet ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t\t};\n\t\n\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tthis._nodeCache.del(sub.cacheId);\n\n\t\t\t\t\t\tif (getBinarySize(JSON.stringify(res)) < 1000000 && \n\t\t\t\t\t\t\t!sub.collections.includes('logs') &&\n\t\t\t\t\t\t\t!sub.collections.find(a => a.endsWith('.versions')) &&\n\t\t\t\t\t\t\t!sub.collections.find(a => a.startsWith('monitor-'))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthis._nodeCache.set(sub.cacheId, JSON.stringify(res));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tsub.cacheId = 0;\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\tfor (let client of sub.clients) {\n\t\t\t\t\t\tlet ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (getBinarySize(JSON.stringify(res)) < 1000000 && \n\t\t\t\t\t\t!sub.collections.includes('logs') &&\n\t\t\t\t\t\t!sub.collections.find(a => a.endsWith('.versions')) &&\n\t\t\t\t\t\t!sub.collections.find(a => a.startsWith('monitor-'))\n\t\t\t\t\t) {\n\t\t\t\t\t\tsub.cacheId = this._cacheId++;\n\t\t\t\t\t\tthis._nodeCache.set(sub.cacheId, JSON.stringify(res));\n\n\t\t\t\t\t\tconst nodeCacheSize = this._nodeCache.getStats().vsize;\n\n\t\t\t\t\t\tif (nodeCacheSize > this._heapLimit) {\n\t\t\t\t\t\t\t// Evict cache entries as needed\n\t\t\t\t\t\t\tlet deleteCount = 0;\n\t\t\t\t\t\t\tconst subArr = this._subscriptions.filter(a => a.cacheId && !a.clients.length);\n\t\t\t\t\t\n\t\t\t\t\t\t\tfor (let zz = 0; zz < subArr.length; zz++) {\n\t\t\t\t\t\t\t\tthis._debugRemoveCacheHits += 1;\n\t\t\t\t\t\t\t\tthis._nodeCache.del(subArr[zz].cacheId);\n\t\t\t\t\t\t\t\tsubArr[zz].cacheId = 0;\n\t\t\t\t\t\t\t\tdeleteCount += 1;\n\t\t\t\t\t\t\t\tif (this._nodeCache.getStats().vsize < this._heapLimit * 0.75) {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t'Sub Cache: ' +\n\t\t\t\t\t\t\t\t\t'Too Big - ' +\n\t\t\t\t\t\t\t\t\tsub.publication +\n\t\t\t\t\t\t\t\t\t' - Deleted: ' +\n\t\t\t\t\t\t\t\t\tdeleteCount +\n\t\t\t\t\t\t\t\t\t' - ' +\n\t\t\t\t\t\t\t\t\tnodeCacheSize\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\telse {\n\t\t\t\t\t\tsub.cacheId = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tfor (let client of sub.clients) {\n\t\t\t\t\tlet ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\tdata: err\n\t\t\t\t\t\t};\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + sub.publication + ' - (sendPubData)\\n\\nData \\n' + JSON.stringify(sub.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(err, null, 2));\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate sendWS(ws: WebSocket, data: ServerResponseModel) {\n\t\tthis._websocketManager.send(ws, data);\n\t}\n\n\tpublic getEnableDebug() {\n\t\treturn this._enableDebug;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/managers/subscription.manager.ts"],"names":["NodeCache","require","os_1","flag_collection_1","logged_in_users_collection_1","app_status_1","cron_jobs_1","files_1","flags_1","flags_update_1","logs_1","notifications_1","report_builder_dashboard_builders_1","report_builder_libraries_1","report_builder_reports_1","super_admin_1","user_groups_1","user_guides_1","resolveio_server_app_1","common_1","numCPUs","cpus","length","v8","SubscriptionManager","this","_publications","_subscriptions","_loggedInUsers","_mongoQueue","_mongoQueueId","_cacheId","_heapSize","getHeapStatistics","_enableDebug","_debugOplogCollections","_debugOplogHits","_debugSubCollections","_debugSubHits","_debugUnSubHits","_debugUnSubAllHits","_debugMongoQueueHits","_debugMongoQueueCollections","_debugSendQueueHits","_debugRemoveCacheHits","_oplogRetryCount","latencyBuffer","Map","LATENCY_UPDATE_INTERVAL","LATENCY_UPDATE_THRESHOLD_MS","_invalidationDebounceTimers","_invalidationPendingTimestamps","DEBOUNCE_DELAY","MAX_WAIT_TIME","create","wss","serverConfig","monitorManagerFunction","_this","subscriptionManager","setImmediate","__awaiter","initialize","_a","sent","prototype","_websocketManager","ResolveIOServer","getMainServer","getWebSocketManager","_monitorManagerFunction","_nodeCache","stdTTL","checkperiod","setInterval","flushThrottledLatencyUpdates","_wss","loadSuperAdminPublications","loadAppStatusPublications","loadLogPublications","loadFilePublications","loadCronJobPublications","loadFlagsUpdatePublications","loadFlagsPublications","loadNotificationPublications","loadReportBuilderReportPublications","loadReportBuilderLibraryPublications","loadUserGroupPublications","loadUserGuidePublications","loadReportBuilderDashboardBuilderPublications","tailOpLog","getEnableDebug","console","log","Date","JSON","stringify","sort","a","b","collection","localeCompare","publication","type","LoggedInUsers","find","_b","userCopy","deepCopy","i","loggedInUser","date","now","getTime","this_1","getWebSocket","id_ws","unsubscribeAll","_c","forEach","sub","j","clients","id_socket","splice","deleteOne","_id","findIndex","client","this_2","some","Flags","findOne","flag","value","setCacheLimit","process","env","IS_WORKERS_ENABLED","_heapLimit","invalidatePubsCache","debounceKey","firstInvalidationTime","get","set","has","clearTimeout","delete","_executeInvalidation","setTimeout","getMongoManager","invalidateQueryCache","collSubs","filter","collections","includes","collSubs_1","__values","collSubs_1_1","next","running","runAgain","user_specific","e_1","ws","readyState","OPEN","sendDataToOneWithRetry","messageId","_f","sendDataToAllWithRetry","delay","ms","Promise","resolve","sendDataToAll","sendDataToOne","publications","method","Object","assign","loggedInLatency","existingEntry","newLatency","lastUpdate","Math","abs","latency","size","updates","Array","from","entries","map","__read","updateOne","update","$set","bulkWrite","clear","error","error_1","subscribe","messageRoute","messageDate","subscriptionData","hits","push","pub","check","_schema","valObj","valKeys","keys","rootKeys","validate","errors","urlData","split","urlModule_1","urlNext","otherRouteSubs","startsWith","otherSub","unsubscribe","id_user","getPublicationCollections","cacheId","processSubscription","createLoggedInUser","user","objectIdHexString","__v","insertOne","Error","indexOf","userSubs","removeWebSocket","getActiveSubscriptions","resumeToken","_oplog$","closed","removeAllListeners","close","exit","pipeline","$match","$and","ns.coll","$nin","$not","lastResumeToken_1","getMainDB","watch","resumeAfter","on","doc","ns","coll","operationType","getMethodManager","callMethod","call","documentKey","NODE_APP_INSTANCE","IS_WORKER_INSTANCE","WORKER_INDEX","cacheData","parse","dateReviver","serverRes","hasError","data","sendWS","del","monitor","startMonitorFunction","function","apply","__spreadArray","res","err_1","sendEmail","finishMonitorFunction","subIndex","_g","res_1","_l","done","getBinarySize","endsWith","_m","_d","nodeCacheSize","getStats","vsize","deleteCount","subArr","zz","_e","err_2","send","exports"],"mappings":"+xEACAA,W,0FAAAC,QAAA,YAAA,GACAC,KAAAD,QAAA,IAAA,EAEAE,kBAAAF,QAAA,gCAAA,EACAG,6BAAAH,QAAA,2CAAA,EAIAI,aAAAJ,QAAA,4BAAA,EACAK,YAAAL,QAAA,2BAAA,EACAM,QAAAN,QAAA,uBAAA,EACAO,QAAAP,QAAA,uBAAA,EACAQ,eAAAR,QAAA,8BAAA,EACAS,OAAAT,QAAA,sBAAA,EACAU,gBAAAV,QAAA,+BAAA,EACAW,oCAAAX,QAAA,mDAAA,EACAY,2BAAAZ,QAAA,0CAAA,EACAa,yBAAAb,QAAA,wCAAA,EACAc,cAAAd,QAAA,6BAAA,EACAe,cAAAf,QAAA,6BAAA,EACAgB,cAAAhB,QAAA,6BAAA,EACAiB,uBAAAjB,QAAA,yBAAA,EACAkB,SAAAlB,QAAA,gBAAA,EAGMmB,SAAU,EAAAlB,KAAAmB,MAAI,EAAGC,OACjBC,GAAKtB,QAAQ,IAAI,EA0BvBuB,oBAAA,WAuDC,SAAAA,sBArDQC,KAAAC,cAAmC,GACnCD,KAAAE,eAA4C,GAE5CF,KAAAG,eAAsC,GAEtCH,KAAAI,YAAiC,GACjCJ,KAAAK,cAAgB,EAKhBL,KAAAM,SAAW,EAEXN,KAAAO,UAAYT,GAAGU,kBAAiB,EAAKb,QAOrCK,KAAAS,aAAe,CAAA,EACfT,KAAAU,uBAAyB,GACzBV,KAAAW,gBAAkB,EAClBX,KAAAY,qBAAuB,GACvBZ,KAAAa,cAAgB,EAChBb,KAAAc,gBAAkB,EAClBd,KAAAe,mBAAqB,EACrBf,KAAAgB,qBAAuB,EACvBhB,KAAAiB,4BAA8B,GAC9BjB,KAAAkB,oBAAsB,EACtBl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EAAI0G,CAAS,E,kGAI3B,MAAA,CAAA,EAAM5P,uBAAAiD,gBAAgBC,cAAa,EAAGgM,iBAAgB,EAAGsB,UAAU,oBAAqB,6BAA+BjQ,KAAK+B,aAA0B,YAAG,sCAAwCgE,EAAIlB,YAAc,8BAAgCP,KAAKC,UAAUwB,EAAIqF,iBAAkB,KAAM,CAAC,EAAI,eAAiB9G,KAAKC,UAAU4M,EAAK,KAAM,CAAC,CAAC,G,cAAhVb,EAAA/N,KAAA,E,aAGA,MAAA,CAAA,EAAMvC,KAAK6C,wBAAwBqN,sBAAsBR,CAAO,G,cAAhEY,EAAA/N,KAAA,E,2BAKKxC,oBAAAyC,UAAAgN,OAAR,SAAe7G,EAAe4G,GAC7BvP,KAAKyC,kBAAkB2O,KAAKzI,EAAI4G,CAAI,CACrC,EAEOxP,oBAAAyC,UAAA0B,eAAP,WACC,OAAOlE,KAAKS,YACb,EACDV,mBAAA,EAAC,EAh/BYsR,QAAAtR,oBAAAA","file":"subscription.manager.js","sourcesContent":["import { ChangeStream, ChangeStreamDeleteDocument, ChangeStreamInsertDocument, ChangeStreamReplaceDocument, ChangeStreamUpdateDocument, ResumeToken } from 'mongodb';\nimport * as NodeCache from 'node-cache';\nimport { cpus } from 'os';\nimport * as WebSocket from 'ws';\nimport { Flags } from '../collections/flag.collection';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { LoggedInUserModel } from '../models/logged-in-users.model';\nimport { ServerResponseModel } from '../models/server-response.model';\nimport { ActiveSubscriptionModel, SubscriptionModel } from '../models/subscription.model';\nimport { loadAppStatusPublications } from '../publications/app-status';\nimport { loadCronJobPublications } from '../publications/cron-jobs';\nimport { loadFilePublications } from '../publications/files';\nimport { loadFlagsPublications } from '../publications/flags';\nimport { loadFlagsUpdatePublications } from '../publications/flags-update';\nimport { loadLogPublications } from '../publications/logs';\nimport { loadNotificationPublications } from '../publications/notifications';\nimport { loadReportBuilderDashboardBuilderPublications } from '../publications/report-builder-dashboard-builders';\nimport { loadReportBuilderLibraryPublications } from '../publications/report-builder-libraries';\nimport { loadReportBuilderReportPublications } from '../publications/report-builder-reports';\nimport { loadSuperAdminPublications } from '../publications/super-admin';\nimport { loadUserGroupPublications } from '../publications/user-groups';\nimport { loadUserGuidePublications } from '../publications/user-guides';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { dateReviver, deepCopy, getBinarySize, objectIdHexString } from '../util/common';\nimport { MonitorManagerFunction } from './monitor.manager';\nimport { WebSocketManager } from './websocket.manager';\nconst numCPUs = cpus().length;\nconst v8 = require('v8');\n\n// Performance Dependencies\n// import * as path from 'path';\n// import { Worker } from 'worker_threads';\n\ninterface MongoQueueModel {\n\t_id: number,\n\ttype: string;\n\tcollection: string;\n\tsubscription: ActiveSubscriptionModel;\n\trunning: boolean;\n\trun_again: boolean;\n}\n\n// interface CurrentPerformanceMonitor {\n// \t_id: number;\n// \tfunction: string;\n// \tpublication: string;\n// \tsubscriptionData: any[];\n// \tdate_start: Date;\n// \tdate_end: Date;\n// \tduration: number;\n// \tresult: string;\n// }\n\nexport class SubscriptionManager {\n\tprivate _websocketManager: WebSocketManager;\n\tprivate _publications: SubscriptionModel = {};\n\tprivate _subscriptions: ActiveSubscriptionModel[] = [];\n\tprivate _wss: WebSocket.Server;\n\tprivate _loggedInUsers: LoggedInUserModel[] = [];\n\n\tprivate _mongoQueue: MongoQueueModel[] = [];\n\tprivate _mongoQueueId = 0;\n\t\n\tprivate _oplog$: ChangeStream;\n\n\tprivate _nodeCache;\n\tprivate _cacheId = 1;\n\n\tprivate _heapSize = v8.getHeapStatistics() / numCPUs;\n\tprivate _heapLimit: number;\n\n\tprivate serverConfig;\n\n\tprivate _monitorManagerFunction: MonitorManagerFunction;\n\n\tprivate _enableDebug = false;\n\tprivate _debugOplogCollections = [];\n\tprivate _debugOplogHits = 0;\n\tprivate _debugSubCollections = [];\n\tprivate _debugSubHits = 0;\n\tprivate _debugUnSubHits = 0;\n\tprivate _debugUnSubAllHits = 0;\n\tprivate _debugMongoQueueHits = 0;\n\tprivate _debugMongoQueueCollections = [];\n\tprivate _debugSendQueueHits = 0;\n\tprivate _debugRemoveCacheHits = 0;\n\n\tprivate _oplogRetryCount = 0;\n\n\t// Buffer to store throttled latency updates with timestamps\n\tprivate latencyBuffer = new Map<string, { latency: number, lastUpdate: Date }>();\n\n\t// Interval to flush latency updates in MongoDB\n\tprivate readonly LATENCY_UPDATE_INTERVAL = 60000;\n\n\t// Minimum time difference between two latency updates for the same user\n\tprivate readonly LATENCY_UPDATE_THRESHOLD_MS = 30000;\n\n\t// private currentPerfomanceMonitor: CurrentPerformanceMonitor[] = [];\n\t// private idPerformance: number = 0;\n\t// private performanceThread;\n\n\tprivate _invalidationDebounceTimers = new Map<string, NodeJS.Timeout>();\n\tprivate _invalidationPendingTimestamps = new Map<string, number>();\n\tprivate readonly DEBOUNCE_DELAY = 100; // 100ms debounce window\n\tprivate readonly MAX_WAIT_TIME = 500; // 500ms maximum delay\n\n\n\tconstructor() {}\n\t\n\tstatic create(wss: WebSocket.Server, serverConfig, monitorManagerFunction: MonitorManagerFunction) {\n\t\tconst subscriptionManager = new SubscriptionManager();\n\t\tsetImmediate(async () => {\n\t\t\tawait subscriptionManager.initialize(wss, serverConfig, monitorManagerFunction);\n\t\t});\n\t\treturn subscriptionManager;\n\t}\n\t\n\tprivate async initialize(wss: WebSocket.Server, serverConfig, monitorManagerFunction: MonitorManagerFunction) {\n\t\tthis._websocketManager = ResolveIOServer.getMainServer().getWebSocketManager();\n\t\tthis._monitorManagerFunction = monitorManagerFunction;\n\n\t\tthis._nodeCache = new NodeCache( { stdTTL: 0, checkperiod: 0 } );\n\n\t\tsetInterval(() => this.flushThrottledLatencyUpdates(), this.LATENCY_UPDATE_INTERVAL);\n\n\t\t// setTimeout(() => {\n\t\t// \tconsole.log('Setting up performance thread');\n\n\t\t// \tthis.performanceThread = new Worker(path.join(__dirname, './subscription.performance.js'));\n\n\t\t// \tthis.performanceThread.on('exit', code => {\n\t\t// \t\tconsole.error(new Date(), 'THREAD EXITED!!!!!!!!!!!!!!!!!!', code);\n\t\t// \t});\n\n\t\t// \tthis.performanceThread.on('error', code => {\n\t\t// \t\tconsole.error(new Date(), 'THREAD RECV ERROR !!!!!!!!!!!!!!!!!!', code);\n\t\t// \t});\n\t\t// }, 5000);\n\n\t\t// setInterval(() => {\n\t\t// \tconsole.log('Post thread msg');\n\t\t// \tthis.performanceThread.postMessage(this.currentPerfomanceMonitor);\n\t\t// \tthis.currentPerfomanceMonitor = [];\n\t\t// }, 10000);\n\n\t\tthis.serverConfig = serverConfig;\n\t\tthis._wss = wss;\n\n\t\t// Publications\n\t\tloadSuperAdminPublications(this);\n\t\tloadAppStatusPublications(this);\n\t\tloadLogPublications(this);\n\t\tloadFilePublications(this);\n\t\tloadCronJobPublications(this);\n\t\tloadFlagsUpdatePublications(this);\n\t\tloadFlagsPublications(this);\n\t\tloadNotificationPublications(this);\n\t\tloadReportBuilderReportPublications(this);\n\t\tloadReportBuilderLibraryPublications(this);\n\t\tloadUserGroupPublications(this);\n\t\tloadUserGuidePublications(this);\n\t\tloadReportBuilderDashboardBuilderPublications(this);\n\n\t\tawait this.tailOpLog();\n\n\t\tsetInterval(() => {\n\t\t\tthis._oplogRetryCount = 0;\n\t\t}, 15000);\n\n\t\tsetInterval(() => {\n\t\t\tif (this.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Subs', this._subscriptions.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Logged In Users', this._loggedInUsers.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue', this._mongoQueue.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue Hits', this._debugMongoQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue Collections', JSON.stringify(this._debugMongoQueueCollections.sort((a, b) => a.collection.localeCompare(b.collection) || a.publication.localeCompare(b.publication)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Oplog Hits', this._debugOplogHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Oplog Collections', JSON.stringify(this._debugOplogCollections.sort((a, b) => a.collection.localeCompare(b.collection) || a.type.localeCompare(b.type)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Send Queue Hits', this._debugSendQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Sub Hits', this._debugSubHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Sub Collections', JSON.stringify(this._debugSubCollections.sort((a, b) => a.publication.localeCompare(b.publication)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub Hits', this._debugUnSubHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub All Hits', this._debugUnSubAllHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Cache Cleanup Hits', this._debugRemoveCacheHits);\n\t\t\t}\n\t\t\t\n\t\t\tthis._debugOplogHits = 0;\n\t\t\tthis._debugOplogCollections = [];\n\t\t\tthis._debugSubCollections = [];\n\t\t\tthis._debugMongoQueueHits = 0;\n\t\t\tthis._debugMongoQueueCollections = [];\n\t\t\tthis._debugSendQueueHits = 0;\n\t\t\tthis._debugSubHits = 0;\n\t\t\tthis._debugUnSubHits = 0;\n\t\t\tthis._debugUnSubAllHits = 0;\n\t\t\tthis._debugRemoveCacheHits = 0;\n\t\t}, 60000);\n\n\t\tsetInterval(async () => {\n\t\t\tthis._loggedInUsers = await LoggedInUsers.find();\n\t\n\t\t\tlet userCopy = deepCopy(this._loggedInUsers);\n\t\t\tfor (let i = this._loggedInUsers.length - 1; i >= 0; i--) {\n\t\t\t\tlet loggedInUser = userCopy[i];\n\n\t\t\t\tif (!loggedInUser.date || Date.now() - loggedInUser.date.getTime() > 120000) {\n\t\t\t\t\tif (this._websocketManager.getWebSocket(loggedInUser.id_ws)) {\n\t\t\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', this._websocketManager.getWebSocket(loggedInUser.id_ws)['user'], this._websocketManager.getWebSocket(loggedInUser.id_ws)['id_socket'], 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait this.unsubscribeAll(this._websocketManager.getWebSocket(loggedInUser.id_ws));\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._subscriptions.forEach(sub => {\n\t\t\t\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\t\t\t\tif (client.id_socket === loggedInUser.id_ws) {\n\t\t\t\t\t\t\t\t\tsub.clients.splice(j, 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\n\t\t\t\t\t\tawait LoggedInUsers.deleteOne({_id: loggedInUser._id});\n\n\t\t\t\t\t\tif (this._loggedInUsers.findIndex(a => a._id === loggedInUser._id) >= 0) {\n\t\t\t\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.findIndex(a => a._id === loggedInUser._id), 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < this._subscriptions.length; i++) {\n\t\t\t\tlet sub = this._subscriptions[i];\n\n\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\tif (!this._loggedInUsers.some(a => a.id_ws === client.id_socket)) {\n\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, 30000);\n\n\t\tlet flag = await Flags.findOne({type: 'Enable Debug'});\n\n\t\tif (flag && flag.value) {\n\t\t\tthis._enableDebug = true;\n\t\t}\n\t\telse {\n\t\t\tthis._enableDebug = false;\n\t\t}\n\n\t\tthis.setCacheLimit();\n\t}\n\n\tprivate setCacheLimit() {\t\n\t\tif (process.env.IS_WORKERS_ENABLED === 'true') {\n\t\t\tthis._heapLimit = this._heapSize * 0.4;\n\t\t}\n\t\telse {\n\t\t\tthis._heapLimit = this._heapSize * 0.3; // Use 50% of total heap size\n\t\t}\n\t}\n\n\tpublic async invalidatePubsCache(collection: string, type: string) {\n\t\tconst debounceKey = collection;\n\t\tconst now = Date.now();\n\t\n\t\t// Initialize or get existing timestamp\n\t\tconst firstInvalidationTime = this._invalidationPendingTimestamps.get(debounceKey) || now;\n\t\tthis._invalidationPendingTimestamps.set(debounceKey, firstInvalidationTime);\n\t\n\t\t// Clear any existing timer\n\t\tif (this._invalidationDebounceTimers.has(debounceKey)) {\n\t\t\tclearTimeout(this._invalidationDebounceTimers.get(debounceKey));\n\t\t}\n\t\n\t\t// Check if we've waited too long\n\t\tconst waitedTooLong = (now - firstInvalidationTime) >= this.MAX_WAIT_TIME;\n\t\t\n\t\tif (waitedTooLong) {\n\t\t\t// Immediate execution path\n\t\t\tthis._invalidationPendingTimestamps.delete(debounceKey);\n\t\t\tawait this._executeInvalidation(collection, type);\n\t\t} else {\n\t\t\t// Normal debounce path\n\t\t\tthis._invalidationDebounceTimers.set(\n\t\t\t\tdebounceKey,\n\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\tthis._invalidationPendingTimestamps.delete(debounceKey);\n\t\t\t\t\tawait this._executeInvalidation(collection, type);\n\t\t\t\t}, this.DEBOUNCE_DELAY)\n\t\t\t);\n\t\t}\n\t}\n\t\n\tprivate async _executeInvalidation(collection: string, type: string) {\n\t\t// Clean up any existing timer (defensive)\n\t\tif (this._invalidationDebounceTimers.has(collection)) {\n\t\t\tclearTimeout(this._invalidationDebounceTimers.get(collection));\n\t\t\tthis._invalidationDebounceTimers.delete(collection);\n\t\t}\n\t\n\t\t// Original invalidation logic\n\t\tResolveIOServer.getMongoManager().invalidateQueryCache(collection);\n\t\n\t\tconst collSubs = this._subscriptions.filter(a => a.collections.includes(collection));\n\t\n\t\tfor (const sub of collSubs) {\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Invalidate Sub', sub.publication, sub.running, sub.runAgain);\n\t\t\t}\n\t\n\t\t\tif (sub.running) {\n\t\t\t\tsub.runAgain = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\n\t\t\tif (this._publications[sub.publication].user_specific) {\n\t\t\t\tfor (let client of sub.clients) {\n\t\t\t\t\tconst ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\tif (ws?.readyState === ws.OPEN) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait this.sendDataToOneWithRetry(ws, client.messageId, sub, collection, type);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\t// Error handling\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tawait this.sendDataToAllWithRetry(sub, collection, type);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async delay(ms: number) {\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn new Promise(resolve => setTimeout(resolve, ms));\n\t}\n\n\tprivate async sendDataToAllWithRetry(sub: ActiveSubscriptionModel, collection: string, type: string) {\n\t\tsub.running = true;\n\n\t\tdo {\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Running sendDataToAll Sub', sub.publication);\n\t\t\t}\n\n\t\t\tsub.runAgain = false;\n\t\t\tawait this.sendDataToAll(sub, collection, type);\n\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Done sendDataToAll Sub', sub.publication, sub.runAgain);\n\t\t\t}\n\n\t\t\tif (sub.runAgain) {\n\t\t\t\tawait this.delay(500); // delay, adjust as needed\n\t\t\t}\n\t\t} while (sub.runAgain);\n\n\t\tsub.running = false;\n\t}\n\n\tprivate async sendDataToOneWithRetry(ws: WebSocket, messageId: number, sub: ActiveSubscriptionModel, collection: string, type: string) {\n\t\tsub.running = true;\n\n\t\tdo {\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Running sendDataToOne Sub', sub.publication);\n\t\t\t}\n\n\t\t\tsub.runAgain = false;\n\t\t\tawait this.sendDataToOne(ws, messageId, sub, collection, type);\n\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Done sendDataToOne Sub', sub.publication, sub.runAgain);\n\t\t\t}\n\n\t\t\tif (sub.runAgain) {\n\t\t\t\tawait this.delay(500); // delay, adjust as needed\n\t\t\t}\n\t\t} while (sub.runAgain);\n\t\tsub.running = false;\n\t}\n\n\t// Add all files to publications private object\n\tpublic publications(method: SubscriptionModel) {\n\t\tthis._publications = Object.assign(this._publications, method);\n\t}\n\n\t// Throttled `loggedInLatency` method\n\tpublic loggedInLatency(ws: WebSocket) {\n\t\tlet loggedInUser = this._loggedInUsers.find(a => a.id_ws === ws['id_socket']);\n\t\tif (!loggedInUser) return;\n\n\t\tconst now = new Date();\n\t\tconst existingEntry = this.latencyBuffer.get(ws['id_socket']);\n\t\tconst newLatency = ws['latency'];\n\n\t\t// Throttle updates: only update if time threshold has passed or latency has significantly changed\n\t\tif (\n\t\t\t!existingEntry || \n\t\t\t(now.getTime() - existingEntry.lastUpdate.getTime() >= this.LATENCY_UPDATE_THRESHOLD_MS) || \n\t\t\t(Math.abs(newLatency - existingEntry.latency) > 100) // Optional: log only significant changes\n\t\t) {\n\t\t\t// Update in-memory and buffer\n\t\t\tloggedInUser.date = now;\n\t\t\tthis.latencyBuffer.set(ws['id_socket'], { latency: newLatency, lastUpdate: now });\n\t\t}\n\t}\n\n\t// Method to flush buffered latency updates in bulk\n\tprivate async flushThrottledLatencyUpdates() {\n\t\tif (this.latencyBuffer.size === 0) return; // No updates to flush\n\n\t\tconst updates = Array.from(this.latencyBuffer.entries()).map(([id_ws, { latency, lastUpdate }]) => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { id_ws },\n\t\t\t\tupdate: { $set: { latency, date: lastUpdate } }\n\t\t\t}\n\t\t}));\n\n\t\ttry {\n\t\t\tawait LoggedInUsers.bulkWrite(updates);\n\t\t\tthis.latencyBuffer.clear(); // Clear buffer after successful update\n\n\t\t\tif (this.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Throttled latency batch update successful', updates.length);\n\t\t\t}\n\t\t}\n\t\tcatch (error) {\n\t\t\tconsole.error(new Date(), 'Sub Manager', 'Throttled latency batch update failed', error);\n\t\t\t// Optional: implement retry logic or logging for failed updates\n\t\t}\n\t}\n\n\t// Subscribe to publication\n\tpublic async subscribe(messageRoute: string, messageDate: Date, ws: WebSocket, messageId: number, publication: string, subscriptionData: any[]) {\n\t\tthis._debugSubHits += 1;\n\n\t\tif (!this._debugSubCollections.some(a => a.publication === publication)) {\n\t\t\tthis._debugSubCollections.push({\n\t\t\t\tpublication: publication,\n\t\t\t\thits: 1\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tthis._debugSubCollections.find(a => a.publication === publication).hits += 1;\n\t\t}\n\n\t\tlet pub = this._publications[publication];\n\n\t\tif (!pub) {\n\t\t\tconsole.error(new Date(), 'No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tif (subscriptionData.length > 1 || subscriptionData[0]) {\n\t\t\t\tif (!pub.check) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Function For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse if (!pub.check._schema) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Schema For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(pub.check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\n\t\t\t\t\tfor (let i = 0; i < subscriptionData.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = subscriptionData[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpub.check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error(new Date(), 'Error in Pub Check (' + publication + ')', errors);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (messageRoute !== 'Bypass') {\n\t\t\t\tlet urlData = messageRoute.split('/');\n\t\t\t\tlet urlModule = '';\n\t\t\t\tlet urlNext = urlData[0];\n\n\t\t\t\tif (urlData[0] === '') {\n\t\t\t\t\turlModule = '/';\n\t\t\t\t\turlNext = urlData[1];\n\t\t\t\t}\n\n\t\t\t\turlModule += urlNext;\n\n\t\t\t\tif (urlData.length > 1) {\n\t\t\t\t\turlModule += '/';\n\t\t\t\t}\n\n\t\t\t\tlet otherRouteSubs = this._subscriptions.filter(a => a.clients.some(b => b.id_socket === ws['id_socket'] && b.messageRoute !== 'Bypass' && b.messageRoute !== '/' && b.messageRoute !== messageRoute && !b.messageRoute.startsWith(urlModule)));\n\n\t\t\t\tif (otherRouteSubs.length) {\n\t\t\t\t\t// ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Detected Undestroyed Subscription - ' + this.serverConfig['CLIENT_NAME'], 'USER: ' + ws['user'] + ' (Socket: ' + ws['id_socket'] + ') ' + ' is on route: ' + messageRoute + ' but has the following subscriptions on other routes:' + JSON.stringify(otherRouteSubs, null, 2));\n\n\t\t\t\t\totherRouteSubs.forEach(otherSub => {\n\t\t\t\t\t\totherSub.clients.filter(a => a.id_socket === ws['id_socket']).forEach(client => {\n\t\t\t\t\t\t\tthis.unsubscribe(client.messageRoute, new Date(), ws, client.messageId, otherSub.publication, otherSub.subscriptionData);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet sub = this._subscriptions.find(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData));\n\n\t\t\t// If sub found (another user watching same data), add client to same sub\n\t\t\tif (sub) {\n\t\t\t\tif (!sub.clients.some(a => a.id_socket === ws['id_socket'] && a.messageId === messageId)) {\n\t\t\t\t\tsub.clients.push({\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket'],\n\t\t\t\t\t\tmessageRoute: messageRoute\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If sub not found, create new sub\n\t\t\telse {\n\t\t\t\tthis._subscriptions.push({\n\t\t\t\t\tpublication: publication,\n\t\t\t\t\tsubscriptionData: subscriptionData,\n\t\t\t\t\tcollections: this.getPublicationCollections(publication),\n\t\t\t\t\tclients: [{\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket'],\n\t\t\t\t\t\tmessageRoute: messageRoute,\n\t\t\t\t\t}],\n\t\t\t\t\tcacheId: 0,\n\t\t\t\t\trunning: false,\n\t\t\t\t\trunAgain: false\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (!sub) {\n\t\t\t\tsub = this._subscriptions.find(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData));\n\t\t\t}\n\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'New Sub', sub.publication, sub.running, sub.runAgain, sub.clients.length);\n\t\t\t}\n\n\t\t\t// Immediately send data to the new client\n\t\t\tawait this.processSubscription(sub, ws, messageId);\n\t\t}\n\t}\n\n\tpublic async createLoggedInUser(id_ws: string): Promise<LoggedInUserModel> {\n\t\tlet ws = this._websocketManager.getWebSocket(id_ws);\n\n\t\tif (ws) {\n\t\t\tlet user = {\n\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t__v: 0,\n\t\t\t\tdate: new Date(),\n\t\t\t\tid_user: ws['id_user'],\n\t\t\t\tuser: ws['user'],\n\t\t\t\tid_ws: ws['id_socket']\n\t\t\t};\n\t\t\t\n\t\t\tthis._loggedInUsers.push(user);\n\t\t\tawait LoggedInUsers.insertOne(user);\n\t\t\t\n\t\t\treturn user;\n\t\t}\n\t\telse {\n\t\t\tthrow new Error('Error in Create Logged In User: No WS');\n\t\t}\n\t}\n\n\t// Unsubscribe from publication \n\tpublic unsubscribe(messageRoute: string, messageDate: Date, ws: WebSocket, messageId: number, publication: string, subscriptionData: any[]) {\t\t\n\t\tthis._debugUnSubHits += 1;\n\n\t\tif (!this._publications[publication]) {\n\t\t\tconsole.log('No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tlet sub = this._subscriptions.find(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData));\n\n\t\t\tif (sub) {\n\t\t\t\tfor (let i = sub.clients.length - 1; i >= 0; i--) {\n\t\t\t\t\tif (sub.clients[i].id_user === ws['id_user'] && sub.clients[i].messageId === messageId && sub.clients[i].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\tconsole.log(new Date(), 'Unsub', sub.publication, sub.running, sub.runAgain, sub.clients.length);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\t// Unsubscribe from publication\n\tpublic async unsubscribeAll(ws: WebSocket) {\n\t\tthis._debugUnSubAllHits += 1;\n\n\t\tif (ws) {\n\t\t\t// Check if WebSocket has already been unsubscribed\n\t\t\tif (ws['isUnsubscribed']) {\n\t\t\t\treturn; // Skip if already unsubscribed\n\t\t\t}\n\t\t\t\n\t\t\t// Mark the WebSocket as unsubscribed to prevent further calls\n\t\t\tws['isUnsubscribed'] = true;\n\t\t\t\n\t\t\tif (this._loggedInUsers.map(a => a.id_ws).indexOf(ws['id_socket']) >= 0) {\n\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.map(a => a.id_ws).indexOf(ws['id_socket']), 1);\n\t\t\t}\n\t\t\t\n\t\t\tawait LoggedInUsers.deleteOne({ id_ws: ws['id_socket'] });\n\n\t\t\tlet userSubs = this._subscriptions.filter(a => a.clients.some(b => b.id_user === ws['id_user'] && b.id_socket === ws['id_socket']));\n\n\t\t\tfor (let i = userSubs.length - 1; i >= 0; i--) {\n\t\t\t\tlet sub = userSubs[i];\n\n\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._websocketManager.removeWebSocket(ws);\n\t\t}\n\t}\n\n\tpublic getActiveSubscriptions() {\n\t\treturn this._subscriptions;\n\t}\n\n\t// Get publication collection\n\tprivate getPublicationCollections(publication: string) {\n\t\treturn this._publications[publication].collections;\n\t}\n\n\t// Watch (tail) Mongo's operation log on the entire database (all insert/modify/delete will trigger this function)\n\tprivate async tailOpLog(resumeToken?: ResumeToken) {\n\t\tif (this._oplog$ && !this._oplog$.closed) {\n\t\t\tthis._oplog$.removeAllListeners();\n\t\t\tawait this._oplog$.close();\n\t\t\tthis._oplog$ = null;\n\t\t}\n\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\tawait new Promise(resolve => setTimeout(resolve, 1000));\n\n\t\tif (!this._oplog$ || this._oplog$.closed) {\n\t\t\tthis._oplogRetryCount += 1;\n\n\t\t\tif (this._oplogRetryCount > 5) {\n\t\t\t\tconsole.error('****************** TAIL OPLOG ERROR, RETRYING A BUNCH OF TIMES, KILLING PROCESS **************************');\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconst pipeline = [\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{'ns.coll': { $nin: [\n\t\t\t\t\t\t\t\t'log-method-latencies', \n\t\t\t\t\t\t\t\t'log-subscriptions', \n\t\t\t\t\t\t\t\t'logs', \n\t\t\t\t\t\t\t\t'counters', \n\t\t\t\t\t\t\t\t'cron-job-histories', \n\t\t\t\t\t\t\t\t'email-histories',\n\t\t\t\t\t\t\t\t'qb-soap-request-histories', \n\t\t\t\t\t\t\t\t'qb-soap-request-responses', \n\t\t\t\t\t\t\t\t'qb-soap-requests',\n\t\t\t\t\t\t\t\t'qb-soap-retries'\n\t\t\t\t\t\t\t] }},\n\t\t\t\t\t\t\t{'ns.coll': { $not: /.*\\.versions$/ }},\n\t\t\t\t\t\t\t{'ns.coll': { $not: /^monitor-/ }},\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\n\t\t\tlet lastResumeToken: ResumeToken;\n\n\t\t\tif (resumeToken) {\n\t\t\t\tlastResumeToken = resumeToken;\n\t\t\t\ttry {\n\t\t\t\t\tthis._oplog$ = ResolveIOServer.getMainDB().watch(pipeline, { resumeAfter: resumeToken });\n\t\t\t\t}\n\t\t\t\tcatch {\n\t\t\t\t\tif (this._oplog$) {\n\t\t\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\t\t\tawait this._oplog$.close();\n\t\t\t\t\t\tthis._oplog$ = null;\n\t\t\t\t\t}\n\n\t\t\t\t\tawait this.tailOpLog(resumeToken);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._oplog$ = ResolveIOServer.getMainDB().watch(pipeline);\n\t\t\t}\n\n\t\t\tconsole.log(new Date(), 'oplog started');\n\n\t\t\tthis._oplog$.on('change', async (doc: ChangeStreamInsertDocument | ChangeStreamUpdateDocument | ChangeStreamReplaceDocument | ChangeStreamDeleteDocument) => {\n\t\t\t\tif (doc.ns) {\n\t\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Oplog Hit', doc.ns);\n\t\t\t\t\t}\n\n\t\t\t\t\tlet collection = doc.ns.coll;\n\n\t\t\t\t\tif (!this._debugOplogCollections.some(a => a.collection === doc.ns.coll && a.type === doc.operationType)) {\n\t\t\t\t\t\tthis._debugOplogCollections.push({\n\t\t\t\t\t\t\tcollection: doc.ns.coll,\n\t\t\t\t\t\t\ttype: doc.operationType,\n\t\t\t\t\t\t\thits: 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\tthis._debugOplogCollections.find(a => a.collection === doc.ns.coll && a.type === doc.operationType).hits += 1;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (collection) {\n\t\t\t\t\t\tthis._debugOplogHits += 1;\n\n\t\t\t\t\t\tif (doc.operationType === 'insert') {\n\t\t\t\t\t\t\tif (collection === 'support-tickets') {\n\t\t\t\t\t\t\t\tif (this.serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().callMethod.call(ResolveIOServer.getMainServer().getMethodManager(), 'sendSupportTicketEmail', doc.documentKey['_id']);\n\t\t\t\t\t\t\t\t\tawait this.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tawait this.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (doc.operationType === 'update' || doc.operationType === 'replace') {\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tawait this.invalidatePubsCache(collection, 'update');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (doc.operationType === 'delete') {\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tawait this.invalidatePubsCache(collection, 'delete');\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\tif (collection === 'flags') {\n\t\t\t\t\t\tlet flag = await Flags.findOne({ type: 'Enable Debug' });\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (flag && flag.value) {\n\t\t\t\t\t\t\tthis._enableDebug = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._enableDebug = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlastResumeToken = doc._id;\n\n\t\t\t\t\tif ((!process.env.NODE_APP_INSTANCE || process.env.NODE_APP_INSTANCE === '0') && (process.env.IS_WORKERS_ENABLED === 'false' || (process.env.IS_WORKER_INSTANCE === 'true' && process.env.WORKER_INDEX === '0'))) {\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthis._oplog$.on('error', async error => {\n\t\t\t\tconsole.log(new Date(), 'oplog error', error);\n\t\t\t\tawait this._oplog$.close();\n\t\t\t});\n\n\t\t\tthis._oplog$.on('end', async () => {\n\t\t\t\tconsole.log(new Date(), 'oplog end');\n\t\t\t\tawait this._oplog$.close();\n\t\t\t});\n\n\t\t\tthis._oplog$.on('close', async () => {\n\t\t\t\tconsole.log(new Date(), 'oplog close');\n\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\tthis._oplog$ = null;\n\t\t\t\tawait this.tailOpLog(lastResumeToken);\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async processSubscription(sub: ActiveSubscriptionModel, ws: WebSocket, messageId: number) {\n\t\tif (!this._publications[sub.publication].user_specific) {\t\t\t\n\t\t\tif (sub.cacheId) {\n\t\t\t\ttry {\n\t\t\t\t\tlet cacheData = JSON.parse(this._nodeCache.get(sub.cacheId), dateReviver);\n\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\tdata: cacheData\n\t\t\t\t\t};\n\n\t\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Process Sub, Cache', sub.publication);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t}\n\t\t\t\tcatch {\n\t\t\t\t\tthis._nodeCache.del(sub.cacheId);\n\t\t\t\t\tsub.cacheId = 0;\n\n\t\t\t\t\tawait this.sendDataToAllWithRetry(sub, '', 'newSub');\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\tconsole.log(new Date(), 'Process Sub, Non - Cache', sub.publication, sub.running);\n\t\t\t\t}\n\n\t\t\t\tif (sub.running) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tawait this.sendDataToAllWithRetry(sub, '', 'newSub');\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Process Sub Specific, Non - Cache', sub.publication, sub.running);\n\t\t\t}\n\n\t\t\tif (sub.running) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tawait this.sendDataToOneWithRetry(ws, messageId, sub, '', 'newSub');\n\t\t}\n\t}\n\n\tprivate async sendDataToOne(ws: WebSocket, messageId: number, sub: ActiveSubscriptionModel, collection: string, type: string) {\n\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('User Specific Publication', sub.publication, '', '', sub.subscriptionData);\n\t\ttry {\n\t\t\tResolveIOServer.getMainServer().getMethodManager().callMethod.call(ResolveIOServer.getMainServer().getMethodManager(), 'insertSubscriptionLog', type, sub.publication, collection, JSON.stringify(sub.subscriptionData));\n\n\t\t\tlet res = await this._publications[sub.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ws['id_user'], ...sub.subscriptionData);\n\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: false,\n\t\t\t\tdata: res\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, serverRes);\n\t\t}\n\t\tcatch (err) {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: err\n\t\t\t};\n\t\t\t\n\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\n\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + sub.publication + ' - (sendDataToOne - WS)\\n\\nData \\n' + JSON.stringify(sub.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(err, null, 2));\n\t\t}\n\t\tfinally {\n\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t}\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate async sendDataToAll(sub: ActiveSubscriptionModel, collection: string, type: string) {\n\t\tif (!sub.clients.length) {\n\t\t\tif (sub.cacheId) {\n\t\t\t\tthis._nodeCache.del(sub.cacheId);\n\t\t\t\tsub.cacheId = 0;\n\t\t\t}\n\n\t\t\tlet subIndex = this._subscriptions.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData));\n\t\t\tif (subIndex >= 0) {\n\t\t\t\tthis._subscriptions.splice(subIndex, 1);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('Publication', sub.publication, '', '', sub.subscriptionData);\n\n\t\t\ttry {\n\t\t\t\tif (sub.publication !== 'superadminAPM' && sub.publication !== 'loggedInUsers') {\n\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().callMethod.call(ResolveIOServer.getMainServer().getMethodManager(), 'insertSubscriptionLog', type, sub.publication, collection, JSON.stringify(sub.subscriptionData));\n\t\t\t\t}\n\n\t\t\t\tlet res = await this._publications[sub.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ...sub.subscriptionData);\n\n\t\t\t\tif (sub.cacheId) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet cacheData = JSON.parse(this._nodeCache.get(sub.cacheId), dateReviver);\n\t\n\t\t\t\t\t\tif (JSON.stringify(cacheData) !== JSON.stringify(res)) {\n\t\t\t\t\t\t\tfor (let client of sub.clients) {\n\t\t\t\t\t\t\t\tlet ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthis._nodeCache.del(sub.cacheId);\n\n\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(res)) < 1000000 && \n\t\t\t\t\t\t\t\t!sub.collections.includes('logs') &&\n\t\t\t\t\t\t\t\t!sub.collections.find(a => a.endsWith('.versions')) &&\n\t\t\t\t\t\t\t\t!sub.collections.find(a => a.startsWith('monitor-'))\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tthis._nodeCache.set(sub.cacheId, JSON.stringify(res));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tsub.cacheId = 0;\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\tcatch {\n\t\t\t\t\t\tsub.clients.map(client => {\n\t\t\t\t\t\t\tlet ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t\t};\n\t\n\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tthis._nodeCache.del(sub.cacheId);\n\n\t\t\t\t\t\tif (getBinarySize(JSON.stringify(res)) < 1000000 && \n\t\t\t\t\t\t\t!sub.collections.includes('logs') &&\n\t\t\t\t\t\t\t!sub.collections.find(a => a.endsWith('.versions')) &&\n\t\t\t\t\t\t\t!sub.collections.find(a => a.startsWith('monitor-'))\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthis._nodeCache.set(sub.cacheId, JSON.stringify(res));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tsub.cacheId = 0;\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\tfor (let client of sub.clients) {\n\t\t\t\t\t\tlet ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (getBinarySize(JSON.stringify(res)) < 1000000 && \n\t\t\t\t\t\t!sub.collections.includes('logs') &&\n\t\t\t\t\t\t!sub.collections.find(a => a.endsWith('.versions')) &&\n\t\t\t\t\t\t!sub.collections.find(a => a.startsWith('monitor-'))\n\t\t\t\t\t) {\n\t\t\t\t\t\tsub.cacheId = this._cacheId++;\n\t\t\t\t\t\tthis._nodeCache.set(sub.cacheId, JSON.stringify(res));\n\n\t\t\t\t\t\tconst nodeCacheSize = this._nodeCache.getStats().vsize;\n\n\t\t\t\t\t\tif (nodeCacheSize > this._heapLimit) {\n\t\t\t\t\t\t\t// Evict cache entries as needed\n\t\t\t\t\t\t\tlet deleteCount = 0;\n\t\t\t\t\t\t\tconst subArr = this._subscriptions.filter(a => a.cacheId && !a.clients.length);\n\t\t\t\t\t\n\t\t\t\t\t\t\tfor (let zz = 0; zz < subArr.length; zz++) {\n\t\t\t\t\t\t\t\tthis._debugRemoveCacheHits += 1;\n\t\t\t\t\t\t\t\tthis._nodeCache.del(subArr[zz].cacheId);\n\t\t\t\t\t\t\t\tsubArr[zz].cacheId = 0;\n\t\t\t\t\t\t\t\tdeleteCount += 1;\n\t\t\t\t\t\t\t\tif (this._nodeCache.getStats().vsize < this._heapLimit * 0.75) {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (this._enableDebug) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t'Sub Cache: ' +\n\t\t\t\t\t\t\t\t\t'Too Big - ' +\n\t\t\t\t\t\t\t\t\tsub.publication +\n\t\t\t\t\t\t\t\t\t' - Deleted: ' +\n\t\t\t\t\t\t\t\t\tdeleteCount +\n\t\t\t\t\t\t\t\t\t' - ' +\n\t\t\t\t\t\t\t\t\tnodeCacheSize\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\telse {\n\t\t\t\t\t\tsub.cacheId = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tfor (let client of sub.clients) {\n\t\t\t\t\tlet ws = this._websocketManager.getWebSocket(client.id_socket);\n\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\tdata: err\n\t\t\t\t\t\t};\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + sub.publication + ' - (sendPubData)\\n\\nData \\n' + JSON.stringify(sub.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(err, null, 2));\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate sendWS(ws: WebSocket, data: ServerResponseModel) {\n\t\tthis._websocketManager.send(ws, data);\n\t}\n\n\tpublic getEnableDebug() {\n\t\treturn this._enableDebug;\n\t}\n}\n"]}
|
package/methods/collections.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(e,n,t,i){return new(t=t||Promise)(function(r,o){function fulfilled(e){try{step(i.next(e))}catch(e){o(e)}}function rejected(e){try{step(i.throw(e))}catch(e){o(e)}}function step(e){var o;e.done?r(e.value):((o=e.value)instanceof t?o:new t(function(e){e(o)})).then(fulfilled,rejected)}step((i=i.apply(e,n||[])).next())})},__generator=this&&this.__generator||function(n,t){var i,l,c,a={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]},s={next:verb(0),throw:verb(1),return:verb(2)};return"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function verb(r){return function(e){var o=[r,e];if(i)throw new TypeError("Generator is already executing.");for(;a=s&&o[s=0]?0:a;)try{if(i=1,l&&(c=2&o[0]?l.return:o[0]?l.throw||((c=l.return)&&c.call(l),0):l.next)&&!(c=c.call(l,o[1])).done)return c;switch(l=0,(o=c?[2&o[0],c.value]:o)[0]){case 0:case 1:c=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,l=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(c=0<(c=a.trys).length&&c[c.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!c||o[1]>c[0]&&o[1]<c[3]))a.label=o[1];else if(6===o[0]&&a.label<c[1])a.label=c[1],c=o;else{if(!(c&&a.label<c[2])){c[2]&&a.ops.pop(),a.trys.pop();continue}a.label=c[2],a.ops.push(o)}}o=t.call(n,a)}catch(e){o=[6,e],l=0}finally{i=c=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}},simpl_schema_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadCollectionMethods=void 0,require("simpl-schema")),pagination_model_1=require("../models/pagination.model"),resolveio_server_app_1=require("../resolveio-server-app"),common_1=require("../util/common");function loadCollectionMethods(e){e.methods({collectionListAll:{function:function(){return Promise.resolve(resolveio_server_app_1.ResolveIOServer.getMongoManager().collections().map(function(e){return e.collectionName}).sort(function(e,o){return e.localeCompare(o)}))}},collectionListRB:{function:function(){return Promise.resolve(resolveio_server_app_1.ResolveIOServer.getMongoManager().collections().filter(function(e){return e.useRB}).map(function(e){return e.collectionName}).sort(function(e,o){return e.localeCompare(o)}))}},findOne:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,o){if(void 0===o&&(o={}),resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).findOne(o);throw new Error("Error in Find One Collection: Invalid collection")}},find:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0},sort:{type:Object,blackbox:!0,optional:!0}}),function:function(e,o,r){if(void 0===o&&(o={}),void 0===r&&(r={}),resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).find(o,{sort:r});throw new Error("Error in Find Collection: Invalid collection")}},findWithOptions:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0},options:{type:pagination_model_1.PaginationOptionsSchema}}),function:function(e,o,r){var n;if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return n={},r.fields&&Object.keys(r.fields).length&&(n.projection=r.fields),r.sort&&Object.keys(r.sort).length&&(n.sort=r.sort),r.limit&&(n.limit=r.limit),r.skip&&(n.skip=r.skip),resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).find(o,n);throw new Error("Error in Find With Options Collection: Invalid collection")}},insertDocument:{check:new simpl_schema_1.default({collection:{type:String},document:{type:Object,blackbox:!0}}),function:function(r,n){return __awaiter(this,void 0,void 0,function(){var o;return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(r))return[3,1];throw new Error("Error in Insert Document Collection: Invalid collection");case 1:return o=(0,common_1.objectIdHexString)(),n._id=o,n.__v=0,[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(r).insertOne(n)];case 2:return e.sent(),[2,o]}})})}},insertManyDocuments:{check:new simpl_schema_1.default({collection:{type:String},documents:{type:Array},"documents.$":{type:Object,blackbox:!0}}),function:function(o,r){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(o))return[3,1];throw new Error("Error in Insert Many Documents Collection: Invalid collection");case 1:return r.forEach(function(e){e._id=(0,common_1.objectIdHexString)(),e.__v=0}),[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(o).insertMany(r)];case 2:return e.sent(),[2,r.map(function(e){return e._id})]}})})}},updateDocument:{check:new simpl_schema_1.default({collection:{type:String},f_document:{type:Object,blackbox:!0}}),function:function(e,o){if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:o._id},o);throw new Error("Error in Update Document Collection: Invalid collection")}},updateDocumentProps:{check:new simpl_schema_1.default({collection:{type:String},doc_id:{type:String},updateParams:{type:Array},"updateParams.$":{type:Object,blackbox:!0},doc__v:{type:Number,optional:!0}}),function:function(l,c,a,s){return __awaiter(this,void 0,void 0,function(){var o,r,n,t,i;return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l))return[3,1];throw new Error("Error in Update Document Props Collection: Invalid collection");case 1:return[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).findOne({_id:c})];case 2:if(o=e.sent()){if(r=(0,common_1.deepCopy)(o),a.forEach(function(e){r[e.prop]=e.data}),s&&r.__v!==s){if(console.log(new Date,"invalid version - "+l,o.__v,s),resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions")){if(i=resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions"),n=o._id,t=o.__v,i)return(i=(0,common_1.getMongoMergeUpdatedDoc)(r,o,i))._id=n,i.__v=t,o._id=n,o.__v=t,[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:n},i,{},!1,!1,o)];throw new Error("Error In Update Document Props Collections: Invalid Version And Could Not Find History Props - DB: "+t+", Trying to update with :"+s)}throw new Error("Error In Update Document Props Collections: Invalid Version And We Are NOT Using Versions On This Collection!")}return[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:r._id},r,{},!1,!1,o)]}throw new Error("Error in Update Document Props Collections: No Document");case 3:return[2]}})})}},updateDocumentOffline:{check:new simpl_schema_1.default({collection:{type:String},f_document:{type:Object,blackbox:!0}}),function:function(l,c){return __awaiter(this,void 0,void 0,function(){var o,r,n,t,i;return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l))return[3,1];throw new Error("Error in Update Document Offline Collection: Invalid collection");case 1:return[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).findOne({_id:c._id})];case 2:if(o=e.sent()){if(o.__v===c.__v)return[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:c._id},c,{},!1,!1,o)];if(console.log("OFFLINE - invalid version - "+l,o.__v,c.__v),r=o._id,n=o.__v,t=c.__v,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions")){if(i=resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions"))return(i=(0,common_1.getMongoMergeUpdatedDoc)(c,o,i))._id=r,i.__v=n,o._id=r,o.__v=n,[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:r},i,{},!1,!1,o)];throw new Error("Error in Update Document Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: "+n+", Trying to update with :"+t)}throw new Error("Error in Update Document Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!")}throw new Error("Error in Update Document Offline Collections: No Document");case 3:return[2]}})})}},updateDocumentPropsOffline:{check:new simpl_schema_1.default({collection:{type:String},doc_id:{type:String},updateParams:{type:Array},"updateParams.$":{type:Object,blackbox:!0},doc__v:{type:Number}}),function:function(l,c,a,s){return __awaiter(this,void 0,void 0,function(){var o,r,n,t,i;return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l))return[3,1];throw new Error("Error in Update Document Props Offline Collection: Invalid collection");case 1:return[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).findOne({_id:c},null,!0)];case 2:if(o=e.sent()){if(r=(0,common_1.deepCopy)(o),a.forEach(function(e){r[e.prop]=e.data}),r.__v===s)return[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:r._id},r,{},!1,!1,o)];if(console.log("OFFLINE - invalid version - "+l,o.__v,s),n=o._id,t=o.__v,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions")){if(i=resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions"))return(i=(0,common_1.getMongoMergeUpdatedDoc)(r,o,i))._id=n,i.__v=t,o._id=n,o.__v=t,[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:n},i,{},!1,!1,o)];throw new Error("Error in Update Document Props Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: "+t+", Trying to update with :"+s)}throw new Error("Error in Update Document Props Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!")}throw new Error("Error in Update Document Props Offline Collections: No Document");case 3:return[2]}})})}},removeDocument:{check:new simpl_schema_1.default({collection:{type:String},doc_id:{type:String}}),function:function(e,o){if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).deleteOne({_id:o});throw new Error("Error in Remove Document Collection: Invalid collection")}},removeDocumentWithQuery:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,o){if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).deleteOne(o);throw new Error("Error in Remove Document With Query Collection: Invalid collection")}},removeDocumentsWithQuery:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,o){if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).deleteMany(o);throw new Error("Error in Remove Documents With Query Collections: Invalid Collection")}}})}exports.loadCollectionMethods=loadCollectionMethods;
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,n,t,i){return new(t=t||Promise)(function(r,o){function fulfilled(e){try{step(i.next(e))}catch(e){o(e)}}function rejected(e){try{step(i.throw(e))}catch(e){o(e)}}function step(e){var o;e.done?r(e.value):((o=e.value)instanceof t?o:new t(function(e){e(o)})).then(fulfilled,rejected)}step((i=i.apply(e,n||[])).next())})},__generator=this&&this.__generator||function(n,t){var i,l,c,a={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]},s={next:verb(0),throw:verb(1),return:verb(2)};return"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function verb(r){return function(e){var o=[r,e];if(i)throw new TypeError("Generator is already executing.");for(;a=s&&o[s=0]?0:a;)try{if(i=1,l&&(c=2&o[0]?l.return:o[0]?l.throw||((c=l.return)&&c.call(l),0):l.next)&&!(c=c.call(l,o[1])).done)return c;switch(l=0,(o=c?[2&o[0],c.value]:o)[0]){case 0:case 1:c=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,l=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(c=0<(c=a.trys).length&&c[c.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!c||o[1]>c[0]&&o[1]<c[3]))a.label=o[1];else if(6===o[0]&&a.label<c[1])a.label=c[1],c=o;else{if(!(c&&a.label<c[2])){c[2]&&a.ops.pop(),a.trys.pop();continue}a.label=c[2],a.ops.push(o)}}o=t.call(n,a)}catch(e){o=[6,e],l=0}finally{i=c=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}},simpl_schema_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadCollectionMethods=void 0,require("simpl-schema")),pagination_model_1=require("../models/pagination.model"),resolveio_server_app_1=require("../resolveio-server-app"),common_1=require("../util/common");function loadCollectionMethods(e){e.methods({collectionListAll:{function:function(){return Promise.resolve(resolveio_server_app_1.ResolveIOServer.getMongoManager().collections().map(function(e){return e.collectionName}).sort(function(e,o){return e.localeCompare(o)}))}},collectionListRB:{function:function(){return Promise.resolve(resolveio_server_app_1.ResolveIOServer.getMongoManager().collections().filter(function(e){return e.useRB}).map(function(e){return e.collectionName}).sort(function(e,o){return e.localeCompare(o)}))}},findOne:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,o){if(void 0===o&&(o={}),resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).findOne(o);throw new Error("Error in Find One Collection: Invalid collection")}},find:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0},sort:{type:Object,blackbox:!0,optional:!0}}),function:function(e,o,r){if(void 0===o&&(o={}),void 0===r&&(r={}),resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).find(o,{sort:r});throw new Error("Error in Find Collection: Invalid collection")}},findWithOptions:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0},options:{type:pagination_model_1.PaginationOptionsSchema}}),function:function(e,o,r){var n;if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return n={},r.fields&&Object.keys(r.fields).length&&(n.projection=r.fields),r.sort&&Object.keys(r.sort).length&&(n.sort=r.sort),r.limit&&(n.limit=r.limit),r.skip&&(n.skip=r.skip),resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).find(o,n);throw new Error("Error in Find With Options Collection: Invalid collection")}},insertDocument:{check:new simpl_schema_1.default({collection:{type:String},document:{type:Object,blackbox:!0}}),function:function(r,n){return __awaiter(this,void 0,void 0,function(){var o;return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(r))return[3,1];throw new Error("Error in Insert Document Collection: Invalid collection");case 1:return o=(0,common_1.objectIdHexString)(),n._id=o,n.__v=0,[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(r).insertOne(n)];case 2:return e.sent(),[2,o]}})})}},insertManyDocuments:{check:new simpl_schema_1.default({collection:{type:String},documents:{type:Array},"documents.$":{type:Object,blackbox:!0}}),function:function(o,r){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(o))return[3,1];throw new Error("Error in Insert Many Documents Collection: Invalid collection");case 1:return r.forEach(function(e){e._id=(0,common_1.objectIdHexString)(),e.__v=0}),[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(o).insertMany(r)];case 2:return e.sent(),[2,r.map(function(e){return e._id})]}})})}},updateDocument:{check:new simpl_schema_1.default({collection:{type:String},f_document:{type:Object,blackbox:!0}}),function:function(e,o){if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).replaceOne({_id:o._id},o);throw new Error("Error in Update Document Collection: Invalid collection")}},updateDocumentProps:{check:new simpl_schema_1.default({collection:{type:String},doc_id:{type:String},updateParams:{type:Array},"updateParams.$":{type:Object,blackbox:!0},doc__v:{type:Number,optional:!0}}),function:function(l,c,a,s){return __awaiter(this,void 0,void 0,function(){var o,r,n,t,i;return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l))return[3,1];throw new Error("Error in Update Document Props Collection: Invalid collection");case 1:return[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).findOne({_id:c})];case 2:return(o=e.sent())?(r=(0,common_1.deepCopy)(o),a.forEach(function(e){r[e.prop]=e.data}),s&&r.__v!==s?[3,3]:[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:r._id},r,{},!1,!1,o)]):[3,7];case 3:return(console.log(new Date,"invalid version - "+l,o.__v,s),resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions"))?[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions").findOne({_id:{_id:o._id,__v:s}})]:[3,5];case 4:if(i=e.sent(),n=o._id,t=o.__v,i)return(i=(0,common_1.getMongoMergeUpdatedDoc)(r,o,i))._id=n,i.__v=t,o._id=n,o.__v=t,[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:n},i,{},!1,!1,o)];throw new Error("Error In Update Document Props Collections: Invalid Version And Could Not Find History Props - DB: "+t+", Trying to update with :"+s);case 5:throw new Error("Error In Update Document Props Collections: Invalid Version And We Are NOT Using Versions On This Collection!");case 6:return[3,8];case 7:throw new Error("Error in Update Document Props Collections: No Document");case 8:return[2]}})})}},updateDocumentOffline:{check:new simpl_schema_1.default({collection:{type:String},f_document:{type:Object,blackbox:!0}}),function:function(l,c){return __awaiter(this,void 0,void 0,function(){var o,r,n,t,i;return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l))return[3,1];throw new Error("Error in Update Document Offline Collection: Invalid collection");case 1:return[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).findOne({_id:c._id})];case 2:return(o=e.sent())?o.__v!==c.__v?[3,3]:[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:c._id},c,{},!1,!1,o)]:[3,7];case 3:return(console.log("OFFLINE - invalid version - "+l,o.__v,c.__v),r=o._id,n=o.__v,t=c.__v,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions"))?[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions").findOne({_id:{_id:r,__v:t}})]:[3,5];case 4:if(i=e.sent())return(i=(0,common_1.getMongoMergeUpdatedDoc)(c,o,i))._id=r,i.__v=n,o._id=r,o.__v=n,[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:r},i,{},!1,!1,o)];throw new Error("Error in Update Document Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: "+n+", Trying to update with :"+t);case 5:throw new Error("Error in Update Document Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!");case 6:return[3,8];case 7:throw new Error("Error in Update Document Offline Collections: No Document");case 8:return[2]}})})}},updateDocumentPropsOffline:{check:new simpl_schema_1.default({collection:{type:String},doc_id:{type:String},updateParams:{type:Array},"updateParams.$":{type:Object,blackbox:!0},doc__v:{type:Number}}),function:function(l,c,a,s){return __awaiter(this,void 0,void 0,function(){var o,r,n,t,i;return __generator(this,function(e){switch(e.label){case 0:if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l))return[3,1];throw new Error("Error in Update Document Props Offline Collection: Invalid collection");case 1:return[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).findOne({_id:c},null,!0)];case 2:return(o=e.sent())?(r=(0,common_1.deepCopy)(o),a.forEach(function(e){r[e.prop]=e.data}),r.__v!==s?[3,3]:[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:r._id},r,{},!1,!1,o)]):[3,7];case 3:return(console.log("OFFLINE - invalid version - "+l,o.__v,s),n=o._id,t=o.__v,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions"))?[4,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l+".versions").findOne({_id:{_id:o._id,__v:s}})]:[3,5];case 4:if(i=e.sent())return(i=(0,common_1.getMongoMergeUpdatedDoc)(r,o,i))._id=n,i.__v=t,o._id=n,o.__v=t,[2,resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(l).replaceOne({_id:n},i,{},!1,!1,o)];throw new Error("Error in Update Document Props Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: "+t+", Trying to update with :"+s);case 5:throw new Error("Error in Update Document Props Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!");case 6:return[3,8];case 7:throw new Error("Error in Update Document Props Offline Collections: No Document");case 8:return[2]}})})}},removeDocument:{check:new simpl_schema_1.default({collection:{type:String},doc_id:{type:String}}),function:function(e,o){if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).deleteOne({_id:o});throw new Error("Error in Remove Document Collection: Invalid collection")}},removeDocumentWithQuery:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,o){if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).deleteOne(o);throw new Error("Error in Remove Document With Query Collection: Invalid collection")}},removeDocumentsWithQuery:{check:new simpl_schema_1.default({collection:{type:String},query:{type:Object,blackbox:!0}}),function:function(e,o){if(resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e))return resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(e).deleteMany(o);throw new Error("Error in Remove Documents With Query Collections: Invalid Collection")}}})}exports.loadCollectionMethods=loadCollectionMethods;
|
|
2
2
|
//# sourceMappingURL=collections.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/methods/collections.ts"],"names":["simpl_schema_1","require","pagination_model_1","resolveio_server_app_1","common_1","loadCollectionMethods","methodManager","methods","collectionListAll","function","Promise","resolve","ResolveIOServer","getMongoManager","collections","map","a","collectionName","sort","b","localeCompare","collectionListRB","filter","useRB","findOne","check","default","collection","type","String","query","Object","blackbox","Error","find","optional","sortQuery","findWithOptions","options","PaginationOptionsSchema","optionsQuery","fields","keys","length","limit","skip","insertDocument","document","id","objectIdHexString","insertOne","_a","sent","insertManyDocuments","documents","Array","documents.$","forEach","insertMany","updateDocument","f_document","replaceOne","_id","updateDocumentProps","doc_id","updateParams","updateParams.$","doc__v","Number","currDoc","modifiedDoc_1","deepCopy","data","prop","__v","console","log","Date","oldDoc","newCurrDocId","newCurrDocV","updatedDoc","getMongoMergeUpdatedDoc","updateDocumentOffline","oldDocV","updateDocumentPropsOffline","modifiedDoc_2","removeDocument","deleteOne","removeDocumentWithQuery","removeDocumentsWithQuery","deleteMany","exports"],"mappings":"k8CAAAA,gB,4FAAAC,QAAA,cAAA,GAEAC,mBAAAD,QAAA,4BAAA,EACAE,uBAAAF,QAAA,yBAAA,EACAG,SAAAH,QAAA,gBAAA,EAEA,SAAgBI,sBAAsBC,GACrCA,EAAcC,QAAQ,CACrBC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CACxBhE,MAAO,IAAIzB,eAAA0B,QAAa,CACvBC,WAAY,CACXC,KAAMC,M,EAEPC,MAAO,CACNF,KAAMG,OACNC,SAAU,CAAA,C,EAEX,EACDvB,SAAU,SAASkB,EAAoBG,GACtC,GAAK3B,uBAAAS,gBAAgBC,gBAAe,EAAGc,WAAWA,CAAU,EAI5D,OAAOxB,uBAAAS,gBAAgBC,gBAAe,EAAGc,WAAWA,CAAU,EAAE6D,UAAU1D,CAAK,EAH9E,MAAM,IAAIG,MAAM,oEAAoE,CAItF,C,EAEDyD,yBAA0B,CACzBjE,MAAO,IAAIzB,eAAA0B,QAAa,CACvBC,WAAY,CACXC,KAAMC,M,EAEPC,MAAO,CACNF,KAAMG,OACNC,SAAU,CAAA,C,EAEX,EACDvB,SAAU,SAASkB,EAAoBG,GACtC,GAAK3B,uBAAAS,gBAAgBC,gBAAe,EAAGc,WAAWA,CAAU,EAI5D,OAAOxB,uBAAAS,gBAAgBC,gBAAe,EAAGc,WAAWA,CAAU,EAAEgE,WAAW7D,CAAK,EAH/E,MAAM,IAAIG,MAAM,sEAAsE,CAIxF,C,EAED,CACF,CA5aA2D,QAAAvF,sBAAAA","file":"collections.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { MethodManager } from '../managers/method.manager';\nimport { PaginationOptions, PaginationOptionsSchema } from '../models/pagination.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { deepCopy, getMongoMergeUpdatedDoc, objectIdHexString } from '../util/common';\n\nexport function loadCollectionMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tcollectionListAll: {\n\t\t\tfunction: function() {\n\t\t\t\treturn Promise.resolve(ResolveIOServer.getMongoManager().collections().map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));\n\t\t\t}\n\t\t},\n\t\tcollectionListRB: {\n\t\t\tfunction: function() {\n\t\t\t\treturn Promise.resolve(ResolveIOServer.getMongoManager().collections().filter(a => a.useRB).map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));\n\t\t\t}\n\t\t},\n\t\t// Query database for any collection and query\n\t\tfindOne: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query = {}) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find One Collection: Invalid collection');\n\t\t\t\t}\n\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).findOne(query);\n\t\t\t}\n\t\t},\n\t\tfind: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tsort: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query = {}, sortQuery = {}) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).find(query, {sort: sortQuery});\n\t\t\t}\n\t\t},\n\t\tfindWithOptions: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\toptions: {\n\t\t\t\t\ttype: PaginationOptionsSchema\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query: Object, options: PaginationOptions) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find With Options Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet optionsQuery = {};\n\n\t\t\t\t\tif (options.fields && Object.keys(options.fields).length) {\n\t\t\t\t\t\toptionsQuery['projection'] = options.fields;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.sort && Object.keys(options.sort).length) {\n\t\t\t\t\t\toptionsQuery['sort'] = options.sort;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.limit) {\n\t\t\t\t\t\toptionsQuery['limit'] = options.limit;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.skip) {\n\t\t\t\t\t\toptionsQuery['skip'] = options.skip;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).find(query, optionsQuery);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Insert 1 document\n\t\t// @Inputs: collection, document\n\t\t// @Outputs: res = _id of new document, err = not inserted\n\t\tinsertDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdocument: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Insert Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet id = objectIdHexString();\n\t\t\t\t\tdocument['_id'] = id;\n\t\t\t\t\tdocument['__v'] = 0;\n\n\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).insertOne(document);\n\t\t\t\t\treturn id;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Insert 1 document\n\t\t// @Inputs: collection, document\n\t\t// @Outputs: res = _id of new document, err = not inserted\n\t\tinsertManyDocuments: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdocuments: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'documents.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, documents: Object[]) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Insert Many Documents Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdocuments.forEach(document => {\n\t\t\t\t\t\tdocument['_id'] = objectIdHexString();\n\t\t\t\t\t\tdocument['__v'] = 0;\n\t\t\t\t\t});\n\n\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).insertMany(documents);\n\t\t\t\t\treturn documents.map(a => a['_id']);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Replaces 1 document with new document (from _id)\n\t\t// @Inputs: collection, document id\n\t\t// @Outputs: res = 1 (updated 1), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update\n\t\tupdateDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tf_document: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, f_document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document);\n\t\t\t}\n\t\t},\n\t\t// Updates 1 document's props (from _id)\n\t\t// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})\n\t\t// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update props\n\t\tupdateDocumentProps: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tupdateParams: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'updateParams.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tdoc__v: {\n\t\t\t\t\ttype: Number,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string, updateParams: any[], doc__v?: number) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Props Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id});\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tlet modifiedDoc = deepCopy(currDoc);\n\n\t\t\t\t\t\tupdateParams.forEach(data => {\n\t\t\t\t\t\t\tmodifiedDoc[data.prop] = data.data;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!doc__v || modifiedDoc.__v === doc__v) {\n\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log(new Date(), 'invalid version - ' + collection, currDoc.__v, doc__v);\n\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = ResolveIOServer.getMongoManager().collection(collection + '.versions');\n\t\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error In Update Document Props Collections: Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error In Update Document Props Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Props Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tupdateDocumentOffline: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tf_document: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, f_document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Offline Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: f_document['_id']});\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tif (currDoc.__v === f_document['__v']) {\n\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('OFFLINE - invalid version - ' + collection, currDoc.__v, f_document['__v']);\n\n\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\t\t\t\t\t\t\tlet oldDocV = f_document['__v'];\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = ResolveIOServer.getMongoManager().collection(collection + '.versions');\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(f_document, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + oldDocV);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Updates 1 document's props (from _id)\n\t\t// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})\n\t\t// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update props\n\t\tupdateDocumentPropsOffline: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tupdateParams: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'updateParams.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tdoc__v: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string, updateParams: any[], doc__v: number) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id}, null, true);\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tlet modifiedDoc = deepCopy(currDoc);\n\n\t\t\t\t\t\tupdateParams.forEach(data => {\n\t\t\t\t\t\t\tmodifiedDoc[data.prop] = data.data;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (modifiedDoc.__v === doc__v) {\n\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('OFFLINE - invalid version - ' + collection, currDoc.__v, doc__v);\n\n\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = ResolveIOServer.getMongoManager().collection(collection + '.versions');\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Removes 1 document (from _id)\n\t\t// @Inputs: collection, document id\n\t\t// @Outputs: res = 1 (deleted), res = 0 (not deleted), err = not deleted\n\t\t// Search for doc, if found then try and remove\n\t\tremoveDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, doc_id: string) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).deleteOne({_id: doc_id});\n\t\t\t}\n\t\t},\n\t\tremoveDocumentWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Document With Query Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).deleteOne(query);\n\t\t\t}\n\t\t},\n\t\tremoveDocumentsWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Documents With Query Collections: Invalid Collection');\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).deleteMany(query);\n\t\t\t}\n\t\t}\n\t});\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/methods/collections.ts"],"names":["simpl_schema_1","require","pagination_model_1","resolveio_server_app_1","common_1","loadCollectionMethods","methodManager","methods","collectionListAll","function","Promise","resolve","ResolveIOServer","getMongoManager","collections","map","a","collectionName","sort","b","localeCompare","collectionListRB","filter","useRB","findOne","check","default","collection","type","String","query","Object","blackbox","Error","find","optional","sortQuery","findWithOptions","options","PaginationOptionsSchema","optionsQuery","fields","keys","length","limit","skip","insertDocument","document","id","objectIdHexString","insertOne","_a","sent","insertManyDocuments","documents","Array","documents.$","forEach","insertMany","updateDocument","f_document","replaceOne","_id","updateDocumentProps","doc_id","updateParams","updateParams.$","doc__v","Number","currDoc","modifiedDoc_1","deepCopy","data","prop","__v","console","log","Date","oldDoc","newCurrDocId","newCurrDocV","updatedDoc","getMongoMergeUpdatedDoc","updateDocumentOffline","oldDocV","updateDocumentPropsOffline","modifiedDoc_2","removeDocument","deleteOne","removeDocumentWithQuery","removeDocumentsWithQuery","deleteMany","exports"],"mappings":"k8CAAAA,gB,4FAAAC,QAAA,cAAA,GAEAC,mBAAAD,QAAA,4BAAA,EACAE,uBAAAF,QAAA,yBAAA,EACAG,SAAAH,QAAA,gBAAA,EAEA,SAAgBI,sBAAsBC,GACrCA,EAAcC,QAAQ,CACrBC,kBAAmB,CAClBC,SAAU,WACT,OAAOC,QAAQC,QAAQR,uBAAAS,gBAAgBC,gBAAe,EAAGC,YAAW,EAAGC,IAAI,SAAAC,GAAK,OAAAA,EAAEC,cAAF,CAAgB,EAAEC,KAAK,SAACF,EAAGG,GAAM,OAAAH,EAAEI,cAAcD,CAAC,CAAjB,CAAkB,CAAC,CACrI,C,EAEDE,iBAAkB,CACjBZ,SAAU,WACT,OAAOC,QAAQC,QAAQR,uBAAAS,gBAAgBC,gBAAe,EAAG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AAI/B,MAAM,yDAAyD,CAI3E,C,EAEDwD,wBAAyB,CACxBhE,MAAO,IAAIzB,eAAA0B,QAAa,CACvBC,WAAY,CACXC,KAAMC,M,EAEPC,MAAO,CACNF,KAAMG,OACNC,SAAU,CAAA,C,EAEX,EACDvB,SAAU,SAASkB,EAAoBG,GACtC,GAAK3B,uBAAAS,gBAAgBC,gBAAe,EAAGc,WAAWA,CAAU,EAI5D,OAAOxB,uBAAAS,gBAAgBC,gBAAe,EAAGc,WAAWA,CAAU,EAAE6D,UAAU1D,CAAK,EAH9E,MAAM,IAAIG,MAAM,oEAAoE,CAItF,C,EAEDyD,yBAA0B,CACzBjE,MAAO,IAAIzB,eAAA0B,QAAa,CACvBC,WAAY,CACXC,KAAMC,M,EAEPC,MAAO,CACNF,KAAMG,OACNC,SAAU,CAAA,C,EAEX,EACDvB,SAAU,SAASkB,EAAoBG,GACtC,GAAK3B,uBAAAS,gBAAgBC,gBAAe,EAAGc,WAAWA,CAAU,EAI5D,OAAOxB,uBAAAS,gBAAgBC,gBAAe,EAAGc,WAAWA,CAAU,EAAEgE,WAAW7D,CAAK,EAH/E,MAAM,IAAIG,MAAM,sEAAsE,CAIxF,C,EAED,CACF,CA9bA2D,QAAAvF,sBAAAA","file":"collections.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { MethodManager } from '../managers/method.manager';\nimport { PaginationOptions, PaginationOptionsSchema } from '../models/pagination.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { deepCopy, getMongoMergeUpdatedDoc, objectIdHexString } from '../util/common';\n\nexport function loadCollectionMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tcollectionListAll: {\n\t\t\tfunction: function() {\n\t\t\t\treturn Promise.resolve(ResolveIOServer.getMongoManager().collections().map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));\n\t\t\t}\n\t\t},\n\t\tcollectionListRB: {\n\t\t\tfunction: function() {\n\t\t\t\treturn Promise.resolve(ResolveIOServer.getMongoManager().collections().filter(a => a.useRB).map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));\n\t\t\t}\n\t\t},\n\t\t// Query database for any collection and query\n\t\tfindOne: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query = {}) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find One Collection: Invalid collection');\n\t\t\t\t}\n\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).findOne(query);\n\t\t\t}\n\t\t},\n\t\tfind: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tsort: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query = {}, sortQuery = {}) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).find(query, {sort: sortQuery});\n\t\t\t}\n\t\t},\n\t\tfindWithOptions: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\toptions: {\n\t\t\t\t\ttype: PaginationOptionsSchema\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query: Object, options: PaginationOptions) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find With Options Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet optionsQuery = {};\n\n\t\t\t\t\tif (options.fields && Object.keys(options.fields).length) {\n\t\t\t\t\t\toptionsQuery['projection'] = options.fields;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.sort && Object.keys(options.sort).length) {\n\t\t\t\t\t\toptionsQuery['sort'] = options.sort;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.limit) {\n\t\t\t\t\t\toptionsQuery['limit'] = options.limit;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.skip) {\n\t\t\t\t\t\toptionsQuery['skip'] = options.skip;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).find(query, optionsQuery);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Insert 1 document\n\t\t// @Inputs: collection, document\n\t\t// @Outputs: res = _id of new document, err = not inserted\n\t\tinsertDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdocument: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Insert Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet id = objectIdHexString();\n\t\t\t\t\tdocument['_id'] = id;\n\t\t\t\t\tdocument['__v'] = 0;\n\n\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).insertOne(document);\n\t\t\t\t\treturn id;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Insert 1 document\n\t\t// @Inputs: collection, document\n\t\t// @Outputs: res = _id of new document, err = not inserted\n\t\tinsertManyDocuments: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdocuments: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'documents.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, documents: Object[]) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Insert Many Documents Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdocuments.forEach(document => {\n\t\t\t\t\t\tdocument['_id'] = objectIdHexString();\n\t\t\t\t\t\tdocument['__v'] = 0;\n\t\t\t\t\t});\n\n\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).insertMany(documents);\n\t\t\t\t\treturn documents.map(a => a['_id']);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Replaces 1 document with new document (from _id)\n\t\t// @Inputs: collection, document id\n\t\t// @Outputs: res = 1 (updated 1), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update\n\t\tupdateDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tf_document: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, f_document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document);\n\t\t\t}\n\t\t},\n\t\t// Updates 1 document's props (from _id)\n\t\t// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})\n\t\t// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update props\n\t\tupdateDocumentProps: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tupdateParams: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'updateParams.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tdoc__v: {\n\t\t\t\t\ttype: Number,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string, updateParams: any[], doc__v?: number) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Props Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id});\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tlet modifiedDoc = deepCopy(currDoc);\n\n\t\t\t\t\t\tupdateParams.forEach(data => {\n\t\t\t\t\t\t\tmodifiedDoc[data.prop] = data.data;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!doc__v || modifiedDoc.__v === doc__v) {\n\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log(new Date(), 'invalid version - ' + collection, currDoc.__v, doc__v);\n\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = await ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\t_id: currDoc._id,\n\t\t\t\t\t\t\t\t\t\t__v: doc__v\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error In Update Document Props Collections: Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error In Update Document Props Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Props Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tupdateDocumentOffline: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tf_document: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, f_document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Offline Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: f_document['_id']});\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tif (currDoc.__v === f_document['__v']) {\n\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('OFFLINE - invalid version - ' + collection, currDoc.__v, f_document['__v']);\n\n\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\t\t\t\t\t\t\tlet oldDocV = f_document['__v'];\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = await ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\t_id: newCurrDocId,\n\t\t\t\t\t\t\t\t\t\t__v: oldDocV\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(f_document, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + oldDocV);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Updates 1 document's props (from _id)\n\t\t// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})\n\t\t// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update props\n\t\tupdateDocumentPropsOffline: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tupdateParams: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'updateParams.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tdoc__v: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string, updateParams: any[], doc__v: number) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id}, null, true);\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tlet modifiedDoc = deepCopy(currDoc);\n\n\t\t\t\t\t\tupdateParams.forEach(data => {\n\t\t\t\t\t\t\tmodifiedDoc[data.prop] = data.data;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (modifiedDoc.__v === doc__v) {\n\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('OFFLINE - invalid version - ' + collection, currDoc.__v, doc__v);\n\n\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = await ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\t_id: currDoc._id,\n\t\t\t\t\t\t\t\t\t\t__v: doc__v\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\t\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Removes 1 document (from _id)\n\t\t// @Inputs: collection, document id\n\t\t// @Outputs: res = 1 (deleted), res = 0 (not deleted), err = not deleted\n\t\t// Search for doc, if found then try and remove\n\t\tremoveDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, doc_id: string) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).deleteOne({_id: doc_id});\n\t\t\t}\n\t\t},\n\t\tremoveDocumentWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Document With Query Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).deleteOne(query);\n\t\t\t}\n\t\t},\n\t\tremoveDocumentsWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Documents With Query Collections: Invalid Collection');\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).deleteMany(query);\n\t\t\t}\n\t\t}\n\t});\n}"]}
|
package/package.json
CHANGED
package/public_api.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export * from './collections/log-method-latency.collection';
|
|
|
11
11
|
export * from './collections/log-subscription.collection';
|
|
12
12
|
export * from './collections/log.collection';
|
|
13
13
|
export * from './collections/logged-in-users.collection';
|
|
14
|
-
export * from './collections/method-response.collection';
|
|
15
14
|
export * from './collections/monitor-cpu.collection';
|
|
16
15
|
export * from './collections/monitor-function.collection';
|
|
17
16
|
export * from './collections/monitor-memory.collection';
|
package/public_api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,o,t){void 0===t&&(t=o);var l=Object.getOwnPropertyDescriptor(r,o);l&&("get"in l?r.__esModule:!l.writable&&!l.configurable)||(l={enumerable:!0,get:function(){return r[o]}}),Object.defineProperty(e,t,l)}:function(e,r,o,t){e[t=void 0===t?o:t]=r[o]}),__exportStar=this&&this.__exportStar||function(e,r){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(r,o)||__createBinding(r,e,o)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./collections/app-status.collection"),exports),__exportStar(require("./collections/counter.collection"),exports),__exportStar(require("./collections/cron-job-history.collection"),exports),__exportStar(require("./collections/cron-job.collection"),exports),__exportStar(require("./collections/email-history.collection"),exports),__exportStar(require("./collections/email-verified.collection"),exports),__exportStar(require("./collections/file.collection"),exports),__exportStar(require("./collections/flag-update.collection"),exports),__exportStar(require("./collections/flag.collection"),exports),__exportStar(require("./collections/log-method-latency.collection"),exports),__exportStar(require("./collections/log-subscription.collection"),exports),__exportStar(require("./collections/log.collection"),exports),__exportStar(require("./collections/logged-in-users.collection"),exports),__exportStar(require("./collections/
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,o,t){void 0===t&&(t=o);var l=Object.getOwnPropertyDescriptor(r,o);l&&("get"in l?r.__esModule:!l.writable&&!l.configurable)||(l={enumerable:!0,get:function(){return r[o]}}),Object.defineProperty(e,t,l)}:function(e,r,o,t){e[t=void 0===t?o:t]=r[o]}),__exportStar=this&&this.__exportStar||function(e,r){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(r,o)||__createBinding(r,e,o)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./collections/app-status.collection"),exports),__exportStar(require("./collections/counter.collection"),exports),__exportStar(require("./collections/cron-job-history.collection"),exports),__exportStar(require("./collections/cron-job.collection"),exports),__exportStar(require("./collections/email-history.collection"),exports),__exportStar(require("./collections/email-verified.collection"),exports),__exportStar(require("./collections/file.collection"),exports),__exportStar(require("./collections/flag-update.collection"),exports),__exportStar(require("./collections/flag.collection"),exports),__exportStar(require("./collections/log-method-latency.collection"),exports),__exportStar(require("./collections/log-subscription.collection"),exports),__exportStar(require("./collections/log.collection"),exports),__exportStar(require("./collections/logged-in-users.collection"),exports),__exportStar(require("./collections/monitor-cpu.collection"),exports),__exportStar(require("./collections/monitor-function.collection"),exports),__exportStar(require("./collections/monitor-memory.collection"),exports),__exportStar(require("./collections/monitor-mongo.collection"),exports),__exportStar(require("./collections/notification.collection"),exports),__exportStar(require("./collections/report-builder-library.collection"),exports),__exportStar(require("./collections/report-builder-report.collection"),exports),__exportStar(require("./collections/user-group.collection"),exports),__exportStar(require("./collections/user-guide.collection"),exports),__exportStar(require("./collections/user.collection"),exports),__exportStar(require("./managers/mongo.manager"),exports),__exportStar(require("./models/app-status.model"),exports),__exportStar(require("./models/billing-logged-in-users.model"),exports),__exportStar(require("./models/collection-document.model"),exports),__exportStar(require("./models/counter.model"),exports),__exportStar(require("./models/cron-job-history.model"),exports),__exportStar(require("./models/cron-job.model"),exports),__exportStar(require("./models/dialog.model"),exports),__exportStar(require("./models/email-history.model"),exports),__exportStar(require("./models/email-verified.model"),exports),__exportStar(require("./models/file.model"),exports),__exportStar(require("./models/flag-update.model"),exports),__exportStar(require("./models/flag.model"),exports),__exportStar(require("./models/log-method-latency.model"),exports),__exportStar(require("./models/log-subscription.model"),exports),__exportStar(require("./models/log.model"),exports),__exportStar(require("./models/logged-in-users.model"),exports),__exportStar(require("./models/method-response.model"),exports),__exportStar(require("./models/method.model"),exports),__exportStar(require("./models/monitor-cpu.model"),exports),__exportStar(require("./models/monitor-memory.model"),exports),__exportStar(require("./models/monitor-mongo.model"),exports),__exportStar(require("./models/notification.model"),exports),__exportStar(require("./models/pagination.model"),exports),__exportStar(require("./models/permission.model"),exports),__exportStar(require("./models/report-builder-library.model"),exports),__exportStar(require("./models/report-builder-report.model"),exports),__exportStar(require("./models/report-builder.model"),exports),__exportStar(require("./models/select-data-label.model"),exports),__exportStar(require("./models/server-response.model"),exports),__exportStar(require("./models/subscription.model"),exports),__exportStar(require("./models/support-ticket.model"),exports),__exportStar(require("./models/user-group.model"),exports),__exportStar(require("./models/user-guide.model"),exports),__exportStar(require("./models/user.model"),exports),__exportStar(require("./resolveio-server-app"),exports),__exportStar(require("./util/common"),exports);
|
|
2
2
|
//# sourceMappingURL=public_api.js.map
|
package/public_api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/public_api.ts"],"names":["__exportStar","require","exports"],"mappings":"4hBAAAA,aAAAC,QAAA,qCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,kCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,2CAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,mCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,wCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,yCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,+BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,sCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,+BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,6CAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,2CAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,8BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,0CAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/public_api.ts"],"names":["__exportStar","require","exports"],"mappings":"4hBAAAA,aAAAC,QAAA,qCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,kCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,2CAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,mCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,wCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,yCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,+BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,sCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,+BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,6CAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,2CAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA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4BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,+BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,8BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,6BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,2BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,2BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,uCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,sCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,+BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,kCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,gCAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,6BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,+BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,2BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,2BAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,qBAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,wBAAA,EAAAC,OAAA,EACAF,aAAAC,QAAA,eAAA,EAAAC,OAAA","file":"public_api.js","sourcesContent":["export * from './collections/app-status.collection';\nexport * from './collections/counter.collection';\nexport * from './collections/cron-job-history.collection';\nexport * from './collections/cron-job.collection';\nexport * from './collections/email-history.collection';\nexport * from './collections/email-verified.collection';\nexport * from './collections/file.collection';\nexport * from './collections/flag-update.collection';\nexport * from './collections/flag.collection';\nexport * from './collections/log-method-latency.collection';\nexport * from './collections/log-subscription.collection';\nexport * from './collections/log.collection';\nexport * from './collections/logged-in-users.collection';\nexport * from './collections/monitor-cpu.collection';\nexport * from './collections/monitor-function.collection';\nexport * from './collections/monitor-memory.collection';\nexport * from './collections/monitor-mongo.collection';\nexport * from './collections/notification.collection';\nexport * from './collections/report-builder-library.collection';\nexport * from './collections/report-builder-report.collection';\nexport * from './collections/user-group.collection';\nexport * from './collections/user-guide.collection';\nexport * from './collections/user.collection';\nexport * from './managers/mongo.manager';\nexport * from './models/app-status.model';\nexport * from './models/billing-logged-in-users.model';\nexport * from './models/collection-document.model';\nexport * from './models/counter.model';\nexport * from './models/cron-job-history.model';\nexport * from './models/cron-job.model';\nexport * from './models/dialog.model';\nexport * from './models/email-history.model';\nexport * from './models/email-verified.model';\nexport * from './models/file.model';\nexport * from './models/flag-update.model';\nexport * from './models/flag.model';\nexport * from './models/log-method-latency.model';\nexport * from './models/log-subscription.model';\nexport * from './models/log.model';\nexport * from './models/logged-in-users.model';\nexport * from './models/method-response.model';\nexport * from './models/method.model';\nexport * from './models/monitor-cpu.model';\nexport * from './models/monitor-memory.model';\nexport * from './models/monitor-mongo.model';\nexport * from './models/notification.model';\nexport * from './models/pagination.model';\nexport * from './models/permission.model';\nexport * from './models/report-builder-library.model';\nexport * from './models/report-builder-report.model';\nexport * from './models/report-builder.model';\nexport * from './models/select-data-label.model';\nexport * from './models/server-response.model';\nexport * from './models/subscription.model';\nexport * from './models/support-ticket.model';\nexport * from './models/user-group.model';\nexport * from './models/user-guide.model';\nexport * from './models/user.model';\nexport * from './resolveio-server-app';\nexport * from './util/common';\n\n"]}
|
package/publications.ts
CHANGED
|
@@ -47,9 +47,6 @@ export function SERVER_PUBLICATIONS(resolveioServer) {
|
|
|
47
47
|
methodlatencies: () => {
|
|
48
48
|
return <Observable<any>> resolveioServer.subscribe('methodlatencies');
|
|
49
49
|
},
|
|
50
|
-
methodresponses: () => {
|
|
51
|
-
return <Observable<any>> resolveioServer.subscribe('methodresponses');
|
|
52
|
-
},
|
|
53
50
|
notifications: () => {
|
|
54
51
|
return <Observable<any>> resolveioServer.subscribe('notifications');
|
|
55
52
|
},
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MethodResponses=void 0;var mongo_manager_1=require("../managers/mongo.manager"),resolveio_server_app_1=require("../resolveio-server-app"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},id_user:{type:String},message_id:{type:Number},method:{type:String},response:{type:Object,blackbox:!0},date:{type:Date}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()&&mongo_manager_1.MongoManagerModel?(e=mongo_manager_1.MongoManagerModel.create({collectionName:"method-responses",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.MethodResponses=e.collection_main,exports.MethodResponses.createIndex({id_user:1,message_id:1}),exports.MethodResponses.createIndex({createdAt:1},{expireAfterSeconds:86400})):setImmediate(function(){initializeCollection()})}exports.MethodResponses=null,initializeCollection();
|
|
2
|
-
//# sourceMappingURL=method-response.collection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/method-response.collection.ts"],"names":["mongo_manager_1","require","resolveio_server_app_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","id_user","message_id","method","response","Object","blackbox","date","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","create","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","MethodResponses","collection_main","createIndex","expireAfterSeconds","setImmediate"],"mappings":"mGAAA,IAAAA,gBAAAC,QAAA,2BAAA,EAEAC,uBAAAD,QAAA,yBAAA,EAEIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,QAAS,CACRR,KAAMC,M,EAEPQ,WAAY,CACXT,KAAMI,M,EAEPM,OAAQ,CACPV,KAAMC,M,EAEPU,SAAU,CACTX,KAAMY,OACNC,SAAU,CAAA,C,EAEXC,KAAM,CACLd,KAAMM,I,GAQR,SAASS,uBACR,IACOC,EADHnB,uBAAAoB,iBAAmBpB,uBAAAoB,gBAAgBC,UAAS,GAAMvB,gBAAAwB,mBAC/CH,EAAQrB,gBAAAwB,kBAAkBC,OAA4B,CAC3DC,eAAgB,mBAChBvB,OAAQA,OACRwB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,I,CACnB,EACDC,QAAAC,gBAAkBd,EAAMe,gBACxBF,QAAAC,gBAAgBE,YAAY,CAACxB,QAAS,EAAGC,WAAY,CAAC,CAAC,EACvDoB,QAAAC,gBAAgBE,YAAY,CAACzB,UAAW,CAAC,EAAG,CAAC0B,mBAAoB,KAAK,CAAC,GAGvEC,aAAa,WACZnB,qBAAoB,CACrB,CAAC,CAEH,CA1BWc,QAAAC,gBAA+D,KAE1Ef,qBAAoB","file":"method-response.collection.js","sourcesContent":["import { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { MethodResponseModel } from '../models/method-response.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tid_user: {\n\t\ttype: String\n\t},\n\tmessage_id: {\n\t\ttype: Number\n\t},\n\tmethod: {\n\t\ttype: String\n\t},\n\tresponse: {\n\t\ttype: Object,\n\t\tblackbox: true\n\t},\n\tdate: {\n\t\ttype: Date\n\t}\n};\n\nexport let MethodResponses: MongoManagerCollection<MethodResponseModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB() && MongoManagerModel) {\n\t\tconst model = MongoManagerModel.create<MethodResponseModel>({\n\t\t\tcollectionName: 'method-responses',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null\n\t\t});\n\t\tMethodResponses = model.collection_main;\n\t\tMethodResponses.createIndex({id_user: 1, message_id: 1});\n\t\tMethodResponses.createIndex({createdAt: 1}, {expireAfterSeconds: 86400});\n\t}\n\telse {\n\t\tsetImmediate(() => {\n\t\t\tinitializeCollection();\n\t\t});\n\t}\n}"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadMethodResponsePublications=void 0;var method_response_collection_1=require("../collections/method-response.collection");function loadMethodResponsePublications(e){e.publications({methodresponses:{function:function(){return method_response_collection_1.MethodResponses.find({})},collections:["method-responses"]}})}exports.loadMethodResponsePublications=loadMethodResponsePublications;
|
|
2
|
-
//# sourceMappingURL=method-responses.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/publications/method-responses.ts"],"names":["method_response_collection_1","require","loadMethodResponsePublications","subscriptionManager","publications","methodresponses","function","MethodResponses","find","collections","exports"],"mappings":"kHACA,IAAAA,6BAAAC,QAAA,2CAAA,EAEA,SAAgBC,+BAA+BC,GAC9CA,EAAoBC,aAAa,CAChCC,gBAAiB,CAChBC,SAAU,WACT,OAAON,6BAAAO,gBAAgBC,KAAK,EAAE,CAC/B,EACAC,YAAa,CAAC,mB,EAEf,CACF,CATAC,QAAAR,+BAAAA","file":"method-responses.js","sourcesContent":["import { SubscriptionManager } from '../managers/subscription.manager';\nimport { MethodResponses } from '../collections/method-response.collection';\n\nexport function loadMethodResponsePublications(subscriptionManager: SubscriptionManager) {\n\tsubscriptionManager.publications({\n\t\tmethodresponses: {\n\t\t\tfunction: function() {\n\t\t\t\treturn MethodResponses.find({});\n\t\t\t},\n\t\t\tcollections: ['method-responses']\n\t\t}\n\t});\n}"]}
|