@payloadcms/storage-r2 0.0.1-beta.0 → 3.58.0-internal.8775d75

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,72 +0,0 @@
1
- import type { Validate } from 'payload'
2
-
3
- type Props = {
4
- productsCollectionSlug?: string
5
- }
6
-
7
- export const validateOptions: (props?: Props) => Validate =
8
- (props) =>
9
- async (values, { data, req }) => {
10
- const { productsCollectionSlug = 'products' } = props || {}
11
- const { t } = req
12
-
13
- if (!values || values.length === 0) {
14
- // @ts-expect-error - TODO: Fix types
15
- return t('ecommerce:variantOptionsRequired')
16
- }
17
-
18
- const productID = data.product
19
-
20
- if (!productID) {
21
- // @ts-expect-error - TODO: Fix types
22
- return t('ecommerce:productRequired')
23
- }
24
-
25
- const product = await req.payload.findByID({
26
- id: productID,
27
- collection: productsCollectionSlug,
28
- depth: 1,
29
- joins: {
30
- variants: {
31
- where: {
32
- id: {
33
- not_equals: data.id, // exclude the current variant from the search
34
- },
35
- },
36
- },
37
- },
38
- select: {
39
- variants: true,
40
- variantTypes: true,
41
- },
42
- user: req.user,
43
- })
44
-
45
- // @ts-expect-error - TODO: Fix types
46
- const variants = product.variants?.docs ?? []
47
-
48
- // @ts-expect-error - TODO: Fix types
49
- if (values.length < product?.variantTypes?.length) {
50
- // @ts-expect-error - TODO: Fix types
51
- return t('ecommerce:variantOptionsRequiredAll')
52
- }
53
-
54
- if (variants.length > 0) {
55
- const existingOptions: (number | string)[][] = []
56
-
57
- variants.forEach((variant: any) => {
58
- existingOptions.push(variant.options)
59
- })
60
-
61
- const exists = existingOptions.some(
62
- (combo) => combo.length === values.length && combo.every((val) => values.includes(val)),
63
- )
64
-
65
- if (exists) {
66
- // @ts-expect-error - TODO: Fix types
67
- return t('ecommerce:variantOptionsAlreadyExists')
68
- }
69
- }
70
-
71
- return true
72
- }
@@ -1,119 +0,0 @@
1
- import type { CollectionConfig, Field } from 'payload'
2
-
3
- import type { CurrenciesConfig, FieldsOverride, InventoryConfig } from '../../types.js'
4
-
5
- import { inventoryField } from '../../fields/inventoryField.js'
6
- import { pricesField } from '../../fields/pricesField.js'
7
- import { variantsCollectionBeforeChange as beforeChange } from './hooks/beforeChange.js'
8
- import { validateOptions } from './hooks/validateOptions.js'
9
-
10
- type Props = {
11
- currenciesConfig?: CurrenciesConfig
12
- /**
13
- * Enables inventory tracking for variants. Defaults to true.
14
- */
15
- inventory?: InventoryConfig
16
- overrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>
17
- /**
18
- * Slug of the products collection, defaults to 'products'.
19
- */
20
- productsSlug?: string
21
- /**
22
- * Slug of the variant options collection, defaults to 'variantOptions'.
23
- */
24
- variantOptionsSlug?: string
25
- }
26
-
27
- export const variantsCollection: (props: Props) => CollectionConfig = (props) => {
28
- const {
29
- currenciesConfig,
30
- inventory = true,
31
- overrides,
32
- productsSlug = 'products',
33
- variantOptionsSlug = 'variantOptions',
34
- } = props || {}
35
- const { supportedCurrencies } = currenciesConfig || {}
36
- const fieldsOverride = overrides?.fields
37
-
38
- const defaultFields: Field[] = [
39
- {
40
- name: 'title',
41
- type: 'text',
42
- admin: {
43
- description:
44
- 'Used for administrative purposes, not shown to customers. This is populated by default.',
45
- },
46
- },
47
- {
48
- name: 'product',
49
- type: 'relationship',
50
- admin: {
51
- description:
52
- 'this should not be editable, or at least, should be able to be pre-filled via default',
53
- readOnly: true,
54
- },
55
- relationTo: productsSlug,
56
- required: true,
57
- },
58
- {
59
- // This might need to be a custom component, to show a selector for each variant that is
60
- // enabled on the parent product
61
- // - separate select inputs, each showing only a specific variant (w/ options)
62
- // - it will save data to the DB as IDs in this relationship field
63
- // and needs a validate function as well which enforces that the options are fully specified,
64
- // and accurate
65
- name: 'options',
66
- type: 'relationship',
67
- admin: {
68
- components: {
69
- Field: {
70
- path: '@payloadcms/plugin-ecommerce/ui#VariantOptionsSelector',
71
- },
72
- },
73
- },
74
- hasMany: true,
75
- label: 'Variant options',
76
- relationTo: variantOptionsSlug,
77
- required: true,
78
- validate: validateOptions(),
79
- },
80
- ...(inventory ? [inventoryField()] : []),
81
- ]
82
-
83
- if (supportedCurrencies?.length && supportedCurrencies.length > 0) {
84
- const currencyOptions: string[] = []
85
-
86
- supportedCurrencies.forEach((currency) => {
87
- currencyOptions.push(currency.code)
88
- })
89
-
90
- if (currenciesConfig) {
91
- defaultFields.push(...pricesField({ currenciesConfig }))
92
- }
93
- }
94
-
95
- const fields =
96
- fieldsOverride && typeof fieldsOverride === 'function'
97
- ? fieldsOverride({ defaultFields })
98
- : defaultFields
99
-
100
- const baseConfig: CollectionConfig = {
101
- slug: 'variants',
102
- ...overrides,
103
- admin: {
104
- // group: false,
105
- useAsTitle: 'title',
106
- ...overrides?.admin,
107
- },
108
- fields,
109
- hooks: {
110
- ...overrides?.hooks,
111
- beforeChange: [
112
- beforeChange({ productsSlug, variantOptionsSlug }),
113
- ...(overrides?.hooks?.beforeChange || []),
114
- ],
115
- },
116
- }
117
-
118
- return { ...baseConfig }
119
- }
package/tsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "strict": true,
5
- },
6
- "references": [{ "path": "../payload" }, { "path": "../ui" }, { "path": "../translations" }]
7
- }