@websolutespa/bom-mixer-models 3.0.0 → 3.0.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 +514 -498
- package/dist/exports/proxy.d.ts.map +1 -1
- package/dist/exports/proxy.js +5 -7
- package/dist/exports/proxy.js.map +1 -1
- package/dist/exports/server.d.ts +1 -1
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +14 -6
- package/dist/exports/server.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +8 -8
- package/src/page/page.service.ts +1 -2
- package/src/route/route-revalidate.handler.ts +18 -8
- package/src/route/route.interceptor.ts +5 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websolutespa/bom-mixer-models",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Mixer Models module of the BOM Repository",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bom",
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@websolutespa/bom-core": "
|
|
25
|
-
"@websolutespa/bom-mixer-store": "
|
|
24
|
+
"@websolutespa/bom-core": "^3.0.1",
|
|
25
|
+
"@websolutespa/bom-mixer-store": "^3.0.1",
|
|
26
26
|
"iron-session": "8.0.4",
|
|
27
27
|
"next": "16.1.6"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/react": "19.2.10",
|
|
31
30
|
"@types/react-dom": "19.2.3",
|
|
32
|
-
"@
|
|
33
|
-
"@websolutespa/
|
|
34
|
-
"@websolutespa/
|
|
31
|
+
"@types/react": "19.2.10",
|
|
32
|
+
"@websolutespa/bom-cli": "^3.0.1",
|
|
33
|
+
"@websolutespa/eslint-config": "^3.0.0",
|
|
34
|
+
"@websolutespa/test": "^3.0.1",
|
|
35
|
+
"@websolutespa/tsconfig": "^3.0.0",
|
|
35
36
|
"eslint": "9.31.0",
|
|
36
|
-
"@websolutespa/eslint-config": "*",
|
|
37
37
|
"npm-run-all": "4.1.5",
|
|
38
38
|
"react": "19.2.3",
|
|
39
39
|
"schema-dts": "1.1.5",
|
package/src/page/page.service.ts
CHANGED
|
@@ -258,7 +258,6 @@ export function getPublicUrl() {
|
|
|
258
258
|
return publicUrl;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
export function resolveHref(href
|
|
262
|
-
href = href || '';
|
|
261
|
+
export function resolveHref(href: string = '') {
|
|
263
262
|
return href.startsWith('http') ? href : `${getPublicUrl()}${href}`;
|
|
264
263
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
|
|
2
|
+
import { Where } from '@websolutespa/bom-core';
|
|
2
3
|
import { apiHandler } from '@websolutespa/bom-mixer-store/server';
|
|
3
4
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
4
5
|
import { resolveRoute } from './route';
|
|
@@ -16,22 +17,31 @@ export function routeRevalidateHandler() {
|
|
|
16
17
|
}
|
|
17
18
|
try {
|
|
18
19
|
/* { "id": 1, "schema": "product", "href": "/product/xxxx" } */
|
|
19
|
-
const { href } = request.body;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
})
|
|
20
|
+
const { href, schema, page } = request.body || {};
|
|
21
|
+
|
|
22
|
+
let where: Where;
|
|
23
|
+
if (href) {
|
|
24
|
+
where = { id: { equals: href } };
|
|
25
|
+
} else if (schema && page) {
|
|
26
|
+
where = { schema: { equals: schema }, page: { equals: page } };
|
|
27
|
+
} else {
|
|
28
|
+
return response.status(400).send('Missing href or schema and page');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const routes = await getRoutes({ where });
|
|
25
32
|
if (routes.length === 0) {
|
|
26
33
|
// console.log('route.notfound', href);
|
|
27
|
-
|
|
34
|
+
const notFoundTarget = href || `${schema}:${page}`;
|
|
35
|
+
return response.status(404).send(`routeRevalidateHandler.notFound ${notFoundTarget}`);
|
|
28
36
|
}
|
|
29
37
|
// console.log('routes', routes);
|
|
30
38
|
for (const route of routes) {
|
|
31
39
|
// console.log('route.found', route);
|
|
32
40
|
const resolvedRoute = resolveRoute(route);
|
|
33
|
-
console.log('route.revalidating', resolvedRoute);
|
|
41
|
+
// console.log('route.revalidating', resolvedRoute);
|
|
34
42
|
await response.revalidate(resolvedRoute);
|
|
43
|
+
|
|
44
|
+
// @TODO: CDN cache purge
|
|
35
45
|
}
|
|
36
46
|
return response.json({ revalidated: true });
|
|
37
47
|
} catch (error) {
|
|
@@ -48,29 +48,20 @@ export async function detectCountry(request: NextRequest, defaultMarket?: string
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
async function getMarkets() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} else {
|
|
55
|
-
routes = await storeApiGet('/market?pagination=false');
|
|
56
|
-
}
|
|
57
|
-
return routes;
|
|
51
|
+
const apiGet = storeStrategy === StoreStrategy.DecoratedApi ? localApiGet : storeApiGet;
|
|
52
|
+
const markets: IMarket[] = await apiGet('/market?pagination=false');
|
|
53
|
+
return markets;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
async function getRootRoutes() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
routes = await localApiGet('/route?where[isRoot][equals]=true');
|
|
64
|
-
} else {
|
|
65
|
-
routes = await storeApiGet('/route?where[isRoot][equals]=true');
|
|
66
|
-
}
|
|
57
|
+
const apiGet = storeStrategy === StoreStrategy.DecoratedApi ? localApiGet : storeApiGet;
|
|
58
|
+
const routes: IRoute[] = await apiGet('/route?where[isRoot][equals]=true');
|
|
67
59
|
return routes;
|
|
68
60
|
}
|
|
69
61
|
|
|
70
62
|
export async function routeAutoDetection(request: NextRequest, next: NextFetchEvent): Promise<string | undefined> {
|
|
71
63
|
let route: string | undefined;
|
|
72
64
|
const url = request.nextUrl;
|
|
73
|
-
// console.log('routeInterceptor.routeAutoDetection', url);
|
|
74
65
|
if (url.pathname === '/') {
|
|
75
66
|
const cookie = request.cookies.get('detectedRoute');
|
|
76
67
|
if (cookie?.value) {
|