@websolutespa/payload-plugin-bowl 1.8.2 → 1.8.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,11 @@
1
1
  # @websolutespa/payload-plugin-bowl
2
2
 
3
+ ## 1.8.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 5ad32d3: Added afterOptin and afterOptout hooks
8
+
3
9
  ## 1.8.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -505,12 +505,20 @@ declare function whereCollection<T = IEntity>(items: T[], where?: {
505
505
  }): Promise<T[]>;
506
506
  declare function sortCollection<T = IEntity>(items: T[], sort?: string): Promise<T[]>;
507
507
 
508
+ type AfterOptHook<T extends TypeWithID = any> = (args: {
509
+ collection: SanitizedCollectionConfig;
510
+ doc: T;
511
+ previousDoc: T;
512
+ req: PayloadRequest;
513
+ }) => any;
508
514
  type WithActionProps = (Omit<CollectionConfig, 'fields'> & {
509
515
  fields: BowlField[];
510
516
  views?: Record<string, AdminView>;
511
517
  custom?: {
512
518
  updateEndUser?: boolean;
513
519
  createCredentials?: boolean;
520
+ afterOptin?: AfterOptHook;
521
+ afterOptout?: AfterOptHook;
514
522
  [key: string]: unknown;
515
523
  };
516
524
  });
