@payloadcms/plugin-ecommerce 3.57.0-internal.f26caed → 3.58.0-canary.4

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 (123) hide show
  1. package/dist/collections/addresses/createAddressesCollection.d.ts +1 -1
  2. package/dist/collections/addresses/createAddressesCollection.d.ts.map +1 -1
  3. package/dist/collections/addresses/createAddressesCollection.js +1 -0
  4. package/dist/collections/addresses/createAddressesCollection.js.map +1 -1
  5. package/dist/collections/addresses/defaultCountries.d.ts +1 -1
  6. package/dist/collections/addresses/defaultCountries.d.ts.map +1 -1
  7. package/dist/collections/addresses/defaultCountries.js.map +1 -1
  8. package/dist/collections/addresses/hooks/beforeChange.d.ts +1 -1
  9. package/dist/collections/addresses/hooks/beforeChange.d.ts.map +1 -1
  10. package/dist/collections/addresses/hooks/beforeChange.js.map +1 -1
  11. package/dist/collections/carts/createCartsCollection.d.ts +1 -1
  12. package/dist/collections/carts/createCartsCollection.d.ts.map +1 -1
  13. package/dist/collections/carts/createCartsCollection.js.map +1 -1
  14. package/dist/collections/orders/createOrdersCollection.d.ts +1 -1
  15. package/dist/collections/orders/createOrdersCollection.d.ts.map +1 -1
  16. package/dist/collections/orders/createOrdersCollection.js.map +1 -1
  17. package/dist/collections/products/createProductsCollection.d.ts +1 -1
  18. package/dist/collections/products/createProductsCollection.d.ts.map +1 -1
  19. package/dist/collections/products/createProductsCollection.js.map +1 -1
  20. package/dist/collections/transactions/createTransactionsCollection.d.ts +1 -1
  21. package/dist/collections/transactions/createTransactionsCollection.d.ts.map +1 -1
  22. package/dist/collections/transactions/createTransactionsCollection.js.map +1 -1
  23. package/dist/collections/variants/createVariantOptionsCollection.d.ts +1 -1
  24. package/dist/collections/variants/createVariantOptionsCollection.d.ts.map +1 -1
  25. package/dist/collections/variants/createVariantOptionsCollection.js.map +1 -1
  26. package/dist/collections/variants/createVariantTypesCollection.d.ts +1 -1
  27. package/dist/collections/variants/createVariantTypesCollection.d.ts.map +1 -1
  28. package/dist/collections/variants/createVariantTypesCollection.js.map +1 -1
  29. package/dist/collections/variants/createVariantsCollection/index.d.ts +1 -1
  30. package/dist/collections/variants/createVariantsCollection/index.d.ts.map +1 -1
  31. package/dist/collections/variants/createVariantsCollection/index.js.map +1 -1
  32. package/dist/currencies/index.d.ts +1 -1
  33. package/dist/currencies/index.d.ts.map +1 -1
  34. package/dist/currencies/index.js.map +1 -1
  35. package/dist/endpoints/confirmOrder.d.ts +1 -1
  36. package/dist/endpoints/confirmOrder.d.ts.map +1 -1
  37. package/dist/endpoints/confirmOrder.js.map +1 -1
  38. package/dist/endpoints/initiatePayment.d.ts +1 -1
  39. package/dist/endpoints/initiatePayment.d.ts.map +1 -1
  40. package/dist/endpoints/initiatePayment.js.map +1 -1
  41. package/dist/exports/types.d.ts +2 -1
  42. package/dist/exports/types.d.ts.map +1 -1
  43. package/dist/exports/types.js.map +1 -1
  44. package/dist/fields/amountField.d.ts +1 -1
  45. package/dist/fields/amountField.d.ts.map +1 -1
  46. package/dist/fields/amountField.js.map +1 -1
  47. package/dist/fields/cartItemsField.d.ts +1 -1
  48. package/dist/fields/cartItemsField.d.ts.map +1 -1
  49. package/dist/fields/cartItemsField.js.map +1 -1
  50. package/dist/fields/currencyField.d.ts +1 -1
  51. package/dist/fields/currencyField.d.ts.map +1 -1
  52. package/dist/fields/currencyField.js.map +1 -1
  53. package/dist/fields/pricesField.d.ts +1 -1
  54. package/dist/fields/pricesField.d.ts.map +1 -1
  55. package/dist/fields/pricesField.js.map +1 -1
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +13 -3
  59. package/dist/index.js.map +1 -1
  60. package/dist/payments/adapters/stripe/confirmOrder.d.ts +1 -1
  61. package/dist/payments/adapters/stripe/confirmOrder.d.ts.map +1 -1
  62. package/dist/payments/adapters/stripe/confirmOrder.js.map +1 -1
  63. package/dist/payments/adapters/stripe/index.d.ts +1 -1
  64. package/dist/payments/adapters/stripe/index.d.ts.map +1 -1
  65. package/dist/payments/adapters/stripe/index.js.map +1 -1
  66. package/dist/payments/adapters/stripe/initiatePayment.d.ts +1 -1
  67. package/dist/payments/adapters/stripe/initiatePayment.d.ts.map +1 -1
  68. package/dist/payments/adapters/stripe/initiatePayment.js.map +1 -1
  69. package/dist/react/provider/index.d.ts +15 -10
  70. package/dist/react/provider/index.d.ts.map +1 -1
  71. package/dist/react/provider/index.js +21 -22
  72. package/dist/react/provider/index.js.map +1 -1
  73. package/dist/react/provider/utilities.d.ts +1 -1
  74. package/dist/react/provider/utilities.d.ts.map +1 -1
  75. package/dist/react/provider/utilities.js.map +1 -1
  76. package/dist/translations/en.d.ts.map +1 -1
  77. package/dist/translations/en.js +1 -0
  78. package/dist/translations/en.js.map +1 -1
  79. package/dist/{types.d.ts → types/index.d.ts} +177 -2
  80. package/dist/types/index.d.ts.map +1 -0
  81. package/dist/types/index.js +3 -0
  82. package/dist/types/index.js.map +1 -0
  83. package/dist/types/utilities.d.ts +36 -0
  84. package/dist/types/utilities.d.ts.map +1 -0
  85. package/dist/types/utilities.js +3 -0
  86. package/dist/types/utilities.js.map +1 -0
  87. package/dist/ui/PriceCell/index.d.ts +1 -1
  88. package/dist/ui/PriceCell/index.d.ts.map +1 -1
  89. package/dist/ui/PriceCell/index.js.map +1 -1
  90. package/dist/ui/PriceInput/FormattedInput.d.ts +1 -1
  91. package/dist/ui/PriceInput/FormattedInput.d.ts.map +1 -1
  92. package/dist/ui/PriceInput/FormattedInput.js.map +1 -1
  93. package/dist/ui/PriceInput/index.d.ts +1 -1
  94. package/dist/ui/PriceInput/index.d.ts.map +1 -1
  95. package/dist/ui/PriceInput/index.js.map +1 -1
  96. package/dist/ui/PriceRowLabel/index.d.ts +1 -1
  97. package/dist/ui/PriceRowLabel/index.d.ts.map +1 -1
  98. package/dist/ui/PriceRowLabel/index.js.map +1 -1
  99. package/dist/ui/utilities.d.ts +1 -1
  100. package/dist/ui/utilities.d.ts.map +1 -1
  101. package/dist/ui/utilities.js.map +1 -1
  102. package/dist/utilities/defaultProductsValidation.d.ts +1 -1
  103. package/dist/utilities/defaultProductsValidation.d.ts.map +1 -1
  104. package/dist/utilities/defaultProductsValidation.js.map +1 -1
  105. package/dist/utilities/getCollectionSlugMap.d.ts +1 -1
  106. package/dist/utilities/getCollectionSlugMap.d.ts.map +1 -1
  107. package/dist/utilities/getCollectionSlugMap.js +5 -4
  108. package/dist/utilities/getCollectionSlugMap.js.map +1 -1
  109. package/dist/utilities/pushTypeScriptProperties.d.ts +10 -0
  110. package/dist/utilities/pushTypeScriptProperties.d.ts.map +1 -0
  111. package/dist/utilities/pushTypeScriptProperties.js +37 -0
  112. package/dist/utilities/pushTypeScriptProperties.js.map +1 -0
  113. package/dist/utilities/sanitizePluginConfig.d.ts +1 -1
  114. package/dist/utilities/sanitizePluginConfig.d.ts.map +1 -1
  115. package/dist/utilities/sanitizePluginConfig.js.map +1 -1
  116. package/package.json +8 -7
  117. package/dist/react/provider/types.d.ts +0 -172
  118. package/dist/react/provider/types.d.ts.map +0 -1
  119. package/dist/react/provider/types.js +0 -3
  120. package/dist/react/provider/types.js.map +0 -1
  121. package/dist/types.d.ts.map +0 -1
  122. package/dist/types.js +0 -3
  123. package/dist/types.js.map +0 -1
