@resolveio/server-lib 20.12.9 → 20.12.11

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.
@@ -304,7 +304,10 @@ function loadCollectionMethods(methodManager) {
304
304
  case 6:
305
305
  _a.sent();
306
306
  return [3 /*break*/, 8];
307
- case 7: throw new Error('Error In Update Document Props Collections: Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);
307
+ case 7:
308
+ // throw new Error('Error In Update Document Props Collections: Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);
309
+ console.log(new Date(), 'Error In Update Document Props Collections: Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);
310
+ _a.label = 8;
308
311
  case 8: return [3 /*break*/, 10];
309
312
  case 9: throw new Error('Error In Update Document Props Collections: Invalid Version And We Are NOT Using Versions On This Collection!');
310
313
  case 10: return [3 /*break*/, 12];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/collections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,sDA8cC;AApdD,6CAAwC;AAExC,+DAAwF;AACxF,gEAA0D;AAC1D,yCAAsF;AAEtF,SAAgB,qBAAqB,CAAC,aAA4B;IACjE,aAAa,CAAC,OAAO,CAAC;QACrB,iBAAiB,EAAE;YAClB,QAAQ,EAAE;gBACT,OAAO,OAAO,CAAC,OAAO,CAAC,sCAAe,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,cAAc,EAAhB,CAAgB,CAAC,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAlB,CAAkB,CAAC,CAAC,CAAC;YACvI,CAAC;SACD;QACD,gBAAgB,EAAE;YACjB,QAAQ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ACzD,IAAI,CAAC,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;oCAC/D,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;gCACvF,CAAC;gCAED,qBAAM,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAA;;gCAA/E,SAA+E,CAAC;gCAEhF,sBAAO,IAAI,EAAC;;;;aACZ;SACD;QACD,wBAAwB,EAAE;YACzB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,UAAU,EAAE;oBACX,IAAI,EAAE,MAAM;iBACZ;gBACD,KAAK,EAAE;oBACN,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,IAAI;iBACd;aACD,CAAC;YACF,QAAQ,EAAE,UAAe,UAAkB,EAAE,KAAa;;;;;gCACzD,IAAI,CAAC,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;oCAC/D,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;gCACzF,CAAC;gCAED,qBAAM,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAA;;gCAAhF,SAAgF,CAAC;gCAEjF,sBAAO,IAAI,EAAC;;;;aACZ;SACD;KACD,CAAC,CAAC;AACJ,CAAC","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\tbypassSession: true,\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\tbypassSession: true,\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\tbypassSession: true,\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: 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 Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document);\n\t\t\t\treturn true;\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\tawait 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\tawait 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\n\t\t\t\treturn true;\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\tawait 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\tawait 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\n\t\t\t\treturn true;\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\tawait 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\tawait 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\n\t\t\t\treturn true;\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: async 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\tawait ResolveIOServer.getMongoManager().collection(collection).deleteOne({_id: doc_id});\n\n\t\t\t\treturn true;\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: async 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\tawait ResolveIOServer.getMongoManager().collection(collection).deleteOne(query);\n\n\t\t\t\treturn true;\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: async 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\tawait ResolveIOServer.getMongoManager().collection(collection).deleteMany(query);\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"sources":["../../src/methods/collections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,sDA+cC;AArdD,6CAAwC;AAExC,+DAAwF;AACxF,gEAA0D;AAC1D,yCAAsF;AAEtF,SAAgB,qBAAqB,CAAC,aAA4B;IACjE,aAAa,CAAC,OAAO,CAAC;QACrB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hF,SAAgF,CAAC;gCAEjF,sBAAO,IAAI,EAAC;;;;aACZ;SACD;KACD,CAAC,CAAC;AACJ,CAAC","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\tbypassSession: true,\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\tbypassSession: true,\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\tbypassSession: true,\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: 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 Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document);\n\t\t\t\treturn true;\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\tawait 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\tawait 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\t// throw 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\tconsole.log(new Date(), '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\n\t\t\t\treturn true;\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\tawait 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\tawait 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\n\t\t\t\treturn true;\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\tawait 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\tawait 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\n\t\t\t\treturn true;\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: async 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\tawait ResolveIOServer.getMongoManager().collection(collection).deleteOne({_id: doc_id});\n\n\t\t\t\treturn true;\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: async 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\tawait ResolveIOServer.getMongoManager().collection(collection).deleteOne(query);\n\n\t\t\t\treturn true;\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: async 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\tawait ResolveIOServer.getMongoManager().collection(collection).deleteMany(query);\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
@@ -6,4 +6,5 @@ export interface LogMethodLatencyModel extends CollectionDocument {
6
6
  method: string;
7
7
  client: string;
8
8
  instance: string;
9
+ instance_index?: string;
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/log-method-latency.model.ts"],"names":[],"mappings":"","file":"log-method-latency.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface LogMethodLatencyModel extends CollectionDocument {\n\tdate_start: Date;\n\tdate_end?: Date;\n\tlatency_ms: number;\n\tmethod: string;\n\tclient: string;\n\tinstance: string;\n}\n"]}
1
+ {"version":3,"sources":["../../src/models/log-method-latency.model.ts"],"names":[],"mappings":"","file":"log-method-latency.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface LogMethodLatencyModel extends CollectionDocument {\n\tdate_start: Date;\n\tdate_end?: Date;\n\tlatency_ms: number;\n\tmethod: string;\n\tclient: string;\n\tinstance: string;\n\tinstance_index?: string;\n}\n"]}
@@ -7,5 +7,6 @@ export interface LogSubscriptionModel extends CollectionDocument {
7
7
  subData: any[];
8
8
  client: string;
9
9
  instance: string;
10
+ instance_index?: string;
10
11
  }
11
12
  export type LogSubscriptionType = 'insert' | 'update' | 'delete';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/log-subscription.model.ts"],"names":[],"mappings":"","file":"log-subscription.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface LogSubscriptionModel extends CollectionDocument {\n\tdate: Date;\n\ttype: LogSubscriptionType;\n\tsubscription: string;\n\tcollection_name: string;\n\tsubData: any[];\n\tclient: string;\n\tinstance: string;\n}\n\nexport type LogSubscriptionType = 'insert' | 'update' | 'delete'\n"]}
1
+ {"version":3,"sources":["../../src/models/log-subscription.model.ts"],"names":[],"mappings":"","file":"log-subscription.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface LogSubscriptionModel extends CollectionDocument {\n\tdate: Date;\n\ttype: LogSubscriptionType;\n\tsubscription: string;\n\tcollection_name: string;\n\tsubData: any[];\n\tclient: string;\n\tinstance: string;\n\tinstance_index?: string;\n}\n\nexport type LogSubscriptionType = 'insert' | 'update' | 'delete'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "20.12.9",
3
+ "version": "20.12.11",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
package/server-app.js CHANGED
@@ -136,7 +136,7 @@ var ResolveIOMainServer = /** @class */ (function () {
136
136
  };
137
137
  ResolveIOMainServer.prototype.initialize = function () {
138
138
  return __awaiter(this, void 0, void 0, function () {
139
- var _a, initServerFlag;
139
+ var _a;
140
140
  var _this = this;
141
141
  return __generator(this, function (_b) {
142
142
  switch (_b.label) {
@@ -159,10 +159,6 @@ var ResolveIOMainServer = /** @class */ (function () {
159
159
  _this._debugMsgQueue = 0;
160
160
  _this._debugMsgRecv = 0;
161
161
  }, 60000);
162
- initServerFlag = false;
163
- setTimeout(function () {
164
- initServerFlag = true;
165
- }, 5000);
166
162
  process.removeAllListeners('unhandledRejection');
167
163
  process.on('unhandledRejection', function (error, rej) { return __awaiter(_this, void 0, void 0, function () {
168
164
  var _a, normalizedError, correlationId, errorDetails, diffTimeSec;
@@ -178,7 +174,10 @@ var ResolveIOMainServer = /** @class */ (function () {
178
174
  if (normalizedError && normalizedError['name'] === 'MongoError' && (normalizedError['code'] === 48 || normalizedError['code'] === 26 || normalizedError['code'] === 11000 || normalizedError['code'] === 251)) {
179
175
  return [2 /*return*/]; // Simply return without doing anything further
180
176
  }
181
- if (normalizedError && normalizedError['name'] === 'MongoServerError' && (!initServerFlag || normalizedError['code'] === 26 || normalizedError['code'] === 11000 || normalizedError['code'] === 86 || normalizedError['code'] === 251)) {
177
+ // if (normalizedError && normalizedError['name'] === 'MongoServerError' && (!initServerFlag || normalizedError['code'] === 26 || normalizedError['code'] === 11000 || normalizedError['code'] === 86 || normalizedError['code'] === 251)) {
178
+ // return; // Simply return without doing anything further
179
+ // }
180
+ if (normalizedError && normalizedError['name'] === 'MongoServerError') {
182
181
  return [2 /*return*/]; // Simply return without doing anything further
183
182
  }
184
183
  errorDetails = {
@@ -191,71 +190,51 @@ var ResolveIOMainServer = /** @class */ (function () {
191
190
  };
192
191
  console.error(new Date(), 'Unhandled Rejection at Promise', [errorDetails]);
193
192
  diffTimeSec = moment().diff(this._serverStartTime, 'seconds');
194
- if (!(normalizedError && (normalizedError['name'] === 'MongoNetworkTimeoutError' || normalizedError instanceof mongodb_1.MongoNetworkTimeoutError))) return [3 /*break*/, 3];
195
- if (!(diffTimeSec > 60 && !this._lastErrorMsg)) return [3 /*break*/, 2];
196
- this._lastErrorMsg = new Date();
197
- setTimeout(function () {
198
- _this._lastErrorMsg = null;
199
- }, 60000);
200
- return [4 /*yield*/, this.reportServerError('SERVER - MongoNetworkTimeoutError - Quitting NodeJS - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], correlationId, Object.assign({ scenario: 'MongoNetworkTimeoutError' }, errorDetails), {
201
- context: 'unhandledRejection',
202
- scenario: 'MongoNetworkTimeoutError'
203
- })];
193
+ if (!(normalizedError && (normalizedError['name'] === 'MongoNetworkTimeoutError' || normalizedError instanceof mongodb_1.MongoNetworkTimeoutError))) return [3 /*break*/, 1];
194
+ if (diffTimeSec > 60 && !this._lastErrorMsg) {
195
+ this._lastErrorMsg = new Date();
196
+ setTimeout(function () {
197
+ _this._lastErrorMsg = null;
198
+ }, 60000);
199
+ // Exiting the process
200
+ process.exit(1);
201
+ }
202
+ return [3 /*break*/, 5];
204
203
  case 1:
205
- _b.sent();
206
- // Exiting the process
204
+ if (!(normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master')) return [3 /*break*/, 2];
205
+ if (diffTimeSec > 60 && !this._lastErrorMsg) {
206
+ this._lastErrorMsg = new Date();
207
+ setTimeout(function () {
208
+ _this._lastErrorMsg = null;
209
+ }, 60000);
210
+ }
207
211
  process.exit(1);
208
- _b.label = 2;
209
- case 2: return [3 /*break*/, 11];
212
+ return [3 /*break*/, 5];
213
+ case 2:
214
+ if (!(normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master and slaveOk=false')) return [3 /*break*/, 3];
215
+ if (diffTimeSec > 60 && !this._lastErrorMsg) {
216
+ this._lastErrorMsg = new Date();
217
+ setTimeout(function () {
218
+ _this._lastErrorMsg = null;
219
+ }, 60000);
220
+ }
221
+ process.exit(1);
222
+ return [3 /*break*/, 5];
210
223
  case 3:
211
- if (!(normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master')) return [3 /*break*/, 6];
224
+ if (!(normalizedError && normalizedError['name'] !== 'StatusError' && normalizedError['message'] !== '')) return [3 /*break*/, 5];
212
225
  if (!(diffTimeSec > 60 && !this._lastErrorMsg)) return [3 /*break*/, 5];
213
226
  this._lastErrorMsg = new Date();
214
227
  setTimeout(function () {
215
228
  _this._lastErrorMsg = null;
216
229
  }, 60000);
217
- return [4 /*yield*/, this.reportServerError('SERVER - Unhandled Rejection - Quitting NodeJS - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], correlationId, Object.assign({ scenario: 'MongoNotMaster' }, errorDetails), {
218
- context: 'unhandledRejection',
219
- scenario: 'MongoNotMaster'
220
- })];
221
- case 4:
222
- _b.sent();
223
- _b.label = 5;
224
- case 5:
225
- process.exit(1);
226
- return [3 /*break*/, 11];
227
- case 6:
228
- if (!(normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master and slaveOk=false')) return [3 /*break*/, 9];
229
- if (!(diffTimeSec > 60 && !this._lastErrorMsg)) return [3 /*break*/, 8];
230
- this._lastErrorMsg = new Date();
231
- setTimeout(function () {
232
- _this._lastErrorMsg = null;
233
- }, 60000);
234
- return [4 /*yield*/, this.reportServerError('SERVER - Unhandled Rejection - Quitting NodeJS - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], correlationId, Object.assign({ scenario: 'MongoNotMasterSlaveOk' }, errorDetails), {
235
- context: 'unhandledRejection',
236
- scenario: 'MongoNotMasterSlaveOk'
237
- })];
238
- case 7:
239
- _b.sent();
240
- _b.label = 8;
241
- case 8:
242
- process.exit(1);
243
- return [3 /*break*/, 11];
244
- case 9:
245
- if (!(normalizedError && normalizedError['name'] !== 'StatusError' && normalizedError['message'] !== '')) return [3 /*break*/, 11];
246
- if (!(diffTimeSec > 60 && !this._lastErrorMsg)) return [3 /*break*/, 11];
247
- this._lastErrorMsg = new Date();
248
- setTimeout(function () {
249
- _this._lastErrorMsg = null;
250
- }, 60000);
251
230
  return [4 /*yield*/, this.reportServerError('SERVER - Unhandled Rejection - ' + resolveio_server_app_1.ResolveIOServer.getServerConfig()['CLIENT_NAME'], correlationId, errorDetails, {
252
231
  context: 'unhandledRejection',
253
232
  scenario: 'General'
254
233
  })];
255
- case 10:
234
+ case 4:
256
235
  _b.sent();
257
- _b.label = 11;
258
- case 11: return [2 /*return*/];
236
+ _b.label = 5;
237
+ case 5: return [2 /*return*/];
259
238
  }
260
239
  });
261
240
  }); });