@payloadcms/plugin-ecommerce 3.72.0-internal.3e70d4c → 3.73.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,qBAAqB,EAAkC,MAAM,kBAAkB,CAAA;AAE7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAA;AAChG,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAA;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAA;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAA;AACzG,OAAO,EAAE,8BAA8B,EAAE,MAAM,0DAA0D,CAAA;AACzG,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAA;AACnG,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAA;AAQrG,eAAO,MAAM,eAAe,kBACV,qBAAqB,sBACd,MAAM,KAAG,OAAO,CAAC,MAAM,CAwT7C,CAAA;AAEH,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,8BAA8B,EAC9B,wBAAwB,EACxB,4BAA4B,GAC7B,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAA;AACjG,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,y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CAAC,MAAM,CAqV7C,CAAA;AAEH,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,8BAA8B,EAC9B,wBAAwB,EACxB,4BAA4B,GAC7B,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAA;AACjG,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,YAAY,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,GACf,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAA;AACzE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA"}
package/dist/index.js CHANGED
@@ -20,18 +20,23 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
20
20
  const sanitizedPluginConfig = sanitizePluginConfig({
21
21
  pluginConfig
22
22
  });
23
- /**
24
- * Used to keep track of the slugs of collections in case they are overridden by the user.
25
- */ const collectionSlugMap = getCollectionSlugMap({
26
- sanitizedPluginConfig
27
- });
28
23
  const accessConfig = sanitizedPluginConfig.access;
29
24
  // Ensure collections exists
30
25
  if (!incomingConfig.collections) {
31
26
  incomingConfig.collections = [];
32
27
  }
33
- // Controls whether variants are enabled in the plugin. This is toggled to true under products config
34
- let enableVariants = false;
28
+ // Determine if variants are enabled based on products config
29
+ const productsConfig = typeof sanitizedPluginConfig.products === 'boolean' ? sanitizedPluginConfig.products ? {
30
+ variants: true
31
+ } : undefined : sanitizedPluginConfig.products;
32
+ const enableVariants = Boolean(productsConfig?.variants);
33
+ /**
34
+ * Used to keep track of the slugs of collections in case they are overridden by the user.
35
+ * Variant-related slugs are only included when variants are enabled.
36
+ */ const collectionSlugMap = getCollectionSlugMap({
37
+ enableVariants,
38
+ sanitizedPluginConfig
39
+ });
35
40
  const currenciesConfig = sanitizedPluginConfig.currencies;
36
41
  let addressFields;
37
42
  if (sanitizedPluginConfig.addresses) {
@@ -48,11 +53,7 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
48
53
  }) : defaultAddressesCollection;
49
54
  incomingConfig.collections.push(addressesCollection);
50
55
  }
51
- if (sanitizedPluginConfig.products) {
52
- const productsConfig = typeof sanitizedPluginConfig.products === 'boolean' ? {
53
- variants: true
54
- } : sanitizedPluginConfig.products;
55
- enableVariants = Boolean(productsConfig.variants);
56
+ if (productsConfig) {
56
57
  if (productsConfig.variants) {
57
58
  const variantsConfig = typeof productsConfig.variants === 'boolean' ? undefined : productsConfig.variants;
58
59
  const defaultVariantsCollection = createVariantsCollection({
@@ -60,22 +61,22 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
60
61
  currenciesConfig,
61
62
  inventory: sanitizedPluginConfig.inventory,
62
63
  productsSlug: collectionSlugMap.products,
63
- variantOptionsSlug: collectionSlugMap.variantOptions,
64
- variantTypesSlug: collectionSlugMap.variantTypes
64
+ variantOptionsSlug: collectionSlugMap.variantOptions ?? 'variantOptions',
65
+ variantTypesSlug: collectionSlugMap.variantTypes ?? 'variantTypes'
65
66
  });
66
67
  const variants = variantsConfig && typeof variantsConfig === 'object' && 'variantsCollectionOverride' in variantsConfig && variantsConfig.variantsCollectionOverride ? await variantsConfig.variantsCollectionOverride({
67
68
  defaultCollection: defaultVariantsCollection
68
69
  }) : defaultVariantsCollection;
69
70
  const defaultVariantTypesCollection = createVariantTypesCollection({
70
71
  access: accessConfig,
71
- variantOptionsSlug: collectionSlugMap.variantOptions
72
+ variantOptionsSlug: collectionSlugMap.variantOptions ?? 'variantOptions'
72
73
  });
73
74
  const variantTypes = variantsConfig && typeof variantsConfig === 'object' && 'variantTypesCollectionOverride' in variantsConfig && variantsConfig.variantTypesCollectionOverride ? await variantsConfig.variantTypesCollectionOverride({
74
75
  defaultCollection: defaultVariantTypesCollection
75
76
  }) : defaultVariantTypesCollection;
76
77
  const defaultVariantOptionsCollection = createVariantOptionsCollection({
77
78
  access: accessConfig,
78
- variantTypesSlug: collectionSlugMap.variantTypes
79
+ variantTypesSlug: collectionSlugMap.variantTypes ?? 'variantTypes'
79
80
  });
80
81
  const variantOptions = variantsConfig && typeof variantsConfig === 'object' && 'variantOptionsCollectionOverride' in variantsConfig && variantsConfig.variantOptionsCollectionOverride ? await variantsConfig.variantOptionsCollectionOverride({
81
82
  defaultCollection: defaultVariantOptionsCollection
@@ -87,8 +88,8 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
87
88
  currenciesConfig,
88
89
  enableVariants,
89
90
  inventory: sanitizedPluginConfig.inventory,
90
- variantsSlug: collectionSlugMap.variants,
91
- variantTypesSlug: collectionSlugMap.variantTypes
91
+ variantsSlug: collectionSlugMap.variants ?? 'variants',
92
+ variantTypesSlug: collectionSlugMap.variantTypes ?? 'variantTypes'
92
93
  });
93
94
  const productsCollection = productsConfig && 'productsCollectionOverride' in productsConfig && productsConfig.productsCollectionOverride ? await productsConfig.productsCollectionOverride({
94
95
  defaultCollection: defaultProductsCollection
@@ -104,7 +105,7 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
104
105
  customersSlug: collectionSlugMap.customers,
105
106
  enableVariants: Boolean(productsConfig.variants),
106
107
  productsSlug: collectionSlugMap.products,
107
- variantsSlug: collectionSlugMap.variants
108
+ variantsSlug: collectionSlugMap.variants ?? 'variants'
108
109
  });
109
110
  const cartsCollection = sanitizedPluginConfig.carts && typeof sanitizedPluginConfig.carts === 'object' && 'cartsCollectionOverride' in sanitizedPluginConfig.carts && sanitizedPluginConfig.carts.cartsCollectionOverride ? await sanitizedPluginConfig.carts.cartsCollectionOverride({
110
111
  defaultCollection: defaultCartsCollection
@@ -120,7 +121,7 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
120
121
  customersSlug: collectionSlugMap.customers,
121
122
  enableVariants,
122
123
  productsSlug: collectionSlugMap.products,
123
- variantsSlug: collectionSlugMap.variants
124
+ variantsSlug: collectionSlugMap.variants ?? 'variants'
124
125
  });
125
126
  const ordersCollection = sanitizedPluginConfig.orders && typeof sanitizedPluginConfig.orders === 'object' && 'ordersCollectionOverride' in sanitizedPluginConfig.orders && sanitizedPluginConfig.orders.ordersCollectionOverride ? await sanitizedPluginConfig.orders.ordersCollectionOverride({
126
127
  defaultCollection: defaultOrdersCollection
@@ -145,7 +146,7 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
145
146
  productsSlug: collectionSlugMap.products,
146
147
  productsValidation,
147
148
  transactionsSlug: collectionSlugMap.transactions,
148
- variantsSlug: collectionSlugMap.variants
149
+ variantsSlug: collectionSlugMap.variants ?? 'variants'
149
150
  }),
150
151
  method: 'post',
151
152
  path: `${methodPath}/initiate`
@@ -156,8 +157,10 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
156
157
  currenciesConfig,
157
158
  ordersSlug: collectionSlugMap.orders,
158
159
  paymentMethod,
160
+ productsSlug: collectionSlugMap.products,
159
161
  productsValidation,
160
- transactionsSlug: collectionSlugMap.transactions
162
+ transactionsSlug: collectionSlugMap.transactions,
163
+ variantsSlug: collectionSlugMap.variants ?? 'variants'
161
164
  }),
162
165
  method: 'post',
163
166
  path: `${methodPath}/confirm-order`
@@ -189,7 +192,7 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
189
192
  ordersSlug: collectionSlugMap.orders,
190
193
  paymentMethods,
191
194
  productsSlug: collectionSlugMap.products,
192
- variantsSlug: collectionSlugMap.variants
195
+ variantsSlug: collectionSlugMap.variants ?? 'variants'
193
196
  });
