@websolutespa/bom-core 1.7.10 → 1.7.12
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 +449 -35
- package/dist/index.js +450 -294
- package/dist/index.mjs +442 -292
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @websolutespa/bom-core
|
|
2
2
|
|
|
3
|
+
## 1.7.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Modified: RouteService, MenuService to handle isHidden Category segments
|
|
8
|
+
|
|
9
|
+
## 1.7.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Modified: JsonService where clauses, limit, sort
|
|
14
|
+
- Added: JsonService tests
|
|
15
|
+
|
|
3
16
|
## 1.7.10
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ type IOverride<T, FromType, ToType> = {
|
|
|
64
64
|
*/
|
|
65
65
|
type ILetter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
|
|
66
66
|
type ILocaleId = `${ILetter}${ILetter}`;
|
|
67
|
-
type ILocalizedString = Record<ILocaleId, string
|
|
67
|
+
type ILocalizedString = Partial<Record<ILocaleId, string>>;
|
|
68
68
|
type ILocalizable = string | ILocalizedString;
|
|
69
69
|
type ILocalized<T> = IOverride<T, ILocalizable, string>;
|
|
70
70
|
|
|
@@ -226,6 +226,7 @@ type ICategory = IEntity & {
|
|
|
226
226
|
order?: number;
|
|
227
227
|
slug: ILocalizable;
|
|
228
228
|
title: ILocalizable;
|
|
229
|
+
isHidden?: boolean;
|
|
229
230
|
};
|
|
230
231
|
type ICategoryItem = ICategory & {
|
|
231
232
|
items: ICategory[];
|
|
@@ -311,7 +312,8 @@ type IMarket = IEntity & {
|
|
|
311
312
|
};
|
|
312
313
|
|
|
313
314
|
type IRoute = {
|
|
314
|
-
category: IEquatable
|
|
315
|
+
category: IEquatable;
|
|
316
|
+
resolvedCategory: IEquatable;
|
|
315
317
|
id: string;
|
|
316
318
|
isDefault?: boolean;
|
|
317
319
|
locale: string;
|
|
@@ -497,7 +499,22 @@ type IPaginationResult<T> = {
|
|
|
497
499
|
docs: T[];
|
|
498
500
|
} & Pagination;
|
|
499
501
|
|
|
500
|
-
|
|
502
|
+
/**
|
|
503
|
+
equals The value must be exactly equal.
|
|
504
|
+
not_equals The query will return all documents where the value is not equal.
|
|
505
|
+
exists Only return documents where the value either exists (true) or does not exist (false).
|
|
506
|
+
greater_than For numeric or date-based fields.
|
|
507
|
+
greater_than_equal For numeric or date-based fields.
|
|
508
|
+
less_than For numeric or date-based fields.
|
|
509
|
+
less_than_equal For numeric or date-based fields.
|
|
510
|
+
like Case-insensitive string must be present. If string of words, all words must be present, in any order.
|
|
511
|
+
contains Must contain the value entered, case-insensitive.
|
|
512
|
+
in The value must be found within the provided comma-delimited list of values.
|
|
513
|
+
not_in The value must NOT be within the provided comma-delimited list of values.
|
|
514
|
+
all The value must contain all values provided in the comma-delimited list.
|
|
515
|
+
near For distance related to a point field comma separated as <longitude>, <latitude>, <maxDistance in meters (nullable)>, <minDistance in meters (nullable)>.
|
|
516
|
+
*/
|
|
517
|
+
type Operator = 'equals' | 'not_equals' | 'exists' | 'greater_than' | 'greater_than_equal' | 'less_than' | 'less_than_equal' | 'like' | 'contains' | 'in' | 'not_in' | 'all' | 'near';
|
|
501
518
|
type WhereField = {
|
|
502
519
|
[key in Operator]?: unknown;
|
|
503
520
|
};
|
|
@@ -596,31 +613,167 @@ type ITemplate = {
|
|
|
596
613
|
collections: string[];
|
|
597
614
|
};
|
|
598
615
|
|
|
599
|
-
|
|
600
|
-
|
|
616
|
+
/**
|
|
617
|
+
* Retrieves the root category from the given list of categories.
|
|
618
|
+
* @param categories - The list of categories.
|
|
619
|
+
* @returns The root category, if found; otherwise undefined.
|
|
620
|
+
*/
|
|
601
621
|
declare function getRootCategory(categories: ICategory[]): ICategory | undefined;
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
622
|
+
/**
|
|
623
|
+
* Retrieves the parent category of an item.
|
|
624
|
+
* @param categories - The array of categories.
|
|
625
|
+
* @param item - The item to find the parent category for.
|
|
626
|
+
* @returns The parent category of the item, or undefined if not found.
|
|
627
|
+
*/
|
|
628
|
+
declare function getParentCategory(categories: ICategory[], item: ICategorized): ICategory | undefined;
|
|
629
|
+
/**
|
|
630
|
+
* Retrieves the parent categories of a category with the given ID.
|
|
631
|
+
* @param categories - The list of categories.
|
|
632
|
+
* @param id - The ID of the category.
|
|
633
|
+
* @returns An array of parent categories.
|
|
634
|
+
*/
|
|
635
|
+
declare function getParentCategoriesById(categories: ICategory[], id?: string): ICategory[];
|
|
636
|
+
/**
|
|
637
|
+
* Retrieves the category segments for an ICategorized item.
|
|
638
|
+
* @param item - The item to retrieve the category segments for.
|
|
639
|
+
* @param categories - The list of categories.
|
|
640
|
+
* @returns An array of category segments.
|
|
641
|
+
*/
|
|
642
|
+
declare function getCategorySegments(categories: ICategory[], item: ICategorized): ICategory[];
|
|
643
|
+
/**
|
|
644
|
+
* Retrieves the category segments for a category.
|
|
645
|
+
* @param item - The category to retrieve the category segments for.
|
|
646
|
+
* @param categories - The list of categories.
|
|
647
|
+
* @returns An array of category segments.
|
|
648
|
+
*/
|
|
649
|
+
declare function getCategorySegmentsByCategory(categories: ICategory[], item: ICategory): ICategory[];
|
|
650
|
+
/**
|
|
651
|
+
* Retrieves the ID of a category or an object that implements IEquatable.
|
|
652
|
+
* @param value - The category or object to retrieve the ID from.
|
|
653
|
+
* @returns The ID of the category or object as a string.
|
|
654
|
+
*/
|
|
655
|
+
declare function asCategoryId(value: undefined): undefined;
|
|
656
|
+
declare function asCategoryId(value: string): string;
|
|
657
|
+
declare function asCategoryId(value: IEntity | IEquatable): string;
|
|
658
|
+
declare function asCategoryId(value: IEntity | IEquatable | undefined): string | undefined;
|
|
659
|
+
/**
|
|
660
|
+
* Finds a category in the given array of categories based on the provided item.
|
|
661
|
+
* @param categories - The array of categories to search in.
|
|
662
|
+
* @param item - The item to find in the categories array.
|
|
663
|
+
* @returns The found category, if any, or undefined.
|
|
664
|
+
*/
|
|
665
|
+
declare function findCategoryInCategories(categories: ICategory[], item: ICategory | IEquatable | undefined): ICategory | undefined;
|
|
666
|
+
/**
|
|
667
|
+
* Finds child categories based on the given item.
|
|
668
|
+
* @param categories - The array of categories to search in.
|
|
669
|
+
* @param item - The item to find child categories for.
|
|
670
|
+
* @returns An array of child categories.
|
|
671
|
+
*/
|
|
672
|
+
declare function findChildCategories(categories: ICategory[], item: ICategory | IEquatable | undefined): ICategory[];
|
|
605
673
|
|
|
674
|
+
/**
|
|
675
|
+
* Combines multiple IClassName objects into a single string of class names.
|
|
676
|
+
* @param props - The IClassName objects to combine.
|
|
677
|
+
* @returns A string of class names.
|
|
678
|
+
*/
|
|
606
679
|
declare function getClassNames(...props: Array<IClassName>): string;
|
|
607
680
|
|
|
681
|
+
/**
|
|
682
|
+
* Retrieves the collection description based on the given text.
|
|
683
|
+
* @param text - The input text.
|
|
684
|
+
* @returns The collection description object.
|
|
685
|
+
*/
|
|
608
686
|
declare function getCollectionDescription(text: string): ICollectionDescription;
|
|
687
|
+
/**
|
|
688
|
+
* Converts a camel case string to snake case.
|
|
689
|
+
* @param text - The input text.
|
|
690
|
+
* @returns The converted snake case string.
|
|
691
|
+
*/
|
|
609
692
|
declare function camelToSnakeCase(text: string): string;
|
|
693
|
+
/**
|
|
694
|
+
* Checks if the given collection description is valid.
|
|
695
|
+
* @param description - The collection description object.
|
|
696
|
+
* @returns True if the collection description is valid, false otherwise.
|
|
697
|
+
*/
|
|
610
698
|
declare function isValidCollectionDescription(description: ICollectionDescription): boolean;
|
|
699
|
+
/**
|
|
700
|
+
* Checks if the given collection description is reserved.
|
|
701
|
+
* @param description - The collection description object.
|
|
702
|
+
* @returns True if the collection description is reserved, false otherwise.
|
|
703
|
+
*/
|
|
611
704
|
declare function isReservedCollectionDescription(description: ICollectionDescription): boolean;
|
|
705
|
+
/**
|
|
706
|
+
* Converts a string to a display name by removing spaces.
|
|
707
|
+
* @param text - The input text.
|
|
708
|
+
* @returns The converted display name.
|
|
709
|
+
*/
|
|
612
710
|
declare function toDisplayName(text: string): string;
|
|
711
|
+
/**
|
|
712
|
+
* Converts a string to its plural form.
|
|
713
|
+
* @param text - The input text.
|
|
714
|
+
* @returns The plural form of the input text.
|
|
715
|
+
*/
|
|
613
716
|
declare function toPluralName(text: string): string;
|
|
717
|
+
/**
|
|
718
|
+
* Converts a string to title case.
|
|
719
|
+
* @param text - The input text.
|
|
720
|
+
* @returns The converted title case string.
|
|
721
|
+
*/
|
|
614
722
|
declare function toTitleCase(text: string): string;
|
|
723
|
+
/**
|
|
724
|
+
* Converts a string to a valid collection name by removing special characters and converting to snake case.
|
|
725
|
+
* @param text - The input text.
|
|
726
|
+
* @returns The converted valid collection name.
|
|
727
|
+
*/
|
|
615
728
|
declare function toValidCollectionName(text: string): string;
|
|
616
729
|
|
|
617
730
|
declare function consoleWarn(message: string, component?: string): void;
|
|
618
731
|
|
|
732
|
+
/**
|
|
733
|
+
* Performs an HTTP fetch request.
|
|
734
|
+
* @param url - The URL to fetch.
|
|
735
|
+
* @param options - The fetch request options.
|
|
736
|
+
* @param serviceOptions - Additional service options.
|
|
737
|
+
* @returns A promise that resolves to the response data.
|
|
738
|
+
*/
|
|
619
739
|
declare function httpFetch(url: string, options?: FetchRequestOptions, serviceOptions?: any): Promise<any>;
|
|
740
|
+
/**
|
|
741
|
+
* Performs an HTTP GET request.
|
|
742
|
+
* @param url - The URL to fetch.
|
|
743
|
+
* @param options - The fetch request options.
|
|
744
|
+
* @returns A promise that resolves to the response data.
|
|
745
|
+
*/
|
|
620
746
|
declare function httpGet(url: string, options?: FetchRequestOptions): Promise<any>;
|
|
747
|
+
/**
|
|
748
|
+
* Performs an HTTP POST request.
|
|
749
|
+
* @param url - The URL to fetch.
|
|
750
|
+
* @param payload - The payload to send in the request body.
|
|
751
|
+
* @param options - The fetch request options.
|
|
752
|
+
* @returns A promise that resolves to the response data.
|
|
753
|
+
*/
|
|
621
754
|
declare function httpPost(url: string, payload: any, options?: FetchRequestOptions): Promise<any>;
|
|
755
|
+
/**
|
|
756
|
+
* Performs an HTTP PUT request.
|
|
757
|
+
* @param url - The URL to fetch.
|
|
758
|
+
* @param payload - The payload to send in the request body.
|
|
759
|
+
* @param options - The fetch request options.
|
|
760
|
+
* @returns A promise that resolves to the response data.
|
|
761
|
+
*/
|
|
622
762
|
declare function httpPut(url: string, payload: any, options?: FetchRequestOptions): Promise<any>;
|
|
763
|
+
/**
|
|
764
|
+
* Performs an HTTP PATCH request.
|
|
765
|
+
* @param url - The URL to fetch.
|
|
766
|
+
* @param payload - The payload to send in the request body.
|
|
767
|
+
* @param options - The fetch request options.
|
|
768
|
+
* @returns A promise that resolves to the response data.
|
|
769
|
+
*/
|
|
623
770
|
declare function httpPatch(url: string, payload: any, options?: FetchRequestOptions): Promise<any>;
|
|
771
|
+
/**
|
|
772
|
+
* Performs an HTTP DELETE request.
|
|
773
|
+
* @param url - The URL to fetch.
|
|
774
|
+
* @param options - The fetch request options.
|
|
775
|
+
* @returns A promise that resolves to the response data.
|
|
776
|
+
*/
|
|
624
777
|
declare function httpDelete(url: string, options?: FetchRequestOptions): Promise<any>;
|
|
625
778
|
|
|
626
779
|
declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
@@ -636,31 +789,38 @@ declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
|
636
789
|
protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
|
|
637
790
|
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
638
791
|
protected newUUID_(): number;
|
|
639
|
-
protected evaluateValue_(value: unknown): unknown;
|
|
640
|
-
/**
|
|
641
|
-
equals The value must be exactly equal.
|
|
642
|
-
not_equals The query will return all documents where the value is not equal.
|
|
643
|
-
greater_than For numeric or date-based fields.
|
|
644
|
-
greater_than_equal For numeric or date-based fields.
|
|
645
|
-
less_than For numeric or date-based fields.
|
|
646
|
-
less_than_equal For numeric or date-based fields.
|
|
647
|
-
like Case-insensitive string must be present. If string of words, all words must be present, in any order.
|
|
648
|
-
contains Must contain the value entered, case-insensitive.
|
|
649
|
-
in The value must be found within the provided comma-delimited list of values.
|
|
650
|
-
not_in The value must NOT be within the provided comma-delimited list of values.
|
|
651
|
-
all The value must contain all values provided in the comma-delimited list.
|
|
652
|
-
exists Only return documents where the value either exists (true) or does not exist (false).
|
|
653
|
-
near For distance related to a point field comma separated as <longitude>, <latitude>, <maxDistance in meters (nullable)>, <minDistance in meters (nullable)>.
|
|
654
|
-
*/
|
|
655
|
-
protected existsClause_(value: unknown, exists?: boolean): boolean;
|
|
656
792
|
protected equalsClause_(value: unknown, equals?: unknown): boolean;
|
|
657
|
-
protected
|
|
658
|
-
protected
|
|
793
|
+
protected notEqualsClause_(value: unknown, not_equals?: unknown): boolean;
|
|
794
|
+
protected existsClause_(value: unknown, exists?: boolean): boolean;
|
|
795
|
+
protected greaterThanClause_(value: unknown, greater_than?: unknown): boolean;
|
|
796
|
+
protected greaterThanEqualClause_(value: unknown, greater_than_equal?: unknown): boolean;
|
|
797
|
+
protected lessThanClause_(value: unknown, less_than?: unknown): boolean;
|
|
798
|
+
protected lessThanEqualClause_(value: unknown, less_than_equal?: unknown): boolean;
|
|
659
799
|
protected likeClause_(value: unknown, query?: string): boolean;
|
|
660
800
|
protected containsClause_(value: unknown, contains?: IEquatable): boolean;
|
|
801
|
+
protected inClause_(value: unknown, values?: unknown[]): boolean;
|
|
802
|
+
protected notInClause_(value: unknown, values?: unknown[]): boolean;
|
|
803
|
+
protected allClause_(value: unknown, values?: unknown[]): boolean;
|
|
804
|
+
protected nearClause_(value: unknown, near?: unknown[]): boolean;
|
|
661
805
|
protected whereItem_<B extends T = T>(item: B, where?: Where): boolean;
|
|
662
|
-
|
|
806
|
+
/**
|
|
807
|
+
equals The value must be exactly equal.
|
|
808
|
+
not_equals The query will return all documents where the value is not equal.
|
|
809
|
+
exists Only return documents where the value either exists (true) or does not exist (false).
|
|
810
|
+
greater_than For numeric or date-based fields.
|
|
811
|
+
greater_than_equal For numeric or date-based fields.
|
|
812
|
+
less_than For numeric or date-based fields.
|
|
813
|
+
less_than_equal For numeric or date-based fields.
|
|
814
|
+
like Case-insensitive string must be present. If string of words, all words must be present, in any order.
|
|
815
|
+
contains Must contain the value entered, case-insensitive.
|
|
816
|
+
in The value must be found within the provided comma-delimited list of values.
|
|
817
|
+
not_in The value must NOT be within the provided comma-delimited list of values.
|
|
818
|
+
all The value must contain all values provided in the comma-delimited list.
|
|
819
|
+
near For distance related to a point field comma separated as <longitude>, <latitude>, <maxDistance in meters (nullable)>, <minDistance in meters (nullable)>.
|
|
820
|
+
*/
|
|
821
|
+
protected whereItems_<B extends T = T>(items: B[], where?: Where, limit?: number): B[];
|
|
663
822
|
protected sortCollection_<B extends T = T>(items: B[], sort?: string): B[];
|
|
823
|
+
protected limitCollection_<B extends T = T>(items: B[], limit?: number): B[];
|
|
664
824
|
protected paginatedItems_<B extends T = T>(items: B[], page?: number, limit?: number): ({
|
|
665
825
|
docs: B[];
|
|
666
826
|
} & Pagination);
|
|
@@ -668,10 +828,43 @@ declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
|
668
828
|
|
|
669
829
|
declare const defaultLocale: string;
|
|
670
830
|
|
|
831
|
+
/**
|
|
832
|
+
* Checks if a value is a localized string.
|
|
833
|
+
* @param value - The value to check.
|
|
834
|
+
* @returns A boolean indicating whether the value is a localized string.
|
|
835
|
+
*/
|
|
671
836
|
declare function isLocalizedString(value: any): value is ILocalizedString;
|
|
837
|
+
/**
|
|
838
|
+
* Converts a localized string object to a string based on the specified locale.
|
|
839
|
+
* @param json - The localized string object.
|
|
840
|
+
* @param locale - The locale to use.
|
|
841
|
+
* @param defaultLocale - The default locale to use if the specified locale is not found.
|
|
842
|
+
* @returns The localized string.
|
|
843
|
+
*/
|
|
672
844
|
declare function localizedToString(json: ILocalizedString, locale: string, defaultLocale?: string): string;
|
|
845
|
+
/**
|
|
846
|
+
* Localizes a value based on the specified locale.
|
|
847
|
+
* @param value - The value to localize.
|
|
848
|
+
* @param locale - The locale to use.
|
|
849
|
+
* @param defaultLocale - The default locale to use if the specified locale is not found.
|
|
850
|
+
* @returns The localized value as a string.
|
|
851
|
+
*/
|
|
673
852
|
declare function localize(value: ILocalizable, locale: string, defaultLocale?: string): string;
|
|
853
|
+
/**
|
|
854
|
+
* Localizes a value or an array/object of values based on the specified locale.
|
|
855
|
+
* @param value - The value or array/object of values to localize.
|
|
856
|
+
* @param locale - The locale to use.
|
|
857
|
+
* @param defaultLocale - The default locale to use if the specified locale is not found.
|
|
858
|
+
* @returns The localized value or array/object of localized values.
|
|
859
|
+
*/
|
|
674
860
|
declare function localizeValue(value: any, locale: string, defaultLocale?: string): any;
|
|
861
|
+
/**
|
|
862
|
+
* Localizes an array/object of values based on the specified locale.
|
|
863
|
+
* @param item - The array/object of values to localize.
|
|
864
|
+
* @param locale - The locale to use.
|
|
865
|
+
* @param defaultLocale - The default locale to use if the specified locale is not found.
|
|
866
|
+
* @returns The localized array/object of values.
|
|
867
|
+
*/
|
|
675
868
|
declare function localizeItem<T = any>(item: T, locale: string, defaultLocale?: string): T;
|
|
676
869
|
|
|
677
870
|
declare enum LoggerLevel {
|
|
@@ -694,33 +887,166 @@ declare class Logger {
|
|
|
694
887
|
|
|
695
888
|
declare const defaultMarket: string;
|
|
696
889
|
|
|
890
|
+
/**
|
|
891
|
+
* Serializes query parameters into a query string.
|
|
892
|
+
* @param queryParams - The query parameters to serialize.
|
|
893
|
+
* @returns The serialized query string.
|
|
894
|
+
*/
|
|
697
895
|
declare function qsSerialize(queryParams?: QueryParams): string;
|
|
896
|
+
/**
|
|
897
|
+
* Serializes query parameters into a raw query string.
|
|
898
|
+
* @param queryParams - The query parameters to serialize.
|
|
899
|
+
* @returns The serialized raw query string.
|
|
900
|
+
*/
|
|
698
901
|
declare function qsSerializeRaw(queryParams?: {}): string;
|
|
902
|
+
/**
|
|
903
|
+
* Deserializes a query string into query parameters.
|
|
904
|
+
* @param query - The query string to deserialize.
|
|
905
|
+
* @param deserializedParams - The deserialized query parameters.
|
|
906
|
+
* @returns The deserialized query parameters.
|
|
907
|
+
*/
|
|
699
908
|
declare function qsDeserialize(query?: string, deserializedParams?: {}): QueryParams;
|
|
909
|
+
/**
|
|
910
|
+
* Deserializes a raw query string into parameters.
|
|
911
|
+
* @param query - The raw query string to deserialize.
|
|
912
|
+
* @param deserializedParams - The deserialized parameters.
|
|
913
|
+
* @returns The deserialized parameters.
|
|
914
|
+
*/
|
|
700
915
|
declare function qsDeserializeRaw(query?: string, deserializedParams?: {}): {};
|
|
701
916
|
|
|
917
|
+
/**
|
|
918
|
+
* Checks if the given headers object is an instance of the Headers class.
|
|
919
|
+
* @param headers - The headers object to check.
|
|
920
|
+
* @returns True if the headers object is an instance of Headers, false otherwise.
|
|
921
|
+
*/
|
|
702
922
|
declare function isHeaders(headers?: IncomingHttpHeaders | Headers): headers is Headers;
|
|
923
|
+
/**
|
|
924
|
+
* Checks if the given headers object is an instance of IncomingHttpHeaders.
|
|
925
|
+
* @param headers - The headers object to check.
|
|
926
|
+
* @returns True if the headers object is an instance of IncomingHttpHeaders, false otherwise.
|
|
927
|
+
*/
|
|
703
928
|
declare function isIncomingHttpHeaders(headers?: IncomingHttpHeaders | Headers): headers is IncomingHttpHeaders;
|
|
929
|
+
/**
|
|
930
|
+
* Retrieves the host from the headers object.
|
|
931
|
+
* @param headers - The headers object.
|
|
932
|
+
* @returns The host value from the headers object, or null if not found.
|
|
933
|
+
*/
|
|
704
934
|
declare function getHost(headers?: IncomingHttpHeaders | Headers): string | null;
|
|
935
|
+
/**
|
|
936
|
+
* Retrieves the protocol from the headers object.
|
|
937
|
+
* @param headers - The headers object.
|
|
938
|
+
* @returns The protocol value from the headers object, or 'https' if not found.
|
|
939
|
+
*/
|
|
705
940
|
declare function getProto(headers?: IncomingHttpHeaders | Headers): string;
|
|
941
|
+
/**
|
|
942
|
+
* Retrieves the origin from the headers object.
|
|
943
|
+
* @param headers - The headers object.
|
|
944
|
+
* @returns The origin value based on the host and protocol from the headers object, or an empty string if not found.
|
|
945
|
+
*/
|
|
706
946
|
declare function getOrigin(headers?: IncomingHttpHeaders | Headers): string;
|
|
707
947
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
948
|
+
/**
|
|
949
|
+
* Represents the route strategy options.
|
|
950
|
+
*/
|
|
711
951
|
declare enum RouteStrategy {
|
|
712
952
|
Auto = "auto",
|
|
713
953
|
Default = "default",
|
|
714
954
|
Manual = "manual"
|
|
715
955
|
}
|
|
956
|
+
/**
|
|
957
|
+
* Collects routes based on the provided data.
|
|
958
|
+
*
|
|
959
|
+
* @param store - The memory store containing categorized items.
|
|
960
|
+
* @param categories - The list of categories.
|
|
961
|
+
* @param markets - The list of markets.
|
|
962
|
+
* @param locales - The list of locales.
|
|
963
|
+
* @returns An array of collected routes.
|
|
964
|
+
*/
|
|
965
|
+
declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[]): IRoute[];
|
|
966
|
+
/**
|
|
967
|
+
* Iterates over each market and locale combination and invokes the callback function.
|
|
968
|
+
*
|
|
969
|
+
* @param markets - The list of markets.
|
|
970
|
+
* @param locales - The list of locales.
|
|
971
|
+
* @param callback - The callback function to be invoked for each market and locale combination.
|
|
972
|
+
*/
|
|
973
|
+
declare function eachMarketLocale(markets: IMarket[], locales: ILocale[], callback: (market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]) => void): void;
|
|
974
|
+
/**
|
|
975
|
+
* Iterates over each categorized item in the store and invokes the callback function.
|
|
976
|
+
*
|
|
977
|
+
* @param store - The memory store containing categorized items.
|
|
978
|
+
* @param callback - The callback function to be invoked for each categorized item.
|
|
979
|
+
*/
|
|
980
|
+
declare function eachCategorized(store: IMemoryStore<ICategorized>, callback: (item: ICategorized, key: string) => void): void;
|
|
981
|
+
/**
|
|
982
|
+
* Finds the default route of a category by categoryId, market, and locale.
|
|
983
|
+
* @param routes - The array of routes to search.
|
|
984
|
+
* @param categoryId - The category ID to match.
|
|
985
|
+
* @param market - The market to match (optional).
|
|
986
|
+
* @param locale - The locale to match (optional).
|
|
987
|
+
* @returns The matching route, if found. Otherwise, undefined.
|
|
988
|
+
*/
|
|
989
|
+
declare function findRouteOfCategory(routes: IRoute[], categoryId: IEquatable, market?: string, locale?: string): IRoute | undefined;
|
|
990
|
+
/**
|
|
991
|
+
* Finds the routes of a category by categoryId.
|
|
992
|
+
* @param routes - The array of routes to search.
|
|
993
|
+
* @param categoryId - The category ID to filter routes by.
|
|
994
|
+
* @param isDefault - Optional. Specifies whether to filter routes by default status. Default is true.
|
|
995
|
+
* @returns An array of routes that match the specified category and default status.
|
|
996
|
+
*/
|
|
997
|
+
declare function findRoutesOfCategory(routes: IRoute[], categoryId: IEquatable, isDefault?: boolean): IRoute[];
|
|
998
|
+
/**
|
|
999
|
+
* Generates the route href based on the provided segments, market, locale, markets, and locales.
|
|
1000
|
+
*
|
|
1001
|
+
* @param segments - The segments of the route.
|
|
1002
|
+
* @param market - The market object.
|
|
1003
|
+
* @param locale - The locale object.
|
|
1004
|
+
* @param markets - The list of markets.
|
|
1005
|
+
* @param locales - The list of locales.
|
|
1006
|
+
* @returns The generated route href.
|
|
1007
|
+
*/
|
|
716
1008
|
declare function getRouteHref(segments: {
|
|
717
1009
|
slug: ILocalizable;
|
|
718
1010
|
}[], market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]): string;
|
|
719
1011
|
|
|
720
|
-
|
|
721
|
-
|
|
1012
|
+
/**
|
|
1013
|
+
* Converts a value to an `IEquatable` or `undefined`.
|
|
1014
|
+
* If the value is an `IEntity`, it extracts the `id` property.
|
|
1015
|
+
* If the `id` is a string that represents a valid number, it returns the number.
|
|
1016
|
+
* Otherwise, it returns the `id` as is.
|
|
1017
|
+
*
|
|
1018
|
+
* @param value The value to convert.
|
|
1019
|
+
* @returns The converted value as an `IEquatable` or `undefined`.
|
|
1020
|
+
*/
|
|
722
1021
|
declare function asEquatable(value: string): IEquatable;
|
|
1022
|
+
declare function asEquatable(value: number): number;
|
|
1023
|
+
/**
|
|
1024
|
+
* Converts a value to a string or `undefined`.
|
|
1025
|
+
* If the value is an `IEntity`, it extracts the `id` property.
|
|
1026
|
+
* If the `id` is defined, it returns it as a string.
|
|
1027
|
+
* Otherwise, it returns `undefined`.
|
|
1028
|
+
*
|
|
1029
|
+
* @param value The value to convert.
|
|
1030
|
+
* @returns The converted value as a string or `undefined`.
|
|
1031
|
+
*/
|
|
1032
|
+
declare function asEquatableString(value: string): string;
|
|
1033
|
+
/**
|
|
1034
|
+
* Converts a value to a number or `undefined`.
|
|
1035
|
+
* If the value is an `IEntity`, it extracts the `id` property.
|
|
1036
|
+
* If the `id` is a string that represents a valid number, it returns the number.
|
|
1037
|
+
* Otherwise, it returns `undefined`.
|
|
1038
|
+
*
|
|
1039
|
+
* @param value The value to convert.
|
|
1040
|
+
* @returns The converted value as a number or `undefined`.
|
|
1041
|
+
*/
|
|
1042
|
+
declare function asEquatableNumber(value: number): number;
|
|
723
1043
|
|
|
1044
|
+
/**
|
|
1045
|
+
* Reorder an array of INamedEntities into an options list sorted by name.
|
|
1046
|
+
*
|
|
1047
|
+
* @param items - The array of INamedEntities to reorder.
|
|
1048
|
+
* @returns An array of sorted IOption.
|
|
1049
|
+
*/
|
|
724
1050
|
declare function asSortedOptions<T extends INamedEntity = INamedEntity>(items: T[]): IOption[];
|
|
725
1051
|
|
|
726
1052
|
/**
|
|
@@ -745,6 +1071,12 @@ declare function cloneItem<T = unknown>(item: T): T;
|
|
|
745
1071
|
|
|
746
1072
|
declare function collectFeatureTypes<T extends IEntity = IEntity>(items: T[], ...keys: string[]): Promise<IFeatureType[]>;
|
|
747
1073
|
|
|
1074
|
+
/**
|
|
1075
|
+
* Collects options from an array of items based on specified keys.
|
|
1076
|
+
* @param items The array of items to collect options from.
|
|
1077
|
+
* @param keys The keys to collect options for.
|
|
1078
|
+
* @returns A promise that resolves to an object containing the collected options.
|
|
1079
|
+
*/
|
|
748
1080
|
declare function collectOptions<T extends IEntity = IEntity>(items: T[], ...keys: string[]): Promise<Partial<Record<keyof T, IOption[]>>>;
|
|
749
1081
|
|
|
750
1082
|
/**
|
|
@@ -779,22 +1111,104 @@ type ListItem<T> = {
|
|
|
779
1111
|
*/
|
|
780
1112
|
declare function enumToList<T extends Record<string, number | string>>(enumeration: T, separatorRegex?: RegExp): ListItem<T>[];
|
|
781
1113
|
|
|
1114
|
+
/**
|
|
1115
|
+
* Checks if the given item is a number.
|
|
1116
|
+
* @param item The item to check.
|
|
1117
|
+
* @returns True if the item is a number, false otherwise.
|
|
1118
|
+
*/
|
|
782
1119
|
declare function isNumber(item: unknown): item is number;
|
|
1120
|
+
/**
|
|
1121
|
+
* Checks if the given item is a string.
|
|
1122
|
+
* @param item The item to check.
|
|
1123
|
+
* @returns True if the item is a string, false otherwise.
|
|
1124
|
+
*/
|
|
783
1125
|
declare function isString(item: unknown): item is string;
|
|
1126
|
+
/**
|
|
1127
|
+
* Checks if the given item is a valid non-empty string.
|
|
1128
|
+
* @param item The item to check.
|
|
1129
|
+
* @returns True if the item is a valid non-empty string, false otherwise.
|
|
1130
|
+
*/
|
|
784
1131
|
declare function isValidString(item: unknown): item is string;
|
|
1132
|
+
/**
|
|
1133
|
+
* Checks if the given item is an array.
|
|
1134
|
+
* @param item The item to check.
|
|
1135
|
+
* @returns True if the item is an array, false otherwise.
|
|
1136
|
+
*/
|
|
785
1137
|
declare function isArray<T = unknown>(item: unknown): item is Array<T>;
|
|
1138
|
+
/**
|
|
1139
|
+
* Checks if the given item is an object.
|
|
1140
|
+
* @param item The item to check.
|
|
1141
|
+
* @returns True if the item is an object, false otherwise.
|
|
1142
|
+
*/
|
|
786
1143
|
declare function isObject<T = Record<string, unknown>>(item: unknown): item is T;
|
|
1144
|
+
/**
|
|
1145
|
+
* Checks if the given item is a promise.
|
|
1146
|
+
* @param result The item to check.
|
|
1147
|
+
* @returns True if the item is a promise, false otherwise.
|
|
1148
|
+
*/
|
|
787
1149
|
declare function isPromise(result: unknown): result is Promise<unknown>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Checks if the given item is a non-null string.
|
|
1152
|
+
* @param item The item to check.
|
|
1153
|
+
* @returns True if the item is a non-null string, false otherwise.
|
|
1154
|
+
*/
|
|
788
1155
|
declare function isNotNullString(item: unknown): item is string;
|
|
1156
|
+
/**
|
|
1157
|
+
* Checks if the given item is equatable.
|
|
1158
|
+
* @param item The item to check.
|
|
1159
|
+
* @returns True if the item is equatable, false otherwise.
|
|
1160
|
+
*/
|
|
789
1161
|
declare function isEquatable(item: unknown): item is IEquatable;
|
|
790
|
-
|
|
1162
|
+
/**
|
|
1163
|
+
* Checks if the given item is an entity.
|
|
1164
|
+
* @param item The item to check.
|
|
1165
|
+
* @returns True if the item is an entity, false otherwise.
|
|
1166
|
+
*/
|
|
1167
|
+
declare function isEntity<T = IEntity>(item: unknown): item is T;
|
|
1168
|
+
/**
|
|
1169
|
+
* Checks if the given item is an unresolved relation.
|
|
1170
|
+
* @param item The item to check.
|
|
1171
|
+
* @returns True if the item is an unresolved relation, false otherwise.
|
|
1172
|
+
*/
|
|
791
1173
|
declare function isUnresolvedRelation(item: unknown): item is IPageUnresolvedRelation;
|
|
1174
|
+
/**
|
|
1175
|
+
* Checks if the given item is a relation.
|
|
1176
|
+
* @param item The item to check.
|
|
1177
|
+
* @returns True if the item is a relation, false otherwise.
|
|
1178
|
+
*/
|
|
792
1179
|
declare function isRelation(item: unknown): item is IPageRelation;
|
|
1180
|
+
/**
|
|
1181
|
+
* Checks if the given item is an undecorated menu item.
|
|
1182
|
+
* @param item The item to check.
|
|
1183
|
+
* @returns True if the item is an undecorated menu item, false otherwise.
|
|
1184
|
+
*/
|
|
793
1185
|
declare function isUndecoratedMenuItem(item: unknown): item is IUndecoratedMenuItem;
|
|
1186
|
+
/**
|
|
1187
|
+
* Checks if the given item is an undecorated navigation.
|
|
1188
|
+
* @param item The item to check.
|
|
1189
|
+
* @returns True if the item is an undecorated navigation, false otherwise.
|
|
1190
|
+
*/
|
|
794
1191
|
declare function isUndecoratedNav<T>(item: unknown): item is IUndecoratedNav<T>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Checks if the given item is an undecorated menu category.
|
|
1194
|
+
* @param item The item to check.
|
|
1195
|
+
* @returns True if the item is an undecorated menu category, false otherwise.
|
|
1196
|
+
*/
|
|
795
1197
|
declare function isUndecoratedMenuCategory(item: unknown): item is IUndecoratedMenuCategory;
|
|
1198
|
+
/**
|
|
1199
|
+
* Checks if the given item is an undecorated menu page.
|
|
1200
|
+
* @param item The item to check.
|
|
1201
|
+
* @returns True if the item is an undecorated menu page, false otherwise.
|
|
1202
|
+
*/
|
|
796
1203
|
declare function isUndecoratedMenuPage(item: unknown): item is IUndecoratedMenuPage;
|
|
797
1204
|
|
|
1205
|
+
/**
|
|
1206
|
+
* Generates a random UUID (Universally Unique Identifier) in version 4 format.
|
|
1207
|
+
*
|
|
1208
|
+
* @returns {string} The generated UUID.
|
|
1209
|
+
*/
|
|
1210
|
+
declare function uuidv4(): string;
|
|
1211
|
+
|
|
798
1212
|
declare function getIsDevelopment(): boolean;
|
|
799
1213
|
declare function getIsProduction(): boolean;
|
|
800
1214
|
declare const isDevelopment: boolean;
|
|
@@ -807,4 +1221,4 @@ declare function asServerProps(props: any): any;
|
|
|
807
1221
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
808
1222
|
declare function merge(target: any, source: any): any;
|
|
809
1223
|
|
|
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,
|
|
1224
|
+
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, asEquatableNumber, asEquatableString, asServerProps, asSortedOptions, awaitAll, camelToSnakeCase, cloneItem, 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 };
|