@payloadcms/storage-r2 0.0.1-beta.0 → 3.50.0-internal.ca62628

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/handleDelete.d.ts +8 -0
  2. package/dist/handleDelete.d.ts.map +1 -0
  3. package/dist/handleDelete.js +8 -0
  4. package/dist/handleDelete.js.map +1 -0
  5. package/dist/handleUpload.d.ts +11 -0
  6. package/dist/handleUpload.d.ts.map +1 -0
  7. package/dist/handleUpload.js +13 -0
  8. package/dist/handleUpload.js.map +1 -0
  9. package/dist/index.d.ts +15 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +59 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/staticHandler.d.ts +11 -0
  14. package/dist/staticHandler.d.ts.map +1 -0
  15. package/dist/staticHandler.js +29 -0
  16. package/dist/staticHandler.js.map +1 -0
  17. package/dist/types.d.ts +16 -0
  18. package/dist/types.d.ts.map +1 -0
  19. package/dist/types.js +3 -0
  20. package/dist/types.js.map +1 -0
  21. package/package.json +57 -1
  22. package/.prettierignore +0 -12
  23. package/.swcrc +0 -24
  24. package/README.md +0 -3
  25. package/eslint.config.js +0 -18
  26. package/src/addresses/addressesCollection.ts +0 -76
  27. package/src/addresses/defaultAddressFields.ts +0 -83
  28. package/src/addresses/defaultCountries.ts +0 -50
  29. package/src/carts/beforeChange.ts +0 -51
  30. package/src/carts/cartsCollection.ts +0 -146
  31. package/src/currencies/index.ts +0 -29
  32. package/src/endpoints/confirmOrder.ts +0 -312
  33. package/src/endpoints/initiatePayment.ts +0 -322
  34. package/src/exports/addresses.ts +0 -2
  35. package/src/exports/currencies.ts +0 -1
  36. package/src/exports/fields.ts +0 -5
  37. package/src/exports/orders.ts +0 -1
  38. package/src/exports/payments/stripe.ts +0 -1
  39. package/src/exports/plugin.ts +0 -1
  40. package/src/exports/products.ts +0 -1
  41. package/src/exports/react.ts +0 -8
  42. package/src/exports/transactions.ts +0 -1
  43. package/src/exports/translations.ts +0 -1
  44. package/src/exports/types.ts +0 -7
  45. package/src/exports/ui.ts +0 -3
  46. package/src/exports/variants.ts +0 -5
  47. package/src/fields/amountField.ts +0 -43
  48. package/src/fields/cartItemsField.ts +0 -84
  49. package/src/fields/currencyField.ts +0 -39
  50. package/src/fields/inventoryField.ts +0 -22
  51. package/src/fields/pricesField.ts +0 -65
  52. package/src/fields/statusField.ts +0 -57
  53. package/src/fields/variantsFields.ts +0 -56
  54. package/src/index.ts +0 -275
  55. package/src/orders/ordersCollection.ts +0 -157
  56. package/src/payments/adapters/stripe/confirmOrder.ts +0 -123
  57. package/src/payments/adapters/stripe/endpoints/webhooks.ts +0 -69
  58. package/src/payments/adapters/stripe/index.ts +0 -135
  59. package/src/payments/adapters/stripe/initiatePayment.ts +0 -131
  60. package/src/products/productsCollection.ts +0 -78
  61. package/src/react/provider/index.tsx +0 -893
  62. package/src/react/provider/types.ts +0 -184
  63. package/src/react/provider/utilities.ts +0 -22
  64. package/src/transactions/transactionsCollection.ts +0 -166
  65. package/src/translations/en.ts +0 -64
  66. package/src/translations/index.ts +0 -11
  67. package/src/translations/translation-schema.json +0 -35
  68. package/src/types.ts +0 -403
  69. package/src/ui/PriceInput/FormattedInput.tsx +0 -134
  70. package/src/ui/PriceInput/index.scss +0 -28
  71. package/src/ui/PriceInput/index.tsx +0 -43
  72. package/src/ui/PriceInput/utilities.ts +0 -46
  73. package/src/ui/PriceRowLabel/index.css +0 -13
  74. package/src/ui/PriceRowLabel/index.tsx +0 -56
  75. package/src/ui/VariantOptionsSelector/ErrorBox.tsx +0 -27
  76. package/src/ui/VariantOptionsSelector/OptionsSelect.tsx +0 -78
  77. package/src/ui/VariantOptionsSelector/index.css +0 -37
  78. package/src/ui/VariantOptionsSelector/index.tsx +0 -83
  79. package/src/utilities/defaultProductsValidation.ts +0 -42
  80. package/src/utilities/errorCodes.ts +0 -14
  81. package/src/utilities/getCollectionSlugMap.ts +0 -84
  82. package/src/utilities/sanitizePluginConfig.ts +0 -80
  83. package/src/variants/variantOptionsCollection.ts +0 -59
  84. package/src/variants/variantTypesCollection.ts +0 -55
  85. package/src/variants/variantsCollection/hooks/beforeChange.ts +0 -47
  86. package/src/variants/variantsCollection/hooks/validateOptions.ts +0 -72
  87. package/src/variants/variantsCollection/index.ts +0 -119
  88. package/tsconfig.json +0 -7
  89. package/tsconfig.tsbuildinfo +0 -1
