@memberjunction/core-entities 5.22.0 → 5.24.0
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/dist/custom/MJUserViewEntityExtended.d.ts +4 -314
- package/dist/custom/MJUserViewEntityExtended.d.ts.map +1 -1
- package/dist/custom/MJUserViewEntityExtended.js +5 -5
- package/dist/custom/MJUserViewEntityExtended.js.map +1 -1
- package/dist/engines/conversations.d.ts +439 -0
- package/dist/engines/conversations.d.ts.map +1 -0
- package/dist/engines/conversations.js +1102 -0
- package/dist/engines/conversations.js.map +1 -0
- package/dist/engines/knowledgeHubMetadata.d.ts +49 -0
- package/dist/engines/knowledgeHubMetadata.d.ts.map +1 -0
- package/dist/engines/knowledgeHubMetadata.js +135 -0
- package/dist/engines/knowledgeHubMetadata.js.map +1 -0
- package/dist/generated/entity_subclasses.d.ts +2681 -89
- package/dist/generated/entity_subclasses.d.ts.map +1 -1
- package/dist/generated/entity_subclasses.js +3340 -280
- package/dist/generated/entity_subclasses.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/readme.md +73 -1
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { BaseEngine, BaseEntityEvent, IMetadataProvider, UserInfo } from "@memberjunction/core";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { MJConversationEntity, MJConversationDetailEntity, MJConversationDetailEntityType, MJAIAgentRunEntity, MJAIAgentRunEntityType, MJConversationDetailRatingEntityType, MJConversationDetailArtifactEntityType } from "../generated/entity_subclasses.js";
|
|
4
|
+
/**
|
|
5
|
+
* Agent Run data returned as JSON from GetConversationComplete query.
|
|
6
|
+
*/
|
|
7
|
+
export type AgentRunJSON = MJAIAgentRunEntityType & {
|
|
8
|
+
Agent: string | null;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Artifact data returned as JSON from GetConversationComplete query.
|
|
12
|
+
*/
|
|
13
|
+
export type ArtifactJSON = MJConversationDetailArtifactEntityType & {
|
|
14
|
+
ArtifactVersionID: string;
|
|
15
|
+
VersionNumber: number;
|
|
16
|
+
VersionName: string | null;
|
|
17
|
+
VersionDescription: string | null;
|
|
18
|
+
VersionCreatedAt: Date;
|
|
19
|
+
ArtifactID: string;
|
|
20
|
+
ArtifactName: string;
|
|
21
|
+
ArtifactType: string;
|
|
22
|
+
ArtifactDescription: string | null;
|
|
23
|
+
Visibility: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Rating data returned as JSON from GetConversationComplete query.
|
|
27
|
+
*/
|
|
28
|
+
export type RatingJSON = MJConversationDetailRatingEntityType & {
|
|
29
|
+
UserName: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Raw query result row from GetConversationComplete (before JSON parsing).
|
|
33
|
+
*/
|
|
34
|
+
export type ConversationDetailComplete = MJConversationDetailEntityType & {
|
|
35
|
+
AgentRunsJSON: string | null;
|
|
36
|
+
ArtifactsJSON: string | null;
|
|
37
|
+
RatingsJSON: string | null;
|
|
38
|
+
UserImageURL: string | null;
|
|
39
|
+
UserImageIconClass: string | null;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Parsed conversation detail with typed related data.
|
|
43
|
+
*/
|
|
44
|
+
export interface ConversationDetailParsed extends MJConversationDetailEntityType {
|
|
45
|
+
agentRuns: AgentRunJSON[];
|
|
46
|
+
artifacts: ArtifactJSON[];
|
|
47
|
+
ratings: RatingJSON[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Helper: parse a raw ConversationDetailComplete row into typed arrays.
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseConversationDetailComplete(queryResult: ConversationDetailComplete): ConversationDetailParsed;
|
|
53
|
+
/** User avatar info extracted from the query */
|
|
54
|
+
export interface UserAvatarInfo {
|
|
55
|
+
ImageURL: string | null;
|
|
56
|
+
IconClass: string | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Cached data for a single conversation's details (messages) and peripheral data.
|
|
60
|
+
* Populated by the efficient GetConversationComplete query in one round-trip.
|
|
61
|
+
*/
|
|
62
|
+
export interface ConversationDetailCache {
|
|
63
|
+
/** The conversation detail (message) entities */
|
|
64
|
+
Details: MJConversationDetailEntity[];
|
|
65
|
+
/** Raw query result rows (used for peripheral data parsing) */
|
|
66
|
+
RawData: ConversationDetailComplete[];
|
|
67
|
+
/** Agent runs keyed by conversation detail ID */
|
|
68
|
+
AgentRunsByDetailId: Map<string, MJAIAgentRunEntity>;
|
|
69
|
+
/** User avatars keyed by UserID */
|
|
70
|
+
UserAvatars: Map<string, UserAvatarInfo>;
|
|
71
|
+
/** Ratings keyed by conversation detail ID */
|
|
72
|
+
RatingsByDetailId: Map<string, RatingJSON[]>;
|
|
73
|
+
/** Parsed artifacts keyed by conversation detail ID */
|
|
74
|
+
ArtifactsByDetailId: Map<string, ArtifactJSON[]>;
|
|
75
|
+
/** Timestamp of when this cache entry was populated */
|
|
76
|
+
LoadedAt: Date;
|
|
77
|
+
/**
|
|
78
|
+
* When true, peripheral data (artifacts/ratings) has changed externally and
|
|
79
|
+
* needs to be re-fetched via a full query reload. Set by entity event handlers
|
|
80
|
+
* for junction entities whose joined fields can't be reconstructed from events alone.
|
|
81
|
+
*/
|
|
82
|
+
PeripheralDataStale: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* ConversationEngine provides centralized, reactive caching for conversations,
|
|
86
|
+
* conversation details (messages), and peripheral data (agent runs, artifacts).
|
|
87
|
+
*
|
|
88
|
+
* This engine is the single source of truth for conversation data across all UI
|
|
89
|
+
* consumers (chat area, sidebar, overlay, etc.). It replaces per-component caching
|
|
90
|
+
* that previously lived in conversation-chat-area component,
|
|
91
|
+
* and other scattered locations.
|
|
92
|
+
*
|
|
93
|
+
* Usage:
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Initialize (call once at app startup after metadata is loaded)
|
|
96
|
+
* await ConversationEngine.Instance.Config(false, contextUser);
|
|
97
|
+
*
|
|
98
|
+
* // Load conversations for the current user
|
|
99
|
+
* await ConversationEngine.Instance.LoadConversations('env-id', contextUser);
|
|
100
|
+
*
|
|
101
|
+
* // Subscribe to conversation list changes
|
|
102
|
+
* ConversationEngine.Instance.Conversations$.subscribe(conversations => {
|
|
103
|
+
* // React to changes
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* // Load details for a specific conversation
|
|
107
|
+
* const details = await ConversationEngine.Instance.LoadConversationDetails('conv-id', contextUser);
|
|
108
|
+
*
|
|
109
|
+
* // Get cached details (instant, no DB round-trip)
|
|
110
|
+
* const cached = ConversationEngine.Instance.GetCachedDetails('conv-id');
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare class ConversationEngine extends BaseEngine<ConversationEngine> {
|
|
114
|
+
/**
|
|
115
|
+
* Returns the global instance of the class. This is a singleton class, so there is only
|
|
116
|
+
* one instance of it in the application. Do not directly create new instances of it,
|
|
117
|
+
* always use this method to get the instance.
|
|
118
|
+
*/
|
|
119
|
+
static get Instance(): ConversationEngine;
|
|
120
|
+
private _conversations$;
|
|
121
|
+
/**
|
|
122
|
+
* Observable stream of the current user's conversation list.
|
|
123
|
+
* Emits whenever conversations are loaded, created, deleted, archived, or pinned.
|
|
124
|
+
*/
|
|
125
|
+
get Conversations$(): Observable<MJConversationEntity[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Current snapshot of conversations (non-reactive).
|
|
128
|
+
*/
|
|
129
|
+
get Conversations(): MJConversationEntity[];
|
|
130
|
+
/** Detail cache keyed by normalized conversation ID */
|
|
131
|
+
private _detailCache;
|
|
132
|
+
/** Track the environment ID used for the last load */
|
|
133
|
+
private _lastEnvironmentId;
|
|
134
|
+
/**
|
|
135
|
+
* Guard flag: set true while the engine itself is performing a mutation.
|
|
136
|
+
* Prevents the entity event handler from re-processing our own saves/deletes,
|
|
137
|
+
* which would cause redundant cache updates or infinite loops.
|
|
138
|
+
*/
|
|
139
|
+
private _selfMutating;
|
|
140
|
+
/**
|
|
141
|
+
* Configures the engine. Unlike other engines that bulk-load entity tables via BaseEngine.Load(),
|
|
142
|
+
* ConversationEngine manages its own caching because conversations are user-scoped and filtered
|
|
143
|
+
* by environment, which doesn't fit the standard "load all rows" pattern.
|
|
144
|
+
*
|
|
145
|
+
* Call this once at startup to initialize the engine. Conversation data is loaded
|
|
146
|
+
* separately via LoadConversations().
|
|
147
|
+
*/
|
|
148
|
+
Config(forceRefresh?: boolean, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Loads conversations from the database for the given user and environment.
|
|
151
|
+
* Results are cached and emitted via Conversations$.
|
|
152
|
+
*
|
|
153
|
+
* @param environmentId - The environment to filter conversations by
|
|
154
|
+
* @param contextUser - The current user context
|
|
155
|
+
* @param forceRefresh - If true, reloads even if data is already cached
|
|
156
|
+
*/
|
|
157
|
+
LoadConversations(environmentId: string, contextUser: UserInfo, forceRefresh?: boolean): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Creates a new conversation, saves it to the database, and adds it to the cached list.
|
|
160
|
+
*
|
|
161
|
+
* @param name - Display name for the conversation
|
|
162
|
+
* @param environmentId - The environment ID
|
|
163
|
+
* @param contextUser - The current user context
|
|
164
|
+
* @param description - Optional description
|
|
165
|
+
* @param projectId - Optional project ID
|
|
166
|
+
* @returns The newly created conversation entity
|
|
167
|
+
* @throws Error if save fails
|
|
168
|
+
*/
|
|
169
|
+
CreateConversation(name: string, environmentId: string, contextUser: UserInfo, description?: string, projectId?: string): Promise<MJConversationEntity>;
|
|
170
|
+
/**
|
|
171
|
+
* Deletes a conversation from the database and removes it from the cached list.
|
|
172
|
+
*
|
|
173
|
+
* @param id - The conversation ID to delete
|
|
174
|
+
* @param contextUser - The current user context
|
|
175
|
+
* @returns true if successful
|
|
176
|
+
* @throws Error if conversation not found or delete fails
|
|
177
|
+
*/
|
|
178
|
+
DeleteConversation(id: string, contextUser: UserInfo): Promise<boolean>;
|
|
179
|
+
/**
|
|
180
|
+
* Archives a conversation (sets IsArchived = true) and removes it from the active list.
|
|
181
|
+
*
|
|
182
|
+
* @param id - The conversation ID to archive
|
|
183
|
+
* @param contextUser - The current user context
|
|
184
|
+
* @returns true if successful
|
|
185
|
+
*/
|
|
186
|
+
ArchiveConversation(id: string, contextUser: UserInfo): Promise<boolean>;
|
|
187
|
+
/**
|
|
188
|
+
* Toggles or sets the pinned status of a conversation.
|
|
189
|
+
*
|
|
190
|
+
* @param id - The conversation ID
|
|
191
|
+
* @param isPinned - Whether the conversation should be pinned
|
|
192
|
+
* @param contextUser - The current user context
|
|
193
|
+
* @returns true if successful
|
|
194
|
+
*/
|
|
195
|
+
PinConversation(id: string, isPinned: boolean, contextUser: UserInfo): Promise<boolean>;
|
|
196
|
+
/**
|
|
197
|
+
* Finds a conversation by ID in the cached list.
|
|
198
|
+
*
|
|
199
|
+
* @param id - The conversation ID to find
|
|
200
|
+
* @returns The conversation entity, or undefined if not in cache
|
|
201
|
+
*/
|
|
202
|
+
GetConversation(id: string): MJConversationEntity | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Saves partial updates to a conversation (Name, Description, or any writable field).
|
|
205
|
+
* Loads the entity from DB, applies updates, saves, and updates the in-memory list.
|
|
206
|
+
*
|
|
207
|
+
* @param id - The conversation ID to update
|
|
208
|
+
* @param updates - Partial fields to update
|
|
209
|
+
* @param contextUser - The current user context
|
|
210
|
+
* @returns true if saved successfully
|
|
211
|
+
* @throws Error if conversation not found or save fails
|
|
212
|
+
*/
|
|
213
|
+
SaveConversation(id: string, updates: Partial<MJConversationEntity>, contextUser: UserInfo): Promise<boolean>;
|
|
214
|
+
/**
|
|
215
|
+
* Deletes multiple conversations in a batch operation with per-item error tracking.
|
|
216
|
+
*
|
|
217
|
+
* @param ids - Array of conversation IDs to delete
|
|
218
|
+
* @param contextUser - The current user context
|
|
219
|
+
* @returns Object with successful and failed deletions
|
|
220
|
+
*/
|
|
221
|
+
DeleteMultipleConversations(ids: string[], contextUser: UserInfo): Promise<{
|
|
222
|
+
Successful: string[];
|
|
223
|
+
Failed: Array<{
|
|
224
|
+
ID: string;
|
|
225
|
+
Name: string;
|
|
226
|
+
Error: string;
|
|
227
|
+
}>;
|
|
228
|
+
}>;
|
|
229
|
+
/**
|
|
230
|
+
* Loads conversation details (messages) for a specific conversation.
|
|
231
|
+
* Results are cached for instant retrieval on subsequent calls.
|
|
232
|
+
*
|
|
233
|
+
* @param conversationId - The conversation to load details for
|
|
234
|
+
* @param contextUser - The current user context
|
|
235
|
+
* @param forceRefresh - If true, reloads even if cached
|
|
236
|
+
* @returns Array of conversation detail entities
|
|
237
|
+
*/
|
|
238
|
+
/**
|
|
239
|
+
* Loads conversation details using the efficient GetConversationComplete query
|
|
240
|
+
* which returns messages, agent runs, artifacts, ratings, and user avatars in one round-trip.
|
|
241
|
+
* Results are cached for instant retrieval on subsequent calls.
|
|
242
|
+
*
|
|
243
|
+
* @param conversationId - The conversation to load details for
|
|
244
|
+
* @param contextUser - The current user context
|
|
245
|
+
* @param forceRefresh - If true, reloads even if cached
|
|
246
|
+
* @returns The full cache entry with all peripheral data
|
|
247
|
+
*/
|
|
248
|
+
LoadConversationDetails(conversationId: string, contextUser: UserInfo, forceRefresh?: boolean): Promise<ConversationDetailCache>;
|
|
249
|
+
/**
|
|
250
|
+
* Builds a full ConversationDetailCache from raw GetConversationComplete query results.
|
|
251
|
+
* Hydrates entity objects and parses peripheral JSON data in one pass.
|
|
252
|
+
*/
|
|
253
|
+
private buildDetailCacheFromRawData;
|
|
254
|
+
/**
|
|
255
|
+
* Refreshes conversation details by re-running the GetConversationComplete query
|
|
256
|
+
* and surgically merging results into the existing cache. Existing objects that
|
|
257
|
+
* haven't changed keep their references (minimizing Angular re-renders).
|
|
258
|
+
*
|
|
259
|
+
* - New messages: appended to Details array
|
|
260
|
+
* - Existing messages: fields updated in-place on the same object
|
|
261
|
+
* - Agent runs: updated in-place or added
|
|
262
|
+
* - Artifacts/ratings: replaced per-detail (cheap — plain data, not entity objects)
|
|
263
|
+
* - User avatars: merged (new users added)
|
|
264
|
+
*
|
|
265
|
+
* If no cache exists yet, falls back to a full load.
|
|
266
|
+
*
|
|
267
|
+
* @param conversationId - The conversation to refresh
|
|
268
|
+
* @param contextUser - The current user context
|
|
269
|
+
* @returns The updated cache entry
|
|
270
|
+
*/
|
|
271
|
+
RefreshConversationDetails(conversationId: string, contextUser: UserInfo): Promise<ConversationDetailCache>;
|
|
272
|
+
/**
|
|
273
|
+
* Returns cached conversation details (messages only) without hitting the database.
|
|
274
|
+
* Returns undefined if no cache entry exists for this conversation.
|
|
275
|
+
*
|
|
276
|
+
* @param conversationId - The conversation ID
|
|
277
|
+
* @returns Cached message entities, or undefined if not cached
|
|
278
|
+
*/
|
|
279
|
+
GetCachedDetails(conversationId: string): MJConversationDetailEntity[] | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* Returns the full cache entry for a conversation, including all peripheral data
|
|
282
|
+
* (agent runs, artifacts, ratings, user avatars). Returns undefined if not cached.
|
|
283
|
+
*
|
|
284
|
+
* This is the primary read method for UI components — returns instant cached data
|
|
285
|
+
* without any database round-trip.
|
|
286
|
+
*
|
|
287
|
+
* @param conversationId - The conversation ID
|
|
288
|
+
* @returns The full cache entry, or undefined
|
|
289
|
+
*/
|
|
290
|
+
GetCachedDetailEntry(conversationId: string): ConversationDetailCache | undefined;
|
|
291
|
+
/**
|
|
292
|
+
* Returns true if conversation details are cached for the given conversation.
|
|
293
|
+
*/
|
|
294
|
+
HasCachedDetails(conversationId: string): boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Adds a detail (message) to the cached list for a conversation.
|
|
297
|
+
* If no cache entry exists, this is a no-op (caller should LoadConversationDetails first).
|
|
298
|
+
*
|
|
299
|
+
* @param conversationId - The conversation this detail belongs to
|
|
300
|
+
* @param detail - The detail entity to add
|
|
301
|
+
*/
|
|
302
|
+
AddDetailToCache(conversationId: string, detail: MJConversationDetailEntity): void;
|
|
303
|
+
/**
|
|
304
|
+
* Updates a detail entity in the cache. Finds by ID and replaces.
|
|
305
|
+
* If the detail is not in cache, this is a no-op.
|
|
306
|
+
*
|
|
307
|
+
* @param conversationId - The conversation this detail belongs to
|
|
308
|
+
* @param detail - The updated detail entity
|
|
309
|
+
*/
|
|
310
|
+
UpdateDetailInCache(conversationId: string, detail: MJConversationDetailEntity): void;
|
|
311
|
+
/**
|
|
312
|
+
* Gets the cached agent run for a specific conversation detail.
|
|
313
|
+
*
|
|
314
|
+
* @param conversationId - The conversation ID
|
|
315
|
+
* @param detailId - The conversation detail ID
|
|
316
|
+
* @returns The agent run entity, or undefined if not cached
|
|
317
|
+
*/
|
|
318
|
+
GetAgentRunForDetail(conversationId: string, detailId: string): MJAIAgentRunEntity | undefined;
|
|
319
|
+
/**
|
|
320
|
+
* Gets all cached agent runs for a conversation, keyed by detail ID.
|
|
321
|
+
*
|
|
322
|
+
* @param conversationId - The conversation ID
|
|
323
|
+
* @returns Map of detail ID to agent run, or empty map if not cached
|
|
324
|
+
*/
|
|
325
|
+
GetAgentRunsMap(conversationId: string): Map<string, MJAIAgentRunEntity>;
|
|
326
|
+
/**
|
|
327
|
+
* Adds or updates an agent run in the cache for a specific detail.
|
|
328
|
+
*
|
|
329
|
+
* @param conversationId - The conversation ID
|
|
330
|
+
* @param detailId - The detail ID the agent run is associated with
|
|
331
|
+
* @param agentRun - The agent run entity
|
|
332
|
+
*/
|
|
333
|
+
SetAgentRunForDetail(conversationId: string, detailId: string, agentRun: MJAIAgentRunEntity): void;
|
|
334
|
+
/**
|
|
335
|
+
* Invalidates (removes) the cached details for a specific conversation.
|
|
336
|
+
* The next call to LoadConversationDetails will fetch fresh data.
|
|
337
|
+
*
|
|
338
|
+
* @param conversationId - The conversation ID to invalidate
|
|
339
|
+
*/
|
|
340
|
+
InvalidateConversation(conversationId: string): void;
|
|
341
|
+
/**
|
|
342
|
+
* Clears all cached data: conversations, details, and peripheral data.
|
|
343
|
+
* Typically called on logout or environment switch.
|
|
344
|
+
*/
|
|
345
|
+
ClearCache(): void;
|
|
346
|
+
/**
|
|
347
|
+
* Creates a new conversation detail (message), saves it, and adds it to the cache.
|
|
348
|
+
*
|
|
349
|
+
* @param conversationId - The conversation this detail belongs to
|
|
350
|
+
* @param role - The message role ('User', 'AI', 'System')
|
|
351
|
+
* @param message - The message content
|
|
352
|
+
* @param contextUser - The current user context
|
|
353
|
+
* @param additionalFields - Optional extra fields to set on the entity
|
|
354
|
+
* @returns The saved conversation detail entity
|
|
355
|
+
*/
|
|
356
|
+
CreateConversationDetail(conversationId: string, role: MJConversationDetailEntity['Role'], message: string, contextUser: UserInfo, additionalFields?: Partial<MJConversationDetailEntity>): Promise<MJConversationDetailEntity>;
|
|
357
|
+
/**
|
|
358
|
+
* Saves an existing conversation detail entity and updates the cache.
|
|
359
|
+
* Use this instead of calling detail.Save() directly to keep the engine cache in sync.
|
|
360
|
+
*
|
|
361
|
+
* @param detail - The conversation detail entity to save (must already be loaded)
|
|
362
|
+
* @returns true if saved successfully
|
|
363
|
+
*/
|
|
364
|
+
SaveConversationDetail(detail: MJConversationDetailEntity): Promise<boolean>;
|
|
365
|
+
/**
|
|
366
|
+
* Deletes a conversation detail and removes it from the cache.
|
|
367
|
+
*
|
|
368
|
+
* @param conversationId - The conversation this detail belongs to
|
|
369
|
+
* @param detailId - The detail ID to delete
|
|
370
|
+
* @param contextUser - The current user context
|
|
371
|
+
* @returns true if deleted successfully
|
|
372
|
+
*/
|
|
373
|
+
DeleteConversationDetail(conversationId: string, detailId: string, contextUser: UserInfo): Promise<boolean>;
|
|
374
|
+
/**
|
|
375
|
+
* Overrides BaseEngine's entity event handler to watch for external mutations
|
|
376
|
+
* to Conversations and Conversation Details. When another piece of code (outside
|
|
377
|
+
* this engine) saves or deletes these entities, we sync our cache.
|
|
378
|
+
*
|
|
379
|
+
* The _selfMutating guard prevents processing events from our own mutations.
|
|
380
|
+
*/
|
|
381
|
+
protected HandleIndividualBaseEntityEvent(event: BaseEntityEvent): Promise<boolean>;
|
|
382
|
+
/**
|
|
383
|
+
* Extracts record data from a BaseEntityEvent.
|
|
384
|
+
* For local events: uses baseEntity directly.
|
|
385
|
+
* For remote-invalidate events: parses recordData JSON from the payload.
|
|
386
|
+
* Returns null if no data is available.
|
|
387
|
+
*/
|
|
388
|
+
private extractRecordData;
|
|
389
|
+
/**
|
|
390
|
+
* Safely merges data onto a target object that may or may not be a BaseEntity.
|
|
391
|
+
* If the target has SetMany (i.e., it's a BaseEntity), uses that to properly handle
|
|
392
|
+
* read-only fields like __mj_CreatedAt. Otherwise falls back to Object.assign.
|
|
393
|
+
*/
|
|
394
|
+
private mergeDataOntoRecord;
|
|
395
|
+
/**
|
|
396
|
+
* Handles save/delete events on Conversation entities from local or remote code.
|
|
397
|
+
*/
|
|
398
|
+
private handleConversationEntityEvent;
|
|
399
|
+
/**
|
|
400
|
+
* Handles save/delete events on ConversationDetail entities from local or remote code.
|
|
401
|
+
*/
|
|
402
|
+
private handleConversationDetailEntityEvent;
|
|
403
|
+
/**
|
|
404
|
+
* Handles save/delete events on AI Agent Run entities from local or remote code.
|
|
405
|
+
* Updates the AgentRunsByDetailId map so timers and status reflect reality.
|
|
406
|
+
*/
|
|
407
|
+
private handleAgentRunEntityEvent;
|
|
408
|
+
/**
|
|
409
|
+
* Handles save/delete events on junction entities (Conversation Detail Artifacts,
|
|
410
|
+
* Conversation Detail Ratings) from local or remote code.
|
|
411
|
+
*
|
|
412
|
+
* These entities have joined fields (ArtifactName, UserName, etc.) that can't be
|
|
413
|
+
* reconstructed from the entity event alone, so we flag the cache as stale.
|
|
414
|
+
* The UI component checks PeripheralDataStale and force-refreshes when needed.
|
|
415
|
+
*/
|
|
416
|
+
private handlePeripheralJunctionEntityEvent;
|
|
417
|
+
/**
|
|
418
|
+
* Saves a partial update to a conversation entity.
|
|
419
|
+
*/
|
|
420
|
+
private saveConversationField;
|
|
421
|
+
/**
|
|
422
|
+
* Removes a conversation from the in-memory list and emits the updated list.
|
|
423
|
+
*/
|
|
424
|
+
private removeFromList;
|
|
425
|
+
/**
|
|
426
|
+
* Removes multiple IDs from the cached list in a single emission.
|
|
427
|
+
* Used by DeleteMultipleConversations for a smooth batch UI update.
|
|
428
|
+
*/
|
|
429
|
+
private removeMultipleFromList;
|
|
430
|
+
/**
|
|
431
|
+
* Removes the detail cache entry for a conversation.
|
|
432
|
+
*/
|
|
433
|
+
private removeDetailCache;
|
|
434
|
+
/**
|
|
435
|
+
* Sorts conversations: pinned first, then by updated date descending.
|
|
436
|
+
*/
|
|
437
|
+
private sortConversations;
|
|
438
|
+
}
|
|
439
|
+
//# sourceMappingURL=conversations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/engines/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4B,eAAe,EAAE,iBAAiB,EAAoE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE5L,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EACH,oBAAoB,EACpB,0BAA0B,EAC1B,8BAA8B,EAC9B,kBAAkB,EAClB,sBAAsB,EACtB,oCAAoC,EACpC,sCAAsC,EACzC,MAAM,gCAAgC,CAAC;AAOxC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,sBAAsB,GAAG;IAChD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,sCAAsC,GAAG;IAChE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gBAAgB,EAAE,IAAI,CAAC;IACvB,UAAU,EAAE,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