@websolutespa/bom-core 0.5.0 → 0.6.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 +6 -0
- package/dist/index.d.ts +22 -1
- package/dist/index.js +48 -0
- package/dist/index.mjs +46 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -363,6 +363,9 @@ type Pagination = {
|
|
|
363
363
|
totalDocs: number;
|
|
364
364
|
totalPages: number;
|
|
365
365
|
};
|
|
366
|
+
type IPaginationResult<T> = {
|
|
367
|
+
docs: T[];
|
|
368
|
+
} & Pagination;
|
|
366
369
|
|
|
367
370
|
type Operator = 'equals' | 'contains' | 'not_equals' | 'in' | 'not_in' | 'exists' | 'greater_than' | 'greater_than_equal' | 'less_than' | 'less_than_equal' | 'like' | 'near';
|
|
368
371
|
type WhereField = {
|
|
@@ -523,6 +526,24 @@ declare function localize(value: ILocalizable, locale?: string, defaultLocale?:
|
|
|
523
526
|
declare function localizeValue(value: any, locale?: string, defaultLocale?: string): any;
|
|
524
527
|
declare function localizeItem<T = any>(item: T, locale?: string, defaultLocale?: string): T;
|
|
525
528
|
|
|
529
|
+
declare enum LoggerLevel {
|
|
530
|
+
NONE = 0,
|
|
531
|
+
ERROR = 1,
|
|
532
|
+
WARN = 2,
|
|
533
|
+
INFO = 3,
|
|
534
|
+
LOG = 4,
|
|
535
|
+
ALL = 5
|
|
536
|
+
}
|
|
537
|
+
declare class Logger {
|
|
538
|
+
static level_: LoggerLevel;
|
|
539
|
+
static setLevel(level: LoggerLevel): void;
|
|
540
|
+
static getLevel(): LoggerLevel;
|
|
541
|
+
static error(...args: unknown[]): void;
|
|
542
|
+
static warn(...args: unknown[]): void;
|
|
543
|
+
static info(...args: unknown[]): void;
|
|
544
|
+
static log(...args: unknown[]): void;
|
|
545
|
+
}
|
|
546
|
+
|
|
526
547
|
declare function qsSerialize(queryParams?: QueryParams): string;
|
|
527
548
|
declare function qsSerializeRaw(queryParams?: {}): string;
|
|
528
549
|
declare function qsDeserialize(query?: string, deserializedParams?: {}): QueryParams;
|
|
@@ -598,4 +619,4 @@ declare function asServerProps(props: any): any;
|
|
|
598
619
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
599
620
|
declare function merge(target: any, source: any): any;
|
|
600
621
|
|
|
601
|
-
export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IContextBaseParams, IContextParams, IDecoratedNav, IEntity, IEquatable, ILabel, ILayout, ILocale, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IPackages, IPage, IPageRelation, IPageRelationResult, IPageResult, IPageUnresolvedRelation, IPartial, 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, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, cloneItem, collectRoutes, consoleWarn, 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, isNotNullString, isObject, isProduction, isRelation, isStage, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
|
|
622
|
+
export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IContextBaseParams, IContextParams, IDecoratedNav, IEntity, IEquatable, ILabel, ILayout, ILocale, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IPackages, IPage, IPageRelation, IPageRelationResult, IPageResult, IPageUnresolvedRelation, IPaginationResult, IPartial, 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, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, cloneItem, collectRoutes, consoleWarn, 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, isNotNullString, isObject, isProduction, isRelation, isStage, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
JsonService: () => JsonService,
|
|
34
|
+
Logger: () => Logger,
|
|
35
|
+
LoggerLevel: () => LoggerLevel,
|
|
34
36
|
RedirectReason: () => RedirectReason,
|
|
35
37
|
RouteStrategy: () => RouteStrategy,
|
|
36
38
|
asCategoryId: () => asCategoryId,
|
|
@@ -750,6 +752,50 @@ function localizeItem(item, locale = "en", defaultLocale = "en") {
|
|
|
750
752
|
return item;
|
|
751
753
|
}
|
|
752
754
|
|
|
755
|
+
// src/logger/logger.ts
|
|
756
|
+
var LoggerLevel = /* @__PURE__ */ ((LoggerLevel2) => {
|
|
757
|
+
LoggerLevel2[LoggerLevel2["NONE"] = 0] = "NONE";
|
|
758
|
+
LoggerLevel2[LoggerLevel2["ERROR"] = 1] = "ERROR";
|
|
759
|
+
LoggerLevel2[LoggerLevel2["WARN"] = 2] = "WARN";
|
|
760
|
+
LoggerLevel2[LoggerLevel2["INFO"] = 3] = "INFO";
|
|
761
|
+
LoggerLevel2[LoggerLevel2["LOG"] = 4] = "LOG";
|
|
762
|
+
LoggerLevel2[LoggerLevel2["ALL"] = 5] = "ALL";
|
|
763
|
+
return LoggerLevel2;
|
|
764
|
+
})(LoggerLevel || {});
|
|
765
|
+
var Logger = class {
|
|
766
|
+
static setLevel(level) {
|
|
767
|
+
this.level_ = level;
|
|
768
|
+
}
|
|
769
|
+
static getLevel() {
|
|
770
|
+
if (isProduction) {
|
|
771
|
+
return 1 /* ERROR */;
|
|
772
|
+
} else {
|
|
773
|
+
return this.level_;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
static error(...args) {
|
|
777
|
+
if (this.getLevel() >= 1 /* ERROR */) {
|
|
778
|
+
console.error(...args);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
static warn(...args) {
|
|
782
|
+
if (this.getLevel() >= 2 /* WARN */) {
|
|
783
|
+
console.warn(...args);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
static info(...args) {
|
|
787
|
+
if (this.getLevel() >= 3 /* INFO */) {
|
|
788
|
+
console.info(...args);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
static log(...args) {
|
|
792
|
+
if (this.getLevel() >= 4 /* LOG */) {
|
|
793
|
+
console.log(...args);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
Logger.level_ = 5 /* ALL */;
|
|
798
|
+
|
|
753
799
|
// src/qs/qs.ts
|
|
754
800
|
function qsSerializeKey(key, parentKey = "") {
|
|
755
801
|
return parentKey ? `${parentKey}[${key}]` : String(key);
|
|
@@ -1006,6 +1052,8 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1006
1052
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1007
1053
|
0 && (module.exports = {
|
|
1008
1054
|
JsonService,
|
|
1055
|
+
Logger,
|
|
1056
|
+
LoggerLevel,
|
|
1009
1057
|
RedirectReason,
|
|
1010
1058
|
RouteStrategy,
|
|
1011
1059
|
asCategoryId,
|
package/dist/index.mjs
CHANGED
|
@@ -642,6 +642,50 @@ function localizeItem(item, locale = "en", defaultLocale = "en") {
|
|
|
642
642
|
return item;
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
+
// src/logger/logger.ts
|
|
646
|
+
var LoggerLevel = /* @__PURE__ */ ((LoggerLevel2) => {
|
|
647
|
+
LoggerLevel2[LoggerLevel2["NONE"] = 0] = "NONE";
|
|
648
|
+
LoggerLevel2[LoggerLevel2["ERROR"] = 1] = "ERROR";
|
|
649
|
+
LoggerLevel2[LoggerLevel2["WARN"] = 2] = "WARN";
|
|
650
|
+
LoggerLevel2[LoggerLevel2["INFO"] = 3] = "INFO";
|
|
651
|
+
LoggerLevel2[LoggerLevel2["LOG"] = 4] = "LOG";
|
|
652
|
+
LoggerLevel2[LoggerLevel2["ALL"] = 5] = "ALL";
|
|
653
|
+
return LoggerLevel2;
|
|
654
|
+
})(LoggerLevel || {});
|
|
655
|
+
var Logger = class {
|
|
656
|
+
static setLevel(level) {
|
|
657
|
+
this.level_ = level;
|
|
658
|
+
}
|
|
659
|
+
static getLevel() {
|
|
660
|
+
if (isProduction) {
|
|
661
|
+
return 1 /* ERROR */;
|
|
662
|
+
} else {
|
|
663
|
+
return this.level_;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
static error(...args) {
|
|
667
|
+
if (this.getLevel() >= 1 /* ERROR */) {
|
|
668
|
+
console.error(...args);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
static warn(...args) {
|
|
672
|
+
if (this.getLevel() >= 2 /* WARN */) {
|
|
673
|
+
console.warn(...args);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
static info(...args) {
|
|
677
|
+
if (this.getLevel() >= 3 /* INFO */) {
|
|
678
|
+
console.info(...args);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
static log(...args) {
|
|
682
|
+
if (this.getLevel() >= 4 /* LOG */) {
|
|
683
|
+
console.log(...args);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
Logger.level_ = 5 /* ALL */;
|
|
688
|
+
|
|
645
689
|
// src/qs/qs.ts
|
|
646
690
|
function qsSerializeKey(key, parentKey = "") {
|
|
647
691
|
return parentKey ? `${parentKey}[${key}]` : String(key);
|
|
@@ -897,6 +941,8 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
897
941
|
})(RedirectReason || {});
|
|
898
942
|
export {
|
|
899
943
|
JsonService,
|
|
944
|
+
Logger,
|
|
945
|
+
LoggerLevel,
|
|
900
946
|
RedirectReason,
|
|
901
947
|
RouteStrategy,
|
|
902
948
|
asCategoryId,
|