@websolutespa/bom-mixer-models 3.0.5 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/exports/proxy.d.ts +0 -2
- package/dist/exports/proxy.d.ts.map +1 -1
- package/dist/exports/proxy.js +25 -44
- package/dist/exports/proxy.js.map +1 -1
- package/dist/exports/server.d.ts +2 -24
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +96 -205
- package/dist/exports/server.js.map +1 -1
- package/dist/index.d.ts +12031 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -9
- package/dist/index.js.map +1 -1
- package/dist/{lazy-JamSYYoh.d.ts → lazy-CoUsrocX.d.ts} +2 -6
- package/dist/lazy-CoUsrocX.d.ts.map +1 -0
- package/dist/page-DUrzmLyV.js +11 -0
- package/dist/page-DUrzmLyV.js.map +1 -0
- package/dist/{route-k0W3AKyo.js → route-BV0T142s.js} +7 -11
- package/dist/route-BV0T142s.js.map +1 -0
- package/package.json +15 -14
- 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.map +0 -1
package/dist/exports/server.js
CHANGED
|
@@ -1,83 +1,56 @@
|
|
|
1
|
-
import { newRouteLink, resolveRoute
|
|
1
|
+
import { i as routeToRouteLink, n as newRouteLink, r as resolveRoute } from "../route-BV0T142s.js";
|
|
2
2
|
import { asCategoryId, asServerProps, defaultLocale, defaultMarket, eachMarketLocale, findRouteOfCategory, getCategorySegments, getOrigin, getRootCategory, isDevelopment } from "@websolutespa/bom-core";
|
|
3
|
-
import { BuildStrategy, StoreStrategy, buildStrategy, storeStrategy } from "@websolutespa/bom-mixer-store";
|
|
4
3
|
import { apiHandler, getStore } from "@websolutespa/bom-mixer-store/server";
|
|
4
|
+
import { BuildStrategy, StoreStrategy, buildStrategy, storeStrategy } from "@websolutespa/bom-mixer-store";
|
|
5
5
|
import { getIronSession } from "iron-session";
|
|
6
|
-
|
|
7
6
|
//#region src/country/country.service.ts
|
|
8
7
|
async function getCountries(locale) {
|
|
9
|
-
|
|
10
|
-
const items = await store.i18n_country.findMany({ locale });
|
|
11
|
-
return items;
|
|
8
|
+
return await (await getStore()).i18n_country.findMany({ locale });
|
|
12
9
|
}
|
|
13
10
|
async function getCountry(id, params = {}) {
|
|
14
|
-
|
|
15
|
-
const item = await store.i18n_country.findOne(id, params);
|
|
16
|
-
return item;
|
|
11
|
+
return await (await getStore()).i18n_country.findOne(id, params);
|
|
17
12
|
}
|
|
18
13
|
async function getCountriesPagination(params = {}) {
|
|
19
|
-
|
|
20
|
-
const pagination = await store.i18n_country.findPaged(params);
|
|
21
|
-
return pagination;
|
|
14
|
+
return await (await getStore()).i18n_country.findPaged(params);
|
|
22
15
|
}
|
|
23
|
-
|
|
24
16
|
//#endregion
|
|
25
17
|
//#region src/province/province.service.ts
|
|
26
18
|
async function getProvinces(locale) {
|
|
27
|
-
|
|
28
|
-
const items = await store.i18n_province.findMany({ locale });
|
|
29
|
-
return items;
|
|
19
|
+
return await (await getStore()).i18n_province.findMany({ locale });
|
|
30
20
|
}
|
|
31
21
|
async function getProvince(id, params = {}) {
|
|
32
|
-
|
|
33
|
-
const item = await store.i18n_province.findOne(id, params);
|
|
34
|
-
return item;
|
|
22
|
+
return await (await getStore()).i18n_province.findOne(id, params);
|
|
35
23
|
}
|
|
36
24
|
async function getProvincesPagination(params = {}) {
|
|
37
|
-
|
|
38
|
-
const pagination = await store.i18n_province.findPaged(params);
|
|
39
|
-
return pagination;
|
|
25
|
+
return await (await getStore()).i18n_province.findPaged(params);
|
|
40
26
|
}
|
|
41
|
-
|
|
42
27
|
//#endregion
|
|
43
28
|
//#region src/region/region.service.ts
|
|
44
29
|
async function getRegions(locale) {
|
|
45
|
-
|
|
46
|
-
const items = await store.i18n_region.findMany({ locale });
|
|
47
|
-
return items;
|
|
30
|
+
return await (await getStore()).i18n_region.findMany({ locale });
|
|
48
31
|
}
|
|
49
32
|
async function getRegion(id, params = {}) {
|
|
50
|
-
|
|
51
|
-
const item = await store.i18n_region.findOne(id, params);
|
|
52
|
-
return item;
|
|
33
|
+
return await (await getStore()).i18n_region.findOne(id, params);
|
|
53
34
|
}
|
|
54
35
|
async function getRegionsPagination(params = {}) {
|
|
55
|
-
|
|
56
|
-
const pagination = await store.i18n_region.findPaged(params);
|
|
57
|
-
return pagination;
|
|
36
|
+
return await (await getStore()).i18n_region.findPaged(params);
|
|
58
37
|
}
|
|
59
|
-
|
|
60
38
|
//#endregion
|
|
61
39
|
//#region src/address/address.service.ts
|
|
62
40
|
async function getAddressOptions(locale) {
|
|
63
41
|
const countries = await getCountries(locale);
|
|
64
42
|
const provinces = await getProvinces(locale);
|
|
65
|
-
const regions = await getRegions(locale);
|
|
66
43
|
return {
|
|
67
44
|
countries,
|
|
68
|
-
regions,
|
|
45
|
+
regions: await getRegions(locale),
|
|
69
46
|
provinces
|
|
70
47
|
};
|
|
71
48
|
}
|
|
72
|
-
|
|
73
49
|
//#endregion
|
|
74
50
|
//#region src/app/app.service.ts
|
|
75
51
|
async function getApp(params = {}) {
|
|
76
|
-
|
|
77
|
-
const item = await store.app.findGlobal(params);
|
|
78
|
-
return item;
|
|
52
|
+
return await (await getStore()).app.findGlobal(params);
|
|
79
53
|
}
|
|
80
|
-
|
|
81
54
|
//#endregion
|
|
82
55
|
//#region src/captions/captions.handler.ts
|
|
83
56
|
const getCaptionsVttProps = async (context) => {
|
|
@@ -100,113 +73,74 @@ ${title ? `
|
|
|
100
73
|
res.end();
|
|
101
74
|
return { props: {} };
|
|
102
75
|
};
|
|
103
|
-
|
|
104
76
|
//#endregion
|
|
105
77
|
//#region src/category/category.service.ts
|
|
106
78
|
async function getCategories(params = {}) {
|
|
107
|
-
|
|
108
|
-
const categories = await store.category.findMany(params);
|
|
109
|
-
return categories;
|
|
79
|
+
return await (await getStore()).category.findMany(params);
|
|
110
80
|
}
|
|
111
81
|
async function getCategory(id, params = {}) {
|
|
112
|
-
|
|
113
|
-
const item = await store.category.findOne(id, params);
|
|
114
|
-
return item;
|
|
82
|
+
return await (await getStore()).category.findOne(id, params);
|
|
115
83
|
}
|
|
116
84
|
async function getSegments(item, params = {}) {
|
|
117
|
-
|
|
118
|
-
return getCategorySegments(categories, item);
|
|
85
|
+
return getCategorySegments(await getCategories(params), item);
|
|
119
86
|
}
|
|
120
|
-
|
|
121
87
|
//#endregion
|
|
122
88
|
//#region src/consent_preference/consent_preference.service.ts
|
|
123
89
|
async function getConsentPreference(id, params = {}) {
|
|
124
|
-
|
|
125
|
-
const item = await store.consent_preference.findOne(id, params);
|
|
126
|
-
return item;
|
|
90
|
+
return await (await getStore()).consent_preference.findOne(id, params);
|
|
127
91
|
}
|
|
128
92
|
async function getConsentPreferences(params = {}) {
|
|
129
|
-
|
|
130
|
-
const items = await store.consent_preference.findMany(params);
|
|
131
|
-
return items;
|
|
93
|
+
return await (await getStore()).consent_preference.findMany(params);
|
|
132
94
|
}
|
|
133
95
|
async function getConsentPreferencesPagination(params = {}) {
|
|
134
|
-
|
|
135
|
-
const pagination = await store.consent_preference.findPaged(params);
|
|
136
|
-
return pagination;
|
|
96
|
+
return await (await getStore()).consent_preference.findPaged(params);
|
|
137
97
|
}
|
|
138
|
-
|
|
139
98
|
//#endregion
|
|
140
99
|
//#region src/label/label.service.ts
|
|
141
100
|
async function getLabels(params = {}) {
|
|
142
|
-
|
|
143
|
-
const items = await store.label.findMany(params);
|
|
144
|
-
return items;
|
|
101
|
+
return await (await getStore()).label.findMany(params);
|
|
145
102
|
}
|
|
146
103
|
async function getLabel(id, params = {}) {
|
|
147
|
-
|
|
148
|
-
const item = await store.label.findOne(id, params);
|
|
149
|
-
return item;
|
|
104
|
+
return await (await getStore()).label.findOne(id, params);
|
|
150
105
|
}
|
|
151
106
|
function resolveLabel(labels, id) {
|
|
152
107
|
const label = labels.find((x) => x.id === id);
|
|
153
108
|
return label && label.text ? label.text.toString() : id;
|
|
154
109
|
}
|
|
155
|
-
|
|
156
110
|
//#endregion
|
|
157
111
|
//#region src/locale/locale.service.ts
|
|
158
112
|
async function getLocales(params = {}) {
|
|
159
|
-
|
|
160
|
-
const items = await store.locale.findMany(params);
|
|
161
|
-
return items;
|
|
113
|
+
return await (await getStore()).locale.findMany(params);
|
|
162
114
|
}
|
|
163
115
|
async function getLocale(id, params = {}) {
|
|
164
|
-
|
|
165
|
-
const item = await store.locale.findOne(id, params);
|
|
166
|
-
return item;
|
|
116
|
+
return await (await getStore()).locale.findOne(id, params);
|
|
167
117
|
}
|
|
168
|
-
|
|
169
118
|
//#endregion
|
|
170
119
|
//#region src/market/market.service.ts
|
|
171
120
|
async function getMarkets(params = {}) {
|
|
172
|
-
|
|
173
|
-
const items = await store.market.findMany(params);
|
|
174
|
-
return items;
|
|
121
|
+
return await (await getStore()).market.findMany(params);
|
|
175
122
|
}
|
|
176
123
|
async function getMarket(id, params = {}) {
|
|
177
|
-
|
|
178
|
-
const item = await store.market.findOne(id, params);
|
|
179
|
-
return item;
|
|
124
|
+
return await (await getStore()).market.findOne(id, params);
|
|
180
125
|
}
|
|
181
|
-
|
|
182
126
|
//#endregion
|
|
183
127
|
//#region src/menu/menu.service.ts
|
|
184
128
|
async function getMenus(params = {}) {
|
|
185
|
-
|
|
186
|
-
const items = await store.menu.findMany(params);
|
|
187
|
-
return items;
|
|
129
|
+
return await (await getStore()).menu.findMany(params);
|
|
188
130
|
}
|
|
189
131
|
async function getMenu(id, params = {}) {
|
|
190
|
-
|
|
191
|
-
const item = await store.menu.findOne(id, params);
|
|
192
|
-
return item;
|
|
132
|
+
return await (await getStore()).menu.findOne(id, params);
|
|
193
133
|
}
|
|
194
|
-
|
|
195
134
|
//#endregion
|
|
196
135
|
//#region src/route/route.service.ts
|
|
197
136
|
async function getRoutes(params = {}) {
|
|
198
|
-
|
|
199
|
-
const routes = await store.route.findMany(params);
|
|
200
|
-
return routes;
|
|
137
|
+
return await (await getStore()).route.findMany(params);
|
|
201
138
|
}
|
|
202
139
|
async function getRoute(id) {
|
|
203
|
-
|
|
204
|
-
const route = await store.route.findOne(id);
|
|
205
|
-
return route;
|
|
140
|
+
return await (await getStore()).route.findOne(id);
|
|
206
141
|
}
|
|
207
142
|
async function getRoutesForSchemas(schemas, market, locale) {
|
|
208
|
-
const
|
|
209
|
-
const routes = await store.route.findMany({ where: {
|
|
143
|
+
const routes = await (await getStore()).route.findMany({ where: {
|
|
210
144
|
schema: { in: schemas },
|
|
211
145
|
market: { equals: market },
|
|
212
146
|
locale: { equals: locale }
|
|
@@ -218,8 +152,7 @@ async function getRoutesForSchemas(schemas, market, locale) {
|
|
|
218
152
|
return items;
|
|
219
153
|
}
|
|
220
154
|
async function getRoutesForTemplates(templates, market, locale) {
|
|
221
|
-
const
|
|
222
|
-
const routes = await store.route.findMany({ where: {
|
|
155
|
+
const routes = await (await getStore()).route.findMany({ where: {
|
|
223
156
|
template: { in: templates },
|
|
224
157
|
market: { equals: market },
|
|
225
158
|
locale: { equals: locale }
|
|
@@ -232,9 +165,7 @@ async function getRoutesForTemplates(templates, market, locale) {
|
|
|
232
165
|
}
|
|
233
166
|
async function getStaticPathsForSchema(schema, template) {
|
|
234
167
|
if (buildStrategy === BuildStrategy.Runtime) return [];
|
|
235
|
-
|
|
236
|
-
const routes = await store.route.findMany({ where: template ? { and: [{ template: { equals: template } }, { schema: { equals: schema } }] } : { schema: { equals: schema } } });
|
|
237
|
-
return routes.map((x) => ({ params: {
|
|
168
|
+
return (await (await getStore()).route.findMany({ where: template ? { and: [{ template: { equals: template } }, { schema: { equals: schema } }] } : { schema: { equals: schema } } })).map((x) => ({ params: {
|
|
238
169
|
id: x.page.toString(),
|
|
239
170
|
market: x.market,
|
|
240
171
|
locale: x.locale
|
|
@@ -245,9 +176,8 @@ async function getStaticPathsForSchemaAndFallback(schema, fallback = "blocking",
|
|
|
245
176
|
paths: [],
|
|
246
177
|
fallback
|
|
247
178
|
};
|
|
248
|
-
const paths = await getStaticPathsForSchema(schema, template);
|
|
249
179
|
return {
|
|
250
|
-
paths,
|
|
180
|
+
paths: await getStaticPathsForSchema(schema, template),
|
|
251
181
|
fallback
|
|
252
182
|
};
|
|
253
183
|
}
|
|
@@ -259,16 +189,14 @@ async function getBreadcrumbFromSegments(segments, route) {
|
|
|
259
189
|
locale: { equals: locale }
|
|
260
190
|
} });
|
|
261
191
|
const tree = segments.map((segment) => {
|
|
262
|
-
const route$1 = findRouteOfCategory(routes, segment.id);
|
|
263
192
|
return {
|
|
264
193
|
segment,
|
|
265
|
-
route:
|
|
194
|
+
route: findRouteOfCategory(routes, segment.id)
|
|
266
195
|
};
|
|
267
196
|
}).filter((x) => Boolean(x.route)).map((x) => {
|
|
268
197
|
const category = x.segment;
|
|
269
|
-
const route
|
|
270
|
-
|
|
271
|
-
return routeLink;
|
|
198
|
+
const route = x.route;
|
|
199
|
+
return newRouteLink(category, route, locale);
|
|
272
200
|
});
|
|
273
201
|
if (!route.isDefault) tree.push(routeToRouteLink(route));
|
|
274
202
|
return tree;
|
|
@@ -284,11 +212,7 @@ async function getRouteLinkTree(market, locale) {
|
|
|
284
212
|
locale
|
|
285
213
|
});
|
|
286
214
|
const rootCategory = getRootCategory(categories);
|
|
287
|
-
if (rootCategory)
|
|
288
|
-
const root = getRouteLinkCategory(locale, routes, categories, rootCategory, rootCategory);
|
|
289
|
-
return root;
|
|
290
|
-
}
|
|
291
|
-
return void 0;
|
|
215
|
+
if (rootCategory) return getRouteLinkCategory(locale, routes, categories, rootCategory, rootCategory);
|
|
292
216
|
}
|
|
293
217
|
function getRouteLinkCategory(locale, routes, categories, rootCategory, category) {
|
|
294
218
|
const route = findRouteOfCategory(routes, category.id);
|
|
@@ -305,7 +229,6 @@ function getRouteLinkCategory(locale, routes, categories, rootCategory, category
|
|
|
305
229
|
routeLink.items = items;
|
|
306
230
|
return routeLink;
|
|
307
231
|
}
|
|
308
|
-
|
|
309
232
|
//#endregion
|
|
310
233
|
//#region src/layout/layout.service.ts
|
|
311
234
|
async function getLayout(market, locale) {
|
|
@@ -325,11 +248,10 @@ async function getLayout(market, locale) {
|
|
|
325
248
|
return object;
|
|
326
249
|
}, {});
|
|
327
250
|
const menu = {};
|
|
328
|
-
|
|
251
|
+
(await getMenus({
|
|
329
252
|
market,
|
|
330
253
|
locale
|
|
331
|
-
})
|
|
332
|
-
menus.forEach((x) => {
|
|
254
|
+
})).forEach((x) => {
|
|
333
255
|
menu[x.id] = x;
|
|
334
256
|
});
|
|
335
257
|
return {
|
|
@@ -345,7 +267,6 @@ async function getLayout(market, locale) {
|
|
|
345
267
|
tree
|
|
346
268
|
};
|
|
347
269
|
}
|
|
348
|
-
|
|
349
270
|
//#endregion
|
|
350
271
|
//#region src/lazy/lazy.service.ts
|
|
351
272
|
const LAZY_PROPS = {};
|
|
@@ -357,8 +278,7 @@ async function getDecoratedComponents(props, extraComponents) {
|
|
|
357
278
|
const components = [...page.components || [], ...extraComponents || []];
|
|
358
279
|
const decoratedComponents = [];
|
|
359
280
|
for (const component of components) {
|
|
360
|
-
const
|
|
361
|
-
const getComponentProps = LAZY_PROPS[key];
|
|
281
|
+
const getComponentProps = LAZY_PROPS[component.blockType || component.schema || "unkown_type"];
|
|
362
282
|
if (typeof getComponentProps === "function") {
|
|
363
283
|
const decoratedComponent = await getComponentProps({
|
|
364
284
|
...props,
|
|
@@ -369,12 +289,10 @@ async function getDecoratedComponents(props, extraComponents) {
|
|
|
369
289
|
}
|
|
370
290
|
page.components = decoratedComponents;
|
|
371
291
|
}
|
|
372
|
-
|
|
373
292
|
//#endregion
|
|
374
293
|
//#region src/page/page.service.ts
|
|
375
294
|
async function findOnePage(schema, id, params) {
|
|
376
|
-
const
|
|
377
|
-
const collection = store[schema];
|
|
295
|
+
const collection = (await getStore())[schema];
|
|
378
296
|
if (!collection) throw `PageService.findOnePage: Collection not found [${schema}]`;
|
|
379
297
|
const page = await collection.findOne(id, params);
|
|
380
298
|
if (page) return page;
|
|
@@ -384,20 +302,17 @@ async function findOnePage(schema, id, params) {
|
|
|
384
302
|
}
|
|
385
303
|
}
|
|
386
304
|
async function findManyPages(schema, params) {
|
|
387
|
-
const
|
|
388
|
-
const collection = store[schema];
|
|
305
|
+
const collection = (await getStore())[schema];
|
|
389
306
|
if (!collection) throw `PageService.findManyPages: Collection not found [${schema}]`;
|
|
390
|
-
|
|
391
|
-
return pages;
|
|
307
|
+
return await collection.findMany(params);
|
|
392
308
|
}
|
|
393
309
|
async function getPage(schema, id, market, locale, options) {
|
|
394
310
|
const { depth = 3, draftMode = false, previewData } = options || {};
|
|
395
|
-
const draft = draftMode === true;
|
|
396
311
|
const page = await findOnePage(schema, id, {
|
|
397
312
|
market,
|
|
398
313
|
locale,
|
|
399
314
|
depth,
|
|
400
|
-
draft
|
|
315
|
+
draft: draftMode === true
|
|
401
316
|
});
|
|
402
317
|
if (page) {
|
|
403
318
|
const routes = await getPageRoutes(schema, id);
|
|
@@ -409,26 +324,24 @@ async function getPage(schema, id, market, locale, options) {
|
|
|
409
324
|
});
|
|
410
325
|
const breadcrumb = currentRoute ? await getBreadcrumbFromSegments(segments, currentRoute) : [];
|
|
411
326
|
const parentRoute = breadcrumb.length > 1 ? breadcrumb[breadcrumb.length - 2] : void 0;
|
|
412
|
-
|
|
327
|
+
return {
|
|
413
328
|
...page,
|
|
414
329
|
href: currentRoute?.id,
|
|
415
330
|
alternates,
|
|
416
331
|
breadcrumb,
|
|
417
332
|
parentRoute
|
|
418
333
|
};
|
|
419
|
-
return pageResult;
|
|
420
334
|
} else {
|
|
421
335
|
console.log("PageService.getPage.notfound", schema, id, locale);
|
|
422
336
|
return;
|
|
423
337
|
}
|
|
424
338
|
}
|
|
425
339
|
async function getSchemaRoutes(schema, market, locale) {
|
|
426
|
-
|
|
340
|
+
return await getRoutes({ where: {
|
|
427
341
|
market: { equals: market },
|
|
428
342
|
locale: { equals: locale },
|
|
429
343
|
schema: { equals: schema }
|
|
430
344
|
} });
|
|
431
|
-
return routes;
|
|
432
345
|
}
|
|
433
346
|
async function getNotFoundRoute(market, locale) {
|
|
434
347
|
const routes = await getRoutes({ where: {
|
|
@@ -472,11 +385,10 @@ async function getPageCategory(schema, page, market, locale) {
|
|
|
472
385
|
});
|
|
473
386
|
const category = pages.length ? pages[0] : null;
|
|
474
387
|
if (category) {
|
|
475
|
-
const
|
|
388
|
+
const currentRoute = (await store.route.findMany({ where: {
|
|
476
389
|
schema: { equals: schema },
|
|
477
390
|
page: { equals: category.id }
|
|
478
|
-
} });
|
|
479
|
-
const currentRoute = routes.find((x) => x.market === market && x.locale === locale);
|
|
391
|
+
} })).find((x) => x.market === market && x.locale === locale);
|
|
480
392
|
if (!currentRoute) throw "No route found for page " + schema + ":" + category.id + " in market " + market + " and locale " + locale;
|
|
481
393
|
return {
|
|
482
394
|
...category,
|
|
@@ -491,40 +403,38 @@ async function getErrorPageLayout() {
|
|
|
491
403
|
const layout = await getLayout(defaultMarket, defaultLocale);
|
|
492
404
|
const title = resolveLabel(layout.labels, "notfound.title");
|
|
493
405
|
const abstract = resolveLabel(layout.labels, "notfound.abstract");
|
|
494
|
-
const category = layout.tree ? {
|
|
495
|
-
id: layout.tree.category,
|
|
496
|
-
title: layout.tree.title,
|
|
497
|
-
href: layout.tree.href,
|
|
498
|
-
slug: ""
|
|
499
|
-
} : {
|
|
500
|
-
id: "homepage",
|
|
501
|
-
title: "Homepage",
|
|
502
|
-
slug: "",
|
|
503
|
-
href: "/"
|
|
504
|
-
};
|
|
505
|
-
const page = {
|
|
506
|
-
abstract,
|
|
507
|
-
alternates: [],
|
|
508
|
-
breadcrumb: [],
|
|
509
|
-
category,
|
|
510
|
-
slug: "",
|
|
511
|
-
href: "",
|
|
512
|
-
id: "notfound",
|
|
513
|
-
locale: layout.locale,
|
|
514
|
-
market: layout.market,
|
|
515
|
-
markets: [],
|
|
516
|
-
meta: {
|
|
517
|
-
title,
|
|
518
|
-
description: abstract,
|
|
519
|
-
keywords: "",
|
|
520
|
-
robots: "all"
|
|
521
|
-
},
|
|
522
|
-
schema: "notfound",
|
|
523
|
-
title
|
|
524
|
-
};
|
|
525
406
|
return {
|
|
526
407
|
layout,
|
|
527
|
-
page
|
|
408
|
+
page: {
|
|
409
|
+
abstract,
|
|
410
|
+
alternates: [],
|
|
411
|
+
breadcrumb: [],
|
|
412
|
+
category: layout.tree ? {
|
|
413
|
+
id: layout.tree.category,
|
|
414
|
+
title: layout.tree.title,
|
|
415
|
+
href: layout.tree.href,
|
|
416
|
+
slug: ""
|
|
417
|
+
} : {
|
|
418
|
+
id: "homepage",
|
|
419
|
+
title: "Homepage",
|
|
420
|
+
slug: "",
|
|
421
|
+
href: "/"
|
|
422
|
+
},
|
|
423
|
+
slug: "",
|
|
424
|
+
href: "",
|
|
425
|
+
id: "notfound",
|
|
426
|
+
locale: layout.locale,
|
|
427
|
+
market: layout.market,
|
|
428
|
+
markets: [],
|
|
429
|
+
meta: {
|
|
430
|
+
title,
|
|
431
|
+
description: abstract,
|
|
432
|
+
keywords: "",
|
|
433
|
+
robots: "all"
|
|
434
|
+
},
|
|
435
|
+
schema: "notfound",
|
|
436
|
+
title
|
|
437
|
+
}
|
|
528
438
|
};
|
|
529
439
|
}
|
|
530
440
|
async function getPageProps(props, extraComponents) {
|
|
@@ -532,29 +442,21 @@ async function getPageProps(props, extraComponents) {
|
|
|
532
442
|
return asServerProps(props);
|
|
533
443
|
}
|
|
534
444
|
function getPublicUrl() {
|
|
535
|
-
|
|
536
|
-
return publicUrl;
|
|
445
|
+
return process.env && process.env.NEXT_PUBLIC_URL ? process.env.NEXT_PUBLIC_URL : "";
|
|
537
446
|
}
|
|
538
447
|
function resolveHref(href = "") {
|
|
539
448
|
return href.startsWith("http") ? href : `${getPublicUrl()}${href}`;
|
|
540
449
|
}
|
|
541
|
-
|
|
542
450
|
//#endregion
|
|
543
451
|
//#region src/redirect/redirect.service.ts
|
|
544
452
|
async function getRedirects(locale) {
|
|
545
|
-
|
|
546
|
-
const items = await store.redirect.findMany({ locale });
|
|
547
|
-
return items;
|
|
453
|
+
return await (await getStore()).redirect.findMany({ locale });
|
|
548
454
|
}
|
|
549
455
|
async function getRedirect(id, params = {}) {
|
|
550
|
-
|
|
551
|
-
const item = await store.redirect.findOne(id, params);
|
|
552
|
-
return item;
|
|
456
|
+
return await (await getStore()).redirect.findOne(id, params);
|
|
553
457
|
}
|
|
554
458
|
async function getRedirectsPagination(params = {}) {
|
|
555
|
-
|
|
556
|
-
const pagination = await store.redirect.findPaged(params);
|
|
557
|
-
return pagination;
|
|
459
|
+
return await (await getStore()).redirect.findPaged(params);
|
|
558
460
|
}
|
|
559
461
|
function redirectTo(layout, key = "not_found") {
|
|
560
462
|
return { redirect: {
|
|
@@ -562,14 +464,12 @@ function redirectTo(layout, key = "not_found") {
|
|
|
562
464
|
destination: layout.topLevelHrefs[key] || "/"
|
|
563
465
|
} };
|
|
564
466
|
}
|
|
565
|
-
|
|
566
467
|
//#endregion
|
|
567
468
|
//#region src/route/route-revalidate.handler.ts
|
|
568
469
|
function routeRevalidateHandler() {
|
|
569
470
|
return apiHandler({ post: async (request, response) => {
|
|
570
471
|
const authorization = request.headers.authorization;
|
|
571
|
-
|
|
572
|
-
if (bearer !== process.env.MIXER_SECRET) return response.status(401).json({ message: "Invalid token" });
|
|
472
|
+
if ((authorization && authorization.replace("Bearer ", "")) !== process.env.MIXER_SECRET) return response.status(401).json({ message: "Invalid token" });
|
|
573
473
|
try {
|
|
574
474
|
const { href, schema, page } = request.body || {};
|
|
575
475
|
let where;
|
|
@@ -594,7 +494,6 @@ function routeRevalidateHandler() {
|
|
|
594
494
|
}
|
|
595
495
|
} });
|
|
596
496
|
}
|
|
597
|
-
|
|
598
497
|
//#endregion
|
|
599
498
|
//#region src/session/session.service.ts
|
|
600
499
|
function getSessionSecret() {
|
|
@@ -603,15 +502,11 @@ function getSessionSecret() {
|
|
|
603
502
|
return secret;
|
|
604
503
|
}
|
|
605
504
|
async function getSession(request, response) {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
cookieName,
|
|
610
|
-
password,
|
|
505
|
+
return await getIronSession(request, response, {
|
|
506
|
+
cookieName: "websolutespa-next-js",
|
|
507
|
+
password: getSessionSecret(),
|
|
611
508
|
cookieOptions: { secure: !isDevelopment }
|
|
612
|
-
};
|
|
613
|
-
const session = await getIronSession(request, response, sessionOptions);
|
|
614
|
-
return session;
|
|
509
|
+
});
|
|
615
510
|
}
|
|
616
511
|
async function getSessionToken(request, response) {
|
|
617
512
|
const session = await getSession(request, response);
|
|
@@ -624,7 +519,6 @@ async function getSessionToken(request, response) {
|
|
|
624
519
|
return;
|
|
625
520
|
}
|
|
626
521
|
}
|
|
627
|
-
|
|
628
522
|
//#endregion
|
|
629
523
|
//#region src/sitemap/sitemap.service.ts
|
|
630
524
|
async function getSiteMapIndex(origin) {
|
|
@@ -637,7 +531,7 @@ async function getSiteMapIndex(origin) {
|
|
|
637
531
|
const getTime = (date) => {
|
|
638
532
|
return typeof date !== "undefined" ? (typeof date === "string" ? new Date(date) : date).getTime() : 0;
|
|
639
533
|
};
|
|
640
|
-
eachMarketLocale(markets, locales, (market, locale, markets
|
|
534
|
+
eachMarketLocale(markets, locales, (market, locale, markets, locales) => {
|
|
641
535
|
const sitemapRoutes = routes.filter((x) => x.market === market.id && x.locale === locale.id);
|
|
642
536
|
sitemapRoutes.sort((a, b) => getTime(a.updatedAt) - getTime(b.updatedAt));
|
|
643
537
|
sitemaps.push({
|
|
@@ -717,14 +611,14 @@ async function getSiteMapXML(origin, marketId, localeId) {
|
|
|
717
611
|
let locales = await getLocales();
|
|
718
612
|
markets = markets.filter((x) => x.isActive !== false);
|
|
719
613
|
locales = locales.filter((x) => x.isActive !== false);
|
|
720
|
-
const defaultMarket
|
|
721
|
-
const defaultLocale
|
|
722
|
-
const defaultMarketLocale = defaultMarket
|
|
614
|
+
const defaultMarket = markets.find((x) => marketId ? x.id === marketId : x.isDefault) || markets[0];
|
|
615
|
+
const defaultLocale = locales.find((x) => localeId ? x.id === localeId : x.isDefault) || locales[0];
|
|
616
|
+
const defaultMarketLocale = defaultMarket && defaultMarket.defaultLanguage ? defaultMarket.defaultLanguage : defaultLocale.id;
|
|
723
617
|
const routes = await getRoutes();
|
|
724
618
|
const isCanonicalRoute = marketId && localeId ? (route) => {
|
|
725
|
-
return route.noindex !== true && route.market === defaultMarket
|
|
619
|
+
return route.noindex !== true && route.market === defaultMarket.id && route.locale === defaultLocale.id;
|
|
726
620
|
} : (route) => {
|
|
727
|
-
return route.noindex !== true && route.market === defaultMarket
|
|
621
|
+
return route.noindex !== true && route.market === defaultMarket.id && route.locale === defaultMarketLocale;
|
|
728
622
|
};
|
|
729
623
|
const getCanonicalAlternates = marketId && localeId ? (canonical) => {
|
|
730
624
|
return [];
|
|
@@ -740,19 +634,17 @@ async function getSiteMapXML(origin, marketId, localeId) {
|
|
|
740
634
|
alternates
|
|
741
635
|
};
|
|
742
636
|
};
|
|
743
|
-
const canonicalRoutes = routes.filter(isCanonicalRoute).map(routeToRouteCanonical);
|
|
744
637
|
return `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="${origin}/sitemap.xsl"?>
|
|
745
638
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
746
639
|
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
747
640
|
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
|
|
748
|
-
${getSiteMapXMLUrls(origin,
|
|
641
|
+
${getSiteMapXMLUrls(origin, routes.filter(isCanonicalRoute).map(routeToRouteCanonical))}
|
|
749
642
|
</urlset>
|
|
750
643
|
`;
|
|
751
644
|
}
|
|
752
645
|
async function getSiteMapXSL(localeId) {
|
|
753
646
|
let locales = await getLocales();
|
|
754
647
|
locales = locales.filter((x) => x.isActive !== false);
|
|
755
|
-
const locale = locales.find((x) => localeId ? x.id === localeId : x.isDefault) || locales[0];
|
|
756
648
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
757
649
|
<xsl:stylesheet version="2.0"
|
|
758
650
|
xmlns:html="http://www.w3.org/TR/REC-html40"
|
|
@@ -761,7 +653,7 @@ async function getSiteMapXSL(localeId) {
|
|
|
761
653
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
762
654
|
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
|
763
655
|
<xsl:template match="/">
|
|
764
|
-
<html lang="${
|
|
656
|
+
<html lang="${(locales.find((x) => localeId ? x.id === localeId : x.isDefault) || locales[0]).id}" xmlns="http://www.w3.org/1999/xhtml">
|
|
765
657
|
<head>
|
|
766
658
|
<title>XML Sitemap</title>
|
|
767
659
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
@@ -914,7 +806,6 @@ async function getSiteMapXSL(localeId) {
|
|
|
914
806
|
</xsl:template>
|
|
915
807
|
</xsl:stylesheet>`;
|
|
916
808
|
}
|
|
917
|
-
|
|
918
809
|
//#endregion
|
|
919
810
|
//#region src/sitemap/sitemap.handler.ts
|
|
920
811
|
const getSiteMapIndexProps = async (context) => {
|
|
@@ -953,7 +844,7 @@ const getSiteMapXSLProps = async (context) => {
|
|
|
953
844
|
res.end();
|
|
954
845
|
return { props: {} };
|
|
955
846
|
};
|
|
956
|
-
|
|
957
847
|
//#endregion
|
|
958
848
|
export { LAZY_PROPS, NotFound, escapeHtml, findManyPages, findOnePage, getAddressOptions, getApp, getBreadcrumbFromSegments, getCaptionsVttProps, getCategories, getCategory, getConsentPreference, getConsentPreferences, getConsentPreferencesPagination, getCountries, getCountriesPagination, getCountry, getDecoratedComponents, getErrorPageLayout, getLabel, getLabels, getLayout, getLocale, getLocales, getMarket, getMarkets, getMenu, getMenus, getNotFoundRoute, getPage, getPageCategory, getPageProps, getPageRoutes, getProvince, getProvinces, getProvincesPagination, getPublicUrl, getRedirect, getRedirects, getRedirectsPagination, getRegion, getRegions, getRegionsPagination, getRoute, getRouteLinkCategory, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSchemaRoutes, getSegments, getSession, getSessionToken, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStaticPathsForSchemaAndFallback, redirectTo, resolveHref, resolveLabel, routeRevalidateHandler, withLazyProps };
|
|
849
|
+
|
|
959
850
|
//# sourceMappingURL=server.js.map
|