@websolutespa/payload-plugin-bowl 1.7.8 → 1.7.9

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,13 @@
1
1
  # @websolutespa/payload-plugin-bowl
2
2
 
3
+ ## 1.7.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 37d1729: Modified: endpoint store handling user
8
+ - Updated dependencies
9
+ - @websolutespa/bom-core@1.7.4
10
+
3
11
  ## 1.7.8
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Resource } from 'i18next';
2
2
  import { Endpoint, AdminView, Locale as Locale$1, Config } from 'payload/config';
3
3
  import { Field, FieldBase, Tab, JSONField, Block as Block$1, FieldAffectingData, HookName, FieldHook as FieldHook$1, UIField as UIField$1 } from 'payload/dist/fields/config/types';
4
4
  import * as payload_types from 'payload/types';
5
- import { PayloadRequest, CollectionAfterChangeHook, CollectionAfterDeleteHook, TypeWithID, CollectionConfig, BeforeDuplicate, Block, GlobalConfig, RichTextField, RelationshipField, CheckboxField, BlockField, DateField, TextField, GroupField, Field as Field$1, UploadField, ArrayField, NumberField, FieldHook, SelectField, CollapsibleField, RowField, TabsField, UIField, EmailField, TextareaField, RadioField, CodeField, PointField, SanitizedCollectionConfig } from 'payload/types';
5
+ import { PayloadRequest, CollectionAfterChangeHook, CollectionAfterDeleteHook, TypeWithID, CollectionConfig, BeforeDuplicate, Where, Block, GlobalConfig, RichTextField, RelationshipField, CheckboxField, BlockField, DateField, TextField, GroupField, Field as Field$1, UploadField, ArrayField, NumberField, FieldHook, SelectField, CollapsibleField, RowField, TabsField, UIField, EmailField, TextareaField, RadioField, CodeField, PointField, SanitizedCollectionConfig } from 'payload/types';
6
6
  import { IEntity, ILocale, ICategorized, IRoute, ICategory, IMarket, IMemoryStore, ILocalizable, IEquatable, IMedia, IPageRelation, ISchema, IMenuItem, IMenu } from '@websolutespa/bom-core';
7
7
  import * as payload_dist_admin_components_forms_FieldDescription_types from 'payload/dist/admin/components/forms/FieldDescription/types';
8
8
  import * as React from 'react';
@@ -14,6 +14,7 @@ import { Props as Props$4 } from 'payload/dist/admin/components/views/collection
14
14
  import { User } from 'payload/dist/auth';
15
15
  import { PaginatedDocs } from 'payload/database';
16
16
  import { Response, NextFunction } from 'express';
17
+ import { RequestContext } from 'payload';
17
18
  import { ContextType } from 'payload/dist/admin/components/utilities/DocumentInfo/types';
18
19
  import { Props as Props$2 } from 'payload/components/views/Cell';
19
20
  import { Props as Props$3 } from 'payload/components/fields/Text';
