@websolutespa/bom-mixer-models 1.7.2 → 1.7.4

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,208 +1,224 @@
1
- # @websolutespa/bom-mixer-models
2
-
3
- ## 1.7.2
4
-
5
- ### Patch Changes
6
-
7
- - Updating: dependencies
8
- - Updated dependencies
9
- - @websolutespa/bom-mixer-store@1.7.3
10
- - @websolutespa/bom-core@1.7.3
11
-
12
- ## 1.7.1
13
-
14
- ### Patch Changes
15
-
16
- - Fixing: findRoute redirects
17
-
18
- ## 1.7.0
19
-
20
- ### Minor Changes
21
-
22
- - 28e86bd: Modified: IPage, Store services & decorators
23
- - Updated dependencies [28e86bd]
24
- - @websolutespa/bom-mixer-store@1.7.0
25
- - @websolutespa/bom-core@1.7.0
26
-
27
- ## 1.6.0
28
-
29
- ### Patch Changes
30
-
31
- - f664993: Added: useLivePreview
32
- - 6707ca2: Fixing LocaleService getLocaleFromProps
33
- - Updated dependencies [f664993]
34
- - Updated dependencies [6cbf4cb]
35
- - @websolutespa/bom-mixer-store@1.4.7
36
- - @websolutespa/bom-core@0.6.7
37
-
38
- ## 1.5.10
39
-
40
- ### Patch Changes
41
-
42
- - Added: captions handler
43
-
44
- ## 1.5.9
45
-
46
- ### Patch Changes
47
-
48
- - Added: lang attribute to sitemap
49
-
50
- ## 1.5.8
51
-
52
- ### Patch Changes
53
-
54
- - Modified: getBreadcrumbFromSegments, getSeoWeight
55
- - Updated dependencies
56
- - @websolutespa/bom-core@0.6.6
57
-
58
- ## 1.5.7
59
-
60
- ### Patch Changes
61
-
62
- - Fixing: getDecoratedComponents
63
-
64
- ## 1.5.6
65
-
66
- ### Patch Changes
67
-
68
- - Added: SeoService
69
- - Modified: IFeatureType, PageService, RedirectService, RouteService
70
- - Updated dependencies
71
- - @websolutespa/bom-mixer-store@1.4.3
72
- - @websolutespa/bom-core@0.6.5
73
-
74
- ## 1.5.5
75
-
76
- ### Patch Changes
77
-
78
- - Modified: RouteInterceptor
79
-
80
- ## 1.5.4
81
-
82
- ### Patch Changes
83
-
84
- - Modified: PageService, RouteInterceptor, RouteService, StructuredData
85
- - Updated dependencies
86
- - @websolutespa/bom-mixer-store@1.4.3
87
-
88
- ## 1.5.3
89
-
90
- ### Patch Changes
91
-
92
- - Modified: RouteService
93
- - Updated dependencies
94
- - @websolutespa/bom-mixer-store@1.4.1
95
- - @websolutespa/bom-core@0.6.3
96
-
97
- ## 1.5.2
98
-
99
- ### Patch Changes
100
-
101
- - Added: StructuredData
102
- - Updated dependencies
103
- - @websolutespa/bom-core@0.6.2
104
-
105
- ## 1.5.1
106
-
107
- ### Patch Changes
108
-
109
- - Added: defaultMarket, defaultLocale
110
- - Updated dependencies [dad63747]
111
- - @websolutespa/bom-core@0.6.1
112
-
113
- ## 1.5.0
114
-
115
- ### Minor Changes
116
-
117
- - Added getDecoratedComponents, getPageProps
118
-
119
- ## 1.4.0
120
-
121
- ### Minor Changes
122
-
123
- - Modified: RouteService, LayoutService
124
-
125
- ## 1.3.0
126
-
127
- ### Minor Changes
128
-
129
- - Added: ILazyProps, ILazyableProps, ILazyedProps
130
-
131
- ## 1.2.1
132
-
133
- ### Patch Changes
134
-
135
- - Added: IAppProps, ILazyProps
136
-
137
- ## 1.2.0
138
-
139
- ### Minor Changes
140
-
141
- - Updating: next 13
142
-
143
- ## 1.1.0
144
-
145
- ### Minor Changes
146
-
147
- - Added: storeApi
148
- - Modified: SiteMapService
149
-
150
- ## 1.0.1
151
-
152
- ### Patch Changes
153
-
154
- - Added: env ROOT_CATEGORY
155
-
156
- ## 0.5.0
157
-
158
- ### Minor Changes
159
-
160
- - Modified routes, added redirects
161
-
162
- ## 0.4.2
163
-
164
- ### Patch Changes
165
-
166
- - Fixing: avoid categories circular reference
167
-
168
- ## 0.4.1
169
-
170
- ### Patch Changes
171
-
172
- - Added: source files
173
-
174
- ## 0.4.0
175
-
176
- ### Minor Changes
177
-
178
- - Added: splat routes
179
-
180
- ## 0.3.0
181
-
182
- ### Minor Changes
183
-
184
- - Added: @websolutespa/bom-core
185
-
186
- ## 0.2.0
187
-
188
- ### Minor Changes
189
-
190
- - Added: LazyComponent Types
191
-
192
- ## 0.1.1
193
-
194
- ### Patch Changes
195
-
196
- - Modified: page service
197
-
198
- ## 0.1.0
199
-
200
- ### Minor Changes
201
-
202
- - mock refactor
203
-
204
- ## 0.0.2
205
-
206
- ### Patch Changes
207
-
208
- - Added: first release
1
+ # @websolutespa/bom-mixer-models
2
+
3
+ ## 1.7.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: structuredData
8
+ - Updated dependencies
9
+ - @websolutespa/bom-core@1.7.5
10
+
11
+ ## 1.7.3
12
+
13
+ ### Patch Changes
14
+
15
+ - Added: getOrigin, getHost
16
+ - Updated dependencies
17
+ - @websolutespa/bom-core@1.7.4
18
+
19
+ ## 1.7.2
20
+
21
+ ### Patch Changes
22
+
23
+ - Updating: dependencies
24
+ - Updated dependencies
25
+ - @websolutespa/bom-mixer-store@1.7.3
26
+ - @websolutespa/bom-core@1.7.3
27
+
28
+ ## 1.7.1
29
+
30
+ ### Patch Changes
31
+
32
+ - Fixing: findRoute redirects
33
+
34
+ ## 1.7.0
35
+
36
+ ### Minor Changes
37
+
38
+ - 28e86bd: Modified: IPage, Store services & decorators
39
+ - Updated dependencies [28e86bd]
40
+ - @websolutespa/bom-mixer-store@1.7.0
41
+ - @websolutespa/bom-core@1.7.0
42
+
43
+ ## 1.6.0
44
+
45
+ ### Patch Changes
46
+
47
+ - f664993: Added: useLivePreview
48
+ - 6707ca2: Fixing LocaleService getLocaleFromProps
49
+ - Updated dependencies [f664993]
50
+ - Updated dependencies [6cbf4cb]
51
+ - @websolutespa/bom-mixer-store@1.4.7
52
+ - @websolutespa/bom-core@0.6.7
53
+
54
+ ## 1.5.10
55
+
56
+ ### Patch Changes
57
+
58
+ - Added: captions handler
59
+
60
+ ## 1.5.9
61
+
62
+ ### Patch Changes
63
+
64
+ - Added: lang attribute to sitemap
65
+
66
+ ## 1.5.8
67
+
68
+ ### Patch Changes
69
+
70
+ - Modified: getBreadcrumbFromSegments, getSeoWeight
71
+ - Updated dependencies
72
+ - @websolutespa/bom-core@0.6.6
73
+
74
+ ## 1.5.7
75
+
76
+ ### Patch Changes
77
+
78
+ - Fixing: getDecoratedComponents
79
+
80
+ ## 1.5.6
81
+
82
+ ### Patch Changes
83
+
84
+ - Added: SeoService
85
+ - Modified: IFeatureType, PageService, RedirectService, RouteService
86
+ - Updated dependencies
87
+ - @websolutespa/bom-mixer-store@1.4.3
88
+ - @websolutespa/bom-core@0.6.5
89
+
90
+ ## 1.5.5
91
+
92
+ ### Patch Changes
93
+
94
+ - Modified: RouteInterceptor
95
+
96
+ ## 1.5.4
97
+
98
+ ### Patch Changes
99
+
100
+ - Modified: PageService, RouteInterceptor, RouteService, StructuredData
101
+ - Updated dependencies
102
+ - @websolutespa/bom-mixer-store@1.4.3
103
+
104
+ ## 1.5.3
105
+
106
+ ### Patch Changes
107
+
108
+ - Modified: RouteService
109
+ - Updated dependencies
110
+ - @websolutespa/bom-mixer-store@1.4.1
111
+ - @websolutespa/bom-core@0.6.3
112
+
113
+ ## 1.5.2
114
+
115
+ ### Patch Changes
116
+
117
+ - Added: StructuredData
118
+ - Updated dependencies
119
+ - @websolutespa/bom-core@0.6.2
120
+
121
+ ## 1.5.1
122
+
123
+ ### Patch Changes
124
+
125
+ - Added: defaultMarket, defaultLocale
126
+ - Updated dependencies [dad63747]
127
+ - @websolutespa/bom-core@0.6.1
128
+
129
+ ## 1.5.0
130
+
131
+ ### Minor Changes
132
+
133
+ - Added getDecoratedComponents, getPageProps
134
+
135
+ ## 1.4.0
136
+
137
+ ### Minor Changes
138
+
139
+ - Modified: RouteService, LayoutService
140
+
141
+ ## 1.3.0
142
+
143
+ ### Minor Changes
144
+
145
+ - Added: ILazyProps, ILazyableProps, ILazyedProps
146
+
147
+ ## 1.2.1
148
+
149
+ ### Patch Changes
150
+
151
+ - Added: IAppProps, ILazyProps
152
+
153
+ ## 1.2.0
154
+
155
+ ### Minor Changes
156
+
157
+ - Updating: next 13
158
+
159
+ ## 1.1.0
160
+
161
+ ### Minor Changes
162
+
163
+ - Added: storeApi
164
+ - Modified: SiteMapService
165
+
166
+ ## 1.0.1
167
+
168
+ ### Patch Changes
169
+
170
+ - Added: env ROOT_CATEGORY
171
+
172
+ ## 0.5.0
173
+
174
+ ### Minor Changes
175
+
176
+ - Modified routes, added redirects
177
+
178
+ ## 0.4.2
179
+
180
+ ### Patch Changes
181
+
182
+ - Fixing: avoid categories circular reference
183
+
184
+ ## 0.4.1
185
+
186
+ ### Patch Changes
187
+
188
+ - Added: source files
189
+
190
+ ## 0.4.0
191
+
192
+ ### Minor Changes
193
+
194
+ - Added: splat routes
195
+
196
+ ## 0.3.0
197
+
198
+ ### Minor Changes
199
+
200
+ - Added: @websolutespa/bom-core
201
+
202
+ ## 0.2.0
203
+
204
+ ### Minor Changes
205
+
206
+ - Added: LazyComponent Types
207
+
208
+ ## 0.1.1
209
+
210
+ ### Patch Changes
211
+
212
+ - Modified: page service
213
+
214
+ ## 0.1.0
215
+
216
+ ### Minor Changes
217
+
218
+ - mock refactor
219
+
220
+ ## 0.0.2
221
+
222
+ ### Patch Changes
223
+
224
+ - Added: first release
package/dist/index.d.ts CHANGED
@@ -286,7 +286,7 @@ declare function getErrorPageLayout(): Promise<{
286
286
  }>;
