@resolveio/server-lib 20.14.44 → 20.14.46
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/fixtures/cron-jobs.js +20 -3
- package/fixtures/cron-jobs.js.map +1 -1
- package/managers/subscription.manager.d.ts +2 -0
- package/managers/subscription.manager.js +16 -0
- package/managers/subscription.manager.js.map +1 -1
- package/methods/ai-terminal.d.ts +28 -1
- package/methods/ai-terminal.js +671 -73
- package/methods/ai-terminal.js.map +1 -1
- package/methods/cron-jobs.js +179 -0
- package/methods/cron-jobs.js.map +1 -1
- package/methods.ts +3 -0
- package/package.json +1 -1
package/fixtures/cron-jobs.js
CHANGED
|
@@ -98,12 +98,29 @@ function loadServerCronJobs() {
|
|
|
98
98
|
_a.sent();
|
|
99
99
|
_a.label = 7;
|
|
100
100
|
case 7:
|
|
101
|
-
if (
|
|
102
|
-
return [4 /*yield*/, cron_job_collection_1.CronJobs.
|
|
101
|
+
if (!!cronJobs.some(function (a) { return a.name === 'Communication Metrics Sync'; })) return [3 /*break*/, 9];
|
|
102
|
+
return [4 /*yield*/, cron_job_collection_1.CronJobs.create({
|
|
103
|
+
_id: (0, common_1.objectIdHexString)(),
|
|
104
|
+
__v: 0,
|
|
105
|
+
name: 'Communication Metrics Sync',
|
|
106
|
+
repeat: true,
|
|
107
|
+
time_to_run: '15 * * * *',
|
|
108
|
+
method_run: 'cronCommunicationMetricsSync',
|
|
109
|
+
method_run_data: {},
|
|
110
|
+
next_run: new Date(),
|
|
111
|
+
running: false,
|
|
112
|
+
timezone: process.env.TZ_CLIENT || 'America/Chicago'
|
|
113
|
+
})];
|
|
103
114
|
case 8:
|
|
104
115
|
_a.sent();
|
|
105
116
|
_a.label = 9;
|
|
106
|
-
case 9:
|
|
117
|
+
case 9:
|
|
118
|
+
if (!cronJobs.some(function (a) { return a.running; })) return [3 /*break*/, 11];
|
|
119
|
+
return [4 /*yield*/, cron_job_collection_1.CronJobs.updateMany({ running: true }, { $set: { running: false } })];
|
|
120
|
+
case 10:
|
|
121
|
+
_a.sent();
|
|
122
|
+
_a.label = 11;
|
|
123
|
+
case 11: return [2 /*return*/];
|
|
107
124
|
}
|
|
108
125
|
});
|
|
109
126
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fixtures/cron-jobs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,
|
|
1
|
+
{"version":3,"sources":["../../src/fixtures/cron-jobs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,gDAmEC;AAtED,0EAA8D;AAC9D,yCAAmD;AAEnD,SAAsB,kBAAkB;;;;;wBAExB,qBAAM,8BAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAA;;oBAAlC,QAAQ,GAAG,SAAuB;yBAElC,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,2BAA2B,EAAtC,CAAsC,CAAC,EAA3D,wBAA2D;oBAC9D,qBAAM,8BAAQ,CAAC,MAAM,CAAC;4BACrB,GAAG,EAAE,IAAA,0BAAiB,GAAE;4BACxB,GAAG,EAAE,CAAC;4BACN,IAAI,EAAG,2BAA2B;4BAClC,MAAM,EAAG,IAAI;4BACb,WAAW,EAAG,WAAW;4BACzB,UAAU,EAAG,4BAA4B;4BACzC,eAAe,EAAG,IAAI;4BACtB,QAAQ,EAAG,IAAI,IAAI,EAAE;4BACrB,OAAO,EAAG,KAAK;4BACf,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,iBAAiB;yBACpD,CAAC,EAAA;;oBAXF,SAWE,CAAC;;;yBAGA,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,gBAAgB,EAA3B,CAA2B,CAAC,EAAhD,wBAAgD;oBACnD,qB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,EAAG,YAAY;4BAC1B,UAAU,EAAG,8BAA8B;4BAC3C,eAAe,EAAG,EAAE;4BACpB,QAAQ,EAAG,IAAI,IAAI,EAAE;4BACrB,OAAO,EAAG,KAAK;4BACf,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,iBAAiB;yBACpD,CAAC,EAAA;;oBAXF,SAWE,CAAC;;;yBAGA,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,EAAT,CAAS,CAAC,EAA7B,yBAA6B;oBAChC,qBAAM,8BAAQ,CAAC,UAAU,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC,EAAC,CAAC,EAAA;;oBAApE,SAAoE,CAAC;;;;;;CAEtE","file":"cron-jobs.js","sourcesContent":["import { CronJobs } from '../collections/cron-job.collection';\nimport { objectIdHexString } from '../util/common';\n\nexport async function loadServerCronJobs() {\n\t\n\tlet cronJobs = await CronJobs.find({});\n\n\tif (!cronJobs.some(a => a.name === 'Email Merged Docs Cleanup')) {\n\t\tawait CronJobs.create({\n\t\t\t_id: objectIdHexString(),\n\t\t\t__v: 0,\n\t\t\tname : 'Email Merged Docs Cleanup', \n\t\t\trepeat : true, \n\t\t\ttime_to_run : '0 0 * * *', \n\t\t\tmethod_run : 'cronEmailMergedDocsCleanUp', \n\t\t\tmethod_run_data : null, \n\t\t\tnext_run : new Date(), \n\t\t\trunning : false,\n\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t});\n\t}\n\n\tif (!cronJobs.some(a => a.name === 'Stuck Cron Job')) {\n\t\tawait CronJobs.create({\n\t\t\t_id: objectIdHexString(),\n\t\t\t__v: 0,\n\t\t\tname : 'Stuck Cron Job', \n\t\t\trepeat : true, \n\t\t\ttime_to_run : '*/5 * * * *', \n\t\t\tmethod_run : 'stuckCronJob', \n\t\t\tmethod_run_data : null, \n\t\t\tnext_run : new Date(), \n\t\t\trunning : false,\n\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t});\n\t}\n\n\tif (!cronJobs.some(a => a.name === 'OpenAI Usage Billing Sync')) {\n\t\tawait CronJobs.create({\n\t\t\t_id: objectIdHexString(),\n\t\t\t__v: 0,\n\t\t\tname : 'OpenAI Usage Billing Sync',\n\t\t\trepeat : true,\n\t\t\ttime_to_run : '0 * * * *',\n\t\t\tmethod_run : 'cronOpenAIUsageBillingSync',\n\t\t\tmethod_run_data : {},\n\t\t\tnext_run : new Date(),\n\t\t\trunning : false,\n\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t});\n\t}\n\n\tif (!cronJobs.some(a => a.name === 'Communication Metrics Sync')) {\n\t\tawait CronJobs.create({\n\t\t\t_id: objectIdHexString(),\n\t\t\t__v: 0,\n\t\t\tname : 'Communication Metrics Sync',\n\t\t\trepeat : true,\n\t\t\ttime_to_run : '15 * * * *',\n\t\t\tmethod_run : 'cronCommunicationMetricsSync',\n\t\t\tmethod_run_data : {},\n\t\t\tnext_run : new Date(),\n\t\t\trunning : false,\n\t\t\ttimezone: process.env.TZ_CLIENT || 'America/Chicago'\n\t\t});\n\t}\n\n\tif (cronJobs.some(a => a.running)) {\n\t\tawait CronJobs.updateMany({running: true}, {$set: {running: false}});\n\t}\n}\n"]}
|
|
@@ -37,6 +37,7 @@ export declare class SubscriptionManager {
|
|
|
37
37
|
private _debugSendQueueHits;
|
|
38
38
|
private _debugRemoveCacheHits;
|
|
39
39
|
private _subSendDebug;
|
|
40
|
+
private _subSendLogEnabled;
|
|
40
41
|
private _subSendLogThresholdMs;
|
|
41
42
|
private _subSendLogBytes;
|
|
42
43
|
private _subSendLogSampleRate;
|
|
@@ -101,6 +102,7 @@ export declare class SubscriptionManager {
|
|
|
101
102
|
private resolveResumeTokenMaxAgeMs;
|
|
102
103
|
private resolveConnectDebug;
|
|
103
104
|
private resolveSubSendDebug;
|
|
105
|
+
private resolveSubSendLogEnabled;
|
|
104
106
|
private resolveSubSendLogThresholdMs;
|
|
105
107
|
private resolveSubSendLogBytes;
|
|
106
108
|
private resolveSubSendLogSampleRate;
|
|
@@ -147,6 +147,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
147
147
|
this._debugSendQueueHits = 0;
|
|
148
148
|
this._debugRemoveCacheHits = 0;
|
|
149
149
|
this._subSendDebug = false;
|
|
150
|
+
this._subSendLogEnabled = false;
|
|
150
151
|
this._subSendLogThresholdMs = 0;
|
|
151
152
|
this._subSendLogBytes = 0;
|
|
152
153
|
this._subSendLogSampleRate = 1;
|
|
@@ -232,6 +233,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
232
233
|
this._wss = wss;
|
|
233
234
|
this._connectDebug = this.resolveConnectDebug();
|
|
234
235
|
this._subSendDebug = this.resolveSubSendDebug();
|
|
236
|
+
this._subSendLogEnabled = this.resolveSubSendLogEnabled();
|
|
235
237
|
this._subSendLogThresholdMs = this.resolveSubSendLogThresholdMs();
|
|
236
238
|
this._subSendLogBytes = this.resolveSubSendLogBytes();
|
|
237
239
|
this._subSendLogSampleRate = this.resolveSubSendLogSampleRate();
|
|
@@ -1248,6 +1250,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1248
1250
|
|| config['SUBSCRIPTION_SEND_DEBUG'];
|
|
1249
1251
|
return this.parseDebugFlag(raw);
|
|
1250
1252
|
};
|
|
1253
|
+
SubscriptionManager.prototype.resolveSubSendLogEnabled = function () {
|
|
1254
|
+
var config = this.serverConfig || resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
1255
|
+
var raw = process.env.SUB_SEND_LOG_ENABLED
|
|
1256
|
+
|| process.env.SUBSCRIPTION_SEND_LOG_ENABLED
|
|
1257
|
+
|| config['SUB_SEND_LOG_ENABLED']
|
|
1258
|
+
|| config['SUBSCRIPTION_SEND_LOG_ENABLED'];
|
|
1259
|
+
if (raw === undefined || raw === null || raw === '') {
|
|
1260
|
+
return this._subSendDebug;
|
|
1261
|
+
}
|
|
1262
|
+
return this.parseDebugFlag(raw);
|
|
1263
|
+
};
|
|
1251
1264
|
SubscriptionManager.prototype.resolveSubSendLogThresholdMs = function () {
|
|
1252
1265
|
var config = this.serverConfig || resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
1253
1266
|
var raw = process.env.SUB_SEND_LOG_THRESHOLD_MS
|
|
@@ -1308,6 +1321,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1308
1321
|
return fallback;
|
|
1309
1322
|
};
|
|
1310
1323
|
SubscriptionManager.prototype.shouldLogSubSend = function (durationMs, payloadBytes) {
|
|
1324
|
+
if (!this._subSendLogEnabled) {
|
|
1325
|
+
return false;
|
|
1326
|
+
}
|
|
1311
1327
|
if (this._subSendLogSampleRate < 1 && Math.random() > this._subSendLogSampleRate) {
|
|
1312
1328
|
return false;
|
|
1313
1329
|
}
|