@websolutespa/payload-plugin-bowl 1.7.13 → 1.7.15
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 +10 -8
- package/dist/index.js +75 -41
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Endpoint, AdminView, Locale as Locale$1, Config } from 'payload/config'
|
|
|
3
3
|
import { Field, FieldBase, Tab, JSONField, Block as Block$1, FieldAffectingData, HookName, FieldHook as FieldHook$1, UIField as UIField$1 } from 'payload/dist/fields/config/types';
|
|
4
4
|
import * as payload_types from 'payload/types';
|
|
5
5
|
import { PayloadRequest, CollectionAfterChangeHook, CollectionAfterDeleteHook, TypeWithID, CollectionConfig, BeforeDuplicate, Where, Block, GlobalConfig, RichTextField, RelationshipField, CheckboxField, BlockField, DateField, TextField, GroupField, Field as Field$1, UploadField, ArrayField, NumberField, FieldHook, SelectField, CollapsibleField, RowField, TabsField, UIField, EmailField, TextareaField, RadioField, CodeField, PointField, SanitizedCollectionConfig } from 'payload/types';
|
|
6
|
-
import { IEntity, ILocale, ICategorized, IRoute, ICategory, IMarket, IMemoryStore, ILocalizable, IEquatable, IMedia, IPageRelation, ISchema, IMenuItem, IMenu } from '@websolutespa/bom-core';
|
|
6
|
+
import { IEntity, ILocale, ICategorized, IRoute, ICategory, IMarket, IMemoryStore, ILocalizable, IEquatable, IMedia, IPageRelation, ISchema, IMenuCategory, IMenuGroup, IMenuLink, IMenuPage, IMenuRoute, IMenuItem, IMenu } from '@websolutespa/bom-core';
|
|
7
7
|
import * as payload_dist_admin_components_forms_FieldDescription_types from 'payload/dist/admin/components/forms/FieldDescription/types';
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
import React__default, { ReactNode } from 'react';
|
|
@@ -208,6 +208,7 @@ declare const staticDetailGet: ((collectionConfig: CollectionConfig) => Endpoint
|
|
|
208
208
|
declare function populateStaticFields<T = IEntity>(item: T, fields: Field[], locale: string): Promise<T>;
|
|
209
209
|
declare function getStaticLoader(slug: string): () => Promise<Option[]>;
|
|
210
210
|
|
|
211
|
+
declare function getStoreRequest(req: PayloadRequest, market?: string, locale?: string): PayloadRequest;
|
|
211
212
|
declare function getStore(req: PayloadRequest): Promise<IMemoryStore>;
|
|
212
213
|
type FindOptions = {
|
|
213
214
|
context?: RequestContext;
|
|
@@ -227,10 +228,11 @@ type FindOptions = {
|
|
|
227
228
|
user?: any;
|
|
228
229
|
where?: Where;
|
|
229
230
|
};
|
|
230
|
-
declare function findCollection<T>(req: PayloadRequest, collection: string, options?: Omit<FindOptions, 'req'>): Promise<
|
|
231
|
+
declare function findCollection<T>(req: PayloadRequest, collection: string, options?: Omit<FindOptions, 'req'>): Promise<T[]>;
|
|
231
232
|
declare function getApiUrl(req: PayloadRequest): string;
|
|
232
233
|
declare function getSearchUrl(req: PayloadRequest, overrideQuery?: {}): string;
|
|
233
234
|
declare function fetchEndpoint<T>(req: PayloadRequest, endpoint: string, query?: {}): Promise<T>;
|
|
235
|
+
declare function fetchStaticCollection<T = any>(req: PayloadRequest, slug: string, query?: {}): Promise<T[]>;
|
|
234
236
|
declare function fetchCollection<T = any>(req: PayloadRequest, slug: string, query?: {}): Promise<{
|
|
235
237
|
docs: T[];
|
|
236
238
|
}>;
|
|
@@ -461,11 +463,11 @@ declare function localizeItem<T = IEntity>(item: T, localizedFields: string[], l
|
|
|
461
463
|
declare function localizeCollection<T = IEntity>(items: T[], localizedFields: string[], locale?: string): Promise<T[]>;
|
|
462
464
|
|
|
463
465
|
declare const MAX_INT = 1000000000000;
|
|
464
|
-
declare function decorateMenuCategory_(item: IUndecoratedMenuCategory, categories: ICategory[], routes: IRoute[], market: string, depth?: number):
|
|
465
|
-
declare function decorateMenuGroup_(item: IUndecoratedMenuGroup, categories: ICategory[], routes: IRoute[], market: string):
|
|
466
|
-
declare function decorateMenuLink_(item: IUndecoratedMenuLink, categories: ICategory[], routes: IRoute[], market: string):
|
|
467
|
-
declare function decorateMenuPage_(item: IUndecoratedMenuPage, categories: ICategory[], routes: IRoute[], market: string):
|
|
468
|
-
declare function decorateMenuRoute_(item: IRoute):
|
|
466
|
+
declare function decorateMenuCategory_(item: IUndecoratedMenuCategory, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuCategory;
|
|
467
|
+
declare function decorateMenuGroup_(item: IUndecoratedMenuGroup, categories: ICategory[], routes: IRoute[], market: string): IMenuGroup;
|
|
468
|
+
declare function decorateMenuLink_(item: IUndecoratedMenuLink, categories: ICategory[], routes: IRoute[], market: string): IMenuLink;
|
|
469
|
+
declare function decorateMenuPage_(item: IUndecoratedMenuPage, categories: ICategory[], routes: IRoute[], market: string): IMenuPage;
|
|
470
|
+
declare function decorateMenuRoute_(item: IRoute): IMenuRoute;
|
|
469
471
|
declare function decorateMenuItem_(item: IUndecoratedMenuItem, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuItem;
|
|
470
472
|
declare function decorateNavItem_(item: IUndecoratedNavItem, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuItem | IMenuItem[];
|
|
471
473
|
declare function hasMarket(item: IUndecoratedMenuItem, market: string): boolean;
|
|
@@ -1163,4 +1165,4 @@ declare const Logo: React__default.FC;
|
|
|
1163
1165
|
|
|
1164
1166
|
declare function webpack(sourceConfig: BowlConfig): (config: any) => any;
|
|
1165
1167
|
|
|
1166
|
-
export { ActionDefault, BlockDefaults, BowlArrayField, BowlBlock, BowlBlockField, BowlCollapsibleField, BowlCollection, BowlConfig, BowlField, BowlGlobal, BowlGroup, BowlGroupField, BowlInitOptions, BowlOptions, BowlPlugin, BowlRole, BowlRowField, BowlSlug, BowlTab, BowlTabsField, CategoryDefaults, CategoryMenu, CategoryMenuProps, CategoryTree, CategoryTreeProps, CheckboxDefaults, CollectionDefault, CollectionHelper, CollectionHook, CollectionHookName, CollectionHooks, ColorCell, ColorConfig, ColorField, ComponentsDefaults, CustomEditModal, CustomEditModalProps, DataField, DataTree, DataTreeDragItem, DataTreeItem, DataTreeItemLi, DataTreeItemProps, DataTreeProps, DataTreeProvider, DataTreeRenameItem, DateDefaults, DebugField, DecoratedList, DecoratedListProps, FindOptions, GlobalDefault, GlobalHelper, GlobalHook, GlobalHookName, GlobalHooks, GroupKey, IBulkAction, IBulkRecord, ICache, IImportItem, IPage, IPageFull, IPagination, IRelation, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNavItem, Icon, ImportExportList, ImportExportListProps, ImportExportRedirectList, ImportLogInvalidTypes, ImportLogType, ImportMode, InMemoryCache, InMemoryCacheOptions, KeyMapper, LeaveModal, LeaveWithoutSavingModal, LeaveWithoutSavingModalProps, LocalizedDescription, LocalizedDescriptionProps, Logo, MAX_INT, MarketDefaults, MediaDefaults, MediasDefaults, MenuItem, MixerContext, Option, OrderDefaults, PRESENTATION_FIELDS, PageDefault, PresentationField, PublicURL, Publish, RelatedDefaults, RichTextDefaults, Save, SaveDraft, SelectDefaults, StaticCollectionConfig, StaticCollectionDefault, TemplateDefaults, TextDefaults, TreeItems, UIStaticCell, UIStaticField, UserRolesDefaults, WithAbstract, WithAbstractProps, WithAction, WithActionProps, WithBlock, WithBlockProps, WithCategory, WithCategoryProps, WithCheckbox, WithCheckboxProps, WithCollection, WithCollectionProps, WithColor, WithColorProps, WithComponents, WithComponentsProps, WithDate, WithDateProps, WithDescription, WithDescriptionProps, WithGlobal, WithGlobalProps, WithId, WithIdProps, WithIsActive, WithIsActiveProps, WithIsDefault, WithIsDefaultProps, WithLink, WithLinkOptions, WithLinkProps, WithMarkets, WithMarketsProps, WithMedia, WithMediaProps, WithMedias, WithMediasProps, WithMenu, WithMenuProps, WithName, WithNameProps, WithOrder, WithOrderProps, WithPage, WithPageProps, WithRelated, WithRelatedProps, WithRichText, WithRichTextProps, WithRoles, WithRolesProps, WithSelect, WithSelectProps, WithSlug, WithSlugProps, WithStatic, WithStaticProps, WithTemplate, WithTemplateProps, WithText, WithTextProps, WithTitle, WithTitleProps, afterCategoryChangeHook, afterCategoryDeleteHook, afterCollectionReadHook, afterMenuReadHook, afterPageChangeHook, afterPageDeleteHook, afterPageReadHook, appearanceOptions, beforeDuplicateCollectionHook, beforeValidate, bowl, collectionBulkPatch, collectionExportGet, collectionImportPost, collectionIndexGet, collectionUpdatePatch, debugField, decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateMenuCategory_, decorateMenuGroup_, decorateMenuItem_, decorateMenuLink_, decorateMenuPage_, decorateMenuRoute_, decorateMenu_, decorateNavItem_, decorateNav_, decorateNavs_, decorateSchema_, decorateSchemas_, deepMerge, bowl as default, defaultGroup, defaultLocale, defaultLocales, defaultMarket, defaultSlug, eachDataField, eachField, encryptData, fetchCollection, fetchCollectionItems, fetchEndpoint, fetchGlobal, fetchGlobalItems, findCollection, formatSlug, getApiUrl, getCollectionItem, getCollectionItems, getEachMarketLocale, getGlobalItems, getLivePreviewURL, getLocale, getNumericParam, getObjectParam, getPages, getPagination, getPreviewURL, getPublicURL, getRoute, getRouteByCategoryAndLocale, getRouteByItemAndLocale, getRoutes, getSearchUrl, getStaticLoader, getStore, getStringParam, getSubRequest, getTranslation, getTranslations, getTreeItemClassName, hasMarket, hasRole, importExportListWithParser, internalSlugs, isAdmin, isAdminOrSelf, isDataField, isObject, isPresentationField, isRelation, isRole, isUndecoratedNavItem, keyWithRequest, localeGet, localizeCollection, localizeItem, log, logMissingTranslations, menuDetailGet, menuIndexGet, modalSlug, optinGet, options, optoutGet, pageDetailGet, pageIndexGet, parseDepth, populateStaticFields, redirectParser, richTextAfterReadHook, richTextSerialize, roles, routeGet, routePost, routePostHandler, setMixerContext, slugToLabel, slugToLabels, sortByGroup, sortCollection, staticCollectionLoaders, staticCollections, staticDetailGet, staticIndexGet, storeGet, textToSlug, toBlock, toCollection, toField, toGlobal, toTab, translateBlock, translateBlocks, translateCollection, translateField, translateFields, translateGlobal, translateTab, translateTabs, webpack, whereCollection, withAbstract, withAbstractRequired, withAction, withBlock, withCategory, withCategoryRequired, withCheckbox, withCheckboxRequired, withCollection, withCollectionHook, withColor, withColorRequired, withComponents, withDate, withDateRequired, withDescription, withDescriptionRequired, withFieldHook, withGlobal, withGlobalHook, withId, withIdRequired, withIsActive, withIsActiveRequired, withIsDefault, withIsDefaultRequired, withLink, withLocalizedDescription, withMarkets, withMarketsRequired, withMedia, withMediaRequired, withMedias, withMediasRequired, withMenu, withName, withNameRequired, withOrder, withOrderRequired, withPage, withRelated, withRichText, withRichTextRequired, withRoles, withSelect, withSelectRequired, withSlug, withSlugRequired, withStaticCollection, withTemplate, withTemplateRequired, withText, withTextRequired, withTitle, withTitleRequired, withUIStatic };
|
|
1168
|
+
export { ActionDefault, BlockDefaults, BowlArrayField, BowlBlock, BowlBlockField, BowlCollapsibleField, BowlCollection, BowlConfig, BowlField, BowlGlobal, BowlGroup, BowlGroupField, BowlInitOptions, BowlOptions, BowlPlugin, BowlRole, BowlRowField, BowlSlug, BowlTab, BowlTabsField, CategoryDefaults, CategoryMenu, CategoryMenuProps, CategoryTree, CategoryTreeProps, CheckboxDefaults, CollectionDefault, CollectionHelper, CollectionHook, CollectionHookName, CollectionHooks, ColorCell, ColorConfig, ColorField, ComponentsDefaults, CustomEditModal, CustomEditModalProps, DataField, DataTree, DataTreeDragItem, DataTreeItem, DataTreeItemLi, DataTreeItemProps, DataTreeProps, DataTreeProvider, DataTreeRenameItem, DateDefaults, DebugField, DecoratedList, DecoratedListProps, FindOptions, GlobalDefault, GlobalHelper, GlobalHook, GlobalHookName, GlobalHooks, GroupKey, IBulkAction, IBulkRecord, ICache, IImportItem, IPage, IPageFull, IPagination, IRelation, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNavItem, Icon, ImportExportList, ImportExportListProps, ImportExportRedirectList, ImportLogInvalidTypes, ImportLogType, ImportMode, InMemoryCache, InMemoryCacheOptions, KeyMapper, LeaveModal, LeaveWithoutSavingModal, LeaveWithoutSavingModalProps, LocalizedDescription, LocalizedDescriptionProps, Logo, MAX_INT, MarketDefaults, MediaDefaults, MediasDefaults, MenuItem, MixerContext, Option, OrderDefaults, PRESENTATION_FIELDS, PageDefault, PresentationField, PublicURL, Publish, RelatedDefaults, RichTextDefaults, Save, SaveDraft, SelectDefaults, StaticCollectionConfig, StaticCollectionDefault, TemplateDefaults, TextDefaults, TreeItems, UIStaticCell, UIStaticField, UserRolesDefaults, WithAbstract, WithAbstractProps, WithAction, WithActionProps, WithBlock, WithBlockProps, WithCategory, WithCategoryProps, WithCheckbox, WithCheckboxProps, WithCollection, WithCollectionProps, WithColor, WithColorProps, WithComponents, WithComponentsProps, WithDate, WithDateProps, WithDescription, WithDescriptionProps, WithGlobal, WithGlobalProps, WithId, WithIdProps, WithIsActive, WithIsActiveProps, WithIsDefault, WithIsDefaultProps, WithLink, WithLinkOptions, WithLinkProps, WithMarkets, WithMarketsProps, WithMedia, WithMediaProps, WithMedias, WithMediasProps, WithMenu, WithMenuProps, WithName, WithNameProps, WithOrder, WithOrderProps, WithPage, WithPageProps, WithRelated, WithRelatedProps, WithRichText, WithRichTextProps, WithRoles, WithRolesProps, WithSelect, WithSelectProps, WithSlug, WithSlugProps, WithStatic, WithStaticProps, WithTemplate, WithTemplateProps, WithText, WithTextProps, WithTitle, WithTitleProps, afterCategoryChangeHook, afterCategoryDeleteHook, afterCollectionReadHook, afterMenuReadHook, afterPageChangeHook, afterPageDeleteHook, afterPageReadHook, appearanceOptions, beforeDuplicateCollectionHook, beforeValidate, bowl, collectionBulkPatch, collectionExportGet, collectionImportPost, collectionIndexGet, collectionUpdatePatch, debugField, decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateMenuCategory_, decorateMenuGroup_, decorateMenuItem_, decorateMenuLink_, decorateMenuPage_, decorateMenuRoute_, decorateMenu_, decorateNavItem_, decorateNav_, decorateNavs_, decorateSchema_, decorateSchemas_, deepMerge, bowl as default, defaultGroup, defaultLocale, defaultLocales, defaultMarket, defaultSlug, eachDataField, eachField, encryptData, fetchCollection, fetchCollectionItems, fetchEndpoint, fetchGlobal, fetchGlobalItems, fetchStaticCollection, findCollection, formatSlug, getApiUrl, getCollectionItem, getCollectionItems, getEachMarketLocale, getGlobalItems, getLivePreviewURL, getLocale, getNumericParam, getObjectParam, getPages, getPagination, getPreviewURL, getPublicURL, getRoute, getRouteByCategoryAndLocale, getRouteByItemAndLocale, getRoutes, getSearchUrl, getStaticLoader, getStore, getStoreRequest, getStringParam, getSubRequest, getTranslation, getTranslations, getTreeItemClassName, hasMarket, hasRole, importExportListWithParser, internalSlugs, isAdmin, isAdminOrSelf, isDataField, isObject, isPresentationField, isRelation, isRole, isUndecoratedNavItem, keyWithRequest, localeGet, localizeCollection, localizeItem, log, logMissingTranslations, menuDetailGet, menuIndexGet, modalSlug, optinGet, options, optoutGet, pageDetailGet, pageIndexGet, parseDepth, populateStaticFields, redirectParser, richTextAfterReadHook, richTextSerialize, roles, routeGet, routePost, routePostHandler, setMixerContext, slugToLabel, slugToLabels, sortByGroup, sortCollection, staticCollectionLoaders, staticCollections, staticDetailGet, staticIndexGet, storeGet, textToSlug, toBlock, toCollection, toField, toGlobal, toTab, translateBlock, translateBlocks, translateCollection, translateField, translateFields, translateGlobal, translateTab, translateTabs, webpack, whereCollection, withAbstract, withAbstractRequired, withAction, withBlock, withCategory, withCategoryRequired, withCheckbox, withCheckboxRequired, withCollection, withCollectionHook, withColor, withColorRequired, withComponents, withDate, withDateRequired, withDescription, withDescriptionRequired, withFieldHook, withGlobal, withGlobalHook, withId, withIdRequired, withIsActive, withIsActiveRequired, withIsDefault, withIsDefaultRequired, withLink, withLocalizedDescription, withMarkets, withMarketsRequired, withMedia, withMediaRequired, withMedias, withMediasRequired, withMenu, withName, withNameRequired, withOrder, withOrderRequired, withPage, withRelated, withRichText, withRichTextRequired, withRoles, withSelect, withSelectRequired, withSlug, withSlugRequired, withStaticCollection, withTemplate, withTemplateRequired, withText, withTextRequired, withTitle, withTitleRequired, withUIStatic };
|
package/dist/index.js
CHANGED
|
@@ -287,6 +287,7 @@ __export(src_exports, {
|
|
|
287
287
|
fetchEndpoint: () => fetchEndpoint,
|
|
288
288
|
fetchGlobal: () => fetchGlobal,
|
|
289
289
|
fetchGlobalItems: () => fetchGlobalItems,
|
|
290
|
+
fetchStaticCollection: () => fetchStaticCollection,
|
|
290
291
|
findCollection: () => findCollection,
|
|
291
292
|
formatSlug: () => formatSlug,
|
|
292
293
|
getApiUrl: () => getApiUrl,
|
|
@@ -309,6 +310,7 @@ __export(src_exports, {
|
|
|
309
310
|
getSearchUrl: () => getSearchUrl,
|
|
310
311
|
getStaticLoader: () => getStaticLoader,
|
|
311
312
|
getStore: () => getStore,
|
|
313
|
+
getStoreRequest: () => getStoreRequest,
|
|
312
314
|
getStringParam: () => getStringParam,
|
|
313
315
|
getSubRequest: () => getSubRequest,
|
|
314
316
|
getTranslation: () => getTranslation4,
|
|
@@ -1736,8 +1738,8 @@ async function localizeItem(item, localizedFields, locale) {
|
|
|
1736
1738
|
return item;
|
|
1737
1739
|
}
|
|
1738
1740
|
__name(localizeItem, "localizeItem");
|
|
1739
|
-
async function localizeCollection(items, localizedFields, locale = "
|
|
1740
|
-
if (locale !== "
|
|
1741
|
+
async function localizeCollection(items, localizedFields, locale = "all") {
|
|
1742
|
+
if (locale !== "all" && localizedFields.length > 0) {
|
|
1741
1743
|
const localizedItems = [];
|
|
1742
1744
|
for (const item of items) {
|
|
1743
1745
|
const localizedItem = await localizeItem(item, localizedFields, locale);
|
|
@@ -3758,6 +3760,7 @@ async function decorateHrefs_(items, slug, context) {
|
|
|
3758
3760
|
__name(decorateHrefs_, "decorateHrefs_");
|
|
3759
3761
|
|
|
3760
3762
|
// src/core/decorators/menu.ts
|
|
3763
|
+
var import_bom_core6 = require("@websolutespa/bom-core");
|
|
3761
3764
|
var MAX_INT = 1e12;
|
|
3762
3765
|
function decorateMenuCategory_(item, categories, routes, market, depth = 0) {
|
|
3763
3766
|
const decoratedItem = {
|
|
@@ -3766,7 +3769,6 @@ function decorateMenuCategory_(item, categories, routes, market, depth = 0) {
|
|
|
3766
3769
|
title: "",
|
|
3767
3770
|
href: "",
|
|
3768
3771
|
category: "",
|
|
3769
|
-
media: item.media,
|
|
3770
3772
|
abstract: item.abstract,
|
|
3771
3773
|
customClass: item.customClass,
|
|
3772
3774
|
extra: item.extra,
|
|
@@ -3776,7 +3778,7 @@ function decorateMenuCategory_(item, categories, routes, market, depth = 0) {
|
|
|
3776
3778
|
if (category) {
|
|
3777
3779
|
decoratedItem.category = category.id;
|
|
3778
3780
|
decoratedItem.title = item.customTitle || category.title;
|
|
3779
|
-
decoratedItem.media =
|
|
3781
|
+
decoratedItem.media = item.media || category.media;
|
|
3780
3782
|
const route = routes.find((x) => x.isDefault && x.category === category.id);
|
|
3781
3783
|
if (route) {
|
|
3782
3784
|
decoratedItem.href = route.id;
|
|
@@ -3843,20 +3845,21 @@ function decorateMenuLink_(item, categories, routes, market) {
|
|
|
3843
3845
|
}
|
|
3844
3846
|
__name(decorateMenuLink_, "decorateMenuLink_");
|
|
3845
3847
|
function decorateMenuPage_(item, categories, routes, market) {
|
|
3848
|
+
const page = (0, import_bom_core6.isObject)(item.page.value) ? item.page.value : {
|
|
3849
|
+
id: item.page.value
|
|
3850
|
+
};
|
|
3846
3851
|
const route = routes.find(
|
|
3847
|
-
(x) => x.schema === item.page.relationTo && x.page ===
|
|
3852
|
+
(x) => x.schema === item.page.relationTo && x.page === page.id
|
|
3848
3853
|
);
|
|
3849
|
-
const href = route?.id;
|
|
3850
3854
|
const schema = item.schema || item.page.relationTo;
|
|
3851
|
-
const page = item.page.value;
|
|
3852
3855
|
const decoratedItem = {
|
|
3853
|
-
id: item.id,
|
|
3854
3856
|
type: item.type,
|
|
3855
|
-
title: item.customTitle || page.title,
|
|
3856
|
-
href,
|
|
3857
|
-
page: page.id,
|
|
3858
3857
|
schema,
|
|
3859
|
-
|
|
3858
|
+
id: item.id,
|
|
3859
|
+
href: route?.id,
|
|
3860
|
+
page: route ? route.page : page.id,
|
|
3861
|
+
title: item.customTitle || (route ? route.title : page.title),
|
|
3862
|
+
media: item.media || (route ? route.media : page.media),
|
|
3860
3863
|
abstract: item.abstract,
|
|
3861
3864
|
customClass: item.customClass,
|
|
3862
3865
|
extra: item.extra,
|
|
@@ -3870,6 +3873,7 @@ function decorateMenuRoute_(item) {
|
|
|
3870
3873
|
id: item.page,
|
|
3871
3874
|
type: "route",
|
|
3872
3875
|
title: item.title,
|
|
3876
|
+
media: item.media,
|
|
3873
3877
|
href: item.id,
|
|
3874
3878
|
page: item.page,
|
|
3875
3879
|
schema: item.schema,
|
|
@@ -3918,7 +3922,7 @@ function decorateNavItem_(item, categories, routes, market, depth = 0) {
|
|
|
3918
3922
|
}
|
|
3919
3923
|
__name(decorateNavItem_, "decorateNavItem_");
|
|
3920
3924
|
function hasMarket(item, market) {
|
|
3921
|
-
return Array.isArray(item.markets) ? item.markets.includes(market) : true;
|
|
3925
|
+
return market === "all" ? true : Array.isArray(item.markets) ? item.markets.includes(market) : true;
|
|
3922
3926
|
}
|
|
3923
3927
|
__name(hasMarket, "hasMarket");
|
|
3924
3928
|
async function decorateMenu_(item, context) {
|
|
@@ -3927,10 +3931,10 @@ async function decorateMenu_(item, context) {
|
|
|
3927
3931
|
items: []
|
|
3928
3932
|
};
|
|
3929
3933
|
const { market, locale, markets, locales: locales2, routes, categories } = context;
|
|
3930
|
-
if (!locales2.includes(locale)) {
|
|
3934
|
+
if (!locales2.includes(locale) && locale !== "all") {
|
|
3931
3935
|
return decoratedItem;
|
|
3932
3936
|
}
|
|
3933
|
-
if (!markets.includes(market)) {
|
|
3937
|
+
if (!markets.includes(market) && market !== "all") {
|
|
3934
3938
|
return decoratedItem;
|
|
3935
3939
|
}
|
|
3936
3940
|
decoratedItem.items = item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market));
|
|
@@ -3939,7 +3943,7 @@ async function decorateMenu_(item, context) {
|
|
|
3939
3943
|
__name(decorateMenu_, "decorateMenu_");
|
|
3940
3944
|
|
|
3941
3945
|
// src/core/decorators/nav.ts
|
|
3942
|
-
var
|
|
3946
|
+
var import_bom_core7 = require("@websolutespa/bom-core");
|
|
3943
3947
|
async function decorateNav_(item, slug, context) {
|
|
3944
3948
|
parseNavs_(item, context);
|
|
3945
3949
|
return item;
|
|
@@ -3954,7 +3958,7 @@ async function decorateNavs_(items, slug, context) {
|
|
|
3954
3958
|
__name(decorateNavs_, "decorateNavs_");
|
|
3955
3959
|
function parseNavs_(item, context) {
|
|
3956
3960
|
const { market, locale, routes, categories } = context;
|
|
3957
|
-
if ((0,
|
|
3961
|
+
if ((0, import_bom_core7.isArray)(item)) {
|
|
3958
3962
|
item.forEach((v, k) => {
|
|
3959
3963
|
if (isUndecoratedNavItem(v)) {
|
|
3960
3964
|
item[k] = decorateNavItem_(v, categories, routes, market);
|
|
@@ -3962,7 +3966,7 @@ function parseNavs_(item, context) {
|
|
|
3962
3966
|
parseNavs_(v, context);
|
|
3963
3967
|
}
|
|
3964
3968
|
});
|
|
3965
|
-
} else if ((0,
|
|
3969
|
+
} else if ((0, import_bom_core7.isObject)(item)) {
|
|
3966
3970
|
Object.entries(item).forEach(([k, v]) => {
|
|
3967
3971
|
if (isUndecoratedNavItem(v)) {
|
|
3968
3972
|
item[k] = decorateNavItem_(v, categories, routes, market);
|
|
@@ -3974,11 +3978,11 @@ function parseNavs_(item, context) {
|
|
|
3974
3978
|
}
|
|
3975
3979
|
__name(parseNavs_, "parseNavs_");
|
|
3976
3980
|
function isUndecoratedNavItem(item) {
|
|
3977
|
-
return (0,
|
|
3981
|
+
return (0, import_bom_core7.isObject)(item) && (item.type === "category" && ((0, import_bom_core7.isEquatable)(item.category) || (0, import_bom_core7.isObject)(item.category)) || item.type === "page" && isRelation(item.page));
|
|
3978
3982
|
}
|
|
3979
3983
|
__name(isUndecoratedNavItem, "isUndecoratedNavItem");
|
|
3980
3984
|
function isRelation(item) {
|
|
3981
|
-
return (0,
|
|
3985
|
+
return (0, import_bom_core7.isObject)(item) && (0, import_bom_core7.isNotNullString)(item.relationTo) && ((0, import_bom_core7.isObject)(item.value) || (0, import_bom_core7.isArray)(item.value));
|
|
3982
3986
|
}
|
|
3983
3987
|
__name(isRelation, "isRelation");
|
|
3984
3988
|
|
|
@@ -4180,15 +4184,34 @@ var afterPageDeleteHook = /* @__PURE__ */ __name(async ({
|
|
|
4180
4184
|
}, "afterPageDeleteHook");
|
|
4181
4185
|
|
|
4182
4186
|
// src/core/api/store.service.ts
|
|
4183
|
-
var
|
|
4187
|
+
var import_bom_core8 = require("@websolutespa/bom-core");
|
|
4184
4188
|
var import_qs2 = __toESM(require("qs"));
|
|
4189
|
+
var USE_CACHE = true;
|
|
4185
4190
|
var CACHE_2 = new InMemoryCache();
|
|
4191
|
+
function getStoreRequest(req, market = "all", locale = "all") {
|
|
4192
|
+
const { where: w, market: m, locale: l, ...rest } = req.query;
|
|
4193
|
+
const subQuery = {
|
|
4194
|
+
market,
|
|
4195
|
+
locale
|
|
4196
|
+
};
|
|
4197
|
+
req.query = {
|
|
4198
|
+
...rest,
|
|
4199
|
+
...subQuery
|
|
4200
|
+
};
|
|
4201
|
+
req.locale = locale;
|
|
4202
|
+
return req;
|
|
4203
|
+
}
|
|
4204
|
+
__name(getStoreRequest, "getStoreRequest");
|
|
4186
4205
|
async function getStore(req) {
|
|
4187
4206
|
const key = keyWithRequest("store", req);
|
|
4188
|
-
if (CACHE_2.has(key)) {
|
|
4207
|
+
if (CACHE_2.has(key) && USE_CACHE && req.query.nocache != null) {
|
|
4189
4208
|
return CACHE_2.get(key);
|
|
4190
4209
|
}
|
|
4210
|
+
const market = "all";
|
|
4211
|
+
const locale = "all";
|
|
4191
4212
|
const store = {};
|
|
4213
|
+
const subRequest = getStoreRequest(req, market, locale);
|
|
4214
|
+
const context = await setMixerContext(subRequest, market, locale);
|
|
4192
4215
|
for (const slug of options.collections) {
|
|
4193
4216
|
try {
|
|
4194
4217
|
const collection = req.payload.collections[slug];
|
|
@@ -4197,36 +4220,40 @@ async function getStore(req) {
|
|
|
4197
4220
|
}
|
|
4198
4221
|
const bowlCollection = options.bowlCollections.find((x) => x.slug === slug);
|
|
4199
4222
|
const type = bowlCollection?.type;
|
|
4200
|
-
let items = [];
|
|
4201
4223
|
switch (type) {
|
|
4202
4224
|
case "withStatic":
|
|
4203
4225
|
{
|
|
4204
|
-
const
|
|
4205
|
-
|
|
4226
|
+
const items = await fetchStaticCollection(subRequest, slug);
|
|
4227
|
+
store[slug] = items;
|
|
4206
4228
|
}
|
|
4207
4229
|
break;
|
|
4208
4230
|
case "withPage":
|
|
4209
4231
|
{
|
|
4210
|
-
const
|
|
4232
|
+
const options2 = {
|
|
4211
4233
|
where: {
|
|
4212
4234
|
_status: {
|
|
4213
4235
|
equals: "published"
|
|
4214
4236
|
}
|
|
4215
4237
|
}
|
|
4216
|
-
}
|
|
4217
|
-
items =
|
|
4238
|
+
};
|
|
4239
|
+
const items = await findCollection(subRequest, slug, options2);
|
|
4240
|
+
store[slug] = items;
|
|
4218
4241
|
}
|
|
4219
4242
|
break;
|
|
4220
4243
|
default: {
|
|
4221
|
-
const
|
|
4222
|
-
|
|
4244
|
+
const options2 = slug === "category" ? {
|
|
4245
|
+
sort: "order"
|
|
4246
|
+
} : void 0;
|
|
4247
|
+
const items = await findCollection(subRequest, slug, options2);
|
|
4248
|
+
store[slug] = items;
|
|
4223
4249
|
}
|
|
4224
4250
|
}
|
|
4225
|
-
store[slug] = items;
|
|
4226
4251
|
} catch (error) {
|
|
4227
4252
|
if (error.status !== 403) {
|
|
4228
4253
|
throw error;
|
|
4229
4254
|
}
|
|
4255
|
+
console.log("StoreService", `no access granted for collection '${slug}'`);
|
|
4256
|
+
store[slug] = [];
|
|
4230
4257
|
}
|
|
4231
4258
|
}
|
|
4232
4259
|
const localeCollection = await fetchCollection(req, "locale", { richText: false });
|
|
@@ -4238,17 +4265,18 @@ async function getStore(req) {
|
|
|
4238
4265
|
}
|
|
4239
4266
|
__name(getStore, "getStore");
|
|
4240
4267
|
async function findCollection(req, collection, options2) {
|
|
4241
|
-
const
|
|
4242
|
-
newRequest.query.richText = "false";
|
|
4243
|
-
const items = await req.payload.find({
|
|
4268
|
+
const response = await req.payload.find({
|
|
4244
4269
|
collection,
|
|
4245
4270
|
depth: 1,
|
|
4246
4271
|
limit: 1e4,
|
|
4247
|
-
locale:
|
|
4248
|
-
|
|
4272
|
+
locale: req.locale,
|
|
4273
|
+
pagination: true,
|
|
4274
|
+
// draft: draft === 'true',
|
|
4275
|
+
req,
|
|
4249
4276
|
user: req.user,
|
|
4250
4277
|
...options2
|
|
4251
4278
|
});
|
|
4279
|
+
const items = (0, import_bom_core8.isArray)(response) ? response : (0, import_bom_core8.isArray)(response.docs) ? response.docs : [];
|
|
4252
4280
|
return items;
|
|
4253
4281
|
}
|
|
4254
4282
|
__name(findCollection, "findCollection");
|
|
@@ -4258,14 +4286,14 @@ function getApiUrl(req) {
|
|
|
4258
4286
|
const port = process.env.PORT || 4e3;
|
|
4259
4287
|
const origin = `http://localhost:${port}`;
|
|
4260
4288
|
let url = `${origin}${config.routes.api}/`;
|
|
4261
|
-
url =
|
|
4289
|
+
url = import_bom_core8.isBrowser ? url : url.replace("://localhost", "://127.0.0.1");
|
|
4262
4290
|
return url;
|
|
4263
4291
|
}
|
|
4264
4292
|
__name(getApiUrl, "getApiUrl");
|
|
4265
4293
|
function getSearchUrl(req, overrideQuery) {
|
|
4266
4294
|
const { query } = req;
|
|
4267
4295
|
const params = Object.assign({
|
|
4268
|
-
locale: "
|
|
4296
|
+
locale: "all",
|
|
4269
4297
|
depth: 1,
|
|
4270
4298
|
limit: 1e4
|
|
4271
4299
|
}, query, overrideQuery);
|
|
@@ -4299,6 +4327,10 @@ async function fetchEndpoint(req, endpoint, query) {
|
|
|
4299
4327
|
}
|
|
4300
4328
|
}
|
|
4301
4329
|
__name(fetchEndpoint, "fetchEndpoint");
|
|
4330
|
+
async function fetchStaticCollection(req, slug, query) {
|
|
4331
|
+
return await fetchEndpoint(req, slug, query);
|
|
4332
|
+
}
|
|
4333
|
+
__name(fetchStaticCollection, "fetchStaticCollection");
|
|
4302
4334
|
async function fetchCollection(req, slug, query) {
|
|
4303
4335
|
return await fetchEndpoint(req, slug, query);
|
|
4304
4336
|
}
|
|
@@ -4897,7 +4929,7 @@ function richTextSerialize(children, includeHtmlTags = true) {
|
|
|
4897
4929
|
case "li":
|
|
4898
4930
|
return `<li>${richTextSerialize(node.children)}</li>`;
|
|
4899
4931
|
case "link":
|
|
4900
|
-
return `<a href="${(0, import_escape_html.default)(node.url)}">${richTextSerialize(node.children)}</a>`;
|
|
4932
|
+
return `<a href="${(0, import_escape_html.default)(node.url)}"${node.newTab ? ' target="_blank"' : ""}>${richTextSerialize(node.children)}</a>`;
|
|
4901
4933
|
default:
|
|
4902
4934
|
return `<p>${richTextSerialize(node.children)}</p>`;
|
|
4903
4935
|
}
|
|
@@ -6354,8 +6386,8 @@ var Province = /* @__PURE__ */ __name((options2) => ({
|
|
|
6354
6386
|
}), "Province");
|
|
6355
6387
|
|
|
6356
6388
|
// src/collections/Redirect.ts
|
|
6357
|
-
var
|
|
6358
|
-
var RedirectStatusOptions = Object.entries(
|
|
6389
|
+
var import_bom_core9 = require("@websolutespa/bom-core");
|
|
6390
|
+
var RedirectStatusOptions = Object.entries(import_bom_core9.RedirectReason).map(([k, v]) => ({
|
|
6359
6391
|
value: v,
|
|
6360
6392
|
label: `${v} - ${k}`
|
|
6361
6393
|
}));
|
|
@@ -7460,6 +7492,7 @@ var src_default = bowl;
|
|
|
7460
7492
|
fetchEndpoint,
|
|
7461
7493
|
fetchGlobal,
|
|
7462
7494
|
fetchGlobalItems,
|
|
7495
|
+
fetchStaticCollection,
|
|
7463
7496
|
findCollection,
|
|
7464
7497
|
formatSlug,
|
|
7465
7498
|
getApiUrl,
|
|
@@ -7482,6 +7515,7 @@ var src_default = bowl;
|
|
|
7482
7515
|
getSearchUrl,
|
|
7483
7516
|
getStaticLoader,
|
|
7484
7517
|
getStore,
|
|
7518
|
+
getStoreRequest,
|
|
7485
7519
|
getStringParam,
|
|
7486
7520
|
getSubRequest,
|
|
7487
7521
|
getTranslation,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websolutespa/payload-plugin-bowl",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.15",
|
|
4
4
|
"description": "Bowl PayloadCms plugin of the BOM Repository",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lint": "eslint *.ts*",
|
|
18
|
-
"test:single": "jest -- \"./src/core/
|
|
18
|
+
"test:single": "jest -- \"./src/core/api/store.service.test.ts\" --forceExit --runInBand --workerIdleMemoryLimit='1000MB'",
|
|
19
19
|
"test": "jest --forceExit --runInBand --workerIdleMemoryLimit='1000MB'",
|
|
20
20
|
"test-watch": "npm test -- --watch",
|
|
21
21
|
"coverage:integration": "npm run test -- --coverage",
|