@websolutespa/bom-mixer-store 1.10.0 → 1.10.1

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,13 @@
1
1
  # @websolutespa/bom-mixer-store
2
2
 
3
+ ## 1.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: IApp global
8
+ - Updated dependencies
9
+ - @websolutespa/bom-core@1.8.24
10
+
3
11
  ## 1.10.0
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FetchRequestOptions, IEquatable, ICategory, IStore, QueryParams, ICategorized, IRoute, ISchema, IUndecoratedMenu, IMenu, IEntity, JsonService, IMemoryStore, IQuerable, IPagedResult } from '@websolutespa/bom-core';
1
+ import { FetchRequestOptions, IEquatable, ICategory, IStore, QueryParams, ICategorized, IRoute, ISchema, IUndecoratedMenu, IMenu, IEntity, JsonService, IMemoryStore, IQuerable, GlobalQueryParams, IPagedResult } from '@websolutespa/bom-core';
2
2
  import { NextApiRequest, NextApiResponse } from 'next';
3
3
  import { NextRequest } from 'next/server';
4
4
 
@@ -141,6 +141,7 @@ declare class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
141
141
  key: string;
142
142
  store: IStore;
143
143
  constructor(key: string, store: IStore);
144
+ findGlobal<B extends T = T>(params?: GlobalQueryParams, token?: string): Promise<B | undefined>;
144
145
  findOne<B extends T = T>(id: IEquatable, params?: Omit<QueryParams, 'where'>, token?: string): Promise<B | undefined>;
145
146
  findMany<B extends T = T>(params?: QueryParams, token?: string): Promise<B[]>;
146
147
  findPaged<B extends T = T>(params?: QueryParams, token?: string): Promise<IPagedResult<B>>;
package/dist/index.js CHANGED
@@ -1178,6 +1178,7 @@ var ENV_COLLECTIONS = process.env.COLLECTIONS ? process.env.COLLECTIONS.split(",
1178
1178
  var MOCK_COLLECTIONS = process.env.MOCKS ? process.env.MOCKS.split(",") : [];
1179
1179
  var STATIC_COLLECTIONS = staticCollections.map((x) => x.slug);
1180
1180
  var KNOWN_COLLECTIONS = [
1181
+ "app",
1181
1182
  "category",
1182
1183
  "label",
1183
1184
  "locale",
@@ -1428,6 +1429,13 @@ var CachedService = class extends import_bom_core12.JsonService {
1428
1429
  data
1429
1430
  });
1430
1431
  }
