@websolutespa/bom-mixer-models 1.0.1 → 1.2.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 +13 -0
- package/dist/index.d.ts +249 -240
- package/dist/index.js +19 -16
- package/dist/index.mjs +20 -17
- package/package.json +6 -6
- package/src/application/application.ts +10 -0
- package/src/checkout/checkout.service.ts +2 -2
- package/src/checkout/checkout.ts +4 -0
- package/src/index.ts +1 -0
- package/src/page/page.service.ts +1 -4
- package/src/route/route.interceptor.ts +2 -12
- package/src/route/route.service.ts +11 -12
- package/src/sitemap/sitemap.handler.ts +15 -5
- package/src/sitemap/sitemap.service.ts +8 -10
- package/src/store/store.ts +1 -3
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,300 +1,309 @@
|
|
|
1
|
-
import { ISchema, IEquatable, IMedia, QueryParams, ICategory, ICategorized, IOption, INamedEntity, ILabel,
|
|
1
|
+
import { ILayout, IPage, IRouteParams, ISchema, IEquatable, IMedia, QueryParams, ICategory, ICategorized, IOption, INamedEntity, ILabel, ILocale, IMarket, IMenu, ValueOf, IPageResult, IRoute, IRouteLink, IQuerable, IRedirect, IEntity } from '@websolutespa/bom-core';
|
|
2
|
+
import { AppProps } from 'next/app';
|
|
2
3
|
import { ComponentType, ComponentProps } from 'react';
|
|
3
4
|
import { HtmlProps } from 'next/dist/shared/lib/html-context';
|
|
4
5
|
import { RenderPageResult } from 'next/dist/shared/lib/utils';
|
|
5
6
|
import { NextRequest, NextFetchEvent, NextResponse } from 'next/server';
|
|
6
7
|
import { GetServerSideProps } from 'next';
|
|
7
8
|
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
type IApplicationProps = Record<string, any> & {
|
|
10
|
+
layout: ILayout;
|
|
11
|
+
page: IPage;
|
|
12
|
+
params: IRouteParams;
|
|
13
|
+
};
|
|
14
|
+
type IApplication = AppProps<IApplicationProps>;
|
|
15
|
+
|
|
16
|
+
type ICartItem = ISchema & {
|
|
17
|
+
id: IEquatable;
|
|
18
|
+
schema: string;
|
|
19
|
+
media: IMedia;
|
|
20
|
+
title: string;
|
|
21
|
+
abstract?: string;
|
|
22
|
+
href: string;
|
|
23
|
+
price: number;
|
|
24
|
+
qty: number;
|
|
25
|
+
};
|
|
18
26
|
type ICartAddItem = Omit<ICartItem, 'qty'>;
|
|
19
27
|
|
|
20
|
-
declare function getCategories(params?: QueryParams): Promise<ICategory[]>;
|
|
21
|
-
declare function getCategory(id: IEquatable, params?: QueryParams): Promise<ICategory | undefined>;
|
|
28
|
+
declare function getCategories(params?: QueryParams): Promise<ICategory[]>;
|
|
29
|
+
declare function getCategory(id: IEquatable, params?: QueryParams): Promise<ICategory | undefined>;
|
|
22
30
|
declare function getSegments(item: ICategorized, params?: QueryParams): Promise<ICategory[]>;
|
|
23
31
|
|
|
24
|
-
type IUserLogin = {
|
|
25
|
-
email: string;
|
|
26
|
-
password: string;
|
|
27
|
-
rememberMe: boolean;
|
|
28
|
-
};
|
|
29
|
-
type IUserRegister = {
|
|
30
|
-
firstName: string;
|
|
31
|
-
lastName: string;
|
|
32
|
-
email: string;
|
|
33
|
-
password: string;
|
|
34
|
-
confirmPassword: string;
|
|
35
|
-
privacy: boolean;
|
|
36
|
-
};
|
|
37
|
-
type IUserForgot = {
|
|
38
|
-
email: string;
|
|
39
|
-
};
|
|
40
|
-
type IUserChangePassword = {
|
|
41
|
-
oldPassword: string;
|
|
42
|
-
newPassword: string;
|
|
43
|
-
confirmNewPassword: string;
|
|
44
|
-
};
|
|
45
|
-
type IUser = ISchema & {
|
|
46
|
-
id: IEquatable;
|
|
47
|
-
firstName: string;
|
|
48
|
-
lastName: string;
|
|
49
|
-
email: string;
|
|
50
|
-
};
|
|
51
|
-
type IAddress = {
|
|
52
|
-
name: string;
|
|
53
|
-
firstName: string;
|
|
54
|
-
lastName: string;
|
|
55
|
-
address: string;
|
|
56
|
-
streetNumber: string;
|
|
57
|
-
zipCode: string;
|
|
58
|
-
city: string;
|
|
59
|
-
country: IOption;
|
|
60
|
-
region?: IOption;
|
|
61
|
-
province?: IOption;
|
|
62
|
-
email: string;
|
|
63
|
-
phoneNumber: string;
|
|
64
|
-
};
|
|
65
|
-
type IAddressOptions = {
|
|
66
|
-
countries: IOption[];
|
|
67
|
-
regions: IOption[];
|
|
68
|
-
provinces: IOption[];
|
|
69
|
-
};
|
|
70
|
-
type IUserAddress = Omit<IAddress, 'name'>;
|
|
32
|
+
type IUserLogin = {
|
|
33
|
+
email: string;
|
|
34
|
+
password: string;
|
|
35
|
+
rememberMe: boolean;
|
|
36
|
+
};
|
|
37
|
+
type IUserRegister = {
|
|
38
|
+
firstName: string;
|
|
39
|
+
lastName: string;
|
|
40
|
+
email: string;
|
|
41
|
+
password: string;
|
|
42
|
+
confirmPassword: string;
|
|
43
|
+
privacy: boolean;
|
|
44
|
+
};
|
|
45
|
+
type IUserForgot = {
|
|
46
|
+
email: string;
|
|
47
|
+
};
|
|
48
|
+
type IUserChangePassword = {
|
|
49
|
+
oldPassword: string;
|
|
50
|
+
newPassword: string;
|
|
51
|
+
confirmNewPassword: string;
|
|
52
|
+
};
|
|
53
|
+
type IUser = ISchema & {
|
|
54
|
+
id: IEquatable;
|
|
55
|
+
firstName: string;
|
|
56
|
+
lastName: string;
|
|
57
|
+
email: string;
|
|
58
|
+
};
|
|
59
|
+
type IAddress = {
|
|
60
|
+
name: string;
|
|
61
|
+
firstName: string;
|
|
62
|
+
lastName: string;
|
|
63
|
+
address: string;
|
|
64
|
+
streetNumber: string;
|
|
65
|
+
zipCode: string;
|
|
66
|
+
city: string;
|
|
67
|
+
country: IOption;
|
|
68
|
+
region?: IOption;
|
|
69
|
+
province?: IOption;
|
|
70
|
+
email: string;
|
|
71
|
+
phoneNumber: string;
|
|
72
|
+
};
|
|
73
|
+
type IAddressOptions = {
|
|
74
|
+
countries: IOption[];
|
|
75
|
+
regions: IOption[];
|
|
76
|
+
provinces: IOption[];
|
|
77
|
+
};
|
|
78
|
+
type IUserAddress = Omit<IAddress, 'name'>;
|
|
71
79
|
type ICompanyAddress = Omit<IAddress, 'firstName' | 'lastName'>;
|
|
72
80
|
|
|
73
|
-
type ICheckout = {
|
|
74
|
-
items: ICheckoutItem[];
|
|
75
|
-
user?: Partial<IUser>;
|
|
76
|
-
shippingAddress: IUserAddress;
|
|
77
|
-
hasInvoice?: boolean;
|
|
78
|
-
hasBilling?: boolean;
|
|
79
|
-
billingAddress?: IUserAddress;
|
|
80
|
-
delivery: ICheckoutDelivery;
|
|
81
|
-
store: ICheckoutStore;
|
|
82
|
-
discounts: ICheckoutDiscount[];
|
|
83
|
-
payment: ICheckoutPayment;
|
|
84
|
-
subTotal: number;
|
|
85
|
-
subTotalFull: number;
|
|
86
|
-
taxes: number;
|
|
87
|
-
total: number;
|
|
88
|
-
};
|
|
89
|
-
type ICheckoutPartial = Partial<ICheckout>;
|
|
90
|
-
type ICheckoutItem = ICartItem & {
|
|
91
|
-
fullPrice: number;
|
|
92
|
-
};
|
|
93
|
-
type ICheckoutInfo = {
|
|
94
|
-
user?: Partial<IUser>;
|
|
95
|
-
shippingAddress: IUserAddress;
|
|
96
|
-
hasInvoice?: boolean;
|
|
97
|
-
hasBilling?: boolean;
|
|
98
|
-
billingAddress?: IUserAddress;
|
|
99
|
-
};
|
|
100
|
-
type ICheckoutDelivery = IOption & {
|
|
101
|
-
abstract: string;
|
|
102
|
-
price: number;
|
|
103
|
-
fullPrice: number;
|
|
104
|
-
};
|
|
105
|
-
type ICheckoutStore = Partial<ICompanyAddress> & IOption & {
|
|
106
|
-
category?: IOption;
|
|
107
|
-
timetable?: string[];
|
|
108
|
-
position?: {
|
|
109
|
-
latitude: number;
|
|
110
|
-
longitude: number;
|
|
111
|
-
};
|
|
112
|
-
distance?: number;
|
|
113
|
-
rank?: number;
|
|
114
|
-
};
|
|
115
|
-
type ICheckoutDiscount = IOption & {
|
|
116
|
-
abstract?: string;
|
|
117
|
-
price: number;
|
|
118
|
-
validFrom: Date | string;
|
|
119
|
-
validTo: Date | string;
|
|
120
|
-
};
|
|
121
|
-
type ICheckoutPayment = IOption & {
|
|
122
|
-
abstract?: string;
|
|
123
|
-
media?: IMedia;
|
|
81
|
+
type ICheckout = {
|
|
82
|
+
items: ICheckoutItem[];
|
|
83
|
+
user?: Partial<IUser>;
|
|
84
|
+
shippingAddress: IUserAddress;
|
|
85
|
+
hasInvoice?: boolean;
|
|
86
|
+
hasBilling?: boolean;
|
|
87
|
+
billingAddress?: IUserAddress;
|
|
88
|
+
delivery: ICheckoutDelivery;
|
|
89
|
+
store: ICheckoutStore;
|
|
90
|
+
discounts: ICheckoutDiscount[];
|
|
91
|
+
payment: ICheckoutPayment;
|
|
92
|
+
subTotal: number;
|
|
93
|
+
subTotalFull: number;
|
|
94
|
+
taxes: number;
|
|
95
|
+
total: number;
|
|
96
|
+
};
|
|
97
|
+
type ICheckoutPartial = Partial<ICheckout>;
|
|
98
|
+
type ICheckoutItem = ICartItem & {
|
|
99
|
+
fullPrice: number;
|
|
100
|
+
};
|
|
101
|
+
type ICheckoutInfo = {
|
|
102
|
+
user?: Partial<IUser>;
|
|
103
|
+
shippingAddress: IUserAddress;
|
|
104
|
+
hasInvoice?: boolean;
|
|
105
|
+
hasBilling?: boolean;
|
|
106
|
+
billingAddress?: IUserAddress;
|
|
107
|
+
};
|
|
108
|
+
type ICheckoutDelivery = IOption & {
|
|
109
|
+
abstract: string;
|
|
110
|
+
price: number;
|
|
111
|
+
fullPrice: number;
|
|
112
|
+
};
|
|
113
|
+
type ICheckoutStore = Partial<ICompanyAddress> & IOption & {
|
|
114
|
+
category?: IOption;
|
|
115
|
+
timetable?: string[];
|
|
116
|
+
position?: {
|
|
117
|
+
latitude: number;
|
|
118
|
+
longitude: number;
|
|
119
|
+
};
|
|
120
|
+
distance?: number;
|
|
121
|
+
rank?: number;
|
|
122
|
+
};
|
|
123
|
+
type ICheckoutDiscount = IOption & {
|
|
124
|
+
abstract?: string;
|
|
125
|
+
price: number;
|
|
126
|
+
validFrom: Date | string;
|
|
127
|
+
validTo: Date | string;
|
|
128
|
+
};
|
|
129
|
+
type ICheckoutPayment = IOption & {
|
|
130
|
+
abstract?: string;
|
|
131
|
+
media?: IMedia;
|
|
132
|
+
};
|
|
133
|
+
type ICheckoutPaymentRedirect = {
|
|
134
|
+
redirectUrl: string;
|
|
124
135
|
};
|
|
125
136
|
|
|
126
|
-
declare function getItems(items: ICartItem[], market: string, locale: string, user?: IUser): Promise<ICheckoutItem[]>;
|
|
127
|
-
declare function getInfo(checkout: ICheckoutPartial, market: string, locale: string): Promise<IAddressOptions>;
|
|
128
|
-
declare function getDeliveries(checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutDelivery[]>;
|
|
129
|
-
declare function getStores(checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutStore[]>;
|
|
130
|
-
declare function getPayments(checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutPayment[]>;
|
|
131
|
-
declare function updateCheckout(checkout: ICheckoutPartial, action: string, market: string, locale: string): Promise<ICheckoutPartial>;
|
|
132
|
-
declare function setDiscountCode(discountCode: string, checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutPartial>;
|
|
133
|
-
declare function getPayment(checkout: ICheckoutPartial, market: string, locale: string): Promise<
|
|
134
|
-
redirectUrl: string;
|
|
135
|
-
}>;
|
|
137
|
+
declare function getItems(items: ICartItem[], market: string, locale: string, user?: IUser): Promise<ICheckoutItem[]>;
|
|
138
|
+
declare function getInfo(checkout: ICheckoutPartial, market: string, locale: string): Promise<IAddressOptions>;
|
|
139
|
+
declare function getDeliveries(checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutDelivery[]>;
|
|
140
|
+
declare function getStores(checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutStore[]>;
|
|
141
|
+
declare function getPayments(checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutPayment[]>;
|
|
142
|
+
declare function updateCheckout(checkout: ICheckoutPartial, action: string, market: string, locale: string): Promise<ICheckoutPartial>;
|
|
143
|
+
declare function setDiscountCode(discountCode: string, checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutPartial>;
|
|
144
|
+
declare function getPayment(checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutPaymentRedirect>;
|
|
136
145
|
|
|
137
|
-
declare function getCountries(locale?: string): Promise<INamedEntity[]>;
|
|
146
|
+
declare function getCountries(locale?: string): Promise<INamedEntity[]>;
|
|
138
147
|
declare function getCountry(id: IEquatable, params?: QueryParams): Promise<INamedEntity | undefined>;
|
|
139
148
|
|
|
140
|
-
type IFeatureType = {
|
|
141
|
-
id: string;
|
|
142
|
-
schema?: string;
|
|
143
|
-
title: string;
|
|
144
|
-
mode: string;
|
|
145
|
-
features?: {
|
|
146
|
-
id: IEquatable;
|
|
147
|
-
title: string;
|
|
148
|
-
[key: string]: unknown;
|
|
149
|
-
}[];
|
|
149
|
+
type IFeatureType = {
|
|
150
|
+
id: string;
|
|
151
|
+
schema?: string;
|
|
152
|
+
title: string;
|
|
153
|
+
mode: string;
|
|
154
|
+
features?: {
|
|
155
|
+
id: IEquatable;
|
|
156
|
+
title: string;
|
|
157
|
+
[key: string]: unknown;
|
|
158
|
+
}[];
|
|
150
159
|
};
|
|
151
160
|
|
|
152
|
-
declare function getFeatureTypes(params?: QueryParams): Promise<IFeatureType[]>;
|
|
161
|
+
declare function getFeatureTypes(params?: QueryParams): Promise<IFeatureType[]>;
|
|
153
162
|
declare function getFeatureType(id: IEquatable, params?: QueryParams): Promise<IFeatureType | undefined>;
|
|
154
163
|
|
|
155
|
-
declare function getLabels(params?: QueryParams): Promise<ILabel[]>;
|
|
156
|
-
declare function getLabel(id: IEquatable, params?: QueryParams): Promise<ILabel | undefined>;
|
|
164
|
+
declare function getLabels(params?: QueryParams): Promise<ILabel[]>;
|
|
165
|
+
declare function getLabel(id: IEquatable, params?: QueryParams): Promise<ILabel | undefined>;
|
|
157
166
|
declare function resolveLabel(labels: ILabel[], id: string): string;
|
|
158
167
|
|
|
159
168
|
declare function getLayout(market: string, locale: string): Promise<ILayout>;
|
|
160
169
|
|
|
161
|
-
type ILazyComponent = {
|
|
162
|
-
schema: string;
|
|
163
|
-
[key: string]: unknown;
|
|
164
|
-
};
|
|
165
|
-
type ILazyComponentProps = {
|
|
166
|
-
item: ILazyComponent;
|
|
167
|
-
};
|
|
168
|
-
type IGenericLazyComponentProps = ILazyComponentProps & any;
|
|
170
|
+
type ILazyComponent = {
|
|
171
|
+
schema: string;
|
|
172
|
+
[key: string]: unknown;
|
|
173
|
+
};
|
|
174
|
+
type ILazyComponentProps = {
|
|
175
|
+
item: ILazyComponent;
|
|
176
|
+
};
|
|
177
|
+
type IGenericLazyComponentProps = ILazyComponentProps & any;
|
|
169
178
|
type ILazyModules = Record<string, ComponentType<ComponentProps<IGenericLazyComponentProps>>>;
|
|
170
179
|
|
|
171
|
-
type ILink = {
|
|
172
|
-
href: string;
|
|
173
|
-
title: string;
|
|
174
|
-
type?: string;
|
|
175
|
-
secure?: boolean;
|
|
180
|
+
type ILink = {
|
|
181
|
+
href: string;
|
|
182
|
+
title: string;
|
|
183
|
+
type?: string;
|
|
184
|
+
secure?: boolean;
|
|
176
185
|
};
|
|
177
186
|
|
|
178
|
-
type IList = INamedEntity & {
|
|
179
|
-
key?: string;
|
|
180
|
-
listId?: IEquatable;
|
|
181
|
-
items?: IList[];
|
|
182
|
-
};
|
|
183
|
-
type IKeyedList = IList & {
|
|
184
|
-
key: string;
|
|
187
|
+
type IList = INamedEntity & {
|
|
188
|
+
key?: string;
|
|
189
|
+
listId?: IEquatable;
|
|
190
|
+
items?: IList[];
|
|
191
|
+
};
|
|
192
|
+
type IKeyedList = IList & {
|
|
193
|
+
key: string;
|
|
185
194
|
};
|
|
186
195
|
|
|
187
|
-
declare function getLists(locale?: string): Promise<IList[]>;
|
|
188
|
-
declare function getListByKeys(keys: string[], locale?: string): Promise<{
|
|
189
|
-
[key: string]: IList[];
|
|
196
|
+
declare function getLists(locale?: string): Promise<IList[]>;
|
|
197
|
+
declare function getListByKeys(keys: string[], locale?: string): Promise<{
|
|
198
|
+
[key: string]: IList[];
|
|
190
199
|
}>;
|
|
191
200
|
|
|
192
|
-
declare function getLocales(params?: QueryParams): Promise<ILocale[]>;
|
|
193
|
-
declare function getLocale(id: IEquatable, params?: QueryParams): Promise<ILocale | undefined>;
|
|
201
|
+
declare function getLocales(params?: QueryParams): Promise<ILocale[]>;
|
|
202
|
+
declare function getLocale(id: IEquatable, params?: QueryParams): Promise<ILocale | undefined>;
|
|
194
203
|
declare function getLocaleFromProps(props: (RenderPageResult & HtmlProps) | undefined): string | undefined;
|
|
195
204
|
|
|
196
|
-
declare function getMarkets(params?: QueryParams): Promise<IMarket[]>;
|
|
205
|
+
declare function getMarkets(params?: QueryParams): Promise<IMarket[]>;
|
|
197
206
|
declare function getMarket(id: IEquatable, params?: QueryParams): Promise<IMarket | undefined>;
|
|
198
207
|
|
|
199
|
-
declare function getMenus(params?: QueryParams): Promise<IMenu[]>;
|
|
208
|
+
declare function getMenus(params?: QueryParams): Promise<IMenu[]>;
|
|
200
209
|
declare function getMenu(id: IEquatable, params?: QueryParams): Promise<IMenu | undefined>;
|
|
201
210
|
|
|
202
|
-
declare const IOrderStatus: {
|
|
203
|
-
Pending: string;
|
|
204
|
-
AwaitingPayment: string;
|
|
205
|
-
AwaitingFulfillment: string;
|
|
206
|
-
AwaitingShipment: string;
|
|
207
|
-
AwaitingPickup: string;
|
|
208
|
-
PartiallyShipped: string;
|
|
209
|
-
Completed: string;
|
|
210
|
-
Shipped: string;
|
|
211
|
-
Cancelled: string;
|
|
212
|
-
Declined: string;
|
|
213
|
-
Refunded: string;
|
|
214
|
-
Disputed: string;
|
|
215
|
-
ManualVerificationRequired: string;
|
|
216
|
-
PartiallyRefunded: string;
|
|
217
|
-
};
|
|
218
|
-
type IOrderStatusValue = ValueOf<typeof IOrderStatus>;
|
|
219
|
-
type IOrder = ICheckout & {
|
|
220
|
-
id: IEquatable;
|
|
221
|
-
date: Date | string;
|
|
222
|
-
status: IOrderStatusValue;
|
|
223
|
-
};
|
|
224
|
-
type IOrderDetail = IOrder & {
|
|
225
|
-
href: string;
|
|
211
|
+
declare const IOrderStatus: {
|
|
212
|
+
Pending: string;
|
|
213
|
+
AwaitingPayment: string;
|
|
214
|
+
AwaitingFulfillment: string;
|
|
215
|
+
AwaitingShipment: string;
|
|
216
|
+
AwaitingPickup: string;
|
|
217
|
+
PartiallyShipped: string;
|
|
218
|
+
Completed: string;
|
|
219
|
+
Shipped: string;
|
|
220
|
+
Cancelled: string;
|
|
221
|
+
Declined: string;
|
|
222
|
+
Refunded: string;
|
|
223
|
+
Disputed: string;
|
|
224
|
+
ManualVerificationRequired: string;
|
|
225
|
+
PartiallyRefunded: string;
|
|
226
|
+
};
|
|
227
|
+
type IOrderStatusValue = ValueOf<typeof IOrderStatus>;
|
|
228
|
+
type IOrder = ICheckout & {
|
|
229
|
+
id: IEquatable;
|
|
230
|
+
date: Date | string;
|
|
231
|
+
status: IOrderStatusValue;
|
|
232
|
+
};
|
|
233
|
+
type IOrderDetail = IOrder & {
|
|
234
|
+
href: string;
|
|
226
235
|
};
|
|
227
236
|
|
|
228
|
-
declare function getOrders(market: string, locale: string): Promise<IOrderDetail[]>;
|
|
237
|
+
declare function getOrders(market: string, locale: string): Promise<IOrderDetail[]>;
|
|
229
238
|
declare function getOrder(id: IEquatable, market: string, locale: string): Promise<IOrderDetail | null>;
|
|
230
239
|
|
|
231
|
-
declare function findOnePage<T extends ICategorized = ICategorized>(schema: string, id: IEquatable, params?: QueryParams): Promise<T | undefined>;
|
|
232
|
-
declare function findManyPages<T extends ICategorized = ICategorized>(schema: string, params?: QueryParams): Promise<T[]>;
|
|
233
|
-
declare function getPage<T extends ICategorized = ICategorized>(schema: string, id: IEquatable, market?: string, locale?: string): Promise<IPageResult<T> | undefined>;
|
|
234
|
-
declare function getPageRoutes(schema: string, id: IEquatable): Promise<IRoute[]>;
|
|
235
|
-
declare function getPageCategory<T extends IPage>(schema: string, page?: IPage, market?: string, locale?: string): Promise<T | undefined>;
|
|
236
|
-
declare function getErrorPageLayout(): Promise<{
|
|
237
|
-
layout: ILayout;
|
|
238
|
-
page: IPage;
|
|
240
|
+
declare function findOnePage<T extends ICategorized = ICategorized>(schema: string, id: IEquatable, params?: QueryParams): Promise<T | undefined>;
|
|
241
|
+
declare function findManyPages<T extends ICategorized = ICategorized>(schema: string, params?: QueryParams): Promise<T[]>;
|
|
242
|
+
declare function getPage<T extends ICategorized = ICategorized>(schema: string, id: IEquatable, market?: string, locale?: string): Promise<IPageResult<T> | undefined>;
|
|
243
|
+
declare function getPageRoutes(schema: string, id: IEquatable): Promise<IRoute[]>;
|
|
244
|
+
declare function getPageCategory<T extends IPage>(schema: string, page?: IPage, market?: string, locale?: string): Promise<T | undefined>;
|
|
245
|
+
declare function getErrorPageLayout(): Promise<{
|
|
246
|
+
layout: ILayout;
|
|
247
|
+
page: IPage;
|
|
239
248
|
}>;
|
|
240
249
|
|
|
241
|
-
declare function getProvinces(locale?: string): Promise<INamedEntity[]>;
|
|
250
|
+
declare function getProvinces(locale?: string): Promise<INamedEntity[]>;
|
|
242
251
|
declare function getProvince(id: IEquatable, params?: QueryParams): Promise<INamedEntity | undefined>;
|
|
243
252
|
|
|
244
|
-
declare function getRegions(locale?: string): Promise<INamedEntity[]>;
|
|
253
|
+
declare function getRegions(locale?: string): Promise<INamedEntity[]>;
|
|
245
254
|
declare function getRegion(id: IEquatable, params?: QueryParams): Promise<INamedEntity | undefined>;
|
|
246
255
|
|
|
247
256
|
declare function routeRevalidateHandler(): any;
|
|
248
257
|
|
|
249
|
-
declare function routeInterceptor(request: NextRequest, next: NextFetchEvent): Promise<NextResponse | undefined>;
|
|
258
|
+
declare function routeInterceptor(request: NextRequest, next: NextFetchEvent): Promise<NextResponse<unknown> | undefined>;
|
|
250
259
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}>;
|
|
256
|
-
declare function getRoutesForTemplates(templates: string[], market?: string, locale?: string): Promise<{
|
|
257
|
-
[key: string]: string;
|
|
258
|
-
}>;
|
|
259
|
-
declare function getStaticPathsForSchema(schema: string): Promise<StaticPath[]>;
|
|
260
|
-
declare function getBreadcrumbFromSegments(segments: ICategory[], market?: string, locale?: string): Promise<IRouteLink[]>;
|
|
261
|
-
declare function getRouteLinkTree(market?: string, locale?: string): Promise<IRouteLink | undefined>;
|
|
262
|
-
declare function categoryToRouteLink(routes: IRoute[], categories: ICategory[], category: ICategory, locale?: string): IRouteLink;
|
|
263
|
-
declare function resolveRoute(route: IRoute & {
|
|
264
|
-
splat?: string;
|
|
265
|
-
}): string;
|
|
266
|
-
type StaticPath = {
|
|
267
|
-
params: {
|
|
268
|
-
[key: string]: string;
|
|
269
|
-
};
|
|
260
|
+
type StaticPath = {
|
|
261
|
+
params: {
|
|
262
|
+
[key: string]: string;
|
|
263
|
+
};
|
|
270
264
|
};
|
|
265
|
+
declare function getRoutes(params?: QueryParams): Promise<IRoute[]>;
|
|
266
|
+
declare function getRoute(id: string): Promise<IRoute | undefined>;
|
|
267
|
+
declare function getRoutesForSchemas(schemas: string[], market?: string, locale?: string): Promise<{
|
|
268
|
+
[key: string]: string;
|
|
269
|
+
}>;
|
|
270
|
+
declare function getRoutesForTemplates(templates: string[], market?: string, locale?: string): Promise<{
|
|
271
|
+
[key: string]: string;
|
|
272
|
+
}>;
|
|
273
|
+
declare function getStaticPathsForSchema(schema: string): Promise<StaticPath[]>;
|
|
274
|
+
declare function getBreadcrumbFromSegments(segments: ICategory[], market?: string, locale?: string): Promise<IRouteLink[]>;
|
|
275
|
+
declare function getRouteLinkTree(market?: string, locale?: string): Promise<IRouteLink | undefined>;
|
|
276
|
+
declare function categoryToRouteLink(routes: IRoute[], categories: ICategory[], category: ICategory, locale?: string): IRouteLink;
|
|
277
|
+
declare function resolveRoute(route: IRoute & {
|
|
278
|
+
splat?: string;
|
|
279
|
+
}): string;
|
|
271
280
|
|
|
272
|
-
declare const getSiteMapIndexProps: GetServerSideProps;
|
|
273
|
-
declare const getSiteMapXMLProps: GetServerSideProps;
|
|
281
|
+
declare const getSiteMapIndexProps: GetServerSideProps;
|
|
282
|
+
declare const getSiteMapXMLProps: GetServerSideProps;
|
|
274
283
|
declare const getSiteMapXSLProps: GetServerSideProps;
|
|
275
284
|
|
|
276
|
-
type ISiteMap = {
|
|
277
|
-
id: string;
|
|
278
|
-
updatedAt?: Date;
|
|
279
|
-
};
|
|
280
|
-
declare function getSiteMapIndex(): Promise<string>;
|
|
281
|
-
declare function getSiteMapXML(marketId?: string, localeId?: string): Promise<string>;
|
|
285
|
+
type ISiteMap = {
|
|
286
|
+
id: string;
|
|
287
|
+
updatedAt?: Date;
|
|
288
|
+
};
|
|
289
|
+
declare function getSiteMapIndex(origin: string): Promise<string>;
|
|
290
|
+
declare function getSiteMapXML(origin: string, marketId?: string, localeId?: string): Promise<string>;
|
|
282
291
|
declare function getSiteMapXSL(): Promise<string>;
|
|
283
292
|
|
|
284
|
-
type IModelStore = {
|
|
285
|
-
category: IQuerable<ICategory>;
|
|
286
|
-
feature_type: IQuerable<IFeatureType>;
|
|
287
|
-
label: IQuerable<ILabel>;
|
|
288
|
-
list: IQuerable<IList>;
|
|
289
|
-
locale: IQuerable<ILocale>;
|
|
290
|
-
market: IQuerable<IMarket>;
|
|
291
|
-
menu: IQuerable<IMenu>;
|
|
292
|
-
redirect: IQuerable<IRedirect>;
|
|
293
|
-
route: IQuerable<IRoute>;
|
|
294
|
-
i18n_country: IQuerable<INamedEntity>;
|
|
295
|
-
i18n_province: IQuerable<INamedEntity>;
|
|
296
|
-
i18n_region: IQuerable<INamedEntity>;
|
|
297
|
-
[key: string]: IQuerable<IEntity>;
|
|
293
|
+
type IModelStore = {
|
|
294
|
+
category: IQuerable<ICategory>;
|
|
295
|
+
feature_type: IQuerable<IFeatureType>;
|
|
296
|
+
label: IQuerable<ILabel>;
|
|
297
|
+
list: IQuerable<IList>;
|
|
298
|
+
locale: IQuerable<ILocale>;
|
|
299
|
+
market: IQuerable<IMarket>;
|
|
300
|
+
menu: IQuerable<IMenu>;
|
|
301
|
+
redirect: IQuerable<IRedirect>;
|
|
302
|
+
route: IQuerable<IRoute>;
|
|
303
|
+
i18n_country: IQuerable<INamedEntity>;
|
|
304
|
+
i18n_province: IQuerable<INamedEntity>;
|
|
305
|
+
i18n_region: IQuerable<INamedEntity>;
|
|
306
|
+
[key: string]: IQuerable<IEntity>;
|
|
298
307
|
};
|
|
299
308
|
|
|
300
|
-
export { IAddress, IAddressOptions, ICartAddItem, ICartItem, ICheckout, ICheckoutDelivery, ICheckoutDiscount, ICheckoutInfo, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutStore, ICompanyAddress, IFeatureType, IGenericLazyComponentProps, IKeyedList, ILazyComponent, ILazyComponentProps, ILazyModules, ILink, IList, IModelStore, IOrder, IOrderDetail, IOrderStatus, IOrderStatusValue, ISiteMap, IUser, IUserAddress, IUserChangePassword, IUserForgot, IUserLogin, IUserRegister, StaticPath, categoryToRouteLink, findManyPages, findOnePage, getBreadcrumbFromSegments, getCategories, getCategory, getCountries, getCountry, getDeliveries, getErrorPageLayout, getFeatureType, getFeatureTypes, getInfo, getItems, getLabel, getLabels, getLayout, getListByKeys, getLists, getLocale, getLocaleFromProps, getLocales, getMarket, getMarkets, getMenu, getMenus, getOrder, getOrders, getPage, getPageCategory, getPageRoutes, getPayment, getPayments, getProvince, getProvinces, getRegion, getRegions, getRoute, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStores, resolveLabel, resolveRoute, routeInterceptor, routeRevalidateHandler, setDiscountCode, updateCheckout };
|
|
309
|
+
export { IAddress, IAddressOptions, IApplication, IApplicationProps, ICartAddItem, ICartItem, ICheckout, ICheckoutDelivery, ICheckoutDiscount, ICheckoutInfo, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutPaymentRedirect, ICheckoutStore, ICompanyAddress, IFeatureType, IGenericLazyComponentProps, IKeyedList, ILazyComponent, ILazyComponentProps, ILazyModules, ILink, IList, IModelStore, IOrder, IOrderDetail, IOrderStatus, IOrderStatusValue, ISiteMap, IUser, IUserAddress, IUserChangePassword, IUserForgot, IUserLogin, IUserRegister, StaticPath, categoryToRouteLink, findManyPages, findOnePage, getBreadcrumbFromSegments, getCategories, getCategory, getCountries, getCountry, getDeliveries, getErrorPageLayout, getFeatureType, getFeatureTypes, getInfo, getItems, getLabel, getLabels, getLayout, getListByKeys, getLists, getLocale, getLocaleFromProps, getLocales, getMarket, getMarkets, getMenu, getMenus, getOrder, getOrders, getPage, getPageCategory, getPageRoutes, getPayment, getPayments, getProvince, getProvinces, getRegion, getRegions, getRoute, getRouteLinkTree, getRoutes, getRoutesForSchemas, getRoutesForTemplates, getSegments, getSiteMapIndex, getSiteMapIndexProps, getSiteMapXML, getSiteMapXMLProps, getSiteMapXSL, getSiteMapXSLProps, getStaticPathsForSchema, getStores, resolveLabel, resolveRoute, routeInterceptor, routeRevalidateHandler, setDiscountCode, updateCheckout };
|
package/dist/index.js
CHANGED
|
@@ -1211,11 +1211,7 @@ async function routeInterceptor(request, next) {
|
|
|
1211
1211
|
let url = request.nextUrl;
|
|
1212
1212
|
let route;
|
|
1213
1213
|
try {
|
|
1214
|
-
|
|
1215
|
-
route = await (0, import_bom_mixer_store14.apiPost)("/route", { pathname: url.pathname, href: url.href });
|
|
1216
|
-
} else {
|
|
1217
|
-
route = await (0, import_bom_mixer_store14.storeApiPost)("/route", { pathname: url.pathname, href: url.href });
|
|
1218
|
-
}
|
|
1214
|
+
route = await (0, import_bom_mixer_store14.storeApiPost)("/route", { pathname: url.pathname, href: url.href });
|
|
1219
1215
|
if (!route) {
|
|
1220
1216
|
console.log("routeInterceptor.route.notfound", url.pathname);
|
|
1221
1217
|
return;
|
|
@@ -1246,8 +1242,7 @@ async function routeInterceptor(request, next) {
|
|
|
1246
1242
|
|
|
1247
1243
|
// src/sitemap/sitemap.service.ts
|
|
1248
1244
|
var import_bom_core3 = require("@websolutespa/bom-core");
|
|
1249
|
-
|
|
1250
|
-
async function getSiteMapIndex() {
|
|
1245
|
+
async function getSiteMapIndex(origin) {
|
|
1251
1246
|
let markets = await getMarkets();
|
|
1252
1247
|
let locales = await getLocales();
|
|
1253
1248
|
markets = markets.filter((x) => x.isActive !== false);
|
|
@@ -1285,20 +1280,20 @@ function getSiteMapXMLImage(canonical) {
|
|
|
1285
1280
|
<image:loc>${canonical.media.src}</image:loc>
|
|
1286
1281
|
</image:image>` : "";
|
|
1287
1282
|
}
|
|
1288
|
-
function getSiteMapXMLAlternates(canonical) {
|
|
1283
|
+
function getSiteMapXMLAlternates(origin, canonical) {
|
|
1289
1284
|
return canonical.alternates.map((alternate) => `
|
|
1290
1285
|
<xhtml:link href="${origin}${alternate.id}" hreflang="${alternate.locale}-${alternate.market}" rel="alternate" />`).join("");
|
|
1291
1286
|
}
|
|
1292
|
-
function getSiteMapXMLUrl(canonical) {
|
|
1287
|
+
function getSiteMapXMLUrl(origin, canonical) {
|
|
1293
1288
|
return `
|
|
1294
1289
|
<url>
|
|
1295
|
-
<loc>${origin}${canonical.id}</loc>${getSiteMapXMLLastMod(canonical)}${getSiteMapXMLAlternates(canonical)}${getSiteMapXMLImage(canonical)}
|
|
1290
|
+
<loc>${origin}${canonical.id}</loc>${getSiteMapXMLLastMod(canonical)}${getSiteMapXMLAlternates(origin, canonical)}${getSiteMapXMLImage(canonical)}
|
|
1296
1291
|
</url>`;
|
|
1297
1292
|
}
|
|
1298
|
-
function getSiteMapXMLUrls(canonicalRoutes) {
|
|
1299
|
-
return canonicalRoutes.map((canonicalRoute) => getSiteMapXMLUrl(canonicalRoute)).join("");
|
|
1293
|
+
function getSiteMapXMLUrls(origin, canonicalRoutes) {
|
|
1294
|
+
return canonicalRoutes.map((canonicalRoute) => getSiteMapXMLUrl(origin, canonicalRoute)).join("");
|
|
1300
1295
|
}
|
|
1301
|
-
async function getSiteMapXML(marketId, localeId) {
|
|
1296
|
+
async function getSiteMapXML(origin, marketId, localeId) {
|
|
1302
1297
|
let markets = await getMarkets();
|
|
1303
1298
|
let locales = await getLocales();
|
|
1304
1299
|
markets = markets.filter((x) => x.isActive !== false);
|
|
@@ -1328,7 +1323,7 @@ async function getSiteMapXML(marketId, localeId) {
|
|
|
1328
1323
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
1329
1324
|
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
1330
1325
|
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
|
|
1331
|
-
${getSiteMapXMLUrls(canonicalRoutes)}
|
|
1326
|
+
${getSiteMapXMLUrls(origin, canonicalRoutes)}
|
|
1332
1327
|
</urlset>
|
|
1333
1328
|
`;
|
|
1334
1329
|
}
|
|
@@ -1499,9 +1494,17 @@ async function getSiteMapXSL() {
|
|
|
1499
1494
|
}
|
|
1500
1495
|
|
|
1501
1496
|
// src/sitemap/sitemap.handler.ts
|
|
1497
|
+
var ORIGIN = process.env.NEXT_PUBLIC_URL || "";
|
|
1498
|
+
function getOrigin(host) {
|
|
1499
|
+
if (host) {
|
|
1500
|
+
return host.indexOf("localhost") !== -1 ? "http://" + host : "https://" + host;
|
|
1501
|
+
} else {
|
|
1502
|
+
return ORIGIN;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1502
1505
|
var getSiteMapIndexProps = async (context) => {
|
|
1503
1506
|
const { req, res } = context;
|
|
1504
|
-
const sitemap = await getSiteMapIndex();
|
|
1507
|
+
const sitemap = await getSiteMapIndex(getOrigin(req.headers.host));
|
|
1505
1508
|
res.setHeader("Content-Type", "application/xml; charset=UTF-8");
|
|
1506
1509
|
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
1507
1510
|
res.setHeader("X-Robots-Tag", "noindex, follow");
|
|
@@ -1516,7 +1519,7 @@ var getSiteMapXMLProps = async (context) => {
|
|
|
1516
1519
|
const params = context.params;
|
|
1517
1520
|
const market = params?.market;
|
|
1518
1521
|
const locale = params?.locale;
|
|
1519
|
-
const sitemap = await getSiteMapXML(market, locale);
|
|
1522
|
+
const sitemap = await getSiteMapXML(getOrigin(req.headers.host), market, locale);
|
|
1520
1523
|
res.setHeader("Content-Type", "application/xml; charset=UTF-8");
|
|
1521
1524
|
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
1522
1525
|
res.setHeader("X-Robots-Tag", "noindex, follow");
|
package/dist/index.mjs
CHANGED
|
@@ -1122,17 +1122,13 @@ function routeRevalidateHandler() {
|
|
|
1122
1122
|
}
|
|
1123
1123
|
|
|
1124
1124
|
// src/route/route.interceptor.ts
|
|
1125
|
-
import {
|
|
1125
|
+
import { storeApiPost } from "@websolutespa/bom-mixer-store";
|
|
1126
1126
|
import { NextResponse } from "next/server";
|
|
1127
1127
|
async function routeInterceptor(request, next) {
|
|
1128
1128
|
let url = request.nextUrl;
|
|
1129
1129
|
let route;
|
|
1130
1130
|
try {
|
|
1131
|
-
|
|
1132
|
-
route = await apiPost("/route", { pathname: url.pathname, href: url.href });
|
|
1133
|
-
} else {
|
|
1134
|
-
route = await storeApiPost("/route", { pathname: url.pathname, href: url.href });
|
|
1135
|
-
}
|
|
1131
|
+
route = await storeApiPost("/route", { pathname: url.pathname, href: url.href });
|
|
1136
1132
|
if (!route) {
|
|
1137
1133
|
console.log("routeInterceptor.route.notfound", url.pathname);
|
|
1138
1134
|
return;
|
|
@@ -1163,8 +1159,7 @@ async function routeInterceptor(request, next) {
|
|
|
1163
1159
|
|
|
1164
1160
|
// src/sitemap/sitemap.service.ts
|
|
1165
1161
|
import { eachMarketLocale } from "@websolutespa/bom-core";
|
|
1166
|
-
|
|
1167
|
-
async function getSiteMapIndex() {
|
|
1162
|
+
async function getSiteMapIndex(origin) {
|
|
1168
1163
|
let markets = await getMarkets();
|
|
1169
1164
|
let locales = await getLocales();
|
|
1170
1165
|
markets = markets.filter((x) => x.isActive !== false);
|
|
@@ -1202,20 +1197,20 @@ function getSiteMapXMLImage(canonical) {
|
|
|
1202
1197
|
<image:loc>${canonical.media.src}</image:loc>
|
|
1203
1198
|
</image:image>` : "";
|
|
1204
1199
|
}
|
|
1205
|
-
function getSiteMapXMLAlternates(canonical) {
|
|
1200
|
+
function getSiteMapXMLAlternates(origin, canonical) {
|
|
1206
1201
|
return canonical.alternates.map((alternate) => `
|
|
1207
1202
|
<xhtml:link href="${origin}${alternate.id}" hreflang="${alternate.locale}-${alternate.market}" rel="alternate" />`).join("");
|
|
1208
1203
|
}
|
|
1209
|
-
function getSiteMapXMLUrl(canonical) {
|
|
1204
|
+
function getSiteMapXMLUrl(origin, canonical) {
|
|
1210
1205
|
return `
|
|
1211
1206
|
<url>
|
|
1212
|
-
<loc>${origin}${canonical.id}</loc>${getSiteMapXMLLastMod(canonical)}${getSiteMapXMLAlternates(canonical)}${getSiteMapXMLImage(canonical)}
|
|
1207
|
+
<loc>${origin}${canonical.id}</loc>${getSiteMapXMLLastMod(canonical)}${getSiteMapXMLAlternates(origin, canonical)}${getSiteMapXMLImage(canonical)}
|
|
1213
1208
|
</url>`;
|
|
1214
1209
|
}
|
|
1215
|
-
function getSiteMapXMLUrls(canonicalRoutes) {
|
|
1216
|
-
return canonicalRoutes.map((canonicalRoute) => getSiteMapXMLUrl(canonicalRoute)).join("");
|
|
1210
|
+
function getSiteMapXMLUrls(origin, canonicalRoutes) {
|
|
1211
|
+
return canonicalRoutes.map((canonicalRoute) => getSiteMapXMLUrl(origin, canonicalRoute)).join("");
|
|
1217
1212
|
}
|
|
1218
|
-
async function getSiteMapXML(marketId, localeId) {
|
|
1213
|
+
async function getSiteMapXML(origin, marketId, localeId) {
|
|
1219
1214
|
let markets = await getMarkets();
|
|
1220
1215
|
let locales = await getLocales();
|
|
1221
1216
|
markets = markets.filter((x) => x.isActive !== false);
|
|
@@ -1245,7 +1240,7 @@ async function getSiteMapXML(marketId, localeId) {
|
|
|
1245
1240
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
1246
1241
|
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
1247
1242
|
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
|
|
1248
|
-
${getSiteMapXMLUrls(canonicalRoutes)}
|
|
1243
|
+
${getSiteMapXMLUrls(origin, canonicalRoutes)}
|
|
1249
1244
|
</urlset>
|
|
1250
1245
|
`;
|
|
1251
1246
|
}
|
|
@@ -1416,9 +1411,17 @@ async function getSiteMapXSL() {
|
|
|
1416
1411
|
}
|
|
1417
1412
|
|
|
1418
1413
|
// src/sitemap/sitemap.handler.ts
|
|
1414
|
+
var ORIGIN = process.env.NEXT_PUBLIC_URL || "";
|
|
1415
|
+
function getOrigin(host) {
|
|
1416
|
+
if (host) {
|
|
1417
|
+
return host.indexOf("localhost") !== -1 ? "http://" + host : "https://" + host;
|
|
1418
|
+
} else {
|
|
1419
|
+
return ORIGIN;
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1419
1422
|
var getSiteMapIndexProps = async (context) => {
|
|
1420
1423
|
const { req, res } = context;
|
|
1421
|
-
const sitemap = await getSiteMapIndex();
|
|
1424
|
+
const sitemap = await getSiteMapIndex(getOrigin(req.headers.host));
|
|
1422
1425
|
res.setHeader("Content-Type", "application/xml; charset=UTF-8");
|
|
1423
1426
|
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
1424
1427
|
res.setHeader("X-Robots-Tag", "noindex, follow");
|
|
@@ -1433,7 +1436,7 @@ var getSiteMapXMLProps = async (context) => {
|
|
|
1433
1436
|
const params = context.params;
|
|
1434
1437
|
const market = params?.market;
|
|
1435
1438
|
const locale = params?.locale;
|
|
1436
|
-
const sitemap = await getSiteMapXML(market, locale);
|
|
1439
|
+
const sitemap = await getSiteMapXML(getOrigin(req.headers.host), market, locale);
|
|
1437
1440
|
res.setHeader("Content-Type", "application/xml; charset=UTF-8");
|
|
1438
1441
|
res.setHeader("X-Frame-Options", "SAMEORIGIN");
|
|
1439
1442
|
res.setHeader("X-Robots-Tag", "noindex, follow");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websolutespa/bom-mixer-models",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Mixer Models module of the BOM Repository",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bom",
|
|
@@ -22,21 +22,21 @@
|
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@websolutespa/bom-core": "*",
|
|
24
24
|
"@websolutespa/bom-mixer-store": "*",
|
|
25
|
-
"next": ">=
|
|
25
|
+
"next": ">= 13.4.19"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/react": "^18.
|
|
29
|
-
"@types/react-dom": "^18.
|
|
28
|
+
"@types/react": "^18.2.18",
|
|
29
|
+
"@types/react-dom": "^18.2.7",
|
|
30
30
|
"@websolutespa/bom-cli": "*",
|
|
31
31
|
"@websolutespa/test": "*",
|
|
32
32
|
"@websolutespa/tsconfig": "*",
|
|
33
|
-
"eslint": "^8.
|
|
33
|
+
"eslint": "^8.46.0",
|
|
34
34
|
"eslint-config-websolute": "*",
|
|
35
35
|
"npm-run-all": "^4.1.5",
|
|
36
36
|
"react": "^18.2.0",
|
|
37
37
|
"ts-node": "^10.9.1",
|
|
38
38
|
"tsup": "^6.7.0",
|
|
39
|
-
"typescript": "^
|
|
39
|
+
"typescript": "^5.1.6"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ILayout, IPage, IRouteParams } from '@websolutespa/bom-core';
|
|
2
|
+
import { AppProps } from 'next/app';
|
|
3
|
+
|
|
4
|
+
export type IApplicationProps = Record<string, any> & {
|
|
5
|
+
layout: ILayout;
|
|
6
|
+
page: IPage;
|
|
7
|
+
params: IRouteParams;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type IApplication = AppProps<IApplicationProps>;
|
|
@@ -5,7 +5,7 @@ import { getProvinces } from '../province/province.service';
|
|
|
5
5
|
import { getRegions } from '../region/region.service';
|
|
6
6
|
import { getRoutesForSchemas } from '../route/route.service';
|
|
7
7
|
import { IAddressOptions, IUser } from '../user/user';
|
|
8
|
-
import { ICheckoutDelivery, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutStore } from './checkout';
|
|
8
|
+
import { ICheckoutDelivery, ICheckoutItem, ICheckoutPartial, ICheckoutPayment, ICheckoutPaymentRedirect, ICheckoutStore } from './checkout';
|
|
9
9
|
|
|
10
10
|
// step 1.
|
|
11
11
|
export async function getItems(items: ICartItem[], market: string, locale: string, user?: IUser): Promise<ICheckoutItem[]> {
|
|
@@ -342,7 +342,7 @@ export async function setDiscountCode(discountCode: string, checkout: ICheckoutP
|
|
|
342
342
|
}
|
|
343
343
|
|
|
344
344
|
// payment
|
|
345
|
-
export async function getPayment(checkout: ICheckoutPartial, market: string, locale: string): Promise<
|
|
345
|
+
export async function getPayment(checkout: ICheckoutPartial, market: string, locale: string): Promise<ICheckoutPaymentRedirect> {
|
|
346
346
|
const knownRoutes = await getRoutesForSchemas(['checkout_result'], market, locale);
|
|
347
347
|
// !!! todo return payment redirectUrl
|
|
348
348
|
const redirectUrl = `${knownRoutes.checkout_result}?orderId=1&status=OK`;
|
package/src/checkout/checkout.ts
CHANGED
package/src/index.ts
CHANGED
package/src/page/page.service.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ICategorized, ICategory, IEquatable, ILayout, IPage, IPageResult,
|
|
3
|
-
IRoute, IRouteLink, QueryParams, SchemaType
|
|
4
|
-
} from '@websolutespa/bom-core';
|
|
1
|
+
import { ICategorized, ICategory, IEquatable, ILayout, IPage, IPageResult, IRoute, IRouteLink, QueryParams, SchemaType } from '@websolutespa/bom-core';
|
|
5
2
|
import { getStore } from '@websolutespa/bom-mixer-store';
|
|
6
3
|
import { getSegments } from '../category/category.service';
|
|
7
4
|
import { resolveLabel } from '../label/label.service';
|
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import { IRoute } from '@websolutespa/bom-core';
|
|
2
|
-
import {
|
|
2
|
+
import { storeApiPost } from '@websolutespa/bom-mixer-store';
|
|
3
3
|
import { NextFetchEvent, NextRequest, NextResponse } from 'next/server';
|
|
4
4
|
import { resolveRoute } from './route.service';
|
|
5
5
|
|
|
6
6
|
export async function routeInterceptor(request: NextRequest, next: NextFetchEvent) {
|
|
7
7
|
let url = request.nextUrl;
|
|
8
8
|
let route: IRoute | undefined;
|
|
9
|
-
// console.log('routeInterceptor.url', url.pathname);
|
|
10
9
|
try {
|
|
11
|
-
/*
|
|
12
|
-
* Cannot call store directly in middleware
|
|
13
|
-
* we must make an api call
|
|
14
|
-
*/
|
|
15
10
|
// console.log('routeInterceptor', url.pathname);
|
|
16
|
-
|
|
17
|
-
route = await apiPost('/route', { pathname: url.pathname, href: url.href });
|
|
18
|
-
} else {
|
|
19
|
-
// route fetch logic moved to bowl
|
|
20
|
-
route = await storeApiPost('/route', { pathname: url.pathname, href: url.href });
|
|
21
|
-
}
|
|
11
|
+
route = await storeApiPost('/route', { pathname: url.pathname, href: url.href });
|
|
22
12
|
// console.log('route', route);
|
|
23
13
|
if (!route) {
|
|
24
14
|
console.log('routeInterceptor.route.notfound', url.pathname);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getRootCategory, ICategory, IRoute, IRouteLink, localize, QueryParams } from '@websolutespa/bom-core';
|
|
2
2
|
import { getStore } from '@websolutespa/bom-mixer-store';
|
|
3
3
|
import { IModelStore } from '../store/store';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
export type StaticPath = { params: { [key: string]: string } };
|
|
5
6
|
|
|
6
7
|
export async function getRoutes(params: QueryParams = {}): Promise<IRoute[]> {
|
|
7
8
|
const store = await getStore<IModelStore>();
|
|
@@ -29,7 +30,7 @@ export async function getRoutesForSchemas(schemas: string[], market?: string, lo
|
|
|
29
30
|
locale: {
|
|
30
31
|
equals: locale,
|
|
31
32
|
},
|
|
32
|
-
}, market, locale
|
|
33
|
+
}, market, locale,
|
|
33
34
|
});
|
|
34
35
|
const items: {
|
|
35
36
|
[key: string]: string;
|
|
@@ -53,7 +54,7 @@ export async function getRoutesForTemplates(templates: string[], market?: string
|
|
|
53
54
|
locale: {
|
|
54
55
|
equals: locale,
|
|
55
56
|
},
|
|
56
|
-
}, market, locale
|
|
57
|
+
}, market, locale,
|
|
57
58
|
});
|
|
58
59
|
const items: {
|
|
59
60
|
[key: string]: string;
|
|
@@ -71,9 +72,9 @@ export async function getStaticPathsForSchema(schema: string): Promise<StaticPat
|
|
|
71
72
|
const routes = await store.route.findMany({
|
|
72
73
|
where: {
|
|
73
74
|
schema: {
|
|
74
|
-
equals: schema
|
|
75
|
-
}
|
|
76
|
-
}
|
|
75
|
+
equals: schema,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
77
78
|
});
|
|
78
79
|
return routes.map((x: any) => ({ params: { id: x.page.toString(), market: x.market, locale: x.locale } }));
|
|
79
80
|
}
|
|
@@ -82,12 +83,12 @@ export async function getBreadcrumbFromSegments(segments: ICategory[], market: s
|
|
|
82
83
|
const routes: IRoute[] = await getRoutes({
|
|
83
84
|
where: {
|
|
84
85
|
market: {
|
|
85
|
-
equals: market
|
|
86
|
+
equals: market,
|
|
86
87
|
},
|
|
87
88
|
locale: {
|
|
88
|
-
equals: locale
|
|
89
|
+
equals: locale,
|
|
89
90
|
},
|
|
90
|
-
}
|
|
91
|
+
},
|
|
91
92
|
});
|
|
92
93
|
const tree: IRouteLink[] = segments.map(segment => {
|
|
93
94
|
const route = routes.find(r =>
|
|
@@ -120,7 +121,7 @@ export async function getRouteLinkTree(market: string = 'ww', locale: string = '
|
|
|
120
121
|
locale: {
|
|
121
122
|
equals: locale,
|
|
122
123
|
},
|
|
123
|
-
}, market, locale
|
|
124
|
+
}, market, locale,
|
|
124
125
|
});
|
|
125
126
|
// console.log('getRouteLinkTree.routes');
|
|
126
127
|
const categories = await store.category.findMany();
|
|
@@ -167,5 +168,3 @@ export function resolveRoute(route: IRoute & { splat?: string }) {
|
|
|
167
168
|
// console.log('resolveRoute', route.schema, resolvedPathname);
|
|
168
169
|
return resolvedPathname;
|
|
169
170
|
}
|
|
170
|
-
|
|
171
|
-
export type StaticPath = { params: { [key: string]: string } };
|
|
@@ -2,10 +2,20 @@ import { IContextParams } from '@websolutespa/bom-core';
|
|
|
2
2
|
import { GetServerSideProps } from 'next';
|
|
3
3
|
import { getSiteMapIndex, getSiteMapXML, getSiteMapXSL } from './sitemap.service';
|
|
4
4
|
|
|
5
|
+
const ORIGIN = process.env.NEXT_PUBLIC_URL || '';
|
|
6
|
+
|
|
7
|
+
function getOrigin(host?: string): string {
|
|
8
|
+
if (host) {
|
|
9
|
+
return host.indexOf('localhost') !== -1 ? 'http://' + host : 'https://' + host;
|
|
10
|
+
} else {
|
|
11
|
+
return ORIGIN;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
export const getSiteMapIndexProps: GetServerSideProps = async (context) => {
|
|
6
16
|
const { req, res } = context;
|
|
7
|
-
// console.log(req.headers.location, req.headers.host, req.headers.origin, req.headers.protocol);
|
|
8
|
-
const sitemap = await getSiteMapIndex();
|
|
17
|
+
// console.log('getSiteMapIndexProps', req.headers.location, req.headers.host, req.headers.origin, req.headers.protocol);
|
|
18
|
+
const sitemap = await getSiteMapIndex(getOrigin(req.headers.host));
|
|
9
19
|
res.setHeader('Content-Type', 'application/xml; charset=UTF-8');
|
|
10
20
|
res.setHeader('X-Frame-Options', 'SAMEORIGIN');
|
|
11
21
|
res.setHeader('X-Robots-Tag', 'noindex, follow');
|
|
@@ -18,11 +28,11 @@ export const getSiteMapIndexProps: GetServerSideProps = async (context) => {
|
|
|
18
28
|
|
|
19
29
|
export const getSiteMapXMLProps: GetServerSideProps = async (context) => {
|
|
20
30
|
const { req, res } = context;
|
|
21
|
-
// console.log(req.headers.location, req.headers.host, req.headers.origin, req.headers.protocol);
|
|
31
|
+
// console.log('getSiteMapXMLProps', req.headers.location, req.headers.host, req.headers.origin, req.headers.protocol);
|
|
22
32
|
const params = context.params as IContextParams;
|
|
23
33
|
const market = params?.market;
|
|
24
34
|
const locale = params?.locale;
|
|
25
|
-
const sitemap = await getSiteMapXML(market, locale);
|
|
35
|
+
const sitemap = await getSiteMapXML(getOrigin(req.headers.host), market, locale);
|
|
26
36
|
res.setHeader('Content-Type', 'application/xml; charset=UTF-8');
|
|
27
37
|
res.setHeader('X-Frame-Options', 'SAMEORIGIN');
|
|
28
38
|
res.setHeader('X-Robots-Tag', 'noindex, follow');
|
|
@@ -35,7 +45,7 @@ export const getSiteMapXMLProps: GetServerSideProps = async (context) => {
|
|
|
35
45
|
|
|
36
46
|
export const getSiteMapXSLProps: GetServerSideProps = async (context) => {
|
|
37
47
|
const { req, res } = context;
|
|
38
|
-
// console.log(req.headers.location, req.headers.host, req.headers.origin, req.headers.protocol);
|
|
48
|
+
// console.log('getSiteMapXSLProps', req.headers.location, req.headers.host, req.headers.origin, req.headers.protocol);
|
|
39
49
|
const sitemap = await getSiteMapXSL();
|
|
40
50
|
res.setHeader('Content-Type', 'application/xml; charset=UTF-8');
|
|
41
51
|
res.setHeader('X-Frame-Options', 'SAMEORIGIN');
|
|
@@ -3,14 +3,12 @@ import { getLocales } from '../locale/locale.service';
|
|
|
3
3
|
import { getMarkets } from '../market/market.service';
|
|
4
4
|
import { getRoutes } from '../route/route.service';
|
|
5
5
|
|
|
6
|
-
const origin = process.env.NEXT_PUBLIC_URL;
|
|
7
|
-
|
|
8
6
|
export type ISiteMap = {
|
|
9
7
|
id: string;
|
|
10
8
|
updatedAt?: Date;
|
|
11
9
|
};
|
|
12
10
|
|
|
13
|
-
export async function getSiteMapIndex(): Promise<string> {
|
|
11
|
+
export async function getSiteMapIndex(origin: string): Promise<string> {
|
|
14
12
|
let markets: IMarket[] = await getMarkets();
|
|
15
13
|
let locales: ILocale[] = await getLocales();
|
|
16
14
|
markets = markets.filter(x => x.isActive !== false);
|
|
@@ -52,23 +50,23 @@ function getSiteMapXMLImage(canonical: IRouteCanonical): string {
|
|
|
52
50
|
</image:image>` : '';
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
function getSiteMapXMLAlternates(canonical: IRouteCanonical): string {
|
|
53
|
+
function getSiteMapXMLAlternates(origin: string, canonical: IRouteCanonical): string {
|
|
56
54
|
return canonical.alternates.map(alternate => `
|
|
57
55
|
<xhtml:link href="${origin}${alternate.id}" hreflang="${alternate.locale}-${alternate.market}" rel="alternate" />`).join('');
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
function getSiteMapXMLUrl(canonical: IRouteCanonical): string {
|
|
58
|
+
function getSiteMapXMLUrl(origin: string, canonical: IRouteCanonical): string {
|
|
61
59
|
return `
|
|
62
60
|
<url>
|
|
63
|
-
<loc>${origin}${canonical.id}</loc>${getSiteMapXMLLastMod(canonical)}${getSiteMapXMLAlternates(canonical)}${getSiteMapXMLImage(canonical)}
|
|
61
|
+
<loc>${origin}${canonical.id}</loc>${getSiteMapXMLLastMod(canonical)}${getSiteMapXMLAlternates(origin, canonical)}${getSiteMapXMLImage(canonical)}
|
|
64
62
|
</url>`;
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
function getSiteMapXMLUrls(canonicalRoutes: IRouteCanonical[]): string {
|
|
68
|
-
return canonicalRoutes.map((canonicalRoute) => getSiteMapXMLUrl(canonicalRoute)).join('');
|
|
65
|
+
function getSiteMapXMLUrls(origin: string, canonicalRoutes: IRouteCanonical[]): string {
|
|
66
|
+
return canonicalRoutes.map((canonicalRoute) => getSiteMapXMLUrl(origin, canonicalRoute)).join('');
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
export async function getSiteMapXML(marketId?: string, localeId?: string): Promise<string> {
|
|
69
|
+
export async function getSiteMapXML(origin: string, marketId?: string, localeId?: string): Promise<string> {
|
|
72
70
|
let markets: IMarket[] = await getMarkets();
|
|
73
71
|
let locales: ILocale[] = await getLocales();
|
|
74
72
|
markets = markets.filter(x => x.isActive !== false);
|
|
@@ -99,7 +97,7 @@ export async function getSiteMapXML(marketId?: string, localeId?: string): Promi
|
|
|
99
97
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
100
98
|
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
101
99
|
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
|
|
102
|
-
${getSiteMapXMLUrls(canonicalRoutes)}
|
|
100
|
+
${getSiteMapXMLUrls(origin, canonicalRoutes)}
|
|
103
101
|
</urlset>
|
|
104
102
|
`;
|
|
105
103
|
}
|
package/src/store/store.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ICategory, IEntity, ILabel, ILocale, IMarket, IMenu, INamedEntity, IQuerable, IRedirect, IRoute
|
|
3
|
-
} from '@websolutespa/bom-core';
|
|
1
|
+
import { ICategory, IEntity, ILabel, ILocale, IMarket, IMenu, INamedEntity, IQuerable, IRedirect, IRoute } from '@websolutespa/bom-core';
|
|
4
2
|
import { IFeatureType } from '../feature_type/feature_type';
|
|
5
3
|
import { IList } from '../list/list';
|
|
6
4
|
|