@athoscommerce/snap-store-mobx 1.2.3-beta.4 → 1.2.3-beta.5
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/AutocompleteStore.d.ts +1 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.js +8 -5
- package/dist/cjs/Autocomplete/Stores/AutocompleteFacetStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/Stores/AutocompleteFacetStore.js +1 -2
- package/dist/cjs/Chat/ChatStore.d.ts +35 -6
- package/dist/cjs/Chat/ChatStore.d.ts.map +1 -1
- package/dist/cjs/Chat/ChatStore.js +201 -77
- package/dist/cjs/Chat/Stores/ChatAttachmentStore.d.ts.map +1 -1
- package/dist/cjs/Chat/Stores/ChatAttachmentStore.js +3 -3
- package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts +2 -0
- package/dist/cjs/Chat/Stores/ChatCompareStore.d.ts.map +1 -1
- package/dist/cjs/Chat/Stores/ChatCompareStore.js +4 -2
- package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts +10 -20
- package/dist/cjs/Chat/Stores/ChatSessionStore.d.ts.map +1 -1
- package/dist/cjs/Chat/Stores/ChatSessionStore.js +33 -87
- package/dist/cjs/Finder/FinderStore.d.ts +1 -1
- package/dist/cjs/Finder/FinderStore.d.ts.map +1 -1
- package/dist/cjs/Finder/FinderStore.js +3 -3
- package/dist/cjs/Finder/Stores/FinderSelectionStore.d.ts +1 -1
- package/dist/cjs/Finder/Stores/FinderSelectionStore.d.ts.map +1 -1
- package/dist/cjs/ProductQuickView/ProductQuickViewStore.d.ts +21 -0
- package/dist/cjs/ProductQuickView/ProductQuickViewStore.d.ts.map +1 -0
- package/dist/cjs/ProductQuickView/ProductQuickViewStore.js +69 -0
- package/dist/cjs/ProductQuickView/cloneProductForQuickView.d.ts +7 -0
- package/dist/cjs/ProductQuickView/cloneProductForQuickView.d.ts.map +1 -0
- package/dist/cjs/ProductQuickView/cloneProductForQuickView.js +23 -0
- package/dist/cjs/Recommendation/RecommendationStore.d.ts +2 -0
- package/dist/cjs/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/cjs/Recommendation/RecommendationStore.js +3 -0
- package/dist/cjs/Recommendation/Stores/RecommendationProfileStore.js +1 -1
- package/dist/cjs/Search/SearchStore.d.ts +1 -1
- package/dist/cjs/Search/SearchStore.d.ts.map +1 -1
- package/dist/cjs/Search/SearchStore.js +2 -2
- package/dist/cjs/Search/Stores/SearchFacetStore.d.ts +12 -12
- package/dist/cjs/Search/Stores/SearchFacetStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/SearchFacetStore.js +25 -32
- package/dist/cjs/Search/Stores/SearchHistoryStore.js +2 -2
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +8 -4
- package/dist/cjs/types.d.ts +8 -2
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.js +5 -3
- package/dist/esm/Autocomplete/Stores/AutocompleteFacetStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/Stores/AutocompleteFacetStore.js +4 -6
- package/dist/esm/Chat/ChatStore.d.ts +35 -6
- package/dist/esm/Chat/ChatStore.d.ts.map +1 -1
- package/dist/esm/Chat/ChatStore.js +188 -65
- package/dist/esm/Chat/Stores/ChatAttachmentStore.d.ts.map +1 -1
- package/dist/esm/Chat/Stores/ChatAttachmentStore.js +3 -3
- package/dist/esm/Chat/Stores/ChatCompareStore.d.ts +2 -0
- package/dist/esm/Chat/Stores/ChatCompareStore.d.ts.map +1 -1
- package/dist/esm/Chat/Stores/ChatCompareStore.js +3 -1
- package/dist/esm/Chat/Stores/ChatSessionStore.d.ts +10 -20
- package/dist/esm/Chat/Stores/ChatSessionStore.d.ts.map +1 -1
- package/dist/esm/Chat/Stores/ChatSessionStore.js +26 -86
- package/dist/esm/Finder/FinderStore.d.ts +1 -1
- package/dist/esm/Finder/FinderStore.d.ts.map +1 -1
- package/dist/esm/Finder/FinderStore.js +1 -1
- package/dist/esm/Finder/Stores/FinderSelectionStore.d.ts +1 -1
- package/dist/esm/Finder/Stores/FinderSelectionStore.d.ts.map +1 -1
- package/dist/esm/ProductQuickView/ProductQuickViewStore.d.ts +21 -0
- package/dist/esm/ProductQuickView/ProductQuickViewStore.d.ts.map +1 -0
- package/dist/esm/ProductQuickView/ProductQuickViewStore.js +56 -0
- package/dist/esm/ProductQuickView/cloneProductForQuickView.d.ts +7 -0
- package/dist/esm/ProductQuickView/cloneProductForQuickView.d.ts.map +1 -0
- package/dist/esm/ProductQuickView/cloneProductForQuickView.js +19 -0
- package/dist/esm/Recommendation/RecommendationStore.d.ts +2 -0
- package/dist/esm/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/esm/Recommendation/RecommendationStore.js +3 -0
- package/dist/esm/Recommendation/Stores/RecommendationProfileStore.js +1 -1
- package/dist/esm/Search/SearchStore.d.ts +1 -1
- package/dist/esm/Search/SearchStore.d.ts.map +1 -1
- package/dist/esm/Search/SearchStore.js +1 -1
- package/dist/esm/Search/Stores/SearchFacetStore.d.ts +12 -12
- package/dist/esm/Search/Stores/SearchFacetStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/SearchFacetStore.js +25 -31
- package/dist/esm/Search/Stores/SearchHistoryStore.js +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/types.d.ts +8 -2
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +11 -6
- package/dist/cjs/Storage/StorageStore.d.ts +0 -27
- package/dist/cjs/Storage/StorageStore.d.ts.map +0 -1
- package/dist/cjs/Storage/StorageStore.js +0 -176
- package/dist/esm/Storage/StorageStore.d.ts +0 -27
- package/dist/esm/Storage/StorageStore.d.ts.map +0 -1
- package/dist/esm/Storage/StorageStore.js +0 -169
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { ChatResponseModel, ChatRequestModel, ChatResponseTextData, ChatResponseProductSearchResultData, ChatResponseInspirationResultData, ChatResponseContentData, ChatResponseProductAnswerData, ChatResponseProductComparisonData, ChatResponseProductRecommendationData, ChatResponseErrorData, ChatResponseTopicDriftData } from '@athoscommerce/snap-client';
|
|
2
2
|
import { ChatAttachmentAddAttachment, ChatAttachmentStore } from '../Stores/ChatAttachmentStore';
|
|
3
|
-
import type { StorageStore } from '
|
|
3
|
+
import type { StorageStore } from '@athoscommerce/snap-toolbox';
|
|
4
4
|
import { MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
5
5
|
import { ChatCompareStore } from './ChatCompareStore';
|
|
6
|
-
import { SearchFacetStore } from '../../Search/Stores/SearchFacetStore';
|
|
7
6
|
export type ChatFeedbacks = {
|
|
8
7
|
messageId: string;
|
|
9
8
|
rating: 'UP' | 'DOWN';
|
|
@@ -38,28 +37,23 @@ type ChatSessionStoreConfig = {
|
|
|
38
37
|
sessionFeedback?: ChatSessionFeedback | null;
|
|
39
38
|
feedbackDismissed?: boolean;
|
|
40
39
|
createdAt?: Date;
|
|
40
|
+
sessionEndTime?: Date;
|
|
41
41
|
committedComparisons?: any[];
|
|
42
42
|
};
|
|
43
43
|
stores: {
|
|
44
44
|
storage: StorageStore;
|
|
45
45
|
};
|
|
46
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
47
|
export type ActionsData = {
|
|
59
48
|
type: 'actions';
|
|
60
49
|
data: any;
|
|
61
50
|
};
|
|
62
|
-
export type ChatActions =
|
|
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
|
+
}>;
|
|
63
57
|
export declare class ChatSessionStore {
|
|
64
58
|
chat: ChatMessage[];
|
|
65
59
|
actions: ChatActions;
|
|
@@ -73,15 +67,11 @@ export declare class ChatSessionStore {
|
|
|
73
67
|
feedbackDismissed: boolean;
|
|
74
68
|
feedbackJustGiven: boolean;
|
|
75
69
|
createdAt: Date;
|
|
70
|
+
sessionEndTime?: Date;
|
|
76
71
|
requestType: string;
|
|
77
72
|
dismissedSideChatMessageId: string | null;
|
|
78
73
|
activeMessageId: string | null;
|
|
79
74
|
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
75
|
/** Whether raw stored results have been hydrated into Product/SearchResultStore instances. */
|
|
86
76
|
hydrated: boolean;
|
|
87
77
|
constructor(params: ChatSessionStoreConfig);
|
|
@@ -107,7 +97,7 @@ export declare class ChatSessionStore {
|
|
|
107
97
|
static pruneStoredSessions(storage: StorageStore, maxSessions?: number): void;
|
|
108
98
|
/** Re-wrap raw stored results as Product / SearchResultStore instances. */
|
|
109
99
|
hydrateResults(meta: MetaResponseModel): void;
|
|
110
|
-
request(request: ChatRequestModel): void;
|
|
100
|
+
request(request: ChatRequestModel, filterLabels?: FilterLabelMap): void;
|
|
111
101
|
update(data: {
|
|
112
102
|
chat: ChatResponseModel;
|
|
113
103
|
meta: MetaResponseModel;
|
|
@@ -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,
|
|
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,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAA6B,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAsItD,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,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;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a,IAAI,WAAW,GAAG,IAAI,CAoCtC;IAEM,iBAAiB,IAAI,IAAI;IAKzB,gBAAgB,IAAI,MAAM,GAAG,SAAS;IAsBtC,KAAK,IAAI,IAAI;IAQpB,OAAO,CAAC,WAAW,CAA8C;IAEjE,gEAAgE;IACzD,aAAa,IAAI,IAAI;IAoB5B;;;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;IAmC7C,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,YAAY,CAAC,EAAE,cAAc,GAAG,IAAI;IA6IvE,MAAM,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,iBAAiB,CAAC;QAAC,IAAI,EAAE,iBAAiB,CAAA;KAAE,GAAG,IAAI;CAyC/E"}
|
|
@@ -17,7 +17,6 @@ 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");
|
|
21
20
|
function createChatResultStore(results, meta) {
|
|
22
21
|
return new SearchResultStore_1.SearchResultStore({
|
|
23
22
|
config: {},
|
|
@@ -36,16 +35,6 @@ function createChatProduct(result, meta) {
|
|
|
36
35
|
responseId: '',
|
|
37
36
|
});
|
|
38
37
|
}
|
|
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
|
-
}
|
|
49
38
|
/** Extract raw serializable data from a Product instance for storage. */
|
|
50
39
|
function serializeProduct(product) {
|
|
51
40
|
var _a, _b;
|
|
@@ -145,44 +134,6 @@ function serializeChatForStorage(chat) {
|
|
|
145
134
|
}
|
|
146
135
|
});
|
|
147
136
|
}
|
|
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
|
-
}
|
|
186
137
|
var ChatSessionStore = /** @class */ (function () {
|
|
187
138
|
function ChatSessionStore(params) {
|
|
188
139
|
this.chat = [];
|
|
@@ -198,25 +149,24 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
198
149
|
this.dismissedSideChatMessageId = null;
|
|
199
150
|
this.activeMessageId = null;
|
|
200
151
|
this.sessionLimitReached = false;
|
|
201
|
-
/** Tracks server-filtered facets the user has explicitly unselected (pending next request). */
|
|
202
|
-
this.removedFacets = [];
|
|
203
152
|
/** Whether raw stored results have been hydrated into Product/SearchResultStore instances. */
|
|
204
153
|
this.hydrated = true;
|
|
205
154
|
this.saveTimerId = null;
|
|
206
|
-
var _a = params.data || {}, id = _a.id, sessionId = _a.sessionId, chat = _a.chat, attachments = _a.attachments, actions = _a.actions, feedbacks = _a.feedbacks, sessionFeedback = _a.sessionFeedback, feedbackDismissed = _a.feedbackDismissed, createdAt = _a.createdAt, committedComparisons = _a.committedComparisons;
|
|
155
|
+
var _a = params.data || {}, id = _a.id, sessionId = _a.sessionId, chat = _a.chat, attachments = _a.attachments, actions = _a.actions, feedbacks = _a.feedbacks, sessionFeedback = _a.sessionFeedback, feedbackDismissed = _a.feedbackDismissed, createdAt = _a.createdAt, sessionEndTime = _a.sessionEndTime, committedComparisons = _a.committedComparisons;
|
|
207
156
|
var stores = params.stores;
|
|
208
157
|
this.id = id || (0, uuid_1.v4)();
|
|
209
158
|
this.sessionId = sessionId;
|
|
210
159
|
this.storage = stores.storage;
|
|
211
160
|
this.actions = actions || [];
|
|
212
161
|
this.createdAt = createdAt ? new Date(createdAt) : new Date();
|
|
162
|
+
this.sessionEndTime = sessionEndTime ? new Date(sessionEndTime) : undefined;
|
|
213
163
|
this.feedbacks = feedbacks || [];
|
|
214
164
|
this.sessionFeedback = sessionFeedback || null;
|
|
215
165
|
this.feedbackDismissed = feedbackDismissed || false;
|
|
216
166
|
// if chat and attachments are passed, load them
|
|
217
167
|
if (chat && chat.length > 0) {
|
|
218
168
|
// productQuery messages only exist to drive the side-chat panel for an
|
|
219
|
-
// in-flight
|
|
169
|
+
// in-flight productQuery click; they must not be rehydrated on reload
|
|
220
170
|
// or the side chat would re-open without the matching primary-chat state
|
|
221
171
|
this.chat = chat.filter(function (message) { return message.messageType !== 'productQuery'; });
|
|
222
172
|
}
|
|
@@ -262,7 +212,6 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
262
212
|
dismissedSideChatMessageId: mobx_1.observable,
|
|
263
213
|
activeMessageId: mobx_1.observable,
|
|
264
214
|
sessionLimitReached: mobx_1.observable,
|
|
265
|
-
removedFacets: mobx_1.observable,
|
|
266
215
|
activeMessage: mobx_1.computed,
|
|
267
216
|
});
|
|
268
217
|
}
|
|
@@ -285,7 +234,7 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
285
234
|
// capture the side-chat message that was active at click time so a back action
|
|
286
235
|
// can restore it even when it's not the last message in the chat
|
|
287
236
|
var sourceMessageId = (_a = this.activeMessage) === null || _a === void 0 ? void 0 : _a.id;
|
|
288
|
-
// drop any trailing productQuery so a fresh
|
|
237
|
+
// drop any trailing productQuery so a fresh productQuery click replaces
|
|
289
238
|
// the side-chat target rather than stacking up
|
|
290
239
|
while (this.chat.length > 0 && ((_b = this.chat[this.chat.length - 1]) === null || _b === void 0 ? void 0 : _b.messageType) === 'productQuery') {
|
|
291
240
|
this.chat.pop();
|
|
@@ -311,10 +260,13 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
311
260
|
};
|
|
312
261
|
Object.defineProperty(ChatSessionStore.prototype, "isExpired", {
|
|
313
262
|
get: function () {
|
|
263
|
+
// Prefer the server-provided end time (returned by chatInit); fall back to a
|
|
264
|
+
// 24-hour window from createdAt for sessions persisted before that field existed.
|
|
265
|
+
if (this.sessionEndTime) {
|
|
266
|
+
return Date.now() > this.sessionEndTime.getTime();
|
|
267
|
+
}
|
|
314
268
|
var ONE_DAY = 24 * 60 * 60 * 1000;
|
|
315
|
-
|
|
316
|
-
var diff = now.getTime() - this.createdAt.getTime();
|
|
317
|
-
return diff > ONE_DAY;
|
|
269
|
+
return Date.now() - this.createdAt.getTime() > ONE_DAY;
|
|
318
270
|
},
|
|
319
271
|
enumerable: false,
|
|
320
272
|
configurable: true
|
|
@@ -392,7 +344,6 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
392
344
|
this.attachments.reset();
|
|
393
345
|
this.chat = [];
|
|
394
346
|
this.actions = [];
|
|
395
|
-
this.removedFacets = [];
|
|
396
347
|
this.feedbacks = [];
|
|
397
348
|
this.sessionFeedback = null;
|
|
398
349
|
};
|
|
@@ -406,11 +357,12 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
406
357
|
sessionId: this.sessionId,
|
|
407
358
|
chat: serializeChatForStorage(this.chat),
|
|
408
359
|
attachments: serializeAttachmentsForStorage(this.attachments.items),
|
|
409
|
-
actions:
|
|
360
|
+
actions: this.actions,
|
|
410
361
|
feedbacks: this.feedbacks,
|
|
411
362
|
sessionFeedback: this.sessionFeedback,
|
|
412
363
|
feedbackDismissed: this.feedbackDismissed,
|
|
413
364
|
createdAt: this.createdAt,
|
|
365
|
+
sessionEndTime: this.sessionEndTime,
|
|
414
366
|
committedComparisons: this.comparisons.committedItems,
|
|
415
367
|
});
|
|
416
368
|
};
|
|
@@ -451,7 +403,6 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
451
403
|
};
|
|
452
404
|
/** Re-wrap raw stored results as Product / SearchResultStore instances. */
|
|
453
405
|
ChatSessionStore.prototype.hydrateResults = function (meta) {
|
|
454
|
-
var _this = this;
|
|
455
406
|
this.chat.forEach(function (message) {
|
|
456
407
|
var _a, _b, _c, _d;
|
|
457
408
|
if (message.messageType === 'productSearchResult') {
|
|
@@ -491,20 +442,12 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
491
442
|
});
|
|
492
443
|
}
|
|
493
444
|
});
|
|
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
|
-
});
|
|
501
445
|
};
|
|
502
|
-
ChatSessionStore.prototype.request = function (request) {
|
|
446
|
+
ChatSessionStore.prototype.request = function (request, filterLabels) {
|
|
503
447
|
var _this = this;
|
|
504
448
|
var _a, _b;
|
|
505
449
|
// clear the questions on new request
|
|
506
450
|
this.actions = [];
|
|
507
|
-
this.removedFacets = [];
|
|
508
451
|
this.requestType = request.data.requestType;
|
|
509
452
|
this.activeMessageId = null;
|
|
510
453
|
// remove any attachments that failed to upload
|
|
@@ -516,11 +459,21 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
516
459
|
if (searchFilters && searchFilters.length > 0) {
|
|
517
460
|
var filterTextArray_1 = [];
|
|
518
461
|
searchFilters.forEach(function (filter) {
|
|
519
|
-
var
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
462
|
+
var _a;
|
|
463
|
+
var labelEntry = filterLabels === null || filterLabels === void 0 ? void 0 : filterLabels[filter.key];
|
|
464
|
+
(_a = filter.options) === null || _a === void 0 ? void 0 : _a.forEach(function (option) {
|
|
465
|
+
var _a, _b;
|
|
466
|
+
var facetLabel = (labelEntry === null || labelEntry === void 0 ? void 0 : labelEntry.facetLabel) || filter.key;
|
|
467
|
+
if ('low' in option || 'high' in option) {
|
|
468
|
+
var low = (_a = option.low) !== null && _a !== void 0 ? _a : '*';
|
|
469
|
+
var high = (_b = option.high) !== null && _b !== void 0 ? _b : '*';
|
|
470
|
+
filterTextArray_1.push("".concat(facetLabel, " ").concat(low, "-").concat(high));
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
var key = option.key;
|
|
474
|
+
var optionLabel = (labelEntry === null || labelEntry === void 0 ? void 0 : labelEntry.values[key]) || key;
|
|
475
|
+
filterTextArray_1.push("".concat(facetLabel, " ").concat(optionLabel));
|
|
476
|
+
}
|
|
524
477
|
});
|
|
525
478
|
});
|
|
526
479
|
this.chat.push({
|
|
@@ -639,7 +592,7 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
639
592
|
this.sessionId = data.chat.context.sessionId;
|
|
640
593
|
var meta = data.meta;
|
|
641
594
|
data.chat.data.forEach(function (messageData) {
|
|
642
|
-
var _a, _b, _c, _d
|
|
595
|
+
var _a, _b, _c, _d;
|
|
643
596
|
// check if the data has questions?
|
|
644
597
|
if (messageData.messageType === 'actions') {
|
|
645
598
|
_this.actions.push({
|
|
@@ -648,19 +601,12 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
648
601
|
});
|
|
649
602
|
return;
|
|
650
603
|
}
|
|
651
|
-
if (messageData.messageType === 'productSearchResult' && ((_a = messageData.facets) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
652
|
-
_this.actions.push({
|
|
653
|
-
type: 'facets',
|
|
654
|
-
data: createChatFacetStore(messageData.facets, meta, _this.storage),
|
|
655
|
-
filterSummary: messageData.filterSummary || [],
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
604
|
// convert raw results to Product instances (via SearchResultStore) so
|
|
659
605
|
// display components can use result.display for mask-aware rendering
|
|
660
|
-
if (messageData.messageType === 'productSearchResult' && ((
|
|
606
|
+
if (messageData.messageType === 'productSearchResult' && ((_a = messageData.results) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
661
607
|
messageData.results = createChatResultStore(messageData.results, meta);
|
|
662
608
|
}
|
|
663
|
-
else if (messageData.messageType === 'inspirationResult' && ((
|
|
609
|
+
else if (messageData.messageType === 'inspirationResult' && ((_b = messageData.inspirationSections) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
664
610
|
messageData.inspirationSections = messageData.inspirationSections.map(function (section) {
|
|
665
611
|
var _a;
|
|
666
612
|
return (__assign(__assign({}, section), { products: ((_a = section.products) === null || _a === void 0 ? void 0 : _a.length)
|
|
@@ -671,10 +617,10 @@ var ChatSessionStore = /** @class */ (function () {
|
|
|
671
617
|
else if (messageData.messageType === 'productAnswer' && messageData.sourceProduct) {
|
|
672
618
|
messageData.sourceProduct = createChatProduct(messageData.sourceProduct, meta);
|
|
673
619
|
}
|
|
674
|
-
else if (messageData.messageType === 'productComparison' && ((
|
|
620
|
+
else if (messageData.messageType === 'productComparison' && ((_c = messageData.searchResults) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
675
621
|
messageData.searchResults = createChatResultStore(messageData.searchResults, meta);
|
|
676
622
|
}
|
|
677
|
-
else if (messageData.messageType === 'productRecommendation' && ((
|
|
623
|
+
else if (messageData.messageType === 'productRecommendation' && ((_d = messageData.recommendationResult) === null || _d === void 0 ? void 0 : _d.length)) {
|
|
678
624
|
messageData.recommendationResult = messageData.recommendationResult.map(function (rec) {
|
|
679
625
|
var _a;
|
|
680
626
|
return (__assign(__assign({}, rec), { results: ((_a = rec.results) === null || _a === void 0 ? void 0 : _a.length) ? createChatResultStore(rec.results, meta) : rec.results }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SearchResponseModel, MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
2
|
+
import { StorageStore } from '@athoscommerce/snap-toolbox';
|
|
2
3
|
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
3
4
|
import { SearchPaginationStore } from '../Search/Stores';
|
|
4
|
-
import { StorageStore } from '../Storage/StorageStore';
|
|
5
5
|
import { FinderSelectionStore } from './Stores';
|
|
6
6
|
import type { FinderStoreConfig, StoreServices, SelectedSelection } from '../types';
|
|
7
7
|
import { UrlManager } from '@athoscommerce/snap-url-manager';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FinderStore.d.ts","sourceRoot":"","sources":["../../../src/Finder/FinderStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO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,GAAG,IAAI;CAsDhI"}
|
|
@@ -28,9 +28,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.FinderStore = void 0;
|
|
30
30
|
var mobx_1 = require("mobx");
|
|
31
|
+
var snap_toolbox_1 = require("@athoscommerce/snap-toolbox");
|
|
31
32
|
var AbstractStore_1 = require("../Abstract/AbstractStore");
|
|
32
33
|
var Stores_1 = require("../Search/Stores");
|
|
33
|
-
var StorageStore_1 = require("../Storage/StorageStore");
|
|
34
34
|
var Stores_2 = require("./Stores");
|
|
35
35
|
var MetaStore_1 = require("../Meta/MetaStore");
|
|
36
36
|
var FinderStore = /** @class */ (function (_super) {
|
|
@@ -59,12 +59,12 @@ var FinderStore = /** @class */ (function (_super) {
|
|
|
59
59
|
}
|
|
60
60
|
_this.services = services;
|
|
61
61
|
if ((_b = _this.config.persist) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
62
|
-
_this.persistedStorage = new
|
|
62
|
+
_this.persistedStorage = new snap_toolbox_1.StorageStore({
|
|
63
63
|
type: 'local',
|
|
64
64
|
key: "athos-".concat(_this.config.id, "-persisted"),
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
_this.storage = new
|
|
67
|
+
_this.storage = new snap_toolbox_1.StorageStore();
|
|
68
68
|
_this.update();
|
|
69
69
|
(0, mobx_1.makeObservable)(_this, {
|
|
70
70
|
selections: mobx_1.observable,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FinderStoreConfig, FinderFieldConfig, StoreServices, SelectedSelection } from '../../types';
|
|
2
|
-
import type { StorageStore } from '
|
|
2
|
+
import type { StorageStore } from '@athoscommerce/snap-toolbox';
|
|
3
3
|
import type { MetaResponseModel, MetaResponseModelFacetGrid, MetaResponseModelFacetHierarchy, MetaResponseModelFacetList, MetaResponseModelFacetPalette, MetaResponseModelFacetSlider, SearchResponseModel, SearchResponseModelFacetRange, SearchResponseModelFacetRangeBuckets, SearchResponseModelFacetValue, SearchResponseModelFacetValueAllOfValues } from '@athoscommerce/snapi-types';
|
|
4
4
|
type FacetWithMeta = MetaResponseModelFacetGrid & MetaResponseModelFacetHierarchy & MetaResponseModelFacetList & MetaResponseModelFacetPalette & MetaResponseModelFacetSlider & SearchResponseModelFacetValue & SearchResponseModelFacetRange & SearchResponseModelFacetRangeBuckets;
|
|
5
5
|
type FinderSelectionStoreConfig = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FinderSelectionStore.d.ts","sourceRoot":"","sources":["../../../../src/Finder/Stores/FinderSelectionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"FinderSelectionStore.d.ts","sourceRoot":"","sources":["../../../../src/Finder/Stores/FinderSelectionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EACX,iBAAiB,EACjB,0BAA0B,EAC1B,+BAA+B,EAC/B,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,mBAAmB,EACnB,6BAA6B,EAC7B,oCAAoC,EACpC,6BAA6B,EAC7B,wCAAwC,EACxC,MAAM,4BAA4B,CAAC;AAEpC,KAAK,aAAa,GAAG,0BAA0B,GAC9C,+BAA+B,GAC/B,0BAA0B,GAC1B,6BAA6B,GAC7B,4BAA4B,GAC5B,6BAA6B,GAC7B,6BAA6B,GAC7B,oCAAoC,CAAC;AAEtC,KAAK,0BAA0B,GAAG;IACjC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,Q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B,CAAC;CACF,CAAC;AAEF,cAAM,SAAU,SAAQ,aAAa;IAC7B,MAAM,EAAG,iBAAiB,CAAC;gBAEtB,aAAa,EAAE,aAAa;IAejC,MAAM,CAAC,KAAK,SAAK;CAWxB;AAED,cAAM,kBAAmB,SAAQ,aAAa;IACtC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAG,WAAW,CAAC;gBAEhB,aAAa,EAAE,aAAa;IAuCjC,MAAM,CAAC,KAAK,SAAK;CA2BxB;AAED,KAAK,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
2
|
+
import type { ProductsResponseModel } from '@athoscommerce/snap-client';
|
|
3
|
+
import { Product } from '../Search/Stores/SearchResultStore';
|
|
4
|
+
/** Composable store holding the currently-displayed quickview product, plus the
|
|
5
|
+
* fetch/error state used by a ProductQuickView UI. Any results-bearing store
|
|
6
|
+
* (Recommendation, Search, Autocomplete, Chat) can hold one as a property. */
|
|
7
|
+
export declare class ProductQuickViewStore {
|
|
8
|
+
product: Product | null;
|
|
9
|
+
error: string | null;
|
|
10
|
+
loading: boolean;
|
|
11
|
+
constructor();
|
|
12
|
+
/** Clone the supplied product and stash it as the quickview target. The clone
|
|
13
|
+
* isolates variant selections and mapping merges from the originating result. */
|
|
14
|
+
set(product: Product, meta?: MetaResponseModel): void;
|
|
15
|
+
/** Merge the parent-level products API response into the cloned product —
|
|
16
|
+
* core mappings get merged in and Variants are created or updated in place. */
|
|
17
|
+
update(response: ProductsResponseModel, meta?: MetaResponseModel): void;
|
|
18
|
+
setError(message: string): void;
|
|
19
|
+
clear(): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ProductQuickViewStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductQuickViewStore.d.ts","sourceRoot":"","sources":["../../../src/ProductQuickView/ProductQuickViewStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,OAAO,EAAY,MAAM,oCAAoC,CAAC;AAGvE;;8EAE8E;AAC9E,qBAAa,qBAAqB;IAC1B,OAAO,EAAE,OAAO,GAAG,IAAI,CAAQ;IAC/B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC5B,OAAO,EAAE,OAAO,CAAS;;IAUhC;qFACiF;IAC1E,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAK5D;mFAC+E;IACxE,MAAM,CAAC,QAAQ,EAAE,qBAAqB,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAuBvE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI/B,KAAK,IAAI,IAAI;CAKpB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ProductQuickViewStore = void 0;
|
|
15
|
+
var mobx_1 = require("mobx");
|
|
16
|
+
var SearchResultStore_1 = require("../Search/Stores/SearchResultStore");
|
|
17
|
+
var cloneProductForQuickView_1 = require("./cloneProductForQuickView");
|
|
18
|
+
/** Composable store holding the currently-displayed quickview product, plus the
|
|
19
|
+
* fetch/error state used by a ProductQuickView UI. Any results-bearing store
|
|
20
|
+
* (Recommendation, Search, Autocomplete, Chat) can hold one as a property. */
|
|
21
|
+
var ProductQuickViewStore = /** @class */ (function () {
|
|
22
|
+
function ProductQuickViewStore() {
|
|
23
|
+
this.product = null;
|
|
24
|
+
this.error = null;
|
|
25
|
+
this.loading = false;
|
|
26
|
+
(0, mobx_1.makeObservable)(this, {
|
|
27
|
+
product: mobx_1.observable,
|
|
28
|
+
error: mobx_1.observable,
|
|
29
|
+
loading: mobx_1.observable,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** Clone the supplied product and stash it as the quickview target. The clone
|
|
33
|
+
* isolates variant selections and mapping merges from the originating result. */
|
|
34
|
+
ProductQuickViewStore.prototype.set = function (product, meta) {
|
|
35
|
+
this.product = (0, cloneProductForQuickView_1.cloneProductForQuickView)(product, meta);
|
|
36
|
+
this.error = null;
|
|
37
|
+
};
|
|
38
|
+
/** Merge the parent-level products API response into the cloned product —
|
|
39
|
+
* core mappings get merged in and Variants are created or updated in place. */
|
|
40
|
+
ProductQuickViewStore.prototype.update = function (response, meta) {
|
|
41
|
+
if (!this.product)
|
|
42
|
+
return;
|
|
43
|
+
this.product.mappings = __assign(__assign({}, this.product.mappings), { core: __assign(__assign({}, this.product.mappings.core), response.mappings.core) });
|
|
44
|
+
if (this.product.variants) {
|
|
45
|
+
this.product.variants.optionConfig = response.variants.optionConfig;
|
|
46
|
+
this.product.variants.update(response.variants.data);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.product.variants = new SearchResultStore_1.Variants({
|
|
50
|
+
data: {
|
|
51
|
+
mask: this.product.mask,
|
|
52
|
+
variants: response.variants.data,
|
|
53
|
+
optionConfig: response.variants.optionConfig,
|
|
54
|
+
meta: meta || {},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
ProductQuickViewStore.prototype.setError = function (message) {
|
|
60
|
+
this.error = message;
|
|
61
|
+
};
|
|
62
|
+
ProductQuickViewStore.prototype.clear = function () {
|
|
63
|
+
this.product = null;
|
|
64
|
+
this.error = null;
|
|
65
|
+
this.loading = false;
|
|
66
|
+
};
|
|
67
|
+
return ProductQuickViewStore;
|
|
68
|
+
}());
|
|
69
|
+
exports.ProductQuickViewStore = ProductQuickViewStore;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
2
|
+
import { Product } from '../Search/Stores/SearchResultStore';
|
|
3
|
+
/** Build a fresh observable Product from an existing one. Variants are intentionally
|
|
4
|
+
* omitted — they're populated from the products API response after the clone is set
|
|
5
|
+
* on the quickview store. */
|
|
6
|
+
export declare function cloneProductForQuickView(product: Product, meta: MetaResponseModel | undefined): Product;
|
|
7
|
+
//# sourceMappingURL=cloneProductForQuickView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloneProductForQuickView.d.ts","sourceRoot":"","sources":["../../../src/ProductQuickView/cloneProductForQuickView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAE7D;;6BAE6B;AAC7B,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAcvG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cloneProductForQuickView = cloneProductForQuickView;
|
|
4
|
+
var SearchResultStore_1 = require("../Search/Stores/SearchResultStore");
|
|
5
|
+
/** Build a fresh observable Product from an existing one. Variants are intentionally
|
|
6
|
+
* omitted — they're populated from the products API response after the clone is set
|
|
7
|
+
* on the quickview store. */
|
|
8
|
+
function cloneProductForQuickView(product, meta) {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
var result = {
|
|
11
|
+
id: product.id,
|
|
12
|
+
responseId: product.responseId,
|
|
13
|
+
mappings: JSON.parse(JSON.stringify(product.mappings || {})),
|
|
14
|
+
attributes: JSON.parse(JSON.stringify(product.attributes || {})),
|
|
15
|
+
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 }); })) || [],
|
|
16
|
+
};
|
|
17
|
+
return new SearchResultStore_1.Product({
|
|
18
|
+
config: {},
|
|
19
|
+
data: { result: result, meta: meta || {} },
|
|
20
|
+
position: (_c = product.position) !== null && _c !== void 0 ? _c : 0,
|
|
21
|
+
responseId: product.responseId,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -5,6 +5,7 @@ import { RecommendationProfileStore } from './Stores';
|
|
|
5
5
|
import type { RecommendationStoreConfig, StoreServices } from '../types';
|
|
6
6
|
import type { RecommendCombinedResponseModel } from '@athoscommerce/snap-client';
|
|
7
7
|
import { MetaStore } from '../Meta/MetaStore';
|
|
8
|
+
import { ProductQuickViewStore } from '../ProductQuickView/ProductQuickViewStore';
|
|
8
9
|
export declare class RecommendationStore extends AbstractStore<RecommendationStoreConfig> {
|
|
9
10
|
services: StoreServices;
|
|
10
11
|
meta?: MetaStore;
|
|
@@ -12,6 +13,7 @@ export declare class RecommendationStore extends AbstractStore<RecommendationSto
|
|
|
12
13
|
profile: RecommendationProfileStore | Record<string, any>;
|
|
13
14
|
results: Product[];
|
|
14
15
|
cart?: CartStore;
|
|
16
|
+
productQuickView: ProductQuickViewStore;
|
|
15
17
|
constructor(config: RecommendationStoreConfig, services: StoreServices);
|
|
16
18
|
reset(): void;
|
|
17
19
|
update(data: RecommendCombinedResponseModel): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecommendationStore.d.ts","sourceRoot":"","sources":["../../../src/Recommendation/RecommendationStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAqB,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"RecommendationStore.d.ts","sourceRoot":"","sources":["../../../src/Recommendation/RecommendationStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAqB,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAElF,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,yBAAyB,CAAC;IACzE,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,UAAS;IACf,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IAC/D,OAAO,EAAE,OAAO,EAAE,CAAM;IACxB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,gBAAgB,EAAE,qBAAqB,CAA+B;gBAEjE,MAAM,EAAE,yBAAyB,EAAE,QAAQ,EAAE,aAAa;IAgB/D,KAAK,IAAI,IAAI;IAOb,MAAM,CAAC,IAAI,EAAE,8BAA8B,GAAG,IAAI;CA+CzD"}
|
|
@@ -26,6 +26,7 @@ var Stores_1 = require("../Search/Stores");
|
|
|
26
26
|
var CartStore_1 = require("../Cart/CartStore");
|
|
27
27
|
var Stores_2 = require("./Stores");
|
|
28
28
|
var MetaStore_1 = require("../Meta/MetaStore");
|
|
29
|
+
var ProductQuickViewStore_1 = require("../ProductQuickView/ProductQuickViewStore");
|
|
29
30
|
var RecommendationStore = /** @class */ (function (_super) {
|
|
30
31
|
__extends(RecommendationStore, _super);
|
|
31
32
|
function RecommendationStore(config, services) {
|
|
@@ -34,6 +35,7 @@ var RecommendationStore = /** @class */ (function (_super) {
|
|
|
34
35
|
_this.loaded = false;
|
|
35
36
|
_this.profile = {};
|
|
36
37
|
_this.results = [];
|
|
38
|
+
_this.productQuickView = new ProductQuickViewStore_1.ProductQuickViewStore();
|
|
37
39
|
if (typeof services != 'object' || typeof ((_a = services.urlManager) === null || _a === void 0 ? void 0 : _a.subscribe) != 'function') {
|
|
38
40
|
throw new Error("Invalid service 'urlManager' passed to AutocompleteStore. Missing \"subscribe\" function.");
|
|
39
41
|
}
|
|
@@ -41,6 +43,7 @@ var RecommendationStore = /** @class */ (function (_super) {
|
|
|
41
43
|
(0, mobx_1.makeObservable)(_this, {
|
|
42
44
|
profile: mobx_1.observable,
|
|
43
45
|
results: mobx_1.observable,
|
|
46
|
+
productQuickView: mobx_1.observable,
|
|
44
47
|
});
|
|
45
48
|
return _this;
|
|
46
49
|
}
|
|
@@ -17,7 +17,7 @@ var RecommendationProfileStore = /** @class */ (function () {
|
|
|
17
17
|
this.tag = profile.tag;
|
|
18
18
|
this.placement = profile.placement;
|
|
19
19
|
this.display = profile.display;
|
|
20
|
-
this.type = profile.
|
|
20
|
+
this.type = profile.isBundle ? 'bundle' : 'default';
|
|
21
21
|
(0, mobx_1.makeObservable)(this, {
|
|
22
22
|
tag: mobx_1.observable,
|
|
23
23
|
placement: mobx_1.observable,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SearchResponseModel, MetaResponseModel } from '@athoscommerce/snapi-types';
|
|
2
|
+
import { StorageStore } from '@athoscommerce/snap-toolbox';
|
|
2
3
|
import type { SearchStoreConfig, StoreServices } from '../types';
|
|
3
4
|
import { SearchMerchandisingStore, SearchFacetStore, SearchFilterStore, SearchResultStore, SearchPaginationStore, SearchSortingStore, SearchQueryStore, SearchHistoryStore } from './Stores';
|
|
4
5
|
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
5
|
-
import { StorageStore } from '../Storage/StorageStore';
|
|
6
6
|
import { MetaStore } from '../Meta/MetaStore';
|
|
7
7
|
export declare class SearchStore extends AbstractStore<SearchStoreConfig> {
|
|
8
8
|
private previousSearch?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchStore.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EACN,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SearchStore.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,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