@websolutespa/bom-mixer-store 1.8.7 → 1.8.9

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,17 @@
1
1
  # @websolutespa/bom-mixer-store
2
2
 
3
+ ## 1.8.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: BuildStrategy.Runtime
8
+
9
+ ## 1.8.8
10
+
11
+ ### Patch Changes
12
+
13
+ - Modified: request & response types
14
+
3
15
  ## 1.8.7
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1746,7 +1746,7 @@ async function getRemoteStoreStaticBuild_() {
1746
1746
  return fromCache(async () => {
1747
1747
  console.log("getRemoteStoreStaticBuild_");
1748
1748
  let store = {};
1749
- const url = "/store";
1749
+ const url = `/store?strategy=${buildStrategy}`;
1750
1750
  const json = await remoteApiGet(url);
1751
1751
  if (json != null) {
1752
1752
  const data = Object.fromEntries(
@@ -1757,24 +1757,9 @@ async function getRemoteStoreStaticBuild_() {
1757
1757
  return store;
1758
1758
  }, "STORE_BUILD_");
1759
1759
  }
1760
- async function getRemoteStoreRuntimeBuild_() {
1761
- return fromCache(async () => {
1762
- console.log("getRemoteStoreRuntimeBuild_");
1763
- const data = {};
1764
- COLLECTIONS.forEach((key) => {
1765
- data[key] = [];
1766
- });
1767
- const store = getMockStoreFromData_(data);
1768
- return store;
1769
- }, "STORE_RUNTIME_BUILD_");
1770
- }
1771
1760
  async function getRemoteStore() {
1772
1761
  if (nextPhase === "phase-production-build" /* ProductionBuild */) {
1773
- if (buildStrategy === "runtime" /* Runtime */) {
1774
- return await getRemoteStoreRuntimeBuild_();
1775
- } else {
1776
- return await getRemoteStoreStaticBuild_();
1777
- }
1762
+ return await getRemoteStoreStaticBuild_();
1778
1763
  } else {
1779
1764
  return await getRemoteStore_();
1780
1765
  }
package/dist/index.mjs CHANGED
@@ -1641,7 +1641,7 @@ async function getRemoteStoreStaticBuild_() {
1641
1641
  return fromCache(async () => {
1642
1642
  console.log("getRemoteStoreStaticBuild_");
1643
1643
  let store = {};
1644
- const url = "/store";
1644
+ const url = `/store?strategy=${buildStrategy}`;
1645
1645
  const json = await remoteApiGet(url);
1646
1646
  if (json != null) {
1647
1647
  const data = Object.fromEntries(
@@ -1652,24 +1652,9 @@ async function getRemoteStoreStaticBuild_() {
1652
1652
  return store;
1653
1653
  }, "STORE_BUILD_");
1654
1654
  }
1655
- async function getRemoteStoreRuntimeBuild_() {
1656
- return fromCache(async () => {
1657
- console.log("getRemoteStoreRuntimeBuild_");
1658
- const data = {};
1659
- COLLECTIONS.forEach((key) => {
1660
- data[key] = [];
1661
- });
1662
- const store = getMockStoreFromData_(data);
1663
- return store;
1664
- }, "STORE_RUNTIME_BUILD_");
1665
- }
1666
1655
  async function getRemoteStore() {
1667
1656
  if (nextPhase === "phase-production-build" /* ProductionBuild */) {
1668
- if (buildStrategy === "runtime" /* Runtime */) {
1669
- return await getRemoteStoreRuntimeBuild_();
1670
- } else {
1671
- return await getRemoteStoreStaticBuild_();
1672
- }
1657
+ return await getRemoteStoreStaticBuild_();
1673
1658
  } else {
1674
1659
  return await getRemoteStore_();
1675
1660
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-store",
3
- "version": "1.8.7",
3
+ "version": "1.8.9",
4
4
  "description": "Mixer Store module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -2,7 +2,7 @@ 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
4
  import { getMockStore, getMockStoreFromData_ } from '../mock/mock.store';
5
- import { BuildStrategy, COLLECTIONS, KNOWN_COLLECTIONS, MOCK_COLLECTIONS, NextPhase, StoreStrategy, buildStrategy, nextPhase, storeStrategy } from '../store/store';
5
+ import { COLLECTIONS, KNOWN_COLLECTIONS, MOCK_COLLECTIONS, NextPhase, StoreStrategy, buildStrategy, nextPhase, storeStrategy } from '../store/store';
6
6
  import { RemoteMenuService } from './remote-menu.service';
7
7
  import { RemotePageService } from './remote-page.service';
8
8
  import { remoteApiGet } from './remote.api';
@@ -49,7 +49,7 @@ async function getRemoteStoreStaticBuild_<T extends IStore>(): Promise<T> {
49
49
  return fromCache<T>(async () => {
50
50
  console.log('getRemoteStoreStaticBuild_');
51
51
  let store: IStore = {};
52
- const url = '/store';
52
+ const url = `/store?strategy=${buildStrategy}`;
53
53
  const json = await remoteApiGet<IMemoryStore>(url);
54
54
  if (json != null) {
55
55
  const data = Object.fromEntries(
@@ -75,11 +75,14 @@ async function getRemoteStoreRuntimeBuild_<T extends IStore>(): Promise<T> {
75
75
 
76
76
  export async function getRemoteStore<T extends IStore>(): Promise<T> {
77
77
  if (nextPhase === NextPhase.ProductionBuild) {
78
+ /*
78
79
  if (buildStrategy === BuildStrategy.Runtime) {
79
80
  return await getRemoteStoreRuntimeBuild_();
80
81
  } else {
81
82
  return await getRemoteStoreStaticBuild_();
82
83
  }
84
+ */
85
+ return await getRemoteStoreStaticBuild_();
83
86
  } else {
84
87
  return await getRemoteStore_();
85
88
  }
@@ -1,11 +1,14 @@
1
1
  import { isDevelopment } from '@websolutespa/bom-core';
2
+ import { IncomingMessage, ServerResponse } from 'http';
2
3
  import { getIronSession, IronSession, SessionOptions } from 'iron-session';
3
4
  import { NextApiRequest, NextApiResponse } from 'next';
4
5
  import { NextRequest, NextResponse } from 'next/server';
5
6
 
6
7
  export async function getSession<T extends object = Record<string, any>>(
7
- request: NextRequest | NextApiRequest,
8
- response: NextResponse | NextApiResponse
8
+ request: NextRequest | NextApiRequest | IncomingMessage & {
9
+ cookies: Partial<{ [key: string]: string }>;
10
+ },
11
+ response: NextResponse | NextApiResponse | ServerResponse<IncomingMessage>
9
12
  ): Promise<IronSession<T>> {
10
13
  const COOKIE_NAME = 'websolutespa-next-js';
11
14
  const COOKIE_PASSWORD = process.env.SECRET_COOKIE_PASSWORD as string || 'SECRET_COOKIE_PASSWORD_32_CHARS_LONG';
@@ -27,8 +30,10 @@ export type SessionWithToken<T extends object = Record<string, any>> = T & Parti
27
30
  }>;
28
31
 
29
32
  export async function getSessionToken<T extends SessionWithToken>(
30
- request: NextRequest | NextApiRequest,
31
- response: NextResponse | NextApiResponse
33
+ request: NextRequest | NextApiRequest | IncomingMessage & {
34
+ cookies: Partial<{ [key: string]: string }>;
35
+ },
36
+ response: NextResponse | NextApiResponse | ServerResponse<IncomingMessage>
32
37
  ): Promise<string | undefined> {
33
38
  const session = await getSession<T>(request, response);
34
39
  if (session.token && session.exp && session.exp > Math.floor(new Date().getTime() / 1000)) {