@websolutespa/payload-plugin-bowl 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.d.ts +89 -81
- package/dist/index.js +238 -195
- package/package.json +7 -5
- package/scss/styles.scss +21 -1
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, 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,
|
|
6
|
+
import { IEntity, ILocale, ICategorized, IRoute, ICategory, IMarket, IMemoryStore, ILocalizable, IEquatable, IMedia, IPageRelation, ISchema, 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';
|
|
@@ -110,6 +110,73 @@ declare const collectionImportPost: ((slug: string) => Endpoint);
|
|
|
110
110
|
declare function getLocale(req: PayloadRequest<any>): Promise<ILocale[]>;
|
|
111
111
|
declare const localeGet: Endpoint;
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Rest api menu get handler.
|
|
115
|
+
*/
|
|
116
|
+
declare const menuIndexGet: ((options: BowlOptions) => Endpoint);
|
|
117
|
+
/**
|
|
118
|
+
* Rest api menu detail get handler.
|
|
119
|
+
*/
|
|
120
|
+
declare const menuDetailGet: ((options: BowlOptions) => Endpoint);
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Rest api page collection detail get handler.
|
|
124
|
+
*/
|
|
125
|
+
declare const pageDetailGet: ((slug: string) => Endpoint);
|
|
126
|
+
/**
|
|
127
|
+
* Rest api page collection get handler.
|
|
128
|
+
*/
|
|
129
|
+
declare const pageIndexGet: ((slug: string) => Endpoint);
|
|
130
|
+
/**
|
|
131
|
+
* Decorate record for Mixer when queried by market and locale.
|
|
132
|
+
*/
|
|
133
|
+
declare const afterPageReadHook: (slug: string) => CollectionConfig['hooks']['afterRead'][number];
|
|
134
|
+
/**
|
|
135
|
+
* Create a record of the pages collection related to the created document.
|
|
136
|
+
*/
|
|
137
|
+
declare const afterPageChangeHook: CollectionAfterChangeHook<ICategorized>;
|
|
138
|
+
/**
|
|
139
|
+
* Delete records of the pages collection related to the deleted document.
|
|
140
|
+
*/
|
|
141
|
+
declare const afterPageDeleteHook: CollectionAfterDeleteHook;
|
|
142
|
+
|
|
143
|
+
type IPagination = {
|
|
144
|
+
hasNextPage: boolean;
|
|
145
|
+
hasPrevPage: boolean;
|
|
146
|
+
limit: number;
|
|
147
|
+
nextPage: number | null;
|
|
148
|
+
page: number;
|
|
149
|
+
pagingCounter: number;
|
|
150
|
+
prevPage: number | null;
|
|
151
|
+
totalDocs: number;
|
|
152
|
+
totalPages: number;
|
|
153
|
+
};
|
|
154
|
+
declare function getPagination<T = IEntity>(items: T[], page?: number, limit?: number): Promise<PaginatedDocs<T>>;
|
|
155
|
+
|
|
156
|
+
declare function getRoutes(req: PayloadRequest): Promise<IRoute[]>;
|
|
157
|
+
declare function getRoute(req: PayloadRequest<any>, id: string): Promise<IRoute | null>;
|
|
158
|
+
declare function getRouteByItemAndLocale(req: PayloadRequest<any>, item: ICategorized, localeId: string, slug: string): Promise<IRoute[]>;
|
|
159
|
+
declare function getRouteByCategoryAndLocale(req: PayloadRequest<any>, item: ICategory, localeId: string, slug: string): Promise<IRoute[]>;
|
|
160
|
+
declare const routeGet: Endpoint;
|
|
161
|
+
declare const routePost: Endpoint;
|
|
162
|
+
declare function routePostHandler(request: any, response: any, next: any): Promise<any>;
|
|
163
|
+
declare function fetchEachMarketLocale(req: PayloadRequest<any>, callback: (market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]) => void): Promise<void>;
|
|
164
|
+
declare function fetchPages(req: PayloadRequest<any>): Promise<IMemoryStore<ICategorized>>;
|
|
165
|
+
|
|
166
|
+
declare function getStore(req: PayloadRequest): Promise<IMemoryStore>;
|
|
167
|
+
declare function getApiUrl(req: PayloadRequest): string;
|
|
168
|
+
declare function getSearchUrl(req: PayloadRequest, overrideQuery?: {}): string;
|
|
169
|
+
declare function fetchEndpoint<T>(req: PayloadRequest, endpoint: string, query?: {}): Promise<T>;
|
|
170
|
+
declare function fetchCollection<T = any>(req: PayloadRequest, slug: string, query?: {}): Promise<{
|
|
171
|
+
docs: T[];
|
|
172
|
+
}>;
|
|
173
|
+
declare function fetchGlobal<T = any>(req: PayloadRequest, slug: string, query?: {}): Promise<{
|
|
174
|
+
items: T[];
|
|
175
|
+
}>;
|
|
176
|
+
declare function fetchCollectionItems<T = any>(req: PayloadRequest<T>, slug: string, query?: {}): Promise<T[]>;
|
|
177
|
+
declare function fetchGlobalItems<T = any>(req: PayloadRequest, slug: string, query?: {}): Promise<T[]>;
|
|
178
|
+
declare const storeGet: Endpoint;
|
|
179
|
+
|
|
113
180
|
type IPage = {
|
|
114
181
|
id: string;
|
|
115
182
|
content: {
|
|
@@ -190,85 +257,6 @@ type MixerContext = {
|
|
|
190
257
|
richText?: boolean;
|
|
191
258
|
};
|
|
192
259
|
|
|
193
|
-
declare const MAX_INT = 1000000000000;
|
|
194
|
-
/**
|
|
195
|
-
* Rest api menu get handler.
|
|
196
|
-
*/
|
|
197
|
-
declare const menuIndexGet: ((options: BowlOptions) => Endpoint);
|
|
198
|
-
/**
|
|
199
|
-
* Rest api menu detail get handler.
|
|
200
|
-
*/
|
|
201
|
-
declare const menuDetailGet: ((options: BowlOptions) => Endpoint);
|
|
202
|
-
declare function getLocales(req: PayloadRequest<any>): Promise<string[]>;
|
|
203
|
-
declare function getMarkets(req: PayloadRequest<any>): Promise<string[]>;
|
|
204
|
-
declare function decorateMenus(req: PayloadRequest<any>, items: IUndecoratedMenu[], market: string, locale: string): Promise<IMenu[]>;
|
|
205
|
-
declare function decorateMenu(req: PayloadRequest<any>, item: IUndecoratedMenu, market: string, locale: string): Promise<IMenu>;
|
|
206
|
-
declare function decorateMenuCategory(item: IUndecoratedMenuCategory, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuItem;
|
|
207
|
-
declare function decorateMenuGroup(item: IUndecoratedMenuGroup, categories: ICategory[], routes: IRoute[], market: string): IMenuItem;
|
|
208
|
-
declare function decorateMenuLink(item: IUndecoratedMenuLink, categories: ICategory[], routes: IRoute[], market: string): IMenuItem;
|
|
209
|
-
declare function decorateMenuPage(item: IUndecoratedMenuPage, categories: ICategory[], routes: IRoute[], market: string): IMenuItem;
|
|
210
|
-
declare function decorateMenuRoute(item: IRoute): IMenuItem;
|
|
211
|
-
declare function decorateMenuItem(item: IUndecoratedMenuItem, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuItem;
|
|
212
|
-
declare function hasMarket(item: IUndecoratedMenuItem, market: string): boolean;
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Rest api page collection detail get handler.
|
|
216
|
-
*/
|
|
217
|
-
declare const pageDetailGet: ((slug: string) => Endpoint);
|
|
218
|
-
/**
|
|
219
|
-
* Rest api page collection get handler.
|
|
220
|
-
*/
|
|
221
|
-
declare const pageIndexGet: ((slug: string) => Endpoint);
|
|
222
|
-
/**
|
|
223
|
-
* Decorate record for Mixer when queried by market and locale.
|
|
224
|
-
*/
|
|
225
|
-
declare const afterPageReadHook: (slug: string) => CollectionConfig['hooks']['afterRead'][number];
|
|
226
|
-
/**
|
|
227
|
-
* Create a record of the pages collection related to the created document.
|
|
228
|
-
*/
|
|
229
|
-
declare const afterPageChangeHook: CollectionAfterChangeHook<ICategorized>;
|
|
230
|
-
/**
|
|
231
|
-
* Delete records of the pages collection related to the deleted document.
|
|
232
|
-
*/
|
|
233
|
-
declare const afterPageDeleteHook: CollectionAfterDeleteHook;
|
|
234
|
-
|
|
235
|
-
type IPagination = {
|
|
236
|
-
hasNextPage: boolean;
|
|
237
|
-
hasPrevPage: boolean;
|
|
238
|
-
limit: number;
|
|
239
|
-
nextPage: number | null;
|
|
240
|
-
page: number;
|
|
241
|
-
pagingCounter: number;
|
|
242
|
-
prevPage: number | null;
|
|
243
|
-
totalDocs: number;
|
|
244
|
-
totalPages: number;
|
|
245
|
-
};
|
|
246
|
-
declare function getPagination<T = IEntity>(items: T[], page?: number, limit?: number): Promise<PaginatedDocs<T>>;
|
|
247
|
-
|
|
248
|
-
declare function getRoutes(req: PayloadRequest): Promise<IRoute[]>;
|
|
249
|
-
declare function getRoute(req: PayloadRequest<any>, id: string): Promise<IRoute | null>;
|
|
250
|
-
declare function getRouteByItemAndLocale(req: PayloadRequest<any>, item: ICategorized, localeId: string, slug: string): Promise<IRoute[]>;
|
|
251
|
-
declare function getRouteByCategoryAndLocale(req: PayloadRequest<any>, item: ICategory, localeId: string, slug: string): Promise<IRoute[]>;
|
|
252
|
-
declare const routeGet: Endpoint;
|
|
253
|
-
declare const routePost: Endpoint;
|
|
254
|
-
declare function routePostHandler(request: any, response: any, next: any): Promise<any>;
|
|
255
|
-
declare function fetchEachMarketLocale(req: PayloadRequest<any>, callback: (market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]) => void): Promise<void>;
|
|
256
|
-
declare function fetchPages(req: PayloadRequest<any>): Promise<IMemoryStore<ICategorized>>;
|
|
257
|
-
|
|
258
|
-
declare function getStore(req: PayloadRequest): Promise<IMemoryStore>;
|
|
259
|
-
declare function getApiUrl(req: PayloadRequest): string;
|
|
260
|
-
declare function getSearchUrl(req: PayloadRequest, overrideQuery?: {}): string;
|
|
261
|
-
declare function fetchEndpoint<T>(req: PayloadRequest, endpoint: string, query?: {}): Promise<T>;
|
|
262
|
-
declare function fetchCollection<T = any>(req: PayloadRequest, slug: string, query?: {}): Promise<{
|
|
263
|
-
docs: T[];
|
|
264
|
-
}>;
|
|
265
|
-
declare function fetchGlobal<T = any>(req: PayloadRequest, slug: string, query?: {}): Promise<{
|
|
266
|
-
items: T[];
|
|
267
|
-
}>;
|
|
268
|
-
declare function fetchCollectionItems<T = any>(req: PayloadRequest<T>, slug: string, query?: {}): Promise<T[]>;
|
|
269
|
-
declare function fetchGlobalItems<T = any>(req: PayloadRequest, slug: string, query?: {}): Promise<T[]>;
|
|
270
|
-
declare const storeGet: Endpoint;
|
|
271
|
-
|
|
272
260
|
declare function getObjectParam(value: unknown): {} | undefined;
|
|
273
261
|
declare function getNumericParam(value: unknown): number | undefined;
|
|
274
262
|
declare function getStringParam(value: unknown): string | undefined;
|
|
@@ -395,6 +383,13 @@ declare const StaticCollectionDefault: Partial<CollectionConfig>;
|
|
|
395
383
|
*/
|
|
396
384
|
declare const withStaticCollection: ({ src, map, duration, ...config }: WithStaticProps) => CollectionConfig;
|
|
397
385
|
|
|
386
|
+
declare function decorateCategory_<T extends ICategorized = ICategorized>(item: T, slug: string, context: MixerContext): Promise<T | T & {
|
|
387
|
+
category: ICategory;
|
|
388
|
+
}>;
|
|
389
|
+
declare function decorateCategories_<T extends ICategorized = ICategorized>(items: T[], slug: string, context: MixerContext): Promise<(T | T & {
|
|
390
|
+
category: ICategory;
|
|
391
|
+
})[]>;
|
|
392
|
+
|
|
398
393
|
declare function decorateHref_<T extends ISchema = ISchema>(item: T, slug: string, context: MixerContext): Promise<T & {
|
|
399
394
|
href: string | null;
|
|
400
395
|
}>;
|
|
@@ -402,6 +397,19 @@ declare function decorateHrefs_<T extends ISchema = ISchema>(items: T[], slug: s
|
|
|
402
397
|
href: string | null;
|
|
403
398
|
})[]>;
|
|
404
399
|
|
|
400
|
+
declare const MAX_INT = 1000000000000;
|
|
401
|
+
declare function getLocales(req: PayloadRequest<any>): Promise<string[]>;
|
|
402
|
+
declare function getMarkets(req: PayloadRequest<any>): Promise<string[]>;
|
|
403
|
+
declare function decorateMenuCategory_(item: IUndecoratedMenuCategory, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuItem;
|
|
404
|
+
declare function decorateMenuGroup_(item: IUndecoratedMenuGroup, categories: ICategory[], routes: IRoute[], market: string): IMenuItem;
|
|
405
|
+
declare function decorateMenuLink_(item: IUndecoratedMenuLink, categories: ICategory[], routes: IRoute[], market: string): IMenuItem;
|
|
406
|
+
declare function decorateMenuPage_(item: IUndecoratedMenuPage, categories: ICategory[], routes: IRoute[], market: string): IMenuItem;
|
|
407
|
+
declare function decorateMenuRoute_(item: IRoute): IMenuItem;
|
|
408
|
+
declare function decorateMenuItem_(item: IUndecoratedMenuItem, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuItem;
|
|
409
|
+
declare function hasMarket(item: IUndecoratedMenuItem, market: string): boolean;
|
|
410
|
+
declare function decorateMenu_(req: PayloadRequest<any>, item: IUndecoratedMenu, market: string, locale: string): Promise<IMenu>;
|
|
411
|
+
declare function decorateMenus_(req: PayloadRequest<any>, items: IUndecoratedMenu[], market: string, locale: string): Promise<IMenu[]>;
|
|
412
|
+
|
|
405
413
|
declare function decorateNav_<T extends ISchema = ISchema>(item: T, slug: string, context: MixerContext): Promise<T>;
|
|
406
414
|
declare function decorateNavs_<T extends ISchema = ISchema>(items: T[], slug: string, context: MixerContext): Promise<T[]>;
|
|
407
415
|
declare function isUndecoratedMenuItem(item: unknown): item is IUndecoratedMenuItem;
|
|
@@ -1089,4 +1097,4 @@ declare const Logo: React__default.FC;
|
|
|
1089
1097
|
|
|
1090
1098
|
declare function webpack(sourceConfig: BowlConfig): (config: any) => any;
|
|
1091
1099
|
|
|
1092
|
-
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, decorateHref_, decorateHrefs_,
|
|
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_, decorateMenus_, decorateNav_, decorateNavs_, decorateSchema_, decorateSchemas_, deepMerge, bowl as default, defaultGroup, defaultLocale, defaultLocales, defaultMarket, defaultSlug, eachDataField, eachField, encryptData, fetchCollection, fetchCollectionItems, fetchEachMarketLocale, fetchEndpoint, fetchGlobal, fetchGlobalItems, fetchPages, formatSlug, getApiUrl, getCollectionItem, getCollectionItems, getGlobalItems, getLivePreviewURL, getLocale, getLocales, getMarkets, getNumericParam, getObjectParam, getPagination, getPreviewURL, getPublicURL, getRoute, getRouteByCategoryAndLocale, getRouteByItemAndLocale, getRoutes, getSearchUrl, getStaticLoader, getStore, getStringParam, 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, 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
|
@@ -253,16 +253,18 @@ __export(src_exports, {
|
|
|
253
253
|
collectionIndexGet: () => collectionIndexGet,
|
|
254
254
|
collectionUpdatePatch: () => collectionUpdatePatch,
|
|
255
255
|
debugField: () => debugField,
|
|
256
|
+
decorateCategories_: () => decorateCategories_,
|
|
257
|
+
decorateCategory_: () => decorateCategory_,
|
|
256
258
|
decorateHref_: () => decorateHref_,
|
|
257
259
|
decorateHrefs_: () => decorateHrefs_,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
260
|
+
decorateMenuCategory_: () => decorateMenuCategory_,
|
|
261
|
+
decorateMenuGroup_: () => decorateMenuGroup_,
|
|
262
|
+
decorateMenuItem_: () => decorateMenuItem_,
|
|
263
|
+
decorateMenuLink_: () => decorateMenuLink_,
|
|
264
|
+
decorateMenuPage_: () => decorateMenuPage_,
|
|
265
|
+
decorateMenuRoute_: () => decorateMenuRoute_,
|
|
266
|
+
decorateMenu_: () => decorateMenu_,
|
|
267
|
+
decorateMenus_: () => decorateMenus_,
|
|
266
268
|
decorateNav_: () => decorateNav_,
|
|
267
269
|
decorateNavs_: () => decorateNavs_,
|
|
268
270
|
decorateSchema_: () => decorateSchema_,
|
|
@@ -2831,10 +2833,10 @@ function keyWithRequest(key, req) {
|
|
|
2831
2833
|
__name(keyWithRequest, "keyWithRequest");
|
|
2832
2834
|
|
|
2833
2835
|
// src/core/api/redirect.service.ts
|
|
2834
|
-
var
|
|
2836
|
+
var import_bom_core6 = require("@websolutespa/bom-core");
|
|
2835
2837
|
|
|
2836
2838
|
// src/core/api/route.service.ts
|
|
2837
|
-
var
|
|
2839
|
+
var import_bom_core5 = require("@websolutespa/bom-core");
|
|
2838
2840
|
|
|
2839
2841
|
// src/core/encryption/encryption.ts
|
|
2840
2842
|
var import_crypto = __toESM(require("crypto"));
|
|
@@ -3527,59 +3529,70 @@ var withGlobal = /* @__PURE__ */ __name((config) => {
|
|
|
3527
3529
|
return globalConfig;
|
|
3528
3530
|
}, "withGlobal");
|
|
3529
3531
|
|
|
3530
|
-
// src/core/
|
|
3531
|
-
var
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
const
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
try {
|
|
3545
|
-
let items = await getCollectionItems(req, options2.slug.menu);
|
|
3546
|
-
if (pagination !== "false") {
|
|
3547
|
-
const response = await getPagination(items, getNumericParam(page), getNumericParam(limit));
|
|
3548
|
-
response.docs = await decorateMenus(req, response.docs, market, locale);
|
|
3549
|
-
res.status(200).send(response);
|
|
3550
|
-
} else {
|
|
3551
|
-
items = await decorateMenus(req, items, market, locale);
|
|
3552
|
-
res.status(200).send(items);
|
|
3553
|
-
}
|
|
3554
|
-
} catch (error) {
|
|
3555
|
-
console.log("menuIndexGet.error", error);
|
|
3556
|
-
res.status(500).send(error);
|
|
3557
|
-
}
|
|
3532
|
+
// src/core/decorators/category.ts
|
|
3533
|
+
var import_bom_core3 = require("@websolutespa/bom-core");
|
|
3534
|
+
async function decorateCategory_(item, slug, context) {
|
|
3535
|
+
const category = item.category;
|
|
3536
|
+
if ((0, import_bom_core3.isObject)(category) && !category.href) {
|
|
3537
|
+
const { market, locale, routes } = context;
|
|
3538
|
+
const route = routes.find(
|
|
3539
|
+
(x) => x.isDefault && x.category === category.id && x.market === market && x.locale === locale
|
|
3540
|
+
);
|
|
3541
|
+
const href = route ? route.id : null;
|
|
3542
|
+
category.href = href;
|
|
3543
|
+
return { ...item, category };
|
|
3544
|
+
} else {
|
|
3545
|
+
return item;
|
|
3558
3546
|
}
|
|
3559
|
-
}
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
res.status(200).send(decoratedItem);
|
|
3577
|
-
} catch (error) {
|
|
3578
|
-
console.log("menuDetailGet.error", error);
|
|
3579
|
-
res.status(500).send(error);
|
|
3547
|
+
}
|
|
3548
|
+
__name(decorateCategory_, "decorateCategory_");
|
|
3549
|
+
async function decorateCategories_(items, slug, context) {
|
|
3550
|
+
const { market, locale } = context;
|
|
3551
|
+
const routes = context.routes.filter(
|
|
3552
|
+
(x) => x.market === market && x.locale === locale
|
|
3553
|
+
);
|
|
3554
|
+
return items.map((item) => {
|
|
3555
|
+
const category = item.category;
|
|
3556
|
+
if ((0, import_bom_core3.isObject)(category) && !category.href) {
|
|
3557
|
+
const route = routes.find(
|
|
3558
|
+
(x) => x.isDefault && x.category === category.id
|
|
3559
|
+
);
|
|
3560
|
+
const href = route ? route.id : null;
|
|
3561
|
+
return { ...item, href };
|
|
3562
|
+
} else {
|
|
3563
|
+
return item;
|
|
3580
3564
|
}
|
|
3581
|
-
}
|
|
3582
|
-
}
|
|
3565
|
+
});
|
|
3566
|
+
}
|
|
3567
|
+
__name(decorateCategories_, "decorateCategories_");
|
|
3568
|
+
|
|
3569
|
+
// src/core/decorators/href.ts
|
|
3570
|
+
async function decorateHref_(item, slug, context) {
|
|
3571
|
+
const { market, locale, routes } = context;
|
|
3572
|
+
const route = routes.find(
|
|
3573
|
+
(x) => x.schema === slug && x.page === item.id && x.market === market && x.locale === locale
|
|
3574
|
+
);
|
|
3575
|
+
const href = route ? route.id : null;
|
|
3576
|
+
return { ...item, href };
|
|
3577
|
+
}
|
|
3578
|
+
__name(decorateHref_, "decorateHref_");
|
|
3579
|
+
async function decorateHrefs_(items, slug, context) {
|
|
3580
|
+
const { market, locale } = context;
|
|
3581
|
+
const routes = context.routes.filter(
|
|
3582
|
+
(x) => x.schema === slug && x.market === market && x.locale === locale
|
|
3583
|
+
);
|
|
3584
|
+
return items.map((item) => {
|
|
3585
|
+
const route = routes.find(
|
|
3586
|
+
(x) => x.page === item.id
|
|
3587
|
+
);
|
|
3588
|
+
const href = route ? route.id : null;
|
|
3589
|
+
return { ...item, href };
|
|
3590
|
+
});
|
|
3591
|
+
}
|
|
3592
|
+
__name(decorateHrefs_, "decorateHrefs_");
|
|
3593
|
+
|
|
3594
|
+
// src/core/decorators/menu.ts
|
|
3595
|
+
var MAX_INT = 1e12;
|
|
3583
3596
|
async function getLocales(req) {
|
|
3584
3597
|
const locales2 = await getGlobalItems(req, options.slug.locale, 0);
|
|
3585
3598
|
return locales2.filter((x) => x.isActive).map((x) => x.id);
|
|
@@ -3590,31 +3603,7 @@ async function getMarkets(req) {
|
|
|
3590
3603
|
return markets.filter((x) => x.isActive).map((x) => x.id);
|
|
3591
3604
|
}
|
|
3592
3605
|
__name(getMarkets, "getMarkets");
|
|
3593
|
-
|
|
3594
|
-
const promises = items.map((x) => decorateMenu(req, x, market, locale));
|
|
3595
|
-
return await Promise.all(promises);
|
|
3596
|
-
}
|
|
3597
|
-
__name(decorateMenus, "decorateMenus");
|
|
3598
|
-
async function decorateMenu(req, item, market, locale) {
|
|
3599
|
-
const decoratedItem = {
|
|
3600
|
-
id: item.id,
|
|
3601
|
-
items: []
|
|
3602
|
-
};
|
|
3603
|
-
const languages = await getLocales(req);
|
|
3604
|
-
if (!languages.includes(locale)) {
|
|
3605
|
-
return decoratedItem;
|
|
3606
|
-
}
|
|
3607
|
-
const markets = await getMarkets(req);
|
|
3608
|
-
if (!markets.includes(market)) {
|
|
3609
|
-
return decoratedItem;
|
|
3610
|
-
}
|
|
3611
|
-
const categories = await getCollectionItems(req, options.slug.category);
|
|
3612
|
-
const routes = (await getRoutes(req)).filter((x) => x.market === market && x.locale === locale);
|
|
3613
|
-
decoratedItem.items = item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem(x, categories, routes, market));
|
|
3614
|
-
return decoratedItem;
|
|
3615
|
-
}
|
|
3616
|
-
__name(decorateMenu, "decorateMenu");
|
|
3617
|
-
function decorateMenuCategory(item, categories, routes, market, depth = 0) {
|
|
3606
|
+
function decorateMenuCategory_(item, categories, routes, market, depth = 0) {
|
|
3618
3607
|
const decoratedItem = {
|
|
3619
3608
|
id: item.id,
|
|
3620
3609
|
type: item.type,
|
|
@@ -3646,7 +3635,7 @@ function decorateMenuCategory(item, categories, routes, market, depth = 0) {
|
|
|
3646
3635
|
childCategories.sort((a, b) => {
|
|
3647
3636
|
return (a.order || MAX_INT) - (b.order || MAX_INT);
|
|
3648
3637
|
});
|
|
3649
|
-
decoratedItem.items = childCategories.map((c) =>
|
|
3638
|
+
decoratedItem.items = childCategories.map((c) => decorateMenuCategory_({
|
|
3650
3639
|
id: c.id,
|
|
3651
3640
|
type: "category",
|
|
3652
3641
|
category: c,
|
|
@@ -3658,37 +3647,37 @@ function decorateMenuCategory(item, categories, routes, market, depth = 0) {
|
|
|
3658
3647
|
childRoutes.sort((a, b) => {
|
|
3659
3648
|
return (a.order || MAX_INT) - (b.order || MAX_INT);
|
|
3660
3649
|
});
|
|
3661
|
-
decoratedItem.items = childRoutes.map((x) =>
|
|
3650
|
+
decoratedItem.items = childRoutes.map((x) => decorateMenuRoute_(x));
|
|
3662
3651
|
}
|
|
3663
3652
|
}
|
|
3664
3653
|
return decoratedItem;
|
|
3665
3654
|
}
|
|
3666
|
-
__name(
|
|
3667
|
-
function
|
|
3655
|
+
__name(decorateMenuCategory_, "decorateMenuCategory_");
|
|
3656
|
+
function decorateMenuGroup_(item, categories, routes, market) {
|
|
3668
3657
|
const decoratedItem = {
|
|
3669
3658
|
id: item.id,
|
|
3670
3659
|
type: item.type,
|
|
3671
3660
|
title: item.title,
|
|
3672
|
-
items: item.items.filter((x) => hasMarket(x, market)).map((x) =>
|
|
3661
|
+
items: item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market)),
|
|
3673
3662
|
extra: item.extra
|
|
3674
3663
|
};
|
|
3675
3664
|
return decoratedItem;
|
|
3676
3665
|
}
|
|
3677
|
-
__name(
|
|
3678
|
-
function
|
|
3666
|
+
__name(decorateMenuGroup_, "decorateMenuGroup_");
|
|
3667
|
+
function decorateMenuLink_(item, categories, routes, market) {
|
|
3679
3668
|
const decoratedItem = {
|
|
3680
3669
|
id: item.id,
|
|
3681
3670
|
type: item.type,
|
|
3682
3671
|
title: item.title,
|
|
3683
3672
|
href: item.href,
|
|
3684
3673
|
target: item.target,
|
|
3685
|
-
items: item.items.filter((x) => hasMarket(x, market)).map((x) =>
|
|
3674
|
+
items: item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market)),
|
|
3686
3675
|
extra: item.extra
|
|
3687
3676
|
};
|
|
3688
3677
|
return decoratedItem;
|
|
3689
3678
|
}
|
|
3690
|
-
__name(
|
|
3691
|
-
function
|
|
3679
|
+
__name(decorateMenuLink_, "decorateMenuLink_");
|
|
3680
|
+
function decorateMenuPage_(item, categories, routes, market) {
|
|
3692
3681
|
let href = item.href;
|
|
3693
3682
|
if (!href) {
|
|
3694
3683
|
const route = routes.find(
|
|
@@ -3705,13 +3694,13 @@ function decorateMenuPage(item, categories, routes, market) {
|
|
|
3705
3694
|
media: item.page.value.media,
|
|
3706
3695
|
page: item.page.value.id,
|
|
3707
3696
|
schema,
|
|
3708
|
-
items: item.items.filter((x) => hasMarket(x, market)).map((x) =>
|
|
3697
|
+
items: item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market)),
|
|
3709
3698
|
extra: item.extra
|
|
3710
3699
|
};
|
|
3711
3700
|
return decoratedItem;
|
|
3712
3701
|
}
|
|
3713
|
-
__name(
|
|
3714
|
-
function
|
|
3702
|
+
__name(decorateMenuPage_, "decorateMenuPage_");
|
|
3703
|
+
function decorateMenuRoute_(item) {
|
|
3715
3704
|
const decoratedItem = {
|
|
3716
3705
|
id: item.page,
|
|
3717
3706
|
type: "route",
|
|
@@ -3723,17 +3712,17 @@ function decorateMenuRoute(item) {
|
|
|
3723
3712
|
};
|
|
3724
3713
|
return decoratedItem;
|
|
3725
3714
|
}
|
|
3726
|
-
__name(
|
|
3727
|
-
function
|
|
3715
|
+
__name(decorateMenuRoute_, "decorateMenuRoute_");
|
|
3716
|
+
function decorateMenuItem_(item, categories, routes, market, depth = 0) {
|
|
3728
3717
|
switch (item.type) {
|
|
3729
3718
|
case "category":
|
|
3730
|
-
return
|
|
3719
|
+
return decorateMenuCategory_(item, categories, routes, market, depth);
|
|
3731
3720
|
case "group":
|
|
3732
|
-
return
|
|
3721
|
+
return decorateMenuGroup_(item, categories, routes, market);
|
|
3733
3722
|
case "link":
|
|
3734
|
-
return
|
|
3723
|
+
return decorateMenuLink_(item, categories, routes, market);
|
|
3735
3724
|
case "page":
|
|
3736
|
-
return
|
|
3725
|
+
return decorateMenuPage_(item, categories, routes, market);
|
|
3737
3726
|
default:
|
|
3738
3727
|
const { blockType, ...rest } = item;
|
|
3739
3728
|
return {
|
|
@@ -3742,72 +3731,38 @@ function decorateMenuItem(item, categories, routes, market, depth = 0) {
|
|
|
3742
3731
|
};
|
|
3743
3732
|
}
|
|
3744
3733
|
}
|
|
3745
|
-
__name(
|
|
3734
|
+
__name(decorateMenuItem_, "decorateMenuItem_");
|
|
3746
3735
|
function hasMarket(item, market) {
|
|
3747
3736
|
return Array.isArray(item.markets) ? item.markets.includes(market) : true;
|
|
3748
3737
|
}
|
|
3749
3738
|
__name(hasMarket, "hasMarket");
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
const { locale } = query2;
|
|
3768
|
-
const depth = getNumericParam(query2.depth);
|
|
3769
|
-
if (depth !== 0 && Array.isArray(menuConfig.fields)) {
|
|
3770
|
-
doc = await populateStaticFields(doc, menuConfig.fields, locale);
|
|
3771
|
-
}
|
|
3772
|
-
}
|
|
3773
|
-
}
|
|
3774
|
-
return doc;
|
|
3775
|
-
});
|
|
3776
|
-
menuConfig.endpoints = [
|
|
3777
|
-
menuIndexGet(options),
|
|
3778
|
-
menuDetailGet(options)
|
|
3779
|
-
];
|
|
3780
|
-
translateCollection(menuConfig);
|
|
3781
|
-
return menuConfig;
|
|
3782
|
-
}, "withMenu");
|
|
3783
|
-
|
|
3784
|
-
// src/core/decorators/href.ts
|
|
3785
|
-
async function decorateHref_(item, slug, context) {
|
|
3786
|
-
const { market, locale, routes } = context;
|
|
3787
|
-
const route = routes.find(
|
|
3788
|
-
(x) => x.schema === slug && x.page === item.id && x.market === market && x.locale === locale
|
|
3789
|
-
);
|
|
3790
|
-
const href = route ? route.id : null;
|
|
3791
|
-
return { ...item, href };
|
|
3739
|
+
async function decorateMenu_(req, item, market, locale) {
|
|
3740
|
+
const decoratedItem = {
|
|
3741
|
+
id: item.id,
|
|
3742
|
+
items: []
|
|
3743
|
+
};
|
|
3744
|
+
const languages = await getLocales(req);
|
|
3745
|
+
if (!languages.includes(locale)) {
|
|
3746
|
+
return decoratedItem;
|
|
3747
|
+
}
|
|
3748
|
+
const markets = await getMarkets(req);
|
|
3749
|
+
if (!markets.includes(market)) {
|
|
3750
|
+
return decoratedItem;
|
|
3751
|
+
}
|
|
3752
|
+
const categories = await getCollectionItems(req, options.slug.category);
|
|
3753
|
+
const routes = (await getRoutes(req)).filter((x) => x.market === market && x.locale === locale);
|
|
3754
|
+
decoratedItem.items = item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market));
|
|
3755
|
+
return decoratedItem;
|
|
3792
3756
|
}
|
|
3793
|
-
__name(
|
|
3794
|
-
async function
|
|
3795
|
-
const
|
|
3796
|
-
|
|
3797
|
-
(x) => x.schema === slug && x.market === market && x.locale === locale
|
|
3798
|
-
);
|
|
3799
|
-
return items.map((item) => {
|
|
3800
|
-
const route = routes.find(
|
|
3801
|
-
(x) => x.page === item.id
|
|
3802
|
-
);
|
|
3803
|
-
const href = route ? route.id : null;
|
|
3804
|
-
return { ...item, href };
|
|
3805
|
-
});
|
|
3757
|
+
__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);
|
|
3806
3761
|
}
|
|
3807
|
-
__name(
|
|
3762
|
+
__name(decorateMenus_, "decorateMenus_");
|
|
3808
3763
|
|
|
3809
3764
|
// src/core/decorators/nav.ts
|
|
3810
|
-
var
|
|
3765
|
+
var import_bom_core4 = require("@websolutespa/bom-core");
|
|
3811
3766
|
async function decorateNav_(item, slug, context) {
|
|
3812
3767
|
parseNavs_(item, context);
|
|
3813
3768
|
return item;
|
|
@@ -3822,18 +3777,18 @@ async function decorateNavs_(items, slug, context) {
|
|
|
3822
3777
|
__name(decorateNavs_, "decorateNavs_");
|
|
3823
3778
|
function parseNavs_(item, context) {
|
|
3824
3779
|
const { market, locale, routes, categories } = context;
|
|
3825
|
-
if ((0,
|
|
3780
|
+
if ((0, import_bom_core4.isArray)(item)) {
|
|
3826
3781
|
item.forEach((v, k) => {
|
|
3827
3782
|
if (isUndecoratedMenuItem(v)) {
|
|
3828
|
-
item[k] =
|
|
3783
|
+
item[k] = decorateMenuItem_(v, categories, routes, market);
|
|
3829
3784
|
} else {
|
|
3830
3785
|
parseNavs_(v, context);
|
|
3831
3786
|
}
|
|
3832
3787
|
});
|
|
3833
|
-
} else if ((0,
|
|
3788
|
+
} else if ((0, import_bom_core4.isObject)(item)) {
|
|
3834
3789
|
Object.entries(item).forEach(([k, v]) => {
|
|
3835
3790
|
if (isUndecoratedMenuItem(v)) {
|
|
3836
|
-
item[k] =
|
|
3791
|
+
item[k] = decorateMenuItem_(v, categories, routes, market);
|
|
3837
3792
|
} else {
|
|
3838
3793
|
parseNavs_(v, context);
|
|
3839
3794
|
}
|
|
@@ -3842,11 +3797,11 @@ function parseNavs_(item, context) {
|
|
|
3842
3797
|
}
|
|
3843
3798
|
__name(parseNavs_, "parseNavs_");
|
|
3844
3799
|
function isUndecoratedMenuItem(item) {
|
|
3845
|
-
return (0,
|
|
3800
|
+
return (0, import_bom_core4.isObject)(item) && (item.type === "category" && ((0, import_bom_core4.isEquatable)(item.category) || (0, import_bom_core4.isObject)(item.category)) || item.type === "page" && isRelation(item.page));
|
|
3846
3801
|
}
|
|
3847
3802
|
__name(isUndecoratedMenuItem, "isUndecoratedMenuItem");
|
|
3848
3803
|
function isRelation(item) {
|
|
3849
|
-
return (0,
|
|
3804
|
+
return (0, import_bom_core4.isObject)(item) && (0, import_bom_core4.isNotNullString)(item.relationTo) && ((0, import_bom_core4.isObject)(item.value) || (0, import_bom_core4.isArray)(item.value));
|
|
3850
3805
|
}
|
|
3851
3806
|
__name(isRelation, "isRelation");
|
|
3852
3807
|
|
|
@@ -3862,6 +3817,92 @@ async function decorateSchemas_(items, slug, context) {
|
|
|
3862
3817
|
}
|
|
3863
3818
|
__name(decorateSchemas_, "decorateSchemas_");
|
|
3864
3819
|
|
|
3820
|
+
// src/core/api/menu.service.ts
|
|
3821
|
+
var menuIndexGet = /* @__PURE__ */ __name((options2) => ({
|
|
3822
|
+
path: "/",
|
|
3823
|
+
method: "get",
|
|
3824
|
+
handler: async (req, res, next) => {
|
|
3825
|
+
const { query } = req;
|
|
3826
|
+
if (!query) {
|
|
3827
|
+
return next();
|
|
3828
|
+
}
|
|
3829
|
+
const { locale, market, pagination, page, limit } = query;
|
|
3830
|
+
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
3831
|
+
return next();
|
|
3832
|
+
}
|
|
3833
|
+
try {
|
|
3834
|
+
let items = await getCollectionItems(req, options2.slug.menu);
|
|
3835
|
+
if (pagination === "true") {
|
|
3836
|
+
const response = await getPagination(items, getNumericParam(page), getNumericParam(limit));
|
|
3837
|
+
response.docs = await decorateMenus_(req, response.docs, market, locale);
|
|
3838
|
+
res.status(200).send(response);
|
|
3839
|
+
} else {
|
|
3840
|
+
items = await decorateMenus_(req, items, market, locale);
|
|
3841
|
+
res.status(200).send(items);
|
|
3842
|
+
}
|
|
3843
|
+
} catch (error) {
|
|
3844
|
+
console.log("menuIndexGet.error", error);
|
|
3845
|
+
res.status(500).send(error);
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
}), "menuIndexGet");
|
|
3849
|
+
var menuDetailGet = /* @__PURE__ */ __name((options2) => ({
|
|
3850
|
+
path: "/:id/",
|
|
3851
|
+
method: "get",
|
|
3852
|
+
handler: async (req, res, next) => {
|
|
3853
|
+
const { query } = req;
|
|
3854
|
+
if (!query) {
|
|
3855
|
+
return next();
|
|
3856
|
+
}
|
|
3857
|
+
const { market, locale } = query;
|
|
3858
|
+
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
3859
|
+
return next();
|
|
3860
|
+
}
|
|
3861
|
+
try {
|
|
3862
|
+
const { id } = req.params;
|
|
3863
|
+
const item = await getCollectionItem(req, options2.slug.menu, id);
|
|
3864
|
+
const decoratedItem = await decorateMenu_(req, item, market, locale);
|
|
3865
|
+
res.status(200).send(decoratedItem);
|
|
3866
|
+
} catch (error) {
|
|
3867
|
+
console.log("menuDetailGet.error", error);
|
|
3868
|
+
res.status(500).send(error);
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
}), "menuDetailGet");
|
|
3872
|
+
|
|
3873
|
+
// src/core/collections/withMenu.ts
|
|
3874
|
+
var withMenu = /* @__PURE__ */ __name((config) => {
|
|
3875
|
+
const menuConfig = deepMerge(CollectionDefault, config);
|
|
3876
|
+
withCollectionHook(menuConfig, "afterRead", async ({
|
|
3877
|
+
doc,
|
|
3878
|
+
// full document data
|
|
3879
|
+
req,
|
|
3880
|
+
// full express request
|
|
3881
|
+
query,
|
|
3882
|
+
// JSON formatted query
|
|
3883
|
+
findMany
|
|
3884
|
+
// boolean to denote if this hook is running against finding one, or finding many
|
|
3885
|
+
}) => {
|
|
3886
|
+
if (doc && !findMany) {
|
|
3887
|
+
const { query: query2 } = req;
|
|
3888
|
+
if (query2) {
|
|
3889
|
+
const { locale } = query2;
|
|
3890
|
+
const depth = getNumericParam(query2.depth);
|
|
3891
|
+
if (depth !== 0 && Array.isArray(menuConfig.fields)) {
|
|
3892
|
+
doc = await populateStaticFields(doc, menuConfig.fields, locale);
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
return doc;
|
|
3897
|
+
});
|
|
3898
|
+
menuConfig.endpoints = [
|
|
3899
|
+
menuIndexGet(options),
|
|
3900
|
+
menuDetailGet(options)
|
|
3901
|
+
];
|
|
3902
|
+
translateCollection(menuConfig);
|
|
3903
|
+
return menuConfig;
|
|
3904
|
+
}, "withMenu");
|
|
3905
|
+
|
|
3865
3906
|
// src/core/api/page.service.ts
|
|
3866
3907
|
function getSubRequest(req) {
|
|
3867
3908
|
const { transactionID, payload, user } = req;
|
|
@@ -3919,7 +3960,6 @@ var pageIndexGet = /* @__PURE__ */ __name((slug) => ({
|
|
|
3919
3960
|
if (!(typeof market === "string" && typeof locale === "string")) {
|
|
3920
3961
|
return next();
|
|
3921
3962
|
}
|
|
3922
|
-
console.log("market", typeof market, market, "locale", typeof locale, locale);
|
|
3923
3963
|
await setMixerContext(req, market, locale);
|
|
3924
3964
|
if (limit === "10000") {
|
|
3925
3965
|
return next();
|
|
@@ -3948,7 +3988,8 @@ var afterPageReadHook = /* @__PURE__ */ __name((slug) => async ({
|
|
|
3948
3988
|
return doc;
|
|
3949
3989
|
}
|
|
3950
3990
|
const withSchema = await decorateSchema_(doc, slug, context);
|
|
3951
|
-
const
|
|
3991
|
+
const withCategory2 = await decorateCategory_(withSchema, slug, context);
|
|
3992
|
+
const withHref = await decorateHref_(withCategory2, slug, context);
|
|
3952
3993
|
const withNav = await decorateNav_(withHref, slug, context);
|
|
3953
3994
|
return withNav;
|
|
3954
3995
|
}, "afterPageReadHook");
|
|
@@ -4739,7 +4780,7 @@ async function getRoutes(req) {
|
|
|
4739
4780
|
if (locales2.length > 0 && markets.length > 0) {
|
|
4740
4781
|
const categories = await getCollectionItems(subRequest, options.slug.category, 1);
|
|
4741
4782
|
const store = await fetchPages(subRequest);
|
|
4742
|
-
routes = (0,
|
|
4783
|
+
routes = (0, import_bom_core5.collectRoutes)(store, categories, markets, locales2);
|
|
4743
4784
|
}
|
|
4744
4785
|
CACHE_2.set(key, routes);
|
|
4745
4786
|
return routes;
|
|
@@ -4754,15 +4795,15 @@ __name(getRoute, "getRoute");
|
|
|
4754
4795
|
async function getRouteByItemAndLocale(req, item, localeId, slug) {
|
|
4755
4796
|
const routes = [];
|
|
4756
4797
|
const categories = await getCollectionItems(req, options.slug.category, 1);
|
|
4757
|
-
const segments = (0,
|
|
4798
|
+
const segments = (0, import_bom_core5.getCategorySegments)(item, categories);
|
|
4758
4799
|
const slugs = segments.map((x) => ({ slug: x.slug }));
|
|
4759
4800
|
if (!item.isDefault) {
|
|
4760
4801
|
slugs.push({ slug: item.slug });
|
|
4761
4802
|
}
|
|
4762
4803
|
await fetchEachMarketLocale(req, (market, locale, markets, locales2) => {
|
|
4763
4804
|
if ((!item.markets || item.markets.includes(market.id)) && locale.id === localeId) {
|
|
4764
|
-
const title = (0,
|
|
4765
|
-
const id = (0,
|
|
4805
|
+
const title = (0, import_bom_core5.localize)(item.title, locale.id);
|
|
4806
|
+
const id = (0, import_bom_core5.getRouteHref)(slugs, market, locale, markets, locales2);
|
|
4766
4807
|
const route = {
|
|
4767
4808
|
id,
|
|
4768
4809
|
market: market.id,
|
|
@@ -4786,11 +4827,11 @@ __name(getRouteByItemAndLocale, "getRouteByItemAndLocale");
|
|
|
4786
4827
|
async function getRouteByCategoryAndLocale(req, item, localeId, slug) {
|
|
4787
4828
|
const routes = [];
|
|
4788
4829
|
const categories = await getCollectionItems(req, options.slug.category, 1);
|
|
4789
|
-
const segments = (0,
|
|
4830
|
+
const segments = (0, import_bom_core5.getCategorySegmentsByCategory)(item, categories);
|
|
4790
4831
|
await fetchEachMarketLocale(req, (market, locale, markets, locales2) => {
|
|
4791
4832
|
if (locale.id === localeId) {
|
|
4792
|
-
const title = (0,
|
|
4793
|
-
const id = (0,
|
|
4833
|
+
const title = (0, import_bom_core5.localize)(item.title, locale.id);
|
|
4834
|
+
const id = (0, import_bom_core5.getRouteHref)(segments, market, locale, markets, locales2);
|
|
4794
4835
|
const route = {
|
|
4795
4836
|
id,
|
|
4796
4837
|
market: market.id,
|
|
@@ -4922,7 +4963,7 @@ async function fetchEachMarketLocale(req, callback) {
|
|
|
4922
4963
|
markets = markets ? markets.filter((x) => x.isActive) : [];
|
|
4923
4964
|
let locales2 = await getGlobalItems(req, options.slug.locale, 0);
|
|
4924
4965
|
locales2 = locales2 ? locales2.filter((x) => x.isActive) : [];
|
|
4925
|
-
return (0,
|
|
4966
|
+
return (0, import_bom_core5.eachMarketLocale)(markets, locales2, callback);
|
|
4926
4967
|
}
|
|
4927
4968
|
__name(fetchEachMarketLocale, "fetchEachMarketLocale");
|
|
4928
4969
|
async function fetchPages(req) {
|
|
@@ -4939,7 +4980,7 @@ __name(fetchPages, "fetchPages");
|
|
|
4939
4980
|
// src/core/api/redirect.service.ts
|
|
4940
4981
|
async function collectPageRedirects(req, previousItem, newItem) {
|
|
4941
4982
|
const collectedRedirects = [];
|
|
4942
|
-
const isProduction = (0,
|
|
4983
|
+
const isProduction = (0, import_bom_core6.getIsProduction)();
|
|
4943
4984
|
if (isProduction) {
|
|
4944
4985
|
const { query, collection, payload, user } = req;
|
|
4945
4986
|
const { locale } = query;
|
|
@@ -4964,7 +5005,7 @@ async function collectPageRedirects(req, previousItem, newItem) {
|
|
|
4964
5005
|
const redirect = {
|
|
4965
5006
|
from: `*${previousRoute.id}`,
|
|
4966
5007
|
to: `*${route.id}`,
|
|
4967
|
-
status:
|
|
5008
|
+
status: import_bom_core6.RedirectReason.MovedPermanently,
|
|
4968
5009
|
isActive: true
|
|
4969
5010
|
};
|
|
4970
5011
|
return redirect;
|
|
@@ -4982,7 +5023,7 @@ async function collectPageRedirects(req, previousItem, newItem) {
|
|
|
4982
5023
|
__name(collectPageRedirects, "collectPageRedirects");
|
|
4983
5024
|
async function collectCategoryRedirects(req, previousItem, newItem) {
|
|
4984
5025
|
const collectedRedirects = [];
|
|
4985
|
-
const isProduction = (0,
|
|
5026
|
+
const isProduction = (0, import_bom_core6.getIsProduction)();
|
|
4986
5027
|
if (isProduction) {
|
|
4987
5028
|
const { query, collection, payload, user } = req;
|
|
4988
5029
|
const { locale } = query;
|
|
@@ -5007,7 +5048,7 @@ async function collectCategoryRedirects(req, previousItem, newItem) {
|
|
|
5007
5048
|
const redirect = {
|
|
5008
5049
|
from: `*${previousRoute.id}*`,
|
|
5009
5050
|
to: `*${route.id}*`,
|
|
5010
|
-
status:
|
|
5051
|
+
status: import_bom_core6.RedirectReason.MovedPermanently,
|
|
5011
5052
|
isActive: true
|
|
5012
5053
|
};
|
|
5013
5054
|
return redirect;
|
|
@@ -5094,7 +5135,7 @@ var localeGet = {
|
|
|
5094
5135
|
};
|
|
5095
5136
|
|
|
5096
5137
|
// src/core/api/store.service.ts
|
|
5097
|
-
var
|
|
5138
|
+
var import_bom_core7 = require("@websolutespa/bom-core");
|
|
5098
5139
|
var import_qs2 = __toESM(require("qs"));
|
|
5099
5140
|
var CACHE_3 = new InMemoryCache();
|
|
5100
5141
|
async function getStore(req) {
|
|
@@ -5127,7 +5168,7 @@ function getApiUrl(req) {
|
|
|
5127
5168
|
const port = process.env.PORT || 4e3;
|
|
5128
5169
|
const origin = `http://localhost:${port}`;
|
|
5129
5170
|
let url = `${origin}${config.routes.api}/`;
|
|
5130
|
-
url =
|
|
5171
|
+
url = import_bom_core7.isBrowser ? url : url.replace("://localhost", "://127.0.0.1");
|
|
5131
5172
|
return url;
|
|
5132
5173
|
}
|
|
5133
5174
|
__name(getApiUrl, "getApiUrl");
|
|
@@ -5793,8 +5834,8 @@ var Province = /* @__PURE__ */ __name((options2) => ({
|
|
|
5793
5834
|
}), "Province");
|
|
5794
5835
|
|
|
5795
5836
|
// src/collections/Redirect.ts
|
|
5796
|
-
var
|
|
5797
|
-
var RedirectStatusOptions = Object.entries(
|
|
5837
|
+
var import_bom_core8 = require("@websolutespa/bom-core");
|
|
5838
|
+
var RedirectStatusOptions = Object.entries(import_bom_core8.RedirectReason).map(([k, v]) => ({
|
|
5798
5839
|
value: v,
|
|
5799
5840
|
label: `${v} - ${k}`
|
|
5800
5841
|
}));
|
|
@@ -6844,16 +6885,18 @@ var src_default = bowl;
|
|
|
6844
6885
|
collectionIndexGet,
|
|
6845
6886
|
collectionUpdatePatch,
|
|
6846
6887
|
debugField,
|
|
6888
|
+
decorateCategories_,
|
|
6889
|
+
decorateCategory_,
|
|
6847
6890
|
decorateHref_,
|
|
6848
6891
|
decorateHrefs_,
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6892
|
+
decorateMenuCategory_,
|
|
6893
|
+
decorateMenuGroup_,
|
|
6894
|
+
decorateMenuItem_,
|
|
6895
|
+
decorateMenuLink_,
|
|
6896
|
+
decorateMenuPage_,
|
|
6897
|
+
decorateMenuRoute_,
|
|
6898
|
+
decorateMenu_,
|
|
6899
|
+
decorateMenus_,
|
|
6857
6900
|
decorateNav_,
|
|
6858
6901
|
decorateNavs_,
|
|
6859
6902
|
decorateSchema_,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websolutespa/payload-plugin-bowl",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Bowl PayloadCms plugin of the BOM Repository",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -34,28 +34,30 @@
|
|
|
34
34
|
"@payloadcms/db-mongodb": ">= 1.2.0",
|
|
35
35
|
"@websolutespa/bom-core": "*",
|
|
36
36
|
"axios": "0.27.2",
|
|
37
|
+
"i18next": ">= 22.4.9",
|
|
37
38
|
"payload": ">= 2.11.2",
|
|
38
39
|
"react": ">= 18.2.0",
|
|
39
|
-
"
|
|
40
|
+
"uuid": ">= 9.0.1"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@types/escape-html": "^1.0.2",
|
|
43
44
|
"@types/express": "^4.17.15",
|
|
44
|
-
"@types/uuid": "^9.0.2",
|
|
45
45
|
"@types/papaparse": "^5.3.7",
|
|
46
|
+
"@types/uuid": "^9.0.2",
|
|
46
47
|
"@websolutespa/bom-cli": "*",
|
|
47
48
|
"@websolutespa/test": "*",
|
|
48
49
|
"@websolutespa/tsconfig": "*",
|
|
49
50
|
"axios": "0.27.2",
|
|
50
51
|
"esbuild-sass-plugin": "^2.10.0",
|
|
51
|
-
"eslint": "^8.46.0",
|
|
52
52
|
"eslint-config-websolute": "*",
|
|
53
|
+
"eslint": "^8.46.0",
|
|
53
54
|
"i18next": "^22.4.9",
|
|
54
55
|
"mongodb-memory-server": "^8.13.0",
|
|
55
56
|
"react": "^18.2.0",
|
|
56
57
|
"ts-node": "^10.9.1",
|
|
57
58
|
"tsup": "^6.7.0",
|
|
58
|
-
"typescript": "^5.1.6"
|
|
59
|
+
"typescript": "^5.1.6",
|
|
60
|
+
"uuid": "^9.0.1"
|
|
59
61
|
},
|
|
60
62
|
"publishConfig": {
|
|
61
63
|
"access": "public"
|
package/scss/styles.scss
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
@use 'sass:math';
|
|
2
2
|
@import "~payload/scss";
|
|
3
3
|
|
|
4
|
+
.nav-group {
|
|
5
|
+
margin-bottom: 2rem;
|
|
6
|
+
|
|
7
|
+
&:first-child {
|
|
8
|
+
margin-top: 2rem;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@media (min-width: 768px) {
|
|
12
|
+
.nav-group__content {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
row-gap: 0.2rem;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.nav__link {
|
|
20
|
+
// padding: 0.2403846154rem 2.8846153846rem 0.2403846154rem 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
4
25
|
.nav-group__label {
|
|
5
26
|
text-transform: uppercase;
|
|
6
27
|
font-size: 0.7em;
|
|
7
|
-
font-weight: bold;
|
|
8
28
|
letter-spacing: 0.03em;
|
|
9
29
|
}
|
|
10
30
|
|