@websolutespa/bom-core 1.8.19 → 1.10.0-next.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 +12 -0
- package/dist/{index.mjs → index.cjs} +184 -10
- package/dist/index.d.cts +1363 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +14 -180
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
ImageStrategy: () => ImageStrategy,
|
|
34
|
+
JsonService: () => JsonService,
|
|
35
|
+
Logger: () => Logger,
|
|
36
|
+
LoggerLevel: () => LoggerLevel,
|
|
37
|
+
MenuCategoryStrategy: () => MenuCategoryStrategy,
|
|
38
|
+
RedirectReason: () => RedirectReason,
|
|
39
|
+
RouteStrategy: () => RouteStrategy,
|
|
40
|
+
arrayShuffle: () => arrayShuffle,
|
|
41
|
+
asCategoryId: () => asCategoryId,
|
|
42
|
+
asEntityId: () => asEntityId,
|
|
43
|
+
asEquatable: () => asEquatable,
|
|
44
|
+
asEquatableNumber: () => asEquatableNumber,
|
|
45
|
+
asEquatableString: () => asEquatableString,
|
|
46
|
+
asServerProps: () => asServerProps,
|
|
47
|
+
asSortedOptions: () => asSortedOptions,
|
|
48
|
+
awaitAll: () => awaitAll,
|
|
49
|
+
base64ToString: () => base64ToString,
|
|
50
|
+
camelToSnakeCase: () => camelToSnakeCase,
|
|
51
|
+
cloneItem: () => cloneItem,
|
|
52
|
+
collectFeatureTypes: () => collectFeatureTypes,
|
|
53
|
+
collectFeatureTypes__: () => collectFeatureTypes__,
|
|
54
|
+
collectOptions: () => collectOptions,
|
|
55
|
+
collectRoutes: () => collectRoutes,
|
|
56
|
+
consoleWarn: () => consoleWarn,
|
|
57
|
+
decryptImageResize: () => decryptImageResize,
|
|
58
|
+
deepMerge: () => deepMerge,
|
|
59
|
+
defaultLocale: () => defaultLocale,
|
|
60
|
+
defaultMarket: () => defaultMarket,
|
|
61
|
+
eachCategorized: () => eachCategorized,
|
|
62
|
+
eachMarketLocale: () => eachMarketLocale,
|
|
63
|
+
eachMedia: () => eachMedia,
|
|
64
|
+
eachValue: () => eachValue,
|
|
65
|
+
encryptImageToken: () => encryptImageToken,
|
|
66
|
+
enumToList: () => enumToList,
|
|
67
|
+
excludeComponent: () => excludeComponent,
|
|
68
|
+
findCategoryInCategories: () => findCategoryInCategories,
|
|
69
|
+
findChildCategories: () => findChildCategories,
|
|
70
|
+
findRouteOfCategory: () => findRouteOfCategory,
|
|
71
|
+
findRoutesOfCategory: () => findRoutesOfCategory,
|
|
72
|
+
getCategorySegments: () => getCategorySegments,
|
|
73
|
+
getCategorySegmentsByCategory: () => getCategorySegmentsByCategory,
|
|
74
|
+
getClassNames: () => getClassNames,
|
|
75
|
+
getCollectionDescription: () => getCollectionDescription,
|
|
76
|
+
getEnv: () => getEnv,
|
|
77
|
+
getHost: () => getHost,
|
|
78
|
+
getIsDevelopment: () => getIsDevelopment,
|
|
79
|
+
getIsProduction: () => getIsProduction,
|
|
80
|
+
getOrigin: () => getOrigin,
|
|
81
|
+
getParentCategoriesById: () => getParentCategoriesById,
|
|
82
|
+
getParentCategory: () => getParentCategory,
|
|
83
|
+
getProto: () => getProto,
|
|
84
|
+
getRootCategory: () => getRootCategory,
|
|
85
|
+
getRouteHref: () => getRouteHref,
|
|
86
|
+
groupComponents: () => groupComponents,
|
|
87
|
+
hasComponents: () => hasComponents,
|
|
88
|
+
hasMarket: () => hasMarket,
|
|
89
|
+
httpDelete: () => httpDelete,
|
|
90
|
+
httpFetch: () => httpFetch,
|
|
91
|
+
httpGet: () => httpGet,
|
|
92
|
+
httpPatch: () => httpPatch,
|
|
93
|
+
httpPost: () => httpPost,
|
|
94
|
+
httpPut: () => httpPut,
|
|
95
|
+
isArray: () => isArray,
|
|
96
|
+
isBrowser: () => isBrowser,
|
|
97
|
+
isComponent: () => isComponent,
|
|
98
|
+
isComponentOfType: () => isComponentOfType,
|
|
99
|
+
isDevelopment: () => isDevelopment,
|
|
100
|
+
isEntity: () => isEntity,
|
|
101
|
+
isEquatable: () => isEquatable,
|
|
102
|
+
isHeaders: () => isHeaders,
|
|
103
|
+
isIncomingHttpHeaders: () => isIncomingHttpHeaders,
|
|
104
|
+
isLocalizedString: () => isLocalizedString,
|
|
105
|
+
isMedia: () => isMedia,
|
|
106
|
+
isMediaImage: () => isMediaImage,
|
|
107
|
+
isMediaJson: () => isMediaJson,
|
|
108
|
+
isMediaPdf: () => isMediaPdf,
|
|
109
|
+
isMediaVideo: () => isMediaVideo,
|
|
110
|
+
isMenuCategory: () => isMenuCategory,
|
|
111
|
+
isMenuGroup: () => isMenuGroup,
|
|
112
|
+
isMenuHref: () => isMenuHref,
|
|
113
|
+
isMenuLink: () => isMenuLink,
|
|
114
|
+
isMenuPage: () => isMenuPage,
|
|
115
|
+
isMenuRoute: () => isMenuRoute,
|
|
116
|
+
isNonEmptyArray: () => isNonEmptyArray,
|
|
117
|
+
isNotNullString: () => isNotNullString,
|
|
118
|
+
isNumber: () => isNumber,
|
|
119
|
+
isObject: () => isObject,
|
|
120
|
+
isProduction: () => isProduction,
|
|
121
|
+
isPromise: () => isPromise,
|
|
122
|
+
isRelation: () => isRelation,
|
|
123
|
+
isReservedCollectionDescription: () => isReservedCollectionDescription,
|
|
124
|
+
isStage: () => isStage,
|
|
125
|
+
isString: () => isString,
|
|
126
|
+
isUndecoratedCategory: () => isUndecoratedCategory,
|
|
127
|
+
isUndecoratedMenuCategory: () => isUndecoratedMenuCategory,
|
|
128
|
+
isUndecoratedMenuItem: () => isUndecoratedMenuItem,
|
|
129
|
+
isUndecoratedMenuPage: () => isUndecoratedMenuPage,
|
|
130
|
+
isUndecoratedNav: () => isUndecoratedNav,
|
|
131
|
+
isUnresolvedCategory: () => isUnresolvedCategory,
|
|
132
|
+
isUnresolvedRelation: () => isUnresolvedRelation,
|
|
133
|
+
isValidCollectionDescription: () => isValidCollectionDescription,
|
|
134
|
+
isValidString: () => isValidString,
|
|
135
|
+
localize: () => localize,
|
|
136
|
+
localizeItem: () => localizeItem,
|
|
137
|
+
localizeValue: () => localizeValue,
|
|
138
|
+
localizedToString: () => localizedToString,
|
|
139
|
+
merge: () => merge,
|
|
140
|
+
pascalCaseToCamelCase: () => pascalCaseToCamelCase,
|
|
141
|
+
pascalCaseToCharCase: () => pascalCaseToCharCase,
|
|
142
|
+
pascalCaseToKebabCase: () => pascalCaseToKebabCase,
|
|
143
|
+
pascalCaseToSnakeCase: () => pascalCaseToSnakeCase,
|
|
144
|
+
passwordStrategy: () => passwordStrategy,
|
|
145
|
+
pickComponent: () => pickComponent,
|
|
146
|
+
pickHero: () => pickHero,
|
|
147
|
+
prependHero: () => prependHero,
|
|
148
|
+
qsDeserialize: () => qsDeserialize,
|
|
149
|
+
qsDeserializeRaw: () => qsDeserializeRaw,
|
|
150
|
+
qsSerialize: () => qsSerialize,
|
|
151
|
+
qsSerializeRaw: () => qsSerializeRaw,
|
|
152
|
+
resolveMediaType: () => resolveMediaType,
|
|
153
|
+
stringToBase64: () => stringToBase64,
|
|
154
|
+
toCamelCase: () => toCamelCase,
|
|
155
|
+
toCharCase: () => toCharCase,
|
|
156
|
+
toDisplayName: () => toDisplayName,
|
|
157
|
+
toFindParams: () => toFindParams,
|
|
158
|
+
toKebabCase: () => toKebabCase,
|
|
159
|
+
toPascalCase: () => toPascalCase,
|
|
160
|
+
toPluralName: () => toPluralName,
|
|
161
|
+
toSnakeCase: () => toSnakeCase,
|
|
162
|
+
toTitleCase: () => toTitleCase,
|
|
163
|
+
toValidCollectionName: () => toValidCollectionName,
|
|
164
|
+
unknownCaseToPascalCase: () => unknownCaseToPascalCase,
|
|
165
|
+
uuidv4: () => uuidv4,
|
|
166
|
+
withSchema: () => withSchema
|
|
167
|
+
});
|
|
168
|
+
module.exports = __toCommonJS(index_exports);
|
|
169
|
+
|
|
1
170
|
// src/utils/arrayShuffle.ts
|
|
2
171
|
function arrayShuffle(items) {
|
|
3
172
|
return items.map((item) => ({ item, order: Math.random() })).sort((a, b) => a.order - b.order).map(({ item }) => item);
|
|
@@ -410,7 +579,7 @@ function isMediaPdf(media) {
|
|
|
410
579
|
return false;
|
|
411
580
|
}
|
|
412
581
|
function isMedia(item) {
|
|
413
|
-
return isObject(item) && "type" in item && (isValidString(item.url) || isValidString(item.src));
|
|
582
|
+
return isObject(item) && ("mimeType" in item || "type" in item) && (isValidString(item.url) || isValidString(item.src));
|
|
414
583
|
}
|
|
415
584
|
|
|
416
585
|
// src/types/menu.ts
|
|
@@ -624,7 +793,7 @@ function classNameCollectionToString(className) {
|
|
|
624
793
|
let classNames = "";
|
|
625
794
|
for (let i = 0; i < total; i++) {
|
|
626
795
|
const key = keys[i];
|
|
627
|
-
const value = className[
|
|
796
|
+
const value = className[key];
|
|
628
797
|
if (!value) {
|
|
629
798
|
continue;
|
|
630
799
|
}
|
|
@@ -653,7 +822,7 @@ function getClassNames(...props) {
|
|
|
653
822
|
}
|
|
654
823
|
|
|
655
824
|
// src/collection/collection.ts
|
|
656
|
-
|
|
825
|
+
var import_pluralize = __toESM(require("pluralize"), 1);
|
|
657
826
|
function getCollectionDescription(text) {
|
|
658
827
|
text = toValidCollectionName(text);
|
|
659
828
|
const displayName = toDisplayName(text);
|
|
@@ -693,7 +862,7 @@ function toDisplayName(text) {
|
|
|
693
862
|
return toTitleCase(text).replace(/\s/g, "");
|
|
694
863
|
}
|
|
695
864
|
function toPluralName(text) {
|
|
696
|
-
const plural =
|
|
865
|
+
const plural = import_pluralize.default.plural(text);
|
|
697
866
|
return plural === text ? `${plural}es` : plural;
|
|
698
867
|
}
|
|
699
868
|
function toTitleCase(text) {
|
|
@@ -823,6 +992,7 @@ function decryptImageResize(token) {
|
|
|
823
992
|
|
|
824
993
|
// src/json/json.service.ts
|
|
825
994
|
var JsonService = class {
|
|
995
|
+
items;
|
|
826
996
|
constructor(items) {
|
|
827
997
|
this.items = items;
|
|
828
998
|
}
|
|
@@ -1079,7 +1249,7 @@ var JsonService = class {
|
|
|
1079
1249
|
return false;
|
|
1080
1250
|
}
|
|
1081
1251
|
const [longitude, latitude, maxDistance, minDistance] = near;
|
|
1082
|
-
const distance = calculateDistanceInMeters_(itemLongitude, itemLatitude, longitude, latitude);
|
|
1252
|
+
const distance = longitude && latitude ? calculateDistanceInMeters_(itemLongitude, itemLatitude, longitude, latitude) : 0;
|
|
1083
1253
|
if (typeof maxDistance === "number" && typeof minDistance === "number") {
|
|
1084
1254
|
return distance <= maxDistance && distance >= minDistance;
|
|
1085
1255
|
} else if (typeof maxDistance === "number") {
|
|
@@ -1265,7 +1435,7 @@ function isLocalizedString(value) {
|
|
|
1265
1435
|
return isLocalizedString2;
|
|
1266
1436
|
}
|
|
1267
1437
|
function localizedToString(json, locale, defaultLocale2 = DEFAULT_LOCALE) {
|
|
1268
|
-
const localizedString = json[locale] || json[defaultLocale2] || Object.values(json)[0];
|
|
1438
|
+
const localizedString = json[locale] || json[defaultLocale2] || Object.values(json)[0] || "";
|
|
1269
1439
|
return localizedString;
|
|
1270
1440
|
}
|
|
1271
1441
|
function localize(value, locale, defaultLocale2 = DEFAULT_LOCALE) {
|
|
@@ -1304,6 +1474,7 @@ var LoggerLevel = /* @__PURE__ */ ((LoggerLevel2) => {
|
|
|
1304
1474
|
return LoggerLevel2;
|
|
1305
1475
|
})(LoggerLevel || {});
|
|
1306
1476
|
var Logger = class {
|
|
1477
|
+
static level_ = 5 /* ALL */;
|
|
1307
1478
|
static setLevel(level) {
|
|
1308
1479
|
this.level_ = level;
|
|
1309
1480
|
}
|
|
@@ -1335,7 +1506,6 @@ var Logger = class {
|
|
|
1335
1506
|
}
|
|
1336
1507
|
}
|
|
1337
1508
|
};
|
|
1338
|
-
Logger.level_ = 5 /* ALL */;
|
|
1339
1509
|
|
|
1340
1510
|
// src/market/market.ts
|
|
1341
1511
|
function getDefaultMarket() {
|
|
@@ -1517,7 +1687,10 @@ function getPickedProps(item) {
|
|
|
1517
1687
|
"order",
|
|
1518
1688
|
"template",
|
|
1519
1689
|
"updatedAt",
|
|
1520
|
-
"useSplat"
|
|
1690
|
+
"useSplat",
|
|
1691
|
+
// 'createdAt',
|
|
1692
|
+
"updatedAt",
|
|
1693
|
+
"_status"
|
|
1521
1694
|
].includes(k)));
|
|
1522
1695
|
return pickedProps;
|
|
1523
1696
|
}
|
|
@@ -1638,7 +1811,8 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1638
1811
|
function hasMarket(item, market) {
|
|
1639
1812
|
return !item.markets || item.markets.length === 0 || item.markets.includes(market.id);
|
|
1640
1813
|
}
|
|
1641
|
-
export
|
|
1814
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1815
|
+
0 && (module.exports = {
|
|
1642
1816
|
ImageStrategy,
|
|
1643
1817
|
JsonService,
|
|
1644
1818
|
Logger,
|
|
@@ -1773,4 +1947,4 @@ export {
|
|
|
1773
1947
|
unknownCaseToPascalCase,
|
|
1774
1948
|
uuidv4,
|
|
1775
1949
|
withSchema
|
|
1776
|
-
};
|
|
1950
|
+
});
|