@websolutespa/bom-core 1.7.3 → 1.7.5
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 +150 -138
- package/dist/index.d.ts +26 -2
- package/dist/index.js +56 -3
- package/dist/index.mjs +51 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,138 +1,150 @@
|
|
|
1
|
-
# @websolutespa/bom-core
|
|
2
|
-
|
|
3
|
-
## 1.7.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
## 1.7.
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
## 1.7.
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
## 1.7.
|
|
22
|
-
|
|
23
|
-
###
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
## 1.
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
###
|
|
36
|
-
|
|
37
|
-
- Modified:
|
|
38
|
-
|
|
39
|
-
##
|
|
40
|
-
|
|
41
|
-
### Patch Changes
|
|
42
|
-
|
|
43
|
-
- Added:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- Modified:
|
|
64
|
-
|
|
65
|
-
## 0.6.
|
|
66
|
-
|
|
67
|
-
### Patch Changes
|
|
68
|
-
|
|
69
|
-
- Added:
|
|
70
|
-
|
|
71
|
-
## 0.6.
|
|
72
|
-
|
|
73
|
-
###
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
## 0.
|
|
78
|
-
|
|
79
|
-
###
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
- Modified:
|
|
102
|
-
|
|
103
|
-
## 0.
|
|
104
|
-
|
|
105
|
-
###
|
|
106
|
-
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
## 0.
|
|
110
|
-
|
|
111
|
-
### Minor Changes
|
|
112
|
-
|
|
113
|
-
- Modified
|
|
114
|
-
|
|
115
|
-
## 0.1
|
|
116
|
-
|
|
117
|
-
### Patch Changes
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
|
|
121
|
-
## 0.
|
|
122
|
-
|
|
123
|
-
###
|
|
124
|
-
|
|
125
|
-
- Modified
|
|
126
|
-
|
|
127
|
-
## 0.1.
|
|
128
|
-
|
|
129
|
-
###
|
|
130
|
-
|
|
131
|
-
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
1
|
+
# @websolutespa/bom-core
|
|
2
|
+
|
|
3
|
+
## 1.7.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Modified: Logger
|
|
8
|
+
|
|
9
|
+
## 1.7.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Added: getOrigin, getHost
|
|
14
|
+
|
|
15
|
+
## 1.7.3
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updating: dependencies
|
|
20
|
+
|
|
21
|
+
## 1.7.2
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Fixing: JsonService containsClause
|
|
26
|
+
|
|
27
|
+
## 1.7.1
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Added: JsonService containsClause
|
|
32
|
+
|
|
33
|
+
## 1.7.0
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- 28e86bd: Modified: IPage, Store services & decorators
|
|
38
|
+
|
|
39
|
+
## 1.6.0
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- 6cbf4cb: Added: IAction, IEndUser, IConsentPreference, IPreference, ILegalNotice
|
|
44
|
+
|
|
45
|
+
## 0.6.6
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Modified: collectRoutes
|
|
50
|
+
|
|
51
|
+
## 0.6.5
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Added: collectFeatureTypes, collectOptions
|
|
56
|
+
- Modified: Category, collectRoutes, getRouteHref, entity
|
|
57
|
+
|
|
58
|
+
## 0.6.4
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- Added: typeGuards, IPagedResult
|
|
63
|
+
- Modified: IUndecoratedMenuCustom
|
|
64
|
+
|
|
65
|
+
## 0.6.3
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Added: isReservedCollectionDescription
|
|
70
|
+
|
|
71
|
+
## 0.6.2
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Modified: IMedia
|
|
76
|
+
|
|
77
|
+
## 0.6.1
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- Added: defaultMarket, defaultLocale
|
|
82
|
+
|
|
83
|
+
## 0.6.0
|
|
84
|
+
|
|
85
|
+
### Minor Changes
|
|
86
|
+
|
|
87
|
+
- Added Logger, IPaginationResult
|
|
88
|
+
|
|
89
|
+
## 0.5.0
|
|
90
|
+
|
|
91
|
+
### Minor Changes
|
|
92
|
+
|
|
93
|
+
- Modified: JsonService, qs
|
|
94
|
+
- Added: asEquatable, cloneItem, typeGuards
|
|
95
|
+
|
|
96
|
+
## 0.4.1
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- Added: IAnchor, babelCase
|
|
101
|
+
- Modified: IApplication, IPageRelation
|
|
102
|
+
|
|
103
|
+
## 0.4.0
|
|
104
|
+
|
|
105
|
+
### Minor Changes
|
|
106
|
+
|
|
107
|
+
- Updating: next 13
|
|
108
|
+
|
|
109
|
+
## 0.3.0
|
|
110
|
+
|
|
111
|
+
### Minor Changes
|
|
112
|
+
|
|
113
|
+
- Modified: HttpService
|
|
114
|
+
|
|
115
|
+
## 0.2.1
|
|
116
|
+
|
|
117
|
+
### Patch Changes
|
|
118
|
+
|
|
119
|
+
- Added: env ROOT_CATEGORY
|
|
120
|
+
|
|
121
|
+
## 0.2.0
|
|
122
|
+
|
|
123
|
+
### Minor Changes
|
|
124
|
+
|
|
125
|
+
- Modified routes, added redirects
|
|
126
|
+
|
|
127
|
+
## 0.1.2
|
|
128
|
+
|
|
129
|
+
### Patch Changes
|
|
130
|
+
|
|
131
|
+
- Modified: MockMenuService
|
|
132
|
+
|
|
133
|
+
## 0.1.1
|
|
134
|
+
|
|
135
|
+
### Patch Changes
|
|
136
|
+
|
|
137
|
+
- Modified: ILocalizable
|
|
138
|
+
|
|
139
|
+
## 0.1.0
|
|
140
|
+
|
|
141
|
+
### Minor Changes
|
|
142
|
+
|
|
143
|
+
- Added: splat routes
|
|
144
|
+
- Added: variants
|
|
145
|
+
|
|
146
|
+
## 0.0.1
|
|
147
|
+
|
|
148
|
+
### Patch Changes
|
|
149
|
+
|
|
150
|
+
- Added: first release
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
1
|
+
import { IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
|
|
2
2
|
import { ParsedUrlQuery } from 'querystring';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
@@ -632,6 +632,11 @@ declare function qsSerializeRaw(queryParams?: {}): string;
|
|
|
632
632
|
declare function qsDeserialize(query?: string, deserializedParams?: {}): QueryParams;
|
|
633
633
|
declare function qsDeserializeRaw(query?: string, deserializedParams?: {}): {};
|
|
634
634
|
|
|
635
|
+
declare function isHeaders(headers?: IncomingHttpHeaders | Headers): headers is Headers;
|
|
636
|
+
declare function isIncomingHttpHeaders(headers?: IncomingHttpHeaders | Headers): headers is IncomingHttpHeaders;
|
|
637
|
+
declare function getHost(headers?: IncomingHttpHeaders | Headers): string | null;
|
|
638
|
+
declare function getOrigin(headers?: IncomingHttpHeaders): string;
|
|
639
|
+
|
|
635
640
|
declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[]): IRoute[];
|
|
636
641
|
declare function eachMarketLocale(markets: IMarket[], locales: ILocale[], callback: (market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]) => void): void;
|
|
637
642
|
declare function eachCategorized(store: IMemoryStore<ICategorized>, callback: (item: ICategorized, key: string) => void): void;
|
|
@@ -672,6 +677,25 @@ declare function collectFeatureTypes<T extends IEntity = IEntity>(items: T[], ..
|
|
|
672
677
|
|
|
673
678
|
declare function collectOptions<T extends IEntity = IEntity>(items: T[], ...keys: string[]): Promise<Partial<Record<keyof T, IOption[]>>>;
|
|
674
679
|
|
|
680
|
+
/**
|
|
681
|
+
* Represents a primitive value that can be used in the deep merge operation.
|
|
682
|
+
*/
|
|
683
|
+
type Primitive = ((...args: any[]) => any) | string | number | boolean | null;
|
|
684
|
+
/**
|
|
685
|
+
* Represents a dynamic value that can be used in the deep merge operation.
|
|
686
|
+
*/
|
|
687
|
+
type Dynamic = {
|
|
688
|
+
[key: string]: Dynamic;
|
|
689
|
+
} | Dynamic[] | Primitive;
|
|
690
|
+
/**
|
|
691
|
+
* Deeply merges two objects or arrays.
|
|
692
|
+
*
|
|
693
|
+
* @param target - The target object or array to merge into.
|
|
694
|
+
* @param source - The source object or array to merge from.
|
|
695
|
+
* @returns The merged object or array.
|
|
696
|
+
*/
|
|
697
|
+
declare function deepMerge<T extends Dynamic, R extends Dynamic = T>(target?: Partial<T>, source?: Partial<R>): T & R;
|
|
698
|
+
|
|
675
699
|
type ListItem<T> = {
|
|
676
700
|
[K in keyof T]: {
|
|
677
701
|
readonly key: string;
|
|
@@ -709,4 +733,4 @@ declare function asServerProps(props: any): any;
|
|
|
709
733
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
710
734
|
declare function merge(target: any, source: any): any;
|
|
711
735
|
|
|
712
|
-
export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IOverrideReturnValue, IOverrideValue, IPackages, IPage, IPageRelation, IPageRelationResult, IPageUnresolvedRelation, IPagedResult, IPaginationResult, IPartial, IPreference, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNav, Json, JsonService, LiteralUnion, Logger, LoggerLevel, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getIsDevelopment, getIsProduction, getParentCategoriesById, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isCategory, isDevelopment, isEntity, isEquatable, isLocalizedString, isMenuHref, isNotNullString, isObject, isProduction, isRelation, isReservedCollectionDescription, isStage, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
|
|
736
|
+
export { Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IOverrideReturnValue, IOverrideValue, IPackages, IPage, IPageRelation, IPageRelationResult, IPageUnresolvedRelation, IPagedResult, IPaginationResult, IPartial, IPreference, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNav, Json, JsonService, LiteralUnion, Logger, LoggerLevel, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isCategory, isDevelopment, isEntity, isEquatable, isHeaders, isIncomingHttpHeaders, isLocalizedString, isMenuHref, isNotNullString, isObject, isProduction, isRelation, isReservedCollectionDescription, isStage, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,7 @@ __export(src_exports, {
|
|
|
45
45
|
collectOptions: () => collectOptions,
|
|
46
46
|
collectRoutes: () => collectRoutes,
|
|
47
47
|
consoleWarn: () => consoleWarn,
|
|
48
|
+
deepMerge: () => deepMerge,
|
|
48
49
|
defaultLocale: () => defaultLocale,
|
|
49
50
|
defaultMarket: () => defaultMarket,
|
|
50
51
|
eachCategorized: () => eachCategorized,
|
|
@@ -55,8 +56,10 @@ __export(src_exports, {
|
|
|
55
56
|
getClassNames: () => getClassNames,
|
|
56
57
|
getCollectionDescription: () => getCollectionDescription,
|
|
57
58
|
getEnv: () => getEnv,
|
|
59
|
+
getHost: () => getHost,
|
|
58
60
|
getIsDevelopment: () => getIsDevelopment,
|
|
59
61
|
getIsProduction: () => getIsProduction,
|
|
62
|
+
getOrigin: () => getOrigin,
|
|
60
63
|
getParentCategoriesById: () => getParentCategoriesById,
|
|
61
64
|
getRootCategory: () => getRootCategory,
|
|
62
65
|
getRouteHref: () => getRouteHref,
|
|
@@ -72,6 +75,8 @@ __export(src_exports, {
|
|
|
72
75
|
isDevelopment: () => isDevelopment,
|
|
73
76
|
isEntity: () => isEntity,
|
|
74
77
|
isEquatable: () => isEquatable,
|
|
78
|
+
isHeaders: () => isHeaders,
|
|
79
|
+
isIncomingHttpHeaders: () => isIncomingHttpHeaders,
|
|
75
80
|
isLocalizedString: () => isLocalizedString,
|
|
76
81
|
isMenuHref: () => isMenuHref,
|
|
77
82
|
isNotNullString: () => isNotNullString,
|
|
@@ -447,6 +452,24 @@ async function collectOptions(items, ...keys) {
|
|
|
447
452
|
return optionsGroup;
|
|
448
453
|
}
|
|
449
454
|
|
|
455
|
+
// src/utils/deepMerge.ts
|
|
456
|
+
function deepMerge(target, source) {
|
|
457
|
+
const output = { ...target };
|
|
458
|
+
if (isObject(target) && isObject(source)) {
|
|
459
|
+
Object.entries(source).forEach(([k, v]) => {
|
|
460
|
+
if (isArray(v)) {
|
|
461
|
+
output[k] = v.map((x) => deepMerge(x, x));
|
|
462
|
+
} else if (isObject(v)) {
|
|
463
|
+
const targetValue = k in target ? target[k] : void 0;
|
|
464
|
+
output[k] = isObject(targetValue) ? deepMerge(targetValue, v) : deepMerge(v, v);
|
|
465
|
+
} else {
|
|
466
|
+
output[k] = v;
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
return output;
|
|
471
|
+
}
|
|
472
|
+
|
|
450
473
|
// src/utils/enumToList.ts
|
|
451
474
|
function enumToList(enumeration, separatorRegex = /_/g) {
|
|
452
475
|
const array = Object.keys(enumeration);
|
|
@@ -876,10 +899,10 @@ var Logger = class {
|
|
|
876
899
|
this.level_ = level;
|
|
877
900
|
}
|
|
878
901
|
static getLevel() {
|
|
879
|
-
if (
|
|
880
|
-
return 1 /* ERROR */;
|
|
881
|
-
} else {
|
|
902
|
+
if (isDevelopment) {
|
|
882
903
|
return this.level_;
|
|
904
|
+
} else {
|
|
905
|
+
return 1 /* ERROR */;
|
|
883
906
|
}
|
|
884
907
|
}
|
|
885
908
|
static error(...args) {
|
|
@@ -1028,6 +1051,31 @@ function qsDeserializeRaw(query = "", deserializedParams = {}) {
|
|
|
1028
1051
|
return deserializedParams;
|
|
1029
1052
|
}
|
|
1030
1053
|
|
|
1054
|
+
// src/request/request.ts
|
|
1055
|
+
function isHeaders(headers) {
|
|
1056
|
+
return typeof headers === "object" && "get" in headers ? typeof headers.get === "function" : false;
|
|
1057
|
+
}
|
|
1058
|
+
function isIncomingHttpHeaders(headers) {
|
|
1059
|
+
return typeof headers === "object" && !("get" in headers);
|
|
1060
|
+
}
|
|
1061
|
+
function getHost(headers) {
|
|
1062
|
+
if (isIncomingHttpHeaders(headers)) {
|
|
1063
|
+
return headers["x-forwarded-host"] || headers.forwarded || headers.host || null;
|
|
1064
|
+
} else if (isHeaders(headers)) {
|
|
1065
|
+
return headers.get("X-Forwarded-Host") || headers.get("Forwarded") || headers.get("Host") || null;
|
|
1066
|
+
} else {
|
|
1067
|
+
return null;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
function getOrigin(headers) {
|
|
1071
|
+
const host = getHost(headers);
|
|
1072
|
+
if (host) {
|
|
1073
|
+
return host.indexOf("localhost") !== -1 ? "http://" + host : "https://" + host;
|
|
1074
|
+
} else {
|
|
1075
|
+
return process.env.NEXT_PUBLIC_URL || "";
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1031
1079
|
// src/route/route.ts
|
|
1032
1080
|
function collectRoutes(store, categories, markets, locales) {
|
|
1033
1081
|
const routes = [];
|
|
@@ -1199,6 +1247,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1199
1247
|
collectOptions,
|
|
1200
1248
|
collectRoutes,
|
|
1201
1249
|
consoleWarn,
|
|
1250
|
+
deepMerge,
|
|
1202
1251
|
defaultLocale,
|
|
1203
1252
|
defaultMarket,
|
|
1204
1253
|
eachCategorized,
|
|
@@ -1209,8 +1258,10 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1209
1258
|
getClassNames,
|
|
1210
1259
|
getCollectionDescription,
|
|
1211
1260
|
getEnv,
|
|
1261
|
+
getHost,
|
|
1212
1262
|
getIsDevelopment,
|
|
1213
1263
|
getIsProduction,
|
|
1264
|
+
getOrigin,
|
|
1214
1265
|
getParentCategoriesById,
|
|
1215
1266
|
getRootCategory,
|
|
1216
1267
|
getRouteHref,
|
|
@@ -1226,6 +1277,8 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1226
1277
|
isDevelopment,
|
|
1227
1278
|
isEntity,
|
|
1228
1279
|
isEquatable,
|
|
1280
|
+
isHeaders,
|
|
1281
|
+
isIncomingHttpHeaders,
|
|
1229
1282
|
isLocalizedString,
|
|
1230
1283
|
isMenuHref,
|
|
1231
1284
|
isNotNullString,
|
package/dist/index.mjs
CHANGED
|
@@ -329,6 +329,24 @@ async function collectOptions(items, ...keys) {
|
|
|
329
329
|
return optionsGroup;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
+
// src/utils/deepMerge.ts
|
|
333
|
+
function deepMerge(target, source) {
|
|
334
|
+
const output = { ...target };
|
|
335
|
+
if (isObject(target) && isObject(source)) {
|
|
336
|
+
Object.entries(source).forEach(([k, v]) => {
|
|
337
|
+
if (isArray(v)) {
|
|
338
|
+
output[k] = v.map((x) => deepMerge(x, x));
|
|
339
|
+
} else if (isObject(v)) {
|
|
340
|
+
const targetValue = k in target ? target[k] : void 0;
|
|
341
|
+
output[k] = isObject(targetValue) ? deepMerge(targetValue, v) : deepMerge(v, v);
|
|
342
|
+
} else {
|
|
343
|
+
output[k] = v;
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return output;
|
|
348
|
+
}
|
|
349
|
+
|
|
332
350
|
// src/utils/enumToList.ts
|
|
333
351
|
function enumToList(enumeration, separatorRegex = /_/g) {
|
|
334
352
|
const array = Object.keys(enumeration);
|
|
@@ -758,10 +776,10 @@ var Logger = class {
|
|
|
758
776
|
this.level_ = level;
|
|
759
777
|
}
|
|
760
778
|
static getLevel() {
|
|
761
|
-
if (
|
|
762
|
-
return 1 /* ERROR */;
|
|
763
|
-
} else {
|
|
779
|
+
if (isDevelopment) {
|
|
764
780
|
return this.level_;
|
|
781
|
+
} else {
|
|
782
|
+
return 1 /* ERROR */;
|
|
765
783
|
}
|
|
766
784
|
}
|
|
767
785
|
static error(...args) {
|
|
@@ -910,6 +928,31 @@ function qsDeserializeRaw(query = "", deserializedParams = {}) {
|
|
|
910
928
|
return deserializedParams;
|
|
911
929
|
}
|
|
912
930
|
|
|
931
|
+
// src/request/request.ts
|
|
932
|
+
function isHeaders(headers) {
|
|
933
|
+
return typeof headers === "object" && "get" in headers ? typeof headers.get === "function" : false;
|
|
934
|
+
}
|
|
935
|
+
function isIncomingHttpHeaders(headers) {
|
|
936
|
+
return typeof headers === "object" && !("get" in headers);
|
|
937
|
+
}
|
|
938
|
+
function getHost(headers) {
|
|
939
|
+
if (isIncomingHttpHeaders(headers)) {
|
|
940
|
+
return headers["x-forwarded-host"] || headers.forwarded || headers.host || null;
|
|
941
|
+
} else if (isHeaders(headers)) {
|
|
942
|
+
return headers.get("X-Forwarded-Host") || headers.get("Forwarded") || headers.get("Host") || null;
|
|
943
|
+
} else {
|
|
944
|
+
return null;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
function getOrigin(headers) {
|
|
948
|
+
const host = getHost(headers);
|
|
949
|
+
if (host) {
|
|
950
|
+
return host.indexOf("localhost") !== -1 ? "http://" + host : "https://" + host;
|
|
951
|
+
} else {
|
|
952
|
+
return process.env.NEXT_PUBLIC_URL || "";
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
913
956
|
// src/route/route.ts
|
|
914
957
|
function collectRoutes(store, categories, markets, locales) {
|
|
915
958
|
const routes = [];
|
|
@@ -1080,6 +1123,7 @@ export {
|
|
|
1080
1123
|
collectOptions,
|
|
1081
1124
|
collectRoutes,
|
|
1082
1125
|
consoleWarn,
|
|
1126
|
+
deepMerge,
|
|
1083
1127
|
defaultLocale,
|
|
1084
1128
|
defaultMarket,
|
|
1085
1129
|
eachCategorized,
|
|
@@ -1090,8 +1134,10 @@ export {
|
|
|
1090
1134
|
getClassNames,
|
|
1091
1135
|
getCollectionDescription,
|
|
1092
1136
|
getEnv,
|
|
1137
|
+
getHost,
|
|
1093
1138
|
getIsDevelopment,
|
|
1094
1139
|
getIsProduction,
|
|
1140
|
+
getOrigin,
|
|
1095
1141
|
getParentCategoriesById,
|
|
1096
1142
|
getRootCategory,
|
|
1097
1143
|
getRouteHref,
|
|
@@ -1107,6 +1153,8 @@ export {
|
|
|
1107
1153
|
isDevelopment,
|
|
1108
1154
|
isEntity,
|
|
1109
1155
|
isEquatable,
|
|
1156
|
+
isHeaders,
|
|
1157
|
+
isIncomingHttpHeaders,
|
|
1110
1158
|
isLocalizedString,
|
|
1111
1159
|
isMenuHref,
|
|
1112
1160
|
isNotNullString,
|