@payloadcms/plugin-ecommerce 3.57.0-internal.f26caed → 3.58.0-canary.5
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/addresses/createAddressesCollection.d.ts +1 -1
- package/dist/collections/addresses/createAddressesCollection.d.ts.map +1 -1
- package/dist/collections/addresses/createAddressesCollection.js +1 -0
- package/dist/collections/addresses/createAddressesCollection.js.map +1 -1
- package/dist/collections/addresses/defaultCountries.d.ts +1 -1
- package/dist/collections/addresses/defaultCountries.d.ts.map +1 -1
- package/dist/collections/addresses/defaultCountries.js.map +1 -1
- package/dist/collections/addresses/hooks/beforeChange.d.ts +1 -1
- package/dist/collections/addresses/hooks/beforeChange.d.ts.map +1 -1
- package/dist/collections/addresses/hooks/beforeChange.js.map +1 -1
- package/dist/collections/carts/createCartsCollection.d.ts +1 -1
- package/dist/collections/carts/createCartsCollection.d.ts.map +1 -1
- package/dist/collections/carts/createCartsCollection.js.map +1 -1
- package/dist/collections/orders/createOrdersCollection.d.ts +1 -1
- package/dist/collections/orders/createOrdersCollection.d.ts.map +1 -1
- package/dist/collections/orders/createOrdersCollection.js.map +1 -1
- package/dist/collections/products/createProductsCollection.d.ts +1 -1
- package/dist/collections/products/createProductsCollection.d.ts.map +1 -1
- package/dist/collections/products/createProductsCollection.js.map +1 -1
- package/dist/collections/transactions/createTransactionsCollection.d.ts +1 -1
- package/dist/collections/transactions/createTransactionsCollection.d.ts.map +1 -1
- package/dist/collections/transactions/createTransactionsCollection.js.map +1 -1
- package/dist/collections/variants/createVariantOptionsCollection.d.ts +1 -1
- package/dist/collections/variants/createVariantOptionsCollection.d.ts.map +1 -1
- package/dist/collections/variants/createVariantOptionsCollection.js.map +1 -1
- package/dist/collections/variants/createVariantTypesCollection.d.ts +1 -1
- package/dist/collections/variants/createVariantTypesCollection.d.ts.map +1 -1
- package/dist/collections/variants/createVariantTypesCollection.js.map +1 -1
- package/dist/collections/variants/createVariantsCollection/index.d.ts +1 -1
- package/dist/collections/variants/createVariantsCollection/index.d.ts.map +1 -1
- package/dist/collections/variants/createVariantsCollection/index.js.map +1 -1
- package/dist/currencies/index.d.ts +1 -1
- package/dist/currencies/index.d.ts.map +1 -1
- package/dist/currencies/index.js.map +1 -1
- package/dist/endpoints/confirmOrder.d.ts +1 -1
- package/dist/endpoints/confirmOrder.d.ts.map +1 -1
- package/dist/endpoints/confirmOrder.js.map +1 -1
- package/dist/endpoints/initiatePayment.d.ts +1 -1
- package/dist/endpoints/initiatePayment.d.ts.map +1 -1
- package/dist/endpoints/initiatePayment.js.map +1 -1
- package/dist/exports/types.d.ts +2 -1
- package/dist/exports/types.d.ts.map +1 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/fields/amountField.d.ts +1 -1
- package/dist/fields/amountField.d.ts.map +1 -1
- package/dist/fields/amountField.js.map +1 -1
- package/dist/fields/cartItemsField.d.ts +1 -1
- package/dist/fields/cartItemsField.d.ts.map +1 -1
- package/dist/fields/cartItemsField.js.map +1 -1
- package/dist/fields/currencyField.d.ts +1 -1
- package/dist/fields/currencyField.d.ts.map +1 -1
- package/dist/fields/currencyField.js.map +1 -1
- package/dist/fields/pricesField.d.ts +1 -1
- package/dist/fields/pricesField.d.ts.map +1 -1
- package/dist/fields/pricesField.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/payments/adapters/stripe/confirmOrder.d.ts +1 -1
- package/dist/payments/adapters/stripe/confirmOrder.d.ts.map +1 -1
- package/dist/payments/adapters/stripe/confirmOrder.js.map +1 -1
- package/dist/payments/adapters/stripe/index.d.ts +1 -1
- 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 +1 -1
- package/dist/payments/adapters/stripe/initiatePayment.d.ts.map +1 -1
- package/dist/payments/adapters/stripe/initiatePayment.js.map +1 -1
- package/dist/react/provider/index.d.ts +15 -10
- package/dist/react/provider/index.d.ts.map +1 -1
- package/dist/react/provider/index.js +21 -22
- package/dist/react/provider/index.js.map +1 -1
- package/dist/react/provider/utilities.d.ts +1 -1
- package/dist/react/provider/utilities.d.ts.map +1 -1
- package/dist/react/provider/utilities.js.map +1 -1
- package/dist/translations/en.d.ts.map +1 -1
- package/dist/translations/en.js +1 -0
- package/dist/translations/en.js.map +1 -1
- package/dist/{types.d.ts → types/index.d.ts} +177 -2
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/utilities.d.ts +36 -0
- package/dist/types/utilities.d.ts.map +1 -0
- package/dist/types/utilities.js +3 -0
- package/dist/types/utilities.js.map +1 -0
- package/dist/ui/PriceCell/index.d.ts +1 -1
- package/dist/ui/PriceCell/index.d.ts.map +1 -1
- package/dist/ui/PriceCell/index.js.map +1 -1
- package/dist/ui/PriceInput/FormattedInput.d.ts +1 -1
- package/dist/ui/PriceInput/FormattedInput.d.ts.map +1 -1
- package/dist/ui/PriceInput/FormattedInput.js.map +1 -1
- package/dist/ui/PriceInput/index.d.ts +1 -1
- package/dist/ui/PriceInput/index.d.ts.map +1 -1
- package/dist/ui/PriceInput/index.js.map +1 -1
- package/dist/ui/PriceRowLabel/index.d.ts +1 -1
- package/dist/ui/PriceRowLabel/index.d.ts.map +1 -1
- package/dist/ui/PriceRowLabel/index.js.map +1 -1
- package/dist/ui/utilities.d.ts +1 -1
- package/dist/ui/utilities.d.ts.map +1 -1
- package/dist/ui/utilities.js.map +1 -1
- package/dist/utilities/defaultProductsValidation.d.ts +1 -1
- package/dist/utilities/defaultProductsValidation.d.ts.map +1 -1
- package/dist/utilities/defaultProductsValidation.js.map +1 -1
- package/dist/utilities/getCollectionSlugMap.d.ts +1 -1
- package/dist/utilities/getCollectionSlugMap.d.ts.map +1 -1
- package/dist/utilities/getCollectionSlugMap.js +5 -4
- package/dist/utilities/getCollectionSlugMap.js.map +1 -1
- package/dist/utilities/pushTypeScriptProperties.d.ts +10 -0
- package/dist/utilities/pushTypeScriptProperties.d.ts.map +1 -0
- package/dist/utilities/pushTypeScriptProperties.js +37 -0
- package/dist/utilities/pushTypeScriptProperties.js.map +1 -0
- package/dist/utilities/sanitizePluginConfig.d.ts +1 -1
- package/dist/utilities/sanitizePluginConfig.d.ts.map +1 -1
- package/dist/utilities/sanitizePluginConfig.js.map +1 -1
- package/package.json +7 -6
- package/dist/react/provider/types.d.ts +0 -172
- package/dist/react/provider/types.d.ts.map +0 -1
- package/dist/react/provider/types.js +0 -3
- package/dist/react/provider/types.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionConfig, Field } from 'payload';
|
|
2
|
-
import type { AccessConfig, CountryType } from '../../types.js';
|
|
2
|
+
import type { AccessConfig, CountryType } from '../../types/index.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
access: {
|
|
5
5
|
adminOrCustomerOwner: AccessConfig['adminOrCustomerOwner'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAddressesCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/addresses/createAddressesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createAddressesCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/addresses/createAddressesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAKrE,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,oBAAoB,EAAE,YAAY,CAAC,sBAAsB,CAAC,CAAA;QAC1D,iBAAiB,EAAE,WAAW,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAA;QACjE,uBAAuB,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAA;KACjE,CAAA;IACD;;OAEG;IACH,aAAa,EAAE,KAAK,EAAE,CAAA;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kBAAkB,CAAC,EAAE,WAAW,EAAE,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBA6EzD,CAAA"}
|
|
@@ -45,6 +45,7 @@ export const createAddressesCollection = (props)=>{
|
|
|
45
45
|
description: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
46
46
|
t('plugin-ecommerce:addressesCollectionDescription'),
|
|
47
47
|
group: 'Ecommerce',
|
|
48
|
+
hidden: true,
|
|
48
49
|
useAsTitle: 'createdAt'
|
|
49
50
|
},
|
|
50
51
|
fields,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/addresses/createAddressesCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CountryType } from '../../types.js'\n\nimport { defaultCountries } from './defaultCountries.js'\nimport { beforeChange } from './hooks/beforeChange.js'\n\ntype Props = {\n access: {\n adminOrCustomerOwner: AccessConfig['adminOrCustomerOwner']\n authenticatedOnly: NonNullable<AccessConfig['authenticatedOnly']>\n customerOnlyFieldAccess: AccessConfig['customerOnlyFieldAccess']\n }\n /**\n * Array of fields used for capturing the address data. Use this over overrides to customise the fields here as it's reused across the plugin.\n */\n addressFields: Field[]\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n supportedCountries?: CountryType[]\n}\n\nexport const createAddressesCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOrCustomerOwner, authenticatedOnly, customerOnlyFieldAccess },\n addressFields,\n customersSlug = 'users',\n } = props || {}\n\n const { supportedCountries: supportedCountriesFromProps } = props || {}\n const supportedCountries = supportedCountriesFromProps || defaultCountries\n const hasOnlyOneCountry = supportedCountries && supportedCountries.length === 1\n\n const fields: Field[] = [\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n ...addressFields.map((field) => {\n if ('name' in field && field.name === 'country') {\n return {\n name: 'country',\n type: 'select',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addressCountry'),\n options: supportedCountries || defaultCountries,\n required: true,\n ...(supportedCountries && supportedCountries?.[0] && hasOnlyOneCountry\n ? {\n defaultValue: supportedCountries?.[0].value,\n }\n : {}),\n } as Field\n }\n\n return field\n }),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'addresses',\n access: {\n create: authenticatedOnly,\n delete: adminOrCustomerOwner,\n read: adminOrCustomerOwner,\n update: adminOrCustomerOwner,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addressesCollectionDescription'),\n group: 'Ecommerce',\n useAsTitle: 'createdAt',\n },\n fields,\n hooks: {\n beforeChange: [beforeChange({ customerOnlyFieldAccess })],\n },\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addresses'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:address'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["defaultCountries","beforeChange","createAddressesCollection","props","access","adminOrCustomerOwner","authenticatedOnly","customerOnlyFieldAccess","addressFields","customersSlug","supportedCountries","supportedCountriesFromProps","hasOnlyOneCountry","length","fields","name","type","admin","position","label","t","relationTo","map","field","options","required","defaultValue","value","baseConfig","slug","create","delete","read","update","description","group","useAsTitle","hooks","labels","plural","singular","timestamps"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,0BAAyB;AAmBtD,OAAO,MAAMC,4BAAgE,CAACC;IAC5E,MAAM,EACJC,QAAQ,EAAEC,oBAAoB,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAE,EAC5EC,aAAa,EACbC,gBAAgB,OAAO,EACxB,GAAGN,SAAS,CAAC;IAEd,MAAM,EAAEO,oBAAoBC,2BAA2B,EAAE,GAAGR,SAAS,CAAC;IACtE,MAAMO,qBAAqBC,+BAA+BX;IAC1D,MAAMY,oBAAoBF,sBAAsBA,mBAAmBG,MAAM,KAAK;IAE9E,MAAMC,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;gBAC/DA,EAAE;YACJC,YAAYZ;QACd;WACGD,cAAcc,GAAG,CAAC,CAACC;YACpB,IAAI,UAAUA,SAASA,MAAMR,IAAI,KAAK,WAAW;gBAC/C,OAAO;oBACLA,MAAM;oBACNC,MAAM;oBACNG,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;wBAC/DA,EAAE;oBACJI,SAASd,sBAAsBV;oBAC/ByB,UAAU;oBACV,GAAIf,sBAAsBA,oBAAoB,CAAC,EAAE,IAAIE,oBACjD;wBACEc,cAAchB,oBAAoB,CAAC,EAAE,CAACiB;oBACxC,IACA,CAAC,CAAC;gBACR;YACF;YAEA,OAAOJ;QACT;KACD;IAED,MAAMK,aAA+B;QACnCC,MAAM;QACNzB,QAAQ;YACN0B,QAAQxB;YACRyB,QAAQ1B;YACR2B,MAAM3B;YACN4B,QAAQ5B;QACV;QACAY,OAAO;YACLiB,aAAa,CAAC,EAAEd,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJe,OAAO;YACPC,YAAY;QACd;
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/addresses/createAddressesCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CountryType } from '../../types/index.js'\n\nimport { defaultCountries } from './defaultCountries.js'\nimport { beforeChange } from './hooks/beforeChange.js'\n\ntype Props = {\n access: {\n adminOrCustomerOwner: AccessConfig['adminOrCustomerOwner']\n authenticatedOnly: NonNullable<AccessConfig['authenticatedOnly']>\n customerOnlyFieldAccess: AccessConfig['customerOnlyFieldAccess']\n }\n /**\n * Array of fields used for capturing the address data. Use this over overrides to customise the fields here as it's reused across the plugin.\n */\n addressFields: Field[]\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n supportedCountries?: CountryType[]\n}\n\nexport const createAddressesCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOrCustomerOwner, authenticatedOnly, customerOnlyFieldAccess },\n addressFields,\n customersSlug = 'users',\n } = props || {}\n\n const { supportedCountries: supportedCountriesFromProps } = props || {}\n const supportedCountries = supportedCountriesFromProps || defaultCountries\n const hasOnlyOneCountry = supportedCountries && supportedCountries.length === 1\n\n const fields: Field[] = [\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n ...addressFields.map((field) => {\n if ('name' in field && field.name === 'country') {\n return {\n name: 'country',\n type: 'select',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addressCountry'),\n options: supportedCountries || defaultCountries,\n required: true,\n ...(supportedCountries && supportedCountries?.[0] && hasOnlyOneCountry\n ? {\n defaultValue: supportedCountries?.[0].value,\n }\n : {}),\n } as Field\n }\n\n return field\n }),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'addresses',\n access: {\n create: authenticatedOnly,\n delete: adminOrCustomerOwner,\n read: adminOrCustomerOwner,\n update: adminOrCustomerOwner,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addressesCollectionDescription'),\n group: 'Ecommerce',\n hidden: true,\n useAsTitle: 'createdAt',\n },\n fields,\n hooks: {\n beforeChange: [beforeChange({ customerOnlyFieldAccess })],\n },\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:addresses'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:address'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["defaultCountries","beforeChange","createAddressesCollection","props","access","adminOrCustomerOwner","authenticatedOnly","customerOnlyFieldAccess","addressFields","customersSlug","supportedCountries","supportedCountriesFromProps","hasOnlyOneCountry","length","fields","name","type","admin","position","label","t","relationTo","map","field","options","required","defaultValue","value","baseConfig","slug","create","delete","read","update","description","group","hidden","useAsTitle","hooks","labels","plural","singular","timestamps"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,YAAY,QAAQ,0BAAyB;AAmBtD,OAAO,MAAMC,4BAAgE,CAACC;IAC5E,MAAM,EACJC,QAAQ,EAAEC,oBAAoB,EAAEC,iBAAiB,EAAEC,uBAAuB,EAAE,EAC5EC,aAAa,EACbC,gBAAgB,OAAO,EACxB,GAAGN,SAAS,CAAC;IAEd,MAAM,EAAEO,oBAAoBC,2BAA2B,EAAE,GAAGR,SAAS,CAAC;IACtE,MAAMO,qBAAqBC,+BAA+BX;IAC1D,MAAMY,oBAAoBF,sBAAsBA,mBAAmBG,MAAM,KAAK;IAE9E,MAAMC,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAC,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;gBAC/DA,EAAE;YACJC,YAAYZ;QACd;WACGD,cAAcc,GAAG,CAAC,CAACC;YACpB,IAAI,UAAUA,SAASA,MAAMR,IAAI,KAAK,WAAW;gBAC/C,OAAO;oBACLA,MAAM;oBACNC,MAAM;oBACNG,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;wBAC/DA,EAAE;oBACJI,SAASd,sBAAsBV;oBAC/ByB,UAAU;oBACV,GAAIf,sBAAsBA,oBAAoB,CAAC,EAAE,IAAIE,oBACjD;wBACEc,cAAchB,oBAAoB,CAAC,EAAE,CAACiB;oBACxC,IACA,CAAC,CAAC;gBACR;YACF;YAEA,OAAOJ;QACT;KACD;IAED,MAAMK,aAA+B;QACnCC,MAAM;QACNzB,QAAQ;YACN0B,QAAQxB;YACRyB,QAAQ1B;YACR2B,MAAM3B;YACN4B,QAAQ5B;QACV;QACAY,OAAO;YACLiB,aAAa,CAAC,EAAEd,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJe,OAAO;YACPC,QAAQ;YACRC,YAAY;QACd;QACAvB;QACAwB,OAAO;YACLrC,cAAc;gBAACA,aAAa;oBAAEM;gBAAwB;aAAG;QAC3D;QACAgC,QAAQ;YACNC,QAAQ,CAAC,EAAEpB,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJqB,UAAU,CAAC,EAAErB,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAsB,YAAY;IACd;IAEA,OAAO;QAAE,GAAGd,UAAU;IAAC;AACzB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultCountries.d.ts","sourceRoot":"","sources":["../../../src/collections/addresses/defaultCountries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"defaultCountries.d.ts","sourceRoot":"","sources":["../../../src/collections/addresses/defaultCountries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,EAyCzC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/addresses/defaultCountries.ts"],"sourcesContent":["import type { CountryType } from '../../types.js'\n\n/**\n * Default list of countries supported for forms and payments.\n * This can be overriden or reused in other parts of the application.\n *\n * The label is the human-readable name of the country, and the value is the ISO 3166-1 alpha-2 code.\n */\nexport const defaultCountries: CountryType[] = [\n { label: 'United States', value: 'US' },\n { label: 'United Kingdom', value: 'GB' },\n { label: 'Canada', value: 'CA' },\n { label: 'Australia', value: 'AU' },\n { label: 'Austria', value: 'AT' },\n { label: 'Belgium', value: 'BE' },\n { label: 'Brazil', value: 'BR' },\n { label: 'Bulgaria', value: 'BG' },\n { label: 'Cyprus', value: 'CY' },\n { label: 'Czech Republic', value: 'CZ' },\n { label: 'Denmark', value: 'DK' },\n { label: 'Estonia', value: 'EE' },\n { label: 'Finland', value: 'FI' },\n { label: 'France', value: 'FR' },\n { label: 'Germany', value: 'DE' },\n { label: 'Greece', value: 'GR' },\n { label: 'Hong Kong', value: 'HK' },\n { label: 'Hungary', value: 'HU' },\n { label: 'India', value: 'IN' },\n { label: 'Ireland', value: 'IE' },\n { label: 'Italy', value: 'IT' },\n { label: 'Japan', value: 'JP' },\n { label: 'Latvia', value: 'LV' },\n { label: 'Lithuania', value: 'LT' },\n { label: 'Luxembourg', value: 'LU' },\n { label: 'Malaysia', value: 'MY' },\n { label: 'Malta', value: 'MT' },\n { label: 'Mexico', value: 'MX' },\n { label: 'Netherlands', value: 'NL' },\n { label: 'New Zealand', value: 'NZ' },\n { label: 'Norway', value: 'NO' },\n { label: 'Poland', value: 'PL' },\n { label: 'Portugal', value: 'PT' },\n { label: 'Romania', value: 'RO' },\n { label: 'Singapore', value: 'SG' },\n { label: 'Slovakia', value: 'SK' },\n { label: 'Slovenia', value: 'SI' },\n { label: 'Spain', value: 'ES' },\n { label: 'Sweden', value: 'SE' },\n { label: 'Switzerland', value: 'CH' },\n]\n"],"names":["defaultCountries","label","value"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,MAAMA,mBAAkC;IAC7C;QAAEC,OAAO;QAAiBC,OAAO;IAAK;IACtC;QAAED,OAAO;QAAkBC,OAAO;IAAK;IACvC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAaC,OAAO;IAAK;IAClC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAkBC,OAAO;IAAK;IACvC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAaC,OAAO;IAAK;IAClC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAaC,OAAO;IAAK;IAClC;QAAED,OAAO;QAAcC,OAAO;IAAK;IACnC;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAeC,OAAO;IAAK;IACpC;QAAED,OAAO;QAAeC,OAAO;IAAK;IACpC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAaC,OAAO;IAAK;IAClC;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAeC,OAAO;IAAK;CACrC,CAAA"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/addresses/defaultCountries.ts"],"sourcesContent":["import type { CountryType } from '../../types/index.js'\n\n/**\n * Default list of countries supported for forms and payments.\n * This can be overriden or reused in other parts of the application.\n *\n * The label is the human-readable name of the country, and the value is the ISO 3166-1 alpha-2 code.\n */\nexport const defaultCountries: CountryType[] = [\n { label: 'United States', value: 'US' },\n { label: 'United Kingdom', value: 'GB' },\n { label: 'Canada', value: 'CA' },\n { label: 'Australia', value: 'AU' },\n { label: 'Austria', value: 'AT' },\n { label: 'Belgium', value: 'BE' },\n { label: 'Brazil', value: 'BR' },\n { label: 'Bulgaria', value: 'BG' },\n { label: 'Cyprus', value: 'CY' },\n { label: 'Czech Republic', value: 'CZ' },\n { label: 'Denmark', value: 'DK' },\n { label: 'Estonia', value: 'EE' },\n { label: 'Finland', value: 'FI' },\n { label: 'France', value: 'FR' },\n { label: 'Germany', value: 'DE' },\n { label: 'Greece', value: 'GR' },\n { label: 'Hong Kong', value: 'HK' },\n { label: 'Hungary', value: 'HU' },\n { label: 'India', value: 'IN' },\n { label: 'Ireland', value: 'IE' },\n { label: 'Italy', value: 'IT' },\n { label: 'Japan', value: 'JP' },\n { label: 'Latvia', value: 'LV' },\n { label: 'Lithuania', value: 'LT' },\n { label: 'Luxembourg', value: 'LU' },\n { label: 'Malaysia', value: 'MY' },\n { label: 'Malta', value: 'MT' },\n { label: 'Mexico', value: 'MX' },\n { label: 'Netherlands', value: 'NL' },\n { label: 'New Zealand', value: 'NZ' },\n { label: 'Norway', value: 'NO' },\n { label: 'Poland', value: 'PL' },\n { label: 'Portugal', value: 'PT' },\n { label: 'Romania', value: 'RO' },\n { label: 'Singapore', value: 'SG' },\n { label: 'Slovakia', value: 'SK' },\n { label: 'Slovenia', value: 'SI' },\n { label: 'Spain', value: 'ES' },\n { label: 'Sweden', value: 'SE' },\n { label: 'Switzerland', value: 'CH' },\n]\n"],"names":["defaultCountries","label","value"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,MAAMA,mBAAkC;IAC7C;QAAEC,OAAO;QAAiBC,OAAO;IAAK;IACtC;QAAED,OAAO;QAAkBC,OAAO;IAAK;IACvC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAaC,OAAO;IAAK;IAClC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAkBC,OAAO;IAAK;IACvC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAaC,OAAO;IAAK;IAClC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAaC,OAAO;IAAK;IAClC;QAAED,OAAO;QAAcC,OAAO;IAAK;IACnC;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAeC,OAAO;IAAK;IACpC;QAAED,OAAO;QAAeC,OAAO;IAAK;IACpC;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAAWC,OAAO;IAAK;IAChC;QAAED,OAAO;QAAaC,OAAO;IAAK;IAClC;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAAYC,OAAO;IAAK;IACjC;QAAED,OAAO;QAASC,OAAO;IAAK;IAC9B;QAAED,OAAO;QAAUC,OAAO;IAAK;IAC/B;QAAED,OAAO;QAAeC,OAAO;IAAK;CACrC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionBeforeChangeHook } from 'payload';
|
|
2
|
-
import type { AccessConfig } from '../../../types.js';
|
|
2
|
+
import type { AccessConfig } from '../../../types/index.js';
|
|
3
3
|
interface Props {
|
|
4
4
|
customerOnlyFieldAccess: AccessConfig['customerOnlyFieldAccess'];
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beforeChange.d.ts","sourceRoot":"","sources":["../../../../src/collections/addresses/hooks/beforeChange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"beforeChange.d.ts","sourceRoot":"","sources":["../../../../src/collections/addresses/hooks/beforeChange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3D,UAAU,KAAK;IACb,uBAAuB,EAAE,YAAY,CAAC,yBAAyB,CAAC,CAAA;CACjE;AAED,eAAO,MAAM,YAAY,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,0BAUzC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/addresses/hooks/beforeChange.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook } from 'payload'\n\nimport type { AccessConfig } from '../../../types.js'\n\ninterface Props {\n customerOnlyFieldAccess: AccessConfig['customerOnlyFieldAccess']\n}\n\nexport const beforeChange: (args: Props) => CollectionBeforeChangeHook =\n ({ customerOnlyFieldAccess }) =>\n async ({ data, req }) => {\n const isCustomer = await customerOnlyFieldAccess({ req })\n\n // Ensure that the customer field is set to the current user's ID if the user is a customer.\n // Admins can set to any customer.\n if (req.user && isCustomer) {\n data.customer = req.user.id\n }\n }\n"],"names":["beforeChange","customerOnlyFieldAccess","data","req","isCustomer","user","customer","id"],"mappings":"AAQA,OAAO,MAAMA,eACX,CAAC,EAAEC,uBAAuB,EAAE,GAC5B,OAAO,EAAEC,IAAI,EAAEC,GAAG,EAAE;QAClB,MAAMC,aAAa,MAAMH,wBAAwB;YAAEE;QAAI;QAEvD,4FAA4F;QAC5F,kCAAkC;QAClC,IAAIA,IAAIE,IAAI,IAAID,YAAY;YAC1BF,KAAKI,QAAQ,GAAGH,IAAIE,IAAI,CAACE,EAAE;QAC7B;IACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/addresses/hooks/beforeChange.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook } from 'payload'\n\nimport type { AccessConfig } from '../../../types/index.js'\n\ninterface Props {\n customerOnlyFieldAccess: AccessConfig['customerOnlyFieldAccess']\n}\n\nexport const beforeChange: (args: Props) => CollectionBeforeChangeHook =\n ({ customerOnlyFieldAccess }) =>\n async ({ data, req }) => {\n const isCustomer = await customerOnlyFieldAccess({ req })\n\n // Ensure that the customer field is set to the current user's ID if the user is a customer.\n // Admins can set to any customer.\n if (req.user && isCustomer) {\n data.customer = req.user.id\n }\n }\n"],"names":["beforeChange","customerOnlyFieldAccess","data","req","isCustomer","user","customer","id"],"mappings":"AAQA,OAAO,MAAMA,eACX,CAAC,EAAEC,uBAAuB,EAAE,GAC5B,OAAO,EAAEC,IAAI,EAAEC,GAAG,EAAE;QAClB,MAAMC,aAAa,MAAMH,wBAAwB;YAAEE;QAAI;QAEvD,4FAA4F;QAC5F,kCAAkC;QAClC,IAAIA,IAAIE,IAAI,IAAID,YAAY;YAC1BF,KAAKI,QAAQ,GAAGH,IAAIE,IAAI,CAACE,EAAE;QAC7B;IACF,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionConfig } from 'payload';
|
|
2
|
-
import type { AccessConfig, CurrenciesConfig } from '../../types.js';
|
|
2
|
+
import type { AccessConfig, CurrenciesConfig } from '../../types/index.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
access: {
|
|
5
5
|
adminOrCustomerOwner: NonNullable<AccessConfig['adminOrCustomerOwner']>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCartsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/carts/createCartsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createCartsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/carts/createCartsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAQ1E,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,oBAAoB,EAAE,WAAW,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAA;QACvE,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAA;KACxD,CAAA;IACD,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBA8IrD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/carts/createCartsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig } from '../../types.js'\n\nimport { amountField } from '../../fields/amountField.js'\nimport { cartItemsField } from '../../fields/cartItemsField.js'\nimport { currencyField } from '../../fields/currencyField.js'\nimport { beforeChangeCart } from './beforeChange.js'\nimport { statusBeforeRead } from './statusBeforeRead.js'\n\ntype Props = {\n access: {\n adminOrCustomerOwner: NonNullable<AccessConfig['adminOrCustomerOwner']>\n publicAccess: NonNullable<AccessConfig['publicAccess']>\n }\n currenciesConfig?: CurrenciesConfig\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Enables support for variants in the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\nexport const createCartsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOrCustomerOwner, publicAccess },\n currenciesConfig,\n customersSlug = 'users',\n enableVariants = false,\n productsSlug = 'products',\n variantsSlug = 'variants',\n } = props || {}\n\n const fields: Field[] = [\n cartItemsField({\n enableVariants,\n overrides: {\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:item'),\n },\n },\n productsSlug,\n variantsSlug,\n }),\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n {\n name: 'purchasedAt',\n type: 'date',\n admin: {\n date: { pickerAppearance: 'dayAndTime' },\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:purchasedAt'),\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n hooks: {\n afterRead: [statusBeforeRead],\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:status'),\n options: [\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:active'),\n value: 'active',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:purchased'),\n value: 'purchased',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:abandoned'),\n value: 'abandoned',\n },\n ],\n virtual: true,\n },\n ...(currenciesConfig\n ? [\n {\n type: 'row',\n admin: { position: 'sidebar' },\n fields: [\n amountField({\n currenciesConfig,\n overrides: {\n name: 'subtotal',\n\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:subtotal'),\n },\n }),\n currencyField({\n currenciesConfig,\n }),\n ],\n } as Field,\n ]\n : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'carts',\n access: {\n create: publicAccess,\n delete: adminOrCustomerOwner,\n read: adminOrCustomerOwner,\n update: adminOrCustomerOwner,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:cartsCollectionDescription'),\n group: 'Ecommerce',\n useAsTitle: 'createdAt',\n },\n fields,\n hooks: {\n beforeChange: [\n // This hook can be used to update the subtotal before saving the cart\n beforeChangeCart({ productsSlug, variantsSlug }),\n ],\n },\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:carts'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:cart'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["amountField","cartItemsField","currencyField","beforeChangeCart","statusBeforeRead","createCartsCollection","props","access","adminOrCustomerOwner","publicAccess","currenciesConfig","customersSlug","enableVariants","productsSlug","variantsSlug","fields","overrides","label","t","labels","plural","singular","name","type","admin","position","relationTo","date","pickerAppearance","readOnly","hooks","afterRead","options","value","virtual","baseConfig","slug","create","delete","read","update","description","group","useAsTitle","beforeChange","timestamps"],"mappings":"AAIA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,aAAa,QAAQ,gCAA+B;AAC7D,SAASC,gBAAgB,QAAQ,oBAAmB;AACpD,SAASC,gBAAgB,QAAQ,wBAAuB;AA2BxD,OAAO,MAAMC,wBAA4D,CAACC;IACxE,MAAM,EACJC,QAAQ,EAAEC,oBAAoB,EAAEC,YAAY,EAAE,EAC9CC,gBAAgB,EAChBC,gBAAgB,OAAO,EACvBC,iBAAiB,KAAK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AAO;oBAAEC,UAAU;gBAAU;gBAC7BV,QAAQ;oBACNf,YAAY;wBACVU;wBACAM,WAAW;4BACTM,MAAM;4BAENL,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;gCAC/DA,EAAE;wBACN;oBACF;oBACAhB,cAAc;wBACZQ;oBACF;iBACD;YACH;SACD,GACD,EAAE;KACP;IAED,MAAMyB,aAA+B;QACnCC,MAAM;QACN7B,QAAQ;YACN8B,QAAQ5B;YACR6B,QAAQ9B;YACR+B,MAAM/B;YACNgC,QAAQhC;QACV;QACAgB,OAAO;YACLiB,aAAa,CAAC,EAAEvB,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJwB,OAAO;YACPC,YAAY;QACd;QACA5B;QACAe,OAAO;YACLc,cAAc;gBACZ,sEAAsE;gBACtEzC,iBAAiB;oBAAEU;oBAAcC;gBAAa;aAC/C;QACH;QACAK,QAAQ;YACNC,QAAQ,CAAC,EAAEF,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJG,UAAU,CAAC,EAAEH,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACA2B,YAAY;IACd;IAEA,OAAO;QAAE,GAAGV,UAAU;IAAC;AACzB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/carts/createCartsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig } from '../../types/index.js'\n\nimport { amountField } from '../../fields/amountField.js'\nimport { cartItemsField } from '../../fields/cartItemsField.js'\nimport { currencyField } from '../../fields/currencyField.js'\nimport { beforeChangeCart } from './beforeChange.js'\nimport { statusBeforeRead } from './statusBeforeRead.js'\n\ntype Props = {\n access: {\n adminOrCustomerOwner: NonNullable<AccessConfig['adminOrCustomerOwner']>\n publicAccess: NonNullable<AccessConfig['publicAccess']>\n }\n currenciesConfig?: CurrenciesConfig\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Enables support for variants in the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\nexport const createCartsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOrCustomerOwner, publicAccess },\n currenciesConfig,\n customersSlug = 'users',\n enableVariants = false,\n productsSlug = 'products',\n variantsSlug = 'variants',\n } = props || {}\n\n const fields: Field[] = [\n cartItemsField({\n enableVariants,\n overrides: {\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:item'),\n },\n },\n productsSlug,\n variantsSlug,\n }),\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n {\n name: 'purchasedAt',\n type: 'date',\n admin: {\n date: { pickerAppearance: 'dayAndTime' },\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:purchasedAt'),\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n hooks: {\n afterRead: [statusBeforeRead],\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:status'),\n options: [\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:active'),\n value: 'active',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:purchased'),\n value: 'purchased',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:abandoned'),\n value: 'abandoned',\n },\n ],\n virtual: true,\n },\n ...(currenciesConfig\n ? [\n {\n type: 'row',\n admin: { position: 'sidebar' },\n fields: [\n amountField({\n currenciesConfig,\n overrides: {\n name: 'subtotal',\n\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:subtotal'),\n },\n }),\n currencyField({\n currenciesConfig,\n }),\n ],\n } as Field,\n ]\n : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'carts',\n access: {\n create: publicAccess,\n delete: adminOrCustomerOwner,\n read: adminOrCustomerOwner,\n update: adminOrCustomerOwner,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:cartsCollectionDescription'),\n group: 'Ecommerce',\n useAsTitle: 'createdAt',\n },\n fields,\n hooks: {\n beforeChange: [\n // This hook can be used to update the subtotal before saving the cart\n beforeChangeCart({ productsSlug, variantsSlug }),\n ],\n },\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:carts'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:cart'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["amountField","cartItemsField","currencyField","beforeChangeCart","statusBeforeRead","createCartsCollection","props","access","adminOrCustomerOwner","publicAccess","currenciesConfig","customersSlug","enableVariants","productsSlug","variantsSlug","fields","overrides","label","t","labels","plural","singular","name","type","admin","position","relationTo","date","pickerAppearance","readOnly","hooks","afterRead","options","value","virtual","baseConfig","slug","create","delete","read","update","description","group","useAsTitle","beforeChange","timestamps"],"mappings":"AAIA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,aAAa,QAAQ,gCAA+B;AAC7D,SAASC,gBAAgB,QAAQ,oBAAmB;AACpD,SAASC,gBAAg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Be,OAAO;gBACT;gBACA;oBACE,+DAA+D;oBAC/DhB,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBe,OAAO;gBACT;aACD;YACDC,SAAS;QACX;WACIxB,mBACA;YACE;gBACEa,MAAM;gBACNC,OAAO;oBAAEC,UAAU;gBAAU;gBAC7BV,QAAQ;oBACNf,YAAY;wBACVU;wBACAM,WAAW;4BACTM,MAAM;4BAENL,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;gCAC/DA,EAAE;wBACN;oBACF;oBACAhB,cAAc;wBACZQ;oBACF;iBACD;YACH;SACD,GACD,EAAE;KACP;IAED,MAAMyB,aAA+B;QACnCC,MAAM;QACN7B,QAAQ;YACN8B,QAAQ5B;YACR6B,QAAQ9B;YACR+B,MAAM/B;YACNgC,QAAQhC;QACV;QACAgB,OAAO;YACLiB,aAAa,CAAC,EAAEvB,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJwB,OAAO;YACPC,YAAY;QACd;QACA5B;QACAe,OAAO;YACLc,cAAc;gBACZ,sEAAsE;gBACtEzC,iBAAiB;oBAAEU;oBAAcC;gBAAa;aAC/C;QACH;QACAK,QAAQ;YACNC,QAAQ,CAAC,EAAEF,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJG,UAAU,CAAC,EAAEH,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACA2B,YAAY;IACd;IAEA,OAAO;QAAE,GAAGV,UAAU;IAAC;AACzB,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionConfig, Field } from 'payload';
|
|
2
|
-
import type { AccessConfig, CurrenciesConfig } from '../../types.js';
|
|
2
|
+
import type { AccessConfig, CurrenciesConfig } from '../../types/index.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
access: {
|
|
5
5
|
adminOnly: NonNullable<AccessConfig['adminOnly']>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOrdersCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/orders/createOrdersCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createOrdersCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/orders/createOrdersCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAM1E,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;QACjD,oBAAoB,EAAE,WAAW,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAA;QACvE,oBAAoB,EAAE,WAAW,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAA;KACxE,CAAA;IACD;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,EAAE,CAAA;IACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBAwLtD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/orders/createOrdersCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig } from '../../types.js'\n\nimport { amountField } from '../../fields/amountField.js'\nimport { cartItemsField } from '../../fields/cartItemsField.js'\nimport { currencyField } from '../../fields/currencyField.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n adminOnlyFieldAccess: NonNullable<AccessConfig['adminOnlyFieldAccess']>\n adminOrCustomerOwner: NonNullable<AccessConfig['adminOrCustomerOwner']>\n }\n /**\n * Array of fields used for capturing the shipping address data.\n */\n addressFields?: Field[]\n currenciesConfig?: CurrenciesConfig\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n enableVariants?: boolean\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the transactions collection, defaults to 'transactions'.\n */\n transactionsSlug?: string\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\nexport const createOrdersCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, adminOnlyFieldAccess, adminOrCustomerOwner },\n addressFields,\n currenciesConfig,\n customersSlug = 'users',\n enableVariants = false,\n productsSlug = 'products',\n transactionsSlug = 'transactions',\n variantsSlug = 'variants',\n } = props || {}\n\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n cartItemsField({\n enableVariants,\n overrides: {\n name: 'items',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:item'),\n },\n },\n productsSlug,\n variantsSlug,\n }),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:orderDetails'),\n },\n {\n fields: [\n ...(addressFields\n ? [\n {\n name: 'shippingAddress',\n type: 'group',\n fields: addressFields,\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:shippingAddress'),\n } as Field,\n ]\n : []),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:shipping'),\n },\n ],\n },\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n {\n name: 'customerEmail',\n type: 'email',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customerEmail'),\n },\n {\n name: 'transactions',\n type: 'relationship',\n access: {\n create: adminOnlyFieldAccess,\n read: adminOnlyFieldAccess,\n update: adminOnlyFieldAccess,\n },\n admin: {\n position: 'sidebar',\n },\n hasMany: true,\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transactions'),\n relationTo: transactionsSlug,\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n defaultValue: 'processing',\n interfaceName: 'OrderStatus',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:status'),\n options: [\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:processing'),\n value: 'processing',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:completed'),\n value: 'completed',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:cancelled'),\n value: 'cancelled',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:refunded'),\n value: 'refunded',\n },\n ],\n },\n\n ...(currenciesConfig\n ? [\n {\n type: 'row',\n admin: {\n position: 'sidebar',\n },\n fields: [\n amountField({\n currenciesConfig,\n }),\n currencyField({\n currenciesConfig,\n }),\n ],\n } as Field,\n ]\n : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'orders',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOrCustomerOwner,\n update: adminOnly,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:ordersCollectionDescription'),\n group: 'Ecommerce',\n useAsTitle: 'createdAt',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:orders'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:order'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["amountField","cartItemsField","currencyField","createOrdersCollection","props","access","adminOnly","adminOnlyFieldAccess","adminOrCustomerOwner","addressFields","currenciesConfig","customersSlug","enableVariants","productsSlug","transactionsSlug","variantsSlug","fields","type","tabs","overrides","name","label","t","labels","plural","singular","admin","position","relationTo","create","read","update","hasMany","defaultValue","interfaceName","options","value","baseConfig","slug","delete","description","group","useAsTitle","timestamps"],"mappings":"AAIA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,aAAa,QAAQ,gCAA+B;AAgC7D,OAAO,MAAMC,yBAA6D,CAACC;IACzE,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,oBAAoB,EAAEC,oBAAoB,EAAE,EACjEC,aAAa,EACbC,gBAAgB,EAChBC,gBAAgB,OAAO,EACvBC,iBAAiB,KAAK,EACtBC,eAAe,UAAU,EACzBC,mBAAmB,cAAc,EACjCC,eAAe,UAAU,EAC1B,GAAGX,SAAS,CAAC;IAEd,MAAMY,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;gBACJ;oBACEF,QAAQ;wBACNf,eAAe;4BACbW;4BACAO,WAAW;gCACTC,MAAM;gCACNC,OAA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YACJa,SAAS;gBACP;oBACE,+DAA+D;oBAC/Dd,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBc,OAAO;gBACT;gBACA;oBACE,+DAA+D;oBAC/Df,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBc,OAAO;gBACT;gBACA;oBACE,+DAA+D;oBAC/Df,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBc,OAAO;gBACT;gBACA;oBACE,+DAA+D;oBAC/Df,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBc,OAAO;gBACT;aACD;QACH;WAEI1B,mBACA;YACE;gBACEO,MAAM;gBACNS,OAAO;oBACLC,UAAU;gBACZ;gBACAX,QAAQ;oBACNhB,YAAY;wBACVU;oBACF;oBACAR,cAAc;wBACZQ;oBACF;iBACD;YACH;SACD,GACD,EAAE;KACP;IAED,MAAM2B,aAA+B;QACnCC,MAAM;QACNjC,QAAQ;YACNwB,QAAQvB;YACRiC,QAAQjC;YACRwB,MAAMtB;YACNuB,QAAQzB;QACV;QACAoB,OAAO;YACLc,aAAa,CAAC,EAAElB,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJmB,OAAO;YACPC,YAAY;QACd;QACA1B;QACAO,QAAQ;YACNC,QAAQ,CAAC,EAAEF,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJG,UAAU,CAAC,EAAEH,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAqB,YAAY;IACd;IAEA,OAAO;QAAE,GAAGN,UAAU;IAAC;AACzB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/orders/createOrdersCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig } from '../../types/index.js'\n\nimport { amountField } from '../../fields/amountField.js'\nimport { cartItemsField } from '../../fields/cartItemsField.js'\nimport { currencyField } from '../../fields/currencyField.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n adminOnlyFieldAccess: NonNullable<AccessConfig['adminOnlyFieldAccess']>\n adminOrCustomerOwner: NonNullable<AccessConfig['adminOrCustomerOwner']>\n }\n /**\n * Array of fields used for capturing the shipping address data.\n */\n addressFields?: Field[]\n currenciesConfig?: CurrenciesConfig\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n enableVariants?: boolean\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the transactions collection, defaults to 'transactions'.\n */\n transactionsSlug?: string\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\nexport const createOrdersCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, adminOnlyFieldAccess, adminOrCustomerOwner },\n addressFields,\n currenciesConfig,\n customersSlug = 'users',\n enableVariants = false,\n productsSlug = 'products',\n transactionsSlug = 'transactions',\n variantsSlug = 'variants',\n } = props || {}\n\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n cartItemsField({\n enableVariants,\n overrides: {\n name: 'items',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:item'),\n },\n },\n productsSlug,\n variantsSlug,\n }),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:orderDetails'),\n },\n {\n fields: [\n ...(addressFields\n ? [\n {\n name: 'shippingAddress',\n type: 'group',\n fields: addressFields,\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:shippingAddress'),\n } as Field,\n ]\n : []),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:shipping'),\n },\n ],\n },\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n {\n name: 'customerEmail',\n type: 'email',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customerEmail'),\n },\n {\n name: 'transactions',\n type: 'relationship',\n access: {\n create: adminOnlyFieldAccess,\n read: adminOnlyFieldAccess,\n update: adminOnlyFieldAccess,\n },\n admin: {\n position: 'sidebar',\n },\n hasMany: true,\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transactions'),\n relationTo: transactionsSlug,\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n defaultValue: 'processing',\n interfaceName: 'OrderStatus',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:status'),\n options: [\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:processing'),\n value: 'processing',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:completed'),\n value: 'completed',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:cancelled'),\n value: 'cancelled',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:refunded'),\n value: 'refunded',\n },\n ],\n },\n\n ...(currenciesConfig\n ? [\n {\n type: 'row',\n admin: {\n position: 'sidebar',\n },\n fields: [\n amountField({\n currenciesConfig,\n }),\n currencyField({\n currenciesConfig,\n }),\n ],\n } as Field,\n ]\n : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'orders',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOrCustomerOwner,\n update: adminOnly,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:ordersCollectionDescription'),\n group: 'Ecommerce',\n useAsTitle: 'createdAt',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:orders'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:order'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["amountField","cartItemsField","currencyField","createOrdersCollection","props","access","adminOnly","adminOnlyFieldAccess","adminOrCustomerOwner","addressFields","currenciesConfig","customersSlug","enableVariants","productsSlug","transactionsSlug","variantsSlug","fields","type","tabs","overrides","name","label","t","labels","plural","singular","admin","position","relationTo","create","read","update","hasMany","defaultValue","interfaceName","options","value","baseConfig","slug","delete","description","group","useAsTitle","timestamps"],"mappings":"AAIA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,aAAa,QAAQ,gCAA+B;AAgC7D,OAAO,MAAMC,yBAA6D,CAACC;IACzE,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,oBAAoB,EAAEC,oBAAoB,EAAE,EACjEC,aAAa,EACbC,gBAAgB,EAChBC,gBAAgB,OAAO,EACvBC,iBAAiB,KAAK,EACtBC,eAAe,UAAU,EACzBC,mBAAmB,cAAc,EACjCC,eAAe,UAAU,EAC1B,GAAGX,SAAS,CAAC;IAEd,MAAMY,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;gBACJ;oBACEF,QAAQ;wBACNf,eAAe;4BACbW;4BACAO,WAAW;gCACTC,MAAM;gCACNC,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;oCAC/DA,EAAE;gCACJC,QAAQ;oCACNC,QAAQ,CAAC,EAAEF,CAAC,EAAE,GACZ,+DAA+D;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+D;oBAC/Df,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBc,OAAO;gBACT;gBACA;oBACE,+DAA+D;oBAC/Df,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBc,OAAO;gBACT;gBACA;oBACE,+DAA+D;oBAC/Df,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;oBACpBc,OAAO;gBACT;aACD;QACH;WAEI1B,mBACA;YACE;gBACEO,MAAM;gBACNS,OAAO;oBACLC,UAAU;gBACZ;gBACAX,QAAQ;oBACNhB,YAAY;wBACVU;oBACF;oBACAR,cAAc;wBACZQ;oBACF;iBACD;YACH;SACD,GACD,EAAE;KACP;IAED,MAAM2B,aAA+B;QACnCC,MAAM;QACNjC,QAAQ;YACNwB,QAAQvB;YACRiC,QAAQjC;YACRwB,MAAMtB;YACNuB,QAAQzB;QACV;QACAoB,OAAO;YACLc,aAAa,CAAC,EAAElB,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJmB,OAAO;YACPC,YAAY;QACd;QACA1B;QACAO,QAAQ;YACNC,QAAQ,CAAC,EAAEF,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJG,UAAU,CAAC,EAAEH,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAqB,YAAY;IACd;IAEA,OAAO;QAAE,GAAGN,UAAU;IAAC;AACzB,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionConfig } from 'payload';
|
|
2
|
-
import type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../types.js';
|
|
2
|
+
import type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../types/index.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
access: {
|
|
5
5
|
adminOnly: NonNullable<AccessConfig['adminOnly']>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProductsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/products/createProductsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createProductsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/products/createProductsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAM3F,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;QACjD,sBAAsB,EAAE,WAAW,CAAC,YAAY,CAAC,wBAAwB,CAAC,CAAC,CAAA;KAC5E,CAAA;IACD,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,eAAe,CAAA;IACrC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBA2DxD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/products/createProductsCollection.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../types.js'\n\nimport { inventoryField } from '../../fields/inventoryField.js'\nimport { pricesField } from '../../fields/pricesField.js'\nimport { variantsFields } from '../../fields/variantsFields.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n adminOrPublishedStatus: NonNullable<AccessConfig['adminOrPublishedStatus']>\n }\n currenciesConfig: CurrenciesConfig\n enableVariants?: boolean\n /**\n * Adds in an inventory field to the product and its variants. This is useful for tracking inventory levels.\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n /**\n * Slug of the variant types collection, defaults to 'variantTypes'.\n */\n variantTypesSlug?: string\n}\n\nexport const createProductsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, adminOrPublishedStatus },\n currenciesConfig,\n enableVariants = false,\n inventory = true,\n variantsSlug = 'variants',\n variantTypesSlug = 'variantTypes',\n } = props || {}\n\n const fields = [\n ...(inventory\n ? [\n inventoryField({\n overrides: {\n admin: {\n condition: ({ enableVariants }) => !enableVariants,\n },\n },\n }),\n ]\n : []),\n ...(enableVariants ? variantsFields({ variantsSlug, variantTypesSlug }) : []),\n ...(currenciesConfig ? [...pricesField({ currenciesConfig })] : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'products',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOrPublishedStatus,\n update: adminOnly,\n },\n admin: {\n defaultColumns: [\n ...(currenciesConfig ? ['prices'] : []),\n ...(enableVariants ? ['variants'] : []),\n ],\n group: 'Ecommerce',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:products'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:product'),\n },\n trash: true,\n versions: {\n drafts: {\n autosave: true,\n },\n },\n }\n\n return baseConfig\n}\n"],"names":["inventoryField","pricesField","variantsFields","createProductsCollection","props","access","adminOnly","adminOrPublishedStatus","currenciesConfig","enableVariants","inventory","variantsSlug","variantTypesSlug","fields","overrides","admin","condition","baseConfig","slug","create","delete","read","update","defaultColumns","group","labels","plural","t","singular","trash","versions","drafts","autosave"],"mappings":"AAIA,SAASA,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,cAAc,QAAQ,iCAAgC;AAwB/D,OAAO,MAAMC,2BAA+D,CAACC;IAC3E,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,sBAAsB,EAAE,EAC7CC,gBAAgB,EAChBC,iBAAiB,KAAK,EACtBC,YAAY,IAAI,EAChBC,eAAe,UAAU,EACzBC,mBAAmB,cAAc,EAClC,GAAGR,SAAS,CAAC;IAEd,MAAMS,SAAS;WACTH,YACA;YACEV,eAAe;gBACbc,WAAW;oBACTC,OAAO;wBACLC,WAAW,CAAC,EAAEP,cAAc,EAAE,GAAK,CAACA;oBACtC;gBACF;YACF;SACD,GACD,EAAE;WACFA,iBAAiBP,eAAe;YAAES;YAAcC;QAAiB,KAAK,EAAE;WACxEJ,mBAAmB;eAAIP,YAAY;gBAAEO;YAAiB;SAAG,GAAG,EAAE;KACnE;IAED,MAAMS,aAA+B;QACnCC,MAAM;QACNb,QAAQ;YACNc,QAAQb;YACRc,QAAQd;YACRe,MAAMd;YACNe,QAAQhB;QACV;QACAS,OAAO;YACLQ,gBAAgB;mBACVf,mBAAmB;oBAAC;iBAAS,GAAG,EAAE;mBAClCC,iBAAiB;oBAAC;iBAAW,GAAG,EAAE;aACvC;YACDe,OAAO;QACT;QACAX;QACAY,QAAQ;YACNC,QAAQ,CAAC,EAAEC,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJC,UAAU,CAAC,EAAED,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAE,OAAO;QACPC,UAAU;YACRC,QAAQ;gBACNC,UAAU;YACZ;QACF;IACF;IAEA,OAAOf;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/products/createProductsCollection.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../types/index.js'\n\nimport { inventoryField } from '../../fields/inventoryField.js'\nimport { pricesField } from '../../fields/pricesField.js'\nimport { variantsFields } from '../../fields/variantsFields.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n adminOrPublishedStatus: NonNullable<AccessConfig['adminOrPublishedStatus']>\n }\n currenciesConfig: CurrenciesConfig\n enableVariants?: boolean\n /**\n * Adds in an inventory field to the product and its variants. This is useful for tracking inventory levels.\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n /**\n * Slug of the variant types collection, defaults to 'variantTypes'.\n */\n variantTypesSlug?: string\n}\n\nexport const createProductsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, adminOrPublishedStatus },\n currenciesConfig,\n enableVariants = false,\n inventory = true,\n variantsSlug = 'variants',\n variantTypesSlug = 'variantTypes',\n } = props || {}\n\n const fields = [\n ...(inventory\n ? [\n inventoryField({\n overrides: {\n admin: {\n condition: ({ enableVariants }) => !enableVariants,\n },\n },\n }),\n ]\n : []),\n ...(enableVariants ? variantsFields({ variantsSlug, variantTypesSlug }) : []),\n ...(currenciesConfig ? [...pricesField({ currenciesConfig })] : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'products',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOrPublishedStatus,\n update: adminOnly,\n },\n admin: {\n defaultColumns: [\n ...(currenciesConfig ? ['prices'] : []),\n ...(enableVariants ? ['variants'] : []),\n ],\n group: 'Ecommerce',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:products'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:product'),\n },\n trash: true,\n versions: {\n drafts: {\n autosave: true,\n },\n },\n }\n\n return baseConfig\n}\n"],"names":["inventoryField","pricesField","variantsFields","createProductsCollection","props","access","adminOnly","adminOrPublishedStatus","currenciesConfig","enableVariants","inventory","variantsSlug","variantTypesSlug","fields","overrides","admin","condition","baseConfig","slug","create","delete","read","update","defaultColumns","group","labels","plural","t","singular","trash","versions","drafts","autosave"],"mappings":"AAIA,SAASA,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,cAAc,QAAQ,iCAAgC;AAwB/D,OAAO,MAAMC,2BAA+D,CAACC;IAC3E,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,sBAAsB,EAAE,EAC7CC,gBAAgB,EAChBC,iBAAiB,KAAK,EACtBC,YAAY,IAAI,EAChBC,eAAe,UAAU,EACzBC,mBAAmB,cAAc,EAClC,GAAGR,SAAS,CAAC;IAEd,MAAMS,SAAS;WACTH,YACA;YACEV,eAAe;gBACbc,WAAW;oBACTC,OAAO;wBACLC,WAAW,CAAC,EAAEP,cAAc,EAAE,GAAK,CAACA;oBACtC;gBACF;YACF;SACD,GACD,EAAE;WACFA,iBAAiBP,eAAe;YAAES;YAAcC;QAAiB,KAAK,EAAE;WACxEJ,mBAAmB;eAAIP,YAAY;gBAAEO;YAAiB;SAAG,GAAG,EAAE;KACnE;IAED,MAAMS,aAA+B;QACnCC,MAAM;QACNb,QAAQ;YACNc,QAAQb;YACRc,QAAQd;YACRe,MAAMd;YACNe,QAAQhB;QACV;QACAS,OAAO;YACLQ,gBAAgB;mBACVf,mBAAmB;oBAAC;iBAAS,GAAG,EAAE;mBAClCC,iBAAiB;oBAAC;iBAAW,GAAG,EAAE;aACvC;YACDe,OAAO;QACT;QACAX;QACAY,QAAQ;YACNC,QAAQ,CAAC,EAAEC,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJC,UAAU,CAAC,EAAED,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAE,OAAO;QACPC,UAAU;YACRC,QAAQ;gBACNC,UAAU;YACZ;QACF;IACF;IAEA,OAAOf;AACT,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionConfig, Field } from 'payload';
|
|
2
|
-
import type { AccessConfig, CurrenciesConfig, PaymentAdapter } from '../../types.js';
|
|
2
|
+
import type { AccessConfig, CurrenciesConfig, PaymentAdapter } from '../../types/index.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
access: {
|
|
5
5
|
adminOnly: NonNullable<AccessConfig['adminOnly']>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTransactionsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/transactions/createTransactionsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createTransactionsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/transactions/createTransactionsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAO1F,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;KAClD,CAAA;IACD;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,EAAE,CAAA;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,cAAc,EAAE,CAAA;IACjC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBA+K5D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/transactions/createTransactionsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig, PaymentAdapter } from '../../types.js'\n\nimport { amountField } from '../../fields/amountField.js'\nimport { cartItemsField } from '../../fields/cartItemsField.js'\nimport { currencyField } from '../../fields/currencyField.js'\nimport { statusField } from '../../fields/statusField.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n }\n /**\n * Array of fields used for capturing the billing address.\n */\n addressFields?: Field[]\n /**\n * Slug of the carts collection, defaults to 'carts'.\n */\n cartsSlug?: string\n currenciesConfig?: CurrenciesConfig\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Enable variants in the transactions collection.\n */\n enableVariants?: boolean\n /**\n * Slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n paymentMethods?: PaymentAdapter[]\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\nexport const createTransactionsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly },\n addressFields,\n cartsSlug = 'carts',\n currenciesConfig,\n customersSlug = 'users',\n enableVariants = false,\n ordersSlug = 'orders',\n paymentMethods,\n productsSlug = 'products',\n variantsSlug = 'variants',\n } = props || {}\n\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n cartItemsField({\n enableVariants,\n overrides: {\n name: 'items',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:item'),\n },\n },\n productsSlug,\n variantsSlug,\n }),\n ...(paymentMethods?.length && paymentMethods.length > 0\n ? [\n {\n name: 'paymentMethod',\n type: 'select',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:paymentMethod'),\n options: paymentMethods.map((method) => ({\n label: method.label ?? method.name,\n value: method.name,\n })),\n } as Field,\n ...(paymentMethods.map((method) => method.group) || []),\n ]\n : []),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transactionDetails'),\n },\n {\n fields: [\n ...(addressFields\n ? [\n {\n name: 'billingAddress',\n type: 'group',\n fields: addressFields,\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:billingAddress'),\n } as Field,\n ]\n : []),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:billing'),\n },\n ],\n },\n statusField({\n overrides: {\n admin: {\n position: 'sidebar',\n },\n },\n }),\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n {\n name: 'customerEmail',\n type: 'email',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customerEmail'),\n },\n {\n name: 'order',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:order'),\n relationTo: ordersSlug,\n },\n {\n name: 'cart',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n relationTo: cartsSlug,\n },\n ...(currenciesConfig\n ? [\n {\n type: 'row',\n admin: {\n position: 'sidebar',\n },\n fields: [\n amountField({\n currenciesConfig,\n }),\n currencyField({\n currenciesConfig,\n }),\n ],\n } as Field,\n ]\n : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'transactions',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOnly,\n update: adminOnly,\n },\n admin: {\n defaultColumns: ['createdAt', 'customer', 'order', 'amount', 'status'],\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transactionsCollectionDescription'),\n group: 'Ecommerce',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transactions'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transaction'),\n },\n }\n\n return { ...baseConfig }\n}\n"],"names":["amountField","cartItemsField","currencyField","statusField","createTransactionsCollection","props","access","adminOnly","addressFields","cartsSlug","currenciesConfig","customersSlug","enableVariants","ordersSlug","paymentMethods","productsSlug","variantsSlug","fields","type","tabs","overrides","name","label","t","labels","plural","singular","length","options","map","method","value","group","admin","position","relationTo","baseConfig","slug","create","delete","read","update","defaultColumns","description"],"mappings":"AAIA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,aAAa,QAAQ,gCAA+B;AAC7D,SAASC,WAAW,QAAQ,8BAA6B;AAsCzD,OAAO,MAAMC,+BAAmE,CAACC;IAC/E,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAE,EACrBC,aAAa,EACbC,YAAY,OAAO,EACnBC,gBAAgB,EAChBC,gBAAgB,OAAO,EACvBC,iBAAiB,KAAK,EACtBC,aAAa,QAAQ,EACrBC,cAAc,EACdC,eAAe,UAAU,EACzBC,eAAe,UAAU,EAC1B,GAAGX,SAAS,CAAC;IAEd,MAAMY,SAAkB;QACtB;YACE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DAA+D;gBAC/DA,EAAE;YACJY,YAAYxB;QACd;QACA;YACEU,MAAM;YACNH,MAAM;YACNe,OAAO;gBACLC,UAAU;YACZ;YACAZ,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;gBAC/DA,EAAE;QACN;QACA;YACEF,MAAM;YACNH,MAAM;YACNe,OAAO;gBACLC,UAAU;YACZ;YACAZ,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;gBAC/DA,EAAE;YACJY,YAAYtB;QACd;QACA;YACEQ,MAAM;YACNH,MAAM;YACNe,OAAO;gBACLC,UAAU;YACZ;YACAC,YAAY1B;QACd;WACIC,mBACA;YACE;gBACEQ,MAAM;gBACNe,OAAO;oBACLC,UAAU;gBACZ;gBACAjB,QAAQ;oBACNjB,YAAY;wBACVU;oBACF;oBACAR,cAAc;wBACZQ;oBACF;iBACD;YACH;SACD,GACD,EAAE;KACP;IAED,MAAM0B,aAA+B;QACnCC,MAAM;QACN/B,QAAQ;YACNgC,QAAQ/B;YACRgC,QAAQhC;YACRiC,MAAMjC;YACNkC,QAAQlC;QACV;QACA0B,OAAO;YACLS,gBAAgB;gBAAC;gBAAa;gBAAY;gBAAS;gBAAU;aAAS;YACtEC,aAAa,CAAC,EAAEpB,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJS,OAAO;QACT;QACAf;QACAO,QAAQ;YACNC,QAAQ,CAAC,EAAEF,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJG,UAAU,CAAC,EAAEH,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;IACF;IAEA,OAAO;QAAE,GAAGa,UAAU;IAAC;AACzB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/transactions/createTransactionsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig, PaymentAdapter } from '../../types/index.js'\n\nimport { amountField } from '../../fields/amountField.js'\nimport { cartItemsField } from '../../fields/cartItemsField.js'\nimport { currencyField } from '../../fields/currencyField.js'\nimport { statusField } from '../../fields/statusField.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n }\n /**\n * Array of fields used for capturing the billing address.\n */\n addressFields?: Field[]\n /**\n * Slug of the carts collection, defaults to 'carts'.\n */\n cartsSlug?: string\n currenciesConfig?: CurrenciesConfig\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Enable variants in the transactions collection.\n */\n enableVariants?: boolean\n /**\n * Slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n paymentMethods?: PaymentAdapter[]\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\nexport const createTransactionsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly },\n addressFields,\n cartsSlug = 'carts',\n currenciesConfig,\n customersSlug = 'users',\n enableVariants = false,\n ordersSlug = 'orders',\n paymentMethods,\n productsSlug = 'products',\n variantsSlug = 'variants',\n } = props || {}\n\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n cartItemsField({\n enableVariants,\n overrides: {\n name: 'items',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:item'),\n },\n },\n productsSlug,\n variantsSlug,\n }),\n ...(paymentMethods?.length && paymentMethods.length > 0\n ? [\n {\n name: 'paymentMethod',\n type: 'select',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:paymentMethod'),\n options: paymentMethods.map((method) => ({\n label: method.label ?? method.name,\n value: method.name,\n })),\n } as Field,\n ...(paymentMethods.map((method) => method.group) || []),\n ]\n : []),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transactionDetails'),\n },\n {\n fields: [\n ...(addressFields\n ? [\n {\n name: 'billingAddress',\n type: 'group',\n fields: addressFields,\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:billingAddress'),\n } as Field,\n ]\n : []),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:billing'),\n },\n ],\n },\n statusField({\n overrides: {\n admin: {\n position: 'sidebar',\n },\n },\n }),\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n {\n name: 'customerEmail',\n type: 'email',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customerEmail'),\n },\n {\n name: 'order',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:order'),\n relationTo: ordersSlug,\n },\n {\n name: 'cart',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n relationTo: cartsSlug,\n },\n ...(currenciesConfig\n ? [\n {\n type: 'row',\n admin: {\n position: 'sidebar',\n },\n fields: [\n amountField({\n currenciesConfig,\n }),\n currencyField({\n currenciesConfig,\n }),\n ],\n } as Field,\n ]\n : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'transactions',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOnly,\n update: adminOnly,\n },\n admin: {\n defaultColumns: ['createdAt', 'customer', 'order', 'amount', 'status'],\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transactionsCollectionDescription'),\n group: 'Ecommerce',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transactions'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transaction'),\n },\n }\n\n return { ...baseConfig }\n}\n"],"names":["amountField","cartItemsField","currencyField","statusField","createTransactionsCollection","props","access","adminOnly","addressFields","cartsSlug","currenciesConfig","customersSlug","enableVariants","ordersSlug","paymentMethods","productsSlug","variantsSlug","fields","type","tabs","overrides","name","label","t","labels","plural","singular","length","options","map","method","value","group","admin","position","relationTo","baseConfig","slug","create","delete","read","update","defaultColumns","description"],"mappings":"AAIA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,aAAa,QAAQ,gCAA+B;AAC7D,SAASC,WAAW,QAAQ,8BAA6B;AAsCzD,OAAO,MAAMC,+BAAmE,CAACC;IAC/E,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAE,EACrBC,aAAa,EACbC,YAAY,OAAO,EACnBC,gBAAgB,EAChBC,gBAAgB,OAAO,EACvBC,iBAAiB,KAAK,EACtBC,aAAa,QAAQ,EACrBC,cAAc,EACdC,eAAe,UAAU,EACzBC,eAAe,UAAU,EAC1B,GAAGX,SAAS,CAAC;IAEd,MAAMY,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;gBACJ;oBACEF,QAAQ;wBACNhB,eAAe;4BACbW;4BACAQ,WAAW;gCACTC,MAAM;gCACNC,OAAO,CAAC,EAAEC,CAAC,EAAE,GACX,+DAA+D;oCAC/DA,EAAE;gCACJC,QAAQ;oCACNC,QAAQ,CAAC,EAAEF,CAAC,EAAE,GACZ,+DAA+D;wCAC/DA,EAAE;oCACJG,UAAU,CAAC,EAAEH,CAAC,EAAE,GACd,+DAA+D;wCAC/DA,EAAE;gCACN;4BACF;4BACAR;4BACAC;wBACF;2BACIF,gBAAgBa,UAAUb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ACLC,UAAU;YACZ;YACAC,YAAY1B;QACd;WACIC,mBACA;YACE;gBACEQ,MAAM;gBACNe,OAAO;oBACLC,UAAU;gBACZ;gBACAjB,QAAQ;oBACNjB,YAAY;wBACVU;oBACF;oBACAR,cAAc;wBACZQ;oBACF;iBACD;YACH;SACD,GACD,EAAE;KACP;IAED,MAAM0B,aAA+B;QACnCC,MAAM;QACN/B,QAAQ;YACNgC,QAAQ/B;YACRgC,QAAQhC;YACRiC,MAAMjC;YACNkC,QAAQlC;QACV;QACA0B,OAAO;YACLS,gBAAgB;gBAAC;gBAAa;gBAAY;gBAAS;gBAAU;aAAS;YACtEC,aAAa,CAAC,EAAEpB,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJS,OAAO;QACT;QACAf;QACAO,QAAQ;YACNC,QAAQ,CAAC,EAAEF,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJG,UAAU,CAAC,EAAEH,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;IACF;IAEA,OAAO;QAAE,GAAGa,UAAU;IAAC;AACzB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createVariantOptionsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/variants/createVariantOptionsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createVariantOptionsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/variants/createVariantOptionsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;QACjD,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAA;KACxD,CAAA;IACD;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,8BAA8B,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBAwD9D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/variants/createVariantOptionsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig } from '../../types.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n publicAccess: NonNullable<AccessConfig['publicAccess']>\n }\n /**\n * Slug of the variant types collection, defaults to 'variantTypes'.\n */\n variantTypesSlug?: string\n}\n\nexport const createVariantOptionsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, publicAccess },\n variantTypesSlug = 'variantTypes',\n } = props || {}\n\n const fields: Field[] = [\n {\n name: 'variantType',\n type: 'relationship',\n admin: {\n readOnly: true,\n },\n relationTo: variantTypesSlug,\n required: true,\n },\n {\n name: 'label',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n description: 'should be defaulted or dynamic based on label',\n },\n required: true,\n },\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'variantOptions',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: publicAccess,\n update: adminOnly,\n },\n admin: {\n group: false,\n useAsTitle: 'label',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantOptions'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantOption'),\n },\n trash: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["createVariantOptionsCollection","props","access","adminOnly","publicAccess","variantTypesSlug","fields","name","type","admin","readOnly","relationTo","required","description","baseConfig","slug","create","delete","read","update","group","useAsTitle","labels","plural","t","singular","trash"],"mappings":"AAeA,OAAO,MAAMA,iCAAqE,CAACC;IACjF,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,YAAY,EAAE,EACnCC,mBAAmB,cAAc,EAClC,GAAGJ,SAAS,CAAC;IAEd,MAAMK,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAC,YAAYN;YACZO,UAAU;QACZ;QACA;YACEL,MAAM;YACNC,MAAM;YACNI,UAAU;QACZ;QACA;YACEL,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLI,aAAa;YACf;YACAD,UAAU;QACZ;KACD;IAED,MAAME,aAA+B;QACnCC,MAAM;QACNb,QAAQ;YACNc,QAAQb;YACRc,QAAQd;YACRe,MAAMd;YACNe,QAAQhB;QACV;QACAM,OAAO;YACLW,OAAO;YACPC,YAAY;QACd;QACAf;QACAgB,QAAQ;YACNC,QAAQ,CAAC,EAAEC,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJC,UAAU,CAAC,EAAED,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAE,OAAO;IACT;IAEA,OAAO;QAAE,GAAGZ,UAAU;IAAC;AACzB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/variants/createVariantOptionsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig } from '../../types/index.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n publicAccess: NonNullable<AccessConfig['publicAccess']>\n }\n /**\n * Slug of the variant types collection, defaults to 'variantTypes'.\n */\n variantTypesSlug?: string\n}\n\nexport const createVariantOptionsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, publicAccess },\n variantTypesSlug = 'variantTypes',\n } = props || {}\n\n const fields: Field[] = [\n {\n name: 'variantType',\n type: 'relationship',\n admin: {\n readOnly: true,\n },\n relationTo: variantTypesSlug,\n required: true,\n },\n {\n name: 'label',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n description: 'should be defaulted or dynamic based on label',\n },\n required: true,\n },\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'variantOptions',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: publicAccess,\n update: adminOnly,\n },\n admin: {\n group: false,\n useAsTitle: 'label',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantOptions'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantOption'),\n },\n trash: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["createVariantOptionsCollection","props","access","adminOnly","publicAccess","variantTypesSlug","fields","name","type","admin","readOnly","relationTo","required","description","baseConfig","slug","create","delete","read","update","group","useAsTitle","labels","plural","t","singular","trash"],"mappings":"AAeA,OAAO,MAAMA,iCAAqE,CAACC;IACjF,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,YAAY,EAAE,EACnCC,mBAAmB,cAAc,EAClC,GAAGJ,SAAS,CAAC;IAEd,MAAMK,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAC,YAAYN;YACZO,UAAU;QACZ;QACA;YACEL,MAAM;YACNC,MAAM;YACNI,UAAU;QACZ;QACA;YACEL,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLI,aAAa;YACf;YACAD,UAAU;QACZ;KACD;IAED,MAAME,aAA+B;QACnCC,MAAM;QACNb,QAAQ;YACNc,QAAQb;YACRc,QAAQd;YACRe,MAAMd;YACNe,QAAQhB;QACV;QACAM,OAAO;YACLW,OAAO;YACPC,YAAY;QACd;QACAf;QACAgB,QAAQ;YACNC,QAAQ,CAAC,EAAEC,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJC,UAAU,CAAC,EAAED,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAE,OAAO;IACT;IAEA,OAAO;QAAE,GAAGZ,UAAU;IAAC;AACzB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createVariantTypesCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/variants/createVariantTypesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createVariantTypesCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/variants/createVariantTypesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;QACjD,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAA;KACxD,CAAA;IACD;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBAoD5D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/variants/createVariantTypesCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig } from '../../types.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n publicAccess: NonNullable<AccessConfig['publicAccess']>\n }\n /**\n * Slug of the variant options collection, defaults to 'variantOptions'.\n */\n variantOptionsSlug?: string\n}\n\nexport const createVariantTypesCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, publicAccess },\n variantOptionsSlug = 'variantOptions',\n } = props || {}\n\n const fields: Field[] = [\n {\n name: 'label',\n type: 'text',\n required: true,\n },\n {\n name: 'name',\n type: 'text',\n required: true,\n },\n {\n name: 'options',\n type: 'join',\n collection: variantOptionsSlug,\n maxDepth: 2,\n on: 'variantType',\n orderable: true,\n },\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'variantTypes',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: publicAccess,\n update: adminOnly,\n },\n admin: {\n group: false,\n useAsTitle: 'label',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantTypes'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantType'),\n },\n trash: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["createVariantTypesCollection","props","access","adminOnly","publicAccess","variantOptionsSlug","fields","name","type","required","collection","maxDepth","on","orderable","baseConfig","slug","create","delete","read","update","admin","group","useAsTitle","labels","plural","t","singular","trash"],"mappings":"AAeA,OAAO,MAAMA,+BAAmE,CAACC;IAC/E,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,YAAY,EAAE,EACnCC,qBAAqB,gBAAgB,EACtC,GAAGJ,SAAS,CAAC;IAEd,MAAMK,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,UAAU;QACZ;QACA;YACEF,MAAM;YACNC,MAAM;YACNC,UAAU;QACZ;QACA;YACEF,MAAM;YACNC,MAAM;YACNE,YAAYL;YACZM,UAAU;YACVC,IAAI;YACJC,WAAW;QACb;KACD;IAED,MAAMC,aAA+B;QACnCC,MAAM;QACNb,QAAQ;YACNc,QAAQb;YACRc,QAAQd;YACRe,MAAMd;YACNe,QAAQhB;QACV;QACAiB,OAAO;YACLC,OAAO;YACPC,YAAY;QACd;QACAhB;QACAiB,QAAQ;YACNC,QAAQ,CAAC,EAAEC,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJC,UAAU,CAAC,EAAED,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAE,OAAO;IACT;IAEA,OAAO;QAAE,GAAGb,UAAU;IAAC;AACzB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/variants/createVariantTypesCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig } from '../../types/index.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n publicAccess: NonNullable<AccessConfig['publicAccess']>\n }\n /**\n * Slug of the variant options collection, defaults to 'variantOptions'.\n */\n variantOptionsSlug?: string\n}\n\nexport const createVariantTypesCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, publicAccess },\n variantOptionsSlug = 'variantOptions',\n } = props || {}\n\n const fields: Field[] = [\n {\n name: 'label',\n type: 'text',\n required: true,\n },\n {\n name: 'name',\n type: 'text',\n required: true,\n },\n {\n name: 'options',\n type: 'join',\n collection: variantOptionsSlug,\n maxDepth: 2,\n on: 'variantType',\n orderable: true,\n },\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'variantTypes',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: publicAccess,\n update: adminOnly,\n },\n admin: {\n group: false,\n useAsTitle: 'label',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantTypes'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantType'),\n },\n trash: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["createVariantTypesCollection","props","access","adminOnly","publicAccess","variantOptionsSlug","fields","name","type","required","collection","maxDepth","on","orderable","baseConfig","slug","create","delete","read","update","admin","group","useAsTitle","labels","plural","t","singular","trash"],"mappings":"AAeA,OAAO,MAAMA,+BAAmE,CAACC;IAC/E,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,YAAY,EAAE,EACnCC,qBAAqB,gBAAgB,EACtC,GAAGJ,SAAS,CAAC;IAEd,MAAMK,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,UAAU;QACZ;QACA;YACEF,MAAM;YACNC,MAAM;YACNC,UAAU;QACZ;QACA;YACEF,MAAM;YACNC,MAAM;YACNE,YAAYL;YACZM,UAAU;YACVC,IAAI;YACJC,WAAW;QACb;KACD;IAED,MAAMC,aAA+B;QACnCC,MAAM;QACNb,QAAQ;YACNc,QAAQb;YACRc,QAAQd;YACRe,MAAMd;YACNe,QAAQhB;QACV;QACAiB,OAAO;YACLC,OAAO;YACPC,YAAY;QACd;QACAhB;QACAiB,QAAQ;YACNC,QAAQ,CAAC,EAAEC,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJC,UAAU,CAAC,EAAED,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAE,OAAO;IACT;IAEA,OAAO;QAAE,GAAGb,UAAU;IAAC;AACzB,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionConfig } from 'payload';
|
|
2
|
-
import type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../../types.js';
|
|
2
|
+
import type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../../types/index.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
access: {
|
|
5
5
|
adminOnly: NonNullable<AccessConfig['adminOnly']>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/collections/variants/createVariantsCollection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/collections/variants/createVariantsCollection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAO9F,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;QACjD,sBAAsB,EAAE,WAAW,CAAC,YAAY,CAAC,wBAAwB,CAAC,CAAC,CAAA;KAC5E,CAAA;IACD,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,eAAe,CAAA;IACrC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBAqGxD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/variants/createVariantsCollection/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../../types.js'\n\nimport { inventoryField } from '../../../fields/inventoryField.js'\nimport { pricesField } from '../../../fields/pricesField.js'\nimport { variantsCollectionBeforeChange as beforeChange } from './hooks/beforeChange.js'\nimport { validateOptions } from './hooks/validateOptions.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n adminOrPublishedStatus: NonNullable<AccessConfig['adminOrPublishedStatus']>\n }\n currenciesConfig?: CurrenciesConfig\n /**\n * Enables inventory tracking for variants. Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the variant options collection, defaults to 'variantOptions'.\n */\n variantOptionsSlug?: string\n}\n\nexport const createVariantsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, adminOrPublishedStatus },\n currenciesConfig,\n inventory = true,\n productsSlug = 'products',\n variantOptionsSlug = 'variantOptions',\n } = props || {}\n const { supportedCurrencies } = currenciesConfig || {}\n\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n admin: {\n description:\n 'Used for administrative purposes, not shown to customers. This is populated by default.',\n },\n },\n {\n name: 'product',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n relationTo: productsSlug,\n required: true,\n },\n {\n // This might need to be a custom component, to show a selector for each variant that is\n // enabled on the parent product\n // - separate select inputs, each showing only a specific variant (w/ options)\n // - it will save data to the DB as IDs in this relationship field\n // and needs a validate function as well which enforces that the options are fully specified, and accurate\n name: 'options',\n type: 'relationship',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/plugin-ecommerce/rsc#VariantOptionsSelector',\n },\n },\n },\n hasMany: true,\n label: 'Variant options',\n relationTo: variantOptionsSlug,\n required: true,\n validate: validateOptions(),\n },\n ...(inventory ? [inventoryField()] : []),\n ]\n\n if (supportedCurrencies?.length && supportedCurrencies.length > 0) {\n const currencyOptions: string[] = []\n\n supportedCurrencies.forEach((currency) => {\n currencyOptions.push(currency.code)\n })\n\n if (currenciesConfig) {\n fields.push(...pricesField({ currenciesConfig }))\n }\n }\n\n const baseConfig: CollectionConfig = {\n slug: 'variants',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOrPublishedStatus,\n update: adminOnly,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantsCollectionDescription'),\n group: false,\n useAsTitle: 'title',\n },\n fields,\n hooks: {\n beforeChange: [beforeChange({ productsSlug, variantOptionsSlug })],\n },\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variants'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variant'),\n },\n trash: true,\n versions: {\n drafts: {\n autosave: true,\n },\n },\n }\n\n return baseConfig\n}\n"],"names":["inventoryField","pricesField","variantsCollectionBeforeChange","beforeChange","validateOptions","createVariantsCollection","props","access","adminOnly","adminOrPublishedStatus","currenciesConfig","inventory","productsSlug","variantOptionsSlug","supportedCurrencies","fields","name","type","admin","description","position","readOnly","relationTo","required","components","Field","path","hasMany","label","validate","length","currencyOptions","forEach","currency","push","code","baseConfig","slug","create","delete","read","update","t","group","useAsTitle","hooks","labels","plural","singular","trash","versions","drafts","autosave"],"mappings":"AAIA,SAASA,cAAc,QAAQ,oCAAmC;AAClE,SAASC,WAAW,QAAQ,iCAAgC;AAC5D,SAASC,kCAAkCC,YAAY,QAAQ,0BAAyB;AACxF,SAASC,eAAe,QAAQ,6BAA4B;AAsB5D,OAAO,MAAMC,2BAA+D,CAACC;IAC3E,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,sBAAsB,EAAE,EAC7CC,gBAAgB,EAChBC,YAAY,IAAI,EAChBC,eAAe,UAAU,EACzBC,qBAAqB,gBAAgB,EACtC,GAAGP,SAAS,CAAC;IACd,MAAM,EAAEQ,mBAAmB,EAAE,GAAGJ,oBAAoB,CAAC;IAErD,MAAMK,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,aACE;YACJ;QACF;QACA;YACEH,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLE,UAAU;gBACVC,UAAU;YACZ;YACAC,YAAYV;YACZW,UAAU;QACZ;QACA;YACE,wFAAwF;YACxF,gCAAgC;YAChC,8EAA8E;YAC9E,kEAAkE;YAClE,0GAA0G;YAC1GP,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLM,YAAY;oBACVC,OAAO;wBACLC,MAAM;oBACR;gBACF;YACF;YACAC,SAAS;YACTC,OAAO;YACPN,YAAYT;YACZU,UAAU;YACVM,UAAUzB;QACZ;WACIO,YAAY;YAACX;SAAiB,GAAG,EAAE;KACxC;IAED,IAAIc,qBAAqBgB,UAAUhB,oBAAoBgB,MAAM,GAAG,GAAG;QACjE,MAAMC,kBAA4B,EAAE;QAEpCjB,oBAAoBkB,OAAO,CAAC,CAACC;YAC3BF,gBAAgBG,IAAI,CAACD,SAASE,IAAI;QACpC;QAEA,IAAIzB,kBAAkB;YACpBK,OAAOmB,IAAI,IAAIjC,YAAY;gBAAES;YAAiB;QAChD;IACF;IAEA,MAAM0B,aAA+B;QACnCC,MAAM;QACN9B,QAAQ;YACN+B,QAAQ9B;YACR+B,QAAQ/B;YACRgC,MAAM/B;YACNgC,QAAQjC;QACV;QACAU,OAAO;YACLC,aAAa,CAAC,EAAEuB,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJC,OAAO;YACPC,YAAY;QACd;QACA7B;QACA8B,OAAO;YACL1C,cAAc;gBAACA,aAAa;oBAAES;oBAAcC;gBAAmB;aAAG;QACpE;QACAiC,QAAQ;YACNC,QAAQ,CAAC,EAAEL,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJM,UAAU,CAAC,EAAEN,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAO,OAAO;QACPC,UAAU;YACRC,QAAQ;gBACNC,UAAU;YACZ;QACF;IACF;IAEA,OAAOhB;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/variants/createVariantsCollection/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../../types/index.js'\n\nimport { inventoryField } from '../../../fields/inventoryField.js'\nimport { pricesField } from '../../../fields/pricesField.js'\nimport { variantsCollectionBeforeChange as beforeChange } from './hooks/beforeChange.js'\nimport { validateOptions } from './hooks/validateOptions.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n adminOrPublishedStatus: NonNullable<AccessConfig['adminOrPublishedStatus']>\n }\n currenciesConfig?: CurrenciesConfig\n /**\n * Enables inventory tracking for variants. Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the variant options collection, defaults to 'variantOptions'.\n */\n variantOptionsSlug?: string\n}\n\nexport const createVariantsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, adminOrPublishedStatus },\n currenciesConfig,\n inventory = true,\n productsSlug = 'products',\n variantOptionsSlug = 'variantOptions',\n } = props || {}\n const { supportedCurrencies } = currenciesConfig || {}\n\n const fields: Field[] = [\n {\n name: 'title',\n type: 'text',\n admin: {\n description:\n 'Used for administrative purposes, not shown to customers. This is populated by default.',\n },\n },\n {\n name: 'product',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n relationTo: productsSlug,\n required: true,\n },\n {\n // This might need to be a custom component, to show a selector for each variant that is\n // enabled on the parent product\n // - separate select inputs, each showing only a specific variant (w/ options)\n // - it will save data to the DB as IDs in this relationship field\n // and needs a validate function as well which enforces that the options are fully specified, and accurate\n name: 'options',\n type: 'relationship',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/plugin-ecommerce/rsc#VariantOptionsSelector',\n },\n },\n },\n hasMany: true,\n label: 'Variant options',\n relationTo: variantOptionsSlug,\n required: true,\n validate: validateOptions(),\n },\n ...(inventory ? [inventoryField()] : []),\n ]\n\n if (supportedCurrencies?.length && supportedCurrencies.length > 0) {\n const currencyOptions: string[] = []\n\n supportedCurrencies.forEach((currency) => {\n currencyOptions.push(currency.code)\n })\n\n if (currenciesConfig) {\n fields.push(...pricesField({ currenciesConfig }))\n }\n }\n\n const baseConfig: CollectionConfig = {\n slug: 'variants',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOrPublishedStatus,\n update: adminOnly,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variantsCollectionDescription'),\n group: false,\n useAsTitle: 'title',\n },\n fields,\n hooks: {\n beforeChange: [beforeChange({ productsSlug, variantOptionsSlug })],\n },\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variants'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:variant'),\n },\n trash: true,\n versions: {\n drafts: {\n autosave: true,\n },\n },\n }\n\n return baseConfig\n}\n"],"names":["inventoryField","pricesField","variantsCollectionBeforeChange","beforeChange","validateOptions","createVariantsCollection","props","access","adminOnly","adminOrPublishedStatus","currenciesConfig","inventory","productsSlug","variantOptionsSlug","supportedCurrencies","fields","name","type","admin","description","position","readOnly","relationTo","required","components","Field","path","hasMany","label","validate","length","currencyOptions","forEach","currency","push","code","baseConfig","slug","create","delete","read","update","t","group","useAsTitle","hooks","labels","plural","singular","trash","versions","drafts","autosave"],"mappings":"AAIA,SAASA,cAAc,QAAQ,oCAAmC;AAClE,SAASC,WAAW,QAAQ,iCAAgC;AAC5D,SAASC,kCAAkCC,YAAY,QAAQ,0BAAyB;AACxF,SAASC,eAAe,QAAQ,6BAA4B;AAsB5D,OAAO,MAAMC,2BAA+D,CAACC;IAC3E,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,sBAAsB,EAAE,EAC7CC,gBAAgB,EAChBC,YAAY,IAAI,EAChBC,eAAe,UAAU,EACzBC,qBAAqB,gBAAgB,EACtC,GAAGP,SAAS,CAAC;IACd,MAAM,EAAEQ,mBAAmB,EAAE,GAAGJ,oBAAoB,CAAC;IAErD,MAAMK,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,aACE;YACJ;QACF;QACA;YACEH,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLE,UAAU;gBACVC,UAAU;YACZ;YACAC,YAAYV;YACZW,UAAU;QACZ;QACA;YACE,wFAAwF;YACxF,gCAAgC;YAChC,8EAA8E;YAC9E,kEAAkE;YAClE,0GAA0G;YAC1GP,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLM,YAAY;oBACVC,OAAO;wBACLC,MAAM;oBACR;gBACF;YACF;YACAC,SAAS;YACTC,OAAO;YACPN,YAAYT;YACZU,UAAU;YACVM,UAAUzB;QACZ;WACIO,YAAY;YAACX;SAAiB,GAAG,EAAE;KACxC;IAED,IAAIc,qBAAqBgB,UAAUhB,oBAAoBgB,MAAM,GAAG,GAAG;QACjE,MAAMC,kBAA4B,EAAE;QAEpCjB,oBAAoBkB,OAAO,CAAC,CAACC;YAC3BF,gBAAgBG,IAAI,CAACD,SAASE,IAAI;QACpC;QAEA,IAAIzB,kBAAkB;YACpBK,OAAOmB,IAAI,IAAIjC,YAAY;gBAAES;YAAiB;QAChD;IACF;IAEA,MAAM0B,aAA+B;QACnCC,MAAM;QACN9B,QAAQ;YACN+B,QAAQ9B;YACR+B,QAAQ/B;YACRgC,MAAM/B;YACNgC,QAAQjC;QACV;QACAU,OAAO;YACLC,aAAa,CAAC,EAAEuB,CAAC,EAAE,GACjB,+DAA+D;gBAC/DA,EAAE;YACJC,OAAO;YACPC,YAAY;QACd;QACA7B;QACA8B,OAAO;YACL1C,cAAc;gBAACA,aAAa;oBAAES;oBAAcC;gBAAmB;aAAG;QACpE;QACAiC,QAAQ;YACNC,QAAQ,CAAC,EAAEL,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJM,UAAU,CAAC,EAAEN,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAO,OAAO;QACPC,UAAU;YACRC,QAAQ;gBACNC,UAAU;YACZ;QACF;IACF;IAEA,OAAOhB;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currencies/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currencies/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,eAAO,MAAM,GAAG,EAAE,QAKjB,CAAA;AAED,eAAO,MAAM,GAAG,EAAE,QAKjB,CAAA;AAED,eAAO,MAAM,GAAG,EAAE,QAKjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/currencies/index.ts"],"sourcesContent":["import type { Currency } from '../types.js'\n\nexport const EUR: Currency = {\n code: 'EUR',\n decimals: 2,\n label: 'Euro',\n symbol: '€',\n}\n\nexport const USD: Currency = {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n}\n\nexport const GBP: Currency = {\n code: 'GBP',\n decimals: 2,\n label: 'British Pound',\n symbol: '£',\n}\n"],"names":["EUR","code","decimals","label","symbol","USD","GBP"],"mappings":"AAEA,OAAO,MAAMA,MAAgB;IAC3BC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,QAAQ;AACV,EAAC;AAED,OAAO,MAAMC,MAAgB;IAC3BJ,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,QAAQ;AACV,EAAC;AAED,OAAO,MAAME,MAAgB;IAC3BL,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,QAAQ;AACV,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/currencies/index.ts"],"sourcesContent":["import type { Currency } from '../types/index.js'\n\nexport const EUR: Currency = {\n code: 'EUR',\n decimals: 2,\n label: 'Euro',\n symbol: '€',\n}\n\nexport const USD: Currency = {\n code: 'USD',\n decimals: 2,\n label: 'US Dollar',\n symbol: '$',\n}\n\nexport const GBP: Currency = {\n code: 'GBP',\n decimals: 2,\n label: 'British Pound',\n symbol: '£',\n}\n"],"names":["EUR","code","decimals","label","symbol","USD","GBP"],"mappings":"AAEA,OAAO,MAAMA,MAAgB;IAC3BC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,QAAQ;AACV,EAAC;AAED,OAAO,MAAMC,MAAgB;IAC3BJ,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,QAAQ;AACV,EAAC;AAED,OAAO,MAAME,MAAgB;IAC3BL,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,QAAQ;AACV,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Endpoint } from 'payload';
|
|
2
|
-
import type { CurrenciesConfig, PaymentAdapter, ProductsValidation } from '../types.js';
|
|
2
|
+
import type { CurrenciesConfig, PaymentAdapter, ProductsValidation } from '../types/index.js';
|
|
3
3
|
type Args = {
|
|
4
4
|
/**
|
|
5
5
|
* The slug of the carts collection, defaults to 'carts'.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmOrder.d.ts","sourceRoot":"","sources":["../../src/endpoints/confirmOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuD,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAE5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"confirmOrder.d.ts","sourceRoot":"","sources":["../../src/endpoints/confirmOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuD,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAE5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE7F,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,cAAc,CAAA;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,KAAK,mBAAmB,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAA;AAE9D;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,mBAkL/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/endpoints/confirmOrder.ts"],"sourcesContent":["import { addDataAndFileToRequest, type DefaultDocumentIDType, type Endpoint } from 'payload'\n\nimport type { CurrenciesConfig, PaymentAdapter, ProductsValidation } from '../types.js'\n\ntype Args = {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n */\n cartsSlug?: string\n currenciesConfig: CurrenciesConfig\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n paymentMethod: PaymentAdapter\n /**\n * The slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Customise the validation used for checking products or variants before a transaction is created.\n */\n productsValidation?: ProductsValidation\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n */\n transactionsSlug?: string\n /**\n * The slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\ntype ConfirmOrderHandler = (args: Args) => Endpoint['handler']\n\n/**\n * Handles the endpoint for initiating payments. We will handle checking the amount and product and variant prices here before it is sent to the payment provider.\n * This is the first step in the payment process.\n */\nexport const confirmOrderHandler: ConfirmOrderHandler =\n ({\n cartsSlug = 'carts',\n currenciesConfig,\n customersSlug = 'users',\n ordersSlug = 'orders',\n paymentMethod,\n productsSlug = 'products',\n productsValidation,\n transactionsSlug = 'transactions',\n variantsSlug = 'variants',\n }) =>\n async (req) => {\n await addDataAndFileToRequest(req)\n\n const data = req.data\n const payload = req.payload\n const user = req.user\n\n let currency: string = currenciesConfig.defaultCurrency\n let cartID: DefaultDocumentIDType = data?.cartID\n let cart = undefined\n let customerEmail: string = user?.email ?? ''\n\n if (user) {\n if (user.cart?.docs && Array.isArray(user.cart.docs) && user.cart.docs.length > 0) {\n if (!cartID && user.cart.docs[0]) {\n // Use the user's cart instead\n if (typeof user.cart.docs[0] === 'object') {\n cartID = user.cart.docs[0].id\n cart = user.cart.docs[0]\n } else {\n cartID = user.cart.docs[0]\n }\n }\n }\n } else {\n // Get the email from the data if user is not available\n if (data?.customerEmail && typeof data.customerEmail === 'string') {\n customerEmail = data.customerEmail\n } else {\n return Response.json(\n {\n message: 'A customer email is required to make a purchase.',\n },\n {\n status: 400,\n },\n )\n }\n }\n\n if (!cart) {\n if (cartID) {\n cart = await payload.findByID({\n id: cartID,\n collection: cartsSlug,\n depth: 2,\n overrideAccess: false,\n select: {\n id: true,\n currency: true,\n customerEmail: true,\n items: true,\n subtotal: true,\n },\n user,\n })\n\n if (!cart) {\n return Response.json(\n {\n message: `Cart with ID ${cartID} not found.`,\n },\n {\n status: 404,\n },\n )\n }\n } else {\n return Response.json(\n {\n message: 'Cart ID is required.',\n },\n {\n status: 400,\n },\n )\n }\n }\n\n if (cart.currency && typeof cart.currency === 'string') {\n currency = cart.currency\n }\n\n // Ensure the currency is provided or inferred in some way\n if (!currency) {\n return Response.json(\n {\n message: 'Currency is required.',\n },\n {\n status: 400,\n },\n )\n }\n\n try {\n const paymentResponse = await paymentMethod.confirmOrder({\n customersSlug,\n data: {\n ...data,\n customerEmail,\n },\n ordersSlug,\n req,\n transactionsSlug,\n })\n\n if (paymentResponse.transactionID) {\n const transaction = await payload.findByID({\n id: paymentResponse.transactionID,\n collection: transactionsSlug,\n depth: 0,\n select: {\n id: true,\n items: true,\n },\n })\n\n if (transaction && Array.isArray(transaction.items) && transaction.items.length > 0) {\n for (const item of transaction.items) {\n if (item.variant) {\n const id = typeof item.variant === 'object' ? item.variant.id : item.variant\n\n await payload.db.updateOne({\n id,\n collection: variantsSlug,\n data: {\n inventory: {\n $inc: item.quantity * -1,\n },\n },\n })\n } else if (item.product) {\n const id = typeof item.product === 'object' ? item.product.id : item.product\n\n await payload.db.updateOne({\n id,\n collection: productsSlug,\n data: {\n inventory: {\n $inc: item.quantity * -1,\n },\n },\n })\n }\n }\n }\n }\n\n if ('paymentResponse.transactionID' in paymentResponse && paymentResponse.transactionID) {\n delete (paymentResponse as Partial<typeof paymentResponse>).transactionID\n }\n\n return Response.json(paymentResponse)\n } catch (error) {\n payload.logger.error(error, 'Error confirming order.')\n\n return Response.json(\n {\n message: 'Error confirming order.',\n },\n {\n status: 500,\n },\n )\n }\n }\n"],"names":["addDataAndFileToRequest","confirmOrderHandler","cartsSlug","currenciesConfig","customersSlug","ordersSlug","paymentMethod","productsSlug","productsValidation","transactionsSlug","variantsSlug","req","data","payload","user","currency","defaultCurrency","cartID","cart","undefined","customerEmail","email","docs","Array","isArray","length","id","Response","json","message","status","findByID","collection","depth","overrideAccess","select","items","subtotal","paymentResponse","confirmOrder","transactionID","transaction","item","variant","db","updateOne","inventory","$inc","quantity","product","error","logger"],"mappings":"AAAA,SAASA,uBAAuB,QAAmD,UAAS;AAuC5F;;;CAGC,GACD,OAAO,MAAMC,sBACX,CAAC,EACCC,YAAY,OAAO,EACnBC,gBAAgB,EAChBC,gBAAgB,OAAO,EACvBC,aAAa,QAAQ,EACrBC,aAAa,EACbC,eAAe,UAAU,EACzBC,kBAAkB,EAClBC,mBAAmB,cAAc,EACjCC,eAAe,UAAU,EAC1B,GACD,OAAOC;QACL,MAAMX,wBAAwBW;QAE9B,MAAMC,OAAOD,IAAIC,IAAI;QACrB,MAAMC,UAAUF,IAAIE,OAAO;QAC3B,MAAMC,OAAOH,IAAIG,IAAI;QAErB,IAAIC,WAAmBZ,iBAAiBa,eAAe;QACvD,IAAIC,SAAgCL,MAAMK;QAC1C,IAAIC,O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,QAAQ+B,EAAE,CAACC,SAAS,CAAC;gCACzBnB;gCACAM,YAAYzB;gCACZK,MAAM;oCACJkC,WAAW;wCACTC,MAAML,KAAKM,QAAQ,GAAG,CAAC;oCACzB;gCACF;4BACF;wBACF;oBACF;gBACF;YACF;YAEA,IAAI,mCAAmCV,mBAAmBA,gBAAgBE,aAAa,EAAE;gBACvF,OAAO,AAACF,gBAAoDE,aAAa;YAC3E;YAEA,OAAOb,SAASC,IAAI,CAACU;QACvB,EAAE,OAAOY,OAAO;YACdrC,QAAQsC,MAAM,CAACD,KAAK,CAACA,OAAO;YAE5B,OAAOvB,SAASC,IAAI,CAClB;gBACEC,SAAS;YACX,GACA;gBACEC,QAAQ;YACV;QAEJ;IACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/endpoints/confirmOrder.ts"],"sourcesContent":["import { addDataAndFileToRequest, type DefaultDocumentIDType, type Endpoint } from 'payload'\n\nimport type { CurrenciesConfig, PaymentAdapter, ProductsValidation } from '../types/index.js'\n\ntype Args = {\n /**\n * The slug of the carts collection, defaults to 'carts'.\n */\n cartsSlug?: string\n currenciesConfig: CurrenciesConfig\n /**\n * The slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * The slug of the orders collection, defaults to 'orders'.\n */\n ordersSlug?: string\n paymentMethod: PaymentAdapter\n /**\n * The slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Customise the validation used for checking products or variants before a transaction is created.\n */\n productsValidation?: ProductsValidation\n /**\n * The slug of the transactions collection, defaults to 'transactions'.\n */\n transactionsSlug?: string\n /**\n * The slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\ntype ConfirmOrderHandler = (args: Args) => Endpoint['handler']\n\n/**\n * Handles the endpoint for initiating payments. We will handle checking the amount and product and variant prices here before it is sent to the payment provider.\n * This is the first step in the payment process.\n */\nexport const confirmOrderHandler: ConfirmOrderHandler =\n ({\n cartsSlug = 'carts',\n currenciesConfig,\n customersSlug = 'users',\n ordersSlug = 'orders',\n paymentMethod,\n productsSlug = 'products',\n productsValidation,\n transactionsSlug = 'transactions',\n variantsSlug = 'variants',\n }) =>\n async (req) => {\n await addDataAndFileToRequest(req)\n\n const data = req.data\n const payload = req.payload\n const user = req.user\n\n let currency: string = currenciesConfig.defaultCurrency\n let cartID: DefaultDocumentIDType = data?.cartID\n let cart = undefined\n let customerEmail: string = user?.email ?? ''\n\n if (user) {\n if (user.cart?.docs && Array.isArray(user.cart.docs) && user.cart.docs.length > 0) {\n if (!cartID && user.cart.docs[0]) {\n // Use the user's cart instead\n if (typeof user.cart.docs[0] === 'object') {\n cartID = user.cart.docs[0].id\n cart = user.cart.docs[0]\n } else {\n cartID = user.cart.docs[0]\n }\n }\n }\n } else {\n // Get the email from the data if user is not available\n if (data?.customerEmail && typeof data.customerEmail === 'string') {\n customerEmail = data.customerEmail\n } else {\n return Response.json(\n {\n message: 'A customer email is required to make a purchase.',\n },\n {\n status: 400,\n },\n )\n }\n }\n\n if (!cart) {\n if (cartID) {\n cart = await payload.findByID({\n id: cartID,\n collection: cartsSlug,\n depth: 2,\n overrideAccess: false,\n select: {\n id: true,\n currency: true,\n customerEmail: true,\n items: true,\n subtotal: true,\n },\n user,\n })\n\n if (!cart) {\n return Response.json(\n {\n message: `Cart with ID ${cartID} not found.`,\n },\n {\n status: 404,\n },\n )\n }\n } else {\n return Response.json(\n {\n message: 'Cart ID is required.',\n },\n {\n status: 400,\n },\n )\n }\n }\n\n if (cart.currency && typeof cart.currency === 'string') {\n currency = cart.currency\n }\n\n // Ensure the currency is provided or inferred in some way\n if (!currency) {\n return Response.json(\n {\n message: 'Currency is required.',\n },\n {\n status: 400,\n },\n )\n }\n\n try {\n const paymentResponse = await paymentMethod.confirmOrder({\n customersSlug,\n data: {\n ...data,\n customerEmail,\n },\n ordersSlug,\n req,\n transactionsSlug,\n })\n\n if (paymentResponse.transactionID) {\n const transaction = await payload.findByID({\n id: paymentResponse.transactionID,\n collection: transactionsSlug,\n depth: 0,\n select: {\n id: true,\n items: true,\n },\n })\n\n if (transaction && Array.isArray(transaction.items) && transaction.items.length > 0) {\n for (const item of transaction.items) {\n if (item.variant) {\n const id = typeof item.variant === 'object' ? item.variant.id : item.variant\n\n await payload.db.updateOne({\n id,\n collection: variantsSlug,\n data: {\n inventory: {\n $inc: item.quantity * -1,\n },\n },\n })\n } else if (item.product) {\n const id = typeof item.product === 'object' ? item.product.id : item.product\n\n await payload.db.updateOne({\n id,\n collection: productsSlug,\n data: {\n inventory: {\n $inc: item.quantity * -1,\n },\n },\n })\n }\n }\n }\n }\n\n if ('paymentResponse.transactionID' in paymentResponse && paymentResponse.transactionID) {\n delete (paymentResponse as Partial<typeof paymentResponse>).transactionID\n }\n\n return Response.json(paymentResponse)\n } catch (error) {\n payload.logger.error(error, 'Error confirming order.')\n\n return Response.json(\n {\n message: 'Error confirming order.',\n },\n {\n status: 500,\n },\n )\n }\n }\n"],"names":["addDataAndFileToRequest","confirmOrderHandler","cartsSlug","currenciesConfig","customersSlug","ordersSlug","paymentMethod","productsSlug","productsValidation","transactionsSlug","variantsSlug","req","data","payload","user","currency","defaultCurrency","cartID","cart","undefined","customerEmail","email","docs","Array","isArray","length","id","Response","json","message","status","findByID","collection","depth","overrideAccess","select","items","subtotal","paymentResponse","confirmOrder","transactionID","transaction","item","variant","db","updateOne","inventory","$inc","quantity","product","error","logger"],"mappings":"AAAA,SAASA,uBAAuB,QAAmD,UAAS;AAuC5F;;;CAGC,GACD,OAAO,MAAMC,sBACX,CAAC,EACCC,YAAY,OAAO,EACnBC,gBAAgB,EAChBC,gBAAgB,OAAO,EACvBC,aAAa,QAAQ,EACrBC,aAAa,EACbC,eAAe,UAAU,EACzBC,kBAAkB,EAClBC,mBAAmB,cAAc,EACjCC,eAAe,UAAU,EAC1B,GACD,OAAOC;QACL,MAAMX,wBAAwBW;QAE9B,MAAMC,OAAOD,IAAIC,IAAI;QACrB,MAAMC,UAAUF,IAAIE,OAAO;QAC3B,MAA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