@resolveio/server-lib 20.11.3 → 20.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/methods/logs.js CHANGED
@@ -50,11 +50,15 @@ function loadLogMethods(methodManager) {
50
50
  function: function (message, data) {
51
51
  var _a, _b, _c;
52
52
  return __awaiter(this, void 0, void 0, function () {
53
- var correlationId, payload;
53
+ var payloadCorrelationId, correlationId, payload;
54
54
  return __generator(this, function (_d) {
55
55
  switch (_d.label) {
56
56
  case 0:
57
- correlationId = (0, error_tracking_1.getCorrelationId)();
57
+ payloadCorrelationId = typeof data === 'object' && data
58
+ ? (typeof data.correlationId === 'string' && data.correlationId)
59
+ || (typeof data.error === 'object' && data.error && typeof data.error.correlationId === 'string' && data.error.correlationId)
60
+ : undefined;
61
+ correlationId = (0, error_tracking_1.getCorrelationId)() || payloadCorrelationId || (0, common_1.objectIdHexString)();
58
62
  payload = {
59
63
  user: this.user,
60
64
  id_user: this.id_user,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/logs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAAkF;AAClF,0FAA8E;AAC9E,gEAAqD;AAErD,gEAA0D;AAC1D,yCAAmD;AACnD,yDAAuD;AACvD,yDAA0D;AAE1D,SAAgB,cAAc,CAAC,aAA4B;IAC1D,aAAa,CAAC,OAAO,CAAC;QACrB,cAAc,EAAE;YACf,QAAQ,EAAE,UAAe,OAAO,EAAE,IAAI;;;;;;;gCAC/B,aAAa,GAAG,IAAA,iCAAgB,GAAE,CAAC;gCACnC,OAAO,GAAG;oCACf,IAAI,EAAE,IAAI,CAAC,IAAI;oCACf,OAAO,EAAE,IAAI,CAAC,OAAO;oCACrB,OAAO,SAAA;oCACP,IAAI,MAAA;oCACJ,aAAa,eAAA;iCACb,CAAC;gCAEF,qBAAM,8BAAa,CAAC,MAAM,CAAC;wCAC1B,SAAS,EAAE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,KAAK,EAAE,SAAS;yCAChB;qCACD,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,uBAAuB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAC,EAAE,IAAI,CAAC,EAAA;;gCAxB/H,YAAY,GAAG,SAwBgH;gCAEnI,sBAAO;wCACN,OAAO,EAAE,SAAS;wCAClB,aAAa,EAAE,aAAa;wCAC5B,eAAe,EAAE,eAAe;wCAChC,YAAY,EAAE,YAAY;qCAC1B,EAAC;;;;aACF;YACD,cAAc,EAAE,IAAI;SACpB;KACD,CAAC,CAAC;AACJ,CAAC;AA5XD,wCA4XC","file":"logs.js","sourcesContent":["import { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { Logs } from '../collections/log.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\nimport { ErrorReporter } from '../util/error-reporter';\nimport { getCorrelationId } from '../util/error-tracking';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tinsertErrorLog: {\n\t\t\tfunction: async function(message, data) {\n\t\t\t\tconst correlationId = getCorrelationId();\n\t\t\t\tconst payload = {\n\t\t\t\t\tuser: this.user,\n\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\tmessage,\n\t\t\t\t\tdata,\n\t\t\t\t\tcorrelationId\n\t\t\t\t};\n\n\t\t\t\tawait ErrorReporter.report({\n\t\t\t\t\tsourceApp: 'method-logs',\n\t\t\t\t\tmessage: 'Error Detected - ' + ResolveIOServer.getClientName(),\n\t\t\t\t\tenvironment: this.serverConfig?.ROOT_URL || ResolveIOServer.getServerConfig()?.ROOT_URL,\n\t\t\t\t\tclientSlug: ResolveIOServer.getClientName(),\n\t\t\t\t\tclientName: ResolveIOServer.getServerConfig()?.CLIENT_NAME,\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t\tcontext: payload,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tcontext: 'insertErrorLog',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t},\n\t\t\t\t\tcorrelationId\n\t\t\t\t});\n\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: JSON.stringify([payload], null, 2),\n\t\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\troute: '',\n\t\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\tpayload: JSON.stringify([payload], null, 2),\n\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\troute: '',\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '',\n\t\t\t\t\t\tcorrelationId\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\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: async function(type, subscription, collection_name, subData) {\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log-subscription',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\t\tsubData: subData\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait LogSubscriptions.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\tsubData: subData,\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com'\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\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: async function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\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\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\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\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet groupId = {};\n\t\t\t\tlet groupSort = {};\n\n\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\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\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\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\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\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\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\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\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\treturn {\n\t\t\t\t\tmethods: latencies,\n\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t};\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"sources":["../../src/methods/logs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAAkF;AAClF,0FAA8E;AAC9E,gEAAqD;AAErD,gEAA0D;AAC1D,yCAAmD;AACnD,yDAAuD;AACvD,yDAA0D;AAE1D,SAAgB,cAAc,CAAC,aAA4B;IACzD,aAAa,CAAC,OAAO,CAAC;QACrB,cAAc,EAAE;YACf,QAAQ,EAAE,UAAe,OAAO,EAAE,IAAI;;;;;;;gCAC/B,oBAAoB,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI;oCAC5D,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ,IA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AE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,uBAAuB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAC,EAAE,IAAI,CAAC,EAAA;;gCAxB/H,eAAe,GAAG,SAwB6G;gCAEhH,qBAAM,8CAAgB,CAAC,SAAS,CAAC;wCACnD;4CACC,MAAM,EAAE;gDACP,IAAI,EAAE;oDACL;wDACC,SAAS,EAAE,EAAC,IAAI,EAAE,UAAU,EAAC;qDAC7B;oDACD;wDACC,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;qDAC3B;iDACD;6CACD;yCACD;wCACD;4CACC,MAAM,EAAE;gDACP,GAAG,EAAE,OAAO;gDACZ,KAAK,EAAE;oDACN,IAAI,EAAE,CAAC;iDACP;6CACD;yCACD;wCACD;4CACC,KAAK,EAAE,SAAS;yCAChB;qCACD,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,uBAAuB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAC,EAAE,IAAI,CAAC,EAAA;;gCAxB/H,YAAY,GAAG,SAwBgH;gCAEnI,sBAAO;wCACN,OAAO,EAAE,SAAS;wCAClB,aAAa,EAAE,aAAa;wCAC5B,eAAe,EAAE,eAAe;wCAChC,YAAY,EAAE,YAAY;qCAC1B,EAAC;;;;aACF;YACD,cAAc,EAAE,IAAI;SACpB;KACD,CAAC,CAAC;AACJ,CAAC;AAhYD,wCAgYC","file":"logs.js","sourcesContent":["import { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { Logs } from '../collections/log.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\nimport { ErrorReporter } from '../util/error-reporter';\nimport { getCorrelationId } from '../util/error-tracking';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\t\tmethodManager.methods({\n\t\t\tinsertErrorLog: {\n\t\t\t\tfunction: async function(message, data) {\n\t\t\t\t\tconst payloadCorrelationId = typeof data === 'object' && data\n\t\t\t\t\t\t? (typeof data.correlationId === 'string' && data.correlationId)\n\t\t\t\t\t\t\t|| (typeof data.error === 'object' && data.error && typeof data.error.correlationId === 'string' && data.error.correlationId)\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst correlationId = getCorrelationId() || payloadCorrelationId || objectIdHexString();\n\t\t\t\t\tconst payload = {\n\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\tid_user: this.id_user,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\tdata,\n\t\t\t\t\tcorrelationId\n\t\t\t\t};\n\n\t\t\t\tawait ErrorReporter.report({\n\t\t\t\t\tsourceApp: 'method-logs',\n\t\t\t\t\tmessage: 'Error Detected - ' + ResolveIOServer.getClientName(),\n\t\t\t\t\tenvironment: this.serverConfig?.ROOT_URL || ResolveIOServer.getServerConfig()?.ROOT_URL,\n\t\t\t\t\tclientSlug: ResolveIOServer.getClientName(),\n\t\t\t\t\tclientName: ResolveIOServer.getServerConfig()?.CLIENT_NAME,\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t\tcontext: payload,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tcontext: 'insertErrorLog',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t},\n\t\t\t\t\tcorrelationId\n\t\t\t\t});\n\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: JSON.stringify([payload], null, 2),\n\t\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\t\troute: '',\n\t\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\ttype: 'error',\n\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\tpayload: JSON.stringify([payload], null, 2),\n\t\t\t\t\t\tmethod: '',\n\t\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\troute: '',\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '',\n\t\t\t\t\t\tcorrelationId\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\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: async function(type, subscription, collection_name, subData) {\n\t\t\t\tif (\n\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t) {\n\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\ttype: 'log-subscription',\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\t\tsubData: subData\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait LogSubscriptions.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\t\tsubData: subData,\n\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\tinstance: 'backend.resolveio.com'\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\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: async function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\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\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\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\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet groupId = {};\n\t\t\t\tlet groupSort = {};\n\n\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tgroupId = {\n\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t},\n\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\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\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\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\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\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\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t$sum: 1\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\t{\n\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t}\n\t\t\t\t], {allowDiskUse: true, readPreference: this.serverConfig['ROOT_URL'] !== 'http://localhost:4200' ? 'secondary' : 'primary'}, true);\n\n\t\t\t\treturn {\n\t\t\t\t\tmethods: latencies,\n\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t};\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "20.11.3",
3
+ "version": "20.11.5",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -1,6 +1,3 @@
1
- type LoggerLike = Pick<typeof console, 'error' | 'warn' | 'info' | 'log'>;
2
- type ResolveIoInsertOverride = (payload: ErrorReportPayload, logger: LoggerLike) => Promise<ErrorReportResult>;
3
- export declare function __setResolveIoInsertOverrideForTesting(fn: ResolveIoInsertOverride | null): void;
4
1
  type FetchLike = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
5
2
  export interface ErrorReportAttachment {
6
3
  name: string;
@@ -49,36 +46,6 @@ export interface ErrorReportResult {
49
46
  status?: number;
50
47
  reason?: string;
51
48
  }
52
- interface ErrorReportPayload {
53
- sourceApp: string;
54
- message: string;
55
- environment?: string;
56
- clientId?: string;
57
- clientSlug?: string;
58
- clientName?: string;
59
- clientRepo?: string;
60
- clientEmail?: string;
61
- severity: string;
62
- stack?: string;
63
- context?: Record<string, any> | string;
64
- metadata?: Record<string, any> | string;
65
- attachments?: ErrorReportAttachment[];
66
- fingerprint?: string;
67
- idempotencyKey?: string;
68
- reportedBy?: string;
69
- reportedAt?: string;
70
- reportedFor?: string;
71
- reportedCount?: number;
72
- reportedSourceHost?: string;
73
- reportedSourceIp?: string;
74
- reportedSourceVersion?: string;
75
- reportedSourcePid?: number;
76
- reportedSourceInstance?: string;
77
- reportedSourceRegion?: string;
78
- reportedSourceCluster?: string;
79
- reportedSourceProcess?: string;
80
- reportedSourceEnv?: Record<string, any>;
81
- }
82
49
  export declare class ErrorReporter {
83
50
  static report(options: ErrorReportOptions): Promise<ErrorReportResult>;
84
51
  }
@@ -63,18 +63,11 @@ var __read = (this && this.__read) || function (o, n) {
63
63
  return ar;
64
64
  };
65
65
  Object.defineProperty(exports, "__esModule", { value: true });
66
- exports.ErrorReporter = exports.__setResolveIoInsertOverrideForTesting = void 0;
66
+ exports.ErrorReporter = void 0;
67
67
  var crypto_1 = require("crypto");
68
- var error_auto_fix_collection_1 = require("../collections/error-auto-fix.collection");
69
68
  var resolveio_server_app_1 = require("../resolveio-server-app");
70
- var common_1 = require("./common");
71
69
  var DEFAULT_ERROR_API_URL = 'https://backend.resolveio.com/api/errors/report';
72
70
  var LOCAL_HOSTNAMES = new Set(['localhost', '127.0.0.1', '0.0.0.0', '::1']);
73
- var resolveIoInsertOverride = null;
74
- function __setResolveIoInsertOverrideForTesting(fn) {
75
- resolveIoInsertOverride = fn;
76
- }
77
- exports.__setResolveIoInsertOverrideForTesting = __setResolveIoInsertOverrideForTesting;
78
71
  var ErrorReporter = /** @class */ (function () {
79
72
  function ErrorReporter() {
80
73
  }
@@ -136,19 +129,15 @@ var ErrorReporter = /** @class */ (function () {
136
129
  logger.error('ErrorReporter payload (suppressed):', payload);
137
130
  return [2 /*return*/, { delivered: false, reason: 'local-environment' }];
138
131
  }
139
- if (!isResolveIOSelfClient(clientName)) return [3 /*break*/, 2];
140
- return [4 /*yield*/, handleResolveIoSelfReport(payload, logger)];
141
- case 1: return [2 /*return*/, _b.sent()];
142
- case 2:
143
132
  transport = options.fetch || globalThis.fetch;
144
133
  if (typeof transport !== 'function') {
145
134
  logger.error('ErrorReporter failed: fetch is not available in this runtime');
146
135
  logger.error('ErrorReporter payload (not sent):', payload);
147
136
  return [2 /*return*/, { delivered: false, reason: 'missing-fetch' }];
148
137
  }
149
- _b.label = 3;
150
- case 3:
151
- _b.trys.push([3, 5, , 6]);
138
+ _b.label = 1;
139
+ case 1:
140
+ _b.trys.push([1, 3, , 4]);
152
141
  return [4 /*yield*/, transport(normalizedApiUrl, {
153
142
  method: 'POST',
154
143
  headers: removeEmptyFields({
@@ -159,19 +148,19 @@ var ErrorReporter = /** @class */ (function () {
159
148
  }),
160
149
  body: JSON.stringify(payload)
161
150
  })];
162
- case 4:
151
+ case 2:
163
152
  response = _b.sent();
164
153
  if (!response.ok) {
165
154
  logger.error('ErrorReporter failed to deliver payload', { status: response.status, statusText: response.statusText });
166
155
  return [2 /*return*/, { delivered: false, status: response.status, reason: 'http-error' }];
167
156
  }
168
157
  return [2 /*return*/, { delivered: true, status: response.status }];
169
- case 5:
158
+ case 3:
170
159
  err_1 = _b.sent();
171
160
  logger.error('ErrorReporter exception while delivering payload', err_1);
172
161
  logger.error('ErrorReporter payload (not sent):', payload);
173
162
  return [2 /*return*/, { delivered: false, reason: 'network-error' }];
174
- case 6: return [2 /*return*/];
163
+ case 4: return [2 /*return*/];
175
164
  }
176
165
  });
177
166
  });
@@ -345,228 +334,6 @@ function mergeMetadata(metadata, correlationId) {
345
334
  }
346
335
  return metadataObj;
347
336
  }
348
- function handleResolveIoSelfReport(payload, logger) {
349
- return __awaiter(this, void 0, void 0, function () {
350
- var doc, upsertResult, err_2;
351
- return __generator(this, function (_a) {
352
- switch (_a.label) {
353
- case 0:
354
- if (!resolveIoInsertOverride) return [3 /*break*/, 2];
355
- return [4 /*yield*/, resolveIoInsertOverride(payload, logger)];
356
- case 1: return [2 /*return*/, _a.sent()];
357
- case 2:
358
- if (!error_auto_fix_collection_1.ErrorAutoFixLogs) {
359
- logger.warn('ErrorReporter ResolveIO insert skipped: error-autofix collection unavailable');
360
- logger.error('ErrorReporter payload (not inserted):', payload);
361
- return [2 /*return*/, { delivered: false, reason: 'resolveio-no-collection' }];
362
- }
363
- _a.label = 3;
364
- case 3:
365
- _a.trys.push([3, 5, , 6]);
366
- doc = buildResolveIoAutoFixDoc(payload);
367
- return [4 /*yield*/, upsertResolveIoAutoFixLog(error_auto_fix_collection_1.ErrorAutoFixLogs, doc)];
368
- case 4:
369
- upsertResult = _a.sent();
370
- return [2 /*return*/, {
371
- delivered: true,
372
- reason: upsertResult.duplicate ? 'resolveio-duplicate' : 'resolveio-insert'
373
- }];
374
- case 5:
375
- err_2 = _a.sent();
376
- logger.error('ErrorReporter failed to insert resolveio auto-fix log', err_2);
377
- logger.error('ErrorReporter payload (not inserted):', payload);
378
- return [2 /*return*/, { delivered: false, reason: 'resolveio-insert-failed' }];
379
- case 6: return [2 /*return*/];
380
- }
381
- });
382
- });
383
- }
384
- function buildResolveIoAutoFixDoc(payload) {
385
- var timestamp = coerceReportedDate(payload.reportedAt);
386
- var safeMessage = (payload.message || '').toString().trim() || 'Unknown error';
387
- var subjectBase = "[AppError] ".concat(payload.sourceApp || 'application').concat(payload.environment ? " (".concat(payload.environment, ")") : '');
388
- var subject = "".concat(subjectBase, " - ").concat(safeMessage.slice(0, 120));
389
- var bodyLines = [
390
- "Source App:\t".concat(payload.sourceApp || 'n/a'),
391
- "Environment:\t".concat(payload.environment || 'n/a'),
392
- "Severity:\t".concat(payload.severity || 'error'),
393
- "Client Hint:\t".concat(payload.clientName || payload.clientSlug || payload.clientRepo || payload.clientId || 'n/a'),
394
- "Reported By:\t".concat(payload.reportedBy || payload.clientEmail || 'n/a'),
395
- "Reported At:\t".concat(timestamp.toISOString()),
396
- "Message:\t".concat(safeMessage)
397
- ];
398
- if (payload.stack) {
399
- bodyLines.push('', 'Stack Trace:', payload.stack.toString());
400
- }
401
- if (isPlainObject(payload.context) && Object.keys(payload.context).length) {
402
- bodyLines.push('', 'Context JSON:', JSON.stringify(payload.context, null, 2));
403
- }
404
- if (isPlainObject(payload.metadata) && Object.keys(payload.metadata).length) {
405
- bodyLines.push('', 'Metadata JSON:', JSON.stringify(payload.metadata, null, 2));
406
- }
407
- var normalizedAttachments = normalizeAttachments(payload.attachments);
408
- if (Array.isArray(normalizedAttachments) && normalizedAttachments.length) {
409
- bodyLines.push('', 'Attachments:');
410
- normalizedAttachments.forEach(function (att) {
411
- var segments = [];
412
- if (att.name) {
413
- segments.push(att.name);
414
- }
415
- if (att.contentType) {
416
- segments.push(att.contentType);
417
- }
418
- if (typeof att.size === 'number') {
419
- segments.push("".concat(att.size, "b"));
420
- }
421
- var summary = segments.length ? segments.join(' | ') : 'attachment';
422
- bodyLines.push("- ".concat(summary).concat(att.url ? " -> ".concat(att.url) : ''));
423
- });
424
- }
425
- if (payload.fingerprint) {
426
- bodyLines.push('', "Fingerprint:\t".concat(payload.fingerprint));
427
- }
428
- if (payload.idempotencyKey) {
429
- bodyLines.push("Idempotency Key:\t".concat(payload.idempotencyKey));
430
- }
431
- var body = bodyLines.join('\n');
432
- var rawHash = (payload.idempotencyKey || '').toString().trim() || generateResolveIoRawHash(subject, body);
433
- var issueHash = (payload.fingerprint || '').toString().trim() || generateResolveIoIssueHash(subject, body);
434
- var fromEmail = payload.reportedBy || payload.clientEmail || '';
435
- var reportMetadata = isPlainObject(payload.metadata) ? payload.metadata : undefined;
436
- var reportContext = isPlainObject(payload.context) ? payload.context : undefined;
437
- return cleanUndefined({
438
- _id: (0, common_1.objectIdHexString)(),
439
- email_hash: rawHash,
440
- issue_hash: issueHash,
441
- subject: subject,
442
- message_id: payload.idempotencyKey ? payload.idempotencyKey.toString() : undefined,
443
- body: body,
444
- status: 'pending',
445
- ignored: false,
446
- attempt_count: 0,
447
- duplicate_count: 0,
448
- first_seen_at: timestamp,
449
- from_email: fromEmail,
450
- id_client: payload.clientId,
451
- client_name: payload.clientName || payload.clientSlug || undefined,
452
- codex_environment: payload.clientRepo || payload.clientSlug || undefined,
453
- source_app: payload.sourceApp,
454
- source_environment: payload.environment,
455
- severity: payload.severity,
456
- reported_by: fromEmail,
457
- last_reported_at: timestamp,
458
- report_metadata: reportMetadata,
459
- report_context: reportContext,
460
- attachments: normalizedAttachments,
461
- createdAt: timestamp,
462
- updatedAt: timestamp
463
- });
464
- }
465
- function upsertResolveIoAutoFixLog(collection, doc) {
466
- return __awaiter(this, void 0, void 0, function () {
467
- var timestamp, existing, updateSet;
468
- return __generator(this, function (_a) {
469
- switch (_a.label) {
470
- case 0:
471
- timestamp = doc.first_seen_at || new Date();
472
- existing = null;
473
- if (!doc.issue_hash) return [3 /*break*/, 2];
474
- return [4 /*yield*/, collection.findOne({ issue_hash: doc.issue_hash })];
475
- case 1:
476
- existing = _a.sent();
477
- _a.label = 2;
478
- case 2:
479
- if (!(!existing && doc.email_hash)) return [3 /*break*/, 4];
480
- return [4 /*yield*/, collection.findOne({ email_hash: doc.email_hash })];
481
- case 3:
482
- existing = _a.sent();
483
- _a.label = 4;
484
- case 4:
485
- if (!existing) return [3 /*break*/, 6];
486
- updateSet = cleanUndefined({
487
- last_duplicate_at: timestamp,
488
- last_reported_at: timestamp,
489
- report_metadata: doc.report_metadata,
490
- report_context: doc.report_context,
491
- attachments: doc.attachments,
492
- severity: doc.severity,
493
- source_app: doc.source_app,
494
- source_environment: doc.source_environment,
495
- reported_by: doc.reported_by,
496
- updatedAt: new Date()
497
- });
498
- return [4 /*yield*/, collection.updateOne({ _id: existing._id }, {
499
- $inc: { duplicate_count: 1 },
500
- $set: updateSet
501
- })];
502
- case 5:
503
- _a.sent();
504
- return [2 /*return*/, { duplicate: true, doc: existing }];
505
- case 6: return [4 /*yield*/, collection.insertOne(doc)];
506
- case 7:
507
- _a.sent();
508
- return [2 /*return*/, { duplicate: false, doc: doc }];
509
- }
510
- });
511
- });
512
- }
513
- function generateResolveIoRawHash(subject, body) {
514
- return (0, crypto_1.createHash)('sha256').update("".concat(subject || '', "\n").concat(body || ''), 'utf8').digest('hex');
515
- }
516
- function generateResolveIoIssueHash(subject, body) {
517
- var normalizedSubject = normalizeTextForAutoFixHash(subject);
518
- var normalizedBody = normalizeBodyForAutoFixHash(body);
519
- return (0, crypto_1.createHash)('sha256').update("".concat(normalizedSubject, "\n").concat(normalizedBody), 'utf8').digest('hex');
520
- }
521
- function normalizeTextForAutoFixHash(value) {
522
- if (!value) {
523
- return '';
524
- }
525
- var normalized = value
526
- .replace(/\r/g, '\n')
527
- .toLowerCase()
528
- .replace(/0x[0-9a-f]+/gi, '0x#')
529
- .replace(/\b[0-9a-f]{7,64}\b/gi, '#')
530
- .replace(/\b[0-9]{4}[-/][0-9]{2}[-/][0-9]{2}(?:[ t][0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?)?\b/g, '#datetime#')
531
- .replace(/\b[0-9]{2}:[0-9]{2}:[0-9]{2}\b/g, '#time#')
532
- .replace(/[0-9]+/g, '#')
533
- .replace(/[^\S\n]+/g, ' ')
534
- .split('\n')
535
- .map(function (line) { return line.trim(); })
536
- .filter(Boolean)
537
- .slice(0, 60)
538
- .join('\n');
539
- return normalized.length > 4000 ? normalized.slice(0, 4000) : normalized;
540
- }
541
- function normalizeBodyForAutoFixHash(body) {
542
- if (!body) {
543
- return '';
544
- }
545
- var withoutStackNoise = body
546
- .replace(/=+\s*stack trace\s*=+/gi, 'stack trace')
547
- .replace(/-{3,}/g, '-')
548
- .replace(/\[[^\]]*request id[^\]]*\]/gi, '[request id]')
549
- .replace(/guid:[^\s]+/gi, 'guid:#')
550
- .replace(/request id:[^\s]+/gi, 'request id:#')
551
- .replace(/correlation id:[^\s]+/gi, 'correlation id:#');
552
- return normalizeTextForAutoFixHash(withoutStackNoise);
553
- }
554
- function cleanUndefined(obj) {
555
- var cleaned = {};
556
- Object.keys(obj || {}).forEach(function (key) {
557
- if (typeof obj[key] !== 'undefined') {
558
- cleaned[key] = obj[key];
559
- }
560
- });
561
- return cleaned;
562
- }
563
- function coerceReportedDate(value) {
564
- if (!value) {
565
- return new Date();
566
- }
567
- var coerced = new Date(value);
568
- return Number.isNaN(coerced.getTime()) ? new Date() : coerced;
569
- }
570
337
  function shouldSuppressForLocalEnvironment(config, apiUrl) {
571
338
  if (isLocalUrl(config === null || config === void 0 ? void 0 : config.ROOT_URL) || isLocalUrl(config === null || config === void 0 ? void 0 : config.SERVER_URL) || process.env.NODE_ENV === 'development') {
572
339
  return true;
@@ -585,14 +352,5 @@ function isLocalUrl(url) {
585
352
  return /localhost|127\.0\.0\.1|0\.0\.0\.0|::1/.test(url);
586
353
  }
587
354
  }
588
- function isResolveIOSelfClient(clientName) {
589
- if (!clientName) {
590
- return false;
591
- }
592
- return clientName.toLowerCase() === 'resolveio';
593
- }
594
- function isPlainObject(value) {
595
- return !!value && typeof value === 'object' && !Array.isArray(value);
596
- }
597
355
 
598
356
  //# sourceMappingURL=error-reporter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/util/error-reporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAoC;AACpC,sFAA4E;AAG5E,gEAA0D;AAC1D,mCAA6C;AAE7C,IAAM,qBAAqB,GAAG,iDAAiD,CAAC;AAChF,IAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;AAK9E,IAAI,uBAAuB,GAAmC,IAAI,CAAC;AAEnE,SAAgB,sCAAsC,CAAC,EAAkC;IACxF,uBAAuB,GAAG,EAAE,CAAC;AAC9B,CAAC;AAFD,wFAEC;AAsFD;IAAA;IA2FA,CAAC;IA1FoB,oBAAM,GAA1B,UAA2B,OAA2B;;;;;;;wBAC/C,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC;wBACnC,MAAM,GAAG,eAAe,EAAE,CAAC;wBAC3B,gBAAgB,GAAG,OAAO,CAAC,MAAM,IAAI,qBAAqB,CAAC;wBAC3D,UAAU,GAAG,OAAO,CAAC,UAAU,KAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,CAAA,KAAI,MAAA,sCAAe,CAAC,aAAa,sFAAI,CAAA,IAAI,WAA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;AAED,SAAS,aAAa,CAAC,KAAU;IAChC,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC","file":"error-reporter.js","sourcesContent":["import { createHash } from 'crypto';\nimport { ErrorAutoFixLogs } from '../collections/error-auto-fix.collection';\nimport { MongoManagerCollection } from '../managers/mongo.manager';\nimport { ErrorAutoFixLogModel } from '../models/error-auto-fix-log.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from './common';\n\nconst DEFAULT_ERROR_API_URL = 'https://backend.resolveio.com/api/errors/report';\nconst LOCAL_HOSTNAMES = new Set(['localhost', '127.0.0.1', '0.0.0.0', '::1']);\n\ntype LoggerLike = Pick<typeof console, 'error' | 'warn' | 'info' | 'log'>;\n// eslint-disable-next-line no-unused-vars\ntype ResolveIoInsertOverride = (payload: ErrorReportPayload, logger: LoggerLike) => Promise<ErrorReportResult>;\nlet resolveIoInsertOverride: ResolveIoInsertOverride | null = null;\n\nexport function __setResolveIoInsertOverrideForTesting(fn: ResolveIoInsertOverride | null) {\n\tresolveIoInsertOverride = fn;\n}\n\n// eslint-disable-next-line no-unused-vars\ntype FetchLike = (input: RequestInfo, init?: RequestInit) => Promise<Response>;\n\nexport interface ErrorReportAttachment {\n\tname: string;\n\turl?: string;\n\tcontentType?: string;\n\tsize?: number;\n}\n\nexport interface ErrorReportOptions {\n\tsourceApp?: string;\n\tmessage?: string;\n\tsubject?: string;\n\tenvironment?: string;\n\tclientId?: string;\n\tclientSlug?: string;\n\tclientName?: string;\n\tclientRepo?: string;\n\tclientEmail?: string;\n\tseverity?: string;\n\tstack?: string | Error;\n\terror?: unknown;\n\tcontext?: Record<string, any> | string | null;\n\tmetadata?: Record<string, any> | string | null;\n\tattachments?: ErrorReportAttachment[];\n\tfingerprint?: string;\n\tidempotencyKey?: string;\n\treportedBy?: string;\n\treportedAt?: string | Date;\n\treportedFor?: string;\n\treportedCount?: number;\n\treportedSourceHost?: string;\n\treportedSourceIp?: string;\n\treportedSourceVersion?: string;\n\treportedSourcePid?: number;\n\treportedSourceInstance?: string;\n\treportedSourceRegion?: string;\n\treportedSourceCluster?: string;\n\treportedSourceProcess?: string;\n\treportedSourceEnv?: Record<string, any>;\n\tcorrelationId?: string;\n\tapiUrl?: string;\n\tfetch?: FetchLike;\n\tlogger?: Pick<typeof console, 'error' | 'warn' | 'info' | 'log'>;\n}\n\nexport interface ErrorReportResult {\n\tdelivered: boolean;\n\tstatus?: number;\n\treason?: string;\n}\n\ninterface ErrorReportPayload {\n\tsourceApp: string;\n\tmessage: string;\n\tenvironment?: string;\n\tclientId?: string;\n\tclientSlug?: string;\n\tclientName?: string;\n\tclientRepo?: string;\n\tclientEmail?: string;\n\tseverity: string;\n\tstack?: string;\n\tcontext?: Record<string, any> | string;\n\tmetadata?: Record<string, any> | string;\n\tattachments?: ErrorReportAttachment[];\n\tfingerprint?: string;\n\tidempotencyKey?: string;\n\treportedBy?: string;\n\treportedAt?: string;\n\treportedFor?: string;\n\treportedCount?: number;\n\treportedSourceHost?: string;\n\treportedSourceIp?: string;\n\treportedSourceVersion?: string;\n\treportedSourcePid?: number;\n\treportedSourceInstance?: string;\n\treportedSourceRegion?: string;\n\treportedSourceCluster?: string;\n\treportedSourceProcess?: string;\n\treportedSourceEnv?: Record<string, any>;\n}\n\nexport class ErrorReporter {\n\tpublic static async report(options: ErrorReportOptions): Promise<ErrorReportResult> {\n\t\tconst logger = options.logger || console;\n\t\tconst config = getServerConfig();\n\t\tconst normalizedApiUrl = options.apiUrl || DEFAULT_ERROR_API_URL;\n\t\tconst clientName = options.clientName || config?.CLIENT_NAME || ResolveIOServer.getClientName?.() || 'resolveio';\n\t\tconst sourceApp = options.sourceApp || clientName || 'resolveio-server-lib';\n\t\tconst environment = options.environment || process.env.RESOLVEIO_ENV || config?.RESOLVEIO_ENV || config?.ENVIRONMENT || config?.ROOT_URL || process.env.NODE_ENV || 'unknown';\n\t\tconst message = options.message || options.subject || 'ResolveIO Error Detected';\n\t\tconst severity = options.severity || 'error';\n\t\tconst stack = normalizeStack(options.stack || options.error);\n\t\tconst context = normalizeStructured(options.context, options.correlationId);\n\t\tconst metadata = normalizeStructured(mergeMetadata(options.metadata, options.correlationId));\n\t\tconst attachments = Array.isArray(options.attachments) ? normalizeAttachments(options.attachments) : undefined;\n\t\tconst fingerprint = options.fingerprint || computeFingerprint(sourceApp, environment, message, stack);\n\t\tconst idempotencyKey = options.idempotencyKey;\n\t\tconst reportedAt = normalizeReportedAt(options.reportedAt);\n\t\tconst normalizedReportedSourceEnv = normalizeStructured(options.reportedSourceEnv);\n\t\tconst payload: ErrorReportPayload = removeEmptyFields({\n\t\t\tsourceApp,\n\t\t\tmessage,\n\t\t\tenvironment,\n\t\t\tclientId: options.clientId,\n\t\t\tclientSlug: options.clientSlug,\n\t\t\tclientName,\n\t\t\tclientRepo: options.clientRepo,\n\t\t\tclientEmail: options.clientEmail,\n\t\t\tseverity,\n\t\t\tstack,\n\t\t\tcontext,\n\t\t\tmetadata,\n\t\t\tattachments,\n\t\t\tfingerprint,\n\t\t\tidempotencyKey,\n\t\t\treportedBy: options.reportedBy,\n\t\t\treportedAt,\n\t\t\treportedFor: options.reportedFor,\n\t\t\treportedCount: options.reportedCount,\n\t\t\treportedSourceHost: options.reportedSourceHost,\n\t\t\treportedSourceIp: options.reportedSourceIp,\n\t\t\treportedSourceVersion: options.reportedSourceVersion,\n\t\t\treportedSourcePid: options.reportedSourcePid,\n\t\t\treportedSourceInstance: options.reportedSourceInstance,\n\t\t\treportedSourceRegion: options.reportedSourceRegion,\n\t\t\treportedSourceCluster: options.reportedSourceCluster,\n\t\t\treportedSourceProcess: options.reportedSourceProcess,\n\t\t\treportedSourceEnv: typeof normalizedReportedSourceEnv === 'string' ? undefined : normalizedReportedSourceEnv as Record<string, any>\n\t\t});\n\n\t\tif (shouldSuppressForLocalEnvironment(config, normalizedApiUrl)) {\n\t\t\tlogger.info('ErrorReporter suppressed: local environment detected');\n\t\t\tlogger.error('ErrorReporter payload (suppressed):', payload);\n\t\t\treturn { delivered: false, reason: 'local-environment' };\n\t\t}\n\n\t\tif (isResolveIOSelfClient(clientName)) {\n\t\t\treturn await handleResolveIoSelfReport(payload, logger);\n\t\t}\n\n\t\tconst transport = options.fetch || globalThis.fetch;\n\t\tif (typeof transport !== 'function') {\n\t\t\tlogger.error('ErrorReporter failed: fetch is not available in this runtime');\n\t\t\tlogger.error('ErrorReporter payload (not sent):', payload);\n\t\t\treturn { delivered: false, reason: 'missing-fetch' };\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await transport(normalizedApiUrl, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: removeEmptyFields({\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'X-ResolveIO-Error-Key': clientName,\n\t\t\t\t\t'X-ResolveIO-Error-Hash': fingerprint,\n\t\t\t\t\t'X-ResolveIO-Idempotency-Key': idempotencyKey\n\t\t\t\t}),\n\t\t\t\tbody: JSON.stringify(payload)\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tlogger.error('ErrorReporter failed to deliver payload', { status: response.status, statusText: response.statusText });\n\t\t\t\treturn { delivered: false, status: response.status, reason: 'http-error' };\n\t\t\t}\n\n\t\t\treturn { delivered: true, status: response.status };\n\t\t}\n\t\tcatch (err) {\n\t\t\tlogger.error('ErrorReporter exception while delivering payload', err);\n\t\t\tlogger.error('ErrorReporter payload (not sent):', payload);\n\t\t\treturn { delivered: false, reason: 'network-error' };\n\t\t}\n\t}\n}\n\nfunction getServerConfig(): Record<string, any> | null {\n\ttry {\n\t\treturn ResolveIOServer.getServerConfig?.() || null;\n\t}\n\tcatch (err) {\n\t\tconsole.error('Failed to read ResolveIO server config', err);\n\t\treturn null;\n\t}\n}\n\nfunction normalizeStack(stack?: string | Error | unknown): string | undefined {\n\tif (!stack) {\n\t\treturn undefined;\n\t}\n\n\tif (typeof stack === 'string') {\n\t\treturn stack;\n\t}\n\n\tif (stack instanceof Error) {\n\t\treturn stack.stack || stack.message;\n\t}\n\n\tif (typeof stack === 'object' && stack !== null && typeof (stack as Record<string, any>).stack === 'string') {\n\t\treturn (stack as Record<string, any>).stack;\n\t}\n\n\tif (typeof stack === 'object' && stack !== null && typeof (stack as Record<string, any>).message === 'string') {\n\t\treturn (stack as Record<string, any>).message;\n\t}\n\n\treturn JSON.stringify(stack);\n}\n\nfunction normalizeStructured(value: any, correlationId?: string): Record<string, any> | string | undefined {\n\tif (value === null || value === undefined) {\n\t\treturn undefined;\n\t}\n\n\tif (typeof value === 'string') {\n\t\treturn value;\n\t}\n\n\tconst serialized = serializeValue(value);\n\tif (correlationId && typeof serialized === 'object' && serialized !== null && !serialized.correlationId) {\n\t\tserialized.correlationId = correlationId;\n\t}\n\treturn serialized;\n}\n\nfunction serializeValue(value: any, seen: WeakSet<object> = new WeakSet()): any {\n\tif (value === null || value === undefined) {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'bigint') {\n\t\treturn value.toString();\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn value.toISOString();\n\t}\n\n\tif (value instanceof Error) {\n\t\tconst base = {\n\t\t\tname: value.name,\n\t\t\tmessage: value.message,\n\t\t\tstack: value.stack\n\t\t};\n\t\treturn Object.assign({}, base, serializeValue(Object.assign({}, value), seen));\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tif (seen.has(value)) {\n\t\t\treturn '[Circular]';\n\t\t}\n\t\tseen.add(value);\n\t\tconst arr = value.map(item => serializeValue(item, seen));\n\t\tseen.delete(value);\n\t\treturn arr;\n\t}\n\n\tif (typeof value === 'object') {\n\t\tif (seen.has(value)) {\n\t\t\treturn '[Circular]';\n\t\t}\n\t\tseen.add(value);\n\t\tconst obj: Record<string, any> = {};\n\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\tobj[key] = serializeValue(val, seen);\n\t\t}\n\t\tseen.delete(value);\n\t\treturn obj;\n\t}\n\n\treturn String(value);\n}\n\nfunction normalizeAttachments(attachments: ErrorReportAttachment[]): ErrorReportAttachment[] {\n\treturn attachments\n\t\t.filter(att => !!att && typeof att === 'object')\n\t\t.map(att => removeEmptyFields({\n\t\t\tname: att.name,\n\t\t\turl: att.url,\n\t\t\tcontentType: att.contentType,\n\t\t\tsize: typeof att.size === 'number' ? att.size : undefined\n\t\t}))\n\t\t.filter(att => !!att.name);\n}\n\nfunction normalizeReportedAt(value?: string | Date): string | undefined {\n\tif (!value) {\n\t\treturn new Date().toISOString();\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn value.toISOString();\n\t}\n\n\tconst date = new Date(value);\n\tif (!isNaN(date.getTime())) {\n\t\treturn date.toISOString();\n\t}\n\n\treturn new Date().toISOString();\n}\n\nfunction computeFingerprint(sourceApp: string, environment: string | undefined, message: string, stack?: string): string | undefined {\n\tconst signature = `${sourceApp || ''}:${environment || ''}:${message || ''}:${stack ? stack.split('\\n').slice(0, 5).join('|') : ''}`;\n\treturn createHash('sha256').update(signature).digest('hex');\n}\n\nfunction removeEmptyFields<T extends Record<string, any>>(obj: T): T {\n\tconst cleaned: Record<string, any> = {};\n\tfor (const [key, value] of Object.entries(obj || {})) {\n\t\tif (value === undefined || value === null || value === '') {\n\t\t\tcontinue;\n\t\t}\n\t\tcleaned[key] = value;\n\t}\n\treturn cleaned as T;\n}\n\nfunction mergeMetadata(metadata: Record<string, any> | string | null | undefined, correlationId?: string) {\n\tif (!metadata && !correlationId) {\n\t\treturn undefined;\n\t}\n\n\tconst base = metadata ? normalizeStructured(metadata) : undefined;\n\tif (!correlationId) {\n\t\treturn base;\n\t}\n\n\tif (typeof base === 'string') {\n\t\treturn {\n\t\t\tcorrelationId,\n\t\t\tmessage: base\n\t\t};\n\t}\n\n\tconst metadataObj = (base || {}) as Record<string, any>;\n\tif (!metadataObj.correlationId) {\n\t\tmetadataObj.correlationId = correlationId;\n\t}\n\treturn metadataObj;\n}\n\nasync function handleResolveIoSelfReport(payload: ErrorReportPayload, logger: LoggerLike): Promise<ErrorReportResult> {\n\tif (resolveIoInsertOverride) {\n\t\treturn await resolveIoInsertOverride(payload, logger);\n\t}\n\n\tif (!ErrorAutoFixLogs) {\n\t\tlogger.warn('ErrorReporter ResolveIO insert skipped: error-autofix collection unavailable');\n\t\tlogger.error('ErrorReporter payload (not inserted):', payload);\n\t\treturn { delivered: false, reason: 'resolveio-no-collection' };\n\t}\n\n\ttry {\n\t\tconst doc = buildResolveIoAutoFixDoc(payload);\n\t\tconst upsertResult = await upsertResolveIoAutoFixLog(ErrorAutoFixLogs, doc);\n\t\treturn {\n\t\t\tdelivered: true,\n\t\t\treason: upsertResult.duplicate ? 'resolveio-duplicate' : 'resolveio-insert'\n\t\t};\n\t}\n\tcatch (err) {\n\t\tlogger.error('ErrorReporter failed to insert resolveio auto-fix log', err);\n\t\tlogger.error('ErrorReporter payload (not inserted):', payload);\n\t\treturn { delivered: false, reason: 'resolveio-insert-failed' };\n\t}\n}\n\nfunction buildResolveIoAutoFixDoc(payload: ErrorReportPayload): ErrorAutoFixLogModel {\n\tconst timestamp = coerceReportedDate(payload.reportedAt);\n\tconst safeMessage = (payload.message || '').toString().trim() || 'Unknown error';\n\tconst subjectBase = `[AppError] ${payload.sourceApp || 'application'}${payload.environment ? ` (${payload.environment})` : ''}`;\n\tconst subject = `${subjectBase} - ${safeMessage.slice(0, 120)}`;\n\tconst bodyLines: string[] = [\n\t\t`Source App:\\t${payload.sourceApp || 'n/a'}`,\n\t\t`Environment:\\t${payload.environment || 'n/a'}`,\n\t\t`Severity:\\t${payload.severity || 'error'}`,\n\t\t`Client Hint:\\t${payload.clientName || payload.clientSlug || payload.clientRepo || payload.clientId || 'n/a'}`,\n\t\t`Reported By:\\t${payload.reportedBy || payload.clientEmail || 'n/a'}`,\n\t\t`Reported At:\\t${timestamp.toISOString()}`,\n\t\t`Message:\\t${safeMessage}`\n\t];\n\n\tif (payload.stack) {\n\t\tbodyLines.push('', 'Stack Trace:', payload.stack.toString());\n\t}\n\n\tif (isPlainObject(payload.context) && Object.keys(payload.context).length) {\n\t\tbodyLines.push('', 'Context JSON:', JSON.stringify(payload.context, null, 2));\n\t}\n\n\tif (isPlainObject(payload.metadata) && Object.keys(payload.metadata).length) {\n\t\tbodyLines.push('', 'Metadata JSON:', JSON.stringify(payload.metadata, null, 2));\n\t}\n\n\tconst normalizedAttachments = normalizeAttachments(payload.attachments);\n\tif (Array.isArray(normalizedAttachments) && normalizedAttachments.length) {\n\t\tbodyLines.push('', 'Attachments:');\n\t\tnormalizedAttachments.forEach(att => {\n\t\t\tconst segments: string[] = [];\n\t\t\tif (att.name) {\n\t\t\t\tsegments.push(att.name);\n\t\t\t}\n\t\t\tif (att.contentType) {\n\t\t\t\tsegments.push(att.contentType);\n\t\t\t}\n\t\t\tif (typeof att.size === 'number') {\n\t\t\t\tsegments.push(`${att.size}b`);\n\t\t\t}\n\t\t\tconst summary = segments.length ? segments.join(' | ') : 'attachment';\n\t\t\tbodyLines.push(`- ${summary}${att.url ? ` -> ${att.url}` : ''}`);\n\t\t});\n\t}\n\n\tif (payload.fingerprint) {\n\t\tbodyLines.push('', `Fingerprint:\\t${payload.fingerprint}`);\n\t}\n\n\tif (payload.idempotencyKey) {\n\t\tbodyLines.push(`Idempotency Key:\\t${payload.idempotencyKey}`);\n\t}\n\n\tconst body = bodyLines.join('\\n');\n\tconst rawHash = (payload.idempotencyKey || '').toString().trim() || generateResolveIoRawHash(subject, body);\n\tconst issueHash = (payload.fingerprint || '').toString().trim() || generateResolveIoIssueHash(subject, body);\n\tconst fromEmail = payload.reportedBy || payload.clientEmail || '';\n\tconst reportMetadata = isPlainObject(payload.metadata) ? payload.metadata : undefined;\n\tconst reportContext = isPlainObject(payload.context) ? payload.context : undefined;\n\n\treturn cleanUndefined<ErrorAutoFixLogModel>({\n\t\t_id: objectIdHexString(),\n\t\temail_hash: rawHash,\n\t\tissue_hash: issueHash,\n\t\tsubject,\n\t\tmessage_id: payload.idempotencyKey ? payload.idempotencyKey.toString() : undefined,\n\t\tbody,\n\t\tstatus: 'pending',\n\t\tignored: false,\n\t\tattempt_count: 0,\n\t\tduplicate_count: 0,\n\t\tfirst_seen_at: timestamp,\n\t\tfrom_email: fromEmail,\n\t\tid_client: payload.clientId,\n\t\tclient_name: payload.clientName || payload.clientSlug || undefined,\n\t\tcodex_environment: payload.clientRepo || payload.clientSlug || undefined,\n\t\tsource_app: payload.sourceApp,\n\t\tsource_environment: payload.environment,\n\t\tseverity: payload.severity,\n\t\treported_by: fromEmail,\n\t\tlast_reported_at: timestamp,\n\t\treport_metadata: reportMetadata,\n\t\treport_context: reportContext,\n\t\tattachments: normalizedAttachments,\n\t\tcreatedAt: timestamp,\n\t\tupdatedAt: timestamp\n\t});\n}\n\nasync function upsertResolveIoAutoFixLog(collection: MongoManagerCollection<ErrorAutoFixLogModel>, doc: ErrorAutoFixLogModel): Promise<{ duplicate: boolean, doc: ErrorAutoFixLogModel }> {\n\tconst timestamp = doc.first_seen_at || new Date();\n\tlet existing: ErrorAutoFixLogModel = null;\n\n\tif (doc.issue_hash) {\n\t\texisting = await collection.findOne({issue_hash: doc.issue_hash});\n\t}\n\n\tif (!existing && doc.email_hash) {\n\t\texisting = await collection.findOne({email_hash: doc.email_hash});\n\t}\n\n\tif (existing) {\n\t\tconst updateSet = cleanUndefined<Partial<ErrorAutoFixLogModel>>({\n\t\t\tlast_duplicate_at: timestamp,\n\t\t\tlast_reported_at: timestamp,\n\t\t\treport_metadata: doc.report_metadata,\n\t\t\treport_context: doc.report_context,\n\t\t\tattachments: doc.attachments,\n\t\t\tseverity: doc.severity,\n\t\t\tsource_app: doc.source_app,\n\t\t\tsource_environment: doc.source_environment,\n\t\t\treported_by: doc.reported_by,\n\t\t\tupdatedAt: new Date()\n\t\t});\n\n\t\tawait collection.updateOne({_id: existing._id}, {\n\t\t\t$inc: { duplicate_count: 1 },\n\t\t\t$set: updateSet\n\t\t});\n\n\t\treturn { duplicate: true, doc: existing };\n\t}\n\n\tawait collection.insertOne(doc as any);\n\treturn { duplicate: false, doc };\n}\n\nfunction generateResolveIoRawHash(subject: string, body: string): string {\n\treturn createHash('sha256').update(`${subject || ''}\\n${body || ''}`, 'utf8').digest('hex');\n}\n\nfunction generateResolveIoIssueHash(subject: string, body: string): string {\n\tconst normalizedSubject = normalizeTextForAutoFixHash(subject);\n\tconst normalizedBody = normalizeBodyForAutoFixHash(body);\n\treturn createHash('sha256').update(`${normalizedSubject}\\n${normalizedBody}`, 'utf8').digest('hex');\n}\n\nfunction normalizeTextForAutoFixHash(value: string): string {\n\tif (!value) {\n\t\treturn '';\n\t}\n\n\tconst normalized = value\n\t\t.replace(/\\r/g, '\\n')\n\t\t.toLowerCase()\n\t\t.replace(/0x[0-9a-f]+/gi, '0x#')\n\t\t.replace(/\\b[0-9a-f]{7,64}\\b/gi, '#')\n\t\t.replace(/\\b[0-9]{4}[-/][0-9]{2}[-/][0-9]{2}(?:[ t][0-9]{2}:[0-9]{2}:[0-9]{2}(?:\\.[0-9]{1,6})?)?\\b/g, '#datetime#')\n\t\t.replace(/\\b[0-9]{2}:[0-9]{2}:[0-9]{2}\\b/g, '#time#')\n\t\t.replace(/[0-9]+/g, '#')\n\t\t.replace(/[^\\S\\n]+/g, ' ')\n\t\t.split('\\n')\n\t\t.map(line => line.trim())\n\t\t.filter(Boolean)\n\t\t.slice(0, 60)\n\t\t.join('\\n');\n\n\treturn normalized.length > 4000 ? normalized.slice(0, 4000) : normalized;\n}\n\nfunction normalizeBodyForAutoFixHash(body: string): string {\n\tif (!body) {\n\t\treturn '';\n\t}\n\n\tconst withoutStackNoise = body\n\t\t.replace(/=+\\s*stack trace\\s*=+/gi, 'stack trace')\n\t\t.replace(/-{3,}/g, '-')\n\t\t.replace(/\\[[^\\]]*request id[^\\]]*\\]/gi, '[request id]')\n\t\t.replace(/guid:[^\\s]+/gi, 'guid:#')\n\t\t.replace(/request id:[^\\s]+/gi, 'request id:#')\n\t\t.replace(/correlation id:[^\\s]+/gi, 'correlation id:#');\n\n\treturn normalizeTextForAutoFixHash(withoutStackNoise);\n}\n\nfunction cleanUndefined<T extends Record<string, any>>(obj: T): T {\n\tconst cleaned: Record<string, any> = {};\n\tObject.keys(obj || {}).forEach(key => {\n\t\tif (typeof obj[key] !== 'undefined') {\n\t\t\tcleaned[key] = obj[key];\n\t\t}\n\t});\n\treturn cleaned as T;\n}\n\nfunction coerceReportedDate(value?: string): Date {\n\tif (!value) {\n\t\treturn new Date();\n\t}\n\n\tconst coerced = new Date(value);\n\treturn Number.isNaN(coerced.getTime()) ? new Date() : coerced;\n}\n\nfunction shouldSuppressForLocalEnvironment(config: Record<string, any> | null, apiUrl: string): boolean {\n\tif (isLocalUrl(config?.ROOT_URL) || isLocalUrl(config?.SERVER_URL) || process.env.NODE_ENV === 'development') {\n\t\treturn true;\n\t}\n\n\treturn isLocalUrl(apiUrl);\n}\n\nfunction isLocalUrl(url?: string): boolean {\n\tif (!url || typeof url !== 'string') {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\treturn LOCAL_HOSTNAMES.has(parsed.hostname.toLowerCase());\n\t}\n\tcatch {\n\t\treturn /localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|::1/.test(url);\n\t}\n}\n\nfunction isResolveIOSelfClient(clientName?: string): boolean {\n\tif (!clientName) {\n\t\treturn false;\n\t}\n\n\treturn clientName.toLowerCase() === 'resolveio';\n}\n\nfunction isPlainObject(value: any): value is Record<string, any> {\n\treturn !!value && typeof value === 'object' && !Array.isArray(value);\n}\n"]}
1
+ {"version":3,"sources":["../../src/util/error-reporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAoC;AACpC,gEAA0D;AAE1D,IAAM,qBAAqB,GAAG,iDAA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C/B,WAAW,CAAC,aAAa,GAAG,aAAa,CAAC;KAC1C;IACD,OAAO,WAAW,CAAC;AACpB,CAAC;AAED,SAAS,iCAAiC,CAAC,MAAkC,EAAE,MAAc;IAC5F,IAAI,UAAU,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAC,IAAI,UAAU,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QAC7G,OAAO,IAAI,CAAC;KACZ;IAED,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,UAAU,CAAC,GAAY;IAC/B,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QACpC,OAAO,KAAK,CAAC;KACb;IAED,IAAI;QACH,IAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;KAC1D;IACD,WAAM;QACL,OAAO,uCAAuC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACzD;AACF,CAAC","file":"error-reporter.js","sourcesContent":["import { createHash } from 'crypto';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nconst DEFAULT_ERROR_API_URL = 'https://backend.resolveio.com/api/errors/report';\nconst LOCAL_HOSTNAMES = new Set(['localhost', '127.0.0.1', '0.0.0.0', '::1']);\n\n// eslint-disable-next-line no-unused-vars\ntype FetchLike = (input: RequestInfo, init?: RequestInit) => Promise<Response>;\n\nexport interface ErrorReportAttachment {\n\tname: string;\n\turl?: string;\n\tcontentType?: string;\n\tsize?: number;\n}\n\nexport interface ErrorReportOptions {\n\tsourceApp?: string;\n\tmessage?: string;\n\tsubject?: string;\n\tenvironment?: string;\n\tclientId?: string;\n\tclientSlug?: string;\n\tclientName?: string;\n\tclientRepo?: string;\n\tclientEmail?: string;\n\tseverity?: string;\n\tstack?: string | Error;\n\terror?: unknown;\n\tcontext?: Record<string, any> | string | null;\n\tmetadata?: Record<string, any> | string | null;\n\tattachments?: ErrorReportAttachment[];\n\tfingerprint?: string;\n\tidempotencyKey?: string;\n\treportedBy?: string;\n\treportedAt?: string | Date;\n\treportedFor?: string;\n\treportedCount?: number;\n\treportedSourceHost?: string;\n\treportedSourceIp?: string;\n\treportedSourceVersion?: string;\n\treportedSourcePid?: number;\n\treportedSourceInstance?: string;\n\treportedSourceRegion?: string;\n\treportedSourceCluster?: string;\n\treportedSourceProcess?: string;\n\treportedSourceEnv?: Record<string, any>;\n\tcorrelationId?: string;\n\tapiUrl?: string;\n\tfetch?: FetchLike;\n\tlogger?: Pick<typeof console, 'error' | 'warn' | 'info' | 'log'>;\n}\n\nexport interface ErrorReportResult {\n\tdelivered: boolean;\n\tstatus?: number;\n\treason?: string;\n}\n\ninterface ErrorReportPayload {\n\tsourceApp: string;\n\tmessage: string;\n\tenvironment?: string;\n\tclientId?: string;\n\tclientSlug?: string;\n\tclientName?: string;\n\tclientRepo?: string;\n\tclientEmail?: string;\n\tseverity: string;\n\tstack?: string;\n\tcontext?: Record<string, any> | string;\n\tmetadata?: Record<string, any> | string;\n\tattachments?: ErrorReportAttachment[];\n\tfingerprint?: string;\n\tidempotencyKey?: string;\n\treportedBy?: string;\n\treportedAt?: string;\n\treportedFor?: string;\n\treportedCount?: number;\n\treportedSourceHost?: string;\n\treportedSourceIp?: string;\n\treportedSourceVersion?: string;\n\treportedSourcePid?: number;\n\treportedSourceInstance?: string;\n\treportedSourceRegion?: string;\n\treportedSourceCluster?: string;\n\treportedSourceProcess?: string;\n\treportedSourceEnv?: Record<string, any>;\n}\n\nexport class ErrorReporter {\n\tpublic static async report(options: ErrorReportOptions): Promise<ErrorReportResult> {\n\t\tconst logger = options.logger || console;\n\t\tconst config = getServerConfig();\n\t\tconst normalizedApiUrl = options.apiUrl || DEFAULT_ERROR_API_URL;\n\t\tconst clientName = options.clientName || config?.CLIENT_NAME || ResolveIOServer.getClientName?.() || 'resolveio';\n\t\tconst sourceApp = options.sourceApp || clientName || 'resolveio-server-lib';\n\t\tconst environment = options.environment || process.env.RESOLVEIO_ENV || config?.RESOLVEIO_ENV || config?.ENVIRONMENT || config?.ROOT_URL || process.env.NODE_ENV || 'unknown';\n\t\tconst message = options.message || options.subject || 'ResolveIO Error Detected';\n\t\tconst severity = options.severity || 'error';\n\t\tconst stack = normalizeStack(options.stack || options.error);\n\t\tconst context = normalizeStructured(options.context, options.correlationId);\n\t\tconst metadata = normalizeStructured(mergeMetadata(options.metadata, options.correlationId));\n\t\tconst attachments = Array.isArray(options.attachments) ? normalizeAttachments(options.attachments) : undefined;\n\t\tconst fingerprint = options.fingerprint || computeFingerprint(sourceApp, environment, message, stack);\n\t\tconst idempotencyKey = options.idempotencyKey;\n\t\tconst reportedAt = normalizeReportedAt(options.reportedAt);\n\t\tconst normalizedReportedSourceEnv = normalizeStructured(options.reportedSourceEnv);\n\t\tconst payload: ErrorReportPayload = removeEmptyFields({\n\t\t\tsourceApp,\n\t\t\tmessage,\n\t\t\tenvironment,\n\t\t\tclientId: options.clientId,\n\t\t\tclientSlug: options.clientSlug,\n\t\t\tclientName,\n\t\t\tclientRepo: options.clientRepo,\n\t\t\tclientEmail: options.clientEmail,\n\t\t\tseverity,\n\t\t\tstack,\n\t\t\tcontext,\n\t\t\tmetadata,\n\t\t\tattachments,\n\t\t\tfingerprint,\n\t\t\tidempotencyKey,\n\t\t\treportedBy: options.reportedBy,\n\t\t\treportedAt,\n\t\t\treportedFor: options.reportedFor,\n\t\t\treportedCount: options.reportedCount,\n\t\t\treportedSourceHost: options.reportedSourceHost,\n\t\t\treportedSourceIp: options.reportedSourceIp,\n\t\t\treportedSourceVersion: options.reportedSourceVersion,\n\t\t\treportedSourcePid: options.reportedSourcePid,\n\t\t\treportedSourceInstance: options.reportedSourceInstance,\n\t\t\treportedSourceRegion: options.reportedSourceRegion,\n\t\t\treportedSourceCluster: options.reportedSourceCluster,\n\t\t\treportedSourceProcess: options.reportedSourceProcess,\n\t\t\treportedSourceEnv: typeof normalizedReportedSourceEnv === 'string' ? undefined : normalizedReportedSourceEnv as Record<string, any>\n\t\t});\n\n\t\tif (shouldSuppressForLocalEnvironment(config, normalizedApiUrl)) {\n\t\t\tlogger.info('ErrorReporter suppressed: local environment detected');\n\t\t\tlogger.error('ErrorReporter payload (suppressed):', payload);\n\t\t\treturn { delivered: false, reason: 'local-environment' };\n\t\t}\n\n\t\tconst transport = options.fetch || globalThis.fetch;\n\t\tif (typeof transport !== 'function') {\n\t\t\tlogger.error('ErrorReporter failed: fetch is not available in this runtime');\n\t\t\tlogger.error('ErrorReporter payload (not sent):', payload);\n\t\t\treturn { delivered: false, reason: 'missing-fetch' };\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await transport(normalizedApiUrl, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: removeEmptyFields({\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'X-ResolveIO-Error-Key': clientName,\n\t\t\t\t\t'X-ResolveIO-Error-Hash': fingerprint,\n\t\t\t\t\t'X-ResolveIO-Idempotency-Key': idempotencyKey\n\t\t\t\t}),\n\t\t\t\tbody: JSON.stringify(payload)\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tlogger.error('ErrorReporter failed to deliver payload', { status: response.status, statusText: response.statusText });\n\t\t\t\treturn { delivered: false, status: response.status, reason: 'http-error' };\n\t\t\t}\n\n\t\t\treturn { delivered: true, status: response.status };\n\t\t}\n\t\tcatch (err) {\n\t\t\tlogger.error('ErrorReporter exception while delivering payload', err);\n\t\t\tlogger.error('ErrorReporter payload (not sent):', payload);\n\t\t\treturn { delivered: false, reason: 'network-error' };\n\t\t}\n\t}\n}\n\nfunction getServerConfig(): Record<string, any> | null {\n\ttry {\n\t\treturn ResolveIOServer.getServerConfig?.() || null;\n\t}\n\tcatch (err) {\n\t\tconsole.error('Failed to read ResolveIO server config', err);\n\t\treturn null;\n\t}\n}\n\nfunction normalizeStack(stack?: string | Error | unknown): string | undefined {\n\tif (!stack) {\n\t\treturn undefined;\n\t}\n\n\tif (typeof stack === 'string') {\n\t\treturn stack;\n\t}\n\n\tif (stack instanceof Error) {\n\t\treturn stack.stack || stack.message;\n\t}\n\n\tif (typeof stack === 'object' && stack !== null && typeof (stack as Record<string, any>).stack === 'string') {\n\t\treturn (stack as Record<string, any>).stack;\n\t}\n\n\tif (typeof stack === 'object' && stack !== null && typeof (stack as Record<string, any>).message === 'string') {\n\t\treturn (stack as Record<string, any>).message;\n\t}\n\n\treturn JSON.stringify(stack);\n}\n\nfunction normalizeStructured(value: any, correlationId?: string): Record<string, any> | string | undefined {\n\tif (value === null || value === undefined) {\n\t\treturn undefined;\n\t}\n\n\tif (typeof value === 'string') {\n\t\treturn value;\n\t}\n\n\tconst serialized = serializeValue(value);\n\tif (correlationId && typeof serialized === 'object' && serialized !== null && !serialized.correlationId) {\n\t\tserialized.correlationId = correlationId;\n\t}\n\treturn serialized;\n}\n\nfunction serializeValue(value: any, seen: WeakSet<object> = new WeakSet()): any {\n\tif (value === null || value === undefined) {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'bigint') {\n\t\treturn value.toString();\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn value.toISOString();\n\t}\n\n\tif (value instanceof Error) {\n\t\tconst base = {\n\t\t\tname: value.name,\n\t\t\tmessage: value.message,\n\t\t\tstack: value.stack\n\t\t};\n\t\treturn Object.assign({}, base, serializeValue(Object.assign({}, value), seen));\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tif (seen.has(value)) {\n\t\t\treturn '[Circular]';\n\t\t}\n\t\tseen.add(value);\n\t\tconst arr = value.map(item => serializeValue(item, seen));\n\t\tseen.delete(value);\n\t\treturn arr;\n\t}\n\n\tif (typeof value === 'object') {\n\t\tif (seen.has(value)) {\n\t\t\treturn '[Circular]';\n\t\t}\n\t\tseen.add(value);\n\t\tconst obj: Record<string, any> = {};\n\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\tobj[key] = serializeValue(val, seen);\n\t\t}\n\t\tseen.delete(value);\n\t\treturn obj;\n\t}\n\n\treturn String(value);\n}\n\nfunction normalizeAttachments(attachments: ErrorReportAttachment[]): ErrorReportAttachment[] {\n\treturn attachments\n\t\t.filter(att => !!att && typeof att === 'object')\n\t\t.map(att => removeEmptyFields({\n\t\t\tname: att.name,\n\t\t\turl: att.url,\n\t\t\tcontentType: att.contentType,\n\t\t\tsize: typeof att.size === 'number' ? att.size : undefined\n\t\t}))\n\t\t.filter(att => !!att.name);\n}\n\nfunction normalizeReportedAt(value?: string | Date): string | undefined {\n\tif (!value) {\n\t\treturn new Date().toISOString();\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn value.toISOString();\n\t}\n\n\tconst date = new Date(value);\n\tif (!isNaN(date.getTime())) {\n\t\treturn date.toISOString();\n\t}\n\n\treturn new Date().toISOString();\n}\n\nfunction computeFingerprint(sourceApp: string, environment: string | undefined, message: string, stack?: string): string | undefined {\n\tconst signature = `${sourceApp || ''}:${environment || ''}:${message || ''}:${stack ? stack.split('\\n').slice(0, 5).join('|') : ''}`;\n\treturn createHash('sha256').update(signature).digest('hex');\n}\n\nfunction removeEmptyFields<T extends Record<string, any>>(obj: T): T {\n\tconst cleaned: Record<string, any> = {};\n\tfor (const [key, value] of Object.entries(obj || {})) {\n\t\tif (value === undefined || value === null || value === '') {\n\t\t\tcontinue;\n\t\t}\n\t\tcleaned[key] = value;\n\t}\n\treturn cleaned as T;\n}\n\nfunction mergeMetadata(metadata: Record<string, any> | string | null | undefined, correlationId?: string) {\n\tif (!metadata && !correlationId) {\n\t\treturn undefined;\n\t}\n\n\tconst base = metadata ? normalizeStructured(metadata) : undefined;\n\tif (!correlationId) {\n\t\treturn base;\n\t}\n\n\tif (typeof base === 'string') {\n\t\treturn {\n\t\t\tcorrelationId,\n\t\t\tmessage: base\n\t\t};\n\t}\n\n\tconst metadataObj = (base || {}) as Record<string, any>;\n\tif (!metadataObj.correlationId) {\n\t\tmetadataObj.correlationId = correlationId;\n\t}\n\treturn metadataObj;\n}\n\nfunction shouldSuppressForLocalEnvironment(config: Record<string, any> | null, apiUrl: string): boolean {\n\tif (isLocalUrl(config?.ROOT_URL) || isLocalUrl(config?.SERVER_URL) || process.env.NODE_ENV === 'development') {\n\t\treturn true;\n\t}\n\n\treturn isLocalUrl(apiUrl);\n}\n\nfunction isLocalUrl(url?: string): boolean {\n\tif (!url || typeof url !== 'string') {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\treturn LOCAL_HOSTNAMES.has(parsed.hostname.toLowerCase());\n\t}\n\tcatch {\n\t\treturn /localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|::1/.test(url);\n\t}\n}\n"]}
@@ -1,3 +0,0 @@
1
- import { MongoManagerCollection } from '../managers/mongo.manager';
2
- import { ErrorAutoFixLogModel } from '../models/error-auto-fix-log.model';
3
- export declare let ErrorAutoFixLogs: MongoManagerCollection<ErrorAutoFixLogModel>;
@@ -1,266 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ErrorAutoFixLogs = void 0;
40
- var mongo_manager_1 = require("../managers/mongo.manager");
41
- var resolveio_server_app_1 = require("../resolveio-server-app");
42
- var schema = {
43
- _id: {
44
- type: String,
45
- optional: true
46
- },
47
- __v: {
48
- type: Number,
49
- optional: true
50
- },
51
- email_hash: {
52
- type: String
53
- },
54
- issue_hash: {
55
- type: String,
56
- optional: true
57
- },
58
- subject: {
59
- type: String
60
- },
61
- message_id: {
62
- type: String,
63
- optional: true
64
- },
65
- body: {
66
- type: String
67
- },
68
- status: {
69
- type: String,
70
- allowedValues: ['pending', 'in_progress', 'success', 'failed', 'skipped']
71
- },
72
- ignored: {
73
- type: Boolean
74
- },
75
- attempt_count: {
76
- type: Number
77
- },
78
- duplicate_count: {
79
- type: Number
80
- },
81
- first_seen_at: {
82
- type: Date
83
- },
84
- last_attempt_at: {
85
- type: Date,
86
- optional: true
87
- },
88
- last_duplicate_at: {
89
- type: Date,
90
- optional: true
91
- },
92
- last_result_at: {
93
- type: Date,
94
- optional: true
95
- },
96
- branch_name: {
97
- type: String,
98
- optional: true
99
- },
100
- pr_url: {
101
- type: String,
102
- optional: true
103
- },
104
- plan_summary: {
105
- type: String,
106
- optional: true
107
- },
108
- plan_body: {
109
- type: String,
110
- optional: true
111
- },
112
- patches: {
113
- type: Array,
114
- optional: true
115
- },
116
- 'patches.$': {
117
- type: String
118
- },
119
- id_client: {
120
- type: String,
121
- optional: true
122
- },
123
- client_name: {
124
- type: String,
125
- optional: true
126
- },
127
- from_email: {
128
- type: String,
129
- optional: true
130
- },
131
- source_type: {
132
- type: String,
133
- optional: true
134
- },
135
- classification_reason: {
136
- type: String,
137
- optional: true
138
- },
139
- codex_task_id: {
140
- type: String,
141
- optional: true
142
- },
143
- codex_environment: {
144
- type: String,
145
- optional: true
146
- },
147
- last_error: {
148
- type: String,
149
- optional: true
150
- },
151
- source_app: {
152
- type: String,
153
- optional: true
154
- },
155
- source_environment: {
156
- type: String,
157
- optional: true
158
- },
159
- severity: {
160
- type: String,
161
- optional: true
162
- },
163
- reported_by: {
164
- type: String,
165
- optional: true
166
- },
167
- last_reported_at: {
168
- type: Date,
169
- optional: true
170
- },
171
- report_metadata: {
172
- type: Object,
173
- optional: true,
174
- blackbox: true
175
- },
176
- report_context: {
177
- type: Object,
178
- optional: true,
179
- blackbox: true
180
- },
181
- attachments: {
182
- type: Array,
183
- optional: true
184
- },
185
- 'attachments.$': {
186
- type: Object
187
- },
188
- 'attachments.$.name': {
189
- type: String,
190
- optional: true
191
- },
192
- 'attachments.$.url': {
193
- type: String,
194
- optional: true
195
- },
196
- 'attachments.$.contentType': {
197
- type: String,
198
- optional: true
199
- },
200
- 'attachments.$.size': {
201
- type: Number,
202
- optional: true
203
- },
204
- createdAt: {
205
- type: Date,
206
- optional: true
207
- },
208
- updatedAt: {
209
- type: Date,
210
- optional: true
211
- }
212
- };
213
- exports.ErrorAutoFixLogs = null;
214
- initializeCollection();
215
- function initializeCollection() {
216
- var _this = this;
217
- if (resolveio_server_app_1.ResolveIOServer && resolveio_server_app_1.ResolveIOServer.getMainDB() && mongo_manager_1.MongoManagerModel) {
218
- var model = mongo_manager_1.MongoManagerModel.create({
219
- collectionName: 'error-autofix-logs',
220
- schema: schema,
221
- useVersionCollection: false,
222
- useReportBuilder: false,
223
- reportBuilderLookupTables: [],
224
- timestamps: true,
225
- createLogs: false,
226
- checkSchema: true,
227
- collectionOptions: null,
228
- skipCache: true
229
- });
230
- exports.ErrorAutoFixLogs = model.collection_main;
231
- setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
232
- var err_1;
233
- return __generator(this, function (_a) {
234
- switch (_a.label) {
235
- case 0:
236
- _a.trys.push([0, 5, , 6]);
237
- return [4 /*yield*/, exports.ErrorAutoFixLogs.createIndex({ email_hash: 1 })];
238
- case 1:
239
- _a.sent();
240
- return [4 /*yield*/, exports.ErrorAutoFixLogs.createIndex({ issue_hash: 1 })];
241
- case 2:
242
- _a.sent();
243
- return [4 /*yield*/, exports.ErrorAutoFixLogs.createIndex({ status: 1 })];
244
- case 3:
245
- _a.sent();
246
- return [4 /*yield*/, exports.ErrorAutoFixLogs.createIndex({ ignored: 1 })];
247
- case 4:
248
- _a.sent();
249
- return [3 /*break*/, 6];
250
- case 5:
251
- err_1 = _a.sent();
252
- console.error('ErrorAutoFixLogs index creation failed', err_1);
253
- return [3 /*break*/, 6];
254
- case 6: return [2 /*return*/];
255
- }
256
- });
257
- }); }, 5000);
258
- }
259
- else {
260
- setImmediate(function () {
261
- initializeCollection();
262
- });
263
- }
264
- }
265
-
266
- //# sourceMappingURL=error-auto-fix.collection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/collections/error-auto-fix.collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAsF;AAEtF,gEAA0D;AAE1D,IAAM,MAAM,GAAQ;IACnB,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,GAAG,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,UAAU,EAAE;QACX,IAAI,EAAE,MAAM;KACZ;IACD,UAAU,EAAE;QACX,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,OAAO,EAAE;QACR,IAAI,EAAE,MAAM;KACZ;IACD,UAAU,EAAE;QACX,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,IAAI,EAAE;QACL,IAAI,EAAE,MAAM;KACZ;IACD,MAAM,EAAE;QACP,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC;KACzE;IACD,OAAO,EAAE;QACR,IAAI,EAAE,OAAO;KACb;IACD,aAAa,EAAE;QACd,IAAI,EAAE,MAAM;KACZ;IACD,eAAe,EAAE;QAChB,IAAI,EAAE,MAAM;KACZ;IACD,aAAa,EAAE;QACd,IAAI,EAAE,IAAI;KACV;IACD,eAAe,EAAE;QAChB,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,iBAAiB,EAAE;QAClB,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,cAAc,EAAE;QACf,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;KACd;IACD,WAAW,EAAE;QACZ,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E,IAAI;YACjB,iBAAiB,EAAE,IAAI;YACvB,SAAS,EAAE,IAAI;SACf,CAAC,CAAC;QACH,wBAAgB,GAAG,KAAK,CAAC,eAAe,CAAC;QACzC,UAAU,CAAC;;;;;;wBAET,qBAAM,wBAAgB,CAAC,WAAW,CAAC,EAAC,UAAU,EAAE,CAAC,EAAC,CAAC,EAAA;;wBAAnD,SAAmD,CAAC;wBACpD,qBAAM,wBAAgB,CAAC,WAAW,CAAC,EAAC,UAAU,EAAE,CAAC,EAAC,CAAC,EAAA;;wBAAnD,SAAmD,CAAC;wBACpD,qBAAM,wBAAgB,CAAC,WAAW,CAAC,EAAC,MAAM,EAAE,CAAC,EAAC,CAAC,EAAA;;wBAA/C,SAA+C,CAAC;wBAChD,qBAAM,wBAAgB,CAAC,WAAW,CAAC,EAAC,OAAO,EAAE,CAAC,EAAC,CAAC,EAAA;;wBAAhD,SAAgD,CAAC;;;;wBAGjD,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAG,CAAC,CAAC;;;;;aAE9D,EAAE,IAAI,CAAC,CAAC;KACT;SACI;QACJ,YAAY,CAAC;YACZ,oBAAoB,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;KACH;AACF,CAAC","file":"error-auto-fix.collection.js","sourcesContent":["import { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { ErrorAutoFixLogModel } from '../models/error-auto-fix-log.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nconst schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\temail_hash: {\n\t\ttype: String\n\t},\n\tissue_hash: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tsubject: {\n\t\ttype: String\n\t},\n\tmessage_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tbody: {\n\t\ttype: String\n\t},\n\tstatus: {\n\t\ttype: String,\n\t\tallowedValues: ['pending', 'in_progress', 'success', 'failed', 'skipped']\n\t},\n\tignored: {\n\t\ttype: Boolean\n\t},\n\tattempt_count: {\n\t\ttype: Number\n\t},\n\tduplicate_count: {\n\t\ttype: Number\n\t},\n\tfirst_seen_at: {\n\t\ttype: Date\n\t},\n\tlast_attempt_at: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tlast_duplicate_at: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tlast_result_at: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tbranch_name: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tpr_url: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tplan_summary: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tplan_body: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tpatches: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'patches.$': {\n\t\ttype: String\n\t},\n\tid_client: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tclient_name: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tfrom_email: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tsource_type: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tclassification_reason: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcodex_task_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcodex_environment: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tlast_error: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tsource_app: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tsource_environment: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tseverity: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\treported_by: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tlast_reported_at: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\treport_metadata: {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t},\n\treport_context: {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t},\n\tattachments: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'attachments.$': {\n\t\ttype: Object\n\t},\n\t'attachments.$.name': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'attachments.$.url': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'attachments.$.contentType': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'attachments.$.size': {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t}\n};\n\nexport let ErrorAutoFixLogs: MongoManagerCollection<ErrorAutoFixLogModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB() && MongoManagerModel) {\n\t\tconst model = MongoManagerModel.create<ErrorAutoFixLogModel>({\n\t\t\tcollectionName: 'error-autofix-logs',\n\t\t\tschema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null,\n\t\t\tskipCache: true\n\t\t});\n\t\tErrorAutoFixLogs = model.collection_main;\n\t\tsetTimeout(async () => {\n\t\t\ttry {\n\t\t\t\tawait ErrorAutoFixLogs.createIndex({email_hash: 1});\n\t\t\t\tawait ErrorAutoFixLogs.createIndex({issue_hash: 1});\n\t\t\t\tawait ErrorAutoFixLogs.createIndex({status: 1});\n\t\t\t\tawait ErrorAutoFixLogs.createIndex({ignored: 1});\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tconsole.error('ErrorAutoFixLogs index creation failed', err);\n\t\t\t}\n\t\t}, 5000);\n\t}\n\telse {\n\t\tsetImmediate(() => {\n\t\t\tinitializeCollection();\n\t\t});\n\t}\n}\n"]}
@@ -1,47 +0,0 @@
1
- export type ErrorAutoFixLogStatus = 'pending' | 'in_progress' | 'success' | 'failed' | 'skipped';
2
- export interface ErrorAutoFixAttachment {
3
- name?: string;
4
- url?: string;
5
- contentType?: string;
6
- size?: number;
7
- }
8
- export interface ErrorAutoFixLogModel {
9
- _id?: string;
10
- __v?: number;
11
- email_hash: string;
12
- issue_hash?: string;
13
- subject: string;
14
- message_id?: string;
15
- body: string;
16
- status: ErrorAutoFixLogStatus;
17
- ignored: boolean;
18
- attempt_count: number;
19
- duplicate_count: number;
20
- first_seen_at: Date;
21
- last_attempt_at?: Date;
22
- last_duplicate_at?: Date;
23
- last_result_at?: Date;
24
- branch_name?: string;
25
- pr_url?: string;
26
- plan_summary?: string;
27
- plan_body?: string;
28
- patches?: string[];
29
- id_client?: string;
30
- client_name?: string;
31
- from_email?: string;
32
- source_type?: 'app' | 'infrastructure' | 'noise';
33
- classification_reason?: string;
34
- codex_task_id?: string;
35
- codex_environment?: string;
36
- last_error?: string;
37
- source_app?: string;
38
- source_environment?: string;
39
- severity?: string;
40
- reported_by?: string;
41
- last_reported_at?: Date;
42
- report_metadata?: Record<string, any>;
43
- report_context?: Record<string, any>;
44
- attachments?: ErrorAutoFixAttachment[];
45
- createdAt?: Date;
46
- updatedAt?: Date;
47
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
-
4
- //# sourceMappingURL=error-auto-fix-log.model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/models/error-auto-fix-log.model.ts"],"names":[],"mappings":"","file":"error-auto-fix-log.model.js","sourcesContent":["export type ErrorAutoFixLogStatus = 'pending' | 'in_progress' | 'success' | 'failed' | 'skipped';\n\nexport interface ErrorAutoFixAttachment {\n\tname?: string;\n\turl?: string;\n\tcontentType?: string;\n\tsize?: number;\n}\n\nexport interface ErrorAutoFixLogModel {\n\t_id?: string;\n\t__v?: number;\n\temail_hash: string;\n\tissue_hash?: string;\n\tsubject: string;\n\tmessage_id?: string;\n\tbody: string;\n\tstatus: ErrorAutoFixLogStatus;\n\tignored: boolean;\n\tattempt_count: number;\n\tduplicate_count: number;\n\tfirst_seen_at: Date;\n\tlast_attempt_at?: Date;\n\tlast_duplicate_at?: Date;\n\tlast_result_at?: Date;\n\tbranch_name?: string;\n\tpr_url?: string;\n\tplan_summary?: string;\n\tplan_body?: string;\n\tpatches?: string[];\n\tid_client?: string;\n\tclient_name?: string;\n\tfrom_email?: string;\n\tsource_type?: 'app' | 'infrastructure' | 'noise';\n\tclassification_reason?: string;\n\tcodex_task_id?: string;\n\tcodex_environment?: string;\n\tlast_error?: string;\n\tsource_app?: string;\n\tsource_environment?: string;\n\tseverity?: string;\n\treported_by?: string;\n\tlast_reported_at?: Date;\n\treport_metadata?: Record<string, any>;\n\treport_context?: Record<string, any>;\n\tattachments?: ErrorAutoFixAttachment[];\n\tcreatedAt?: Date;\n\tupdatedAt?: Date;\n}\n"]}