@websolutespa/payload-plugin-bowl 1.8.2 → 1.8.4

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,17 @@
1
1
  # @websolutespa/payload-plugin-bowl
2
2
 
3
+ ## 1.8.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: StoreService, MenuService
8
+
9
+ ## 1.8.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 5ad32d3: Added afterOptin and afterOptout hooks
14
+
3
15
  ## 1.8.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -499,18 +499,27 @@ declare function getNumericParam(value: unknown): number | undefined;
499
499
  declare function getStringParam(value: unknown): string | undefined;
500
500
  declare function getSubRequest(req: PayloadRequest): PayloadRequest;
501
501
  declare function setMixerContext(req: PayloadRequest, market: string, locale: string): Promise<MixerContext>;
502
+ declare function filterRoutes(routes: IRoute[], market: string, locale: string): IRoute[];
502
503
 
503
504
  declare function whereCollection<T = IEntity>(items: T[], where?: {
504
505
  [key: string]: any;
505
506
  }): Promise<T[]>;
506
507
  declare function sortCollection<T = IEntity>(items: T[], sort?: string): Promise<T[]>;
507
508
 
509
+ type AfterOptHook<T extends TypeWithID = any> = (args: {
510
+ collection: SanitizedCollectionConfig;
511
+ doc: T;
512
+ previousDoc: T;
513
+ req: PayloadRequest;
514
+ }) => any;
508
515
  type WithActionProps = (Omit<CollectionConfig, 'fields'> & {
509
516
  fields: BowlField[];
510
517
  views?: Record<string, AdminView>;
511
518
  custom?: {
512
519
  updateEndUser?: boolean;
513
520
  createCredentials?: boolean;
521
+ afterOptin?: AfterOptHook;
522
+ afterOptout?: AfterOptHook;
514
523
  [key: string]: unknown;
515
524
  };
516
525
  });