@@ -0,0 +1,37 @@
1
+ export const pushTypeScriptProperties = ({ collectionSlugMap, jsonSchema })=>{
2
+ if (!jsonSchema.properties) {
3
+ jsonSchema.properties = {};
4
+ }
5
+ if (Array.isArray(jsonSchema.required)) {
6
+ jsonSchema.required.push('ecommerce');
7
+ }
8
+ const requiredCollectionProperties = [];
9
+ const propertiesMap = new Map();
10
+ Object.entries(collectionSlugMap).forEach(([key, slug])=>{
11
+ propertiesMap.set(key, {
12
+ $ref: `#/definitions/${slug}`
13
+ });
14
+ requiredCollectionProperties.push(slug);
15
+ });
16
+ jsonSchema.properties.ecommerce = {
17
+ type: 'object',
18
+ additionalProperties: false,
19
+ description: 'Generated by the Payload Ecommerce plugin',
20
+ properties: {
21
+ collections: {
22
+ type: 'object',
23
+ additionalProperties: false,
24
+ properties: {
25
+ ...Object.fromEntries(propertiesMap)
26
+ },
27
+ required: requiredCollectionProperties
28
+ }
29
+ },
30
+ required: [
31
+ 'collections'
32
+ ]
33
+ };
34
+ return jsonSchema;
35
+ };
36
+
37
+ //# sourceMappingURL=pushTypeScriptProperties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/pushTypeScriptProperties.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { SanitizedConfig } from 'payload'\n\nimport type { CollectionSlugMap, SanitizedEcommercePluginConfig } from '../types/index.js'\n\nexport const pushTypeScriptProperties = ({\n collectionSlugMap,\n jsonSchema,\n}: {\n collectionSlugMap: CollectionSlugMap\n config: SanitizedConfig\n jsonSchema: JSONSchema4\n sanitizedPluginConfig: SanitizedEcommercePluginConfig\n}): JSONSchema4 => {\n if (!jsonSchema.properties) {\n jsonSchema.properties = {}\n }\n\n if (Array.isArray(jsonSchema.required)) {\n jsonSchema.required.push('ecommerce')\n }\n\n const requiredCollectionProperties: string[] = []\n const propertiesMap = new Map<string, { $ref: string }>()\n\n Object.entries(collectionSlugMap).forEach(([key, slug]) => {\n propertiesMap.set(key, { $ref: `#/definitions/${slug}` })\n\n requiredCollectionProperties.push(slug)\n })\n\n jsonSchema.properties.ecommerce = {\n type: 'object',\n additionalProperties: false,\n description: 'Generated by the Payload Ecommerce plugin',\n properties: {\n collections: {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...Object.fromEntries(propertiesMap),\n },\n required: requiredCollectionProperties,\n },\n },\n required: ['collections'],\n }\n\n return jsonSchema\n}\n"],"names":["pushTypeScriptProperties","collectionSlugMap","jsonSchema","properties","Array","isArray","required","push","requiredCollectionProperties","propertiesMap","Map","Object","entries","forEach","key","slug","set","$ref","ecommerce","type","additionalProperties","description","collections","fromEntries"],"mappings":"AAMA,OAAO,MAAMA,2BAA2B,CAAC,EACvCC,iBAAiB,EACjBC,UAAU,EAMX;IACC,IAAI,CAACA,WAAWC,UAAU,EAAE;QAC1BD,WAAWC,UAAU,GAAG,CAAC;IAC3B;IAEA,IAAIC,MAAMC,OAAO,CAACH,WAAWI,QAAQ,GAAG;QACtCJ,WAAWI,QAAQ,CAACC,IAAI,CAAC;IAC3B;IAEA,MAAMC,+BAAyC,EAAE;IACjD,MAAMC,gBAAgB,IAAIC;IAE1BC,OAAOC,OAAO,CAACX,mBAAmBY,OAAO,CAAC,CAAC,CAACC,KAAKC,KAAK;QACpDN,cAAcO,GAAG,CAACF,KAAK;YAAEG,MAAM,CAAC,cAAc,EAAEF,MAAM;QAAC;QAEvDP,6BAA6BD,IAAI,CAACQ;IACpC;IAEAb,WAAWC,UAAU,CAACe,SAAS,GAAG;QAChCC,MAAM;QACNC,sBAAsB;QACtBC,aAAa;QACblB,YAAY;YACVmB,aAAa;gBACXH,MAAM;gBACNC,sBAAsB;gBACtBjB,YAAY;oBACV,GAAGQ,OAAOY,WAAW,CAACd,cAAc;gBACtC;gBACAH,UAAUE;YACZ;QACF;QACAF,UAAU;YAAC;SAAc;IAC3B;IAEA,OAAOJ;AACT,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { EcommercePluginConfig, SanitizedEcommercePluginConfig } from '../types.js';
1
+ import type { EcommercePluginConfig, SanitizedEcommercePluginConfig } from '../types/index.js';
2
2
  type Props = {
3
3
  pluginConfig: EcommercePluginConfig;
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizePluginConfig.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizePluginConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAA;AAKxF,KAAK,KAAK,GAAG;IACX,YAAY,EAAE,qBAAqB,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,oBAAoB,qBAAsB,KAAK,KAAG,8BAkF9D,CAAA"}
1
+ {"version":3,"file":"sanitizePluginConfig.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizePluginConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAA;AAK9F,KAAK,KAAK,GAAG;IACX,YAAY,EAAE,qBAAqB,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,oBAAoB,qBAAsB,KAAK,KAAG,8BAkF9D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/sanitizePluginConfig.ts"],"sourcesContent":["import type { EcommercePluginConfig, SanitizedEcommercePluginConfig } from '../types.js'\n\nimport { defaultAddressFields } from '../collections/addresses/defaultAddressFields.js'\nimport { USD } from '../currencies/index.js'\n\ntype Props = {\n pluginConfig: EcommercePluginConfig\n}\n\nexport const sanitizePluginConfig = ({ pluginConfig }: Props): SanitizedEcommercePluginConfig => {\n const config = {\n ...pluginConfig,\n } as Partial<SanitizedEcommercePluginConfig>\n\n if (typeof config.customers === 'undefined') {\n config.customers = {\n slug: 'users',\n }\n }\n\n if (\n typeof config.addresses === 'undefined' ||\n (typeof config.addresses === 'boolean' && config.addresses === true)\n ) {\n config.addresses = {\n addressFields: defaultAddressFields(),\n }\n } else {\n const addressFields =\n (typeof pluginConfig.addresses === 'object' &&\n typeof pluginConfig.addresses.addressFields === 'function' &&\n pluginConfig.addresses.addressFields({\n defaultFields: defaultAddressFields(),\n })) ||\n defaultAddressFields()\n\n config.addresses = {\n ...config.addresses,\n addressFields,\n }\n }\n\n if (!config.currencies) {\n config.currencies = {\n defaultCurrency: 'USD',\n supportedCurrencies: [USD],\n }\n }\n\n if (\n typeof config.inventory === 'undefined' ||\n (typeof config.inventory === 'boolean' && config.inventory === true)\n ) {\n config.inventory = {\n fieldName: 'inventory',\n }\n }\n\n if (typeof config.carts === 'undefined') {\n config.carts = true\n }\n\n if (typeof config.orders === 'undefined') {\n config.orders = true\n }\n\n if (typeof config.transactions === 'undefined') {\n config.transactions = true\n }\n\n if (typeof config.payments === 'undefined') {\n config.payments = {\n paymentMethods: [],\n }\n } else if (!config.payments.paymentMethods) {\n config.payments.paymentMethods = []\n }\n\n if (config.products) {\n if (typeof config.products === 'object' && typeof config.products.variants === 'undefined') {\n config.products.variants = true\n }\n }\n\n config.access = {\n authenticatedOnly: ({ req: { user } }) => Boolean(user),\n publicAccess: () => true,\n ...pluginConfig.access,\n }\n\n return config as SanitizedEcommercePluginConfig\n}\n"],"names":["defaultAddressFields","USD","sanitizePluginConfig","pluginConfig","config","customers","slug","addresses","addressFields","defaultFields","currencies","defaultCurrency","supportedCurrencies","inventory","fieldName","carts","orders","transactions","payments","paymentMethods","products","variants","access","authenticatedOnly","req","user","Boolean","publicAccess"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,mDAAkD;AACvF,SAASC,GAAG,QAAQ,yBAAwB;AAM5C,OAAO,MAAMC,uBAAuB,CAAC,EAAEC,YAAY,EAAS;IAC1D,MAAMC,SAAS;QACb,GAAGD,YAAY;IACjB;IAEA,IAAI,OAAOC,OAAOC,SAAS,KAAK,aAAa;QAC3CD,OAAOC,SAAS,GAAG;YACjBC,MAAM;QACR;IACF;IAEA,IACE,OAAOF,OAAOG,SAAS,KAAK,eAC3B,OAAOH,OAAOG,SAAS,KAAK,aAAaH,OAAOG,SAAS,KAAK,MAC/D;QACAH,OAAOG,SAAS,GAAG;YACjBC,eAAeR;QACjB;IACF,OAAO;QACL,MAAMQ,gBACJ,AAAC,OAAOL,aAAaI,SAAS,KAAK,YACjC,OAAOJ,aAAaI,SAAS,CAACC,aAAa,KAAK,cAChDL,aAAaI,SAAS,CAACC,aAAa,CAAC;YACnCC,eAAeT;QACjB,MACFA;QAEFI,OAAOG,SAAS,GAAG;YACjB,GAAGH,OAAOG,SAAS;YACnBC;QACF;IACF;IAEA,IAAI,CAACJ,OAAOM,UAAU,EAAE;QACtBN,OAAOM,UAAU,GAAG;YAClBC,iBAAiB;YACjBC,qBAAqB;gBAACX;aAAI;QAC5B;IACF;IAEA,IACE,OAAOG,OAAOS,SAAS,KAAK,eAC3B,OAAOT,OAAOS,SAAS,KAAK,aAAaT,OAAOS,SAAS,KAAK,MAC/D;QACAT,OAAOS,SAAS,GAAG;YACjBC,WAAW;QACb;IACF;IAEA,IAAI,OAAOV,OAAOW,KAAK,KAAK,aAAa;QACvCX,OAAOW,KAAK,GAAG;IACjB;IAEA,IAAI,OAAOX,OAAOY,MAAM,KAAK,aAAa;QACxCZ,OAAOY,MAAM,GAAG;IAClB;IAEA,IAAI,OAAOZ,OAAOa,YAAY,KAAK,aAAa;QAC9Cb,OAAOa,YAAY,GAAG;IACxB;IAEA,IAAI,OAAOb,OAAOc,QAAQ,KAAK,aAAa;QAC1Cd,OAAOc,QAAQ,GAAG;YAChBC,gBAAgB,EAAE;QACpB;IACF,OAAO,IAAI,CAACf,OAAOc,QAAQ,CAACC,cAAc,EAAE;QAC1Cf,OAAOc,QAAQ,CAACC,cAAc,GAAG,EAAE;IACrC;IAEA,IAAIf,OAAOgB,QAAQ,EAAE;QACnB,IAAI,OAAOhB,OAAOgB,QAAQ,KAAK,YAAY,OAAOhB,OAAOgB,QAAQ,CAACC,QAAQ,KAAK,aAAa;YAC1FjB,OAAOgB,QAAQ,CAACC,QAAQ,GAAG;QAC7B;IACF;IAEAjB,OAAOkB,MAAM,GAAG;QACdC,mBAAmB,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAKC,QAAQD;QAClDE,cAAc,IAAM;QACpB,GAAGxB,aAAamB,MAAM;IACxB;IAEA,OAAOlB;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/sanitizePluginConfig.ts"],"sourcesContent":["import type { EcommercePluginConfig, SanitizedEcommercePluginConfig } from '../types/index.js'\n\nimport { defaultAddressFields } from '../collections/addresses/defaultAddressFields.js'\nimport { USD } from '../currencies/index.js'\n\ntype Props = {\n pluginConfig: EcommercePluginConfig\n}\n\nexport const sanitizePluginConfig = ({ pluginConfig }: Props): SanitizedEcommercePluginConfig => {\n const config = {\n ...pluginConfig,\n } as Partial<SanitizedEcommercePluginConfig>\n\n if (typeof config.customers === 'undefined') {\n config.customers = {\n slug: 'users',\n }\n }\n\n if (\n typeof config.addresses === 'undefined' ||\n (typeof config.addresses === 'boolean' && config.addresses === true)\n ) {\n config.addresses = {\n addressFields: defaultAddressFields(),\n }\n } else {\n const addressFields =\n (typeof pluginConfig.addresses === 'object' &&\n typeof pluginConfig.addresses.addressFields === 'function' &&\n pluginConfig.addresses.addressFields({\n defaultFields: defaultAddressFields(),\n })) ||\n defaultAddressFields()\n\n config.addresses = {\n ...config.addresses,\n addressFields,\n }\n }\n\n if (!config.currencies) {\n config.currencies = {\n defaultCurrency: 'USD',\n supportedCurrencies: [USD],\n }\n }\n\n if (\n typeof config.inventory === 'undefined' ||\n (typeof config.inventory === 'boolean' && config.inventory === true)\n ) {\n config.inventory = {\n fieldName: 'inventory',\n }\n }\n\n if (typeof config.carts === 'undefined') {\n config.carts = true\n }\n\n if (typeof config.orders === 'undefined') {\n config.orders = true\n }\n\n if (typeof config.transactions === 'undefined') {\n config.transactions = true\n }\n\n if (typeof config.payments === 'undefined') {\n config.payments = {\n paymentMethods: [],\n }\n } else if (!config.payments.paymentMethods) {\n config.payments.paymentMethods = []\n }\n\n if (config.products) {\n if (typeof config.products === 'object' && typeof config.products.variants === 'undefined') {\n config.products.variants = true\n }\n }\n\n config.access = {\n authenticatedOnly: ({ req: { user } }) => Boolean(user),\n publicAccess: () => true,\n ...pluginConfig.access,\n }\n\n return config as SanitizedEcommercePluginConfig\n}\n"],"names":["defaultAddressFields","USD","sanitizePluginConfig","pluginConfig","config","customers","slug","addresses","addressFields","defaultFields","currencies","defaultCurrency","supportedCurrencies","inventory","fieldName","carts","orders","transactions","payments","paymentMethods","products","variants","access","authenticatedOnly","req","user","Boolean","publicAccess"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,mDAAkD;AACvF,SAASC,GAAG,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I,CAACf,OAAOc,QAAQ,CAACC,cAAc,EAAE;QAC1Cf,OAAOc,QAAQ,CAACC,cAAc,GAAG,EAAE;IACrC;IAEA,IAAIf,OAAOgB,QAAQ,EAAE;QACnB,IAAI,OAAOhB,OAAOgB,QAAQ,KAAK,YAAY,OAAOhB,OAAOgB,QAAQ,CAACC,QAAQ,KAAK,aAAa;YAC1FjB,OAAOgB,QAAQ,CAACC,QAAQ,GAAG;QAC7B;IACF;IAEAjB,OAAOkB,MAAM,GAAG;QACdC,mBAAmB,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAKC,QAAQD;QAClDE,cAAc,IAAM;QACpB,GAAGxB,aAAamB,MAAM;IACxB;IAEA,OAAOlB;AACT,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-ecommerce",
3
- "version": "3.57.0-internal.f26caed",
3
+ "version": "3.58.0-canary.4",
4
4
  "description": "Ecommerce plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -69,21 +69,22 @@
69
69
  ],
70
70
  "dependencies": {
71
71
  "qs-esm": "7.0.2",
72
- "@payloadcms/translations": "3.57.0-internal.f26caed",
73
- "@payloadcms/ui": "3.57.0-internal.f26caed"
72
+ "@payloadcms/translations": "3.58.0-canary.4",
73
+ "@payloadcms/ui": "3.58.0-canary.4"
74
74
  },
75
75
  "devDependencies": {
76
+ "@types/json-schema": "7.0.15",
76
77
  "@types/react": "19.1.0",
77
78
  "@types/react-dom": "19.1.2",
78
79
  "stripe": "18.3.0",
79
- "@payloadcms/eslint-config": "3.28.0",
80
- "payload": "3.57.0-internal.f26caed",
81
- "@payloadcms/next": "3.57.0-internal.f26caed"
80
+ "@payloadcms/next": "3.58.0-canary.4",
81
+ "payload": "3.58.0-canary.4",
82
+ "@payloadcms/eslint-config": "3.28.0"
82
83
  },
83
84
  "peerDependencies": {
84
85
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
85
86
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
86
- "payload": "3.57.0-internal.f26caed"
87
+ "payload": "3.58.0-canary.4"
87
88
  },
88
89
  "publishConfig": {
89
90
  "registry": "https://registry.npmjs.org/"
@@ -1,172 +0,0 @@
1
- import type { DefaultDocumentIDType, PopulateType, SelectType, TypedCollection } from 'payload';
2
- import type React from 'react';
3
- import type { CurrenciesConfig, Currency, PaymentAdapterClient } from '../../types.js';
4
- type GeneratedTypes = import('payload').GeneratedTypes;
5
- export type SyncLocalStorageConfig = {
6
- /**
7
- * Key to use for localStorage.
8
- * Defaults to 'cart'.
9
- */
10
- key?: string;
11
- };
12
- type APIProps = {
13
- /**
14
- * The route for the Payload API, defaults to `/api`.
15
- */
16
- apiRoute?: string;
17
- /**
18
- * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.
19
- *
20
- * Defaults to `{ depth: 0 }`.
21
- */
22
- cartsFetchQuery?: {
23
- depth?: number;
24
- populate?: PopulateType;
25
- select?: SelectType;
26
- };
27
- /**
28
- * 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`.
29
- */
30
- serverURL?: string;
31
- };
32
- export type ContextProps = {
33
- /**
34
- * The slug for the addresses collection.
35
- *
36
- * Defaults to 'addresses'.
37
- */
38
- addressesSlug?: string;
39
- api?: APIProps;
40
- /**
41
- * The slug for the carts collection.
42
- *
43
- * Defaults to 'carts'.
44
- */
45
- cartsSlug?: string;
46
- children?: React.ReactNode;
47
- /**
48
- * The configuration for currencies used in the ecommerce context.
49
- * This is used to handle currency formatting and calculations, defaults to USD.
50
- */
51
- currenciesConfig?: CurrenciesConfig;
52
- /**
53
- * The slug for the customers collection.
54
- *
55
- * Defaults to 'users'.
56
- */
57
- customersSlug?: string;
58
- /**
59
- * Enable debug mode for the ecommerce context. This will log additional information to the console.
60
- * Defaults to false.
61
- */
62
- debug?: boolean;
63
- /**
64
- * Whether to enable support for variants in the cart.
65
- * This allows adding products with specific variants to the cart.
66
- * Defaults to false.
67
- */
68
- enableVariants?: boolean;
69
- /**
70
- * Supported payment methods for the ecommerce context.
71
- */
72
- paymentMethods?: PaymentAdapterClient[];
73
- /**
74
- * Whether to enable localStorage for cart persistence.
75
- * Defaults to true.
76
- */
77
- syncLocalStorage?: boolean | SyncLocalStorageConfig;
78
- };
79
- /**
80
- * Type used internally to represent the cart item to be added.
81
- */
82
- type CartItemArgument = {
83
- /**
84
- * The ID of the product to add to the cart. Always required.
85
- */
86
- product: DefaultDocumentIDType;
87
- /**
88
- * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.
89
- */
90
- variant?: DefaultDocumentIDType;
91
- };
92
- export type EcommerceContext = {
93
- /**
94
- * Add an item to the cart.
95
- */
96
- addItem: (item: CartItemArgument, quantity?: number) => Promise<void>;
97
- /**
98
- * All current addresses for the current user.
99
- * This is used to manage shipping and billing addresses.
100
- */
101
- addresses?: TypedCollection['addresses'][];
102
- /**
103
- * The current data of the cart.
104
- */
105
- cart?: GeneratedTypes['collections']['carts'];
106
- /**
107
- * The ID of the current cart corresponding to the cart in the database or local storage.
108
- */
109
- cartID?: DefaultDocumentIDType;
110
- /**
111
- * Clear the cart, removing all items.
112
- */
113
- clearCart: () => Promise<void>;
114
- /**
115
- * Initiate a payment using the selected payment method.
116
- * This method should be called after the cart is ready for checkout.
117
- * It requires the payment method ID and any necessary payment data.
118
- */
119
- confirmOrder: (paymentMethodID: string, options?: {
120
- additionalData: Record<string, unknown>;
121
- }) => Promise<unknown>;
122
- /**
123
- * Create a new address by providing the data.
124
- */
125
- createAddress: (data: Partial<TypedCollection['addresses']>) => Promise<void>;
126
- /**
127
- * The configuration for the currencies used in the ecommerce context.
128
- */
129
- currenciesConfig: CurrenciesConfig;
130
- /**
131
- * The currently selected currency used for the cart and price formatting automatically.
132
- */
133
- currency: Currency;
134
- /**
135
- * Decrement an item in the cart by its index ID.
136
- * If quantity reaches 0, the item will be removed from the cart.
137
- */
138
- decrementItem: (item: DefaultDocumentIDType) => Promise<void>;
139
- /**
140
- * Increment an item in the cart by its index ID.
141
- */
142
- incrementItem: (item: DefaultDocumentIDType) => Promise<void>;
143
- /**
144
- * Initiate a payment using the selected payment method.
145
- * This method should be called after the cart is ready for checkout.
146
- * It requires the payment method ID and any necessary payment data.
147
- */
148
- initiatePayment: (paymentMethodID: string, options?: {
149
- additionalData: Record<string, unknown>;
150
- }) => Promise<unknown>;
151
- paymentMethods: PaymentAdapterClient[];
152
- /**
153
- * Remove an item from the cart by its index ID.
154
- */
155
- removeItem: (item: DefaultDocumentIDType) => Promise<void>;
156
- /**
157
- * The name of the currently selected payment method.
158
- * This is used to determine which payment method to use when initiating a payment.
159
- */
160
- selectedPaymentMethod?: null | string;
161
- /**
162
- * Change the currency for the cart, it defaults to the configured currency.
163
- * This will update the currency used for pricing and calculations.
164
- */
165
- setCurrency: (currency: string) => void;
166
- /**
167
- * Update an address by providing the data and the ID.
168
- */
169
- updateAddress: (addressID: DefaultDocumentIDType, data: Partial<TypedCollection['addresses']>) => Promise<void>;
170
- };
171
- export {};
172
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/provider/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAGtF,KAAK,cAAc,GAAG,OAAO,SAAS,EAAE,cAAc,CAAA;AAEtD,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,QAAQ,GAAG;IACd;;OAEG;IACH,QAAQ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EAAE,qBAAqB,EAChC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,KACxC,OAAO,CAAC,IAAI,CAAC,CAAA;CACnB,CAAA"}
@@ -1,3 +0,0 @@
1
- export { };
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/react/provider/types.ts"],"sourcesContent":["import type { DefaultDocumentIDType, PopulateType, SelectType, TypedCollection } from 'payload'\nimport type React from 'react'\n\nimport type { CurrenciesConfig, Currency, PaymentAdapterClient } from '../../types.js'\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype GeneratedTypes = import('payload').GeneratedTypes\n\nexport type SyncLocalStorageConfig = {\n /**\n * Key to use for localStorage.\n * Defaults to 'cart'.\n */\n key?: string\n}\n\ntype APIProps = {\n /**\n * The route for the Payload API, defaults to `/api`.\n */\n apiRoute?: string\n /**\n * Customise the query used to fetch carts. Use this when you need to fetch additional data and optimise queries using depth, select and populate.\n *\n * Defaults to `{ depth: 0 }`.\n */\n cartsFetchQuery?: {\n depth?: number\n populate?: PopulateType\n select?: SelectType\n }\n /**\n * The route for the Payload API, defaults to ``. Eg for a Payload app running on `http://localhost:3000`, the default serverURL would be `http://localhost:3000`.\n */\n serverURL?: string\n}\n\nexport type ContextProps = {\n /**\n * The slug for the addresses collection.\n *\n * Defaults to 'addresses'.\n */\n addressesSlug?: string\n api?: APIProps\n /**\n * The slug for the carts collection.\n *\n * Defaults to 'carts'.\n */\n cartsSlug?: string\n children?: React.ReactNode\n /**\n * The configuration for currencies used in the ecommerce context.\n * This is used to handle currency formatting and calculations, defaults to USD.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The slug for the customers collection.\n *\n * Defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Enable debug mode for the ecommerce context. This will log additional information to the console.\n * Defaults to false.\n */\n debug?: boolean\n /**\n * Whether to enable support for variants in the cart.\n * This allows adding products with specific variants to the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Supported payment methods for the ecommerce context.\n */\n paymentMethods?: PaymentAdapterClient[]\n /**\n * Whether to enable localStorage for cart persistence.\n * Defaults to true.\n */\n syncLocalStorage?: boolean | SyncLocalStorageConfig\n}\n\n/**\n * Type used internally to represent the cart item to be added.\n */\ntype CartItemArgument = {\n /**\n * The ID of the product to add to the cart. Always required.\n */\n product: DefaultDocumentIDType\n /**\n * The ID of the variant to add to the cart. Optional, if not provided, the product will be added without a variant.\n */\n variant?: DefaultDocumentIDType\n}\n\nexport type EcommerceContext = {\n /**\n * Add an item to the cart.\n */\n addItem: (item: CartItemArgument, quantity?: number) => Promise<void>\n /**\n * All current addresses for the current user.\n * This is used to manage shipping and billing addresses.\n */\n addresses?: TypedCollection['addresses'][]\n /**\n * The current data of the cart.\n */\n // @ts-ignore\n cart?: GeneratedTypes['collections']['carts']\n /**\n * The ID of the current cart corresponding to the cart in the database or local storage.\n */\n cartID?: DefaultDocumentIDType\n /**\n * Clear the cart, removing all items.\n */\n clearCart: () => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n confirmOrder: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n /**\n * Create a new address by providing the data.\n */\n createAddress: (data: Partial<TypedCollection['addresses']>) => Promise<void>\n /**\n * The configuration for the currencies used in the ecommerce context.\n */\n currenciesConfig: CurrenciesConfig\n /**\n * The currently selected currency used for the cart and price formatting automatically.\n */\n currency: Currency\n /**\n * Decrement an item in the cart by its index ID.\n * If quantity reaches 0, the item will be removed from the cart.\n */\n decrementItem: (item: DefaultDocumentIDType) => Promise<void>\n /**\n * Increment an item in the cart by its index ID.\n */\n incrementItem: (item: DefaultDocumentIDType) => Promise<void>\n /**\n * Initiate a payment using the selected payment method.\n * This method should be called after the cart is ready for checkout.\n * It requires the payment method ID and any necessary payment data.\n */\n initiatePayment: (\n paymentMethodID: string,\n options?: { additionalData: Record<string, unknown> },\n ) => Promise<unknown>\n paymentMethods: PaymentAdapterClient[]\n /**\n * Remove an item from the cart by its index ID.\n */\n removeItem: (item: DefaultDocumentIDType) => Promise<void>\n /**\n * The name of the currently selected payment method.\n * This is used to determine which payment method to use when initiating a payment.\n */\n selectedPaymentMethod?: null | string\n /**\n * Change the currency for the cart, it defaults to the configured currency.\n * This will update the currency used for pricing and calculations.\n */\n setCurrency: (currency: string) => void\n /**\n * Update an address by providing the data and the ID.\n */\n updateAddress: (\n addressID: DefaultDocumentIDType,\n data: Partial<TypedCollection['addresses']>,\n ) => Promise<void>\n}\n"],"names":[],"mappings":"AAmGA,WAoFC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,qBAAqB,EACrB,QAAQ,EACR,KAAK,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACV,eAAe,EACf,KAAK,EACN,MAAM,SAAS,CAAA;AAEhB,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE;IAAE,aAAa,EAAE,KAAK,EAAE,CAAA;CAAE,KAAK,KAAK,EAAE,CAAA;AAE1E,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE;IACtC,iBAAiB,EAAE,gBAAgB,CAAA;CACpC,KAAK,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAElD,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,qBAAqB,CAAA;IACzB,OAAO,EAAE,qBAAqB,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;IAC5D,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,qBAAqB,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;CAC9D,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,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C,EAAE,OAAO,GAAG,kBAAkB,CAAA;CAC5C,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAA;IAC9B,SAAS,EAAE;QAAE,aAAa,EAAE,KAAK,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,CAAA;IAC9E,UAAU,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAA;IACtC,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,QAAQ,EAAE;QACR,cAAc,EAAE,EAAE,GAAG,cAAc,EAAE,CAAA;KACtC,CAAA;CACF,GAAG,IAAI,CACN,QAAQ,CAAC,qBAAqB,CAAC,EAC/B,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,UAAU,CACjE,CAAA"}
package/dist/types.js DELETED
@@ -1,3 +0,0 @@
1
- export { };
2
-
3
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n Access,\n CollectionConfig,\n DefaultDocumentIDType,\n Endpoint,\n Field,\n FieldAccess,\n GroupField,\n PayloadRequest,\n SelectType,\n TypedCollection,\n Where,\n} from 'payload'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type CollectionOverride = (args: {\n defaultCollection: CollectionConfig\n}) => CollectionConfig | Promise<CollectionConfig>\n\nexport type CartItem = {\n id: DefaultDocumentIDType\n product: DefaultDocumentIDType | TypedCollection['products']\n quantity: number\n variant?: DefaultDocumentIDType | TypedCollection['variants']\n}\n\ntype DefaultCartType = {\n currency?: string\n customer?: DefaultDocumentIDType | TypedCollection['customers']\n id: DefaultDocumentIDType\n items: CartItem[]\n subtotal?: number\n}\n\nexport type Cart = DefaultCartType\n\ntype InitiatePaymentReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n}\n\ntype InitiatePayment = (args: {\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n data: {\n /**\n * Billing address for the payment.\n */\n billingAddress: TypedCollection['addresses']\n /**\n * Cart items.\n */\n cart: Cart\n /**\n * Currency code to use for the payment.\n */\n currency: string\n customerEmail: string\n /**\n * Shipping address for the payment.\n */\n shippingAddress?: TypedCollection['addresses']\n }\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug: string\n}) => InitiatePaymentReturnType | Promise<InitiatePaymentReturnType>\n\ntype ConfirmOrderReturnType = {\n /**\n * Allows for additional data to be returned, such as payment method specific data\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n message: string\n orderID: DefaultDocumentIDType\n transactionID: DefaultDocumentIDType\n}\n\ntype ConfirmOrder = (args: {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n * For example, this is used to retrieve the cart for the order.\n */\n cartsSlug?: string\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Data made available to the payment method when confirming an order. You should get the cart items from the transaction.\n */\n data: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any // Allows for additional data to be passed through, such as payment method specific data\n customerEmail?: string\n }\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n req: PayloadRequest\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n * For example, this is used to create a record of the payment intent in the transactions collection.\n */\n transactionsSlug?: string\n}) => ConfirmOrderReturnType | Promise<ConfirmOrderReturnType>\n\n/**\n * The full payment adapter config expected as part of the config for the Ecommerce plugin.\n *\n * You can insert this type directly or return it from a function constructing it.\n */\nexport type PaymentAdapter = {\n /**\n * The function that is called via the `/api/payments/{provider_name}/confirm-order` endpoint to confirm an order after a payment has been made.\n *\n * You should handle the order confirmation logic here.\n *\n * @example\n *\n * ```ts\n * const confirmOrder: ConfirmOrder = async ({ data: { customerEmail }, ordersSlug, req, transactionsSlug }) => {\n // Confirm the payment with Stripe or another payment provider here\n // Create an order in the orders collection here\n // Update the record of the payment intent in the transactions collection here\n return {\n message: 'Order confirmed successfully',\n orderID: 'order_123',\n transactionID: 'txn_123',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n confirmOrder: ConfirmOrder\n /**\n * An array of endpoints to be bootstrapped to Payload's API in order to support the payment method. All API paths are relative to `/api/payments/{provider_name}`.\n *\n * So for example, path `/webhooks` in the Stripe adapter becomes `/api/payments/stripe/webhooks`.\n *\n * @example '/webhooks'\n */\n endpoints?: Endpoint[]\n /**\n * A group configuration to be used in the admin interface to display the payment method.\n *\n * @example\n *\n * ```ts\n * const groupField: GroupField = {\n name: 'stripe',\n type: 'group',\n admin: {\n condition: (data) => data?.paymentMethod === 'stripe',\n },\n fields: [\n {\n name: 'stripeCustomerID',\n type: 'text',\n label: 'Stripe Customer ID',\n required: true,\n },\n {\n name: 'stripePaymentIntentID',\n type: 'text',\n label: 'Stripe PaymentIntent ID',\n required: true,\n },\n ],\n }\n * ```\n */\n group: GroupField\n /**\n * The function that is called via the `/api/payments/{provider_name}/initiate` endpoint to initiate a payment for an order.\n *\n * You should handle the payment initiation logic here.\n *\n * @example\n *\n * ```ts\n * const initiatePayment: InitiatePayment = async ({ data: { cart, currency, customerEmail, billingAddress, shippingAddress }, req, transactionsSlug }) => {\n // Create a payment intent with Stripe or another payment provider here\n // Create a record of the payment intent in the transactions collection here\n return {\n message: 'Payment initiated successfully',\n // Include any additional data required for the payment method here\n }\n }\n * ```\n */\n initiatePayment: InitiatePayment\n /**\n * The label of the payment method\n * @example\n * 'Bank Transfer'\n */\n label?: string\n /**\n * The name of the payment method\n * @example 'stripe'\n */\n name: string\n}\n\nexport type PaymentAdapterClient = {\n confirmOrder: boolean\n initiatePayment: boolean\n} & Pick<PaymentAdapter, 'label' | 'name'>\n\nexport type Currency = {\n /**\n * The ISO 4217 currency code\n * @example 'usd'\n */\n code: string\n /**\n * The number of decimal places the currency uses\n * @example 2\n */\n decimals: number\n /**\n * A user friendly name for the currency.\n *\n * @example 'US Dollar'\n */\n label: string\n /**\n * The symbol of the currency\n * @example '$'\n */\n symbol: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterArgs = {\n /**\n * Overrides the default fields of the collection. Affects the payment fields on collections such as transactions.\n */\n groupOverrides?: { fields?: FieldsOverride } & Partial<Omit<GroupField, 'fields'>>\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\n/**\n * Commonly used arguments for a Payment Adapter function, it's use is entirely optional.\n */\nexport type PaymentAdapterClientArgs = {\n /**\n * The visually readable label for the payment method.\n * @example 'Bank Transfer'\n */\n label?: string\n}\n\nexport type VariantsConfig = {\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantOptionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantOptionsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantsCollectionOverride?: CollectionOverride\n /**\n * Override the default variants collection. If you override the collection, you should ensure it has the required fields for variants or re-use the default fields.\n *\n * @example\n *\n * ```ts\n * variants: {\n variantTypesCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'customField',\n label: 'Custom Field',\n type: 'text',\n },\n ],\n })\n }\n ```\n */\n variantTypesCollectionOverride?: CollectionOverride\n}\n\nexport type ProductsConfig = {\n /**\n * Override the default products collection. If you override the collection, you should ensure it has the required fields for products or re-use the default fields.\n *\n * @example\n *\n * ```ts\n products: {\n productsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n productsCollectionOverride?: CollectionOverride\n /**\n * Customise the validation used for checking products or variants before a transaction is created or a payment can be confirmed.\n */\n validation?: ProductsValidation\n /**\n * Enable variants and provide configuration for the variant collections.\n *\n * Defaults to true.\n */\n variants?: boolean | VariantsConfig\n}\n\nexport type OrdersConfig = {\n /**\n * Override the default orders collection. If you override the collection, you should ensure it has the required fields for orders or re-use the default fields.\n *\n * @example\n *\n * ```ts\n orders: {\n ordersCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n ordersCollectionOverride?: CollectionOverride\n}\n\nexport type TransactionsConfig = {\n /**\n * Override the default transactions collection. If you override the collection, you should ensure it has the required fields for transactions or re-use the default fields.\n *\n * @example\n *\n * ```ts\n transactions: {\n transactionsCollectionOverride: ({ defaultCollection }) => ({\n ...defaultCollection,\n fields: [\n ...defaultCollection.fields,\n {\n name: 'notes',\n label: 'Notes',\n type: 'textarea',\n },\n ],\n })\n }\n ```\n */\n transactionsCollectionOverride?: CollectionOverride\n}\n\nexport type CustomQuery = {\n depth?: number\n select?: SelectType\n where?: Where\n}\n\nexport type PaymentsConfig = {\n paymentMethods?: PaymentAdapter[]\n productsQuery?: CustomQuery\n variantsQuery?: CustomQuery\n}\n\nexport type CountryType = {\n /**\n * A user friendly name for the country.\n */\n label: string\n /**\n * The ISO 3166-1 alpha-2 country code.\n * @example 'US'\n */\n value: string\n}\n\n/**\n * Configuration for the addresses used by the Ecommerce plugin. Use this to override the default collection or fields used throughout\n */\ntype AddressesConfig = {\n /**\n * Override the default addresses collection. If you override the collection, you should ensure it has the required fields for addresses or re-use the default fields.\n *\n * @example\n * ```ts\n * addressesCollectionOverride: (defaultCollection) => {\n * return {\n * ...defaultCollection,\n * fields: [\n * ...defaultCollection.fields,\n * // add custom fields here\n * ],\n * }\n * }\n * ```\n */\n addressesCollectionOverride?: CollectionOverride\n /**\n * These fields will be applied to all locations where addresses are used, such as Orders and Transactions. Preferred use over the collectionOverride config.\n */\n addressFields?: FieldsOverride\n /**\n * Provide an array of countries to support for addresses. This will be used in the admin interface to provide a select field of countries.\n *\n * Defaults to a set of commonly used countries.\n *\n * @example\n * ```\n * [\n { label: 'United States', value: 'US' },\n { label: 'Canada', value: 'CA' },\n ]\n */\n supportedCountries?: CountryType[]\n}\n\nexport type CustomersConfig = {\n /**\n * Slug of the customers collection, defaults to 'users'.\n * This is used to link carts and orders to customers.\n */\n slug: string\n}\n\nexport type CartsConfig = {\n cartsCollectionOverride?: CollectionOverride\n}\n\nexport type InventoryConfig = {\n /**\n * Override the default field used to track inventory levels. Defaults to 'inventory'.\n */\n fieldName?: string\n}\n\nexport type CurrenciesConfig = {\n /**\n * Defaults to the first supported currency.\n *\n * @example 'USD'\n */\n defaultCurrency: string\n /**\n *\n */\n supportedCurrencies: Currency[]\n}\n\n/**\n * A function that validates a product or variant before a transaction is created or completed.\n * This should throw an error if validation fails as it will be caught by the function calling it.\n */\nexport type ProductsValidation = (args: {\n /**\n * The full currencies config, allowing you to check against supported currencies and their settings.\n */\n currenciesConfig?: CurrenciesConfig\n /**\n * The ISO 4217 currency code being usen in this transaction.\n */\n currency?: string\n /**\n * The full product data.\n */\n product: TypedCollection['products']\n /**\n * Quantity to check the inventory amount against.\n */\n quantity: number\n /**\n * The full variant data, if a variant was selected for the product otherwise it will be undefined.\n */\n variant?: TypedCollection['variants']\n}) => Promise<void> | void\n\n/**\n * A map of collection slugs used by the Ecommerce plugin.\n * Provides an easy way to track the slugs of collections even when they are overridden.\n */\nexport type CollectionSlugMap = {\n addresses: string\n carts: string\n customers: string\n orders: string\n products: string\n transactions: string\n variantOptions: string\n variants: string\n variantTypes: string\n}\n\n/**\n * Access control functions used throughout the Ecommerce plugin.\n * You must provide these when configuring the plugin.\n *\n * @example\n *\n * ```ts\n * access: {\n adminOnly,\n adminOnlyFieldAccess,\n adminOrCustomerOwner,\n adminOrPublishedStatus,\n customerOnlyFieldAccess,\n }\n ```\n */\nexport type AccessConfig = {\n /**\n * Limited to only admin users.\n */\n adminOnly: Access\n /**\n * Limited to only admin users, specifically for Field level access control.\n */\n adminOnlyFieldAccess: FieldAccess\n /**\n * Is the owner of the document via the `customer` field or is an admin.\n */\n adminOrCustomerOwner: Access\n /**\n * The document status is published or user is admin.\n */\n adminOrPublishedStatus: Access\n /**\n * Authenticated users only. Defaults to the example function.\n *\n * @example\n * anyUser: ({ req }) => !!req?.user\n */\n authenticatedOnly?: Access\n /**\n * Limited to customers only, specifically for Field level access control.\n */\n customerOnlyFieldAccess: FieldAccess\n /**\n * Entirely public access. Defaults to the example function.\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 * Enable tracking of transactions. Accepts a config object to override the default collection settings.\n *\n * Defaults to true when the paymentMethods array is provided.\n */\n transactions?: boolean | TransactionsConfig\n}\n\nexport type SanitizedEcommercePluginConfig = {\n access: Required<AccessConfig>\n addresses: { addressFields: Field[] } & Omit<AddressesConfig, 'addressFields'>\n currencies: Required<CurrenciesConfig>\n inventory?: InventoryConfig\n payments: {\n paymentMethods: [] | PaymentAdapter[]\n }\n} & Omit<\n Required<EcommercePluginConfig>,\n 'access' | 'addresses' | 'currencies' | 'inventory' | 'payments'\n>\n"],"names":[],"mappings":"AA+qBA,WAWC"}