194
197
  const transactionsCollection = sanitizedPluginConfig.transactions && typeof sanitizedPluginConfig.transactions === 'object' && 'transactionsCollectionOverride' in sanitizedPluginConfig.transactions && sanitizedPluginConfig.transactions.transactionsCollectionOverride ? await sanitizedPluginConfig.transactions.transactionsCollectionOverride({
195
198
  defaultCollection: defaultTransactionsCollection
@@ -203,6 +206,28 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
203
206
  incomingConfig.i18n.translations = {};
204
207
  }
205
208
  incomingConfig.i18n.translations = deepMergeSimple(translations, incomingConfig.i18n?.translations);
209
+ /**
210
+ * Merge plugin translations
211
+ */ if (!incomingConfig.i18n) {
212
+ incomingConfig.i18n = {};
213
+ }
214
+ Object.entries(translations).forEach(([locale, pluginI18nObject])=>{
215
+ const typedLocale = locale;
216
+ if (!incomingConfig.i18n.translations) {
217
+ incomingConfig.i18n.translations = {};
218
+ }
219
+ if (!(typedLocale in incomingConfig.i18n.translations)) {
220
+ incomingConfig.i18n.translations[typedLocale] = {};
221
+ }
222
+ if (!('plugin-ecommerce' in incomingConfig.i18n.translations[typedLocale])) {
223
+ ;
224
+ incomingConfig.i18n.translations[typedLocale]['plugin-ecommerce'] = {};
225
+ }
226
+ ;
227
+ incomingConfig.i18n.translations[typedLocale]['plugin-ecommerce'] = {
228
+ ...pluginI18nObject.translations['plugin-ecommerce']
229
+ };
230
+ });
206
231
  if (!incomingConfig.typescript) {
207
232
  incomingConfig.typescript = {};
208
233
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config, Endpoint } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\n\nimport type { EcommercePluginConfig, SanitizedEcommercePluginConfig } from './types/index.js'\n\nimport { createAddressesCollection } from './collections/addresses/createAddressesCollection.js'\nimport { createCartsCollection } from './collections/carts/createCartsCollection.js'\nimport { createOrdersCollection } from './collections/orders/createOrdersCollection.js'\nimport { createProductsCollection } from './collections/products/createProductsCollection.js'\nimport { createTransactionsCollection } from './collections/transactions/createTransactionsCollection.js'\nimport { createVariantOptionsCollection } from './collections/variants/createVariantOptionsCollection.js'\nimport { createVariantsCollection } from './collections/variants/createVariantsCollection/index.js'\nimport { createVariantTypesCollection } from './collections/variants/createVariantTypesCollection.js'\nimport { confirmOrderHandler } from './endpoints/confirmOrder.js'\nimport { initiatePaymentHandler } from './endpoints/initiatePayment.js'\nimport { translations } from './translations/index.js'\nimport { getCollectionSlugMap } from './utilities/getCollectionSlugMap.js'\nimport { pushTypeScriptProperties } from './utilities/pushTypeScriptProperties.js'\nimport { sanitizePluginConfig } from './utilities/sanitizePluginConfig.js'\n\nexport const ecommercePlugin =\n (pluginConfig?: EcommercePluginConfig) =>\n async (incomingConfig: Config): Promise<Config> => {\n if (!pluginConfig) {\n return incomingConfig\n }\n\n const sanitizedPluginConfig = sanitizePluginConfig({ pluginConfig })\n /**\n * Used to keep track of the slugs of collections in case they are overridden by the user.\n */\n const collectionSlugMap = getCollectionSlugMap({ sanitizedPluginConfig })\n\n const accessConfig = sanitizedPluginConfig.access\n\n // Ensure collections exists\n if (!incomingConfig.collections) {\n incomingConfig.collections = []\n }\n\n // Controls whether variants are enabled in the plugin. This is toggled to true under products config\n let enableVariants = false\n\n const currenciesConfig: Required<SanitizedEcommercePluginConfig['currencies']> =\n sanitizedPluginConfig.currencies\n\n let addressFields\n\n if (sanitizedPluginConfig.addresses) {\n addressFields = sanitizedPluginConfig.addresses.addressFields\n\n const supportedCountries = sanitizedPluginConfig.addresses.supportedCountries\n\n const defaultAddressesCollection = createAddressesCollection({\n access: accessConfig,\n addressFields,\n customersSlug: collectionSlugMap.customers,\n supportedCountries,\n })\n\n const addressesCollection =\n sanitizedPluginConfig.addresses &&\n typeof sanitizedPluginConfig.addresses === 'object' &&\n 'addressesCollectionOverride' in sanitizedPluginConfig.addresses &&\n sanitizedPluginConfig.addresses.addressesCollectionOverride\n ? await sanitizedPluginConfig.addresses.addressesCollectionOverride({\n defaultCollection: defaultAddressesCollection,\n })\n : defaultAddressesCollection\n\n incomingConfig.collections.push(addressesCollection)\n }\n\n if (sanitizedPluginConfig.products) {\n const productsConfig =\n typeof sanitizedPluginConfig.products === 'boolean'\n ? {\n variants: true,\n }\n : sanitizedPluginConfig.products\n\n enableVariants = Boolean(productsConfig.variants)\n\n if (productsConfig.variants) {\n const variantsConfig =\n typeof productsConfig.variants === 'boolean' ? undefined : productsConfig.variants\n\n const defaultVariantsCollection = createVariantsCollection({\n access: accessConfig,\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n productsSlug: collectionSlugMap.products,\n variantOptionsSlug: collectionSlugMap.variantOptions,\n variantTypesSlug: collectionSlugMap.variantTypes,\n })\n\n const variants =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantsCollectionOverride' in variantsConfig &&\n variantsConfig.variantsCollectionOverride\n ? await variantsConfig.variantsCollectionOverride({\n defaultCollection: defaultVariantsCollection,\n })\n : defaultVariantsCollection\n\n const defaultVariantTypesCollection = createVariantTypesCollection({\n access: accessConfig,\n variantOptionsSlug: collectionSlugMap.variantOptions,\n })\n\n const variantTypes =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantTypesCollectionOverride' in variantsConfig &&\n variantsConfig.variantTypesCollectionOverride\n ? await variantsConfig.variantTypesCollectionOverride({\n defaultCollection: defaultVariantTypesCollection,\n })\n : defaultVariantTypesCollection\n\n const defaultVariantOptionsCollection = createVariantOptionsCollection({\n access: accessConfig,\n variantTypesSlug: collectionSlugMap.variantTypes,\n })\n\n const variantOptions =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantOptionsCollectionOverride' in variantsConfig &&\n variantsConfig.variantOptionsCollectionOverride\n ? await variantsConfig.variantOptionsCollectionOverride({\n defaultCollection: defaultVariantOptionsCollection,\n })\n : defaultVariantOptionsCollection\n\n incomingConfig.collections.push(variants, variantTypes, variantOptions)\n }\n\n const defaultProductsCollection = createProductsCollection({\n access: accessConfig,\n currenciesConfig,\n enableVariants,\n inventory: sanitizedPluginConfig.inventory,\n variantsSlug: collectionSlugMap.variants,\n variantTypesSlug: collectionSlugMap.variantTypes,\n })\n\n const productsCollection =\n productsConfig &&\n 'productsCollectionOverride' in productsConfig &&\n productsConfig.productsCollectionOverride\n ? await productsConfig.productsCollectionOverride({\n defaultCollection: defaultProductsCollection,\n })\n : defaultProductsCollection\n\n incomingConfig.collections.push(productsCollection)\n\n if (sanitizedPluginConfig.carts) {\n const cartsConfig =\n typeof sanitizedPluginConfig.carts === 'object' ? sanitizedPluginConfig.carts : {}\n\n const defaultCartsCollection = createCartsCollection({\n access: accessConfig,\n allowGuestCarts: cartsConfig.allowGuestCarts,\n cartItemMatcher: cartsConfig.cartItemMatcher,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants: Boolean(productsConfig.variants),\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const cartsCollection =\n sanitizedPluginConfig.carts &&\n typeof sanitizedPluginConfig.carts === 'object' &&\n 'cartsCollectionOverride' in sanitizedPluginConfig.carts &&\n sanitizedPluginConfig.carts.cartsCollectionOverride\n ? await sanitizedPluginConfig.carts.cartsCollectionOverride({\n defaultCollection: defaultCartsCollection,\n })\n : defaultCartsCollection\n\n incomingConfig.collections.push(cartsCollection)\n }\n }\n\n if (sanitizedPluginConfig.orders) {\n const defaultOrdersCollection = createOrdersCollection({\n access: accessConfig,\n addressFields,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const ordersCollection =\n sanitizedPluginConfig.orders &&\n typeof sanitizedPluginConfig.orders === 'object' &&\n 'ordersCollectionOverride' in sanitizedPluginConfig.orders &&\n sanitizedPluginConfig.orders.ordersCollectionOverride\n ? await sanitizedPluginConfig.orders.ordersCollectionOverride({\n defaultCollection: defaultOrdersCollection,\n })\n : defaultOrdersCollection\n\n incomingConfig.collections.push(ordersCollection)\n }\n\n const paymentMethods = sanitizedPluginConfig.payments.paymentMethods\n\n if (sanitizedPluginConfig.payments) {\n if (paymentMethods.length) {\n if (!Array.isArray(incomingConfig.endpoints)) {\n incomingConfig.endpoints = []\n }\n\n const productsValidation =\n (typeof sanitizedPluginConfig.products === 'object' &&\n sanitizedPluginConfig.products.validation) ||\n undefined\n\n paymentMethods.forEach((paymentMethod) => {\n const methodPath = `/payments/${paymentMethod.name}`\n const endpoints: Endpoint[] = []\n\n const initiatePayment: Endpoint = {\n handler: initiatePaymentHandler({\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n paymentMethod,\n productsSlug: collectionSlugMap.products,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n variantsSlug: collectionSlugMap.variants,\n }),\n method: 'post',\n path: `${methodPath}/initiate`,\n }\n\n const confirmOrder: Endpoint = {\n handler: confirmOrderHandler({\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n ordersSlug: collectionSlugMap.orders,\n paymentMethod,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n }),\n method: 'post',\n path: `${methodPath}/confirm-order`,\n }\n\n endpoints.push(initiatePayment, confirmOrder)\n\n // Attach any additional endpoints defined in the payment method\n if (paymentMethod.endpoints && paymentMethod.endpoints.length > 0) {\n const methodEndpoints = paymentMethod.endpoints.map((endpoint) => {\n const path = endpoint.path.startsWith('/') ? endpoint.path : `/${endpoint.path}`\n\n return {\n ...endpoint,\n path: `${methodPath}${path}`,\n }\n })\n\n endpoints.push(...methodEndpoints)\n }\n\n incomingConfig.endpoints!.push(...endpoints)\n })\n }\n }\n\n if (sanitizedPluginConfig.transactions) {\n const defaultTransactionsCollection = createTransactionsCollection({\n access: accessConfig,\n addressFields,\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n ordersSlug: collectionSlugMap.orders,\n paymentMethods,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const transactionsCollection =\n sanitizedPluginConfig.transactions &&\n typeof sanitizedPluginConfig.transactions === 'object' &&\n 'transactionsCollectionOverride' in sanitizedPluginConfig.transactions &&\n sanitizedPluginConfig.transactions.transactionsCollectionOverride\n ? await sanitizedPluginConfig.transactions.transactionsCollectionOverride({\n defaultCollection: defaultTransactionsCollection,\n })\n : defaultTransactionsCollection\n\n incomingConfig.collections.push(transactionsCollection)\n }\n\n if (!incomingConfig.i18n) {\n incomingConfig.i18n = {}\n }\n\n if (!incomingConfig.i18n?.translations) {\n incomingConfig.i18n.translations = {}\n }\n\n incomingConfig.i18n.translations = deepMergeSimple(\n translations,\n incomingConfig.i18n?.translations,\n )\n\n if (!incomingConfig.typescript) {\n incomingConfig.typescript = {}\n }\n\n if (!incomingConfig.typescript.schema) {\n incomingConfig.typescript.schema = []\n }\n\n incomingConfig.typescript.schema.push((args) =>\n pushTypeScriptProperties({\n ...args,\n collectionSlugMap,\n sanitizedPluginConfig,\n }),\n )\n\n return incomingConfig\n }\n\nexport {\n createAddressesCollection,\n createCartsCollection,\n createOrdersCollection,\n createProductsCollection,\n createTransactionsCollection,\n createVariantOptionsCollection,\n createVariantsCollection,\n createVariantTypesCollection,\n}\n\nexport { addItem } from './collections/carts/operations/addItem.js'\nexport { clearCart } from './collections/carts/operations/clearCart.js'\nexport { defaultCartItemMatcher } from './collections/carts/operations/defaultCartItemMatcher.js'\nexport { removeItem } from './collections/carts/operations/removeItem.js'\nexport { isNumericOperator } from './collections/carts/operations/types.js'\nexport type {\n AddItemArgs,\n CartItemData,\n CartItemMatcher,\n CartItemMatcherArgs,\n CartOperationResult,\n ClearCartArgs,\n FieldWithOperator,\n NewCartItem,\n NumericOperator,\n RemoveItemArgs,\n UpdateItemArgs,\n} from './collections/carts/operations/types.js'\nexport { updateItem } from './collections/carts/operations/updateItem.js'\nexport { EUR, GBP, USD } from './currencies/index.js'\nexport { amountField } from './fields/amountField.js'\nexport { currencyField } from './fields/currencyField.js'\nexport { pricesField } from './fields/pricesField.js'\nexport { statusField } from './fields/statusField.js'\nexport { variantsFields } from './fields/variantsFields.js'\n"],"names":["deepMergeSimple","createAddressesCollection","createCartsCollection","createOrdersCollection","createProductsCollection","createTransactionsCollection","createVariantOptionsCollection","createVariantsCollection","createVariantTypesCollection","confirmOrderHandler","initiatePaymentHandler","translations","getCollectionSlugMap","pushTypeScriptProperties","sanitizePluginConfig","ecommercePlugin","pluginConfig","incomingConfig","sanitizedPluginConfig","collectionSlugMap","accessConfig","access","collections","enableVariants","currenciesConfig","currencies","addressFields","addresses","supportedCountries","defaultAddressesCollection","customersSlug","customers","addressesCollection","addressesCollectionOverride","defaultCollection","push","products","productsConfig","variants","Boolean","variantsConfig","undefined","defaultVariantsCollection","inventory","productsSlug","variantOptionsSlug","variantOptions","variantTypesSlug","variantTypes","variantsCollectionOverride","defaultVariantTypesCollection","variantTypesCollectionOverride","defaultVariantOptionsCollection","variantOptionsCollectionOverride","defaultProductsCollection","variantsSlug","productsCollection","productsCollectionOverride","carts","cartsConfig","defaultCartsCollection","allowGuestCarts","cartItemMatcher","cartsCollection","cartsCollectionOverride","orders","defaultOrdersCollection","ordersCollection","ordersCollectionOverride","paymentMethods","payments","length","Array","isArray","endpoints","productsValidation","validation","forEach","paymentMethod","methodPath","name","initiatePayment","handler","transactionsSlug","transactions","method","path","confirmOrder","cartsSlug","ordersSlug","methodEndpoints","map","endpoint","startsWith","defaultTransactionsCollection","transactionsCollection","transactionsCollectionOverride","i18n","typescript","schema","args","addItem","clearCart","defaultCartItemMatcher","removeItem","isNumericOperator","updateItem","EUR","GBP","USD","amountField","currencyField","pricesField","statusField","variantsFields"],"mappings":"AAEA,SAASA,eAAe,QAAQ,iBAAgB;AAIhD,SAASC,yBAAyB,QAAQ,uDAAsD;AAChG,SAASC,qBAAqB,QAAQ,+CAA8C;AACpF,SAASC,sBAAsB,QAAQ,iDAAgD;AACvF,SAASC,wBAAwB,QAAQ,qDAAoD;AAC7F,SAASC,4BAA4B,QAAQ,6DAA4D;AACzG,SAASC,8BAA8B,QAAQ,2DAA0D;AACzG,SAASC,wBAAwB,QAAQ,2DAA0D;AACnG,SAASC,4BAA4B,QAAQ,yDAAwD;AACrG,SAASC,mBAAmB,QAAQ,8BAA6B;AACjE,SAASC,sBAAsB,QAAQ,iCAAgC;AACvE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E,OAAO,MAAMC,kBACX,CAACC,eACD,OAAOC;QACL,IAAI,CAACD,cAAc;YACjB,OAAOC;QACT;QAEA,MAAMC,wBAAwBJ,qBAAqB;YAAEE;QAAa;QAClE;;KAEC,GACD,MAAMG,oBAAoBP,qBAAqB;YAAEM;QAAsB;QAEvE,MAAME,eAAeF,sBAAsBG,MAAM;QAEjD,4BAA4B;QAC5B,IAAI,CAACJ,eAAeK,WAAW,EAAE;YAC/BL,eAAeK,WAAW,GAAG,EAAE;QACjC;QAEA,qGAAqG;QACrG,IAAIC,iBAAiB;QAErB,MAAMC,mBACJN,sBAAsBO,UAAU;QAElC,IAAIC;QAEJ,IAAIR,sBAAsBS,SAAS,EAAE;YACnCD,gBAAgBR,sBAAsBS,SAAS,CAACD,aAAa;YAE7D,MAAME,qBAAqBV,sBAAsBS,SAAS,CAACC,kBAAkB;YAE7E,MAAMC,6BAA6B5B,0BAA0B;gBAC3DoB,QAAQD;gBACRM;gBACAI,eAAeX,kBAAkBY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BAA2B;AACzD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,cAAc,QAAQ,6BAA4B"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { Config, Endpoint } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\n\nimport type { PluginDefaultTranslationsObject } from './translations/types.js'\nimport type { EcommercePluginConfig, SanitizedEcommercePluginConfig } from './types/index.js'\n\nimport { createAddressesCollection } from './collections/addresses/createAddressesCollection.js'\nimport { createCartsCollection } from './collections/carts/createCartsCollection.js'\nimport { createOrdersCollection } from './collections/orders/createOrdersCollection.js'\nimport { createProductsCollection } from './collections/products/createProductsCollection.js'\nimport { createTransactionsCollection } from './collections/transactions/createTransactionsCollection.js'\nimport { createVariantOptionsCollection } from './collections/variants/createVariantOptionsCollection.js'\nimport { createVariantsCollection } from './collections/variants/createVariantsCollection/index.js'\nimport { createVariantTypesCollection } from './collections/variants/createVariantTypesCollection.js'\nimport { confirmOrderHandler } from './endpoints/confirmOrder.js'\nimport { initiatePaymentHandler } from './endpoints/initiatePayment.js'\nimport { translations } from './translations/index.js'\nimport { getCollectionSlugMap } from './utilities/getCollectionSlugMap.js'\nimport { pushTypeScriptProperties } from './utilities/pushTypeScriptProperties.js'\nimport { sanitizePluginConfig } from './utilities/sanitizePluginConfig.js'\n\nexport const ecommercePlugin =\n (pluginConfig?: EcommercePluginConfig) =>\n async (incomingConfig: Config): Promise<Config> => {\n if (!pluginConfig) {\n return incomingConfig\n }\n\n const sanitizedPluginConfig = sanitizePluginConfig({ pluginConfig })\n\n const accessConfig = sanitizedPluginConfig.access\n\n // Ensure collections exists\n if (!incomingConfig.collections) {\n incomingConfig.collections = []\n }\n\n // Determine if variants are enabled based on products config\n const productsConfig =\n typeof sanitizedPluginConfig.products === 'boolean'\n ? sanitizedPluginConfig.products\n ? { variants: true }\n : undefined\n : sanitizedPluginConfig.products\n\n const enableVariants = Boolean(productsConfig?.variants)\n\n /**\n * Used to keep track of the slugs of collections in case they are overridden by the user.\n * Variant-related slugs are only included when variants are enabled.\n */\n const collectionSlugMap = getCollectionSlugMap({ enableVariants, sanitizedPluginConfig })\n\n const currenciesConfig: Required<SanitizedEcommercePluginConfig['currencies']> =\n sanitizedPluginConfig.currencies\n\n let addressFields\n\n if (sanitizedPluginConfig.addresses) {\n addressFields = sanitizedPluginConfig.addresses.addressFields\n\n const supportedCountries = sanitizedPluginConfig.addresses.supportedCountries\n\n const defaultAddressesCollection = createAddressesCollection({\n access: accessConfig,\n addressFields,\n customersSlug: collectionSlugMap.customers,\n supportedCountries,\n })\n\n const addressesCollection =\n sanitizedPluginConfig.addresses &&\n typeof sanitizedPluginConfig.addresses === 'object' &&\n 'addressesCollectionOverride' in sanitizedPluginConfig.addresses &&\n sanitizedPluginConfig.addresses.addressesCollectionOverride\n ? await sanitizedPluginConfig.addresses.addressesCollectionOverride({\n defaultCollection: defaultAddressesCollection,\n })\n : defaultAddressesCollection\n\n incomingConfig.collections.push(addressesCollection)\n }\n\n if (productsConfig) {\n if (productsConfig.variants) {\n const variantsConfig =\n typeof productsConfig.variants === 'boolean' ? undefined : productsConfig.variants\n\n const defaultVariantsCollection = createVariantsCollection({\n access: accessConfig,\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n productsSlug: collectionSlugMap.products,\n variantOptionsSlug: collectionSlugMap.variantOptions ?? 'variantOptions',\n variantTypesSlug: collectionSlugMap.variantTypes ?? 'variantTypes',\n })\n\n const variants =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantsCollectionOverride' in variantsConfig &&\n variantsConfig.variantsCollectionOverride\n ? await variantsConfig.variantsCollectionOverride({\n defaultCollection: defaultVariantsCollection,\n })\n : defaultVariantsCollection\n\n const defaultVariantTypesCollection = createVariantTypesCollection({\n access: accessConfig,\n variantOptionsSlug: collectionSlugMap.variantOptions ?? 'variantOptions',\n })\n\n const variantTypes =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantTypesCollectionOverride' in variantsConfig &&\n variantsConfig.variantTypesCollectionOverride\n ? await variantsConfig.variantTypesCollectionOverride({\n defaultCollection: defaultVariantTypesCollection,\n })\n : defaultVariantTypesCollection\n\n const defaultVariantOptionsCollection = createVariantOptionsCollection({\n access: accessConfig,\n variantTypesSlug: collectionSlugMap.variantTypes ?? 'variantTypes',\n })\n\n const variantOptions =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantOptionsCollectionOverride' in variantsConfig &&\n variantsConfig.variantOptionsCollectionOverride\n ? await variantsConfig.variantOptionsCollectionOverride({\n defaultCollection: defaultVariantOptionsCollection,\n })\n : defaultVariantOptionsCollection\n\n incomingConfig.collections.push(variants, variantTypes, variantOptions)\n }\n\n const defaultProductsCollection = createProductsCollection({\n access: accessConfig,\n currenciesConfig,\n enableVariants,\n inventory: sanitizedPluginConfig.inventory,\n variantsSlug: collectionSlugMap.variants ?? 'variants',\n variantTypesSlug: collectionSlugMap.variantTypes ?? 'variantTypes',\n })\n\n const productsCollection =\n productsConfig &&\n 'productsCollectionOverride' in productsConfig &&\n productsConfig.productsCollectionOverride\n ? await productsConfig.productsCollectionOverride({\n defaultCollection: defaultProductsCollection,\n })\n : defaultProductsCollection\n\n incomingConfig.collections.push(productsCollection)\n\n if (sanitizedPluginConfig.carts) {\n const cartsConfig =\n typeof sanitizedPluginConfig.carts === 'object' ? sanitizedPluginConfig.carts : {}\n\n const defaultCartsCollection = createCartsCollection({\n access: accessConfig,\n allowGuestCarts: cartsConfig.allowGuestCarts,\n cartItemMatcher: cartsConfig.cartItemMatcher,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants: Boolean(productsConfig.variants),\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants ?? 'variants',\n })\n\n const cartsCollection =\n sanitizedPluginConfig.carts &&\n typeof sanitizedPluginConfig.carts === 'object' &&\n 'cartsCollectionOverride' in sanitizedPluginConfig.carts &&\n sanitizedPluginConfig.carts.cartsCollectionOverride\n ? await sanitizedPluginConfig.carts.cartsCollectionOverride({\n defaultCollection: defaultCartsCollection,\n })\n : defaultCartsCollection\n\n incomingConfig.collections.push(cartsCollection)\n }\n }\n\n if (sanitizedPluginConfig.orders) {\n const defaultOrdersCollection = createOrdersCollection({\n access: accessConfig,\n addressFields,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants ?? 'variants',\n })\n\n const ordersCollection =\n sanitizedPluginConfig.orders &&\n typeof sanitizedPluginConfig.orders === 'object' &&\n 'ordersCollectionOverride' in sanitizedPluginConfig.orders &&\n sanitizedPluginConfig.orders.ordersCollectionOverride\n ? await sanitizedPluginConfig.orders.ordersCollectionOverride({\n defaultCollection: defaultOrdersCollection,\n })\n : defaultOrdersCollection\n\n incomingConfig.collections.push(ordersCollection)\n }\n\n const paymentMethods = sanitizedPluginConfig.payments.paymentMethods\n\n if (sanitizedPluginConfig.payments) {\n if (paymentMethods.length) {\n if (!Array.isArray(incomingConfig.endpoints)) {\n incomingConfig.endpoints = []\n }\n\n const productsValidation =\n (typeof sanitizedPluginConfig.products === 'object' &&\n sanitizedPluginConfig.products.validation) ||\n undefined\n\n paymentMethods.forEach((paymentMethod) => {\n const methodPath = `/payments/${paymentMethod.name}`\n const endpoints: Endpoint[] = []\n\n const initiatePayment: Endpoint = {\n handler: initiatePaymentHandler({\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n paymentMethod,\n productsSlug: collectionSlugMap.products,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n variantsSlug: collectionSlugMap.variants ?? 'variants',\n }),\n method: 'post',\n path: `${methodPath}/initiate`,\n }\n\n const confirmOrder: Endpoint = {\n handler: confirmOrderHandler({\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n ordersSlug: collectionSlugMap.orders,\n paymentMethod,\n productsSlug: collectionSlugMap.products,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n variantsSlug: collectionSlugMap.variants ?? 'variants',\n }),\n method: 'post',\n path: `${methodPath}/confirm-order`,\n }\n\n endpoints.push(initiatePayment, confirmOrder)\n\n // Attach any additional endpoints defined in the payment method\n if (paymentMethod.endpoints && paymentMethod.endpoints.length > 0) {\n const methodEndpoints = paymentMethod.endpoints.map((endpoint) => {\n const path = endpoint.path.startsWith('/') ? endpoint.path : `/${endpoint.path}`\n\n return {\n ...endpoint,\n path: `${methodPath}${path}`,\n }\n })\n\n endpoints.push(...methodEndpoints)\n }\n\n incomingConfig.endpoints!.push(...endpoints)\n })\n }\n }\n\n if (sanitizedPluginConfig.transactions) {\n const defaultTransactionsCollection = createTransactionsCollection({\n access: accessConfig,\n addressFields,\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n ordersSlug: collectionSlugMap.orders,\n paymentMethods,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants ?? 'variants',\n })\n\n const transactionsCollection =\n sanitizedPluginConfig.transactions &&\n typeof sanitizedPluginConfig.transactions === 'object' &&\n 'transactionsCollectionOverride' in sanitizedPluginConfig.transactions &&\n sanitizedPluginConfig.transactions.transactionsCollectionOverride\n ? await sanitizedPluginConfig.transactions.transactionsCollectionOverride({\n defaultCollection: defaultTransactionsCollection,\n })\n : defaultTransactionsCollection\n\n incomingConfig.collections.push(transactionsCollection)\n }\n\n if (!incomingConfig.i18n) {\n incomingConfig.i18n = {}\n }\n\n if (!incomingConfig.i18n?.translations) {\n incomingConfig.i18n.translations = {}\n }\n\n incomingConfig.i18n.translations = deepMergeSimple(\n translations,\n incomingConfig.i18n?.translations,\n )\n\n /**\n * Merge plugin translations\n */\n if (!incomingConfig.i18n) {\n incomingConfig.i18n = {}\n }\n Object.entries(translations).forEach(([locale, pluginI18nObject]) => {\n const typedLocale = locale as AcceptedLanguages\n if (!incomingConfig.i18n!.translations) {\n incomingConfig.i18n!.translations = {}\n }\n if (!(typedLocale in incomingConfig.i18n!.translations)) {\n incomingConfig.i18n!.translations[typedLocale] = {}\n }\n if (!('plugin-ecommerce' in incomingConfig.i18n!.translations[typedLocale]!)) {\n ;(incomingConfig.i18n!.translations[typedLocale] as PluginDefaultTranslationsObject)[\n 'plugin-ecommerce'\n ] = {} as PluginDefaultTranslationsObject['plugin-ecommerce']\n }\n\n ;(incomingConfig.i18n!.translations[typedLocale] as PluginDefaultTranslationsObject)[\n 'plugin-ecommerce'\n ] = {\n ...pluginI18nObject.translations['plugin-ecommerce'],\n }\n })\n\n if (!incomingConfig.typescript) {\n incomingConfig.typescript = {}\n }\n\n if (!incomingConfig.typescript.schema) {\n incomingConfig.typescript.schema = []\n }\n\n incomingConfig.typescript.schema.push((args) =>\n pushTypeScriptProperties({\n ...args,\n collectionSlugMap,\n sanitizedPluginConfig,\n }),\n )\n\n return incomingConfig\n }\n\nexport {\n createAddressesCollection,\n createCartsCollection,\n createOrdersCollection,\n createProductsCollection,\n createTransactionsCollection,\n createVariantOptionsCollection,\n createVariantsCollection,\n createVariantTypesCollection,\n}\n\nexport { addItem } from './collections/carts/operations/addItem.js'\nexport { clearCart } from './collections/carts/operations/clearCart.js'\nexport { defaultCartItemMatcher } from './collections/carts/operations/defaultCartItemMatcher.js'\nexport { removeItem } from './collections/carts/operations/removeItem.js'\nexport { isNumericOperator } from './collections/carts/operations/types.js'\nexport type {\n AddItemArgs,\n CartItemData,\n CartItemMatcher,\n CartItemMatcherArgs,\n CartOperationResult,\n ClearCartArgs,\n FieldWithOperator,\n NewCartItem,\n NumericOperator,\n RemoveItemArgs,\n UpdateItemArgs,\n} from './collections/carts/operations/types.js'\nexport { updateItem } from './collections/carts/operations/updateItem.js'\nexport { EUR, GBP, USD } from './currencies/index.js'\nexport { amountField } from './fields/amountField.js'\nexport { currencyField } from './fields/currencyField.js'\nexport { pricesField } from './fields/pricesField.js'\nexport { statusField } from './fields/statusField.js'\nexport { variantsFields } from './fields/variantsFields.js'\n"],"names":["deepMergeSimple","createAddressesCollection","createCartsCollection","createOrdersCollection","createProductsCollection","createTransactionsCollection","createVariantOptionsCollection","createVariantsCollection","createVariantTypesCollection","confirmOrderHandler","initiatePaymentHandler","translations","getCollectionSlugMap","pushTypeScriptProperties","sanitizePluginConfig","ecommercePlugin","pluginConfig","incomingConfig","sanitizedPluginConfig","accessConfig","access","collections","productsConfig","products","variants","undefined","enableVariants","Boolean","collectionSlugMap","currenciesConfig","currencies","addressFields","addresses","supportedCountries","defaultAddressesCollection","customersSlug","customers","addressesCollection","addressesCollectionOverride","defaultCollection","push","variantsConfig","defaultVariantsCollection","inventory","productsSlug","variantOptionsSlug","variantOptions","variantTypesSlug","variantTypes","variantsCollectionOverride","defaultVariantTypesCollection","variantTypesCollectionOverride","defaultVariantOptionsCollection","variantOptionsCollectionOverride","defaultProductsCollection","variantsSlug","productsCollection","productsCollectionOverride","carts","cartsConfig","defaultCartsCollection","allowGuestCarts","cartItemMatcher","cartsCollection","cartsCollectionOverride","orders","defaultOrdersCollection","ordersCollection","ordersCollectionOverride","paymentMethods","payments","length","Array","isArray","endpoints","productsValidation","validation","forEach","paymentMethod","methodPath","name","initiatePayment","handler","transactionsSlug","transactions","method","path","confirmOrder","cartsSlug","ordersSlug","methodEndpoints","map","endpoint","startsWith","defaultTransactionsCollection","transactionsCollection","transactionsCollectionOverride","i18n","Object","entries","locale","pluginI18nObject","typedLocale","typescript","schema","args","addItem","clearCart","defaultCartItemMatcher","removeItem","isNumericOperator","updateItem","EUR","GBP","USD","amountField","currencyField","pricesField","statusField","variantsFields"],"mappings":"AAGA,SAASA,eAAe,QAAQ,iBAAgB;AAKhD,SAASC,yBAAyB,QAAQ,uDAAsD;AAChG,SAASC,qBAAqB,QAAQ,+CAA8C;AACpF,SAASC,sBAAsB,QAAQ,iDAAgD;AACvF,SAASC,wBAAwB,QAAQ,qDAAoD;AAC7F,SAASC,4BAA4B,QAAQ,6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AEAvF,eAAesF,UAAU,CAACC,MAAM,CAAChE,IAAI,CAAC,CAACiE,OACrC5F,yBAAyB;gBACvB,GAAG4F,IAAI;gBACP7E;gBACAV;YACF;QAGF,OAAOD;IACT,EAAC;AAEH,SACEhB,yBAAyB,EACzBC,qBAAqB,EACrBC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,wBAAwB,EACxBC,4BAA4B,KAC7B;AAED,SAASkG,OAAO,QAAQ,4CAA2C;AACnE,SAASC,SAAS,QAAQ,8CAA6C;AACvE,SAASC,sBAAsB,QAAQ,2DAA0D;AACjG,SAASC,UAAU,QAAQ,+CAA8C;AACzE,SAASC,iBAAiB,QAAQ,0CAAyC;AAc3E,SAASC,UAAU,QAAQ,+CAA8C;AACzE,SAASC,GAAG,EAAEC,GAAG,EAAEC,GAAG,QAAQ,wBAAuB;AACrD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,cAAc,QAAQ,6BAA4B"}
@@ -1 +1 @@
1
- {"version":3,"file":"initiatePayment.d.ts","sourceRoot":"","sources":["../../../../src/payments/adapters/stripe/initiatePayment.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAA6B,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9E,KAAK,KAAK,GAAG;IACX,UAAU,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;IACxC,SAAS,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,WAAW,CAAC,cAAc,CAAC,CAAC,iBAAiB,CAuH1F,CAAA"}
1
+ {"version":3,"file":"initiatePayment.d.ts","sourceRoot":"","sources":["../../../../src/payments/adapters/stripe/initiatePayment.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAA6B,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9E,KAAK,KAAK,GAAG;IACX,UAAU,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;IACxC,SAAS,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,WAAW,CAAC,cAAc,CAAC,CAAC,iBAAiB,CA4H1F,CAAA"}
@@ -45,10 +45,16 @@ export const initiatePayment = (props)=>async ({ data, req, transactionsSlug })=
45
45
  const flattenedCart = cart.items.map((item)=>{
46
46
  const productID = typeof item.product === 'object' ? item.product.id : item.product;
47
47
  const variantID = item.variant ? typeof item.variant === 'object' ? item.variant.id : item.variant : undefined;
48
+ // Preserve any additional custom properties (e.g., deliveryOption, customizations)
49
+ // that may have been added via cartItemMatcher
50
+ const { product: _product, variant: _variant, ...customProperties } = item;
48
51
  return {
52
+ ...customProperties,
49
53
  product: productID,
50
54
  quantity: item.quantity,
51
- variant: variantID
55
+ ...variantID ? {
56
+ variant: variantID
57
+ } : {}
52
58
  };
53
59
  });
54
60
  const shippingAddressAsString = JSON.stringify(shippingAddressFromData);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/payments/adapters/stripe/initiatePayment.ts"],"sourcesContent":["import Stripe from 'stripe'\n\nimport type { PaymentAdapter } from '../../../types/index.js'\nimport type { InitiatePaymentReturnType, StripeAdapterArgs } from './index.js'\n\ntype Props = {\n apiVersion?: Stripe.StripeConfig['apiVersion']\n appInfo?: Stripe.StripeConfig['appInfo']\n secretKey: StripeAdapterArgs['secretKey']\n}\n\nexport const initiatePayment: (props: Props) => NonNullable<PaymentAdapter>['initiatePayment'] =\n (props) =>\n async ({ data, req, transactionsSlug }) => {\n const payload = req.payload\n const { apiVersion, appInfo, secretKey } = props || {}\n\n const customerEmail = data.customerEmail\n const currency = data.currency\n const cart = data.cart\n const amount = cart.subtotal\n const billingAddressFromData = data.billingAddress\n const shippingAddressFromData = data.shippingAddress\n\n if (!secretKey) {\n throw new Error('Stripe secret key is required.')\n }\n\n if (!currency) {\n throw new Error('Currency is required.')\n }\n\n if (!cart || !cart.items || cart.items.length === 0) {\n throw new Error('Cart is empty or not provided.')\n }\n\n if (!customerEmail || typeof customerEmail !== 'string') {\n throw new Error('A valid customer email is required to make a purchase.')\n }\n\n if (!amount || typeof amount !== 'number' || amount <= 0) {\n throw new Error('A valid amount is required to initiate a payment.')\n }\n\n const stripe = new Stripe(secretKey, {\n // API version can only be the latest, stripe recommends ts ignoring it\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - ignoring since possible versions are not type safe, only the latest version is recognised\n apiVersion: apiVersion || '2025-06-30.preview',\n appInfo: appInfo || {\n name: 'Stripe Payload Plugin',\n url: 'https://payloadcms.com',\n },\n })\n\n try {\n let customer = (\n await stripe.customers.list({\n email: customerEmail,\n })\n ).data[0]\n\n if (!customer?.id) {\n customer = await stripe.customers.create({\n email: customerEmail,\n })\n }\n\n const flattenedCart = cart.items.map((item) => {\n const productID = typeof item.product === 'object' ? item.product.id : item.product\n const variantID = item.variant\n ? typeof item.variant === 'object'\n ? item.variant.id\n : item.variant\n : undefined\n\n return {\n product: productID,\n quantity: item.quantity,\n variant: variantID,\n }\n })\n\n const shippingAddressAsString = JSON.stringify(shippingAddressFromData)\n\n const paymentIntent = await stripe.paymentIntents.create({\n amount,\n automatic_payment_methods: {\n enabled: true,\n },\n currency,\n customer: customer.id,\n metadata: {\n cartID: cart.id,\n cartItemsSnapshot: JSON.stringify(flattenedCart),\n shippingAddress: shippingAddressAsString,\n },\n })\n\n // Create a transaction for the payment intent in the database\n const transaction = await payload.create({\n collection: transactionsSlug,\n data: {\n ...(req.user ? { customer: req.user.id } : { customerEmail }),\n amount: paymentIntent.amount,\n billingAddress: billingAddressFromData,\n cart: cart.id,\n currency: paymentIntent.currency.toUpperCase(),\n items: flattenedCart,\n paymentMethod: 'stripe',\n status: 'pending',\n stripe: {\n customerID: customer.id,\n paymentIntentID: paymentIntent.id,\n },\n },\n })\n\n const returnData: InitiatePaymentReturnType = {\n clientSecret: paymentIntent.client_secret || '',\n message: 'Payment initiated successfully',\n paymentIntentID: paymentIntent.id,\n }\n\n return returnData\n } catch (error) {\n payload.logger.error(error, 'Error initiating payment with Stripe')\n\n throw new Error(error instanceof Error ? error.message : 'Unknown error initiating payment')\n }\n }\n"],"names":["Stripe","initiatePayment","props","data","req","transactionsSlug","payload","apiVersion","appInfo","secretKey","customerEmail","currency","cart","amount","subtotal","billingAddressFromData","billingAddress","shippingAddressFromData","shippingAddress","Error","items","length","stripe","name","url","customer","customers","list","email","id","create","flattenedCart","map","item","productID","product","variantID","variant","undefined","quantity","shippingAddressAsString","JSON","stringify","paymentIntent","paymentIntents","automatic_payment_methods","enabled","metadata","cartID","cartItemsSnapshot","transaction","collection","user","toUpperCase","paymentMethod","status","customerID","paymentIntentID","returnData","clientSecret","client_secret","message","error","logger"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAW3B,OAAO,MAAMC,kBACX,CAACC,QACD,OAAO,EAAEC,IAAI,EAAEC,GAAG,EAAEC,gBAAgB,EAAE;QACpC,MAAMC,UAAUF,IAAIE,OAAO;QAC3B,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGP,SAAS,CAAC;QAErD,MAAMQ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{"version":3,"sources":["../../../../src/payments/adapters/stripe/initiatePayment.ts"],"sourcesContent":["import Stripe from 'stripe'\n\nimport type { PaymentAdapter } from '../../../types/index.js'\nimport type { InitiatePaymentReturnType, StripeAdapterArgs } from './index.js'\n\ntype Props = {\n apiVersion?: Stripe.StripeConfig['apiVersion']\n appInfo?: Stripe.StripeConfig['appInfo']\n secretKey: StripeAdapterArgs['secretKey']\n}\n\nexport const initiatePayment: (props: Props) => NonNullable<PaymentAdapter>['initiatePayment'] =\n (props) =>\n async ({ data, req, transactionsSlug }) => {\n const payload = req.payload\n const { apiVersion, appInfo, secretKey } = props || {}\n\n const customerEmail = data.customerEmail\n const currency = data.currency\n const cart = data.cart\n const amount = cart.subtotal\n const billingAddressFromData = data.billingAddress\n const shippingAddressFromData = data.shippingAddress\n\n if (!secretKey) {\n throw new Error('Stripe secret key is required.')\n }\n\n if (!currency) {\n throw new Error('Currency is required.')\n }\n\n if (!cart || !cart.items || cart.items.length === 0) {\n throw new Error('Cart is empty or not provided.')\n }\n\n if (!customerEmail || typeof customerEmail !== 'string') {\n throw new Error('A valid customer email is required to make a purchase.')\n }\n\n if (!amount || typeof amount !== 'number' || amount <= 0) {\n throw new Error('A valid amount is required to initiate a payment.')\n }\n\n const stripe = new Stripe(secretKey, {\n // API version can only be the latest, stripe recommends ts ignoring it\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - ignoring since possible versions are not type safe, only the latest version is recognised\n apiVersion: apiVersion || '2025-06-30.preview',\n appInfo: appInfo || {\n name: 'Stripe Payload Plugin',\n url: 'https://payloadcms.com',\n },\n })\n\n try {\n let customer = (\n await stripe.customers.list({\n email: customerEmail,\n })\n ).data[0]\n\n if (!customer?.id) {\n customer = await stripe.customers.create({\n email: customerEmail,\n })\n }\n\n const flattenedCart = cart.items.map((item) => {\n const productID = typeof item.product === 'object' ? item.product.id : item.product\n const variantID = item.variant\n ? typeof item.variant === 'object'\n ? item.variant.id\n : item.variant\n : undefined\n\n // Preserve any additional custom properties (e.g., deliveryOption, customizations)\n // that may have been added via cartItemMatcher\n const { product: _product, variant: _variant, ...customProperties } = item\n\n return {\n ...customProperties,\n product: productID,\n quantity: item.quantity,\n ...(variantID ? { variant: variantID } : {}),\n }\n })\n\n const shippingAddressAsString = JSON.stringify(shippingAddressFromData)\n\n const paymentIntent = await stripe.paymentIntents.create({\n amount,\n automatic_payment_methods: {\n enabled: true,\n },\n currency,\n customer: customer.id,\n metadata: {\n cartID: cart.id,\n cartItemsSnapshot: JSON.stringify(flattenedCart),\n shippingAddress: shippingAddressAsString,\n },\n })\n\n // Create a transaction for the payment intent in the database\n const transaction = await payload.create({\n collection: transactionsSlug,\n data: {\n ...(req.user ? { customer: req.user.id } : { customerEmail }),\n amount: paymentIntent.amount,\n billingAddress: billingAddressFromData,\n cart: cart.id,\n currency: paymentIntent.currency.toUpperCase(),\n items: flattenedCart,\n paymentMethod: 'stripe',\n status: 'pending',\n stripe: {\n customerID: customer.id,\n paymentIntentID: paymentIntent.id,\n },\n },\n })\n\n const returnData: InitiatePaymentReturnType = {\n clientSecret: paymentIntent.client_secret || '',\n message: 'Payment initiated successfully',\n paymentIntentID: paymentIntent.id,\n }\n\n return returnData\n } catch (error) {\n payload.logger.error(error, 'Error initiating payment with Stripe')\n\n throw new Error(error instanceof Error ? error.message : 'Unknown error initiating payment')\n }\n }\n"],"names":["Stripe","initiatePayment","props","data","req","transactionsSlug","payload","apiVersion","appInfo","secretKey","customerEmail","currency","cart","amount","subtotal","billingAddressFromData","billingAddress","shippingAddressFromData","shippingAddress","Error","items","length","stripe","name","url","customer","customers","list","email","id","create","flattenedCart","map","item","productID","product","variantID","variant","undefined","_product","_variant","customProperties","quantity","shippingAddressAsString","JSON","stringify","paymentIntent","paymentIntents","automatic_payment_methods","enabled","metadata","cartID","cartItemsSnapshot","transaction","collection","user","toUpperCase","paymentMethod","status","customerID","paymentIntentID","returnData","clientSecret","client_secret","message","error","logger"],"mappings":"AAAA,OAAOA,YAAY,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BACP0B,eAAe;oBACfC,QAAQ;oBACRpC,QAAQ;wBACNqC,YAAYlC,SAASI,EAAE;wBACvB+B,iBAAiBd,cAAcjB,EAAE;oBACnC;gBACF;YACF;YAEA,MAAMgC,aAAwC;gBAC5CC,cAAchB,cAAciB,aAAa,IAAI;gBAC7CC,SAAS;gBACTJ,iBAAiBd,cAAcjB,EAAE;YACnC;YAEA,OAAOgC;QACT,EAAE,OAAOI,OAAO;YACd3D,QAAQ4D,MAAM,CAACD,KAAK,CAACA,OAAO;YAE5B,MAAM,IAAI9C,MAAM8C,iBAAiB9C,QAAQ8C,MAAMD,OAAO,GAAG;QAC3D;IACF,EAAC"}
@@ -578,6 +578,7 @@ export type ProductsValidation = (args: {
578
578
  /**
579
579
  * A map of collection slugs used by the Ecommerce plugin.
580
580
  * Provides an easy way to track the slugs of collections even when they are overridden.
581
+ * Variant-related slugs are only present when variants are enabled.
581
582
  */
582
583
  export type CollectionSlugMap = {
583
584
  addresses: string;
@@ -586,9 +587,9 @@ export type CollectionSlugMap = {
586
587
  orders: string;
587
588
  products: string;
588
589
  transactions: string;
589
- variantOptions: string;
590
- variants: string;
591
- variantTypes: string;
590
+ variantOptions?: string;
591
+ variants?: string;
592
+ variantTypes?: string;
592
593
  };
593
594
  /**
594
595
  * Access control functions used throughout the Ecommerce plugin.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,QAAQ,EACR,KAAK,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,eAAe,EACf,SAAS,EACT,KAAK,EACN,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,MAAM,cAAc,GAAG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C,CAAC,WAAW,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACjG;;OAEG;IACH,IAAI,EAAE,IAAI,GAAG,SAAS,CAAA;CACvB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n Access,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n PopulateType,\n SelectType,\n TypedCollection,\n TypedUser,\n Where,\n} from 'payload'\nimport type React from 'react'\n\nimport type { TypedEcommerce } from './utilities.js'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type CollectionOverride = (args: {\n defaultCollection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type CartItem = {\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id: string\n product: DefaultDocumentIDType | TypedCollection['products']\n quantity: number\n variant?: DefaultDocumentIDType | TypedCollection['variants']\n}\n\ntype DefaultCartType = {\n currency?: string\n customer?: DefaultDocumentIDType | TypedCollection['customers']\n id: DefaultDocumentIDType\n items: CartItem[]\n subtotal?: number\n}\n\nexport type Cart = DefaultCartType\n\ntype InitiatePaymentReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n}\n\ntype InitiatePayment = (args: {\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n data: {\n /**\n * Billing address for the payment.\n */\n billingAddress: TypedCollection['addresses']\n /**\n * Cart items.\n */\n cart: Cart\n /**\n * Currency code to use for the payment.\n */\n currency: string\n customerEmail: string\n /**\n * Shipping address for the payment.\n */\n shippingAddress?: TypedCollection['addresses']\n }\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug: string\n}) => InitiatePaymentReturnType | Promise<InitiatePaymentReturnType>\n\ntype ConfirmOrderReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n orderID: DefaultDocumentIDType\n transactionID: DefaultDocumentIDType\n}\n\ntype ConfirmOrder = (args: {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n * For example, this is used to retrieve the cart for the order.\n */\n cartsSlug?: string\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Data made available to the payment method when confirming an order. You should get the cart items from the transaction.\n */\n data: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any // Allows for additional data to be passed through, such as payment method specific data\n customerEmail?: string\n }\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug?: string\n}) => ConfirmOrderReturnType | Promise<ConfirmOrderReturnType>\n\n/**\n * The full payment adapter config expected as part of the config for the Ecommerce plugin.\n *\n * You can insert this type directly or return it from a function constructing it.\n */\nexport type PaymentAdapter = {\n /**\n * The function that is called via the `/api/payments/{provider_name}/confirm-order` endpoint to confirm an order after a payment has been made.\n *\n * You should handle the order confirmation logic here.\n *\n * @example\n *\n * ```ts\n * const confirmOrder: ConfirmOrder = async ({ data: { customerEmail }, ordersSlug, req, transactionsSlug }) => {\n // Confirm the payment with Stripe or another payment provider here\n // Create an order in the orders collection here\n // Update the record of the payment intent in the transactions collection here\n return {\n message: 'Order confirmed successfully',\n orderID: 'order_123',\n transactionID: 'txn_123',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n confirmOrder: ConfirmOrder\n /**\n * An array of endpoints to be bootstrapped to Payload's API in order to support the payment method. All API paths are relative to `/api/payments/{provider_name}`.\n *\n * So for example, path `/webhooks` in the Stripe adapter becomes `/api/payments/stripe/webhooks`.\n *\n * @example '/webhooks'\n */\n endpoints?: Endpoint[]\n /**\n * A group configuration to be used in the admin interface to display the payment method.\n *\n * @example\n *\n * ```ts\n * const groupField: GroupField = {\n name: 'stripe',\n type: 'group',\n admin: {\n condition: (data) => data?.paymentMethod === 'stripe',\n },\n fields: [\n {\n name: 'stripeCustomerID',\n type: 'text',\n label: 'Stripe Customer ID',\n required: true,\n },\n {\n name: 'stripePaymentIntentID',\n type: 'text',\n label: 'Stripe PaymentIntent ID',\n required: true,\n },\n ],\n }\n * ```\n */\n group: GroupField\n /**\n * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.\n *\n * You should handle the payment initiation logic here.\n *\n * @example\n *\n * ```ts\n * const initiatePayment: InitiatePayment = async ({ data: { cart, currency, customerEmail, billingAddress, shippingAddress }, req, transactionsSlug }) => {\n // Create a payment intent with Stripe or another payment provider here\n // Create a record of the payment intent in the transactions collection here\n return {\n message: 'Payment initiated successfully',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n initiatePayment: InitiatePayment\n /**\n * The label of the payment method\n * @example\n * 'Bank Transfer'\n */\n label?: string\n /**\n * The name of the payment method\n * @example 'stripe'\n */\n name: string\n}\n\nexport type PaymentAdapterClient = {\n confirmOrder: boolean\n initiatePayment: boolean\n} & Pick<PaymentAdapter, 'label' | 'name'>\n\nexport type Currency = {\n /**\n * The ISO 4217 currency code\n * @example 'usd'\n */\n code: string\n /**\n * The number of decimal places the currency uses\n * @example 2\n */\n decimals: number\n /**\n * A user friendly name for the currency.\n *\n * @example 'US Dollar'\n */\n label: string\n /**\n * The symbol of the currency\n * @example '$'\n */\n symbol: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterArgs = {\n /**\n * Overrides the default fields of the collection. Affects the payment fields on collections such as transactions.\n */\n groupOverrides?: { fields?: FieldsOverride } & Partial<Omit<GroupField, 'fields'>>\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterClientArgs = {\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\nexport type VariantsConfig = {\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantOptionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantOptionsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantTypesCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantTypesCollectionOverride?: CollectionOverride\n}\n\nexport type ProductsConfig = {\n /**\n * Override the default products collection. If you override the collection, you should ensure it has the required fields for products or re-use the default fields.\n *\n * @example\n *\n * ```ts\n products: {\n productsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n productsCollectionOverride?: CollectionOverride\n /**\n * Customise the validation used for checking products or variants before a transaction is created or a payment can be confirmed.\n */\n validation?: ProductsValidation\n /**\n * Enable variants and provide configuration for the variant collections.\n *\n * Defaults to true.\n */\n variants?: boolean | VariantsConfig\n}\n\nexport type OrdersConfig = {\n /**\n * Override the default orders collection. If you override the collection, you should ensure it has the required fields for orders or re-use the default fields.\n *\n * @example\n *\n * ```ts\n orders: {\n ordersCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n ordersCollectionOverride?: CollectionOverride\n}\n\nexport type TransactionsConfig = {\n /**\n * Override the default transactions collection. If you override the collection, you should ensure it has the required fields for transactions or re-use the default fields.\n *\n * @example\n *\n * ```ts\n transactions: {\n transactionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n transactionsCollectionOverride?: CollectionOverride\n}\n\nexport type CustomQuery = {\n depth?: number\n select?: SelectType\n where?: Where\n}\n\nexport type PaymentsConfig = {\n paymentMethods?: PaymentAdapter[]\n productsQuery?: CustomQuery\n variantsQuery?: CustomQuery\n}\n\nexport type CountryType = {\n /**\n * A user friendly name for the country.\n */\n label: string\n /**\n * The ISO 3166-1 alpha-2 country code.\n * @example 'US'\n */\n value: string\n}\n\n/**\n * Configuration for the addresses used by the Ecommerce plugin. Use this to override the default collection or fields used throughout\n */\ntype AddressesConfig = {\n /**\n * Override the default addresses collection. If you override the collection, you should ensure it has the required fields for addresses or re-use the default fields.\n *\n * @example\n * ```ts\n * addressesCollectionOverride: (defaultCollection) => {\n * return {\n * ...defaultCollection,\n * fields: [\n * ...defaultCollection.fields,\n * // add custom fields here\n * ],\n * }\n * }\n * ```\n */\n addressesCollectionOverride?: CollectionOverride\n /**\n * These fields will be applied to all locations where addresses are used, such as Orders and Transactions. Preferred use over the collectionOverride config.\n */\n addressFields?: FieldsOverride\n /**\n * Provide an array of countries to support for addresses. This will be used in the admin interface to provide a select field of countries.\n *\n * Defaults to a set of commonly used countries.\n *\n * @example\n * ```\n * [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ]\n */\n supportedCountries?: CountryType[]\n}\n\nexport type CustomersConfig = {\n /**\n * Slug of the customers collection, defaults to 'users'.\n * This is used to link carts and orders to customers.\n */\n slug: string\n}\n\n/**\n * Arguments for the cart item matcher function.\n */\nexport type CartItemMatcherArgs = {\n /** The existing cart item to compare against */\n existingItem: {\n [key: string]: unknown\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id?: string\n product: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n quantity: number\n variant?: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n }\n /** The new item being added */\n newItem: {\n [key: string]: unknown\n product: DefaultDocumentIDType\n quantity?: number\n variant?: DefaultDocumentIDType\n }\n}\n\n/**\n * Function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n */\nexport type CartItemMatcher = (args: CartItemMatcherArgs) => boolean\n\nexport type CartsConfig = {\n /**\n * Allow guest (unauthenticated) users to create carts.\n * When enabled, guests can create carts without being logged in.\n * Defaults to true.\n */\n allowGuestCarts?: boolean\n /**\n * Custom function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n *\n * Use this to add custom uniqueness criteria beyond product and variant IDs.\n *\n * @default defaultCartItemMatcher (matches by product and variant ID only)\n *\n * @example\n * ```ts\n * cartItemMatcher: ({ existingItem, newItem }) => {\n * // Match by product, variant, AND custom delivery option\n * const productMatch = existingItem.product === newItem.product\n * const variantMatch = existingItem.variant === newItem.variant\n * const deliveryMatch = existingItem.deliveryOption === newItem.deliveryOption\n * return productMatch && variantMatch && deliveryMatch\n * }\n * ```\n */\n cartItemMatcher?: CartItemMatcher\n cartsCollectionOverride?: CollectionOverride\n}\n\nexport type InventoryConfig = {\n /**\n * Override the default field used to track inventory levels. Defaults to 'inventory'.\n */\n fieldName?: string\n}\n\nexport type CurrenciesConfig = {\n /**\n * Defaults to the first supported currency.\n *\n * @example 'USD'\n */\n defaultCurrency: string\n /**\n *\n */\n supportedCurrencies: Currency[]\n}\n\n/**\n * A function that validates a product or variant before a transaction is created or completed.\n * This should throw an error if validation fails as it will be caught by the function calling it.\n */\nexport type ProductsValidation = (args: {\n /**\n * The full currencies config, allowing you to check against supported currencies and their settings.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The ISO 4217 currency code being usen in this transaction.\n */\n currency?: string\n /**\n * The full product data.\n */\n product: TypedCollection['products']\n /**\n * Quantity to check the inventory amount against.\n */\n quantity: number\n /**\n * The full variant data, if a variant was selected for the product otherwise it will be undefined.\n */\n variant?: TypedCollection['variants']\n}) => Promise<void> | void\n\n/**\n * A map of collection slugs used by the Ecommerce plugin.\n * Provides an easy way to track the slugs of collections even when they are overridden.\n */\nexport type CollectionSlugMap = {\n addresses: string\n carts: string\n customers: string\n orders: string\n products: string\n transactions: string\n variantOptions: string\n variants: string\n variantTypes: string\n}\n\n/**\n * Access control functions used throughout the Ecommerce plugin.\n * Provide atomic access functions that can be composed using or, and, conditional utilities.\n *\n * @example\n * ```ts\n * access: {\n * isAdmin: ({ req }) => checkRole(['admin'], req.user),\n * isAuthenticated: ({ req }) => !!req.user,\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user),\n * isDocumentOwner: ({ req }) => {\n * if (!req.user) return false\n * return { customer: { equals: req.user.id } }\n * },\n * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),\n * adminOrPublishedStatus: ({ req }) => {\n * if (checkRole(['admin'], req.user)) return true\n * return { _status: { equals: 'published' } }\n * },\n * }\n * ```\n */\nexport type AccessConfig = {\n /**\n * Limited to only admin users, specifically for Field level access control.\n */\n adminOnlyFieldAccess: FieldAccess\n /**\n * The document status is published or user is admin.\n */\n adminOrPublishedStatus: Access\n /**\n * @deprecated Will be removed in v4. Use `isCustomer` instead.\n * Limited to customers only, specifically for Field level access control.\n */\n customerOnlyFieldAccess?: FieldAccess\n /**\n * Checks if the user is an admin.\n * @returns true if admin, false otherwise\n */\n isAdmin: Access\n /**\n * Checks if the user is authenticated (any role).\n * @returns true if authenticated, false otherwise\n */\n isAuthenticated?: Access\n /**\n * Checks if the user is a customer (authenticated but not an admin).\n * Used internally to auto-assign customer ID when creating addresses.\n * @returns true if user is a non-admin customer, false otherwise\n *\n * @example\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user)\n */\n isCustomer?: FieldAccess\n /**\n * Checks if the user owns the document being accessed.\n * Typically returns a Where query to filter by customer field.\n * @returns true for full access, false for no access, or Where query for conditional access\n */\n isDocumentOwner: Access\n /**\n * Entirely public access. Defaults to returning true.\n *\n * @example\n * publicAccess: () => true\n */\n publicAccess?: Access\n}\n\nexport type EcommercePluginConfig = {\n /**\n * Customise the access control for the plugin.\n *\n * @example\n * ```ts\n * ```\n */\n access: AccessConfig\n /**\n * Enable the addresses collection to allow customers, transactions and orders to have multiple addresses for shipping and billing. Accepts an override to customise the addresses collection.\n * Defaults to supporting a default set of countries.\n */\n addresses?: AddressesConfig | boolean\n /**\n * Configure the target collection used for carts.\n *\n * Defaults to true.\n */\n carts?: boolean | CartsConfig\n /**\n * Configure supported currencies and default settings.\n *\n * Defaults to supporting USD.\n */\n currencies?: CurrenciesConfig\n /**\n * Configure the target collection used for customers.\n *\n * @example\n * ```ts\n * customers: {\n * slug: 'users', // default\n * }\n *\n */\n customers: CustomersConfig\n /**\n * Enable tracking of inventory for products and variants. Accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Enables orders and accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n orders?: boolean | OrdersConfig\n /**\n * Enable tracking of payments. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n payments?: PaymentsConfig\n /**\n * Enables products and variants. Accepts a config object to override the product collection and each variant collection type.\n *\n * Defaults to true.\n */\n products?: boolean | ProductsConfig\n /**\n * Override the default slugs used across the plugin. This lets the plugin know which slugs to use for various internal operations and fields.\n */\n slugMap?: Partial<CollectionSlugMap>\n /**\n * Enable tracking of transactions. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n transactions?: boolean | TransactionsConfig\n}\n\nexport type SanitizedAccessConfig = Pick<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'> &\n Required<Omit<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'>>\n\nexport type SanitizedEcommercePluginConfig = {\n access: SanitizedAccessConfig\n addresses: { addressFields: Field[] } & Omit<AddressesConfig, 'addressFields'>\n currencies: Required<CurrenciesConfig>\n inventory?: InventoryConfig\n payments: {\n paymentMethods: [] | PaymentAdapter[]\n }\n} & Omit<\n Required<EcommercePluginConfig>,\n 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'\n>\n\nexport type EcommerceCollections = TypedEcommerce['collections']\n\nexport type AddressesCollection = EcommerceCollections['addresses']\nexport type CartsCollection = EcommerceCollections['carts']\n\nexport type SyncLocalStorageConfig = {\n /**\n * Key to use for localStorage.\n * Defaults to 'cart'.\n */\n key?: string\n}\n\ntype APIProps = {\n /**\n * The route for the Payload API, defaults to `/api`.\n */\n apiRoute?: string\n /**\n * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.\n *\n * Defaults to `{ depth: 0 }`.\n */\n cartsFetchQuery?: {\n depth?: number\n populate?: PopulateType\n select?: SelectType\n }\n /**\n * The route for the Payload API, defaults to ``. Eg for a Payload app running on `http://localhost:3000`, the default serverURL would be `http://localhost:3000`.\n */\n serverURL?: string\n}\n\n/**\n * Memoized configuration object exposed via the useEcommerce hook.\n * Contains collection slugs and API settings for building URLs and queries.\n */\nexport type EcommerceConfig = {\n /**\n * The slug for the addresses collection.\n */\n addressesSlug: CollectionSlug\n /**\n * API configuration including the base route.\n */\n api: {\n /**\n * The base API route, e.g. '/api'.\n */\n apiRoute: string\n }\n /**\n * The slug for the carts collection.\n */\n cartsSlug: CollectionSlug\n /**\n * The slug for the customers collection.\n */\n customersSlug: CollectionSlug\n}\n\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: CollectionSlug\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: CollectionSlug\n children?: React.ReactNode\n /**\n * The configuration for currencies used in the ecommerce context.\n * This is used to handle currency formatting and calculations, defaults to USD.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The slug for the customers collection.\n *\n * Defaults to 'users'.\n */\n customersSlug?: CollectionSlug\n /**\n * Enable debug mode for the ecommerce context. This will log additional information to the console.\n * Defaults to false.\n */\n debug?: boolean\n /**\n * Whether to enable support for variants in the cart.\n * This allows adding products with specific variants to the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Supported payment methods for the ecommerce context.\n */\n paymentMethods?: PaymentAdapterClient[]\n /**\n * Whether to enable localStorage for cart persistence.\n * Defaults to true.\n */\n syncLocalStorage?: boolean | SyncLocalStorageConfig\n}\n\n/**\n * Type used internally to represent the cart item to be added.\n */\ntype CartItemArgument = {\n /**\n * The ID of the product to add to the cart. Always required.\n */\n product: DefaultDocumentIDType\n /**\n * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.\n */\n variant?: DefaultDocumentIDType\n}\n\nexport type EcommerceContextType<T extends EcommerceCollections = EcommerceCollections> = {\n /**\n * Add an item to the cart.\n */\n addItem: (item: CartItemArgument, quantity?: number) => Promise<void>\n /**\n * All current addresses for the current user.\n * This is used to manage shipping and billing addresses.\n */\n addresses?: T['addresses'][]\n /**\n * The current data of the cart.\n */\n cart?: T['addresses']\n /**\n * The ID of the current cart corresponding to the cart in the database or local storage.\n */\n cartID?: DefaultDocumentIDType\n /**\n * Clear the cart, removing all items.\n */\n clearCart: () => Promise<void>\n /**\n * Clears all ecommerce session data including cart, addresses, and user state.\n * Should be called when a user logs out.\n * This also clears localStorage cart data when syncLocalStorage is enabled.\n */\n clearSession: () => void\n /**\n * Memoized configuration object containing collection slugs and API settings.\n * Use this to build URLs and queries with the correct collection slugs.\n */\n config: EcommerceConfig\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n confirmOrder: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Create a new address by providing the data.\n */\n createAddress: (data: Partial<T['addresses']>) => Promise<void>\n /**\n * The configuration for the currencies used in the ecommerce context.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The currently selected currency used for the cart and price formatting automatically.\n */\n currency: Currency\n /**\n * Decrement an item in the cart by its array item ID.\n * If quantity reaches 0, the item will be removed from the cart.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n decrementItem: (item: string) => Promise<void>\n /**\n * Increment an item in the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n incrementItem: (item: string) => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n initiatePayment: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Indicates whether any cart operation is currently in progress.\n * Useful for disabling buttons and preventing race conditions.\n */\n isLoading: boolean\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n mergeCart: (\n targetCartID: DefaultDocumentIDType,\n sourceCartID: DefaultDocumentIDType,\n sourceSecret?: string,\n ) => Promise<T['carts'] | void>\n /**\n * Called after a successful login to handle cart state.\n * If a guest cart exists, it will be merged with the user's existing cart\n * or assigned to the user if they have no cart.\n * Cart secrets are cleared as authenticated users don't need them.\n *\n * @returns Promise that resolves when cart state is properly set up for the user.\n */\n onLogin: () => Promise<void>\n /**\n * Called during logout to clear all ecommerce session data.\n * Clears cart, addresses, user state, and localStorage cart data.\n * This is an alias for clearSession() but named for semantic clarity.\n */\n onLogout: () => void\n paymentMethods: PaymentAdapterClient[]\n /**\n * Refresh the cart.\n */\n refreshCart: () => Promise<void>\n /**\n * Remove an item from the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n removeItem: (item: string) => Promise<void>\n /**\n * The name of the currently selected payment method.\n * This is used to determine which payment method to use when initiating a payment.\n */\n selectedPaymentMethod?: null | string\n /**\n * Change the currency for the cart, it defaults to the configured currency.\n * This will update the currency used for pricing and calculations.\n */\n setCurrency: (currency: string) => void\n /**\n * Update an address by providing the data and the ID.\n */\n updateAddress: (addressID: DefaultDocumentIDType, data: Partial<T['addresses']>) => Promise<void>\n /**\n * The current authenticated user, or null if not logged in.\n */\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAm5BA,WAwIC"}
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n Access,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n PopulateType,\n SelectType,\n TypedCollection,\n TypedUser,\n Where,\n} from 'payload'\nimport type React from 'react'\n\nimport type { TypedEcommerce } from './utilities.js'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type CollectionOverride = (args: {\n defaultCollection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type CartItem = {\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id: string\n product: DefaultDocumentIDType | TypedCollection['products']\n quantity: number\n variant?: DefaultDocumentIDType | TypedCollection['variants']\n}\n\ntype DefaultCartType = {\n currency?: string\n customer?: DefaultDocumentIDType | TypedCollection['customers']\n id: DefaultDocumentIDType\n items: CartItem[]\n subtotal?: number\n}\n\nexport type Cart = DefaultCartType\n\ntype InitiatePaymentReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n}\n\ntype InitiatePayment = (args: {\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n data: {\n /**\n * Billing address for the payment.\n */\n billingAddress: TypedCollection['addresses']\n /**\n * Cart items.\n */\n cart: Cart\n /**\n * Currency code to use for the payment.\n */\n currency: string\n customerEmail: string\n /**\n * Shipping address for the payment.\n */\n shippingAddress?: TypedCollection['addresses']\n }\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug: string\n}) => InitiatePaymentReturnType | Promise<InitiatePaymentReturnType>\n\ntype ConfirmOrderReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n orderID: DefaultDocumentIDType\n transactionID: DefaultDocumentIDType\n}\n\ntype ConfirmOrder = (args: {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n * For example, this is used to retrieve the cart for the order.\n */\n cartsSlug?: string\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Data made available to the payment method when confirming an order. You should get the cart items from the transaction.\n */\n data: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any // Allows for additional data to be passed through, such as payment method specific data\n customerEmail?: string\n }\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug?: string\n}) => ConfirmOrderReturnType | Promise<ConfirmOrderReturnType>\n\n/**\n * The full payment adapter config expected as part of the config for the Ecommerce plugin.\n *\n * You can insert this type directly or return it from a function constructing it.\n */\nexport type PaymentAdapter = {\n /**\n * The function that is called via the `/api/payments/{provider_name}/confirm-order` endpoint to confirm an order after a payment has been made.\n *\n * You should handle the order confirmation logic here.\n *\n * @example\n *\n * ```ts\n * const confirmOrder: ConfirmOrder = async ({ data: { customerEmail }, ordersSlug, req, transactionsSlug }) => {\n // Confirm the payment with Stripe or another payment provider here\n // Create an order in the orders collection here\n // Update the record of the payment intent in the transactions collection here\n return {\n message: 'Order confirmed successfully',\n orderID: 'order_123',\n transactionID: 'txn_123',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n confirmOrder: ConfirmOrder\n /**\n * An array of endpoints to be bootstrapped to Payload's API in order to support the payment method. All API paths are relative to `/api/payments/{provider_name}`.\n *\n * So for example, path `/webhooks` in the Stripe adapter becomes `/api/payments/stripe/webhooks`.\n *\n * @example '/webhooks'\n */\n endpoints?: Endpoint[]\n /**\n * A group configuration to be used in the admin interface to display the payment method.\n *\n * @example\n *\n * ```ts\n * const groupField: GroupField = {\n name: 'stripe',\n type: 'group',\n admin: {\n condition: (data) => data?.paymentMethod === 'stripe',\n },\n fields: [\n {\n name: 'stripeCustomerID',\n type: 'text',\n label: 'Stripe Customer ID',\n required: true,\n },\n {\n name: 'stripePaymentIntentID',\n type: 'text',\n label: 'Stripe PaymentIntent ID',\n required: true,\n },\n ],\n }\n * ```\n */\n group: GroupField\n /**\n * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.\n *\n * You should handle the payment initiation logic here.\n *\n * @example\n *\n * ```ts\n * const initiatePayment: InitiatePayment = async ({ data: { cart, currency, customerEmail, billingAddress, shippingAddress }, req, transactionsSlug }) => {\n // Create a payment intent with Stripe or another payment provider here\n // Create a record of the payment intent in the transactions collection here\n return {\n message: 'Payment initiated successfully',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n initiatePayment: InitiatePayment\n /**\n * The label of the payment method\n * @example\n * 'Bank Transfer'\n */\n label?: string\n /**\n * The name of the payment method\n * @example 'stripe'\n */\n name: string\n}\n\nexport type PaymentAdapterClient = {\n confirmOrder: boolean\n initiatePayment: boolean\n} & Pick<PaymentAdapter, 'label' | 'name'>\n\nexport type Currency = {\n /**\n * The ISO 4217 currency code\n * @example 'usd'\n */\n code: string\n /**\n * The number of decimal places the currency uses\n * @example 2\n */\n decimals: number\n /**\n * A user friendly name for the currency.\n *\n * @example 'US Dollar'\n */\n label: string\n /**\n * The symbol of the currency\n * @example '$'\n */\n symbol: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterArgs = {\n /**\n * Overrides the default fields of the collection. Affects the payment fields on collections such as transactions.\n */\n groupOverrides?: { fields?: FieldsOverride } & Partial<Omit<GroupField, 'fields'>>\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterClientArgs = {\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\nexport type VariantsConfig = {\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantOptionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantOptionsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantTypesCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantTypesCollectionOverride?: CollectionOverride\n}\n\nexport type ProductsConfig = {\n /**\n * Override the default products collection. If you override the collection, you should ensure it has the required fields for products or re-use the default fields.\n *\n * @example\n *\n * ```ts\n products: {\n productsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n productsCollectionOverride?: CollectionOverride\n /**\n * Customise the validation used for checking products or variants before a transaction is created or a payment can be confirmed.\n */\n validation?: ProductsValidation\n /**\n * Enable variants and provide configuration for the variant collections.\n *\n * Defaults to true.\n */\n variants?: boolean | VariantsConfig\n}\n\nexport type OrdersConfig = {\n /**\n * Override the default orders collection. If you override the collection, you should ensure it has the required fields for orders or re-use the default fields.\n *\n * @example\n *\n * ```ts\n orders: {\n ordersCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n ordersCollectionOverride?: CollectionOverride\n}\n\nexport type TransactionsConfig = {\n /**\n * Override the default transactions collection. If you override the collection, you should ensure it has the required fields for transactions or re-use the default fields.\n *\n * @example\n *\n * ```ts\n transactions: {\n transactionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n transactionsCollectionOverride?: CollectionOverride\n}\n\nexport type CustomQuery = {\n depth?: number\n select?: SelectType\n where?: Where\n}\n\nexport type PaymentsConfig = {\n paymentMethods?: PaymentAdapter[]\n productsQuery?: CustomQuery\n variantsQuery?: CustomQuery\n}\n\nexport type CountryType = {\n /**\n * A user friendly name for the country.\n */\n label: string\n /**\n * The ISO 3166-1 alpha-2 country code.\n * @example 'US'\n */\n value: string\n}\n\n/**\n * Configuration for the addresses used by the Ecommerce plugin. Use this to override the default collection or fields used throughout\n */\ntype AddressesConfig = {\n /**\n * Override the default addresses collection. If you override the collection, you should ensure it has the required fields for addresses or re-use the default fields.\n *\n * @example\n * ```ts\n * addressesCollectionOverride: (defaultCollection) => {\n * return {\n * ...defaultCollection,\n * fields: [\n * ...defaultCollection.fields,\n * // add custom fields here\n * ],\n * }\n * }\n * ```\n */\n addressesCollectionOverride?: CollectionOverride\n /**\n * These fields will be applied to all locations where addresses are used, such as Orders and Transactions. Preferred use over the collectionOverride config.\n */\n addressFields?: FieldsOverride\n /**\n * Provide an array of countries to support for addresses. This will be used in the admin interface to provide a select field of countries.\n *\n * Defaults to a set of commonly used countries.\n *\n * @example\n * ```\n * [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ]\n */\n supportedCountries?: CountryType[]\n}\n\nexport type CustomersConfig = {\n /**\n * Slug of the customers collection, defaults to 'users'.\n * This is used to link carts and orders to customers.\n */\n slug: string\n}\n\n/**\n * Arguments for the cart item matcher function.\n */\nexport type CartItemMatcherArgs = {\n /** The existing cart item to compare against */\n existingItem: {\n [key: string]: unknown\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id?: string\n product: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n quantity: number\n variant?: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n }\n /** The new item being added */\n newItem: {\n [key: string]: unknown\n product: DefaultDocumentIDType\n quantity?: number\n variant?: DefaultDocumentIDType\n }\n}\n\n/**\n * Function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n */\nexport type CartItemMatcher = (args: CartItemMatcherArgs) => boolean\n\nexport type CartsConfig = {\n /**\n * Allow guest (unauthenticated) users to create carts.\n * When enabled, guests can create carts without being logged in.\n * Defaults to true.\n */\n allowGuestCarts?: boolean\n /**\n * Custom function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n *\n * Use this to add custom uniqueness criteria beyond product and variant IDs.\n *\n * @default defaultCartItemMatcher (matches by product and variant ID only)\n *\n * @example\n * ```ts\n * cartItemMatcher: ({ existingItem, newItem }) => {\n * // Match by product, variant, AND custom delivery option\n * const productMatch = existingItem.product === newItem.product\n * const variantMatch = existingItem.variant === newItem.variant\n * const deliveryMatch = existingItem.deliveryOption === newItem.deliveryOption\n * return productMatch && variantMatch && deliveryMatch\n * }\n * ```\n */\n cartItemMatcher?: CartItemMatcher\n cartsCollectionOverride?: CollectionOverride\n}\n\nexport type InventoryConfig = {\n /**\n * Override the default field used to track inventory levels. Defaults to 'inventory'.\n */\n fieldName?: string\n}\n\nexport type CurrenciesConfig = {\n /**\n * Defaults to the first supported currency.\n *\n * @example 'USD'\n */\n defaultCurrency: string\n /**\n *\n */\n supportedCurrencies: Currency[]\n}\n\n/**\n * A function that validates a product or variant before a transaction is created or completed.\n * This should throw an error if validation fails as it will be caught by the function calling it.\n */\nexport type ProductsValidation = (args: {\n /**\n * The full currencies config, allowing you to check against supported currencies and their settings.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The ISO 4217 currency code being usen in this transaction.\n */\n currency?: string\n /**\n * The full product data.\n */\n product: TypedCollection['products']\n /**\n * Quantity to check the inventory amount against.\n */\n quantity: number\n /**\n * The full variant data, if a variant was selected for the product otherwise it will be undefined.\n */\n variant?: TypedCollection['variants']\n}) => Promise<void> | void\n\n/**\n * A map of collection slugs used by the Ecommerce plugin.\n * Provides an easy way to track the slugs of collections even when they are overridden.\n * Variant-related slugs are only present when variants are enabled.\n */\nexport type CollectionSlugMap = {\n addresses: string\n carts: string\n customers: string\n orders: string\n products: string\n transactions: string\n variantOptions?: string\n variants?: string\n variantTypes?: string\n}\n\n/**\n * Access control functions used throughout the Ecommerce plugin.\n * Provide atomic access functions that can be composed using or, and, conditional utilities.\n *\n * @example\n * ```ts\n * access: {\n * isAdmin: ({ req }) => checkRole(['admin'], req.user),\n * isAuthenticated: ({ req }) => !!req.user,\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user),\n * isDocumentOwner: ({ req }) => {\n * if (!req.user) return false\n * return { customer: { equals: req.user.id } }\n * },\n * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),\n * adminOrPublishedStatus: ({ req }) => {\n * if (checkRole(['admin'], req.user)) return true\n * return { _status: { equals: 'published' } }\n * },\n * }\n * ```\n */\nexport type AccessConfig = {\n /**\n * Limited to only admin users, specifically for Field level access control.\n */\n adminOnlyFieldAccess: FieldAccess\n /**\n * The document status is published or user is admin.\n */\n adminOrPublishedStatus: Access\n /**\n * @deprecated Will be removed in v4. Use `isCustomer` instead.\n * Limited to customers only, specifically for Field level access control.\n */\n customerOnlyFieldAccess?: FieldAccess\n /**\n * Checks if the user is an admin.\n * @returns true if admin, false otherwise\n */\n isAdmin: Access\n /**\n * Checks if the user is authenticated (any role).\n * @returns true if authenticated, false otherwise\n */\n isAuthenticated?: Access\n /**\n * Checks if the user is a customer (authenticated but not an admin).\n * Used internally to auto-assign customer ID when creating addresses.\n * @returns true if user is a non-admin customer, false otherwise\n *\n * @example\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user)\n */\n isCustomer?: FieldAccess\n /**\n * Checks if the user owns the document being accessed.\n * Typically returns a Where query to filter by customer field.\n * @returns true for full access, false for no access, or Where query for conditional access\n */\n isDocumentOwner: Access\n /**\n * Entirely public access. Defaults to returning true.\n *\n * @example\n * publicAccess: () => true\n */\n publicAccess?: Access\n}\n\nexport type EcommercePluginConfig = {\n /**\n * Customise the access control for the plugin.\n *\n * @example\n * ```ts\n * ```\n */\n access: AccessConfig\n /**\n * Enable the addresses collection to allow customers, transactions and orders to have multiple addresses for shipping and billing. Accepts an override to customise the addresses collection.\n * Defaults to supporting a default set of countries.\n */\n addresses?: AddressesConfig | boolean\n /**\n * Configure the target collection used for carts.\n *\n * Defaults to true.\n */\n carts?: boolean | CartsConfig\n /**\n * Configure supported currencies and default settings.\n *\n * Defaults to supporting USD.\n */\n currencies?: CurrenciesConfig\n /**\n * Configure the target collection used for customers.\n *\n * @example\n * ```ts\n * customers: {\n * slug: 'users', // default\n * }\n *\n */\n customers: CustomersConfig\n /**\n * Enable tracking of inventory for products and variants. Accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Enables orders and accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n orders?: boolean | OrdersConfig\n /**\n * Enable tracking of payments. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n payments?: PaymentsConfig\n /**\n * Enables products and variants. Accepts a config object to override the product collection and each variant collection type.\n *\n * Defaults to true.\n */\n products?: boolean | ProductsConfig\n /**\n * Override the default slugs used across the plugin. This lets the plugin know which slugs to use for various internal operations and fields.\n */\n slugMap?: Partial<CollectionSlugMap>\n /**\n * Enable tracking of transactions. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n transactions?: boolean | TransactionsConfig\n}\n\nexport type SanitizedAccessConfig = Pick<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'> &\n Required<Omit<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'>>\n\nexport type SanitizedEcommercePluginConfig = {\n access: SanitizedAccessConfig\n addresses: { addressFields: Field[] } & Omit<AddressesConfig, 'addressFields'>\n currencies: Required<CurrenciesConfig>\n inventory?: InventoryConfig\n payments: {\n paymentMethods: [] | PaymentAdapter[]\n }\n} & Omit<\n Required<EcommercePluginConfig>,\n 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'\n>\n\nexport type EcommerceCollections = TypedEcommerce['collections']\n\nexport type AddressesCollection = EcommerceCollections['addresses']\nexport type CartsCollection = EcommerceCollections['carts']\n\nexport type SyncLocalStorageConfig = {\n /**\n * Key to use for localStorage.\n * Defaults to 'cart'.\n */\n key?: string\n}\n\ntype APIProps = {\n /**\n * The route for the Payload API, defaults to `/api`.\n */\n apiRoute?: string\n /**\n * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.\n *\n * Defaults to `{ depth: 0 }`.\n */\n cartsFetchQuery?: {\n depth?: number\n populate?: PopulateType\n select?: SelectType\n }\n /**\n * The route for the Payload API, defaults to ``. Eg for a Payload app running on `http://localhost:3000`, the default serverURL would be `http://localhost:3000`.\n */\n serverURL?: string\n}\n\n/**\n * Memoized configuration object exposed via the useEcommerce hook.\n * Contains collection slugs and API settings for building URLs and queries.\n */\nexport type EcommerceConfig = {\n /**\n * The slug for the addresses collection.\n */\n addressesSlug: CollectionSlug\n /**\n * API configuration including the base route.\n */\n api: {\n /**\n * The base API route, e.g. '/api'.\n */\n apiRoute: string\n }\n /**\n * The slug for the carts collection.\n */\n cartsSlug: CollectionSlug\n /**\n * The slug for the customers collection.\n */\n customersSlug: CollectionSlug\n}\n\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: CollectionSlug\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: CollectionSlug\n children?: React.ReactNode\n /**\n * The configuration for currencies used in the ecommerce context.\n * This is used to handle currency formatting and calculations, defaults to USD.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The slug for the customers collection.\n *\n * Defaults to 'users'.\n */\n customersSlug?: CollectionSlug\n /**\n * Enable debug mode for the ecommerce context. This will log additional information to the console.\n * Defaults to false.\n */\n debug?: boolean\n /**\n * Whether to enable support for variants in the cart.\n * This allows adding products with specific variants to the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Supported payment methods for the ecommerce context.\n */\n paymentMethods?: PaymentAdapterClient[]\n /**\n * Whether to enable localStorage for cart persistence.\n * Defaults to true.\n */\n syncLocalStorage?: boolean | SyncLocalStorageConfig\n}\n\n/**\n * Type used internally to represent the cart item to be added.\n */\ntype CartItemArgument = {\n /**\n * The ID of the product to add to the cart. Always required.\n */\n product: DefaultDocumentIDType\n /**\n * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.\n */\n variant?: DefaultDocumentIDType\n}\n\nexport type EcommerceContextType<T extends EcommerceCollections = EcommerceCollections> = {\n /**\n * Add an item to the cart.\n */\n addItem: (item: CartItemArgument, quantity?: number) => Promise<void>\n /**\n * All current addresses for the current user.\n * This is used to manage shipping and billing addresses.\n */\n addresses?: T['addresses'][]\n /**\n * The current data of the cart.\n */\n cart?: T['addresses']\n /**\n * The ID of the current cart corresponding to the cart in the database or local storage.\n */\n cartID?: DefaultDocumentIDType\n /**\n * Clear the cart, removing all items.\n */\n clearCart: () => Promise<void>\n /**\n * Clears all ecommerce session data including cart, addresses, and user state.\n * Should be called when a user logs out.\n * This also clears localStorage cart data when syncLocalStorage is enabled.\n */\n clearSession: () => void\n /**\n * Memoized configuration object containing collection slugs and API settings.\n * Use this to build URLs and queries with the correct collection slugs.\n */\n config: EcommerceConfig\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n confirmOrder: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Create a new address by providing the data.\n */\n createAddress: (data: Partial<T['addresses']>) => Promise<void>\n /**\n * The configuration for the currencies used in the ecommerce context.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The currently selected currency used for the cart and price formatting automatically.\n */\n currency: Currency\n /**\n * Decrement an item in the cart by its array item ID.\n * If quantity reaches 0, the item will be removed from the cart.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n decrementItem: (item: string) => Promise<void>\n /**\n * Increment an item in the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n incrementItem: (item: string) => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n initiatePayment: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Indicates whether any cart operation is currently in progress.\n * Useful for disabling buttons and preventing race conditions.\n */\n isLoading: boolean\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n mergeCart: (\n targetCartID: DefaultDocumentIDType,\n sourceCartID: DefaultDocumentIDType,\n sourceSecret?: string,\n ) => Promise<T['carts'] | void>\n /**\n * Called after a successful login to handle cart state.\n * If a guest cart exists, it will be merged with the user's existing cart\n * or assigned to the user if they have no cart.\n * Cart secrets are cleared as authenticated users don't need them.\n *\n * @returns Promise that resolves when cart state is properly set up for the user.\n */\n onLogin: () => Promise<void>\n /**\n * Called during logout to clear all ecommerce session data.\n * Clears cart, addresses, user state, and localStorage cart data.\n * This is an alias for clearSession() but named for semantic clarity.\n */\n onLogout: () => void\n paymentMethods: PaymentAdapterClient[]\n /**\n * Refresh the cart.\n */\n refreshCart: () => Promise<void>\n /**\n * Remove an item from the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n removeItem: (item: string) => Promise<void>\n /**\n * The name of the currently selected payment method.\n * This is used to determine which payment method to use when initiating a payment.\n */\n selectedPaymentMethod?: null | string\n /**\n * Change the currency for the cart, it defaults to the configured currency.\n * This will update the currency used for pricing and calculations.\n */\n setCurrency: (currency: string) => void\n /**\n * Update an address by providing the data and the ID.\n */\n updateAddress: (addressID: DefaultDocumentIDType, data: Partial<T['addresses']>) => Promise<void>\n /**\n * The current authenticated user, or null if not logged in.\n */\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAo5BA,WAwIC"}
@@ -1,11 +1,13 @@
1
1
  import type { CollectionSlugMap, SanitizedEcommercePluginConfig } from '../types/index.js';
2
2
  type Props = {
3
+ enableVariants?: boolean;
3
4
  sanitizedPluginConfig: SanitizedEcommercePluginConfig;
4
5
  };
5
6
  /**
6
7
  * Generates a map of collection slugs based on the sanitized plugin configuration.
7
8
  * Takes into consideration any collection overrides provided in the plugin.
9
+ * Variant-related slugs are only included when enableVariants is true.
8
10
  */
9
- export declare const getCollectionSlugMap: ({ sanitizedPluginConfig }: Props) => CollectionSlugMap;
11
+ export declare const getCollectionSlugMap: ({ enableVariants, sanitizedPluginConfig, }: Props) => CollectionSlugMap;
10
12
  export {};
11
13
  //# sourceMappingURL=getCollectionSlugMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCollectionSlugMap.d.ts","sourceRoot":"","sources":["../../src/utilities/getCollectionSlugMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAA;AAE1F,KAAK,KAAK,GAAG;IACX,qBAAqB,EAAE,8BAA8B,CAAA;CACtD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,8BAA+B,KAAK,KAAG,iBAoBvE,CAAA"}
1
+ {"version":3,"file":"getCollectionSlugMap.d.ts","sourceRoot":"","sources":["../../src/utilities/getCollectionSlugMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAA;AAE1F,KAAK,KAAK,GAAG;IACX,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,qBAAqB,EAAE,8BAA8B,CAAA;CACtD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,+CAG9B,KAAK,KAAG,iBAiCV,CAAA"}
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Generates a map of collection slugs based on the sanitized plugin configuration.
3
3
  * Takes into consideration any collection overrides provided in the plugin.
4
- */ export const getCollectionSlugMap = ({ sanitizedPluginConfig })=>{
4
+ * Variant-related slugs are only included when enableVariants is true.
5
+ */ export const getCollectionSlugMap = ({ enableVariants = false, sanitizedPluginConfig })=>{
5
6
  const defaultSlugMap = {
6
7
  addresses: 'addresses',
7
8
  carts: 'carts',
@@ -9,17 +10,26 @@
9
10
  orders: 'orders',
10
11
  products: 'products',
11
12
  transactions: 'transactions',
12
- variantOptions: 'variantOptions',
13
- variants: 'variants',
14
- variantTypes: 'variantTypes'
13
+ ...enableVariants ? {
14
+ variantOptions: 'variantOptions',
15
+ variants: 'variants',
16
+ variantTypes: 'variantTypes'
17
+ } : {}
15
18
  };
16
19
  const collectionSlugsMap = defaultSlugMap;
17
20
  if (typeof sanitizedPluginConfig.customers === 'object' && sanitizedPluginConfig.customers.slug) {
18
21
  collectionSlugsMap.customers = sanitizedPluginConfig.customers.slug;
19
22
  }
23
+ // Only include variant slugs from slugMap if variants are enabled
24
+ const slugMapOverrides = sanitizedPluginConfig.slugMap || {};
25
+ if (!enableVariants) {
26
+ delete slugMapOverrides.variantOptions;
27
+ delete slugMapOverrides.variants;
28
+ delete slugMapOverrides.variantTypes;
29
+ }
20
30
  return {
21
31
  ...collectionSlugsMap,
22
- ...sanitizedPluginConfig.slugMap || {}
32
+ ...slugMapOverrides
23
33
  };
24
34
  };
25
35
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getCollectionSlugMap.ts"],"sourcesContent":["import type { CollectionSlugMap, SanitizedEcommercePluginConfig } from '../types/index.js'\n\ntype Props = {\n sanitizedPluginConfig: SanitizedEcommercePluginConfig\n}\n\n/**\n * Generates a map of collection slugs based on the sanitized plugin configuration.\n * Takes into consideration any collection overrides provided in the plugin.\n */\nexport const getCollectionSlugMap = ({ sanitizedPluginConfig }: Props): CollectionSlugMap => {\n const defaultSlugMap: CollectionSlugMap = {\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n variantOptions: 'variantOptions',\n variants: 'variants',\n variantTypes: 'variantTypes',\n }\n\n const collectionSlugsMap: CollectionSlugMap = defaultSlugMap\n\n if (typeof sanitizedPluginConfig.customers === 'object' && sanitizedPluginConfig.customers.slug) {\n collectionSlugsMap.customers = sanitizedPluginConfig.customers.slug\n }\n\n return { ...collectionSlugsMap, ...(sanitizedPluginConfig.slugMap || {}) }\n}\n"],"names":["getCollectionSlugMap","sanitizedPluginConfig","defaultSlugMap","addresses","carts","customers","orders","products","transactions","variantOptions","variants","variantTypes","collectionSlugsMap","slug","slugMap"],"mappings":"AAMA;;;CAGC,GACD,OAAO,MAAMA,uBAAuB,CAAC,EAAEC,qBAAqB,EAAS;IACnE,MAAMC,iBAAoC;QACxCC,WAAW;QACXC,OAAO;QACPC,WAAW;QACXC,QAAQ;QACRC,UAAU;QACVC,cAAc;QACdC,gBAAgB;QAChBC,UAAU;QACVC,cAAc;IAChB;IAEA,MAAMC,qBAAwCV;IAE9C,IAAI,OAAOD,sBAAsBI,SAAS,KAAK,YAAYJ,sBAAsBI,SAAS,CAACQ,IAAI,EAAE;QAC/FD,mBAAmBP,SAAS,GAAGJ,sBAAsBI,SAAS,CAACQ,IAAI;IACrE;IAEA,OAAO;QAAE,GAAGD,kBAAkB;QAAE,GAAIX,sBAAsBa,OAAO,IAAI,CAAC,CAAC;IAAE;AAC3E,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/getCollectionSlugMap.ts"],"sourcesContent":["import type { CollectionSlugMap, SanitizedEcommercePluginConfig } from '../types/index.js'\n\ntype Props = {\n enableVariants?: boolean\n sanitizedPluginConfig: SanitizedEcommercePluginConfig\n}\n\n/**\n * Generates a map of collection slugs based on the sanitized plugin configuration.\n * Takes into consideration any collection overrides provided in the plugin.\n * Variant-related slugs are only included when enableVariants is true.\n */\nexport const getCollectionSlugMap = ({\n enableVariants = false,\n sanitizedPluginConfig,\n}: Props): CollectionSlugMap => {\n const defaultSlugMap: CollectionSlugMap = {\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n ...(enableVariants\n ? {\n variantOptions: 'variantOptions',\n variants: 'variants',\n variantTypes: 'variantTypes',\n }\n : {}),\n }\n\n const collectionSlugsMap: CollectionSlugMap = defaultSlugMap\n\n if (typeof sanitizedPluginConfig.customers === 'object' && sanitizedPluginConfig.customers.slug) {\n collectionSlugsMap.customers = sanitizedPluginConfig.customers.slug\n }\n\n // Only include variant slugs from slugMap if variants are enabled\n const slugMapOverrides = sanitizedPluginConfig.slugMap || {}\n\n if (!enableVariants) {\n delete slugMapOverrides.variantOptions\n delete slugMapOverrides.variants\n delete slugMapOverrides.variantTypes\n }\n\n return { ...collectionSlugsMap, ...slugMapOverrides }\n}\n"],"names":["getCollectionSlugMap","enableVariants","sanitizedPluginConfig","defaultSlugMap","addresses","carts","customers","orders","products","transactions","variantOptions","variants","variantTypes","collectionSlugsMap","slug","slugMapOverrides","slugMap"],"mappings":"AAOA;;;;CAIC,GACD,OAAO,MAAMA,uBAAuB,CAAC,EACnCC,iBAAiB,KAAK,EACtBC,qBAAqB,EACf;IACN,MAAMC,iBAAoC;QACxCC,WAAW;QACXC,OAAO;QACPC,WAAW;QACXC,QAAQ;QACRC,UAAU;QACVC,cAAc;QACd,GAAIR,iBACA;YACES,gBAAgB;YAChBC,UAAU;YACVC,cAAc;QAChB,IACA,CAAC,CAAC;IACR;IAEA,MAAMC,qBAAwCV;IAE9C,IAAI,OAAOD,sBAAsBI,SAAS,KAAK,YAAYJ,sBAAsBI,SAAS,CAACQ,IAAI,EAAE;QAC/FD,mBAAmBP,SAAS,GAAGJ,sBAAsBI,SAAS,CAACQ,IAAI;IACrE;IAEA,kEAAkE;IAClE,MAAMC,mBAAmBb,sBAAsBc,OAAO,IAAI,CAAC;IAE3D,IAAI,CAACf,gBAAgB;QACnB,OAAOc,iBAAiBL,cAAc;QACtC,OAAOK,iBAAiBJ,QAAQ;QAChC,OAAOI,iBAAiBH,YAAY;IACtC;IAEA,OAAO;QAAE,GAAGC,kBAAkB;QAAE,GAAGE,gBAAgB;IAAC;AACtD,EAAC"}
@@ -33,10 +33,24 @@ describe('getCollectionSlugMap', ()=>{
33
33
  products: true,
34
34
  transactions: true
35
35
  };
36
- it('should return default slug map when no overrides are provided', ()=>{
36
+ it('should return default slug map without variant slugs when enableVariants is false', ()=>{
37
37
  const result = getCollectionSlugMap({
38
38
  sanitizedPluginConfig: baseConfig
39
39
  });
40
+ expect(result).toEqual({
41
+ addresses: 'addresses',
42
+ carts: 'carts',
43
+ customers: 'users',
44
+ orders: 'orders',
45
+ products: 'products',
46
+ transactions: 'transactions'
47
+ });
48
+ });
49
+ it('should return default slug map with variant slugs when enableVariants is true', ()=>{
50
+ const result = getCollectionSlugMap({
51
+ enableVariants: true,
52
+ sanitizedPluginConfig: baseConfig
53
+ });
40
54
  expect(result).toEqual({
41
55
  addresses: 'addresses',
42
56
  carts: 'carts',
@@ -57,11 +71,12 @@ describe('getCollectionSlugMap', ()=>{
57
71
  }
58
72
  };
59
73
  const result = getCollectionSlugMap({
74
+ enableVariants: true,
60
75
  sanitizedPluginConfig: config
61
76
  });
62
77
  expect(result.customers).toBe('custom-users');
63
78
  });
64
- it('should apply slugMap overrides', ()=>{
79
+ it('should apply slugMap overrides when variants enabled', ()=>{
65
80
  const config = {
66
81
  ...baseConfig,
67
82
  slugMap: {
@@ -71,6 +86,7 @@ describe('getCollectionSlugMap', ()=>{
71
86
  }
72
87
  };
73
88
  const result = getCollectionSlugMap({
89
+ enableVariants: true,
74
90
  sanitizedPluginConfig: config
75
91
  });
76
92
  expect(result.products).toBe('custom-products');
@@ -80,6 +96,23 @@ describe('getCollectionSlugMap', ()=>{
80
96
  expect(result.addresses).toBe('addresses');
81
97
  expect(result.carts).toBe('carts');
82
98
  });
99
+ it('should not apply variant slugMap overrides when variants disabled', ()=>{
100
+ const config = {
101
+ ...baseConfig,
102
+ slugMap: {
103
+ products: 'custom-products',
104
+ variants: 'custom-variants',
105
+ orders: 'custom-orders'
106
+ }
107
+ };
108
+ const result = getCollectionSlugMap({
109
+ enableVariants: false,
110
+ sanitizedPluginConfig: config
111
+ });
112
+ expect(result.products).toBe('custom-products');
113
+ expect(result.variants).toBeUndefined();
114
+ expect(result.orders).toBe('custom-orders');
115
+ });
83
116
  it('should prioritize slugMap overrides over customers slug', ()=>{
84
117
  const config = {
85
118
  ...baseConfig,
@@ -91,11 +124,12 @@ describe('getCollectionSlugMap', ()=>{
91
124
  }
92
125
  };
93
126
  const result = getCollectionSlugMap({
127
+ enableVariants: true,
94
128
  sanitizedPluginConfig: config
95
129
  });
96
130
  expect(result.customers).toBe('overridden-users');
97
131
  });
98
- it('should handle partial slugMap overrides', ()=>{
132
+ it('should handle partial slugMap overrides with variants enabled', ()=>{
99
133
  const config = {
100
134
  ...baseConfig,
101
135
  slugMap: {
@@ -103,6 +137,7 @@ describe('getCollectionSlugMap', ()=>{
103
137
  }
104
138
  };
105
139
  const result = getCollectionSlugMap({
140
+ enableVariants: true,
106
141
  sanitizedPluginConfig: config
107
142
  });
108
143
  expect(result.products).toBe('items');
@@ -115,12 +150,34 @@ describe('getCollectionSlugMap', ()=>{
115
150
  expect(result.variantOptions).toBe('variantOptions');
116
151
  expect(result.variantTypes).toBe('variantTypes');
117
152
  });
118
- it('should handle empty slugMap', ()=>{
153
+ it('should handle partial slugMap overrides with variants disabled', ()=>{
154
+ const config = {
155
+ ...baseConfig,
156
+ slugMap: {
157
+ products: 'items'
158
+ }
159
+ };
160
+ const result = getCollectionSlugMap({
161
+ enableVariants: false,
162
+ sanitizedPluginConfig: config
163
+ });
164
+ expect(result.products).toBe('items');
165
+ expect(result.addresses).toBe('addresses');
166
+ expect(result.carts).toBe('carts');
167
+ expect(result.customers).toBe('users');
168
+ expect(result.orders).toBe('orders');
169
+ expect(result.transactions).toBe('transactions');
170
+ expect(result.variants).toBeUndefined();
171
+ expect(result.variantOptions).toBeUndefined();
172
+ expect(result.variantTypes).toBeUndefined();
173
+ });
174
+ it('should handle empty slugMap with variants enabled', ()=>{
119
175
  const config = {
120
176
  ...baseConfig,
121
177
  slugMap: {}
122
178
  };
123
179
  const result = getCollectionSlugMap({
180
+ enableVariants: true,
124
181
  sanitizedPluginConfig: config
125
182
  });
126
183
  expect(result).toEqual({
@@ -135,12 +192,31 @@ describe('getCollectionSlugMap', ()=>{
135
192
  variantTypes: 'variantTypes'
136
193
  });
137
194
  });
138
- it('should handle undefined slugMap', ()=>{
195
+ it('should handle empty slugMap with variants disabled', ()=>{
196
+ const config = {
197
+ ...baseConfig,
198
+ slugMap: {}
199
+ };
200
+ const result = getCollectionSlugMap({
201
+ enableVariants: false,
202
+ sanitizedPluginConfig: config
203
+ });
204
+ expect(result).toEqual({
205
+ addresses: 'addresses',
206
+ carts: 'carts',
207
+ customers: 'users',
208
+ orders: 'orders',
209
+ products: 'products',
210
+ transactions: 'transactions'
211
+ });
212
+ });
213
+ it('should handle undefined slugMap with variants enabled', ()=>{
139
214
  const config = {
140
215
  ...baseConfig,
141
216
  slugMap: undefined
142
217
  };
143
218
  const result = getCollectionSlugMap({
219
+ enableVariants: true,
144
220
  sanitizedPluginConfig: config
145
221
  });
146
222
  expect(result).toEqual({
@@ -155,6 +231,24 @@ describe('getCollectionSlugMap', ()=>{
155
231
  variantTypes: 'variantTypes'
156
232
  });
157
233
  });
234
+ it('should handle undefined slugMap with variants disabled', ()=>{
235
+ const config = {
236
+ ...baseConfig,
237
+ slugMap: undefined
238
+ };
239
+ const result = getCollectionSlugMap({
240
+ enableVariants: false,
241
+ sanitizedPluginConfig: config
242
+ });
243
+ expect(result).toEqual({
244
+ addresses: 'addresses',
245
+ carts: 'carts',
246
+ customers: 'users',
247
+ orders: 'orders',
248
+ products: 'products',
249
+ transactions: 'transactions'
250
+ });
251
+ });
158
252
  });
159
253
 
160
254
  //# sourceMappingURL=getCollectionSlugMap.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getCollectionSlugMap.spec.ts"],"sourcesContent":["import { describe, it, expect, vitest } from 'vitest'\nimport type { SanitizedEcommercePluginConfig } from '../types/index.js'\n\nimport { USD } from '../currencies/index.js'\nimport { getCollectionSlugMap } from './getCollectionSlugMap'\n\ndescribe('getCollectionSlugMap', () => {\n const mockAccessConfig = {\n adminOnlyFieldAccess: vitest.fn(),\n adminOrPublishedStatus: vitest.fn(),\n customerOnlyFieldAccess: vitest.fn(),\n isAdmin: vitest.fn(),\n isAuthenticated: vitest.fn(),\n isDocumentOwner: vitest.fn(),\n publicAccess: vitest.fn(),\n }\n\n const baseConfig: SanitizedEcommercePluginConfig = {\n access: mockAccessConfig,\n addresses: {\n addressFields: [],\n },\n carts: true,\n currencies: {\n defaultCurrency: 'USD',\n supportedCurrencies: [USD],\n },\n customers: {\n slug: 'users',\n },\n orders: true,\n payments: {\n paymentMethods: [],\n },\n products: true,\n transactions: true,\n }\n\n it('should return default slug map when no overrides are provided', () => {\n const result = getCollectionSlugMap({ sanitizedPluginConfig: baseConfig })\n\n expect(result).toEqual({\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n variantOptions: 'variantOptions',\n variants: 'variants',\n variantTypes: 'variantTypes',\n })\n })\n\n it('should use custom customers slug when provided', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n customers: {\n slug: 'custom-users',\n },\n }\n\n const result = getCollectionSlugMap({ sanitizedPluginConfig: config })\n\n expect(result.customers).toBe('custom-users')\n })\n\n it('should apply slugMap overrides', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: {\n products: 'custom-products',\n variants: 'custom-variants',\n orders: 'custom-orders',\n },\n }\n\n const result = getCollectionSlugMap({ sanitizedPluginConfig: config })\n\n expect(result.products).toBe('custom-products')\n expect(result.variants).toBe('custom-variants')\n expect(result.orders).toBe('custom-orders')\n // Other slugs should remain default\n expect(result.addresses).toBe('addresses')\n expect(result.carts).toBe('carts')\n })\n\n it('should prioritize slugMap overrides over customers slug', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n customers: {\n slug: 'my-users',\n },\n slugMap: {\n customers: 'overridden-users',\n },\n }\n\n const result = getCollectionSlugMap({ sanitizedPluginConfig: config })\n\n expect(result.customers).toBe('overridden-users')\n })\n\n it('should handle partial slugMap overrides', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: {\n products: 'items',\n },\n }\n\n const result = getCollectionSlugMap({ sanitizedPluginConfig: config })\n\n expect(result.products).toBe('items')\n expect(result.addresses).toBe('addresses')\n expect(result.carts).toBe('carts')\n expect(result.customers).toBe('users')\n expect(result.orders).toBe('orders')\n expect(result.transactions).toBe('transactions')\n expect(result.variants).toBe('variants')\n expect(result.variantOptions).toBe('variantOptions')\n expect(result.variantTypes).toBe('variantTypes')\n })\n\n it('should handle empty slugMap', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: {},\n }\n\n const result = getCollectionSlugMap({ sanitizedPluginConfig: config })\n\n expect(result).toEqual({\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n variantOptions: 'variantOptions',\n variants: 'variants',\n variantTypes: 'variantTypes',\n })\n })\n\n it('should handle undefined slugMap', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: undefined,\n }\n\n const result = getCollectionSlugMap({ sanitizedPluginConfig: config })\n\n expect(result).toEqual({\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n variantOptions: 'variantOptions',\n variants: 'variants',\n variantTypes: 'variantTypes',\n })\n })\n})\n"],"names":["describe","it","expect","vitest","USD","getCollectionSlugMap","mockAccessConfig","adminOnlyFieldAccess","fn","adminOrPublishedStatus","customerOnlyFieldAccess","isAdmin","isAuthenticated","isDocumentOwner","publicAccess","baseConfig","access","addresses","addressFields","carts","currencies","defaultCurrency","supportedCurrencies","customers","slug","orders","payments","paymentMethods","products","transactions","result","sanitizedPluginConfig","toEqual","variantOptions","variants","variantTypes","config","toBe","slugMap","undefined"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,MAAM,QAAQ,SAAQ;AAGrD,SAASC,GAAG,QAAQ,yBAAwB;AAC5C,SAASC,oBAAoB,QAAQ,yBAAwB;AAE7DL,SAAS,wBAAwB;IAC/B,MAAMM,mBAAmB;QACvBC,sBAAsBJ,OAAOK,EAAE;QAC/BC,wBAAwBN,OAAOK,EAAE;QACjCE,yBAAyBP,OAAOK,EAAE;QAClCG,SAASR,OAAOK,EAAE;QAClBI,iBAAiBT,OAAOK,EAAE;QAC1BK,iBAAiBV,OAAOK,EAAE;QAC1BM,cAAcX,OAAOK,EAAE;IACzB;IAEA,MAAMO,aAA6C;QACjDC,QAAQV;QACRW,WAAW;YACTC,eAAe,EAAE;QACnB;QACAC,OAAO;QACPC,YAAY;YACVC,iBAAiB;YACjBC,qBAAqB;gBAAClB;aAAI;QAC5B;QACAmB,WAAW;YACTC,MAAM;QACR;QACAC,QAAQ;QACRC,UAAU;YACRC,gBAAgB,EAAE;QACpB;QACAC,UAAU;QACVC,cAAc;IAChB;IAEA5B,GAAG,iEAAiE;QAClE,MAAM6B,SAASzB,qBAAqB;YAAE0B,uBAAuBhB;QAAW;QAExEb,OAAO4B,QAAQE,OAAO,CAAC;YACrBf,WAAW;YACXE,OAAO;YACPI,WAAW;YACXE,QAAQ;YACRG,UAAU;YACVC,cAAc;YACdI,gBAAgB;YAChBC,UAAU;YACVC,cAAc;QAChB;IACF;IAEAlC,GAAG,kDAAkD;QACnD,MAAMmC,S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C9BnC,OAAO4B,OAAOL,MAAM,EAAEY,IAAI,CAAC;QAC3BnC,OAAO4B,OAAOD,YAAY,EAAEQ,IAAI,CAAC;QACjCnC,OAAO4B,OAAOI,QAAQ,EAAEG,IAAI,CAAC;QAC7BnC,OAAO4B,OAAOG,cAAc,EAAEI,IAAI,CAAC;QACnCnC,OAAO4B,OAAOK,YAAY,EAAEE,IAAI,CAAC;IACnC;IAEApC,GAAG,+BAA+B;QAChC,MAAMmC,SAAyC;YAC7C,GAAGrB,UAAU;YACbuB,SAAS,CAAC;QACZ;QAEA,MAAMR,SAASzB,qBAAqB;YAAE0B,uBAAuBK;QAAO;QAEpElC,OAAO4B,QAAQE,OAAO,CAAC;YACrBf,WAAW;YACXE,OAAO;YACPI,WAAW;YACXE,QAAQ;YACRG,UAAU;YACVC,cAAc;YACdI,gBAAgB;YAChBC,UAAU;YACVC,cAAc;QAChB;IACF;IAEAlC,GAAG,mCAAmC;QACpC,MAAMmC,SAAyC;YAC7C,GAAGrB,UAAU;YACbuB,SAASC;QACX;QAEA,MAAMT,SAASzB,qBAAqB;YAAE0B,uBAAuBK;QAAO;QAEpElC,OAAO4B,QAAQE,OAAO,CAAC;YACrBf,WAAW;YACXE,OAAO;YACPI,WAAW;YACXE,QAAQ;YACRG,UAAU;YACVC,cAAc;YACdI,gBAAgB;YAChBC,UAAU;YACVC,cAAc;QAChB;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/getCollectionSlugMap.spec.ts"],"sourcesContent":["import { describe, it, expect, vitest } from 'vitest'\nimport type { SanitizedEcommercePluginConfig } from '../types/index.js'\n\nimport { USD } from '../currencies/index.js'\nimport { getCollectionSlugMap } from './getCollectionSlugMap'\n\ndescribe('getCollectionSlugMap', () => {\n const mockAccessConfig = {\n adminOnlyFieldAccess: vitest.fn(),\n adminOrPublishedStatus: vitest.fn(),\n customerOnlyFieldAccess: vitest.fn(),\n isAdmin: vitest.fn(),\n isAuthenticated: vitest.fn(),\n isDocumentOwner: vitest.fn(),\n publicAccess: vitest.fn(),\n }\n\n const baseConfig: SanitizedEcommercePluginConfig = {\n access: mockAccessConfig,\n addresses: {\n addressFields: [],\n },\n carts: true,\n currencies: {\n defaultCurrency: 'USD',\n supportedCurrencies: [USD],\n },\n customers: {\n slug: 'users',\n },\n orders: true,\n payments: {\n paymentMethods: [],\n },\n products: true,\n transactions: true,\n }\n\n it('should return default slug map without variant slugs when enableVariants is false', () => {\n const result = getCollectionSlugMap({ sanitizedPluginConfig: baseConfig })\n\n expect(result).toEqual({\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n })\n })\n\n it('should return default slug map with variant slugs when enableVariants is true', () => {\n const result = getCollectionSlugMap({ enableVariants: true, sanitizedPluginConfig: baseConfig })\n\n expect(result).toEqual({\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n variantOptions: 'variantOptions',\n variants: 'variants',\n variantTypes: 'variantTypes',\n })\n })\n\n it('should use custom customers slug when provided', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n customers: {\n slug: 'custom-users',\n },\n }\n\n const result = getCollectionSlugMap({ enableVariants: true, sanitizedPluginConfig: config })\n\n expect(result.customers).toBe('custom-users')\n })\n\n it('should apply slugMap overrides when variants enabled', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: {\n products: 'custom-products',\n variants: 'custom-variants',\n orders: 'custom-orders',\n },\n }\n\n const result = getCollectionSlugMap({ enableVariants: true, sanitizedPluginConfig: config })\n\n expect(result.products).toBe('custom-products')\n expect(result.variants).toBe('custom-variants')\n expect(result.orders).toBe('custom-orders')\n // Other slugs should remain default\n expect(result.addresses).toBe('addresses')\n expect(result.carts).toBe('carts')\n })\n\n it('should not apply variant slugMap overrides when variants disabled', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: {\n products: 'custom-products',\n variants: 'custom-variants',\n orders: 'custom-orders',\n },\n }\n\n const result = getCollectionSlugMap({ enableVariants: false, sanitizedPluginConfig: config })\n\n expect(result.products).toBe('custom-products')\n expect(result.variants).toBeUndefined()\n expect(result.orders).toBe('custom-orders')\n })\n\n it('should prioritize slugMap overrides over customers slug', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n customers: {\n slug: 'my-users',\n },\n slugMap: {\n customers: 'overridden-users',\n },\n }\n\n const result = getCollectionSlugMap({ enableVariants: true, sanitizedPluginConfig: config })\n\n expect(result.customers).toBe('overridden-users')\n })\n\n it('should handle partial slugMap overrides with variants enabled', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: {\n products: 'items',\n },\n }\n\n const result = getCollectionSlugMap({ enableVariants: true, sanitizedPluginConfig: config })\n\n expect(result.products).toBe('items')\n expect(result.addresses).toBe('addresses')\n expect(result.carts).toBe('carts')\n expect(result.customers).toBe('users')\n expect(result.orders).toBe('orders')\n expect(result.transactions).toBe('transactions')\n expect(result.variants).toBe('variants')\n expect(result.variantOptions).toBe('variantOptions')\n expect(result.variantTypes).toBe('variantTypes')\n })\n\n it('should handle partial slugMap overrides with variants disabled', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: {\n products: 'items',\n },\n }\n\n const result = getCollectionSlugMap({ enableVariants: false, sanitizedPluginConfig: config })\n\n expect(result.products).toBe('items')\n expect(result.addresses).toBe('addresses')\n expect(result.carts).toBe('carts')\n expect(result.customers).toBe('users')\n expect(result.orders).toBe('orders')\n expect(result.transactions).toBe('transactions')\n expect(result.variants).toBeUndefined()\n expect(result.variantOptions).toBeUndefined()\n expect(result.variantTypes).toBeUndefined()\n })\n\n it('should handle empty slugMap with variants enabled', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: {},\n }\n\n const result = getCollectionSlugMap({ enableVariants: true, sanitizedPluginConfig: config })\n\n expect(result).toEqual({\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n variantOptions: 'variantOptions',\n variants: 'variants',\n variantTypes: 'variantTypes',\n })\n })\n\n it('should handle empty slugMap with variants disabled', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: {},\n }\n\n const result = getCollectionSlugMap({ enableVariants: false, sanitizedPluginConfig: config })\n\n expect(result).toEqual({\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n })\n })\n\n it('should handle undefined slugMap with variants enabled', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: undefined,\n }\n\n const result = getCollectionSlugMap({ enableVariants: true, sanitizedPluginConfig: config })\n\n expect(result).toEqual({\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n variantOptions: 'variantOptions',\n variants: 'variants',\n variantTypes: 'variantTypes',\n })\n })\n\n it('should handle undefined slugMap with variants disabled', () => {\n const config: SanitizedEcommercePluginConfig = {\n ...baseConfig,\n slugMap: undefined,\n }\n\n const result = getCollectionSlugMap({ enableVariants: false, sanitizedPluginConfig: config })\n\n expect(result).toEqual({\n addresses: 'addresses',\n carts: 'carts',\n customers: 'users',\n orders: 'orders',\n products: 'products',\n transactions: 'transactions',\n })\n })\n})\n"],"names":["describe","it","expect","vitest","USD","getCollectionSlugMap","mockAccessConfig","adminOnlyFieldAccess","fn","adminOrPublishedStatus","customerOnlyFieldAccess","isAdmin","isAuthenticated","isDocumentOwner","publicAccess","baseConfig","access","addresses","addressFields","carts","currencies","defaultCurrency","supportedCurrencies","customers","slug","orders","payments","paymentMethods","products","transactions","result","sanitizedPluginConfig","toEqual","enableVariants","variantOptions","variants","variantTypes","config","toBe","slugMap","toBeUndefined","undefined"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,MAAM,QAAQ,SA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;QACZ;QAEA,MAAMT,SAASzB,qBAAqB;YAAE4B,gBAAgB;YAAMF,uBAAuBM;QAAO;QAE1FnC,OAAO4B,QAAQE,OAAO,CAAC;YACrBf,WAAW;YACXE,OAAO;YACPI,WAAW;YACXE,QAAQ;YACRG,UAAU;YACVC,cAAc;YACdK,gBAAgB;YAChBC,UAAU;YACVC,cAAc;QAChB;IACF;IAEAnC,GAAG,sDAAsD;QACvD,MAAMoC,SAAyC;YAC7C,GAAGtB,UAAU;YACbwB,SAAS,CAAC;QACZ;QAEA,MAAMT,SAASzB,qBAAqB;YAAE4B,gBAAgB;YAAOF,uBAAuBM;QAAO;QAE3FnC,OAAO4B,QAAQE,OAAO,CAAC;YACrBf,WAAW;YACXE,OAAO;YACPI,WAAW;YACXE,QAAQ;YACRG,UAAU;YACVC,cAAc;QAChB;IACF;IAEA5B,GAAG,yDAAyD;QAC1D,MAAMoC,SAAyC;YAC7C,GAAGtB,UAAU;YACbwB,SAASE;QACX;QAEA,MAAMX,SAASzB,qBAAqB;YAAE4B,gBAAgB;YAAMF,uBAAuBM;QAAO;QAE1FnC,OAAO4B,QAAQE,OAAO,CAAC;YACrBf,WAAW;YACXE,OAAO;YACPI,WAAW;YACXE,QAAQ;YACRG,UAAU;YACVC,cAAc;YACdK,gBAAgB;YAChBC,UAAU;YACVC,cAAc;QAChB;IACF;IAEAnC,GAAG,0DAA0D;QAC3D,MAAMoC,SAAyC;YAC7C,GAAGtB,UAAU;YACbwB,SAASE;QACX;QAEA,MAAMX,SAASzB,qBAAqB;YAAE4B,gBAAgB;YAAOF,uBAAuBM;QAAO;QAE3FnC,OAAO4B,QAAQE,OAAO,CAAC;YACrBf,WAAW;YACXE,OAAO;YACPI,WAAW;YACXE,QAAQ;YACRG,UAAU;YACVC,cAAc;QAChB;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-ecommerce",
3
- "version": "3.72.0-internal.3e70d4c",
3
+ "version": "3.73.0-canary.0",
4
4
  "description": "Ecommerce plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -74,23 +74,23 @@
74
74
  ],
75
75
  "dependencies": {
76
76
  "qs-esm": "7.0.2",
77
- "@payloadcms/translations": "3.72.0-internal.3e70d4c",
78
- "@payloadcms/ui": "3.72.0-internal.3e70d4c"
77
+ "@payloadcms/translations": "3.73.0-canary.0",
78
+ "@payloadcms/ui": "3.73.0-canary.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@types/json-schema": "7.0.15",
82
82
  "@types/react": "19.2.1",
83
83
  "@types/react-dom": "19.2.1",
84
84
  "stripe": "18.3.0",
85
- "@payloadcms/next": "3.72.0-internal.3e70d4c",
86
- "@payloadcms/translations": "3.72.0-internal.3e70d4c",
87
- "payload": "3.72.0-internal.3e70d4c",
88
- "@payloadcms/eslint-config": "3.28.0"
85
+ "@payloadcms/eslint-config": "3.28.0",
86
+ "@payloadcms/next": "3.73.0-canary.0",
87
+ "@payloadcms/translations": "3.73.0-canary.0",
88
+ "payload": "3.73.0-canary.0"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
92
92
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
93
- "payload": "3.72.0-internal.3e70d4c"
93
+ "payload": "3.73.0-canary.0"
94
94
  },
95
95
  "publishConfig": {
96
96
  "registry": "https://registry.npmjs.org/"