@websolutespa/bom-core 1.8.4 → 1.8.6
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.d.ts +5 -2
- package/dist/index.js +32 -10
- package/dist/index.mjs +30 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
|
|
|
2
2
|
import { ParsedUrlQuery } from 'querystring';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
5
|
+
declare function base64ToString(text: string): string;
|
|
6
|
+
declare function stringToBase64(text: string): string;
|
|
7
|
+
|
|
5
8
|
type Json = string | number | boolean | null | Json[] | {
|
|
6
9
|
[key: string]: Json;
|
|
7
10
|
};
|
|
@@ -1038,7 +1041,7 @@ declare enum RouteStrategy {
|
|
|
1038
1041
|
* @param locales - The list of locales.
|
|
1039
1042
|
* @returns An array of collected routes.
|
|
1040
1043
|
*/
|
|
1041
|
-
declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[]): IRoute[];
|
|
1044
|
+
declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[], medias?: IMedia[]): IRoute[];
|
|
1042
1045
|
/**
|
|
1043
1046
|
* Iterates over each market and locale combination and invokes the callback function.
|
|
1044
1047
|
*
|
|
@@ -1300,4 +1303,4 @@ declare function asServerProps(props: any): any;
|
|
|
1300
1303
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
1301
1304
|
declare function merge(target: any, source: any): any;
|
|
1302
1305
|
|
|
1303
|
-
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, IImageResize, 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, IPageItem, 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, ImageStrategy, Json, JsonService, LiteralUnion, Logger, LoggerLevel, MenuCategoryStrategy, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RequireAtLeastOne, RouteStrategy, SchemaType, ServerSidePropsContext, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, arrayShuffle, asCategoryId, asEntityId, asEquatable, asEquatableNumber, asEquatableString, asServerProps, asSortedOptions, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectFeatureTypes__, collectOptions, collectRoutes, consoleWarn, decryptImageResize, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, encryptImageToken, enumToList, findCategoryInCategories, findChildCategories, findRouteOfCategory, findRoutesOfCategory, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getParentCategory, getProto, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, 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, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, uuidv4, withSchema };
|
|
1306
|
+
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, IImageResize, 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, IPageItem, 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, ImageStrategy, Json, JsonService, LiteralUnion, Logger, LoggerLevel, MenuCategoryStrategy, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RequireAtLeastOne, RouteStrategy, SchemaType, ServerSidePropsContext, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, arrayShuffle, asCategoryId, asEntityId, asEquatable, asEquatableNumber, asEquatableString, asServerProps, asSortedOptions, awaitAll, base64ToString, camelToSnakeCase, cloneItem, collectFeatureTypes, collectFeatureTypes__, collectOptions, collectRoutes, consoleWarn, decryptImageResize, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, encryptImageToken, enumToList, findCategoryInCategories, findChildCategories, findRouteOfCategory, findRoutesOfCategory, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getParentCategory, getProto, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, 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, stringToBase64, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, uuidv4, withSchema };
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ __export(src_exports, {
|
|
|
46
46
|
asServerProps: () => asServerProps,
|
|
47
47
|
asSortedOptions: () => asSortedOptions,
|
|
48
48
|
awaitAll: () => awaitAll,
|
|
49
|
+
base64ToString: () => base64ToString,
|
|
49
50
|
camelToSnakeCase: () => camelToSnakeCase,
|
|
50
51
|
cloneItem: () => cloneItem,
|
|
51
52
|
collectFeatureTypes: () => collectFeatureTypes,
|
|
@@ -128,6 +129,7 @@ __export(src_exports, {
|
|
|
128
129
|
qsSerialize: () => qsSerialize,
|
|
129
130
|
qsSerializeRaw: () => qsSerializeRaw,
|
|
130
131
|
resolveMediaType: () => resolveMediaType,
|
|
132
|
+
stringToBase64: () => stringToBase64,
|
|
131
133
|
toCamelCase: () => toCamelCase,
|
|
132
134
|
toCharCase: () => toCharCase,
|
|
133
135
|
toDisplayName: () => toDisplayName,
|
|
@@ -489,6 +491,14 @@ function merge(target, source) {
|
|
|
489
491
|
return target;
|
|
490
492
|
}
|
|
491
493
|
|
|
494
|
+
// src/base64/base64.ts
|
|
495
|
+
function base64ToString(text) {
|
|
496
|
+
return isBrowser ? window.atob(text) : Buffer.from(text, "base64").toString();
|
|
497
|
+
}
|
|
498
|
+
function stringToBase64(text) {
|
|
499
|
+
return isBrowser ? window.btoa(text) : Buffer.from(text).toString("base64");
|
|
500
|
+
}
|
|
501
|
+
|
|
492
502
|
// src/category/category.ts
|
|
493
503
|
var ROOT_CATEGORY = process.env.ROOT_CATEGORY || "";
|
|
494
504
|
function getRootCategory(categories) {
|
|
@@ -717,12 +727,6 @@ async function httpDelete(url, options = {}) {
|
|
|
717
727
|
function getSecret() {
|
|
718
728
|
return process.env.IMAGE_SECRET || "The sun sets over the calm ocean";
|
|
719
729
|
}
|
|
720
|
-
function base64ToString_(text) {
|
|
721
|
-
return isBrowser ? window.atob(text) : Buffer.from(text, "base64").toString();
|
|
722
|
-
}
|
|
723
|
-
function stringToBase64_(text) {
|
|
724
|
-
return isBrowser ? window.btoa(text) : Buffer.from(text).toString("base64");
|
|
725
|
-
}
|
|
726
730
|
function textToArrayBuffer_(text) {
|
|
727
731
|
const encoder = new TextEncoder();
|
|
728
732
|
const arrayBuffer = encoder.encode(text);
|
|
@@ -744,11 +748,11 @@ function xor_(text, secret) {
|
|
|
744
748
|
}
|
|
745
749
|
function encrypt_(text, secret) {
|
|
746
750
|
const encrypted = xor_(text, secret);
|
|
747
|
-
const base64 =
|
|
751
|
+
const base64 = stringToBase64(encrypted);
|
|
748
752
|
return base64;
|
|
749
753
|
}
|
|
750
754
|
function decrypt_(base64, secret) {
|
|
751
|
-
const text =
|
|
755
|
+
const text = base64ToString(base64);
|
|
752
756
|
const decrypted = xor_(text, secret);
|
|
753
757
|
return decrypted;
|
|
754
758
|
}
|
|
@@ -1374,7 +1378,6 @@ function getPickedProps(item) {
|
|
|
1374
1378
|
const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
|
|
1375
1379
|
"category",
|
|
1376
1380
|
"isDefault",
|
|
1377
|
-
"media",
|
|
1378
1381
|
"order",
|
|
1379
1382
|
"template",
|
|
1380
1383
|
"updatedAt",
|
|
@@ -1382,7 +1385,7 @@ function getPickedProps(item) {
|
|
|
1382
1385
|
].includes(k)));
|
|
1383
1386
|
return pickedProps;
|
|
1384
1387
|
}
|
|
1385
|
-
function collectRoutes(store, categories, markets, locales) {
|
|
1388
|
+
function collectRoutes(store, categories, markets, locales, medias) {
|
|
1386
1389
|
const routes = [];
|
|
1387
1390
|
if (locales.length > 0 && markets.length > 0) {
|
|
1388
1391
|
const rootCategory = getRootCategory(categories);
|
|
@@ -1411,12 +1414,22 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
1411
1414
|
schema: key,
|
|
1412
1415
|
title
|
|
1413
1416
|
};
|
|
1417
|
+
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1418
|
+
if (Array.isArray(medias) && mediaId) {
|
|
1419
|
+
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1420
|
+
if (media) {
|
|
1421
|
+
route.media = media;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1414
1424
|
routes.push(route);
|
|
1415
1425
|
}
|
|
1416
1426
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1417
1427
|
if (!item.markets || item.markets.includes(market.id)) {
|
|
1418
1428
|
const title = localize(item.title, locale.id);
|
|
1419
1429
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1430
|
+
if (!id) {
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1420
1433
|
const pickedProps = getPickedProps(item);
|
|
1421
1434
|
const route = {
|
|
1422
1435
|
...pickedProps,
|
|
@@ -1428,6 +1441,13 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
1428
1441
|
schema: key,
|
|
1429
1442
|
title
|
|
1430
1443
|
};
|
|
1444
|
+
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1445
|
+
if (Array.isArray(medias) && mediaId) {
|
|
1446
|
+
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1447
|
+
if (media) {
|
|
1448
|
+
route.media = media;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1431
1451
|
routes.push(route);
|
|
1432
1452
|
}
|
|
1433
1453
|
});
|
|
@@ -1604,6 +1624,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1604
1624
|
asServerProps,
|
|
1605
1625
|
asSortedOptions,
|
|
1606
1626
|
awaitAll,
|
|
1627
|
+
base64ToString,
|
|
1607
1628
|
camelToSnakeCase,
|
|
1608
1629
|
cloneItem,
|
|
1609
1630
|
collectFeatureTypes,
|
|
@@ -1686,6 +1707,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1686
1707
|
qsSerialize,
|
|
1687
1708
|
qsSerializeRaw,
|
|
1688
1709
|
resolveMediaType,
|
|
1710
|
+
stringToBase64,
|
|
1689
1711
|
toCamelCase,
|
|
1690
1712
|
toCharCase,
|
|
1691
1713
|
toDisplayName,
|
package/dist/index.mjs
CHANGED
|
@@ -343,6 +343,14 @@ function merge(target, source) {
|
|
|
343
343
|
return target;
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
+
// src/base64/base64.ts
|
|
347
|
+
function base64ToString(text) {
|
|
348
|
+
return isBrowser ? window.atob(text) : Buffer.from(text, "base64").toString();
|
|
349
|
+
}
|
|
350
|
+
function stringToBase64(text) {
|
|
351
|
+
return isBrowser ? window.btoa(text) : Buffer.from(text).toString("base64");
|
|
352
|
+
}
|
|
353
|
+
|
|
346
354
|
// src/category/category.ts
|
|
347
355
|
var ROOT_CATEGORY = process.env.ROOT_CATEGORY || "";
|
|
348
356
|
function getRootCategory(categories) {
|
|
@@ -571,12 +579,6 @@ async function httpDelete(url, options = {}) {
|
|
|
571
579
|
function getSecret() {
|
|
572
580
|
return process.env.IMAGE_SECRET || "The sun sets over the calm ocean";
|
|
573
581
|
}
|
|
574
|
-
function base64ToString_(text) {
|
|
575
|
-
return isBrowser ? window.atob(text) : Buffer.from(text, "base64").toString();
|
|
576
|
-
}
|
|
577
|
-
function stringToBase64_(text) {
|
|
578
|
-
return isBrowser ? window.btoa(text) : Buffer.from(text).toString("base64");
|
|
579
|
-
}
|
|
580
582
|
function textToArrayBuffer_(text) {
|
|
581
583
|
const encoder = new TextEncoder();
|
|
582
584
|
const arrayBuffer = encoder.encode(text);
|
|
@@ -598,11 +600,11 @@ function xor_(text, secret) {
|
|
|
598
600
|
}
|
|
599
601
|
function encrypt_(text, secret) {
|
|
600
602
|
const encrypted = xor_(text, secret);
|
|
601
|
-
const base64 =
|
|
603
|
+
const base64 = stringToBase64(encrypted);
|
|
602
604
|
return base64;
|
|
603
605
|
}
|
|
604
606
|
function decrypt_(base64, secret) {
|
|
605
|
-
const text =
|
|
607
|
+
const text = base64ToString(base64);
|
|
606
608
|
const decrypted = xor_(text, secret);
|
|
607
609
|
return decrypted;
|
|
608
610
|
}
|
|
@@ -1228,7 +1230,6 @@ function getPickedProps(item) {
|
|
|
1228
1230
|
const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
|
|
1229
1231
|
"category",
|
|
1230
1232
|
"isDefault",
|
|
1231
|
-
"media",
|
|
1232
1233
|
"order",
|
|
1233
1234
|
"template",
|
|
1234
1235
|
"updatedAt",
|
|
@@ -1236,7 +1237,7 @@ function getPickedProps(item) {
|
|
|
1236
1237
|
].includes(k)));
|
|
1237
1238
|
return pickedProps;
|
|
1238
1239
|
}
|
|
1239
|
-
function collectRoutes(store, categories, markets, locales) {
|
|
1240
|
+
function collectRoutes(store, categories, markets, locales, medias) {
|
|
1240
1241
|
const routes = [];
|
|
1241
1242
|
if (locales.length > 0 && markets.length > 0) {
|
|
1242
1243
|
const rootCategory = getRootCategory(categories);
|
|
@@ -1265,12 +1266,22 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
1265
1266
|
schema: key,
|
|
1266
1267
|
title
|
|
1267
1268
|
};
|
|
1269
|
+
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1270
|
+
if (Array.isArray(medias) && mediaId) {
|
|
1271
|
+
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1272
|
+
if (media) {
|
|
1273
|
+
route.media = media;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1268
1276
|
routes.push(route);
|
|
1269
1277
|
}
|
|
1270
1278
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1271
1279
|
if (!item.markets || item.markets.includes(market.id)) {
|
|
1272
1280
|
const title = localize(item.title, locale.id);
|
|
1273
1281
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1282
|
+
if (!id) {
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1274
1285
|
const pickedProps = getPickedProps(item);
|
|
1275
1286
|
const route = {
|
|
1276
1287
|
...pickedProps,
|
|
@@ -1282,6 +1293,13 @@ function collectRoutes(store, categories, markets, locales) {
|
|
|
1282
1293
|
schema: key,
|
|
1283
1294
|
title
|
|
1284
1295
|
};
|
|
1296
|
+
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1297
|
+
if (Array.isArray(medias) && mediaId) {
|
|
1298
|
+
const media = item.media && medias.find((x) => x.id === mediaId);
|
|
1299
|
+
if (media) {
|
|
1300
|
+
route.media = media;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1285
1303
|
routes.push(route);
|
|
1286
1304
|
}
|
|
1287
1305
|
});
|
|
@@ -1457,6 +1475,7 @@ export {
|
|
|
1457
1475
|
asServerProps,
|
|
1458
1476
|
asSortedOptions,
|
|
1459
1477
|
awaitAll,
|
|
1478
|
+
base64ToString,
|
|
1460
1479
|
camelToSnakeCase,
|
|
1461
1480
|
cloneItem,
|
|
1462
1481
|
collectFeatureTypes,
|
|
@@ -1539,6 +1558,7 @@ export {
|
|
|
1539
1558
|
qsSerialize,
|
|
1540
1559
|
qsSerializeRaw,
|
|
1541
1560
|
resolveMediaType,
|
|
1561
|
+
stringToBase64,
|
|
1542
1562
|
toCamelCase,
|
|
1543
1563
|
toCharCase,
|
|
1544
1564
|
toDisplayName,
|