@payloadcms/plugin-ecommerce 3.57.0-internal.74d0404 → 3.57.0-internal.8586ab4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,qBAAqB,EAAkC,MAAM,YAAY,CAAA;AAEvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAA;AAChG,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAA;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAA;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAA;AAC7F,OAAO,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAA;AACzG,OAAO,EAAE,8BAA8B,EAAE,MAAM,0DAA0D,CAAA;AACzG,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAA;AACnG,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAA;AAOrG,eAAO,MAAM,eAAe,kBACV,qBAAqB,sBACd,MAAM,KAAG,OAAO,CAAC,MAAM,CA6T7C,CAAA;AAEH,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,8BAA8B,EAC9B,wBAAwB,EACxB,4BAA4B,GAC7B,CAAA;AAED,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE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M,4BAA4B,CAAA"}
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import { confirmOrderHandler } from './endpoints/confirmOrder.js';
11
11
  import { initiatePaymentHandler } from './endpoints/initiatePayment.js';
12
12
  import { translations } from './translations/index.js';
13
13
  import { getCollectionSlugMap } from './utilities/getCollectionSlugMap.js';
14
+ import { pushTypeScriptProperties } from './utilities/pushTypeScriptProperties.js';
14
15
  import { sanitizePluginConfig } from './utilities/sanitizePluginConfig.js';
15
16
  export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
16
17
  if (!pluginConfig) {
@@ -223,9 +224,17 @@ export const ecommercePlugin = (pluginConfig)=>async (incomingConfig)=>{
223
224
  incomingConfig.i18n.translations = {};
224
225
  }
225
226
  incomingConfig.i18n.translations = deepMergeSimple(translations, incomingConfig.i18n?.translations);
226
- return {
227
- ...incomingConfig
228
- };
227
+ if (!incomingConfig.typescript) {
228
+ incomingConfig.typescript = {};
229
+ }
230
+ if (!incomingConfig.typescript.schema) {
231
+ incomingConfig.typescript.schema = [];
232
+ }
233
+ incomingConfig.typescript.schema.push((args)=>pushTypeScriptProperties({
234
+ ...args,
235
+ sanitizedPluginConfig
236
+ }));
237
+ return incomingConfig;
229
238
  };
230
239
  export { createAddressesCollection, createCartsCollection, createOrdersCollection, createProductsCollection, createTransactionsCollection, createVariantOptionsCollection, createVariantsCollection, createVariantTypesCollection, };
