@websolutespa/bom-mixer-models 1.7.6 → 1.7.7
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,14 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-models
|
|
2
2
|
|
|
3
|
+
## 1.7.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Modified: RouteService, MenuService to handle isHidden Category segments
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @websolutespa/bom-mixer-store@1.7.8
|
|
10
|
+
- @websolutespa/bom-core@1.7.12
|
|
11
|
+
|
|
3
12
|
## 1.7.6
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -141,7 +141,7 @@ async function getCategory(id, params = {}) {
|
|
|
141
141
|
}
|
|
142
142
|
async function getSegments(item, params = {}) {
|
|
143
143
|
const categories = await getCategories(params);
|
|
144
|
-
return (0, import_bom_core.getCategorySegments)(
|
|
144
|
+
return (0, import_bom_core.getCategorySegments)(categories, item);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// src/country/country.service.ts
|
|
@@ -265,9 +265,7 @@ async function getBreadcrumbFromSegments(segments, route) {
|
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
267
|
const tree = segments.map((segment) => {
|
|
268
|
-
const route2 = routes.
|
|
269
|
-
(r) => r.category === segment.id && r.isDefault
|
|
270
|
-
);
|
|
268
|
+
const route2 = (0, import_bom_core2.findRouteOfCategory)(routes, segment.id);
|
|
271
269
|
return {
|
|
272
270
|
segment,
|
|
273
271
|
route: route2
|
|
@@ -304,15 +302,13 @@ async function getRouteLinkTree(market, locale) {
|
|
|
304
302
|
return void 0;
|
|
305
303
|
}
|
|
306
304
|
function categoryToRouteLink(routes, categories, category, locale) {
|
|
307
|
-
const route = routes.
|
|
308
|
-
(r) => r.category === category.id && r.isDefault
|
|
309
|
-
);
|
|
305
|
+
const route = (0, import_bom_core2.findRouteOfCategory)(routes, category.id);
|
|
310
306
|
if (!route) {
|
|
311
307
|
return void 0;
|
|
312
308
|
}
|
|
313
309
|
const rootCategory = (0, import_bom_core2.getRootCategory)(categories);
|
|
314
310
|
const childCategories = categories.filter((x) => {
|
|
315
|
-
const parentId =
|
|
311
|
+
const parentId = (0, import_bom_core2.asCategoryId)(x.category);
|
|
316
312
|
return rootCategory && rootCategory.id === category.id ? x.id !== rootCategory.id && (parentId === category.id || !parentId) : parentId === category.id;
|
|
317
313
|
});
|
|
318
314
|
const routeLink = newRouteLink(category, route, locale);
|
|
@@ -1235,7 +1231,7 @@ async function getPageCategory(schema, page, market, locale) {
|
|
|
1235
1231
|
const pages = await findManyPages(schema, {
|
|
1236
1232
|
where: {
|
|
1237
1233
|
category: {
|
|
1238
|
-
equals:
|
|
1234
|
+
equals: (0, import_bom_core3.asCategoryId)(page.category)
|
|
1239
1235
|
}
|
|
1240
1236
|
},
|
|
1241
1237
|
market,
|
|
@@ -1742,7 +1738,7 @@ var DefaultStructuredDataCollections = {
|
|
|
1742
1738
|
article: ["news_detail"]
|
|
1743
1739
|
};
|
|
1744
1740
|
function resolveTemplate(value) {
|
|
1745
|
-
return (0, import_bom_core7.
|
|
1741
|
+
return (0, import_bom_core7.asEquatableString)(value);
|
|
1746
1742
|
}
|
|
1747
1743
|
function resolveMediaSrc(media) {
|
|
1748
1744
|
return resolveHref(media.src || media.url);
|
|
@@ -1751,14 +1747,15 @@ function resolveStructuredData(page, websiteName = "WebsiteName", types = Defaul
|
|
|
1751
1747
|
let schema = null;
|
|
1752
1748
|
let pageType = page.schema || "";
|
|
1753
1749
|
if (page.template) {
|
|
1754
|
-
pageType = (0, import_bom_core7.
|
|
1750
|
+
pageType = (0, import_bom_core7.asEquatableString)(page.template);
|
|
1755
1751
|
}
|
|
1756
1752
|
if (types.article.includes(pageType)) {
|
|
1753
|
+
const mediaSrc = page.media ? resolveMediaSrc(page.media) : void 0;
|
|
1757
1754
|
schema = {
|
|
1758
1755
|
"@context": "https://schema.org",
|
|
1759
1756
|
"@type": "NewsArticle",
|
|
1760
1757
|
headline: page.title,
|
|
1761
|
-
image:
|
|
1758
|
+
image: mediaSrc ? [mediaSrc] : [],
|
|
1762
1759
|
datePublished: page.createdAt,
|
|
1763
1760
|
dateModified: page.updatedAt,
|
|
1764
1761
|
author: [{
|
package/dist/index.mjs
CHANGED
|
@@ -40,7 +40,7 @@ async function getCategory(id, params = {}) {
|
|
|
40
40
|
}
|
|
41
41
|
async function getSegments(item, params = {}) {
|
|
42
42
|
const categories = await getCategories(params);
|
|
43
|
-
return getCategorySegments(
|
|
43
|
+
return getCategorySegments(categories, item);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// src/country/country.service.ts
|
|
@@ -83,7 +83,7 @@ async function getRegion(id, params = {}) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// src/route/route.service.ts
|
|
86
|
-
import { asCategoryId, defaultLocale, defaultMarket, getRootCategory, localize } from "@websolutespa/bom-core";
|
|
86
|
+
import { asCategoryId, defaultLocale, defaultMarket, findRouteOfCategory, getRootCategory, localize } from "@websolutespa/bom-core";
|
|
87
87
|
import { getStore as getStore5 } from "@websolutespa/bom-mixer-store";
|
|
88
88
|
async function getRoutes(params = {}) {
|
|
89
89
|
const store = await getStore5();
|
|
@@ -164,9 +164,7 @@ async function getBreadcrumbFromSegments(segments, route) {
|
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
166
|
const tree = segments.map((segment) => {
|
|
167
|
-
const route2 = routes.
|
|
168
|
-
(r) => r.category === segment.id && r.isDefault
|
|
169
|
-
);
|
|
167
|
+
const route2 = findRouteOfCategory(routes, segment.id);
|
|
170
168
|
return {
|
|
171
169
|
segment,
|
|
172
170
|
route: route2
|
|
@@ -203,15 +201,13 @@ async function getRouteLinkTree(market, locale) {
|
|
|
203
201
|
return void 0;
|
|
204
202
|
}
|
|
205
203
|
function categoryToRouteLink(routes, categories, category, locale) {
|
|
206
|
-
const route = routes.
|
|
207
|
-
(r) => r.category === category.id && r.isDefault
|
|
208
|
-
);
|
|
204
|
+
const route = findRouteOfCategory(routes, category.id);
|
|
209
205
|
if (!route) {
|
|
210
206
|
return void 0;
|
|
211
207
|
}
|
|
212
208
|
const rootCategory = getRootCategory(categories);
|
|
213
209
|
const childCategories = categories.filter((x) => {
|
|
214
|
-
const parentId =
|
|
210
|
+
const parentId = asCategoryId(x.category);
|
|
215
211
|
return rootCategory && rootCategory.id === category.id ? x.id !== rootCategory.id && (parentId === category.id || !parentId) : parentId === category.id;
|
|
216
212
|
});
|
|
217
213
|
const routeLink = newRouteLink(category, route, locale);
|
|
@@ -1034,7 +1030,7 @@ async function getOrder(id, market, locale) {
|
|
|
1034
1030
|
}
|
|
1035
1031
|
|
|
1036
1032
|
// src/page/page.service.ts
|
|
1037
|
-
import { asServerProps, defaultLocale as defaultLocale2, defaultMarket as defaultMarket2 } from "@websolutespa/bom-core";
|
|
1033
|
+
import { asCategoryId as asCategoryId2, asServerProps, defaultLocale as defaultLocale2, defaultMarket as defaultMarket2 } from "@websolutespa/bom-core";
|
|
1038
1034
|
import { RemoteServiceStrategy, getStore as getStore12 } from "@websolutespa/bom-mixer-store";
|
|
1039
1035
|
async function findOnePage(schema, id, params) {
|
|
1040
1036
|
const store = await getStore12();
|
|
@@ -1134,7 +1130,7 @@ async function getPageCategory(schema, page, market, locale) {
|
|
|
1134
1130
|
const pages = await findManyPages(schema, {
|
|
1135
1131
|
where: {
|
|
1136
1132
|
category: {
|
|
1137
|
-
equals:
|
|
1133
|
+
equals: asCategoryId2(page.category)
|
|
1138
1134
|
}
|
|
1139
1135
|
},
|
|
1140
1136
|
market,
|
|
@@ -1636,12 +1632,12 @@ var getSiteMapXSLProps = async (context) => {
|
|
|
1636
1632
|
};
|
|
1637
1633
|
|
|
1638
1634
|
// src/structured_data/structured_data.ts
|
|
1639
|
-
import {
|
|
1635
|
+
import { asEquatableString } from "@websolutespa/bom-core";
|
|
1640
1636
|
var DefaultStructuredDataCollections = {
|
|
1641
1637
|
article: ["news_detail"]
|
|
1642
1638
|
};
|
|
1643
1639
|
function resolveTemplate(value) {
|
|
1644
|
-
return
|
|
1640
|
+
return asEquatableString(value);
|
|
1645
1641
|
}
|
|
1646
1642
|
function resolveMediaSrc(media) {
|
|
1647
1643
|
return resolveHref(media.src || media.url);
|
|
@@ -1650,14 +1646,15 @@ function resolveStructuredData(page, websiteName = "WebsiteName", types = Defaul
|
|
|
1650
1646
|
let schema = null;
|
|
1651
1647
|
let pageType = page.schema || "";
|
|
1652
1648
|
if (page.template) {
|
|
1653
|
-
pageType =
|
|
1649
|
+
pageType = asEquatableString(page.template);
|
|
1654
1650
|
}
|
|
1655
1651
|
if (types.article.includes(pageType)) {
|
|
1652
|
+
const mediaSrc = page.media ? resolveMediaSrc(page.media) : void 0;
|
|
1656
1653
|
schema = {
|
|
1657
1654
|
"@context": "https://schema.org",
|
|
1658
1655
|
"@type": "NewsArticle",
|
|
1659
1656
|
headline: page.title,
|
|
1660
|
-
image:
|
|
1657
|
+
image: mediaSrc ? [mediaSrc] : [],
|
|
1661
1658
|
datePublished: page.createdAt,
|
|
1662
1659
|
dateModified: page.updatedAt,
|
|
1663
1660
|
author: [{
|
package/package.json
CHANGED
|
@@ -16,5 +16,5 @@ export async function getCategory(id: IEquatable, params: QueryParams = {}): Pro
|
|
|
16
16
|
|
|
17
17
|
export async function getSegments(item: ICategorized, params: QueryParams = {}): Promise<ICategory[]> {
|
|
18
18
|
const categories: ICategory[] = await getCategories(params);
|
|
19
|
-
return getCategorySegments(
|
|
19
|
+
return getCategorySegments(categories, item);
|
|
20
20
|
}
|
package/src/page/page.service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICategorized, ICategory, IEquatable, ILayout, IPage, IRoute, IRouteLink, PageProps, QueryParams, SchemaType, asServerProps, defaultLocale, defaultMarket } from '@websolutespa/bom-core';
|
|
1
|
+
import { ICategorized, ICategory, IEquatable, ILayout, IPage, IRoute, IRouteLink, PageProps, QueryParams, SchemaType, asCategoryId, asServerProps, defaultLocale, defaultMarket } from '@websolutespa/bom-core';
|
|
2
2
|
import { RemoteServiceStrategy, getStore } from '@websolutespa/bom-mixer-store';
|
|
3
3
|
import { Redirect } from 'next';
|
|
4
4
|
import { getSegments } from '../category/category.service';
|
|
@@ -42,6 +42,7 @@ export async function getPage<T extends ICategorized = ICategorized>(schema: str
|
|
|
42
42
|
const currentRoute = routes.find((x: IRoute) => x.market === market && x.locale === locale);
|
|
43
43
|
const alternates = routes.filter((x: IRoute) => x.market !== market || x.locale !== locale);
|
|
44
44
|
const segments: ICategory[] = await getSegments(page);
|
|
45
|
+
// console.log('getPage.currentRoute', currentRoute?.category);
|
|
45
46
|
// console.log('getPage.segments', segments.map(x => x.id));
|
|
46
47
|
const breadcrumb: IRouteLink[] =
|
|
47
48
|
currentRoute ?
|
|
@@ -123,7 +124,7 @@ export async function getPageCategory<T extends ICategorized>(schema: string, pa
|
|
|
123
124
|
const pages = await findManyPages<T>(schema, {
|
|
124
125
|
where: {
|
|
125
126
|
category: {
|
|
126
|
-
equals:
|
|
127
|
+
equals: asCategoryId(page.category),
|
|
127
128
|
},
|
|
128
129
|
}, market, locale,
|
|
129
130
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { asCategoryId, defaultLocale, defaultMarket, getRootCategory, ICategory, IRoute, IRouteLink, localize, QueryParams } from '@websolutespa/bom-core';
|
|
1
|
+
import { asCategoryId, defaultLocale, defaultMarket, findRouteOfCategory, getRootCategory, ICategory, IRoute, IRouteLink, localize, QueryParams } from '@websolutespa/bom-core';
|
|
2
2
|
import { getStore } from '@websolutespa/bom-mixer-store';
|
|
3
3
|
import { IModelStore } from '../store/store';
|
|
4
4
|
|
|
@@ -93,9 +93,7 @@ export async function getBreadcrumbFromSegments(segments: ICategory[], route: IR
|
|
|
93
93
|
},
|
|
94
94
|
});
|
|
95
95
|
const tree: IRouteLink[] = segments.map(segment => {
|
|
96
|
-
const route = routes.
|
|
97
|
-
r.category === segment.id && r.isDefault
|
|
98
|
-
);
|
|
96
|
+
const route = findRouteOfCategory(routes, segment.id);
|
|
99
97
|
return {
|
|
100
98
|
segment,
|
|
101
99
|
route,
|
|
@@ -141,16 +139,13 @@ export async function getRouteLinkTree(market: string, locale: string): Promise<
|
|
|
141
139
|
}
|
|
142
140
|
|
|
143
141
|
export function categoryToRouteLink(routes: IRoute[], categories: ICategory[], category: ICategory, locale: string): IRouteLink | undefined {
|
|
144
|
-
const route = routes.
|
|
145
|
-
r.category === category.id &&
|
|
146
|
-
r.isDefault
|
|
147
|
-
);
|
|
142
|
+
const route = findRouteOfCategory(routes, category.id);
|
|
148
143
|
if (!route) {
|
|
149
144
|
return undefined;
|
|
150
145
|
}
|
|
151
146
|
const rootCategory = getRootCategory(categories);
|
|
152
147
|
const childCategories = categories.filter(x => {
|
|
153
|
-
const parentId =
|
|
148
|
+
const parentId = asCategoryId(x.category);
|
|
154
149
|
return rootCategory && rootCategory.id === category.id ?
|
|
155
150
|
(x.id !== rootCategory.id && (parentId === category.id || !parentId)) :
|
|
156
151
|
parentId === category.id;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMedia, IPage,
|
|
1
|
+
import { IMedia, IPage, asEquatableString } from '@websolutespa/bom-core';
|
|
2
2
|
import { getPublicUrl, resolveHref } from '../page/page.service';
|
|
3
3
|
|
|
4
4
|
export type StructuredDataPerson = {
|
|
@@ -84,7 +84,7 @@ const DefaultStructuredDataCollections: StructuredDataCollections = {
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
export function resolveTemplate(value: any): string | undefined {
|
|
87
|
-
return
|
|
87
|
+
return asEquatableString(value);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export function resolveMediaSrc(media: IMedia): string | undefined {
|
|
@@ -99,14 +99,15 @@ export function resolveStructuredData(
|
|
|
99
99
|
let schema: {} | null = null;
|
|
100
100
|
let pageType = page.schema || '';
|
|
101
101
|
if (page.template) {
|
|
102
|
-
pageType =
|
|
102
|
+
pageType = asEquatableString(page.template);
|
|
103
103
|
}
|
|
104
104
|
if (types.article.includes(pageType)) {
|
|
105
|
+
const mediaSrc = page.media ? resolveMediaSrc(page.media) : undefined;
|
|
105
106
|
schema = {
|
|
106
107
|
'@context': 'https://schema.org',
|
|
107
108
|
'@type': 'NewsArticle',
|
|
108
109
|
headline: page.title,
|
|
109
|
-
image:
|
|
110
|
+
image: mediaSrc ? [mediaSrc] : [],
|
|
110
111
|
datePublished: page.createdAt,
|
|
111
112
|
dateModified: page.updatedAt,
|
|
112
113
|
author: [{
|