@payloadcms/plugin-ecommerce 3.71.0-internal.e36f916 → 3.71.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.
Files changed (275) hide show
  1. package/dist/collections/addresses/createAddressesCollection.d.ts +1 -1
  2. package/dist/collections/addresses/createAddressesCollection.d.ts.map +1 -1
  3. package/dist/collections/addresses/createAddressesCollection.js +1 -1
  4. package/dist/collections/addresses/createAddressesCollection.js.map +1 -1
  5. package/dist/collections/addresses/hooks/beforeChange.d.ts +2 -3
  6. package/dist/collections/addresses/hooks/beforeChange.d.ts.map +1 -1
  7. package/dist/collections/addresses/hooks/beforeChange.js +7 -3
  8. package/dist/collections/addresses/hooks/beforeChange.js.map +1 -1
  9. package/dist/collections/carts/beforeChange.d.ts.map +1 -1
  10. package/dist/collections/carts/beforeChange.js.map +1 -1
  11. package/dist/collections/carts/createCartsCollection.d.ts +21 -0
  12. package/dist/collections/carts/createCartsCollection.d.ts.map +1 -1
  13. package/dist/collections/carts/createCartsCollection.js +27 -2
  14. package/dist/collections/carts/createCartsCollection.js.map +1 -1
  15. package/dist/collections/carts/endpoints/addItem.d.ts +19 -0
  16. package/dist/collections/carts/endpoints/addItem.d.ts.map +1 -0
  17. package/dist/collections/carts/endpoints/addItem.js +54 -0
  18. package/dist/collections/carts/endpoints/addItem.js.map +1 -0
  19. package/dist/collections/carts/endpoints/clearCart.d.ts +15 -0
  20. package/dist/collections/carts/endpoints/clearCart.d.ts.map +1 -0
  21. package/dist/collections/carts/endpoints/clearCart.js +41 -0
  22. package/dist/collections/carts/endpoints/clearCart.js.map +1 -0
  23. package/dist/collections/carts/endpoints/mergeCart.d.ts +21 -0
  24. package/dist/collections/carts/endpoints/mergeCart.d.ts.map +1 -0
  25. package/dist/collections/carts/endpoints/mergeCart.js +72 -0
  26. package/dist/collections/carts/endpoints/mergeCart.js.map +1 -0
  27. package/dist/collections/carts/endpoints/removeItem.d.ts +16 -0
  28. package/dist/collections/carts/endpoints/removeItem.d.ts.map +1 -0
  29. package/dist/collections/carts/endpoints/removeItem.js +51 -0
  30. package/dist/collections/carts/endpoints/removeItem.js.map +1 -0
  31. package/dist/collections/carts/endpoints/updateItem.d.ts +40 -0
  32. package/dist/collections/carts/endpoints/updateItem.d.ts.map +1 -0
  33. package/dist/collections/carts/endpoints/updateItem.js +95 -0
  34. package/dist/collections/carts/endpoints/updateItem.js.map +1 -0
  35. package/dist/collections/carts/hasCartSecretAccess.d.ts +2 -2
  36. package/dist/collections/carts/hasCartSecretAccess.js +3 -3
  37. package/dist/collections/carts/hasCartSecretAccess.js.map +1 -1
  38. package/dist/collections/carts/operations/addItem.d.ts +24 -0
  39. package/dist/collections/carts/operations/addItem.d.ts.map +1 -0
  40. package/dist/collections/carts/operations/addItem.js +95 -0
  41. package/dist/collections/carts/operations/addItem.js.map +1 -0
  42. package/dist/collections/carts/operations/clearCart.d.ts +20 -0
  43. package/dist/collections/carts/operations/clearCart.d.ts.map +1 -0
  44. package/dist/collections/carts/operations/clearCart.js +53 -0
  45. package/dist/collections/carts/operations/clearCart.js.map +1 -0
  46. package/dist/collections/carts/operations/createRequestWithSecret.d.ts +11 -0
  47. package/dist/collections/carts/operations/createRequestWithSecret.d.ts.map +1 -0
  48. package/dist/collections/carts/operations/createRequestWithSecret.js +21 -0
  49. package/dist/collections/carts/operations/createRequestWithSecret.js.map +1 -0
  50. package/dist/collections/carts/operations/defaultCartItemMatcher.d.ts +19 -0
  51. package/dist/collections/carts/operations/defaultCartItemMatcher.d.ts.map +1 -0
  52. package/dist/collections/carts/operations/defaultCartItemMatcher.js +25 -0
  53. package/dist/collections/carts/operations/defaultCartItemMatcher.js.map +1 -0
  54. package/dist/collections/carts/operations/defaultCartItemMatcher.spec.js +358 -0
  55. package/dist/collections/carts/operations/defaultCartItemMatcher.spec.js.map +1 -0
  56. package/dist/collections/carts/operations/mergeCart.d.ts +54 -0
  57. package/dist/collections/carts/operations/mergeCart.d.ts.map +1 -0
  58. package/dist/collections/carts/operations/mergeCart.js +144 -0
  59. package/dist/collections/carts/operations/mergeCart.js.map +1 -0
  60. package/dist/collections/carts/operations/removeItem.d.ts +21 -0
  61. package/dist/collections/carts/operations/removeItem.d.ts.map +1 -0
  62. package/dist/collections/carts/operations/removeItem.js +69 -0
  63. package/dist/collections/carts/operations/removeItem.js.map +1 -0
  64. package/dist/collections/carts/operations/types.d.ts +152 -0
  65. package/dist/collections/carts/operations/types.d.ts.map +1 -0
  66. package/dist/collections/carts/operations/types.js +7 -0
  67. package/dist/collections/carts/operations/types.js.map +1 -0
  68. package/dist/collections/carts/operations/updateItem.d.ts +41 -0
  69. package/dist/collections/carts/operations/updateItem.d.ts.map +1 -0
  70. package/dist/collections/carts/operations/updateItem.js +110 -0
  71. package/dist/collections/carts/operations/updateItem.js.map +1 -0
  72. package/dist/collections/variants/createVariantsCollection/index.d.ts +4 -0
  73. package/dist/collections/variants/createVariantsCollection/index.d.ts.map +1 -1
  74. package/dist/collections/variants/createVariantsCollection/index.js +8 -2
  75. package/dist/collections/variants/createVariantsCollection/index.js.map +1 -1
  76. package/dist/endpoints/confirmOrder.d.ts.map +1 -1
  77. package/dist/endpoints/confirmOrder.js +9 -2
  78. package/dist/endpoints/confirmOrder.js.map +1 -1
  79. package/dist/endpoints/initiatePayment.d.ts.map +1 -1
  80. package/dist/endpoints/initiatePayment.js +8 -2
  81. package/dist/endpoints/initiatePayment.js.map +1 -1
  82. package/dist/exports/client/react.d.ts +1 -1
  83. package/dist/exports/client/react.d.ts.map +1 -1
  84. package/dist/exports/client/react.js +1 -1
  85. package/dist/exports/client/react.js.map +1 -1
  86. package/dist/exports/types.d.ts +1 -1
  87. package/dist/exports/types.d.ts.map +1 -1
  88. package/dist/exports/types.js.map +1 -1
  89. package/dist/index.d.ts +7 -0
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +9 -1
  92. package/dist/index.js.map +1 -1
  93. package/dist/payments/adapters/stripe/confirmOrder.d.ts.map +1 -1
  94. package/dist/payments/adapters/stripe/confirmOrder.js +2 -2
  95. package/dist/payments/adapters/stripe/confirmOrder.js.map +1 -1
  96. package/dist/react/provider/index.d.ts +5 -4
  97. package/dist/react/provider/index.d.ts.map +1 -1
  98. package/dist/react/provider/index.js +449 -265
  99. package/dist/react/provider/index.js.map +1 -1
  100. package/dist/translations/index.d.ts +3 -4
  101. package/dist/translations/index.d.ts.map +1 -1
  102. package/dist/translations/index.js +80 -2
  103. package/dist/translations/index.js.map +1 -1
  104. package/dist/translations/languages/ar.d.ts +89 -0
  105. package/dist/translations/languages/ar.d.ts.map +1 -0
  106. package/dist/translations/languages/ar.js +92 -0
  107. package/dist/translations/languages/ar.js.map +1 -0
  108. package/dist/translations/languages/az.d.ts +89 -0
  109. package/dist/translations/languages/az.d.ts.map +1 -0
  110. package/dist/translations/languages/az.js +92 -0
  111. package/dist/translations/languages/az.js.map +1 -0
  112. package/dist/translations/languages/bg.d.ts +89 -0
  113. package/dist/translations/languages/bg.d.ts.map +1 -0
  114. package/dist/translations/languages/bg.js +92 -0
  115. package/dist/translations/languages/bg.js.map +1 -0
  116. package/dist/translations/languages/ca.d.ts +89 -0
  117. package/dist/translations/languages/ca.d.ts.map +1 -0
  118. package/dist/translations/languages/ca.js +92 -0
  119. package/dist/translations/languages/ca.js.map +1 -0
  120. package/dist/translations/languages/cs.d.ts +89 -0
  121. package/dist/translations/languages/cs.d.ts.map +1 -0
  122. package/dist/translations/languages/cs.js +92 -0
  123. package/dist/translations/languages/cs.js.map +1 -0
  124. package/dist/translations/languages/da.d.ts +89 -0
  125. package/dist/translations/languages/da.d.ts.map +1 -0
  126. package/dist/translations/languages/da.js +92 -0
  127. package/dist/translations/languages/da.js.map +1 -0
  128. package/dist/translations/languages/de.d.ts +89 -0
  129. package/dist/translations/languages/de.d.ts.map +1 -0
  130. package/dist/translations/languages/de.js +92 -0
  131. package/dist/translations/languages/de.js.map +1 -0
  132. package/dist/translations/languages/en.d.ts +89 -0
  133. package/dist/translations/languages/en.d.ts.map +1 -0
  134. package/dist/translations/languages/en.js +92 -0
  135. package/dist/translations/languages/en.js.map +1 -0
  136. package/dist/translations/languages/es.d.ts +89 -0
  137. package/dist/translations/languages/es.d.ts.map +1 -0
  138. package/dist/translations/languages/es.js +92 -0
  139. package/dist/translations/languages/es.js.map +1 -0
  140. package/dist/translations/languages/et.d.ts +89 -0
  141. package/dist/translations/languages/et.d.ts.map +1 -0
  142. package/dist/translations/languages/et.js +92 -0
  143. package/dist/translations/languages/et.js.map +1 -0
  144. package/dist/translations/languages/fa.d.ts +89 -0
  145. package/dist/translations/languages/fa.d.ts.map +1 -0
  146. package/dist/translations/languages/fa.js +92 -0
  147. package/dist/translations/languages/fa.js.map +1 -0
  148. package/dist/translations/languages/fr.d.ts +89 -0
  149. package/dist/translations/languages/fr.d.ts.map +1 -0
  150. package/dist/translations/languages/fr.js +92 -0
  151. package/dist/translations/languages/fr.js.map +1 -0
  152. package/dist/translations/languages/he.d.ts +89 -0
  153. package/dist/translations/languages/he.d.ts.map +1 -0
  154. package/dist/translations/languages/he.js +92 -0
  155. package/dist/translations/languages/he.js.map +1 -0
  156. package/dist/translations/languages/hr.d.ts +89 -0
  157. package/dist/translations/languages/hr.d.ts.map +1 -0
  158. package/dist/translations/languages/hr.js +92 -0
  159. package/dist/translations/languages/hr.js.map +1 -0
  160. package/dist/translations/languages/hu.d.ts +89 -0
  161. package/dist/translations/languages/hu.d.ts.map +1 -0
  162. package/dist/translations/languages/hu.js +92 -0
  163. package/dist/translations/languages/hu.js.map +1 -0
  164. package/dist/translations/languages/hy.d.ts +89 -0
  165. package/dist/translations/languages/hy.d.ts.map +1 -0
  166. package/dist/translations/languages/hy.js +92 -0
  167. package/dist/translations/languages/hy.js.map +1 -0
  168. package/dist/translations/languages/is.d.ts +89 -0
  169. package/dist/translations/languages/is.d.ts.map +1 -0
  170. package/dist/translations/languages/is.js +92 -0
  171. package/dist/translations/languages/is.js.map +1 -0
  172. package/dist/translations/languages/it.d.ts +89 -0
  173. package/dist/translations/languages/it.d.ts.map +1 -0
  174. package/dist/translations/languages/it.js +92 -0
  175. package/dist/translations/languages/it.js.map +1 -0
  176. package/dist/translations/languages/ja.d.ts +89 -0
  177. package/dist/translations/languages/ja.d.ts.map +1 -0
  178. package/dist/translations/languages/ja.js +92 -0
  179. package/dist/translations/languages/ja.js.map +1 -0
  180. package/dist/translations/languages/ko.d.ts +89 -0
  181. package/dist/translations/languages/ko.d.ts.map +1 -0
  182. package/dist/translations/languages/ko.js +92 -0
  183. package/dist/translations/languages/ko.js.map +1 -0
  184. package/dist/translations/languages/lt.d.ts +89 -0
  185. package/dist/translations/languages/lt.d.ts.map +1 -0
  186. package/dist/translations/languages/lt.js +92 -0
  187. package/dist/translations/languages/lt.js.map +1 -0
  188. package/dist/translations/languages/my.d.ts +89 -0
  189. package/dist/translations/languages/my.d.ts.map +1 -0
  190. package/dist/translations/languages/my.js +92 -0
  191. package/dist/translations/languages/my.js.map +1 -0
  192. package/dist/translations/languages/nb.d.ts +89 -0
  193. package/dist/translations/languages/nb.d.ts.map +1 -0
  194. package/dist/translations/languages/nb.js +92 -0
  195. package/dist/translations/languages/nb.js.map +1 -0
  196. package/dist/translations/languages/nl.d.ts +89 -0
  197. package/dist/translations/languages/nl.d.ts.map +1 -0
  198. package/dist/translations/languages/nl.js +92 -0
  199. package/dist/translations/languages/nl.js.map +1 -0
  200. package/dist/translations/languages/pl.d.ts +89 -0
  201. package/dist/translations/languages/pl.d.ts.map +1 -0
  202. package/dist/translations/languages/pl.js +92 -0
  203. package/dist/translations/languages/pl.js.map +1 -0
  204. package/dist/translations/languages/pt.d.ts +89 -0
  205. package/dist/translations/languages/pt.d.ts.map +1 -0
  206. package/dist/translations/languages/pt.js +92 -0
  207. package/dist/translations/languages/pt.js.map +1 -0
  208. package/dist/translations/languages/ro.d.ts +89 -0
  209. package/dist/translations/languages/ro.d.ts.map +1 -0
  210. package/dist/translations/languages/ro.js +92 -0
  211. package/dist/translations/languages/ro.js.map +1 -0
  212. package/dist/translations/languages/rs.d.ts +89 -0
  213. package/dist/translations/languages/rs.d.ts.map +1 -0
  214. package/dist/translations/languages/rs.js +92 -0
  215. package/dist/translations/languages/rs.js.map +1 -0
  216. package/dist/translations/languages/rsLatin.d.ts +89 -0
  217. package/dist/translations/languages/rsLatin.d.ts.map +1 -0
  218. package/dist/translations/languages/rsLatin.js +92 -0
  219. package/dist/translations/languages/rsLatin.js.map +1 -0
  220. package/dist/translations/languages/ru.d.ts +89 -0
  221. package/dist/translations/languages/ru.d.ts.map +1 -0
  222. package/dist/translations/languages/ru.js +92 -0
  223. package/dist/translations/languages/ru.js.map +1 -0
  224. package/dist/translations/languages/sk.d.ts +89 -0
  225. package/dist/translations/languages/sk.d.ts.map +1 -0
  226. package/dist/translations/languages/sk.js +92 -0
  227. package/dist/translations/languages/sk.js.map +1 -0
  228. package/dist/translations/languages/sl.d.ts +89 -0
  229. package/dist/translations/languages/sl.d.ts.map +1 -0
  230. package/dist/translations/languages/sl.js +92 -0
  231. package/dist/translations/languages/sl.js.map +1 -0
  232. package/dist/translations/languages/sv.d.ts +89 -0
  233. package/dist/translations/languages/sv.d.ts.map +1 -0
  234. package/dist/translations/languages/sv.js +92 -0
  235. package/dist/translations/languages/sv.js.map +1 -0
  236. package/dist/translations/languages/ta.d.ts +89 -0
  237. package/dist/translations/languages/ta.d.ts.map +1 -0
  238. package/dist/translations/languages/ta.js +92 -0
  239. package/dist/translations/languages/ta.js.map +1 -0
  240. package/dist/translations/languages/th.d.ts +89 -0
  241. package/dist/translations/languages/th.d.ts.map +1 -0
  242. package/dist/translations/languages/th.js +92 -0
  243. package/dist/translations/languages/th.js.map +1 -0
  244. package/dist/translations/languages/tr.d.ts +89 -0
  245. package/dist/translations/languages/tr.d.ts.map +1 -0
  246. package/dist/translations/languages/tr.js +92 -0
  247. package/dist/translations/languages/tr.js.map +1 -0
  248. package/dist/translations/languages/uk.d.ts +89 -0
  249. package/dist/translations/languages/uk.d.ts.map +1 -0
  250. package/dist/translations/languages/uk.js +92 -0
  251. package/dist/translations/languages/uk.js.map +1 -0
  252. package/dist/translations/languages/vi.d.ts +89 -0
  253. package/dist/translations/languages/vi.d.ts.map +1 -0
  254. package/dist/translations/languages/vi.js +92 -0
  255. package/dist/translations/languages/vi.js.map +1 -0
  256. package/dist/translations/languages/zh.d.ts +89 -0
  257. package/dist/translations/languages/zh.d.ts.map +1 -0
  258. package/dist/translations/languages/zh.js +92 -0
  259. package/dist/translations/languages/zh.js.map +1 -0
  260. package/dist/translations/languages/zhTw.d.ts +89 -0
  261. package/dist/translations/languages/zhTw.d.ts.map +1 -0
  262. package/dist/translations/languages/zhTw.js +92 -0
  263. package/dist/translations/languages/zhTw.js.map +1 -0
  264. package/dist/translations/translation-schema.json +313 -5
  265. package/dist/translations/types.d.ts +89 -0
  266. package/dist/translations/types.d.ts.map +1 -0
  267. package/dist/translations/types.js +3 -0
  268. package/dist/translations/types.js.map +1 -0
  269. package/dist/types/index.d.ts +154 -14
  270. package/dist/types/index.d.ts.map +1 -1
  271. package/dist/types/index.js.map +1 -1
  272. package/dist/ui/VariantOptionsSelector/index.d.ts.map +1 -1
  273. package/dist/ui/VariantOptionsSelector/index.js +6 -3
  274. package/dist/ui/VariantOptionsSelector/index.js.map +1 -1
  275. package/package.json +16 -10
