@resolveio/server-lib 22.1.24 → 22.1.25
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/collections/ai-terminal-conversation.collection.js +9 -2
- package/collections/ai-terminal-conversation.collection.js.map +1 -1
- package/collections/notification.collection.js.map +1 -1
- package/managers/local-log.manager.js +12 -3
- package/managers/local-log.manager.js.map +1 -1
- package/methods/ai-terminal.js +105 -39
- package/methods/ai-terminal.js.map +1 -1
- package/models/ai-terminal-conversation.model.d.ts +1 -0
- package/models/ai-terminal-conversation.model.js.map +1 -1
- package/package.json +1 -3
- package/publications/ai-terminal.js +67 -3
- package/publications/ai-terminal.js.map +1 -1
|
@@ -3,6 +3,7 @@ export type AiTerminalMode = 'openai' | 'codex';
|
|
|
3
3
|
export type AiTerminalConversationStatus = 'active' | 'archived';
|
|
4
4
|
export interface AiTerminalConversationModel extends CollectionDocument {
|
|
5
5
|
id_client?: string;
|
|
6
|
+
id_user?: string;
|
|
6
7
|
id_app?: string;
|
|
7
8
|
title?: string;
|
|
8
9
|
mode?: AiTerminalMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/models/ai-terminal-conversation.model.ts"],"names":[],"mappings":"","file":"ai-terminal-conversation.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport type AiTerminalMode = 'openai' | 'codex';\nexport type AiTerminalConversationStatus = 'active' | 'archived';\n\nexport interface AiTerminalConversationModel extends CollectionDocument {\n\tid_client?: string;\n\tid_app?: string;\n\ttitle?: string;\n\tmode?: AiTerminalMode;\n\tbranch_enabled?: boolean;\n\tbranch_name?: string;\n\tstatus?: AiTerminalConversationStatus;\n\tprofile_id?: string;\n\tmetadata?: Record<string, any>;\n\tlast_message_at?: Date;\n\tlast_message_id?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/models/ai-terminal-conversation.model.ts"],"names":[],"mappings":"","file":"ai-terminal-conversation.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport type AiTerminalMode = 'openai' | 'codex';\nexport type AiTerminalConversationStatus = 'active' | 'archived';\n\nexport interface AiTerminalConversationModel extends CollectionDocument {\n\tid_client?: string;\n\tid_user?: string;\n\tid_app?: string;\n\ttitle?: string;\n\tmode?: AiTerminalMode;\n\tbranch_enabled?: boolean;\n\tbranch_name?: string;\n\tstatus?: AiTerminalConversationStatus;\n\tprofile_id?: string;\n\tmetadata?: Record<string, any>;\n\tlast_message_at?: Date;\n\tlast_message_id?: string;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resolveio/server-lib",
|
|
3
|
-
"version": "22.1.
|
|
3
|
+
"version": "22.1.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"package": "./build_package.sh",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"axios": "1.13.2",
|
|
38
38
|
"clone": "2.1.2",
|
|
39
39
|
"cron": "4.3.3",
|
|
40
|
-
"crypto": "1.0.1",
|
|
41
40
|
"deep-diff": "1.0.2",
|
|
42
41
|
"deep-object-diff": "1.1.9",
|
|
43
42
|
"exceljs": "4.4.0",
|
|
@@ -103,7 +102,6 @@
|
|
|
103
102
|
"body-parser": "2.2.0",
|
|
104
103
|
"clone": "2.1.2",
|
|
105
104
|
"cron": "4.3.3",
|
|
106
|
-
"crypto": "1.0.1",
|
|
107
105
|
"deep-diff": "1.0.2",
|
|
108
106
|
"deep-object-diff": "1.1.9",
|
|
109
107
|
"exceljs": "4.4.0",
|
|
@@ -1,4 +1,40 @@
|
|
|
1
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["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
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.loadAiTerminalPublications = loadAiTerminalPublications;
|
|
4
40
|
var simpl_schema_1 = require("simpl-schema");
|
|
@@ -8,7 +44,13 @@ function loadAiTerminalPublications(subscriptionManager) {
|
|
|
8
44
|
subscriptionManager.publications({
|
|
9
45
|
aiTerminalConversations: {
|
|
10
46
|
function: function (id_client, id_app, status) {
|
|
11
|
-
var
|
|
47
|
+
var idUser = normalizeOptionalString((this === null || this === void 0 ? void 0 : this.id_user) || '');
|
|
48
|
+
if (!idUser) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
var query = {
|
|
52
|
+
id_user: idUser
|
|
53
|
+
};
|
|
12
54
|
if (id_client) {
|
|
13
55
|
query.id_client = id_client;
|
|
14
56
|
}
|
|
@@ -38,8 +80,26 @@ function loadAiTerminalPublications(subscriptionManager) {
|
|
|
38
80
|
},
|
|
39
81
|
aiTerminalMessages: {
|
|
40
82
|
function: function (id_conversation, limit) {
|
|
41
|
-
|
|
42
|
-
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
var idUser, conversation, limitValue;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
idUser = normalizeOptionalString((this === null || this === void 0 ? void 0 : this.id_user) || '');
|
|
89
|
+
if (!idUser) {
|
|
90
|
+
return [2 /*return*/, []];
|
|
91
|
+
}
|
|
92
|
+
return [4 /*yield*/, ai_terminal_conversation_collection_1.AiTerminalConversations.findById(id_conversation)];
|
|
93
|
+
case 1:
|
|
94
|
+
conversation = _a.sent();
|
|
95
|
+
if (!conversation || normalizeOptionalString(conversation.id_user) !== idUser) {
|
|
96
|
+
return [2 /*return*/, []];
|
|
97
|
+
}
|
|
98
|
+
limitValue = Number.isFinite(Number(limit)) ? Math.min(Math.max(Number(limit), 1), 400) : 200;
|
|
99
|
+
return [2 /*return*/, ai_terminal_message_collection_1.AiTerminalMessages.find({ id_conversation: id_conversation }, { sort: { createdAt: 1 }, limit: limitValue })];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
43
103
|
},
|
|
44
104
|
check: new simpl_schema_1.default({
|
|
45
105
|
id_conversation: {
|
|
@@ -54,5 +114,9 @@ function loadAiTerminalPublications(subscriptionManager) {
|
|
|
54
114
|
}
|
|
55
115
|
});
|
|
56
116
|
}
|
|
117
|
+
function normalizeOptionalString(value) {
|
|
118
|
+
var raw = typeof value === 'string' ? value.trim() : '';
|
|
119
|
+
return raw || '';
|
|
120
|
+
}
|
|
57
121
|
|
|
58
122
|
//# sourceMappingURL=ai-terminal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/publications/ai-terminal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/publications/ai-terminal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,gEA+DC;AAnED,6CAAwC;AACxC,0GAA6F;AAC7F,gGAAmF;AAEnF,SAAgB,0BAA0B,CAAC,mBAAmB;IAC7D,mBAAmB,CAAC,YAAY,CAAC;QAChC,uBAAuB,EAAE;YACxB,QAAQ,EAAE,UAAS,SAAkB,EAAE,MAAe,EAAE,MAAe;gBACtE,IAAM,MAAM,GAAG,uBAAuB,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,KAAI,EAAE,CAAC,CAAC;gBAC5D,IAAI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AI,uBAAuB,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;oCAC/E,sBAAO,EAAE,EAAC;gCACX,CAAC;gCACK,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;gCACpG,sBAAO,mDAAkB,CAAC,IAAI,CAAC,EAAE,eAAe,iBAAA,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAC;;;;aACnG;YACD,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,eAAe,EAAE;oBAChB,IAAI,EAAE,MAAM;iBACZ;gBACD,KAAK,EAAE;oBACN,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,IAAI;iBACd;aACD,CAAC;YACF,WAAW,EAAE,CAAC,sBAAsB,CAAC;SACrC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAU;IAC1C,IAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,OAAO,GAAG,IAAI,EAAE,CAAC;AAClB,CAAC","file":"ai-terminal.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { AiTerminalConversations } from '../collections/ai-terminal-conversation.collection';\nimport { AiTerminalMessages } from '../collections/ai-terminal-message.collection';\n\nexport function loadAiTerminalPublications(subscriptionManager) {\n\tsubscriptionManager.publications({\n\t\taiTerminalConversations: {\n\t\t\tfunction: function(id_client?: string, id_app?: string, status?: string) {\n\t\t\t\tconst idUser = normalizeOptionalString(this?.id_user || '');\n\t\t\t\tif (!idUser) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst query: any = {\n\t\t\t\t\tid_user: idUser\n\t\t\t\t};\n\t\t\t\tif (id_client) {\n\t\t\t\t\tquery.id_client = id_client;\n\t\t\t\t}\n\t\t\t\tif (id_app) {\n\t\t\t\t\tquery.id_app = id_app;\n\t\t\t\t}\n\t\t\t\tif (status) {\n\t\t\t\t\tquery.status = status;\n\t\t\t\t}\n\t\t\t\treturn AiTerminalConversations.find(query, { sort: { updatedAt: -1 }, limit: 200 });\n\t\t\t},\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_client: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\toptional: true\n\t\t\t\t},\n\t\t\t\tid_app: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\toptional: true\n\t\t\t\t},\n\t\t\t\tstatus: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tcollections: ['ai-terminal-conversations']\n\t\t},\n\t\taiTerminalMessages: {\n\t\t\tfunction: async function(id_conversation: string, limit?: number) {\n\t\t\t\tconst idUser = normalizeOptionalString(this?.id_user || '');\n\t\t\t\tif (!idUser) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst conversation = await AiTerminalConversations.findById(id_conversation);\n\t\t\t\tif (!conversation || normalizeOptionalString(conversation.id_user) !== idUser) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst limitValue = Number.isFinite(Number(limit)) ? Math.min(Math.max(Number(limit), 1), 400) : 200;\n\t\t\t\treturn AiTerminalMessages.find({ id_conversation }, { sort: { createdAt: 1 }, limit: limitValue });\n\t\t\t},\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_conversation: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tlimit: {\n\t\t\t\t\ttype: Number,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tcollections: ['ai-terminal-messages']\n\t\t}\n\t});\n}\n\nfunction normalizeOptionalString(value: any): string {\n\tconst raw = typeof value === 'string' ? value.trim() : '';\n\treturn raw || '';\n}\n"]}
|