@websolutespa/bom-mixer-models 1.8.13 → 1.8.14

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,15 @@
1
1
  # @websolutespa/bom-mixer-models
2
2
 
3
+ ## 1.8.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: request & response types
8
+ - Updated dependencies
9
+ - Updated dependencies
10
+ - @websolutespa/bom-mixer-store@1.8.7
11
+ - @websolutespa/bom-core@1.8.15
12
+
3
13
  ## 1.8.13
4
14
 
5
15
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import { IOption, ILayout, IPage, IRouteParams, QueryParams, ICategory, IEquatable, ICategorized, IEntity, IPaginationResult, INamedEntity, ILabel, IComponent, PageProps, ILocale, IMarket, IMenu, IRoute, IRedirect, IRouteLink, IQuerable, IMedia } from '@websolutespa/bom-core';
2
2
  import { AppProps } from 'next/app';
3
3
  import { FC, ReactNode, ComponentType } from 'react';
4
- import { GetServerSideProps, Redirect } from 'next';
4
+ import { GetServerSideProps, Redirect, NextApiRequest, NextApiResponse } from 'next';
5
5
  import { DynamicOptions, Loader } from 'next/dynamic';
6
6
  import * as _websolutespa_bom_mixer_store from '@websolutespa/bom-mixer-store';
7
7
  import { NextRequest, NextFetchEvent, NextResponse } from 'next/server';
8
- import { IncomingMessage, ServerResponse } from 'http';
9
8
  import { IronSession } from 'iron-session';
10
9
 
11
10
  type IAddressOptions = {
@@ -205,12 +204,12 @@ declare function resolveRoute(route: IRoute & {
205
204
  type SeoWeight = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
206
205
  declare const getSeoWeight: (index?: number, seoWeight?: SeoWeight) => (subIndex?: number) => SeoWeight;
207
206
 
208
- declare function getSession<T extends object = Record<string, any>>(request: Request | IncomingMessage, response: Response | ServerResponse): Promise<IronSession<T>>;
207
+ declare function getSession<T extends object = Record<string, any>>(request: NextRequest | NextApiRequest, response: NextResponse | NextApiResponse): Promise<IronSession<T>>;
209
208
  type SessionWithToken<T extends object = Record<string, any>> = T & Partial<{
210
209
  token: string;
211
210
  exp: number;
212
211
  }>;
213
- declare function getSessionToken<T extends SessionWithToken>(request: Request | IncomingMessage, response: Response | ServerResponse): Promise<string | null>;
212
+ declare function getSessionToken<T extends SessionWithToken>(request: NextRequest | NextApiRequest, response: NextResponse | NextApiResponse): Promise<string | undefined>;
214
213
 
215
214
  declare const getSiteMapIndexProps: GetServerSideProps;
216
215
  declare const getSiteMapXMLProps: GetServerSideProps;
package/dist/index.js CHANGED
@@ -885,7 +885,7 @@ async function getSessionToken(request, response) {
885
885
  session.exp = void 0;
886
886
  await session.save();
887
887
  session.destroy();
888
- return null;
888
+ return;
889
889
  }
890
890
  }
891
891
 
package/dist/index.mjs CHANGED
@@ -783,7 +783,7 @@ async function getSessionToken(request, response) {
783
783
  session.exp = void 0;
784
784
  await session.save();
785
785
  session.destroy();
786
- return null;
786
+ return;
787
787
  }
788
788
  }
789
789
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-models",
3
- "version": "1.8.13",
3
+ "version": "1.8.14",
4
4
  "description": "Mixer Models module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -1,10 +1,11 @@
1
1
  import { isDevelopment } from '@websolutespa/bom-core';
2
- import { IncomingMessage, ServerResponse } from 'http';
3
2
  import { getIronSession, IronSession, SessionOptions } from 'iron-session';
3
+ import { NextApiRequest, NextApiResponse } from 'next';
4
+ import { NextRequest, NextResponse } from 'next/server';
4
5
 
5
6
  export async function getSession<T extends object = Record<string, any>>(
6
- request: Request | IncomingMessage,
7
- response: Response | ServerResponse
7
+ request: NextRequest | NextApiRequest,
8
+ response: NextResponse | NextApiResponse
8
9
  ): Promise<IronSession<T>> {
9
10
  const COOKIE_NAME = 'websolutespa-next-js';
10
11
  const COOKIE_PASSWORD = process.env.SECRET_COOKIE_PASSWORD as string || 'SECRET_COOKIE_PASSWORD_32_CHARS_LONG';
@@ -26,9 +27,9 @@ export type SessionWithToken<T extends object = Record<string, any>> = T & Parti
26
27
  }>;
27
28
 
28
29
  export async function getSessionToken<T extends SessionWithToken>(
29
- request: Request | IncomingMessage,
30
- response: Response | ServerResponse
31
- ): Promise<string | null> {
30
+ request: NextRequest | NextApiRequest,
31
+ response: NextResponse | NextApiResponse
32
+ ): Promise<string | undefined> {
32
33
  const session = await getSession<T>(request, response);
33
34
  if (session.token && session.exp && session.exp > Math.floor(new Date().getTime() / 1000)) {
34
35
  return session.token;
@@ -37,6 +38,6 @@ export async function getSessionToken<T extends SessionWithToken>(
37
38
  session.exp = undefined;
38
39
  await session.save();
39
40
  session.destroy();
40
- return null;
41
+ return;
41
42
  }
42
43
  }