@websolutespa/payload-plugin-bowl 1.7.0 → 1.7.1
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 +17 -11
- package/dist/index.js +114 -101
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -118,15 +118,19 @@ declare const menuIndexGet: ((options: BowlOptions) => Endpoint);
|
|
|
118
118
|
* Rest api menu detail get handler.
|
|
119
119
|
*/
|
|
120
120
|
declare const menuDetailGet: ((options: BowlOptions) => Endpoint);
|
|
121
|
-
|
|
122
121
|
/**
|
|
123
|
-
*
|
|
122
|
+
* Decorate record for Mixer when queried by market and locale.
|
|
124
123
|
*/
|
|
125
|
-
declare const
|
|
124
|
+
declare const afterMenuReadHook: (slug: string) => CollectionConfig['hooks']['afterRead'][number];
|
|
125
|
+
|
|
126
126
|
/**
|
|
127
127
|
* Rest api page collection get handler.
|
|
128
128
|
*/
|
|
129
129
|
declare const pageIndexGet: ((slug: string) => Endpoint);
|
|
130
|
+
/**
|
|
131
|
+
* Rest api page collection detail get handler.
|
|
132
|
+
*/
|
|
133
|
+
declare const pageDetailGet: ((slug: string) => Endpoint);
|
|
130
134
|
/**
|
|
131
135
|
* Decorate record for Mixer when queried by market and locale.
|
|
132
136
|
*/
|
|
@@ -160,8 +164,8 @@ declare function getRouteByCategoryAndLocale(req: PayloadRequest<any>, item: ICa
|
|
|
160
164
|
declare const routeGet: Endpoint;
|
|
161
165
|
declare const routePost: Endpoint;
|
|
162
166
|
declare function routePostHandler(request: any, response: any, next: any): Promise<any>;
|
|
163
|
-
declare function
|
|
164
|
-
declare function
|
|
167
|
+
declare function getEachMarketLocale(req: PayloadRequest<any>, callback: (market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]) => void): Promise<void>;
|
|
168
|
+
declare function getPages(req: PayloadRequest<any>): Promise<IMemoryStore<ICategorized>>;
|
|
165
169
|
|
|
166
170
|
declare function getStore(req: PayloadRequest): Promise<IMemoryStore>;
|
|
167
171
|
declare function getApiUrl(req: PayloadRequest): string;
|
|
@@ -210,9 +214,10 @@ type IUndecoratedMenuBase = {
|
|
|
210
214
|
id: IEquatable;
|
|
211
215
|
type: string;
|
|
212
216
|
items: IUndecoratedMenuItem[];
|
|
213
|
-
markets?: string[];
|
|
214
217
|
abstract?: string;
|
|
218
|
+
customClass?: string;
|
|
215
219
|
extra?: string;
|
|
220
|
+
markets?: string[];
|
|
216
221
|
media?: IMedia;
|
|
217
222
|
};
|
|
218
223
|
type IUndecoratedMenuCategory = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
@@ -255,11 +260,15 @@ type MixerContext = {
|
|
|
255
260
|
routes?: IRoute[];
|
|
256
261
|
categories?: ICategory[];
|
|
257
262
|
richText?: boolean;
|
|
263
|
+
locales?: string[];
|
|
264
|
+
markets?: string[];
|
|
258
265
|
};
|
|
259
266
|
|
|
260
267
|
declare function getObjectParam(value: unknown): {} | undefined;
|
|
261
268
|
declare function getNumericParam(value: unknown): number | undefined;
|
|
262
269
|
declare function getStringParam(value: unknown): string | undefined;
|
|
270
|
+
declare function getSubRequest(req: PayloadRequest): PayloadRequest;
|
|
271
|
+
declare function setMixerContext(req: PayloadRequest, market: string, locale: string): Promise<MixerContext>;
|
|
263
272
|
|
|
264
273
|
type WithActionProps = (Omit<CollectionConfig, 'fields'> & {
|
|
265
274
|
fields: BowlField[];
|
|
@@ -398,8 +407,6 @@ declare function decorateHrefs_<T extends ISchema = ISchema>(items: T[], slug: s
|
|
|
398
407
|
})[]>;
|
|
399
408
|
|
|
400
409
|
declare const MAX_INT = 1000000000000;
|
|
401
|
-
declare function getLocales(req: PayloadRequest<any>): Promise<string[]>;
|
|
402
|
-
declare function getMarkets(req: PayloadRequest<any>): Promise<string[]>;
|
|
403
410
|
declare function decorateMenuCategory_(item: IUndecoratedMenuCategory, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuItem;
|
|
404
411
|
declare function decorateMenuGroup_(item: IUndecoratedMenuGroup, categories: ICategory[], routes: IRoute[], market: string): IMenuItem;
|
|
405
412
|
declare function decorateMenuLink_(item: IUndecoratedMenuLink, categories: ICategory[], routes: IRoute[], market: string): IMenuItem;
|
|
@@ -407,8 +414,7 @@ declare function decorateMenuPage_(item: IUndecoratedMenuPage, categories: ICate
|
|
|
407
414
|
declare function decorateMenuRoute_(item: IRoute): IMenuItem;
|
|
408
415
|
declare function decorateMenuItem_(item: IUndecoratedMenuItem, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuItem;
|
|
409
416
|
declare function hasMarket(item: IUndecoratedMenuItem, market: string): boolean;
|
|
410
|
-
declare function decorateMenu_(
|
|
411
|
-
declare function decorateMenus_(req: PayloadRequest<any>, items: IUndecoratedMenu[], market: string, locale: string): Promise<IMenu[]>;
|
|
417
|
+
declare function decorateMenu_(item: IUndecoratedMenu, context: MixerContext): Promise<IMenu>;
|
|
412
418
|
|
|
413
419
|
declare function decorateNav_<T extends ISchema = ISchema>(item: T, slug: string, context: MixerContext): Promise<T>;
|
|
414
420
|
declare function decorateNavs_<T extends ISchema = ISchema>(items: T[], slug: string, context: MixerContext): Promise<T[]>;
|
|
@@ -1097,4 +1103,4 @@ declare const Logo: React__default.FC;
|
|
|
1097
1103
|
|
|
1098
1104
|
declare function webpack(sourceConfig: BowlConfig): (config: any) => any;
|
|
1099
1105
|
|
|
1100
|
-
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, GlobalDefault, GlobalHelper, GlobalHook, GlobalHookName, GlobalHooks, GroupKey, IBulkAction, IBulkRecord, ICache, IImportItem, IPage, IPageFull, IPagination, IRelation, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, Icon, ImportExportList, ImportExportListProps, ImportExportRedirectList, ImportLogInvalidTypes, ImportLogType, ImportMode, InMemoryCache, InMemoryCacheOptions, 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, afterPageChangeHook, afterPageDeleteHook, afterPageReadHook, appearanceOptions, beforeValidate, bowl, collectionBulkPatch, collectionExportGet, collectionImportPost, collectionIndexGet, collectionUpdatePatch, debugField, decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateMenuCategory_, decorateMenuGroup_, decorateMenuItem_, decorateMenuLink_, decorateMenuPage_, decorateMenuRoute_, decorateMenu_,
|
|
1106
|
+
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, GlobalDefault, GlobalHelper, GlobalHook, GlobalHookName, GlobalHooks, GroupKey, IBulkAction, IBulkRecord, ICache, IImportItem, IPage, IPageFull, IPagination, IRelation, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, Icon, ImportExportList, ImportExportListProps, ImportExportRedirectList, ImportLogInvalidTypes, ImportLogType, ImportMode, InMemoryCache, InMemoryCacheOptions, 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, afterMenuReadHook, afterPageChangeHook, afterPageDeleteHook, afterPageReadHook, appearanceOptions, beforeValidate, bowl, collectionBulkPatch, collectionExportGet, collectionImportPost, collectionIndexGet, collectionUpdatePatch, debugField, decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateMenuCategory_, decorateMenuGroup_, decorateMenuItem_, decorateMenuLink_, decorateMenuPage_, decorateMenuRoute_, decorateMenu_, decorateNav_, decorateNavs_, decorateSchema_, decorateSchemas_, deepMerge, bowl as default, defaultGroup, defaultLocale, defaultLocales, defaultMarket, defaultSlug, eachDataField, eachField, encryptData, fetchCollection, fetchCollectionItems, fetchEndpoint, fetchGlobal, fetchGlobalItems, 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, isDataField, isObject, isPresentationField, isRelation, isRole, isUndecoratedMenuItem, keyWithRequest, localeGet, localizeCollection, log, logMissingTranslations, menuDetailGet, menuIndexGet, modalSlug, optinPost, options, pageDetailGet, pageIndexGet, parseDepth, populateStaticFields, redirectParser, richTextAfterReadHook, richTextSerialize, roles, routeGet, routePost, routePostHandler, setMixerContext, slugToLabel, slugToLabels, sortByGroup, sortCollection, 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
|
@@ -241,6 +241,7 @@ __export(src_exports, {
|
|
|
241
241
|
UserRolesDefaults: () => UserRolesDefaults,
|
|
242
242
|
afterCategoryChangeHook: () => afterCategoryChangeHook,
|
|
243
243
|
afterCategoryDeleteHook: () => afterCategoryDeleteHook,
|
|
244
|
+
afterMenuReadHook: () => afterMenuReadHook,
|
|
244
245
|
afterPageChangeHook: () => afterPageChangeHook,
|
|
245
246
|
afterPageDeleteHook: () => afterPageDeleteHook,
|
|
246
247
|
afterPageReadHook: () => afterPageReadHook,
|
|
@@ -264,7 +265,6 @@ __export(src_exports, {
|
|
|
264
265
|
decorateMenuPage_: () => decorateMenuPage_,
|
|
265
266
|
decorateMenuRoute_: () => decorateMenuRoute_,
|
|
266
267
|
decorateMenu_: () => decorateMenu_,
|
|
267
|
-
decorateMenus_: () => decorateMenus_,
|
|
268
268
|
decorateNav_: () => decorateNav_,
|
|
269
269
|
decorateNavs_: () => decorateNavs_,
|
|
270
270
|
decorateSchema_: () => decorateSchema_,
|
|
@@ -281,22 +281,20 @@ __export(src_exports, {
|
|
|
281
281
|
encryptData: () => encryptData,
|
|
282
282
|
fetchCollection: () => fetchCollection,
|
|
283
283
|
fetchCollectionItems: () => fetchCollectionItems,
|
|
284
|
-
fetchEachMarketLocale: () => fetchEachMarketLocale,
|
|
285
284
|
fetchEndpoint: () => fetchEndpoint,
|
|
286
285
|
fetchGlobal: () => fetchGlobal,
|
|
287
286
|
fetchGlobalItems: () => fetchGlobalItems,
|
|
288
|
-
fetchPages: () => fetchPages,
|
|
289
287
|
formatSlug: () => formatSlug,
|
|
290
288
|
getApiUrl: () => getApiUrl,
|
|
291
289
|
getCollectionItem: () => getCollectionItem,
|
|
292
290
|
getCollectionItems: () => getCollectionItems,
|
|
291
|
+
getEachMarketLocale: () => getEachMarketLocale,
|
|
293
292
|
getGlobalItems: () => getGlobalItems,
|
|
294
293
|
getLivePreviewURL: () => getLivePreviewURL,
|
|
295
294
|
getLocale: () => getLocale,
|
|
296
|
-
getLocales: () => getLocales,
|
|
297
|
-
getMarkets: () => getMarkets,
|
|
298
295
|
getNumericParam: () => getNumericParam,
|
|
299
296
|
getObjectParam: () => getObjectParam,
|
|
297
|
+
getPages: () => getPages,
|
|
300
298
|
getPagination: () => getPagination,
|
|
301
299
|
getPreviewURL: () => getPreviewURL,
|
|
302
300
|
getPublicURL: () => getPublicURL,
|
|
@@ -308,6 +306,7 @@ __export(src_exports, {
|
|
|
308
306
|
getStaticLoader: () => getStaticLoader,
|
|
309
307
|
getStore: () => getStore,
|
|
310
308
|
getStringParam: () => getStringParam,
|
|
309
|
+
getSubRequest: () => getSubRequest,
|
|
311
310
|
getTranslation: () => getTranslation4,
|
|
312
311
|
getTranslations: () => getTranslations,
|
|
313
312
|
getTreeItemClassName: () => getTreeItemClassName,
|
|
@@ -343,6 +342,7 @@ __export(src_exports, {
|
|
|
343
342
|
routeGet: () => routeGet,
|
|
344
343
|
routePost: () => routePost,
|
|
345
344
|
routePostHandler: () => routePostHandler,
|
|
345
|
+
setMixerContext: () => setMixerContext,
|
|
346
346
|
slugToLabel: () => slugToLabel,
|
|
347
347
|
slugToLabels: () => slugToLabels,
|
|
348
348
|
sortByGroup: () => sortByGroup,
|
|
@@ -1673,7 +1673,6 @@ function DataTree(props) {
|
|
|
1673
1673
|
}), "onSetName");
|
|
1674
1674
|
const dataProvider = new DataTreeProvider(items, onSetName);
|
|
1675
1675
|
dataProvider.onItemsDidChange((items2) => {
|
|
1676
|
-
console.log("onItemsDidChange", items2);
|
|
1677
1676
|
if (typeof onChange === "function") {
|
|
1678
1677
|
onChange(items2);
|
|
1679
1678
|
}
|
|
@@ -1844,7 +1843,7 @@ var CategoryTree = /* @__PURE__ */ __name((props) => {
|
|
|
1844
1843
|
const onSubmit = /* @__PURE__ */ __name(async () => {
|
|
1845
1844
|
const changesToCategories = /* @__PURE__ */ __name((changes2) => {
|
|
1846
1845
|
const newCategories2 = categories.map((x) => ({ ...x }));
|
|
1847
|
-
const root = changes2
|
|
1846
|
+
const root = changes2[ROOT_ITEM];
|
|
1848
1847
|
let order = 0;
|
|
1849
1848
|
const parseChildren = /* @__PURE__ */ __name((parent) => {
|
|
1850
1849
|
const parentIndex = parent.index;
|
|
@@ -3134,6 +3133,33 @@ function getStringParam(value) {
|
|
|
3134
3133
|
return void 0;
|
|
3135
3134
|
}
|
|
3136
3135
|
__name(getStringParam, "getStringParam");
|
|
3136
|
+
function getSubRequest(req) {
|
|
3137
|
+
const { transactionID, payload, user } = req;
|
|
3138
|
+
const { where, ...rest } = req.query;
|
|
3139
|
+
const subRequest = {
|
|
3140
|
+
user,
|
|
3141
|
+
transactionID,
|
|
3142
|
+
query: {
|
|
3143
|
+
...rest
|
|
3144
|
+
},
|
|
3145
|
+
payload
|
|
3146
|
+
};
|
|
3147
|
+
return subRequest;
|
|
3148
|
+
}
|
|
3149
|
+
__name(getSubRequest, "getSubRequest");
|
|
3150
|
+
async function setMixerContext(req, market, locale) {
|
|
3151
|
+
const subRequest = getSubRequest(req);
|
|
3152
|
+
const localeItems = await getGlobalItems(subRequest, options.slug.locale, 0);
|
|
3153
|
+
const locales2 = localeItems.filter((x) => x.isActive).map((x) => x.id);
|
|
3154
|
+
const marketItems = await getCollectionItems(req, options.slug.market, 0);
|
|
3155
|
+
const markets = marketItems.filter((x) => x.isActive).map((x) => x.id);
|
|
3156
|
+
const routes = await getRoutes(subRequest);
|
|
3157
|
+
const categories = await getCollectionItems(subRequest, options.slug.category);
|
|
3158
|
+
const richText = req.query?.richText === "true";
|
|
3159
|
+
const context = Object.assign(req.context, { market, locale, markets, locales: locales2, routes, categories, richText });
|
|
3160
|
+
return context;
|
|
3161
|
+
}
|
|
3162
|
+
__name(setMixerContext, "setMixerContext");
|
|
3137
3163
|
|
|
3138
3164
|
// src/core/collections/withStaticCollection.ts
|
|
3139
3165
|
var import_axios = __toESM(require("axios"));
|
|
@@ -3593,16 +3619,6 @@ __name(decorateHrefs_, "decorateHrefs_");
|
|
|
3593
3619
|
|
|
3594
3620
|
// src/core/decorators/menu.ts
|
|
3595
3621
|
var MAX_INT = 1e12;
|
|
3596
|
-
async function getLocales(req) {
|
|
3597
|
-
const locales2 = await getGlobalItems(req, options.slug.locale, 0);
|
|
3598
|
-
return locales2.filter((x) => x.isActive).map((x) => x.id);
|
|
3599
|
-
}
|
|
3600
|
-
__name(getLocales, "getLocales");
|
|
3601
|
-
async function getMarkets(req) {
|
|
3602
|
-
const markets = await getCollectionItems(req, options.slug.market, 0);
|
|
3603
|
-
return markets.filter((x) => x.isActive).map((x) => x.id);
|
|
3604
|
-
}
|
|
3605
|
-
__name(getMarkets, "getMarkets");
|
|
3606
3622
|
function decorateMenuCategory_(item, categories, routes, market, depth = 0) {
|
|
3607
3623
|
const decoratedItem = {
|
|
3608
3624
|
id: item.id,
|
|
@@ -3610,8 +3626,11 @@ function decorateMenuCategory_(item, categories, routes, market, depth = 0) {
|
|
|
3610
3626
|
title: "",
|
|
3611
3627
|
href: "",
|
|
3612
3628
|
category: "",
|
|
3613
|
-
|
|
3614
|
-
|
|
3629
|
+
media: item.media,
|
|
3630
|
+
abstract: item.abstract,
|
|
3631
|
+
customClass: item.customClass,
|
|
3632
|
+
extra: item.extra,
|
|
3633
|
+
items: []
|
|
3615
3634
|
};
|
|
3616
3635
|
const category = typeof item.category === "string" ? categories.find((x) => x.id === item.category) : item.category;
|
|
3617
3636
|
if (category) {
|
|
@@ -3658,8 +3677,11 @@ function decorateMenuGroup_(item, categories, routes, market) {
|
|
|
3658
3677
|
id: item.id,
|
|
3659
3678
|
type: item.type,
|
|
3660
3679
|
title: item.title,
|
|
3661
|
-
|
|
3662
|
-
|
|
3680
|
+
media: item.media,
|
|
3681
|
+
abstract: item.abstract,
|
|
3682
|
+
customClass: item.customClass,
|
|
3683
|
+
extra: item.extra,
|
|
3684
|
+
items: item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market))
|
|
3663
3685
|
};
|
|
3664
3686
|
return decoratedItem;
|
|
3665
3687
|
}
|
|
@@ -3671,8 +3693,11 @@ function decorateMenuLink_(item, categories, routes, market) {
|
|
|
3671
3693
|
title: item.title,
|
|
3672
3694
|
href: item.href,
|
|
3673
3695
|
target: item.target,
|
|
3674
|
-
|
|
3675
|
-
|
|
3696
|
+
media: item.media,
|
|
3697
|
+
abstract: item.abstract,
|
|
3698
|
+
customClass: item.customClass,
|
|
3699
|
+
extra: item.extra,
|
|
3700
|
+
items: item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market))
|
|
3676
3701
|
};
|
|
3677
3702
|
return decoratedItem;
|
|
3678
3703
|
}
|
|
@@ -3686,16 +3711,19 @@ function decorateMenuPage_(item, categories, routes, market) {
|
|
|
3686
3711
|
href = route?.id;
|
|
3687
3712
|
}
|
|
3688
3713
|
const schema = item.schema || item.page.relationTo;
|
|
3714
|
+
const page = item.page.value;
|
|
3689
3715
|
const decoratedItem = {
|
|
3690
3716
|
id: item.id,
|
|
3691
3717
|
type: item.type,
|
|
3692
|
-
title: item.customTitle ||
|
|
3718
|
+
title: item.customTitle || page.title,
|
|
3693
3719
|
href,
|
|
3694
|
-
|
|
3695
|
-
page: item.page.value.id,
|
|
3720
|
+
page: page.id,
|
|
3696
3721
|
schema,
|
|
3697
|
-
|
|
3698
|
-
|
|
3722
|
+
media: item.media || page.media,
|
|
3723
|
+
abstract: item.abstract,
|
|
3724
|
+
customClass: item.customClass,
|
|
3725
|
+
extra: item.extra,
|
|
3726
|
+
items: item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market))
|
|
3699
3727
|
};
|
|
3700
3728
|
return decoratedItem;
|
|
3701
3729
|
}
|
|
@@ -3736,30 +3764,22 @@ function hasMarket(item, market) {
|
|
|
3736
3764
|
return Array.isArray(item.markets) ? item.markets.includes(market) : true;
|
|
3737
3765
|
}
|
|
3738
3766
|
__name(hasMarket, "hasMarket");
|
|
3739
|
-
async function decorateMenu_(
|
|
3767
|
+
async function decorateMenu_(item, context) {
|
|
3740
3768
|
const decoratedItem = {
|
|
3741
3769
|
id: item.id,
|
|
3742
3770
|
items: []
|
|
3743
3771
|
};
|
|
3744
|
-
const
|
|
3745
|
-
if (!
|
|
3772
|
+
const { market, locale, markets, locales: locales2, routes, categories } = context;
|
|
3773
|
+
if (!locales2.includes(locale)) {
|
|
3746
3774
|
return decoratedItem;
|
|
3747
3775
|
}
|
|
3748
|
-
const markets = await getMarkets(req);
|
|
3749
3776
|
if (!markets.includes(market)) {
|
|
3750
3777
|
return decoratedItem;
|
|
3751
3778
|
}
|
|
3752
|
-
const categories = await getCollectionItems(req, options.slug.category);
|
|
3753
|
-
const routes = (await getRoutes(req)).filter((x) => x.market === market && x.locale === locale);
|
|
3754
3779
|
decoratedItem.items = item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market));
|
|
3755
3780
|
return decoratedItem;
|
|
3756
3781
|
}
|
|
3757
3782
|
__name(decorateMenu_, "decorateMenu_");
|
|
3758
|
-
async function decorateMenus_(req, items, market, locale) {
|
|
3759
|
-
const promises = items.map((x) => decorateMenu_(req, x, market, locale));
|
|
3760
|
-
return await Promise.all(promises);
|
|
3761
|
-
}
|
|
3762
|
-
__name(decorateMenus_, "decorateMenus_");
|
|
3763
3783
|
|
|
3764
3784
|
// src/core/decorators/nav.ts
|
|
3765
3785
|
var import_bom_core4 = require("@websolutespa/bom-core");
|
|
@@ -3830,14 +3850,13 @@ var menuIndexGet = /* @__PURE__ */ __name((options2) => ({
|
|
|
3830
3850
|
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
3831
3851
|
return next();
|
|
3832
3852
|
}
|
|
3853
|
+
const context = await setMixerContext(req, market, locale);
|
|
3833
3854
|
try {
|
|
3834
|
-
|
|
3855
|
+
const items = await getCollectionItems(req, options2.slug.menu);
|
|
3835
3856
|
if (pagination === "true") {
|
|
3836
3857
|
const response = await getPagination(items, getNumericParam(page), getNumericParam(limit));
|
|
3837
|
-
response.docs = await decorateMenus_(req, response.docs, market, locale);
|
|
3838
3858
|
res.status(200).send(response);
|
|
3839
3859
|
} else {
|
|
3840
|
-
items = await decorateMenus_(req, items, market, locale);
|
|
3841
3860
|
res.status(200).send(items);
|
|
3842
3861
|
}
|
|
3843
3862
|
} catch (error) {
|
|
@@ -3858,17 +3877,32 @@ var menuDetailGet = /* @__PURE__ */ __name((options2) => ({
|
|
|
3858
3877
|
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
3859
3878
|
return next();
|
|
3860
3879
|
}
|
|
3880
|
+
const context = await setMixerContext(req, market, locale);
|
|
3861
3881
|
try {
|
|
3862
3882
|
const { id } = req.params;
|
|
3863
3883
|
const item = await getCollectionItem(req, options2.slug.menu, id);
|
|
3864
|
-
|
|
3865
|
-
res.status(200).send(decoratedItem);
|
|
3884
|
+
res.status(200).send(item);
|
|
3866
3885
|
} catch (error) {
|
|
3867
3886
|
console.log("menuDetailGet.error", error);
|
|
3868
3887
|
res.status(500).send(error);
|
|
3869
3888
|
}
|
|
3870
3889
|
}
|
|
3871
3890
|
}), "menuDetailGet");
|
|
3891
|
+
var afterMenuReadHook = /* @__PURE__ */ __name((slug) => async ({
|
|
3892
|
+
doc,
|
|
3893
|
+
req,
|
|
3894
|
+
query,
|
|
3895
|
+
findMany,
|
|
3896
|
+
context
|
|
3897
|
+
}) => {
|
|
3898
|
+
const { market, locale, markets, locales: locales2, routes, categories } = context;
|
|
3899
|
+
if (!market || !locale || !markets || !locales2 || !routes || !categories) {
|
|
3900
|
+
return doc;
|
|
3901
|
+
}
|
|
3902
|
+
const withSchema = await decorateSchema_(doc, slug, context);
|
|
3903
|
+
const withMenu2 = await decorateMenu_(withSchema, context);
|
|
3904
|
+
return withMenu2;
|
|
3905
|
+
}, "afterMenuReadHook");
|
|
3872
3906
|
|
|
3873
3907
|
// src/core/collections/withMenu.ts
|
|
3874
3908
|
var withMenu = /* @__PURE__ */ __name((config) => {
|
|
@@ -3899,54 +3933,12 @@ var withMenu = /* @__PURE__ */ __name((config) => {
|
|
|
3899
3933
|
menuIndexGet(options),
|
|
3900
3934
|
menuDetailGet(options)
|
|
3901
3935
|
];
|
|
3936
|
+
withCollectionHook(menuConfig, "afterRead", afterMenuReadHook(config.slug));
|
|
3902
3937
|
translateCollection(menuConfig);
|
|
3903
3938
|
return menuConfig;
|
|
3904
3939
|
}, "withMenu");
|
|
3905
3940
|
|
|
3906
3941
|
// src/core/api/page.service.ts
|
|
3907
|
-
function getSubRequest(req) {
|
|
3908
|
-
const { transactionID, payload, user } = req;
|
|
3909
|
-
const { where, ...rest } = req.query;
|
|
3910
|
-
const subRequest = {
|
|
3911
|
-
user,
|
|
3912
|
-
transactionID,
|
|
3913
|
-
query: {
|
|
3914
|
-
...rest
|
|
3915
|
-
},
|
|
3916
|
-
payload
|
|
3917
|
-
};
|
|
3918
|
-
return subRequest;
|
|
3919
|
-
}
|
|
3920
|
-
__name(getSubRequest, "getSubRequest");
|
|
3921
|
-
async function setMixerContext(req, market, locale) {
|
|
3922
|
-
const subRequest = getSubRequest(req);
|
|
3923
|
-
const routes = await getRoutes(subRequest);
|
|
3924
|
-
const categories = await getCollectionItems(subRequest, options.slug.category);
|
|
3925
|
-
const richText = req.query?.richText === "true";
|
|
3926
|
-
Object.assign(req.context, { market, locale, routes, categories, richText });
|
|
3927
|
-
}
|
|
3928
|
-
__name(setMixerContext, "setMixerContext");
|
|
3929
|
-
var pageDetailGet = /* @__PURE__ */ __name((slug) => ({
|
|
3930
|
-
path: "/:id/",
|
|
3931
|
-
method: "get",
|
|
3932
|
-
handler: async (req, res, next) => {
|
|
3933
|
-
try {
|
|
3934
|
-
const { query } = req;
|
|
3935
|
-
if (!query) {
|
|
3936
|
-
return next();
|
|
3937
|
-
}
|
|
3938
|
-
const { market, locale } = query;
|
|
3939
|
-
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
3940
|
-
return next();
|
|
3941
|
-
}
|
|
3942
|
-
await setMixerContext(req, market, locale);
|
|
3943
|
-
return next();
|
|
3944
|
-
} catch (error) {
|
|
3945
|
-
console.log("pageDetailGet.error", error);
|
|
3946
|
-
res.status(500).send(error);
|
|
3947
|
-
}
|
|
3948
|
-
}
|
|
3949
|
-
}), "pageDetailGet");
|
|
3950
3942
|
var pageIndexGet = /* @__PURE__ */ __name((slug) => ({
|
|
3951
3943
|
path: "/",
|
|
3952
3944
|
method: "get",
|
|
@@ -3960,7 +3952,7 @@ var pageIndexGet = /* @__PURE__ */ __name((slug) => ({
|
|
|
3960
3952
|
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
3961
3953
|
return next();
|
|
3962
3954
|
}
|
|
3963
|
-
await setMixerContext(req, market, locale);
|
|
3955
|
+
const context = await setMixerContext(req, market, locale);
|
|
3964
3956
|
if (limit === "10000") {
|
|
3965
3957
|
return next();
|
|
3966
3958
|
}
|
|
@@ -3976,6 +3968,27 @@ var pageIndexGet = /* @__PURE__ */ __name((slug) => ({
|
|
|
3976
3968
|
}
|
|
3977
3969
|
}
|
|
3978
3970
|
}), "pageIndexGet");
|
|
3971
|
+
var pageDetailGet = /* @__PURE__ */ __name((slug) => ({
|
|
3972
|
+
path: "/:id/",
|
|
3973
|
+
method: "get",
|
|
3974
|
+
handler: async (req, res, next) => {
|
|
3975
|
+
try {
|
|
3976
|
+
const { query } = req;
|
|
3977
|
+
if (!query) {
|
|
3978
|
+
return next();
|
|
3979
|
+
}
|
|
3980
|
+
const { market, locale } = query;
|
|
3981
|
+
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
3982
|
+
return next();
|
|
3983
|
+
}
|
|
3984
|
+
const context = await setMixerContext(req, market, locale);
|
|
3985
|
+
return next();
|
|
3986
|
+
} catch (error) {
|
|
3987
|
+
console.log("pageDetailGet.error", error);
|
|
3988
|
+
res.status(500).send(error);
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
}), "pageDetailGet");
|
|
3979
3992
|
var afterPageReadHook = /* @__PURE__ */ __name((slug) => async ({
|
|
3980
3993
|
doc,
|
|
3981
3994
|
req,
|
|
@@ -4048,7 +4061,7 @@ var richTextAfterReadHook = /* @__PURE__ */ __name((args) => {
|
|
|
4048
4061
|
return richTextSerialize(value);
|
|
4049
4062
|
}
|
|
4050
4063
|
const { market, locale, richText } = req.context;
|
|
4051
|
-
if (!market
|
|
4064
|
+
if (!(typeof market === "string" && typeof locale === "string") || richText === true) {
|
|
4052
4065
|
return value;
|
|
4053
4066
|
}
|
|
4054
4067
|
return richTextSerialize(value);
|
|
@@ -4779,7 +4792,7 @@ async function getRoutes(req) {
|
|
|
4779
4792
|
locales2 = locales2 ? locales2.filter((x) => x.isActive) : [];
|
|
4780
4793
|
if (locales2.length > 0 && markets.length > 0) {
|
|
4781
4794
|
const categories = await getCollectionItems(subRequest, options.slug.category, 1);
|
|
4782
|
-
const store = await
|
|
4795
|
+
const store = await getPages(subRequest);
|
|
4783
4796
|
routes = (0, import_bom_core5.collectRoutes)(store, categories, markets, locales2);
|
|
4784
4797
|
}
|
|
4785
4798
|
CACHE_2.set(key, routes);
|
|
@@ -4800,7 +4813,7 @@ async function getRouteByItemAndLocale(req, item, localeId, slug) {
|
|
|
4800
4813
|
if (!item.isDefault) {
|
|
4801
4814
|
slugs.push({ slug: item.slug });
|
|
4802
4815
|
}
|
|
4803
|
-
await
|
|
4816
|
+
await getEachMarketLocale(req, (market, locale, markets, locales2) => {
|
|
4804
4817
|
if ((!item.markets || item.markets.includes(market.id)) && locale.id === localeId) {
|
|
4805
4818
|
const title = (0, import_bom_core5.localize)(item.title, locale.id);
|
|
4806
4819
|
const id = (0, import_bom_core5.getRouteHref)(slugs, market, locale, markets, locales2);
|
|
@@ -4828,7 +4841,7 @@ async function getRouteByCategoryAndLocale(req, item, localeId, slug) {
|
|
|
4828
4841
|
const routes = [];
|
|
4829
4842
|
const categories = await getCollectionItems(req, options.slug.category, 1);
|
|
4830
4843
|
const segments = (0, import_bom_core5.getCategorySegmentsByCategory)(item, categories);
|
|
4831
|
-
await
|
|
4844
|
+
await getEachMarketLocale(req, (market, locale, markets, locales2) => {
|
|
4832
4845
|
if (locale.id === localeId) {
|
|
4833
4846
|
const title = (0, import_bom_core5.localize)(item.title, locale.id);
|
|
4834
4847
|
const id = (0, import_bom_core5.getRouteHref)(segments, market, locale, markets, locales2);
|
|
@@ -4958,15 +4971,15 @@ async function routePostHandler(request, response, next) {
|
|
|
4958
4971
|
}
|
|
4959
4972
|
}
|
|
4960
4973
|
__name(routePostHandler, "routePostHandler");
|
|
4961
|
-
async function
|
|
4974
|
+
async function getEachMarketLocale(req, callback) {
|
|
4962
4975
|
let markets = await getCollectionItems(req, options.slug.market, 0);
|
|
4963
4976
|
markets = markets ? markets.filter((x) => x.isActive) : [];
|
|
4964
4977
|
let locales2 = await getGlobalItems(req, options.slug.locale, 0);
|
|
4965
4978
|
locales2 = locales2 ? locales2.filter((x) => x.isActive) : [];
|
|
4966
4979
|
return (0, import_bom_core5.eachMarketLocale)(markets, locales2, callback);
|
|
4967
4980
|
}
|
|
4968
|
-
__name(
|
|
4969
|
-
async function
|
|
4981
|
+
__name(getEachMarketLocale, "getEachMarketLocale");
|
|
4982
|
+
async function getPages(req) {
|
|
4970
4983
|
const store = {};
|
|
4971
4984
|
const keys = options.pages;
|
|
4972
4985
|
for (const key of keys) {
|
|
@@ -4975,7 +4988,7 @@ async function fetchPages(req) {
|
|
|
4975
4988
|
}
|
|
4976
4989
|
return store;
|
|
4977
4990
|
}
|
|
4978
|
-
__name(
|
|
4991
|
+
__name(getPages, "getPages");
|
|
4979
4992
|
|
|
4980
4993
|
// src/core/api/redirect.service.ts
|
|
4981
4994
|
async function collectPageRedirects(req, previousItem, newItem) {
|
|
@@ -6873,6 +6886,7 @@ var src_default = bowl;
|
|
|
6873
6886
|
UserRolesDefaults,
|
|
6874
6887
|
afterCategoryChangeHook,
|
|
6875
6888
|
afterCategoryDeleteHook,
|
|
6889
|
+
afterMenuReadHook,
|
|
6876
6890
|
afterPageChangeHook,
|
|
6877
6891
|
afterPageDeleteHook,
|
|
6878
6892
|
afterPageReadHook,
|
|
@@ -6896,7 +6910,6 @@ var src_default = bowl;
|
|
|
6896
6910
|
decorateMenuPage_,
|
|
6897
6911
|
decorateMenuRoute_,
|
|
6898
6912
|
decorateMenu_,
|
|
6899
|
-
decorateMenus_,
|
|
6900
6913
|
decorateNav_,
|
|
6901
6914
|
decorateNavs_,
|
|
6902
6915
|
decorateSchema_,
|
|
@@ -6912,22 +6925,20 @@ var src_default = bowl;
|
|
|
6912
6925
|
encryptData,
|
|
6913
6926
|
fetchCollection,
|
|
6914
6927
|
fetchCollectionItems,
|
|
6915
|
-
fetchEachMarketLocale,
|
|
6916
6928
|
fetchEndpoint,
|
|
6917
6929
|
fetchGlobal,
|
|
6918
6930
|
fetchGlobalItems,
|
|
6919
|
-
fetchPages,
|
|
6920
6931
|
formatSlug,
|
|
6921
6932
|
getApiUrl,
|
|
6922
6933
|
getCollectionItem,
|
|
6923
6934
|
getCollectionItems,
|
|
6935
|
+
getEachMarketLocale,
|
|
6924
6936
|
getGlobalItems,
|
|
6925
6937
|
getLivePreviewURL,
|
|
6926
6938
|
getLocale,
|
|
6927
|
-
getLocales,
|
|
6928
|
-
getMarkets,
|
|
6929
6939
|
getNumericParam,
|
|
6930
6940
|
getObjectParam,
|
|
6941
|
+
getPages,
|
|
6931
6942
|
getPagination,
|
|
6932
6943
|
getPreviewURL,
|
|
6933
6944
|
getPublicURL,
|
|
@@ -6939,6 +6950,7 @@ var src_default = bowl;
|
|
|
6939
6950
|
getStaticLoader,
|
|
6940
6951
|
getStore,
|
|
6941
6952
|
getStringParam,
|
|
6953
|
+
getSubRequest,
|
|
6942
6954
|
getTranslation,
|
|
6943
6955
|
getTranslations,
|
|
6944
6956
|
getTreeItemClassName,
|
|
@@ -6974,6 +6986,7 @@ var src_default = bowl;
|
|
|
6974
6986
|
routeGet,
|
|
6975
6987
|
routePost,
|
|
6976
6988
|
routePostHandler,
|
|
6989
|
+
setMixerContext,
|
|
6977
6990
|
slugToLabel,
|
|
6978
6991
|
slugToLabels,
|
|
6979
6992
|
sortByGroup,
|