@payloadcms/plugin-ecommerce 3.84.0-internal.d5d6e43 → 3.84.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collections/orders/createOrdersCollection.d.ts +0 -6
- package/dist/collections/orders/createOrdersCollection.d.ts.map +1 -1
- package/dist/collections/orders/createOrdersCollection.js +1 -7
- package/dist/collections/orders/createOrdersCollection.js.map +1 -1
- package/dist/collections/transactions/createTransactionsCollection.d.ts +0 -6
- package/dist/collections/transactions/createTransactionsCollection.d.ts.map +1 -1
- package/dist/collections/transactions/createTransactionsCollection.js +1 -7
- package/dist/collections/transactions/createTransactionsCollection.js.map +1 -1
- package/dist/endpoints/confirmOrder.d.ts +1 -11
- package/dist/endpoints/confirmOrder.d.ts.map +1 -1
- package/dist/endpoints/confirmOrder.js +2 -74
- package/dist/endpoints/confirmOrder.js.map +1 -1
- package/dist/endpoints/initiatePayment.d.ts +1 -11
- package/dist/endpoints/initiatePayment.d.ts.map +1 -1
- package/dist/endpoints/initiatePayment.js +3 -74
- package/dist/endpoints/initiatePayment.js.map +1 -1
- package/dist/exports/types.d.ts +1 -1
- package/dist/exports/types.d.ts.map +1 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +1 -1
- package/dist/payments/adapters/stripe/index.d.ts +1 -2
- package/dist/payments/adapters/stripe/index.d.ts.map +1 -1
- package/dist/payments/adapters/stripe/index.js.map +1 -1
- package/dist/payments/adapters/stripe/initiatePayment.d.ts.map +1 -1
- package/dist/payments/adapters/stripe/initiatePayment.js +3 -6
- package/dist/payments/adapters/stripe/initiatePayment.js.map +1 -1
- package/dist/react/provider/index.d.ts +1 -0
- package/dist/react/provider/index.d.ts.map +1 -1
- package/dist/react/provider/index.js +9 -7
- package/dist/react/provider/index.js.map +1 -1
- package/dist/types/index.d.ts +6 -201
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/ui/PriceCell/index.d.ts.map +1 -1
- package/dist/ui/PriceCell/index.js +9 -11
- package/dist/ui/PriceCell/index.js.map +1 -1
- package/dist/ui/PriceRowLabel/index.d.ts.map +1 -1
- package/dist/ui/PriceRowLabel/index.js +15 -15
- package/dist/ui/PriceRowLabel/index.js.map +1 -1
- package/dist/ui/utilities.d.ts +11 -0
- package/dist/ui/utilities.d.ts.map +1 -1
- package/dist/ui/utilities.js +14 -0
- package/dist/ui/utilities.js.map +1 -1
- package/dist/utilities/sanitizePluginConfig.spec.js +0 -35
- package/dist/utilities/sanitizePluginConfig.spec.js.map +1 -1
- package/package.json +7 -7
- package/dist/fields/summaryField.d.ts +0 -14
- package/dist/fields/summaryField.d.ts.map +0 -1
- package/dist/fields/summaryField.js +0 -83
- package/dist/fields/summaryField.js.map +0 -1
- package/dist/utilities/runPaymentHooks.d.ts +0 -28
- package/dist/utilities/runPaymentHooks.d.ts.map +0 -1
- package/dist/utilities/runPaymentHooks.js +0 -68
- package/dist/utilities/runPaymentHooks.js.map +0 -1
- package/dist/utilities/runPaymentHooks.spec.js +0 -324
- package/dist/utilities/runPaymentHooks.spec.js.map +0 -1
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n Access,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n PopulateType,\n SelectType,\n TypedCollection,\n TypedUser,\n Where,\n} from 'payload'\nimport type React from 'react'\n\nimport type { TypedEcommerce } from './utilities.js'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type CollectionOverride = (args: {\n defaultCollection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type CartItem = {\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id: string\n product: DefaultDocumentIDType | TypedCollection['products']\n quantity: number\n variant?: DefaultDocumentIDType | TypedCollection['variants']\n}\n\ntype DefaultCartType = {\n currency?: string\n customer?: DefaultDocumentIDType | TypedCollection['customers']\n id: DefaultDocumentIDType\n items: CartItem[]\n subtotal?: number\n}\n\nexport type Cart = DefaultCartType\n\nexport type LineType = 'custom' | 'discount' | 'gift_card' | 'shipping' | 'subtotal' | 'tax'\n\n/**\n * A single line item making up a payment summary — items, tax, shipping, discount, etc.\n */\nexport type Line = {\n /**\n * The signed amount of the line in the smallest currency unit (e.g. cents for USD).\n * Positive values increase the total (tax, shipping).\n * Negative values decrease the total (discount, gift card).\n */\n amount: number\n /**\n * Human-readable label for display (e.g., \"CA Sales Tax\", \"Standard Shipping\").\n */\n label: string\n /**\n * Optional metadata for adapter-specific or user-specific data. A common pattern\n * is to stash a `taxable` flag here so later hooks know whether to include this line,\n * or an external identifier for idempotency with a tax/shipping provider.\n */\n metadata?: Record<string, unknown>\n /**\n * The type of line.\n */\n type: LineType\n}\n\n/**\n * Full breakdown of the payment amount. Passed through the beforeInitiatePayment hook\n * pipeline and returned in the `/payments/{provider}/initiate` response.\n *\n * The plugin recomputes `total` from `lines` after every hook, so you never need to\n * update `total` yourself inside a hook — just return the updated `lines`. The first\n * line is always the cart subtotal and is managed by the plugin; removing it or changing\n * its amount will throw.\n */\nexport type Summary = {\n /**\n * The ISO currency code used for all line amounts.\n */\n currency: string\n /**\n * Ordered list of line items contributing to the total.\n * `lines[0]` is always the cart subtotal and is managed by the plugin.\n */\n lines: Line[]\n /**\n * The final amount charged. Always equal to `sum(lines[].amount)`. This value is\n * recomputed by the plugin after each hook — any value a hook sets is ignored.\n */\n total: number\n}\n\n/**\n * Context provided to payment hooks during the initiate payment flow.\n */\nexport type PaymentHookContext = {\n /**\n * Billing address, if provided.\n */\n billingAddress?: TypedCollection['addresses']\n /**\n * The validated cart with items.\n */\n cart: Cart\n /**\n * The currencies configuration.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The resolved currency code.\n */\n currency: string\n /**\n * Customer email address.\n */\n customerEmail: string\n /**\n * The Payload request object.\n */\n req: PayloadRequest\n /**\n * Shipping address, if provided.\n */\n shippingAddress?: TypedCollection['addresses']\n}\n\n/**\n * Hook that runs before payment initiation, after validation.\n *\n * Receives the current `Summary` (total, currency, lines) and must return an updated\n * `Summary`. Typically you'll spread the incoming summary and append your line:\n *\n * ```ts\n * return {\n * ...summary,\n * lines: [...summary.lines, { type: 'tax', label: 'Sales Tax', amount: 1500 }],\n * }\n * ```\n *\n * The plugin recomputes `summary.total` from `summary.lines` after this hook runs,\n * so you never need to update `total` yourself.\n *\n * Throwing an error aborts the payment.\n */\nexport type BeforeInitiatePaymentHook = (\n args: {\n /**\n * The running summary — the cart subtotal plus any lines contributed by prior hooks.\n * Return a new summary with your line appended (or existing lines modified).\n */\n summary: Summary\n } & PaymentHookContext,\n) => Promise<Summary> | Summary\n\n/**\n * Hook that runs before order confirmation.\n * Can inspect data before the adapter confirms. Throwing an error aborts the confirmation.\n */\nexport type BeforeConfirmOrderHook = (args: {\n /**\n * Customer email.\n */\n customerEmail: string\n /**\n * All data passed to the confirm-order endpoint.\n */\n data: Record<string, unknown>\n /**\n * The Payload request object.\n */\n req: PayloadRequest\n}) => Promise<void> | void\n\n/**\n * Hook that runs after order confirmation succeeds.\n * For side effects only (sending emails, updating external systems, redeeming gift cards).\n * Return value is ignored. Errors are logged but do not fail the response.\n */\nexport type AfterConfirmOrderHook = (args: {\n /**\n * The created order ID.\n */\n orderID: DefaultDocumentIDType\n /**\n * The Payload request object.\n */\n req: PayloadRequest\n /**\n * The transaction ID.\n */\n transactionID: DefaultDocumentIDType\n}) => Promise<void> | void\n\n/**\n * Hook configuration for the payment flow. Used at both the plugin level\n * (runs for all payment methods) and the adapter level (runs for that adapter only).\n */\nexport type PaymentHooks = {\n afterConfirmOrder?: AfterConfirmOrderHook[]\n beforeConfirmOrder?: BeforeConfirmOrderHook[]\n beforeInitiatePayment?: BeforeInitiatePaymentHook[]\n}\n\ntype InitiatePaymentReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n /**\n * Optional ID of the transaction record created during initiation. When returned,\n * the plugin will write the computed `summary` onto this transaction — so the\n * breakdown (subtotal, tax, shipping, etc.) is available on the record alongside\n * the total.\n */\n transactionID?: DefaultDocumentIDType\n}\n\ntype InitiatePayment = (args: {\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n data: {\n /**\n * Billing address for the payment.\n */\n billingAddress: TypedCollection['addresses']\n /**\n * Cart items.\n */\n cart: Cart\n /**\n * Currency code to use for the payment.\n */\n currency: string\n customerEmail: string\n /**\n * Shipping address for the payment.\n */\n shippingAddress?: TypedCollection['addresses']\n /**\n * The final payment summary after all beforeInitiatePayment hooks have run.\n * Use `summary.total` as the amount to charge and store `summary.lines` if you\n * need to persist the breakdown (e.g. in provider metadata).\n */\n summary: Summary\n }\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug: string\n}) => InitiatePaymentReturnType | Promise<InitiatePaymentReturnType>\n\ntype ConfirmOrderReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n orderID: DefaultDocumentIDType\n transactionID: DefaultDocumentIDType\n}\n\ntype ConfirmOrder = (args: {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n * For example, this is used to retrieve the cart for the order.\n */\n cartsSlug?: string\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Data made available to the payment method when confirming an order. You should get the cart items from the transaction.\n */\n data: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any // Allows for additional data to be passed through, such as payment method specific data\n customerEmail?: string\n }\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug?: string\n}) => ConfirmOrderReturnType | Promise<ConfirmOrderReturnType>\n\n/**\n * The full payment adapter config expected as part of the config for the Ecommerce plugin.\n *\n * You can insert this type directly or return it from a function constructing it.\n */\nexport type PaymentAdapter = {\n /**\n * The function that is called via the `/api/payments/{provider_name}/confirm-order` endpoint to confirm an order after a payment has been made.\n *\n * You should handle the order confirmation logic here.\n *\n * @example\n *\n * ```ts\n * const confirmOrder: ConfirmOrder = async ({ data: { customerEmail }, ordersSlug, req, transactionsSlug }) => {\n // Confirm the payment with Stripe or another payment provider here\n // Create an order in the orders collection here\n // Update the record of the payment intent in the transactions collection here\n return {\n message: 'Order confirmed successfully',\n orderID: 'order_123',\n transactionID: 'txn_123',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n confirmOrder: ConfirmOrder\n /**\n * An array of endpoints to be bootstrapped to Payload's API in order to support the payment method. All API paths are relative to `/api/payments/{provider_name}`.\n *\n * So for example, path `/webhooks` in the Stripe adapter becomes `/api/payments/stripe/webhooks`.\n *\n * @example '/webhooks'\n */\n endpoints?: Endpoint[]\n /**\n * A group configuration to be used in the admin interface to display the payment method.\n *\n * @example\n *\n * ```ts\n * const groupField: GroupField = {\n name: 'stripe',\n type: 'group',\n admin: {\n condition: (data) => data?.paymentMethod === 'stripe',\n },\n fields: [\n {\n name: 'stripeCustomerID',\n type: 'text',\n label: 'Stripe Customer ID',\n required: true,\n },\n {\n name: 'stripePaymentIntentID',\n type: 'text',\n label: 'Stripe PaymentIntent ID',\n required: true,\n },\n ],\n }\n * ```\n */\n group: GroupField\n /**\n * Hooks specific to this payment adapter. These run after plugin-level hooks.\n *\n * @example\n * ```ts\n * hooks: {\n * beforeInitiatePayment: [\n * async ({ subtotal }) => {\n * return [{ type: 'tax', label: 'Stripe Tax', amount: calculatedTax }]\n * },\n * ],\n * }\n * ```\n */\n hooks?: PaymentHooks\n /**\n * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.\n *\n * You should handle the payment initiation logic here.\n *\n * @example\n *\n * ```ts\n * const initiatePayment: InitiatePayment = async ({ data: { cart, currency, customerEmail, billingAddress, shippingAddress }, req, transactionsSlug }) => {\n // Create a payment intent with Stripe or another payment provider here\n // Create a record of the payment intent in the transactions collection here\n return {\n message: 'Payment initiated successfully',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n initiatePayment: InitiatePayment\n /**\n * The label of the payment method\n * @example\n * 'Bank Transfer'\n */\n label?: string\n /**\n * The name of the payment method\n * @example 'stripe'\n */\n name: string\n}\n\nexport type PaymentAdapterClient = {\n confirmOrder: boolean\n initiatePayment: boolean\n} & Pick<PaymentAdapter, 'label' | 'name'>\n\nexport type Currency = {\n /**\n * The ISO 4217 currency code\n * @example 'usd'\n */\n code: string\n /**\n * The number of decimal places the currency uses\n * @example 2\n */\n decimals: number\n /**\n * A user friendly name for the currency.\n *\n * @example 'US Dollar'\n */\n label: string\n /**\n * The symbol of the currency\n * @example '$'\n */\n symbol: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterArgs = {\n /**\n * Overrides the default fields of the collection. Affects the payment fields on collections such as transactions.\n */\n groupOverrides?: { fields?: FieldsOverride } & Partial<Omit<GroupField, 'fields'>>\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterClientArgs = {\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\nexport type VariantsConfig = {\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantOptionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantOptionsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantTypesCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantTypesCollectionOverride?: CollectionOverride\n}\n\nexport type ProductsConfig = {\n /**\n * Override the default products collection. If you override the collection, you should ensure it has the required fields for products or re-use the default fields.\n *\n * @example\n *\n * ```ts\n products: {\n productsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n productsCollectionOverride?: CollectionOverride\n /**\n * Customise the validation used for checking products or variants before a transaction is created or a payment can be confirmed.\n */\n validation?: ProductsValidation\n /**\n * Enable variants and provide configuration for the variant collections.\n *\n * Defaults to true.\n */\n variants?: boolean | VariantsConfig\n}\n\nexport type OrdersConfig = {\n /**\n * Override the default orders collection. If you override the collection, you should ensure it has the required fields for orders or re-use the default fields.\n *\n * @example\n *\n * ```ts\n orders: {\n ordersCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n ordersCollectionOverride?: CollectionOverride\n}\n\nexport type TransactionsConfig = {\n /**\n * Override the default transactions collection. If you override the collection, you should ensure it has the required fields for transactions or re-use the default fields.\n *\n * @example\n *\n * ```ts\n transactions: {\n transactionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n transactionsCollectionOverride?: CollectionOverride\n}\n\nexport type CustomQuery = {\n depth?: number\n select?: SelectType\n where?: Where\n}\n\nexport type PaymentsConfig = {\n /**\n * Hooks that run for all payment methods. Plugin-level hooks execute before adapter-level hooks.\n *\n * @example\n * ```ts\n * hooks: {\n * beforeInitiatePayment: [\n * async ({ subtotal, shippingAddress }) => {\n * const taxRate = await fetchTaxRate(shippingAddress)\n * return [{ type: 'tax', label: 'Sales Tax', amount: Math.round(subtotal * taxRate) }]\n * },\n * ],\n * }\n * ```\n */\n hooks?: PaymentHooks\n paymentMethods?: PaymentAdapter[]\n productsQuery?: CustomQuery\n variantsQuery?: CustomQuery\n}\n\nexport type CountryType = {\n /**\n * A user friendly name for the country.\n */\n label: string\n /**\n * The ISO 3166-1 alpha-2 country code.\n * @example 'US'\n */\n value: string\n}\n\n/**\n * Configuration for the addresses used by the Ecommerce plugin. Use this to override the default collection or fields used throughout\n */\ntype AddressesConfig = {\n /**\n * Override the default addresses collection. If you override the collection, you should ensure it has the required fields for addresses or re-use the default fields.\n *\n * @example\n * ```ts\n * addressesCollectionOverride: (defaultCollection) => {\n * return {\n * ...defaultCollection,\n * fields: [\n * ...defaultCollection.fields,\n * // add custom fields here\n * ],\n * }\n * }\n * ```\n */\n addressesCollectionOverride?: CollectionOverride\n /**\n * These fields will be applied to all locations where addresses are used, such as Orders and Transactions. Preferred use over the collectionOverride config.\n */\n addressFields?: FieldsOverride\n /**\n * Provide an array of countries to support for addresses. This will be used in the admin interface to provide a select field of countries.\n *\n * Defaults to a set of commonly used countries.\n *\n * @example\n * ```\n * [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ]\n */\n supportedCountries?: CountryType[]\n}\n\nexport type CustomersConfig = {\n /**\n * Slug of the customers collection, defaults to 'users'.\n * This is used to link carts and orders to customers.\n */\n slug: string\n}\n\n/**\n * Arguments for the cart item matcher function.\n */\nexport type CartItemMatcherArgs = {\n /** The existing cart item to compare against */\n existingItem: {\n [key: string]: unknown\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id?: string\n product: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n quantity: number\n variant?: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n }\n /** The new item being added */\n newItem: {\n [key: string]: unknown\n product: DefaultDocumentIDType\n quantity?: number\n variant?: DefaultDocumentIDType\n }\n}\n\n/**\n * Function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n */\nexport type CartItemMatcher = (args: CartItemMatcherArgs) => boolean\n\nexport type CartsConfig = {\n /**\n * Allow guest (unauthenticated) users to create carts.\n * When enabled, guests can create carts without being logged in.\n * Defaults to true.\n */\n allowGuestCarts?: boolean\n /**\n * Custom function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n *\n * Use this to add custom uniqueness criteria beyond product and variant IDs.\n *\n * @default defaultCartItemMatcher (matches by product and variant ID only)\n *\n * @example\n * ```ts\n * cartItemMatcher: ({ existingItem, newItem }) => {\n * // Match by product, variant, AND custom delivery option\n * const productMatch = existingItem.product === newItem.product\n * const variantMatch = existingItem.variant === newItem.variant\n * const deliveryMatch = existingItem.deliveryOption === newItem.deliveryOption\n * return productMatch && variantMatch && deliveryMatch\n * }\n * ```\n */\n cartItemMatcher?: CartItemMatcher\n cartsCollectionOverride?: CollectionOverride\n}\n\nexport type InventoryConfig = {\n /**\n * Override the default field used to track inventory levels. Defaults to 'inventory'.\n */\n fieldName?: string\n}\n\nexport type CurrenciesConfig = {\n /**\n * Defaults to the first supported currency.\n *\n * @example 'USD'\n */\n defaultCurrency: string\n /**\n *\n */\n supportedCurrencies: Currency[]\n}\n\n/**\n * A function that validates a product or variant before a transaction is created or completed.\n * This should throw an error if validation fails as it will be caught by the function calling it.\n */\nexport type ProductsValidation = (args: {\n /**\n * The full currencies config, allowing you to check against supported currencies and their settings.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The ISO 4217 currency code being usen in this transaction.\n */\n currency?: string\n /**\n * The full product data.\n */\n product: TypedCollection['products']\n /**\n * Quantity to check the inventory amount against.\n */\n quantity: number\n /**\n * The full variant data, if a variant was selected for the product otherwise it will be undefined.\n */\n variant?: TypedCollection['variants']\n}) => Promise<void> | void\n\n/**\n * A map of collection slugs used by the Ecommerce plugin.\n * Provides an easy way to track the slugs of collections even when they are overridden.\n * Variant-related slugs are only present when variants are enabled.\n */\nexport type CollectionSlugMap = {\n addresses: string\n carts: string\n customers: string\n orders: string\n products: string\n transactions: string\n variantOptions?: string\n variants?: string\n variantTypes?: string\n}\n\n/**\n * Access control functions used throughout the Ecommerce plugin.\n * Provide atomic access functions that can be composed using or, and, conditional utilities.\n *\n * @example\n * ```ts\n * access: {\n * isAdmin: ({ req }) => checkRole(['admin'], req.user),\n * isAuthenticated: ({ req }) => !!req.user,\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user),\n * isDocumentOwner: ({ req }) => {\n * if (!req.user) return false\n * return { customer: { equals: req.user.id } }\n * },\n * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),\n * adminOrPublishedStatus: ({ req }) => {\n * if (checkRole(['admin'], req.user)) return true\n * return { _status: { equals: 'published' } }\n * },\n * }\n * ```\n */\nexport type AccessConfig = {\n /**\n * Limited to only admin users, specifically for Field level access control.\n */\n adminOnlyFieldAccess: FieldAccess\n /**\n * The document status is published or user is admin.\n */\n adminOrPublishedStatus: Access\n /**\n * @deprecated Will be removed in v4. Use `isCustomer` instead.\n * Limited to customers only, specifically for Field level access control.\n */\n customerOnlyFieldAccess?: FieldAccess\n /**\n * Checks if the user is an admin.\n * @returns true if admin, false otherwise\n */\n isAdmin: Access\n /**\n * Checks if the user is authenticated (any role).\n * @returns true if authenticated, false otherwise\n */\n isAuthenticated?: Access\n /**\n * Checks if the user is a customer (authenticated but not an admin).\n * Used internally to auto-assign customer ID when creating addresses.\n * @returns true if user is a non-admin customer, false otherwise\n *\n * @example\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user)\n */\n isCustomer?: FieldAccess\n /**\n * Checks if the user owns the document being accessed.\n * Typically returns a Where query to filter by customer field.\n * @returns true for full access, false for no access, or Where query for conditional access\n */\n isDocumentOwner: Access\n /**\n * Entirely public access. Defaults to returning true.\n *\n * @example\n * publicAccess: () => true\n */\n publicAccess?: Access\n}\n\nexport type EcommercePluginConfig = {\n /**\n * Customise the access control for the plugin.\n *\n * @example\n * ```ts\n * ```\n */\n access: AccessConfig\n /**\n * Enable the addresses collection to allow customers, transactions and orders to have multiple addresses for shipping and billing. Accepts an override to customise the addresses collection.\n * Defaults to supporting a default set of countries.\n */\n addresses?: AddressesConfig | boolean\n /**\n * Configure the target collection used for carts.\n *\n * Defaults to true.\n */\n carts?: boolean | CartsConfig\n /**\n * Configure supported currencies and default settings.\n *\n * Defaults to supporting USD.\n */\n currencies?: CurrenciesConfig\n /**\n * Configure the target collection used for customers.\n *\n * @example\n * ```ts\n * customers: {\n * slug: 'users', // default\n * }\n *\n */\n customers: CustomersConfig\n /**\n * Enable tracking of inventory for products and variants. Accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Enables orders and accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n orders?: boolean | OrdersConfig\n /**\n * Enable tracking of payments. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n payments?: PaymentsConfig\n /**\n * Enables products and variants. Accepts a config object to override the product collection and each variant collection type.\n *\n * Defaults to true.\n */\n products?: boolean | ProductsConfig\n /**\n * Override the default slugs used across the plugin. This lets the plugin know which slugs to use for various internal operations and fields.\n */\n slugMap?: Partial<CollectionSlugMap>\n /**\n * Enable tracking of transactions. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n transactions?: boolean | TransactionsConfig\n}\n\nexport type SanitizedAccessConfig = Pick<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'> &\n Required<Omit<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'>>\n\nexport type SanitizedEcommercePluginConfig = {\n access: SanitizedAccessConfig\n addresses: { addressFields: Field[] } & Omit<AddressesConfig, 'addressFields'>\n currencies: Required<CurrenciesConfig>\n inventory?: InventoryConfig\n payments: {\n hooks?: PaymentHooks\n paymentMethods: [] | PaymentAdapter[]\n }\n} & Omit<\n Required<EcommercePluginConfig>,\n 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'\n>\n\nexport type EcommerceCollections = TypedEcommerce['collections']\n\nexport type AddressesCollection = EcommerceCollections['addresses']\nexport type CartsCollection = EcommerceCollections['carts']\n\nexport type SyncLocalStorageConfig = {\n /**\n * Key to use for localStorage.\n * Defaults to 'cart'.\n */\n key?: string\n}\n\ntype APIProps = {\n /**\n * The route for the Payload API, defaults to `/api`.\n */\n apiRoute?: string\n /**\n * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.\n *\n * Defaults to `{ depth: 0 }`.\n */\n cartsFetchQuery?: {\n depth?: number\n populate?: PopulateType\n select?: SelectType\n }\n /**\n * The route for the Payload API, defaults to ``. Eg for a Payload app running on `http://localhost:3000`, the default serverURL would be `http://localhost:3000`.\n */\n serverURL?: string\n}\n\n/**\n * Memoized configuration object exposed via the useEcommerce hook.\n * Contains collection slugs and API settings for building URLs and queries.\n */\nexport type EcommerceConfig = {\n /**\n * The slug for the addresses collection.\n */\n addressesSlug: CollectionSlug\n /**\n * API configuration including the base route.\n */\n api: {\n /**\n * The base API route, e.g. '/api'.\n */\n apiRoute: string\n }\n /**\n * The slug for the carts collection.\n */\n cartsSlug: CollectionSlug\n /**\n * The slug for the customers collection.\n */\n customersSlug: CollectionSlug\n}\n\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: CollectionSlug\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: CollectionSlug\n children?: React.ReactNode\n /**\n * The configuration for currencies used in the ecommerce context.\n * This is used to handle currency formatting and calculations, defaults to USD.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The slug for the customers collection.\n *\n * Defaults to 'users'.\n */\n customersSlug?: CollectionSlug\n /**\n * Enable debug mode for the ecommerce context. This will log additional information to the console.\n * Defaults to false.\n */\n debug?: boolean\n /**\n * Whether to enable support for variants in the cart.\n * This allows adding products with specific variants to the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Supported payment methods for the ecommerce context.\n */\n paymentMethods?: PaymentAdapterClient[]\n /**\n * Whether to enable localStorage for cart persistence.\n * Defaults to true.\n */\n syncLocalStorage?: boolean | SyncLocalStorageConfig\n}\n\n/**\n * Type used internally to represent the cart item to be added.\n */\ntype CartItemArgument = {\n /**\n * The ID of the product to add to the cart. Always required.\n */\n product: DefaultDocumentIDType\n /**\n * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.\n */\n variant?: DefaultDocumentIDType\n}\n\nexport type EcommerceContextType<T extends EcommerceCollections = EcommerceCollections> = {\n /**\n * Add an item to the cart.\n */\n addItem: (item: CartItemArgument, quantity?: number) => Promise<void>\n /**\n * All current addresses for the current user.\n * This is used to manage shipping and billing addresses.\n */\n addresses?: T['addresses'][]\n /**\n * The current data of the cart.\n */\n cart?: T['addresses']\n /**\n * The ID of the current cart corresponding to the cart in the database or local storage.\n */\n cartID?: DefaultDocumentIDType\n /**\n * Clear the cart, removing all items.\n */\n clearCart: () => Promise<void>\n /**\n * Clears all ecommerce session data including cart, addresses, and user state.\n * Should be called when a user logs out.\n * This also clears localStorage cart data when syncLocalStorage is enabled.\n */\n clearSession: () => void\n /**\n * Memoized configuration object containing collection slugs and API settings.\n * Use this to build URLs and queries with the correct collection slugs.\n */\n config: EcommerceConfig\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n confirmOrder: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Create a new address by providing the data.\n */\n createAddress: (data: Partial<T['addresses']>) => Promise<void>\n /**\n * The configuration for the currencies used in the ecommerce context.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The currently selected currency used for the cart and price formatting automatically.\n */\n currency: Currency\n /**\n * Decrement an item in the cart by its array item ID.\n * If quantity reaches 0, the item will be removed from the cart.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n decrementItem: (item: string) => Promise<void>\n /**\n * Increment an item in the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n incrementItem: (item: string) => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n initiatePayment: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Indicates whether any cart operation is currently in progress.\n * Useful for disabling buttons and preventing race conditions.\n */\n isLoading: boolean\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n mergeCart: (\n targetCartID: DefaultDocumentIDType,\n sourceCartID: DefaultDocumentIDType,\n sourceSecret?: string,\n ) => Promise<T['carts'] | void>\n /**\n * Called after a successful login to handle cart state.\n * If a guest cart exists, it will be merged with the user's existing cart\n * or assigned to the user if they have no cart.\n * Cart secrets are cleared as authenticated users don't need them.\n *\n * @returns Promise that resolves when cart state is properly set up for the user.\n */\n onLogin: () => Promise<void>\n /**\n * Called during logout to clear all ecommerce session data.\n * Clears cart, addresses, user state, and localStorage cart data.\n * This is an alias for clearSession() but named for semantic clarity.\n */\n onLogout: () => void\n paymentMethods: PaymentAdapterClient[]\n /**\n * Refresh the cart.\n */\n refreshCart: () => Promise<void>\n /**\n * Remove an item from the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n removeItem: (item: string) => Promise<void>\n /**\n * The name of the currently selected payment method.\n * This is used to determine which payment method to use when initiating a payment.\n */\n selectedPaymentMethod?: null | string\n /**\n * Change the currency for the cart, it defaults to the configured currency.\n * This will update the currency used for pricing and calculations.\n */\n setCurrency: (currency: string) => void\n /**\n * Update an address by providing the data and the ID.\n */\n updateAddress: (addressID: DefaultDocumentIDType, data: Partial<T['addresses']>) => Promise<void>\n /**\n * The current authenticated user, or null if not logged in.\n */\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAsmCA,WAwIC"}
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n Access,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n PopulateType,\n SelectType,\n TypedCollection,\n TypedUser,\n Where,\n} from 'payload'\nimport type React from 'react'\n\nimport type { TypedEcommerce } from './utilities.js'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type CollectionOverride = (args: {\n defaultCollection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type CartItem = {\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id: string\n product: DefaultDocumentIDType | TypedCollection['products']\n quantity: number\n variant?: DefaultDocumentIDType | TypedCollection['variants']\n}\n\ntype DefaultCartType = {\n currency?: string\n customer?: DefaultDocumentIDType | TypedCollection['customers']\n id: DefaultDocumentIDType\n items: CartItem[]\n subtotal?: number\n}\n\nexport type Cart = DefaultCartType\n\ntype InitiatePaymentReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n}\n\ntype InitiatePayment = (args: {\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n data: {\n /**\n * Billing address for the payment.\n */\n billingAddress: TypedCollection['addresses']\n /**\n * Cart items.\n */\n cart: Cart\n /**\n * Currency code to use for the payment.\n */\n currency: string\n customerEmail: string\n /**\n * Shipping address for the payment.\n */\n shippingAddress?: TypedCollection['addresses']\n }\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug: string\n}) => InitiatePaymentReturnType | Promise<InitiatePaymentReturnType>\n\ntype ConfirmOrderReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n orderID: DefaultDocumentIDType\n transactionID: DefaultDocumentIDType\n}\n\ntype ConfirmOrder = (args: {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n * For example, this is used to retrieve the cart for the order.\n */\n cartsSlug?: string\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Data made available to the payment method when confirming an order. You should get the cart items from the transaction.\n */\n data: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any // Allows for additional data to be passed through, such as payment method specific data\n customerEmail?: string\n }\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug?: string\n}) => ConfirmOrderReturnType | Promise<ConfirmOrderReturnType>\n\n/**\n * The full payment adapter config expected as part of the config for the Ecommerce plugin.\n *\n * You can insert this type directly or return it from a function constructing it.\n */\nexport type PaymentAdapter = {\n /**\n * The function that is called via the `/api/payments/{provider_name}/confirm-order` endpoint to confirm an order after a payment has been made.\n *\n * You should handle the order confirmation logic here.\n *\n * @example\n *\n * ```ts\n * const confirmOrder: ConfirmOrder = async ({ data: { customerEmail }, ordersSlug, req, transactionsSlug }) => {\n // Confirm the payment with Stripe or another payment provider here\n // Create an order in the orders collection here\n // Update the record of the payment intent in the transactions collection here\n return {\n message: 'Order confirmed successfully',\n orderID: 'order_123',\n transactionID: 'txn_123',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n confirmOrder: ConfirmOrder\n /**\n * An array of endpoints to be bootstrapped to Payload's API in order to support the payment method. All API paths are relative to `/api/payments/{provider_name}`.\n *\n * So for example, path `/webhooks` in the Stripe adapter becomes `/api/payments/stripe/webhooks`.\n *\n * @example '/webhooks'\n */\n endpoints?: Endpoint[]\n /**\n * A group configuration to be used in the admin interface to display the payment method.\n *\n * @example\n *\n * ```ts\n * const groupField: GroupField = {\n name: 'stripe',\n type: 'group',\n admin: {\n condition: (data) => data?.paymentMethod === 'stripe',\n },\n fields: [\n {\n name: 'stripeCustomerID',\n type: 'text',\n label: 'Stripe Customer ID',\n required: true,\n },\n {\n name: 'stripePaymentIntentID',\n type: 'text',\n label: 'Stripe PaymentIntent ID',\n required: true,\n },\n ],\n }\n * ```\n */\n group: GroupField\n /**\n * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.\n *\n * You should handle the payment initiation logic here.\n *\n * @example\n *\n * ```ts\n * const initiatePayment: InitiatePayment = async ({ data: { cart, currency, customerEmail, billingAddress, shippingAddress }, req, transactionsSlug }) => {\n // Create a payment intent with Stripe or another payment provider here\n // Create a record of the payment intent in the transactions collection here\n return {\n message: 'Payment initiated successfully',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n initiatePayment: InitiatePayment\n /**\n * The label of the payment method\n * @example\n * 'Bank Transfer'\n */\n label?: string\n /**\n * The name of the payment method\n * @example 'stripe'\n */\n name: string\n}\n\nexport type PaymentAdapterClient = {\n confirmOrder: boolean\n initiatePayment: boolean\n} & Pick<PaymentAdapter, 'label' | 'name'>\n\nexport type Currency = {\n /**\n * The ISO 4217 currency code\n * @example 'USD'\n */\n code: string\n /**\n * The number of decimal places the currency uses\n * @example 2\n */\n decimals: number\n /**\n * A user friendly name for the currency.\n *\n * @example 'US Dollar'\n */\n label: string\n /**\n * The symbol of the currency\n * @example '$'\n */\n symbol: string\n /**\n * The display format for the currency symbol in formatted output.\n * @example 'symbol'\n */\n symbolDisplay?: 'code' | 'symbol'\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterArgs = {\n /**\n * Overrides the default fields of the collection. Affects the payment fields on collections such as transactions.\n */\n groupOverrides?: { fields?: FieldsOverride } & Partial<Omit<GroupField, 'fields'>>\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterClientArgs = {\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\nexport type VariantsConfig = {\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantOptionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantOptionsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantTypesCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantTypesCollectionOverride?: CollectionOverride\n}\n\nexport type ProductsConfig = {\n /**\n * Override the default products collection. If you override the collection, you should ensure it has the required fields for products or re-use the default fields.\n *\n * @example\n *\n * ```ts\n products: {\n productsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n productsCollectionOverride?: CollectionOverride\n /**\n * Customise the validation used for checking products or variants before a transaction is created or a payment can be confirmed.\n */\n validation?: ProductsValidation\n /**\n * Enable variants and provide configuration for the variant collections.\n *\n * Defaults to true.\n */\n variants?: boolean | VariantsConfig\n}\n\nexport type OrdersConfig = {\n /**\n * Override the default orders collection. If you override the collection, you should ensure it has the required fields for orders or re-use the default fields.\n *\n * @example\n *\n * ```ts\n orders: {\n ordersCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n ordersCollectionOverride?: CollectionOverride\n}\n\nexport type TransactionsConfig = {\n /**\n * Override the default transactions collection. If you override the collection, you should ensure it has the required fields for transactions or re-use the default fields.\n *\n * @example\n *\n * ```ts\n transactions: {\n transactionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n transactionsCollectionOverride?: CollectionOverride\n}\n\nexport type CustomQuery = {\n depth?: number\n select?: SelectType\n where?: Where\n}\n\nexport type PaymentsConfig = {\n paymentMethods?: PaymentAdapter[]\n productsQuery?: CustomQuery\n variantsQuery?: CustomQuery\n}\n\nexport type CountryType = {\n /**\n * A user friendly name for the country.\n */\n label: string\n /**\n * The ISO 3166-1 alpha-2 country code.\n * @example 'US'\n */\n value: string\n}\n\n/**\n * Configuration for the addresses used by the Ecommerce plugin. Use this to override the default collection or fields used throughout\n */\ntype AddressesConfig = {\n /**\n * Override the default addresses collection. If you override the collection, you should ensure it has the required fields for addresses or re-use the default fields.\n *\n * @example\n * ```ts\n * addressesCollectionOverride: (defaultCollection) => {\n * return {\n * ...defaultCollection,\n * fields: [\n * ...defaultCollection.fields,\n * // add custom fields here\n * ],\n * }\n * }\n * ```\n */\n addressesCollectionOverride?: CollectionOverride\n /**\n * These fields will be applied to all locations where addresses are used, such as Orders and Transactions. Preferred use over the collectionOverride config.\n */\n addressFields?: FieldsOverride\n /**\n * Provide an array of countries to support for addresses. This will be used in the admin interface to provide a select field of countries.\n *\n * Defaults to a set of commonly used countries.\n *\n * @example\n * ```\n * [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ]\n */\n supportedCountries?: CountryType[]\n}\n\nexport type CustomersConfig = {\n /**\n * Slug of the customers collection, defaults to 'users'.\n * This is used to link carts and orders to customers.\n */\n slug: string\n}\n\n/**\n * Arguments for the cart item matcher function.\n */\nexport type CartItemMatcherArgs = {\n /** The existing cart item to compare against */\n existingItem: {\n [key: string]: unknown\n /**\n * The ID of the cart item. Array item IDs are always strings in Payload,\n * regardless of the database adapter's default ID type.\n */\n id?: string\n product: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n quantity: number\n variant?: { [key: string]: unknown; id: DefaultDocumentIDType } | DefaultDocumentIDType\n }\n /** The new item being added */\n newItem: {\n [key: string]: unknown\n product: DefaultDocumentIDType\n quantity?: number\n variant?: DefaultDocumentIDType\n }\n}\n\n/**\n * Function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n */\nexport type CartItemMatcher = (args: CartItemMatcherArgs) => boolean\n\nexport type CartsConfig = {\n /**\n * Allow guest (unauthenticated) users to create carts.\n * When enabled, guests can create carts without being logged in.\n * Defaults to true.\n */\n allowGuestCarts?: boolean\n /**\n * Custom function to determine if two cart items should be considered the same.\n * When items match, their quantities are combined instead of creating separate entries.\n *\n * Use this to add custom uniqueness criteria beyond product and variant IDs.\n *\n * @default defaultCartItemMatcher (matches by product and variant ID only)\n *\n * @example\n * ```ts\n * cartItemMatcher: ({ existingItem, newItem }) => {\n * // Match by product, variant, AND custom delivery option\n * const productMatch = existingItem.product === newItem.product\n * const variantMatch = existingItem.variant === newItem.variant\n * const deliveryMatch = existingItem.deliveryOption === newItem.deliveryOption\n * return productMatch && variantMatch && deliveryMatch\n * }\n * ```\n */\n cartItemMatcher?: CartItemMatcher\n cartsCollectionOverride?: CollectionOverride\n}\n\nexport type InventoryConfig = {\n /**\n * Override the default field used to track inventory levels. Defaults to 'inventory'.\n */\n fieldName?: string\n}\n\nexport type CurrenciesConfig = {\n /**\n * Defaults to the first supported currency.\n *\n * @example 'USD'\n */\n defaultCurrency: string\n /**\n *\n */\n supportedCurrencies: Currency[]\n}\n\n/**\n * A function that validates a product or variant before a transaction is created or completed.\n * This should throw an error if validation fails as it will be caught by the function calling it.\n */\nexport type ProductsValidation = (args: {\n /**\n * The full currencies config, allowing you to check against supported currencies and their settings.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The ISO 4217 currency code being usen in this transaction.\n */\n currency?: string\n /**\n * The full product data.\n */\n product: TypedCollection['products']\n /**\n * Quantity to check the inventory amount against.\n */\n quantity: number\n /**\n * The full variant data, if a variant was selected for the product otherwise it will be undefined.\n */\n variant?: TypedCollection['variants']\n}) => Promise<void> | void\n\n/**\n * A map of collection slugs used by the Ecommerce plugin.\n * Provides an easy way to track the slugs of collections even when they are overridden.\n * Variant-related slugs are only present when variants are enabled.\n */\nexport type CollectionSlugMap = {\n addresses: string\n carts: string\n customers: string\n orders: string\n products: string\n transactions: string\n variantOptions?: string\n variants?: string\n variantTypes?: string\n}\n\n/**\n * Access control functions used throughout the Ecommerce plugin.\n * Provide atomic access functions that can be composed using or, and, conditional utilities.\n *\n * @example\n * ```ts\n * access: {\n * isAdmin: ({ req }) => checkRole(['admin'], req.user),\n * isAuthenticated: ({ req }) => !!req.user,\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user),\n * isDocumentOwner: ({ req }) => {\n * if (!req.user) return false\n * return { customer: { equals: req.user.id } }\n * },\n * adminOnlyFieldAccess: ({ req }) => checkRole(['admin'], req.user),\n * adminOrPublishedStatus: ({ req }) => {\n * if (checkRole(['admin'], req.user)) return true\n * return { _status: { equals: 'published' } }\n * },\n * }\n * ```\n */\nexport type AccessConfig = {\n /**\n * Limited to only admin users, specifically for Field level access control.\n */\n adminOnlyFieldAccess: FieldAccess\n /**\n * The document status is published or user is admin.\n */\n adminOrPublishedStatus: Access\n /**\n * @deprecated Will be removed in v4. Use `isCustomer` instead.\n * Limited to customers only, specifically for Field level access control.\n */\n customerOnlyFieldAccess?: FieldAccess\n /**\n * Checks if the user is an admin.\n * @returns true if admin, false otherwise\n */\n isAdmin: Access\n /**\n * Checks if the user is authenticated (any role).\n * @returns true if authenticated, false otherwise\n */\n isAuthenticated?: Access\n /**\n * Checks if the user is a customer (authenticated but not an admin).\n * Used internally to auto-assign customer ID when creating addresses.\n * @returns true if user is a non-admin customer, false otherwise\n *\n * @example\n * isCustomer: ({ req }) => req.user && !checkRole(['admin'], req.user)\n */\n isCustomer?: FieldAccess\n /**\n * Checks if the user owns the document being accessed.\n * Typically returns a Where query to filter by customer field.\n * @returns true for full access, false for no access, or Where query for conditional access\n */\n isDocumentOwner: Access\n /**\n * Entirely public access. Defaults to returning true.\n *\n * @example\n * publicAccess: () => true\n */\n publicAccess?: Access\n}\n\nexport type EcommercePluginConfig = {\n /**\n * Customise the access control for the plugin.\n *\n * @example\n * ```ts\n * ```\n */\n access: AccessConfig\n /**\n * Enable the addresses collection to allow customers, transactions and orders to have multiple addresses for shipping and billing. Accepts an override to customise the addresses collection.\n * Defaults to supporting a default set of countries.\n */\n addresses?: AddressesConfig | boolean\n /**\n * Configure the target collection used for carts.\n *\n * Defaults to true.\n */\n carts?: boolean | CartsConfig\n /**\n * Configure supported currencies and default settings.\n *\n * Defaults to supporting USD.\n */\n currencies?: CurrenciesConfig\n /**\n * Configure the target collection used for customers.\n *\n * @example\n * ```ts\n * customers: {\n * slug: 'users', // default\n * }\n *\n */\n customers: CustomersConfig\n /**\n * Enable tracking of inventory for products and variants. Accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Enables orders and accepts a config object to override the default collection settings.\n *\n * Defaults to true.\n */\n orders?: boolean | OrdersConfig\n /**\n * Enable tracking of payments. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n payments?: PaymentsConfig\n /**\n * Enables products and variants. Accepts a config object to override the product collection and each variant collection type.\n *\n * Defaults to true.\n */\n products?: boolean | ProductsConfig\n /**\n * Override the default slugs used across the plugin. This lets the plugin know which slugs to use for various internal operations and fields.\n */\n slugMap?: Partial<CollectionSlugMap>\n /**\n * Enable tracking of transactions. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n transactions?: boolean | TransactionsConfig\n}\n\nexport type SanitizedAccessConfig = Pick<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'> &\n Required<Omit<AccessConfig, 'customerOnlyFieldAccess' | 'isCustomer'>>\n\nexport type SanitizedEcommercePluginConfig = {\n access: SanitizedAccessConfig\n addresses: { addressFields: Field[] } & Omit<AddressesConfig, 'addressFields'>\n currencies: Required<CurrenciesConfig>\n inventory?: InventoryConfig\n payments: {\n paymentMethods: [] | PaymentAdapter[]\n }\n} & Omit<\n Required<EcommercePluginConfig>,\n 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'\n>\n\nexport type EcommerceCollections = TypedEcommerce['collections']\n\nexport type AddressesCollection = EcommerceCollections['addresses']\nexport type CartsCollection = EcommerceCollections['carts']\n\nexport type SyncLocalStorageConfig = {\n /**\n * Key to use for localStorage.\n * Defaults to 'cart'.\n */\n key?: string\n}\n\ntype APIProps = {\n /**\n * The route for the Payload API, defaults to `/api`.\n */\n apiRoute?: string\n /**\n * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.\n *\n * Defaults to `{ depth: 0 }`.\n */\n cartsFetchQuery?: {\n depth?: number\n populate?: PopulateType\n select?: SelectType\n }\n /**\n * The route for the Payload API, defaults to ``. Eg for a Payload app running on `http://localhost:3000`, the default serverURL would be `http://localhost:3000`.\n */\n serverURL?: string\n}\n\n/**\n * Memoized configuration object exposed via the useEcommerce hook.\n * Contains collection slugs and API settings for building URLs and queries.\n */\nexport type EcommerceConfig = {\n /**\n * The slug for the addresses collection.\n */\n addressesSlug: CollectionSlug\n /**\n * API configuration including the base route.\n */\n api: {\n /**\n * The base API route, e.g. '/api'.\n */\n apiRoute: string\n }\n /**\n * The slug for the carts collection.\n */\n cartsSlug: CollectionSlug\n /**\n * The slug for the customers collection.\n */\n customersSlug: CollectionSlug\n}\n\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: CollectionSlug\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: CollectionSlug\n children?: React.ReactNode\n /**\n * The configuration for currencies used in the ecommerce context.\n * This is used to handle currency formatting and calculations, defaults to USD.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The slug for the customers collection.\n *\n * Defaults to 'users'.\n */\n customersSlug?: CollectionSlug\n /**\n * Enable debug mode for the ecommerce context. This will log additional information to the console.\n * Defaults to false.\n */\n debug?: boolean\n /**\n * Whether to enable support for variants in the cart.\n * This allows adding products with specific variants to the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Supported payment methods for the ecommerce context.\n */\n paymentMethods?: PaymentAdapterClient[]\n /**\n * Whether to enable localStorage for cart persistence.\n * Defaults to true.\n */\n syncLocalStorage?: boolean | SyncLocalStorageConfig\n}\n\n/**\n * Type used internally to represent the cart item to be added.\n */\ntype CartItemArgument = {\n /**\n * The ID of the product to add to the cart. Always required.\n */\n product: DefaultDocumentIDType\n /**\n * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.\n */\n variant?: DefaultDocumentIDType\n}\n\nexport type EcommerceContextType<T extends EcommerceCollections = EcommerceCollections> = {\n /**\n * Add an item to the cart.\n */\n addItem: (item: CartItemArgument, quantity?: number) => Promise<void>\n /**\n * All current addresses for the current user.\n * This is used to manage shipping and billing addresses.\n */\n addresses?: T['addresses'][]\n /**\n * The current data of the cart.\n */\n cart?: T['addresses']\n /**\n * The ID of the current cart corresponding to the cart in the database or local storage.\n */\n cartID?: DefaultDocumentIDType\n /**\n * Clear the cart, removing all items.\n */\n clearCart: () => Promise<void>\n /**\n * Clears all ecommerce session data including cart, addresses, and user state.\n * Should be called when a user logs out.\n * This also clears localStorage cart data when syncLocalStorage is enabled.\n */\n clearSession: () => void\n /**\n * Memoized configuration object containing collection slugs and API settings.\n * Use this to build URLs and queries with the correct collection slugs.\n */\n config: EcommerceConfig\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n confirmOrder: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Create a new address by providing the data.\n */\n createAddress: (data: Partial<T['addresses']>) => Promise<void>\n /**\n * The configuration for the currencies used in the ecommerce context.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The currently selected currency used for the cart and price formatting automatically.\n */\n currency: Currency\n /**\n * Decrement an item in the cart by its array item ID.\n * If quantity reaches 0, the item will be removed from the cart.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n decrementItem: (item: string) => Promise<void>\n /**\n * Increment an item in the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n incrementItem: (item: string) => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n initiatePayment: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Indicates whether any cart operation is currently in progress.\n * Useful for disabling buttons and preventing race conditions.\n */\n isLoading: boolean\n /**\n * Merges items from a source cart into a target cart.\n * Useful for merging a guest cart into a user's existing cart after login.\n *\n * @param targetCartID - The ID of the cart to merge items into\n * @param sourceCartID - The ID of the cart to merge items from\n * @param sourceSecret - The secret for the source cart (required for guest carts)\n * @returns The merged cart\n */\n mergeCart: (\n targetCartID: DefaultDocumentIDType,\n sourceCartID: DefaultDocumentIDType,\n sourceSecret?: string,\n ) => Promise<T['carts'] | void>\n /**\n * Called after a successful login to handle cart state.\n * If a guest cart exists, it will be merged with the user's existing cart\n * or assigned to the user if they have no cart.\n * Cart secrets are cleared as authenticated users don't need them.\n *\n * @returns Promise that resolves when cart state is properly set up for the user.\n */\n onLogin: () => Promise<void>\n /**\n * Called during logout to clear all ecommerce session data.\n * Clears cart, addresses, user state, and localStorage cart data.\n * This is an alias for clearSession() but named for semantic clarity.\n */\n onLogout: () => void\n paymentMethods: PaymentAdapterClient[]\n /**\n * Refresh the cart.\n */\n refreshCart: () => Promise<void>\n /**\n * Remove an item from the cart by its array item ID.\n * @param item - The cart item ID (always a string, as array item IDs are strings in Payload)\n */\n removeItem: (item: string) => Promise<void>\n /**\n * The name of the currently selected payment method.\n * This is used to determine which payment method to use when initiating a payment.\n */\n selectedPaymentMethod?: null | string\n /**\n * Change the currency for the cart, it defaults to the configured currency.\n * This will update the currency used for pricing and calculations.\n */\n setCurrency: (currency: string) => void\n /**\n * Update an address by providing the data and the ID.\n */\n updateAddress: (addressID: DefaultDocumentIDType, data: Partial<T['addresses']>) => Promise<void>\n /**\n * The current authenticated user, or null if not logged in.\n */\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAy5BA,WAwIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceCell/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceCell/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAIzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAItE,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAA;CAC9C,GAAG,yBAAyB,CAAA;AAE7B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA0BrC,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useTranslation } from '@payloadcms/ui';
|
|
4
|
-
import {
|
|
4
|
+
import { formatPrice } from '../utilities.js';
|
|
5
5
|
export const PriceCell = (args)=>{
|
|
6
|
-
const { t } = useTranslation();
|
|
6
|
+
const { i18n, t } = useTranslation();
|
|
7
7
|
const { cellData, currenciesConfig, currency: currencyFromProps, rowData } = args;
|
|
8
8
|
const currency = currencyFromProps || currenciesConfig.supportedCurrencies[0];
|
|
9
9
|
if (!currency) {
|
|
@@ -24,14 +24,12 @@ export const PriceCell = (args)=>{
|
|
|
24
24
|
children: t('plugin-ecommerce:priceNotSet')
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
return /*#__PURE__*/
|
|
28
|
-
children:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
]
|
|
27
|
+
return /*#__PURE__*/ _jsx("span", {
|
|
28
|
+
children: formatPrice({
|
|
29
|
+
baseValue: cellData,
|
|
30
|
+
currency,
|
|
31
|
+
locale: i18n.language
|
|
32
|
+
})
|
|
35
33
|
});
|
|
36
34
|
};
|
|
37
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/PriceCell/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultCellComponentProps, TypedCollection } from 'payload'\n\nimport { useTranslation } from '@payloadcms/ui'\n\nimport type { CurrenciesConfig, Currency } from '../../types/index.js'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/PriceCell/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DefaultCellComponentProps, TypedCollection } from 'payload'\n\nimport { useTranslation } from '@payloadcms/ui'\n\nimport type { CurrenciesConfig, Currency } from '../../types/index.js'\n\nimport { formatPrice } from '../utilities.js'\n\ntype Props = {\n cellData?: number\n currenciesConfig: CurrenciesConfig\n currency?: Currency\n path: string\n rowData: Partial<TypedCollection['products']>\n} & DefaultCellComponentProps\n\nexport const PriceCell: React.FC<Props> = (args) => {\n const { i18n, t } = useTranslation()\n const { cellData, currenciesConfig, currency: currencyFromProps, rowData } = args\n\n const currency = currencyFromProps || currenciesConfig.supportedCurrencies[0]\n\n if (!currency) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:currencyNotSet')}</span>\n }\n\n if (\n (cellData == null || typeof cellData !== 'number') &&\n 'enableVariants' in rowData &&\n rowData.enableVariants\n ) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceSetInVariants')}</span>\n }\n\n if (cellData == null) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceNotSet')}</span>\n }\n\n return <span>{formatPrice({ baseValue: cellData, currency, locale: i18n.language })}</span>\n}\n"],"names":["useTranslation","formatPrice","PriceCell","args","i18n","t","cellData","currenciesConfig","currency","currencyFromProps","rowData","supportedCurrencies","span","enableVariants","baseValue","locale","language"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,WAAW,QAAQ,kBAAiB;AAU7C,OAAO,MAAMC,YAA6B,CAACC;IACzC,MAAM,EAAEC,IAAI,EAAEC,CAAC,EAAE,GAAGL;IACpB,MAAM,EAAEM,QAAQ,EAAEC,gBAAgB,EAAEC,UAAUC,iBAAiB,EAAEC,OAAO,EAAE,GAAGP;IAE7E,MAAMK,WAAWC,qBAAqBF,iBAAiBI,mBAAmB,CAAC,EAAE;IAE7E,IAAI,CAACH,UAAU;QACb,2DAA2D;QAC3D,qBAAO,KAACI;sBAAMP,EAAE;;IAClB;IAEA,IACE,AAACC,CAAAA,YAAY,QAAQ,OAAOA,aAAa,QAAO,KAChD,oBAAoBI,WACpBA,QAAQG,cAAc,EACtB;QACA,2DAA2D;QAC3D,qBAAO,KAACD;sBAAMP,EAAE;;IAClB;IAEA,IAAIC,YAAY,MAAM;QACpB,2DAA2D;QAC3D,qBAAO,KAACM;sBAAMP,EAAE;;IAClB;IAEA,qBAAO,KAACO;kBAAMX,YAAY;YAAEa,WAAWR;YAAUE;YAAUO,QAAQX,KAAKY,QAAQ;QAAC;;AACnF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceRowLabel/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,aAAa,CAAA;AAGpB,KAAK,KAAK,GAAG;IACX,gBAAgB,EAAE,gBAAgB,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceRowLabel/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,aAAa,CAAA;AAGpB,KAAK,KAAK,GAAG;IACX,gBAAgB,EAAE,gBAAgB,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAuCzC,CAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRowLabel } from '@payloadcms/ui';
|
|
3
|
+
import { useRowLabel, useTranslation } from '@payloadcms/ui';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import './index.css';
|
|
6
|
-
import {
|
|
6
|
+
import { formatPrice } from '../utilities.js';
|
|
7
7
|
export const PriceRowLabel = (props)=>{
|
|
8
8
|
const { currenciesConfig } = props;
|
|
9
9
|
const { defaultCurrency, supportedCurrencies } = currenciesConfig;
|
|
10
|
+
const { i18n } = useTranslation();
|
|
10
11
|
const { data } = useRowLabel();
|
|
11
12
|
const currency = useMemo(()=>{
|
|
12
13
|
if (data.currency) {
|
|
@@ -22,17 +23,19 @@ export const PriceRowLabel = (props)=>{
|
|
|
22
23
|
supportedCurrencies,
|
|
23
24
|
defaultCurrency
|
|
24
25
|
]);
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
baseValue: data.amount,
|
|
29
|
-
currency: currency
|
|
30
|
-
});
|
|
26
|
+
const formattedPrice = useMemo(()=>{
|
|
27
|
+
if (!currency) {
|
|
28
|
+
return '0';
|
|
31
29
|
}
|
|
32
|
-
return
|
|
30
|
+
return formatPrice({
|
|
31
|
+
baseValue: data.amount ?? 0,
|
|
32
|
+
currency,
|
|
33
|
+
locale: i18n.language
|
|
34
|
+
});
|
|
33
35
|
}, [
|
|
34
36
|
currency,
|
|
35
|
-
data.amount
|
|
37
|
+
data.amount,
|
|
38
|
+
i18n.language
|
|
36
39
|
]);
|
|
37
40
|
return /*#__PURE__*/ _jsxs("div", {
|
|
38
41
|
className: "priceRowLabel",
|
|
@@ -44,11 +47,8 @@ export const PriceRowLabel = (props)=>{
|
|
|
44
47
|
/*#__PURE__*/ _jsxs("div", {
|
|
45
48
|
className: "priceValue",
|
|
46
49
|
children: [
|
|
47
|
-
/*#__PURE__*/
|
|
48
|
-
children:
|
|
49
|
-
currency?.symbol,
|
|
50
|
-
amount
|
|
51
|
-
]
|
|
50
|
+
/*#__PURE__*/ _jsx("span", {
|
|
51
|
+
children: formattedPrice
|
|
52
52
|
}),
|
|
53
53
|
/*#__PURE__*/ _jsxs("span", {
|
|
54
54
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/PriceRowLabel/index.tsx"],"sourcesContent":["'use client'\n\nimport { useRowLabel } from '@payloadcms/ui'\nimport { useMemo } from 'react'\n\nimport type { CurrenciesConfig } from '../../types/index.js'\n\nimport './index.css'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/PriceRowLabel/index.tsx"],"sourcesContent":["'use client'\n\nimport { useRowLabel, useTranslation } from '@payloadcms/ui'\nimport { useMemo } from 'react'\n\nimport type { CurrenciesConfig } from '../../types/index.js'\n\nimport './index.css'\nimport { formatPrice } from '../utilities.js'\n\ntype Props = {\n currenciesConfig: CurrenciesConfig\n}\n\nexport const PriceRowLabel: React.FC<Props> = (props) => {\n const { currenciesConfig } = props\n const { defaultCurrency, supportedCurrencies } = currenciesConfig\n\n const { i18n } = useTranslation()\n const { data } = useRowLabel<{ amount: number; currency: string }>()\n\n const currency = useMemo(() => {\n if (data.currency) {\n return supportedCurrencies.find((c) => c.code === data.currency) ?? supportedCurrencies[0]\n }\n\n const fallbackCurrency = supportedCurrencies.find((c) => c.code === defaultCurrency)\n\n if (fallbackCurrency) {\n return fallbackCurrency\n }\n\n return supportedCurrencies[0]\n }, [data.currency, supportedCurrencies, defaultCurrency])\n\n const formattedPrice = useMemo(() => {\n if (!currency) {\n return '0'\n }\n\n return formatPrice({ baseValue: data.amount ?? 0, currency, locale: i18n.language })\n }, [currency, data.amount, i18n.language])\n\n return (\n <div className=\"priceRowLabel\">\n <div className=\"priceLabel\">Price:</div>\n\n <div className=\"priceValue\">\n <span>{formattedPrice}</span>\n <span>({data.currency})</span>\n </div>\n </div>\n )\n}\n"],"names":["useRowLabel","useTranslation","useMemo","formatPrice","PriceRowLabel","props","currenciesConfig","defaultCurrency","supportedCurrencies","i18n","data","currency","find","c","code","fallbackCurrency","formattedPrice","baseValue","amount","locale","language","div","className","span"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAEC,cAAc,QAAQ,iBAAgB;AAC5D,SAASC,OAAO,QAAQ,QAAO;AAI/B,OAAO,cAAa;AACpB,SAASC,WAAW,QAAQ,kBAAiB;AAM7C,OAAO,MAAMC,gBAAiC,CAACC;IAC7C,MAAM,EAAEC,gBAAgB,EAAE,GAAGD;IAC7B,MAAM,EAAEE,eAAe,EAAEC,mBAAmB,EAAE,GAAGF;IAEjD,MAAM,EAAEG,IAAI,EAAE,GAAGR;IACjB,MAAM,EAAES,IAAI,EAAE,GAAGV;IAEjB,MAAMW,WAAWT,QAAQ;QACvB,IAAIQ,KAAKC,QAAQ,EAAE;YACjB,OAAOH,oBAAoBI,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,KAAKC,QAAQ,KAAKH,mBAAmB,CAAC,EAAE;QAC5F;QAEA,MAAMO,mBAAmBP,oBAAoBI,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKP;QAEpE,IAAIQ,kBAAkB;YACpB,OAAOA;QACT;QAEA,OAAOP,mBAAmB,CAAC,EAAE;IAC/B,GAAG;QAACE,KAAKC,QAAQ;QAAEH;QAAqBD;KAAgB;IAExD,MAAMS,iBAAiBd,QAAQ;QAC7B,IAAI,CAACS,UAAU;YACb,OAAO;QACT;QAEA,OAAOR,YAAY;YAAEc,WAAWP,KAAKQ,MAAM,IAAI;YAAGP;YAAUQ,QAAQV,KAAKW,QAAQ;QAAC;IACpF,GAAG;QAACT;QAAUD,KAAKQ,MAAM;QAAET,KAAKW,QAAQ;KAAC;IAEzC,qBACE,MAACC;QAAIC,WAAU;;0BACb,KAACD;gBAAIC,WAAU;0BAAa;;0BAE5B,MAACD;gBAAIC,WAAU;;kCACb,KAACC;kCAAMP;;kCACP,MAACO;;4BAAK;4BAAEb,KAAKC,QAAQ;4BAAC;;;;;;;AAI9B,EAAC"}
|
package/dist/ui/utilities.d.ts
CHANGED
|
@@ -13,4 +13,15 @@ export declare const convertFromBaseValue: ({ baseValue, currency, }: {
|
|
|
13
13
|
baseValue: number;
|
|
14
14
|
currency: Currency;
|
|
15
15
|
}) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Format a base value as a locale-aware currency string using the Intl API.
|
|
18
|
+
*
|
|
19
|
+
* @example formatPrice({ baseValue: 2500, currency: USD }) // "$25.00"
|
|
20
|
+
* @example formatPrice({ baseValue: 2500, currency: EUR, locale: 'de' }) // "25,00 €"
|
|
21
|
+
*/
|
|
22
|
+
export declare const formatPrice: ({ baseValue, currency, locale, }: {
|
|
23
|
+
baseValue: number;
|
|
24
|
+
currency: Currency;
|
|
25
|
+
locale?: string;
|
|
26
|
+
}) => string;
|
|
16
27
|
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/ui/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,kBAAkB,gCAG5B;IACD,QAAQ,EAAE,QAAQ,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,KAAG,MAaH,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,6BAG9B;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAAA;CACnB,KAAG,MAUH,CAAA"}
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/ui/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,kBAAkB,gCAG5B;IACD,QAAQ,EAAE,QAAQ,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,KAAG,MAaH,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,6BAG9B;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAAA;CACnB,KAAG,MAUH,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,qCAIrB;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,KAAG,MAQH,CAAA"}
|
package/dist/ui/utilities.js
CHANGED
|
@@ -22,5 +22,19 @@
|
|
|
22
22
|
// Format with the correct number of decimal places
|
|
23
23
|
return decimalValue.toFixed(currency.decimals);
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Format a base value as a locale-aware currency string using the Intl API.
|
|
27
|
+
*
|
|
28
|
+
* @example formatPrice({ baseValue: 2500, currency: USD }) // "$25.00"
|
|
29
|
+
* @example formatPrice({ baseValue: 2500, currency: EUR, locale: 'de' }) // "25,00 €"
|
|
30
|
+
*/ export const formatPrice = ({ baseValue, currency, locale = 'en' })=>{
|
|
31
|
+
return new Intl.NumberFormat(locale, {
|
|
32
|
+
currency: currency.code,
|
|
33
|
+
currencyDisplay: currency.symbolDisplay ?? 'symbol',
|
|
34
|
+
maximumFractionDigits: currency.decimals,
|
|
35
|
+
minimumFractionDigits: currency.decimals,
|
|
36
|
+
style: 'currency'
|
|
37
|
+
}).format(baseValue / Math.pow(10, currency.decimals));
|
|
38
|
+
};
|
|
25
39
|
|
|
26
40
|
//# sourceMappingURL=utilities.js.map
|
package/dist/ui/utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ui/utilities.ts"],"sourcesContent":["import type { Currency } from '../types/index.js'\n\n/**\n * Convert display value with decimal point to base value (e.g., $25.00 to 2500)\n */\nexport const convertToBaseValue = ({\n currency,\n displayValue,\n}: {\n currency: Currency\n displayValue: string\n}): number => {\n if (!currency) {\n return parseFloat(displayValue)\n }\n\n // Remove currency symbol and any non-numeric characters except decimal\n const cleanValue = displayValue.replace(currency.symbol, '').replace(/[^0-9.]/g, '')\n\n // Parse the clean value to a float\n const floatValue = parseFloat(cleanValue || '0')\n\n // Convert to the base value (e.g., cents for USD)\n return Math.round(floatValue * Math.pow(10, currency.decimals))\n}\n\n/**\n * Convert base value to display value with decimal point (e.g., 2500 to $25.00)\n */\nexport const convertFromBaseValue = ({\n baseValue,\n currency,\n}: {\n baseValue: number\n currency: Currency\n}): string => {\n if (!currency) {\n return baseValue.toString()\n }\n\n // Convert from base value (e.g., cents) to decimal value (e.g., dollars)\n const decimalValue = baseValue / Math.pow(10, currency.decimals)\n\n // Format with the correct number of decimal places\n return decimalValue.toFixed(currency.decimals)\n}\n"],"names":["convertToBaseValue","currency","displayValue","parseFloat","cleanValue","replace","symbol","floatValue","Math","round","pow","decimals","convertFromBaseValue","baseValue","toString","decimalValue","toFixed"],"mappings":"AAEA;;CAEC,GACD,OAAO,MAAMA,qBAAqB,CAAC,EACjCC,QAAQ,EACRC,YAAY,EAIb;IACC,IAAI,CAACD,UAAU;QACb,OAAOE,WAAWD;IACpB;IAEA,uEAAuE;IACvE,MAAME,aAAaF,aAAaG,OAAO,CAACJ,SAASK,MAAM,EAAE,IAAID,OAAO,CAAC,YAAY;IAEjF,mCAAmC;IACnC,MAAME,aAAaJ,WAAWC,cAAc;IAE5C,kDAAkD;IAClD,OAAOI,KAAKC,KAAK,CAACF,aAAaC,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;AAC/D,EAAC;AAED;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,SAAS,EACTZ,QAAQ,EAIT;IACC,IAAI,CAACA,UAAU;QACb,OAAOY,UAAUC,QAAQ;IAC3B;IAEA,yEAAyE;IACzE,MAAMC,eAAeF,YAAYL,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;IAE/D,mDAAmD;IACnD,OAAOI,aAAaC,OAAO,CAACf,SAASU,QAAQ;AAC/C,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/ui/utilities.ts"],"sourcesContent":["import type { Currency } from '../types/index.js'\n\n/**\n * Convert display value with decimal point to base value (e.g., $25.00 to 2500)\n */\nexport const convertToBaseValue = ({\n currency,\n displayValue,\n}: {\n currency: Currency\n displayValue: string\n}): number => {\n if (!currency) {\n return parseFloat(displayValue)\n }\n\n // Remove currency symbol and any non-numeric characters except decimal\n const cleanValue = displayValue.replace(currency.symbol, '').replace(/[^0-9.]/g, '')\n\n // Parse the clean value to a float\n const floatValue = parseFloat(cleanValue || '0')\n\n // Convert to the base value (e.g., cents for USD)\n return Math.round(floatValue * Math.pow(10, currency.decimals))\n}\n\n/**\n * Convert base value to display value with decimal point (e.g., 2500 to $25.00)\n */\nexport const convertFromBaseValue = ({\n baseValue,\n currency,\n}: {\n baseValue: number\n currency: Currency\n}): string => {\n if (!currency) {\n return baseValue.toString()\n }\n\n // Convert from base value (e.g., cents) to decimal value (e.g., dollars)\n const decimalValue = baseValue / Math.pow(10, currency.decimals)\n\n // Format with the correct number of decimal places\n return decimalValue.toFixed(currency.decimals)\n}\n\n/**\n * Format a base value as a locale-aware currency string using the Intl API.\n *\n * @example formatPrice({ baseValue: 2500, currency: USD }) // \"$25.00\"\n * @example formatPrice({ baseValue: 2500, currency: EUR, locale: 'de' }) // \"25,00 €\"\n */\nexport const formatPrice = ({\n baseValue,\n currency,\n locale = 'en',\n}: {\n baseValue: number\n currency: Currency\n locale?: string\n}): string => {\n return new Intl.NumberFormat(locale, {\n currency: currency.code,\n currencyDisplay: currency.symbolDisplay ?? 'symbol',\n maximumFractionDigits: currency.decimals,\n minimumFractionDigits: currency.decimals,\n style: 'currency',\n }).format(baseValue / Math.pow(10, currency.decimals))\n}\n"],"names":["convertToBaseValue","currency","displayValue","parseFloat","cleanValue","replace","symbol","floatValue","Math","round","pow","decimals","convertFromBaseValue","baseValue","toString","decimalValue","toFixed","formatPrice","locale","Intl","NumberFormat","code","currencyDisplay","symbolDisplay","maximumFractionDigits","minimumFractionDigits","style","format"],"mappings":"AAEA;;CAEC,GACD,OAAO,MAAMA,qBAAqB,CAAC,EACjCC,QAAQ,EACRC,YAAY,EAIb;IACC,IAAI,CAACD,UAAU;QACb,OAAOE,WAAWD;IACpB;IAEA,uEAAuE;IACvE,MAAME,aAAaF,aAAaG,OAAO,CAACJ,SAASK,MAAM,EAAE,IAAID,OAAO,CAAC,YAAY;IAEjF,mCAAmC;IACnC,MAAME,aAAaJ,WAAWC,cAAc;IAE5C,kDAAkD;IAClD,OAAOI,KAAKC,KAAK,CAACF,aAAaC,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;AAC/D,EAAC;AAED;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,SAAS,EACTZ,QAAQ,EAIT;IACC,IAAI,CAACA,UAAU;QACb,OAAOY,UAAUC,QAAQ;IAC3B;IAEA,yEAAyE;IACzE,MAAMC,eAAeF,YAAYL,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;IAE/D,mDAAmD;IACnD,OAAOI,aAAaC,OAAO,CAACf,SAASU,QAAQ;AAC/C,EAAC;AAED;;;;;CAKC,GACD,OAAO,MAAMM,cAAc,CAAC,EAC1BJ,SAAS,EACTZ,QAAQ,EACRiB,SAAS,IAAI,EAKd;IACC,OAAO,IAAIC,KAAKC,YAAY,CAACF,QAAQ;QACnCjB,UAAUA,SAASoB,IAAI;QACvBC,iBAAiBrB,SAASsB,aAAa,IAAI;QAC3CC,uBAAuBvB,SAASU,QAAQ;QACxCc,uBAAuBxB,SAASU,QAAQ;QACxCe,OAAO;IACT,GAAGC,MAAM,CAACd,YAAYL,KAAKE,GAAG,CAAC,IAAIT,SAASU,QAAQ;AACtD,EAAC"}
|
|
@@ -345,41 +345,6 @@ describe('sanitizePluginConfig', ()=>{
|
|
|
345
345
|
mockAdapter
|
|
346
346
|
]);
|
|
347
347
|
});
|
|
348
|
-
it('should preserve hooks when provided', ()=>{
|
|
349
|
-
const beforeInitiateHook = vitest.fn();
|
|
350
|
-
const afterConfirmHook = vitest.fn();
|
|
351
|
-
const config = {
|
|
352
|
-
...minimalConfig,
|
|
353
|
-
payments: {
|
|
354
|
-
hooks: {
|
|
355
|
-
afterConfirmOrder: [
|
|
356
|
-
afterConfirmHook
|
|
357
|
-
],
|
|
358
|
-
beforeInitiatePayment: [
|
|
359
|
-
beforeInitiateHook
|
|
360
|
-
]
|
|
361
|
-
},
|
|
362
|
-
paymentMethods: []
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
const result = sanitizePluginConfig({
|
|
366
|
-
pluginConfig: config
|
|
367
|
-
});
|
|
368
|
-
expect(result.payments.hooks).toEqual({
|
|
369
|
-
afterConfirmOrder: [
|
|
370
|
-
afterConfirmHook
|
|
371
|
-
],
|
|
372
|
-
beforeInitiatePayment: [
|
|
373
|
-
beforeInitiateHook
|
|
374
|
-
]
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
it('should default hooks to undefined when not provided', ()=>{
|
|
378
|
-
const result = sanitizePluginConfig({
|
|
379
|
-
pluginConfig: minimalConfig
|
|
380
|
-
});
|
|
381
|
-
expect(result.payments.hooks).toBeUndefined();
|
|
382
|
-
});
|
|
383
348
|
});
|
|
384
349
|
describe('products', ()=>{
|
|
385
350
|
it('should default variants to true when products is object and variants is undefined', ()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/sanitizePluginConfig.spec.ts"],"sourcesContent":["import { describe, it, expect, vitest } from 'vitest'\nimport type { EcommercePluginConfig } from '../types/index.js'\n\nimport { EUR, USD } from '../currencies/index.js'\nimport { sanitizePluginConfig } from './sanitizePluginConfig'\n\ndescribe('sanitizePluginConfig', () => {\n const mockAccessConfig = {\n adminOnlyFieldAccess: vitest.fn(),\n adminOrPublishedStatus: vitest.fn(),\n customerOnlyFieldAccess: vitest.fn(),\n isAdmin: vitest.fn(),\n isAuthenticated: vitest.fn(),\n isDocumentOwner: vitest.fn(),\n }\n\n const minimalConfig: EcommercePluginConfig = {\n access: mockAccessConfig,\n customers: {\n slug: 'users',\n },\n }\n\n describe('customers', () => {\n it('should default customers slug to \"users\" when undefined', () => {\n const config: EcommercePluginConfig = {\n access: mockAccessConfig,\n customers: undefined as any,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.customers).toEqual({\n slug: 'users',\n })\n })\n\n it('should preserve custom customers slug', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n customers: {\n slug: 'custom-users',\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.customers.slug).toBe('custom-users')\n })\n })\n\n describe('addresses', () => {\n it('should create default addresses config when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.addresses).toBeDefined()\n expect(result.addresses.addressFields).toBeDefined()\n expect(Array.isArray(result.addresses.addressFields)).toBe(true)\n expect(result.addresses.addressFields.length).toBeGreaterThan(0)\n })\n\n it('should create default addresses config when set to true', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n addresses: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.addresses).toBeDefined()\n expect(result.addresses.addressFields).toBeDefined()\n expect(Array.isArray(result.addresses.addressFields)).toBe(true)\n })\n\n it('should use custom addressFields function', () => {\n const customField = {\n name: 'customField',\n type: 'text' as const,\n }\n\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n addresses: {\n addressFields: ({ defaultFields }) => [...defaultFields, customField],\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.addresses.addressFields).toBeDefined()\n const lastField = result.addresses.addressFields[result.addresses.addressFields.length - 1]\n expect(lastField).toEqual(customField)\n })\n\n it('should preserve other address config properties', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n addresses: {\n addressFields: ({ defaultFields }) => defaultFields,\n supportedCountries: [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ],\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.addresses.supportedCountries).toEqual([\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ])\n })\n })\n\n describe('currencies', () => {\n it('should default to USD when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.currencies).toEqual({\n defaultCurrency: 'USD',\n supportedCurrencies: [USD],\n })\n })\n\n it('should preserve custom currencies config', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n currencies: {\n defaultCurrency: 'EUR',\n supportedCurrencies: [USD, EUR],\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.currencies).toEqual({\n defaultCurrency: 'EUR',\n supportedCurrencies: [USD, EUR],\n })\n })\n })\n\n describe('inventory', () => {\n it('should default inventory config when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.inventory).toEqual({\n fieldName: 'inventory',\n })\n })\n\n it('should default inventory config when set to true', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n inventory: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.inventory).toEqual({\n fieldName: 'inventory',\n })\n })\n\n it('should preserve custom inventory config', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n inventory: {\n fieldName: 'stock',\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.inventory).toEqual({\n fieldName: 'stock',\n })\n })\n\n it('should allow disabling inventory with false', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n inventory: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.inventory).toBe(false)\n })\n })\n\n describe('carts', () => {\n it('should default carts to object with allowGuestCarts true when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.carts).toEqual({\n allowGuestCarts: true,\n })\n })\n\n it('should convert carts true to object with allowGuestCarts true', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toEqual({\n allowGuestCarts: true,\n })\n })\n\n it('should preserve carts false', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toBe(false)\n })\n\n it('should default allowGuestCarts to true when carts is object without it', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: {} as any,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toEqual({\n allowGuestCarts: true,\n })\n })\n\n it('should preserve explicit allowGuestCarts false', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: {\n allowGuestCarts: false,\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toEqual({\n allowGuestCarts: false,\n })\n })\n\n it('should preserve other carts config properties', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: {\n allowGuestCarts: false,\n cartsCollectionOverride: vitest.fn() as any,\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toHaveProperty('allowGuestCarts', false)\n expect(result.carts).toHaveProperty('cartsCollectionOverride')\n })\n })\n\n describe('orders', () => {\n it('should default orders to true when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.orders).toBe(true)\n })\n\n it('should preserve orders config', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n orders: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.orders).toBe(false)\n })\n })\n\n describe('transactions', () => {\n it('should default transactions to true when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.transactions).toBe(true)\n })\n\n it('should preserve transactions config', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n transactions: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.transactions).toBe(false)\n })\n })\n\n describe('payments', () => {\n it('should default payments to empty array when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.payments).toEqual({\n paymentMethods: [],\n })\n })\n\n it('should default paymentMethods to empty array when not provided', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n payments: {} as any,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.payments.paymentMethods).toEqual([])\n })\n\n it('should preserve payment methods', () => {\n const mockAdapter = {\n name: 'stripe',\n label: 'Stripe',\n } as any\n\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n payments: {\n paymentMethods: [mockAdapter],\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.payments.paymentMethods).toEqual([mockAdapter])\n })\n\n it('should preserve hooks when provided', () => {\n const beforeInitiateHook = vitest.fn()\n const afterConfirmHook = vitest.fn()\n\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n payments: {\n hooks: {\n afterConfirmOrder: [afterConfirmHook],\n beforeInitiatePayment: [beforeInitiateHook],\n },\n paymentMethods: [],\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.payments.hooks).toEqual({\n afterConfirmOrder: [afterConfirmHook],\n beforeInitiatePayment: [beforeInitiateHook],\n })\n })\n\n it('should default hooks to undefined when not provided', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.payments.hooks).toBeUndefined()\n })\n })\n\n describe('products', () => {\n it('should default variants to true when products is object and variants is undefined', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n products: {},\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.products).toEqual({\n variants: true,\n })\n })\n\n it('should preserve variants config when provided', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n products: {\n variants: false,\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.products).toEqual({\n variants: false,\n })\n })\n\n it('should not modify products when set to true', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n products: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.products).toBe(true)\n })\n\n it('should not modify products when set to false', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n products: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.products).toBe(false)\n })\n })\n\n describe('access', () => {\n it('should provide default isAuthenticated function', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.access.isAuthenticated).toBeDefined()\n expect(typeof result.access.isAuthenticated).toBe('function')\n })\n\n it('should provide default publicAccess function', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.access.publicAccess).toBeDefined()\n expect(typeof result.access.publicAccess).toBe('function')\n })\n\n it('should allow user-provided access functions to override defaults', () => {\n const customIsAuthenticated = vitest.fn()\n const customPublicAccess = vitest.fn()\n\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n access: {\n ...mockAccessConfig,\n isAuthenticated: customIsAuthenticated,\n publicAccess: customPublicAccess,\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.access.isAuthenticated).toBe(customIsAuthenticated)\n expect(result.access.publicAccess).toBe(customPublicAccess)\n })\n\n it('should preserve all user-provided access functions', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.access.adminOnlyFieldAccess).toBe(mockAccessConfig.adminOnlyFieldAccess)\n expect(result.access.adminOrPublishedStatus).toBe(mockAccessConfig.adminOrPublishedStatus)\n expect(result.access.customerOnlyFieldAccess).toBe(mockAccessConfig.customerOnlyFieldAccess)\n expect(result.access.isAdmin).toBe(mockAccessConfig.isAdmin)\n expect(result.access.isDocumentOwner).toBe(mockAccessConfig.isDocumentOwner)\n })\n\n it('default publicAccess should always return true', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n // @ts-expect-error - ignoring for test\n expect(result.access.publicAccess()).toBe(true)\n })\n\n it('default isAuthenticated should be provided', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.access.isAuthenticated).toBeDefined()\n expect(typeof result.access.isAuthenticated).toBe('function')\n })\n })\n\n describe('complete config', () => {\n it('should handle a fully configured plugin', () => {\n const fullConfig: EcommercePluginConfig = {\n access: mockAccessConfig,\n addresses: {\n addressFields: ({ defaultFields }) => defaultFields,\n supportedCountries: [{ label: 'US', value: 'US' }],\n },\n carts: {\n allowGuestCarts: true,\n },\n currencies: {\n defaultCurrency: 'EUR',\n supportedCurrencies: [USD, EUR],\n },\n customers: {\n slug: 'customers',\n },\n inventory: {\n fieldName: 'stock',\n },\n orders: true,\n payments: {\n paymentMethods: [],\n },\n products: {\n variants: true,\n },\n slugMap: {\n products: 'items',\n },\n transactions: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: fullConfig })\n\n expect(result.customers.slug).toBe('customers')\n expect(result.currencies.defaultCurrency).toBe('EUR')\n expect(result.inventory).toEqual({ fieldName: 'stock' })\n expect(result.carts).toHaveProperty('allowGuestCarts', true)\n expect(result.orders).toBe(true)\n expect(result.transactions).toBe(true)\n expect(result.products).toEqual({ variants: true })\n expect(result.slugMap).toEqual({ products: 'items' })\n })\n })\n})\n"],"names":["describe","it","expect","vitest","EUR","USD","sanitizePluginConfig","mockAccessConfig","adminOnlyFieldAccess","fn","adminOrPublishedStatus","customerOnlyFieldAccess","isAdmin","isAuthenticated","isDocumentOwner","minimalConfig","access","customers","slug","config","undefined","result","pluginConfig","toEqual","toBe","addresses","toBeDefined","addressFields","Array","isArray","length","toBeGreaterThan","customField","name","type","defaultFields","lastField","supportedCountries","label","value","currencies","defaultCurrency","supportedCurrencies","inventory","fieldName","carts","allowGuestCarts","cartsCollectionOverride","toHaveProperty","orders","transactions","payments","paymentMethods","mockAdapter","beforeInitiateHook","afterConfirmHook","hooks","afterConfirmOrder","beforeInitiatePayment","toBeUndefined","products","variants","publicAccess","customIsAuthenticated","customPublicAccess","fullConfig","slugMap"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,MAAM,QAAQ,SAAQ;AAGrD,SAASC,GAAG,EAAEC,GAAG,QAAQ,yBAAwB;AACjD,SAASC,oBAAoB,QAAQ,yBAAwB;AAE7DN,SAAS,wBAAwB;IAC/B,MAAMO,mBAAmB;QACvBC,sBAAsBL,OAAOM,EAAE;QAC/BC,wBAAwBP,OAAOM,EAAE;QACjCE,yBAAyBR,OAAOM,EAAE;QAClCG,SAAST,OAAOM,EAAE;QAClBI,iBAAiBV,OAAOM,EAAE;QAC1BK,iBAAiBX,OAAOM,EAAE;IAC5B;IAEA,MAAMM,gBAAuC;QAC3CC,QAAQT;QACRU,WAAW;YACTC,MAAM;QACR;IACF;IAEAlB,SAAS,aAAa;QACpBC,GAAG,2DAA2D;YAC5D,MAAMkB,SAAgC;gBACpCH,QAAQT;gBACRU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AAU;gBACZ;gBACAK,SAAS;oBACPN,UAAU;gBACZ;gBACAV,cAAc;YAChB;YAEA,MAAM7B,SAASf,qBAAqB;gBAAEgB,cAAc2C;YAAW;YAE/D/D,OAAOmB,OAAOJ,SAAS,CAACC,IAAI,EAAEM,IAAI,CAAC;YACnCtB,OAAOmB,OAAOmB,UAAU,CAACC,eAAe,EAAEjB,IAAI,CAAC;YAC/CtB,OAAOmB,OAAOsB,SAAS,EAAEpB,OAAO,CAAC;gBAAEqB,WAAW;YAAQ;YACtD1C,OAAOmB,OAAOwB,KAAK,EAAEG,cAAc,CAAC,mBAAmB;YACvD9C,OAAOmB,OAAO4B,MAAM,EAAEzB,IAAI,CAAC;YAC3BtB,OAAOmB,OAAO6B,YAAY,EAAE1B,IAAI,CAAC;YACjCtB,OAAOmB,OAAOuC,QAAQ,EAAErC,OAAO,CAAC;gBAAEsC,UAAU;YAAK;YACjD3D,OAAOmB,OAAO6C,OAAO,EAAE3C,OAAO,CAAC;gBAAEqC,UAAU;YAAQ;QACrD;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/sanitizePluginConfig.spec.ts"],"sourcesContent":["import { describe, it, expect, vitest } from 'vitest'\nimport type { EcommercePluginConfig } from '../types/index.js'\n\nimport { EUR, USD } from '../currencies/index.js'\nimport { sanitizePluginConfig } from './sanitizePluginConfig'\n\ndescribe('sanitizePluginConfig', () => {\n const mockAccessConfig = {\n adminOnlyFieldAccess: vitest.fn(),\n adminOrPublishedStatus: vitest.fn(),\n customerOnlyFieldAccess: vitest.fn(),\n isAdmin: vitest.fn(),\n isAuthenticated: vitest.fn(),\n isDocumentOwner: vitest.fn(),\n }\n\n const minimalConfig: EcommercePluginConfig = {\n access: mockAccessConfig,\n customers: {\n slug: 'users',\n },\n }\n\n describe('customers', () => {\n it('should default customers slug to \"users\" when undefined', () => {\n const config: EcommercePluginConfig = {\n access: mockAccessConfig,\n customers: undefined as any,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.customers).toEqual({\n slug: 'users',\n })\n })\n\n it('should preserve custom customers slug', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n customers: {\n slug: 'custom-users',\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.customers.slug).toBe('custom-users')\n })\n })\n\n describe('addresses', () => {\n it('should create default addresses config when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.addresses).toBeDefined()\n expect(result.addresses.addressFields).toBeDefined()\n expect(Array.isArray(result.addresses.addressFields)).toBe(true)\n expect(result.addresses.addressFields.length).toBeGreaterThan(0)\n })\n\n it('should create default addresses config when set to true', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n addresses: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.addresses).toBeDefined()\n expect(result.addresses.addressFields).toBeDefined()\n expect(Array.isArray(result.addresses.addressFields)).toBe(true)\n })\n\n it('should use custom addressFields function', () => {\n const customField = {\n name: 'customField',\n type: 'text' as const,\n }\n\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n addresses: {\n addressFields: ({ defaultFields }) => [...defaultFields, customField],\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.addresses.addressFields).toBeDefined()\n const lastField = result.addresses.addressFields[result.addresses.addressFields.length - 1]\n expect(lastField).toEqual(customField)\n })\n\n it('should preserve other address config properties', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n addresses: {\n addressFields: ({ defaultFields }) => defaultFields,\n supportedCountries: [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ],\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.addresses.supportedCountries).toEqual([\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ])\n })\n })\n\n describe('currencies', () => {\n it('should default to USD when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.currencies).toEqual({\n defaultCurrency: 'USD',\n supportedCurrencies: [USD],\n })\n })\n\n it('should preserve custom currencies config', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n currencies: {\n defaultCurrency: 'EUR',\n supportedCurrencies: [USD, EUR],\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.currencies).toEqual({\n defaultCurrency: 'EUR',\n supportedCurrencies: [USD, EUR],\n })\n })\n })\n\n describe('inventory', () => {\n it('should default inventory config when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.inventory).toEqual({\n fieldName: 'inventory',\n })\n })\n\n it('should default inventory config when set to true', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n inventory: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.inventory).toEqual({\n fieldName: 'inventory',\n })\n })\n\n it('should preserve custom inventory config', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n inventory: {\n fieldName: 'stock',\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.inventory).toEqual({\n fieldName: 'stock',\n })\n })\n\n it('should allow disabling inventory with false', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n inventory: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.inventory).toBe(false)\n })\n })\n\n describe('carts', () => {\n it('should default carts to object with allowGuestCarts true when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.carts).toEqual({\n allowGuestCarts: true,\n })\n })\n\n it('should convert carts true to object with allowGuestCarts true', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toEqual({\n allowGuestCarts: true,\n })\n })\n\n it('should preserve carts false', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toBe(false)\n })\n\n it('should default allowGuestCarts to true when carts is object without it', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: {} as any,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toEqual({\n allowGuestCarts: true,\n })\n })\n\n it('should preserve explicit allowGuestCarts false', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: {\n allowGuestCarts: false,\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toEqual({\n allowGuestCarts: false,\n })\n })\n\n it('should preserve other carts config properties', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n carts: {\n allowGuestCarts: false,\n cartsCollectionOverride: vitest.fn() as any,\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.carts).toHaveProperty('allowGuestCarts', false)\n expect(result.carts).toHaveProperty('cartsCollectionOverride')\n })\n })\n\n describe('orders', () => {\n it('should default orders to true when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.orders).toBe(true)\n })\n\n it('should preserve orders config', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n orders: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.orders).toBe(false)\n })\n })\n\n describe('transactions', () => {\n it('should default transactions to true when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.transactions).toBe(true)\n })\n\n it('should preserve transactions config', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n transactions: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.transactions).toBe(false)\n })\n })\n\n describe('payments', () => {\n it('should default payments to empty array when undefined', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.payments).toEqual({\n paymentMethods: [],\n })\n })\n\n it('should default paymentMethods to empty array when not provided', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n payments: {} as any,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.payments.paymentMethods).toEqual([])\n })\n\n it('should preserve payment methods', () => {\n const mockAdapter = {\n name: 'stripe',\n label: 'Stripe',\n } as any\n\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n payments: {\n paymentMethods: [mockAdapter],\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.payments.paymentMethods).toEqual([mockAdapter])\n })\n })\n\n describe('products', () => {\n it('should default variants to true when products is object and variants is undefined', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n products: {},\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.products).toEqual({\n variants: true,\n })\n })\n\n it('should preserve variants config when provided', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n products: {\n variants: false,\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.products).toEqual({\n variants: false,\n })\n })\n\n it('should not modify products when set to true', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n products: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.products).toBe(true)\n })\n\n it('should not modify products when set to false', () => {\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n products: false,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.products).toBe(false)\n })\n })\n\n describe('access', () => {\n it('should provide default isAuthenticated function', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.access.isAuthenticated).toBeDefined()\n expect(typeof result.access.isAuthenticated).toBe('function')\n })\n\n it('should provide default publicAccess function', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.access.publicAccess).toBeDefined()\n expect(typeof result.access.publicAccess).toBe('function')\n })\n\n it('should allow user-provided access functions to override defaults', () => {\n const customIsAuthenticated = vitest.fn()\n const customPublicAccess = vitest.fn()\n\n const config: EcommercePluginConfig = {\n ...minimalConfig,\n access: {\n ...mockAccessConfig,\n isAuthenticated: customIsAuthenticated,\n publicAccess: customPublicAccess,\n },\n }\n\n const result = sanitizePluginConfig({ pluginConfig: config })\n\n expect(result.access.isAuthenticated).toBe(customIsAuthenticated)\n expect(result.access.publicAccess).toBe(customPublicAccess)\n })\n\n it('should preserve all user-provided access functions', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.access.adminOnlyFieldAccess).toBe(mockAccessConfig.adminOnlyFieldAccess)\n expect(result.access.adminOrPublishedStatus).toBe(mockAccessConfig.adminOrPublishedStatus)\n expect(result.access.customerOnlyFieldAccess).toBe(mockAccessConfig.customerOnlyFieldAccess)\n expect(result.access.isAdmin).toBe(mockAccessConfig.isAdmin)\n expect(result.access.isDocumentOwner).toBe(mockAccessConfig.isDocumentOwner)\n })\n\n it('default publicAccess should always return true', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n // @ts-expect-error - ignoring for test\n expect(result.access.publicAccess()).toBe(true)\n })\n\n it('default isAuthenticated should be provided', () => {\n const result = sanitizePluginConfig({ pluginConfig: minimalConfig })\n\n expect(result.access.isAuthenticated).toBeDefined()\n expect(typeof result.access.isAuthenticated).toBe('function')\n })\n })\n\n describe('complete config', () => {\n it('should handle a fully configured plugin', () => {\n const fullConfig: EcommercePluginConfig = {\n access: mockAccessConfig,\n addresses: {\n addressFields: ({ defaultFields }) => defaultFields,\n supportedCountries: [{ label: 'US', value: 'US' }],\n },\n carts: {\n allowGuestCarts: true,\n },\n currencies: {\n defaultCurrency: 'EUR',\n supportedCurrencies: [USD, EUR],\n },\n customers: {\n slug: 'customers',\n },\n inventory: {\n fieldName: 'stock',\n },\n orders: true,\n payments: {\n paymentMethods: [],\n },\n products: {\n variants: true,\n },\n slugMap: {\n products: 'items',\n },\n transactions: true,\n }\n\n const result = sanitizePluginConfig({ pluginConfig: fullConfig })\n\n expect(result.customers.slug).toBe('customers')\n expect(result.currencies.defaultCurrency).toBe('EUR')\n expect(result.inventory).toEqual({ fieldName: 'stock' })\n expect(result.carts).toHaveProperty('allowGuestCarts', true)\n expect(result.orders).toBe(true)\n expect(result.transactions).toBe(true)\n expect(result.products).toEqual({ variants: true })\n expect(result.slugMap).toEqual({ products: 'items' })\n })\n })\n})\n"],"names":["describe","it","expect","vitest","EUR","USD","sanitizePluginConfig","mockAccessConfig","adminOnlyFieldAccess","fn","adminOrPublishedStatus","customerOnlyFieldAccess","isAdmin","isAuthenticated","isDocumentOwner","minimalConfig","access","customers","slug","config","undefined","result","pluginConfig","toEqual","toBe","addresses","toBeDefined","addressFields","Array","isArray","length","toBeGreaterThan","customField","name","type","defaultFields","lastField","supportedCountries","label","value","currencies","defaultCurrency","supportedCurrencies","inventory","fieldName","carts","allowGuestCarts","cartsCollectionOverride","toHaveProperty","orders","transactions","payments","paymentMethods","mockAdapter","products","variants","publicAccess","customIsAuthenticated","customPublicAccess","fullConfig","slugMap"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,MAAM,QAAQ,SAAQ;AAGrD,SAASC,GAAG,EAAEC,GAAG,QAAQ,yBAAwB;AACjD,SAASC,oBAAoB,QAAQ,yBAAwB;AAE7DN,SAAS,wBAAwB;IAC/B,MAAMO,mBAAmB;QACvBC,sBAAsBL,OAAOM,EAAE;QAC/BC,wBAAwBP,OAAOM,EAAE;QACjCE,yBAAyBR,OAAOM,EAAE;QAClCG,SAAST,OAAOM,EAAE;QAClBI,iBAAiBV,OAAOM,EAAE;QAC1BK,iBAAiBX,OAAOM,EAAE;IAC5B;IAEA,MAAMM,gBAAuC;QAC3CC,QAAQT;QACRU,WAAW;YACTC,MAAM;QACR;IACF;IAEAlB,SAAS,aAAa;QACpBC,GAAG,2DAA2D;YAC5D,MAAMkB,SAAgC;gBACpCH,QAAQT;gBACRU,WAAWG;YACb;YAEA,MAAMC,SAASf,qBAAqB;gBAAEgB,cAAcH;YAAO;YAE3DjB,OAAOmB,OAAOJ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|
{
|
|
2
2
|
"name": "@payloadcms/plugin-ecommerce",
|
|
3
|
-
"version": "3.84.
|
|
3
|
+
"version": "3.84.1",
|
|
4
4
|
"description": "Ecommerce plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
],
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"qs-esm": "8.0.1",
|
|
77
|
-
"@payloadcms/
|
|
78
|
-
"@payloadcms/
|
|
77
|
+
"@payloadcms/ui": "3.84.1",
|
|
78
|
+
"@payloadcms/translations": "3.84.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@types/json-schema": "7.0.15",
|
|
@@ -83,14 +83,14 @@
|
|
|
83
83
|
"@types/react-dom": "19.2.3",
|
|
84
84
|
"stripe": "18.3.0",
|
|
85
85
|
"@payloadcms/eslint-config": "3.28.0",
|
|
86
|
-
"@payloadcms/next": "3.84.
|
|
87
|
-
"@payloadcms/translations": "3.84.
|
|
88
|
-
"payload": "3.84.
|
|
86
|
+
"@payloadcms/next": "3.84.1",
|
|
87
|
+
"@payloadcms/translations": "3.84.1",
|
|
88
|
+
"payload": "3.84.1"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
92
92
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
93
|
-
"payload": "3.84.
|
|
93
|
+
"payload": "3.84.1"
|
|
94
94
|
},
|
|
95
95
|
"publishConfig": {
|
|
96
96
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { GroupField } from 'payload';
|
|
2
|
-
import type { CurrenciesConfig } from '../types/index.js';
|
|
3
|
-
type Props = {
|
|
4
|
-
currenciesConfig: CurrenciesConfig;
|
|
5
|
-
overrides?: Partial<GroupField>;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* A read-only group field that records the computed payment summary for a
|
|
9
|
-
* transaction or order — total, currency, and the ordered list of lines
|
|
10
|
-
* (subtotal, tax, shipping, discount, etc.) produced by the payment hook pipeline.
|
|
11
|
-
*/
|
|
12
|
-
export declare const summaryField: (props: Props) => GroupField;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=summaryField.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summaryField.d.ts","sourceRoot":"","sources":["../../src/fields/summaryField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,UAAU,EAAE,MAAM,SAAS,CAAA;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAKzD,KAAK,KAAK,GAAG;IACX,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;CAChC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,UAoD5C,CAAA"}
|