@websolutespa/bom-mixer-models 2.0.1-next.2 → 2.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 +44 -7
- package/dist/index.d.ts +424 -253
- package/dist/index.js +1450 -41
- package/dist/index.mjs +1363 -0
- package/package.json +27 -75
- package/src/app/app.service.ts +9 -0
- package/src/captions/captions.handler.ts +1 -1
- package/src/category/category.service.ts +3 -3
- package/src/consent_preference/consent_preference.service.ts +4 -4
- package/src/consent_preference/consent_preference.ts +1 -1
- package/src/country/country.service.ts +4 -4
- package/src/index.ts +20 -3
- package/src/label/label.service.ts +3 -3
- package/src/layout/layout.service.ts +5 -2
- package/src/lazy/lazy.ts +26 -0
- package/src/locale/locale.service.ts +13 -3
- package/src/market/market.service.ts +3 -3
- package/src/menu/menu.service.ts +3 -3
- package/src/page/page.service.ts +7 -10
- package/src/province/province.service.ts +4 -4
- package/src/redirect/redirect.service.ts +4 -4
- package/src/region/region.service.ts +4 -4
- package/src/route/route-revalidate.handler.ts +2 -3
- package/src/route/route.interceptor.ts +121 -5
- package/src/route/route.service.ts +49 -11
- package/src/sitemap/sitemap.service.ts +8 -9
- package/src/store/store.ts +2 -1
- package/dist/exports/middleware.d.ts +0 -9
- package/dist/exports/middleware.d.ts.map +0 -1
- package/dist/exports/middleware.js +0 -82
- package/dist/exports/middleware.js.map +0 -1
- package/dist/exports/server.d.ts +0 -178
- package/dist/exports/server.d.ts.map +0 -1
- package/dist/exports/server.js +0 -921
- package/dist/exports/server.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lazy-JamSYYoh.d.ts +0 -84
- package/dist/lazy-JamSYYoh.d.ts.map +0 -1
- package/dist/page-BLbZbnWg.js +0 -12
- package/dist/page-BLbZbnWg.js.map +0 -1
- package/dist/route-k0W3AKyo.js +0 -53
- package/dist/route-k0W3AKyo.js.map +0 -1
- package/src/exports/middleware.ts +0 -2
- package/src/exports/server.ts +0 -21
- package/src/lazy/lazy.service.ts +0 -31
- package/src/locale/locale.ts +0 -9
- package/src/page/page.ts +0 -9
- package/src/route/route.ts +0 -64
package/dist/index.js
CHANGED
|
@@ -1,55 +1,1464 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
LAZY_PROPS: () => LAZY_PROPS,
|
|
24
|
+
NotFound: () => NotFound,
|
|
25
|
+
detectCountry: () => detectCountry,
|
|
26
|
+
detectLocale: () => detectLocale,
|
|
27
|
+
escapeHtml: () => escapeHtml,
|
|
28
|
+
findManyPages: () => findManyPages,
|
|
29
|
+
findOnePage: () => findOnePage,
|
|
30
|
+
getAddressOptions: () => getAddressOptions,
|
|
31
|
+
getBreadcrumbFromSegments: () => getBreadcrumbFromSegments,
|
|
32
|
+
getCaptionsVttProps: () => getCaptionsVttProps,
|
|
33
|
+
getCategories: () => getCategories,
|
|
34
|
+
getCategory: () => getCategory,
|
|
35
|
+
getConsentPreference: () => getConsentPreference,
|
|
36
|
+
getConsentPreferences: () => getConsentPreferences,
|
|
37
|
+
getConsentPreferencesPagination: () => getConsentPreferencesPagination,
|
|
38
|
+
getCountries: () => getCountries,
|
|
39
|
+
getCountriesPagination: () => getCountriesPagination,
|
|
40
|
+
getCountry: () => getCountry,
|
|
41
|
+
getDecoratedComponents: () => getDecoratedComponents,
|
|
42
|
+
getErrorPageLayout: () => getErrorPageLayout,
|
|
43
|
+
getLabel: () => getLabel,
|
|
44
|
+
getLabels: () => getLabels,
|
|
45
|
+
getLayout: () => getLayout,
|
|
46
|
+
getLink: () => getLink,
|
|
47
|
+
getLocale: () => getLocale,
|
|
48
|
+
getLocaleFromProps: () => getLocaleFromProps,
|
|
49
|
+
getLocales: () => getLocales,
|
|
50
|
+
getMarket: () => getMarket,
|
|
51
|
+
getMarkets: () => getMarkets,
|
|
52
|
+
getMenu: () => getMenu,
|
|
53
|
+
getMenus: () => getMenus,
|
|
54
|
+
getPage: () => getPage,
|
|
55
|
+
getPageCategory: () => getPageCategory,
|
|
56
|
+
getPageProps: () => getPageProps,
|
|
57
|
+
getPageRoutes: () => getPageRoutes,
|
|
58
|
+
getProvince: () => getProvince,
|
|
59
|
+
getProvinces: () => getProvinces,
|
|
60
|
+
getProvincesPagination: () => getProvincesPagination,
|
|
61
|
+
getPublicUrl: () => getPublicUrl,
|
|
62
|
+
getRedirect: () => getRedirect,
|
|
63
|
+
getRedirects: () => getRedirects,
|
|
64
|
+
getRedirectsPagination: () => getRedirectsPagination,
|
|
65
|
+
getRegion: () => getRegion,
|
|
66
|
+
getRegions: () => getRegions,
|
|
67
|
+
getRegionsPagination: () => getRegionsPagination,
|
|
68
|
+
getRoute: () => getRoute,
|
|
69
|
+
getRouteLinkCategory: () => getRouteLinkCategory,
|
|
70
|
+
getRouteLinkTree: () => getRouteLinkTree,
|
|
71
|
+
getRoutes: () => getRoutes,
|
|
72
|
+
getRoutesForSchemas: () => getRoutesForSchemas,
|
|
73
|
+
getRoutesForTemplates: () => getRoutesForTemplates,
|
|
74
|
+
getSegments: () => getSegments,
|
|
75
|
+
getSeoWeight: () => getSeoWeight,
|
|
76
|
+
getSession: () => getSession,
|
|
77
|
+
getSessionToken: () => getSessionToken,
|
|
78
|
+
getSiteMapIndex: () => getSiteMapIndex,
|
|
79
|
+
getSiteMapIndexProps: () => getSiteMapIndexProps,
|
|
80
|
+
getSiteMapXML: () => getSiteMapXML,
|
|
81
|
+
getSiteMapXMLProps: () => getSiteMapXMLProps,
|
|
82
|
+
getSiteMapXSL: () => getSiteMapXSL,
|
|
83
|
+
getSiteMapXSLProps: () => getSiteMapXSLProps,
|
|
84
|
+
getStaticPathsForSchema: () => getStaticPathsForSchema,
|
|
85
|
+
getStaticPathsForSchemaAndFallback: () => getStaticPathsForSchemaAndFallback,
|
|
86
|
+
getUtmz: () => getUtmz,
|
|
87
|
+
newRouteLink: () => newRouteLink,
|
|
88
|
+
pushDataLayer: () => pushDataLayer,
|
|
89
|
+
redirectTo: () => redirectTo,
|
|
90
|
+
resolveHref: () => resolveHref,
|
|
91
|
+
resolveLabel: () => resolveLabel,
|
|
92
|
+
resolveRoute: () => resolveRoute,
|
|
93
|
+
routeAutoDetection: () => routeAutoDetection,
|
|
94
|
+
routeInterceptor: () => routeInterceptor,
|
|
95
|
+
routeRevalidateHandler: () => routeRevalidateHandler,
|
|
96
|
+
routeToRouteLink: () => routeToRouteLink,
|
|
97
|
+
withLazyProps: () => withLazyProps
|
|
98
|
+
});
|
|
99
|
+
module.exports = __toCommonJS(src_exports);
|
|
100
|
+
|
|
101
|
+
// src/country/country.service.ts
|
|
102
|
+
var import_bom_mixer_store = require("@websolutespa/bom-mixer-store");
|
|
103
|
+
async function getCountries(locale) {
|
|
104
|
+
const store = await (0, import_bom_mixer_store.getStore)();
|
|
105
|
+
const items = await store.i18n_country.findMany({ locale });
|
|
106
|
+
return items;
|
|
107
|
+
}
|
|
108
|
+
async function getCountry(id, params = {}) {
|
|
109
|
+
const store = await (0, import_bom_mixer_store.getStore)();
|
|
110
|
+
const item = await store.i18n_country.findOne(id, params);
|
|
111
|
+
return item;
|
|
112
|
+
}
|
|
113
|
+
async function getCountriesPagination(params = {}) {
|
|
114
|
+
const store = await (0, import_bom_mixer_store.getStore)();
|
|
115
|
+
const pagination = await store.i18n_country.findPaged(params);
|
|
116
|
+
return pagination;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/province/province.service.ts
|
|
120
|
+
var import_bom_mixer_store2 = require("@websolutespa/bom-mixer-store");
|
|
121
|
+
async function getProvinces(locale) {
|
|
122
|
+
const store = await (0, import_bom_mixer_store2.getStore)();
|
|
123
|
+
const items = await store.i18n_province.findMany({ locale });
|
|
124
|
+
return items;
|
|
125
|
+
}
|
|
126
|
+
async function getProvince(id, params = {}) {
|
|
127
|
+
const store = await (0, import_bom_mixer_store2.getStore)();
|
|
128
|
+
const item = await store.i18n_province.findOne(id, params);
|
|
129
|
+
return item;
|
|
130
|
+
}
|
|
131
|
+
async function getProvincesPagination(params = {}) {
|
|
132
|
+
const store = await (0, import_bom_mixer_store2.getStore)();
|
|
133
|
+
const pagination = await store.i18n_province.findPaged(params);
|
|
134
|
+
return pagination;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/region/region.service.ts
|
|
138
|
+
var import_bom_mixer_store3 = require("@websolutespa/bom-mixer-store");
|
|
139
|
+
async function getRegions(locale) {
|
|
140
|
+
const store = await (0, import_bom_mixer_store3.getStore)();
|
|
141
|
+
const items = await store.i18n_region.findMany({ locale });
|
|
142
|
+
return items;
|
|
143
|
+
}
|
|
144
|
+
async function getRegion(id, params = {}) {
|
|
145
|
+
const store = await (0, import_bom_mixer_store3.getStore)();
|
|
146
|
+
const item = await store.i18n_region.findOne(id, params);
|
|
147
|
+
return item;
|
|
148
|
+
}
|
|
149
|
+
async function getRegionsPagination(params = {}) {
|
|
150
|
+
const store = await (0, import_bom_mixer_store3.getStore)();
|
|
151
|
+
const pagination = await store.i18n_region.findPaged(params);
|
|
152
|
+
return pagination;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/address/address.service.ts
|
|
156
|
+
async function getAddressOptions(locale) {
|
|
157
|
+
const countries = await getCountries(locale);
|
|
158
|
+
const provinces = await getProvinces(locale);
|
|
159
|
+
const regions = await getRegions(locale);
|
|
160
|
+
return {
|
|
161
|
+
countries,
|
|
162
|
+
regions,
|
|
163
|
+
provinces
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/captions/captions.handler.ts
|
|
168
|
+
var getCaptionsVttProps = async (context) => {
|
|
169
|
+
const { req, res, params, query } = context;
|
|
170
|
+
const locale = query?.locale;
|
|
171
|
+
const title = query?.title;
|
|
172
|
+
const captions = (
|
|
173
|
+
/* html */
|
|
174
|
+
`WEBVTT
|
|
175
|
+
|
|
176
|
+
00:00:01.000 --> 00:00:03.000
|
|
177
|
+
- This video has no audio.
|
|
178
|
+
|
|
179
|
+
${title ? `
|
|
180
|
+
00:00:04.000 --> 00:00:06.000
|
|
181
|
+
- The title of the video is "${title}".
|
|
182
|
+
` : ""}`
|
|
183
|
+
);
|
|
184
|
+
res.setHeader("Content-Type", "text/plain; charset=UTF-8");
|
|
185
|
+
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
186
|
+
res.setHeader("X-Robots-Tag", "noindex, follow");
|
|
187
|
+
res.write(captions);
|
|
188
|
+
res.end();
|
|
189
|
+
return {
|
|
190
|
+
props: {}
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// src/category/category.service.ts
|
|
195
|
+
var import_bom_core = require("@websolutespa/bom-core");
|
|
196
|
+
var import_bom_mixer_store4 = require("@websolutespa/bom-mixer-store");
|
|
197
|
+
async function getCategories(params = {}) {
|
|
198
|
+
const store = await (0, import_bom_mixer_store4.getStore)();
|
|
199
|
+
const categories = await store.category.findMany(params);
|
|
200
|
+
return categories;
|
|
201
|
+
}
|
|
202
|
+
async function getCategory(id, params = {}) {
|
|
203
|
+
const store = await (0, import_bom_mixer_store4.getStore)();
|
|
204
|
+
const item = await store.category.findOne(id, params);
|
|
205
|
+
return item;
|
|
206
|
+
}
|
|
207
|
+
async function getSegments(item, params = {}) {
|
|
208
|
+
const categories = await getCategories(params);
|
|
209
|
+
return (0, import_bom_core.getCategorySegments)(categories, item);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/consent_preference/consent_preference.service.ts
|
|
213
|
+
var import_bom_mixer_store5 = require("@websolutespa/bom-mixer-store");
|
|
214
|
+
async function getConsentPreference(id, params = {}) {
|
|
215
|
+
const store = await (0, import_bom_mixer_store5.getStore)();
|
|
216
|
+
const item = await store.consent_preference.findOne(id, params);
|
|
217
|
+
return item;
|
|
218
|
+
}
|
|
219
|
+
async function getConsentPreferences(params = {}) {
|
|
220
|
+
const store = await (0, import_bom_mixer_store5.getStore)();
|
|
221
|
+
const items = await store.consent_preference.findMany(params);
|
|
222
|
+
return items;
|
|
223
|
+
}
|
|
224
|
+
async function getConsentPreferencesPagination(params = {}) {
|
|
225
|
+
const store = await (0, import_bom_mixer_store5.getStore)();
|
|
226
|
+
const pagination = await store.consent_preference.findPaged(params);
|
|
227
|
+
return pagination;
|
|
228
|
+
}
|
|
4
229
|
|
|
5
|
-
|
|
230
|
+
// src/gtm/gtm.service.ts
|
|
231
|
+
var import_bom_core2 = require("@websolutespa/bom-core");
|
|
6
232
|
function pushDataLayer(record) {
|
|
7
|
-
|
|
233
|
+
if (import_bom_core2.isBrowser) {
|
|
234
|
+
window.dataLayer?.push(record);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/label/label.service.ts
|
|
239
|
+
var import_bom_mixer_store6 = require("@websolutespa/bom-mixer-store");
|
|
240
|
+
async function getLabels(params = {}) {
|
|
241
|
+
const store = await (0, import_bom_mixer_store6.getStore)();
|
|
242
|
+
const items = await store.label.findMany(params);
|
|
243
|
+
return items;
|
|
244
|
+
}
|
|
245
|
+
async function getLabel(id, params = {}) {
|
|
246
|
+
const store = await (0, import_bom_mixer_store6.getStore)();
|
|
247
|
+
const item = await store.label.findOne(id, params);
|
|
248
|
+
return item;
|
|
249
|
+
}
|
|
250
|
+
function resolveLabel(labels, id) {
|
|
251
|
+
const label = labels.find((x) => x.id === id);
|
|
252
|
+
return label && label.text ? label.text.toString() : id;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/app/app.service.ts
|
|
256
|
+
var import_bom_mixer_store7 = require("@websolutespa/bom-mixer-store");
|
|
257
|
+
async function getApp(params = {}) {
|
|
258
|
+
const store = await (0, import_bom_mixer_store7.getStore)();
|
|
259
|
+
const item = await store.app.findGlobal(params);
|
|
260
|
+
return item;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// src/locale/locale.service.ts
|
|
264
|
+
var import_bom_mixer_store8 = require("@websolutespa/bom-mixer-store");
|
|
265
|
+
async function getLocales(params = {}) {
|
|
266
|
+
const store = await (0, import_bom_mixer_store8.getStore)();
|
|
267
|
+
const items = await store.locale.findMany(params);
|
|
268
|
+
return items;
|
|
269
|
+
}
|
|
270
|
+
async function getLocale(id, params = {}) {
|
|
271
|
+
const store = await (0, import_bom_mixer_store8.getStore)();
|
|
272
|
+
const item = await store.locale.findOne(id, params);
|
|
273
|
+
return item;
|
|
274
|
+
}
|
|
275
|
+
function getLocaleFromProps(props) {
|
|
276
|
+
return props?.__NEXT_DATA__?.query?.locale;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// src/market/market.service.ts
|
|
280
|
+
var import_bom_mixer_store9 = require("@websolutespa/bom-mixer-store");
|
|
281
|
+
async function getMarkets(params = {}) {
|
|
282
|
+
const store = await (0, import_bom_mixer_store9.getStore)();
|
|
283
|
+
const items = await store.market.findMany(params);
|
|
284
|
+
return items;
|
|
285
|
+
}
|
|
286
|
+
async function getMarket(id, params = {}) {
|
|
287
|
+
const store = await (0, import_bom_mixer_store9.getStore)();
|
|
288
|
+
const item = await store.market.findOne(id, params);
|
|
289
|
+
return item;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/menu/menu.service.ts
|
|
293
|
+
var import_bom_mixer_store10 = require("@websolutespa/bom-mixer-store");
|
|
294
|
+
async function getMenus(params = {}) {
|
|
295
|
+
const store = await (0, import_bom_mixer_store10.getStore)();
|
|
296
|
+
const items = await store.menu.findMany(params);
|
|
297
|
+
return items;
|
|
298
|
+
}
|
|
299
|
+
async function getMenu(id, params = {}) {
|
|
300
|
+
const store = await (0, import_bom_mixer_store10.getStore)();
|
|
301
|
+
const item = await store.menu.findOne(id, params);
|
|
302
|
+
return item;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/route/route.service.ts
|
|
306
|
+
var import_bom_core3 = require("@websolutespa/bom-core");
|
|
307
|
+
var import_bom_mixer_store11 = require("@websolutespa/bom-mixer-store");
|
|
308
|
+
async function getRoutes(params = {}) {
|
|
309
|
+
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
310
|
+
const routes = await store.route.findMany(params);
|
|
311
|
+
return routes;
|
|
312
|
+
}
|
|
313
|
+
async function getRoute(id) {
|
|
314
|
+
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
315
|
+
const route = await store.route.findOne(id);
|
|
316
|
+
return route;
|
|
317
|
+
}
|
|
318
|
+
async function getRoutesForSchemas(schemas, market, locale) {
|
|
319
|
+
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
320
|
+
const routes = await store.route.findMany({
|
|
321
|
+
where: {
|
|
322
|
+
schema: {
|
|
323
|
+
in: schemas
|
|
324
|
+
},
|
|
325
|
+
market: {
|
|
326
|
+
equals: market
|
|
327
|
+
},
|
|
328
|
+
locale: {
|
|
329
|
+
equals: locale
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
const items = {};
|
|
334
|
+
routes.forEach((route) => {
|
|
335
|
+
items[route.schema] = route.id;
|
|
336
|
+
});
|
|
337
|
+
return items;
|
|
338
|
+
}
|
|
339
|
+
async function getRoutesForTemplates(templates, market, locale) {
|
|
340
|
+
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
341
|
+
const routes = await store.route.findMany({
|
|
342
|
+
where: {
|
|
343
|
+
template: {
|
|
344
|
+
in: templates
|
|
345
|
+
},
|
|
346
|
+
market: {
|
|
347
|
+
equals: market
|
|
348
|
+
},
|
|
349
|
+
locale: {
|
|
350
|
+
equals: locale
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
const items = {};
|
|
355
|
+
routes.forEach((route) => {
|
|
356
|
+
if (route.template) {
|
|
357
|
+
items[route.template] = route.id;
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
return items;
|
|
361
|
+
}
|
|
362
|
+
async function getStaticPathsForSchema(schema, template) {
|
|
363
|
+
if (import_bom_mixer_store11.buildStrategy === import_bom_mixer_store11.BuildStrategy.Runtime) {
|
|
364
|
+
return [];
|
|
365
|
+
}
|
|
366
|
+
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
367
|
+
const routes = await store.route.findMany({
|
|
368
|
+
where: template ? {
|
|
369
|
+
and: [{
|
|
370
|
+
template: {
|
|
371
|
+
equals: template
|
|
372
|
+
}
|
|
373
|
+
}, {
|
|
374
|
+
schema: {
|
|
375
|
+
equals: schema
|
|
376
|
+
}
|
|
377
|
+
}]
|
|
378
|
+
} : {
|
|
379
|
+
schema: {
|
|
380
|
+
equals: schema
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
return routes.map((x) => ({ params: { id: x.page.toString(), market: x.market, locale: x.locale } }));
|
|
385
|
+
}
|
|
386
|
+
async function getStaticPathsForSchemaAndFallback(schema, fallback = "blocking", template) {
|
|
387
|
+
if (import_bom_mixer_store11.buildStrategy === import_bom_mixer_store11.BuildStrategy.Runtime || fallback === "blocking" && import_bom_mixer_store11.storeStrategy !== import_bom_mixer_store11.StoreStrategy.Mock) {
|
|
388
|
+
return { paths: [], fallback };
|
|
389
|
+
}
|
|
390
|
+
const paths = await getStaticPathsForSchema(schema, template);
|
|
391
|
+
return {
|
|
392
|
+
paths,
|
|
393
|
+
fallback
|
|
394
|
+
// fallback: 'blocking', // runs before initial render
|
|
395
|
+
// fallback: true, // runs in the background
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
async function getBreadcrumbFromSegments(segments, route) {
|
|
399
|
+
const market = route.market || import_bom_core3.defaultMarket;
|
|
400
|
+
const locale = route.locale || import_bom_core3.defaultLocale;
|
|
401
|
+
const routes = await getRoutes({
|
|
402
|
+
where: {
|
|
403
|
+
market: {
|
|
404
|
+
equals: market
|
|
405
|
+
},
|
|
406
|
+
locale: {
|
|
407
|
+
equals: locale
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
const tree = segments.map((segment) => {
|
|
412
|
+
const route2 = (0, import_bom_core3.findRouteOfCategory)(routes, segment.id);
|
|
413
|
+
return {
|
|
414
|
+
segment,
|
|
415
|
+
route: route2
|
|
416
|
+
};
|
|
417
|
+
}).filter((x) => Boolean(x.route)).map((x) => {
|
|
418
|
+
const category = x.segment;
|
|
419
|
+
const route2 = x.route;
|
|
420
|
+
const routeLink = newRouteLink(category, route2, locale);
|
|
421
|
+
return routeLink;
|
|
422
|
+
});
|
|
423
|
+
if (!route.isDefault) {
|
|
424
|
+
tree.push(routeToRouteLink(route));
|
|
425
|
+
}
|
|
426
|
+
return tree;
|
|
427
|
+
}
|
|
428
|
+
async function getRouteLinkTree(market, locale) {
|
|
429
|
+
const store = await (0, import_bom_mixer_store11.getStore)();
|
|
430
|
+
const routes = await store.route.findMany({
|
|
431
|
+
where: {
|
|
432
|
+
market: {
|
|
433
|
+
equals: market
|
|
434
|
+
},
|
|
435
|
+
locale: {
|
|
436
|
+
equals: locale
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
const categories = await store.category.findMany({ market, locale });
|
|
441
|
+
const rootCategory = (0, import_bom_core3.getRootCategory)(categories);
|
|
442
|
+
if (rootCategory) {
|
|
443
|
+
const root = getRouteLinkCategory(locale, routes, categories, rootCategory, rootCategory);
|
|
444
|
+
return root;
|
|
445
|
+
}
|
|
446
|
+
return void 0;
|
|
447
|
+
}
|
|
448
|
+
function getRouteLinkCategory(locale, routes, categories, rootCategory, category) {
|
|
449
|
+
const route = (0, import_bom_core3.findRouteOfCategory)(routes, category.id);
|
|
450
|
+
const otherCategories = categories.filter((x) => x.id !== category.id);
|
|
451
|
+
const childCategories = otherCategories.filter((x) => (0, import_bom_core3.asCategoryId)(x.category) === category.id);
|
|
452
|
+
const routeLink = newRouteLink(category, route, locale);
|
|
453
|
+
const items = [];
|
|
454
|
+
for (const childCategory of childCategories) {
|
|
455
|
+
const itemOrItems = getRouteLinkCategory(locale, routes, otherCategories, rootCategory, childCategory);
|
|
456
|
+
if (Array.isArray(itemOrItems)) {
|
|
457
|
+
items.push(...itemOrItems);
|
|
458
|
+
} else if (itemOrItems) {
|
|
459
|
+
items.push(itemOrItems);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (!route || category.isHidden && category.id !== rootCategory.id) {
|
|
463
|
+
return items;
|
|
464
|
+
}
|
|
465
|
+
routeLink.items = items;
|
|
466
|
+
return routeLink;
|
|
467
|
+
}
|
|
468
|
+
function newRouteLink(category, route, locale) {
|
|
469
|
+
const href = route && route.id ? route.id.toString() : "/";
|
|
470
|
+
const id = route?.page || category.id;
|
|
471
|
+
const media = category.media || route?.media;
|
|
472
|
+
const schema = route?.template || route?.schema || category?.schema || "unknown";
|
|
473
|
+
const title = (0, import_bom_core3.localize)(category.title || route?.title || "untitled", locale);
|
|
474
|
+
const routeLink = {
|
|
475
|
+
category: category.id,
|
|
476
|
+
href,
|
|
477
|
+
id,
|
|
478
|
+
items: [],
|
|
479
|
+
media,
|
|
480
|
+
schema,
|
|
481
|
+
title
|
|
482
|
+
};
|
|
483
|
+
return routeLink;
|
|
484
|
+
}
|
|
485
|
+
function routeToRouteLink(route) {
|
|
486
|
+
const routeLink = {
|
|
487
|
+
category: (0, import_bom_core3.asCategoryId)(route.category),
|
|
488
|
+
href: route.id,
|
|
489
|
+
id: route.page,
|
|
490
|
+
items: [],
|
|
491
|
+
media: route.media,
|
|
492
|
+
schema: route.schema,
|
|
493
|
+
title: route.title
|
|
494
|
+
};
|
|
495
|
+
return routeLink;
|
|
496
|
+
}
|
|
497
|
+
function resolveRoute(route) {
|
|
498
|
+
const routepath = route.template || route.schema;
|
|
499
|
+
const resolvedPathname = `/${route.market}/${route.locale}/${routepath}/${route.page}${route.splat || ""}`;
|
|
500
|
+
return resolvedPathname;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/layout/layout.service.ts
|
|
504
|
+
async function getLayout(market, locale) {
|
|
505
|
+
const markets = await getMarkets({ locale });
|
|
506
|
+
const locales = await getLocales({ locale });
|
|
507
|
+
const labels = await getLabels({ locale });
|
|
508
|
+
const app = await getApp({ locale }) || {};
|
|
509
|
+
const tree = await getRouteLinkTree(market, locale);
|
|
510
|
+
const firstLevelRoutes = tree?.items || [];
|
|
511
|
+
const flatTopLevelRoutes = tree ? [tree, ...firstLevelRoutes] : [];
|
|
512
|
+
const topLevelRoutes = flatTopLevelRoutes.reduce((object, routeLink) => {
|
|
513
|
+
if (!object[routeLink.schema] || routeLink.schema === routeLink.category) {
|
|
514
|
+
object[routeLink.schema] = routeLink;
|
|
515
|
+
}
|
|
516
|
+
return object;
|
|
517
|
+
}, {});
|
|
518
|
+
const topLevelHrefs = flatTopLevelRoutes.reduce((object, routeLink) => {
|
|
519
|
+
if (routeLink.href && (!object[routeLink.schema] || routeLink.schema === routeLink.category)) {
|
|
520
|
+
object[routeLink.schema] = routeLink.href;
|
|
521
|
+
}
|
|
522
|
+
return object;
|
|
523
|
+
}, {});
|
|
524
|
+
const menu = {};
|
|
525
|
+
const menus = await getMenus({ market, locale });
|
|
526
|
+
menus.forEach((x) => {
|
|
527
|
+
menu[x.id] = x;
|
|
528
|
+
});
|
|
529
|
+
return {
|
|
530
|
+
labels,
|
|
531
|
+
locale,
|
|
532
|
+
locales,
|
|
533
|
+
market,
|
|
534
|
+
markets,
|
|
535
|
+
app,
|
|
536
|
+
menu,
|
|
537
|
+
topLevelHrefs,
|
|
538
|
+
topLevelRoutes,
|
|
539
|
+
tree
|
|
540
|
+
};
|
|
8
541
|
}
|
|
9
542
|
|
|
10
|
-
|
|
11
|
-
|
|
543
|
+
// src/lazy/lazy.ts
|
|
544
|
+
var LAZY_PROPS = {};
|
|
545
|
+
function withLazyProps(key, getComponentProps) {
|
|
546
|
+
LAZY_PROPS[key] = getComponentProps;
|
|
547
|
+
}
|
|
548
|
+
async function getDecoratedComponents(props, extraComponents) {
|
|
549
|
+
const page = props.page;
|
|
550
|
+
const components = [
|
|
551
|
+
...page.components || [],
|
|
552
|
+
...extraComponents || []
|
|
553
|
+
];
|
|
554
|
+
const decoratedComponents = [];
|
|
555
|
+
for (const component of components) {
|
|
556
|
+
const key = component.blockType || component.schema || "unkown_type";
|
|
557
|
+
const getComponentProps = LAZY_PROPS[key];
|
|
558
|
+
if (typeof getComponentProps === "function") {
|
|
559
|
+
const decoratedComponent = await getComponentProps({ ...props, component });
|
|
560
|
+
decoratedComponents.push(decoratedComponent);
|
|
561
|
+
} else {
|
|
562
|
+
decoratedComponents.push(component);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
page.components = decoratedComponents;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// src/link/link.service.ts
|
|
12
569
|
function getLink_(category, routeLink) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
570
|
+
if (routeLink) {
|
|
571
|
+
if (routeLink.category === category) {
|
|
572
|
+
return routeLink.href;
|
|
573
|
+
}
|
|
574
|
+
if (routeLink.items) {
|
|
575
|
+
return routeLink.items.reduce((p, c) => {
|
|
576
|
+
return getLink_(category, c) || p;
|
|
577
|
+
}, void 0);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return void 0;
|
|
20
581
|
}
|
|
21
582
|
function getLink(category, layout) {
|
|
22
|
-
|
|
583
|
+
return getLink_(category, layout.tree);
|
|
23
584
|
}
|
|
24
585
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
586
|
+
// src/page/page.service.ts
|
|
587
|
+
var import_bom_core4 = require("@websolutespa/bom-core");
|
|
588
|
+
var import_bom_mixer_store12 = require("@websolutespa/bom-mixer-store");
|
|
589
|
+
async function findOnePage(schema, id, params) {
|
|
590
|
+
const store = await (0, import_bom_mixer_store12.getStore)();
|
|
591
|
+
const collection = store[schema];
|
|
592
|
+
if (!collection) {
|
|
593
|
+
throw `PageService.findOnePage: Collection not found [${schema}]`;
|
|
594
|
+
}
|
|
595
|
+
const page = await collection.findOne(id, params);
|
|
596
|
+
if (page) {
|
|
597
|
+
return page;
|
|
598
|
+
} else {
|
|
599
|
+
console.log("PageService.findOnePage.notfound", schema, params);
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
async function findManyPages(schema, params) {
|
|
604
|
+
const store = await (0, import_bom_mixer_store12.getStore)();
|
|
605
|
+
const collection = store[schema];
|
|
606
|
+
if (!collection) {
|
|
607
|
+
throw `PageService.findManyPages: Collection not found [${schema}]`;
|
|
608
|
+
}
|
|
609
|
+
const pages = await collection.findMany(params);
|
|
610
|
+
return pages;
|
|
611
|
+
}
|
|
612
|
+
async function getPage(schema, id, market, locale, options) {
|
|
613
|
+
const { depth = 3, draftMode = false, previewData } = options || {};
|
|
614
|
+
const draft = draftMode === true;
|
|
615
|
+
const page = await findOnePage(schema, id, { market, locale, depth, draft });
|
|
616
|
+
if (page) {
|
|
617
|
+
const routes = await getPageRoutes(schema, id);
|
|
618
|
+
const currentRoute = routes.find((x) => x.market === market && x.locale === locale);
|
|
619
|
+
const alternates = routes;
|
|
620
|
+
const segments = await getSegments(page, { market, locale });
|
|
621
|
+
const breadcrumb = currentRoute ? await getBreadcrumbFromSegments(segments, currentRoute) : [];
|
|
622
|
+
const parentRoute = breadcrumb.length > 1 ? breadcrumb[breadcrumb.length - 2] : void 0;
|
|
623
|
+
const pageResult = {
|
|
624
|
+
...page,
|
|
625
|
+
href: currentRoute?.id,
|
|
626
|
+
// !!! route?
|
|
627
|
+
alternates,
|
|
628
|
+
breadcrumb,
|
|
629
|
+
parentRoute
|
|
630
|
+
};
|
|
631
|
+
return pageResult;
|
|
632
|
+
} else {
|
|
633
|
+
console.log("PageService.getPage.notfound", schema, id, locale);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
async function NotFound(market, locale) {
|
|
638
|
+
const routes = await getRoutes({
|
|
639
|
+
where: {
|
|
640
|
+
market: {
|
|
641
|
+
equals: market
|
|
642
|
+
},
|
|
643
|
+
locale: {
|
|
644
|
+
equals: locale
|
|
645
|
+
},
|
|
646
|
+
schema: {
|
|
647
|
+
equals: "notfound"
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
if (routes.length > 0) {
|
|
652
|
+
return {
|
|
653
|
+
redirect: {
|
|
654
|
+
destination: routes[0].id,
|
|
655
|
+
permanent: false
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
async function getPageRoutes(schema, id) {
|
|
662
|
+
const store = await (0, import_bom_mixer_store12.getStore)();
|
|
663
|
+
let routes = [];
|
|
664
|
+
try {
|
|
665
|
+
routes = await store.route.findMany({
|
|
666
|
+
where: {
|
|
667
|
+
page: {
|
|
668
|
+
equals: id
|
|
669
|
+
},
|
|
670
|
+
schema: {
|
|
671
|
+
equals: schema
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
} catch (error) {
|
|
676
|
+
console.error("No routes found for page " + schema + ":" + id);
|
|
677
|
+
}
|
|
678
|
+
return routes;
|
|
679
|
+
}
|
|
680
|
+
async function getPageCategory(schema, page, market, locale) {
|
|
681
|
+
if (!page) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
const store = await (0, import_bom_mixer_store12.getStore)();
|
|
685
|
+
const pages = await findManyPages(schema, {
|
|
686
|
+
where: {
|
|
687
|
+
category: {
|
|
688
|
+
equals: (0, import_bom_core4.asCategoryId)(page.category)
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
market,
|
|
692
|
+
locale
|
|
693
|
+
});
|
|
694
|
+
const category = pages.length ? pages[0] : null;
|
|
695
|
+
if (category) {
|
|
696
|
+
const routes = await store.route.findMany({
|
|
697
|
+
where: {
|
|
698
|
+
schema: {
|
|
699
|
+
equals: schema
|
|
700
|
+
},
|
|
701
|
+
page: {
|
|
702
|
+
equals: category.id
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
const currentRoute = routes.find((x) => x.market === market && x.locale === locale);
|
|
707
|
+
if (!currentRoute) {
|
|
708
|
+
throw "No route found for page " + schema + ":" + category.id + " in market " + market + " and locale " + locale;
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
...category,
|
|
712
|
+
href: currentRoute.id
|
|
713
|
+
};
|
|
714
|
+
} else {
|
|
715
|
+
console.log("PageService.getPageCategory.notfound", schema, locale);
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
async function getErrorPageLayout() {
|
|
720
|
+
const layout = await getLayout(import_bom_core4.defaultMarket, import_bom_core4.defaultLocale);
|
|
721
|
+
const title = resolveLabel(layout.labels, "notfound.title");
|
|
722
|
+
const abstract = resolveLabel(layout.labels, "notfound.abstract");
|
|
723
|
+
const category = layout.tree ? {
|
|
724
|
+
id: layout.tree.category,
|
|
725
|
+
title: layout.tree.title,
|
|
726
|
+
href: layout.tree.href,
|
|
727
|
+
slug: ""
|
|
728
|
+
} : {
|
|
729
|
+
id: "homepage",
|
|
730
|
+
title: "Homepage",
|
|
731
|
+
slug: "",
|
|
732
|
+
href: "/"
|
|
733
|
+
};
|
|
734
|
+
const page = {
|
|
735
|
+
abstract,
|
|
736
|
+
alternates: [],
|
|
737
|
+
breadcrumb: [],
|
|
738
|
+
category,
|
|
739
|
+
slug: "",
|
|
740
|
+
href: "",
|
|
741
|
+
id: "notfound",
|
|
742
|
+
locale: layout.locale,
|
|
743
|
+
market: layout.market,
|
|
744
|
+
markets: [],
|
|
745
|
+
meta: {
|
|
746
|
+
title,
|
|
747
|
+
description: abstract,
|
|
748
|
+
keywords: "",
|
|
749
|
+
robots: "all"
|
|
750
|
+
},
|
|
751
|
+
schema: "notfound",
|
|
752
|
+
title
|
|
753
|
+
};
|
|
754
|
+
return { layout, page };
|
|
755
|
+
}
|
|
756
|
+
async function getPageProps(props, extraComponents) {
|
|
757
|
+
if (props.page) {
|
|
758
|
+
await getDecoratedComponents(props, extraComponents);
|
|
759
|
+
}
|
|
760
|
+
return (0, import_bom_core4.asServerProps)(props);
|
|
761
|
+
}
|
|
762
|
+
function getPublicUrl() {
|
|
763
|
+
const publicUrl = process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
|
|
764
|
+
return publicUrl;
|
|
765
|
+
}
|
|
766
|
+
function resolveHref(href) {
|
|
767
|
+
href = href || "";
|
|
768
|
+
return href.startsWith("http") ? href : `${getPublicUrl()}${href}`;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// src/redirect/redirect.service.ts
|
|
772
|
+
var import_bom_mixer_store13 = require("@websolutespa/bom-mixer-store");
|
|
773
|
+
async function getRedirects(locale) {
|
|
774
|
+
const store = await (0, import_bom_mixer_store13.getStore)();
|
|
775
|
+
const items = await store.redirect.findMany({ locale });
|
|
776
|
+
return items;
|
|
777
|
+
}
|
|
778
|
+
async function getRedirect(id, params = {}) {
|
|
779
|
+
const store = await (0, import_bom_mixer_store13.getStore)();
|
|
780
|
+
const item = await store.redirect.findOne(id, params);
|
|
781
|
+
return item;
|
|
782
|
+
}
|
|
783
|
+
async function getRedirectsPagination(params = {}) {
|
|
784
|
+
const store = await (0, import_bom_mixer_store13.getStore)();
|
|
785
|
+
const pagination = await store.redirect.findPaged(params);
|
|
786
|
+
return pagination;
|
|
787
|
+
}
|
|
788
|
+
function redirectTo(layout, key = "not_found") {
|
|
789
|
+
return {
|
|
790
|
+
redirect: {
|
|
791
|
+
permanent: false,
|
|
792
|
+
destination: layout.topLevelHrefs[key] || "/"
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// src/route/route-revalidate.handler.ts
|
|
798
|
+
var import_bom_mixer_store14 = require("@websolutespa/bom-mixer-store");
|
|
799
|
+
function routeRevalidateHandler() {
|
|
800
|
+
return (0, import_bom_mixer_store14.apiHandler)({
|
|
801
|
+
post: async (request, response) => {
|
|
802
|
+
const authorization = request.headers.authorization;
|
|
803
|
+
const bearer = authorization && authorization.replace("Bearer ", "");
|
|
804
|
+
if (bearer !== process.env.HOOKS_SECRET) {
|
|
805
|
+
return response.status(401).json({ message: "Invalid token" });
|
|
806
|
+
}
|
|
807
|
+
try {
|
|
808
|
+
const { href } = request.body;
|
|
809
|
+
const routes = await getRoutes({
|
|
810
|
+
where: {
|
|
811
|
+
id: { equals: href }
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
if (routes.length === 0) {
|
|
815
|
+
return response.status(404).send(`routeRevalidateHandler.notFound ${href}`);
|
|
816
|
+
}
|
|
817
|
+
for (const route of routes) {
|
|
818
|
+
const resolvedRoute = resolveRoute(route);
|
|
819
|
+
console.log("route.revalidating", resolvedRoute);
|
|
820
|
+
await response.revalidate(resolvedRoute);
|
|
821
|
+
}
|
|
822
|
+
return response.json({ revalidated: true });
|
|
823
|
+
} catch (error) {
|
|
824
|
+
return response.status(500).send("Error revalidating");
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
});
|
|
29
828
|
}
|
|
30
829
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
830
|
+
// src/route/route.interceptor.ts
|
|
831
|
+
var import_bom_core5 = require("@websolutespa/bom-core");
|
|
832
|
+
var import_bom_mixer_store15 = require("@websolutespa/bom-mixer-store");
|
|
833
|
+
var import_server = require("next/server");
|
|
834
|
+
async function detectLocale(request, defaultLocale4) {
|
|
835
|
+
const acceptLanguage = request.headers.get("accept-language")?.split(",")[0];
|
|
836
|
+
const detectedLocale = request.cookies.get("NEXT_LOCALE")?.value || acceptLanguage || defaultLocale4 || process.env.DEFAULT_LOCALE;
|
|
837
|
+
return detectedLocale;
|
|
838
|
+
}
|
|
839
|
+
async function detectCountry(request, defaultMarket4) {
|
|
840
|
+
const ip = request.ip || request.headers.get("X-Forwarded-For") || request.headers.get("x-real-ip");
|
|
841
|
+
const isValidIp = ip?.match(/^(\d+?)\.(\d+?)\.(\d+?)\.(\d+?)$/);
|
|
842
|
+
let detectedCountry = "";
|
|
843
|
+
try {
|
|
844
|
+
const token = process.env.IPINFO_TOKEN;
|
|
845
|
+
if (token) {
|
|
846
|
+
const url = isValidIp ? `https://api.ipinfo.io/lite/${ip}/country_code?token=${token}` : `https://api.ipinfo.io/lite/me/country_code?token=${token}`;
|
|
847
|
+
const response = await fetch(url);
|
|
848
|
+
if (response.ok) {
|
|
849
|
+
const data = await response.text();
|
|
850
|
+
detectedCountry = data.toLowerCase();
|
|
851
|
+
}
|
|
852
|
+
} else {
|
|
853
|
+
const url = `https://geoip.websolute.it/Ip2Location/get_info.aspx?ipaddress=${isValidIp ? ip : ""}`;
|
|
854
|
+
const response = await fetch(url);
|
|
855
|
+
if (response.ok) {
|
|
856
|
+
const xml = await response.text();
|
|
857
|
+
detectedCountry = ((xml.split("<CountryCode><![CDATA[")[1] || "").split("]]></CountryCode>")[0] || "").replace("-", "").toLowerCase();
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
return detectedCountry || defaultMarket4 || process.env.DEFAULT_MARKET;
|
|
861
|
+
} catch (error) {
|
|
862
|
+
console.log("routeInterceptor.detectCountry.error", error);
|
|
863
|
+
}
|
|
864
|
+
return defaultMarket4 || process.env.DEFAULT_MARKET;
|
|
865
|
+
}
|
|
866
|
+
async function getMarkets2() {
|
|
867
|
+
const apiGet = import_bom_mixer_store15.storeStrategy === import_bom_mixer_store15.StoreStrategy.DecoratedApi ? import_bom_mixer_store15.localApiGet : import_bom_mixer_store15.storeApiGet;
|
|
868
|
+
const markets = await apiGet("/market?pagination=false");
|
|
869
|
+
return markets;
|
|
870
|
+
}
|
|
871
|
+
async function getRootRoutes() {
|
|
872
|
+
const apiGet = import_bom_mixer_store15.storeStrategy === import_bom_mixer_store15.StoreStrategy.DecoratedApi ? import_bom_mixer_store15.localApiGet : import_bom_mixer_store15.storeApiGet;
|
|
873
|
+
const routes = await apiGet("/route?where[isRoot][equals]=true");
|
|
874
|
+
return routes;
|
|
875
|
+
}
|
|
876
|
+
async function routeAutoDetection(request, next) {
|
|
877
|
+
let route;
|
|
878
|
+
const url = request.nextUrl;
|
|
879
|
+
if (url.pathname === "/") {
|
|
880
|
+
const cookie = request.cookies.get("detectedRoute");
|
|
881
|
+
if (cookie?.value) {
|
|
882
|
+
return cookie.value;
|
|
883
|
+
}
|
|
884
|
+
const rootRoutes = await getRootRoutes();
|
|
885
|
+
const defaultRoute = rootRoutes.find((x) => x.id === "/");
|
|
886
|
+
if (defaultRoute) {
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
const markets = await getMarkets2();
|
|
890
|
+
const market = markets.find((x) => x.isDefault) || markets.find((x) => x.id === import_bom_core5.defaultMarket) || markets[0];
|
|
891
|
+
const detectedCountry = await detectCountry(request, market.id);
|
|
892
|
+
const detectedMarket = detectedCountry ? markets.filter((x) => Array.isArray(x.countries)).find((x) => {
|
|
893
|
+
const countries = (x.countries || []).map((x2) => typeof x2 === "string" ? x2 : x2.id);
|
|
894
|
+
return countries.includes(detectedCountry);
|
|
895
|
+
}) || markets.find((x) => !Array.isArray(x.countries)) : void 0;
|
|
896
|
+
let detectedMarketRoutes = rootRoutes.filter((x) => x.market === detectedMarket?.id);
|
|
897
|
+
if (detectedMarketRoutes.length === 0) {
|
|
898
|
+
detectedMarketRoutes = rootRoutes.filter((x) => x.market === market.id);
|
|
899
|
+
}
|
|
900
|
+
const defaultMarketLocale = market.defaultLanguage ? typeof market.defaultLanguage === "string" ? market.defaultLanguage : market.defaultLanguage.id : import_bom_core5.defaultLocale;
|
|
901
|
+
const detectedLocale = await detectLocale(request, defaultMarketLocale);
|
|
902
|
+
const detectedLocaleRoutes = detectedMarketRoutes.filter((x) => x.locale === detectedLocale);
|
|
903
|
+
const detectedRoute = detectedLocaleRoutes.length > 0 ? detectedLocaleRoutes[0] : detectedMarketRoutes.find((x) => {
|
|
904
|
+
const market2 = markets.find((m) => m.id === x.market);
|
|
905
|
+
const marketLocale = market2.defaultLanguage ? (0, import_bom_core5.asEquatable)(market2.defaultLanguage) : defaultMarketLocale;
|
|
906
|
+
return x.locale === marketLocale;
|
|
907
|
+
});
|
|
908
|
+
if (detectedRoute && detectedRoute.id !== url.pathname) {
|
|
909
|
+
console.log("routeInterceptor.routeAutoDetection", detectedLocale, detectedCountry, detectedRoute.id);
|
|
910
|
+
route = detectedRoute.id;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
return route;
|
|
914
|
+
}
|
|
915
|
+
async function routeInterceptor(request, next) {
|
|
916
|
+
let route;
|
|
917
|
+
let url = request.nextUrl;
|
|
918
|
+
const hrefBeforeRedirect = getHrefBeforeRedirect(request);
|
|
919
|
+
try {
|
|
920
|
+
const redirectUrl = await routeAutoDetection(request, next);
|
|
921
|
+
if (redirectUrl) {
|
|
922
|
+
const response2 = import_server.NextResponse.redirect(resolveHref(redirectUrl), import_bom_core5.isDevelopment ? 307 : 301);
|
|
923
|
+
response2.cookies.set({
|
|
924
|
+
expires: new Date(Date.now() + 1 * 24 * 60 * 60 * 1e3),
|
|
925
|
+
httpOnly: true,
|
|
926
|
+
name: "detectedRoute",
|
|
927
|
+
path: "/",
|
|
928
|
+
sameSite: "lax",
|
|
929
|
+
secure: true,
|
|
930
|
+
value: redirectUrl
|
|
931
|
+
});
|
|
932
|
+
return response2;
|
|
933
|
+
}
|
|
934
|
+
if (import_bom_mixer_store15.storeStrategy === import_bom_mixer_store15.StoreStrategy.DecoratedApi) {
|
|
935
|
+
route = await (0, import_bom_mixer_store15.localApiPost)("/route", { pathname: url.pathname, href: url.href, hrefBeforeRedirect });
|
|
936
|
+
} else {
|
|
937
|
+
route = await (0, import_bom_mixer_store15.storeApiPost)("/route", { pathname: url.pathname, href: url.href, hrefBeforeRedirect });
|
|
938
|
+
}
|
|
939
|
+
if (!route) {
|
|
940
|
+
console.log("routeInterceptor.route.notfound", url.pathname);
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
} catch (error) {
|
|
944
|
+
if (error.status >= 300 && error.status < 400) {
|
|
945
|
+
console.log("routeInterceptor.3xx", url.pathname, error.status, error.statusText);
|
|
946
|
+
try {
|
|
947
|
+
const { redirectUrl } = await error.json();
|
|
948
|
+
const response2 = import_server.NextResponse.redirect(redirectUrl, error.status);
|
|
949
|
+
return response2;
|
|
950
|
+
} catch (error2) {
|
|
951
|
+
const publicUrl = getPublicUrl();
|
|
952
|
+
console.log("routeInterceptor.3xx.error", `cannot parse response, redirecting to ${publicUrl}`);
|
|
953
|
+
const response2 = import_server.NextResponse.redirect(publicUrl, 307);
|
|
954
|
+
return response2;
|
|
955
|
+
}
|
|
956
|
+
} else if (error.status === 410) {
|
|
957
|
+
console.log("routeInterceptor.410", url.pathname, error.status, error.statusText);
|
|
958
|
+
url = request.nextUrl.clone();
|
|
959
|
+
url.pathname = `/${error.status}`;
|
|
960
|
+
const response2 = import_server.NextResponse.rewrite(url, {
|
|
961
|
+
status: error.status,
|
|
962
|
+
statusText: error.statusText,
|
|
963
|
+
request
|
|
964
|
+
});
|
|
965
|
+
return response2;
|
|
966
|
+
} else if (error.status >= 400 && error.status < 500) {
|
|
967
|
+
console.log("routeInterceptor.4xx", url.pathname, error.status, error.statusText);
|
|
968
|
+
const response2 = import_server.NextResponse.next({
|
|
969
|
+
status: error.status,
|
|
970
|
+
statusText: error.statusText,
|
|
971
|
+
request
|
|
972
|
+
});
|
|
973
|
+
return response2;
|
|
974
|
+
}
|
|
975
|
+
console.log("routeInterceptor.error", url.pathname, error.url, error.status, error.statusText || error);
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
url = request.nextUrl.clone();
|
|
979
|
+
const resolvedPathname = resolveRoute(route);
|
|
980
|
+
url.pathname = resolvedPathname;
|
|
981
|
+
const response = import_server.NextResponse.rewrite(url);
|
|
982
|
+
return response;
|
|
983
|
+
}
|
|
984
|
+
function getHrefBeforeRedirect(request) {
|
|
985
|
+
let hrefBeforeRedirect = null;
|
|
986
|
+
const urlBeforeRedirect = request.nextUrl.clone();
|
|
987
|
+
const host = (0, import_bom_core5.getHost)(request.headers);
|
|
988
|
+
if (host) {
|
|
989
|
+
urlBeforeRedirect.host = host;
|
|
990
|
+
urlBeforeRedirect.port = host.split(":")[1] || "";
|
|
991
|
+
hrefBeforeRedirect = urlBeforeRedirect.href;
|
|
992
|
+
}
|
|
993
|
+
return hrefBeforeRedirect;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// src/seo/seo.service.ts
|
|
997
|
+
var getSeoWeight = (index = 0, seoWeight) => {
|
|
998
|
+
const getter = (subIndex = 0) => {
|
|
999
|
+
const i = seoWeight ? parseInt(seoWeight.replace(/\D/g, "")) : index === 0 ? 1 : 2;
|
|
1000
|
+
return `h${Math.min(i + subIndex, 6)}`;
|
|
1001
|
+
};
|
|
1002
|
+
return getter;
|
|
39
1003
|
};
|
|
40
1004
|
|
|
41
|
-
|
|
42
|
-
|
|
1005
|
+
// src/session/session.service.ts
|
|
1006
|
+
var import_bom_core6 = require("@websolutespa/bom-core");
|
|
1007
|
+
var import_iron_session = require("iron-session");
|
|
1008
|
+
async function getSession(request, response) {
|
|
1009
|
+
const COOKIE_NAME = "websolutespa-next-js";
|
|
1010
|
+
const COOKIE_PASSWORD = process.env.SECRET_COOKIE_PASSWORD || "SECRET_COOKIE_PASSWORD_32_CHARS_LONG";
|
|
1011
|
+
const sessionOptions = {
|
|
1012
|
+
cookieName: COOKIE_NAME,
|
|
1013
|
+
// secure: true should be used in production (HTTPS) but can't be used in development (HTTP)
|
|
1014
|
+
cookieOptions: {
|
|
1015
|
+
secure: !import_bom_core6.isDevelopment
|
|
1016
|
+
},
|
|
1017
|
+
password: COOKIE_PASSWORD
|
|
1018
|
+
};
|
|
1019
|
+
const session = await (0, import_iron_session.getIronSession)(request, response, sessionOptions);
|
|
1020
|
+
return session;
|
|
1021
|
+
}
|
|
1022
|
+
async function getSessionToken(request, response) {
|
|
1023
|
+
const session = await getSession(request, response);
|
|
1024
|
+
if (session.token && session.exp && session.exp > Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3)) {
|
|
1025
|
+
return session.token;
|
|
1026
|
+
} else {
|
|
1027
|
+
session.token = void 0;
|
|
1028
|
+
session.exp = void 0;
|
|
1029
|
+
await session.save();
|
|
1030
|
+
session.destroy();
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// src/sitemap/sitemap.handler.ts
|
|
1036
|
+
var import_bom_core8 = require("@websolutespa/bom-core");
|
|
1037
|
+
|
|
1038
|
+
// src/sitemap/sitemap.service.ts
|
|
1039
|
+
var import_bom_core7 = require("@websolutespa/bom-core");
|
|
1040
|
+
async function getSiteMapIndex(origin) {
|
|
1041
|
+
let markets = await getMarkets();
|
|
1042
|
+
let locales = await getLocales();
|
|
1043
|
+
markets = markets.filter((x) => x.isActive !== false);
|
|
1044
|
+
locales = locales.filter((x) => x.isActive !== false);
|
|
1045
|
+
const routes = await getRoutes();
|
|
1046
|
+
const sitemaps = [];
|
|
1047
|
+
const getTime = (date) => {
|
|
1048
|
+
return typeof date !== "undefined" ? (typeof date === "string" ? new Date(date) : date).getTime() : 0;
|
|
1049
|
+
};
|
|
1050
|
+
(0, import_bom_core7.eachMarketLocale)(markets, locales, (market, locale, markets2, locales2) => {
|
|
1051
|
+
const sitemapRoutes = routes.filter((x) => x.market === market.id && x.locale === locale.id);
|
|
1052
|
+
sitemapRoutes.sort((a, b) => getTime(a.updatedAt) - getTime(b.updatedAt));
|
|
1053
|
+
sitemaps.push({
|
|
1054
|
+
id: `/${market.id}/${locale.id}/sitemap.xml`,
|
|
1055
|
+
updatedAt: sitemapRoutes.length > 0 ? sitemapRoutes[sitemapRoutes.length - 1].updatedAt : void 0
|
|
1056
|
+
});
|
|
1057
|
+
});
|
|
1058
|
+
return `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="${origin}/sitemap.xsl"?>
|
|
1059
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
1060
|
+
${sitemaps.map((sitemap) => `
|
|
1061
|
+
<sitemap>
|
|
1062
|
+
<loc>${escapeHtml(encodeURI(`${origin}${sitemap.id}`))}</loc>${sitemap.updatedAt ? `
|
|
1063
|
+
<lastmod>${escapeHtml(String(sitemap.updatedAt))}</lastmod>` : ""}
|
|
1064
|
+
</sitemap>
|
|
1065
|
+
`).join("")}
|
|
1066
|
+
</sitemapindex>`;
|
|
1067
|
+
}
|
|
1068
|
+
function getSiteMapXMLLastMod(canonical) {
|
|
1069
|
+
return canonical.updatedAt ? `
|
|
1070
|
+
<lastmod>${escapeHtml(String(canonical.updatedAt))}</lastmod>` : "";
|
|
1071
|
+
}
|
|
1072
|
+
function getSiteMapXMLImage(canonical) {
|
|
1073
|
+
return canonical.media ? `
|
|
1074
|
+
<image:image>
|
|
1075
|
+
<image:loc>${escapeHtml(encodeURI(`${canonical.media.src || canonical.media.url}`))}</image:loc>
|
|
1076
|
+
</image:image>` : "";
|
|
1077
|
+
}
|
|
1078
|
+
function getSiteMapXMLAlternates(origin, canonical) {
|
|
1079
|
+
return canonical.alternates.map((alternate) => `
|
|
1080
|
+
<xhtml:link href="${escapeHtml(encodeURI(`${origin}${alternate.id}`))}" hreflang="${alternate.locale}-${alternate.market}" rel="alternate" />`).join("");
|
|
1081
|
+
}
|
|
1082
|
+
function getSiteMapXMLUrl(origin, canonical) {
|
|
1083
|
+
return `
|
|
1084
|
+
<url>
|
|
1085
|
+
<loc>${escapeHtml(encodeURI(`${origin}${canonical.id}`))}</loc>${getSiteMapXMLLastMod(canonical)}${getSiteMapXMLAlternates(origin, canonical)}${getSiteMapXMLImage(canonical)}
|
|
1086
|
+
</url>`;
|
|
1087
|
+
}
|
|
1088
|
+
function escapeHtml(string) {
|
|
1089
|
+
const matchHtmlRegExp = /["'&<>]/;
|
|
1090
|
+
const str = "" + string;
|
|
1091
|
+
const match = matchHtmlRegExp.exec(str);
|
|
1092
|
+
if (!match) {
|
|
1093
|
+
return str;
|
|
1094
|
+
}
|
|
1095
|
+
let escape;
|
|
1096
|
+
let html = "";
|
|
1097
|
+
let index = 0;
|
|
1098
|
+
let lastIndex = 0;
|
|
1099
|
+
for (index = match.index; index < str.length; index++) {
|
|
1100
|
+
switch (str.charCodeAt(index)) {
|
|
1101
|
+
case 34:
|
|
1102
|
+
escape = """;
|
|
1103
|
+
break;
|
|
1104
|
+
case 38:
|
|
1105
|
+
escape = "&";
|
|
1106
|
+
break;
|
|
1107
|
+
case 39:
|
|
1108
|
+
escape = "'";
|
|
1109
|
+
break;
|
|
1110
|
+
case 60:
|
|
1111
|
+
escape = "<";
|
|
1112
|
+
break;
|
|
1113
|
+
case 62:
|
|
1114
|
+
escape = ">";
|
|
1115
|
+
break;
|
|
1116
|
+
default:
|
|
1117
|
+
continue;
|
|
1118
|
+
}
|
|
1119
|
+
if (lastIndex !== index) {
|
|
1120
|
+
html += str.substring(lastIndex, index);
|
|
1121
|
+
}
|
|
1122
|
+
lastIndex = index + 1;
|
|
1123
|
+
html += escape;
|
|
1124
|
+
}
|
|
1125
|
+
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
|
1126
|
+
}
|
|
1127
|
+
function getSiteMapXMLUrls(origin, canonicalRoutes) {
|
|
1128
|
+
return canonicalRoutes.map((canonicalRoute) => getSiteMapXMLUrl(origin, canonicalRoute)).join("");
|
|
1129
|
+
}
|
|
1130
|
+
async function getSiteMapXML(origin, marketId, localeId) {
|
|
1131
|
+
let markets = await getMarkets();
|
|
1132
|
+
let locales = await getLocales();
|
|
1133
|
+
markets = markets.filter((x) => x.isActive !== false);
|
|
1134
|
+
locales = locales.filter((x) => x.isActive !== false);
|
|
1135
|
+
const defaultMarket4 = markets.find((x) => marketId ? x.id === marketId : x.isDefault) || markets[0];
|
|
1136
|
+
const defaultLocale4 = locales.find((x) => localeId ? x.id === localeId : x.isDefault) || locales[0];
|
|
1137
|
+
const defaultMarketLocale = defaultMarket4 && defaultMarket4.defaultLanguage ? defaultMarket4.defaultLanguage : defaultLocale4.id;
|
|
1138
|
+
const routes = await getRoutes();
|
|
1139
|
+
const isCanonicalRoute = marketId && localeId ? (route) => {
|
|
1140
|
+
return route.noindex !== true && route.market === defaultMarket4.id && route.locale === defaultLocale4.id;
|
|
1141
|
+
} : (route) => {
|
|
1142
|
+
return route.noindex !== true && route.market === defaultMarket4.id && route.locale === defaultMarketLocale;
|
|
1143
|
+
};
|
|
1144
|
+
const getCanonicalAlternates = marketId && localeId ? (canonical) => {
|
|
1145
|
+
return [];
|
|
1146
|
+
} : (canonical) => {
|
|
1147
|
+
return routes.filter((alternate) => {
|
|
1148
|
+
return alternate !== canonical && alternate.schema === canonical.schema && alternate.page === canonical.page;
|
|
1149
|
+
});
|
|
1150
|
+
};
|
|
1151
|
+
const routeToRouteCanonical = (canonical) => {
|
|
1152
|
+
const alternates = getCanonicalAlternates(canonical);
|
|
1153
|
+
return { ...canonical, alternates };
|
|
1154
|
+
};
|
|
1155
|
+
const canonicalRoutes = routes.filter(isCanonicalRoute).map(routeToRouteCanonical);
|
|
1156
|
+
return `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="${origin}/sitemap.xsl"?>
|
|
1157
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
1158
|
+
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
1159
|
+
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
|
|
1160
|
+
${getSiteMapXMLUrls(origin, canonicalRoutes)}
|
|
1161
|
+
</urlset>
|
|
1162
|
+
`;
|
|
1163
|
+
}
|
|
1164
|
+
async function getSiteMapXSL(localeId) {
|
|
1165
|
+
let locales = await getLocales();
|
|
1166
|
+
locales = locales.filter((x) => x.isActive !== false);
|
|
1167
|
+
const defaultLocale4 = locales.find((x) => localeId ? x.id === localeId : x.isDefault) || locales[0];
|
|
1168
|
+
return (
|
|
1169
|
+
/* html */
|
|
1170
|
+
`<?xml version="1.0" encoding="UTF-8"?>
|
|
1171
|
+
<xsl:stylesheet version="2.0"
|
|
1172
|
+
xmlns:html="http://www.w3.org/TR/REC-html40"
|
|
1173
|
+
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
|
1174
|
+
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
1175
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
1176
|
+
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
|
1177
|
+
<xsl:template match="/">
|
|
1178
|
+
<html lang="${defaultLocale4.id}" xmlns="http://www.w3.org/1999/xhtml">
|
|
1179
|
+
<head>
|
|
1180
|
+
<title>XML Sitemap</title>
|
|
1181
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
1182
|
+
<style type="text/css">
|
|
1183
|
+
html {
|
|
1184
|
+
padding: 0;
|
|
1185
|
+
background: #09090A;
|
|
1186
|
+
color: #fefefe;
|
|
1187
|
+
}
|
|
1188
|
+
body {
|
|
1189
|
+
padding: 15px;
|
|
1190
|
+
font-family: Inter,-apple-system,'Helvetica Neue','Segoe UI',Roboto,Arial,'Noto Sans',sans-serif;
|
|
1191
|
+
font-size: 13px;
|
|
1192
|
+
background: #09090A;
|
|
1193
|
+
color: #fefefe;
|
|
1194
|
+
}
|
|
1195
|
+
.container {
|
|
1196
|
+
margin: 0 auto;
|
|
1197
|
+
max-width: 1280px;
|
|
1198
|
+
}
|
|
1199
|
+
a {
|
|
1200
|
+
color: #fefefe;
|
|
1201
|
+
text-decoration: none;
|
|
1202
|
+
}
|
|
1203
|
+
a:visited {
|
|
1204
|
+
color: #9e9e9e;
|
|
1205
|
+
}
|
|
1206
|
+
a:hover {
|
|
1207
|
+
text-decoration: underline;
|
|
1208
|
+
}
|
|
1209
|
+
table {
|
|
1210
|
+
width: 100%;
|
|
1211
|
+
margin: 10px 0;
|
|
1212
|
+
border: none;
|
|
1213
|
+
border-collapse: collapse;
|
|
1214
|
+
}
|
|
1215
|
+
td,
|
|
1216
|
+
th {
|
|
1217
|
+
text-align: left;
|
|
1218
|
+
font-size: 12px;
|
|
1219
|
+
padding: 3px;
|
|
1220
|
+
}
|
|
1221
|
+
th:not(:last-child),
|
|
1222
|
+
td:not(:last-child) {
|
|
1223
|
+
padding-right: 30px;
|
|
1224
|
+
}
|
|
1225
|
+
thead th {
|
|
1226
|
+
border-bottom: 1px solid #0e0e0f;
|
|
1227
|
+
}
|
|
1228
|
+
#sitemap tr:nth-child(odd) td {
|
|
1229
|
+
background-color: #0e0e0f;
|
|
1230
|
+
}
|
|
1231
|
+
#sitemap tbody tr:hover td {
|
|
1232
|
+
background-color: #1A1A1B;
|
|
1233
|
+
}
|
|
1234
|
+
#sitemap tbody tr:hover td,
|
|
1235
|
+
#sitemap tbody tr:hover td a {
|
|
1236
|
+
color: #fefefe;
|
|
1237
|
+
}
|
|
1238
|
+
.wysiwyg {
|
|
1239
|
+
margin: 0;
|
|
1240
|
+
padding: 0 0 10px 0;
|
|
1241
|
+
line-height: 1.2em;
|
|
1242
|
+
}
|
|
1243
|
+
.wysiwyg a {
|
|
1244
|
+
color: #00ea4e;
|
|
1245
|
+
font-weight: 600;
|
|
1246
|
+
}
|
|
1247
|
+
.wysiwyg a:visited {
|
|
1248
|
+
color: #00ea4e;
|
|
1249
|
+
}
|
|
1250
|
+
</style>
|
|
1251
|
+
</head>
|
|
1252
|
+
<body>
|
|
1253
|
+
<div class="container">
|
|
1254
|
+
<h1>XML Sitemap</h1>
|
|
1255
|
+
<p class="wysiwyg">
|
|
1256
|
+
This is an XML Sitemap meant for consumption by search engines, generated by <a href="https://github.com/websolutespa/bom" target="_blank" rel="noopener">Mixer</a>.
|
|
1257
|
+
</p>
|
|
1258
|
+
<p class="wysiwyg">
|
|
1259
|
+
You can find more information about XML sitemaps on <a href="https://sitemaps.org" target="_blank" rel="noopener">sitemaps.org</a>.
|
|
1260
|
+
</p>
|
|
1261
|
+
<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) > 0">
|
|
1262
|
+
<p class="wysiwyg">
|
|
1263
|
+
This sitemap index file contains <xsl:value-of select="count(sitemap:sitemapindex/sitemap:sitemap)"/> sitemaps.
|
|
1264
|
+
</p>
|
|
1265
|
+
<table id="sitemap" cellpadding="3">
|
|
1266
|
+
<thead>
|
|
1267
|
+
<tr>
|
|
1268
|
+
<th width="75%">Sitemap</th>
|
|
1269
|
+
<th width="25%" title="Last Modification Time">Updated At</th>
|
|
1270
|
+
</tr>
|
|
1271
|
+
</thead>
|
|
1272
|
+
<tbody>
|
|
1273
|
+
<xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap">
|
|
1274
|
+
<xsl:variable name="sitemapURL">
|
|
1275
|
+
<xsl:value-of select="sitemap:loc"/>
|
|
1276
|
+
</xsl:variable>
|
|
1277
|
+
<tr>
|
|
1278
|
+
<td>
|
|
1279
|
+
<a href="{$sitemapURL}"><xsl:value-of select="sitemap:loc"/></a>
|
|
1280
|
+
</td>
|
|
1281
|
+
<td>
|
|
1282
|
+
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)),concat(' ', substring(sitemap:lastmod,20,6)))"/>
|
|
1283
|
+
</td>
|
|
1284
|
+
</tr>
|
|
1285
|
+
</xsl:for-each>
|
|
1286
|
+
</tbody>
|
|
1287
|
+
</table>
|
|
1288
|
+
</xsl:if>
|
|
1289
|
+
<xsl:if test="count(sitemap:sitemapindex/sitemap:sitemap) < 1">
|
|
1290
|
+
<p class="wysiwyg">
|
|
1291
|
+
This sitemap contains <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> URLs.
|
|
1292
|
+
</p>
|
|
1293
|
+
<table id="sitemap" cellpadding="3">
|
|
1294
|
+
<thead>
|
|
1295
|
+
<tr>
|
|
1296
|
+
<th width="75%">URL</th>
|
|
1297
|
+
<th width="15%" title="Last Modification Time">Updated At</th>
|
|
1298
|
+
<th width="10%">Images</th>
|
|
1299
|
+
</tr>
|
|
1300
|
+
</thead>
|
|
1301
|
+
<tbody>
|
|
1302
|
+
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
|
|
1303
|
+
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
|
|
1304
|
+
<xsl:for-each select="sitemap:urlset/sitemap:url">
|
|
1305
|
+
<tr>
|
|
1306
|
+
<td>
|
|
1307
|
+
<xsl:variable name="itemURL">
|
|
1308
|
+
<xsl:value-of select="sitemap:loc"/>
|
|
1309
|
+
</xsl:variable>
|
|
1310
|
+
<a href="{$itemURL}">
|
|
1311
|
+
<xsl:value-of select="sitemap:loc"/>
|
|
1312
|
+
</a>
|
|
1313
|
+
</td>
|
|
1314
|
+
<td>
|
|
1315
|
+
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)),concat(' ', substring(sitemap:lastmod,20,6)))"/>
|
|
1316
|
+
</td>
|
|
1317
|
+
<td>
|
|
1318
|
+
<xsl:value-of select="count(image:image)"/>
|
|
1319
|
+
</td>
|
|
1320
|
+
</tr>
|
|
1321
|
+
</xsl:for-each>
|
|
1322
|
+
</tbody>
|
|
1323
|
+
</table>
|
|
1324
|
+
</xsl:if>
|
|
1325
|
+
</div>
|
|
1326
|
+
</body>
|
|
1327
|
+
</html>
|
|
1328
|
+
</xsl:template>
|
|
1329
|
+
</xsl:stylesheet>`
|
|
1330
|
+
);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
// src/sitemap/sitemap.handler.ts
|
|
1334
|
+
var getSiteMapIndexProps = async (context) => {
|
|
1335
|
+
const { req, res } = context;
|
|
1336
|
+
const sitemap = await getSiteMapIndex((0, import_bom_core8.getOrigin)(req.headers));
|
|
1337
|
+
res.setHeader("Content-Type", "application/xml; charset=UTF-8");
|
|
1338
|
+
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
1339
|
+
res.setHeader("X-Robots-Tag", "noindex, follow");
|
|
1340
|
+
res.write(sitemap);
|
|
1341
|
+
res.end();
|
|
1342
|
+
return {
|
|
1343
|
+
props: {}
|
|
1344
|
+
};
|
|
1345
|
+
};
|
|
1346
|
+
var getSiteMapXMLProps = async (context) => {
|
|
1347
|
+
const { req, res } = context;
|
|
1348
|
+
const params = context.params;
|
|
1349
|
+
const market = params?.market;
|
|
1350
|
+
const locale = params?.locale;
|
|
1351
|
+
const sitemap = await getSiteMapXML((0, import_bom_core8.getOrigin)(req.headers), market, locale);
|
|
1352
|
+
res.setHeader("Content-Type", "application/xml; charset=UTF-8");
|
|
1353
|
+
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
1354
|
+
res.setHeader("X-Robots-Tag", "noindex, follow");
|
|
1355
|
+
res.write(sitemap);
|
|
1356
|
+
res.end();
|
|
1357
|
+
return {
|
|
1358
|
+
props: {}
|
|
1359
|
+
};
|
|
1360
|
+
};
|
|
1361
|
+
var getSiteMapXSLProps = async (context) => {
|
|
1362
|
+
const { req, res } = context;
|
|
1363
|
+
const params = context.params;
|
|
1364
|
+
const market = params?.market;
|
|
1365
|
+
const locale = params?.locale;
|
|
1366
|
+
const sitemap = await getSiteMapXSL(locale);
|
|
1367
|
+
res.setHeader("Content-Type", "application/xml; charset=UTF-8");
|
|
1368
|
+
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
1369
|
+
res.setHeader("X-Robots-Tag", "noindex, follow");
|
|
1370
|
+
res.write(sitemap);
|
|
1371
|
+
res.end();
|
|
1372
|
+
return {
|
|
1373
|
+
props: {}
|
|
1374
|
+
};
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
// src/utmz/utmz.service.ts
|
|
43
1378
|
function getUtmz(request) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1379
|
+
let utmz = "N/A";
|
|
1380
|
+
if (typeof request.cookies.__utmz === "string") {
|
|
1381
|
+
utmz = request.cookies.__utmz;
|
|
1382
|
+
const i = utmz.indexOf("utmcsr");
|
|
1383
|
+
utmz = utmz.substring(i === -1 ? 0 : i);
|
|
1384
|
+
}
|
|
1385
|
+
return utmz;
|
|
1386
|
+
}
|
|
1387
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1388
|
+
0 && (module.exports = {
|
|
1389
|
+
LAZY_PROPS,
|
|
1390
|
+
NotFound,
|
|
1391
|
+
detectCountry,
|
|
1392
|
+
detectLocale,
|
|
1393
|
+
escapeHtml,
|
|
1394
|
+
findManyPages,
|
|
1395
|
+
findOnePage,
|
|
1396
|
+
getAddressOptions,
|
|
1397
|
+
getBreadcrumbFromSegments,
|
|
1398
|
+
getCaptionsVttProps,
|
|
1399
|
+
getCategories,
|
|
1400
|
+
getCategory,
|
|
1401
|
+
getConsentPreference,
|
|
1402
|
+
getConsentPreferences,
|
|
1403
|
+
getConsentPreferencesPagination,
|
|
1404
|
+
getCountries,
|
|
1405
|
+
getCountriesPagination,
|
|
1406
|
+
getCountry,
|
|
1407
|
+
getDecoratedComponents,
|
|
1408
|
+
getErrorPageLayout,
|
|
1409
|
+
getLabel,
|
|
1410
|
+
getLabels,
|
|
1411
|
+
getLayout,
|
|
1412
|
+
getLink,
|
|
1413
|
+
getLocale,
|
|
1414
|
+
getLocaleFromProps,
|
|
1415
|
+
getLocales,
|
|
1416
|
+
getMarket,
|
|
1417
|
+
getMarkets,
|
|
1418
|
+
getMenu,
|
|
1419
|
+
getMenus,
|
|
1420
|
+
getPage,
|
|
1421
|
+
getPageCategory,
|
|
1422
|
+
getPageProps,
|
|
1423
|
+
getPageRoutes,
|
|
1424
|
+
getProvince,
|
|
1425
|
+
getProvinces,
|
|
1426
|
+
getProvincesPagination,
|
|
1427
|
+
getPublicUrl,
|
|
1428
|
+
getRedirect,
|
|
1429
|
+
getRedirects,
|
|
1430
|
+
getRedirectsPagination,
|
|
1431
|
+
getRegion,
|
|
1432
|
+
getRegions,
|
|
1433
|
+
getRegionsPagination,
|
|
1434
|
+
getRoute,
|
|
1435
|
+
getRouteLinkCategory,
|
|
1436
|
+
getRouteLinkTree,
|
|
1437
|
+
getRoutes,
|
|
1438
|
+
getRoutesForSchemas,
|
|
1439
|
+
getRoutesForTemplates,
|
|
1440
|
+
getSegments,
|
|
1441
|
+
getSeoWeight,
|
|
1442
|
+
getSession,
|
|
1443
|
+
getSessionToken,
|
|
1444
|
+
getSiteMapIndex,
|
|
1445
|
+
getSiteMapIndexProps,
|
|
1446
|
+
getSiteMapXML,
|
|
1447
|
+
getSiteMapXMLProps,
|
|
1448
|
+
getSiteMapXSL,
|
|
1449
|
+
getSiteMapXSLProps,
|
|
1450
|
+
getStaticPathsForSchema,
|
|
1451
|
+
getStaticPathsForSchemaAndFallback,
|
|
1452
|
+
getUtmz,
|
|
1453
|
+
newRouteLink,
|
|
1454
|
+
pushDataLayer,
|
|
1455
|
+
redirectTo,
|
|
1456
|
+
resolveHref,
|
|
1457
|
+
resolveLabel,
|
|
1458
|
+
resolveRoute,
|
|
1459
|
+
routeAutoDetection,
|
|
1460
|
+
routeInterceptor,
|
|
1461
|
+
routeRevalidateHandler,
|
|
1462
|
+
routeToRouteLink,
|
|
1463
|
+
withLazyProps
|
|
1464
|
+
});
|