@resolveio/server-lib 22.2.50 → 22.2.52

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/methods/aws.js CHANGED
@@ -731,6 +731,7 @@ function loadAWSMethods(methodManager) {
731
731
  type: Number
732
732
  }
733
733
  }),
734
+ bypassLogs: true,
734
735
  function: function (key, expires) {
735
736
  var s3 = this.getAWS().s3();
736
737
  var getCommand = new client_s3_1.GetObjectCommand({
@@ -752,6 +753,7 @@ function loadAWSMethods(methodManager) {
752
753
  type: Number
753
754
  }
754
755
  }),
756
+ bypassLogs: true,
755
757
  function: function (keys, expires) {
756
758
  return __awaiter(this, void 0, void 0, function () {
757
759
  var res, i, key, s3, getCommand, _a, _b;
@@ -789,6 +791,7 @@ function loadAWSMethods(methodManager) {
789
791
  type: String
790
792
  }
791
793
  }),
794
+ bypassLogs: true,
792
795
  function: function (url) {
793
796
  return __awaiter(this, void 0, void 0, function () {
794
797
  var response, contentType, dataBase64;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/aws.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,wCAwlBC;AAroBD,gDAAsD;AACtD,sEAA6D;AAC7D,+BAA0B;AAC1B,6CAAwC;AACxC,kEAAuD;AAEvD,gEAA0D;AAC1D,yCAAmD;AACnD,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACvB,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,IAAI,MAAM,GAAG,OAAO,CAAC;AAErB,IAAM,qBAAqB,GAAG;IAC7B,MAAM,EAAE,yBAAyB;IACjC,MAAM,EAAE,yBAAyB;IACjC,MAAM,EAAE,2BAA2B;IACnC,KAAK,EAAE,kBAAkB;IACzB,OAAO,EAAE,0BAA0B;IACnC,OAAO,EAAE,kBAAkB;IAC3B,KAAK,EAAE,wBAAwB;IAC/B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AE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,EAAA;;gCAAhI,SAAgI,CAAC;;oCAGlI,sBAAO,IAAI,EAAC;oCAGZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;;;;gCAIpE,MAAG,CAAC,MAAM,GAAG,2BAA2B,GAAG,MAAG,CAAC,MAAM,CAAC;gCACtD,MAAM,MAAG,CAAC;;;;;aAEX;SACD;KACD,CAAC,CAAC;AACJ,CAAC","file":"aws.js","sourcesContent":["import { GetObjectCommand } from '@aws-sdk/client-s3';\nimport { getSignedUrl } from '@aws-sdk/s3-request-presigner';\nimport axios from 'axios';\nimport SimpleSchema from 'simpl-schema';\nimport { Files } from '../collections/file.collection';\nimport { AWS, MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\nlet fs = require('fs');\nlet path = require('path');\nlet pdfCnt = 1000000;\n\nconst NON_PDF_CONTENT_TYPES = {\n\t'.csv': 'text/csv; charset=utf-8',\n\t'.css': 'text/css; charset=utf-8',\n\t'.env': 'text/plain; charset=utf-8',\n\t'.gz': 'application/gzip',\n\t'.html': 'text/html; charset=utf-8',\n\t'.json': 'application/json',\n\t'.js': 'application/javascript',\n\t'.md': 'text/markdown; charset=utf-8',\n\t'.tar': 'application/x-tar',\n\t'.tgz': 'application/gzip',\n\t'.ts': 'application/typescript',\n\t'.txt': 'text/plain; charset=utf-8',\n\t'.xml': 'application/xml',\n\t'.yaml': 'application/yaml',\n\t'.yml': 'application/yaml',\n\t'.zip': 'application/zip'\n};\n\nfunction inferNonPDFContentType(fileName: string): string {\n\tif (!fileName) {\n\t\treturn 'application/octet-stream';\n\t}\n\n\tconst normalized = fileName.toLowerCase();\n\tif (normalized.endsWith('.tar.gz')) {\n\t\treturn 'application/gzip';\n\t}\n\n\tconst extension = path.extname(normalized);\n\treturn NON_PDF_CONTENT_TYPES[extension] || 'application/octet-stream';\n}\n\nexport function loadAWSMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tuploadFileAndSave: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tfileName: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tfileData: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tfileSize: {\n\t\t\t\t\ttype: Number\n\t\t\t\t},\n\t\t\t\tfileOrder: {\n\t\t\t\t\ttype: Number\n\t\t\t\t},\n\t\t\t\tfileType: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tcompress: {\n\t\t\t\t\ttype: Boolean\n\t\t\t\t}\n\t\t\t}),\n\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\tfunction: async function(fileName: string, fileData: string, fileSize: number, fileOrder: number, fileType: string, compress: Boolean) {\n\t\t\t\tif (!fileName) {\n\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t}\n\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\tconst maxRetries = 3;\n\t\t\t\tlet attempt = 0;\n\n\t\t\t\twhile (attempt <= maxRetries) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET,\n\t\t\t\t\t\t\tKey: key,\n\t\t\t\t\t\t\tBody: Buffer.from(fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''), 'base64'), \n\t\t\t\t\t\t\tACL: 'private', \n\t\t\t\t\t\t\tContentType: fileData.split(',')[0].split(':')[1].split(';')[0], \n\t\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\treturn Files.create({\n\t\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\tif (attempt <= maxRetries) {\n\t\t\t\t\t\t\tconst backoff = Math.pow(2, attempt) * 1000;\n\t\t\t\t\t\t\tconsole.warn(`Attempt ${attempt} failed. Retrying in ${backoff / 1000} seconds...`);\n\t\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, backoff));\n\t\t\t\t\t\t} \n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthrow new Error(`Error in AWS Upload File And Save: Failed to upload after ${maxRetries} attempts: ${err.message}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\t\tuploadPDFBufferAndSave: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tfileName: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tfileDataBuffer: {\n\t\t\t\t\ttype: Buffer\n\t\t\t\t},\n\t\t\t\tfileSize: {\n\t\t\t\t\ttype: Number\n\t\t\t\t},\n\t\t\t\tfileOrder: {\n\t\t\t\t\ttype: Number\n\t\t\t\t},\n\t\t\t\tfileType: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tfunction: async function(fileName: string, fileDataBuffer: any, fileSize: number, fileOrder: number, fileType: string) {\n\t\t\t\t\tif (!fileName) {\n\t\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t\t}\n\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\tconst maxRetries = 3;\n\t\t\t\tlet attempt = 0;\n\n\t\t\t\twhile (attempt <= maxRetries) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET,\n\t\t\t\t\t\t\tKey: key,\n\t\t\t\t\t\t\tBody: fileDataBuffer,\n\t\t\t\t\t\t\tACL: 'private',\n\t\t\t\t\t\t\tContentType: 'application/pdf',\n\t\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\treturn Files.create({\n\t\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\tif (attempt <= maxRetries) {\n\t\t\t\t\t\t\tconst backoff = Math.pow(2, attempt) * 1000;\n\t\t\t\t\t\t\tconsole.warn(`Attempt ${attempt} failed. Retrying in ${backoff / 1000} seconds...`);\n\t\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, backoff));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthrow new Error(`Error in AWS Upload PDF Buffer And Save: Failed to upload after ${maxRetries} attempts: ${err.message}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tuploadNonPDFFileAndSave: {\n\t\t\tcheck: new SimpleSchema({\t\n\t\t\t\tfileName: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileData: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileSize: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileOrder: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileType: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t}\t\n\t\t\t}),\t\n\t\t\tfunction: async function(fileName: string, fileData: string, fileSize: number, fileOrder: number, fileType: string) {\t\n\t\t\t\tif (!fileName) {\n\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t}\n\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + fileName;\t\n\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tconst contentType = inferNonPDFContentType(fileName);\n\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: key, \n\t\t\t\t\t\tBody: Buffer.from(fileData), \n\t\t\t\t\t\tACL: 'private', \n\t\t\t\t\t\tContentType: contentType, \n\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t});\n\n\t\t\t\t\tif (res) {\n\t\t\t\t\t\treturn Files.create({\t\n\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType\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\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Upload Non PDF File And Save: ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\t\n\t\t},\n\t\tuploadNonPDFBufferAndSave: {\n\t\t\tcheck: new SimpleSchema({\t\n\t\t\t\tfileName: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileDataBuffer: {\t\n\t\t\t\t\ttype: Buffer\n\t\t\t\t},\t\n\t\t\t\tfileSize: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileOrder: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileType: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t}\t\n\t\t\t}),\t\n\t\t\tfunction: async function(fileName: string, fileDataBuffer, fileSize: number, fileOrder: number, fileType: string) {\t\n\t\t\t\tif (!fileName) {\n\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t}\n\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + fileName;\t\n\t\t\t\t\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\n\t\t\t\ttry {\n\t\t\t\t\tconst contentType = inferNonPDFContentType(fileName);\n\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: key, \n\t\t\t\t\t\tBody: fileDataBuffer, \n\t\t\t\t\t\tACL: 'private', \n\t\t\t\t\t\tContentType: contentType, \n\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t});\n\n\t\t\t\t\tif (res) {\n\t\t\t\t\t\treturn Files.create({\t\n\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType\n\t\t\t\t\t\t});\n\t\t\t\t\t}\t\n\t\t\t\t\telse {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Upload Non PDF Buffer And Save: ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\t\n\t\t},\n\t\tuploadNonPDFStreamAndSave: {\n\t\t\tcheck: new SimpleSchema({\t\n\t\t\t\tfileName: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileData: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileOrder: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileType: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t}\t\n\t\t\t}),\t\n\t\t\tfunction: async function(fileName: string, fileData: string, fileOrder: number, fileType: string) {\t\n\t\t\t\tif (!fileName) {\n\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + fileName;\t\n\t\t\t\t\t\t\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tconst contentType = inferNonPDFContentType(fileName);\n\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: key, \n\t\t\t\t\t\tBody: fs.createReadStream(fileData), \n\t\t\t\t\t\tACL: 'private', \n\t\t\t\t\t\tContentType: contentType, \n\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t});\n\n\t\t\t\t\tif (res) {\n\t\t\t\t\t\treturn Files.create({\t\n\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: 1, key: key, order: fileOrder, type: fileType\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\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Upload Non PDF Stream And Save: ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\t\n\t\t},\n\t\tdeleteFiles: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tkeys: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'keys.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(keys: string[]) {\n\t\t\t\tif (!Array.isArray(keys) || keys.length === 0) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\tlet files = await Files.find({key: {$in: keys}});\n\t\n\t\t\t\tlet deleteCnt = files.length;\n\t\n\t\t\t\tfor (let file of files) {\n\t\t\t\t\tawait Files.deleteOne({_id: file._id});\n\t\t\t\t\t\n\t\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\t\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet res = await s3.deleteObject({\n\t\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\t\tKey: file.key\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\tdeleteCnt--;\n\t\t\t\t\t\t\tif (!deleteCnt) {\n\t\t\t\t\t\t\t\treturn files.length;\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 (err) {\n\t\t\t\t\t\terr.mesage = 'Error In AWS Delete Files: ' + err.mesage;\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t},\n\t\tdeleteFile: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tkey: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(key: string) {\t\t\n\t\t\t\tlet file = await Files.findOne({key: key});\n\t\n\t\t\t\tif (file) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait Files.deleteOne({_id: file._id});\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\terr.mesage = 'Error In AWS Delete File (Resolve Side): ' + err.mesage;\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tlet res = await s3.deleteObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET,\n\t\t\t\t\t\tKey: key\n\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Delete File (AWS Side): ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tdeleteFileWithId: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_file: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(id_file: string) {\n\t\t\t\tlet file = await Files.findOne({_id: id_file});\n\t\n\t\t\t\tif (!file) {\n\t\t\t\t\tthrow new Error('Error in AWS Delete File With ID: Could not find file');\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait Files.deleteOne({_id: file._id});\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Delete File With ID (Resolve Side): ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tlet res = await s3.deleteObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET,\n\t\t\t\t\t\tKey: file.key\n\t\t\t\t\t});\n\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Delete File With ID (AWS Side): ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tgetSignedUrlsAndFilesWithId: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tids: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'ids.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(ids: string[], expires: number) {\n\t\t\t\tlet res = [];\n\n\t\t\t\tlet files = await Files.find({_id: {$in: ids}});\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < files.length; i++) {\n\t\t\t\t\tlet file = files[i];\n\t\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: file.key\n\t\t\t\t\t});\n\t\t\t\t\tres.push(await getSignedUrl(s3, getCommand, {expiresIn: expires}));\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn {res: res, fileArray: files.map(a => a.name)};\n\t\t\t}\n\t\t},\n\t\tgetSignedUrlWithId: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_file: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(id_file: string, expires: number) {\n\t\t\t\tlet file = await Files.findOne({_id: id_file});\n\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\tKey: file.key\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\treturn getSignedUrl(s3, getCommand, {expiresIn: expires});\n\t\t\t}\n\t\t},\n\t\tgetSignedUrlUSEast1BucketAndKey: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tbucket: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tkey: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(bucket: string, key: string, expires: number) {\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3USEast1();\n\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\tBucket: bucket, \n\t\t\t\t\tKey: key\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\treturn getSignedUrl(s3, getCommand, {expiresIn: expires});\n\t\t\t}\n\t\t},\n\t\tgetSignedUrl: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tkey: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(key: string, expires: number) {\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\tKey: key\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\treturn getSignedUrl(s3, getCommand, {expiresIn: expires});\n\t\t\t}\n\t\t},\n\t\tgetSignedUrls: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tkeys: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'keys.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(keys: string[], expires: number) {\n\t\t\t\tlet res = [];\n\n\t\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\t\tlet key = keys[i];\n\t\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: key\n\t\t\t\t\t});\n\n\t\t\t\t\tres.push(await getSignedUrl(s3, getCommand, {expiresIn: expires}));\n\t\t\t\t}\n\n\t\t\t\treturn res;\n\t\t\t}\n\t\t},\n\t\tgetDataURIfromURL: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\turl: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(url: string) {\n\t\t\t\tconst response = await axios.get(url, {\n\t\t\t\t\tresponseType: 'arraybuffer'\n\t\t\t\t});\n\t\t\t\n\t\t\t\tif (response.status !== 200) {\n\t\t\t\t\tthrow new Error(`Error in Get Data URI From URL: Failed to fetch URL, status: ${response.status}`);\n\t\t\t\t}\n\t\t\t\n\t\t\t\tconst contentType = response.headers['content-type'];\n\t\t\t\tconst dataBase64 = Buffer.from(response.data).toString('base64');\n\t\t\t\treturn `data:${contentType};base64,${dataBase64}`;\n\t\t\t}\n\t\t},\n\t\temailFile: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_file: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\temail: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n additional_message: {\n type: String\n }\n\t\t\t}),\n\t\t\tfunction: async function(id_file: string, email: string, additional_message) {\n\t\t\t\tlet file = await Files.findById(id_file);\n\n\t\t\t\tif (!file) {\n\t\t\t\t\tthrow new Error('Error in AWS Email File: Could not find file');\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tlet resPDF = await this.callMethod('getSignedUrl', file.key, 259200);\n\t\t\t\t\t\n\t\t\t\t\tif (resPDF) {\n\t\t\t\t\t\tif (file.size < 5000000) {\n\t\t\t\t\t\t\tlet emailMessage = 'Attached is the file requested for email.\\n' + (additional_message !== '' ? '\\nAdditional Message:\\n' + additional_message + '\\n' : '') ;\n\n\t\t\t\t\t\t\tawait this.sendEmail(email, ResolveIOServer.getClientName() + ' File - ' + file.name, emailMessage, '', [{\n\t\t\t\t\t\t\t\tfilename: file.name,\n\t\t\t\t\t\t\t\tpath: resPDF\n\t\t\t\t\t\t\t}], null, '');\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tlet emailMessage = 'Please click the link to the requested file.\\n' + (additional_message !== '' ? '\\nAdditional Message:\\n' + additional_message + '\\n' : '') ;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tawait this.sendEmail(email, ResolveIOServer.getClientName() + ' File - ' + file.name, emailMessage + resPDF, '', null, null, '');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthrow new Error('Error in AWS Email File: Could not get file URL');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Email File: ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"sources":["../../src/methods/aws.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,wCA2lBC;AAxoBD,gDAAsD;AACtD,sEAA6D;AAC7D,+BAA0B;AAC1B,6CAAwC;AACxC,kEAAuD;AAEvD,gEAA0D;AAC1D,yCAAmD;AACnD,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACvB,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,IAAI,MAAM,GAAG,OAAO,CAAC;AAErB,IAAM,qBAAqB,GAAG;IAC7B,MAAM,EAAE,yBAAyB;IACjC,MAAM,EAAE,yBAAyB;IACjC,MAAM,EAAE,2BAA2B;IACnC,KAAK,EAAE,kBAAkB;IACzB,OAAO,EAAE,0BAA0B;IACnC,OAAO,EAAE,kBAAkB;IAC3B,KAAK,EAAE,wBAAwB;IAC/B,KAAK,EAAE,8BAA8B;IACrC,MAAM,EAAE,mBAAmB;IAC3B,MAAM,EAAE,kBAAkB;IAC1B,KAAK,EAAE,wBAAwB;IAC/B,MAAM,EAAE,2BAA2B;IACnC,MAAM,EAAE,iBAAiB;I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lI,sBAAO,IAAI,EAAC;oCAGZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;;;;gCAIpE,MAAG,CAAC,MAAM,GAAG,2BAA2B,GAAG,MAAG,CAAC,MAAM,CAAC;gCACtD,MAAM,MAAG,CAAC;;;;;aAEX;SACD;KACD,CAAC,CAAC;AACJ,CAAC","file":"aws.js","sourcesContent":["import { GetObjectCommand } from '@aws-sdk/client-s3';\nimport { getSignedUrl } from '@aws-sdk/s3-request-presigner';\nimport axios from 'axios';\nimport SimpleSchema from 'simpl-schema';\nimport { Files } from '../collections/file.collection';\nimport { AWS, MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\nlet fs = require('fs');\nlet path = require('path');\nlet pdfCnt = 1000000;\n\nconst NON_PDF_CONTENT_TYPES = {\n\t'.csv': 'text/csv; charset=utf-8',\n\t'.css': 'text/css; charset=utf-8',\n\t'.env': 'text/plain; charset=utf-8',\n\t'.gz': 'application/gzip',\n\t'.html': 'text/html; charset=utf-8',\n\t'.json': 'application/json',\n\t'.js': 'application/javascript',\n\t'.md': 'text/markdown; charset=utf-8',\n\t'.tar': 'application/x-tar',\n\t'.tgz': 'application/gzip',\n\t'.ts': 'application/typescript',\n\t'.txt': 'text/plain; charset=utf-8',\n\t'.xml': 'application/xml',\n\t'.yaml': 'application/yaml',\n\t'.yml': 'application/yaml',\n\t'.zip': 'application/zip'\n};\n\nfunction inferNonPDFContentType(fileName: string): string {\n\tif (!fileName) {\n\t\treturn 'application/octet-stream';\n\t}\n\n\tconst normalized = fileName.toLowerCase();\n\tif (normalized.endsWith('.tar.gz')) {\n\t\treturn 'application/gzip';\n\t}\n\n\tconst extension = path.extname(normalized);\n\treturn NON_PDF_CONTENT_TYPES[extension] || 'application/octet-stream';\n}\n\nexport function loadAWSMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tuploadFileAndSave: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tfileName: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tfileData: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tfileSize: {\n\t\t\t\t\ttype: Number\n\t\t\t\t},\n\t\t\t\tfileOrder: {\n\t\t\t\t\ttype: Number\n\t\t\t\t},\n\t\t\t\tfileType: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tcompress: {\n\t\t\t\t\ttype: Boolean\n\t\t\t\t}\n\t\t\t}),\n\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\tfunction: async function(fileName: string, fileData: string, fileSize: number, fileOrder: number, fileType: string, compress: Boolean) {\n\t\t\t\tif (!fileName) {\n\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t}\n\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\tconst maxRetries = 3;\n\t\t\t\tlet attempt = 0;\n\n\t\t\t\twhile (attempt <= maxRetries) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET,\n\t\t\t\t\t\t\tKey: key,\n\t\t\t\t\t\t\tBody: Buffer.from(fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''), 'base64'), \n\t\t\t\t\t\t\tACL: 'private', \n\t\t\t\t\t\t\tContentType: fileData.split(',')[0].split(':')[1].split(';')[0], \n\t\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\treturn Files.create({\n\t\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\tif (attempt <= maxRetries) {\n\t\t\t\t\t\t\tconst backoff = Math.pow(2, attempt) * 1000;\n\t\t\t\t\t\t\tconsole.warn(`Attempt ${attempt} failed. Retrying in ${backoff / 1000} seconds...`);\n\t\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, backoff));\n\t\t\t\t\t\t} \n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthrow new Error(`Error in AWS Upload File And Save: Failed to upload after ${maxRetries} attempts: ${err.message}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\t\tuploadPDFBufferAndSave: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tfileName: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tfileDataBuffer: {\n\t\t\t\t\ttype: Buffer\n\t\t\t\t},\n\t\t\t\tfileSize: {\n\t\t\t\t\ttype: Number\n\t\t\t\t},\n\t\t\t\tfileOrder: {\n\t\t\t\t\ttype: Number\n\t\t\t\t},\n\t\t\t\tfileType: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tfunction: async function(fileName: string, fileDataBuffer: any, fileSize: number, fileOrder: number, fileType: string) {\n\t\t\t\t\tif (!fileName) {\n\t\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t\t}\n\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\tconst maxRetries = 3;\n\t\t\t\tlet attempt = 0;\n\n\t\t\t\twhile (attempt <= maxRetries) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET,\n\t\t\t\t\t\t\tKey: key,\n\t\t\t\t\t\t\tBody: fileDataBuffer,\n\t\t\t\t\t\t\tACL: 'private',\n\t\t\t\t\t\t\tContentType: 'application/pdf',\n\t\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\treturn Files.create({\n\t\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\tattempt++;\n\t\t\t\t\t\tif (attempt <= maxRetries) {\n\t\t\t\t\t\t\tconst backoff = Math.pow(2, attempt) * 1000;\n\t\t\t\t\t\t\tconsole.warn(`Attempt ${attempt} failed. Retrying in ${backoff / 1000} seconds...`);\n\t\t\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, backoff));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthrow new Error(`Error in AWS Upload PDF Buffer And Save: Failed to upload after ${maxRetries} attempts: ${err.message}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t\tuploadNonPDFFileAndSave: {\n\t\t\tcheck: new SimpleSchema({\t\n\t\t\t\tfileName: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileData: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileSize: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileOrder: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileType: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t}\t\n\t\t\t}),\t\n\t\t\tfunction: async function(fileName: string, fileData: string, fileSize: number, fileOrder: number, fileType: string) {\t\n\t\t\t\tif (!fileName) {\n\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t}\n\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + fileName;\t\n\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tconst contentType = inferNonPDFContentType(fileName);\n\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: key, \n\t\t\t\t\t\tBody: Buffer.from(fileData), \n\t\t\t\t\t\tACL: 'private', \n\t\t\t\t\t\tContentType: contentType, \n\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t});\n\n\t\t\t\t\tif (res) {\n\t\t\t\t\t\treturn Files.create({\t\n\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType\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\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Upload Non PDF File And Save: ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\t\n\t\t},\n\t\tuploadNonPDFBufferAndSave: {\n\t\t\tcheck: new SimpleSchema({\t\n\t\t\t\tfileName: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileDataBuffer: {\t\n\t\t\t\t\ttype: Buffer\n\t\t\t\t},\t\n\t\t\t\tfileSize: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileOrder: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileType: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t}\t\n\t\t\t}),\t\n\t\t\tfunction: async function(fileName: string, fileDataBuffer, fileSize: number, fileOrder: number, fileType: string) {\t\n\t\t\t\tif (!fileName) {\n\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t}\n\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + fileName;\t\n\t\t\t\t\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\n\t\t\t\ttry {\n\t\t\t\t\tconst contentType = inferNonPDFContentType(fileName);\n\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: key, \n\t\t\t\t\t\tBody: fileDataBuffer, \n\t\t\t\t\t\tACL: 'private', \n\t\t\t\t\t\tContentType: contentType, \n\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t});\n\n\t\t\t\t\tif (res) {\n\t\t\t\t\t\treturn Files.create({\t\n\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType\n\t\t\t\t\t\t});\n\t\t\t\t\t}\t\n\t\t\t\t\telse {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Upload Non PDF Buffer And Save: ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\t\n\t\t},\n\t\tuploadNonPDFStreamAndSave: {\n\t\t\tcheck: new SimpleSchema({\t\n\t\t\t\tfileName: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileData: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t},\t\n\t\t\t\tfileOrder: {\t\n\t\t\t\t\ttype: Number\t\n\t\t\t\t},\t\n\t\t\t\tfileType: {\t\n\t\t\t\t\ttype: String\t\n\t\t\t\t}\t\n\t\t\t}),\t\n\t\t\tfunction: async function(fileName: string, fileData: string, fileOrder: number, fileType: string) {\t\n\t\t\t\tif (!fileName) {\n\t\t\t\t\tthrow new Error(\"Invalid File Name provided\");\n\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\tlet key = 'uploads/' + Date.now() + '-' + fileName;\t\n\t\t\t\t\t\t\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tconst contentType = inferNonPDFContentType(fileName);\n\t\t\t\t\tlet res = await s3.putObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: key, \n\t\t\t\t\t\tBody: fs.createReadStream(fileData), \n\t\t\t\t\t\tACL: 'private', \n\t\t\t\t\t\tContentType: contentType, \n\t\t\t\t\t\tContentDisposition: 'inline'\n\t\t\t\t\t});\n\n\t\t\t\t\tif (res) {\n\t\t\t\t\t\treturn Files.create({\t\n\t\t\t\t\t\t\t_id: objectIdHexString(), __v: 0, name: fileName, size: 1, key: key, order: fileOrder, type: fileType\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\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Upload Non PDF Stream And Save: ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\t\n\t\t},\n\t\tdeleteFiles: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tkeys: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'keys.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(keys: string[]) {\n\t\t\t\tif (!Array.isArray(keys) || keys.length === 0) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\tlet files = await Files.find({key: {$in: keys}});\n\t\n\t\t\t\tlet deleteCnt = files.length;\n\t\n\t\t\t\tfor (let file of files) {\n\t\t\t\t\tawait Files.deleteOne({_id: file._id});\n\t\t\t\t\t\n\t\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\t\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet res = await s3.deleteObject({\n\t\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\t\tKey: file.key\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\tdeleteCnt--;\n\t\t\t\t\t\t\tif (!deleteCnt) {\n\t\t\t\t\t\t\t\treturn files.length;\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 (err) {\n\t\t\t\t\t\terr.mesage = 'Error In AWS Delete Files: ' + err.mesage;\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t},\n\t\tdeleteFile: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tkey: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(key: string) {\t\t\n\t\t\t\tlet file = await Files.findOne({key: key});\n\t\n\t\t\t\tif (file) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait Files.deleteOne({_id: file._id});\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\terr.mesage = 'Error In AWS Delete File (Resolve Side): ' + err.mesage;\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tlet res = await s3.deleteObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET,\n\t\t\t\t\t\tKey: key\n\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Delete File (AWS Side): ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tdeleteFileWithId: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_file: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(id_file: string) {\n\t\t\t\tlet file = await Files.findOne({_id: id_file});\n\t\n\t\t\t\tif (!file) {\n\t\t\t\t\tthrow new Error('Error in AWS Delete File With ID: Could not find file');\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait Files.deleteOne({_id: file._id});\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Delete File With ID (Resolve Side): ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tlet res = await s3.deleteObject({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET,\n\t\t\t\t\t\tKey: file.key\n\t\t\t\t\t});\n\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Delete File With ID (AWS Side): ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tgetSignedUrlsAndFilesWithId: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tids: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'ids.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(ids: string[], expires: number) {\n\t\t\t\tlet res = [];\n\n\t\t\t\tlet files = await Files.find({_id: {$in: ids}});\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < files.length; i++) {\n\t\t\t\t\tlet file = files[i];\n\t\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: file.key\n\t\t\t\t\t});\n\t\t\t\t\tres.push(await getSignedUrl(s3, getCommand, {expiresIn: expires}));\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn {res: res, fileArray: files.map(a => a.name)};\n\t\t\t}\n\t\t},\n\t\tgetSignedUrlWithId: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_file: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(id_file: string, expires: number) {\n\t\t\t\tlet file = await Files.findOne({_id: id_file});\n\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\tKey: file.key\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\treturn getSignedUrl(s3, getCommand, {expiresIn: expires});\n\t\t\t}\n\t\t},\n\t\tgetSignedUrlUSEast1BucketAndKey: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tbucket: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tkey: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(bucket: string, key: string, expires: number) {\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3USEast1();\n\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\tBucket: bucket, \n\t\t\t\t\tKey: key\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\treturn getSignedUrl(s3, getCommand, {expiresIn: expires});\n\t\t\t}\n\t\t},\n\t\tgetSignedUrl: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tkey: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tbypassLogs: true,\n\t\t\tfunction: function(key: string, expires: number) {\n\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\tKey: key\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\treturn getSignedUrl(s3, getCommand, {expiresIn: expires});\n\t\t\t}\n\t\t},\n\t\tgetSignedUrls: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tkeys: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'keys.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\texpires: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tbypassLogs: true,\n\t\t\tfunction: async function(keys: string[], expires: number) {\n\t\t\t\tlet res = [];\n\n\t\t\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\t\t\tlet key = keys[i];\n\t\t\t\t\tlet s3 = (<AWS>this.getAWS()).s3();\n\t\t\t\t\tlet getCommand = new GetObjectCommand({\n\t\t\t\t\t\tBucket: process.env.AWS_S3_BUCKET, \n\t\t\t\t\t\tKey: key\n\t\t\t\t\t});\n\n\t\t\t\t\tres.push(await getSignedUrl(s3, getCommand, {expiresIn: expires}));\n\t\t\t\t}\n\n\t\t\t\treturn res;\n\t\t\t}\n\t\t},\n\t\tgetDataURIfromURL: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\turl: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tbypassLogs: true,\n\t\t\tfunction: async function(url: string) {\n\t\t\t\tconst response = await axios.get(url, {\n\t\t\t\t\tresponseType: 'arraybuffer'\n\t\t\t\t});\n\t\t\t\n\t\t\t\tif (response.status !== 200) {\n\t\t\t\t\tthrow new Error(`Error in Get Data URI From URL: Failed to fetch URL, status: ${response.status}`);\n\t\t\t\t}\n\t\t\t\n\t\t\t\tconst contentType = response.headers['content-type'];\n\t\t\t\tconst dataBase64 = Buffer.from(response.data).toString('base64');\n\t\t\t\treturn `data:${contentType};base64,${dataBase64}`;\n\t\t\t}\n\t\t},\n\t\temailFile: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_file: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\temail: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n additional_message: {\n type: String\n }\n\t\t\t}),\n\t\t\tfunction: async function(id_file: string, email: string, additional_message) {\n\t\t\t\tlet file = await Files.findById(id_file);\n\n\t\t\t\tif (!file) {\n\t\t\t\t\tthrow new Error('Error in AWS Email File: Could not find file');\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tlet resPDF = await this.callMethod('getSignedUrl', file.key, 259200);\n\t\t\t\t\t\n\t\t\t\t\tif (resPDF) {\n\t\t\t\t\t\tif (file.size < 5000000) {\n\t\t\t\t\t\t\tlet emailMessage = 'Attached is the file requested for email.\\n' + (additional_message !== '' ? '\\nAdditional Message:\\n' + additional_message + '\\n' : '') ;\n\n\t\t\t\t\t\t\tawait this.sendEmail(email, ResolveIOServer.getClientName() + ' File - ' + file.name, emailMessage, '', [{\n\t\t\t\t\t\t\t\tfilename: file.name,\n\t\t\t\t\t\t\t\tpath: resPDF\n\t\t\t\t\t\t\t}], null, '');\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tlet emailMessage = 'Please click the link to the requested file.\\n' + (additional_message !== '' ? '\\nAdditional Message:\\n' + additional_message + '\\n' : '') ;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tawait this.sendEmail(email, ResolveIOServer.getClientName() + ' File - ' + file.name, emailMessage + resPDF, '', null, null, '');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthrow new Error('Error in AWS Email File: Could not get file URL');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.mesage = 'Error In AWS Email File: ' + err.mesage;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
@@ -69,6 +69,7 @@ var pagination_model_1 = require("../models/pagination.model");
69
69
  var resolveio_server_app_1 = require("../resolveio-server-app");
70
70
  var common_1 = require("../util/common");
71
71
  var ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
72
+ var INVOICE_COLLECTION = 'invoices';
72
73
  var SUPPORT_TICKET_COLLECTION = 'support-tickets';
73
74
  var SUPPORT_TICKET_SYSTEM_USER_ID = 'resolveio';
74
75
  var SUPPORT_TICKET_SYSTEM_USER = 'ResolveIO';
@@ -153,11 +154,41 @@ function normalizeSupportTicketMessage(message) {
153
154
  }
154
155
  return normalizedMessage;
155
156
  }
157
+ function roundInvoiceLifecycleDate(value) {
158
+ var parsedValue = coerceDateValue(value);
159
+ if (!(parsedValue instanceof Date) || Number.isNaN(parsedValue.getTime())) {
160
+ return null;
161
+ }
162
+ var roundedDate = new Date(parsedValue);
163
+ roundedDate.setSeconds(0, 0);
164
+ return roundedDate;
165
+ }
166
+ function normalizeInvoiceLifecycleDates(doc) {
167
+ if (!doc || (doc.status !== 'Invoiced' && doc.status !== 'Paid/Closed')) {
168
+ return;
169
+ }
170
+ var invoiceDate = roundInvoiceLifecycleDate(doc.date_invoice)
171
+ || roundInvoiceLifecycleDate(doc.createdAt)
172
+ || roundInvoiceLifecycleDate(new Date());
173
+ if (!doc.date_invoice && invoiceDate) {
174
+ doc.date_invoice = invoiceDate;
175
+ }
176
+ if (!doc.date_due && doc.date_invoice instanceof Date && !Number.isNaN(doc.date_invoice.getTime())) {
177
+ var dueDate = new Date(doc.date_invoice);
178
+ dueDate.setDate(dueDate.getDate() + 30);
179
+ doc.date_due = dueDate;
180
+ }
181
+ }
156
182
  function normalizeDocumentBeforeReplace(collection, doc) {
157
- if (!doc || collection !== SUPPORT_TICKET_COLLECTION || !Array.isArray(doc.messages)) {
183
+ if (!doc) {
158
184
  return;
159
185
  }
160
- doc.messages = doc.messages.map(function (message) { return normalizeSupportTicketMessage(message); });
186
+ if (collection === INVOICE_COLLECTION) {
187
+ normalizeInvoiceLifecycleDates(doc);
188
+ }
189
+ if (collection === SUPPORT_TICKET_COLLECTION && Array.isArray(doc.messages)) {
190
+ doc.messages = doc.messages.map(function (message) { return normalizeSupportTicketMessage(message); });
191
+ }
161
192
  }
162
193
  function loadCollectionMethods(methodManager) {
163
194
  methodManager.methods({
@@ -174,6 +205,7 @@ function loadCollectionMethods(methodManager) {
174
205
  // Query database for any collection and query
175
206
  findOne: {
176
207
  bypassSession: true,
208
+ bypassLogs: true,
177
209
  check: new simpl_schema_1.default({
178
210
  collection: {
179
211
  type: String
@@ -193,6 +225,7 @@ function loadCollectionMethods(methodManager) {
193
225
  },
194
226
  find: {
195
227
  bypassSession: true,
228
+ bypassLogs: true,
196
229
  check: new simpl_schema_1.default({
197
230
  collection: {
198
231
  type: String
@@ -218,6 +251,7 @@ function loadCollectionMethods(methodManager) {
218
251
  },
219
252
  findWithOptions: {
220
253
  bypassSession: true,
254
+ bypassLogs: true,
221
255
  check: new simpl_schema_1.default({
222
256
  collection: {
223
257
  type: String
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/collections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;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\nconst ISO_DATE_REGEX = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$/;\nconst SUPPORT_TICKET_COLLECTION = 'support-tickets';\nconst SUPPORT_TICKET_SYSTEM_USER_ID = 'resolveio';\nconst SUPPORT_TICKET_SYSTEM_USER = 'ResolveIO';\n\nfunction coerceDateValue(value: unknown): unknown {\n\tif (value instanceof Date) {\n\t\treturn value;\n\t}\n\n\tif (typeof value !== 'string' || !ISO_DATE_REGEX.test(value)) {\n\t\treturn value;\n\t}\n\n\tconst parsed = new Date(value);\n\treturn Number.isNaN(parsed.getTime()) ? value : parsed;\n}\n\nfunction coerceDatePath(target: any, segments: string[]) {\n\tif (!target || !segments.length) {\n\t\treturn;\n\t}\n\n\tconst [segment, ...rest] = segments;\n\n\tif (segment === '$') {\n\t\tif (Array.isArray(target)) {\n\t\t\ttarget.forEach(item => coerceDatePath(item, rest));\n\t\t}\n\t\treturn;\n\t}\n\n\tif (!Object.prototype.hasOwnProperty.call(target, segment)) {\n\t\treturn;\n\t}\n\n\tif (rest.length === 0) {\n\t\tconst updatedValue = coerceDateValue(target[segment]);\n\t\tif (updatedValue !== target[segment]) {\n\t\t\ttarget[segment] = updatedValue;\n\t\t}\n\t\treturn;\n\t}\n\n\tcoerceDatePath(target[segment], rest);\n}\n\nfunction coerceDateFields(collectionRef: any, doc: any) {\n\tif (!collectionRef || !collectionRef.simplschema || !doc) {\n\t\treturn;\n\t}\n\n\tconst schema = collectionRef.simplschema;\n\tconst schemaKeys = Object.keys(schema.schema());\n\n\tschemaKeys.forEach(schemaKey => {\n\t\tconst definition = schema.schema(schemaKey);\n\t\tconst typeDefs = definition?.type?.definitions;\n\t\tif (!typeDefs || !typeDefs.some(typeDef => typeDef.type === Date)) {\n\t\t\treturn;\n\t\t}\n\n\t\tcoerceDatePath(doc, schemaKey.split('.'));\n\t});\n}\n\nfunction normalizeSupportTicketMessage(message: any): any {\n\tif (!message || typeof message !== 'object' || Array.isArray(message)) {\n\t\treturn message;\n\t}\n\n\tconst normalizedMessage = {\n\t\t...message\n\t};\n\tconst currentIdUser = typeof normalizedMessage.id_user === 'string' ? normalizedMessage.id_user.trim() : '';\n\tif (currentIdUser) {\n\t\treturn normalizedMessage;\n\t}\n\n\tconst normalizedUser = String(normalizedMessage.user || '').trim().toLowerCase();\n\tconst normalizedType = String(normalizedMessage.type || '').trim().toLowerCase();\n\tconst normalizedSource = String(normalizedMessage.source || '').trim().toLowerCase();\n\tconst normalizedVisibility = String(normalizedMessage.visibility || '').trim().toLowerCase();\n\tconst normalizedBadge = String(normalizedMessage.badge || '').trim().toLowerCase();\n\tconst isInternalSystemMessage = normalizedMessage.internal === true\n\t\t|| normalizedType === 'resolveio'\n\t\t|| normalizedType === 'internal'\n\t\t|| normalizedSource.startsWith('support-')\n\t\t|| normalizedSource.startsWith('support_')\n\t\t|| normalizedVisibility === 'internal'\n\t\t|| normalizedBadge === 'internal'\n\t\t|| normalizedBadge === 'ai'\n\t\t|| normalizedUser.startsWith('resolveio');\n\n\tif (!isInternalSystemMessage) {\n\t\treturn normalizedMessage;\n\t}\n\n\tnormalizedMessage.id_user = SUPPORT_TICKET_SYSTEM_USER_ID;\n\tif (!String(normalizedMessage.user || '').trim()) {\n\t\tnormalizedMessage.user = SUPPORT_TICKET_SYSTEM_USER;\n\t}\n\treturn normalizedMessage;\n}\n\nfunction normalizeDocumentBeforeReplace(collection: string, doc: any) {\n\tif (!doc || collection !== SUPPORT_TICKET_COLLECTION || !Array.isArray(doc.messages)) {\n\t\treturn;\n\t}\n\n\tdoc.messages = doc.messages.map((message: any) => normalizeSupportTicketMessage(message));\n}\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\tconst collectionRef = ResolveIOServer.getMongoManager().collection(collection);\n\t\t\t\tif (!collectionRef) {\n\t\t\t\t\tthrow new Error('Error in Update Document Collection: Invalid collection');\n\t\t\t\t}\n\n\t\t\t\tnormalizeDocumentBeforeReplace(collection, f_document);\n\t\t\t\tcoerceDateFields(collectionRef, f_document);\n\t\t\t\tawait collectionRef.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\tconst collectionRef = ResolveIOServer.getMongoManager().collection(collection);\n\t\t\t\tif (!collectionRef) {\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 collectionRef.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\tnormalizeDocumentBeforeReplace(collection, modifiedDoc);\n\t\t\t\t\t\t\tcoerceDateFields(collectionRef, modifiedDoc);\n\t\t\t\t\t\t\tawait collectionRef.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\tnormalizeDocumentBeforeReplace(collection, updatedDoc);\n\t\t\t\t\t\t\t\t\tcoerceDateFields(collectionRef, updatedDoc);\n\t\t\t\t\t\t\t\t\tawait collectionRef.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\tconst collectionRef = ResolveIOServer.getMongoManager().collection(collection);\n\t\t\t\tif (!collectionRef) {\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 collectionRef.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\tnormalizeDocumentBeforeReplace(collection, f_document);\n\t\t\t\t\t\t\tcoerceDateFields(collectionRef, f_document);\n\t\t\t\t\t\t\tawait collectionRef.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\tnormalizeDocumentBeforeReplace(collection, updatedDoc);\n\t\t\t\t\t\t\t\t\tcoerceDateFields(collectionRef, updatedDoc);\n\t\t\t\t\t\t\t\t\tawait collectionRef.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\tconst collectionRef = ResolveIOServer.getMongoManager().collection(collection);\n\t\t\t\tif (!collectionRef) {\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 collectionRef.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\tnormalizeDocumentBeforeReplace(collection, modifiedDoc);\n\t\t\t\t\t\t\tcoerceDateFields(collectionRef, modifiedDoc);\n\t\t\t\t\t\t\tawait collectionRef.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\tnormalizeDocumentBeforeReplace(collection, updatedDoc);\n\t\t\t\t\t\t\t\t\tcoerceDateFields(collectionRef, updatedDoc);\n\t\t\t\t\t\t\t\t\tawait collectionRef.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4JA,sDAoeC;AAhoBD,6CAAwC;AAExC,+DAAwF;AACxF,gEAA0D;AAC1D,yCAAsF;AAEtF,IAAM,cAAc,GAAG,kDAAkD,CAAC;AAC1E,IAAM,kBAAkB,GAAG,UAAU,CAAC;AACtC,IAAM,yBAAyB,GAAG,iBAAiB,CAAC;AACpD,IAAM,6BAA6B,GAAG,WAAW,CAAC;AAClD,IAAM,0BAA0B,GAAG,WAAW,CAAC;AAE/C,SAAS,eAAe,CAAC,KAAc;IACtC,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QA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ACD,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,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\nconst ISO_DATE_REGEX = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$/;\nconst INVOICE_COLLECTION = 'invoices';\nconst SUPPORT_TICKET_COLLECTION = 'support-tickets';\nconst SUPPORT_TICKET_SYSTEM_USER_ID = 'resolveio';\nconst SUPPORT_TICKET_SYSTEM_USER = 'ResolveIO';\n\nfunction coerceDateValue(value: unknown): unknown {\n\tif (value instanceof Date) {\n\t\treturn value;\n\t}\n\n\tif (typeof value !== 'string' || !ISO_DATE_REGEX.test(value)) {\n\t\treturn value;\n\t}\n\n\tconst parsed = new Date(value);\n\treturn Number.isNaN(parsed.getTime()) ? value : parsed;\n}\n\nfunction coerceDatePath(target: any, segments: string[]) {\n\tif (!target || !segments.length) {\n\t\treturn;\n\t}\n\n\tconst [segment, ...rest] = segments;\n\n\tif (segment === '$') {\n\t\tif (Array.isArray(target)) {\n\t\t\ttarget.forEach(item => coerceDatePath(item, rest));\n\t\t}\n\t\treturn;\n\t}\n\n\tif (!Object.prototype.hasOwnProperty.call(target, segment)) {\n\t\treturn;\n\t}\n\n\tif (rest.length === 0) {\n\t\tconst updatedValue = coerceDateValue(target[segment]);\n\t\tif (updatedValue !== target[segment]) {\n\t\t\ttarget[segment] = updatedValue;\n\t\t}\n\t\treturn;\n\t}\n\n\tcoerceDatePath(target[segment], rest);\n}\n\nfunction coerceDateFields(collectionRef: any, doc: any) {\n\tif (!collectionRef || !collectionRef.simplschema || !doc) {\n\t\treturn;\n\t}\n\n\tconst schema = collectionRef.simplschema;\n\tconst schemaKeys = Object.keys(schema.schema());\n\n\tschemaKeys.forEach(schemaKey => {\n\t\tconst definition = schema.schema(schemaKey);\n\t\tconst typeDefs = definition?.type?.definitions;\n\t\tif (!typeDefs || !typeDefs.some(typeDef => typeDef.type === Date)) {\n\t\t\treturn;\n\t\t}\n\n\t\tcoerceDatePath(doc, schemaKey.split('.'));\n\t});\n}\n\nfunction normalizeSupportTicketMessage(message: any): any {\n\tif (!message || typeof message !== 'object' || Array.isArray(message)) {\n\t\treturn message;\n\t}\n\n\tconst normalizedMessage = {\n\t\t...message\n\t};\n\tconst currentIdUser = typeof normalizedMessage.id_user === 'string' ? normalizedMessage.id_user.trim() : '';\n\tif (currentIdUser) {\n\t\treturn normalizedMessage;\n\t}\n\n\tconst normalizedUser = String(normalizedMessage.user || '').trim().toLowerCase();\n\tconst normalizedType = String(normalizedMessage.type || '').trim().toLowerCase();\n\tconst normalizedSource = String(normalizedMessage.source || '').trim().toLowerCase();\n\tconst normalizedVisibility = String(normalizedMessage.visibility || '').trim().toLowerCase();\n\tconst normalizedBadge = String(normalizedMessage.badge || '').trim().toLowerCase();\n\tconst isInternalSystemMessage = normalizedMessage.internal === true\n\t\t|| normalizedType === 'resolveio'\n\t\t|| normalizedType === 'internal'\n\t\t|| normalizedSource.startsWith('support-')\n\t\t|| normalizedSource.startsWith('support_')\n\t\t|| normalizedVisibility === 'internal'\n\t\t|| normalizedBadge === 'internal'\n\t\t|| normalizedBadge === 'ai'\n\t\t|| normalizedUser.startsWith('resolveio');\n\n\tif (!isInternalSystemMessage) {\n\t\treturn normalizedMessage;\n\t}\n\n\tnormalizedMessage.id_user = SUPPORT_TICKET_SYSTEM_USER_ID;\n\tif (!String(normalizedMessage.user || '').trim()) {\n\t\tnormalizedMessage.user = SUPPORT_TICKET_SYSTEM_USER;\n\t}\n\treturn normalizedMessage;\n}\n\nfunction roundInvoiceLifecycleDate(value: unknown): Date | null {\n\tconst parsedValue = coerceDateValue(value);\n\tif (!(parsedValue instanceof Date) || Number.isNaN(parsedValue.getTime())) {\n\t\treturn null;\n\t}\n\n\tconst roundedDate = new Date(parsedValue);\n\troundedDate.setSeconds(0, 0);\n\treturn roundedDate;\n}\n\nfunction normalizeInvoiceLifecycleDates(doc: any) {\n\tif (!doc || (doc.status !== 'Invoiced' && doc.status !== 'Paid/Closed')) {\n\t\treturn;\n\t}\n\n\tconst invoiceDate = roundInvoiceLifecycleDate(doc.date_invoice)\n\t\t|| roundInvoiceLifecycleDate(doc.createdAt)\n\t\t|| roundInvoiceLifecycleDate(new Date());\n\n\tif (!doc.date_invoice && invoiceDate) {\n\t\tdoc.date_invoice = invoiceDate;\n\t}\n\tif (!doc.date_due && doc.date_invoice instanceof Date && !Number.isNaN(doc.date_invoice.getTime())) {\n\t\tconst dueDate = new Date(doc.date_invoice);\n\t\tdueDate.setDate(dueDate.getDate() + 30);\n\t\tdoc.date_due = dueDate;\n\t}\n}\n\nfunction normalizeDocumentBeforeReplace(collection: string, doc: any) {\n\tif (!doc) {\n\t\treturn;\n\t}\n\n\tif (collection === INVOICE_COLLECTION) {\n\t\tnormalizeInvoiceLifecycleDates(doc);\n\t}\n\n\tif (collection === SUPPORT_TICKET_COLLECTION && Array.isArray(doc.messages)) {\n\t\tdoc.messages = doc.messages.map((message: any) => normalizeSupportTicketMessage(message));\n\t}\n}\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\tbypassLogs: 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\tbypassLogs: 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\tbypassLogs: 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\tconst collectionRef = ResolveIOServer.getMongoManager().collection(collection);\n\t\t\t\tif (!collectionRef) {\n\t\t\t\t\tthrow new Error('Error in Update Document Collection: Invalid collection');\n\t\t\t\t}\n\n\t\t\t\tnormalizeDocumentBeforeReplace(collection, f_document);\n\t\t\t\tcoerceDateFields(collectionRef, f_document);\n\t\t\t\tawait collectionRef.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\tconst collectionRef = ResolveIOServer.getMongoManager().collection(collection);\n\t\t\t\tif (!collectionRef) {\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 collectionRef.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\tnormalizeDocumentBeforeReplace(collection, modifiedDoc);\n\t\t\t\t\t\t\tcoerceDateFields(collectionRef, modifiedDoc);\n\t\t\t\t\t\t\tawait collectionRef.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\tnormalizeDocumentBeforeReplace(collection, updatedDoc);\n\t\t\t\t\t\t\t\t\tcoerceDateFields(collectionRef, updatedDoc);\n\t\t\t\t\t\t\t\t\tawait collectionRef.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\tconst collectionRef = ResolveIOServer.getMongoManager().collection(collection);\n\t\t\t\tif (!collectionRef) {\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 collectionRef.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\tnormalizeDocumentBeforeReplace(collection, f_document);\n\t\t\t\t\t\t\tcoerceDateFields(collectionRef, f_document);\n\t\t\t\t\t\t\tawait collectionRef.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\tnormalizeDocumentBeforeReplace(collection, updatedDoc);\n\t\t\t\t\t\t\t\t\tcoerceDateFields(collectionRef, updatedDoc);\n\t\t\t\t\t\t\t\t\tawait collectionRef.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\tconst collectionRef = ResolveIOServer.getMongoManager().collection(collection);\n\t\t\t\tif (!collectionRef) {\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 collectionRef.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\tnormalizeDocumentBeforeReplace(collection, modifiedDoc);\n\t\t\t\t\t\t\tcoerceDateFields(collectionRef, modifiedDoc);\n\t\t\t\t\t\t\tawait collectionRef.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\tnormalizeDocumentBeforeReplace(collection, updatedDoc);\n\t\t\t\t\t\t\t\t\tcoerceDateFields(collectionRef, updatedDoc);\n\t\t\t\t\t\t\t\t\tawait collectionRef.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"]}
@@ -49,6 +49,7 @@ function loadCounterMethods(methodManager) {
49
49
  type: String
50
50
  }
51
51
  }),
52
+ bypassLogs: true,
52
53
  function: function (counterType) {
53
54
  return __awaiter(this, void 0, void 0, function () {
54
55
  var counter, newCount;
@@ -85,6 +86,7 @@ function loadCounterMethods(methodManager) {
85
86
  blackbox: true
86
87
  }
87
88
  }),
89
+ bypassLogs: true,
88
90
  function: function (collectionType, query) {
89
91
  if (!resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(collectionType)) {
90
92
  throw new Error('Error in Count Collection With Query: Invalid collection');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/counters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,gDA4DC;AAlED,6CAAwC;AACxC,wEAA6D;AAE7D,gEAA0D;AAC1D,yCAAmD;AAEnD,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACrB,UAAU,EAAE;YACX,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,WAAW,EAAE;oBACZ,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAe,WAAmB;;;;;oCAC7B,qBAAM,6BAAQ,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC,EAAA;;gCAArD,OAAO,GAAG,SAA2C;qCAErD,CAAC,OAAO,EAAR,wBAAQ;gCACX,qBAAM,6BAAQ,CAAC,MAAM,CAAC;wCACrB,GAAG,EAAE,IAAA,0BAAiB,GAAE;wCACxB,KAAK,EAAE,CAAC;wCACR,IAAI,EAAE,WAAW;qCACjB,CAAC,EAAA;;gCAJF,SAIE,CAAC;gCAEH,sBAAO,CAAC,EAAC;oCAGM,qBAAM,6BAAQ,CAAC,gBAAgB,CAAC,EAAC,IAAI,EAAE,WAAW,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,EAAC,CAAC,EAAA;;gCAAnF,QAAQ,GAAG,SAAwE;gCAEvF,sBAAO,QAAQ,CAAC,KAAK,EAAC;;;;aAEvB;SACD;QACD,wBAAwB,EAAE;YACzB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,cAAc,EAAE;oBACf,IAAI,EAAE,MAAM;iBACZ;gBACD,KAAK,EAAE;oBACN,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,IAAI;iBACd;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,cAAsB,EAAE,KAAa;gBACvD,IAAI,CAAC,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;oBACnE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;gBAC7E,CAAC;gBAED,OAAO,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC3F,CAAC;SACD;QACD,eAAe,EAAE;YAChB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,cAAc,EAAE;oBACf,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,cAAsB;gBACxC,IAAI,CAAC,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;oBACnE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;gBAClE,CAAC;gBAED,OAAO,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,EAAE,CAAC;YACtF,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC","file":"counters.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Counters } from '../collections/counter.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\n\nexport function loadCounterMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tincCounter: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcounterType: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(counterType: string) {\n\t\t\t\tlet counter = await Counters.findOne({type: counterType});\n\n\t\t\t\tif (!counter) {\n\t\t\t\t\tawait Counters.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\tcount: 2,\n\t\t\t\t\t\ttype: counterType\n\t\t\t\t\t});\n\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet newCount = await Counters.findOneAndUpdate({type: counterType}, {$inc: {count: 1}});\n\n\t\t\t\t\treturn newCount.count;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tcountCollectionWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollectionType: {\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(collectionType: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collectionType)) {\n\t\t\t\t\tthrow new Error('Error in Count Collection With Query: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collectionType).countDocuments(query);\n\t\t\t}\n\t\t},\n\t\tcountCollection: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollectionType: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collectionType: string) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collectionType)) {\n\t\t\t\t\tthrow new Error('Error in Count Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collectionType).countDocuments();\n\t\t\t}\n\t\t}\n\t});\n}"]}
1
+ {"version":3,"sources":["../../src/methods/counters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,EAAE,CAAC;oBACnE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;gBAC7E,CAAC;gBAED,OAAO,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC3F,CAAC;SACD;QACD,eAAe,EAAE;YAChB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,cAAc,EAAE;oBACf,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,cAAsB;gBACxC,IAAI,CAAC,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;oBACnE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;gBAClE,CAAC;gBAED,OAAO,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,EAAE,CAAC;YACtF,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC","file":"counters.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Counters } from '../collections/counter.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\n\nexport function loadCounterMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tincCounter: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcounterType: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tbypassLogs: true,\n\t\t\tfunction: async function(counterType: string) {\n\t\t\t\tlet counter = await Counters.findOne({type: counterType});\n\n\t\t\t\tif (!counter) {\n\t\t\t\t\tawait Counters.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\tcount: 2,\n\t\t\t\t\t\ttype: counterType\n\t\t\t\t\t});\n\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet newCount = await Counters.findOneAndUpdate({type: counterType}, {$inc: {count: 1}});\n\n\t\t\t\t\treturn newCount.count;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tcountCollectionWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollectionType: {\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\tbypassLogs: true,\n\t\t\tfunction: function(collectionType: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collectionType)) {\n\t\t\t\t\tthrow new Error('Error in Count Collection With Query: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collectionType).countDocuments(query);\n\t\t\t}\n\t\t},\n\t\tcountCollection: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollectionType: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collectionType: string) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collectionType)) {\n\t\t\t\t\tthrow new Error('Error in Count Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collectionType).countDocuments();\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
package/methods/logs.js CHANGED
@@ -358,6 +358,7 @@ function loadLogMethods(methodManager) {
358
358
  skipValidation: true
359
359
  },
360
360
  insertSubscriptionLog: {
361
+ bypassLogs: true,
361
362
  function: function (type, subscription, collection_name, subData) {
362
363
  return __awaiter(this, void 0, void 0, function () {
363
364
  return __generator(this, function (_a) {