@resolveio/server-lib 20.5.0 → 20.5.1

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LocalLogManager=void 0;var fs=require("fs"),LocalLogManager=function(){function LocalLogManager(){fs.existsSync("~/logs")||fs.mkdirSync("~/logs"),this._logFilePath="~/logs/local-logs.jsonl"}return LocalLogManager.prototype.writeLog=function(o){try{var e=JSON.stringify(o)+"\n";fs.appendFileSync(this._logFilePath,e,{encoding:"utf8"})}catch(o){console.error(new Date,"LocalLogManager","Failed to write log to file:",o)}},LocalLogManager.prototype.writeLogs=function(o){if(o&&0!==o.length)try{var e=o.map(function(o){return JSON.stringify(o)}).join("\n")+"\n";fs.appendFileSync(this._logFilePath,e,{encoding:"utf8"})}catch(o){console.error(new Date,"LocalLogManager","Failed to write logs batch:",o)}},LocalLogManager.prototype.offloadLogs=function(){var o=[];try{if(!fs.existsSync(this._logFilePath))return o;var e=fs.readFileSync(this._logFilePath,"utf8");if(0===e.trim().length)return o;o=e.split("\n").filter(function(o){return""!==o.trim()}),fs.writeFileSync(this._logFilePath,"")}catch(o){console.error(new Date,"LocalLogManager","Failed to offload logs:",o)}return o},LocalLogManager}();exports.LocalLogManager=LocalLogManager;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LocalLogManager=void 0;var fs=require("fs"),__1=require(".."),LocalLogManager=function(){function LocalLogManager(){"https://resolveio.com"===__1.ResolveIOServer.getServerConfig().ROOT_URL||"http://localhost:4200"===__1.ResolveIOServer.getServerConfig().ROOT_URL||fs.existsSync("~/logs")||fs.mkdirSync("~/logs"),this._logFilePath="~/logs/local-logs.jsonl"}return LocalLogManager.prototype.writeLog=function(e){try{var o=JSON.stringify(e)+"\n";fs.appendFileSync(this._logFilePath,o,{encoding:"utf8"})}catch(e){console.error(new Date,"LocalLogManager","Failed to write log to file:",e)}},LocalLogManager.prototype.writeLogs=function(e){if(e&&0!==e.length)try{var o=e.map(function(e){return JSON.stringify(e)}).join("\n")+"\n";fs.appendFileSync(this._logFilePath,o,{encoding:"utf8"})}catch(e){console.error(new Date,"LocalLogManager","Failed to write logs batch:",e)}},LocalLogManager.prototype.offloadLogs=function(){var e=[];try{if(!fs.existsSync(this._logFilePath))return e;var o=fs.readFileSync(this._logFilePath,"utf8");if(0===o.trim().length)return e;e=o.split("\n").filter(function(e){return""!==e.trim()}),fs.writeFileSync(this._logFilePath,"")}catch(e){console.error(new Date,"LocalLogManager","Failed to offload logs:",e)}return e},LocalLogManager}();exports.LocalLogManager=LocalLogManager;
2
2
  //# sourceMappingURL=local-log.manager.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/managers/local-log.manager.ts"],"names":["fs","require","LocalLogManager","existsSync","mkdirSync","this","_logFilePath","prototype","writeLog","logEntry","line","JSON","stringify","appendFileSync","encoding","err","console","error","Date","writeLogs","items","length","lines","map","item","join","offloadLogs","result","fileData","readFileSync","trim","split","filter","l","writeFileSync","exports"],"mappings":"mGAGA,IAAAA,GAAAC,QAAA,IAAA,EAeAC,gBAAA,WAGC,SAAAA,kBACMF,GAAGG,WAAW,QAAQ,GAC1BH,GAAGI,UAAU,QAAQ,EAEtBC,KAAKC,aAAe,yBACrB,CAwDD,OArDQJ,gBAAAK,UAAAC,SAAP,SAAgBC,GACf,IACC,IAAIC,EAAOC,KAAKC,UAAUH,CAAQ,EAAI,KACtCT,GAAGa,eAAeR,KAAKC,aAAcI,EAAM,CAAEI,SAAU,MAAM,CAAE,C,CAEhE,MAAMC,GAELC,QAAQC,MAAM,IAAIC,KAAQ,kBAAmB,+BAAgCH,CAAG,C,CAElF,EAEOb,gBAAAK,UAAAY,UAAP,SAAiBC,GAChB,GAAKA,GAA0B,IAAjBA,EAAMC,OAIpB,IAEC,IAAIC,EAAQF,EAAMG,IAAI,SAAAC,GAAQ,OAAAb,KAAKC,UAAUY,CAAI,CAAnB,CAAoB,EAAEC,KAAK,IAAI,EAAI,KACjEzB,GAAGa,eAAeR,KAAKC,aAAcgB,EAAO,CAAER,SAAU,MAAM,CAAE,C,CAEjE,MAAOC,GACNC,QAAQC,MAAM,IAAIC,KAAQ,kBAAmB,8BAA+BH,CAAG,C,CAEjF,EAKOb,gBAAAK,UAAAmB,YAAP,WACC,IAAIC,EAAS,GAEb,IACC,GAAI,CAAC3B,GAAGG,WAAWE,KAAKC,YAAY,EACnC,OAAOqB,EAGR,IAAIC,EAAW5B,GAAG6B,aAAaxB,KAAKC,aAAc,MAAM,EACxD,GAA+B,IAA3BsB,EAASE,KAAI,EAAGT,OACnB,OAAOM,EAGRA,EAASC,EAASG,MAAM,IAAI,EAAEC,OAAO,SAAAC,GAAK,MAAa,KAAbA,EAAEH,KAAI,CAAN,CAAe,EAGzD9B,GAAGkC,cAAc7B,KAAKC,aAAc,EAAE,C,CAEvC,MAAMS,GACLC,QAAQC,MAAM,IAAIC,KAAQ,kBAAmB,0BAA2BH,CAAG,C,CAG5E,OAAOY,CACR,EACDzB,eAAA,EAAC,EAhEYiC,QAAAjC,gBAAAA","file":"local-log.manager.js","sourcesContent":["/***************\nlocal-logs.manager.ts\n****************/\nimport * as fs from 'fs';\n\nexport type LocalLogType = 'monitor-mongo' \n\t| 'monitor-memory'\n\t| 'monitor-cpu'\n\t| 'log'\n\t| 'log-method-latency'\n\t| 'log-subscription';\n\nexport interface LocalLogModel {\n\ttype: LocalLogType;\n\tdate: Date;\n\tdata: any;\n}\n\nexport class LocalLogManager {\n\tprivate _logFilePath: string;\n\n\tconstructor() {\n\t\tif (!fs.existsSync('~/logs')) {\n\t\t\tfs.mkdirSync('~/logs');\n\t\t}\n\t\tthis._logFilePath = '~/logs/local-logs.jsonl';\n\t}\n\n\t// Internal method to append a JSON line to the file\n\tpublic writeLog(logEntry: LocalLogModel): void {\n\t\ttry {\n\t\t\tlet line = JSON.stringify(logEntry) + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, line, { encoding: 'utf8' });\n\t\t}\n\t\tcatch(err) {\n\t\t\t// If there's an error writing logs, you might want to handle it or queue it\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write log to file:', err);\n\t\t}\n\t}\n\n\tpublic writeLogs(items: LocalLogModel[]): void {\n\t\tif (!items || items.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert each item to a JSON string, add newline\n\t\t\tlet lines = items.map(item => JSON.stringify(item)).join('\\n') + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, lines, { encoding: 'utf8' });\n\t\t}\n\t\tcatch (err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write logs batch:', err);\n\t\t}\n\t}\n\n\t/**\n\t * Reads all logs from disk, then empties the file.\n\t */\n\tpublic offloadLogs(): any[] {\n\t\tlet result = [];\n\n\t\ttry {\n\t\t\tif (!fs.existsSync(this._logFilePath)) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tlet fileData = fs.readFileSync(this._logFilePath, 'utf8');\n\t\t\tif (fileData.trim().length === 0) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tresult = fileData.split('\\n').filter(l => l.trim() !== '');\n\n\t\t\t// Truncate the file so we don't send logs more than once\n\t\t\tfs.writeFileSync(this._logFilePath, '');\n\t\t}\n\t\tcatch(err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to offload logs:', err);\n\t\t}\n\n\t\treturn result;\n\t}\n}"]}
