@websolutespa/payload-plugin-bowl 1.7.1 → 1.7.3

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @websolutespa/payload-plugin-bowl
2
2
 
3
+ ## 1.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: WhereService, StaticService, localize decorator
8
+ - Modified: withCollection, withStaticCollection, withAction, CollectionService, PageService
9
+
10
+ ## 1.7.2
11
+
12
+ ### Patch Changes
13
+
14
+ - Fixing: setMixerContext
15
+
3
16
  ## 1.7.1
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -62,7 +62,7 @@ declare const afterCategoryDeleteHook: CollectionAfterDeleteHook;
62
62
  declare function parseDepth(depth?: unknown): number;
63
63
  declare function getCollectionItems<T extends TypeWithID & Record<string, unknown>>(req: PayloadRequest, slug: string, depth?: number): Promise<T[]>;
64
64
  declare function getCollectionItem<T extends TypeWithID & Record<string, unknown>>(req: PayloadRequest, slug: string, id: string, depth?: number): Promise<T>;
65
- declare function getGlobalItems<T extends TypeWithID = any>(req: PayloadRequest, slug: string, depth?: number): Promise<T[]>;
65
+ declare function getGlobalItems<T extends TypeWithID & Record<string, unknown>>(req: PayloadRequest, slug: string, depth?: number): Promise<T[]>;
66
66
  /**
67
67
  * Rest api collection index get handler.
68
68
  */
@@ -106,6 +106,10 @@ declare enum ImportMode {
106
106
  * Rest api collection import post handler.
107
107
  */
108
108
  declare const collectionImportPost: ((slug: string) => Endpoint);
109
+ /**
110
+ * Decorate record for with static collection data.
111
+ */
112
+ declare const afterCollectionReadHook: (collectionConfig: CollectionConfig) => CollectionConfig['hooks']['afterRead'][number];
109
113
 
110
114
  declare function getLocale(req: PayloadRequest<any>): Promise<ILocale[]>;
111
115
  declare const localeGet: Endpoint;
@@ -167,6 +171,27 @@ declare function routePostHandler(request: any, response: any, next: any): Promi
167
171
  declare function getEachMarketLocale(req: PayloadRequest<any>, callback: (market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]) => void): Promise<void>;
168
172
  declare function getPages(req: PayloadRequest<any>): Promise<IMemoryStore<ICategorized>>;
169
173
 
174
+ type Option = {
175
+ id: string;
176
+ name: string;
177
+ [key: string]: unknown;
178
+ };
179
+ type KeyMapper = {
180
+ [key: string]: string;
181
+ };
182
+ declare const staticCollections: string[];
183
+ declare const staticCollectionLoaders: Record<string, () => Promise<Option[]>>;
184
+ /**
185
+ * Rest api static collection get handler.
186
+ */
187
+ declare const staticIndexGet: ((collectionConfig: CollectionConfig) => Endpoint);
188
+ /**
189
+ * Rest api static collection detail get handler.
190
+ */
191
+ declare const staticDetailGet: ((collectionConfig: CollectionConfig) => Endpoint);
192
+ declare function populateStaticFields<T = IEntity>(item: T, fields: Field[], locale: string): Promise<T>;
193
+ declare function getStaticLoader(slug: string): () => Promise<Option[]>;
194
+
170
195
  declare function getStore(req: PayloadRequest): Promise<IMemoryStore>;
171
196
  declare function getApiUrl(req: PayloadRequest): string;
172
197
  declare function getSearchUrl(req: PayloadRequest, overrideQuery?: {}): string;
@@ -270,6 +295,11 @@ declare function getStringParam(value: unknown): string | undefined;
270
295
  declare function getSubRequest(req: PayloadRequest): PayloadRequest;
271
296
  declare function setMixerContext(req: PayloadRequest, market: string, locale: string): Promise<MixerContext>;
272
297
 
298
+ declare function whereCollection<T = IEntity>(items: T[], where?: {
299
+ [key: string]: any;
300
+ }): Promise<T[]>;
301
+ declare function sortCollection<T = IEntity>(items: T[], sort?: string): Promise<T[]>;
302
+
273
303
  type WithActionProps = (Omit<CollectionConfig, 'fields'> & {
274
304
  fields: BowlField[];
275
305
  views?: Record<string, AdminView>;
@@ -364,27 +394,12 @@ type WithStaticProps = (Omit<CollectionConfig, 'fields'> & StaticCollectionConfi
364
394
  type WithStatic = WithStaticProps & {
365
395
  type: 'withStatic';
366
396
  };
367
- type Option = {
368
- id: string;
369
- name: string;
370
- [key: string]: unknown;
371
- };
372
- type KeyMapper = {
373
- [key: string]: string;
374
- };
375
397
  type StaticCollectionSrc = string | Option[] | ((config: CollectionConfig) => Option[]) | ((config: CollectionConfig) => Promise<Option[]>);
376
398
  type StaticCollectionConfig = {
377
399
  src: StaticCollectionSrc;
378
400
  map?: KeyMapper;
379
401
  duration?: number | false;
380
402
  };
381
- declare function whereCollection<T = IEntity>(items: T[], where?: {
382
- [key: string]: any;
383
- }): Promise<T[]>;
384
- declare function populateStaticFields<T = IEntity>(item: T, fields: Field[], locale: string): Promise<T>;
385
- declare function localizeCollection<T = IEntity>(items: T[], localizedFields: string[], locale?: string): Promise<T[]>;
386
- declare function sortCollection<T = IEntity>(items: T[], sort?: string): Promise<T[]>;
387
- declare function getStaticLoader(slug: string): any;
388
403
  declare const StaticCollectionDefault: Partial<CollectionConfig>;
389
404
  /**
390
405
  * @param {CollectionConfig & StaticCollectionConfig} config
@@ -406,6 +421,9 @@ declare function decorateHrefs_<T extends ISchema = ISchema>(items: T[], slug: s
406
421
  href: string | null;
407
422
  })[]>;
408
423
 
424
+ declare function localizeItem<T = IEntity>(item: T, localizedFields: string[], locale: string): Promise<T>;
425
+ declare function localizeCollection<T = IEntity>(items: T[], localizedFields: string[], locale?: string): Promise<T[]>;
426
+
409
427
  declare const MAX_INT = 1000000000000;
410
428
  declare function decorateMenuCategory_(item: IUndecoratedMenuCategory, categories: ICategory[], routes: IRoute[], market: string, depth?: number): IMenuItem;
411
429
  declare function decorateMenuGroup_(item: IUndecoratedMenuGroup, categories: ICategory[], routes: IRoute[], market: string): IMenuItem;
@@ -1103,4 +1121,4 @@ declare const Logo: React__default.FC;
1103
1121
 
1104
1122
  declare function webpack(sourceConfig: BowlConfig): (config: any) => any;
1105
1123
 
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 };
1124
+ 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, 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, 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, localizeItem, log, logMissingTranslations, menuDetailGet, menuIndexGet, modalSlug, optinPost, options, 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 };