231
240
  export { EUR, GBP, USD } from './currencies/index.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config, Endpoint } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\n\nimport type { EcommercePluginConfig, SanitizedEcommercePluginConfig } from './types.js'\n\nimport { createAddressesCollection } from './collections/addresses/createAddressesCollection.js'\nimport { createCartsCollection } from './collections/carts/createCartsCollection.js'\nimport { createOrdersCollection } from './collections/orders/createOrdersCollection.js'\nimport { createProductsCollection } from './collections/products/createProductsCollection.js'\nimport { createTransactionsCollection } from './collections/transactions/createTransactionsCollection.js'\nimport { createVariantOptionsCollection } from './collections/variants/createVariantOptionsCollection.js'\nimport { createVariantsCollection } from './collections/variants/createVariantsCollection/index.js'\nimport { createVariantTypesCollection } from './collections/variants/createVariantTypesCollection.js'\nimport { confirmOrderHandler } from './endpoints/confirmOrder.js'\nimport { initiatePaymentHandler } from './endpoints/initiatePayment.js'\nimport { translations } from './translations/index.js'\nimport { getCollectionSlugMap } from './utilities/getCollectionSlugMap.js'\nimport { sanitizePluginConfig } from './utilities/sanitizePluginConfig.js'\n\nexport const ecommercePlugin =\n (pluginConfig?: EcommercePluginConfig) =>\n async (incomingConfig: Config): Promise<Config> => {\n if (!pluginConfig) {\n return incomingConfig\n }\n\n const sanitizedPluginConfig = sanitizePluginConfig({ pluginConfig })\n /**\n * Used to keep track of the slugs of collections in case they are overridden by the user.\n */\n const collectionSlugMap = getCollectionSlugMap({ sanitizedPluginConfig })\n\n const accessConfig = sanitizedPluginConfig.access\n\n // Ensure collections exists\n if (!incomingConfig.collections) {\n incomingConfig.collections = []\n }\n\n // Controls whether variants are enabled in the plugin. This is toggled to true under products config\n let enableVariants = false\n\n const currenciesConfig: Required<SanitizedEcommercePluginConfig['currencies']> =\n sanitizedPluginConfig.currencies\n\n let addressFields\n\n if (sanitizedPluginConfig.addresses) {\n addressFields = sanitizedPluginConfig.addresses.addressFields\n\n const supportedCountries = sanitizedPluginConfig.addresses.supportedCountries\n\n const defaultAddressesCollection = createAddressesCollection({\n access: {\n adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,\n authenticatedOnly: accessConfig.authenticatedOnly,\n customerOnlyFieldAccess: accessConfig.customerOnlyFieldAccess,\n },\n addressFields,\n customersSlug: collectionSlugMap.customers,\n supportedCountries,\n })\n\n const addressesCollection =\n sanitizedPluginConfig.addresses &&\n typeof sanitizedPluginConfig.addresses === 'object' &&\n 'addressesCollectionOverride' in sanitizedPluginConfig.addresses &&\n sanitizedPluginConfig.addresses.addressesCollectionOverride\n ? await sanitizedPluginConfig.addresses.addressesCollectionOverride({\n defaultCollection: defaultAddressesCollection,\n })\n : defaultAddressesCollection\n\n incomingConfig.collections.push(addressesCollection)\n }\n\n if (sanitizedPluginConfig.products) {\n const productsConfig =\n typeof sanitizedPluginConfig.products === 'boolean'\n ? {\n variants: true,\n }\n : sanitizedPluginConfig.products\n\n enableVariants = Boolean(productsConfig.variants)\n\n if (productsConfig.variants) {\n const variantsConfig =\n typeof productsConfig.variants === 'boolean' ? undefined : productsConfig.variants\n\n const defaultVariantsCollection = createVariantsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n adminOrPublishedStatus: accessConfig.adminOrPublishedStatus,\n },\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n productsSlug: collectionSlugMap.products,\n variantOptionsSlug: collectionSlugMap.variantOptions,\n })\n\n const variants =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantsCollectionOverride' in variantsConfig &&\n variantsConfig.variantsCollectionOverride\n ? await variantsConfig.variantsCollectionOverride({\n defaultCollection: defaultVariantsCollection,\n })\n : defaultVariantsCollection\n\n const defaultVariantTypesCollection = createVariantTypesCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n publicAccess: accessConfig.publicAccess,\n },\n variantOptionsSlug: collectionSlugMap.variantOptions,\n })\n\n const variantTypes =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantTypesCollectionOverride' in variantsConfig &&\n variantsConfig.variantTypesCollectionOverride\n ? await variantsConfig.variantTypesCollectionOverride({\n defaultCollection: defaultVariantTypesCollection,\n })\n : defaultVariantTypesCollection\n\n const defaultVariantOptionsCollection = createVariantOptionsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n publicAccess: accessConfig.publicAccess,\n },\n variantTypesSlug: collectionSlugMap.variantTypes,\n })\n\n const variantOptions =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantOptionsCollectionOverride' in variantsConfig &&\n variantsConfig.variantOptionsCollectionOverride\n ? await variantsConfig.variantOptionsCollectionOverride({\n defaultCollection: defaultVariantOptionsCollection,\n })\n : defaultVariantOptionsCollection\n\n incomingConfig.collections.push(variants, variantTypes, variantOptions)\n }\n\n const defaultProductsCollection = createProductsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n adminOrPublishedStatus: accessConfig.adminOrPublishedStatus,\n },\n currenciesConfig,\n enableVariants,\n inventory: sanitizedPluginConfig.inventory,\n variantsSlug: collectionSlugMap.variants,\n variantTypesSlug: collectionSlugMap.variantTypes,\n })\n\n const productsCollection =\n productsConfig &&\n 'productsCollectionOverride' in productsConfig &&\n productsConfig.productsCollectionOverride\n ? await productsConfig.productsCollectionOverride({\n defaultCollection: defaultProductsCollection,\n })\n : defaultProductsCollection\n\n incomingConfig.collections.push(productsCollection)\n\n if (sanitizedPluginConfig.carts) {\n const defaultCartsCollection = createCartsCollection({\n access: {\n adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,\n publicAccess: accessConfig.publicAccess,\n },\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants: Boolean(productsConfig.variants),\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const cartsCollection =\n sanitizedPluginConfig.carts &&\n typeof sanitizedPluginConfig.carts === 'object' &&\n 'cartsCollectionOverride' in sanitizedPluginConfig.carts &&\n sanitizedPluginConfig.carts.cartsCollectionOverride\n ? await sanitizedPluginConfig.carts.cartsCollectionOverride({\n defaultCollection: defaultCartsCollection,\n })\n : defaultCartsCollection\n\n incomingConfig.collections.push(cartsCollection)\n }\n }\n\n if (sanitizedPluginConfig.orders) {\n const defaultOrdersCollection = createOrdersCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n adminOnlyFieldAccess: accessConfig.adminOnlyFieldAccess,\n adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,\n },\n addressFields,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const ordersCollection =\n sanitizedPluginConfig.orders &&\n typeof sanitizedPluginConfig.orders === 'object' &&\n 'ordersCollectionOverride' in sanitizedPluginConfig.orders &&\n sanitizedPluginConfig.orders.ordersCollectionOverride\n ? await sanitizedPluginConfig.orders.ordersCollectionOverride({\n defaultCollection: defaultOrdersCollection,\n })\n : defaultOrdersCollection\n\n incomingConfig.collections.push(ordersCollection)\n }\n\n const paymentMethods = sanitizedPluginConfig.payments.paymentMethods\n\n if (sanitizedPluginConfig.payments) {\n if (paymentMethods.length) {\n if (!Array.isArray(incomingConfig.endpoints)) {\n incomingConfig.endpoints = []\n }\n\n const productsValidation =\n (typeof sanitizedPluginConfig.products === 'object' &&\n sanitizedPluginConfig.products.validation) ||\n undefined\n\n paymentMethods.forEach((paymentMethod) => {\n const methodPath = `/payments/${paymentMethod.name}`\n const endpoints: Endpoint[] = []\n\n const initiatePayment: Endpoint = {\n handler: initiatePaymentHandler({\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n paymentMethod,\n productsSlug: collectionSlugMap.products,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n variantsSlug: collectionSlugMap.variants,\n }),\n method: 'post',\n path: `${methodPath}/initiate`,\n }\n\n const confirmOrder: Endpoint = {\n handler: confirmOrderHandler({\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n ordersSlug: collectionSlugMap.orders,\n paymentMethod,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n }),\n method: 'post',\n path: `${methodPath}/confirm-order`,\n }\n\n endpoints.push(initiatePayment, confirmOrder)\n\n // Attach any additional endpoints defined in the payment method\n if (paymentMethod.endpoints && paymentMethod.endpoints.length > 0) {\n const methodEndpoints = paymentMethod.endpoints.map((endpoint) => {\n const path = endpoint.path.startsWith('/') ? endpoint.path : `/${endpoint.path}`\n\n return {\n ...endpoint,\n path: `${methodPath}${path}`,\n }\n })\n\n endpoints.push(...methodEndpoints)\n }\n\n incomingConfig.endpoints!.push(...endpoints)\n })\n }\n }\n\n if (sanitizedPluginConfig.transactions) {\n const defaultTransactionsCollection = createTransactionsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n },\n addressFields,\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n ordersSlug: collectionSlugMap.orders,\n paymentMethods,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const transactionsCollection =\n sanitizedPluginConfig.transactions &&\n typeof sanitizedPluginConfig.transactions === 'object' &&\n 'transactionsCollectionOverride' in sanitizedPluginConfig.transactions &&\n sanitizedPluginConfig.transactions.transactionsCollectionOverride\n ? await sanitizedPluginConfig.transactions.transactionsCollectionOverride({\n defaultCollection: defaultTransactionsCollection,\n })\n : defaultTransactionsCollection\n\n incomingConfig.collections.push(transactionsCollection)\n }\n\n if (!incomingConfig.i18n) {\n incomingConfig.i18n = {}\n }\n\n if (!incomingConfig.i18n?.translations) {\n incomingConfig.i18n.translations = {}\n }\n\n incomingConfig.i18n.translations = deepMergeSimple(\n translations,\n incomingConfig.i18n?.translations,\n )\n\n return {\n ...incomingConfig,\n }\n }\n\nexport {\n createAddressesCollection,\n createCartsCollection,\n createOrdersCollection,\n createProductsCollection,\n createTransactionsCollection,\n createVariantOptionsCollection,\n createVariantsCollection,\n createVariantTypesCollection,\n}\n\nexport { EUR, GBP, USD } from './currencies/index.js'\nexport { amountField } from './fields/amountField.js'\nexport { currencyField } from './fields/currencyField.js'\nexport { pricesField } from './fields/pricesField.js'\nexport { statusField } from './fields/statusField.js'\nexport { variantsFields } from './fields/variantsFields.js'\n"],"names":["deepMergeSimple","createAddressesCollection","createCartsCollection","createOrdersCollection","createProductsCollection","createTransactionsCollection","createVariantOptionsCollection","createVariantsCollection","createVariantTypesCollection","confirmOrderHandler","initiatePaymentHandler","translations","getCollectionSlugMap","sanitizePluginConfig","ecommercePlugin","pluginConfig","incomingConfig","sanitizedPluginConfig","collectionSlugMap","accessConfig","access","collections","enableVariants","currenciesConfig","currencies","addressFields","addresses","supportedCountries","defaultAddressesCollection","adminOrCustomerOwner","authenticatedOnly","customerOnlyFieldAccess","customersSlug","customers","addressesCollection","addressesCollectionOverride","defaultCollection","push","products","productsConfig","variants","Boolean","variantsConfig","undefined","defaultVariantsCollection","adminOnly","adminOrPublishedStatus","inventory","productsSlug","variantOptionsSlug","variantOptions","variantsCollectionOverride","defaultVariantTypesCollection","publicAccess","variantTypes","variantTypesCollectionOverride","defaultVariantOptionsCollection","variantTypesSlug","variantOptionsCollectionOverride","defaultProductsCollection","variantsSlug","productsCollection","productsCollectionOverride","carts","defaultCartsCollection","cartsCollection","cartsCollectionOverride","orders","defaultOrdersCollection","adminOnlyFieldAccess","ordersCollection","ordersCollectionOverride","paymentMethods","payments","length","Array","isArray","endpoints","productsValidation","validation","forEach","paymentMethod","methodPath","name","initiatePayment","handler","transactionsSlug","transactions","method","path","confirmOrder","cartsSlug","ordersSlug","methodEndpoints","map","endpoint","startsWith","defaultTransactionsCollection","transactionsCollection","transactionsCollectionOverride","i18n","EUR","GBP","USD","amountField","currencyField","pricesField","statusField","variantsFields"],"mappings":"AAEA,SAASA,eAAe,QAAQ,iBAAgB;AAIhD,SAASC,yBAAyB,QAAQ,uDAAsD;AAChG,SAASC,qBAAqB,QAAQ,+CAA8C;AACpF,SAASC,sBAAsB,QAAQ,iDAAgD;AACvF,SAASC,wBAAwB,QAAQ,qDAAoD;AAC7F,SAASC,4BAA4B,QAAQ,6DAA4D;AACzG,SAASC,8BAA8B,QAAQ,2DAA0D;AACzG,SAASC,wBAAwB,QAAQ,2DAA0D;AACnG,SAASC,4BAA4B,QAAQ,yDAAwD;AACrG,SAASC,mBAAmB,QAAQ,8BAA6B;AACjE,SAASC,sBAAsB,QAAQ,iCAAgC;AACvE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,oB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jF,eAAeK,WAAW,CAACgB,IAAI,CAAC6D;QAClC;QAEA,IAAI,CAAClF,eAAeoF,IAAI,EAAE;YACxBpF,eAAeoF,IAAI,GAAG,CAAC;QACzB;QAEA,IAAI,CAACpF,eAAeoF,IAAI,EAAEzF,cAAc;YACtCK,eAAeoF,IAAI,CAACzF,YAAY,GAAG,CAAC;QACtC;QAEAK,eAAeoF,IAAI,CAACzF,YAAY,GAAGX,gBACjCW,cACAK,eAAeoF,IAAI,EAAEzF;QAGvB,OAAO;YACL,GAAGK,cAAc;QACnB;IACF,EAAC;AAEH,SACEf,yBAAyB,EACzBC,qBAAqB,EACrBC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,wBAAwB,EACxBC,4BAA4B,KAC7B;AAED,SAAS6F,GAAG,EAAEC,GAAG,EAAEC,GAAG,QAAQ,wBAAuB;AACrD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,cAAc,QAAQ,6BAA4B"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config, Endpoint } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\n\nimport type { EcommercePluginConfig, SanitizedEcommercePluginConfig } from './types.js'\n\nimport { createAddressesCollection } from './collections/addresses/createAddressesCollection.js'\nimport { createCartsCollection } from './collections/carts/createCartsCollection.js'\nimport { createOrdersCollection } from './collections/orders/createOrdersCollection.js'\nimport { createProductsCollection } from './collections/products/createProductsCollection.js'\nimport { createTransactionsCollection } from './collections/transactions/createTransactionsCollection.js'\nimport { createVariantOptionsCollection } from './collections/variants/createVariantOptionsCollection.js'\nimport { createVariantsCollection } from './collections/variants/createVariantsCollection/index.js'\nimport { createVariantTypesCollection } from './collections/variants/createVariantTypesCollection.js'\nimport { confirmOrderHandler } from './endpoints/confirmOrder.js'\nimport { initiatePaymentHandler } from './endpoints/initiatePayment.js'\nimport { translations } from './translations/index.js'\nimport { getCollectionSlugMap } from './utilities/getCollectionSlugMap.js'\nimport { pushTypeScriptProperties } from './utilities/pushTypeScriptProperties.js'\nimport { sanitizePluginConfig } from './utilities/sanitizePluginConfig.js'\n\nexport const ecommercePlugin =\n (pluginConfig?: EcommercePluginConfig) =>\n async (incomingConfig: Config): Promise<Config> => {\n if (!pluginConfig) {\n return incomingConfig\n }\n\n const sanitizedPluginConfig = sanitizePluginConfig({ pluginConfig })\n /**\n * Used to keep track of the slugs of collections in case they are overridden by the user.\n */\n const collectionSlugMap = getCollectionSlugMap({ sanitizedPluginConfig })\n\n const accessConfig = sanitizedPluginConfig.access\n\n // Ensure collections exists\n if (!incomingConfig.collections) {\n incomingConfig.collections = []\n }\n\n // Controls whether variants are enabled in the plugin. This is toggled to true under products config\n let enableVariants = false\n\n const currenciesConfig: Required<SanitizedEcommercePluginConfig['currencies']> =\n sanitizedPluginConfig.currencies\n\n let addressFields\n\n if (sanitizedPluginConfig.addresses) {\n addressFields = sanitizedPluginConfig.addresses.addressFields\n\n const supportedCountries = sanitizedPluginConfig.addresses.supportedCountries\n\n const defaultAddressesCollection = createAddressesCollection({\n access: {\n adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,\n authenticatedOnly: accessConfig.authenticatedOnly,\n customerOnlyFieldAccess: accessConfig.customerOnlyFieldAccess,\n },\n addressFields,\n customersSlug: collectionSlugMap.customers,\n supportedCountries,\n })\n\n const addressesCollection =\n sanitizedPluginConfig.addresses &&\n typeof sanitizedPluginConfig.addresses === 'object' &&\n 'addressesCollectionOverride' in sanitizedPluginConfig.addresses &&\n sanitizedPluginConfig.addresses.addressesCollectionOverride\n ? await sanitizedPluginConfig.addresses.addressesCollectionOverride({\n defaultCollection: defaultAddressesCollection,\n })\n : defaultAddressesCollection\n\n incomingConfig.collections.push(addressesCollection)\n }\n\n if (sanitizedPluginConfig.products) {\n const productsConfig =\n typeof sanitizedPluginConfig.products === 'boolean'\n ? {\n variants: true,\n }\n : sanitizedPluginConfig.products\n\n enableVariants = Boolean(productsConfig.variants)\n\n if (productsConfig.variants) {\n const variantsConfig =\n typeof productsConfig.variants === 'boolean' ? undefined : productsConfig.variants\n\n const defaultVariantsCollection = createVariantsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n adminOrPublishedStatus: accessConfig.adminOrPublishedStatus,\n },\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n productsSlug: collectionSlugMap.products,\n variantOptionsSlug: collectionSlugMap.variantOptions,\n })\n\n const variants =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantsCollectionOverride' in variantsConfig &&\n variantsConfig.variantsCollectionOverride\n ? await variantsConfig.variantsCollectionOverride({\n defaultCollection: defaultVariantsCollection,\n })\n : defaultVariantsCollection\n\n const defaultVariantTypesCollection = createVariantTypesCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n publicAccess: accessConfig.publicAccess,\n },\n variantOptionsSlug: collectionSlugMap.variantOptions,\n })\n\n const variantTypes =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantTypesCollectionOverride' in variantsConfig &&\n variantsConfig.variantTypesCollectionOverride\n ? await variantsConfig.variantTypesCollectionOverride({\n defaultCollection: defaultVariantTypesCollection,\n })\n : defaultVariantTypesCollection\n\n const defaultVariantOptionsCollection = createVariantOptionsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n publicAccess: accessConfig.publicAccess,\n },\n variantTypesSlug: collectionSlugMap.variantTypes,\n })\n\n const variantOptions =\n variantsConfig &&\n typeof variantsConfig === 'object' &&\n 'variantOptionsCollectionOverride' in variantsConfig &&\n variantsConfig.variantOptionsCollectionOverride\n ? await variantsConfig.variantOptionsCollectionOverride({\n defaultCollection: defaultVariantOptionsCollection,\n })\n : defaultVariantOptionsCollection\n\n incomingConfig.collections.push(variants, variantTypes, variantOptions)\n }\n\n const defaultProductsCollection = createProductsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n adminOrPublishedStatus: accessConfig.adminOrPublishedStatus,\n },\n currenciesConfig,\n enableVariants,\n inventory: sanitizedPluginConfig.inventory,\n variantsSlug: collectionSlugMap.variants,\n variantTypesSlug: collectionSlugMap.variantTypes,\n })\n\n const productsCollection =\n productsConfig &&\n 'productsCollectionOverride' in productsConfig &&\n productsConfig.productsCollectionOverride\n ? await productsConfig.productsCollectionOverride({\n defaultCollection: defaultProductsCollection,\n })\n : defaultProductsCollection\n\n incomingConfig.collections.push(productsCollection)\n\n if (sanitizedPluginConfig.carts) {\n const defaultCartsCollection = createCartsCollection({\n access: {\n adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,\n publicAccess: accessConfig.publicAccess,\n },\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants: Boolean(productsConfig.variants),\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const cartsCollection =\n sanitizedPluginConfig.carts &&\n typeof sanitizedPluginConfig.carts === 'object' &&\n 'cartsCollectionOverride' in sanitizedPluginConfig.carts &&\n sanitizedPluginConfig.carts.cartsCollectionOverride\n ? await sanitizedPluginConfig.carts.cartsCollectionOverride({\n defaultCollection: defaultCartsCollection,\n })\n : defaultCartsCollection\n\n incomingConfig.collections.push(cartsCollection)\n }\n }\n\n if (sanitizedPluginConfig.orders) {\n const defaultOrdersCollection = createOrdersCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n adminOnlyFieldAccess: accessConfig.adminOnlyFieldAccess,\n adminOrCustomerOwner: accessConfig.adminOrCustomerOwner,\n },\n addressFields,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const ordersCollection =\n sanitizedPluginConfig.orders &&\n typeof sanitizedPluginConfig.orders === 'object' &&\n 'ordersCollectionOverride' in sanitizedPluginConfig.orders &&\n sanitizedPluginConfig.orders.ordersCollectionOverride\n ? await sanitizedPluginConfig.orders.ordersCollectionOverride({\n defaultCollection: defaultOrdersCollection,\n })\n : defaultOrdersCollection\n\n incomingConfig.collections.push(ordersCollection)\n }\n\n const paymentMethods = sanitizedPluginConfig.payments.paymentMethods\n\n if (sanitizedPluginConfig.payments) {\n if (paymentMethods.length) {\n if (!Array.isArray(incomingConfig.endpoints)) {\n incomingConfig.endpoints = []\n }\n\n const productsValidation =\n (typeof sanitizedPluginConfig.products === 'object' &&\n sanitizedPluginConfig.products.validation) ||\n undefined\n\n paymentMethods.forEach((paymentMethod) => {\n const methodPath = `/payments/${paymentMethod.name}`\n const endpoints: Endpoint[] = []\n\n const initiatePayment: Endpoint = {\n handler: initiatePaymentHandler({\n currenciesConfig,\n inventory: sanitizedPluginConfig.inventory,\n paymentMethod,\n productsSlug: collectionSlugMap.products,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n variantsSlug: collectionSlugMap.variants,\n }),\n method: 'post',\n path: `${methodPath}/initiate`,\n }\n\n const confirmOrder: Endpoint = {\n handler: confirmOrderHandler({\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n ordersSlug: collectionSlugMap.orders,\n paymentMethod,\n productsValidation,\n transactionsSlug: collectionSlugMap.transactions,\n }),\n method: 'post',\n path: `${methodPath}/confirm-order`,\n }\n\n endpoints.push(initiatePayment, confirmOrder)\n\n // Attach any additional endpoints defined in the payment method\n if (paymentMethod.endpoints && paymentMethod.endpoints.length > 0) {\n const methodEndpoints = paymentMethod.endpoints.map((endpoint) => {\n const path = endpoint.path.startsWith('/') ? endpoint.path : `/${endpoint.path}`\n\n return {\n ...endpoint,\n path: `${methodPath}${path}`,\n }\n })\n\n endpoints.push(...methodEndpoints)\n }\n\n incomingConfig.endpoints!.push(...endpoints)\n })\n }\n }\n\n if (sanitizedPluginConfig.transactions) {\n const defaultTransactionsCollection = createTransactionsCollection({\n access: {\n adminOnly: accessConfig.adminOnly,\n },\n addressFields,\n cartsSlug: collectionSlugMap.carts,\n currenciesConfig,\n customersSlug: collectionSlugMap.customers,\n enableVariants,\n ordersSlug: collectionSlugMap.orders,\n paymentMethods,\n productsSlug: collectionSlugMap.products,\n variantsSlug: collectionSlugMap.variants,\n })\n\n const transactionsCollection =\n sanitizedPluginConfig.transactions &&\n typeof sanitizedPluginConfig.transactions === 'object' &&\n 'transactionsCollectionOverride' in sanitizedPluginConfig.transactions &&\n sanitizedPluginConfig.transactions.transactionsCollectionOverride\n ? await sanitizedPluginConfig.transactions.transactionsCollectionOverride({\n defaultCollection: defaultTransactionsCollection,\n })\n : defaultTransactionsCollection\n\n incomingConfig.collections.push(transactionsCollection)\n }\n\n if (!incomingConfig.i18n) {\n incomingConfig.i18n = {}\n }\n\n if (!incomingConfig.i18n?.translations) {\n incomingConfig.i18n.translations = {}\n }\n\n incomingConfig.i18n.translations = deepMergeSimple(\n translations,\n incomingConfig.i18n?.translations,\n )\n\n if (!incomingConfig.typescript) {\n incomingConfig.typescript = {}\n }\n\n if (!incomingConfig.typescript.schema) {\n incomingConfig.typescript.schema = []\n }\n\n incomingConfig.typescript.schema.push((args) =>\n pushTypeScriptProperties({ ...args, sanitizedPluginConfig }),\n )\n\n return incomingConfig\n }\n\nexport {\n createAddressesCollection,\n createCartsCollection,\n createOrdersCollection,\n createProductsCollection,\n createTransactionsCollection,\n createVariantOptionsCollection,\n createVariantsCollection,\n createVariantTypesCollection,\n}\n\nexport { EUR, GBP, USD } from './currencies/index.js'\nexport { amountField } from './fields/amountField.js'\nexport { currencyField } from './fields/currencyField.js'\nexport { pricesField } from './fields/pricesField.js'\nexport { statusField } from './fields/statusField.js'\nexport { variantsFields } from './fields/variantsFields.js'\n"],"names":["deepMergeSimple","createAddressesCollection","createCartsCollection","createOrdersCollection","createProductsCollection","createTransactionsCollection","createVariantOptionsCollection","createVariantsCollection","createVariantTypesCollection","confirmOrderHandler","initiatePaymentHandler","translations","getCollectionSlugMap","pushTypeScriptProperties","sanitizePluginConfig","ecommercePlugin","pluginConfig","incomingConfig","sanitizedPluginConfig","collectionSlugMap","accessConfig","access","collections","enableVariants","currenciesConfig","currencies","addressFields","addresses","supportedCountries","defaultAddressesCollection","adminOrCustomerOwner","authenticatedOnly","customerOnlyFieldAccess","customersSlug","customers","addressesCollection","addressesCollectionOverride","defaultCollection","push","products","productsConfig","variants","Boolean","variantsConfig","undefined","defaultVariantsCollection","adminOnly","adminOrPublishedStatus","inventory","productsSlug","variantOptionsSlug","variantOptions","variantsCollectionOverride","defaultVariantTypesCollection","publicAccess","variantTypes","variantTypesCollectionOverride","defaultVariantOptionsCollection","variantTypesSlug","variantOptionsCollectionOverride","defaultProductsCollection","variantsSlug","productsCollection","productsCollectionOverride","carts","defaultCartsCollection","cartsCollection","cartsCollectionOverride","orders","defaultOrdersCollection","adminOnlyFieldAccess","ordersCollection","ordersCollectionOverride","paymentMethods","payments","length","Array","isArray","endpoints","productsValidation","validation","forEach","paymentMethod","methodPath","name","initiatePayment","handler","transactionsSlug","transactions","method","path","confirmOrder","cartsSlug","ordersSlug","methodEndpoints","map","endpoint","startsWith","defaultTransactionsCollection","transactionsCollection","transactionsCollectionOverride","i18n","typescript","schema","args","EUR","GBP","USD","amountField","currencyField","pricesField","statusField","variantsFields"],"mappings":"AAEA,SAASA,eAAe,QAAQ,iBAAgB;AAIhD,SAASC,yBAAyB,QAAQ,uDAAsD;AAChG,SAASC,qBAAqB,QAAQ,+CAA8C;AACpF,SAASC,sBAAsB,QAAQ,iDAAgD;AACvF,SAASC,wBAAwB,QAAQ,qDAAoD;AAC7F,SAASC,4BAA4B,QAAQ,6DAA4D;AACzG,SAASC,8BAA8B,QAAQ,2DAA0D;AACzG,SAASC,wBAAwB,QAAQ,2DAA0D;AACnG,SAASC,4BAA4B,QAAQ,yDAAwD;AACrG,SAASC,mBAAmB,QAAQ,8BAA6B;AACjE,SAASC,sBAAsB,QAAQ,iCAAgC;AACvE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,oBAAoB,QAAQ,sCAA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,CAACY,8BAA8B,CAAC;gBACtE/D,mBAAmB6D;YACrB,KACAA;YAENjF,eAAeK,WAAW,CAACgB,IAAI,CAAC6D;QAClC;QAEA,IAAI,CAAClF,eAAeoF,IAAI,EAAE;YACxBpF,eAAeoF,IAAI,GAAG,CAAC;QACzB;QAEA,IAAI,CAACpF,eAAeoF,IAAI,EAAE1F,cAAc;YACtCM,eAAeoF,IAAI,CAAC1F,YAAY,GAAG,CAAC;QACtC;QAEAM,eAAeoF,IAAI,CAAC1F,YAAY,GAAGX,gBACjCW,cACAM,eAAeoF,IAAI,EAAE1F;QAGvB,IAAI,CAACM,eAAeqF,UAAU,EAAE;YAC9BrF,eAAeqF,UAAU,GAAG,CAAC;QAC/B;QAEA,IAAI,CAACrF,eAAeqF,UAAU,CAACC,MAAM,EAAE;YACrCtF,eAAeqF,UAAU,CAACC,MAAM,GAAG,EAAE;QACvC;QAEAtF,eAAeqF,UAAU,CAACC,MAAM,CAACjE,IAAI,CAAC,CAACkE,OACrC3F,yBAAyB;gBAAE,GAAG2F,IAAI;gBAAEtF;YAAsB;QAG5D,OAAOD;IACT,EAAC;AAEH,SACEhB,yBAAyB,EACzBC,qBAAqB,EACrBC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,wBAAwB,EACxBC,4BAA4B,KAC7B;AAED,SAASiG,GAAG,EAAEC,GAAG,EAAEC,GAAG,QAAQ,wBAAuB;AACrD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,cAAc,QAAQ,6BAA4B"}
@@ -1,7 +1,7 @@
1
- import { type DefaultDocumentIDType, type TypedCollection } from 'payload';
1
+ import type { DefaultDocumentIDType } from 'payload';
2
2
  import React from 'react';
3
3
  import type { Currency } from '../../types.js';
4
- import type { ContextProps, EcommerceContext as EcommerceContextType } from './types.js';
4
+ import type { ContextProps, EcommerceContext as EcommerceContextType, TypedEcommerce } from './types.js';
5
5
  export declare const EcommerceProvider: React.FC<ContextProps>;
6
6
  export declare const useEcommerce: () => EcommerceContextType;
7
7
  export declare const useCurrency: () => {
@@ -35,7 +35,7 @@ export declare const usePayments: () => {
35
35
  };
36
36
  export declare const useAddresses: () => {
37
37
  addresses: (import("payload").JsonObject & import("payload").TypeWithID)[] | undefined;
38
- createAddress: (data: Partial<TypedCollection["addresses"]>) => Promise<void>;
39
- updateAddress: (addressID: DefaultDocumentIDType, data: Partial<TypedCollection["addresses"]>) => Promise<void>;
38
+ createAddress: (data: Partial<TypedEcommerce["addressesCollection"]>) => Promise<void>;
39
+ updateAddress: (addressID: DefaultDocumentIDType, data: Partial<TypedEcommerce["addressesCollection"]>) => Promise<void>;
40
40
  };
41
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/provider/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAkB,MAAM,SAAS,CAAA;AAG1F,OAAO,KAAgF,MAAM,OAAO,CAAA;AAEpG,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAuCxF,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAwvBpD,CAAA;AAED,eAAO,MAAM,YAAY,4BAQxB,CAAA;AAED,eAAO,MAAM,WAAW;;6BAIX,IAAI,GAAG,MAAM,YAAY;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE,KAAG,MAAM;;;CAkCrE,CAAA;AAED,eAAO,MAAM,OAAO;;;;;;;;;;CAQnB,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;CAQvB,CAAA;AAED,eAAO,MAAM,YAAY;;;;CAQxB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/provider/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAa,MAAM,SAAS,CAAA;AAI/D,OAAO,KAAgF,MAAM,OAAO,CAAA;AAEpG,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,IAAI,oBAAoB,EACxC,cAAc,EACf,MAAM,YAAY,CAAA;AAuCnB,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAwvBpD,CAAA;AAED,eAAO,MAAM,YAAY,4BAQxB,CAAA;AAED,eAAO,MAAM,WAAW;;6BAIX,IAAI,GAAG,MAAM,YAAY;QAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KAAE,KAAG,MAAM;;;CAkCrE,CAAA;AAED,eAAO,MAAM,OAAO;;;;;;;;;;CAQnB,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;CAQvB,CAAA;AAED,eAAO,MAAM,YAAY;;;;CAQxB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/react/provider/index.tsx"],"sourcesContent":["'use client'\nimport { type DefaultDocumentIDType, type TypedCollection, type TypedUser } from 'payload'\nimport { deepMergeSimple } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { CartItem, Currency } from '../../types.js'\nimport type { ContextProps, EcommerceContext as EcommerceContextType } from './types.js'\n\nconst defaultContext: EcommerceContextType = {\n addItem: async () => {},\n clearCart: async () => {},\n confirmOrder: async () => {},\n createAddress: async () => {},\n currenciesConfig: {\n defaultCurrency: 'USD',\n supportedCurrencies: [\n {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n ],\n },\n currency: {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n decrementItem: async () => {},\n incrementItem: async () => {},\n initiatePayment: async () => {},\n paymentMethods: [],\n removeItem: async () => {},\n setCurrency: () => {},\n updateAddress: async () => {},\n}\n\nconst EcommerceContext = createContext<EcommerceContextType>(defaultContext)\n\nconst defaultLocalStorage = {\n key: 'cart',\n}\n\nexport const EcommerceProvider: React.FC<ContextProps> = ({\n addressesSlug = 'addresses',\n api,\n cartsSlug = 'carts',\n children,\n currenciesConfig = {\n defaultCurrency: 'USD',\n supportedCurrencies: [\n {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n ],\n },\n customersSlug = 'users',\n debug = false,\n paymentMethods = [],\n syncLocalStorage = true,\n}) => {\n const localStorageConfig =\n syncLocalStorage && typeof syncLocalStorage === 'object'\n ? {\n ...defaultLocalStorage,\n ...syncLocalStorage,\n }\n : defaultLocalStorage\n\n const { apiRoute = '/api', cartsFetchQuery = {}, serverURL = '' } = api || {}\n const baseAPIURL = `${serverURL}${apiRoute}`\n\n const [user, setUser] = useState<null | TypedUser>(null)\n\n const [addresses, setAddresses] = useState<TypedCollection['addresses'][]>()\n\n const hasRendered = useRef(false)\n\n /**\n * The ID of the cart associated with the current session.\n * This is used to identify the cart in the database or local storage.\n * It can be null if no cart has been created yet.\n */\n const [cartID, setCartID] = useState<DefaultDocumentIDType>()\n const [cart, setCart] = useState<TypedCollection['carts']>()\n\n const [selectedCurrency, setSelectedCurrency] = useState<Currency>(\n () =>\n currenciesConfig.supportedCurrencies.find(\n (c) => c.code === currenciesConfig.defaultCurrency,\n )!,\n )\n\n const [selectedPaymentMethod, setSelectedPaymentMethod] = useState<null | string>(null)\n\n const cartQuery = useMemo(() => {\n const priceField = `priceIn${selectedCurrency.code}`\n\n const baseQuery = {\n depth: 0,\n populate: {\n products: {\n [priceField]: true,\n },\n variants: {\n options: true,\n [priceField]: true,\n },\n },\n select: {\n items: true,\n subtotal: true,\n },\n }\n\n return deepMergeSimple(baseQuery, cartsFetchQuery)\n }, [selectedCurrency.code, cartsFetchQuery])\n\n const createCart = useCallback(\n async (initialData: Record<string, unknown>) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}?${query}`, {\n body: JSON.stringify({\n ...initialData,\n currency: selectedCurrency.code,\n customer: user?.id,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to create cart: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Cart creation error: ${data.error}`)\n }\n\n return data.doc as TypedCollection['carts']\n },\n [baseAPIURL, cartQuery, cartsSlug, selectedCurrency.code, user?.id],\n )\n\n const getCart = useCallback(\n async (cartID: DefaultDocumentIDType) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch cart: ${errorText}`)\n }\n const data = await response.json()\n if (data.error) {\n throw new Error(`Cart fetch error: ${data.error}`)\n }\n\n return data as TypedCollection['carts']\n },\n [baseAPIURL, cartQuery, cartsSlug],\n )\n\n const updateCart = useCallback(\n async (cartID: DefaultDocumentIDType, data: Partial<TypedCollection['carts']>) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}?${query}`, {\n body: JSON.stringify(data),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PATCH',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update cart: ${errorText}`)\n }\n\n const updatedCart = await response.json()\n setCart(updatedCart.doc as TypedCollection['carts'])\n },\n [baseAPIURL, cartQuery, cartsSlug],\n )\n\n const deleteCart = useCallback(\n async (cartID: DefaultDocumentIDType) => {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'DELETE',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update cart: ${errorText}`)\n }\n\n setCart(undefined)\n setCartID(undefined)\n },\n [baseAPIURL, cartsSlug],\n )\n\n useEffect(() => {\n if (hasRendered.current) {\n if (syncLocalStorage && cartID) {\n localStorage.setItem(localStorageConfig.key, cartID as string)\n }\n }\n }, [cartID, localStorageConfig.key, syncLocalStorage])\n\n const addItem: EcommerceContextType['addItem'] = useCallback(\n async (item, quantity = 1) => {\n if (cartID) {\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex = existingCart.items.findIndex((cartItem: CartItem) => {\n const productID =\n typeof cartItem.product === 'object' ? cartItem.product.id : item.product\n const variantID =\n cartItem.variant && typeof cartItem.variant === 'object'\n ? cartItem.variant.id\n : item.variant\n\n return (\n productID === item.product &&\n (item.variant && variantID ? variantID === item.variant : true)\n )\n })\n\n let updatedItems = [...existingCart.items]\n if (existingItemIndex !== -1) {\n // If the item exists, update its quantity\n updatedItems[existingItemIndex].quantity =\n updatedItems[existingItemIndex].quantity + quantity\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If the item does not exist, add it to the cart\n updatedItems = [...existingCart.items, { ...item, quantity }]\n }\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If no cartID exists, create a new cart\n const newCart = await createCart({ items: [{ ...item, quantity }] })\n\n setCartID(newCart.id)\n setCart(newCart)\n }\n },\n [cartID, createCart, getCart, updateCart],\n )\n\n const removeItem: EcommerceContextType['removeItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex = existingCart.items.findIndex(\n (cartItem: CartItem) => cartItem.id === targetID,\n )\n\n if (existingItemIndex !== -1) {\n // If the item exists, remove it from the cart\n const updatedItems = [...existingCart.items]\n updatedItems.splice(existingItemIndex, 1)\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const incrementItem: EcommerceContextType['incrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex = existingCart.items.findIndex(\n (cartItem: CartItem) => cartItem.id === targetID,\n )\n\n let updatedItems = [...existingCart.items]\n\n if (existingItemIndex !== -1) {\n // If the item exists, increment its quantity\n updatedItems[existingItemIndex].quantity = updatedItems[existingItemIndex].quantity + 1 // Increment by 1\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If the item does not exist, add it to the cart with quantity 1\n updatedItems = [...existingCart.items, { product: targetID, quantity: 1 }]\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const decrementItem: EcommerceContextType['decrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex = existingCart.items.findIndex(\n (cartItem: CartItem) => cartItem.id === targetID,\n )\n\n const updatedItems = [...existingCart.items]\n\n if (existingItemIndex !== -1) {\n // If the item exists, decrement its quantity\n updatedItems[existingItemIndex].quantity = updatedItems[existingItemIndex].quantity - 1 // Decrement by 1\n\n // If the quantity reaches 0, remove the item from the cart\n if (updatedItems[existingItemIndex].quantity <= 0) {\n updatedItems.splice(existingItemIndex, 1)\n }\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const clearCart: EcommerceContextType['clearCart'] = useCallback(async () => {\n if (cartID) {\n await deleteCart(cartID)\n }\n }, [cartID, deleteCart])\n\n const setCurrency: EcommerceContextType['setCurrency'] = useCallback(\n (currency) => {\n if (selectedCurrency.code === currency) {\n return\n }\n\n const foundCurrency = currenciesConfig.supportedCurrencies.find((c) => c.code === currency)\n if (!foundCurrency) {\n throw new Error(`Currency with code \"${currency}\" not found in config`)\n }\n\n setSelectedCurrency(foundCurrency)\n },\n [currenciesConfig.supportedCurrencies, selectedCurrency.code],\n )\n\n const initiatePayment = useCallback<EcommerceContextType['initiatePayment']>(\n async (paymentMethodID, options) => {\n const paymentMethod = paymentMethods.find((method) => method.name === paymentMethodID)\n\n if (!paymentMethod) {\n throw new Error(`Payment method with ID \"${paymentMethodID}\" not found`)\n }\n\n if (!cartID) {\n throw new Error(`No cart is provided.`)\n }\n\n setSelectedPaymentMethod(paymentMethodID)\n\n if (paymentMethod.initiatePayment) {\n const fetchURL = `${baseAPIURL}/payments/${paymentMethodID}/initiate`\n\n const data = {\n cartID,\n currency: selectedCurrency.code,\n }\n\n try {\n const response = await fetch(fetchURL, {\n body: JSON.stringify({\n ...data,\n ...(options?.additionalData || {}),\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const responseError = await response.text()\n throw new Error(responseError)\n }\n\n const responseData = await response.json()\n\n if (responseData.error) {\n throw new Error(responseData.error)\n }\n\n return responseData\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error initiating payment:', error)\n }\n throw new Error(error instanceof Error ? error.message : 'Failed to initiate payment')\n }\n } else {\n throw new Error(`Payment method \"${paymentMethodID}\" does not support payment initiation`)\n }\n },\n [baseAPIURL, cartID, debug, paymentMethods, selectedCurrency.code],\n )\n\n const confirmOrder = useCallback<EcommerceContextType['initiatePayment']>(\n async (paymentMethodID, options) => {\n if (!cartID) {\n throw new Error(`Cart is empty.`)\n }\n\n const paymentMethod = paymentMethods.find((pm) => pm.name === paymentMethodID)\n\n if (!paymentMethod) {\n throw new Error(`Payment method with ID \"${paymentMethodID}\" not found`)\n }\n\n if (paymentMethod.confirmOrder) {\n const fetchURL = `${baseAPIURL}/payments/${paymentMethodID}/confirm-order`\n\n const data = {\n cartID,\n currency: selectedCurrency.code,\n }\n\n const response = await fetch(fetchURL, {\n body: JSON.stringify({\n ...data,\n ...(options?.additionalData || {}),\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const responseError = await response.text()\n throw new Error(responseError)\n }\n\n const responseData = await response.json()\n\n if (responseData.error) {\n throw new Error(responseData.error)\n }\n\n return responseData\n } else {\n throw new Error(`Payment method \"${paymentMethodID}\" does not support order confirmation`)\n }\n },\n [baseAPIURL, cartID, paymentMethods, selectedCurrency.code],\n )\n\n const getUser = useCallback(async () => {\n try {\n const query = qs.stringify({\n depth: 0,\n select: {\n id: true,\n carts: true,\n },\n })\n\n const response = await fetch(`${baseAPIURL}/${customersSlug}/me?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch user: ${errorText}`)\n }\n\n const userData = await response.json()\n\n if (userData.error) {\n throw new Error(`User fetch error: ${userData.error}`)\n }\n\n if (userData.user) {\n setUser(userData.user as TypedUser)\n return userData.user as TypedUser\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching user:', error)\n }\n setUser(null)\n throw new Error(\n `Failed to fetch user: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }, [baseAPIURL, customersSlug, debug])\n\n const getAddresses = useCallback(async () => {\n if (!user) {\n return\n }\n\n try {\n const query = qs.stringify({\n depth: 0,\n limit: 0,\n pagination: false,\n })\n\n const response = await fetch(`${baseAPIURL}/${addressesSlug}?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n throw new Error(errorText)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address fetch error: ${data.error}`)\n }\n\n if (data.docs && data.docs.length > 0) {\n setAddresses(data.docs)\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching addresses:', error)\n }\n setAddresses(undefined)\n throw new Error(\n `Failed to fetch addresses: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }, [user, baseAPIURL, addressesSlug, debug])\n\n const updateAddress = useCallback<EcommerceContextType['updateAddress']>(\n async (addressID, address) => {\n if (!user) {\n throw new Error('User must be logged in to update or create an address')\n }\n\n try {\n const response = await fetch(`${baseAPIURL}/${addressesSlug}/${addressID}`, {\n body: JSON.stringify(address),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PATCH',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update or create address: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address update/create error: ${data.error}`)\n }\n\n // Refresh addresses after updating or creating\n await getAddresses()\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error updating or creating address:', error)\n }\n\n throw new Error(\n `Failed to update or create address: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n },\n [user, baseAPIURL, addressesSlug, getAddresses, debug],\n )\n\n const createAddress = useCallback<EcommerceContextType['createAddress']>(\n async (address) => {\n if (!user) {\n throw new Error('User must be logged in to update or create an address')\n }\n\n try {\n const response = await fetch(`${baseAPIURL}/${addressesSlug}`, {\n body: JSON.stringify(address),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update or create address: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address update/create error: ${data.error}`)\n }\n\n // Refresh addresses after updating or creating\n await getAddresses()\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error updating or creating address:', error)\n }\n\n throw new Error(\n `Failed to update or create address: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n },\n [user, baseAPIURL, addressesSlug, getAddresses, debug],\n )\n\n // If localStorage is enabled, we can add logic to persist the cart state\n useEffect(() => {\n if (!hasRendered.current) {\n if (syncLocalStorage) {\n const storedCart = localStorage.getItem(localStorageConfig.key)\n if (storedCart) {\n getCart(storedCart)\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(storedCart as DefaultDocumentIDType)\n })\n .catch((_) => {\n // console.error('Error fetching cart from localStorage:', error)\n // If there's an error fetching the cart, we can clear it from localStorage\n localStorage.removeItem(localStorageConfig.key)\n setCartID(undefined)\n setCart(undefined)\n })\n }\n }\n\n hasRendered.current = true\n\n void getUser().then((user) => {\n if (user && user.cart?.docs && user.cart.docs.length > 0) {\n // If the user has carts, we can set the cartID to the first cart\n const cartID =\n typeof user.cart.docs[0] === 'object' ? user.cart.docs[0].id : user.cart.docs[0]\n\n if (cartID) {\n getCart(cartID)\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(cartID)\n })\n .catch((error) => {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching user cart:', error)\n }\n\n setCart(undefined)\n setCartID(undefined)\n\n throw new Error(`Failed to fetch user cart: ${error.message}`)\n })\n }\n }\n })\n }\n }, [debug, getAddresses, getCart, getUser, localStorageConfig.key, syncLocalStorage])\n\n useEffect(() => {\n if (user) {\n // If the user is logged in, fetch their addresses\n void getAddresses()\n } else {\n // If no user is logged in, clear addresses\n setAddresses(undefined)\n }\n }, [getAddresses, user])\n\n return (\n <EcommerceContext\n value={{\n addItem,\n addresses,\n cart,\n clearCart,\n confirmOrder,\n createAddress,\n currenciesConfig,\n currency: selectedCurrency,\n decrementItem,\n incrementItem,\n initiatePayment,\n paymentMethods,\n removeItem,\n selectedPaymentMethod,\n setCurrency,\n updateAddress,\n }}\n >\n {children}\n </EcommerceContext>\n )\n}\n\nexport const useEcommerce = () => {\n const context = use(EcommerceContext)\n\n if (!context) {\n throw new Error('useEcommerce must be used within an EcommerceProvider')\n }\n\n return context\n}\n\nexport const useCurrency = () => {\n const { currenciesConfig, currency, setCurrency } = useEcommerce()\n\n const formatCurrency = useCallback(\n (value?: null | number, options?: { currency?: Currency }): string => {\n if (value === undefined || value === null) {\n return ''\n }\n\n const currencyToUse = options?.currency || currency\n\n if (!currencyToUse) {\n return value.toString()\n }\n\n if (value === 0) {\n return `${currencyToUse.symbol}0.${'0'.repeat(currencyToUse.decimals)}`\n }\n\n // Convert from base value (e.g., cents) to decimal value (e.g., dollars)\n const decimalValue = value / Math.pow(10, currencyToUse.decimals)\n\n // Format with the correct number of decimal places\n return `${currencyToUse.symbol}${decimalValue.toFixed(currencyToUse.decimals)}`\n },\n [currency],\n )\n\n if (!currency) {\n throw new Error('useCurrency must be used within an EcommerceProvider')\n }\n\n return {\n currency,\n formatCurrency,\n setCurrency,\n supportedCurrencies: currenciesConfig.supportedCurrencies,\n }\n}\n\nexport const useCart = () => {\n const { addItem, cart, clearCart, decrementItem, incrementItem, removeItem } = useEcommerce()\n\n if (!addItem) {\n throw new Error('useCart must be used within an EcommerceProvider')\n }\n\n return { addItem, cart, clearCart, decrementItem, incrementItem, removeItem }\n}\n\nexport const usePayments = () => {\n const { confirmOrder, initiatePayment, paymentMethods, selectedPaymentMethod } = useEcommerce()\n\n if (!initiatePayment) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { confirmOrder, initiatePayment, paymentMethods, selectedPaymentMethod }\n}\n\nexport const useAddresses = () => {\n const { addresses, createAddress, updateAddress } = useEcommerce()\n\n if (!createAddress) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { addresses, createAddress, updateAddress }\n}\n"],"names":["deepMergeSimple","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","defaultContext","addItem","clearCart","confirmOrder","createAddress","currenciesConfig","defaultCurrency","supportedCurrencies","code","decimals","label","symbol","currency","decrementItem","incrementItem","initiatePayment","paymentMethods","removeItem","setCurrency","updateAddress","EcommerceContext","defaultLocalStorage","key","EcommerceProvider","addressesSlug","api","cartsSlug","children","customersSlug","debug","syncLocalStorage","localStorageConfig","apiRoute","cartsFetchQuery","serverURL","baseAPIURL","user","setUser","addresses","setAddresses","hasRendered","cartID","setCartID","cart","setCart","selectedCurrency","setSelectedCurrency","find","c","selectedPaymentMethod","setSelectedPaymentMethod","cartQuery","priceField","baseQuery","depth","populate","products","variants","options","select","items","subtotal","createCart","initialData","query","stringify","response","fetch","body","JSON","customer","id","credentials","headers","method","ok","errorText","text","Error","data","json","error","doc","getCart","updateCart","updatedCart","deleteCart","undefined","current","localStorage","setItem","item","quantity","existingCart","existingItemIndex","findIndex","cartItem","productID","product","variantID","variant","updatedItems","newCart","targetID","splice","foundCurrency","paymentMethodID","paymentMethod","name","fetchURL","additionalData","responseError","responseData","console","message","pm","getUser","carts","userData","getAddresses","limit","pagination","docs","length","addressID","address","storedCart","getItem","then","fetchedCart","catch","_","value","useEcommerce","context","useCurrency","formatCurrency","currencyToUse","toString","repeat","decimalValue","Math","pow","toFixed","useCart","usePayments","useAddresses"],"mappings":"AAAA;;AAEA,SAASA,eAAe,QAAQ,iBAAgB;AAChD,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,M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+D,MAAM;IAClB;IAEA,OAAO;QAAE3E;QAAcY;QAAiBC;QAAgBiC;IAAsB;AAChF,EAAC;AAED,OAAO,MAAMiG,eAAe;IAC1B,MAAM,EAAE5G,SAAS,EAAElC,aAAa,EAAEe,aAAa,EAAE,GAAGkH;IAEpD,IAAI,CAACjI,eAAe;QAClB,MAAM,IAAI0E,MAAM;IAClB;IAEA,OAAO;QAAExC;QAAWlC;QAAee;IAAc;AACnD,EAAC"}
1
+ {"version":3,"sources":["../../../src/react/provider/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultDocumentIDType, TypedUser } from 'payload'\n\nimport { deepMergeSimple } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { CartItem, Currency } from '../../types.js'\nimport type {\n ContextProps,\n EcommerceContext as EcommerceContextType,\n TypedEcommerce,\n} from './types.js'\n\nconst defaultContext: EcommerceContextType = {\n addItem: async () => {},\n clearCart: async () => {},\n confirmOrder: async () => {},\n createAddress: async () => {},\n currenciesConfig: {\n defaultCurrency: 'USD',\n supportedCurrencies: [\n {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n ],\n },\n currency: {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n decrementItem: async () => {},\n incrementItem: async () => {},\n initiatePayment: async () => {},\n paymentMethods: [],\n removeItem: async () => {},\n setCurrency: () => {},\n updateAddress: async () => {},\n}\n\nconst EcommerceContext = createContext<EcommerceContextType>(defaultContext)\n\nconst defaultLocalStorage = {\n key: 'cart',\n}\n\nexport const EcommerceProvider: React.FC<ContextProps> = ({\n addressesSlug = 'addresses',\n api,\n cartsSlug = 'carts',\n children,\n currenciesConfig = {\n defaultCurrency: 'USD',\n supportedCurrencies: [\n {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n },\n ],\n },\n customersSlug = 'users',\n debug = false,\n paymentMethods = [],\n syncLocalStorage = true,\n}) => {\n const localStorageConfig =\n syncLocalStorage && typeof syncLocalStorage === 'object'\n ? {\n ...defaultLocalStorage,\n ...syncLocalStorage,\n }\n : defaultLocalStorage\n\n const { apiRoute = '/api', cartsFetchQuery = {}, serverURL = '' } = api || {}\n const baseAPIURL = `${serverURL}${apiRoute}`\n\n const [user, setUser] = useState<null | TypedUser>(null)\n\n const [addresses, setAddresses] = useState<TypedEcommerce['addressesCollection'][]>()\n\n const hasRendered = useRef(false)\n\n /**\n * The ID of the cart associated with the current session.\n * This is used to identify the cart in the database or local storage.\n * It can be null if no cart has been created yet.\n */\n const [cartID, setCartID] = useState<DefaultDocumentIDType>()\n const [cart, setCart] = useState<TypedEcommerce['cartsCollection']>()\n\n const [selectedCurrency, setSelectedCurrency] = useState<Currency>(\n () =>\n currenciesConfig.supportedCurrencies.find(\n (c) => c.code === currenciesConfig.defaultCurrency,\n )!,\n )\n\n const [selectedPaymentMethod, setSelectedPaymentMethod] = useState<null | string>(null)\n\n const cartQuery = useMemo(() => {\n const priceField = `priceIn${selectedCurrency.code}`\n\n const baseQuery = {\n depth: 0,\n populate: {\n products: {\n [priceField]: true,\n },\n variants: {\n options: true,\n [priceField]: true,\n },\n },\n select: {\n items: true,\n subtotal: true,\n },\n }\n\n return deepMergeSimple(baseQuery, cartsFetchQuery)\n }, [selectedCurrency.code, cartsFetchQuery])\n\n const createCart = useCallback(\n async (initialData: Record<string, unknown>) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}?${query}`, {\n body: JSON.stringify({\n ...initialData,\n currency: selectedCurrency.code,\n customer: user?.id,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to create cart: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Cart creation error: ${data.error}`)\n }\n\n return data.doc as TypedEcommerce['cartsCollection']\n },\n [baseAPIURL, cartQuery, cartsSlug, selectedCurrency.code, user?.id],\n )\n\n const getCart = useCallback(\n async (cartID: DefaultDocumentIDType) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch cart: ${errorText}`)\n }\n const data = await response.json()\n if (data.error) {\n throw new Error(`Cart fetch error: ${data.error}`)\n }\n\n return data as TypedEcommerce['cartsCollection']\n },\n [baseAPIURL, cartQuery, cartsSlug],\n )\n\n const updateCart = useCallback(\n async (cartID: DefaultDocumentIDType, data: Partial<TypedEcommerce['cartsCollection']>) => {\n const query = qs.stringify(cartQuery)\n\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}?${query}`, {\n body: JSON.stringify(data),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PATCH',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update cart: ${errorText}`)\n }\n\n const updatedCart = await response.json()\n setCart(updatedCart.doc as TypedEcommerce['cartsCollection'])\n },\n [baseAPIURL, cartQuery, cartsSlug],\n )\n\n const deleteCart = useCallback(\n async (cartID: DefaultDocumentIDType) => {\n const response = await fetch(`${baseAPIURL}/${cartsSlug}/${cartID}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'DELETE',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update cart: ${errorText}`)\n }\n\n setCart(undefined)\n setCartID(undefined)\n },\n [baseAPIURL, cartsSlug],\n )\n\n useEffect(() => {\n if (hasRendered.current) {\n if (syncLocalStorage && cartID) {\n localStorage.setItem(localStorageConfig.key, cartID as string)\n }\n }\n }, [cartID, localStorageConfig.key, syncLocalStorage])\n\n const addItem: EcommerceContextType['addItem'] = useCallback(\n async (item, quantity = 1) => {\n if (cartID) {\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex = existingCart.items.findIndex((cartItem: CartItem) => {\n const productID =\n typeof cartItem.product === 'object' ? cartItem.product.id : item.product\n const variantID =\n cartItem.variant && typeof cartItem.variant === 'object'\n ? cartItem.variant.id\n : item.variant\n\n return (\n productID === item.product &&\n (item.variant && variantID ? variantID === item.variant : true)\n )\n })\n\n let updatedItems = [...existingCart.items]\n if (existingItemIndex !== -1) {\n // If the item exists, update its quantity\n updatedItems[existingItemIndex].quantity =\n updatedItems[existingItemIndex].quantity + quantity\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If the item does not exist, add it to the cart\n updatedItems = [...existingCart.items, { ...item, quantity }]\n }\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If no cartID exists, create a new cart\n const newCart = await createCart({ items: [{ ...item, quantity }] })\n\n setCartID(newCart.id)\n setCart(newCart)\n }\n },\n [cartID, createCart, getCart, updateCart],\n )\n\n const removeItem: EcommerceContextType['removeItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex = existingCart.items.findIndex(\n (cartItem: CartItem) => cartItem.id === targetID,\n )\n\n if (existingItemIndex !== -1) {\n // If the item exists, remove it from the cart\n const updatedItems = [...existingCart.items]\n updatedItems.splice(existingItemIndex, 1)\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const incrementItem: EcommerceContextType['incrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex = existingCart.items.findIndex(\n (cartItem: CartItem) => cartItem.id === targetID,\n )\n\n let updatedItems = [...existingCart.items]\n\n if (existingItemIndex !== -1) {\n // If the item exists, increment its quantity\n updatedItems[existingItemIndex].quantity = updatedItems[existingItemIndex].quantity + 1 // Increment by 1\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n } else {\n // If the item does not exist, add it to the cart with quantity 1\n updatedItems = [...existingCart.items, { product: targetID, quantity: 1 }]\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const decrementItem: EcommerceContextType['decrementItem'] = useCallback(\n async (targetID) => {\n if (!cartID) {\n return\n }\n\n const existingCart = await getCart(cartID)\n\n if (!existingCart) {\n // console.error(`Cart with ID \"${cartID}\" not found`)\n setCartID(undefined)\n setCart(undefined)\n return\n }\n\n // Check if the item already exists in the cart\n const existingItemIndex = existingCart.items.findIndex(\n (cartItem: CartItem) => cartItem.id === targetID,\n )\n\n const updatedItems = [...existingCart.items]\n\n if (existingItemIndex !== -1) {\n // If the item exists, decrement its quantity\n updatedItems[existingItemIndex].quantity = updatedItems[existingItemIndex].quantity - 1 // Decrement by 1\n\n // If the quantity reaches 0, remove the item from the cart\n if (updatedItems[existingItemIndex].quantity <= 0) {\n updatedItems.splice(existingItemIndex, 1)\n }\n\n // Update the cart with the new items\n await updateCart(cartID, {\n items: updatedItems,\n })\n }\n },\n [cartID, getCart, updateCart],\n )\n\n const clearCart: EcommerceContextType['clearCart'] = useCallback(async () => {\n if (cartID) {\n await deleteCart(cartID)\n }\n }, [cartID, deleteCart])\n\n const setCurrency: EcommerceContextType['setCurrency'] = useCallback(\n (currency) => {\n if (selectedCurrency.code === currency) {\n return\n }\n\n const foundCurrency = currenciesConfig.supportedCurrencies.find((c) => c.code === currency)\n if (!foundCurrency) {\n throw new Error(`Currency with code \"${currency}\" not found in config`)\n }\n\n setSelectedCurrency(foundCurrency)\n },\n [currenciesConfig.supportedCurrencies, selectedCurrency.code],\n )\n\n const initiatePayment = useCallback<EcommerceContextType['initiatePayment']>(\n async (paymentMethodID, options) => {\n const paymentMethod = paymentMethods.find((method) => method.name === paymentMethodID)\n\n if (!paymentMethod) {\n throw new Error(`Payment method with ID \"${paymentMethodID}\" not found`)\n }\n\n if (!cartID) {\n throw new Error(`No cart is provided.`)\n }\n\n setSelectedPaymentMethod(paymentMethodID)\n\n if (paymentMethod.initiatePayment) {\n const fetchURL = `${baseAPIURL}/payments/${paymentMethodID}/initiate`\n\n const data = {\n cartID,\n currency: selectedCurrency.code,\n }\n\n try {\n const response = await fetch(fetchURL, {\n body: JSON.stringify({\n ...data,\n ...(options?.additionalData || {}),\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const responseError = await response.text()\n throw new Error(responseError)\n }\n\n const responseData = await response.json()\n\n if (responseData.error) {\n throw new Error(responseData.error)\n }\n\n return responseData\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error initiating payment:', error)\n }\n throw new Error(error instanceof Error ? error.message : 'Failed to initiate payment')\n }\n } else {\n throw new Error(`Payment method \"${paymentMethodID}\" does not support payment initiation`)\n }\n },\n [baseAPIURL, cartID, debug, paymentMethods, selectedCurrency.code],\n )\n\n const confirmOrder = useCallback<EcommerceContextType['initiatePayment']>(\n async (paymentMethodID, options) => {\n if (!cartID) {\n throw new Error(`Cart is empty.`)\n }\n\n const paymentMethod = paymentMethods.find((pm) => pm.name === paymentMethodID)\n\n if (!paymentMethod) {\n throw new Error(`Payment method with ID \"${paymentMethodID}\" not found`)\n }\n\n if (paymentMethod.confirmOrder) {\n const fetchURL = `${baseAPIURL}/payments/${paymentMethodID}/confirm-order`\n\n const data = {\n cartID,\n currency: selectedCurrency.code,\n }\n\n const response = await fetch(fetchURL, {\n body: JSON.stringify({\n ...data,\n ...(options?.additionalData || {}),\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const responseError = await response.text()\n throw new Error(responseError)\n }\n\n const responseData = await response.json()\n\n if (responseData.error) {\n throw new Error(responseData.error)\n }\n\n return responseData\n } else {\n throw new Error(`Payment method \"${paymentMethodID}\" does not support order confirmation`)\n }\n },\n [baseAPIURL, cartID, paymentMethods, selectedCurrency.code],\n )\n\n const getUser = useCallback(async () => {\n try {\n const query = qs.stringify({\n depth: 0,\n select: {\n id: true,\n carts: true,\n },\n })\n\n const response = await fetch(`${baseAPIURL}/${customersSlug}/me?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to fetch user: ${errorText}`)\n }\n\n const userData = await response.json()\n\n if (userData.error) {\n throw new Error(`User fetch error: ${userData.error}`)\n }\n\n if (userData.user) {\n setUser(userData.user as TypedUser)\n return userData.user as TypedUser\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching user:', error)\n }\n setUser(null)\n throw new Error(\n `Failed to fetch user: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }, [baseAPIURL, customersSlug, debug])\n\n const getAddresses = useCallback(async () => {\n if (!user) {\n return\n }\n\n try {\n const query = qs.stringify({\n depth: 0,\n limit: 0,\n pagination: false,\n })\n\n const response = await fetch(`${baseAPIURL}/${addressesSlug}?${query}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n throw new Error(errorText)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address fetch error: ${data.error}`)\n }\n\n if (data.docs && data.docs.length > 0) {\n setAddresses(data.docs)\n }\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching addresses:', error)\n }\n setAddresses(undefined)\n throw new Error(\n `Failed to fetch addresses: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }, [user, baseAPIURL, addressesSlug, debug])\n\n const updateAddress = useCallback<EcommerceContextType['updateAddress']>(\n async (addressID, address) => {\n if (!user) {\n throw new Error('User must be logged in to update or create an address')\n }\n\n try {\n const response = await fetch(`${baseAPIURL}/${addressesSlug}/${addressID}`, {\n body: JSON.stringify(address),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PATCH',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update or create address: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address update/create error: ${data.error}`)\n }\n\n // Refresh addresses after updating or creating\n await getAddresses()\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error updating or creating address:', error)\n }\n\n throw new Error(\n `Failed to update or create address: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n },\n [user, baseAPIURL, addressesSlug, getAddresses, debug],\n )\n\n const createAddress = useCallback<EcommerceContextType['createAddress']>(\n async (address) => {\n if (!user) {\n throw new Error('User must be logged in to update or create an address')\n }\n\n try {\n const response = await fetch(`${baseAPIURL}/${addressesSlug}`, {\n body: JSON.stringify(address),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n throw new Error(`Failed to update or create address: ${errorText}`)\n }\n\n const data = await response.json()\n\n if (data.error) {\n throw new Error(`Address update/create error: ${data.error}`)\n }\n\n // Refresh addresses after updating or creating\n await getAddresses()\n } catch (error) {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error updating or creating address:', error)\n }\n\n throw new Error(\n `Failed to update or create address: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n },\n [user, baseAPIURL, addressesSlug, getAddresses, debug],\n )\n\n // If localStorage is enabled, we can add logic to persist the cart state\n useEffect(() => {\n if (!hasRendered.current) {\n if (syncLocalStorage) {\n const storedCart = localStorage.getItem(localStorageConfig.key)\n if (storedCart) {\n getCart(storedCart)\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(storedCart as DefaultDocumentIDType)\n })\n .catch((_) => {\n // console.error('Error fetching cart from localStorage:', error)\n // If there's an error fetching the cart, we can clear it from localStorage\n localStorage.removeItem(localStorageConfig.key)\n setCartID(undefined)\n setCart(undefined)\n })\n }\n }\n\n hasRendered.current = true\n\n void getUser().then((user) => {\n if (user && user.cart?.docs && user.cart.docs.length > 0) {\n // If the user has carts, we can set the cartID to the first cart\n const cartID =\n typeof user.cart.docs[0] === 'object' ? user.cart.docs[0].id : user.cart.docs[0]\n\n if (cartID) {\n getCart(cartID)\n .then((fetchedCart) => {\n setCart(fetchedCart)\n setCartID(cartID)\n })\n .catch((error) => {\n if (debug) {\n // eslint-disable-next-line no-console\n console.error('Error fetching user cart:', error)\n }\n\n setCart(undefined)\n setCartID(undefined)\n\n throw new Error(`Failed to fetch user cart: ${error.message}`)\n })\n }\n }\n })\n }\n }, [debug, getAddresses, getCart, getUser, localStorageConfig.key, syncLocalStorage])\n\n useEffect(() => {\n if (user) {\n // If the user is logged in, fetch their addresses\n void getAddresses()\n } else {\n // If no user is logged in, clear addresses\n setAddresses(undefined)\n }\n }, [getAddresses, user])\n\n return (\n <EcommerceContext\n value={{\n addItem,\n addresses,\n cart,\n clearCart,\n confirmOrder,\n createAddress,\n currenciesConfig,\n currency: selectedCurrency,\n decrementItem,\n incrementItem,\n initiatePayment,\n paymentMethods,\n removeItem,\n selectedPaymentMethod,\n setCurrency,\n updateAddress,\n }}\n >\n {children}\n </EcommerceContext>\n )\n}\n\nexport const useEcommerce = () => {\n const context = use(EcommerceContext)\n\n if (!context) {\n throw new Error('useEcommerce must be used within an EcommerceProvider')\n }\n\n return context\n}\n\nexport const useCurrency = () => {\n const { currenciesConfig, currency, setCurrency } = useEcommerce()\n\n const formatCurrency = useCallback(\n (value?: null | number, options?: { currency?: Currency }): string => {\n if (value === undefined || value === null) {\n return ''\n }\n\n const currencyToUse = options?.currency || currency\n\n if (!currencyToUse) {\n return value.toString()\n }\n\n if (value === 0) {\n return `${currencyToUse.symbol}0.${'0'.repeat(currencyToUse.decimals)}`\n }\n\n // Convert from base value (e.g., cents) to decimal value (e.g., dollars)\n const decimalValue = value / Math.pow(10, currencyToUse.decimals)\n\n // Format with the correct number of decimal places\n return `${currencyToUse.symbol}${decimalValue.toFixed(currencyToUse.decimals)}`\n },\n [currency],\n )\n\n if (!currency) {\n throw new Error('useCurrency must be used within an EcommerceProvider')\n }\n\n return {\n currency,\n formatCurrency,\n setCurrency,\n supportedCurrencies: currenciesConfig.supportedCurrencies,\n }\n}\n\nexport const useCart = () => {\n const { addItem, cart, clearCart, decrementItem, incrementItem, removeItem } = useEcommerce()\n\n if (!addItem) {\n throw new Error('useCart must be used within an EcommerceProvider')\n }\n\n return { addItem, cart, clearCart, decrementItem, incrementItem, removeItem }\n}\n\nexport const usePayments = () => {\n const { confirmOrder, initiatePayment, paymentMethods, selectedPaymentMethod } = useEcommerce()\n\n if (!initiatePayment) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { confirmOrder, initiatePayment, paymentMethods, selectedPaymentMethod }\n}\n\nexport const useAddresses = () => {\n const { addresses, createAddress, updateAddress } = useEcommerce()\n\n if (!createAddress) {\n throw new Error('usePayments must be used within an EcommerceProvider')\n }\n\n return { addresses, createAddress, updateAddress }\n}\n"],"names":["deepMergeSimple","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","defaultContext","addItem","clearCart","confirmOrder","createAddress","currenciesConfig","defaultCurrency","supportedCurrencies","code","decimals","label","symbol","currency","decrementItem","incrementItem","initiatePayment","paymentMethods","removeItem","setCurrency","updateAddress","EcommerceContext","defaultLocalStorage","key","EcommerceProvider","addressesSlug","api","cartsSlug","children","customersSlug","debug","syncLocalStorage","localStorageConfig","apiRoute","cartsFetchQuery","serverURL","baseAPIURL","user","setUser","addresses","setAddresses","hasRendered","cartID","setCartID","cart","setCart","selectedCurrency","setSelectedCurrency","find","c","selectedPaymentMethod","setSelectedPaymentMethod","cartQuery","priceField","baseQuery","depth","populate","products","variants","options","select","items","subtotal","createCart","initialData","query","stringify","response","fetch","body","JSON","customer","id","credentials","headers","method","ok","errorText","text","Error","data","json","error","doc","getCart","updateCart","updatedCart","deleteCart","undefined","current","localStorage","setItem","item","quantity","existingCart","existingItemIndex","findIndex","cartItem","productID","product","variantID","variant","updatedItems","newCart","targetID","splice","foundCurrency","paymentMethodID","paymentMethod","name","fetchURL","additionalData","responseError","responseData","console","message","pm","getUser","carts","userData","getAddresses","limit","pagination","docs","length","addressID","address","storedCart","getItem","then","fetchedCart","catch","_","value","useEcommerce","context","useCurrency","formatCurrency","currencyToUse","toString","repeat","decimalValue","Math","pow","toFixed","useCart","usePayments","useAddresses"],"mappings":"AAAA;;AAGA,SAASA,eAAe,QAAQ,iBAAgB;AAChD,YAAYC,QAAQ,SAAQ;AAC5B,OAAOC,SAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AASpG,MAAMC,iBAAuC;IAC3CC,SAAS,WAAa;IACtBC,WAAW,WAAa;IACxBC,cAAc,WAAa;IAC3BC,eAAe,WAAa;IAC5BC,kBAAkB;QAChBC,iBAAiB;QACjBC,qBAAqB;YACnB;gBACEC,MAAM;gBACNC,UAAU;gBACVC,OAAO;gBACPC,QAAQ;YACV;SACD;IACH;IACAC,UAAU;QACRJ,MAAM;QACNC,UAAU;QACVC,OAAO;QACPC,QAAQ;IACV;IACAE,eAAe,WAAa;IAC5BC,eAAe,WAAa;IAC5BC,iBAAiB,WAAa;IAC9BC,gBAAgB,EAAE;IAClBC,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I,MAAM,CAACF,cAAchI,QAAQ,GAAG;QACzE;QAEA,yEAAyE;QACzE,MAAMmI,eAAeR,QAAQS,KAAKC,GAAG,CAAC,IAAIL,cAAchI,QAAQ;QAEhE,mDAAmD;QACnD,OAAO,GAAGgI,cAAc9H,MAAM,GAAGiI,aAAaG,OAAO,CAACN,cAAchI,QAAQ,GAAG;IACjF,GACA;QAACG;KAAS;IAGZ,IAAI,CAACA,UAAU;QACb,MAAM,IAAIkE,MAAM;IAClB;IAEA,OAAO;QACLlE;QACA4H;QACAtH;QACAX,qBAAqBF,iBAAiBE,mBAAmB;IAC3D;AACF,EAAC;AAED,OAAO,MAAMyI,UAAU;IACrB,MAAM,EAAE/I,OAAO,EAAE0C,IAAI,EAAEzC,SAAS,EAAEW,aAAa,EAAEC,aAAa,EAAEG,UAAU,EAAE,GAAGoH;IAE/E,IAAI,CAACpI,SAAS;QACZ,MAAM,IAAI6E,MAAM;IAClB;IAEA,OAAO;QAAE7E;QAAS0C;QAAMzC;QAAWW;QAAeC;QAAeG;IAAW;AAC9E,EAAC;AAED,OAAO,MAAMgI,cAAc;IACzB,MAAM,EAAE9I,YAAY,EAAEY,eAAe,EAAEC,cAAc,EAAEiC,qBAAqB,EAAE,GAAGoF;IAEjF,IAAI,CAACtH,iBAAiB;QACpB,MAAM,IAAI+D,MAAM;IAClB;IAEA,OAAO;QAAE3E;QAAcY;QAAiBC;QAAgBiC;IAAsB;AAChF,EAAC;AAED,OAAO,MAAMiG,eAAe;IAC1B,MAAM,EAAE5G,SAAS,EAAElC,aAAa,EAAEe,aAAa,EAAE,GAAGkH;IAEpD,IAAI,CAACjI,eAAe;QAClB,MAAM,IAAI0E,MAAM;IAClB;IAEA,OAAO;QAAExC;QAAWlC;QAAee;IAAc;AACnD,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { DefaultDocumentIDType, PopulateType, SelectType, TypedCollection } from 'payload';
1
+ import type { DefaultDocumentIDType, GeneratedTypes, PopulateType, SelectType } from 'payload';
2
2
  import type React from 'react';
3
3
  import type { CurrenciesConfig, Currency, PaymentAdapterClient } from '../../types.js';
4
4
  export type SyncLocalStorageConfig = {
@@ -97,11 +97,11 @@ export type EcommerceContext = {
97
97
  * All current addresses for the current user.
98
98
  * This is used to manage shipping and billing addresses.
99
99
  */
100
- addresses?: TypedCollection['addresses'][];
100
+ addresses?: TypedEcommerce['addressesCollection'][];
101
101
  /**
102
102
  * The current data of the cart.
103
103
  */
104
- cart?: TypedCollection['carts'];
104
+ cart?: TypedEcommerce['cartsCollection'];
105
105
  /**
106
106
  * The ID of the current cart corresponding to the cart in the database or local storage.
107
107
  */
@@ -121,7 +121,7 @@ export type EcommerceContext = {
121
121
  /**
122
122
  * Create a new address by providing the data.
123
123
  */
124
- createAddress: (data: Partial<TypedCollection['addresses']>) => Promise<void>;
124
+ createAddress: (data: Partial<TypedEcommerce['addressesCollection']>) => Promise<void>;
125
125
  /**
126
126
  * The configuration for the currencies used in the ecommerce context.
127
127
  */
@@ -165,7 +165,17 @@ export type EcommerceContext = {
165
165
  /**
166
166
  * Update an address by providing the data and the ID.
167
167
  */
168
- updateAddress: (addressID: DefaultDocumentIDType, data: Partial<TypedCollection['addresses']>) => Promise<void>;
168
+ updateAddress: (addressID: DefaultDocumentIDType, data: Partial<TypedEcommerce['addressesCollection']>) => Promise<void>;
169
169
  };
170
+ type ResolveEcommerceType<T> = 'ecommerce' extends keyof T ? T['ecommerce'] : T['ecommerceUntyped'];
171
+ export type TypedEcommerce = ResolveEcommerceType<GeneratedTypes>;
172
+ declare module 'payload' {
173
+ interface GeneratedTypes {
174
+ ecommerceUntyped: {
175
+ addressesCollection: TypedCollection['addresses'];
176
+ cartsCollection: TypedCollection['carts'];
177
+ };
178
+ }
179
+ }
170
180
  export {};
171
181
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/provider/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qB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;QAC7B,gBAAgB,EAAE;YAChB,mBAAmB,EAAE,eAAe,CAAC,WAAW,CAAC,CAAA;YACjD,eAAe,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;SAC1C,CAAA;KACF;CACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/react/provider/types.ts"],"sourcesContent":["import type { DefaultDocumentIDType, PopulateType, SelectType, TypedCollection } from 'payload'\nimport type React from 'react'\n\nimport type { CurrenciesConfig, Currency, PaymentAdapterClient } from '../../types.js'\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 EcommerceContext = {\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?: TypedCollection['addresses'][]\n /**\n * The current data of the cart.\n */\n cart?: TypedCollection['carts']\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<TypedCollection['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 paymentMethods: PaymentAdapterClient[]\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: (\n addressID: DefaultDocumentIDType,\n data: Partial<TypedCollection['addresses']>,\n ) => Promise<void>\n}\n"],"names":[],"mappings":"AAgGA,WAmFC"}
1
+ {"version":3,"sources":["../../../src/react/provider/types.ts"],"sourcesContent":["import type {\n DefaultDocumentIDType,\n GeneratedTypes,\n PopulateType,\n SelectType,\n TypedCollection,\n} from 'payload'\nimport type React from 'react'\n\nimport type { CurrenciesConfig, Currency, PaymentAdapterClient } from '../../types.js'\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 EcommerceContext = {\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?: TypedEcommerce['addressesCollection'][]\n /**\n * The current data of the cart.\n */\n cart?: TypedEcommerce['cartsCollection']\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<TypedEcommerce['addressesCollection']>) => 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 paymentMethods: PaymentAdapterClient[]\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: (\n addressID: DefaultDocumentIDType,\n data: Partial<TypedEcommerce['addressesCollection']>,\n ) => Promise<void>\n}\n\ntype ResolveEcommerceType<T> = 'ecommerce' extends keyof T\n ? T['ecommerce']\n : // @ts-expect-error - typescript doesnt play nice here\n T['ecommerceUntyped']\n\nexport type TypedEcommerce = ResolveEcommerceType<GeneratedTypes>\n\ndeclare module 'payload' {\n export interface GeneratedTypes {\n ecommerceUntyped: {\n addressesCollection: TypedCollection['addresses']\n cartsCollection: TypedCollection['carts']\n }\n }\n}\n"],"names":[],"mappings":"AAgMA,WAAiE"}
@@ -0,0 +1,9 @@
1
+ import type { JSONSchema4 } from 'json-schema';
2
+ import type { SanitizedConfig } from 'payload';
3
+ import type { SanitizedEcommercePluginConfig } from '../types.js';
4
+ export declare const pushTypeScriptProperties: ({ jsonSchema, }: {
5
+ config: SanitizedConfig;
6
+ jsonSchema: JSONSchema4;
7
+ sanitizedPluginConfig: SanitizedEcommercePluginConfig;
8
+ }) => JSONSchema4;
9
+ //# sourceMappingURL=pushTypeScriptProperties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushTypeScriptProperties.d.ts","sourceRoot":"","sources":["../../src/utilities/pushTypeScriptProperties.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAA;AAEjE,eAAO,MAAM,wBAAwB,oBAElC;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,EAAE,WAAW,CAAA;IACvB,qBAAqB,EAAE,8BAA8B,CAAA;CACtD,KAAG,WA0BH,CAAA"}
@@ -0,0 +1,28 @@
1
+ export const pushTypeScriptProperties = ({ jsonSchema })=>{
2
+ if (!jsonSchema.properties) {
3
+ jsonSchema.properties = {};
4
+ }
5
+ if (Array.isArray(jsonSchema.required)) {
6
+ jsonSchema.required.push('ecommerce');
7
+ }
8
+ const requiredProperties = [
9
+ 'addressesCollection',
10
+ 'cartsCollection'
11
+ ];
12
+ jsonSchema.properties.ecommerce = {
13
+ type: 'object',
14
+ additionalProperties: false,
15
+ properties: {
16
+ addressesCollection: {
17
+ $ref: `#/definitions/addresses`
18
+ },
19
+ cartsCollection: {
20
+ $ref: `#/definitions/carts`
21
+ }
22
+ },
23
+ required: requiredProperties
24
+ };
25
+ return jsonSchema;
26
+ };
27
+
28
+ //# sourceMappingURL=pushTypeScriptProperties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/pushTypeScriptProperties.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { SanitizedConfig } from 'payload'\n\nimport type { SanitizedEcommercePluginConfig } from '../types.js'\n\nexport const pushTypeScriptProperties = ({\n jsonSchema,\n}: {\n config: SanitizedConfig\n jsonSchema: JSONSchema4\n sanitizedPluginConfig: SanitizedEcommercePluginConfig\n}): JSONSchema4 => {\n if (!jsonSchema.properties) {\n jsonSchema.properties = {}\n }\n\n if (Array.isArray(jsonSchema.required)) {\n jsonSchema.required.push('ecommerce')\n }\n\n const requiredProperties = ['addressesCollection', 'cartsCollection']\n\n jsonSchema.properties.ecommerce = {\n type: 'object',\n additionalProperties: false,\n properties: {\n addressesCollection: {\n $ref: `#/definitions/addresses`,\n },\n cartsCollection: {\n $ref: `#/definitions/carts`,\n },\n },\n required: requiredProperties,\n }\n\n return jsonSchema\n}\n"],"names":["pushTypeScriptProperties","jsonSchema","properties","Array","isArray","required","push","requiredProperties","ecommerce","type","additionalProperties","addressesCollection","$ref","cartsCollection"],"mappings":"AAMA,OAAO,MAAMA,2BAA2B,CAAC,EACvCC,UAAU,EAKX;IACC,IAAI,CAACA,WAAWC,UAAU,EAAE;QAC1BD,WAAWC,UAAU,GAAG,CAAC;IAC3B;IAEA,IAAIC,MAAMC,OAAO,CAACH,WAAWI,QAAQ,GAAG;QACtCJ,WAAWI,QAAQ,CAACC,IAAI,CAAC;IAC3B;IAEA,MAAMC,qBAAqB;QAAC;QAAuB;KAAkB;IAErEN,WAAWC,UAAU,CAACM,SAAS,GAAG;QAChCC,MAAM;QACNC,sBAAsB;QACtBR,YAAY;YACVS,qBAAqB;gBACnBC,MAAM,CAAC,uBAAuB,CAAC;YACjC;YACAC,iBAAiB;gBACfD,MAAM,CAAC,mBAAmB,CAAC;YAC7B;QACF;QACAP,UAAUE;IACZ;IAEA,OAAON;AACT,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-ecommerce",
3
- "version": "3.57.0-internal.74d0404",
3
+ "version": "3.57.0-internal.8586ab4",
4
4
  "description": "Ecommerce plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -69,21 +69,22 @@
69
69
  ],
70
70
  "dependencies": {
71
71
  "qs-esm": "7.0.2",
72
- "@payloadcms/translations": "3.57.0-internal.74d0404",
73
- "@payloadcms/ui": "3.57.0-internal.74d0404"
72
+ "@payloadcms/translations": "3.57.0-internal.8586ab4",
73
+ "@payloadcms/ui": "3.57.0-internal.8586ab4"
74
74
  },
75
75
  "devDependencies": {
76
+ "@types/json-schema": "7.0.15",
76
77
  "@types/react": "19.1.0",
77
78
  "@types/react-dom": "19.1.2",
78
79
  "stripe": "18.3.0",
79
- "@payloadcms/next": "3.57.0-internal.74d0404",
80
- "payload": "3.57.0-internal.74d0404",
81
- "@payloadcms/eslint-config": "3.28.0"
80
+ "@payloadcms/eslint-config": "3.28.0",
81
+ "@payloadcms/next": "3.57.0-internal.8586ab4",
82
+ "payload": "3.57.0-internal.8586ab4"
82
83
  },
83
84
  "peerDependencies": {
84
85
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
85
86
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
86
- "payload": "3.57.0-internal.74d0404"
87
+ "payload": "3.57.0-internal.8586ab4"
87
88
  },
88
89
  "publishConfig": {
89
90
  "registry": "https://registry.npmjs.org/"