@athoscommerce/snap-store-mobx 1.2.3-beta.3 → 1.2.3-beta.4
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.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/Stores/AutocompleteFacetStore.js +4 -2
- package/dist/cjs/Chat/ChatStore.d.ts +2 -0
- package/dist/cjs/Chat/ChatStore.d.ts.map +1 -1
- package/dist/cjs/Chat/ChatStore.js +39 -3
- package/dist/cjs/Chat/Stores/ChatAttachmentStore.d.ts.map +1 -1
- package/dist/cjs/Chat/Stores/ChatAttachmentStore.js +4 -2
- package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts +14 -1
- package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts.map +1 -1
- package/dist/cjs/Chat/Stores/ChatSessionStore.js +67 -2
- package/dist/cjs/Search/Stores/SearchFacetStore.d.ts +11 -11
- package/dist/cjs/Search/Stores/SearchFacetStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/SearchFacetStore.js +32 -22
- package/dist/esm/Autocomplete/Stores/AutocompleteFacetStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/Stores/AutocompleteFacetStore.js +7 -5
- package/dist/esm/Chat/ChatStore.d.ts +2 -0
- package/dist/esm/Chat/ChatStore.d.ts.map +1 -1
- package/dist/esm/Chat/ChatStore.js +38 -3
- package/dist/esm/Chat/Stores/ChatAttachmentStore.d.ts.map +1 -1
- package/dist/esm/Chat/Stores/ChatAttachmentStore.js +4 -2
- package/dist/esm/Chat/Stores/ChatSessionStore.d.ts +14 -1
- package/dist/esm/Chat/Stores/ChatSessionStore.d.ts.map +1 -1
- package/dist/esm/Chat/Stores/ChatSessionStore.js +70 -2
- package/dist/esm/Search/Stores/SearchFacetStore.d.ts +11 -11
- package/dist/esm/Search/Stores/SearchFacetStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/SearchFacetStore.js +31 -22
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteFacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Autocomplete/Stores/AutocompleteFacetStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,KAAK,4BAA4B,GAAG,sBAAsB,GAAG;IAC5D,KAAK,EAAE;QACN,YAAY,EAAE,sBAAsB,CAAC;KACrC,CAAC;CACF,CAAC;AACF,qBAAa,sBAAuB,SAAQ,KAAK;IAChD,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAEW,MAAM,EAAE,4BAA4B;
|
|
1
|
+
{"version":3,"file":"AutocompleteFacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Autocomplete/Stores/AutocompleteFacetStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,KAAK,4BAA4B,GAAG,sBAAsB,GAAG;IAC5D,KAAK,EAAE;QACN,YAAY,EAAE,sBAAsB,CAAC;KACrC,CAAC;CACF,CAAC;AACF,qBAAa,sBAAuB,SAAQ,KAAK;IAChD,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAEW,MAAM,EAAE,4BAA4B;CAoChD"}
|
|
@@ -33,12 +33,14 @@ var AutocompleteFacetStore = /** @class */ (function (_super) {
|
|
|
33
33
|
function AutocompleteFacetStore(params) {
|
|
34
34
|
var _a = params || {}, services = _a.services, state = _a.state;
|
|
35
35
|
// allow for only a singular facet option selection at a time
|
|
36
|
-
var facets = new Stores_1.SearchFacetStore(__assign(__assign({}, params), { services:
|
|
36
|
+
var facets = new Stores_1.SearchFacetStore(__assign(__assign({}, params), { services: (services === null || services === void 0 ? void 0 : services.urlManager)
|
|
37
|
+
? __assign(__assign({}, services), { urlManager: services.urlManager.remove('filter') }) : services }));
|
|
37
38
|
// mutate facet values to add 'preview' function
|
|
38
39
|
facets.forEach(function (facet) {
|
|
39
40
|
var _a;
|
|
40
41
|
(_a = facet.values) === null || _a === void 0 ? void 0 : _a.forEach(function (value) {
|
|
41
42
|
value.preview = function () {
|
|
43
|
+
var _a;
|
|
42
44
|
facets.map(function (facet) {
|
|
43
45
|
var _a;
|
|
44
46
|
facet.filtered = false;
|
|
@@ -49,7 +51,7 @@ var AutocompleteFacetStore = /** @class */ (function (_super) {
|
|
|
49
51
|
facet.filtered = true;
|
|
50
52
|
value.filtered = true;
|
|
51
53
|
state === null || state === void 0 ? void 0 : state.autocomplete.locks.facets.lock();
|
|
52
|
-
value.url.go();
|
|
54
|
+
(_a = value.url) === null || _a === void 0 ? void 0 : _a.go();
|
|
53
55
|
};
|
|
54
56
|
});
|
|
55
57
|
});
|
|
@@ -27,6 +27,7 @@ export declare class ChatStore extends AbstractStore<ChatStoreConfig> {
|
|
|
27
27
|
get currentChat(): ChatSessionStore | undefined;
|
|
28
28
|
get chatsIds(): string[];
|
|
29
29
|
get blocked(): boolean;
|
|
30
|
+
private applyChatStatusResponse;
|
|
30
31
|
handleChatStatusResponse(response: ChatStatusResponse): boolean;
|
|
31
32
|
reset(): void;
|
|
32
33
|
setProductQuickview(product: Product): void;
|
|
@@ -46,6 +47,7 @@ export declare class ChatStore extends AbstractStore<ChatStoreConfig> {
|
|
|
46
47
|
removeFacet(key: string, value: string): void;
|
|
47
48
|
clearPendingFacets(): void;
|
|
48
49
|
isFacetSelected(key: string, value: string): boolean;
|
|
50
|
+
isFacetRemoved(key: string, value: string): boolean;
|
|
49
51
|
request(request: ChatRequestModel): void;
|
|
50
52
|
update(data: {
|
|
51
53
|
chat: ChatResponseModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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
|
|
|
66
66
|
_this.storage.set('chatStatusResponse', null);
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
|
|
69
|
+
// Apply the stored response without persisting, so the 12-hour
|
|
70
|
+
// checkTime keeps counting from the last real API call rather
|
|
71
|
+
// than resetting on every page load.
|
|
72
|
+
_this.applyChatStatusResponse(storedChatStatus.response);
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
catch (_a) {
|
|
@@ -168,16 +171,22 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
168
171
|
enumerable: false,
|
|
169
172
|
configurable: true
|
|
170
173
|
});
|
|
171
|
-
ChatStore.prototype.
|
|
174
|
+
ChatStore.prototype.applyChatStatusResponse = function (response) {
|
|
172
175
|
var chatbot = response.chatbot, features = response.features;
|
|
173
176
|
var status = chatbot.status, suggestedQuestions = chatbot.suggestedQuestions, welcomeMessage = chatbot.welcomeMessage;
|
|
174
177
|
this.chatEnabled = status.enabled === true;
|
|
175
178
|
this.features = features;
|
|
176
179
|
this.suggestedQuestions = suggestedQuestions || [];
|
|
177
180
|
this.welcomeMessage = welcomeMessage || '';
|
|
178
|
-
this.storage.set('chatStatusResponse', JSON.stringify({ response: response, checkTime: Date.now() }));
|
|
179
181
|
return this.chatEnabled;
|
|
180
182
|
};
|
|
183
|
+
ChatStore.prototype.handleChatStatusResponse = function (response) {
|
|
184
|
+
var enabled = this.applyChatStatusResponse(response);
|
|
185
|
+
// Always persist on a real API response — restarts the 12-hour expiration
|
|
186
|
+
// so each new chat session refreshes the cache.
|
|
187
|
+
this.storage.set('chatStatusResponse', JSON.stringify({ response: response, checkTime: Date.now() }));
|
|
188
|
+
return enabled;
|
|
189
|
+
};
|
|
181
190
|
ChatStore.prototype.reset = function () {
|
|
182
191
|
this.chats = [];
|
|
183
192
|
this.clearProductQuickview();
|
|
@@ -302,6 +311,13 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
302
311
|
label: facet.label,
|
|
303
312
|
count: facet.count,
|
|
304
313
|
});
|
|
314
|
+
// If re-selecting a previously removed server-side filter, remove it from removedFacets
|
|
315
|
+
if (this.currentChat) {
|
|
316
|
+
var removedIndex = this.currentChat.removedFacets.findIndex(function (rf) { return rf.key === facet.key && rf.value === facet.value; });
|
|
317
|
+
if (removedIndex !== -1) {
|
|
318
|
+
this.currentChat.removedFacets.splice(removedIndex, 1);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
305
321
|
};
|
|
306
322
|
ChatStore.prototype.removeFacet = function (key, value) {
|
|
307
323
|
var _a, _b, _c;
|
|
@@ -317,6 +333,14 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
317
333
|
(_c = this.currentChat) === null || _c === void 0 ? void 0 : _c.attachments.items.splice(index, 1);
|
|
318
334
|
}
|
|
319
335
|
}
|
|
336
|
+
else if (this.currentChat) {
|
|
337
|
+
// No attachment exists — this is a server-side filtered facet.
|
|
338
|
+
// Track it as explicitly removed so the next request excludes it.
|
|
339
|
+
var alreadyRemoved = this.currentChat.removedFacets.some(function (rf) { return rf.key === key && rf.value === value; });
|
|
340
|
+
if (!alreadyRemoved) {
|
|
341
|
+
this.currentChat.removedFacets.push({ key: key, value: value });
|
|
342
|
+
}
|
|
343
|
+
}
|
|
320
344
|
};
|
|
321
345
|
ChatStore.prototype.clearPendingFacets = function () {
|
|
322
346
|
var _this = this;
|
|
@@ -329,9 +353,17 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
329
353
|
(_b = _this.currentChat) === null || _b === void 0 ? void 0 : _b.attachments.items.splice(index, 1);
|
|
330
354
|
}
|
|
331
355
|
});
|
|
356
|
+
if (this.currentChat) {
|
|
357
|
+
this.currentChat.removedFacets = [];
|
|
358
|
+
}
|
|
332
359
|
};
|
|
333
360
|
ChatStore.prototype.isFacetSelected = function (key, value) {
|
|
334
361
|
var _a;
|
|
362
|
+
// A facet that has been explicitly removed by the user is not selected,
|
|
363
|
+
// even if the server still reports it as filtered.
|
|
364
|
+
if (this.isFacetRemoved(key, value)) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
335
367
|
return (((_a = this.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.items.some(function (item) {
|
|
336
368
|
return item.type === 'facet' &&
|
|
337
369
|
item.key === key &&
|
|
@@ -339,6 +371,10 @@ var ChatStore = /** @class */ (function (_super) {
|
|
|
339
371
|
(item.state === 'active' || item.state === 'attached');
|
|
340
372
|
})) || false);
|
|
341
373
|
};
|
|
374
|
+
ChatStore.prototype.isFacetRemoved = function (key, value) {
|
|
375
|
+
var _a;
|
|
376
|
+
return ((_a = this.currentChat) === null || _a === void 0 ? void 0 : _a.removedFacets.some(function (rf) { return rf.key === key && rf.value === value; })) || false;
|
|
377
|
+
};
|
|
342
378
|
ChatStore.prototype.request = function (request) {
|
|
343
379
|
var _this = this;
|
|
344
380
|
var _a, _b, _c;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,QA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EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;gBAET,EAAE,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,yBAAyB;CAkBjG;AACD,qBAAa,mBAAoB,SAAQ,cAAc;IAC/C,IAAI,EAAE,OAAO,GAAG,KAAK,CAAW;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEX,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,yBAAyB;IAoB9G,MAAM,gDAKH;QACF,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,eAAe,CAAC;KACxB,KAAG,OAAO,CAAC,IAAI,CAAC,CAUf;CACF"}
|
|
@@ -123,9 +123,11 @@ var ChatAttachmentStore = /** @class */ (function () {
|
|
|
123
123
|
existingProductAttachment.requestType = attachment.requestType; // changes existing attachments to the incoming requestType
|
|
124
124
|
return existingProductAttachment;
|
|
125
125
|
}
|
|
126
|
-
//
|
|
126
|
+
// productComparison supports up to 4 products (matches ChatCompareStore.maxItems);
|
|
127
|
+
// trim oldest active/attached product attachments to keep total below the cap.
|
|
128
|
+
var COMPARISON_MAX = 4;
|
|
127
129
|
var productAttachments = this.items.filter(function (item) { return item.type === 'product' && (item.state === 'active' || item.state === 'attached'); });
|
|
128
|
-
while (productAttachments.length >=
|
|
130
|
+
while (productAttachments.length >= COMPARISON_MAX) {
|
|
129
131
|
var toRemove = productAttachments.pop();
|
|
130
132
|
if (toRemove) {
|
|
131
133
|
this.remove(toRemove.id);
|
|
@@ -3,6 +3,7 @@ import { ChatAttachmentAddAttachment, ChatAttachmentStore } from '../Stores/Chat
|
|
|
3
3
|
import type { StorageStore } from '../../Storage/StorageStore';
|
|
4
4
|
import { MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
5
5
|
import { ChatCompareStore } from './ChatCompareStore';
|
|
6
|
+
import { SearchFacetStore } from '../../Search/Stores/SearchFacetStore';
|
|
6
7
|
export type ChatFeedbacks = {
|
|
7
8
|
messageId: string;
|
|
8
9
|
rating: 'UP' | 'DOWN';
|
|
@@ -45,7 +46,14 @@ type ChatSessionStoreConfig = {
|
|
|
45
46
|
};
|
|
46
47
|
export type FacetsData = {
|
|
47
48
|
type: 'facets';
|
|
48
|
-
data:
|
|
49
|
+
data: SearchFacetStore;
|
|
50
|
+
filterSummary?: {
|
|
51
|
+
field: string;
|
|
52
|
+
value: string;
|
|
53
|
+
label?: string;
|
|
54
|
+
filterLabel?: string;
|
|
55
|
+
filterValue?: string;
|
|
56
|
+
}[];
|
|
49
57
|
};
|
|
50
58
|
export type ActionsData = {
|
|
51
59
|
type: 'actions';
|
|
@@ -69,6 +77,11 @@ export declare class ChatSessionStore {
|
|
|
69
77
|
dismissedSideChatMessageId: string | null;
|
|
70
78
|
activeMessageId: string | null;
|
|
71
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
|
+
}[];
|
|
72
85
|
/** Whether raw stored results have been hydrated into Product/SearchResultStore instances. */
|
|
73
86
|
hydrated: boolean;
|
|
74
87
|
constructor(params: ChatSessionStoreConfig);
|
|
@@ -1 +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,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,
|
|
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;AAE5D,MAAM,MAAM,eAAe,GAAG;IAC7B,EAAE,EAAE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,IAAI;IAWvB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKlC,uBAAuB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAqB1C,sBAAsB,CAAC,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI;IAQpE,IAAI,SAAS,IAAI,OAAO,CAKvB;IAED,IAAI,UAAU,IAAI,0BAA0B,GAAG,IAAI,CAGlD;IAED,IAAI,aAAa,IAAI,WAAW,GAAG,IAAI,CAoCtC;IAEM,iBAAiB,IAAI,IAAI;IAKzB,gBAAgB,IAAI,MAAM,GAAG,SAAS;IAsBtC,KAAK,IAAI,IAAI;IASpB,OAAO,CAAC,WAAW,CAA8C;IAEjE,gEAAgE;IACzD,aAAa,IAAI,IAAI;IAmB5B;;;OAGG;IACI,IAAI,IAAI,IAAI;IAUnB,8DAA8D;WAChD,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,GAAE,MAAW,GAAG,IAAI;IAmBxF,2EAA2E;IACpE,cAAc,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI;IA6C7C,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAyIxC,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,iBAAiB,CAAC;QAAC,IAAI,EAAE,iBAAiB,CAAA;KAAE,GAAG,IAAI;CAiD/E"}
|
|
@@ -17,6 +17,7 @@ var uuid_1 = require("uuid");
|
|
|
17
17
|
var ChatAttachmentStore_1 = require("../Stores/ChatAttachmentStore");
|
|
18
18
|
var ChatCompareStore_1 = require("./ChatCompareStore");
|
|
19
19
|
var SearchResultStore_1 = require("../../Search/Stores/SearchResultStore");
|
|
20
|
+
var SearchFacetStore_1 = require("../../Search/Stores/SearchFacetStore");
|
|
20
21
|
function createChatResultStore(results, meta) {
|
|
21
22
|
return new SearchResultStore_1.SearchResultStore({
|
|
22
23
|
config: {},
|
|
@@ -35,8 +36,19 @@ function createChatProduct(result, meta) {
|
|
|
35
36
|
responseId: '',
|
|
36
37
|
});
|
|
37
38
|
}
|
|
39
|
+
function createChatFacetStore(facets, meta, storage) {
|
|
40
|
+
return new SearchFacetStore_1.SearchFacetStore({
|
|
41
|
+
config: {},
|
|
42
|
+
stores: { storage: storage },
|
|
43
|
+
data: {
|
|
44
|
+
search: { facets: facets },
|
|
45
|
+
meta: meta,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
38
49
|
/** Extract raw serializable data from a Product instance for storage. */
|
|
39
50
|
function serializeProduct(product) {
|
|
51
|
+
var _a, _b;
|
|
40
52
|
if (!(product instanceof SearchResultStore_1.Product))
|
|
41
53
|
return product;
|
|
42
54
|
var raw = {
|
|
@@ -44,6 +56,7 @@ function serializeProduct(product) {
|
|
|
44
56
|
responseId: product.responseId,
|
|
45
57
|
mappings: product.mappings,
|
|
46
58
|
attributes: product.attributes,
|
|
59
|
+
badges: ((_b = (_a = product.badges) === null || _a === void 0 ? void 0 : _a.all) === null || _b === void 0 ? void 0 : _b.map(function (b) { return ({ tag: b.tag }); })) || [],
|
|
47
60
|
};
|
|
48
61
|
if (product.variants) {
|
|
49
62
|
raw.variants = {
|
|
@@ -132,6 +145,44 @@ function serializeChatForStorage(chat) {
|
|
|
132
145
|
}
|
|
133
146
|
});
|
|
134
147
|
}
|
|
148
|
+
/** Serialize SearchFacetStore instances in actions back to plain facet arrays for localStorage. */
|
|
149
|
+
function serializeActionsForStorage(actions) {
|
|
150
|
+
return actions.map(function (action) {
|
|
151
|
+
if (action.type === 'facets') {
|
|
152
|
+
return __assign(__assign({}, action), { data: serializeFacetStore(action.data) });
|
|
153
|
+
}
|
|
154
|
+
return action;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/** Convert a SearchFacetStore (or raw array) back to plain serializable facet objects. */
|
|
158
|
+
function serializeFacetStore(facetStore) {
|
|
159
|
+
return Array.from(facetStore).map(function (facet) {
|
|
160
|
+
var serialized = {
|
|
161
|
+
field: facet.field,
|
|
162
|
+
label: facet.label,
|
|
163
|
+
type: facet.type,
|
|
164
|
+
filtered: facet.filtered,
|
|
165
|
+
};
|
|
166
|
+
if (facet.values) {
|
|
167
|
+
serialized.values = facet.values.map(function (value) {
|
|
168
|
+
if (facet.type === 'range-buckets') {
|
|
169
|
+
return { low: value.low, high: value.high, label: value.label, count: value.count, filtered: value.filtered };
|
|
170
|
+
}
|
|
171
|
+
return { value: value.value, label: value.label, count: value.count, filtered: value.filtered };
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if (facet.range) {
|
|
175
|
+
serialized.range = facet.range;
|
|
176
|
+
}
|
|
177
|
+
if (facet.active) {
|
|
178
|
+
serialized.active = facet.active;
|
|
179
|
+
}
|
|
180
|
+
if (facet.step != null) {
|
|
181
|
+
serialized.step = facet.step;
|
|
182
|
+
}
|
|
183
|
+
return serialized;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
135
186
|
var ChatSessionStore = /** @class */ (function () {
|
|
136
187
|
function ChatSessionStore(params) {
|
|
137
188
|
this.chat = [];
|
|
@@ -147,6 +198,8 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
147
198
|
this.dismissedSideChatMessageId = null;
|
|
148
199
|
this.activeMessageId = null;
|
|
149
200
|
this.sessionLimitReached = false;
|
|
201
|
+
/** Tracks server-filtered facets the user has explicitly unselected (pending next request). */
|
|
202
|
+
this.removedFacets = [];
|
|
150
203
|
/** Whether raw stored results have been hydrated into Product/SearchResultStore instances. */
|
|
151
204
|
this.hydrated = true;
|
|
152
205
|
this.saveTimerId = null;
|
|
@@ -209,6 +262,7 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
209
262
|
dismissedSideChatMessageId: mobx_1.observable,
|
|
210
263
|
activeMessageId: mobx_1.observable,
|
|
211
264
|
sessionLimitReached: mobx_1.observable,
|
|
265
|
+
removedFacets: mobx_1.observable,
|
|
212
266
|
activeMessage: mobx_1.computed,
|
|
213
267
|
});
|
|
214
268
|
}
|
|
@@ -338,6 +392,7 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
338
392
|
this.attachments.reset();
|
|
339
393
|
this.chat = [];
|
|
340
394
|
this.actions = [];
|
|
395
|
+
this.removedFacets = [];
|
|
341
396
|
this.feedbacks = [];
|
|
342
397
|
this.sessionFeedback = null;
|
|
343
398
|
};
|
|
@@ -351,7 +406,7 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
351
406
|
sessionId: this.sessionId,
|
|
352
407
|
chat: serializeChatForStorage(this.chat),
|
|
353
408
|
attachments: serializeAttachmentsForStorage(this.attachments.items),
|
|
354
|
-
actions: this.actions,
|
|
409
|
+
actions: serializeActionsForStorage(this.actions),
|
|
355
410
|
feedbacks: this.feedbacks,
|
|
356
411
|
sessionFeedback: this.sessionFeedback,
|
|
357
412
|
feedbackDismissed: this.feedbackDismissed,
|
|
@@ -396,6 +451,7 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
396
451
|
};
|
|
397
452
|
/** Re-wrap raw stored results as Product / SearchResultStore instances. */
|
|
398
453
|
ChatSessionStore.prototype.hydrateResults = function (meta) {
|
|
454
|
+
var _this = this;
|
|
399
455
|
this.chat.forEach(function (message) {
|
|
400
456
|
var _a, _b, _c, _d;
|
|
401
457
|
if (message.messageType === 'productSearchResult') {
|
|
@@ -435,12 +491,20 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
435
491
|
});
|
|
436
492
|
}
|
|
437
493
|
});
|
|
494
|
+
// Re-wrap raw stored facets as SearchFacetStore instances
|
|
495
|
+
this.actions.forEach(function (action, index) {
|
|
496
|
+
var _a;
|
|
497
|
+
if (action.type === 'facets' && ((_a = action.data) === null || _a === void 0 ? void 0 : _a.length) > 0 && !(action.data instanceof SearchFacetStore_1.SearchFacetStore)) {
|
|
498
|
+
_this.actions[index] = __assign(__assign({}, action), { data: createChatFacetStore(action.data, meta, _this.storage) });
|
|
499
|
+
}
|
|
500
|
+
});
|
|
438
501
|
};
|
|
439
502
|
ChatSessionStore.prototype.request = function (request) {
|
|
440
503
|
var _this = this;
|
|
441
504
|
var _a, _b;
|
|
442
505
|
// clear the questions on new request
|
|
443
506
|
this.actions = [];
|
|
507
|
+
this.removedFacets = [];
|
|
444
508
|
this.requestType = request.data.requestType;
|
|
445
509
|
this.activeMessageId = null;
|
|
446
510
|
// remove any attachments that failed to upload
|
|
@@ -587,7 +651,8 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
587
651
|
if (messageData.messageType === 'productSearchResult' && ((_a = messageData.facets) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
588
652
|
_this.actions.push({
|
|
589
653
|
type: 'facets',
|
|
590
|
-
data: messageData.facets,
|
|
654
|
+
data: createChatFacetStore(messageData.facets, meta, _this.storage),
|
|
655
|
+
filterSummary: messageData.filterSummary || [],
|
|
591
656
|
});
|
|
592
657
|
}
|
|
593
658
|
// convert raw results to Product instances (via SearchResultStore) so
|
|
@@ -7,7 +7,7 @@ export type SearchFacetStoreConfig = {
|
|
|
7
7
|
stores: {
|
|
8
8
|
storage: StorageStore;
|
|
9
9
|
};
|
|
10
|
-
services
|
|
10
|
+
services?: StoreServices;
|
|
11
11
|
data: {
|
|
12
12
|
search?: SearchResponseModel;
|
|
13
13
|
meta: MetaResponseModel;
|
|
@@ -18,7 +18,7 @@ export declare class SearchFacetStore extends Array {
|
|
|
18
18
|
constructor(params: SearchFacetStoreConfig);
|
|
19
19
|
}
|
|
20
20
|
export declare class Facet {
|
|
21
|
-
services
|
|
21
|
+
services?: StoreServices;
|
|
22
22
|
type: 'range' | 'value' | 'range-buckets';
|
|
23
23
|
field: string;
|
|
24
24
|
filtered: boolean;
|
|
@@ -27,9 +27,9 @@ export declare class Facet {
|
|
|
27
27
|
display: string;
|
|
28
28
|
label: string;
|
|
29
29
|
storage: StorageStore;
|
|
30
|
-
constructor(services: StoreServices, storage: StorageStore, facet: SearchResponseModelFacetValue | SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacet, config: FacetStoreConfig);
|
|
30
|
+
constructor(services: StoreServices | undefined, storage: StorageStore, facet: SearchResponseModelFacetValue | SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacet, config: FacetStoreConfig);
|
|
31
31
|
get clear(): {
|
|
32
|
-
url: UrlManager;
|
|
32
|
+
url: UrlManager | undefined;
|
|
33
33
|
};
|
|
34
34
|
toggleCollapse(): void;
|
|
35
35
|
}
|
|
@@ -39,7 +39,7 @@ export declare class RangeFacet extends Facet {
|
|
|
39
39
|
active?: SearchRequestModelFilterRangeAllOfValue;
|
|
40
40
|
formatSeparator: string;
|
|
41
41
|
formatValue: string;
|
|
42
|
-
constructor(services: StoreServices, storage: StorageStore, facet: SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacetSlider, config: FacetStoreConfig);
|
|
42
|
+
constructor(services: StoreServices | undefined, storage: StorageStore, facet: SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacetSlider, config: FacetStoreConfig);
|
|
43
43
|
get filteredCount(): number;
|
|
44
44
|
}
|
|
45
45
|
export declare class ValueFacet extends Facet {
|
|
@@ -57,7 +57,7 @@ export declare class ValueFacet extends Facet {
|
|
|
57
57
|
toggle: (val?: boolean) => void;
|
|
58
58
|
calculate: () => void;
|
|
59
59
|
};
|
|
60
|
-
constructor(services: StoreServices, storage: StorageStore, facet: SearchResponseModelFacetValue, facetMeta: MetaResponseModelFacet, config: FacetStoreConfig);
|
|
60
|
+
constructor(services: StoreServices | undefined, storage: StorageStore, facet: SearchResponseModelFacetValue, facetMeta: MetaResponseModelFacet, config: FacetStoreConfig);
|
|
61
61
|
get filteredCount(): number;
|
|
62
62
|
get refinedValues(): (FacetHierarchyValue | FacetValue | FacetRangeValue | undefined)[];
|
|
63
63
|
}
|
|
@@ -67,14 +67,14 @@ export declare class FacetValue {
|
|
|
67
67
|
filtered: boolean;
|
|
68
68
|
value: string;
|
|
69
69
|
custom: object;
|
|
70
|
-
url
|
|
70
|
+
url?: UrlManager;
|
|
71
71
|
preview?: () => void;
|
|
72
|
-
constructor(services: StoreServices, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
72
|
+
constructor(services: StoreServices | undefined, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
73
73
|
}
|
|
74
74
|
export declare class FacetHierarchyValue extends FacetValue {
|
|
75
75
|
level: number;
|
|
76
76
|
history: boolean;
|
|
77
|
-
constructor(services: StoreServices, facet: ValueFacet & MetaResponseModelFacetHierarchyAllOf, value: SearchResponseModelFacetValueAllOfValues, filteredValues: SearchResponseModelFacetValueAllOfValues[]);
|
|
77
|
+
constructor(services: StoreServices | undefined, facet: ValueFacet & MetaResponseModelFacetHierarchyAllOf, value: SearchResponseModelFacetValueAllOfValues, filteredValues: SearchResponseModelFacetValueAllOfValues[]);
|
|
78
78
|
}
|
|
79
79
|
export declare class FacetRangeValue {
|
|
80
80
|
label: string;
|
|
@@ -83,7 +83,7 @@ export declare class FacetRangeValue {
|
|
|
83
83
|
low: number;
|
|
84
84
|
high: number;
|
|
85
85
|
custom: object;
|
|
86
|
-
url
|
|
87
|
-
constructor(services: StoreServices, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
86
|
+
url?: UrlManager;
|
|
87
|
+
constructor(services: StoreServices | undefined, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
88
88
|
}
|
|
89
89
|
//# sourceMappingURL=SearchFacetStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchFacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchFacetStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/G,OAAO,KAAK,EACX,sBAAsB,EAEtB,4B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
|
@@ -128,8 +128,9 @@ var Facet = /** @class */ (function () {
|
|
|
128
128
|
}
|
|
129
129
|
Object.defineProperty(Facet.prototype, "clear", {
|
|
130
130
|
get: function () {
|
|
131
|
+
var _a, _b;
|
|
131
132
|
return {
|
|
132
|
-
url: this.services.urlManager.remove('page').remove("filter.".concat(this.field)),
|
|
133
|
+
url: (_b = (_a = this.services) === null || _a === void 0 ? void 0 : _a.urlManager) === null || _b === void 0 ? void 0 : _b.remove('page').remove("filter.".concat(this.field)),
|
|
133
134
|
};
|
|
134
135
|
},
|
|
135
136
|
enumerable: false,
|
|
@@ -305,15 +306,18 @@ exports.ValueFacet = ValueFacet;
|
|
|
305
306
|
var FacetValue = /** @class */ (function () {
|
|
306
307
|
function FacetValue(services, facet, value) {
|
|
307
308
|
Object.assign(this, value);
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
valueUrl =
|
|
309
|
+
var urlManager = services === null || services === void 0 ? void 0 : services.urlManager;
|
|
310
|
+
if (urlManager) {
|
|
311
|
+
if (this.filtered) {
|
|
312
|
+
this.url = urlManager.remove('page').remove("filter.".concat(facet.field), value.value);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
var valueUrl = urlManager.remove('page');
|
|
316
|
+
if (facet.multiple == 'single') {
|
|
317
|
+
valueUrl = valueUrl === null || valueUrl === void 0 ? void 0 : valueUrl.remove("filter.".concat(facet.field));
|
|
318
|
+
}
|
|
319
|
+
this.url = valueUrl === null || valueUrl === void 0 ? void 0 : valueUrl.merge("filter.".concat(facet.field), value.value);
|
|
315
320
|
}
|
|
316
|
-
this.url = valueUrl === null || valueUrl === void 0 ? void 0 : valueUrl.merge("filter.".concat(facet.field), value.value);
|
|
317
321
|
}
|
|
318
322
|
}
|
|
319
323
|
return FacetValue;
|
|
@@ -335,11 +339,14 @@ var FacetHierarchyValue = /** @class */ (function (_super) {
|
|
|
335
339
|
_this.history = true;
|
|
336
340
|
}
|
|
337
341
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
342
|
+
var urlManager = services === null || services === void 0 ? void 0 : services.urlManager;
|
|
343
|
+
if (urlManager) {
|
|
344
|
+
if (value.value) {
|
|
345
|
+
_this.url = urlManager.remove('page').set("filter.".concat(facet.field), value.value);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
_this.url = urlManager.remove('page').remove("filter.".concat(facet.field));
|
|
349
|
+
}
|
|
343
350
|
}
|
|
344
351
|
return _this;
|
|
345
352
|
}
|
|
@@ -349,15 +356,18 @@ exports.FacetHierarchyValue = FacetHierarchyValue;
|
|
|
349
356
|
var FacetRangeValue = /** @class */ (function () {
|
|
350
357
|
function FacetRangeValue(services, facet, value) {
|
|
351
358
|
Object.assign(this, value);
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
valueUrl =
|
|
359
|
+
var urlManager = services === null || services === void 0 ? void 0 : services.urlManager;
|
|
360
|
+
if (urlManager) {
|
|
361
|
+
if (this.filtered) {
|
|
362
|
+
this.url = urlManager.remove('page').remove("filter.".concat(facet.field), [{ low: this.low, high: this.high }]);
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
var valueUrl = urlManager.remove('page');
|
|
366
|
+
if (facet.multiple == 'single') {
|
|
367
|
+
valueUrl = valueUrl === null || valueUrl === void 0 ? void 0 : valueUrl.remove("filter.".concat(facet.field));
|
|
368
|
+
}
|
|
369
|
+
this.url = valueUrl === null || valueUrl === void 0 ? void 0 : valueUrl.merge("filter.".concat(facet.field), [{ low: this.low, high: this.high }]);
|
|
359
370
|
}
|
|
360
|
-
this.url = valueUrl === null || valueUrl === void 0 ? void 0 : valueUrl.merge("filter.".concat(facet.field), [{ low: this.low, high: this.high }]);
|
|
361
371
|
}
|
|
362
372
|
}
|
|
363
373
|
return FacetRangeValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteFacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Autocomplete/Stores/AutocompleteFacetStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,KAAK,4BAA4B,GAAG,sBAAsB,GAAG;IAC5D,KAAK,EAAE;QACN,YAAY,EAAE,sBAAsB,CAAC;KACrC,CAAC;CACF,CAAC;AACF,qBAAa,sBAAuB,SAAQ,KAAK;IAChD,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAEW,MAAM,EAAE,4BAA4B;
|
|
1
|
+
{"version":3,"file":"AutocompleteFacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Autocomplete/Stores/AutocompleteFacetStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,KAAK,4BAA4B,GAAG,sBAAsB,GAAG;IAC5D,KAAK,EAAE;QACN,YAAY,EAAE,sBAAsB,CAAC;KACrC,CAAC;CACF,CAAC;AACF,qBAAa,sBAAuB,SAAQ,KAAK;IAChD,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAEW,MAAM,EAAE,4BAA4B;CAoChD"}
|
|
@@ -8,10 +8,12 @@ export class AutocompleteFacetStore extends Array {
|
|
|
8
8
|
// allow for only a singular facet option selection at a time
|
|
9
9
|
const facets = new SearchFacetStore({
|
|
10
10
|
...params,
|
|
11
|
-
services:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
services: services?.urlManager
|
|
12
|
+
? {
|
|
13
|
+
...services,
|
|
14
|
+
urlManager: services.urlManager.remove('filter'),
|
|
15
|
+
}
|
|
16
|
+
: services,
|
|
15
17
|
});
|
|
16
18
|
// mutate facet values to add 'preview' function
|
|
17
19
|
facets.forEach((facet) => {
|
|
@@ -26,7 +28,7 @@ export class AutocompleteFacetStore extends Array {
|
|
|
26
28
|
facet.filtered = true;
|
|
27
29
|
value.filtered = true;
|
|
28
30
|
state?.autocomplete.locks.facets.lock();
|
|
29
|
-
value.url
|
|
31
|
+
value.url?.go();
|
|
30
32
|
};
|
|
31
33
|
});
|
|
32
34
|
});
|
|
@@ -27,6 +27,7 @@ export declare class ChatStore extends AbstractStore<ChatStoreConfig> {
|
|
|
27
27
|
get currentChat(): ChatSessionStore | undefined;
|
|
28
28
|
get chatsIds(): string[];
|
|
29
29
|
get blocked(): boolean;
|
|
30
|
+
private applyChatStatusResponse;
|
|
30
31
|
handleChatStatusResponse(response: ChatStatusResponse): boolean;
|
|
31
32
|
reset(): void;
|
|
32
33
|
setProductQuickview(product: Product): void;
|
|
@@ -46,6 +47,7 @@ export declare class ChatStore extends AbstractStore<ChatStoreConfig> {
|
|
|
46
47
|
removeFacet(key: string, value: string): void;
|
|
47
48
|
clearPendingFacets(): void;
|
|
48
49
|
isFacetSelected(key: string, value: string): boolean;
|
|
50
|
+
isFacetRemoved(key: string, value: string): boolean;
|
|
49
51
|
request(request: ChatRequestModel): void;
|
|
50
52
|
update(data: {
|
|
51
53
|
chat: ChatResponseModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatStore.d.ts","sourceRoot":"","sources":["../../../src/Chat/ChatStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBA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IAAI;IAI/C,qBAAqB,IAAI,IAAI;IAK7B,YAAY,IAAI,IAAI;IAoBpB,UAAU,CAAC,IAAI,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,gBAAgB;IAyB1D,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAa5B,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE;QAAE,WAAW,EAAE,cAAc,GAAG,gBAAgB,GAAG,mBAAmB,CAAA;KAAE,GAAG,IAAI;IAkBtH,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAMjC,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAmB1B,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAuB7C,kBAAkB,IAAI,IAAI;IAc1B,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAkBpD,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAInD,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAmBxC,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,iBAAiB,CAAC;QAAC,IAAI,EAAE,iBAAiB,CAAA;KAAE,GAAG,IAAI;CAkB/E"}
|
|
@@ -36,7 +36,10 @@ export class ChatStore extends AbstractStore {
|
|
|
36
36
|
this.storage.set('chatStatusResponse', null);
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
|
-
|
|
39
|
+
// Apply the stored response without persisting, so the 12-hour
|
|
40
|
+
// checkTime keeps counting from the last real API call rather
|
|
41
|
+
// than resetting on every page load.
|
|
42
|
+
this.applyChatStatusResponse(storedChatStatus.response);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
catch {
|
|
@@ -126,16 +129,22 @@ export class ChatStore extends AbstractStore {
|
|
|
126
129
|
}
|
|
127
130
|
return isBlocked;
|
|
128
131
|
}
|
|
129
|
-
|
|
132
|
+
applyChatStatusResponse(response) {
|
|
130
133
|
const { chatbot, features } = response;
|
|
131
134
|
const { status, suggestedQuestions, welcomeMessage } = chatbot;
|
|
132
135
|
this.chatEnabled = status.enabled === true;
|
|
133
136
|
this.features = features;
|
|
134
137
|
this.suggestedQuestions = suggestedQuestions || [];
|
|
135
138
|
this.welcomeMessage = welcomeMessage || '';
|
|
136
|
-
this.storage.set('chatStatusResponse', JSON.stringify({ response, checkTime: Date.now() }));
|
|
137
139
|
return this.chatEnabled;
|
|
138
140
|
}
|
|
141
|
+
handleChatStatusResponse(response) {
|
|
142
|
+
const enabled = this.applyChatStatusResponse(response);
|
|
143
|
+
// Always persist on a real API response — restarts the 12-hour expiration
|
|
144
|
+
// so each new chat session refreshes the cache.
|
|
145
|
+
this.storage.set('chatStatusResponse', JSON.stringify({ response, checkTime: Date.now() }));
|
|
146
|
+
return enabled;
|
|
147
|
+
}
|
|
139
148
|
reset() {
|
|
140
149
|
this.chats = [];
|
|
141
150
|
this.clearProductQuickview();
|
|
@@ -259,6 +268,13 @@ export class ChatStore extends AbstractStore {
|
|
|
259
268
|
label: facet.label,
|
|
260
269
|
count: facet.count,
|
|
261
270
|
});
|
|
271
|
+
// If re-selecting a previously removed server-side filter, remove it from removedFacets
|
|
272
|
+
if (this.currentChat) {
|
|
273
|
+
const removedIndex = this.currentChat.removedFacets.findIndex((rf) => rf.key === facet.key && rf.value === facet.value);
|
|
274
|
+
if (removedIndex !== -1) {
|
|
275
|
+
this.currentChat.removedFacets.splice(removedIndex, 1);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
262
278
|
}
|
|
263
279
|
removeFacet(key, value) {
|
|
264
280
|
const facetAttachment = this.currentChat?.attachments.items.find((item) => item.type === 'facet' &&
|
|
@@ -271,6 +287,14 @@ export class ChatStore extends AbstractStore {
|
|
|
271
287
|
this.currentChat?.attachments.items.splice(index, 1);
|
|
272
288
|
}
|
|
273
289
|
}
|
|
290
|
+
else if (this.currentChat) {
|
|
291
|
+
// No attachment exists — this is a server-side filtered facet.
|
|
292
|
+
// Track it as explicitly removed so the next request excludes it.
|
|
293
|
+
const alreadyRemoved = this.currentChat.removedFacets.some((rf) => rf.key === key && rf.value === value);
|
|
294
|
+
if (!alreadyRemoved) {
|
|
295
|
+
this.currentChat.removedFacets.push({ key, value });
|
|
296
|
+
}
|
|
297
|
+
}
|
|
274
298
|
}
|
|
275
299
|
clearPendingFacets() {
|
|
276
300
|
const facetAttachments = this.currentChat?.attachments.items.filter((item) => item.type === 'facet' && (item.state === 'active' || item.state === 'attached')) || [];
|
|
@@ -280,13 +304,24 @@ export class ChatStore extends AbstractStore {
|
|
|
280
304
|
this.currentChat?.attachments.items.splice(index, 1);
|
|
281
305
|
}
|
|
282
306
|
});
|
|
307
|
+
if (this.currentChat) {
|
|
308
|
+
this.currentChat.removedFacets = [];
|
|
309
|
+
}
|
|
283
310
|
}
|
|
284
311
|
isFacetSelected(key, value) {
|
|
312
|
+
// A facet that has been explicitly removed by the user is not selected,
|
|
313
|
+
// even if the server still reports it as filtered.
|
|
314
|
+
if (this.isFacetRemoved(key, value)) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
285
317
|
return (this.currentChat?.attachments.items.some((item) => item.type === 'facet' &&
|
|
286
318
|
item.key === key &&
|
|
287
319
|
item.value === value &&
|
|
288
320
|
(item.state === 'active' || item.state === 'attached')) || false);
|
|
289
321
|
}
|
|
322
|
+
isFacetRemoved(key, value) {
|
|
323
|
+
return this.currentChat?.removedFacets.some((rf) => rf.key === key && rf.value === value) || false;
|
|
324
|
+
}
|
|
290
325
|
request(request) {
|
|
291
326
|
this.currentChat?.request(request);
|
|
292
327
|
// remove any facet attachments after request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatAttachmentStore.d.ts","sourceRoot":"","sources":["../../../../src/Chat/Stores/ChatAttachmentStore.ts"],"names":[],"mappings":"AAKA,KA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,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,eAAe,CAAC;KACxB,KAAG,OAAO,CAAC,IAAI,CAAC,CAUf;CACF"}
|
|
@@ -58,9 +58,11 @@ export class ChatAttachmentStore {
|
|
|
58
58
|
existingProductAttachment.requestType = attachment.requestType; // changes existing attachments to the incoming requestType
|
|
59
59
|
return existingProductAttachment;
|
|
60
60
|
}
|
|
61
|
-
//
|
|
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;
|
|
62
64
|
const productAttachments = this.items.filter((item) => item.type === 'product' && (item.state === 'active' || item.state === 'attached'));
|
|
63
|
-
while (productAttachments.length >=
|
|
65
|
+
while (productAttachments.length >= COMPARISON_MAX) {
|
|
64
66
|
const toRemove = productAttachments.pop();
|
|
65
67
|
if (toRemove) {
|
|
66
68
|
this.remove(toRemove.id);
|
|
@@ -3,6 +3,7 @@ import { ChatAttachmentAddAttachment, ChatAttachmentStore } from '../Stores/Chat
|
|
|
3
3
|
import type { StorageStore } from '../../Storage/StorageStore';
|
|
4
4
|
import { MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
5
5
|
import { ChatCompareStore } from './ChatCompareStore';
|
|
6
|
+
import { SearchFacetStore } from '../../Search/Stores/SearchFacetStore';
|
|
6
7
|
export type ChatFeedbacks = {
|
|
7
8
|
messageId: string;
|
|
8
9
|
rating: 'UP' | 'DOWN';
|
|
@@ -45,7 +46,14 @@ type ChatSessionStoreConfig = {
|
|
|
45
46
|
};
|
|
46
47
|
export type FacetsData = {
|
|
47
48
|
type: 'facets';
|
|
48
|
-
data:
|
|
49
|
+
data: SearchFacetStore;
|
|
50
|
+
filterSummary?: {
|
|
51
|
+
field: string;
|
|
52
|
+
value: string;
|
|
53
|
+
label?: string;
|
|
54
|
+
filterLabel?: string;
|
|
55
|
+
filterValue?: string;
|
|
56
|
+
}[];
|
|
49
57
|
};
|
|
50
58
|
export type ActionsData = {
|
|
51
59
|
type: 'actions';
|
|
@@ -69,6 +77,11 @@ export declare class ChatSessionStore {
|
|
|
69
77
|
dismissedSideChatMessageId: string | null;
|
|
70
78
|
activeMessageId: string | null;
|
|
71
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
|
+
}[];
|
|
72
85
|
/** Whether raw stored results have been hydrated into Product/SearchResultStore instances. */
|
|
73
86
|
hydrated: boolean;
|
|
74
87
|
constructor(params: ChatSessionStoreConfig);
|
|
@@ -1 +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,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,
|
|
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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;IA6C7C,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAyIxC,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,iBAAiB,CAAC;QAAC,IAAI,EAAE,iBAAiB,CAAA;KAAE,GAAG,IAAI;CAiD/E"}
|
|
@@ -3,6 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
3
3
|
import { ChatAttachmentStore, } from '../Stores/ChatAttachmentStore';
|
|
4
4
|
import { ChatCompareStore } from './ChatCompareStore';
|
|
5
5
|
import { SearchResultStore, Product } from '../../Search/Stores/SearchResultStore';
|
|
6
|
+
import { SearchFacetStore } from '../../Search/Stores/SearchFacetStore';
|
|
6
7
|
function createChatResultStore(results, meta) {
|
|
7
8
|
return new SearchResultStore({
|
|
8
9
|
config: {},
|
|
@@ -21,6 +22,16 @@ function createChatProduct(result, meta) {
|
|
|
21
22
|
responseId: '',
|
|
22
23
|
});
|
|
23
24
|
}
|
|
25
|
+
function createChatFacetStore(facets, meta, storage) {
|
|
26
|
+
return new SearchFacetStore({
|
|
27
|
+
config: {},
|
|
28
|
+
stores: { storage },
|
|
29
|
+
data: {
|
|
30
|
+
search: { facets },
|
|
31
|
+
meta,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
24
35
|
/** Extract raw serializable data from a Product instance for storage. */
|
|
25
36
|
function serializeProduct(product) {
|
|
26
37
|
if (!(product instanceof Product))
|
|
@@ -30,6 +41,7 @@ function serializeProduct(product) {
|
|
|
30
41
|
responseId: product.responseId,
|
|
31
42
|
mappings: product.mappings,
|
|
32
43
|
attributes: product.attributes,
|
|
44
|
+
badges: product.badges?.all?.map((b) => ({ tag: b.tag })) || [],
|
|
33
45
|
};
|
|
34
46
|
if (product.variants) {
|
|
35
47
|
raw.variants = {
|
|
@@ -129,6 +141,47 @@ function serializeChatForStorage(chat) {
|
|
|
129
141
|
}
|
|
130
142
|
});
|
|
131
143
|
}
|
|
144
|
+
/** Serialize SearchFacetStore instances in actions back to plain facet arrays for localStorage. */
|
|
145
|
+
function serializeActionsForStorage(actions) {
|
|
146
|
+
return actions.map((action) => {
|
|
147
|
+
if (action.type === 'facets') {
|
|
148
|
+
return {
|
|
149
|
+
...action,
|
|
150
|
+
data: serializeFacetStore(action.data),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return action;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/** Convert a SearchFacetStore (or raw array) back to plain serializable facet objects. */
|
|
157
|
+
function serializeFacetStore(facetStore) {
|
|
158
|
+
return Array.from(facetStore).map((facet) => {
|
|
159
|
+
const serialized = {
|
|
160
|
+
field: facet.field,
|
|
161
|
+
label: facet.label,
|
|
162
|
+
type: facet.type,
|
|
163
|
+
filtered: facet.filtered,
|
|
164
|
+
};
|
|
165
|
+
if (facet.values) {
|
|
166
|
+
serialized.values = facet.values.map((value) => {
|
|
167
|
+
if (facet.type === 'range-buckets') {
|
|
168
|
+
return { low: value.low, high: value.high, label: value.label, count: value.count, filtered: value.filtered };
|
|
169
|
+
}
|
|
170
|
+
return { value: value.value, label: value.label, count: value.count, filtered: value.filtered };
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (facet.range) {
|
|
174
|
+
serialized.range = facet.range;
|
|
175
|
+
}
|
|
176
|
+
if (facet.active) {
|
|
177
|
+
serialized.active = facet.active;
|
|
178
|
+
}
|
|
179
|
+
if (facet.step != null) {
|
|
180
|
+
serialized.step = facet.step;
|
|
181
|
+
}
|
|
182
|
+
return serialized;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
132
185
|
export class ChatSessionStore {
|
|
133
186
|
constructor(params) {
|
|
134
187
|
this.chat = [];
|
|
@@ -144,6 +197,8 @@ export class ChatSessionStore {
|
|
|
144
197
|
this.dismissedSideChatMessageId = null;
|
|
145
198
|
this.activeMessageId = null;
|
|
146
199
|
this.sessionLimitReached = false;
|
|
200
|
+
/** Tracks server-filtered facets the user has explicitly unselected (pending next request). */
|
|
201
|
+
this.removedFacets = [];
|
|
147
202
|
/** Whether raw stored results have been hydrated into Product/SearchResultStore instances. */
|
|
148
203
|
this.hydrated = true;
|
|
149
204
|
this.saveTimerId = null;
|
|
@@ -206,6 +261,7 @@ export class ChatSessionStore {
|
|
|
206
261
|
dismissedSideChatMessageId: observable,
|
|
207
262
|
activeMessageId: observable,
|
|
208
263
|
sessionLimitReached: observable,
|
|
264
|
+
removedFacets: observable,
|
|
209
265
|
activeMessage: computed,
|
|
210
266
|
});
|
|
211
267
|
}
|
|
@@ -321,6 +377,7 @@ export class ChatSessionStore {
|
|
|
321
377
|
this.attachments.reset();
|
|
322
378
|
this.chat = [];
|
|
323
379
|
this.actions = [];
|
|
380
|
+
this.removedFacets = [];
|
|
324
381
|
this.feedbacks = [];
|
|
325
382
|
this.sessionFeedback = null;
|
|
326
383
|
}
|
|
@@ -334,7 +391,7 @@ export class ChatSessionStore {
|
|
|
334
391
|
sessionId: this.sessionId,
|
|
335
392
|
chat: serializeChatForStorage(this.chat),
|
|
336
393
|
attachments: serializeAttachmentsForStorage(this.attachments.items),
|
|
337
|
-
actions: this.actions,
|
|
394
|
+
actions: serializeActionsForStorage(this.actions),
|
|
338
395
|
feedbacks: this.feedbacks,
|
|
339
396
|
sessionFeedback: this.sessionFeedback,
|
|
340
397
|
feedbackDismissed: this.feedbackDismissed,
|
|
@@ -412,10 +469,20 @@ export class ChatSessionStore {
|
|
|
412
469
|
});
|
|
413
470
|
}
|
|
414
471
|
});
|
|
472
|
+
// Re-wrap raw stored facets as SearchFacetStore instances
|
|
473
|
+
this.actions.forEach((action, index) => {
|
|
474
|
+
if (action.type === 'facets' && action.data?.length > 0 && !(action.data instanceof SearchFacetStore)) {
|
|
475
|
+
this.actions[index] = {
|
|
476
|
+
...action,
|
|
477
|
+
data: createChatFacetStore(action.data, meta, this.storage),
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
});
|
|
415
481
|
}
|
|
416
482
|
request(request) {
|
|
417
483
|
// clear the questions on new request
|
|
418
484
|
this.actions = [];
|
|
485
|
+
this.removedFacets = [];
|
|
419
486
|
this.requestType = request.data.requestType;
|
|
420
487
|
this.activeMessageId = null;
|
|
421
488
|
// remove any attachments that failed to upload
|
|
@@ -558,7 +625,8 @@ export class ChatSessionStore {
|
|
|
558
625
|
if (messageData.messageType === 'productSearchResult' && messageData.facets?.length > 0) {
|
|
559
626
|
this.actions.push({
|
|
560
627
|
type: 'facets',
|
|
561
|
-
data: messageData.facets,
|
|
628
|
+
data: createChatFacetStore(messageData.facets, meta, this.storage),
|
|
629
|
+
filterSummary: messageData.filterSummary || [],
|
|
562
630
|
});
|
|
563
631
|
}
|
|
564
632
|
// convert raw results to Product instances (via SearchResultStore) so
|
|
@@ -7,7 +7,7 @@ export type SearchFacetStoreConfig = {
|
|
|
7
7
|
stores: {
|
|
8
8
|
storage: StorageStore;
|
|
9
9
|
};
|
|
10
|
-
services
|
|
10
|
+
services?: StoreServices;
|
|
11
11
|
data: {
|
|
12
12
|
search?: SearchResponseModel;
|
|
13
13
|
meta: MetaResponseModel;
|
|
@@ -18,7 +18,7 @@ export declare class SearchFacetStore extends Array {
|
|
|
18
18
|
constructor(params: SearchFacetStoreConfig);
|
|
19
19
|
}
|
|
20
20
|
export declare class Facet {
|
|
21
|
-
services
|
|
21
|
+
services?: StoreServices;
|
|
22
22
|
type: 'range' | 'value' | 'range-buckets';
|
|
23
23
|
field: string;
|
|
24
24
|
filtered: boolean;
|
|
@@ -27,9 +27,9 @@ export declare class Facet {
|
|
|
27
27
|
display: string;
|
|
28
28
|
label: string;
|
|
29
29
|
storage: StorageStore;
|
|
30
|
-
constructor(services: StoreServices, storage: StorageStore, facet: SearchResponseModelFacetValue | SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacet, config: FacetStoreConfig);
|
|
30
|
+
constructor(services: StoreServices | undefined, storage: StorageStore, facet: SearchResponseModelFacetValue | SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacet, config: FacetStoreConfig);
|
|
31
31
|
get clear(): {
|
|
32
|
-
url: UrlManager;
|
|
32
|
+
url: UrlManager | undefined;
|
|
33
33
|
};
|
|
34
34
|
toggleCollapse(): void;
|
|
35
35
|
}
|
|
@@ -39,7 +39,7 @@ export declare class RangeFacet extends Facet {
|
|
|
39
39
|
active?: SearchRequestModelFilterRangeAllOfValue;
|
|
40
40
|
formatSeparator: string;
|
|
41
41
|
formatValue: string;
|
|
42
|
-
constructor(services: StoreServices, storage: StorageStore, facet: SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacetSlider, config: FacetStoreConfig);
|
|
42
|
+
constructor(services: StoreServices | undefined, storage: StorageStore, facet: SearchResponseModelFacetRange, facetMeta: MetaResponseModelFacetSlider, config: FacetStoreConfig);
|
|
43
43
|
get filteredCount(): number;
|
|
44
44
|
}
|
|
45
45
|
export declare class ValueFacet extends Facet {
|
|
@@ -57,7 +57,7 @@ export declare class ValueFacet extends Facet {
|
|
|
57
57
|
toggle: (val?: boolean) => void;
|
|
58
58
|
calculate: () => void;
|
|
59
59
|
};
|
|
60
|
-
constructor(services: StoreServices, storage: StorageStore, facet: SearchResponseModelFacetValue, facetMeta: MetaResponseModelFacet, config: FacetStoreConfig);
|
|
60
|
+
constructor(services: StoreServices | undefined, storage: StorageStore, facet: SearchResponseModelFacetValue, facetMeta: MetaResponseModelFacet, config: FacetStoreConfig);
|
|
61
61
|
get filteredCount(): number;
|
|
62
62
|
get refinedValues(): (FacetHierarchyValue | FacetValue | FacetRangeValue | undefined)[];
|
|
63
63
|
}
|
|
@@ -67,14 +67,14 @@ export declare class FacetValue {
|
|
|
67
67
|
filtered: boolean;
|
|
68
68
|
value: string;
|
|
69
69
|
custom: object;
|
|
70
|
-
url
|
|
70
|
+
url?: UrlManager;
|
|
71
71
|
preview?: () => void;
|
|
72
|
-
constructor(services: StoreServices, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
72
|
+
constructor(services: StoreServices | undefined, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
73
73
|
}
|
|
74
74
|
export declare class FacetHierarchyValue extends FacetValue {
|
|
75
75
|
level: number;
|
|
76
76
|
history: boolean;
|
|
77
|
-
constructor(services: StoreServices, facet: ValueFacet & MetaResponseModelFacetHierarchyAllOf, value: SearchResponseModelFacetValueAllOfValues, filteredValues: SearchResponseModelFacetValueAllOfValues[]);
|
|
77
|
+
constructor(services: StoreServices | undefined, facet: ValueFacet & MetaResponseModelFacetHierarchyAllOf, value: SearchResponseModelFacetValueAllOfValues, filteredValues: SearchResponseModelFacetValueAllOfValues[]);
|
|
78
78
|
}
|
|
79
79
|
export declare class FacetRangeValue {
|
|
80
80
|
label: string;
|
|
@@ -83,7 +83,7 @@ export declare class FacetRangeValue {
|
|
|
83
83
|
low: number;
|
|
84
84
|
high: number;
|
|
85
85
|
custom: object;
|
|
86
|
-
url
|
|
87
|
-
constructor(services: StoreServices, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
86
|
+
url?: UrlManager;
|
|
87
|
+
constructor(services: StoreServices | undefined, facet: ValueFacet, value: SearchResponseModelFacetValueAllOfValues);
|
|
88
88
|
}
|
|
89
89
|
//# sourceMappingURL=SearchFacetStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchFacetStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchFacetStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/G,OAAO,KAAK,EACX,sBAAsB,EAEtB,4BAA4B,EAC5B,uCAAuC,EACvC,oCAAoC,EAEpC,6BAA6B,EAC7B,6BAA6B,EAE7B,wCAAwC,EACxC,uCAAuC,EAC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services
|
|
92
|
+
url: this.services?.urlManager?.remove('page').remove(`filter.${this.field}`),
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
toggleCollapse() {
|
|
@@ -238,15 +238,18 @@ export class ValueFacet extends Facet {
|
|
|
238
238
|
export class FacetValue {
|
|
239
239
|
constructor(services, facet, value) {
|
|
240
240
|
Object.assign(this, value);
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
valueUrl =
|
|
241
|
+
const urlManager = services?.urlManager;
|
|
242
|
+
if (urlManager) {
|
|
243
|
+
if (this.filtered) {
|
|
244
|
+
this.url = urlManager.remove('page').remove(`filter.${facet.field}`, value.value);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
let valueUrl = urlManager.remove('page');
|
|
248
|
+
if (facet.multiple == 'single') {
|
|
249
|
+
valueUrl = valueUrl?.remove(`filter.${facet.field}`);
|
|
250
|
+
}
|
|
251
|
+
this.url = valueUrl?.merge(`filter.${facet.field}`, value.value);
|
|
248
252
|
}
|
|
249
|
-
this.url = valueUrl?.merge(`filter.${facet.field}`, value.value);
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
}
|
|
@@ -264,26 +267,32 @@ export class FacetHierarchyValue extends FacetValue {
|
|
|
264
267
|
this.history = true;
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
const urlManager = services?.urlManager;
|
|
271
|
+
if (urlManager) {
|
|
272
|
+
if (value.value) {
|
|
273
|
+
this.url = urlManager.remove('page').set(`filter.${facet.field}`, value.value);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
this.url = urlManager.remove('page').remove(`filter.${facet.field}`);
|
|
277
|
+
}
|
|
272
278
|
}
|
|
273
279
|
}
|
|
274
280
|
}
|
|
275
281
|
export class FacetRangeValue {
|
|
276
282
|
constructor(services, facet, value) {
|
|
277
283
|
Object.assign(this, value);
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
valueUrl =
|
|
284
|
+
const urlManager = services?.urlManager;
|
|
285
|
+
if (urlManager) {
|
|
286
|
+
if (this.filtered) {
|
|
287
|
+
this.url = urlManager.remove('page').remove(`filter.${facet.field}`, [{ low: this.low, high: this.high }]);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
let valueUrl = urlManager.remove('page');
|
|
291
|
+
if (facet.multiple == 'single') {
|
|
292
|
+
valueUrl = valueUrl?.remove(`filter.${facet.field}`);
|
|
293
|
+
}
|
|
294
|
+
this.url = valueUrl?.merge(`filter.${facet.field}`, [{ low: this.low, high: this.high }]);
|
|
285
295
|
}
|
|
286
|
-
this.url = valueUrl?.merge(`filter.${facet.field}`, [{ low: this.low, high: this.high }]);
|
|
287
296
|
}
|
|
288
297
|
}
|
|
289
298
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athoscommerce/snap-store-mobx",
|
|
3
|
-
"version": "1.2.3-beta.
|
|
3
|
+
"version": "1.2.3-beta.4+cf2eeebec",
|
|
4
4
|
"description": "Snap MobX Store",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"test:watch": "jest --watch"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@athoscommerce/snap-toolbox": "1.2.3-beta.
|
|
26
|
+
"@athoscommerce/snap-toolbox": "1.2.3-beta.4+cf2eeebec",
|
|
27
27
|
"mobx": "6.15.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@athoscommerce/snap-client": "1.2.3-beta.
|
|
31
|
-
"@athoscommerce/snap-url-manager": "1.2.3-beta.
|
|
30
|
+
"@athoscommerce/snap-client": "1.2.3-beta.4+cf2eeebec",
|
|
31
|
+
"@athoscommerce/snap-url-manager": "1.2.3-beta.4+cf2eeebec"
|
|
32
32
|
},
|
|
33
33
|
"sideEffects": false,
|
|
34
34
|
"files": [
|
|
35
35
|
"dist/**/*"
|
|
36
36
|
],
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "cf2eeebec7baf5a7746dcd90c21bccd9a5b15544"
|
|
38
38
|
}
|