@websolutespa/bom-mixer-models 0.2.0 → 0.4.0
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 +37 -25
- package/dist/index.d.ts +8 -154
- package/dist/index.js +54 -55
- package/dist/index.mjs +48 -49
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,25 +1,37 @@
|
|
|
1
|
-
# @websolutespa/bom-mixer-models
|
|
2
|
-
|
|
3
|
-
## 0.
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- Added:
|
|
8
|
-
|
|
9
|
-
## 0.
|
|
10
|
-
|
|
11
|
-
###
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
## 0.
|
|
16
|
-
|
|
17
|
-
### Minor Changes
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
## 0.
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
-
|
|
1
|
+
# @websolutespa/bom-mixer-models
|
|
2
|
+
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added: splat routes.
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Added: @websolutespa/bom-core.
|
|
14
|
+
|
|
15
|
+
## 0.2.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- Added: LazyComponent Types.
|
|
20
|
+
|
|
21
|
+
## 0.1.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Modified: page service.
|
|
26
|
+
|
|
27
|
+
## 0.1.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- mock refactor.
|
|
32
|
+
|
|
33
|
+
## 0.0.2
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Added: first release.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import { ISchema, IEquatable,
|
|
1
|
+
import { ISchema, IEquatable, IMedia, QueryParams, ICategory, ICategorized, IOption, INamedEntity, ILabel, ILayout, ILocale, IMarket, IMenu, ValueOf, IPageResult, IRoute, IPage, IRouteLink, IQuerable, IEntity } from '@websolutespa/bom-core';
|
|
2
2
|
import { ComponentType, ComponentProps } from 'react';
|
|
3
3
|
import { NextRequest, NextFetchEvent, NextResponse } from 'next/server';
|
|
4
4
|
|
|
5
|
-
type IMediaType = 'image' | 'video' | string;
|
|
6
|
-
type IMedia = {
|
|
7
|
-
src: string;
|
|
8
|
-
type: IMediaType;
|
|
9
|
-
alt?: string;
|
|
10
|
-
title?: string;
|
|
11
|
-
abstract?: string;
|
|
12
|
-
width?: number;
|
|
13
|
-
height?: number;
|
|
14
|
-
url?: string;
|
|
15
|
-
media?: IMedia;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
5
|
type ICartItem = ISchema & {
|
|
19
6
|
id: IEquatable;
|
|
20
7
|
schema: string;
|
|
@@ -27,31 +14,9 @@ type ICartItem = ISchema & {
|
|
|
27
14
|
};
|
|
28
15
|
type ICartAddItem = Omit<ICartItem, 'qty'>;
|
|
29
16
|
|
|
30
|
-
type ICategory = IEntity & {
|
|
31
|
-
id: IEquatable;
|
|
32
|
-
slug?: ILocalizedString | string;
|
|
33
|
-
title?: ILocalizedString | string;
|
|
34
|
-
media?: IMedia;
|
|
35
|
-
schema?: string;
|
|
36
|
-
page?: IEquatable;
|
|
37
|
-
category?: IEquatable | ICategory;
|
|
38
|
-
};
|
|
39
|
-
type ICategoryItem = ICategory & {
|
|
40
|
-
items: ICategory[];
|
|
41
|
-
};
|
|
42
|
-
type ICategorized = {
|
|
43
|
-
id: IEquatable;
|
|
44
|
-
schema?: string;
|
|
45
|
-
category: IEquatable | ICategory;
|
|
46
|
-
isDefault?: boolean;
|
|
47
|
-
slug?: ILocalizedString | string;
|
|
48
|
-
title?: ILocalizedString | string;
|
|
49
|
-
media?: IMedia;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
17
|
declare function getCategories(params?: QueryParams): Promise<ICategory[]>;
|
|
53
18
|
declare function getSegments(item: ICategorized, params?: QueryParams): Promise<ICategory[]>;
|
|
54
|
-
declare function getRouteSegments(
|
|
19
|
+
declare function getRouteSegments(item: ICategorized, categories: ICategory[]): ICategory[];
|
|
55
20
|
|
|
56
21
|
type IUserLogin = {
|
|
57
22
|
email: string;
|
|
@@ -182,73 +147,9 @@ type IFeatureType = {
|
|
|
182
147
|
|
|
183
148
|
declare function getFeatureTypes(params?: QueryParams): Promise<IFeatureType[]>;
|
|
184
149
|
|
|
185
|
-
type ILabel = IEntity & {
|
|
186
|
-
id: IEquatable;
|
|
187
|
-
text?: string | ILocalizedString;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
150
|
declare function getLabels(params?: QueryParams): Promise<ILabel[]>;
|
|
191
151
|
declare function resolveLabel(labels: ILabel[], id: string): string;
|
|
192
152
|
|
|
193
|
-
type ILocale = IEntity & {
|
|
194
|
-
id: string;
|
|
195
|
-
title?: string;
|
|
196
|
-
isActive?: boolean;
|
|
197
|
-
isDefault?: boolean;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
type IMarket = IEntity & {
|
|
201
|
-
id: string;
|
|
202
|
-
title?: string;
|
|
203
|
-
isActive?: boolean;
|
|
204
|
-
isDefault?: boolean;
|
|
205
|
-
countries?: string[];
|
|
206
|
-
languages?: string[];
|
|
207
|
-
defaultLanguage?: string;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
type IRoute = {
|
|
211
|
-
id: string;
|
|
212
|
-
market: string;
|
|
213
|
-
locale: string;
|
|
214
|
-
category: string;
|
|
215
|
-
page: IEquatable;
|
|
216
|
-
schema: string;
|
|
217
|
-
template?: string;
|
|
218
|
-
};
|
|
219
|
-
type IRouteLink = {
|
|
220
|
-
id: IEquatable;
|
|
221
|
-
href: string;
|
|
222
|
-
title: string;
|
|
223
|
-
items?: IRouteLink[];
|
|
224
|
-
media?: IMedia;
|
|
225
|
-
};
|
|
226
|
-
type IRouteParams = {
|
|
227
|
-
id: IEquatable;
|
|
228
|
-
market: string;
|
|
229
|
-
locale: string;
|
|
230
|
-
[key: string]: any;
|
|
231
|
-
};
|
|
232
|
-
type SchemaType = string;
|
|
233
|
-
|
|
234
|
-
type ILayout = {
|
|
235
|
-
market: string;
|
|
236
|
-
locale: string;
|
|
237
|
-
markets: IMarket[];
|
|
238
|
-
locales: ILocale[];
|
|
239
|
-
labels: ILabel[];
|
|
240
|
-
tree?: IRouteLink;
|
|
241
|
-
navs: {
|
|
242
|
-
[key: string]: IRouteLink[];
|
|
243
|
-
};
|
|
244
|
-
topLevelRoutes: {
|
|
245
|
-
[key: string]: IRouteLink;
|
|
246
|
-
};
|
|
247
|
-
topLevelHrefs: {
|
|
248
|
-
[key: string]: string;
|
|
249
|
-
};
|
|
250
|
-
};
|
|
251
|
-
|
|
252
153
|
declare function getLayout(market: string, locale: string): Promise<ILayout>;
|
|
253
154
|
|
|
254
155
|
type ILazyComponent = {
|
|
@@ -286,17 +187,8 @@ declare function getLocales(params?: QueryParams): Promise<ILocale[]>;
|
|
|
286
187
|
|
|
287
188
|
declare function getMarkets(params?: QueryParams): Promise<IMarket[]>;
|
|
288
189
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
items: IMenuItem[];
|
|
292
|
-
};
|
|
293
|
-
type IMenuItem = {
|
|
294
|
-
name: string;
|
|
295
|
-
href: string;
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
declare function getMenu(id: IEquatable): Promise<IMenu | undefined>;
|
|
299
|
-
declare function getMenus(): Promise<IMenu[]>;
|
|
190
|
+
declare function getMenu(id: IEquatable, params?: QueryParams): Promise<IMenu | undefined>;
|
|
191
|
+
declare function getMenus(params?: QueryParams): Promise<IMenu[]>;
|
|
300
192
|
|
|
301
193
|
declare const IOrderStatus: {
|
|
302
194
|
Pending: string;
|
|
@@ -327,46 +219,6 @@ type IOrderDetail = IOrder & {
|
|
|
327
219
|
declare function getOrders(market: string, locale: string): Promise<IOrderDetail[]>;
|
|
328
220
|
declare function getOrder(id: IEquatable, market: string, locale: string): Promise<IOrderDetail | null>;
|
|
329
221
|
|
|
330
|
-
type IMeta = {
|
|
331
|
-
title?: string;
|
|
332
|
-
description?: string;
|
|
333
|
-
keywords?: string;
|
|
334
|
-
robots?: string;
|
|
335
|
-
};
|
|
336
|
-
type IImage = {
|
|
337
|
-
url: string;
|
|
338
|
-
type?: string;
|
|
339
|
-
alt?: string;
|
|
340
|
-
title?: string;
|
|
341
|
-
caption?: string;
|
|
342
|
-
width?: number;
|
|
343
|
-
height?: number;
|
|
344
|
-
};
|
|
345
|
-
type IPage = ICategorized & {
|
|
346
|
-
slug?: string;
|
|
347
|
-
href: string;
|
|
348
|
-
alternates: IRoute[];
|
|
349
|
-
breadcrumb: IRouteLink[];
|
|
350
|
-
parentRoute?: IRouteLink;
|
|
351
|
-
title?: string;
|
|
352
|
-
abstract?: string;
|
|
353
|
-
description?: string;
|
|
354
|
-
content?: string;
|
|
355
|
-
createdAt?: Date;
|
|
356
|
-
updatedAt?: Date;
|
|
357
|
-
meta?: IMeta;
|
|
358
|
-
[key: string]: any;
|
|
359
|
-
};
|
|
360
|
-
type IPageResult<T extends ICategorized = ICategorized> = IPage & T;
|
|
361
|
-
type PageProps<T extends ICategorized = ICategorized> = {
|
|
362
|
-
layout: ILayout;
|
|
363
|
-
page: IPageResult<T>;
|
|
364
|
-
params: IRouteParams;
|
|
365
|
-
locales?: string[];
|
|
366
|
-
locale?: string;
|
|
367
|
-
defaultLocale?: string;
|
|
368
|
-
};
|
|
369
|
-
|
|
370
222
|
declare function findOnePage<T extends ICategorized = ICategorized>(schema: string, id: IEquatable, params?: QueryParams): Promise<T | undefined>;
|
|
371
223
|
declare function findManyPages<T extends ICategorized = ICategorized>(schema: string, params?: QueryParams): Promise<T[]>;
|
|
372
224
|
declare function getPage<T extends ICategorized = ICategorized>(schema: string, id: IEquatable, market?: string, locale?: string): Promise<IPageResult<T> | undefined>;
|
|
@@ -397,7 +249,9 @@ declare function getStaticPathsForSchema(schema: string): Promise<StaticPath[]>;
|
|
|
397
249
|
declare function getBreadcrumbFromSegments(segments: ICategory[], market?: string, locale?: string): Promise<IRouteLink[]>;
|
|
398
250
|
declare function getRouteLinkTree(market?: string, locale?: string): Promise<IRouteLink | undefined>;
|
|
399
251
|
declare function categoryToRouteLink(routes: IRoute[], categories: ICategory[], category: ICategory, locale?: string): IRouteLink;
|
|
400
|
-
declare function resolveRoute(route: IRoute
|
|
252
|
+
declare function resolveRoute(route: IRoute & {
|
|
253
|
+
splat?: string;
|
|
254
|
+
}): string;
|
|
401
255
|
type StaticPath = {
|
|
402
256
|
params: {
|
|
403
257
|
[key: string]: string;
|
|
@@ -419,4 +273,4 @@ type IModelStore = {
|
|
|
419
273
|
[key: string]: IQuerable<IEntity>;
|
|
420
274
|
};
|
|
421
275
|
|
|
422
|
-
export { IAddress, IAddressOptions, ICartAddItem, ICartItem,
|
|
276
|
+
export { IAddress, IAddressOptions, ICartAddItem, ICartItem, ICheckout, ICheckoutDelivery, ICheckoutDiscount, ICheckoutInfo, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutStore, ICompanyAddress, IFeatureType, IGenericLazyComponentProps, IKeyedList, ILazyComponent, ILazyComponentProps, ILazyModules, ILink, IList, IModelStore, IOrder, IOrderDetail, IOrderStatus, IOrderStatusValue, IUser, IUserAddress, IUserChangePassword, IUserForgot, IUserLogin, IUserRegister, StaticPath, categoryToRouteLink, findManyPages, findOnePage, getBreadcrumbFromSegments, getCategories, getCountries, getDeliveries, getErrorPageLayout, getFeatureTypes, getInfo, getItems, getLabels, getLayout, getListByKeys, getLists, getLocales, getMarkets, getMenu, getMenus, getOrder, getOrders, getPage, getPageCategory, getPageRoutes, getPayment, getPayments, getProvinces, getRegions, getRoute, getRouteLinkTree, getRouteSegments, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getStaticPathsForSchema, getStores, resolveLabel, resolveRoute, routeInterceptor, routeRevalidateHandler, setDiscountCode, updateCheckout };
|
package/dist/index.js
CHANGED
|
@@ -76,9 +76,9 @@ async function getCategories(params = {}) {
|
|
|
76
76
|
}
|
|
77
77
|
async function getSegments(item, params = {}) {
|
|
78
78
|
const categories = await getCategories(params);
|
|
79
|
-
return getRouteSegments(item
|
|
79
|
+
return getRouteSegments(item, categories);
|
|
80
80
|
}
|
|
81
|
-
function getRouteSegments(
|
|
81
|
+
function getRouteSegments(item, categories) {
|
|
82
82
|
const segments = [];
|
|
83
83
|
let parentId = item.category || null;
|
|
84
84
|
while (parentId != null) {
|
|
@@ -94,14 +94,13 @@ function getRouteSegments(schema, item, categories) {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
if (item.isDefault !== true) {
|
|
97
|
-
|
|
97
|
+
const segment = {
|
|
98
98
|
id: item.id,
|
|
99
99
|
title: item.title,
|
|
100
100
|
slug: item.slug,
|
|
101
|
-
schema,
|
|
102
|
-
page: item.id,
|
|
103
101
|
media: item.media
|
|
104
|
-
}
|
|
102
|
+
};
|
|
103
|
+
segments.push(segment);
|
|
105
104
|
}
|
|
106
105
|
return segments;
|
|
107
106
|
}
|
|
@@ -131,7 +130,7 @@ async function getRegions(locale) {
|
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
// src/route/route.service.ts
|
|
134
|
-
var
|
|
133
|
+
var import_bom_core = require("@websolutespa/bom-core");
|
|
135
134
|
var import_bom_mixer_store5 = require("@websolutespa/bom-mixer-store");
|
|
136
135
|
async function getRoutes(params = {}) {
|
|
137
136
|
const store = await (0, import_bom_mixer_store5.getStore)();
|
|
@@ -214,17 +213,17 @@ async function getBreadcrumbFromSegments(segments, market = "ww", locale = "en")
|
|
|
214
213
|
}
|
|
215
214
|
});
|
|
216
215
|
const tree = segments.map((segment) => {
|
|
217
|
-
const route =
|
|
218
|
-
(r) => r.
|
|
219
|
-
)
|
|
216
|
+
const route = routes.find(
|
|
217
|
+
(r) => r.category === segment.id
|
|
218
|
+
);
|
|
220
219
|
const href = route ? route.id.toString() : "/#";
|
|
221
220
|
return { segment, href };
|
|
222
221
|
}).map((x) => {
|
|
223
222
|
const segment = x.segment;
|
|
224
223
|
const href = x.href;
|
|
225
224
|
let title = segment.title || "untitled";
|
|
226
|
-
if ((0,
|
|
227
|
-
title = (0,
|
|
225
|
+
if ((0, import_bom_core.isLocalizedString)(title)) {
|
|
226
|
+
title = (0, import_bom_core.localizedToString)(title, locale);
|
|
228
227
|
}
|
|
229
228
|
return {
|
|
230
229
|
id: segment.id,
|
|
@@ -261,10 +260,10 @@ function categoryToRouteLink(routes, categories, category, locale = "en") {
|
|
|
261
260
|
const route = routes.find(
|
|
262
261
|
(r) => r.category === category.id
|
|
263
262
|
);
|
|
264
|
-
const href = route ? route.id.toString() : "
|
|
263
|
+
const href = route && route.id ? route.id.toString() : "/";
|
|
265
264
|
let title = category.title || "untitled";
|
|
266
|
-
if ((0,
|
|
267
|
-
title = (0,
|
|
265
|
+
if ((0, import_bom_core.isLocalizedString)(title)) {
|
|
266
|
+
title = (0, import_bom_core.localizedToString)(title, locale);
|
|
268
267
|
}
|
|
269
268
|
const childCategories = categories.filter((x) => {
|
|
270
269
|
const parentId = x.category && typeof x.category === "object" ? x.category["id"] : x.category;
|
|
@@ -280,7 +279,7 @@ function categoryToRouteLink(routes, categories, category, locale = "en") {
|
|
|
280
279
|
}
|
|
281
280
|
function resolveRoute(route) {
|
|
282
281
|
const routepath = route.template ? route.template : route.schema;
|
|
283
|
-
const resolvedPathname = `/${route.market}/${route.locale}/${routepath}/${route.page}`;
|
|
282
|
+
const resolvedPathname = `/${route.market}/${route.locale}/${routepath}/${route.page}${route.splat || ""}`;
|
|
284
283
|
return resolvedPathname;
|
|
285
284
|
}
|
|
286
285
|
|
|
@@ -630,6 +629,19 @@ async function getMarkets(params = {}) {
|
|
|
630
629
|
return items;
|
|
631
630
|
}
|
|
632
631
|
|
|
632
|
+
// src/menu/menu.service.ts
|
|
633
|
+
var import_bom_mixer_store10 = require("@websolutespa/bom-mixer-store");
|
|
634
|
+
async function getMenu(id, params = {}) {
|
|
635
|
+
const store = await (0, import_bom_mixer_store10.getStore)();
|
|
636
|
+
const item = await store.menu.findOne(id, params);
|
|
637
|
+
return item;
|
|
638
|
+
}
|
|
639
|
+
async function getMenus(params = {}) {
|
|
640
|
+
const store = await (0, import_bom_mixer_store10.getStore)();
|
|
641
|
+
const items = await store.menu.findMany(params);
|
|
642
|
+
return items;
|
|
643
|
+
}
|
|
644
|
+
|
|
633
645
|
// src/layout/layout.service.ts
|
|
634
646
|
async function getLayout(market, locale) {
|
|
635
647
|
const markets = await getMarkets({ locale });
|
|
@@ -648,33 +660,33 @@ async function getLayout(market, locale) {
|
|
|
648
660
|
}
|
|
649
661
|
return object;
|
|
650
662
|
}, {});
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
};
|
|
663
|
+
const menu = {};
|
|
664
|
+
const menus = await getMenus({ market, locale });
|
|
665
|
+
menus.forEach((x) => {
|
|
666
|
+
menu[x.id] = x;
|
|
667
|
+
});
|
|
656
668
|
return {
|
|
657
|
-
markets,
|
|
658
|
-
market,
|
|
659
|
-
locales,
|
|
660
|
-
locale,
|
|
661
669
|
labels,
|
|
662
|
-
|
|
663
|
-
|
|
670
|
+
locale,
|
|
671
|
+
locales,
|
|
672
|
+
market,
|
|
673
|
+
markets,
|
|
674
|
+
menu,
|
|
675
|
+
topLevelHrefs,
|
|
664
676
|
topLevelRoutes,
|
|
665
|
-
|
|
677
|
+
tree
|
|
666
678
|
};
|
|
667
679
|
}
|
|
668
680
|
|
|
669
681
|
// src/list/list.service.ts
|
|
670
|
-
var
|
|
682
|
+
var import_bom_mixer_store11 = require("@websolutespa/bom-mixer-store");
|
|
671
683
|
async function getLists(locale) {
|
|
672
|
-
const store = await (0,
|
|
684
|
+
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
673
685
|
const items = await store.list.findMany({ locale });
|
|
674
686
|
return items;
|
|
675
687
|
}
|
|
676
688
|
async function getListByKeys(keys, locale) {
|
|
677
|
-
const store = await (0,
|
|
689
|
+
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
678
690
|
const items = await store.list.findMany({ locale });
|
|
679
691
|
const lists = {};
|
|
680
692
|
items.filter((x) => x.key && keys.includes(x.key)).forEach((x) => {
|
|
@@ -683,19 +695,6 @@ async function getListByKeys(keys, locale) {
|
|
|
683
695
|
return lists;
|
|
684
696
|
}
|
|
685
697
|
|
|
686
|
-
// src/menu/menu.service.ts
|
|
687
|
-
var import_bom_mixer_store11 = require("@websolutespa/bom-mixer-store");
|
|
688
|
-
async function getMenu(id) {
|
|
689
|
-
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
690
|
-
const item = await store.menu.findOne(id);
|
|
691
|
-
return item;
|
|
692
|
-
}
|
|
693
|
-
async function getMenus() {
|
|
694
|
-
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
695
|
-
const items = await store.menu.findMany();
|
|
696
|
-
return items;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
698
|
// src/order/order.ts
|
|
700
699
|
var IOrderStatus = {
|
|
701
700
|
Pending: "pending",
|
|
@@ -1044,7 +1043,6 @@ async function findManyPages(schema, params) {
|
|
|
1044
1043
|
return pages;
|
|
1045
1044
|
}
|
|
1046
1045
|
async function getPage(schema, id, market, locale) {
|
|
1047
|
-
const store = await (0, import_bom_mixer_store12.getStore)();
|
|
1048
1046
|
const page = await findOnePage(schema, id, { market, locale });
|
|
1049
1047
|
if (page) {
|
|
1050
1048
|
const routes = await getPageRoutes(schema, id);
|
|
@@ -1131,28 +1129,29 @@ async function getErrorPageLayout() {
|
|
|
1131
1129
|
const title = resolveLabel(layout.labels, "notfound.title");
|
|
1132
1130
|
const abstract = resolveLabel(layout.labels, "notfound.abstract");
|
|
1133
1131
|
const page = {
|
|
1134
|
-
|
|
1135
|
-
schema: "notfound",
|
|
1136
|
-
href: "",
|
|
1132
|
+
abstract,
|
|
1137
1133
|
alternates: [],
|
|
1138
1134
|
breadcrumb: [],
|
|
1139
|
-
title,
|
|
1140
|
-
abstract,
|
|
1141
1135
|
category: "homepage",
|
|
1136
|
+
href: "",
|
|
1137
|
+
id: "notfound",
|
|
1138
|
+
markets: [],
|
|
1142
1139
|
meta: {
|
|
1143
1140
|
title,
|
|
1144
1141
|
description: abstract,
|
|
1145
1142
|
keywords: "",
|
|
1146
1143
|
robots: "all"
|
|
1147
|
-
}
|
|
1144
|
+
},
|
|
1145
|
+
schema: "notfound",
|
|
1146
|
+
title
|
|
1148
1147
|
};
|
|
1149
1148
|
return { layout, page };
|
|
1150
1149
|
}
|
|
1151
1150
|
|
|
1152
1151
|
// src/route/route-revalidate.handler.ts
|
|
1153
|
-
var
|
|
1152
|
+
var import_bom_mixer_store13 = require("@websolutespa/bom-mixer-store");
|
|
1154
1153
|
function routeRevalidateHandler() {
|
|
1155
|
-
return (0,
|
|
1154
|
+
return (0, import_bom_mixer_store13.apiHandler)({
|
|
1156
1155
|
post: async (request, response) => {
|
|
1157
1156
|
const authorization = request.headers.authorization;
|
|
1158
1157
|
const bearer = authorization && authorization.replace("Bearer ", "");
|
|
@@ -1176,13 +1175,13 @@ function routeRevalidateHandler() {
|
|
|
1176
1175
|
}
|
|
1177
1176
|
|
|
1178
1177
|
// src/route/route.interceptor.ts
|
|
1179
|
-
var
|
|
1178
|
+
var import_bom_mixer_store14 = require("@websolutespa/bom-mixer-store");
|
|
1180
1179
|
var import_server = require("next/server");
|
|
1181
1180
|
async function routeInterceptor(request, next) {
|
|
1182
1181
|
let url = request.nextUrl;
|
|
1183
1182
|
let route;
|
|
1184
1183
|
try {
|
|
1185
|
-
route = await (0,
|
|
1184
|
+
route = await (0, import_bom_mixer_store14.apiPost)("/route", { pathname: url.pathname });
|
|
1186
1185
|
if (!route) {
|
|
1187
1186
|
console.log("routeInterceptor.route.notfound", url.pathname);
|
|
1188
1187
|
return;
|
package/dist/index.mjs
CHANGED
|
@@ -7,9 +7,9 @@ async function getCategories(params = {}) {
|
|
|
7
7
|
}
|
|
8
8
|
async function getSegments(item, params = {}) {
|
|
9
9
|
const categories = await getCategories(params);
|
|
10
|
-
return getRouteSegments(item
|
|
10
|
+
return getRouteSegments(item, categories);
|
|
11
11
|
}
|
|
12
|
-
function getRouteSegments(
|
|
12
|
+
function getRouteSegments(item, categories) {
|
|
13
13
|
const segments = [];
|
|
14
14
|
let parentId = item.category || null;
|
|
15
15
|
while (parentId != null) {
|
|
@@ -25,14 +25,13 @@ function getRouteSegments(schema, item, categories) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
if (item.isDefault !== true) {
|
|
28
|
-
|
|
28
|
+
const segment = {
|
|
29
29
|
id: item.id,
|
|
30
30
|
title: item.title,
|
|
31
31
|
slug: item.slug,
|
|
32
|
-
schema,
|
|
33
|
-
page: item.id,
|
|
34
32
|
media: item.media
|
|
35
|
-
}
|
|
33
|
+
};
|
|
34
|
+
segments.push(segment);
|
|
36
35
|
}
|
|
37
36
|
return segments;
|
|
38
37
|
}
|
|
@@ -62,7 +61,7 @@ async function getRegions(locale) {
|
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
// src/route/route.service.ts
|
|
65
|
-
import { isLocalizedString, localizedToString } from "@websolutespa/bom-
|
|
64
|
+
import { isLocalizedString, localizedToString } from "@websolutespa/bom-core";
|
|
66
65
|
import { getStore as getStore5 } from "@websolutespa/bom-mixer-store";
|
|
67
66
|
async function getRoutes(params = {}) {
|
|
68
67
|
const store = await getStore5();
|
|
@@ -145,9 +144,9 @@ async function getBreadcrumbFromSegments(segments, market = "ww", locale = "en")
|
|
|
145
144
|
}
|
|
146
145
|
});
|
|
147
146
|
const tree = segments.map((segment) => {
|
|
148
|
-
const route =
|
|
149
|
-
(r) => r.
|
|
150
|
-
)
|
|
147
|
+
const route = routes.find(
|
|
148
|
+
(r) => r.category === segment.id
|
|
149
|
+
);
|
|
151
150
|
const href = route ? route.id.toString() : "/#";
|
|
152
151
|
return { segment, href };
|
|
153
152
|
}).map((x) => {
|
|
@@ -192,7 +191,7 @@ function categoryToRouteLink(routes, categories, category, locale = "en") {
|
|
|
192
191
|
const route = routes.find(
|
|
193
192
|
(r) => r.category === category.id
|
|
194
193
|
);
|
|
195
|
-
const href = route ? route.id.toString() : "
|
|
194
|
+
const href = route && route.id ? route.id.toString() : "/";
|
|
196
195
|
let title = category.title || "untitled";
|
|
197
196
|
if (isLocalizedString(title)) {
|
|
198
197
|
title = localizedToString(title, locale);
|
|
@@ -211,7 +210,7 @@ function categoryToRouteLink(routes, categories, category, locale = "en") {
|
|
|
211
210
|
}
|
|
212
211
|
function resolveRoute(route) {
|
|
213
212
|
const routepath = route.template ? route.template : route.schema;
|
|
214
|
-
const resolvedPathname = `/${route.market}/${route.locale}/${routepath}/${route.page}`;
|
|
213
|
+
const resolvedPathname = `/${route.market}/${route.locale}/${routepath}/${route.page}${route.splat || ""}`;
|
|
215
214
|
return resolvedPathname;
|
|
216
215
|
}
|
|
217
216
|
|
|
@@ -561,6 +560,19 @@ async function getMarkets(params = {}) {
|
|
|
561
560
|
return items;
|
|
562
561
|
}
|
|
563
562
|
|
|
563
|
+
// src/menu/menu.service.ts
|
|
564
|
+
import { getStore as getStore10 } from "@websolutespa/bom-mixer-store";
|
|
565
|
+
async function getMenu(id, params = {}) {
|
|
566
|
+
const store = await getStore10();
|
|
567
|
+
const item = await store.menu.findOne(id, params);
|
|
568
|
+
return item;
|
|
569
|
+
}
|
|
570
|
+
async function getMenus(params = {}) {
|
|
571
|
+
const store = await getStore10();
|
|
572
|
+
const items = await store.menu.findMany(params);
|
|
573
|
+
return items;
|
|
574
|
+
}
|
|
575
|
+
|
|
564
576
|
// src/layout/layout.service.ts
|
|
565
577
|
async function getLayout(market, locale) {
|
|
566
578
|
const markets = await getMarkets({ locale });
|
|
@@ -579,33 +591,33 @@ async function getLayout(market, locale) {
|
|
|
579
591
|
}
|
|
580
592
|
return object;
|
|
581
593
|
}, {});
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
};
|
|
594
|
+
const menu = {};
|
|
595
|
+
const menus = await getMenus({ market, locale });
|
|
596
|
+
menus.forEach((x) => {
|
|
597
|
+
menu[x.id] = x;
|
|
598
|
+
});
|
|
587
599
|
return {
|
|
588
|
-
markets,
|
|
589
|
-
market,
|
|
590
|
-
locales,
|
|
591
|
-
locale,
|
|
592
600
|
labels,
|
|
593
|
-
|
|
594
|
-
|
|
601
|
+
locale,
|
|
602
|
+
locales,
|
|
603
|
+
market,
|
|
604
|
+
markets,
|
|
605
|
+
menu,
|
|
606
|
+
topLevelHrefs,
|
|
595
607
|
topLevelRoutes,
|
|
596
|
-
|
|
608
|
+
tree
|
|
597
609
|
};
|
|
598
610
|
}
|
|
599
611
|
|
|
600
612
|
// src/list/list.service.ts
|
|
601
|
-
import { getStore as
|
|
613
|
+
import { getStore as getStore11 } from "@websolutespa/bom-mixer-store";
|
|
602
614
|
async function getLists(locale) {
|
|
603
|
-
const store = await
|
|
615
|
+
const store = await getStore11();
|
|
604
616
|
const items = await store.list.findMany({ locale });
|
|
605
617
|
return items;
|
|
606
618
|
}
|
|
607
619
|
async function getListByKeys(keys, locale) {
|
|
608
|
-
const store = await
|
|
620
|
+
const store = await getStore11();
|
|
609
621
|
const items = await store.list.findMany({ locale });
|
|
610
622
|
const lists = {};
|
|
611
623
|
items.filter((x) => x.key && keys.includes(x.key)).forEach((x) => {
|
|
@@ -614,19 +626,6 @@ async function getListByKeys(keys, locale) {
|
|
|
614
626
|
return lists;
|
|
615
627
|
}
|
|
616
628
|
|
|
617
|
-
// src/menu/menu.service.ts
|
|
618
|
-
import { getStore as getStore11 } from "@websolutespa/bom-mixer-store";
|
|
619
|
-
async function getMenu(id) {
|
|
620
|
-
const store = await getStore11();
|
|
621
|
-
const item = await store.menu.findOne(id);
|
|
622
|
-
return item;
|
|
623
|
-
}
|
|
624
|
-
async function getMenus() {
|
|
625
|
-
const store = await getStore11();
|
|
626
|
-
const items = await store.menu.findMany();
|
|
627
|
-
return items;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
629
|
// src/order/order.ts
|
|
631
630
|
var IOrderStatus = {
|
|
632
631
|
Pending: "pending",
|
|
@@ -975,7 +974,6 @@ async function findManyPages(schema, params) {
|
|
|
975
974
|
return pages;
|
|
976
975
|
}
|
|
977
976
|
async function getPage(schema, id, market, locale) {
|
|
978
|
-
const store = await getStore12();
|
|
979
977
|
const page = await findOnePage(schema, id, { market, locale });
|
|
980
978
|
if (page) {
|
|
981
979
|
const routes = await getPageRoutes(schema, id);
|
|
@@ -1062,26 +1060,27 @@ async function getErrorPageLayout() {
|
|
|
1062
1060
|
const title = resolveLabel(layout.labels, "notfound.title");
|
|
1063
1061
|
const abstract = resolveLabel(layout.labels, "notfound.abstract");
|
|
1064
1062
|
const page = {
|
|
1065
|
-
|
|
1066
|
-
schema: "notfound",
|
|
1067
|
-
href: "",
|
|
1063
|
+
abstract,
|
|
1068
1064
|
alternates: [],
|
|
1069
1065
|
breadcrumb: [],
|
|
1070
|
-
title,
|
|
1071
|
-
abstract,
|
|
1072
1066
|
category: "homepage",
|
|
1067
|
+
href: "",
|
|
1068
|
+
id: "notfound",
|
|
1069
|
+
markets: [],
|
|
1073
1070
|
meta: {
|
|
1074
1071
|
title,
|
|
1075
1072
|
description: abstract,
|
|
1076
1073
|
keywords: "",
|
|
1077
1074
|
robots: "all"
|
|
1078
|
-
}
|
|
1075
|
+
},
|
|
1076
|
+
schema: "notfound",
|
|
1077
|
+
title
|
|
1079
1078
|
};
|
|
1080
1079
|
return { layout, page };
|
|
1081
1080
|
}
|
|
1082
1081
|
|
|
1083
1082
|
// src/route/route-revalidate.handler.ts
|
|
1084
|
-
import { apiHandler } from "@websolutespa/bom-mixer-
|
|
1083
|
+
import { apiHandler } from "@websolutespa/bom-mixer-store";
|
|
1085
1084
|
function routeRevalidateHandler() {
|
|
1086
1085
|
return apiHandler({
|
|
1087
1086
|
post: async (request, response) => {
|
|
@@ -1107,7 +1106,7 @@ function routeRevalidateHandler() {
|
|
|
1107
1106
|
}
|
|
1108
1107
|
|
|
1109
1108
|
// src/route/route.interceptor.ts
|
|
1110
|
-
import { apiPost } from "@websolutespa/bom-mixer-
|
|
1109
|
+
import { apiPost } from "@websolutespa/bom-mixer-store";
|
|
1111
1110
|
import { NextResponse } from "next/server";
|
|
1112
1111
|
async function routeInterceptor(request, next) {
|
|
1113
1112
|
let url = request.nextUrl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websolutespa/bom-mixer-models",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Mixer Models module of the BOM Repository",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bom",
|
|
@@ -18,11 +18,10 @@
|
|
|
18
18
|
"prepack": "bom prepack",
|
|
19
19
|
"postpack": "bom postpack"
|
|
20
20
|
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@websolutespa/bom-mixer-core": "*",
|
|
23
|
-
"@websolutespa/bom-mixer-store": "*"
|
|
24
|
-
},
|
|
21
|
+
"dependencies": {},
|
|
25
22
|
"peerDependencies": {
|
|
23
|
+
"@websolutespa/bom-core": "*",
|
|
24
|
+
"@websolutespa/bom-mixer-store": "*",
|
|
26
25
|
"next": ">= 12.3.2"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|