1
+ {"version":3,"sources":["../../src/managers/local-log.manager.ts"],"names":["fs","require","__1","LocalLogManager","ResolveIOServer","getServerConfig","existsSync","mkdirSync","this","_logFilePath","prototype","writeLog","logEntry","line","JSON","stringify","appendFileSync","encoding","err","console","error","Date","writeLogs","items","length","lines","map","item","join","offloadLogs","result","fileData","readFileSync","trim","split","filter","l","writeFileSync","exports"],"mappings":"mGAGA,IAAAA,GAAAC,QAAA,IAAA,EACAC,IAAAD,QAAA,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,kBAAmB,0BAA2BH,CAAG,C,CAG5E,OAAOY,CACR,EACD3B,eAAA,EAAC,EAtEYmC,QAAAnC,gBAAAA","file":"local-log.manager.js","sourcesContent":["/***************\nlocal-logs.manager.ts\n****************/\nimport * as fs from 'fs';\nimport { ResolveIOServer } from '..';\n\nexport type LocalLogType = 'monitor-mongo' \n\t| 'monitor-memory'\n\t| 'monitor-cpu'\n\t| 'log'\n\t| 'log-method-latency'\n\t| 'log-subscription';\n\nexport interface LocalLogModel {\n\ttype: LocalLogType;\n\tdate: Date;\n\tdata: any;\n}\n\nexport class LocalLogManager {\n\tprivate _logFilePath: string;\n\n\tconstructor() {\n\t\tif (\n\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t) {\n\t\t\tif (!fs.existsSync('~/logs')) {\n\t\t\t\tfs.mkdirSync('~/logs');\n\t\t\t}\n\t\t}\n\t\t\n\t\tthis._logFilePath = '~/logs/local-logs.jsonl';\n\t}\n\n\t// Internal method to append a JSON line to the file\n\tpublic writeLog(logEntry: LocalLogModel): void {\n\t\ttry {\n\t\t\tlet line = JSON.stringify(logEntry) + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, line, { encoding: 'utf8' });\n\t\t}\n\t\tcatch(err) {\n\t\t\t// If there's an error writing logs, you might want to handle it or queue it\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write log to file:', err);\n\t\t}\n\t}\n\n\tpublic writeLogs(items: LocalLogModel[]): void {\n\t\tif (!items || items.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert each item to a JSON string, add newline\n\t\t\tlet lines = items.map(item => JSON.stringify(item)).join('\\n') + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, lines, { encoding: 'utf8' });\n\t\t}\n\t\tcatch (err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write logs batch:', err);\n\t\t}\n\t}\n\n\t/**\n\t * Reads all logs from disk, then empties the file.\n\t */\n\tpublic offloadLogs(): any[] {\n\t\tlet result = [];\n\n\t\ttry {\n\t\t\tif (!fs.existsSync(this._logFilePath)) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tlet fileData = fs.readFileSync(this._logFilePath, 'utf8');\n\t\t\tif (fileData.trim().length === 0) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tresult = fileData.split('\\n').filter(l => l.trim() !== '');\n\n\t\t\t// Truncate the file so we don't send logs more than once\n\t\t\tfs.writeFileSync(this._logFilePath, '');\n\t\t}\n\t\tcatch(err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to offload logs:', err);\n\t\t}\n\n\t\treturn result;\n\t}\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "20.5.0",
3
+ "version": "20.5.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",