@@ -776,6 +785,8 @@ declare const withLink: ({ appearances, disableLabel, ...props }?: WithLinkProps
776
785
  condition?: payload_types.Condition<any, any>;
777
786
  description?: payload_dist_admin_components_forms_FieldDescription_types.Description;
778
787
  disableBulkEdit?: boolean;
788
+ disableListColumn?: boolean;
789
+ disableListFilter?: boolean;
779
790
  disabled?: boolean;
780
791
  hidden?: boolean;
781
792
  position?: "sidebar";
@@ -1021,13 +1032,6 @@ type GroupKey = {
1021
1032
  };
1022
1033
  declare function sortByGroup<T extends (CollectionConfig | GlobalConfig) = CollectionConfig | GlobalConfig>(collectionsOrGlobals: T[]): T[];
1023
1034
 
1024
- type WithNewsletterSubscriptionProps = (Omit<RelationshipField, 'type' | 'name' | 'relationTo'> & {
1025
- name?: string;
1026
- });
1027
- type WithNewsletterSubscription = WithNewsletterSubscriptionProps & {
1028
- type: 'withNewsletterSubscription';
1029
- };
1030
-
1031
1035
  type WithColorProps = (Omit<TextField, 'type' | 'name' | 'hasMany'> & {
1032
1036
  name?: string;
1033
1037
  });
@@ -1122,7 +1126,7 @@ type BowlRowField = Omit<RowField, 'fields'> & {
1122
1126
  type BowlTabsField = Omit<TabsField, 'tabs'> & {
1123
1127
  tabs: BowlTab[];
1124
1128
  };
1125
- type BowlField = Exclude<Field, ArrayField | BlockField | CollapsibleField | GroupField | RowField | TabsField> | BowlArrayField | BowlBlockField | BowlCollapsibleField | BowlGroupField | BowlRowField | BowlTabsField | WithAbstract | WithCategory | WithCheckbox | WithColor | WithComponents | WithDate | WithDescription | WithId | WithIsActive | WithIsDefault | WithLink | WithMarkets | WithMedia | WithMedias | WithName | WithNewsletterSubscription | WithOrder | WithRelated | WithRichText | WithSelect | WithSlug | WithTemplate | WithTenants | WithText | WithTitle | WithRoles;
1129
+ type BowlField = Exclude<Field, ArrayField | BlockField | CollapsibleField | GroupField | RowField | TabsField> | BowlArrayField | BowlBlockField | BowlCollapsibleField | BowlGroupField | BowlRowField | BowlTabsField | WithAbstract | WithCategory | WithCheckbox | WithColor | WithComponents | WithDate | WithDescription | WithId | WithIsActive | WithIsDefault | WithLink | WithMarkets | WithMedia | WithMedias | WithName | WithOrder | WithRelated | WithRichText | WithSelect | WithSlug | WithTemplate | WithTenants | WithText | WithTitle | WithRoles;
1126
1130
  type BowlBlock = Block | WithBlock;
1127
1131
  type BowlCollection = WithCollection | WithPage | WithStatic | WithMenu | WithAction | CollectionConfig & {
1128
1132
  type?: string;
@@ -1150,7 +1154,6 @@ type BowlSlug = {
1150
1154
  template: string;
1151
1155
  legalNotice: string;
1152
1156
  consentPreference: string;
1153
- newsletterSubscription: string;
1154
1157
  users: string;
1155
1158
  endUsers: string;
1156
1159
  endUserCredentials: string;
@@ -1241,4 +1244,4 @@ declare const Logo: React__default.FC;
1241
1244
 
1242
1245
  declare function webpack(sourceConfig: BowlConfig): (config: any) => any;
1243
1246
 
1244
- 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, CategoryTreeConflictProps, CategoryTreeItem, CategoryTreeItems, CategoryTreeProps, CheckboxDefaults, CollectionDefault, CollectionHelper, CollectionHook, CollectionHookName, CollectionHooks, ColorCell, ColorConfig, ColorField, ComponentsDefaults, CustomEditModal, CustomEditModalProps, DataField, DataTree, DataTreeDragItem, DataTreeInstance, DataTreeItem, DataTreeItemLi, DataTreeItemProps, DataTreeProps, DataTreeProvider, DataTreeRenameItem, DateDefaults, DebugField, DecoratedList, DecoratedListProps, FindOptions, GlobalDefault, GlobalHelper, GlobalHook, GlobalHookName, GlobalHooks, GroupKey, IBulkAction, IBulkRecord, ICache, IImportItem, IPage, IPageFull, IPagination, IRelation, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNavItem, Icon, ImportExportList, ImportExportListProps, ImportExportRedirectList, ImportLogInvalidTypes, ImportLogType, ImportMode, InMemoryCache, InMemoryCacheOptions, KeyMapper, LeaveModal, LeaveWithoutSavingModal, LeaveWithoutSavingModalProps, LocalizedDescription, LocalizedDescriptionProps, Logo, MAX_INT, MarketDefaults, MediaDefaults, MediasDefaults, MenuItem, MixerContext, Option, OrderDefaults, PRESENTATION_FIELDS, PageDefault, PresentationField, PublicURL, Publish, ROOT_ITEM, RelatedDefaults, RichTextDefaults, RouteConflict, Save, SaveDraft, SelectDefaults, StaticCollectionConfig, StaticCollectionDefault, TemplateDefaults, TenantsDefault, TextDefaults, TreeItemData, 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, WithTenants, WithTenantsProps, WithText, WithTextProps, WithTitle, WithTitleProps, afterCategoryChangeHook, afterCategoryDeleteHook, afterCollectionReadHook, afterMenuReadHook, afterPageChangeHook, afterPageDeleteHook, afterPageReadHook, afterReadItem, afterReadItems, afterStaticReadHook, appearanceOptions, beforeDuplicateCollectionHook, beforeValidate, bowl, collectionBulkPatch, collectionExportGet, collectionImportPost, collectionIndexGet, collectionUpdatePatch, debugField, decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateMenuCategory_, decorateMenuGroup_, decorateMenuItem_, decorateMenuLink_, decorateMenuPage_, decorateMenuRoute_, decorateMenu_, decorateNavItem_, decorateNav_, decorateNavs_, decorateSchema_, decorateSchemas_, deepMerge, bowl as default, defaultGroup, defaultLocale, defaultLocales, defaultMarket, defaultSlug, eachDataField, eachField, encryptData, findCollection, formatSlug, getApiUrl, getCollectionItem, getCollectionItems, getEachMarketLocale, getGlobalItems, getLivePreviewURL, getLocale, getNewCategoriesFromChanges, getNumericParam, getObjectParam, getPages, getPagination, getPreviewURL, getPublicURL, getRoute, getRouteByCategoryAndLocale, getRouteByItemAndLocale, getRoutes, getSearchUrl, getStaticLoader, getStringParam, getSubRequest, getTranslation, getTranslations, getTreeItemClassName, hasMarket, hasRole, importExportListWithParser, internalSlugs, isAdmin, isAdminOrSelf, isDataField, isObject, isPresentationField, isRelation, isRole, isTenant, isUndecoratedNavItem, keyWithRequest, localeGet, localizeCollection, localizeItem, log, logMissingTranslations, menuDetailGet, menuIndexGet, modalSlug, optinGet, options, optoutGet, pageDetailGet, pageIndexGet, parseDepth, redirectParser, richTextAfterReadHook, richTextSerialize, roles, routeChangesPost, 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, withTenants, withText, withTextRequired, withTitle, withTitleRequired, withUIStatic };
1247
+ export { ActionDefault, AfterOptHook, BlockDefaults, BowlArrayField, BowlBlock, BowlBlockField, BowlCollapsibleField, BowlCollection, BowlConfig, BowlField, BowlGlobal, BowlGroup, BowlGroupField, BowlInitOptions, BowlOptions, BowlPlugin, BowlRole, BowlRowField, BowlSlug, BowlTab, BowlTabsField, CategoryDefaults, CategoryMenu, CategoryMenuProps, CategoryTree, CategoryTreeConflictProps, CategoryTreeItem, CategoryTreeItems, CategoryTreeProps, CheckboxDefaults, CollectionDefault, CollectionHelper, CollectionHook, CollectionHookName, CollectionHooks, ColorCell, ColorConfig, ColorField, ComponentsDefaults, CustomEditModal, CustomEditModalProps, DataField, DataTree, DataTreeDragItem, DataTreeInstance, DataTreeItem, DataTreeItemLi, DataTreeItemProps, DataTreeProps, DataTreeProvider, DataTreeRenameItem, DateDefaults, DebugField, DecoratedList, DecoratedListProps, FindOptions, GlobalDefault, GlobalHelper, GlobalHook, GlobalHookName, GlobalHooks, GroupKey, IBulkAction, IBulkRecord, ICache, IImportItem, IPage, IPageFull, IPagination, IRelation, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNavItem, Icon, ImportExportList, ImportExportListProps, ImportExportRedirectList, ImportLogInvalidTypes, ImportLogType, ImportMode, InMemoryCache, InMemoryCacheOptions, KeyMapper, LeaveModal, LeaveWithoutSavingModal, LeaveWithoutSavingModalProps, LocalizedDescription, LocalizedDescriptionProps, Logo, MAX_INT, MarketDefaults, MediaDefaults, MediasDefaults, MenuItem, MixerContext, Option, OrderDefaults, PRESENTATION_FIELDS, PageDefault, PresentationField, PublicURL, Publish, ROOT_ITEM, RelatedDefaults, RichTextDefaults, RouteConflict, Save, SaveDraft, SelectDefaults, StaticCollectionConfig, StaticCollectionDefault, TemplateDefaults, TenantsDefault, TextDefaults, TreeItemData, 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, WithTenants, WithTenantsProps, WithText, WithTextProps, WithTitle, WithTitleProps, afterCategoryChangeHook, afterCategoryDeleteHook, afterCollectionReadHook, afterMenuReadHook, afterPageChangeHook, afterPageDeleteHook, afterPageReadHook, afterReadItem, afterReadItems, afterStaticReadHook, appearanceOptions, beforeDuplicateCollectionHook, beforeValidate, bowl, collectionBulkPatch, collectionExportGet, collectionImportPost, collectionIndexGet, collectionUpdatePatch, debugField, decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateMenuCategory_, decorateMenuGroup_, decorateMenuItem_, decorateMenuLink_, decorateMenuPage_, decorateMenuRoute_, decorateMenu_, decorateNavItem_, decorateNav_, decorateNavs_, decorateSchema_, decorateSchemas_, deepMerge, bowl as default, defaultGroup, defaultLocale, defaultLocales, defaultMarket, defaultSlug, eachDataField, eachField, encryptData, filterRoutes, findCollection, formatSlug, getApiUrl, getCollectionItem, getCollectionItems, getEachMarketLocale, getGlobalItems, getLivePreviewURL, getLocale, getNewCategoriesFromChanges, getNumericParam, getObjectParam, getPages, getPagination, getPreviewURL, getPublicURL, getRoute, getRouteByCategoryAndLocale, getRouteByItemAndLocale, getRoutes, getSearchUrl, getStaticLoader, getStringParam, getSubRequest, getTranslation, getTranslations, getTreeItemClassName, hasMarket, hasRole, importExportListWithParser, internalSlugs, isAdmin, isAdminOrSelf, isDataField, isObject, isPresentationField, isRelation, isRole, isTenant, isUndecoratedNavItem, keyWithRequest, localeGet, localizeCollection, localizeItem, log, logMissingTranslations, menuDetailGet, menuIndexGet, modalSlug, optinGet, options, optoutGet, pageDetailGet, pageIndexGet, parseDepth, redirectParser, richTextAfterReadHook, richTextSerialize, roles, routeChangesPost, 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, withTenants, withText, withTextRequired, withTitle, withTitleRequired, withUIStatic };
package/dist/index.js CHANGED
@@ -287,6 +287,7 @@ __export(src_exports, {
287
287
  eachDataField: () => eachDataField,
288
288
  eachField: () => eachField,
289
289
  encryptData: () => encryptData,
290
+ filterRoutes: () => filterRoutes,
290
291
  findCollection: () => findCollection,
291
292
  formatSlug: () => formatSlug,
292
293
  getApiUrl: () => getApiUrl,
@@ -1137,7 +1138,12 @@ var defaultSlug = {
1137
1138
  page: "page",
1138
1139
  redirect: "redirect",
1139
1140
  template: "template",
1140
- //
1141
+ endUsers: "end_users",
1142
+ endUserCredentials: "end_user_credentials",
1143
+ users: "users",
1144
+ legalNotice: "legal_notice",
1145
+ consentPreference: "consent_preference",
1146
+ // i18n
1141
1147
  continent: "i18n_continent",
1142
1148
  country: "i18n_country",
1143
1149
  countryZone: "i18n_country_zone",
@@ -1145,13 +1151,7 @@ var defaultSlug = {
1145
1151
  municipality: "i18n_municipality",
1146
1152
  province: "i18n_province",
1147
1153
  region: "i18n_region",
1148
- subContinent: "i18n_sub_continent",
1149
- endUsers: "end_users",
1150
- endUserCredentials: "end_user_credentials",
1151
- users: "users",
1152
- legalNotice: "legal_notice",
1153
- consentPreference: "consent_preference",
1154
- newsletterSubscription: "newsletter_subscription"
1154
+ subContinent: "i18n_sub_continent"
1155
1155
  };
1156
1156
  var defaultGroup = {
1157
1157
  content: "content",
@@ -1387,7 +1387,7 @@ function getStringParam(value) {
1387
1387
  }
1388
1388
  __name(getStringParam, "getStringParam");
1389
1389
  function getSubRequest(req) {
1390
- const { transactionID, payload: payload2, user } = req;
1390
+ const { transactionID, payload, user } = req;
1391
1391
  const { where, ...rest } = req.query;
1392
1392
  const subRequest = {
1393
1393
  user,
@@ -1395,7 +1395,7 @@ function getSubRequest(req) {
1395
1395
  query: {
1396
1396
  ...rest
1397
1397
  },
1398
- payload: payload2
1398
+ payload
1399
1399
  };
1400
1400
  return subRequest;
1401
1401
  }
@@ -1413,6 +1413,12 @@ async function setMixerContext(req, market, locale) {
1413
1413
  return context;
1414
1414
  }
1415
1415
  __name(setMixerContext, "setMixerContext");
1416
+ function filterRoutes(routes, market, locale) {
1417
+ market = market === "all" ? options.defaultMarket : market;
1418
+ locale = locale === "all" ? options.defaultLocale : locale;
1419
+ return routes.filter((x) => x.market === market && x.locale === locale);
1420
+ }
1421
+ __name(filterRoutes, "filterRoutes");
1416
1422
 
1417
1423
  // src/core/decorators/localize.ts
1418
1424
  async function localizeItem(item, localizedFields, locale) {
@@ -1710,11 +1716,11 @@ function parseDepth(depth) {
1710
1716
  }
1711
1717
  __name(parseDepth, "parseDepth");
1712
1718
  async function getCollectionItems(req, slug, depth) {
1713
- const { query = {}, payload: payload2, user } = req;
1719
+ const { query = {}, payload, user } = req;
1714
1720
  const { locale, where, sort, draft } = query;
1715
1721
  depth = depth !== void 0 ? depth : parseDepth(query.depth);
1716
1722
  query.depth = String(depth);
1717
- const response = await payload2.find({
1723
+ const response = await payload.find({
1718
1724
  collection: slug,
1719
1725
  draft: draft === "true",
1720
1726
  locale,
@@ -1733,11 +1739,11 @@ async function getCollectionItems(req, slug, depth) {
1733
1739
  }
1734
1740
  __name(getCollectionItems, "getCollectionItems");
1735
1741
  async function getCollectionItem(req, slug, id, depth) {
1736
- const { query = {}, payload: payload2, user } = req;
1742
+ const { query = {}, payload, user } = req;
1737
1743
  const { locale, draft } = query;
1738
1744
  depth = depth !== void 0 ? depth : parseDepth(query.depth);
1739
1745
  query.depth = String(depth);
1740
- const item = await payload2.findByID({
1746
+ const item = await payload.findByID({
1741
1747
  collection: slug,
1742
1748
  id,
1743
1749
  draft: draft === "true",
@@ -1752,11 +1758,11 @@ async function getCollectionItem(req, slug, id, depth) {
1752
1758
  }
1753
1759
  __name(getCollectionItem, "getCollectionItem");
1754
1760
  async function getGlobalItems(req, slug, depth) {
1755
- const { query = {}, payload: payload2, user } = req;
1761
+ const { query = {}, payload, user } = req;
1756
1762
  const { locale, draft } = query;
1757
1763
  depth = depth !== void 0 ? depth : parseDepth(query.depth);
1758
1764
  query.depth = String(depth);
1759
- const response = await payload2.findGlobal({
1765
+ const response = await payload.findGlobal({
1760
1766
  slug,
1761
1767
  depth,
1762
1768
  locale,
@@ -1813,8 +1819,8 @@ var collectionBulkPatch = /* @__PURE__ */ __name((slug) => ({
1813
1819
  path: "/bulk",
1814
1820
  method: "patch",
1815
1821
  handler: async (req, res, next) => {
1816
- const { payload: payload2 } = req;
1817
- const adapter = payload2.db;
1822
+ const { payload } = req;
1823
+ const adapter = payload.db;
1818
1824
  const model = adapter.collections[slug];
1819
1825
  if (!model) {
1820
1826
  return next();
@@ -1871,8 +1877,8 @@ var collectionUpdatePatch = /* @__PURE__ */ __name((slug) => ({
1871
1877
  path: "/update",
1872
1878
  method: "patch",
1873
1879
  handler: async (req, res, next) => {
1874
- const { collection, user, payload: payload2 } = req;
1875
- const adapter = payload2.db;
1880
+ const { collection, user, payload } = req;
1881
+ const adapter = payload.db;
1876
1882
  const model = adapter.collections[slug];
1877
1883
  if (!model) {
1878
1884
  return next();
@@ -1958,13 +1964,13 @@ var collectionImportPost = /* @__PURE__ */ __name((slug) => ({
1958
1964
  path: "/import",
1959
1965
  method: "post",
1960
1966
  handler: async (req, res, next) => {
1961
- const { url, query, params, payload: payload2, user } = req;
1967
+ const { url, query, params, payload, user } = req;
1962
1968
  const { locale, where, sort, depth, draft, page, limit, pagination, mode } = query;
1963
1969
  const importMode = mode || "append" /* Append */;
1964
- const defaultLocale2 = payload2.config.localization ? payload2.config.localization.defaultLocale : "en";
1970
+ const defaultLocale2 = payload.config.localization ? payload.config.localization.defaultLocale : "en";
1965
1971
  try {
1966
1972
  const deleteItems = /* @__PURE__ */ __name(async () => {
1967
- return await payload2.delete({
1973
+ return await payload.delete({
1968
1974
  collection: slug,
1969
1975
  where: {
1970
1976
  id: {
@@ -1981,7 +1987,7 @@ var collectionImportPost = /* @__PURE__ */ __name((slug) => ({
1981
1987
  });
1982
1988
  }, "deleteItems");
1983
1989
  const insertItem = /* @__PURE__ */ __name(async (item) => {
1984
- return await payload2.create({
1990
+ return await payload.create({
1985
1991
  collection: slug,
1986
1992
  data: item,
1987
1993
  locale,
@@ -1992,7 +1998,7 @@ var collectionImportPost = /* @__PURE__ */ __name((slug) => ({
1992
1998
  });
1993
1999
  }, "insertItem");
1994
2000
  const updateItem = /* @__PURE__ */ __name(async (item) => {
1995
- return await payload2.update({
2001
+ return await payload.update({
1996
2002
  collection: slug,
1997
2003
  data: item,
1998
2004
  id: item.id,
@@ -2101,9 +2107,10 @@ async function getRoutes(req) {
2101
2107
  let locales2 = await getGlobalItems(subRequest, options.slug.locale, 0);
2102
2108
  locales2 = locales2 ? locales2.filter((x) => x.isActive) : [];
2103
2109
  if (locales2.length > 0 && markets.length > 0) {
2104
- const categories = await getCollectionItems(unlocalizedRequest, options.slug.category, 1);
2105
2110
  const store = await getPages(unlocalizedRequest);
2106
- routes = (0, import_bom_core2.collectRoutes)(store, categories, markets, locales2);
2111
+ const categories = await getCollectionItems(unlocalizedRequest, options.slug.category, 1);
2112
+ const medias = await getCollectionItems(unlocalizedRequest, options.slug.media, 1);
2113
+ routes = (0, import_bom_core2.collectRoutes)(store, categories, markets, locales2, medias);
2107
2114
  }
2108
2115
  CACHE_.set(key, routes);
2109
2116
  return routes;
@@ -2320,8 +2327,8 @@ async function routePostHandler(request, response, next) {
2320
2327
  const url = new URL(href);
2321
2328
  const urlBeforeRedirect = hrefBeforeRedirect ? new URL(hrefBeforeRedirect) : null;
2322
2329
  const sanitizedHref = sanitizeHref(url, urlBeforeRedirect);
2323
- const { payload: payload2 } = request;
2324
- const payloadResponse = await payload2.find({
2330
+ const { payload } = request;
2331
+ const payloadResponse = await payload.find({
2325
2332
  collection: options.slug.redirect,
2326
2333
  where: {
2327
2334
  isActive: {
@@ -2434,14 +2441,14 @@ async function collectPageRedirects(req, previousItem, newItem) {
2434
2441
  const collectedRedirects = [];
2435
2442
  const isProduction = (0, import_bom_core3.getIsProduction)();
2436
2443
  if (isProduction) {
2437
- const { query = {}, collection, payload: payload2, user } = req;
2444
+ const { query = {}, collection, payload, user } = req;
2438
2445
  const { locale } = query;
2439
2446
  const slug = collection.config.slug;
2440
2447
  const previousRoutes = await getRouteByItemAndLocale(req, previousItem, locale, slug);
2441
2448
  const routes = await getRouteByItemAndLocale(req, newItem, locale, slug);
2442
- const defaultLocale2 = payload2.config.localization ? payload2.config.localization.defaultLocale : "en";
2449
+ const defaultLocale2 = payload.config.localization ? payload.config.localization.defaultLocale : "en";
2443
2450
  const insertItem = /* @__PURE__ */ __name(async (item) => {
2444
- return await payload2.create({
2451
+ return await payload.create({
2445
2452
  collection: options.slug.redirect,
2446
2453
  data: item,
2447
2454
  locale,
@@ -2477,14 +2484,14 @@ async function collectCategoryRedirects(req, previousItem, newItem) {
2477
2484
  const collectedRedirects = [];
2478
2485
  const isProduction = (0, import_bom_core3.getIsProduction)();
2479
2486
  if (isProduction) {
2480
- const { query = {}, collection, payload: payload2, user } = req;
2487
+ const { query = {}, collection, payload, user } = req;
2481
2488
  const { locale } = query;
2482
2489
  const slug = collection.config.slug;
2483
2490
  const previousRoutes = await getRouteByCategoryAndLocale(req, previousItem, locale, slug);
2484
2491
  const routes = await getRouteByCategoryAndLocale(req, newItem, locale, collection.config.slug);
2485
- const defaultLocale2 = payload2.config.localization ? payload2.config.localization.defaultLocale : "en";
2492
+ const defaultLocale2 = payload.config.localization ? payload.config.localization.defaultLocale : "en";
2486
2493
  const insertItem = /* @__PURE__ */ __name(async (item) => {
2487
- return await payload2.create({
2494
+ return await payload.create({
2488
2495
  collection: options.slug.redirect,
2489
2496
  data: item,
2490
2497
  locale,
@@ -2589,12 +2596,12 @@ var EventEmitter = class {
2589
2596
  get numberOfHandlers() {
2590
2597
  return this.handlers.filter((h) => !!h).length;
2591
2598
  }
2592
- async emit(payload2) {
2599
+ async emit(payload) {
2593
2600
  const promises = [];
2594
- this.options?.logger?.("emit", payload2);
2601
+ this.options?.logger?.("emit", payload);
2595
2602
  for (const handler of this.handlers) {
2596
2603
  if (handler) {
2597
- const res = handler(payload2);
2604
+ const res = handler(payload);
2598
2605
  if (typeof res?.then === "function") {
2599
2606
  promises.push(res);
2600
2607
  }
@@ -2644,7 +2651,7 @@ var DataTreeProvider = class {
2644
2651
  }
2645
2652
  }
2646
2653
  onDidChangeTreeData(callback) {
2647
- const handlerId = this.onDidChangeTreeDataEmitter.on((payload2) => callback(payload2));
2654
+ const handlerId = this.onDidChangeTreeDataEmitter.on((payload) => callback(payload));
2648
2655
  return {
2649
2656
  dispose: () => this.onDidChangeTreeDataEmitter.off(handlerId)
2650
2657
  };
@@ -3060,13 +3067,13 @@ var CategoryTree = /* @__PURE__ */ __name((props) => {
3060
3067
  return;
3061
3068
  }
3062
3069
  const getPostData = /* @__PURE__ */ __name((changes2) => {
3063
- const payload2 = Object.fromEntries(
3070
+ const payload = Object.fromEntries(
3064
3071
  Object.entries(changes2).map(([k, v]) => [k, {
3065
3072
  index: v.index,
3066
3073
  children: v.children
3067
3074
  }])
3068
3075
  );
3069
- return payload2;
3076
+ return payload;
3070
3077
  }, "getPostData");
3071
3078
  const getRoutes2 = /* @__PURE__ */ __name(async () => {
3072
3079
  try {
@@ -3775,11 +3782,11 @@ var isAdminOrSelf = /* @__PURE__ */ __name(({ req: { user } }) => {
3775
3782
  }
3776
3783
  };
3777
3784
  }, "isAdminOrSelf");
3778
- var isTenant = /* @__PURE__ */ __name((slug) => ({ req: { user, payload: payload2 } }) => {
3785
+ var isTenant = /* @__PURE__ */ __name((slug) => ({ req: { user, payload } }) => {
3779
3786
  if (!isUserWithTenants(user)) {
3780
3787
  return false;
3781
3788
  }
3782
- const userCollection = payload2.config.collections.find((x) => x.slug === user.collection);
3789
+ const userCollection = payload.config.collections.find((x) => x.slug === user.collection);
3783
3790
  const tenantsField = userCollection.fields.find((x) => x.type === "relationship" && x.name === "tenants");
3784
3791
  const tenantCollections = [].concat(tenantsField.relationTo);
3785
3792
  const isPolymorphicRel = Array.isArray(tenantsField.relationTo);
@@ -3792,7 +3799,7 @@ var isTenant = /* @__PURE__ */ __name((slug) => ({ req: { user, payload: payload
3792
3799
  };
3793
3800
  return query2;
3794
3801
  }
3795
- const collectionConfig = payload2.config.collections.find((x) => x.slug === slug);
3802
+ const collectionConfig = payload.config.collections.find((x) => x.slug === slug);
3796
3803
  const fields = collectionConfig.fields.filter((field) => field.type === "relationship" && tenantCollections.find((x) => field.relationTo.includes(x)) !== void 0);
3797
3804
  if (!fields.length) {
3798
3805
  return false;
@@ -3832,9 +3839,6 @@ var isTenant = /* @__PURE__ */ __name((slug) => ({ req: { user, payload: payload
3832
3839
  return query;
3833
3840
  }, "isTenant");
3834
3841
 
3835
- // src/core/api/action.service.ts
3836
- var import_payload = __toESM(require("payload"));
3837
-
3838
3842
  // src/core/utils/deepMerge.ts
3839
3843
  function isObject(item) {
3840
3844
  return item && typeof item === "object" && !Array.isArray(item);
@@ -3972,41 +3976,58 @@ function sortByGroup(collectionsOrGlobals) {
3972
3976
  __name(sortByGroup, "sortByGroup");
3973
3977
 
3974
3978
  // src/core/api/action.service.ts
3975
- var optout = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
3976
- const action = await import_payload.default.findByID({
3979
+ var optout = /* @__PURE__ */ __name(async (req) => {
3980
+ const { payload } = req;
3981
+ const actionId = req.params.id;
3982
+ const actionSlug = req.params.slug;
3983
+ const action = await payload.findByID({
3977
3984
  collection: actionSlug,
3978
3985
  id: actionId
3979
3986
  });
3980
3987
  const { endUser, consentPreferences } = action;
3988
+ const config = payload.collections[actionSlug].config;
3981
3989
  if (endUser) {
3982
- const data = {
3990
+ const data2 = {
3983
3991
  consentPreferences: endUser.consentPreferences?.filter((x) => !consentPreferences.map((y) => y.id).includes(x.consentPreference.id)).map((x) => ({
3984
3992
  consentPreference: x.consentPreference.id,
3985
3993
  date: x.date
3986
3994
  })) ?? []
3987
3995
  };
3988
- await import_payload.default.update({
3996
+ await payload.update({
3989
3997
  collection: options.slug.endUsers,
3990
3998
  id: endUser.id,
3991
- data
3999
+ data: data2
3992
4000
  });
3993
4001
  }
3994
- await import_payload.default.update({
4002
+ const data = {
4003
+ consentsRevoked: true,
4004
+ consentsRevokedDate: /* @__PURE__ */ new Date()
4005
+ };
4006
+ await payload.update({
3995
4007
  collection: actionSlug,
3996
4008
  id: actionId,
3997
- data: {
3998
- consentsRevoked: true,
3999
- consentsRevokedDate: /* @__PURE__ */ new Date()
4000
- }
4009
+ data
4001
4010
  });
4011
+ if (typeof config.custom?.afterOptout === "function") {
4012
+ await config.custom.afterOptout({
4013
+ collection: config,
4014
+ doc: { ...action, ...data },
4015
+ previousDoc: action,
4016
+ req
4017
+ });
4018
+ }
4002
4019
  }, "optout");
4003
- var optin = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
4004
- const action = await import_payload.default.findByID({
4020
+ var optin = /* @__PURE__ */ __name(async (req) => {
4021
+ const { payload } = req;
4022
+ const actionId = req.params.id;
4023
+ const actionSlug = req.params.slug;
4024
+ const action = await payload.findByID({
4005
4025
  collection: actionSlug,
4006
4026
  id: actionId
4007
4027
  });
4008
4028
  const { email, password, consentPreferences } = action;
4009
- const config = import_payload.default.collections[actionSlug].config;
4029
+ const config = payload.collections[actionSlug].config;
4030
+ let data = { endUser: void 0 };
4010
4031
  if (config.custom?.updateEndUser) {
4011
4032
  const updateFields = config.fields.filter((field) => field.custom?.updateEndUser);
4012
4033
  const actionData = updateFields.reduce((acc, field) => {
@@ -4015,7 +4036,7 @@ var optin = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
4015
4036
  }
4016
4037
  return acc;
4017
4038
  }, {});
4018
- const { docs: endUsers } = await import_payload.default.find({
4039
+ const { docs: endUsers } = await payload.find({
4019
4040
  collection: options.slug.endUsers,
4020
4041
  where: {
4021
4042
  email: { equals: email }
@@ -4041,7 +4062,7 @@ var optin = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
4041
4062
  });
4042
4063
  }
4043
4064
  });
4044
- endUser = await import_payload.default.update({
4065
+ endUser = await payload.update({
4045
4066
  collection: options.slug.endUsers,
4046
4067
  id: endUser.id,
4047
4068
  data: actionData
@@ -4051,40 +4072,47 @@ var optin = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
4051
4072
  consentPreference: actionConsent.id,
4052
4073
  date: /* @__PURE__ */ new Date()
4053
4074
  }));
4054
- endUser = await import_payload.default.create({
4075
+ endUser = await payload.create({
4055
4076
  collection: options.slug.endUsers,
4056
4077
  data: { email, ...actionData }
4057
4078
  });
4058
4079
  }
4059
- await import_payload.default.update({
4080
+ data.endUser = endUser.id;
4081
+ await payload.update({
4060
4082
  collection: actionSlug,
4061
4083
  id: actionId,
4062
- data: {
4063
- endUser: endUser.id
4064
- }
4084
+ data
4065
4085
  });
4066
4086
  if (config.custom.createCredentials) {
4067
- const { docs: userCredentials } = await import_payload.default.find({
4087
+ const { docs: userCredentials } = await payload.find({
4068
4088
  collection: options.slug.endUserCredentials,
4069
4089
  where: {
4070
4090
  email: { equals: email }
4071
4091
  }
4072
4092
  });
4073
4093
  if (userCredentials.length === 0) {
4074
- await import_payload.default.create({
4094
+ await payload.create({
4075
4095
  collection: options.slug.endUserCredentials,
4076
4096
  data: { email, password, endUser: endUser.id, ...actionData }
4077
4097
  });
4078
4098
  }
4079
4099
  }
4080
4100
  }
4101
+ if (typeof config.custom?.afterOptin === "function") {
4102
+ await config.custom.afterOptin({
4103
+ collection: config,
4104
+ doc: action,
4105
+ previousDoc: { ...action, ...data },
4106
+ req
4107
+ });
4108
+ }
4081
4109
  }, "optin");
4082
4110
  var optinGet = {
4083
4111
  path: "/actions/optin/:id/:slug",
4084
4112
  method: "get",
4085
4113
  handler: async (req, res, next) => {
4086
4114
  try {
4087
- await optin(req.params.id, req.params.slug);
4115
+ await optin(req);
4088
4116
  return res.status(200).send({ status: 200, message: "optin success" });
4089
4117
  } catch (error) {
4090
4118
  console.error("ActionService.optinGet.error", error);
@@ -4101,7 +4129,7 @@ var optoutGet = {
4101
4129
  method: "get",
4102
4130
  handler: async (req, res, next) => {
4103
4131
  try {
4104
- await optout(req.params.id, req.params.slug);
4132
+ await optout(req);
4105
4133
  return res.status(200).send({ status: 200, message: "optout success" });
4106
4134
  } catch (error) {
4107
4135
  console.error("ActionService.optoutGet.error", error);
@@ -4177,9 +4205,7 @@ async function decorateCategory_(item, slug, context) {
4177
4205
  __name(decorateCategory_, "decorateCategory_");
4178
4206
  async function decorateCategories_(items, slug, context) {
4179
4207
  const { market, locale } = context;
4180
- const routes = context.routes.filter(
4181
- (x) => x.market === market && x.locale === locale
4182
- );
4208
+ const routes = filterRoutes(context.routes, market, locale);
4183
4209
  return items.map((item) => {
4184
4210
  const category = item.category;
4185
4211
  if ((0, import_bom_core6.isObject)(category) && !category.href) {
@@ -4359,13 +4385,22 @@ function decorateMenuPage_(item, categories, routes, market) {
4359
4385
  id: item.id,
4360
4386
  href: route?.id,
4361
4387
  page: route ? route.page : page.id,
4362
- title: item.customTitle || (route ? route.title : page.title),
4363
- media: item.media || (route ? route.media : page.media),
4364
- abstract: item.abstract,
4365
- customClass: item.customClass,
4366
- extra: item.extra,
4388
+ title: item.customTitle || page.title || route?.title,
4367
4389
  items: item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, routes, market))
4368
4390
  };
4391
+ if (item.abstract) {
4392
+ decoratedItem.abstract = item.abstract;
4393
+ }
4394
+ if (item.extra) {
4395
+ decoratedItem.extra = item.extra;
4396
+ }
4397
+ if (item.customClass) {
4398
+ decoratedItem.customClass = item.customClass;
4399
+ }
4400
+ const media = item.media || page.media || route?.media;
4401
+ if (media) {
4402
+ decoratedItem.media = media;
4403
+ }
4369
4404
  return decoratedItem;
4370
4405
  }
4371
4406
  __name(decorateMenuPage_, "decorateMenuPage_");
@@ -4438,7 +4473,7 @@ async function decorateMenu_(item, context) {
4438
4473
  if (!markets.includes(market) && market !== "all") {
4439
4474
  return decoratedItem;
4440
4475
  }
4441
- const filteredRoutes = routes.filter((x) => x.market === market && x.locale === locale);
4476
+ const filteredRoutes = filterRoutes(routes, market, locale);
4442
4477
  decoratedItem.items = item.items.filter((x) => hasMarket(x, market)).map((x) => decorateMenuItem_(x, categories, filteredRoutes, market));
4443
4478
  return decoratedItem;
4444
4479
  }
@@ -4798,8 +4833,8 @@ async function findCollection(req, collection, options2) {
4798
4833
  }
4799
4834
  __name(findCollection, "findCollection");
4800
4835
  function getApiUrl(req) {
4801
- const { payload: payload2 } = req;
4802
- const { config } = payload2;
4836
+ const { payload } = req;
4837
+ const { config } = payload;
4803
4838
  const port = process.env.PORT || 4e3;
4804
4839
  const origin = `http://localhost:${port}`;
4805
4840
  let url = `${origin}${config.routes.api}/`;
@@ -7221,17 +7256,6 @@ var Locale = /* @__PURE__ */ __name((options2) => ({
7221
7256
  ]
7222
7257
  }), "Locale");
7223
7258
 
7224
- // src/core/fields/withNewsletterSubscription.ts
7225
- var NewsletterSubscriptionDefaults = {
7226
- name: "newsletter_subscription",
7227
- type: "relationship",
7228
- relationTo: options.slug.newsletterSubscription
7229
- };
7230
- var withNewsletterSubscription = /* @__PURE__ */ __name((options2 = {}) => {
7231
- const field = deepMerge(NewsletterSubscriptionDefaults, options2);
7232
- return field;
7233
- }, "withNewsletterSubscription");
7234
-
7235
7259
  // src/fields/color-picker/ColorCell.tsx
7236
7260
  var import_jsx_runtime15 = require("react/jsx-runtime");
7237
7261
  var ColorCell = /* @__PURE__ */ __name((props) => {
@@ -7559,9 +7583,6 @@ function toField(item) {
7559
7583
  case "withName":
7560
7584
  delete item.type;
7561
7585
  return withName(item);
7562
- case "withNewsletterSubscription":
7563
- delete item.type;
7564
- return withNewsletterSubscription(item);
7565
7586
  case "withOrder":
7566
7587
  delete item.type;
7567
7588
  return withOrder(item);
@@ -7989,6 +8010,7 @@ var src_default = bowl;
7989
8010
  eachDataField,
7990
8011
  eachField,
7991
8012
  encryptData,
8013
+ filterRoutes,
7992
8014
  findCollection,
7993
8015
  formatSlug,
7994
8016
  getApiUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/payload-plugin-bowl",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "Bowl PayloadCms plugin of the BOM Repository",
5
5
  "keywords": [
6
6
  "payload",