diff --git a/packages/api/src/resolvers/type/delivery-provider-types.ts b/packages/api/src/resolvers/type/delivery-provider-types.ts index 00d90d8059..c495e4da16 100644 --- a/packages/api/src/resolvers/type/delivery-provider-types.ts +++ b/packages/api/src/resolvers/type/delivery-provider-types.ts @@ -40,15 +40,8 @@ export interface DeliveryProviderHelperTypes { export const DeliveryProvider: DeliveryProviderHelperTypes = { interface(obj, _, { modules }) { const Interface = modules.delivery.findInterface(obj); - - // TODO: Harmonize with Payment, eliminate double mappings (_id -> key -> _id ...) if (!Interface) return null; - - return { - _id: Interface.key, - label: Interface.label, - version: Interface.version, - }; + return Interface; }, async isActive(deliveryProvider, _, requestContext) { diff --git a/packages/core-delivery/src/module/configureDeliveryModule.ts b/packages/core-delivery/src/module/configureDeliveryModule.ts index ec552383be..61567fb4bd 100644 --- a/packages/core-delivery/src/module/configureDeliveryModule.ts +++ b/packages/core-delivery/src/module/configureDeliveryModule.ts @@ -85,8 +85,14 @@ export const configureDeliveryModule = async ({ // Delivery Adapter - findInterface: (deliveryProvider) => { - return DeliveryDirector.getAdapter(deliveryProvider.adapterKey); + findInterface: (paymentProvider) => { + const Adapter = DeliveryDirector.getAdapter(paymentProvider.adapterKey); + if (!Adapter) return null; + return { + _id: Adapter.key, + label: Adapter.label, + version: Adapter.version, + }; }, findInterfaces: ({ type }) => { diff --git a/packages/platform/src/templates/utils/getOrderSummaryData.ts b/packages/platform/src/templates/utils/getOrderSummaryData.ts index 97b4a7fc1e..a5a4eaf4ab 100644 --- a/packages/platform/src/templates/utils/getOrderSummaryData.ts +++ b/packages/platform/src/templates/utils/getOrderSummaryData.ts @@ -2,7 +2,6 @@ import { UnchainedCore } from '@unchainedshop/types/core.js'; import { Order } from '@unchainedshop/types/orders.js'; import { OrderPricingRowCategory } from '@unchainedshop/types/orders.pricing.js'; import { Locale } from '@unchainedshop/types/common.js'; -import { DeliveryInterface } from '@unchainedshop/types/delivery.js'; import formatPrice from './formatPrice.js'; import { formatAddress } from './formatAddress.js'; diff --git a/packages/types/delivery.ts b/packages/types/delivery.ts index 0f28f6d752..e437324e54 100644 --- a/packages/types/delivery.ts +++ b/packages/types/delivery.ts @@ -134,7 +134,7 @@ export type DeliveryModule = ModuleMutationsWithReturnDoc & { }) => IDeliveryPricingSheet; // Delivery adapter - findInterface: (params: DeliveryProvider) => IDeliveryAdapter; + findInterface: (params: DeliveryProvider) => DeliveryInterface; findInterfaces: (params: { type: DeliveryProviderType }) => Array; findSupported: ( params: { order: Order },