@athoscommerce/snap-store-mobx 1.5.0 → 1.5.1-beta.110
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/cjs/Autocomplete/Stores/AutocompleteFacetStore.js +2 -1
- package/dist/cjs/Chat/ChatStore.d.ts +86 -0
- package/dist/cjs/Chat/ChatStore.d.ts.map +1 -0
- package/dist/cjs/Chat/ChatStore.js +539 -0
- package/dist/cjs/Chat/Stores/ChatAttachmentStore.d.ts +98 -0
- package/dist/cjs/Chat/Stores/ChatAttachmentStore.d.ts.map +1 -0
- package/dist/cjs/Chat/Stores/ChatAttachmentStore.js +314 -0
- package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts +16 -0
- package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts.map +1 -0
- package/dist/cjs/Chat/Stores/ChatCompareStore.js +65 -0
- package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts +107 -0
- package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts.map +1 -0
- package/dist/cjs/Chat/Stores/ChatSessionStore.js +635 -0
- package/dist/cjs/Search/Stores/SearchFacetStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/SearchFacetStore.js +13 -10
- package/dist/cjs/Search/Stores/index.d.ts +1 -1
- package/dist/cjs/Search/Stores/index.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/index.js +2 -1
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/types.d.ts +21 -2
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/Autocomplete/Stores/AutocompleteFacetStore.js +1 -1
- package/dist/esm/Chat/ChatStore.d.ts +86 -0
- package/dist/esm/Chat/ChatStore.d.ts.map +1 -0
- package/dist/esm/Chat/ChatStore.js +478 -0
- package/dist/esm/Chat/Stores/ChatAttachmentStore.d.ts +98 -0
- package/dist/esm/Chat/Stores/ChatAttachmentStore.d.ts.map +1 -0
- package/dist/esm/Chat/Stores/ChatAttachmentStore.js +222 -0
- package/dist/esm/Chat/Stores/ChatCompareStore.d.ts +16 -0
- package/dist/esm/Chat/Stores/ChatCompareStore.d.ts.map +1 -0
- package/dist/esm/Chat/Stores/ChatCompareStore.js +51 -0
- package/dist/esm/Chat/Stores/ChatSessionStore.d.ts +107 -0
- package/dist/esm/Chat/Stores/ChatSessionStore.d.ts.map +1 -0
- package/dist/esm/Chat/Stores/ChatSessionStore.js +601 -0
- package/dist/esm/Search/Stores/SearchFacetStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/SearchFacetStore.js +13 -10
- package/dist/esm/Search/Stores/index.d.ts +1 -1
- package/dist/esm/Search/Stores/index.d.ts.map +1 -1
- package/dist/esm/Search/Stores/index.js +1 -1
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/types.d.ts +21 -2
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
// TODO: implement
|
|
2
|
+
// how should localStorage be handled for attachments?
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
import { makeObservable, observable, computed } from 'mobx';
|
|
5
|
+
import { CHAT_COMPARISON_MAX } from './ChatCompareStore';
|
|
6
|
+
export class ChatAttachmentStore {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.items = [];
|
|
9
|
+
makeObservable(this, {
|
|
10
|
+
items: observable,
|
|
11
|
+
attached: computed,
|
|
12
|
+
compared: computed,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
get attached() {
|
|
16
|
+
return this.items.filter((item) => item.state !== 'saved');
|
|
17
|
+
}
|
|
18
|
+
get compared() {
|
|
19
|
+
return this.items
|
|
20
|
+
.filter((item) => item.state !== 'saved')
|
|
21
|
+
.filter((item) => item.type === 'product')
|
|
22
|
+
.filter((item) => item.requestType === 'productComparison');
|
|
23
|
+
}
|
|
24
|
+
add(attachment) {
|
|
25
|
+
// TODO: check if attachment already exists
|
|
26
|
+
switch (attachment.type) {
|
|
27
|
+
case 'image': {
|
|
28
|
+
// if there are currently any other attachments remove them
|
|
29
|
+
this.items.forEach((item) => {
|
|
30
|
+
this.remove(item.id);
|
|
31
|
+
});
|
|
32
|
+
const newAttachment = new ChatAttachmentImage(attachment);
|
|
33
|
+
this.items.push(newAttachment);
|
|
34
|
+
return newAttachment;
|
|
35
|
+
}
|
|
36
|
+
case 'product': {
|
|
37
|
+
// 'productSimilar' and 'productQuery' are single-product flows — replace any
|
|
38
|
+
// existing attachments so the conversation only targets the latest product
|
|
39
|
+
if (attachment.requestType === 'productSimilar' || attachment.requestType === 'productQuery') {
|
|
40
|
+
this.items.forEach((item) => {
|
|
41
|
+
this.remove(item.id);
|
|
42
|
+
});
|
|
43
|
+
const newAttachment = new ChatAttachmentProduct(attachment);
|
|
44
|
+
this.items.unshift(newAttachment);
|
|
45
|
+
return newAttachment;
|
|
46
|
+
}
|
|
47
|
+
// For 'productQuery' or 'productComparison', continue with existing logic
|
|
48
|
+
// if there are currently any other attachments remove them
|
|
49
|
+
this.items.forEach((item) => {
|
|
50
|
+
if (item.type !== 'product') {
|
|
51
|
+
this.remove(item.id);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
// check if product is already attached
|
|
55
|
+
const existingProductAttachment = this.items.find((item) => item.type === 'product' &&
|
|
56
|
+
(item.state === 'active' || item.state === 'attached') &&
|
|
57
|
+
item.productId === attachment.productId);
|
|
58
|
+
if (existingProductAttachment) {
|
|
59
|
+
existingProductAttachment.requestType = attachment.requestType; // changes existing attachments to the incoming requestType
|
|
60
|
+
return existingProductAttachment;
|
|
61
|
+
}
|
|
62
|
+
// productComparison supports up to CHAT_COMPARISON_MAX products (matches ChatCompareStore.maxItems);
|
|
63
|
+
// trim oldest active/attached product attachments to keep total below the cap.
|
|
64
|
+
const productAttachments = this.items.filter((item) => item.type === 'product' && (item.state === 'active' || item.state === 'attached'));
|
|
65
|
+
while (productAttachments.length >= CHAT_COMPARISON_MAX) {
|
|
66
|
+
const toRemove = productAttachments.pop();
|
|
67
|
+
if (toRemove) {
|
|
68
|
+
this.remove(toRemove.id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
this.items.forEach((item) => {
|
|
72
|
+
item.requestType = attachment.requestType; // changes existing attachments to the incoming requestType
|
|
73
|
+
});
|
|
74
|
+
const newAttachment = new ChatAttachmentProduct(attachment);
|
|
75
|
+
this.items.unshift(newAttachment);
|
|
76
|
+
return newAttachment;
|
|
77
|
+
}
|
|
78
|
+
case 'facet': {
|
|
79
|
+
// if there are currently any non-facet attachments remove them
|
|
80
|
+
this.items.forEach((item) => {
|
|
81
|
+
if (item.type !== 'facet') {
|
|
82
|
+
this.remove(item.id);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
// check if this exact facet value is already attached
|
|
86
|
+
const existingFacet = this.items.find((item) => item.type === 'facet' &&
|
|
87
|
+
item.key === attachment.key &&
|
|
88
|
+
item.value === attachment.value &&
|
|
89
|
+
(item.state === 'active' || item.state === 'attached'));
|
|
90
|
+
if (existingFacet) {
|
|
91
|
+
return existingFacet;
|
|
92
|
+
}
|
|
93
|
+
const newAttachment = new ChatAttachmentFacet(attachment);
|
|
94
|
+
this.items.push(newAttachment);
|
|
95
|
+
return newAttachment;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
remove(id) {
|
|
100
|
+
const index = this.items.findIndex((item) => item.id === id);
|
|
101
|
+
const attachment = this.items[index];
|
|
102
|
+
if (attachment.state === 'active' || attachment.state === 'saved') {
|
|
103
|
+
attachment.save();
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
if (index !== -1) {
|
|
107
|
+
this.items.splice(index, 1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
get(id) {
|
|
112
|
+
return this.items.find((item) => item.id === id);
|
|
113
|
+
}
|
|
114
|
+
reset() {
|
|
115
|
+
this.items = [];
|
|
116
|
+
}
|
|
117
|
+
// Restore serialized attachments from storage without running the add() dedup logic,
|
|
118
|
+
// which would otherwise drop earlier images when multiple attachments are loaded.
|
|
119
|
+
hydrate(attachments) {
|
|
120
|
+
attachments.forEach((attachment) => {
|
|
121
|
+
switch (attachment.type) {
|
|
122
|
+
case 'image':
|
|
123
|
+
this.items.push(new ChatAttachmentImage(attachment));
|
|
124
|
+
break;
|
|
125
|
+
case 'product':
|
|
126
|
+
this.items.push(new ChatAttachmentProduct(attachment));
|
|
127
|
+
break;
|
|
128
|
+
case 'facet':
|
|
129
|
+
this.items.push(new ChatAttachmentFacet(attachment));
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
class ChatAttachment {
|
|
136
|
+
constructor(params = {}) {
|
|
137
|
+
this.state = 'loading';
|
|
138
|
+
this.error = undefined;
|
|
139
|
+
this.id = params.data?.id ?? uuidv4();
|
|
140
|
+
this.state = params.data?.state ?? 'loading';
|
|
141
|
+
makeObservable(this, {
|
|
142
|
+
id: observable,
|
|
143
|
+
state: observable,
|
|
144
|
+
error: observable,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
save() {
|
|
148
|
+
this.state = 'saved';
|
|
149
|
+
}
|
|
150
|
+
activate() {
|
|
151
|
+
this.state = 'active';
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export class ChatAttachmentProduct extends ChatAttachment {
|
|
155
|
+
constructor({ id, productId, thumbnailUrl, name, requestType, state, error }) {
|
|
156
|
+
super({ data: { id, state, error } });
|
|
157
|
+
this.type = 'product';
|
|
158
|
+
this.state = state ?? 'attached';
|
|
159
|
+
this.productId = productId;
|
|
160
|
+
this.thumbnailUrl = thumbnailUrl;
|
|
161
|
+
this.name = name;
|
|
162
|
+
this.requestType = requestType;
|
|
163
|
+
makeObservable(this, {
|
|
164
|
+
type: observable,
|
|
165
|
+
productId: observable,
|
|
166
|
+
thumbnailUrl: observable,
|
|
167
|
+
name: observable,
|
|
168
|
+
requestType: observable,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export class ChatAttachmentFacet extends ChatAttachment {
|
|
173
|
+
constructor({ id, key, facetLabel, value, label, count, state, error }) {
|
|
174
|
+
super({ data: { id, state, error } });
|
|
175
|
+
this.type = 'facet';
|
|
176
|
+
this.state = state ?? 'attached';
|
|
177
|
+
this.key = key;
|
|
178
|
+
this.facetLabel = facetLabel;
|
|
179
|
+
this.value = value;
|
|
180
|
+
this.label = label;
|
|
181
|
+
this.count = count;
|
|
182
|
+
makeObservable(this, {
|
|
183
|
+
type: observable,
|
|
184
|
+
key: observable,
|
|
185
|
+
facetLabel: observable,
|
|
186
|
+
value: observable,
|
|
187
|
+
label: observable,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export class ChatAttachmentImage extends ChatAttachment {
|
|
192
|
+
constructor({ id, base64, fileName, imageId, imageUrl, thumbnailUrl, state, error }) {
|
|
193
|
+
super({ data: { id, state, error } });
|
|
194
|
+
this.type = 'image';
|
|
195
|
+
// used to update attachment after upload or from
|
|
196
|
+
this.update = async ({ imageId, imageUrl, thumbnailUrl, error, }) => {
|
|
197
|
+
if (imageId && imageUrl && thumbnailUrl) {
|
|
198
|
+
this.state = 'attached';
|
|
199
|
+
this.imageId = imageId;
|
|
200
|
+
this.imageUrl = imageUrl;
|
|
201
|
+
this.thumbnailUrl = thumbnailUrl;
|
|
202
|
+
}
|
|
203
|
+
else if (error) {
|
|
204
|
+
this.state = 'error';
|
|
205
|
+
this.error = error;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
this.base64 = base64;
|
|
209
|
+
this.fileName = fileName;
|
|
210
|
+
this.imageId = imageId;
|
|
211
|
+
this.imageUrl = imageUrl;
|
|
212
|
+
this.thumbnailUrl = thumbnailUrl;
|
|
213
|
+
makeObservable(this, {
|
|
214
|
+
type: observable,
|
|
215
|
+
imageId: observable,
|
|
216
|
+
imageUrl: observable,
|
|
217
|
+
thumbnailUrl: observable,
|
|
218
|
+
base64: observable,
|
|
219
|
+
fileName: observable,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Maximum number of products that can be added to a chat comparison. */
|
|
2
|
+
export declare const CHAT_COMPARISON_MAX = 4;
|
|
3
|
+
export declare class ChatCompareStore {
|
|
4
|
+
items: any[];
|
|
5
|
+
committedItems: any[];
|
|
6
|
+
maxItems: number;
|
|
7
|
+
constructor();
|
|
8
|
+
add(item: any): void;
|
|
9
|
+
remove(itemId: string): void;
|
|
10
|
+
reset(): void;
|
|
11
|
+
resetCommitted(): void;
|
|
12
|
+
commit(): void;
|
|
13
|
+
get compared(): any[];
|
|
14
|
+
get committed(): any[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ChatCompareStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatCompareStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/ChatCompareStore.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,qBAAa,gBAAgB;IACrB,KAAK,EAAE,GAAG,EAAE,CAAM;IAClB,cAAc,EAAE,GAAG,EAAE,CAAM;IAC3B,QAAQ,EAAE,MAAM,CAAuB;;IAa9C,GAAG,CAAC,IAAI,EAAE,GAAG;IAYb,MAAM,CAAC,MAAM,EAAE,MAAM;IAIrB,KAAK;IAIL,cAAc;IAKd,MAAM;IAON,IAAI,QAAQ,UAEX;IAED,IAAI,SAAS,UAEZ;CACD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { computed, makeObservable, observable } from 'mobx';
|
|
2
|
+
/** Maximum number of products that can be added to a chat comparison. */
|
|
3
|
+
export const CHAT_COMPARISON_MAX = 4;
|
|
4
|
+
export class ChatCompareStore {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.items = [];
|
|
7
|
+
this.committedItems = [];
|
|
8
|
+
this.maxItems = CHAT_COMPARISON_MAX;
|
|
9
|
+
makeObservable(this, {
|
|
10
|
+
items: observable,
|
|
11
|
+
committedItems: observable,
|
|
12
|
+
maxItems: observable,
|
|
13
|
+
compared: computed,
|
|
14
|
+
committed: computed,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
// add, remove, reset methods
|
|
18
|
+
add(item) {
|
|
19
|
+
// prevent adding the same product to the comparison twice
|
|
20
|
+
if (item.result?.id && this.items.some((existing) => existing.result?.id === item.result.id)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (this.items.length >= this.maxItems) {
|
|
24
|
+
// handle max items reached, e.g. remove the oldest item
|
|
25
|
+
this.items.shift();
|
|
26
|
+
}
|
|
27
|
+
this.items.push(item);
|
|
28
|
+
}
|
|
29
|
+
remove(itemId) {
|
|
30
|
+
this.items = this.items.filter((item) => item.result?.id !== itemId);
|
|
31
|
+
}
|
|
32
|
+
reset() {
|
|
33
|
+
this.items = [];
|
|
34
|
+
}
|
|
35
|
+
resetCommitted() {
|
|
36
|
+
this.committedItems = [];
|
|
37
|
+
}
|
|
38
|
+
// move the current items to the committed list and clear items
|
|
39
|
+
commit() {
|
|
40
|
+
if (this.items.length > 0) {
|
|
41
|
+
this.committedItems = this.items.slice();
|
|
42
|
+
this.items = [];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
get compared() {
|
|
46
|
+
return this.items;
|
|
47
|
+
}
|
|
48
|
+
get committed() {
|
|
49
|
+
return this.committedItems;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { ChatResponseModel, ChatRequestModel, ChatResponseTextData, ChatResponseProductSearchResultData, ChatResponseInspirationResultData, ChatResponseContentData, ChatResponseProductAnswerData, ChatResponseProductComparisonData, ChatResponseProductRecommendationData, ChatResponseErrorData, ChatResponseTopicDriftData } from '@athoscommerce/snap-client';
|
|
2
|
+
import { ChatAttachmentAddAttachment, ChatAttachmentStore } from '../Stores/ChatAttachmentStore';
|
|
3
|
+
import type { StorageStore } from '@athoscommerce/snap-toolbox';
|
|
4
|
+
import { MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
5
|
+
import { ChatCompareStore } from './ChatCompareStore';
|
|
6
|
+
export type ChatFeedbacks = {
|
|
7
|
+
messageId: string;
|
|
8
|
+
rating: 'UP' | 'DOWN';
|
|
9
|
+
};
|
|
10
|
+
export type ChatSessionFeedback = {
|
|
11
|
+
rating: 'UP' | 'DOWN';
|
|
12
|
+
};
|
|
13
|
+
export type ChatUserMessage = {
|
|
14
|
+
id: string;
|
|
15
|
+
messageType: 'user';
|
|
16
|
+
text: string;
|
|
17
|
+
attachments?: string[];
|
|
18
|
+
requestType?: string;
|
|
19
|
+
request?: Record<string, any>;
|
|
20
|
+
};
|
|
21
|
+
export type ChatProductQueryMessageData = {
|
|
22
|
+
id: string;
|
|
23
|
+
messageType: 'productQuery';
|
|
24
|
+
sourceProduct: any;
|
|
25
|
+
sourceMessageId?: string;
|
|
26
|
+
};
|
|
27
|
+
export type ChatSystemMessage = ChatResponseTextData | ChatResponseContentData | ChatResponseProductSearchResultData | ChatResponseInspirationResultData | ChatResponseProductAnswerData | ChatResponseProductComparisonData | ChatResponseProductRecommendationData | ChatResponseErrorData | ChatResponseTopicDriftData | ChatProductQueryMessageData;
|
|
28
|
+
export type ChatMessage = ChatUserMessage | ChatSystemMessage;
|
|
29
|
+
type ChatSessionStoreConfig = {
|
|
30
|
+
data?: {
|
|
31
|
+
id?: string;
|
|
32
|
+
sessionId?: string;
|
|
33
|
+
chat?: ChatMessage[];
|
|
34
|
+
attachments?: ChatAttachmentAddAttachment[];
|
|
35
|
+
actions?: ChatActions;
|
|
36
|
+
feedbacks?: ChatFeedbacks[];
|
|
37
|
+
sessionFeedback?: ChatSessionFeedback | null;
|
|
38
|
+
feedbackDismissed?: boolean;
|
|
39
|
+
createdAt?: Date;
|
|
40
|
+
sessionEndTime?: Date;
|
|
41
|
+
committedComparisons?: any[];
|
|
42
|
+
};
|
|
43
|
+
stores: {
|
|
44
|
+
storage: StorageStore;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type ActionsData = {
|
|
48
|
+
type: 'actions';
|
|
49
|
+
data: any;
|
|
50
|
+
};
|
|
51
|
+
export type ChatActions = ActionsData[];
|
|
52
|
+
/** Snapshot of facet labels keyed by field — used to render the user message text for a productSearch request. */
|
|
53
|
+
export type FilterLabelMap = Record<string, {
|
|
54
|
+
facetLabel: string;
|
|
55
|
+
values: Record<string, string>;
|
|
56
|
+
}>;
|
|
57
|
+
export declare class ChatSessionStore {
|
|
58
|
+
chat: ChatMessage[];
|
|
59
|
+
actions: ChatActions;
|
|
60
|
+
id: string;
|
|
61
|
+
sessionId?: string;
|
|
62
|
+
attachments: ChatAttachmentStore;
|
|
63
|
+
comparisons: ChatCompareStore;
|
|
64
|
+
storage: StorageStore;
|
|
65
|
+
feedbacks: ChatFeedbacks[];
|
|
66
|
+
sessionFeedback: ChatSessionFeedback | null;
|
|
67
|
+
feedbackDismissed: boolean;
|
|
68
|
+
feedbackJustGiven: boolean;
|
|
69
|
+
createdAt: Date;
|
|
70
|
+
sessionEndTime?: Date;
|
|
71
|
+
requestType: string;
|
|
72
|
+
dismissedSideChatMessageId: string | null;
|
|
73
|
+
activeMessageId: string | null;
|
|
74
|
+
sessionLimitReached: boolean;
|
|
75
|
+
/** Whether raw stored results have been hydrated into Product/SearchResultStore instances. */
|
|
76
|
+
hydrated: boolean;
|
|
77
|
+
constructor(params: ChatSessionStoreConfig);
|
|
78
|
+
dismissSideChat(): void;
|
|
79
|
+
setActiveMessage(id: string): void;
|
|
80
|
+
pushProductQueryMessage(result: any): void;
|
|
81
|
+
popProductQueryMessage(restoreActiveMessageId?: string): void;
|
|
82
|
+
get isExpired(): boolean;
|
|
83
|
+
get topicDrift(): ChatResponseTopicDriftData | null;
|
|
84
|
+
get activeMessage(): ChatMessage | null;
|
|
85
|
+
dismissTopicDrift(): void;
|
|
86
|
+
handleTopicDrift(): string | undefined;
|
|
87
|
+
reset(): void;
|
|
88
|
+
private saveTimerId;
|
|
89
|
+
/** Persist the session to storage immediately (synchronous). */
|
|
90
|
+
saveImmediate(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Schedule a save — multiple calls within the debounce window are coalesced
|
|
93
|
+
* into a single localStorage write.
|
|
94
|
+
*/
|
|
95
|
+
save(): void;
|
|
96
|
+
/** Remove oldest stored sessions when exceeding the limit. */
|
|
97
|
+
static pruneStoredSessions(storage: StorageStore, maxSessions?: number): void;
|
|
98
|
+
/** Re-wrap raw stored results as Product / SearchResultStore instances. */
|
|
99
|
+
hydrateResults(meta: MetaResponseModel): void;
|
|
100
|
+
request(request: ChatRequestModel, filterLabels?: FilterLabelMap): void;
|
|
101
|
+
update(data: {
|
|
102
|
+
chat: ChatResponseModel;
|
|
103
|
+
meta: MetaResponseModel;
|
|
104
|
+
}): void;
|
|
105
|
+
}
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=ChatSessionStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSessionStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/ChatSessionStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,mCAAmC,EACnC,iCAAiC,EACjC,uBAAuB,EACvB,6BAA6B,EAC7B,iCAAiC,EACjC,qCAAqC,EACrC,qBAAqB,EACrB,0BAA0B,EAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,2BAA2B,EAI3B,mBAAmB,EACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BA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