1432
+ async findGlobal(params = {}) {
1433
+ const serializedParams = (0, import_bom_core12.qsSerialize)(params);
1434
+ const key = `findGlobal?${serializedParams}`;
1435
+ return await this.fromCache_(async () => {
1436
+ return await this.service_.findGlobal(params);
1437
+ }, key);
1438
+ }
1431
1439
  async findOne(id, params = {}) {
1432
1440
  const serializedParams = (0, import_bom_core12.qsSerialize)(params);
1433
1441
  const key = `findOne[${id}]?${serializedParams}`;
@@ -1539,6 +1547,21 @@ var RemoteService = class {
1539
1547
  this.key = key;
1540
1548
  this.store = store;
1541
1549
  }
1550
+ async findGlobal(params = {}, token) {
1551
+ params.richText = String(params.richText) === "true" ? true : false;
1552
+ const query = (0, import_bom_core14.qsSerialize)(params);
1553
+ const search = query ? `?${query}` : "";
1554
+ const url = `/globals/${this.key}${search}`;
1555
+ try {
1556
+ const item = await remoteApiGet(url, getRemoteApiRequestOptions(token));
1557
+ if (item) {
1558
+ return await this.decorateOne_(item, params);
1559
+ }
1560
+ } catch (error) {
1561
+ console.log("RemoteService", this.key, "findGlobal.error");
1562
+ }
1563
+ return;
1564
+ }
1542
1565
  async findOne(id, params = {}, token) {
1543
1566
  params.richText = String(params.richText) === "true" ? true : false;
1544
1567
  const query = (0, import_bom_core14.qsSerialize)(params);
@@ -2278,6 +2301,13 @@ async function getLabels(params = {}) {
2278
2301
  return items;
2279
2302
  }
2280
2303
 
2304
+ // ../models/src/app/app.service.ts
2305
+ async function getApp(params = {}) {
2306
+ const store = await getStore();
2307
+ const item = await store.app.findGlobal(params);
2308
+ return item;
2309
+ }
2310
+
2281
2311
  // ../models/src/locale/locale.service.ts
2282
2312
  async function getLocales(params = {}) {
2283
2313
  const store = await getStore();
@@ -2364,6 +2394,7 @@ async function getLayout(market, locale) {
2364
2394
  const markets = await getMarkets({ locale });
2365
2395
  const locales = await getLocales({ locale });
2366
2396
  const labels = await getLabels({ locale });
2397
+ const app = await getApp({ locale }) || {};
2367
2398
  const tree = await getRouteLinkTree(market, locale);
2368
2399
  const firstLevelRoutes = tree?.items || [];
2369
2400
  const flatTopLevelRoutes = tree ? [tree, ...firstLevelRoutes] : [];
@@ -2390,6 +2421,7 @@ async function getLayout(market, locale) {
2390
2421
  locales,
2391
2422
  market,
2392
2423
  markets,
2424
+ app,
2393
2425
  menu,
2394
2426
  topLevelHrefs,
2395
2427
  topLevelRoutes,
package/dist/index.mjs CHANGED
@@ -1073,6 +1073,7 @@ var ENV_COLLECTIONS = process.env.COLLECTIONS ? process.env.COLLECTIONS.split(",
1073
1073
  var MOCK_COLLECTIONS = process.env.MOCKS ? process.env.MOCKS.split(",") : [];
1074
1074
  var STATIC_COLLECTIONS = staticCollections.map((x) => x.slug);
1075
1075
  var KNOWN_COLLECTIONS = [
1076
+ "app",
1076
1077
  "category",
1077
1078
  "label",
1078
1079
  "locale",
@@ -1323,6 +1324,13 @@ var CachedService = class extends JsonService3 {
1323
1324
  data
1324
1325
  });
1325
1326
  }
1327
+ async findGlobal(params = {}) {
1328
+ const serializedParams = qsSerialize(params);
1329
+ const key = `findGlobal?${serializedParams}`;
1330
+ return await this.fromCache_(async () => {
1331
+ return await this.service_.findGlobal(params);
1332
+ }, key);
1333
+ }
1326
1334
  async findOne(id, params = {}) {
1327
1335
  const serializedParams = qsSerialize(params);
1328
1336
  const key = `findOne[${id}]?${serializedParams}`;
@@ -1434,6 +1442,21 @@ var RemoteService = class {
1434
1442
  this.key = key;
1435
1443
  this.store = store;
1436
1444
  }
1445
+ async findGlobal(params = {}, token) {
1446
+ params.richText = String(params.richText) === "true" ? true : false;
1447
+ const query = qsSerialize2(params);
1448
+ const search = query ? `?${query}` : "";
1449
+ const url = `/globals/${this.key}${search}`;
1450
+ try {
1451
+ const item = await remoteApiGet(url, getRemoteApiRequestOptions(token));
1452
+ if (item) {
1453
+ return await this.decorateOne_(item, params);
1454
+ }
1455
+ } catch (error) {
1456
+ console.log("RemoteService", this.key, "findGlobal.error");
1457
+ }
1458
+ return;
1459
+ }
1437
1460
  async findOne(id, params = {}, token) {
1438
1461
  params.richText = String(params.richText) === "true" ? true : false;
1439
1462
  const query = qsSerialize2(params);
@@ -2173,6 +2196,13 @@ async function getLabels(params = {}) {
2173
2196
  return items;
2174
2197
  }
2175
2198
 
2199
+ // ../models/src/app/app.service.ts
2200
+ async function getApp(params = {}) {
2201
+ const store = await getStore();
2202
+ const item = await store.app.findGlobal(params);
2203
+ return item;
2204
+ }
2205
+
2176
2206
  // ../models/src/locale/locale.service.ts
2177
2207
  async function getLocales(params = {}) {
2178
2208
  const store = await getStore();
@@ -2259,6 +2289,7 @@ async function getLayout(market, locale) {
2259
2289
  const markets = await getMarkets({ locale });
2260
2290
  const locales = await getLocales({ locale });
2261
2291
  const labels = await getLabels({ locale });
2292
+ const app = await getApp({ locale }) || {};
2262
2293
  const tree = await getRouteLinkTree(market, locale);
2263
2294
  const firstLevelRoutes = tree?.items || [];
2264
2295
  const flatTopLevelRoutes = tree ? [tree, ...firstLevelRoutes] : [];
@@ -2285,6 +2316,7 @@ async function getLayout(market, locale) {
2285
2316
  locales,
2286
2317
  market,
2287
2318
  markets,
2319
+ app,
2288
2320
  menu,
2289
2321
  topLevelHrefs,
2290
2322
  topLevelRoutes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-store",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Mixer Store module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -1,4 +1,4 @@
1
- import { IEntity, IEquatable, IPagedResult, IQuerable, JsonService, QueryParams, qsSerialize } from '@websolutespa/bom-core';
1
+ import { GlobalQueryParams, IEntity, IEquatable, IPagedResult, IQuerable, JsonService, QueryParams, qsSerialize } from '@websolutespa/bom-core';
2
2
  import { StoreStrategy, storeCacheDuration, storeStrategy } from '../store/store';
3
3
 
4
4
  export type ICacheResult<T extends IEntity = IEntity> = T | T[] | IPagedResult<T> | undefined;
@@ -60,6 +60,14 @@ export class CachedService<T extends IEntity = IEntity> extends JsonService<T> {
60
60
  });
61
61
  }
62
62
 
63
+ async findGlobal<B extends T = T>(params: GlobalQueryParams = {}): Promise<B | undefined> {
64
+ const serializedParams = qsSerialize(params);
65
+ const key = `findGlobal?${serializedParams}`;
66
+ return await this.fromCache_(async () => {
67
+ return await this.service_.findGlobal(params);
68
+ }, key) as B | undefined;
69
+ }
70
+
63
71
  async findOne<B extends T = T>(id: IEquatable, params: QueryParams = {}): Promise<B | undefined> {
64
72
  const serializedParams = qsSerialize(params);
65
73
  const key = `findOne[${id}]?${serializedParams}`;
@@ -1,4 +1,4 @@
1
- import { IEntity, IEquatable, IPagedResult, IQuerable, IStore, qsSerialize, QueryParams } from '@websolutespa/bom-core';
1
+ import { GlobalQueryParams, IEntity, IEquatable, IPagedResult, IQuerable, IStore, qsSerialize, QueryParams } from '@websolutespa/bom-core';
2
2
  import { getRemoteApiRequestOptions } from '../api/api';
3
3
  import { decorateSchema_, decorateSchemas_ } from '../decorators';
4
4
  import { remoteApiDelete, remoteApiGet, remoteApiPatch, remoteApiPost } from './remote.api';
@@ -22,6 +22,23 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
22
22
  this.store = store;
23
23
  }
24
24
 
25
+ async findGlobal<B extends T = T>(params: GlobalQueryParams = {}, token?: string): Promise<B | undefined> {
26
+ params.richText = String(params.richText) === 'true' ? true : false;
27
+ const query = qsSerialize(params);
28
+ const search = query ? `?${query}` : '';
29
+ const url = `/globals/${this.key}${search}`;
30
+ // console.log('RemoteService', this.key, 'findGlobal', url);
31
+ try {
32
+ const item = await remoteApiGet<B>(url, getRemoteApiRequestOptions(token));
33
+ if (item) {
34
+ return await this.decorateOne_(item, params);
35
+ }
36
+ } catch (error) {
37
+ console.log('RemoteService', this.key, 'findGlobal.error');
38
+ }
39
+ return;
40
+ }
41
+
25
42
  async findOne<B extends T = T>(id: IEquatable, params: Omit<QueryParams, 'where'> = {}, token?: string): Promise<B | undefined> {
26
43
  params.richText = String(params.richText) === 'true' ? true : false;
27
44
  const query = qsSerialize(params);
@@ -69,6 +69,7 @@ const ENV_COLLECTIONS: string[] = process.env.COLLECTIONS ? process.env.COLLECTI
69
69
  export const MOCK_COLLECTIONS: string[] = process.env.MOCKS ? process.env.MOCKS.split(',') : [];
70
70
  export const STATIC_COLLECTIONS: string[] = staticCollections.map(x => x.slug);
71
71
  export const KNOWN_COLLECTIONS: string[] = [
72
+ 'app',
72
73
  'category',
73
74
  'label',
74
75
  'locale',