287
287
  type PartialPageProps<T extends ICategorized, B> = Omit<PageProps<T>, 'page'> & Partial<Pick<PageProps<T>, 'page'>> & B;
288
288
  declare function getPageProps<T extends ICategorized, B = any>(props: PartialPageProps<T, B>): Promise<PageProps<T> & B>;
289
- declare function getOrigin(): string;
289
+ declare function getPublicUrl(): string;
290
290
  declare function resolveHref(href?: string): string;
291
291
 
292
292
  declare const getPreviewProps: GetServerSideProps;
@@ -428,6 +428,8 @@ type StructuredDataEvent = {
428
428
  };
429
429
  type StructuredDataKeys = 'article';
430
430
  type StructuredDataCollections = Record<StructuredDataKeys, string[]>;
431
- declare function resolveStructuredData(page: IPage, types?: StructuredDataCollections): string | undefined;
431
+ declare function resolveTemplate(value: any): string | undefined;
432
+ declare function resolveMediaSrc(media: IMedia): string | undefined;
433
+ declare function resolveStructuredData(page: IPage, websiteName?: string, types?: StructuredDataCollections): string | undefined;
432
434
 
433
- export { IAddress, IAddressOptions, IAppProps, IApplication, IApplicationProps, ICartAddItem, ICartItem, ICheckout, ICheckoutDelivery, ICheckoutDiscount, ICheckoutInfo, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutPaymentRedirect, ICheckoutStore, ICompanyAddress, IFeatureType, IKeyedList, ILazyComponent, ILazyComponentFunc, ILazyComponentProps, ILazyFuncProps, ILazyModules, ILazyProps, ILazyStaticProps, ILazyStaticPropsFunc, ILazyableProps, ILazyedProps, ILink, IList, IModelStore, IOrder, IOrderDetail, IOrderStatus, IOrderStatusValue, ISiteMap, IUser, IUserAddress, IUserChangePassword, IUserForgot, IUserLogin, IUserRegister, LAZY_PROPS, NotFound, PartialPageProps, SeoWeight, StaticPath, StructuredDataAddress, StructuredDataArticle, StructuredDataCollections, StructuredDataEvent, StructuredDataKeys, StructuredDataOffer, StructuredDataOrganization, StructuredDataPerformingGroup, StructuredDataPerson, StructuredDataPlace, categoryToRouteLink, findManyPages, findOnePage, getBreadcrumbFromSegments, getCaptionsVttProps, getCategories, getCategory, getCountries, getCountry, getDecoratedComponents, getDeliveries, getErrorPageLayout, getFeatureType, getFeatureTypes, getInfo, getItems, getLabel, getLabels, getLayout, getListByKeys, getLists, getLocale, getLocaleFromProps, getLocales, getMarket, getMarkets, getMenu, getMenus, getOrder, getOrders, getOrigin, getPage, getPageCategory, getPageProps, getPageRoutes, getPayment, getPayments, getPreviewProps, getProvince, getProvinces, getRedirect, getRedirects, getRegion, getRegions, getRoute, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getSeoWeight, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStores, newRouteLink, redirectTo, resolveHref, resolveLabel, resolveRoute, resolveStructuredData, routeInterceptor, routeRevalidateHandler, routeToRouteLink, setDiscountCode, updateCheckout, withLazyProps };
435
+ export { IAddress, IAddressOptions, IAppProps, IApplication, IApplicationProps, ICartAddItem, ICartItem, ICheckout, ICheckoutDelivery, ICheckoutDiscount, ICheckoutInfo, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutPaymentRedirect, ICheckoutStore, ICompanyAddress, IFeatureType, IKeyedList, ILazyComponent, ILazyComponentFunc, ILazyComponentProps, ILazyFuncProps, ILazyModules, ILazyProps, ILazyStaticProps, ILazyStaticPropsFunc, ILazyableProps, ILazyedProps, ILink, IList, IModelStore, IOrder, IOrderDetail, IOrderStatus, IOrderStatusValue, ISiteMap, IUser, IUserAddress, IUserChangePassword, IUserForgot, IUserLogin, IUserRegister, LAZY_PROPS, NotFound, PartialPageProps, SeoWeight, StaticPath, StructuredDataAddress, StructuredDataArticle, StructuredDataCollections, StructuredDataEvent, StructuredDataKeys, StructuredDataOffer, StructuredDataOrganization, StructuredDataPerformingGroup, StructuredDataPerson, StructuredDataPlace, categoryToRouteLink, findManyPages, findOnePage, getBreadcrumbFromSegments, getCaptionsVttProps, getCategories, getCategory, getCountries, getCountry, getDecoratedComponents, getDeliveries, getErrorPageLayout, getFeatureType, getFeatureTypes, getInfo, getItems, getLabel, getLabels, getLayout, getListByKeys, getLists, getLocale, getLocaleFromProps, getLocales, getMarket, getMarkets, getMenu, getMenus, getOrder, getOrders, getPage, getPageCategory, getPageProps, getPageRoutes, getPayment, getPayments, getPreviewProps, getProvince, getProvinces, getPublicUrl, getRedirect, getRedirects, getRegion, getRegions, getRoute, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getSeoWeight, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStores, newRouteLink, redirectTo, resolveHref, resolveLabel, resolveMediaSrc, resolveRoute, resolveStructuredData, resolveTemplate, routeInterceptor, routeRevalidateHandler, routeToRouteLink, setDiscountCode, updateCheckout, withLazyProps };
package/dist/index.js CHANGED
@@ -53,7 +53,6 @@ __export(src_exports, {
53
53
  getMenus: () => getMenus,
54
54
  getOrder: () => getOrder,
55
55
  getOrders: () => getOrders,
56
- getOrigin: () => getOrigin,
57
56
  getPage: () => getPage,
58
57
  getPageCategory: () => getPageCategory,
59
58
  getPageProps: () => getPageProps,
@@ -63,6 +62,7 @@ __export(src_exports, {
63
62
  getPreviewProps: () => getPreviewProps,
64
63
  getProvince: () => getProvince,
65
64
  getProvinces: () => getProvinces,
65
+ getPublicUrl: () => getPublicUrl,
66
66
  getRedirect: () => getRedirect,
67
67
  getRedirects: () => getRedirects,
68
68
  getRegion: () => getRegion,
@@ -86,8 +86,10 @@ __export(src_exports, {
86
86
  redirectTo: () => redirectTo,
87
87
  resolveHref: () => resolveHref,
88
88
  resolveLabel: () => resolveLabel,
89
+ resolveMediaSrc: () => resolveMediaSrc,
89
90
  resolveRoute: () => resolveRoute,
90
91
  resolveStructuredData: () => resolveStructuredData,
92
+ resolveTemplate: () => resolveTemplate,
91
93
  routeInterceptor: () => routeInterceptor,
92
94
  routeRevalidateHandler: () => routeRevalidateHandler,
93
95
  routeToRouteLink: () => routeToRouteLink,
@@ -1300,12 +1302,12 @@ async function getPageProps(props) {
1300
1302
  }
1301
1303
  return (0, import_bom_core3.asServerProps)(props);
1302
1304
  }
1303
- function getOrigin() {
1304
- const origin = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
1305
- return origin;
1305
+ function getPublicUrl() {
1306
+ const publicUrl = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
1307
+ return publicUrl;
1306
1308
  }
1307
1309
  function resolveHref(href = "") {
1308
- return href.startsWith("http") ? href : `${getOrigin()}${href}`;
1310
+ return href.startsWith("http") ? href : `${getPublicUrl()}${href}`;
1309
1311
  }
1310
1312
 
1311
1313
  // src/preview/preview.handler.ts
@@ -1370,6 +1372,7 @@ function routeRevalidateHandler() {
1370
1372
  }
1371
1373
 
1372
1374
  // src/route/route.interceptor.ts
1375
+ var import_bom_core4 = require("@websolutespa/bom-core");
1373
1376
  var import_bom_mixer_store16 = require("@websolutespa/bom-mixer-store");
1374
1377
  var import_server = require("next/server");
1375
1378
  async function routeInterceptor(request, next) {
@@ -1412,8 +1415,8 @@ async function routeInterceptor(request, next) {
1412
1415
  function getHrefBeforeRedirect(request) {
1413
1416
  let hrefBeforeRedirect = null;
1414
1417
  const urlBeforeRedirect = request.nextUrl.clone();
1415
- const host = request.headers.get("host");
1416
- if (typeof host === "string") {
1418
+ const host = (0, import_bom_core4.getHost)(request.headers);
1419
+ if (host) {
1417
1420
  urlBeforeRedirect.host = host;
1418
1421
  urlBeforeRedirect.port = host.split(":")[1] || "";
1419
1422
  hrefBeforeRedirect = urlBeforeRedirect.href;
@@ -1430,8 +1433,11 @@ var getSeoWeight = (index = 0, seoWeight) => {
1430
1433
  return getter;
1431
1434
  };
1432
1435
 
1436
+ // src/sitemap/sitemap.handler.ts
1437
+ var import_bom_core6 = require("@websolutespa/bom-core");
1438
+
1433
1439
  // src/sitemap/sitemap.service.ts
1434
- var import_bom_core4 = require("@websolutespa/bom-core");
1440
+ var import_bom_core5 = require("@websolutespa/bom-core");
1435
1441
  async function getSiteMapIndex(origin) {
1436
1442
  let markets = await getMarkets();
1437
1443
  let locales = await getLocales();
@@ -1442,7 +1448,7 @@ async function getSiteMapIndex(origin) {
1442
1448
  const getTime = (date) => {
1443
1449
  return typeof date !== "undefined" ? (typeof date === "string" ? new Date(date) : date).getTime() : 0;
1444
1450
  };
1445
- (0, import_bom_core4.eachMarketLocale)(markets, locales, (market, locale, markets2, locales2) => {
1451
+ (0, import_bom_core5.eachMarketLocale)(markets, locales, (market, locale, markets2, locales2) => {
1446
1452
  const sitemapRoutes = routes.filter((x) => x.market === market.id && x.locale === locale.id);
1447
1453
  sitemapRoutes.sort((a, b) => getTime(a.updatedAt) - getTime(b.updatedAt));
1448
1454
  sitemaps.push({
@@ -1687,17 +1693,9 @@ async function getSiteMapXSL(localeId) {
1687
1693
  }
1688
1694
 
1689
1695
  // src/sitemap/sitemap.handler.ts
1690
- var ORIGIN = process.env.NEXT_PUBLIC_URL || "";
1691
- function getOrigin2(host) {
1692
- if (host) {
1693
- return host.indexOf("localhost") !== -1 ? "http://" + host : "https://" + host;
1694
- } else {
1695
- return ORIGIN;
1696
- }
1697
- }
1698
1696
  var getSiteMapIndexProps = async (context) => {
1699
1697
  const { req, res } = context;
1700
- const sitemap = await getSiteMapIndex(getOrigin2(req.headers.host));
1698
+ const sitemap = await getSiteMapIndex((0, import_bom_core6.getOrigin)(req.headers));
1701
1699
  res.setHeader("Content-Type", "application/xml; charset=UTF-8");
1702
1700
  res.setHeader("X-Frame-Options", "SAMEORIGIN");
1703
1701
  res.setHeader("X-Robots-Tag", "noindex, follow");
@@ -1712,7 +1710,7 @@ var getSiteMapXMLProps = async (context) => {
1712
1710
  const params = context.params;
1713
1711
  const market = params?.market;
1714
1712
  const locale = params?.locale;
1715
- const sitemap = await getSiteMapXML(getOrigin2(req.headers.host), market, locale);
1713
+ const sitemap = await getSiteMapXML((0, import_bom_core6.getOrigin)(req.headers), market, locale);
1716
1714
  res.setHeader("Content-Type", "application/xml; charset=UTF-8");
1717
1715
  res.setHeader("X-Frame-Options", "SAMEORIGIN");
1718
1716
  res.setHeader("X-Robots-Tag", "noindex, follow");
@@ -1739,26 +1737,35 @@ var getSiteMapXSLProps = async (context) => {
1739
1737
  };
1740
1738
 
1741
1739
  // src/structured_data/structured_data.ts
1740
+ var import_bom_core7 = require("@websolutespa/bom-core");
1742
1741
  var DefaultStructuredDataCollections = {
1743
1742
  article: ["news_detail"]
1744
1743
  };
1745
- function resolveStructuredData(page, types = DefaultStructuredDataCollections) {
1744
+ function resolveTemplate(value) {
1745
+ return (0, import_bom_core7.asCategoryId)(value);
1746
+ }
1747
+ function resolveMediaSrc(media) {
1748
+ return resolveHref(media.src || media.url);
1749
+ }
1750
+ function resolveStructuredData(page, websiteName = "WebsiteName", types = DefaultStructuredDataCollections) {
1746
1751
  let schema = null;
1747
1752
  const json = null;
1748
- const pageType = page.template || page.schema || "";
1753
+ let pageType = page.schema || "";
1754
+ if (page.template) {
1755
+ pageType = (0, import_bom_core7.asCategoryId)(page.template);
1756
+ }
1749
1757
  if (types.article.includes(pageType)) {
1750
1758
  schema = {
1751
1759
  "@context": "https://schema.org",
1752
1760
  "@type": "NewsArticle",
1753
1761
  headline: page.title,
1754
- image: page.media ? [resolveHref(page.media.src)] : [],
1762
+ image: page.media ? [resolveMediaSrc(page.media)] : [],
1755
1763
  datePublished: page.createdAt,
1756
1764
  dateModified: page.updatedAt,
1757
1765
  author: [{
1758
- "@type": "Organization",
1759
- name: "WebsiteName"
1760
- // 'Autorità del bacino distrettuale dell\'Appennino Centrale',
1761
- // url: 'https://twitter.com/autoritadac',
1766
+ "@type": "Person",
1767
+ name: websiteName,
1768
+ url: getPublicUrl()
1762
1769
  }]
1763
1770
  };
1764
1771
  }
@@ -1802,7 +1809,6 @@ function resolveStructuredData(page, types = DefaultStructuredDataCollections) {
1802
1809
  getMenus,
1803
1810
  getOrder,
1804
1811
  getOrders,
1805
- getOrigin,
1806
1812
  getPage,
1807
1813
  getPageCategory,
1808
1814
  getPageProps,
@@ -1812,6 +1818,7 @@ function resolveStructuredData(page, types = DefaultStructuredDataCollections) {
1812
1818
  getPreviewProps,
1813
1819
  getProvince,
1814
1820
  getProvinces,
1821
+ getPublicUrl,
1815
1822
  getRedirect,
1816
1823
  getRedirects,
1817
1824
  getRegion,
@@ -1835,8 +1842,10 @@ function resolveStructuredData(page, types = DefaultStructuredDataCollections) {
1835
1842
  redirectTo,
1836
1843
  resolveHref,
1837
1844
  resolveLabel,
1845
+ resolveMediaSrc,
1838
1846
  resolveRoute,
1839
1847
  resolveStructuredData,
1848
+ resolveTemplate,
1840
1849
  routeInterceptor,
1841
1850
  routeRevalidateHandler,
1842
1851
  routeToRouteLink,
package/dist/index.mjs CHANGED
@@ -1201,12 +1201,12 @@ async function getPageProps(props) {
1201
1201
  }
1202
1202
  return asServerProps(props);
1203
1203
  }
1204
- function getOrigin() {
1205
- const origin = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
1206
- return origin;
1204
+ function getPublicUrl() {
1205
+ const publicUrl = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
1206
+ return publicUrl;
1207
1207
  }
1208
1208
  function resolveHref(href = "") {
1209
- return href.startsWith("http") ? href : `${getOrigin()}${href}`;
1209
+ return href.startsWith("http") ? href : `${getPublicUrl()}${href}`;
1210
1210
  }
1211
1211
 
1212
1212
  // src/preview/preview.handler.ts
@@ -1271,6 +1271,7 @@ function routeRevalidateHandler() {
1271
1271
  }
1272
1272
 
1273
1273
  // src/route/route.interceptor.ts
1274
+ import { getHost } from "@websolutespa/bom-core";
1274
1275
  import { StoreStrategy, localApiPost, storeApiPost, storeStrategy } from "@websolutespa/bom-mixer-store";
1275
1276
  import { NextResponse } from "next/server";
1276
1277
  async function routeInterceptor(request, next) {
@@ -1313,8 +1314,8 @@ async function routeInterceptor(request, next) {
1313
1314
  function getHrefBeforeRedirect(request) {
1314
1315
  let hrefBeforeRedirect = null;
1315
1316
  const urlBeforeRedirect = request.nextUrl.clone();
1316
- const host = request.headers.get("host");
1317
- if (typeof host === "string") {
1317
+ const host = getHost(request.headers);
1318
+ if (host) {
1318
1319
  urlBeforeRedirect.host = host;
1319
1320
  urlBeforeRedirect.port = host.split(":")[1] || "";
1320
1321
  hrefBeforeRedirect = urlBeforeRedirect.href;
@@ -1331,6 +1332,9 @@ var getSeoWeight = (index = 0, seoWeight) => {
1331
1332
  return getter;
1332
1333
  };
1333
1334
 
1335
+ // src/sitemap/sitemap.handler.ts
1336
+ import { getOrigin } from "@websolutespa/bom-core";
1337
+
1334
1338
  // src/sitemap/sitemap.service.ts
1335
1339
  import { eachMarketLocale } from "@websolutespa/bom-core";
1336
1340
  async function getSiteMapIndex(origin) {
@@ -1588,17 +1592,9 @@ async function getSiteMapXSL(localeId) {
1588
1592
  }
1589
1593
 
1590
1594
  // src/sitemap/sitemap.handler.ts
1591
- var ORIGIN = process.env.NEXT_PUBLIC_URL || "";
1592
- function getOrigin2(host) {
1593
- if (host) {
1594
- return host.indexOf("localhost") !== -1 ? "http://" + host : "https://" + host;
1595
- } else {
1596
- return ORIGIN;
1597
- }
1598
- }
1599
1595
  var getSiteMapIndexProps = async (context) => {
1600
1596
  const { req, res } = context;
1601
- const sitemap = await getSiteMapIndex(getOrigin2(req.headers.host));
1597
+ const sitemap = await getSiteMapIndex(getOrigin(req.headers));
1602
1598
  res.setHeader("Content-Type", "application/xml; charset=UTF-8");
1603
1599
  res.setHeader("X-Frame-Options", "SAMEORIGIN");
1604
1600
  res.setHeader("X-Robots-Tag", "noindex, follow");
@@ -1613,7 +1609,7 @@ var getSiteMapXMLProps = async (context) => {
1613
1609
  const params = context.params;
1614
1610
  const market = params?.market;
1615
1611
  const locale = params?.locale;
1616
- const sitemap = await getSiteMapXML(getOrigin2(req.headers.host), market, locale);
1612
+ const sitemap = await getSiteMapXML(getOrigin(req.headers), market, locale);
1617
1613
  res.setHeader("Content-Type", "application/xml; charset=UTF-8");
1618
1614
  res.setHeader("X-Frame-Options", "SAMEORIGIN");
1619
1615
  res.setHeader("X-Robots-Tag", "noindex, follow");
@@ -1640,26 +1636,35 @@ var getSiteMapXSLProps = async (context) => {
1640
1636
  };
1641
1637
 
1642
1638
  // src/structured_data/structured_data.ts
1639
+ import { asCategoryId as asCategoryId2 } from "@websolutespa/bom-core";
1643
1640
  var DefaultStructuredDataCollections = {
1644
1641
  article: ["news_detail"]
1645
1642
  };
1646
- function resolveStructuredData(page, types = DefaultStructuredDataCollections) {
1643
+ function resolveTemplate(value) {
1644
+ return asCategoryId2(value);
1645
+ }
1646
+ function resolveMediaSrc(media) {
1647
+ return resolveHref(media.src || media.url);
1648
+ }
1649
+ function resolveStructuredData(page, websiteName = "WebsiteName", types = DefaultStructuredDataCollections) {
1647
1650
  let schema = null;
1648
1651
  const json = null;
1649
- const pageType = page.template || page.schema || "";
1652
+ let pageType = page.schema || "";
1653
+ if (page.template) {
1654
+ pageType = asCategoryId2(page.template);
1655
+ }
1650
1656
  if (types.article.includes(pageType)) {
1651
1657
  schema = {
1652
1658
  "@context": "https://schema.org",
1653
1659
  "@type": "NewsArticle",
1654
1660
  headline: page.title,
1655
- image: page.media ? [resolveHref(page.media.src)] : [],
1661
+ image: page.media ? [resolveMediaSrc(page.media)] : [],
1656
1662
  datePublished: page.createdAt,
1657
1663
  dateModified: page.updatedAt,
1658
1664
  author: [{
1659
- "@type": "Organization",
1660
- name: "WebsiteName"
1661
- // 'Autorità del bacino distrettuale dell\'Appennino Centrale',
1662
- // url: 'https://twitter.com/autoritadac',
1665
+ "@type": "Person",
1666
+ name: websiteName,
1667
+ url: getPublicUrl()
1663
1668
  }]
1664
1669
  };
1665
1670
  }
@@ -1702,7 +1707,6 @@ export {
1702
1707
  getMenus,
1703
1708
  getOrder,
1704
1709
  getOrders,
1705
- getOrigin,
1706
1710
  getPage,
1707
1711
  getPageCategory,
1708
1712
  getPageProps,
@@ -1712,6 +1716,7 @@ export {
1712
1716
  getPreviewProps,
1713
1717
  getProvince,
1714
1718
  getProvinces,
1719
+ getPublicUrl,
1715
1720
  getRedirect,
1716
1721
  getRedirects,
1717
1722
  getRegion,
@@ -1735,8 +1740,10 @@ export {
1735
1740
  redirectTo,
1736
1741
  resolveHref,
1737
1742
  resolveLabel,
1743
+ resolveMediaSrc,
1738
1744
  resolveRoute,
1739
1745
  resolveStructuredData,
1746
+ resolveTemplate,
1740
1747
  routeInterceptor,
1741
1748
  routeRevalidateHandler,
1742
1749
  routeToRouteLink,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-models",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "Mixer Models module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -198,11 +198,11 @@ export async function getPageProps<T extends ICategorized, B = any>(props: Parti
198
198
  return asServerProps(props) as PageProps<T> & B;
199
199
  }
200
200
 
201
- export function getOrigin() {
202
- const origin = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : '';
203
- return origin;
201
+ export function getPublicUrl() {
202
+ const publicUrl = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : '';
203
+ return publicUrl;
204
204
  }
205
205
 
206
206
  export function resolveHref(href: string = '') {
207
- return href.startsWith('http') ? href : `${getOrigin()}${href}`;
207
+ return href.startsWith('http') ? href : `${getPublicUrl()}${href}`;
208
208
  }
@@ -1,4 +1,4 @@
1
- import { IRoute } from '@websolutespa/bom-core';
1
+ import { IRoute, getHost } from '@websolutespa/bom-core';
2
2
  import { StoreStrategy, localApiPost, storeApiPost, storeStrategy } from '@websolutespa/bom-mixer-store';
3
3
  import { NextFetchEvent, NextRequest, NextResponse } from 'next/server';
4
4
  import { resolveRoute } from './route.service';
@@ -51,17 +51,11 @@ export async function routeInterceptor(request: NextRequest, next: NextFetchEven
51
51
  function getHrefBeforeRedirect(request: NextRequest): string | null {
52
52
  let hrefBeforeRedirect: string | null = null;
53
53
  const urlBeforeRedirect = request.nextUrl.clone();
54
- const host = request.headers.get('host');
55
- if (typeof host === 'string') {
54
+ const host = getHost(request.headers);
55
+ if (host) {
56
56
  urlBeforeRedirect.host = host;
57
57
  urlBeforeRedirect.port = host.split(':')[1] || '';
58
58
  hrefBeforeRedirect = urlBeforeRedirect.href;
59
59
  }
60
- /*
61
- console.log('urlBeforeRedirect', urlBeforeRedirect.href);
62
- console.log('url', request.url);
63
- console.log('nextUrl', request.nextUrl.href, 'origin', request.nextUrl.origin);
64
- console.log('host', request.headers.get('host'), 'referer', request.headers.get('referer'));
65
- */
66
60
  return hrefBeforeRedirect;
67
61
  }
@@ -1,21 +1,11 @@
1
- import { IContextParams } from '@websolutespa/bom-core';
1
+ import { IContextParams, getOrigin } from '@websolutespa/bom-core';
2
2
  import { GetServerSideProps } from 'next';
3
3
  import { getSiteMapIndex, getSiteMapXML, getSiteMapXSL } from './sitemap.service';
4
4
 
5
- const ORIGIN = process.env.NEXT_PUBLIC_URL || '';
6
-
7
- function getOrigin(host?: string): string {
8
- if (host) {
9
- return host.indexOf('localhost') !== -1 ? 'http://' + host : 'https://' + host;
10
- } else {
11
- return ORIGIN;
12
- }
13
- }
14
-
15
5
  export const getSiteMapIndexProps: GetServerSideProps = async (context) => {
16
6
  const { req, res } = context;
17
7
  // console.log('getSiteMapIndexProps', req.headers.location, req.headers.host, req.headers.origin, req.headers.protocol);
18
- const sitemap = await getSiteMapIndex(getOrigin(req.headers.host));
8
+ const sitemap = await getSiteMapIndex(getOrigin(req.headers));
19
9
  res.setHeader('Content-Type', 'application/xml; charset=UTF-8');
20
10
  res.setHeader('X-Frame-Options', 'SAMEORIGIN');
21
11
  res.setHeader('X-Robots-Tag', 'noindex, follow');
@@ -32,7 +22,7 @@ export const getSiteMapXMLProps: GetServerSideProps = async (context) => {
32
22
  const params = context.params as IContextParams;
33
23
  const market = params?.market;
34
24
  const locale = params?.locale;
35
- const sitemap = await getSiteMapXML(getOrigin(req.headers.host), market, locale);
25
+ const sitemap = await getSiteMapXML(getOrigin(req.headers), market, locale);
36
26
  res.setHeader('Content-Type', 'application/xml; charset=UTF-8');
37
27
  res.setHeader('X-Frame-Options', 'SAMEORIGIN');
38
28
  res.setHeader('X-Robots-Tag', 'noindex, follow');
@@ -1,5 +1,5 @@
1
- import { IPage } from '@websolutespa/bom-core';
2
- import { resolveHref } from '../page/page.service';
1
+ import { IMedia, IPage, asCategoryId } from '@websolutespa/bom-core';
2
+ import { getPublicUrl, resolveHref } from '../page/page.service';
3
3
 
4
4
  export type StructuredDataPerson = {
5
5
  '@type': 'Person';
@@ -83,22 +83,37 @@ const DefaultStructuredDataCollections: StructuredDataCollections = {
83
83
  article: ['news_detail'],
84
84
  };
85
85
 
86
- export function resolveStructuredData(page: IPage, types: StructuredDataCollections = DefaultStructuredDataCollections): string | undefined {
86
+ export function resolveTemplate(value: any): string | undefined {
87
+ return asCategoryId(value);
88
+ }
89
+
90
+ export function resolveMediaSrc(media: IMedia): string | undefined {
91
+ return resolveHref(media.src || media.url);
92
+ }
93
+
94
+ export function resolveStructuredData(
95
+ page: IPage,
96
+ websiteName = 'WebsiteName',
97
+ types: StructuredDataCollections = DefaultStructuredDataCollections
98
+ ): string | undefined {
87
99
  let schema = null;
88
100
  const json: {} | null = null;
89
- const pageType = page.template || page.schema || '';
101
+ let pageType = page.schema || '';
102
+ if (page.template) {
103
+ pageType = asCategoryId(page.template);
104
+ }
90
105
  if (types.article.includes(pageType)) {
91
106
  schema = {
92
107
  '@context': 'https://schema.org',
93
108
  '@type': 'NewsArticle',
94
109
  headline: page.title,
95
- image: page.media ? [resolveHref(page.media.src)] : [],
110
+ image: page.media ? [resolveMediaSrc(page.media)] : [],
96
111
  datePublished: page.createdAt,
97
112
  dateModified: page.updatedAt,
98
113
  author: [{
99
- '@type': 'Organization',
100
- name: 'WebsiteName', // 'Autorità del bacino distrettuale dell\'Appennino Centrale',
101
- // url: 'https://twitter.com/autoritadac',
114
+ '@type': 'Person',
115
+ name: websiteName,
116
+ url: getPublicUrl(),
102
117
  }],
103
118
  } as StructuredDataArticle;
104
119
  }