@@ -776,6 +784,8 @@ declare const withLink: ({ appearances, disableLabel, ...props }?: WithLinkProps
776
784
  condition?: payload_types.Condition<any, any>;
777
785
  description?: payload_dist_admin_components_forms_FieldDescription_types.Description;
778
786
  disableBulkEdit?: boolean;
787
+ disableListColumn?: boolean;
788
+ disableListFilter?: boolean;
779
789
  disabled?: boolean;
780
790
  hidden?: boolean;
781
791
  position?: "sidebar";
@@ -1021,13 +1031,6 @@ type GroupKey = {
1021
1031
  };
1022
1032
  declare function sortByGroup<T extends (CollectionConfig | GlobalConfig) = CollectionConfig | GlobalConfig>(collectionsOrGlobals: T[]): T[];
1023
1033
 
1024
- type WithNewsletterSubscriptionProps = (Omit<RelationshipField, 'type' | 'name' | 'relationTo'> & {
1025
- name?: string;
1026
- });
1027
- type WithNewsletterSubscription = WithNewsletterSubscriptionProps & {
1028
- type: 'withNewsletterSubscription';
1029
- };
1030
-
1031
1034
  type WithColorProps = (Omit<TextField, 'type' | 'name' | 'hasMany'> & {
1032
1035
  name?: string;
1033
1036
  });
@@ -1122,7 +1125,7 @@ type BowlRowField = Omit<RowField, 'fields'> & {
1122
1125
  type BowlTabsField = Omit<TabsField, 'tabs'> & {
1123
1126
  tabs: BowlTab[];
1124
1127
  };
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;
1128
+ 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
1129
  type BowlBlock = Block | WithBlock;
1127
1130
  type BowlCollection = WithCollection | WithPage | WithStatic | WithMenu | WithAction | CollectionConfig & {
1128
1131
  type?: string;
@@ -1150,7 +1153,6 @@ type BowlSlug = {
1150
1153
  template: string;
1151
1154
  legalNotice: string;
1152
1155
  consentPreference: string;
1153
- newsletterSubscription: string;
1154
1156
  users: string;
1155
1157
  endUsers: string;
1156
1158
  endUserCredentials: string;
@@ -1241,4 +1243,4 @@ declare const Logo: React__default.FC;
1241
1243
 
1242
1244
  declare function webpack(sourceConfig: BowlConfig): (config: any) => any;
1243
1245
 
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 };
1246
+ 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, 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
@@ -1137,7 +1137,12 @@ var defaultSlug = {
1137
1137
  page: "page",
1138
1138
  redirect: "redirect",
1139
1139
  template: "template",
1140
- //
1140
+ endUsers: "end_users",
1141
+ endUserCredentials: "end_user_credentials",
1142
+ users: "users",
1143
+ legalNotice: "legal_notice",
1144
+ consentPreference: "consent_preference",
1145
+ // i18n
1141
1146
  continent: "i18n_continent",
1142
1147
  country: "i18n_country",
1143
1148
  countryZone: "i18n_country_zone",
@@ -1145,13 +1150,7 @@ var defaultSlug = {
1145
1150
  municipality: "i18n_municipality",
1146
1151
  province: "i18n_province",
1147
1152
  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"
1153
+ subContinent: "i18n_sub_continent"
1155
1154
  };
1156
1155
  var defaultGroup = {
1157
1156
  content: "content",
@@ -1387,7 +1386,7 @@ function getStringParam(value) {
1387
1386
  }
1388
1387
  __name(getStringParam, "getStringParam");
1389
1388
  function getSubRequest(req) {
1390
- const { transactionID, payload: payload2, user } = req;
1389
+ const { transactionID, payload, user } = req;
1391
1390
  const { where, ...rest } = req.query;
1392
1391
  const subRequest = {
1393
1392
  user,
@@ -1395,7 +1394,7 @@ function getSubRequest(req) {
1395
1394
  query: {
1396
1395
  ...rest
1397
1396
  },
1398
- payload: payload2
1397
+ payload
1399
1398
  };
1400
1399
  return subRequest;
1401
1400
  }
@@ -1710,11 +1709,11 @@ function parseDepth(depth) {
1710
1709
  }
1711
1710
  __name(parseDepth, "parseDepth");
1712
1711
  async function getCollectionItems(req, slug, depth) {
1713
- const { query = {}, payload: payload2, user } = req;
1712
+ const { query = {}, payload, user } = req;
1714
1713
  const { locale, where, sort, draft } = query;
1715
1714
  depth = depth !== void 0 ? depth : parseDepth(query.depth);
1716
1715
  query.depth = String(depth);
1717
- const response = await payload2.find({
1716
+ const response = await payload.find({
1718
1717
  collection: slug,
1719
1718
  draft: draft === "true",
1720
1719
  locale,
@@ -1733,11 +1732,11 @@ async function getCollectionItems(req, slug, depth) {
1733
1732
  }
1734
1733
  __name(getCollectionItems, "getCollectionItems");
1735
1734
  async function getCollectionItem(req, slug, id, depth) {
1736
- const { query = {}, payload: payload2, user } = req;
1735
+ const { query = {}, payload, user } = req;
1737
1736
  const { locale, draft } = query;
1738
1737
  depth = depth !== void 0 ? depth : parseDepth(query.depth);
1739
1738
  query.depth = String(depth);
1740
- const item = await payload2.findByID({
1739
+ const item = await payload.findByID({
1741
1740
  collection: slug,
1742
1741
  id,
1743
1742
  draft: draft === "true",
@@ -1752,11 +1751,11 @@ async function getCollectionItem(req, slug, id, depth) {
1752
1751
  }
1753
1752
  __name(getCollectionItem, "getCollectionItem");
1754
1753
  async function getGlobalItems(req, slug, depth) {
1755
- const { query = {}, payload: payload2, user } = req;
1754
+ const { query = {}, payload, user } = req;
1756
1755
  const { locale, draft } = query;
1757
1756
  depth = depth !== void 0 ? depth : parseDepth(query.depth);
1758
1757
  query.depth = String(depth);
1759
- const response = await payload2.findGlobal({
1758
+ const response = await payload.findGlobal({
1760
1759
  slug,
1761
1760
  depth,
1762
1761
  locale,
@@ -1813,8 +1812,8 @@ var collectionBulkPatch = /* @__PURE__ */ __name((slug) => ({
1813
1812
  path: "/bulk",
1814
1813
  method: "patch",
1815
1814
  handler: async (req, res, next) => {
1816
- const { payload: payload2 } = req;
1817
- const adapter = payload2.db;
1815
+ const { payload } = req;
1816
+ const adapter = payload.db;
1818
1817
  const model = adapter.collections[slug];
1819
1818
  if (!model) {
1820
1819
  return next();
@@ -1871,8 +1870,8 @@ var collectionUpdatePatch = /* @__PURE__ */ __name((slug) => ({
1871
1870
  path: "/update",
1872
1871
  method: "patch",
1873
1872
  handler: async (req, res, next) => {
1874
- const { collection, user, payload: payload2 } = req;
1875
- const adapter = payload2.db;
1873
+ const { collection, user, payload } = req;
1874
+ const adapter = payload.db;
1876
1875
  const model = adapter.collections[slug];
1877
1876
  if (!model) {
1878
1877
  return next();
@@ -1958,13 +1957,13 @@ var collectionImportPost = /* @__PURE__ */ __name((slug) => ({
1958
1957
  path: "/import",
1959
1958
  method: "post",
1960
1959
  handler: async (req, res, next) => {
1961
- const { url, query, params, payload: payload2, user } = req;
1960
+ const { url, query, params, payload, user } = req;
1962
1961
  const { locale, where, sort, depth, draft, page, limit, pagination, mode } = query;
1963
1962
  const importMode = mode || "append" /* Append */;
1964
- const defaultLocale2 = payload2.config.localization ? payload2.config.localization.defaultLocale : "en";
1963
+ const defaultLocale2 = payload.config.localization ? payload.config.localization.defaultLocale : "en";
1965
1964
  try {
1966
1965
  const deleteItems = /* @__PURE__ */ __name(async () => {
1967
- return await payload2.delete({
1966
+ return await payload.delete({
1968
1967
  collection: slug,
1969
1968
  where: {
1970
1969
  id: {
@@ -1981,7 +1980,7 @@ var collectionImportPost = /* @__PURE__ */ __name((slug) => ({
1981
1980
  });
1982
1981
  }, "deleteItems");
1983
1982
  const insertItem = /* @__PURE__ */ __name(async (item) => {
1984
- return await payload2.create({
1983
+ return await payload.create({
1985
1984
  collection: slug,
1986
1985
  data: item,
1987
1986
  locale,
@@ -1992,7 +1991,7 @@ var collectionImportPost = /* @__PURE__ */ __name((slug) => ({
1992
1991
  });
1993
1992
  }, "insertItem");
1994
1993
  const updateItem = /* @__PURE__ */ __name(async (item) => {
1995
- return await payload2.update({
1994
+ return await payload.update({
1996
1995
  collection: slug,
1997
1996
  data: item,
1998
1997
  id: item.id,
@@ -2320,8 +2319,8 @@ async function routePostHandler(request, response, next) {
2320
2319
  const url = new URL(href);
2321
2320
  const urlBeforeRedirect = hrefBeforeRedirect ? new URL(hrefBeforeRedirect) : null;
2322
2321
  const sanitizedHref = sanitizeHref(url, urlBeforeRedirect);
2323
- const { payload: payload2 } = request;
2324
- const payloadResponse = await payload2.find({
2322
+ const { payload } = request;
2323
+ const payloadResponse = await payload.find({
2325
2324
  collection: options.slug.redirect,
2326
2325
  where: {
2327
2326
  isActive: {
@@ -2434,14 +2433,14 @@ async function collectPageRedirects(req, previousItem, newItem) {
2434
2433
  const collectedRedirects = [];
2435
2434
  const isProduction = (0, import_bom_core3.getIsProduction)();
2436
2435
  if (isProduction) {
2437
- const { query = {}, collection, payload: payload2, user } = req;
2436
+ const { query = {}, collection, payload, user } = req;
2438
2437
  const { locale } = query;
2439
2438
  const slug = collection.config.slug;
2440
2439
  const previousRoutes = await getRouteByItemAndLocale(req, previousItem, locale, slug);
2441
2440
  const routes = await getRouteByItemAndLocale(req, newItem, locale, slug);
2442
- const defaultLocale2 = payload2.config.localization ? payload2.config.localization.defaultLocale : "en";
2441
+ const defaultLocale2 = payload.config.localization ? payload.config.localization.defaultLocale : "en";
2443
2442
  const insertItem = /* @__PURE__ */ __name(async (item) => {
2444
- return await payload2.create({
2443
+ return await payload.create({
2445
2444
  collection: options.slug.redirect,
2446
2445
  data: item,
2447
2446
  locale,
@@ -2477,14 +2476,14 @@ async function collectCategoryRedirects(req, previousItem, newItem) {
2477
2476
  const collectedRedirects = [];
2478
2477
  const isProduction = (0, import_bom_core3.getIsProduction)();
2479
2478
  if (isProduction) {
2480
- const { query = {}, collection, payload: payload2, user } = req;
2479
+ const { query = {}, collection, payload, user } = req;
2481
2480
  const { locale } = query;
2482
2481
  const slug = collection.config.slug;
2483
2482
  const previousRoutes = await getRouteByCategoryAndLocale(req, previousItem, locale, slug);
2484
2483
  const routes = await getRouteByCategoryAndLocale(req, newItem, locale, collection.config.slug);
2485
- const defaultLocale2 = payload2.config.localization ? payload2.config.localization.defaultLocale : "en";
2484
+ const defaultLocale2 = payload.config.localization ? payload.config.localization.defaultLocale : "en";
2486
2485
  const insertItem = /* @__PURE__ */ __name(async (item) => {
2487
- return await payload2.create({
2486
+ return await payload.create({
2488
2487
  collection: options.slug.redirect,
2489
2488
  data: item,
2490
2489
  locale,
@@ -2589,12 +2588,12 @@ var EventEmitter = class {
2589
2588
  get numberOfHandlers() {
2590
2589
  return this.handlers.filter((h) => !!h).length;
2591
2590
  }
2592
- async emit(payload2) {
2591
+ async emit(payload) {
2593
2592
  const promises = [];
2594
- this.options?.logger?.("emit", payload2);
2593
+ this.options?.logger?.("emit", payload);
2595
2594
  for (const handler of this.handlers) {
2596
2595
  if (handler) {
2597
- const res = handler(payload2);
2596
+ const res = handler(payload);
2598
2597
  if (typeof res?.then === "function") {
2599
2598
  promises.push(res);
2600
2599
  }
@@ -2644,7 +2643,7 @@ var DataTreeProvider = class {
2644
2643
  }
2645
2644
  }
2646
2645
  onDidChangeTreeData(callback) {
2647
- const handlerId = this.onDidChangeTreeDataEmitter.on((payload2) => callback(payload2));
2646
+ const handlerId = this.onDidChangeTreeDataEmitter.on((payload) => callback(payload));
2648
2647
  return {
2649
2648
  dispose: () => this.onDidChangeTreeDataEmitter.off(handlerId)
2650
2649
  };
@@ -3060,13 +3059,13 @@ var CategoryTree = /* @__PURE__ */ __name((props) => {
3060
3059
  return;
3061
3060
  }
3062
3061
  const getPostData = /* @__PURE__ */ __name((changes2) => {
3063
- const payload2 = Object.fromEntries(
3062
+ const payload = Object.fromEntries(
3064
3063
  Object.entries(changes2).map(([k, v]) => [k, {
3065
3064
  index: v.index,
3066
3065
  children: v.children
3067
3066
  }])
3068
3067
  );
3069
- return payload2;
3068
+ return payload;
3070
3069
  }, "getPostData");
3071
3070
  const getRoutes2 = /* @__PURE__ */ __name(async () => {
3072
3071
  try {
@@ -3775,11 +3774,11 @@ var isAdminOrSelf = /* @__PURE__ */ __name(({ req: { user } }) => {
3775
3774
  }
3776
3775
  };
3777
3776
  }, "isAdminOrSelf");
3778
- var isTenant = /* @__PURE__ */ __name((slug) => ({ req: { user, payload: payload2 } }) => {
3777
+ var isTenant = /* @__PURE__ */ __name((slug) => ({ req: { user, payload } }) => {
3779
3778
  if (!isUserWithTenants(user)) {
3780
3779
  return false;
3781
3780
  }
3782
- const userCollection = payload2.config.collections.find((x) => x.slug === user.collection);
3781
+ const userCollection = payload.config.collections.find((x) => x.slug === user.collection);
3783
3782
  const tenantsField = userCollection.fields.find((x) => x.type === "relationship" && x.name === "tenants");
3784
3783
  const tenantCollections = [].concat(tenantsField.relationTo);
3785
3784
  const isPolymorphicRel = Array.isArray(tenantsField.relationTo);
@@ -3792,7 +3791,7 @@ var isTenant = /* @__PURE__ */ __name((slug) => ({ req: { user, payload: payload
3792
3791
  };
3793
3792
  return query2;
3794
3793
  }
3795
- const collectionConfig = payload2.config.collections.find((x) => x.slug === slug);
3794
+ const collectionConfig = payload.config.collections.find((x) => x.slug === slug);
3796
3795
  const fields = collectionConfig.fields.filter((field) => field.type === "relationship" && tenantCollections.find((x) => field.relationTo.includes(x)) !== void 0);
3797
3796
  if (!fields.length) {
3798
3797
  return false;
@@ -3832,9 +3831,6 @@ var isTenant = /* @__PURE__ */ __name((slug) => ({ req: { user, payload: payload
3832
3831
  return query;
3833
3832
  }, "isTenant");
3834
3833
 
3835
- // src/core/api/action.service.ts
3836
- var import_payload = __toESM(require("payload"));
3837
-
3838
3834
  // src/core/utils/deepMerge.ts
3839
3835
  function isObject(item) {
3840
3836
  return item && typeof item === "object" && !Array.isArray(item);
@@ -3972,41 +3968,58 @@ function sortByGroup(collectionsOrGlobals) {
3972
3968
  __name(sortByGroup, "sortByGroup");
3973
3969
 
3974
3970
  // src/core/api/action.service.ts
3975
- var optout = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
3976
- const action = await import_payload.default.findByID({
3971
+ var optout = /* @__PURE__ */ __name(async (req) => {
3972
+ const { payload } = req;
3973
+ const actionId = req.params.id;
3974
+ const actionSlug = req.params.slug;
3975
+ const action = await payload.findByID({
3977
3976
  collection: actionSlug,
3978
3977
  id: actionId
3979
3978
  });
3980
3979
  const { endUser, consentPreferences } = action;
3980
+ const config = payload.collections[actionSlug].config;
3981
3981
  if (endUser) {
3982
- const data = {
3982
+ const data2 = {
3983
3983
  consentPreferences: endUser.consentPreferences?.filter((x) => !consentPreferences.map((y) => y.id).includes(x.consentPreference.id)).map((x) => ({
3984
3984
  consentPreference: x.consentPreference.id,
3985
3985
  date: x.date
3986
3986
  })) ?? []
3987
3987
  };
3988
- await import_payload.default.update({
3988
+ await payload.update({
3989
3989
  collection: options.slug.endUsers,
3990
3990
  id: endUser.id,
3991
- data
3991
+ data: data2
3992
3992
  });
3993
3993
  }
3994
- await import_payload.default.update({
3994
+ const data = {
3995
+ consentsRevoked: true,
3996
+ consentsRevokedDate: /* @__PURE__ */ new Date()
3997
+ };
3998
+ await payload.update({
3995
3999
  collection: actionSlug,
3996
4000
  id: actionId,
3997
- data: {
3998
- consentsRevoked: true,
3999
- consentsRevokedDate: /* @__PURE__ */ new Date()
4000
- }
4001
+ data
4001
4002
  });
4003
+ if (typeof config.custom?.afterOptout === "function") {
4004
+ await config.custom.afterOptout({
4005
+ collection: config,
4006
+ doc: { ...action, ...data },
4007
+ previousDoc: action,
4008
+ req
4009
+ });
4010
+ }
4002
4011
  }, "optout");
4003
- var optin = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
4004
- const action = await import_payload.default.findByID({
4012
+ var optin = /* @__PURE__ */ __name(async (req) => {
4013
+ const { payload } = req;
4014
+ const actionId = req.params.id;
4015
+ const actionSlug = req.params.slug;
4016
+ const action = await payload.findByID({
4005
4017
  collection: actionSlug,
4006
4018
  id: actionId
4007
4019
  });
4008
4020
  const { email, password, consentPreferences } = action;
4009
- const config = import_payload.default.collections[actionSlug].config;
4021
+ const config = payload.collections[actionSlug].config;
4022
+ let data = { endUser: void 0 };
4010
4023
  if (config.custom?.updateEndUser) {
4011
4024
  const updateFields = config.fields.filter((field) => field.custom?.updateEndUser);
4012
4025
  const actionData = updateFields.reduce((acc, field) => {
@@ -4015,7 +4028,7 @@ var optin = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
4015
4028
  }
4016
4029
  return acc;
4017
4030
  }, {});
4018
- const { docs: endUsers } = await import_payload.default.find({
4031
+ const { docs: endUsers } = await payload.find({
4019
4032
  collection: options.slug.endUsers,
4020
4033
  where: {
4021
4034
  email: { equals: email }
@@ -4041,7 +4054,7 @@ var optin = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
4041
4054
  });
4042
4055
  }
4043
4056
  });
4044
- endUser = await import_payload.default.update({
4057
+ endUser = await payload.update({
4045
4058
  collection: options.slug.endUsers,
4046
4059
  id: endUser.id,
4047
4060
  data: actionData
@@ -4051,40 +4064,47 @@ var optin = /* @__PURE__ */ __name(async (actionId, actionSlug) => {
4051
4064
  consentPreference: actionConsent.id,
4052
4065
  date: /* @__PURE__ */ new Date()
4053
4066
  }));
4054
- endUser = await import_payload.default.create({
4067
+ endUser = await payload.create({
4055
4068
  collection: options.slug.endUsers,
4056
4069
  data: { email, ...actionData }
4057
4070
  });
4058
4071
  }
4059
- await import_payload.default.update({
4072
+ data.endUser = endUser.id;
4073
+ await payload.update({
4060
4074
  collection: actionSlug,
4061
4075
  id: actionId,
4062
- data: {
4063
- endUser: endUser.id
4064
- }
4076
+ data
4065
4077
  });
4066
4078
  if (config.custom.createCredentials) {
4067
- const { docs: userCredentials } = await import_payload.default.find({
4079
+ const { docs: userCredentials } = await payload.find({
4068
4080
  collection: options.slug.endUserCredentials,
4069
4081
  where: {
4070
4082
  email: { equals: email }
4071
4083
  }
4072
4084
  });
4073
4085
  if (userCredentials.length === 0) {
4074
- await import_payload.default.create({
4086
+ await payload.create({
4075
4087
  collection: options.slug.endUserCredentials,
4076
4088
  data: { email, password, endUser: endUser.id, ...actionData }
4077
4089
  });
4078
4090
  }
4079
4091
  }
4080
4092
  }
4093
+ if (typeof config.custom?.afterOptin === "function") {
4094
+ await config.custom.afterOptin({
4095
+ collection: config,
4096
+ doc: action,
4097
+ previousDoc: { ...action, ...data },
4098
+ req
4099
+ });
4100
+ }
4081
4101
  }, "optin");
4082
4102
  var optinGet = {
4083
4103
  path: "/actions/optin/:id/:slug",
4084
4104
  method: "get",
4085
4105
  handler: async (req, res, next) => {
4086
4106
  try {
4087
- await optin(req.params.id, req.params.slug);
4107
+ await optin(req);
4088
4108
  return res.status(200).send({ status: 200, message: "optin success" });
4089
4109
  } catch (error) {
4090
4110
  console.error("ActionService.optinGet.error", error);
@@ -4101,7 +4121,7 @@ var optoutGet = {
4101
4121
  method: "get",
4102
4122
  handler: async (req, res, next) => {
4103
4123
  try {
4104
- await optout(req.params.id, req.params.slug);
4124
+ await optout(req);
4105
4125
  return res.status(200).send({ status: 200, message: "optout success" });
4106
4126
  } catch (error) {
4107
4127
  console.error("ActionService.optoutGet.error", error);
@@ -4798,8 +4818,8 @@ async function findCollection(req, collection, options2) {
4798
4818
  }
4799
4819
  __name(findCollection, "findCollection");
4800
4820
  function getApiUrl(req) {
4801
- const { payload: payload2 } = req;
4802
- const { config } = payload2;
4821
+ const { payload } = req;
4822
+ const { config } = payload;
4803
4823
  const port = process.env.PORT || 4e3;
4804
4824
  const origin = `http://localhost:${port}`;
4805
4825
  let url = `${origin}${config.routes.api}/`;
@@ -7221,17 +7241,6 @@ var Locale = /* @__PURE__ */ __name((options2) => ({
7221
7241
  ]
7222
7242
  }), "Locale");
7223
7243
 
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
7244
  // src/fields/color-picker/ColorCell.tsx
7236
7245
  var import_jsx_runtime15 = require("react/jsx-runtime");
7237
7246
  var ColorCell = /* @__PURE__ */ __name((props) => {
@@ -7559,9 +7568,6 @@ function toField(item) {
7559
7568
  case "withName":
7560
7569
  delete item.type;
7561
7570
  return withName(item);
7562
- case "withNewsletterSubscription":
7563
- delete item.type;
7564
- return withNewsletterSubscription(item);
7565
7571
  case "withOrder":
7566
7572
  delete item.type;
7567
7573
  return withOrder(item);
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.3",
4
4
  "description": "Bowl PayloadCms plugin of the BOM Repository",
5
5
  "keywords": [
6
6
  "payload",