@@ -1,184 +0,0 @@
1
- import type { DefaultDocumentIDType, PopulateType, SelectType, TypedCollection } from 'payload'
2
- import type React from 'react'
3
-
4
- import type { CurrenciesConfig, Currency, PaymentAdapterClient } from '../../types.js'
5
-
6
- export type SyncLocalStorageConfig = {
7
- /**
8
- * Key to use for localStorage.
9
- * Defaults to 'cart'.
10
- */
11
- key?: string
12
- }
13
-
14
- type APIProps = {
15
- /**
16
- * The route for the Payload API, defaults to `/api`.
17
- */
18
- apiRoute?: string
19
- /**
20
- * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.
21
- *
22
- * Defaults to `{ depth: 0 }`.
23
- */
24
- cartsFetchQuery?: {
25
- depth?: number
26
- populate?: PopulateType
27
- select?: SelectType
28
- }
29
- /**
30
- * 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`.
31
- */
32
- serverURL?: string
33
- }
34
-
35
- export type ContextProps = {
36
- /**
37
- * The slug for the addresses collection.
38
- *
39
- * Defaults to 'addresses'.
40
- */
41
- addressesSlug?: string
42
- api?: APIProps
43
- /**
44
- * The slug for the carts collection.
45
- *
46
- * Defaults to 'carts'.
47
- */
48
- cartsSlug?: string
49
- children?: React.ReactNode
50
- /**
51
- * The configuration for currencies used in the ecommerce context.
52
- * This is used to handle currency formatting and calculations, defaults to USD.
53
- */
54
- currenciesConfig?: CurrenciesConfig
55
- /**
56
- * The slug for the customers collection.
57
- *
58
- * Defaults to 'users'.
59
- */
60
- customersSlug?: string
61
- /**
62
- * Enable debug mode for the ecommerce context. This will log additional information to the console.
63
- * Defaults to false.
64
- */
65
- debug?: boolean
66
- /**
67
- * Whether to enable support for variants in the cart.
68
- * This allows adding products with specific variants to the cart.
69
- * Defaults to false.
70
- */
71
- enableVariants?: boolean
72
- /**
73
- * Supported payment methods for the ecommerce context.
74
- */
75
- paymentMethods?: PaymentAdapterClient[]
76
- /**
77
- * Whether to enable localStorage for cart persistence.
78
- * Defaults to true.
79
- */
80
- syncLocalStorage?: boolean | SyncLocalStorageConfig
81
- }
82
-
83
- /**
84
- * Type used internally to represent the cart item to be added.
85
- */
86
- type CartItemArgument = {
87
- /**
88
- * The ID of the product to add to the cart. Always required.
89
- */
90
- product: DefaultDocumentIDType
91
- /**
92
- * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.
93
- */
94
- variant?: DefaultDocumentIDType
95
- }
96
-
97
- export type EcommerceContext = {
98
- /**
99
- * Add an item to the cart.
100
- */
101
- addItem: (item: CartItemArgument, quantity?: number) => Promise<void>
102
- /**
103
- * All current addresses for the current user.
104
- * This is used to manage shipping and billing addresses.
105
- */
106
- addresses?: TypedCollection['addresses'][]
107
- /**
108
- * The current data of the cart.
109
- */
110
- cart?: TypedCollection['carts']
111
- /**
112
- * The ID of the current cart corresponding to the cart in the database or local storage.
113
- */
114
- cartID?: DefaultDocumentIDType
115
- /**
116
- * Clear the cart, removing all items.
117
- */
118
- clearCart: () => Promise<void>
119
- /**
120
- * Initiate a payment using the selected payment method.
121
- * This method should be called after the cart is ready for checkout.
122
- * It requires the payment method ID and any necessary payment data.
123
- */
124
- confirmOrder: (
125
- paymentMethodID: string,
126
- options?: { additionalData: Record<string, unknown> },
127
- ) => Promise<unknown>
128
- /**
129
- * Create a new address by providing the data.
130
- */
131
- createAddress: (data: Partial<TypedCollection['addresses']>) => Promise<void>
132
- /**
133
- * The configuration for the currencies used in the ecommerce context.
134
- */
135
- currenciesConfig: CurrenciesConfig
136
- /**
137
- * The currently selected currency used for the cart and price formatting automatically.
138
- */
139
- currency: Currency
140
- /**
141
- * Decrement an item in the cart by its index ID.
142
- * If quantity reaches 0, the item will be removed from the cart.
143
- */
144
- decrementItem: (item: DefaultDocumentIDType) => Promise<void>
145
- /**
146
- * Increment an item in the cart by its index ID.
147
- */
148
- incrementItem: (item: DefaultDocumentIDType) => Promise<void>
149
- /**
150
- * Initiate a payment using the selected payment method.
151
- * This method should be called after the cart is ready for checkout.
152
- * It requires the payment method ID and any necessary payment data.
153
- */
154
- initiatePayment: (
155
- paymentMethodID: string,
156
- options?: { additionalData: Record<string, unknown> },
157
- ) => Promise<unknown>
158
- /**
159
- *
160
- */
161
- paymentData?: Record<string, unknown>
162
- paymentMethods: PaymentAdapterClient[]
163
- /**
164
- * Remove an item from the cart by its index ID.
165
- */
166
- removeItem: (item: DefaultDocumentIDType) => Promise<void>
167
- /**
168
- * The name of the currently selected payment method.
169
- * This is used to determine which payment method to use when initiating a payment.
170
- */
171
- selectedPaymentMethod?: null | string
172
- /**
173
- * Change the currency for the cart, it defaults to the configured currency.
174
- * This will update the currency used for pricing and calculations.
175
- */
176
- setCurrency: (currency: string) => void
177
- /**
178
- * Update an address by providing the data and the ID.
179
- */
180
- updateAddress: (
181
- addressID: DefaultDocumentIDType,
182
- data: Partial<TypedCollection['addresses']>,
183
- ) => Promise<void>
184
- }
@@ -1,22 +0,0 @@
1
- import type { Currency } from '../../types.js'
2
-
3
- /**
4
- * Convert base value to display value with decimal point (e.g., 2500 to $25.00)
5
- */
6
- export const convertFromBaseValue = ({
7
- baseValue,
8
- currency,
9
- }: {
10
- baseValue: number
11
- currency: Currency
12
- }): string => {
13
- if (!currency) {
14
- return baseValue.toString()
15
- }
16
-
17
- // Convert from base value (e.g., cents) to decimal value (e.g., dollars)
18
- const decimalValue = baseValue / Math.pow(10, currency.decimals)
19
-
20
- // Format with the correct number of decimal places
21
- return decimalValue.toFixed(currency.decimals)
22
- }
@@ -1,166 +0,0 @@
1
- import type { CollectionConfig, Field } from 'payload'
2
-
3
- import type { CurrenciesConfig, FieldsOverride, PaymentAdapter } from '../types.js'
4
-
5
- import { amountField } from '../fields/amountField.js'
6
- import { cartItemsField } from '../fields/cartItemsField.js'
7
- import { currencyField } from '../fields/currencyField.js'
8
- import { statusField } from '../fields/statusField.js'
9
-
10
- type Props = {
11
- /**
12
- * Array of fields used for capturing the billing address.
13
- */
14
- addressFields?: Field[]
15
- /**
16
- * Slug of the carts collection, defaults to 'carts'.
17
- */
18
- cartsSlug?: string
19
- currenciesConfig?: CurrenciesConfig
20
- /**
21
- * Slug of the customers collection, defaults to 'users'.
22
- */
23
- customersSlug?: string
24
- /**
25
- * Enable variants in the transactions collection.
26
- */
27
- enableVariants?: boolean
28
- /**
29
- * Slug of the orders collection, defaults to 'orders'.
30
- */
31
- ordersSlug?: string
32
- overrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>
33
- paymentMethods?: PaymentAdapter[]
34
- /**
35
- * Slug of the products collection, defaults to 'products'.
36
- */
37
- productsSlug?: string
38
- /**
39
- * Slug of the variants collection, defaults to 'variants'.
40
- */
41
- variantsSlug?: string
42
- }
43
-
44
- export const transactionsCollection: (props?: Props) => CollectionConfig = (props) => {
45
- const {
46
- addressFields,
47
- cartsSlug = 'carts',
48
- currenciesConfig,
49
- customersSlug = 'users',
50
- enableVariants = false,
51
- ordersSlug = 'orders',
52
- overrides,
53
- paymentMethods,
54
- productsSlug = 'products',
55
- variantsSlug = 'variants',
56
- } = props || {}
57
-
58
- const fieldsOverride = overrides?.fields
59
-
60
- const defaultFields: Field[] = [
61
- {
62
- name: 'customer',
63
- type: 'relationship',
64
- label: ({ t }) =>
65
- // @ts-expect-error - translations are not typed in plugins yet
66
- t('plugin-ecommerce:customer'),
67
- relationTo: customersSlug,
68
- },
69
- {
70
- name: 'customerEmail',
71
- type: 'email',
72
- label: ({ t }) =>
73
- // @ts-expect-error - translations are not typed in plugins yet
74
- t('plugin-ecommerce:customerEmail'),
75
- },
76
- {
77
- name: 'order',
78
- type: 'relationship',
79
- label: ({ t }) =>
80
- // @ts-expect-error - translations are not typed in plugins yet
81
- t('plugin-ecommerce:order'),
82
- relationTo: ordersSlug,
83
- },
84
- {
85
- name: 'cart',
86
- type: 'relationship',
87
- relationTo: cartsSlug,
88
- },
89
- ...(addressFields
90
- ? [
91
- {
92
- name: 'billingAddress',
93
- type: 'group',
94
- fields: addressFields,
95
- label: ({ t }) =>
96
- // @ts-expect-error - translations are not typed in plugins yet
97
- t('plugin-ecommerce:shippingAddress'),
98
- } as Field,
99
- ]
100
- : []),
101
- cartItemsField({
102
- enableVariants,
103
- overrides: {
104
- name: 'items',
105
- label: ({ t }) =>
106
- // @ts-expect-error - translations are not typed in plugins yet
107
- t('plugin-ecommerce:items'),
108
- labels: {
109
- plural: ({ t }) =>
110
- // @ts-expect-error - translations are not typed in plugins yet
111
- t('plugin-ecommerce:items'),
112
- singular: ({ t }) =>
113
- // @ts-expect-error - translations are not typed in plugins yet
114
- t('plugin-ecommerce:item'),
115
- },
116
- },
117
- productsSlug,
118
- variantsSlug,
119
- }),
120
- statusField(),
121
- ]
122
-
123
- if (paymentMethods?.length && paymentMethods.length > 0) {
124
- defaultFields.push({
125
- name: 'paymentMethod',
126
- type: 'select',
127
- label: ({ t }) =>
128
- // @ts-expect-error - translations are not typed in plugins yet
129
- t('plugin-ecommerce:paymentMethod'),
130
- options: paymentMethods.map((method) => ({
131
- label: method.label ?? method.name,
132
- value: method.name,
133
- })),
134
- })
135
-
136
- paymentMethods.forEach((method) => {
137
- defaultFields.push(method.group)
138
- })
139
- }
140
-
141
- if (currenciesConfig) {
142
- defaultFields.push(currencyField({ currenciesConfig }))
143
- defaultFields.push(amountField({ currenciesConfig }))
144
- }
145
-
146
- const fields =
147
- fieldsOverride && typeof fieldsOverride === 'function'
148
- ? fieldsOverride({ defaultFields })
149
- : defaultFields
150
-
151
- const baseConfig: CollectionConfig = {
152
- slug: 'transactions',
153
- ...overrides,
154
- access: {
155
- read: () => true,
156
- ...(overrides?.access || []),
157
- },
158
- admin: {
159
- defaultColumns: ['createdAt', 'customer', 'order', 'amount', 'status'],
160
- ...overrides?.admin,
161
- },
162
- fields,
163
- }
164
-
165
- return { ...baseConfig }
166
- }
@@ -1,64 +0,0 @@
1
- import type { GenericTranslationsObject } from '@payloadcms/translations'
2
-
3
- export const en: GenericTranslationsObject = {
4
- $schema: './translation-schema.json',
5
- 'plugin-ecommerce': {
6
- abandoned: 'Abandoned',
7
- addressCity: 'City',
8
- addressCompany: 'Company',
9
- addressCountry: 'Country',
10
- addressFirstName: 'First name',
11
- addressLastName: 'Last name',
12
- addressLine1: 'Address 1',
13
- addressLine2: 'Address 2',
14
- addressPhone: 'Phone',
15
- addressPostalCode: 'Postal code',
16
- addressState: 'State',
17
- addressTitle: 'Title',
18
- amount: 'Amount',
19
- availableVariants: 'Available variants',
20
- billingAddress: 'Billing address',
21
- cancelled: 'Cancelled',
22
- cart: 'Cart',
23
- completed: 'Completed',
24
- currency: 'Currency',
25
- customer: 'Customer',
26
- customerEmail: 'Customer email',
27
- customers: 'Customers',
28
- enableCurrencyPrice: `Enable {{currency}} price`,
29
- enableVariants: 'Enable variants',
30
- expired: 'Expired',
31
- failed: 'Failed',
32
- inventory: 'Inventory',
33
- item: 'Item',
34
- items: 'Items',
35
- open: 'Open',
36
- order: 'Order',
37
- paymentMethod: 'Payment method',
38
- paymentMethods: 'Payment methods',
39
- pending: 'Pending',
40
- price: 'Price',
41
- priceIn: 'Price ({{currency}})',
42
- prices: 'Prices',
43
- processing: 'Processing',
44
- product: 'Product',
45
- productRequired: 'A product is required.',
46
- products: 'Products',
47
- quantity: 'Quantity',
48
- refunded: 'Refunded',
49
- shippingAddress: 'Shipping address',
50
- status: 'Status',
51
- subtotal: 'Subtotal',
52
- succeeded: 'Succeeded',
53
- transactions: 'Transactions',
54
- variant: 'Variant',
55
- variantOptions: 'Variant options',
56
- variantOptionsAlreadyExists:
57
- 'This variant combo is already in use by another variant. Please select different options.',
58
- variantOptionsRequired: 'Variant options are required.',
59
- variantOptionsRequiredAll: 'All variant options are required.',
60
- variants: 'Variants',
61
- variantType: 'Variant type',
62
- variantTypes: 'Variant types',
63
- },
64
- }
@@ -1,11 +0,0 @@
1
- import type { GenericTranslationsObject, NestedKeysStripped } from '@payloadcms/translations'
2
-
3
- import { en } from './en.js'
4
-
5
- export const translations = {
6
- en,
7
- }
8
-
9
- export type EcommerceTranslations = GenericTranslationsObject
10
-
11
- export type EcommerceTranslationKeys = NestedKeysStripped<EcommerceTranslations>
@@ -1,35 +0,0 @@
1
- {
2
- "type": "object",
3
- "$schema": "http://json-schema.org/draft-04/schema#",
4
- "additionalProperties": false,
5
- "properties": {
6
- "$schema": {
7
- "type": "string"
8
- },
9
- "ecommerce": {
10
- "type": "object",
11
- "additionalProperties": false,
12
- "properties": {
13
- "variantOptionsAlreadyExists": {
14
- "type": "string"
15
- },
16
- "productRquired": {
17
- "type": "string"
18
- },
19
- "variantOptionsRequired": {
20
- "type": "string"
21
- },
22
- "variantOptionsRequiredAll": {
23
- "type": "string"
24
- }
25
- },
26
- "required": [
27
- "variantOptionsAlreadyExists",
28
- "productRquired",
29
- "variantOptionsRequired",
30
- "variantOptionsRequiredAll"
31
- ]
32
- }
33
- },
34
- "required": ["ecommerce"]
35
- }