@resolveio/server-lib 20.14.45 → 20.14.47
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/methods/ai-terminal.d.ts +28 -1
- package/methods/ai-terminal.js +847 -76
- 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,qBAAM,8BAAQ,CAAC,MAAM,CAAC;4BACrB,GAAG,EAAE,IAAA,0BAAiB,GAAE;4BACxB,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AQ,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"]}
|
package/methods/ai-terminal.d.ts
CHANGED
|
@@ -3,11 +3,12 @@ export type AiAssistantMongoReadInput = {
|
|
|
3
3
|
collection?: string;
|
|
4
4
|
query?: Record<string, any>;
|
|
5
5
|
options?: {
|
|
6
|
-
projection?: Record<string, number>;
|
|
6
|
+
projection?: Record<string, number | boolean>;
|
|
7
7
|
sort?: Record<string, any>;
|
|
8
8
|
limit?: number;
|
|
9
9
|
skip?: number;
|
|
10
10
|
includeTotal?: boolean;
|
|
11
|
+
includeIds?: boolean;
|
|
11
12
|
};
|
|
12
13
|
permissionView?: string;
|
|
13
14
|
id_client?: string;
|
|
@@ -27,6 +28,7 @@ export type AiAssistantMongoAggregateInput = {
|
|
|
27
28
|
allowDiskUse?: boolean;
|
|
28
29
|
maxTimeMS?: number;
|
|
29
30
|
limit?: number;
|
|
31
|
+
includeIds?: boolean;
|
|
30
32
|
};
|
|
31
33
|
permissionView?: string;
|
|
32
34
|
id_client?: string;
|
|
@@ -37,6 +39,31 @@ export type AiAssistantMongoAggregateInput = {
|
|
|
37
39
|
readonly?: boolean;
|
|
38
40
|
};
|
|
39
41
|
};
|
|
42
|
+
type AiAssistantDisplayTable = {
|
|
43
|
+
columns: string[];
|
|
44
|
+
rows: Array<Record<string, any>>;
|
|
45
|
+
rowCount: number;
|
|
46
|
+
total?: number | null;
|
|
47
|
+
truncated?: boolean;
|
|
48
|
+
includeIds?: boolean;
|
|
49
|
+
};
|
|
50
|
+
type AssistantMongoDirective = {
|
|
51
|
+
type: 'read' | 'aggregate';
|
|
52
|
+
payload: Record<string, any> | null;
|
|
53
|
+
cleaned: string;
|
|
54
|
+
rawLine: string;
|
|
55
|
+
};
|
|
40
56
|
export declare function loadAiTerminalMethods(methodManager: any): void;
|
|
41
57
|
export declare function executeAiAssistantMongoRead(payload: AiAssistantMongoReadInput, context: any): Promise<any>;
|
|
42
58
|
export declare function executeAiAssistantMongoAggregate(payload: AiAssistantMongoAggregateInput, context: any): Promise<any>;
|
|
59
|
+
export declare function extractAssistantMongoDirective(content: string): AssistantMongoDirective | null;
|
|
60
|
+
export declare function serializeMongoValue(value: any, maxLength?: number): string | number | boolean | null;
|
|
61
|
+
export declare function flattenForTable(doc: any): Record<string, any>;
|
|
62
|
+
export declare function buildDisplayTable(docs: any[], options?: {
|
|
63
|
+
maxColumns?: number;
|
|
64
|
+
maxRows?: number;
|
|
65
|
+
includeIds?: boolean;
|
|
66
|
+
priorityFields?: string[];
|
|
67
|
+
}): AiAssistantDisplayTable;
|
|
68
|
+
export declare function formatDisplayTableMarkdown(display: AiAssistantDisplayTable): string;
|
|
69
|
+
export {};
|