@websolutespa/bom-mixer-store 1.8.1 → 1.8.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @websolutespa/bom-mixer-store
2
2
 
3
+ ## 1.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: getRemoteStoreStaticBuild_
8
+
3
9
  ## 1.8.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1648,17 +1648,14 @@ async function getRemoteStore_() {
1648
1648
  async function getRemoteStoreStaticBuild_() {
1649
1649
  return fromCache(async () => {
1650
1650
  console.log("getRemoteStoreStaticBuild_");
1651
- const store = {};
1651
+ let store = {};
1652
1652
  const url = "/store";
1653
1653
  const json = await remoteApiGet(url);
1654
1654
  if (json != null) {
1655
- const collections = Object.keys(json);
1656
- collections.sort();
1657
- collections.forEach((key) => {
1658
- if (json[key]) {
1659
- store[key] = new MockService(json[key], store);
1660
- }
1661
- });
1655
+ const data = Object.fromEntries(
1656
+ COLLECTIONS.map((key) => [key, json[key] || []])
1657
+ );
1658
+ store = getMockStoreFromData_(data);
1662
1659
  }
1663
1660
  return store;
1664
1661
  }, "STORE_BUILD_");
@@ -2186,7 +2183,7 @@ function newRouteLink(category, route, locale) {
2186
2183
  const href = route && route.id ? route.id.toString() : "/";
2187
2184
  const id = route?.page || category.id;
2188
2185
  const media = category.media || route?.media;
2189
- const schema = route?.schema || category?.schema || "unknown";
2186
+ const schema = route?.template || route?.schema || category?.schema || "unknown";
2190
2187
  const title = (0, import_bom_core15.localize)(category.title || route?.title || "untitled", locale);
2191
2188
  const routeLink = {
2192
2189
  category: category.id,
@@ -2215,7 +2212,7 @@ async function getLayout(market, locale) {
2215
2212
  return object;
2216
2213
  }, {});
2217
2214
  const topLevelHrefs = flatTopLevelRoutes.reduce((object, routeLink) => {
2218
- if (routeLink.href && !object[routeLink.schema] || routeLink.schema === routeLink.category) {
2215
+ if (routeLink.href && (!object[routeLink.schema] || routeLink.schema === routeLink.category)) {
2219
2216
  object[routeLink.schema] = routeLink.href;
2220
2217
  }
2221
2218
  return object;
package/dist/index.mjs CHANGED
@@ -1543,17 +1543,14 @@ async function getRemoteStore_() {
1543
1543
  async function getRemoteStoreStaticBuild_() {
1544
1544
  return fromCache(async () => {
1545
1545
  console.log("getRemoteStoreStaticBuild_");
1546
- const store = {};
1546
+ let store = {};
1547
1547
  const url = "/store";
1548
1548
  const json = await remoteApiGet(url);
1549
1549
  if (json != null) {
1550
- const collections = Object.keys(json);
1551
- collections.sort();
1552
- collections.forEach((key) => {
1553
- if (json[key]) {
1554
- store[key] = new MockService(json[key], store);
1555
- }
1556
- });
1550
+ const data = Object.fromEntries(
1551
+ COLLECTIONS.map((key) => [key, json[key] || []])
1552
+ );
1553
+ store = getMockStoreFromData_(data);
1557
1554
  }
1558
1555
  return store;
1559
1556
  }, "STORE_BUILD_");
@@ -2081,7 +2078,7 @@ function newRouteLink(category, route, locale) {
2081
2078
  const href = route && route.id ? route.id.toString() : "/";
2082
2079
  const id = route?.page || category.id;
2083
2080
  const media = category.media || route?.media;
2084
- const schema = route?.schema || category?.schema || "unknown";
2081
+ const schema = route?.template || route?.schema || category?.schema || "unknown";
2085
2082
  const title = localize(category.title || route?.title || "untitled", locale);
2086
2083
  const routeLink = {
2087
2084
  category: category.id,
@@ -2110,7 +2107,7 @@ async function getLayout(market, locale) {
2110
2107
  return object;
2111
2108
  }, {});
2112
2109
  const topLevelHrefs = flatTopLevelRoutes.reduce((object, routeLink) => {
2113
- if (routeLink.href && !object[routeLink.schema] || routeLink.schema === routeLink.category) {
2110
+ if (routeLink.href && (!object[routeLink.schema] || routeLink.schema === routeLink.category)) {
2114
2111
  object[routeLink.schema] = routeLink.href;
2115
2112
  }
2116
2113
  return object;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-store",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "Mixer Store module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -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
- const store: IStore = {};
51
+ let store: IStore = {};
53
52
  const url = '/store';
54
53
  const json = await remoteApiGet<IMemoryStore>(url);
55
54
  if (json != null) {
56
- const collections = Object.keys(json);
57
- collections.sort();
58
- collections.forEach(key => {
59
- if (json[key]) {
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_');