@resolveio/server-lib 22.2.49 → 22.2.51
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/managers/method.manager.js +7 -9
- package/managers/method.manager.js.map +1 -1
- package/methods/aws.js +3 -0
- package/methods/aws.js.map +1 -1
- package/methods/collections.js +62 -0
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +2 -0
- package/methods/counters.js.map +1 -1
- package/methods/logs.js +1 -0
- package/methods/logs.js.map +1 -1
- package/methods/publications.js +1 -1
- package/methods/publications.js.map +1 -1
- package/methods/support.js +1 -0
- package/methods/support.js.map +1 -1
- package/models/method.model.d.ts +2 -0
- package/models/method.model.js.map +1 -1
- package/package.json +1 -1
- package/services/codex-client.js +9 -0
- package/services/codex-client.js.map +1 -1
package/methods/aws.js.map
CHANGED
|
@@ -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,KAAK,EAAE,8BAA8B;IACrC,MAAM,EAAE,mBAAmB;IAC3B,MAAM,EAAE,kBAAkB;IAC1B,K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AGlI,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;IACzB,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,kBAAkB;IAC1B,MAAM,EAAE,iBAA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;;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"]}
|
package/methods/collections.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -58,6 +69,9 @@ var pagination_model_1 = require("../models/pagination.model");
|
|
|
58
69
|
var resolveio_server_app_1 = require("../resolveio-server-app");
|
|
59
70
|
var common_1 = require("../util/common");
|
|
60
71
|
var ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
|
|
72
|
+
var SUPPORT_TICKET_COLLECTION = 'support-tickets';
|
|
73
|
+
var SUPPORT_TICKET_SYSTEM_USER_ID = 'resolveio';
|
|
74
|
+
var SUPPORT_TICKET_SYSTEM_USER = 'ResolveIO';
|
|
61
75
|
function coerceDateValue(value) {
|
|
62
76
|
if (value instanceof Date) {
|
|
63
77
|
return value;
|
|
@@ -107,6 +121,44 @@ function coerceDateFields(collectionRef, doc) {
|
|
|
107
121
|
coerceDatePath(doc, schemaKey.split('.'));
|
|
108
122
|
});
|
|
109
123
|
}
|
|
124
|
+
function normalizeSupportTicketMessage(message) {
|
|
125
|
+
if (!message || typeof message !== 'object' || Array.isArray(message)) {
|
|
126
|
+
return message;
|
|
127
|
+
}
|
|
128
|
+
var normalizedMessage = __assign({}, message);
|
|
129
|
+
var currentIdUser = typeof normalizedMessage.id_user === 'string' ? normalizedMessage.id_user.trim() : '';
|
|
130
|
+
if (currentIdUser) {
|
|
131
|
+
return normalizedMessage;
|
|
132
|
+
}
|
|
133
|
+
var normalizedUser = String(normalizedMessage.user || '').trim().toLowerCase();
|
|
134
|
+
var normalizedType = String(normalizedMessage.type || '').trim().toLowerCase();
|
|
135
|
+
var normalizedSource = String(normalizedMessage.source || '').trim().toLowerCase();
|
|
136
|
+
var normalizedVisibility = String(normalizedMessage.visibility || '').trim().toLowerCase();
|
|
137
|
+
var normalizedBadge = String(normalizedMessage.badge || '').trim().toLowerCase();
|
|
138
|
+
var isInternalSystemMessage = normalizedMessage.internal === true
|
|
139
|
+
|| normalizedType === 'resolveio'
|
|
140
|
+
|| normalizedType === 'internal'
|
|
141
|
+
|| normalizedSource.startsWith('support-')
|
|
142
|
+
|| normalizedSource.startsWith('support_')
|
|
143
|
+
|| normalizedVisibility === 'internal'
|
|
144
|
+
|| normalizedBadge === 'internal'
|
|
145
|
+
|| normalizedBadge === 'ai'
|
|
146
|
+
|| normalizedUser.startsWith('resolveio');
|
|
147
|
+
if (!isInternalSystemMessage) {
|
|
148
|
+
return normalizedMessage;
|
|
149
|
+
}
|
|
150
|
+
normalizedMessage.id_user = SUPPORT_TICKET_SYSTEM_USER_ID;
|
|
151
|
+
if (!String(normalizedMessage.user || '').trim()) {
|
|
152
|
+
normalizedMessage.user = SUPPORT_TICKET_SYSTEM_USER;
|
|
153
|
+
}
|
|
154
|
+
return normalizedMessage;
|
|
155
|
+
}
|
|
156
|
+
function normalizeDocumentBeforeReplace(collection, doc) {
|
|
157
|
+
if (!doc || collection !== SUPPORT_TICKET_COLLECTION || !Array.isArray(doc.messages)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
doc.messages = doc.messages.map(function (message) { return normalizeSupportTicketMessage(message); });
|
|
161
|
+
}
|
|
110
162
|
function loadCollectionMethods(methodManager) {
|
|
111
163
|
methodManager.methods({
|
|
112
164
|
collectionListAll: {
|
|
@@ -122,6 +174,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
122
174
|
// Query database for any collection and query
|
|
123
175
|
findOne: {
|
|
124
176
|
bypassSession: true,
|
|
177
|
+
bypassLogs: true,
|
|
125
178
|
check: new simpl_schema_1.default({
|
|
126
179
|
collection: {
|
|
127
180
|
type: String
|
|
@@ -141,6 +194,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
141
194
|
},
|
|
142
195
|
find: {
|
|
143
196
|
bypassSession: true,
|
|
197
|
+
bypassLogs: true,
|
|
144
198
|
check: new simpl_schema_1.default({
|
|
145
199
|
collection: {
|
|
146
200
|
type: String
|
|
@@ -166,6 +220,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
166
220
|
},
|
|
167
221
|
findWithOptions: {
|
|
168
222
|
bypassSession: true,
|
|
223
|
+
bypassLogs: true,
|
|
169
224
|
check: new simpl_schema_1.default({
|
|
170
225
|
collection: {
|
|
171
226
|
type: String
|
|
@@ -295,6 +350,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
295
350
|
if (!collectionRef) {
|
|
296
351
|
throw new Error('Error in Update Document Collection: Invalid collection');
|
|
297
352
|
}
|
|
353
|
+
normalizeDocumentBeforeReplace(collection, f_document);
|
|
298
354
|
coerceDateFields(collectionRef, f_document);
|
|
299
355
|
return [4 /*yield*/, collectionRef.replaceOne({ _id: f_document['_id'] }, f_document)];
|
|
300
356
|
case 1:
|
|
@@ -347,6 +403,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
347
403
|
modifiedDoc_1[data.prop] = data.data;
|
|
348
404
|
});
|
|
349
405
|
if (!(!doc__v || modifiedDoc_1.__v === doc__v)) return [3 /*break*/, 4];
|
|
406
|
+
normalizeDocumentBeforeReplace(collection, modifiedDoc_1);
|
|
350
407
|
coerceDateFields(collectionRef, modifiedDoc_1);
|
|
351
408
|
return [4 /*yield*/, collectionRef.replaceOne({ _id: modifiedDoc_1._id }, modifiedDoc_1, {}, false, false, currDoc)];
|
|
352
409
|
case 3:
|
|
@@ -371,6 +428,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
371
428
|
updatedDoc.__v = newCurrDocV;
|
|
372
429
|
currDoc._id = newCurrDocId;
|
|
373
430
|
currDoc.__v = newCurrDocV;
|
|
431
|
+
normalizeDocumentBeforeReplace(collection, updatedDoc);
|
|
374
432
|
coerceDateFields(collectionRef, updatedDoc);
|
|
375
433
|
return [4 /*yield*/, collectionRef.replaceOne({ _id: newCurrDocId }, updatedDoc, {}, false, false, currDoc)];
|
|
376
434
|
case 6:
|
|
@@ -414,6 +472,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
414
472
|
currDoc = _a.sent();
|
|
415
473
|
if (!currDoc) return [3 /*break*/, 11];
|
|
416
474
|
if (!(currDoc.__v === f_document['__v'])) return [3 /*break*/, 4];
|
|
475
|
+
normalizeDocumentBeforeReplace(collection, f_document);
|
|
417
476
|
coerceDateFields(collectionRef, f_document);
|
|
418
477
|
return [4 /*yield*/, collectionRef.replaceOne({ _id: f_document['_id'] }, f_document, {}, false, false, currDoc)];
|
|
419
478
|
case 3:
|
|
@@ -439,6 +498,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
439
498
|
updatedDoc.__v = newCurrDocV;
|
|
440
499
|
currDoc._id = newCurrDocId;
|
|
441
500
|
currDoc.__v = newCurrDocV;
|
|
501
|
+
normalizeDocumentBeforeReplace(collection, updatedDoc);
|
|
442
502
|
coerceDateFields(collectionRef, updatedDoc);
|
|
443
503
|
return [4 /*yield*/, collectionRef.replaceOne({ _id: newCurrDocId }, updatedDoc, {}, false, false, currDoc)];
|
|
444
504
|
case 6:
|
|
@@ -496,6 +556,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
496
556
|
modifiedDoc_2[data.prop] = data.data;
|
|
497
557
|
});
|
|
498
558
|
if (!(modifiedDoc_2.__v === doc__v)) return [3 /*break*/, 4];
|
|
559
|
+
normalizeDocumentBeforeReplace(collection, modifiedDoc_2);
|
|
499
560
|
coerceDateFields(collectionRef, modifiedDoc_2);
|
|
500
561
|
return [4 /*yield*/, collectionRef.replaceOne({ _id: modifiedDoc_2._id }, modifiedDoc_2, {}, false, false, currDoc)];
|
|
501
562
|
case 3:
|
|
@@ -520,6 +581,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
520
581
|
updatedDoc.__v = newCurrDocV;
|
|
521
582
|
currDoc._id = newCurrDocId;
|
|
522
583
|
currDoc.__v = newCurrDocV;
|
|
584
|
+
normalizeDocumentBeforeReplace(collection, updatedDoc);
|
|
523
585
|
coerceDateFields(collectionRef, updatedDoc);
|
|
524
586
|
return [4 /*yield*/, collectionRef.replaceOne({ _id: newCurrDocId }, updatedDoc, {}, false, false, currDoc)];
|
|
525
587
|
case 6:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/methods/collections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,sDA0dC;AA/hBD,6CAAwC;AAExC,+DAAwF;AACxF,gEAA0D;AAC1D,yCAAsF;AAEtF,IAAM,cAAc,GAAG,kDAAkD,CAAC;AAE1E,SAAS,eAAe,CAAC,KAAc;IACtC,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,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E,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$/;\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\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\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\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\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\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\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\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\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/coll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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 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\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"]}
|
package/methods/counters.js
CHANGED
|
@@ -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');
|
package/methods/counters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/methods/counters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,
|
|
1
|
+
{"version":3,"sources":["../../src/methods/counters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,gDA8DC;AApED,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,UAAU,EAAE,IAAI;YAChB,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,UAAU,EAAE,IAAI;YAChB,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\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) {
|