@@ -1,4 +1,4 @@
1
- import type { Access, CollectionConfig, DefaultDocumentIDType, Endpoint, Field, FieldAccess, GroupField, PayloadRequest, PopulateType, SelectType, TypedCollection, Where } from 'payload';
1
+ import type { Access, CollectionConfig, CollectionSlug, DefaultDocumentIDType, Endpoint, Field, FieldAccess, GroupField, PayloadRequest, PopulateType, SelectType, TypedCollection, TypedUser, Where } from 'payload';
2
2
  import type React from 'react';
3
3
  import type { TypedEcommerce } from './utilities.js';
4
4
  export type FieldsOverride = (args: {
@@ -8,7 +8,11 @@ export type CollectionOverride = (args: {
8
8
  defaultCollection: CollectionConfig;
9
9
  }) => CollectionConfig | Promise<CollectionConfig>;
10
10
  export type CartItem = {
11
- id: DefaultDocumentIDType;
11
+ /**
12
+ * The ID of the cart item. Array item IDs are always strings in Payload,
13
+ * regardless of the database adapter's default ID type.
14
+ */
15
+ id: string;
12
16
  product: DefaultDocumentIDType | TypedCollection['products'];
13
17
  quantity: number;
14
18
  variant?: DefaultDocumentIDType | TypedCollection['variants'];
@@ -463,6 +467,41 @@ export type CustomersConfig = {
463
467
  */
464
468
  slug: string;
465
469
  };
470
+ /**
471
+ * Arguments for the cart item matcher function.
472
+ */
473
+ export type CartItemMatcherArgs = {
474
+ /** The existing cart item to compare against */
475
+ existingItem: {
476
+ [key: string]: unknown;
477
+ /**
478
+ * The ID of the cart item. Array item IDs are always strings in Payload,
479
+ * regardless of the database adapter's default ID type.
480
+ */
481
+ id?: string;
482
+ product: {
483
+ [key: string]: unknown;
484
+ id: DefaultDocumentIDType;
485
+ } | DefaultDocumentIDType;
486
+ quantity: number;
487
+ variant?: {
488
+ [key: string]: unknown;
489
+ id: DefaultDocumentIDType;
490
+ } | DefaultDocumentIDType;
491
+ };
492
+ /** The new item being added */
493
+ newItem: {
494
+ [key: string]: unknown;
495
+ product: DefaultDocumentIDType;
496
+ quantity?: number;
497
+ variant?: DefaultDocumentIDType;
498
+ };
499
+ };
500
+ /**
501
+ * Function to determine if two cart items should be considered the same.
502
+ * When items match, their quantities are combined instead of creating separate entries.
503
+ */
504
+ export type CartItemMatcher = (args: CartItemMatcherArgs) => boolean;
466
505
  export type CartsConfig = {
467
506
  /**
468
507
  * Allow guest (unauthenticated) users to create carts.
@@ -470,6 +509,26 @@ export type CartsConfig = {
470
509
  * Defaults to true.
471
510
  */
472
511
  allowGuestCarts?: boolean;
512
+ /**
513
+ * Custom function to determine if two cart items should be considered the same.
514
+ * When items match, their quantities are combined instead of creating separate entries.
515
+ *
516
+ * Use this to add custom uniqueness criteria beyond product and variant IDs.
517
+ *
518
+ * @default defaultCartItemMatcher (matches by product and variant ID only)
519
+ *
520
+ * @example
521
+ * ```ts
522
+ * cartItemMatcher: ({ existingItem, newItem }) => {
523
+ * // Match by product, variant, AND custom delivery option
524
+ * const productMatch = existingItem.product === newItem.product
525
+ * const variantMatch = existingItem.variant === newItem.variant
526
+ * const deliveryMatch = existingItem.deliveryOption === newItem.deliveryOption
527
+ * return productMatch && variantMatch && deliveryMatch
528
+ * }
529
+ * ```
530
+ */
531
+ cartItemMatcher?: CartItemMatcher;
473
532
  cartsCollectionOverride?: CollectionOverride;
474
533
  };
475
534
  export type InventoryConfig = {
@@ -540,12 +599,12 @@ export type CollectionSlugMap = {
540
599
  * access: {
541
600
  * isAdmin: ({ req }) => checkRole(['admin'], req.user),
542
601
  * isAuthenticated: ({ req }) => !!req.user,
602
+ * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user),
543
603
  * isDocumentOwner: ({ req }) => {
544
604
  * if (!req.user) return false
545
605
  * return { customer: { equals: req.user.id } }
546
606
  * },
547
607
  * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),
548
- * customerOnlyFieldAccess: ({ req }) => !!req.user,
549
608
  * adminOrPublishedStatus: ({ req }) => {
550
609
  * if (checkRole(['admin'], req.user)) return true
551
610
  * return { _status: { equals: 'published' } }
@@ -563,9 +622,10 @@ export type AccessConfig = {
563
622
  */
564
623
  adminOrPublishedStatus: Access;
565
624
  /**
625
+ * @deprecated Will be removed in v4. Use `isCustomer` instead.
566
626
  * Limited to customers only, specifically for Field level access control.
567
627
  */
568
- customerOnlyFieldAccess: FieldAccess;
628
+ customerOnlyFieldAccess?: FieldAccess;
569
629
  /**
570
630
  * Checks if the user is an admin.
571
631
  * @returns true if admin, false otherwise
@@ -576,6 +636,15 @@ export type AccessConfig = {
576
636
  * @returns true if authenticated, false otherwise
577
637
  */
578
638
  isAuthenticated?: Access;
639
+ /**
640
+ * Checks if the user is a customer (authenticated but not an admin).
641
+ * Used internally to auto-assign customer ID when creating addresses.
642
+ * @returns true if user is a non-admin customer, false otherwise
643
+ *
644
+ * @example
645
+ * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user)
646
+ */
647
+ isCustomer?: FieldAccess;
579
648
  /**
580
649
  * Checks if the user owns the document being accessed.
581
650
  * Typically returns a Where query to filter by customer field.
@@ -662,8 +731,9 @@ export type EcommercePluginConfig = {
662
731
  */
663
732
  transactions?: boolean | TransactionsConfig;
664
733
  };
734
+ export type SanitizedAccessConfig = Pick<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'> & Required<Omit<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'>>;
665
735
  export type SanitizedEcommercePluginConfig = {
666
- access: Required<AccessConfig>;
736
+ access: SanitizedAccessConfig;
667
737
  addresses: {
668
738
  addressFields: Field[];
669
739
  } & Omit<AddressesConfig, 'addressFields'>;
@@ -703,20 +773,47 @@ type APIProps = {
703
773
  */
704
774
  serverURL?: string;
705
775
  };
776
+ /**
777
+ * Memoized configuration object exposed via the useEcommerce hook.
778
+ * Contains collection slugs and API settings for building URLs and queries.
779
+ */
780
+ export type EcommerceConfig = {
781
+ /**
782
+ * The slug for the addresses collection.
783
+ */
784
+ addressesSlug: CollectionSlug;
785
+ /**
786
+ * API configuration including the base route.
787
+ */
788
+ api: {
789
+ /**
790
+ * The base API route, e.g. '/api'.
791
+ */
792
+ apiRoute: string;
793
+ };
794
+ /**
795
+ * The slug for the carts collection.
796
+ */
797
+ cartsSlug: CollectionSlug;
798
+ /**
799
+ * The slug for the customers collection.
800
+ */
801
+ customersSlug: CollectionSlug;
802
+ };
706
803
  export type ContextProps = {
707
804
  /**
708
805
  * The slug for the addresses collection.
709
806
  *
710
807
  * Defaults to 'addresses'.
711
808
  */
712
- addressesSlug?: string;
809
+ addressesSlug?: CollectionSlug;
713
810
  api?: APIProps;
714
811
  /**
715
812
  * The slug for the carts collection.
716
813
  *
717
814
  * Defaults to 'carts'.
718
815
  */
719
- cartsSlug?: string;
816
+ cartsSlug?: CollectionSlug;
720
817
  children?: React.ReactNode;
721
818
  /**
722
819
  * The configuration for currencies used in the ecommerce context.
@@ -728,7 +825,7 @@ export type ContextProps = {
728
825
  *
729
826
  * Defaults to 'users'.
730
827
  */
731
- customersSlug?: string;
828
+ customersSlug?: CollectionSlug;
732
829
  /**
733
830
  * Enable debug mode for the ecommerce context. This will log additional information to the console.
734
831
  * Defaults to false.
@@ -785,6 +882,17 @@ export type EcommerceContextType<T extends EcommerceCollections = EcommerceColle
785
882
  * Clear the cart, removing all items.
786
883
  */
787
884
  clearCart: () => Promise<void>;
885
+ /**
886
+ * Clears all ecommerce session data including cart, addresses, and user state.
887
+ * Should be called when a user logs out.
888
+ * This also clears localStorage cart data when syncLocalStorage is enabled.
889
+ */
890
+ clearSession: () => void;
891
+ /**
892
+ * Memoized configuration object containing collection slugs and API settings.
893
+ * Use this to build URLs and queries with the correct collection slugs.
894
+ */
895
+ config: EcommerceConfig;
788
896
  /**
789
897
  * Initiate a payment using the selected payment method.
790
898
  * This method should be called after the cart is ready for checkout.
@@ -806,14 +914,16 @@ export type EcommerceContextType<T extends EcommerceCollections = EcommerceColle
806
914
  */
807
915
  currency: Currency;
808
916
  /**
809
- * Decrement an item in the cart by its index ID.
917
+ * Decrement an item in the cart by its array item ID.
810
918
  * If quantity reaches 0, the item will be removed from the cart.
919
+ * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)
811
920
  */
812
- decrementItem: (item: DefaultDocumentIDType) => Promise<void>;
921
+ decrementItem: (item: string) => Promise<void>;
813
922
  /**
814
- * Increment an item in the cart by its index ID.
923
+ * Increment an item in the cart by its array item ID.
924
+ * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)
815
925
  */
816
- incrementItem: (item: DefaultDocumentIDType) => Promise<void>;
926
+ incrementItem: (item: string) => Promise<void>;
817
927
  /**
818
928
  * Initiate a payment using the selected payment method.
819
929
  * This method should be called after the cart is ready for checkout.
@@ -827,15 +937,41 @@ export type EcommerceContextType<T extends EcommerceCollections = EcommerceColle
827
937
  * Useful for disabling buttons and preventing race conditions.
828
938
  */
829
939
  isLoading: boolean;
940
+ /**
941
+ * Merges items from a source cart into a target cart.
942
+ * Useful for merging a guest cart into a user's existing cart after login.
943
+ *
944
+ * @param targetCartID - The ID of the cart to merge items into
945
+ * @param sourceCartID - The ID of the cart to merge items from
946
+ * @param sourceSecret - The secret for the source cart (required for guest carts)
947
+ * @returns The merged cart
948
+ */
949
+ mergeCart: (targetCartID: DefaultDocumentIDType, sourceCartID: DefaultDocumentIDType, sourceSecret?: string) => Promise<T['carts'] | void>;
950
+ /**
951
+ * Called after a successful login to handle cart state.
952
+ * If a guest cart exists, it will be merged with the user's existing cart
953
+ * or assigned to the user if they have no cart.
954
+ * Cart secrets are cleared as authenticated users don't need them.
955
+ *
956
+ * @returns Promise that resolves when cart state is properly set up for the user.
957
+ */
958
+ onLogin: () => Promise<void>;
959
+ /**
960
+ * Called during logout to clear all ecommerce session data.
961
+ * Clears cart, addresses, user state, and localStorage cart data.
962
+ * This is an alias for clearSession() but named for semantic clarity.
963
+ */
964
+ onLogout: () => void;
830
965
  paymentMethods: PaymentAdapterClient[];
831
966
  /**
832
967
  * Refresh the cart.
833
968
  */
834
969
  refreshCart: () => Promise<void>;
835
970
  /**
836
- * Remove an item from the cart by its index ID.
971
+ * Remove an item from the cart by its array item ID.
972
+ * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)
837
973
  */
838
- removeItem: (item: DefaultDocumentIDType) => Promise<void>;
974
+ removeItem: (item: string) => Promise<void>;
839
975
  /**
840
976
  * The name of the currently selected payment method.
841
977
  * This is used to determine which payment method to use when initiating a payment.
@@ -850,6 +986,10 @@ export type EcommerceContextType<T extends EcommerceCollections = EcommerceColle
850
986
  * Update an address by providing the data and the ID.
851
987
  */
852
988
  updateAddress: (addressID: DefaultDocumentIDType, data: Partial<T['addresses']>) => Promise<void>;
989
+ /**
990
+ * The current authenticated user, or null if not logged in.
991
+ */
992
+ user: null | TypedUser;
853
993
  };
854
994
  export {};
855
995
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"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efaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n PopulateType,\n SelectType,\n TypedCollection,\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 id: DefaultDocumentIDType\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\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 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 * isDocumentOwner: ({ req }) => {\n * if (!req.user) return false\n * return { customer: { equals: req.user.id } }\n * },\n * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),\n * customerOnlyFieldAccess: ({ req }) => !!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 * 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 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 SanitizedEcommercePluginConfig = {\n access: Required<AccessConfig>\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\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: string\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: string\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?: string\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 * 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 index ID.\n * If quantity reaches 0, the item will be removed from the cart.\n */\n decrementItem: (item: DefaultDocumentIDType) => Promise<void>\n /**\n * Increment an item in the cart by its index ID.\n */\n incrementItem: (item: DefaultDocumentIDType) => 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 paymentMethods: PaymentAdapterClient[]\n /**\n * Refresh the cart.\n */\n refreshCart: () => Promise<void>\n /**\n * Remove an item from the cart by its index ID.\n */\n removeItem: (item: DefaultDocumentIDType) => 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"],"names":[],"mappings":"AAizBA,WAyFC"}
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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/VariantOptionsSelector/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAKrD,OAAO,aAAa,CAAA;AAEpB,KAAK,KAAK,GAAG,EAAE,GAAG,sBAAsB,CAAA;AAExC,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA0ElD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/VariantOptionsSelector/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAKrD,OAAO,aAAa,CAAA;AAGpB,KAAK,KAAK,GAAG,EAAE,GAAG,sBAAsB,CAAA;AAExC,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA8ElD,CAAA"}
@@ -4,11 +4,14 @@ import { ErrorBox } from './ErrorBox.js';
4
4
  import './index.css';
5
5
  import { OptionsSelect } from './OptionsSelect.js';
6
6
  export const VariantOptionsSelector = async (props)=>{
7
- const { clientField, data, path, req, user } = props;
7
+ const { clientField, data, field, path, req, user } = props;
8
8
  const { label } = clientField;
9
+ // Get collection slugs from field custom prop, with defaults for backwards compatibility
10
+ const productsSlug = field.custom?.productsSlug || 'products';
11
+ const variantTypesSlug = field.custom?.variantTypesSlug || 'variantTypes';
9
12
  const product = await req.payload.findByID({
10
13
  id: data.product,
11
- collection: 'products',
14
+ collection: productsSlug,
12
15
  depth: 0,
13
16
  draft: true,
14
17
  select: {
@@ -28,7 +31,7 @@ export const VariantOptionsSelector = async (props)=>{
28
31
  for (const variantTypeID of variantTypeIDs){
29
32
  const variantType = await req.payload.findByID({
30
33
  id: variantTypeID,
31
- collection: 'variantTypes',
34
+ collection: variantTypesSlug,
32
35
  depth: 1,
33
36
  joins: {
34
37
  options: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ui/VariantOptionsSelector/index.tsx"],"sourcesContent":["import type { SelectFieldServerProps } from 'payload'\n\nimport { FieldLabel } from '@payloadcms/ui'\n\nimport { ErrorBox } from './ErrorBox.js'\nimport './index.css'\nimport { OptionsSelect } from './OptionsSelect.js'\ntype Props = {} & SelectFieldServerProps\n\nexport const VariantOptionsSelector: React.FC<Props> = async (props) => {\n const { clientField, data, path, req, user } = props\n const { label } = clientField\n\n const product = await req.payload.findByID({\n id: data.product,\n collection: 'products',\n depth: 0,\n draft: true,\n select: {\n variants: true,\n variantTypes: true,\n },\n user,\n })\n\n // @ts-expect-error - TODO: Fix types\n const existingVariantOptions = product.variants?.docs?.map((variant) => variant.options) ?? []\n\n const variantTypeIDs = product.variantTypes\n\n const variantTypes = []\n\n // Need to get the variant types separately so that the options are populated\n // @ts-expect-error - TODO: Fix types\n if (variantTypeIDs?.length && variantTypeIDs.length > 0) {\n // @ts-expect-error - TODO: Fix types\n for (const variantTypeID of variantTypeIDs) {\n const variantType = await req.payload.findByID({\n id: variantTypeID,\n collection: 'variantTypes',\n depth: 1,\n joins: {\n options: {\n sort: 'value',\n },\n },\n })\n\n if (variantType) {\n variantTypes.push(variantType)\n }\n }\n }\n\n return (\n <div className=\"variantOptionsSelector\">\n <div className=\"variantOptionsSelectorHeading\">\n <FieldLabel as=\"span\" label={label} />\n </div>\n\n <ErrorBox existingOptions={existingVariantOptions} path={path}>\n <div className=\"variantOptionsSelectorList\">\n {variantTypes.map((type) => {\n // @ts-expect-error - TODO: Fix types\n const options = type.options.docs.map((option) => ({\n label: option.label,\n value: option.id,\n }))\n\n return (\n <OptionsSelect\n field={clientField}\n key={type.name}\n label={type.label || type.name}\n options={options}\n path={path}\n />\n )\n })}\n </div>\n </ErrorBox>\n </div>\n )\n}\n"],"names":["FieldLabel","ErrorBox","OptionsSelect","VariantOptionsSelector","props","clientField","data","path","req","user","label","product","payload","findByID","id","collection","depth","draft","select","variants","variantTypes","existingVariantOptions","docs","map","variant","options","variantTypeIDs","length","variantTypeID","variantType","joins","sort","push","div","className","as","existingOptions","type","option","value","field","name"],"mappings":";AAEA,SAASA,UAAU,QAAQ,iBAAgB;AAE3C,SAASC,QAAQ,QAAQ,gBAAe;AACxC,OAAO,cAAa;AACpB,SAASC,aAAa,QAAQ,qBAAoB;AAGlD,OAAO,MAAMC,yBAA0C,OAAOC;IAC5D,MAAM,EAAEC,WAAW,EAAEC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGL;IAC/C,MAAM,EAAEM,KAAK,EAAE,GAAGL;IAElB,MAAMM,UAAU,MAAMH,IAAII,OAAO,CAACC,QAAQ,CAAC;QACzCC,IAAIR,KAAKK,OAAO;QAChBI,YAAY;QACZC,OAAO;QACPC,OAAO;QACPC,QAAQ;YACNC,UAAU;YACVC,cAAc;QAChB;QACAX;IACF;IAEA,qCAAqC;IACrC,MAAMY,yBAAyBV,QAAQQ,QAAQ,EAAEG,MAAMC,IAAI,CAACC,UAAYA,QAAQC,OAAO,KAAK,EAAE;IAE9F,MAAMC,iBAAiBf,QAAQS,YAAY;IAE3C,MAAMA,eAAe,EAAE;IAEvB,6EAA6E;IAC7E,qCAAqC;IACrC,IAAIM,gBAAgBC,UAAUD,eAAeC,MAAM,GAAG,GAAG;QACvD,qCAAqC;QACrC,KAAK,MAAMC,iBAAiBF,eAAgB;YAC1C,MAAMG,cAAc,MAAMrB,IAAII,OAAO,CAACC,QAAQ,CAAC;gBAC7CC,IAAIc;gBACJb,YAAY;gBACZC,OAAO;gBACPc,OAAO;oBACLL,SAAS;wBACPM,MAAM;oBACR;gBACF;YACF;YAEA,IAAIF,aAAa;gBACfT,aAAaY,IAAI,CAACH;YACpB;QACF;IACF;IAEA,qBACE,MAACI;QAAIC,WAAU;;0BACb,KAACD;gBAAIC,WAAU;0BACb,cAAA,KAAClC;oBAAWmC,IAAG;oBAAOzB,OAAOA;;;0BAG/B,KAACT;gBAASmC,iBAAiBf;gBAAwBd,MAAMA;0BACvD,cAAA,KAAC0B;oBAAIC,WAAU;8BACZd,aAAaG,GAAG,CAAC,CAACc;wBACjB,qCAAqC;wBACrC,MAAMZ,UAAUY,KAAKZ,OAAO,CAACH,IAAI,CAACC,GAAG,CAAC,CAACe,SAAY,CAAA;gCACjD5B,OAAO4B,OAAO5B,KAAK;gCACnB6B,OAAOD,OAAOxB,EAAE;4BAClB,CAAA;wBAEA,qBACE,KAACZ;4BACCsC,OAAOnC;4BAEPK,OAAO2B,KAAK3B,KAAK,IAAI2B,KAAKI,IAAI;4BAC9BhB,SAASA;4BACTlB,MAAMA;2BAHD8B,KAAKI,IAAI;oBAMpB;;;;;AAKV,EAAC"}
1
+ {"version":3,"sources":["../../../src/ui/VariantOptionsSelector/index.tsx"],"sourcesContent":["import type { SelectFieldServerProps } from 'payload'\n\nimport { FieldLabel } from '@payloadcms/ui'\n\nimport { ErrorBox } from './ErrorBox.js'\nimport './index.css'\nimport { OptionsSelect } from './OptionsSelect.js'\n\ntype Props = {} & SelectFieldServerProps\n\nexport const VariantOptionsSelector: React.FC<Props> = async (props) => {\n const { clientField, data, field, path, req, user } = props\n const { label } = clientField\n\n // Get collection slugs from field custom prop, with defaults for backwards compatibility\n const productsSlug = (field.custom?.productsSlug as string) || 'products'\n const variantTypesSlug = (field.custom?.variantTypesSlug as string) || 'variantTypes'\n\n const product = await req.payload.findByID({\n id: data.product,\n collection: productsSlug,\n depth: 0,\n draft: true,\n select: {\n variants: true,\n variantTypes: true,\n },\n user,\n })\n\n // @ts-expect-error - TODO: Fix types\n const existingVariantOptions = product.variants?.docs?.map((variant) => variant.options) ?? []\n\n const variantTypeIDs = product.variantTypes\n\n const variantTypes = []\n\n // Need to get the variant types separately so that the options are populated\n // @ts-expect-error - TODO: Fix types\n if (variantTypeIDs?.length && variantTypeIDs.length > 0) {\n // @ts-expect-error - TODO: Fix types\n for (const variantTypeID of variantTypeIDs) {\n const variantType = await req.payload.findByID({\n id: variantTypeID,\n collection: variantTypesSlug,\n depth: 1,\n joins: {\n options: {\n sort: 'value',\n },\n },\n })\n\n if (variantType) {\n variantTypes.push(variantType)\n }\n }\n }\n\n return (\n <div className=\"variantOptionsSelector\">\n <div className=\"variantOptionsSelectorHeading\">\n <FieldLabel as=\"span\" label={label} />\n </div>\n\n <ErrorBox existingOptions={existingVariantOptions} path={path}>\n <div className=\"variantOptionsSelectorList\">\n {variantTypes.map((type) => {\n // @ts-expect-error - TODO: Fix types\n const options = type.options.docs.map((option) => ({\n label: option.label,\n value: option.id,\n }))\n\n return (\n <OptionsSelect\n field={clientField}\n key={type.name}\n label={type.label || type.name}\n options={options}\n path={path}\n />\n )\n })}\n </div>\n </ErrorBox>\n </div>\n )\n}\n"],"names":["FieldLabel","ErrorBox","OptionsSelect","VariantOptionsSelector","props","clientField","data","field","path","req","user","label","productsSlug","custom","variantTypesSlug","product","payload","findByID","id","collection","depth","draft","select","variants","variantTypes","existingVariantOptions","docs","map","variant","options","variantTypeIDs","length","variantTypeID","variantType","joins","sort","push","div","className","as","existingOptions","type","option","value","name"],"mappings":";AAEA,SAASA,UAAU,QAAQ,iBAAgB;AAE3C,SAASC,QAAQ,QAAQ,gBAAe;AACxC,OAAO,cAAa;AACpB,SAASC,aAAa,QAAQ,qBAAoB;AAIlD,OAAO,MAAMC,yBAA0C,OAAOC;IAC5D,MAAM,EAAEC,WAAW,EAAEC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGN;IACtD,MAAM,EAAEO,KAAK,EAAE,GAAGN;IAElB,yFAAyF;IACzF,MAAMO,eAAe,AAACL,MAAMM,MAAM,EAAED,gBAA2B;IAC/D,MAAME,mBAAmB,AAACP,MAAMM,MAAM,EAAEC,oBAA+B;IAEvE,MAAMC,UAAU,MAAMN,IAAIO,OAAO,CAACC,QAAQ,CAAC;QACzCC,IAAIZ,KAAKS,OAAO;QAChBI,YAAYP;QACZQ,OAAO;QACPC,OAAO;QACPC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ecommerce",
3
- "version": "3.71.0-internal.e36f916",
3
+ "version": "3.71.0",
4
4
  "description": "Ecommerce plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -56,10 +56,15 @@
56
56
  "types": "./dist/exports/client/react.d.ts",
57
57
  "default": "./dist/exports/client/react.js"
58
58
  },
59
- "./translations": {
60
- "import": "./dist/exports/translations.js",
61
- "types": "./dist/exports/translations.d.ts",
62
- "default": "./dist/exports/translations.js"
59
+ "./translations/languages/all": {
60
+ "import": "./dist/translations/index.js",
61
+ "types": "./dist/translations/index.d.ts",
62
+ "default": "./dist/translations/index.js"
63
+ },
64
+ "./translations/languages/*": {
65
+ "import": "./dist/translations/languages/*.js",
66
+ "types": "./dist/translations/languages/*.d.ts",
67
+ "default": "./dist/translations/languages/*.js"
63
68
  }
64
69
  },
65
70
  "main": "./dist/index.js",
@@ -69,8 +74,8 @@
69
74
  ],
70
75
  "dependencies": {
71
76
  "qs-esm": "7.0.2",
72
- "@payloadcms/translations": "3.71.0-internal.e36f916",
73
- "@payloadcms/ui": "3.71.0-internal.e36f916"
77
+ "@payloadcms/ui": "3.71.0",
78
+ "@payloadcms/translations": "3.71.0"
74
79
  },
75
80
  "devDependencies": {
76
81
  "@types/json-schema": "7.0.15",
@@ -78,13 +83,14 @@
78
83
  "@types/react-dom": "19.2.1",
79
84
  "stripe": "18.3.0",
80
85
  "@payloadcms/eslint-config": "3.28.0",
81
- "payload": "3.71.0-internal.e36f916",
82
- "@payloadcms/next": "3.71.0-internal.e36f916"
86
+ "@payloadcms/next": "3.71.0",
87
+ "@payloadcms/translations": "3.71.0",
88
+ "payload": "3.71.0"
83
89
  },
84
90
  "peerDependencies": {
85
91
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
86
92
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
87
- "payload": "3.71.0-internal.e36f916"
93
+ "payload": "3.71.0"
88
94
  },
89
95
  "publishConfig": {
90
96
  "registry": "https://registry.npmjs.org/"