@athoscommerce/snap-store-mobx 1.2.3-beta.4 → 1.4.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.
Files changed (81) hide show
  1. package/dist/cjs/Autocomplete/AutocompleteStore.d.ts +1 -1
  2. package/dist/cjs/Autocomplete/AutocompleteStore.d.ts.map +1 -1
  3. package/dist/cjs/Autocomplete/AutocompleteStore.js +4 -4
  4. package/dist/cjs/Autocomplete/Stores/AutocompleteFacetStore.d.ts.map +1 -1
  5. package/dist/cjs/Autocomplete/Stores/AutocompleteFacetStore.js +2 -4
  6. package/dist/cjs/Finder/FinderStore.d.ts +1 -1
  7. package/dist/cjs/Finder/FinderStore.d.ts.map +1 -1
  8. package/dist/cjs/Finder/FinderStore.js +3 -3
  9. package/dist/cjs/Finder/Stores/FinderSelectionStore.d.ts +1 -1
  10. package/dist/cjs/Finder/Stores/FinderSelectionStore.d.ts.map +1 -1
  11. package/dist/cjs/Search/SearchStore.d.ts +1 -1
  12. package/dist/cjs/Search/SearchStore.d.ts.map +1 -1
  13. package/dist/cjs/Search/SearchStore.js +2 -2
  14. package/dist/cjs/Search/Stores/SearchFacetStore.d.ts +12 -12
  15. package/dist/cjs/Search/Stores/SearchFacetStore.d.ts.map +1 -1
  16. package/dist/cjs/Search/Stores/SearchFacetStore.js +22 -32
  17. package/dist/cjs/Search/Stores/SearchHistoryStore.js +2 -2
  18. package/dist/cjs/Search/Stores/index.d.ts +1 -1
  19. package/dist/cjs/Search/Stores/index.d.ts.map +1 -1
  20. package/dist/cjs/Search/Stores/index.js +1 -2
  21. package/dist/cjs/index.d.ts +1 -5
  22. package/dist/cjs/index.d.ts.map +1 -1
  23. package/dist/cjs/index.js +4 -8
  24. package/dist/cjs/types.d.ts +2 -13
  25. package/dist/cjs/types.d.ts.map +1 -1
  26. package/dist/esm/Autocomplete/AutocompleteStore.d.ts +1 -1
  27. package/dist/esm/Autocomplete/AutocompleteStore.d.ts.map +1 -1
  28. package/dist/esm/Autocomplete/AutocompleteStore.js +2 -2
  29. package/dist/esm/Autocomplete/Stores/AutocompleteFacetStore.d.ts.map +1 -1
  30. package/dist/esm/Autocomplete/Stores/AutocompleteFacetStore.js +5 -7
  31. package/dist/esm/Finder/FinderStore.d.ts +1 -1
  32. package/dist/esm/Finder/FinderStore.d.ts.map +1 -1
  33. package/dist/esm/Finder/FinderStore.js +1 -1
  34. package/dist/esm/Finder/Stores/FinderSelectionStore.d.ts +1 -1
  35. package/dist/esm/Finder/Stores/FinderSelectionStore.d.ts.map +1 -1
  36. package/dist/esm/Search/SearchStore.d.ts +1 -1
  37. package/dist/esm/Search/SearchStore.d.ts.map +1 -1
  38. package/dist/esm/Search/SearchStore.js +1 -1
  39. package/dist/esm/Search/Stores/SearchFacetStore.d.ts +12 -12
  40. package/dist/esm/Search/Stores/SearchFacetStore.d.ts.map +1 -1
  41. package/dist/esm/Search/Stores/SearchFacetStore.js +22 -31
  42. package/dist/esm/Search/Stores/SearchHistoryStore.js +1 -1
  43. package/dist/esm/Search/Stores/index.d.ts +1 -1
  44. package/dist/esm/Search/Stores/index.d.ts.map +1 -1
  45. package/dist/esm/Search/Stores/index.js +1 -1
  46. package/dist/esm/index.d.ts +1 -5
  47. package/dist/esm/index.d.ts.map +1 -1
  48. package/dist/esm/index.js +1 -3
  49. package/dist/esm/types.d.ts +2 -13
  50. package/dist/esm/types.d.ts.map +1 -1
  51. package/package.json +11 -6
  52. package/dist/cjs/Chat/ChatStore.d.ts +0 -57
  53. package/dist/cjs/Chat/ChatStore.d.ts.map +0 -1
  54. package/dist/cjs/Chat/ChatStore.js +0 -415
  55. package/dist/cjs/Chat/Stores/ChatAttachmentStore.d.ts +0 -98
  56. package/dist/cjs/Chat/Stores/ChatAttachmentStore.d.ts.map +0 -1
  57. package/dist/cjs/Chat/Stores/ChatAttachmentStore.js +0 -314
  58. package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts +0 -14
  59. package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts.map +0 -1
  60. package/dist/cjs/Chat/Stores/ChatCompareStore.js +0 -63
  61. package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts +0 -117
  62. package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts.map +0 -1
  63. package/dist/cjs/Chat/Stores/ChatSessionStore.js +0 -689
  64. package/dist/cjs/Storage/StorageStore.d.ts +0 -27
  65. package/dist/cjs/Storage/StorageStore.d.ts.map +0 -1
  66. package/dist/cjs/Storage/StorageStore.js +0 -176
  67. package/dist/esm/Chat/ChatStore.d.ts +0 -57
  68. package/dist/esm/Chat/ChatStore.d.ts.map +0 -1
  69. package/dist/esm/Chat/ChatStore.js +0 -355
  70. package/dist/esm/Chat/Stores/ChatAttachmentStore.d.ts +0 -98
  71. package/dist/esm/Chat/Stores/ChatAttachmentStore.d.ts.map +0 -1
  72. package/dist/esm/Chat/Stores/ChatAttachmentStore.js +0 -222
  73. package/dist/esm/Chat/Stores/ChatCompareStore.d.ts +0 -14
  74. package/dist/esm/Chat/Stores/ChatCompareStore.d.ts.map +0 -1
  75. package/dist/esm/Chat/Stores/ChatCompareStore.js +0 -49
  76. package/dist/esm/Chat/Stores/ChatSessionStore.d.ts +0 -117
  77. package/dist/esm/Chat/Stores/ChatSessionStore.d.ts.map +0 -1
  78. package/dist/esm/Chat/Stores/ChatSessionStore.js +0 -661
  79. package/dist/esm/Storage/StorageStore.d.ts +0 -27
  80. package/dist/esm/Storage/StorageStore.d.ts.map +0 -1
  81. package/dist/esm/Storage/StorageStore.js +0 -169
