@websolutespa/bom-mixer-store 1.8.1 → 1.8.3
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/CHANGELOG.md +12 -0
- package/dist/index.js +7 -12
- package/dist/index.mjs +7 -12
- package/package.json +1 -1
- package/src/mock/mock-page.service.ts +2 -2
- package/src/remote/remote-page.service.ts +2 -2
- package/src/remote/remote.store.ts +5 -9
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -793,7 +793,6 @@ var MockPageService = class extends MockService {
|
|
|
793
793
|
async decorateMany_(items, params = {}) {
|
|
794
794
|
const store = this.store;
|
|
795
795
|
let decoratedItems = items;
|
|
796
|
-
decoratedItems = await optimizeMany_(decoratedItems);
|
|
797
796
|
decoratedItems = await decorateCategories_(store, decoratedItems, params);
|
|
798
797
|
decoratedItems = await decorateLocalizables_(decoratedItems, params);
|
|
799
798
|
decoratedItems = await decorateHrefs_(store, decoratedItems, params);
|
|
@@ -1603,7 +1602,6 @@ var RemotePageService = class extends RemoteService {
|
|
|
1603
1602
|
async decorateMany_(items, params = {}) {
|
|
1604
1603
|
const store = this.store;
|
|
1605
1604
|
let decoratedItems = items;
|
|
1606
|
-
decoratedItems = await optimizeMany_(decoratedItems);
|
|
1607
1605
|
decoratedItems = await decorateSchemas_(store, decoratedItems, this.key);
|
|
1608
1606
|
decoratedItems = await decorateCategories_(store, decoratedItems, params);
|
|
1609
1607
|
decoratedItems = await decorateHrefs_(store, decoratedItems, params);
|
|
@@ -1648,17 +1646,14 @@ async function getRemoteStore_() {
|
|
|
1648
1646
|
async function getRemoteStoreStaticBuild_() {
|
|
1649
1647
|
return fromCache(async () => {
|
|
1650
1648
|
console.log("getRemoteStoreStaticBuild_");
|
|
1651
|
-
|
|
1649
|
+
let store = {};
|
|
1652
1650
|
const url = "/store";
|
|
1653
1651
|
const json = await remoteApiGet(url);
|
|
1654
1652
|
if (json != null) {
|
|
1655
|
-
const
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
store[key] = new MockService(json[key], store);
|
|
1660
|
-
}
|
|
1661
|
-
});
|
|
1653
|
+
const data = Object.fromEntries(
|
|
1654
|
+
COLLECTIONS.map((key) => [key, json[key] || []])
|
|
1655
|
+
);
|
|
1656
|
+
store = getMockStoreFromData_(data);
|
|
1662
1657
|
}
|
|
1663
1658
|
return store;
|
|
1664
1659
|
}, "STORE_BUILD_");
|
|
@@ -2186,7 +2181,7 @@ function newRouteLink(category, route, locale) {
|
|
|
2186
2181
|
const href = route && route.id ? route.id.toString() : "/";
|
|
2187
2182
|
const id = route?.page || category.id;
|
|
2188
2183
|
const media = category.media || route?.media;
|
|
2189
|
-
const schema = route?.schema || category?.schema || "unknown";
|
|
2184
|
+
const schema = route?.template || route?.schema || category?.schema || "unknown";
|
|
2190
2185
|
const title = (0, import_bom_core15.localize)(category.title || route?.title || "untitled", locale);
|
|
2191
2186
|
const routeLink = {
|
|
2192
2187
|
category: category.id,
|
|
@@ -2215,7 +2210,7 @@ async function getLayout(market, locale) {
|
|
|
2215
2210
|
return object;
|
|
2216
2211
|
}, {});
|
|
2217
2212
|
const topLevelHrefs = flatTopLevelRoutes.reduce((object, routeLink) => {
|
|
2218
|
-
if (routeLink.href && !object[routeLink.schema] || routeLink.schema === routeLink.category) {
|
|
2213
|
+
if (routeLink.href && (!object[routeLink.schema] || routeLink.schema === routeLink.category)) {
|
|
2219
2214
|
object[routeLink.schema] = routeLink.href;
|
|
2220
2215
|
}
|
|
2221
2216
|
return object;
|
package/dist/index.mjs
CHANGED
|
@@ -688,7 +688,6 @@ var MockPageService = class extends MockService {
|
|
|
688
688
|
async decorateMany_(items, params = {}) {
|
|
689
689
|
const store = this.store;
|
|
690
690
|
let decoratedItems = items;
|
|
691
|
-
decoratedItems = await optimizeMany_(decoratedItems);
|
|
692
691
|
decoratedItems = await decorateCategories_(store, decoratedItems, params);
|
|
693
692
|
decoratedItems = await decorateLocalizables_(decoratedItems, params);
|
|
694
693
|
decoratedItems = await decorateHrefs_(store, decoratedItems, params);
|
|
@@ -1498,7 +1497,6 @@ var RemotePageService = class extends RemoteService {
|
|
|
1498
1497
|
async decorateMany_(items, params = {}) {
|
|
1499
1498
|
const store = this.store;
|
|
1500
1499
|
let decoratedItems = items;
|
|
1501
|
-
decoratedItems = await optimizeMany_(decoratedItems);
|
|
1502
1500
|
decoratedItems = await decorateSchemas_(store, decoratedItems, this.key);
|
|
1503
1501
|
decoratedItems = await decorateCategories_(store, decoratedItems, params);
|
|
1504
1502
|
decoratedItems = await decorateHrefs_(store, decoratedItems, params);
|
|
@@ -1543,17 +1541,14 @@ async function getRemoteStore_() {
|
|
|
1543
1541
|
async function getRemoteStoreStaticBuild_() {
|
|
1544
1542
|
return fromCache(async () => {
|
|
1545
1543
|
console.log("getRemoteStoreStaticBuild_");
|
|
1546
|
-
|
|
1544
|
+
let store = {};
|
|
1547
1545
|
const url = "/store";
|
|
1548
1546
|
const json = await remoteApiGet(url);
|
|
1549
1547
|
if (json != null) {
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
store[key] = new MockService(json[key], store);
|
|
1555
|
-
}
|
|
1556
|
-
});
|
|
1548
|
+
const data = Object.fromEntries(
|
|
1549
|
+
COLLECTIONS.map((key) => [key, json[key] || []])
|
|
1550
|
+
);
|
|
1551
|
+
store = getMockStoreFromData_(data);
|
|
1557
1552
|
}
|
|
1558
1553
|
return store;
|
|
1559
1554
|
}, "STORE_BUILD_");
|
|
@@ -2081,7 +2076,7 @@ function newRouteLink(category, route, locale) {
|
|
|
2081
2076
|
const href = route && route.id ? route.id.toString() : "/";
|
|
2082
2077
|
const id = route?.page || category.id;
|
|
2083
2078
|
const media = category.media || route?.media;
|
|
2084
|
-
const schema = route?.schema || category?.schema || "unknown";
|
|
2079
|
+
const schema = route?.template || route?.schema || category?.schema || "unknown";
|
|
2085
2080
|
const title = localize(category.title || route?.title || "untitled", locale);
|
|
2086
2081
|
const routeLink = {
|
|
2087
2082
|
category: category.id,
|
|
@@ -2110,7 +2105,7 @@ async function getLayout(market, locale) {
|
|
|
2110
2105
|
return object;
|
|
2111
2106
|
}, {});
|
|
2112
2107
|
const topLevelHrefs = flatTopLevelRoutes.reduce((object, routeLink) => {
|
|
2113
|
-
if (routeLink.href && !object[routeLink.schema] || routeLink.schema === routeLink.category) {
|
|
2108
|
+
if (routeLink.href && (!object[routeLink.schema] || routeLink.schema === routeLink.category)) {
|
|
2114
2109
|
object[routeLink.schema] = routeLink.href;
|
|
2115
2110
|
}
|
|
2116
2111
|
return object;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICategorized, QueryParams } from '@websolutespa/bom-core';
|
|
2
|
-
import { decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateLocalizable_, decorateLocalizables_, decorateNav_, decorateRelation_, decorateRelations_
|
|
2
|
+
import { decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateLocalizable_, decorateLocalizables_, decorateNav_, decorateRelation_, decorateRelations_ } from '../decorators';
|
|
3
3
|
import { MockService } from './mock.service';
|
|
4
4
|
|
|
5
5
|
export class MockPageService<T extends ICategorized = ICategorized> extends MockService<T> {
|
|
@@ -22,7 +22,7 @@ export class MockPageService<T extends ICategorized = ICategorized> extends Mock
|
|
|
22
22
|
protected override async decorateMany_<B extends T = T>(items: B[], params: QueryParams = {}): Promise<B[]> {
|
|
23
23
|
const store = this.store;
|
|
24
24
|
let decoratedItems = items;
|
|
25
|
-
decoratedItems = await optimizeMany_(decoratedItems);
|
|
25
|
+
// decoratedItems = await optimizeMany_(decoratedItems);
|
|
26
26
|
decoratedItems = await decorateCategories_<B>(store, decoratedItems, params);
|
|
27
27
|
decoratedItems = await decorateLocalizables_<B>(decoratedItems, params);
|
|
28
28
|
decoratedItems = await decorateHrefs_<B>(store, decoratedItems, params);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICategorized, QueryParams } from '@websolutespa/bom-core';
|
|
2
|
-
import { decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateNav_, decorateRelation_, decorateSchema_, decorateSchemas_
|
|
2
|
+
import { decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateNav_, decorateRelation_, decorateSchema_, decorateSchemas_ } from '../decorators';
|
|
3
3
|
import { RemoteService } from './remote.service';
|
|
4
4
|
|
|
5
5
|
export class RemotePageService<T extends ICategorized = ICategorized> extends RemoteService<T> {
|
|
@@ -22,7 +22,7 @@ export class RemotePageService<T extends ICategorized = ICategorized> extends Re
|
|
|
22
22
|
protected override async decorateMany_<B extends T = T>(items: B[], params: QueryParams = {}): Promise<B[]> {
|
|
23
23
|
const store = this.store;
|
|
24
24
|
let decoratedItems = items;
|
|
25
|
-
decoratedItems = await optimizeMany_<B>(decoratedItems);
|
|
25
|
+
// decoratedItems = await optimizeMany_<B>(decoratedItems);
|
|
26
26
|
decoratedItems = await decorateSchemas_<B>(store, decoratedItems, this.key);
|
|
27
27
|
decoratedItems = await decorateCategories_<B>(store, decoratedItems, params);
|
|
28
28
|
decoratedItems = await decorateHrefs_<B>(store, decoratedItems, params);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IMemoryStore, IQuerable, IStore } from '@websolutespa/bom-core';
|
|
2
2
|
import { fromCache } from '../cache/cache.service';
|
|
3
3
|
import { CachedService } from '../cached/cached.service';
|
|
4
|
-
import { MockService } from '../mock/mock.service';
|
|
5
4
|
import { getMockStore, getMockStoreFromData_ } from '../mock/mock.store';
|
|
6
5
|
import { BuildStrategy, COLLECTIONS, KNOWN_COLLECTIONS, MOCK_COLLECTIONS, NextPhase, StoreStrategy, buildStrategy, nextPhase, storeStrategy } from '../store/store';
|
|
7
6
|
import { RemoteMenuService } from './remote-menu.service';
|
|
@@ -49,17 +48,14 @@ async function getRemoteStore_<T extends IStore>(): Promise<T> {
|
|
|
49
48
|
async function getRemoteStoreStaticBuild_<T extends IStore>(): Promise<T> {
|
|
50
49
|
return fromCache<T>(async () => {
|
|
51
50
|
console.log('getRemoteStoreStaticBuild_');
|
|
52
|
-
|
|
51
|
+
let store: IStore = {};
|
|
53
52
|
const url = '/store';
|
|
54
53
|
const json = await remoteApiGet<IMemoryStore>(url);
|
|
55
54
|
if (json != null) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
store[key] = new MockService(json[key], store);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
55
|
+
const data = Object.fromEntries(
|
|
56
|
+
COLLECTIONS.map(key => ([key, json[key] || []]))
|
|
57
|
+
);
|
|
58
|
+
store = getMockStoreFromData_(data);
|
|
63
59
|
}
|
|
64
60
|
return store as T;
|
|
65
61
|
}, 'STORE_BUILD_');
|