@searchspring/snap-store-mobx 0.54.0 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts +2 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/cjs/Autocomplete/AutocompleteStore.js +7 -6
- package/dist/cjs/Finder/FinderStore.d.ts +3 -2
- package/dist/cjs/Finder/FinderStore.d.ts.map +1 -1
- package/dist/cjs/Finder/FinderStore.js +5 -5
- package/dist/cjs/Meta/MetaStore.d.ts +15 -0
- package/dist/cjs/Meta/MetaStore.d.ts.map +1 -0
- package/dist/cjs/Meta/MetaStore.js +54 -0
- package/dist/cjs/Recommendation/RecommendationStore.d.ts +6 -1
- package/dist/cjs/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/cjs/Recommendation/RecommendationStore.js +3 -1
- package/dist/cjs/Search/SearchStore.d.ts +2 -1
- package/dist/cjs/Search/SearchStore.d.ts.map +1 -1
- package/dist/cjs/Search/SearchStore.js +7 -6
- package/dist/cjs/Search/Stores/SearchHistoryStore.js +1 -1
- package/dist/cjs/Search/Stores/SearchResultStore.d.ts +12 -4
- package/dist/cjs/Search/Stores/SearchResultStore.d.ts.map +1 -1
- package/dist/cjs/Search/Stores/SearchResultStore.js +63 -4
- package/dist/cjs/Storage/StorageStore.d.ts +5 -5
- package/dist/cjs/Storage/StorageStore.d.ts.map +1 -1
- package/dist/cjs/Storage/StorageStore.js +17 -17
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/types.d.ts +2 -1
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts +2 -1
- package/dist/esm/Autocomplete/AutocompleteStore.d.ts.map +1 -1
- package/dist/esm/Autocomplete/AutocompleteStore.js +7 -6
- package/dist/esm/Finder/FinderStore.d.ts +3 -2
- package/dist/esm/Finder/FinderStore.d.ts.map +1 -1
- package/dist/esm/Finder/FinderStore.js +6 -6
- package/dist/esm/Meta/MetaStore.d.ts +15 -0
- package/dist/esm/Meta/MetaStore.d.ts.map +1 -0
- package/dist/esm/Meta/MetaStore.js +44 -0
- package/dist/esm/Recommendation/RecommendationStore.d.ts +6 -1
- package/dist/esm/Recommendation/RecommendationStore.d.ts.map +1 -1
- package/dist/esm/Recommendation/RecommendationStore.js +3 -1
- package/dist/esm/Search/SearchStore.d.ts +2 -1
- package/dist/esm/Search/SearchStore.d.ts.map +1 -1
- package/dist/esm/Search/SearchStore.js +7 -6
- package/dist/esm/Search/Stores/SearchHistoryStore.js +2 -2
- package/dist/esm/Search/Stores/SearchResultStore.d.ts +12 -4
- package/dist/esm/Search/Stores/SearchResultStore.d.ts.map +1 -1
- package/dist/esm/Search/Stores/SearchResultStore.js +53 -3
- package/dist/esm/Storage/StorageStore.d.ts +5 -5
- package/dist/esm/Storage/StorageStore.d.ts.map +1 -1
- package/dist/esm/Storage/StorageStore.js +17 -17
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/types.d.ts +2 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -6,9 +6,10 @@ import { AutocompleteStateStore, AutocompleteTermStore, AutocompleteQueryStore,
|
|
|
6
6
|
import type { AutocompleteResponseModel, MetaResponseModel } from '@searchspring/snapi-types';
|
|
7
7
|
import type { TrendingResponseModel } from '@searchspring/snap-client';
|
|
8
8
|
import type { AutocompleteStoreConfig, StoreServices } from '../types';
|
|
9
|
+
import { MetaStore } from '../Meta/MetaStore';
|
|
9
10
|
export declare class AutocompleteStore extends AbstractStore {
|
|
10
11
|
services: StoreServices;
|
|
11
|
-
meta:
|
|
12
|
+
meta: MetaStore;
|
|
12
13
|
merchandising: SearchMerchandisingStore;
|
|
13
14
|
search: AutocompleteQueryStore;
|
|
14
15
|
terms: AutocompleteTermStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteStore.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"AutocompleteStore.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,MAAM,UAAU,CAA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stractStore_1 = require("../Abstract/AbstractStore");
|
|
|
21
21
|
var Stores_1 = require("../Search/Stores");
|
|
22
22
|
var StorageStore_1 = require("../Storage/StorageStore");
|
|
23
23
|
var Stores_2 = require("./Stores");
|
|
24
|
+
var MetaStore_1 = require("../Meta/MetaStore");
|
|
24
25
|
var AutocompleteStore = /** @class */ (function (_super) {
|
|
25
26
|
__extends(AutocompleteStore, _super);
|
|
26
27
|
function AutocompleteStore(config, services) {
|
|
@@ -106,7 +107,7 @@ var AutocompleteStore = /** @class */ (function (_super) {
|
|
|
106
107
|
return;
|
|
107
108
|
this.error = undefined;
|
|
108
109
|
this.loaded = !!data.pagination;
|
|
109
|
-
this.meta = data.meta
|
|
110
|
+
this.meta = new MetaStore_1.MetaStore(data.meta);
|
|
110
111
|
// set the query to match the actual queried term and not the input query
|
|
111
112
|
if (data.search) {
|
|
112
113
|
this.state.url = this.services.urlManager = this.services.urlManager.set('query', data.search.query);
|
|
@@ -123,17 +124,17 @@ var AutocompleteStore = /** @class */ (function (_super) {
|
|
|
123
124
|
this.search = new Stores_2.AutocompleteQueryStore(this.services, data.autocomplete || {}, data.search || {}, this.config);
|
|
124
125
|
// only run if we want to update the facets (not locked)
|
|
125
126
|
if (!this.state.locks.facets.locked) {
|
|
126
|
-
this.facets = new Stores_2.AutocompleteFacetStore(this.config, this.services, this.storage, data.facets || [], data.pagination || {}, this.meta, this.state, data.merchandising || {});
|
|
127
|
+
this.facets = new Stores_2.AutocompleteFacetStore(this.config, this.services, this.storage, data.facets || [], data.pagination || {}, this.meta.data, this.state, data.merchandising || {});
|
|
127
128
|
}
|
|
128
|
-
this.filters = new Stores_1.SearchFilterStore(this.services, data.filters, this.meta);
|
|
129
|
-
this.results = new Stores_1.SearchResultStore(this.config, this.services, data.results || [], data.pagination, data.merchandising);
|
|
129
|
+
this.filters = new Stores_1.SearchFilterStore(this.services, data.filters, this.meta.data);
|
|
130
|
+
this.results = new Stores_1.SearchResultStore(this.config, this.services, this.meta.data, data.results || [], data.pagination, data.merchandising);
|
|
130
131
|
if ((this.results.length === 0 && !this.trending.filter(function (term) { return term.active; }).length) || ((_a = this.terms) === null || _a === void 0 ? void 0 : _a.filter(function (term) { return term.active; }).length)) {
|
|
131
132
|
// if a trending term was selected and then a subsequent search yields no results, reset trending terms to remove active state
|
|
132
133
|
// OR if any terms are active, also reset to ensure only a single term or trending term is active
|
|
133
134
|
this.resetTrending();
|
|
134
135
|
}
|
|
135
|
-
this.pagination = new Stores_1.SearchPaginationStore(this.config, this.services, data.pagination, this.meta);
|
|
136
|
-
this.sorting = new Stores_1.SearchSortingStore(this.services, data.sorting || [], data.search || {}, this.meta);
|
|
136
|
+
this.pagination = new Stores_1.SearchPaginationStore(this.config, this.services, data.pagination, this.meta.data);
|
|
137
|
+
this.sorting = new Stores_1.SearchSortingStore(this.services, data.sorting || [], data.search || {}, this.meta.data);
|
|
137
138
|
};
|
|
138
139
|
return AutocompleteStore;
|
|
139
140
|
}(AbstractStore_1.AbstractStore));
|
|
@@ -5,10 +5,11 @@ import { StorageStore } from '../Storage/StorageStore';
|
|
|
5
5
|
import { FinderSelectionStore } from './Stores';
|
|
6
6
|
import type { FinderStoreConfig, StoreServices, SelectedSelection, FinderStoreState } from '../types';
|
|
7
7
|
import { UrlManager } from '@searchspring/snap-url-manager';
|
|
8
|
+
import { MetaStore } from '../Meta/MetaStore';
|
|
8
9
|
export declare class FinderStore extends AbstractStore {
|
|
9
10
|
services: StoreServices;
|
|
10
11
|
config: FinderStoreConfig;
|
|
11
|
-
meta:
|
|
12
|
+
meta: MetaStore;
|
|
12
13
|
storage: StorageStore;
|
|
13
14
|
persistedStorage: StorageStore;
|
|
14
15
|
pagination: SearchPaginationStore;
|
|
@@ -20,7 +21,7 @@ export declare class FinderStore extends AbstractStore {
|
|
|
20
21
|
reset: () => void;
|
|
21
22
|
loadPersisted(): void;
|
|
22
23
|
update(data: SearchResponseModel & {
|
|
23
|
-
meta
|
|
24
|
+
meta?: MetaResponseModel;
|
|
24
25
|
}, selectedSelections?: SelectedSelection[]): void;
|
|
25
26
|
}
|
|
26
27
|
//# sourceMappingURL=FinderStore.d.ts.map
|
|
@@ -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,2BAA2B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"FinderStore.d.ts","sourceRoot":"","sources":["../../../src/Finder/FinderStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACtG,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,qBAAa,WAAY,SAAQ,aAAa;IACtC,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAG,iBAAiB,CAAC;IAC3B,IAAI,EAAG,SAAS,CAAC;IACjB,OAAO,EAAE,YAAY,CAAC;IACtB,gBAAgB,EAAG,YAAY,CAAC;IAChC,UAAU,EAAG,qBAAqB,CAAC;IACnC,UAAU,EAAG,oBAAoB,CAAC;IAClC,KAAK,EAAE,gBAAgB,CAE5B;gBAEU,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa;IA0BvD,UAAU,CAAC,IAAI,EAAE,MAAM,aAAa,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAQhE,IAAI,EAAE,MAAM,IAAI,CAAY;IAE5B,KAAK,QAAO,IAAI,CAWrB;IAEK,aAAa,IAAI,IAAI;IAyBrB,MAAM,CAAC,IAAI,EAAE,mBAAmB,GAAG;QAAE,IAAI,CAAC,EAAE,iBAAiB,CAAA;KAAE,EAAE,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,GAAG,IAAI;CAiCvH"}
|
|
@@ -32,12 +32,12 @@ var AbstractStore_1 = require("../Abstract/AbstractStore");
|
|
|
32
32
|
var Stores_1 = require("../Search/Stores");
|
|
33
33
|
var StorageStore_1 = require("../Storage/StorageStore");
|
|
34
34
|
var Stores_2 = require("./Stores");
|
|
35
|
+
var MetaStore_1 = require("../Meta/MetaStore");
|
|
35
36
|
var FinderStore = /** @class */ (function (_super) {
|
|
36
37
|
__extends(FinderStore, _super);
|
|
37
38
|
function FinderStore(config, services) {
|
|
38
39
|
var _a, _b;
|
|
39
40
|
var _this = _super.call(this, config) || this;
|
|
40
|
-
_this.meta = {};
|
|
41
41
|
_this.state = {
|
|
42
42
|
persisted: false,
|
|
43
43
|
};
|
|
@@ -62,7 +62,7 @@ var FinderStore = /** @class */ (function (_super) {
|
|
|
62
62
|
_this.services = services;
|
|
63
63
|
if ((_b = config.persist) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
64
64
|
_this.persistedStorage = new StorageStore_1.StorageStore({
|
|
65
|
-
type:
|
|
65
|
+
type: 'local',
|
|
66
66
|
key: "ss-".concat(config.id, "-persisted"),
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -107,12 +107,12 @@ var FinderStore = /** @class */ (function (_super) {
|
|
|
107
107
|
var _this = this;
|
|
108
108
|
this.error = undefined;
|
|
109
109
|
this.loaded = !!data.pagination;
|
|
110
|
-
this.meta = data.meta;
|
|
111
|
-
this.pagination = new Stores_1.SearchPaginationStore(this.config, this.services, data.pagination, this.meta);
|
|
110
|
+
this.meta = new MetaStore_1.MetaStore(data.meta);
|
|
111
|
+
this.pagination = new Stores_1.SearchPaginationStore(this.config, this.services, data.pagination, this.meta.data);
|
|
112
112
|
this.selections = new Stores_2.FinderSelectionStore(this.config, this.services, {
|
|
113
113
|
state: this.state,
|
|
114
114
|
facets: data.facets || [],
|
|
115
|
-
meta: this.meta,
|
|
115
|
+
meta: this.meta.data,
|
|
116
116
|
loading: this.loading,
|
|
117
117
|
storage: this.storage,
|
|
118
118
|
selections: selectedSelections || [],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MetaResponseModel } from '@searchspring/snapi-types';
|
|
2
|
+
export declare class MetaStore {
|
|
3
|
+
data: MetaResponseModel;
|
|
4
|
+
badges: MetaBadges;
|
|
5
|
+
constructor(metaData?: MetaResponseModel);
|
|
6
|
+
}
|
|
7
|
+
declare class MetaBadges {
|
|
8
|
+
groups: Record<string, {
|
|
9
|
+
sections: string[];
|
|
10
|
+
grid: string[][];
|
|
11
|
+
}>;
|
|
12
|
+
constructor(metaData?: MetaResponseModel);
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=MetaStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetaStore.d.ts","sourceRoot":"","sources":["../../../src/Meta/MetaStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,qBAAa,SAAS;IACd,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,UAAU,CAAC;gBAEd,QAAQ,CAAC,EAAE,iBAAiB;CAIxC;AAED,cAAM,UAAU;IACR,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;KAAE,CAAC,CAAM;gBAEjE,QAAQ,CAAC,EAAE,iBAAiB;CA8BxC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetaStore = void 0;
|
|
4
|
+
var MetaStore = /** @class */ (function () {
|
|
5
|
+
function MetaStore(metaData) {
|
|
6
|
+
this.data = metaData !== null && metaData !== void 0 ? metaData : {};
|
|
7
|
+
this.badges = new MetaBadges(this.data);
|
|
8
|
+
}
|
|
9
|
+
return MetaStore;
|
|
10
|
+
}());
|
|
11
|
+
exports.MetaStore = MetaStore;
|
|
12
|
+
var MetaBadges = /** @class */ (function () {
|
|
13
|
+
function MetaBadges(metaData) {
|
|
14
|
+
var _this = this;
|
|
15
|
+
this.groups = {};
|
|
16
|
+
// 'overlay' group is created by default - could support additional groups via config in the future
|
|
17
|
+
var groups = { overlay: { sections: ['left', 'right'] } };
|
|
18
|
+
// process groups - create the grid for each group
|
|
19
|
+
Object.keys(groups).map(function (name) {
|
|
20
|
+
var group = groups[name];
|
|
21
|
+
var sections = group.sections.map(function (section) {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
return ({
|
|
24
|
+
areas: ((_c = (_b = (_a = metaData === null || metaData === void 0 ? void 0 : metaData.badges) === null || _a === void 0 ? void 0 : _a.locations) === null || _b === void 0 ? void 0 : _b[section]) === null || _c === void 0 ? void 0 : _c.map(function (area) { return area.tag; })) || [],
|
|
25
|
+
grid: [],
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
// find lcm of sections
|
|
29
|
+
var lcmSections = sections.map(function (section) { return section.areas.length; }).reduce(lcm);
|
|
30
|
+
sections.forEach(function (section) {
|
|
31
|
+
section.grid = Array.from({ length: lcmSections }).map(function (_, index) { return section.areas[Math.floor(index / (lcmSections / section.areas.length))]; });
|
|
32
|
+
});
|
|
33
|
+
// set the grid by creating rows of columns
|
|
34
|
+
var grid = Array.from({ length: lcmSections }).map(function (_, i) {
|
|
35
|
+
return sections.map(function (section) { return section.grid[i]; });
|
|
36
|
+
});
|
|
37
|
+
_this.groups[name] = {
|
|
38
|
+
sections: group.sections,
|
|
39
|
+
grid: grid,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return MetaBadges;
|
|
44
|
+
}());
|
|
45
|
+
function gcd(a, b) {
|
|
46
|
+
if (!b) {
|
|
47
|
+
return a;
|
|
48
|
+
}
|
|
49
|
+
return gcd(b, a % b);
|
|
50
|
+
}
|
|
51
|
+
function lcm(a, b) {
|
|
52
|
+
var gcdValue = gcd(a, b);
|
|
53
|
+
return (a * b) / gcdValue;
|
|
54
|
+
}
|
|
@@ -4,14 +4,19 @@ import { CartStore } from '../Cart/CartStore';
|
|
|
4
4
|
import { RecommendationProfileStore } from './Stores';
|
|
5
5
|
import type { RecommendationStoreConfig, StoreServices } from '../types';
|
|
6
6
|
import type { RecommendCombinedResponseModel } from '@searchspring/snap-client';
|
|
7
|
+
import { MetaResponseModel } from '@searchspring/snapi-types';
|
|
8
|
+
import { MetaStore } from '../Meta/MetaStore';
|
|
7
9
|
export declare class RecommendationStore extends AbstractStore {
|
|
8
10
|
services: StoreServices;
|
|
11
|
+
meta: MetaStore;
|
|
9
12
|
loaded: boolean;
|
|
10
13
|
profile: RecommendationProfileStore;
|
|
11
14
|
results: Product[];
|
|
12
15
|
cart: CartStore;
|
|
13
16
|
constructor(config: RecommendationStoreConfig, services: StoreServices);
|
|
14
17
|
reset(): void;
|
|
15
|
-
update(data?: RecommendCombinedResponseModel
|
|
18
|
+
update(data?: RecommendCombinedResponseModel & {
|
|
19
|
+
meta?: MetaResponseModel;
|
|
20
|
+
}): void;
|
|
16
21
|
}
|
|
17
22
|
//# sourceMappingURL=RecommendationStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecommendationStore.d.ts","sourceRoot":"","sources":["../../../src/Recommendation/RecommendationStore.ts"],"names":[],"mappings":"AACA,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,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"RecommendationStore.d.ts","sourceRoot":"","sources":["../../../src/Recommendation/RecommendationStore.ts"],"names":[],"mappings":"AACA,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,2BAA2B,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,qBAAa,mBAAoB,SAAQ,aAAa;IAC9C,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAG,SAAS,CAAC;IACjB,MAAM,UAAS;IACf,OAAO,EAAG,0BAA0B,CAAC;IACrC,OAAO,EAAG,OAAO,EAAE,CAAC;IACpB,IAAI,EAAG,SAAS,CAAC;gBAEZ,MAAM,EAAE,yBAAyB,EAAE,QAAQ,EAAE,aAAa;IAiB/D,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,IAAI,CAAC,EAAE,8BAA8B,GAAG;QAAE,IAAI,CAAC,EAAE,iBAAiB,CAAA;KAAE,GAAG,IAAI;CAYzF"}
|
|
@@ -21,6 +21,7 @@ var AbstractStore_1 = require("../Abstract/AbstractStore");
|
|
|
21
21
|
var Stores_1 = require("../Search/Stores");
|
|
22
22
|
var CartStore_1 = require("../Cart/CartStore");
|
|
23
23
|
var Stores_2 = require("./Stores");
|
|
24
|
+
var MetaStore_1 = require("../Meta/MetaStore");
|
|
24
25
|
var RecommendationStore = /** @class */ (function (_super) {
|
|
25
26
|
__extends(RecommendationStore, _super);
|
|
26
27
|
function RecommendationStore(config, services) {
|
|
@@ -44,8 +45,9 @@ var RecommendationStore = /** @class */ (function (_super) {
|
|
|
44
45
|
RecommendationStore.prototype.update = function (data) {
|
|
45
46
|
this.error = undefined;
|
|
46
47
|
this.loaded = !!(data === null || data === void 0 ? void 0 : data.profile);
|
|
48
|
+
this.meta = new MetaStore_1.MetaStore(data === null || data === void 0 ? void 0 : data.meta);
|
|
47
49
|
this.profile = new Stores_2.RecommendationProfileStore(this.services, data);
|
|
48
|
-
this.results = new Stores_1.SearchResultStore(this.config, this.services, data === null || data === void 0 ? void 0 : data.results);
|
|
50
|
+
this.results = new Stores_1.SearchResultStore(this.config, this.services, this.meta.data, data === null || data === void 0 ? void 0 : data.results);
|
|
49
51
|
// only create a cart store when type is bundle
|
|
50
52
|
if (this.profile.type == 'bundle') {
|
|
51
53
|
this.cart = new CartStore_1.CartStore();
|
|
@@ -3,9 +3,10 @@ import type { SearchStoreConfig, StoreServices } from '../types';
|
|
|
3
3
|
import { SearchMerchandisingStore, SearchFacetStore, SearchFilterStore, SearchResultStore, SearchPaginationStore, SearchSortingStore, SearchQueryStore, SearchHistoryStore } from './Stores';
|
|
4
4
|
import { AbstractStore } from '../Abstract/AbstractStore';
|
|
5
5
|
import { StorageStore } from '../Storage/StorageStore';
|
|
6
|
+
import { MetaStore } from '../Meta/MetaStore';
|
|
6
7
|
export declare class SearchStore extends AbstractStore {
|
|
7
8
|
services: StoreServices;
|
|
8
|
-
meta:
|
|
9
|
+
meta: MetaStore;
|
|
9
10
|
merchandising: SearchMerchandisingStore;
|
|
10
11
|
search: SearchQueryStore;
|
|
11
12
|
facets: SearchFacetStore;
|
|
@@ -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,2BAA2B,CAAC;AACxF,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;AAElB,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchStore.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACxF,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;AAElB,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,qBAAa,WAAY,SAAQ,aAAa;IACtC,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAG,SAAS,CAAC;IACjB,aAAa,EAAG,wBAAwB,CAAC;IACzC,MAAM,EAAG,gBAAgB,CAAC;IAC1B,MAAM,EAAG,gBAAgB,CAAC;IAC1B,OAAO,EAAG,iBAAiB,CAAC;IAC5B,OAAO,EAAG,iBAAiB,CAAC;IAC5B,UAAU,EAAG,qBAAqB,CAAC;IACnC,OAAO,EAAG,kBAAkB,CAAC;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,kBAAkB,CAAC;gBAEvB,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa;IAiDvD,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,IAAI,GAAE,mBAAmB,GAAG;QAAE,IAAI,CAAC,EAAE,iBAAiB,CAAA;KAAO,GAAG,IAAI;CAoBlF"}
|
|
@@ -20,6 +20,7 @@ var mobx_1 = require("mobx");
|
|
|
20
20
|
var Stores_1 = require("./Stores");
|
|
21
21
|
var AbstractStore_1 = require("../Abstract/AbstractStore");
|
|
22
22
|
var StorageStore_1 = require("../Storage/StorageStore");
|
|
23
|
+
var MetaStore_1 = require("../Meta/MetaStore");
|
|
23
24
|
var SearchStore = /** @class */ (function (_super) {
|
|
24
25
|
__extends(SearchStore, _super);
|
|
25
26
|
function SearchStore(config, services) {
|
|
@@ -70,14 +71,14 @@ var SearchStore = /** @class */ (function (_super) {
|
|
|
70
71
|
if (data === void 0) { data = {}; }
|
|
71
72
|
this.error = undefined;
|
|
72
73
|
this.loaded = !!data.pagination;
|
|
73
|
-
this.meta = data.meta
|
|
74
|
+
this.meta = new MetaStore_1.MetaStore(data.meta);
|
|
74
75
|
this.merchandising = new Stores_1.SearchMerchandisingStore(this.services, (data === null || data === void 0 ? void 0 : data.merchandising) || {});
|
|
75
76
|
this.search = new Stores_1.SearchQueryStore(this.services, (data === null || data === void 0 ? void 0 : data.search) || {});
|
|
76
|
-
this.facets = new Stores_1.SearchFacetStore(this.config, this.services, this.storage, data.facets, (data === null || data === void 0 ? void 0 : data.pagination) || {}, this.meta, (data === null || data === void 0 ? void 0 : data.merchandising) || {});
|
|
77
|
-
this.filters = new Stores_1.SearchFilterStore(this.services, data.filters, this.meta);
|
|
78
|
-
this.results = new Stores_1.SearchResultStore(this.config, this.services, (data === null || data === void 0 ? void 0 : data.results) || [], data.pagination, data.merchandising);
|
|
79
|
-
this.pagination = new Stores_1.SearchPaginationStore(this.config, this.services, data.pagination, this.meta);
|
|
80
|
-
this.sorting = new Stores_1.SearchSortingStore(this.services, (data === null || data === void 0 ? void 0 : data.sorting) || [], (data === null || data === void 0 ? void 0 : data.search) || {}, this.meta);
|
|
77
|
+
this.facets = new Stores_1.SearchFacetStore(this.config, this.services, this.storage, data.facets, (data === null || data === void 0 ? void 0 : data.pagination) || {}, this.meta.data, (data === null || data === void 0 ? void 0 : data.merchandising) || {});
|
|
78
|
+
this.filters = new Stores_1.SearchFilterStore(this.services, data.filters, this.meta.data);
|
|
79
|
+
this.results = new Stores_1.SearchResultStore(this.config, this.services, this.meta.data, (data === null || data === void 0 ? void 0 : data.results) || [], data.pagination, data.merchandising);
|
|
80
|
+
this.pagination = new Stores_1.SearchPaginationStore(this.config, this.services, data.pagination, this.meta.data);
|
|
81
|
+
this.sorting = new Stores_1.SearchSortingStore(this.services, (data === null || data === void 0 ? void 0 : data.sorting) || [], (data === null || data === void 0 ? void 0 : data.search) || {}, this.meta.data);
|
|
81
82
|
};
|
|
82
83
|
return SearchStore;
|
|
83
84
|
}(AbstractStore_1.AbstractStore));
|
|
@@ -28,7 +28,7 @@ var SearchHistoryStore = /** @class */ (function () {
|
|
|
28
28
|
this.config.max = 25;
|
|
29
29
|
}
|
|
30
30
|
this.storage = new StorageStore_1.StorageStore({
|
|
31
|
-
type:
|
|
31
|
+
type: 'local',
|
|
32
32
|
key: "ss-history".concat(this.config.siteId ? "-".concat(this.config.siteId) : ""),
|
|
33
33
|
});
|
|
34
34
|
// reset to zero to clear any potentially existing terms
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { StoreServices, StoreConfigs, VariantSelectionOptions, VariantConfig } from '../../types';
|
|
2
|
-
import type { SearchResponseModelResult, SearchResponseModelPagination, SearchResponseModelMerchandising, SearchResponseModelResultMappings, SearchResponseModelMerchandisingContentInline, SearchResponseModelMerchandisingContentConfig } from '@searchspring/snapi-types';
|
|
1
|
+
import type { StoreServices, StoreConfigs, VariantSelectionOptions, ResultBadge, VariantConfig } from '../../types';
|
|
2
|
+
import type { SearchResponseModelResult, SearchResponseModelPagination, SearchResponseModelMerchandising, SearchResponseModelResultMappings, SearchResponseModelMerchandisingContentInline, SearchResponseModelMerchandisingContentConfig, MetaResponseModel } from '@searchspring/snapi-types';
|
|
3
3
|
export declare class SearchResultStore extends Array<Product | Banner> {
|
|
4
4
|
static get [Symbol.species](): ArrayConstructor;
|
|
5
|
-
constructor(config: StoreConfigs, services: StoreServices, resultData?: SearchResponseModelResult[], paginationData?: SearchResponseModelPagination, merchData?: SearchResponseModelMerchandising);
|
|
5
|
+
constructor(config: StoreConfigs, services: StoreServices, metaData: MetaResponseModel, resultData?: SearchResponseModelResult[], paginationData?: SearchResponseModelPagination, merchData?: SearchResponseModelMerchandising);
|
|
6
6
|
}
|
|
7
7
|
export declare class Banner {
|
|
8
8
|
type: string;
|
|
@@ -35,12 +35,20 @@ export declare class Product {
|
|
|
35
35
|
mappings: SearchResponseModelResultMappings;
|
|
36
36
|
custom: {};
|
|
37
37
|
children?: Array<Child>;
|
|
38
|
+
badges: Badges;
|
|
38
39
|
quantity: number;
|
|
39
40
|
mask: ProductMask;
|
|
40
41
|
variants?: Variants;
|
|
41
|
-
constructor(services: StoreServices, result: SearchResponseModelResult, config?: StoreConfigs);
|
|
42
|
+
constructor(services: StoreServices, result: SearchResponseModelResult, metaData: MetaResponseModel, config?: StoreConfigs);
|
|
42
43
|
get display(): ProductMinimal;
|
|
43
44
|
}
|
|
45
|
+
export declare class Badges {
|
|
46
|
+
all: ResultBadge[];
|
|
47
|
+
constructor(result: SearchResponseModelResult, metaData: MetaResponseModel);
|
|
48
|
+
atLocation(location?: string[] | string): ResultBadge[];
|
|
49
|
+
get tags(): Record<string, ResultBadge>;
|
|
50
|
+
get locations(): Record<string, Record<string, ResultBadge[]>>;
|
|
51
|
+
}
|
|
44
52
|
export declare class ProductMask {
|
|
45
53
|
data: Partial<Product>;
|
|
46
54
|
constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchResultStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchResultStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqB,aAAa,EAAE,YAAY,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchResultStore.d.ts","sourceRoot":"","sources":["../../../../src/Search/Stores/SearchResultStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqB,aAAa,EAAE,YAAY,EAAE,uBAAuB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvI,OAAO,KAAK,EACX,yBAAyB,EACzB,6BAA6B,EAC7B,gCAAgC,EAChC,iCAAiC,EACjC,6CAA6C,EAC7C,6CAA6C,EAC7C,iBAAiB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,iBAAkB,SAAQ,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IAC7D,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAE9C;gBAGA,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,iBAAiB,EAC3B,UAAU,CAAC,EAAE,yBAAyB,EAAE,EACxC,cAAc,CAAC,EAAE,6BAA6B,EAC9C,SAAS,CAAC,EAAE,gCAAgC;CAqB7C;AAED,qBAAa,MAAM;IACX,IAAI,SAAY;IAChB,EAA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AE,OAAO,CAAC;CACpB,CAAC;AAEF,qBAAa,gBAAgB;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAM;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAM;IACjC,MAAM,EAAE,cAAc,EAAE,CAAM;IAErC,OAAO,CAAC,cAAc,CAAa;gBAEvB,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,uBAAuB;IAgBhE,YAAY,CAAC,QAAQ,EAAE,QAAQ;IA4D/B,KAAK;IAKL,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,iBAAiB,UAAQ;CAYtD;AAED,qBAAa,OAAO;IACZ,IAAI,SAAa;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IACzC,OAAO,EAAE,MAAM,CACrB,MAAM,EACN;QACC,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;KAClB,CACD,CAAC;IAEK,QAAQ,EAAE,iCAAiC,CAEhD;IACK,MAAM,KAAM;gBAEP,WAAW,EAAE,WAAW;CAapC;AAED,cAAM,KAAK;IACH,IAAI,SAAW;IACf,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IACzC,MAAM,KAAM;gBAEP,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,yBAAyB;CAUtE"}
|
|
@@ -38,16 +38,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
39
|
};
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.Variant = exports.VariantSelection = exports.Variants = exports.ProductMask = exports.Product = exports.Banner = exports.SearchResultStore = void 0;
|
|
41
|
+
exports.Variant = exports.VariantSelection = exports.Variants = exports.ProductMask = exports.Badges = exports.Product = exports.Banner = exports.SearchResultStore = void 0;
|
|
42
42
|
var mobx_1 = require("mobx");
|
|
43
43
|
var deepmerge_1 = __importDefault(require("deepmerge"));
|
|
44
44
|
var is_plain_object_1 = require("is-plain-object");
|
|
45
45
|
var SearchResultStore = /** @class */ (function (_super) {
|
|
46
46
|
__extends(SearchResultStore, _super);
|
|
47
|
-
function SearchResultStore(config, services, resultData, paginationData, merchData) {
|
|
47
|
+
function SearchResultStore(config, services, metaData, resultData, paginationData, merchData) {
|
|
48
48
|
var _a;
|
|
49
49
|
var results = (resultData || []).map(function (result) {
|
|
50
|
-
return new Product(services, result, config);
|
|
50
|
+
return new Product(services, result, metaData, config);
|
|
51
51
|
});
|
|
52
52
|
if ((_a = merchData === null || merchData === void 0 ? void 0 : merchData.content) === null || _a === void 0 ? void 0 : _a.inline) {
|
|
53
53
|
var banners = merchData.content.inline
|
|
@@ -94,7 +94,7 @@ var Banner = /** @class */ (function () {
|
|
|
94
94
|
}());
|
|
95
95
|
exports.Banner = Banner;
|
|
96
96
|
var Product = /** @class */ (function () {
|
|
97
|
-
function Product(services, result, config) {
|
|
97
|
+
function Product(services, result, metaData, config) {
|
|
98
98
|
var _a, _b, _c, _d;
|
|
99
99
|
this.type = 'product';
|
|
100
100
|
this.attributes = {};
|
|
@@ -108,6 +108,7 @@ var Product = /** @class */ (function () {
|
|
|
108
108
|
this.id = result.id;
|
|
109
109
|
this.attributes = result.attributes;
|
|
110
110
|
this.mappings = result.mappings;
|
|
111
|
+
this.badges = new Badges(result, metaData);
|
|
111
112
|
var variantsField = (_b = (_a = config === null || config === void 0 ? void 0 : config.settings) === null || _a === void 0 ? void 0 : _a.variants) === null || _b === void 0 ? void 0 : _b.field;
|
|
112
113
|
if (config && variantsField && this.attributes && this.attributes[variantsField]) {
|
|
113
114
|
try {
|
|
@@ -149,6 +150,64 @@ var Product = /** @class */ (function () {
|
|
|
149
150
|
return Product;
|
|
150
151
|
}());
|
|
151
152
|
exports.Product = Product;
|
|
153
|
+
var Badges = /** @class */ (function () {
|
|
154
|
+
function Badges(result, metaData) {
|
|
155
|
+
this.all = [];
|
|
156
|
+
this.all = (result.badges || [])
|
|
157
|
+
.filter(function (badge) {
|
|
158
|
+
var _a, _b, _c;
|
|
159
|
+
// remove badges that are not in the meta or are disabled
|
|
160
|
+
return !!((badge === null || badge === void 0 ? void 0 : badge.tag) && ((_a = metaData === null || metaData === void 0 ? void 0 : metaData.badges) === null || _a === void 0 ? void 0 : _a.tags) && ((_b = metaData === null || metaData === void 0 ? void 0 : metaData.badges) === null || _b === void 0 ? void 0 : _b.tags[badge.tag]) && ((_c = metaData === null || metaData === void 0 ? void 0 : metaData.badges) === null || _c === void 0 ? void 0 : _c.tags[badge.tag].enabled));
|
|
161
|
+
})
|
|
162
|
+
.map(function (badge) {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
// merge badge with badge meta data
|
|
165
|
+
var metaBadgeData = (_b = (_a = metaData === null || metaData === void 0 ? void 0 : metaData.badges) === null || _a === void 0 ? void 0 : _a.tags) === null || _b === void 0 ? void 0 : _b[badge.tag];
|
|
166
|
+
return __assign(__assign({}, badge), metaBadgeData);
|
|
167
|
+
})
|
|
168
|
+
.sort(function (a, b) {
|
|
169
|
+
return a.priority - b.priority;
|
|
170
|
+
});
|
|
171
|
+
(0, mobx_1.makeObservable)(this, {
|
|
172
|
+
all: mobx_1.observable,
|
|
173
|
+
tags: mobx_1.computed,
|
|
174
|
+
locations: mobx_1.computed,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// get all the result badges that are in a specific location
|
|
178
|
+
Badges.prototype.atLocation = function (location) {
|
|
179
|
+
var locations = Array.isArray(location) ? location : [location];
|
|
180
|
+
return this.all.filter(function (badge) {
|
|
181
|
+
// filter location
|
|
182
|
+
return locations.some(function (location) { return badge.location.startsWith("".concat(location, "/")) || badge.location == location; });
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
Object.defineProperty(Badges.prototype, "tags", {
|
|
186
|
+
get: function () {
|
|
187
|
+
return this.all.reduce(function (badgeMap, badge) {
|
|
188
|
+
badgeMap[badge.tag] = badge;
|
|
189
|
+
return badgeMap;
|
|
190
|
+
}, {});
|
|
191
|
+
},
|
|
192
|
+
enumerable: false,
|
|
193
|
+
configurable: true
|
|
194
|
+
});
|
|
195
|
+
Object.defineProperty(Badges.prototype, "locations", {
|
|
196
|
+
get: function () {
|
|
197
|
+
return this.all.reduce(function (locationMap, badge) {
|
|
198
|
+
// put badge in location by path
|
|
199
|
+
var _a = badge.location.split('/'), section = _a[0], tag = _a[1];
|
|
200
|
+
locationMap[section] = locationMap[section] || {};
|
|
201
|
+
locationMap[section][tag] = (locationMap[section][tag] || []).concat(badge);
|
|
202
|
+
return locationMap;
|
|
203
|
+
}, {});
|
|
204
|
+
},
|
|
205
|
+
enumerable: false,
|
|
206
|
+
configurable: true
|
|
207
|
+
});
|
|
208
|
+
return Badges;
|
|
209
|
+
}());
|
|
210
|
+
exports.Badges = Badges;
|
|
152
211
|
// Mask is used to power the product display for quick attribute swapping
|
|
153
212
|
var ProductMask = /** @class */ (function () {
|
|
154
213
|
function ProductMask() {
|
|
@@ -10,7 +10,7 @@ export declare class StorageStore {
|
|
|
10
10
|
clear(): void;
|
|
11
11
|
}
|
|
12
12
|
export type StorageConfig = {
|
|
13
|
-
type: StorageType;
|
|
13
|
+
type: StorageType | keyof typeof StorageType;
|
|
14
14
|
cookie?: {
|
|
15
15
|
expiration?: number;
|
|
16
16
|
sameSite?: string;
|
|
@@ -18,9 +18,9 @@ export type StorageConfig = {
|
|
|
18
18
|
key: string;
|
|
19
19
|
};
|
|
20
20
|
export declare enum StorageType {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
session = "session",
|
|
22
|
+
local = "local",
|
|
23
|
+
cookie = "cookie",
|
|
24
|
+
memory = "memory"
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=StorageStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageStore.d.ts","sourceRoot":"","sources":["../../../src/Storage/StorageStore.ts"],"names":[],"mappings":"AAMA,qBAAa,YAAY;IACxB,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,GAAG,CAAgB;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAE3B,MAAM,CAAC,EAAE,aAAa;IA8C3B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAyBnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAiClC,KAAK,IAAI,IAAI;CAcpB;AAED,MAAM,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"StorageStore.d.ts","sourceRoot":"","sources":["../../../src/Storage/StorageStore.ts"],"names":[],"mappings":"AAMA,qBAAa,YAAY;IACxB,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,GAAG,CAAgB;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;gBAE3B,MAAM,CAAC,EAAE,aAAa;IA8C3B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAyBnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAiClC,KAAK,IAAI,IAAI;CAcpB;AAED,MAAM,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,WAAW,GAAG,MAAM,OAAO,WAAW,CAAC;IAC7C,MAAM,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,oBAAY,WAAW;IACtB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CACjB"}
|
|
@@ -24,7 +24,7 @@ var StorageStore = /** @class */ (function () {
|
|
|
24
24
|
this.sameSite = config.cookie.sameSite;
|
|
25
25
|
}
|
|
26
26
|
switch (config.type) {
|
|
27
|
-
case StorageType.
|
|
27
|
+
case StorageType.session: {
|
|
28
28
|
this.type = snap_toolbox_1.featureFlags.storage ? config.type : null;
|
|
29
29
|
if (this.type) {
|
|
30
30
|
this.state = JSON.parse(window.sessionStorage.getItem(this.key) || '{}');
|
|
@@ -32,7 +32,7 @@ var StorageStore = /** @class */ (function () {
|
|
|
32
32
|
}
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
|
-
case StorageType.
|
|
35
|
+
case StorageType.local: {
|
|
36
36
|
this.type = snap_toolbox_1.featureFlags.storage ? config.type : null;
|
|
37
37
|
if (this.type) {
|
|
38
38
|
this.state = JSON.parse(window.localStorage.getItem(this.key) || '{}');
|
|
@@ -40,7 +40,7 @@ var StorageStore = /** @class */ (function () {
|
|
|
40
40
|
}
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
|
-
case StorageType.
|
|
43
|
+
case StorageType.cookie: {
|
|
44
44
|
if (snap_toolbox_1.featureFlags.cookies) {
|
|
45
45
|
this.type = config.type;
|
|
46
46
|
var data = utils.cookies.get(this.key);
|
|
@@ -51,7 +51,7 @@ var StorageStore = /** @class */ (function () {
|
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
53
|
default: {
|
|
54
|
-
this.type = StorageType.
|
|
54
|
+
this.type = StorageType.memory;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -69,28 +69,28 @@ var StorageStore = /** @class */ (function () {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
switch (this.type) {
|
|
72
|
-
case StorageType.
|
|
72
|
+
case StorageType.session:
|
|
73
73
|
window.sessionStorage.setItem(this.key, JSON.stringify(this.state));
|
|
74
74
|
break;
|
|
75
|
-
case StorageType.
|
|
75
|
+
case StorageType.local:
|
|
76
76
|
window.localStorage.setItem(this.key, JSON.stringify(this.state));
|
|
77
77
|
break;
|
|
78
|
-
case StorageType.
|
|
78
|
+
case StorageType.cookie:
|
|
79
79
|
utils.cookies.set(this.key, JSON.stringify(this.state), this.sameSite, this.expiration);
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
StorageStore.prototype.get = function (path) {
|
|
84
84
|
switch (this.type) {
|
|
85
|
-
case StorageType.
|
|
85
|
+
case StorageType.session:
|
|
86
86
|
var sessionData = window.sessionStorage.getItem(this.key);
|
|
87
87
|
this.state = sessionData ? JSON.parse(sessionData) : {};
|
|
88
88
|
break;
|
|
89
|
-
case StorageType.
|
|
89
|
+
case StorageType.local:
|
|
90
90
|
var localData = window.localStorage.getItem(this.key);
|
|
91
91
|
this.state = localData ? JSON.parse(localData) : {};
|
|
92
92
|
break;
|
|
93
|
-
case StorageType.
|
|
93
|
+
case StorageType.cookie:
|
|
94
94
|
var data = utils.cookies.get(this.key);
|
|
95
95
|
if (data) {
|
|
96
96
|
this.state = JSON.parse(data) || {};
|
|
@@ -115,13 +115,13 @@ var StorageStore = /** @class */ (function () {
|
|
|
115
115
|
};
|
|
116
116
|
StorageStore.prototype.clear = function () {
|
|
117
117
|
switch (this.type) {
|
|
118
|
-
case StorageType.
|
|
118
|
+
case StorageType.session:
|
|
119
119
|
window.sessionStorage.removeItem(this.key);
|
|
120
120
|
break;
|
|
121
|
-
case StorageType.
|
|
121
|
+
case StorageType.local:
|
|
122
122
|
window.localStorage.removeItem(this.key);
|
|
123
123
|
break;
|
|
124
|
-
case StorageType.
|
|
124
|
+
case StorageType.cookie:
|
|
125
125
|
utils.cookies.unset(this.key);
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
@@ -132,8 +132,8 @@ var StorageStore = /** @class */ (function () {
|
|
|
132
132
|
exports.StorageStore = StorageStore;
|
|
133
133
|
var StorageType;
|
|
134
134
|
(function (StorageType) {
|
|
135
|
-
StorageType["
|
|
136
|
-
StorageType["
|
|
137
|
-
StorageType["
|
|
138
|
-
StorageType["
|
|
135
|
+
StorageType["session"] = "session";
|
|
136
|
+
StorageType["local"] = "local";
|
|
137
|
+
StorageType["cookie"] = "cookie";
|
|
138
|
+
StorageType["memory"] = "memory";
|
|
139
139
|
})(StorageType || (exports.StorageType = StorageType = {}));
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export * from './Search/Stores/';
|
|
|
6
6
|
export { RecommendationStore } from './Recommendation/RecommendationStore';
|
|
7
7
|
export { CartStore } from './Cart/CartStore';
|
|
8
8
|
export { StorageStore, StorageConfig, StorageType } from './Storage/StorageStore';
|
|
9
|
+
export { MetaStore } from './Meta/MetaStore';
|
|
9
10
|
export * from './types';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,cAAc,SAAS,CAAC"}
|