@@ -198,6 +199,25 @@ declare function populateStaticFields<T = IEntity>(item: T, fields: Field[], loc
198
199
  declare function getStaticLoader(slug: string): () => Promise<Option[]>;
199
200
 
200
201
  declare function getStore(req: PayloadRequest): Promise<IMemoryStore>;
202
+ type FindOptions = {
203
+ context?: RequestContext;
204
+ currentDepth?: number;
205
+ depth?: number;
206
+ disableErrors?: boolean;
207
+ draft?: boolean;
208
+ fallbackLocale?: string;
209
+ limit?: number;
210
+ locale?: string;
211
+ overrideAccess?: boolean;
212
+ page?: number;
213
+ pagination?: boolean;
214
+ req?: PayloadRequest;
215
+ showHiddenFields?: boolean;
216
+ sort?: string;
217
+ user?: any;
218
+ where?: Where;
219
+ };
220
+ declare function findCollection<T>(req: PayloadRequest, collection: string, options?: Omit<FindOptions, 'req'>): Promise<PaginatedDocs<T>>;
201
221
  declare function getApiUrl(req: PayloadRequest): string;
202
222
  declare function getSearchUrl(req: PayloadRequest, overrideQuery?: {}): string;
203
223
  declare function fetchEndpoint<T>(req: PayloadRequest, endpoint: string, query?: {}): Promise<T>;
@@ -662,7 +682,7 @@ declare const richTextAfterReadHook: FieldBase['hooks']['afterRead'][number];
662
682
  declare const RichTextDefaults: RichTextField;
663
683
  declare const withRichText: (options?: Partial<RichTextField>) => RichTextField;
664
684
  declare const withRichTextRequired: (options?: Partial<RichTextField>) => RichTextField;
665
- declare function richTextSerialize(children?: any[]): string;
685
+ declare function richTextSerialize(children?: any[], includeHtmlTags?: boolean): string;
666
686
 
667
687
  type WithRolesProps = (Omit<SelectField, 'type' | 'name' | 'options'> & {
668
688
  name?: string;
@@ -972,6 +992,8 @@ declare const roles: {
972
992
  type Values<T> = T[keyof T];
973
993
  type BowlRole = Values<typeof roles> | string;
974
994
  type BowlOptions = {
995
+ bowlCollections: BowlCollection[];
996
+ bowlGlobals: BowlGlobal[];
975
997
  collections: string[];
976
998
  defaultLocale: string;
977
999
  defaultMarket: string;
@@ -981,13 +1003,13 @@ type BowlOptions = {
981
1003
  blocks: BowlBlock[];
982
1004
  };
983
1005
  pages: string[];
984
- slug: BowlSlug;
985
- translations: Resource;
986
1006
  plugins: BowlPlugin[];
987
1007
  roles: typeof roles & Record<string, string>;
988
- rolesUser: BowlRole[];
989
1008
  rolesEndUser: BowlRole[];
990
1009
  rolesList: BowlRole[];
1010
+ rolesUser: BowlRole[];
1011
+ slug: BowlSlug;
1012
+ translations: Resource;
991
1013
  };
992
1014
  type BowlInitOptions = {
993
1015
  defaultMarket?: string;
@@ -1128,4 +1150,4 @@ declare const Logo: React__default.FC;
1128
1150
 
1129
1151
  declare function webpack(sourceConfig: BowlConfig): (config: any) => any;
1130
1152
 
1131
- 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, 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, 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, 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, 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, isUndecoratedNavItem, 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 };
1153
+ 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, 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, 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, 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, fetchCollection, fetchCollectionItems, fetchEndpoint, fetchGlobal, fetchGlobalItems, findCollection, 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, isUndecoratedNavItem, 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 };
package/dist/index.js CHANGED
@@ -287,6 +287,7 @@ __export(src_exports, {
287
287
  fetchEndpoint: () => fetchEndpoint,
288
288
  fetchGlobal: () => fetchGlobal,
289
289
  fetchGlobalItems: () => fetchGlobalItems,
290
+ findCollection: () => findCollection,
290
291
  formatSlug: () => formatSlug,
291
292
  getApiUrl: () => getApiUrl,
292
293
  getCollectionItem: () => getCollectionItem,
@@ -1110,6 +1111,8 @@ var defaultLocales = ["en", "it"];
1110
1111
  var defaultLocale = process.env.DEFAULT_LOCALE || "en";
1111
1112
  var defaultMarket = process.env.DEFAULT_MARKET || "ww";
1112
1113
  var options = {
1114
+ bowlCollections: [],
1115
+ bowlGlobals: [],
1113
1116
  collections: [],
1114
1117
  defaultLocale,
1115
1118
  defaultMarket,
@@ -1120,12 +1123,12 @@ var options = {
1120
1123
  },
1121
1124
  pages: [],
1122
1125
  plugins: [],
1123
- slug: defaultSlug,
1124
- translations,
1125
1126
  roles,
1126
- rolesUser: [roles.Admin, roles.Editor],
1127
1127
  rolesEndUser: [roles.User],
1128
- rolesList: Object.values(roles)
1128
+ rolesList: Object.values(roles),
1129
+ rolesUser: [roles.Admin, roles.Editor],
1130
+ slug: defaultSlug,
1131
+ translations
1129
1132
  };
1130
1133
  var internalSlugs = Object.entries(defaultSlug).map((x) => x[1]);
1131
1134
 
@@ -1623,9 +1626,22 @@ async function getEachMarketLocale(req, callback) {
1623
1626
  __name(getEachMarketLocale, "getEachMarketLocale");
1624
1627
  async function getPages(req) {
1625
1628
  const store = {};
1629
+ const where = typeof req.query.where === "object" ? req.query.where : {};
1630
+ const subRequest = {
1631
+ ...req,
1632
+ query: {
1633
+ ...req.query,
1634
+ where: {
1635
+ ...where,
1636
+ _status: {
1637
+ equals: "published"
1638
+ }
1639
+ }
1640
+ }
1641
+ };
1626
1642
  const keys = options.pages;
1627
1643
  for (const key of keys) {
1628
- const items = await getCollectionItems(req, key, 0);
1644
+ const items = await getCollectionItems(subRequest, key, 0);
1629
1645
  store[key] = items;
1630
1646
  }
1631
1647
  return store;
@@ -3973,6 +3989,13 @@ var pageIndexGet = /* @__PURE__ */ __name((slug) => ({
3973
3989
  }
3974
3990
  const { locale, market, pagination } = query;
3975
3991
  if (typeof market === "string" && typeof locale === "string") {
3992
+ const where = typeof req.query.where === "object" ? req.query.where : {};
3993
+ req.query.where = {
3994
+ ...where,
3995
+ _status: {
3996
+ equals: "published"
3997
+ }
3998
+ };
3976
3999
  const context = await setMixerContext(req, market, locale);
3977
4000
  if (pagination === "true") {
3978
4001
  return next();
@@ -4004,6 +4027,13 @@ var pageDetailGet = /* @__PURE__ */ __name((slug) => ({
4004
4027
  if (!(typeof market === "string" && typeof locale === "string")) {
4005
4028
  return next();
4006
4029
  }
4030
+ const where = typeof req.query.where === "object" ? req.query.where : {};
4031
+ req.query.where = {
4032
+ ...where,
4033
+ _status: {
4034
+ equals: "published"
4035
+ }
4036
+ };
4007
4037
  const context = await setMixerContext(req, market, locale);
4008
4038
  return next();
4009
4039
  } catch (error) {
@@ -4075,8 +4105,38 @@ async function getStore(req) {
4075
4105
  const store = {};
4076
4106
  for (const slug of options.collections) {
4077
4107
  try {
4078
- const collection = await fetchCollection(req, slug, { richText: false });
4079
- store[slug] = collection.docs;
4108
+ const collection = req.payload.collections[slug];
4109
+ if (!collection) {
4110
+ throw `collection '${slug}' not found`;
4111
+ }
4112
+ const bowlCollection = options.bowlCollections.find((x) => x.slug === slug);
4113
+ const type = bowlCollection?.type;
4114
+ let items = [];
4115
+ switch (type) {
4116
+ case "withStatic":
4117
+ {
4118
+ const response = await fetchCollection(req, slug, { richText: false });
4119
+ items = response.docs;
4120
+ }
4121
+ break;
4122
+ case "withPage":
4123
+ {
4124
+ const response = await findCollection(req, slug, {
4125
+ where: {
4126
+ _status: {
4127
+ equals: "published"
4128
+ }
4129
+ }
4130
+ });
4131
+ items = response.docs;
4132
+ }
4133
+ break;
4134
+ default: {
4135
+ const response = await findCollection(req, slug);
4136
+ items = response.docs;
4137
+ }
4138
+ }
4139
+ store[slug] = items;
4080
4140
  } catch (error) {
4081
4141
  if (error.status !== 403) {
4082
4142
  throw error;
@@ -4091,6 +4151,21 @@ async function getStore(req) {
4091
4151
  return store;
4092
4152
  }
4093
4153
  __name(getStore, "getStore");
4154
+ async function findCollection(req, collection, options2) {
4155
+ const newRequest = { ...req };
4156
+ newRequest.query.richText = "false";
4157
+ const items = await req.payload.find({
4158
+ collection,
4159
+ depth: 1,
4160
+ limit: 1e4,
4161
+ locale: "*",
4162
+ req: newRequest,
4163
+ user: req.user,
4164
+ ...options2
4165
+ });
4166
+ return items;
4167
+ }
4168
+ __name(findCollection, "findCollection");
4094
4169
  function getApiUrl(req) {
4095
4170
  const { payload } = req;
4096
4171
  const { config } = payload;
@@ -4121,7 +4196,10 @@ async function fetchEndpoint(req, endpoint, query) {
4121
4196
  const httpGetResponse = await fetch(url, {
4122
4197
  method: "GET",
4123
4198
  headers: {
4124
- "Content-Type": "application/json"
4199
+ "Content-Type": "application/json",
4200
+ ...req.headers.authorization ? {
4201
+ "Authorization": req.headers.authorization
4202
+ } : {}
4125
4203
  }
4126
4204
  });
4127
4205
  if (!httpGetResponse.ok) {
@@ -4130,7 +4208,7 @@ async function fetchEndpoint(req, endpoint, query) {
4130
4208
  const json = await httpGetResponse.json();
4131
4209
  return json;
4132
4210
  } catch (error) {
4133
- console.log("StoreService.fetchEndpoint.error", error.statusText);
4211
+ console.log("StoreService.fetchEndpoint.error", endpoint, error.statusText);
4134
4212
  throw error;
4135
4213
  }
4136
4214
  }
@@ -5514,11 +5592,14 @@ var withRichTextRequired = /* @__PURE__ */ __name((options2 = {}) => {
5514
5592
  }, options2);
5515
5593
  return field;
5516
5594
  }, "withRichTextRequired");
5517
- function richTextSerialize(children) {
5595
+ function richTextSerialize(children, includeHtmlTags = true) {
5518
5596
  if (Array.isArray(children)) {
5519
5597
  return children.map((node, i) => {
5520
5598
  if (import_slate.Text.isText(node)) {
5521
5599
  let text = node.text;
5600
+ if (!includeHtmlTags) {
5601
+ return text;
5602
+ }
5522
5603
  if (node.bold) {
5523
5604
  text = `<strong>${text}</strong>`;
5524
5605
  }
@@ -5533,6 +5614,9 @@ function richTextSerialize(children) {
5533
5614
  if (!node) {
5534
5615
  return null;
5535
5616
  }
5617
+ if (!includeHtmlTags) {
5618
+ return richTextSerialize(node.children, includeHtmlTags);
5619
+ }
5536
5620
  switch (node.type) {
5537
5621
  case "h1":
5538
5622
  return `<h1>${richTextSerialize(node.children)}</h1>`;
@@ -6848,6 +6932,8 @@ var bowl = /* @__PURE__ */ __name((sourceOptions = {}) => (sourceConfig) => {
6848
6932
  ...filteredGlobals,
6849
6933
  ...bowlGlobals.map((x) => x(options))
6850
6934
  ];
6935
+ options.bowlCollections = unmappedCollections;
6936
+ options.bowlGlobals = unmappedGlobals;
6851
6937
  const adminViews = {};
6852
6938
  unmappedCollections.forEach((x) => {
6853
6939
  if (x.views) {
@@ -7062,6 +7148,7 @@ var src_default = bowl;
7062
7148
  fetchEndpoint,
7063
7149
  fetchGlobal,
7064
7150
  fetchGlobalItems,
7151
+ findCollection,
7065
7152
  formatSlug,
7066
7153
  getApiUrl,
7067
7154
  getCollectionItem,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/payload-plugin-bowl",
3
- "version": "1.7.8",
3
+ "version": "1.7.9",
4
4
  "description": "Bowl PayloadCms plugin of the BOM Repository",
5
5
  "keywords": [
6
6
  "payload",