@websolutespa/bom-core 1.8.3 → 1.8.4
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 +6 -0
- package/dist/index.d.ts +21 -1
- package/dist/index.js +67 -0
- package/dist/index.mjs +64 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -292,6 +292,23 @@ type FetchRequestOptions = {
|
|
|
292
292
|
type FetchService<T = unknown> = (url: string, options?: FetchRequestOptions, serviceOptions?: any) => Promise<T>;
|
|
293
293
|
type FetchError = any;
|
|
294
294
|
|
|
295
|
+
declare enum ImageStrategy {
|
|
296
|
+
None = "none",
|
|
297
|
+
Next = "next",
|
|
298
|
+
Mixer = "mixer",
|
|
299
|
+
Oven = "oven",
|
|
300
|
+
Token = "token",
|
|
301
|
+
Custom = "custom"
|
|
302
|
+
}
|
|
303
|
+
type IImageResize = {
|
|
304
|
+
q: number;
|
|
305
|
+
w: number;
|
|
306
|
+
h?: number;
|
|
307
|
+
x?: number;
|
|
308
|
+
y?: number;
|
|
309
|
+
src: string;
|
|
310
|
+
};
|
|
311
|
+
|
|
295
312
|
type ILabel = IEntity & {
|
|
296
313
|
id: IEquatable;
|
|
297
314
|
text?: ILocalizable;
|
|
@@ -832,6 +849,9 @@ declare function httpPatch(url: string, payload: any, options?: FetchRequestOpti
|
|
|
832
849
|
*/
|
|
833
850
|
declare function httpDelete(url: string, options?: FetchRequestOptions): Promise<any>;
|
|
834
851
|
|
|
852
|
+
declare function encryptImageToken(imageResize: IImageResize): string;
|
|
853
|
+
declare function decryptImageResize(token: string): IImageResize;
|
|
854
|
+
|
|
835
855
|
declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
836
856
|
items: T[];
|
|
837
857
|
constructor(items: T[]);
|
|
@@ -1280,4 +1300,4 @@ declare function asServerProps(props: any): any;
|
|
|
1280
1300
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
1281
1301
|
declare function merge(target: any, source: any): any;
|
|
1282
1302
|
|
|
1283
|
-
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, 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, 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, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
ImageStrategy: () => ImageStrategy,
|
|
33
34
|
JsonService: () => JsonService,
|
|
34
35
|
Logger: () => Logger,
|
|
35
36
|
LoggerLevel: () => LoggerLevel,
|
|
@@ -52,11 +53,13 @@ __export(src_exports, {
|
|
|
52
53
|
collectOptions: () => collectOptions,
|
|
53
54
|
collectRoutes: () => collectRoutes,
|
|
54
55
|
consoleWarn: () => consoleWarn,
|
|
56
|
+
decryptImageResize: () => decryptImageResize,
|
|
55
57
|
deepMerge: () => deepMerge,
|
|
56
58
|
defaultLocale: () => defaultLocale,
|
|
57
59
|
defaultMarket: () => defaultMarket,
|
|
58
60
|
eachCategorized: () => eachCategorized,
|
|
59
61
|
eachMarketLocale: () => eachMarketLocale,
|
|
62
|
+
encryptImageToken: () => encryptImageToken,
|
|
60
63
|
enumToList: () => enumToList,
|
|
61
64
|
findCategoryInCategories: () => findCategoryInCategories,
|
|
62
65
|
findChildCategories: () => findChildCategories,
|
|
@@ -710,6 +713,56 @@ async function httpDelete(url, options = {}) {
|
|
|
710
713
|
return await httpFetch(url, { ...options, method: "DELETE" });
|
|
711
714
|
}
|
|
712
715
|
|
|
716
|
+
// src/image/image.ts
|
|
717
|
+
function getSecret() {
|
|
718
|
+
return process.env.IMAGE_SECRET || "The sun sets over the calm ocean";
|
|
719
|
+
}
|
|
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
|
+
function textToArrayBuffer_(text) {
|
|
727
|
+
const encoder = new TextEncoder();
|
|
728
|
+
const arrayBuffer = encoder.encode(text);
|
|
729
|
+
return arrayBuffer;
|
|
730
|
+
}
|
|
731
|
+
function arrayBufferToText_(arrayBuffer) {
|
|
732
|
+
const encoder = new TextDecoder("utf-8");
|
|
733
|
+
const text = encoder.decode(arrayBuffer);
|
|
734
|
+
return text;
|
|
735
|
+
}
|
|
736
|
+
function xor_(text, secret) {
|
|
737
|
+
const s = textToArrayBuffer_(secret);
|
|
738
|
+
const t = textToArrayBuffer_(text);
|
|
739
|
+
const m = t.map((a, i) => {
|
|
740
|
+
const b = s[i % s.length];
|
|
741
|
+
return a ^ b;
|
|
742
|
+
});
|
|
743
|
+
return arrayBufferToText_(m);
|
|
744
|
+
}
|
|
745
|
+
function encrypt_(text, secret) {
|
|
746
|
+
const encrypted = xor_(text, secret);
|
|
747
|
+
const base64 = stringToBase64_(encrypted);
|
|
748
|
+
return base64;
|
|
749
|
+
}
|
|
750
|
+
function decrypt_(base64, secret) {
|
|
751
|
+
const text = base64ToString_(base64);
|
|
752
|
+
const decrypted = xor_(text, secret);
|
|
753
|
+
return decrypted;
|
|
754
|
+
}
|
|
755
|
+
function encryptImageToken(imageResize) {
|
|
756
|
+
const text = JSON.stringify(imageResize);
|
|
757
|
+
const token = encrypt_(text, getSecret());
|
|
758
|
+
return token;
|
|
759
|
+
}
|
|
760
|
+
function decryptImageResize(token) {
|
|
761
|
+
const text = decrypt_(token, getSecret());
|
|
762
|
+
const data = JSON.parse(text);
|
|
763
|
+
return data;
|
|
764
|
+
}
|
|
765
|
+
|
|
713
766
|
// src/json/json.service.ts
|
|
714
767
|
var JsonService = class {
|
|
715
768
|
constructor(items) {
|
|
@@ -1450,6 +1503,17 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1450
1503
|
return `${prefix}${href}`;
|
|
1451
1504
|
}
|
|
1452
1505
|
|
|
1506
|
+
// src/types/image.ts
|
|
1507
|
+
var ImageStrategy = /* @__PURE__ */ ((ImageStrategy2) => {
|
|
1508
|
+
ImageStrategy2["None"] = "none";
|
|
1509
|
+
ImageStrategy2["Next"] = "next";
|
|
1510
|
+
ImageStrategy2["Mixer"] = "mixer";
|
|
1511
|
+
ImageStrategy2["Oven"] = "oven";
|
|
1512
|
+
ImageStrategy2["Token"] = "token";
|
|
1513
|
+
ImageStrategy2["Custom"] = "custom";
|
|
1514
|
+
return ImageStrategy2;
|
|
1515
|
+
})(ImageStrategy || {});
|
|
1516
|
+
|
|
1453
1517
|
// src/types/media.ts
|
|
1454
1518
|
function resolveMediaType(media) {
|
|
1455
1519
|
if (typeof media.type === "string" && media.type.length > 0) {
|
|
@@ -1524,6 +1588,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1524
1588
|
})(RedirectReason || {});
|
|
1525
1589
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1526
1590
|
0 && (module.exports = {
|
|
1591
|
+
ImageStrategy,
|
|
1527
1592
|
JsonService,
|
|
1528
1593
|
Logger,
|
|
1529
1594
|
LoggerLevel,
|
|
@@ -1546,11 +1611,13 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1546
1611
|
collectOptions,
|
|
1547
1612
|
collectRoutes,
|
|
1548
1613
|
consoleWarn,
|
|
1614
|
+
decryptImageResize,
|
|
1549
1615
|
deepMerge,
|
|
1550
1616
|
defaultLocale,
|
|
1551
1617
|
defaultMarket,
|
|
1552
1618
|
eachCategorized,
|
|
1553
1619
|
eachMarketLocale,
|
|
1620
|
+
encryptImageToken,
|
|
1554
1621
|
enumToList,
|
|
1555
1622
|
findCategoryInCategories,
|
|
1556
1623
|
findChildCategories,
|
package/dist/index.mjs
CHANGED
|
@@ -567,6 +567,56 @@ async function httpDelete(url, options = {}) {
|
|
|
567
567
|
return await httpFetch(url, { ...options, method: "DELETE" });
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
+
// src/image/image.ts
|
|
571
|
+
function getSecret() {
|
|
572
|
+
return process.env.IMAGE_SECRET || "The sun sets over the calm ocean";
|
|
573
|
+
}
|
|
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
|
+
function textToArrayBuffer_(text) {
|
|
581
|
+
const encoder = new TextEncoder();
|
|
582
|
+
const arrayBuffer = encoder.encode(text);
|
|
583
|
+
return arrayBuffer;
|
|
584
|
+
}
|
|
585
|
+
function arrayBufferToText_(arrayBuffer) {
|
|
586
|
+
const encoder = new TextDecoder("utf-8");
|
|
587
|
+
const text = encoder.decode(arrayBuffer);
|
|
588
|
+
return text;
|
|
589
|
+
}
|
|
590
|
+
function xor_(text, secret) {
|
|
591
|
+
const s = textToArrayBuffer_(secret);
|
|
592
|
+
const t = textToArrayBuffer_(text);
|
|
593
|
+
const m = t.map((a, i) => {
|
|
594
|
+
const b = s[i % s.length];
|
|
595
|
+
return a ^ b;
|
|
596
|
+
});
|
|
597
|
+
return arrayBufferToText_(m);
|
|
598
|
+
}
|
|
599
|
+
function encrypt_(text, secret) {
|
|
600
|
+
const encrypted = xor_(text, secret);
|
|
601
|
+
const base64 = stringToBase64_(encrypted);
|
|
602
|
+
return base64;
|
|
603
|
+
}
|
|
604
|
+
function decrypt_(base64, secret) {
|
|
605
|
+
const text = base64ToString_(base64);
|
|
606
|
+
const decrypted = xor_(text, secret);
|
|
607
|
+
return decrypted;
|
|
608
|
+
}
|
|
609
|
+
function encryptImageToken(imageResize) {
|
|
610
|
+
const text = JSON.stringify(imageResize);
|
|
611
|
+
const token = encrypt_(text, getSecret());
|
|
612
|
+
return token;
|
|
613
|
+
}
|
|
614
|
+
function decryptImageResize(token) {
|
|
615
|
+
const text = decrypt_(token, getSecret());
|
|
616
|
+
const data = JSON.parse(text);
|
|
617
|
+
return data;
|
|
618
|
+
}
|
|
619
|
+
|
|
570
620
|
// src/json/json.service.ts
|
|
571
621
|
var JsonService = class {
|
|
572
622
|
constructor(items) {
|
|
@@ -1307,6 +1357,17 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1307
1357
|
return `${prefix}${href}`;
|
|
1308
1358
|
}
|
|
1309
1359
|
|
|
1360
|
+
// src/types/image.ts
|
|
1361
|
+
var ImageStrategy = /* @__PURE__ */ ((ImageStrategy2) => {
|
|
1362
|
+
ImageStrategy2["None"] = "none";
|
|
1363
|
+
ImageStrategy2["Next"] = "next";
|
|
1364
|
+
ImageStrategy2["Mixer"] = "mixer";
|
|
1365
|
+
ImageStrategy2["Oven"] = "oven";
|
|
1366
|
+
ImageStrategy2["Token"] = "token";
|
|
1367
|
+
ImageStrategy2["Custom"] = "custom";
|
|
1368
|
+
return ImageStrategy2;
|
|
1369
|
+
})(ImageStrategy || {});
|
|
1370
|
+
|
|
1310
1371
|
// src/types/media.ts
|
|
1311
1372
|
function resolveMediaType(media) {
|
|
1312
1373
|
if (typeof media.type === "string" && media.type.length > 0) {
|
|
@@ -1380,6 +1441,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1380
1441
|
return RedirectReason2;
|
|
1381
1442
|
})(RedirectReason || {});
|
|
1382
1443
|
export {
|
|
1444
|
+
ImageStrategy,
|
|
1383
1445
|
JsonService,
|
|
1384
1446
|
Logger,
|
|
1385
1447
|
LoggerLevel,
|
|
@@ -1402,11 +1464,13 @@ export {
|
|
|
1402
1464
|
collectOptions,
|
|
1403
1465
|
collectRoutes,
|
|
1404
1466
|
consoleWarn,
|
|
1467
|
+
decryptImageResize,
|
|
1405
1468
|
deepMerge,
|
|
1406
1469
|
defaultLocale,
|
|
1407
1470
|
defaultMarket,
|
|
1408
1471
|
eachCategorized,
|
|
1409
1472
|
eachMarketLocale,
|
|
1473
|
+
encryptImageToken,
|
|
1410
1474
|
enumToList,
|
|
1411
1475
|
findCategoryInCategories,
|
|
1412
1476
|
findChildCategories,
|