@websolutespa/bom-core 1.7.8 → 1.7.10
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 +7 -4
- package/dist/index.js +36 -4
- package/dist/index.mjs +31 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -43,9 +43,6 @@ type ServerSidePropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends
|
|
|
43
43
|
};
|
|
44
44
|
type IServerSideSplatContext<T extends {} = {}> = ServerSidePropsContext<IContextBaseParams & T>;
|
|
45
45
|
type IServerSideContext<T extends {} = {}> = ServerSidePropsContext<IContextParams & T>;
|
|
46
|
-
type StateValue = StateValue[] | {
|
|
47
|
-
[key: string]: StateValue;
|
|
48
|
-
} | number | string | boolean | null | undefined;
|
|
49
46
|
type IPartial<T> = {
|
|
50
47
|
[P in keyof T]?: Partial<T[P]>;
|
|
51
48
|
};
|
|
@@ -724,6 +721,8 @@ declare function textToSlug(title: string): string;
|
|
|
724
721
|
|
|
725
722
|
declare function asEquatable(value: string): IEquatable;
|
|
726
723
|
|
|
724
|
+
declare function asSortedOptions<T extends INamedEntity = INamedEntity>(items: T[]): IOption[];
|
|
725
|
+
|
|
727
726
|
/**
|
|
728
727
|
* PascalCase
|
|
729
728
|
* camelCase
|
|
@@ -780,8 +779,12 @@ type ListItem<T> = {
|
|
|
780
779
|
*/
|
|
781
780
|
declare function enumToList<T extends Record<string, number | string>>(enumeration: T, separatorRegex?: RegExp): ListItem<T>[];
|
|
782
781
|
|
|
782
|
+
declare function isNumber(item: unknown): item is number;
|
|
783
|
+
declare function isString(item: unknown): item is string;
|
|
784
|
+
declare function isValidString(item: unknown): item is string;
|
|
783
785
|
declare function isArray<T = unknown>(item: unknown): item is Array<T>;
|
|
784
786
|
declare function isObject<T = Record<string, unknown>>(item: unknown): item is T;
|
|
787
|
+
declare function isPromise(result: unknown): result is Promise<unknown>;
|
|
785
788
|
declare function isNotNullString(item: unknown): item is string;
|
|
786
789
|
declare function isEquatable(item: unknown): item is IEquatable;
|
|
787
790
|
declare function isEntity(item: unknown): item is IEntity;
|
|
@@ -804,4 +807,4 @@ declare function asServerProps(props: any): any;
|
|
|
804
807
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
805
808
|
declare function merge(target: any, source: any): any;
|
|
806
809
|
|
|
807
|
-
export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IActionEmailData, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEmailConfig, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaImage, IMediaInfo, IMediaJson, IMediaPdf, IMediaType, IMediaVideo, 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,
|
|
810
|
+
export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IActionEmailData, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEmailConfig, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaImage, IMediaInfo, IMediaJson, IMediaPdf, IMediaType, IMediaVideo, 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, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, asSortedOptions, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getProto, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isCategory, isDevelopment, isEntity, isEquatable, isHeaders, isIncomingHttpHeaders, isLocalizedString, isMediaImage, isMediaJson, isMediaPdf, isMediaVideo, isMenuHref, isNotNullString, isNumber, isObject, isProduction, isPromise, isRelation, isReservedCollectionDescription, isStage, isString, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, isValidString, 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
|
@@ -38,6 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
asCategoryId: () => asCategoryId,
|
|
39
39
|
asEquatable: () => asEquatable,
|
|
40
40
|
asServerProps: () => asServerProps,
|
|
41
|
+
asSortedOptions: () => asSortedOptions,
|
|
41
42
|
awaitAll: () => awaitAll,
|
|
42
43
|
camelToSnakeCase: () => camelToSnakeCase,
|
|
43
44
|
cloneItem: () => cloneItem,
|
|
@@ -85,17 +86,21 @@ __export(src_exports, {
|
|
|
85
86
|
isMediaVideo: () => isMediaVideo,
|
|
86
87
|
isMenuHref: () => isMenuHref,
|
|
87
88
|
isNotNullString: () => isNotNullString,
|
|
89
|
+
isNumber: () => isNumber,
|
|
88
90
|
isObject: () => isObject,
|
|
89
91
|
isProduction: () => isProduction,
|
|
92
|
+
isPromise: () => isPromise,
|
|
90
93
|
isRelation: () => isRelation,
|
|
91
94
|
isReservedCollectionDescription: () => isReservedCollectionDescription,
|
|
92
95
|
isStage: () => isStage,
|
|
96
|
+
isString: () => isString,
|
|
93
97
|
isUndecoratedMenuCategory: () => isUndecoratedMenuCategory,
|
|
94
98
|
isUndecoratedMenuItem: () => isUndecoratedMenuItem,
|
|
95
99
|
isUndecoratedMenuPage: () => isUndecoratedMenuPage,
|
|
96
100
|
isUndecoratedNav: () => isUndecoratedNav,
|
|
97
101
|
isUnresolvedRelation: () => isUnresolvedRelation,
|
|
98
102
|
isValidCollectionDescription: () => isValidCollectionDescription,
|
|
103
|
+
isValidString: () => isValidString,
|
|
99
104
|
localize: () => localize,
|
|
100
105
|
localizeItem: () => localizeItem,
|
|
101
106
|
localizeValue: () => localizeValue,
|
|
@@ -299,6 +304,16 @@ function asEquatable(value) {
|
|
|
299
304
|
return value;
|
|
300
305
|
}
|
|
301
306
|
|
|
307
|
+
// src/utils/asSortedOptions.ts
|
|
308
|
+
function asSortedOptions(items) {
|
|
309
|
+
items.sort((a, b) => {
|
|
310
|
+
const nameA = a.name.toLowerCase();
|
|
311
|
+
const nameB = b.name.toLowerCase();
|
|
312
|
+
return nameA < nameB ? -1 : nameA > nameB ? 1 : 0;
|
|
313
|
+
});
|
|
314
|
+
return items;
|
|
315
|
+
}
|
|
316
|
+
|
|
302
317
|
// src/utils/babelCase.ts
|
|
303
318
|
function unknownCaseToPascalCase(unknownCase) {
|
|
304
319
|
const pascalCase = unknownCase.replace(
|
|
@@ -350,12 +365,24 @@ function toSnakeCase(unknownCase) {
|
|
|
350
365
|
}
|
|
351
366
|
|
|
352
367
|
// src/utils/typeGuards.ts
|
|
368
|
+
function isNumber(item) {
|
|
369
|
+
return typeof item === "number";
|
|
370
|
+
}
|
|
371
|
+
function isString(item) {
|
|
372
|
+
return typeof item === "string";
|
|
373
|
+
}
|
|
374
|
+
function isValidString(item) {
|
|
375
|
+
return typeof item === "string" && item.length > 0;
|
|
376
|
+
}
|
|
353
377
|
function isArray(item) {
|
|
354
378
|
return Array.isArray(item);
|
|
355
379
|
}
|
|
356
380
|
function isObject(item) {
|
|
357
381
|
return item != null && typeof item === "object" && !isArray(item);
|
|
358
382
|
}
|
|
383
|
+
function isPromise(result) {
|
|
384
|
+
return isObject(result) && typeof result.then === "function";
|
|
385
|
+
}
|
|
359
386
|
function isNotNullString(item) {
|
|
360
387
|
return typeof item === "string" && Boolean(item);
|
|
361
388
|
}
|
|
@@ -1074,17 +1101,17 @@ function getHost(headers) {
|
|
|
1074
1101
|
}
|
|
1075
1102
|
function getProto(headers) {
|
|
1076
1103
|
if (isIncomingHttpHeaders(headers)) {
|
|
1077
|
-
return headers["x-forwarded-proto"] || "https
|
|
1104
|
+
return headers["x-forwarded-proto"] || "https";
|
|
1078
1105
|
} else if (isHeaders(headers)) {
|
|
1079
|
-
return headers.get("X-Forwarded-Proto") || "https
|
|
1106
|
+
return headers.get("X-Forwarded-Proto") || "https";
|
|
1080
1107
|
} else {
|
|
1081
|
-
return "https
|
|
1108
|
+
return "https";
|
|
1082
1109
|
}
|
|
1083
1110
|
}
|
|
1084
1111
|
function getOrigin(headers) {
|
|
1085
1112
|
const host = getHost(headers);
|
|
1086
1113
|
if (host) {
|
|
1087
|
-
return host.indexOf("localhost") !== -1 ? "http://" + host : getProto(headers) + host;
|
|
1114
|
+
return host.indexOf("localhost") !== -1 ? "http://" + host : getProto(headers) + "://" + host;
|
|
1088
1115
|
} else {
|
|
1089
1116
|
return process.env.NEXT_PUBLIC_URL || "";
|
|
1090
1117
|
}
|
|
@@ -1293,6 +1320,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1293
1320
|
asCategoryId,
|
|
1294
1321
|
asEquatable,
|
|
1295
1322
|
asServerProps,
|
|
1323
|
+
asSortedOptions,
|
|
1296
1324
|
awaitAll,
|
|
1297
1325
|
camelToSnakeCase,
|
|
1298
1326
|
cloneItem,
|
|
@@ -1340,17 +1368,21 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1340
1368
|
isMediaVideo,
|
|
1341
1369
|
isMenuHref,
|
|
1342
1370
|
isNotNullString,
|
|
1371
|
+
isNumber,
|
|
1343
1372
|
isObject,
|
|
1344
1373
|
isProduction,
|
|
1374
|
+
isPromise,
|
|
1345
1375
|
isRelation,
|
|
1346
1376
|
isReservedCollectionDescription,
|
|
1347
1377
|
isStage,
|
|
1378
|
+
isString,
|
|
1348
1379
|
isUndecoratedMenuCategory,
|
|
1349
1380
|
isUndecoratedMenuItem,
|
|
1350
1381
|
isUndecoratedMenuPage,
|
|
1351
1382
|
isUndecoratedNav,
|
|
1352
1383
|
isUnresolvedRelation,
|
|
1353
1384
|
isValidCollectionDescription,
|
|
1385
|
+
isValidString,
|
|
1354
1386
|
localize,
|
|
1355
1387
|
localizeItem,
|
|
1356
1388
|
localizeValue,
|
package/dist/index.mjs
CHANGED
|
@@ -171,6 +171,16 @@ function asEquatable(value) {
|
|
|
171
171
|
return value;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
// src/utils/asSortedOptions.ts
|
|
175
|
+
function asSortedOptions(items) {
|
|
176
|
+
items.sort((a, b) => {
|
|
177
|
+
const nameA = a.name.toLowerCase();
|
|
178
|
+
const nameB = b.name.toLowerCase();
|
|
179
|
+
return nameA < nameB ? -1 : nameA > nameB ? 1 : 0;
|
|
180
|
+
});
|
|
181
|
+
return items;
|
|
182
|
+
}
|
|
183
|
+
|
|
174
184
|
// src/utils/babelCase.ts
|
|
175
185
|
function unknownCaseToPascalCase(unknownCase) {
|
|
176
186
|
const pascalCase = unknownCase.replace(
|
|
@@ -222,12 +232,24 @@ function toSnakeCase(unknownCase) {
|
|
|
222
232
|
}
|
|
223
233
|
|
|
224
234
|
// src/utils/typeGuards.ts
|
|
235
|
+
function isNumber(item) {
|
|
236
|
+
return typeof item === "number";
|
|
237
|
+
}
|
|
238
|
+
function isString(item) {
|
|
239
|
+
return typeof item === "string";
|
|
240
|
+
}
|
|
241
|
+
function isValidString(item) {
|
|
242
|
+
return typeof item === "string" && item.length > 0;
|
|
243
|
+
}
|
|
225
244
|
function isArray(item) {
|
|
226
245
|
return Array.isArray(item);
|
|
227
246
|
}
|
|
228
247
|
function isObject(item) {
|
|
229
248
|
return item != null && typeof item === "object" && !isArray(item);
|
|
230
249
|
}
|
|
250
|
+
function isPromise(result) {
|
|
251
|
+
return isObject(result) && typeof result.then === "function";
|
|
252
|
+
}
|
|
231
253
|
function isNotNullString(item) {
|
|
232
254
|
return typeof item === "string" && Boolean(item);
|
|
233
255
|
}
|
|
@@ -946,17 +968,17 @@ function getHost(headers) {
|
|
|
946
968
|
}
|
|
947
969
|
function getProto(headers) {
|
|
948
970
|
if (isIncomingHttpHeaders(headers)) {
|
|
949
|
-
return headers["x-forwarded-proto"] || "https
|
|
971
|
+
return headers["x-forwarded-proto"] || "https";
|
|
950
972
|
} else if (isHeaders(headers)) {
|
|
951
|
-
return headers.get("X-Forwarded-Proto") || "https
|
|
973
|
+
return headers.get("X-Forwarded-Proto") || "https";
|
|
952
974
|
} else {
|
|
953
|
-
return "https
|
|
975
|
+
return "https";
|
|
954
976
|
}
|
|
955
977
|
}
|
|
956
978
|
function getOrigin(headers) {
|
|
957
979
|
const host = getHost(headers);
|
|
958
980
|
if (host) {
|
|
959
|
-
return host.indexOf("localhost") !== -1 ? "http://" + host : getProto(headers) + host;
|
|
981
|
+
return host.indexOf("localhost") !== -1 ? "http://" + host : getProto(headers) + "://" + host;
|
|
960
982
|
} else {
|
|
961
983
|
return process.env.NEXT_PUBLIC_URL || "";
|
|
962
984
|
}
|
|
@@ -1164,6 +1186,7 @@ export {
|
|
|
1164
1186
|
asCategoryId,
|
|
1165
1187
|
asEquatable,
|
|
1166
1188
|
asServerProps,
|
|
1189
|
+
asSortedOptions,
|
|
1167
1190
|
awaitAll,
|
|
1168
1191
|
camelToSnakeCase,
|
|
1169
1192
|
cloneItem,
|
|
@@ -1211,17 +1234,21 @@ export {
|
|
|
1211
1234
|
isMediaVideo,
|
|
1212
1235
|
isMenuHref,
|
|
1213
1236
|
isNotNullString,
|
|
1237
|
+
isNumber,
|
|
1214
1238
|
isObject,
|
|
1215
1239
|
isProduction,
|
|
1240
|
+
isPromise,
|
|
1216
1241
|
isRelation,
|
|
1217
1242
|
isReservedCollectionDescription,
|
|
1218
1243
|
isStage,
|
|
1244
|
+
isString,
|
|
1219
1245
|
isUndecoratedMenuCategory,
|
|
1220
1246
|
isUndecoratedMenuItem,
|
|
1221
1247
|
isUndecoratedMenuPage,
|
|
1222
1248
|
isUndecoratedNav,
|
|
1223
1249
|
isUnresolvedRelation,
|
|
1224
1250
|
isValidCollectionDescription,
|
|
1251
|
+
isValidString,
|
|
1225
1252
|
localize,
|
|
1226
1253
|
localizeItem,
|
|
1227
1254
|
localizeValue,
|