@@ -1,98 +0,0 @@
1
- type AttachmentState = 'loading' | 'error' | 'attached' | 'active' | 'saved';
2
- type AttachmentError = {
3
- message: string;
4
- };
5
- export type ChatAttachmentAddAttachment = ChatAttachmentImageConfig | ChatAttachmentProductConfig | ChatAttachmentFacetConfig;
6
- export declare class ChatAttachmentStore {
7
- items: ChatAttachments[];
8
- constructor();
9
- get attached(): ChatAttachments[];
10
- get compared(): ChatAttachmentProduct[];
11
- add<T extends ChatAttachments>(attachment: ChatAttachmentAddAttachment): T;
12
- remove(id: string): void;
13
- get(id: string): ChatAttachments | undefined;
14
- reset(): void;
15
- hydrate(attachments: ChatAttachmentAddAttachment[]): void;
16
- }
17
- type ChatAttachments = ChatAttachmentImage | ChatAttachmentProduct | ChatAttachmentFacet;
18
- declare abstract class ChatAttachment {
19
- abstract type: string;
20
- id: string;
21
- state: AttachmentState;
22
- error?: AttachmentError;
23
- constructor(params?: {
24
- data?: {
25
- id?: string;
26
- state?: AttachmentState;
27
- error?: AttachmentError;
28
- };
29
- });
30
- save(): void;
31
- activate(): void;
32
- }
33
- type ChatAttachmentImageConfig = {
34
- type: 'image';
35
- id?: string;
36
- base64?: string;
37
- fileName?: string;
38
- imageId?: string;
39
- imageUrl?: string;
40
- thumbnailUrl?: string;
41
- state?: AttachmentState;
42
- error?: AttachmentError;
43
- };
44
- type ChatAttachmentProductConfig = {
45
- type: 'product';
46
- id?: string;
47
- productId: string;
48
- thumbnailUrl: string;
49
- name: string;
50
- requestType: 'productQuery' | 'productSimilar' | 'productComparison';
51
- state?: AttachmentState;
52
- error?: AttachmentError;
53
- };
54
- type ChatAttachmentFacetConfig = {
55
- type: 'facet';
56
- id?: string;
57
- key: string;
58
- facetLabel: string;
59
- value: string;
60
- label: string;
61
- count: number;
62
- state?: AttachmentState;
63
- error?: AttachmentError;
64
- };
65
- export declare class ChatAttachmentProduct extends ChatAttachment {
66
- type: 'product' | never;
67
- productId: string;
68
- thumbnailUrl: string;
69
- name: string;
70
- requestType: 'productQuery' | 'productSimilar' | 'productComparison';
71
- constructor({ id, productId, thumbnailUrl, name, requestType, state, error }: ChatAttachmentProductConfig);
72
- }
73
- export declare class ChatAttachmentFacet extends ChatAttachment {
74
- type: 'facet' | never;
75
- key: string;
76
- facetLabel: string;
77
- value: string;
78
- label: string;
79
- count: number;
80
- constructor({ id, key, facetLabel, value, label, count, state, error }: ChatAttachmentFacetConfig);
81
- }
82
- export declare class ChatAttachmentImage extends ChatAttachment {
83
- type: 'image' | never;
84
- fileName?: string;
85
- imageId?: string;
86
- imageUrl?: string;
87
- thumbnailUrl?: string;
88
- base64?: string;
89
- constructor({ id, base64, fileName, imageId, imageUrl, thumbnailUrl, state, error }: ChatAttachmentImageConfig);
90
- update: ({ imageId, imageUrl, thumbnailUrl, error, }: {
91
- imageId?: string;
92
- imageUrl?: string;
93
- thumbnailUrl?: string;
94
- error?: AttachmentError;
95
- }) => Promise<void>;
96
- }
97
- export {};
98
- //# sourceMappingURL=ChatAttachmentStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatAttachmentStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/ChatAttachmentStore.ts"],"names":[],"mappings":"AAKA,KAAK,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC7E,KAAK,eAAe,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,yBAAyB,GAAG,2BAA2B,GAAG,yBAAyB,CAAC;AAE9H,qBAAa,mBAAmB;IACxB,KAAK,EAAE,eAAe,EAAE,CAAM;;IAUrC,IAAI,QAAQ,sBAEX;IAED,IAAI,QAAQ,4BAKX;IAED,GAAG,CAAC,CAAC,SAAS,eAAe,EAAE,UAAU,EAAE,2BAA2B,GAAG,CAAC;IAiG1E,MAAM,CAAC,EAAE,EAAE,MAAM;IAajB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI5C,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,WAAW,EAAE,2BAA2B,EAAE,GAAG,IAAI;CAezD;AAID,KAAK,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;AAEzF,uBAAe,cAAc;IAC5B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAEtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE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MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,eAAe,CAAC;KACxB,KAAG,OAAO,CAAC,IAAI,CAAC,CAUf;CACF"}
@@ -1,222 +0,0 @@
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
- export class ChatAttachmentStore {
6
- constructor() {
7
- this.items = [];
8
- makeObservable(this, {
9
- items: observable,
10
- attached: computed,
11
- compared: computed,
12
- });
13
- }
14
- get attached() {
15
- return this.items.filter((item) => item.state !== 'saved');
16
- }
17
- get compared() {
18
- return this.items
19
- .filter((item) => item.state !== 'saved')
20
- .filter((item) => item.type === 'product')
21
- .filter((item) => item.requestType === 'productComparison');
22
- }
23
- add(attachment) {
24
- // TODO: check if attachment already exists
25
- switch (attachment.type) {
26
- case 'image': {
27
- // if there are currently any other attachments remove them
28
- this.items.forEach((item) => {
29
- this.remove(item.id);
30
- });
31
- const newAttachment = new ChatAttachmentImage(attachment);
32
- this.items.push(newAttachment);
33
- return newAttachment;
34
- }
35
- case 'product': {
36
- // 'productSimilar' and 'productQuery' are single-product flows — replace any
37
- // existing attachments so the conversation only targets the latest product
38
- if (attachment.requestType === 'productSimilar' || attachment.requestType === 'productQuery') {
39
- this.items.forEach((item) => {
40
- this.remove(item.id);
41
- });
42
- const newAttachment = new ChatAttachmentProduct(attachment);
43
- this.items.unshift(newAttachment);
44
- return newAttachment;
45
- }
46
- // For 'productQuery' or 'productComparison', continue with existing logic
47
- // if there are currently any other attachments remove them
48
- this.items.forEach((item) => {
49
- if (item.type !== 'product') {
50
- this.remove(item.id);
51
- }
52
- });
53
- // check if product is already attached
54
- const existingProductAttachment = this.items.find((item) => item.type === 'product' &&
55
- (item.state === 'active' || item.state === 'attached') &&
56
- item.productId === attachment.productId);
57
- if (existingProductAttachment) {
58
- existingProductAttachment.requestType = attachment.requestType; // changes existing attachments to the incoming requestType
59
- return existingProductAttachment;
60
- }
61
- // productComparison supports up to 4 products (matches ChatCompareStore.maxItems);
62
- // trim oldest active/attached product attachments to keep total below the cap.
63
- const COMPARISON_MAX = 4;
64
- const productAttachments = this.items.filter((item) => item.type === 'product' && (item.state === 'active' || item.state === 'attached'));
65
- while (productAttachments.length >= 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
- }
@@ -1,14 +0,0 @@
1
- export declare class ChatCompareStore {
2
- items: any[];
3
- committedItems: any[];
4
- maxItems: number;
5
- constructor();
6
- add(item: any): void;
7
- remove(itemId: string): void;
8
- reset(): void;
9
- resetCommitted(): void;
10
- commit(): void;
11
- get compared(): any[];
12
- get committed(): any[];
13
- }
14
- //# sourceMappingURL=ChatCompareStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatCompareStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/ChatCompareStore.ts"],"names":[],"mappings":"AAEA,qBAAa,gBAAgB;IACrB,KAAK,EAAE,GAAG,EAAE,CAAM;IAClB,cAAc,EAAE,GAAG,EAAE,CAAM;IAC3B,QAAQ,EAAE,MAAM,CAAK;;IAa5B,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"}
@@ -1,49 +0,0 @@
1
- import { computed, makeObservable, observable } from 'mobx';
2
- export class ChatCompareStore {
3
- constructor() {
4
- this.items = [];
5
- this.committedItems = [];
6
- this.maxItems = 4;
7
- makeObservable(this, {
8
- items: observable,
9
- committedItems: observable,
10
- maxItems: observable,
11
- compared: computed,
12
- committed: computed,
13
- });
14
- }
15
- // add, remove, reset methods
16
- add(item) {
17
- // prevent adding the same product to the comparison twice
18
- if (item.result?.id && this.items.some((existing) => existing.result?.id === item.result.id)) {
19
- return;
20
- }
21
- if (this.items.length >= this.maxItems) {
22
- // handle max items reached, e.g. remove the oldest item
23
- this.items.shift();
24
- }
25
- this.items.push(item);
26
- }
27
- remove(itemId) {
28
- this.items = this.items.filter((item) => item.result?.id !== itemId);
29
- }
30
- reset() {
31
- this.items = [];
32
- }
33
- resetCommitted() {
34
- this.committedItems = [];
35
- }
36
- // move the current items to the committed list and clear items
37
- commit() {
38
- if (this.items.length > 0) {
39
- this.committedItems = this.items.slice();
40
- this.items = [];
41
- }
42
- }
43
- get compared() {
44
- return this.items;
45
- }
46
- get committed() {
47
- return this.committedItems;
48
- }
49
- }
@@ -1,117 +0,0 @@
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 '../../Storage/StorageStore';
4
- import { MetaResponseModel } from '@athoscommerce/snapi-types';
5
- import { ChatCompareStore } from './ChatCompareStore';
6
- import { SearchFacetStore } from '../../Search/Stores/SearchFacetStore';
7
- export type ChatFeedbacks = {
8
- messageId: string;
9
- rating: 'UP' | 'DOWN';
10
- };
11
- export type ChatSessionFeedback = {
12
- rating: 'UP' | 'DOWN';
13
- };
14
- export type ChatUserMessage = {
15
- id: string;
16
- messageType: 'user';
17
- text: string;
18
- attachments?: string[];
19
- requestType?: string;
20
- request?: Record<string, any>;
21
- };
22
- export type ChatProductQueryMessageData = {
23
- id: string;
24
- messageType: 'productQuery';
25
- sourceProduct: any;
26
- sourceMessageId?: string;
27
- };
28
- export type ChatSystemMessage = ChatResponseTextData | ChatResponseContentData | ChatResponseProductSearchResultData | ChatResponseInspirationResultData | ChatResponseProductAnswerData | ChatResponseProductComparisonData | ChatResponseProductRecommendationData | ChatResponseErrorData | ChatResponseTopicDriftData | ChatProductQueryMessageData;
29
- export type ChatMessage = ChatUserMessage | ChatSystemMessage;
30
- type ChatSessionStoreConfig = {
31
- data?: {
32
- id?: string;
33
- sessionId?: string;
34
- chat?: ChatMessage[];
35
- attachments?: ChatAttachmentAddAttachment[];
36
- actions?: ChatActions;
37
- feedbacks?: ChatFeedbacks[];
38
- sessionFeedback?: ChatSessionFeedback | null;
39
- feedbackDismissed?: boolean;
40
- createdAt?: Date;
41
- committedComparisons?: any[];
42
- };
43
- stores: {
44
- storage: StorageStore;
45
- };
46
- };
47
- export type FacetsData = {
48
- type: 'facets';
49
- data: SearchFacetStore;
50
- filterSummary?: {
51
- field: string;
52
- value: string;
53
- label?: string;
54
- filterLabel?: string;
55
- filterValue?: string;
56
- }[];
57
- };
58
- export type ActionsData = {
59
- type: 'actions';
60
- data: any;
61
- };
62
- export type ChatActions = (FacetsData | ActionsData)[];
63
- export declare class ChatSessionStore {
64
- chat: ChatMessage[];
65
- actions: ChatActions;
66
- id: string;
67
- sessionId?: string;
68
- attachments: ChatAttachmentStore;
69
- comparisons: ChatCompareStore;
70
- storage: StorageStore;
71
- feedbacks: ChatFeedbacks[];
72
- sessionFeedback: ChatSessionFeedback | null;
73
- feedbackDismissed: boolean;
74
- feedbackJustGiven: boolean;
75
- createdAt: Date;
76
- requestType: string;
77
- dismissedSideChatMessageId: string | null;
78
- activeMessageId: string | null;
79
- sessionLimitReached: boolean;
80
- /** Tracks server-filtered facets the user has explicitly unselected (pending next request). */
81
- removedFacets: {
82
- key: string;
83
- value: string;
84
- }[];
85
- /** Whether raw stored results have been hydrated into Product/SearchResultStore instances. */
86
- hydrated: boolean;
87
- constructor(params: ChatSessionStoreConfig);
88
- dismissSideChat(): void;
89
- setActiveMessage(id: string): void;
90
- pushProductQueryMessage(result: any): void;
91
- popProductQueryMessage(restoreActiveMessageId?: string): void;
92
- get isExpired(): boolean;
93
- get topicDrift(): ChatResponseTopicDriftData | null;
94
- get activeMessage(): ChatMessage | null;
95
- dismissTopicDrift(): void;
96
- handleTopicDrift(): string | undefined;
97
- reset(): void;
98
- private saveTimerId;
99
- /** Persist the session to storage immediately (synchronous). */
100
- saveImmediate(): void;
101
- /**
102
- * Schedule a save — multiple calls within the debounce window are coalesced
103
- * into a single localStorage write.
104
- */
105
- save(): void;
106
- /** Remove oldest stored sessions when exceeding the limit. */
107
- static pruneStoredSessions(storage: StorageStore, maxSessions?: number): void;
108
- /** Re-wrap raw stored results as Product / SearchResultStore instances. */
109
- hydrateResults(meta: MetaResponseModel): void;
110
- request(request: ChatRequestModel): void;
111
- update(data: {
112
- chat: ChatResponseModel;
113
- meta: MetaResponseModel;
114
- }): void;
115
- }
116
- export {};
117
- //# sourceMappingURL=ChatSessionStore.d.ts.map
@@ -1 +0,0 @@
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,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAuD,MAAM,4BAA4B,CAAC;AACpH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AA2LxE,MAAM,MAAM,aAAa,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,MAAM,mBAAmB,GAAG;IAAE,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE,CAAC;AAE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