UNPKG

@medusajs/types

Version:
1,153 lines • 108 kB
import { FindConfig } from "../common"; import { RestoreReturn, SoftDeleteReturn } from "../dal"; import { IModuleService } from "../modules-sdk"; import { Context } from "../shared-context"; import { FilterableFulfillmentProps, FilterableFulfillmentProviderProps, FilterableFulfillmentSetProps, FilterableGeoZoneProps, FilterableServiceZoneProps, FilterableShippingOptionForContextProps, FilterableShippingOptionProps, FilterableShippingOptionRuleProps, FilterableShippingOptionTypeProps, FilterableShippingProfileProps, FulfillmentDTO, FulfillmentProviderDTO, FulfillmentSetDTO, GeoZoneDTO, ServiceZoneDTO, ShippingOptionDTO, ShippingOptionRuleDTO, ShippingOptionTypeDTO, ShippingProfileDTO } from "./common"; import { CalculateShippingOptionPriceDTO, CreateFulfillmentSetDTO, CreateGeoZoneDTO, CreateServiceZoneDTO, CreateShippingOptionDTO, CreateShippingOptionRuleDTO, UpdateFulfillmentDTO, UpdateFulfillmentSetDTO, UpdateGeoZoneDTO, UpdateServiceZoneDTO, UpdateShippingOptionDTO, UpdateShippingOptionRuleDTO, UpdateShippingProfileDTO, UpsertServiceZoneDTO, UpsertShippingOptionDTO } from "./mutations"; import { CreateFulfillmentDTO } from "./mutations/fulfillment"; import { CreateShippingProfileDTO, UpsertShippingProfileDTO } from "./mutations/shipping-profile"; import { CalculatedShippingOptionPrice, ValidateFulfillmentDataContext } from "./provider"; /** * The main service interface for the Fulfillment Module. */ export interface IFulfillmentModuleService extends IModuleService { /** * This method retrieves a fulfillment set by its ID. * * @param {string} id - The ID of the fulfillment set. * @param {FindConfig<FulfillmentSetDTO>} config - The configurations determining how the fulfillment set is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a fulfillment set. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<FulfillmentSetDTO>} The retrieved fulfillment set. * * @example * A simple example that retrieves a fulfillment set by its ID: * * ```ts * const fulfillmentSet = * await fulfillmentModuleService.retrieveFulfillmentSet("fuset_123") * ``` * * To specify relations that should be retrieved: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const fulfillmentSet = await fulfillmentModuleService.retrieveFulfillmentSet( * "fuset_123", * { * relations: ["service_zones"], * } * ) * ``` */ retrieveFulfillmentSet(id: string, config?: FindConfig<FulfillmentSetDTO>, sharedContext?: Context): Promise<FulfillmentSetDTO>; /** * This method retrieves a paginated list of fulfillment sets based on optional filters and configuration. * * @param {FilterableFulfillmentSetProps} filters - The filters to apply on the retrieved fulfillment sets. * @param {FindConfig<FulfillmentSetDTO>} config - The configurations determining how the fulfillment set is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a fulfillment set. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<FulfillmentSetDTO[]>} The list of fulfillment sets. * * @example * To retrieve a list of fulfillment sets using their IDs: * * ```ts * const fulfillmentSets = await fulfillmentModuleService.listFulfillmentSets({ * id: ["fuset_123", "fuset_321"], * }) * ``` * * To specify relations that should be retrieved within the fulfillment set: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const fulfillmentSets = await fulfillmentModuleService.listFulfillmentSets( * { * id: ["fuset_123", "fuset_321"], * }, * { * relations: ["search_zones"], * } * ) * ``` * * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: * * ```ts * const fulfillmentSets = await fulfillmentModuleService.listFulfillmentSets( * { * id: ["fuset_123", "fuset_321"], * }, * { * relations: ["search_zones"], * take: 20, * skip: 2, * } * ) * ``` */ listFulfillmentSets(filters?: FilterableFulfillmentSetProps, config?: FindConfig<FulfillmentSetDTO>, sharedContext?: Context): Promise<FulfillmentSetDTO[]>; /** * This method retrieves a paginated list of fulfillment sets along with the total count of available fulfillment sets satisfying the provided filters. * * @param {FilterableFulfillmentSetProps} filters - The filters to apply on the retrieved fulfillment sets. * @param {FindConfig<FulfillmentSetDTO>} config - The configurations determining how the fulfillment set is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a fulfillment set. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<[FulfillmentSetDTO[], number]>} The list of fulfillment sets along with their total count. * * @example * To retrieve a list of fulfillment sets using their IDs: * * ```ts * const [fulfillmentSets, count] = * await fulfillmentModuleService.listAndCountFulfillmentSets({ * id: ["fuset_123", "fuset_321"], * }) * ``` * * To specify relations that should be retrieved within the fulfillment set: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const [fulfillmentSets, count] = * await fulfillmentModuleService.listAndCountFulfillmentSets( * { * id: ["fuset_123", "fuset_321"], * }, * { * relations: ["search_zones"], * } * ) * ``` * * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: * * ```ts * const [fulfillmentSets, count] = * await fulfillmentModuleService.listAndCountFulfillmentSets( * { * id: ["fuset_123", "fuset_321"], * }, * { * relations: ["search_zones"], * take: 20, * skip: 2, * } * ) * ``` */ listAndCountFulfillmentSets(filters?: FilterableFulfillmentSetProps, config?: FindConfig<FulfillmentSetDTO>, sharedContext?: Context): Promise<[FulfillmentSetDTO[], number]>; /** * This method creates fulfillment sets. * * @param {CreateFulfillmentSetDTO[]} data - The fulfillment sets to be created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<FulfillmentSetDTO[]>} The created fulfillment sets. * * @example * const fulfillmentSets = await fulfillmentModuleService.createFulfillmentSets( * [ * { * name: "Shipping", * type: "default", * }, * { * name: "Pickup", * type: "provider-controlled", * }, * ] * ) */ createFulfillmentSets(data: CreateFulfillmentSetDTO[], sharedContext?: Context): Promise<FulfillmentSetDTO[]>; /** * This method creates a fulfillment set. * * @param {CreateFulfillmentSetDTO} data - The fulfillment set to be created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<FulfillmentSetDTO>} The created fulfillment set. * * @example * const fulfillmentSet = await fulfillmentModuleService.createFulfillmentSets({ * name: "Shipping", * type: "default", * }) */ createFulfillmentSets(data: CreateFulfillmentSetDTO, sharedContext?: Context): Promise<FulfillmentSetDTO>; /** * This method updates existing fulfillment sets. * * @param {UpdateFulfillmentSetDTO[]} data - The attributes to update in the fulfillment sets. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<FulfillmentSetDTO[]>} The updated fulfillment sets. * * @example * const fulfillmentSets = await fulfillmentModuleService.updateFulfillmentSets( * [ * { * id: "fuset_123", * name: "Shipping", * }, * { * id: "fuset_321", * name: "Pickup", * }, * ] * ) */ updateFulfillmentSets(data: UpdateFulfillmentSetDTO[], sharedContext?: Context): Promise<FulfillmentSetDTO[]>; /** * This method updates an existing fulfillment set. * * @param {UpdateFulfillmentSetDTO} data - The attributes to update in the fulfillment set. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<FulfillmentSetDTO>} The updated fulfillment set. * * @example * const fulfillmentSet = await fulfillmentModuleService.updateFulfillmentSets({ * id: "fuset_123", * name: "Shipping", * }) */ updateFulfillmentSets(data: UpdateFulfillmentSetDTO, sharedContext?: Context): Promise<FulfillmentSetDTO>; /** * This method deletes fulfillment sets by their IDs. * * @param {string[]} ids - The IDs of the fulfillment sets. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void>} Resolves when the fulfillment sets are deleted successfully. * * @example * await fulfillmentModuleService.deleteFulfillmentSets([ * "fuset_123", * "fuset_321", * ]) */ deleteFulfillmentSets(ids: string[], sharedContext?: Context): Promise<void>; /** * This method deletes a fulfillment set by its ID. * * @param {string} id - The ID of the fulfillment set. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void>} Resolves when the fulfillment set is deleted successfully. * * @example * await fulfillmentModuleService.deleteFulfillmentSets("fuset_123") */ deleteFulfillmentSets(id: string, sharedContext?: Context): Promise<void>; /** * This method soft deletes fulfillment sets by their IDs. * * @param {string[]} fulfillmentIds - The IDs of the fulfillment sets. * @param {SoftDeleteReturn<TReturnableLinkableKeys>} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were also soft deleted. * If there are no related records, the promise resolves to `void`. * * @example * await fulfillmentModuleService.softDeleteFulfillmentSets([ * "fuset_123", * "fuset_321", * ]) */ softDeleteFulfillmentSets<TReturnableLinkableKeys extends string = string>(fulfillmentIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>; /** * This method restores a soft deleted fulfillment by its IDs. * * @param {string[]} fulfillmentIds - The IDs of the fulfillment sets. * @param {RestoreReturn<TReturnableLinkableKeys>} config - Configurations determining which relations to restore along with each of the fulfillment sets. You can pass to its `returnLinkableKeys` * property any of the fulfillment set's relation attribute names. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were restored. * If there are no related records restored, the promise resolves to `void`. * * @example * await fulfillmentModuleService.restoreFulfillmentSets([ * "fuset_123", * "fuset_321", * ]) */ restoreFulfillmentSets<TReturnableLinkableKeys extends string = string>(fulfillmentIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>; /** * This method retrieves a service zone by its ID. * * @param {string} id - The ID of the service zone. * @param {FindConfig<ServiceZoneDTO>} config - The configurations determining how the service zone is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a service zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ServiceZoneDTO>} The retrieved service zone. * * @example * A simple example that retrieves a service zone by its ID: * * ```ts * const serviceZone = * await fulfillmentModuleService.retrieveServiceZone( * "serzo_123" * ) * ``` * * To specify relations that should be retrieved: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const serviceZone = * await fulfillmentModuleService.retrieveServiceZone( * "serzo_123", * { * relations: ["shipping_options"], * } * ) * ``` */ retrieveServiceZone(id: string, config?: FindConfig<ServiceZoneDTO>, sharedContext?: Context): Promise<ServiceZoneDTO>; /** * This method retrieves a paginated list of service zones based on optional filters and configuration. * * @param {FilterableServiceZoneProps} filters - The filters to apply on the retrieved service zones. * @param {FindConfig<ServiceZoneDTO>} config - The configurations determining how the service zone is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a service zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ServiceZoneDTO[]>} The list of service zones. * * @example * To retrieve a list of service zones using their IDs: * * ```ts * const serviceZones = * await fulfillmentModuleService.listServiceZones({ * id: ["serzo_123", "serzo_321"], * }) * ``` * * To specify relations that should be retrieved within the service zone: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const serviceZones = * await fulfillmentModuleService.listServiceZones( * { * id: ["serzo_123", "serzo_321"], * }, * { * relations: ["shipping_options"], * } * ) * ``` * * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: * * ```ts * const serviceZones = * await fulfillmentModuleService.listServiceZones( * { * id: ["serzo_123", "serzo_321"], * }, * { * relations: ["shipping_options"], * take: 20, * skip: 2, * } * ) * ``` */ listServiceZones(filters?: FilterableServiceZoneProps, config?: FindConfig<ServiceZoneDTO>, sharedContext?: Context): Promise<ServiceZoneDTO[]>; /** * This method retrieves a paginated list of service zones along with the total count of available service zones satisfying the provided filters. * * @param {FilterableServiceZoneProps} filters - The filters to apply on the retrieved service zones. * @param {FindConfig<ServiceZoneDTO>} config - The configurations determining how the service zone is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a service zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<[ServiceZoneDTO[], number]>} The list of service zones along with their total count. * * @example * To retrieve a list of service zones using their IDs: * * ```ts * const [serviceZones, count] = * await fulfillmentModuleService.listAndCountServiceZones({ * id: ["serzo_123", "serzo_321"], * }) * ``` * * To specify relations that should be retrieved within the service zone: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const [serviceZones, count] = * await fulfillmentModuleService.listAndCountServiceZones( * { * id: ["serzo_123", "serzo_321"], * }, * { * relations: ["shipping_options"], * } * ) * ``` * * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: * * ```ts * const [serviceZones, count] = * await fulfillmentModuleService.listAndCountServiceZones( * { * id: ["serzo_123", "serzo_321"], * }, * { * relations: ["shipping_options"], * take: 20, * skip: 2, * } * ) * ``` */ listAndCountServiceZones(filters?: FilterableServiceZoneProps, config?: FindConfig<ServiceZoneDTO>, sharedContext?: Context): Promise<[ServiceZoneDTO[], number]>; /** * This method creates service zones. * * @param {CreateServiceZoneDTO[]} data - The service zones to be created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ServiceZoneDTO[]>} The created service zones. * * @example * const serviceZones = * await fulfillmentModuleService.createServiceZones([ * { * name: "Nordic Shipping Methods", * fulfillment_set_id: "fuset_123", * }, * { * name: "Pickup Service Area", * fulfillment_set_id: "fuset_321", * }, * ]) */ createServiceZones(data: CreateServiceZoneDTO[], sharedContext?: Context): Promise<ServiceZoneDTO[]>; /** * This method creates a service zone. * * @param {CreateServiceZoneDTO} data - The service zone to be created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ServiceZoneDTO>} The created service zone. * * @example * const serviceZone = * await fulfillmentModuleService.createServiceZones({ * name: "Nordic Shipping Methods", * fulfillment_set_id: "fuset_123", * }) */ createServiceZones(data: CreateServiceZoneDTO, sharedContext?: Context): Promise<ServiceZoneDTO>; /** * This method updates an existing service zone. * * @param {string} id - The ID of the service zone. * @param {UpdateServiceZoneDTO} data - The attributes to update in the service zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ServiceZoneDTO>} The updated service zone. * * @example * const serviceZone = * await fulfillmentModuleService.updateServiceZones( * "serzo_123", * { * name: "US", * } * ) */ updateServiceZones(id: string, data: UpdateServiceZoneDTO, sharedContext?: Context): Promise<ServiceZoneDTO>; /** * This method updates existing service zones matching the specified filters. * * @param {FilterableServiceZoneProps} selector - The filters specifying which service zones to update. * @param {UpdateServiceZoneDTO} data - The attributes to update in the service zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ServiceZoneDTO[]>} The updated service zones. * * @example * const serviceZones = * await fulfillmentModuleService.updateServiceZones( * { * id: ["serzo_123", "serzo_321"], * }, * { * name: "US", * } * ) */ updateServiceZones(selector: FilterableServiceZoneProps, data: UpdateServiceZoneDTO, sharedContext?: Context): Promise<ServiceZoneDTO[]>; /** * This method updates or creates a service zone if it doesn't exist. * * @param {UpsertServiceZoneDTO} data - The attributes in the service zone to be created or updated. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ServiceZoneDTO>} The created or updated service zone. * * @example * const serviceZone = * await fulfillmentModuleService.upsertServiceZones({ * id: "serzo_123", * name: "US", * }) */ upsertServiceZones(data: UpsertServiceZoneDTO, sharedContext?: Context): Promise<ServiceZoneDTO>; /** * This method updates or creates service zones if they don't exist. * * @param {UpsertServiceZoneDTO[]} data - The attributes in the service zones to be created or updated. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ServiceZoneDTO[]>} The created or updated service zones. * * @example * const serviceZones = * await fulfillmentModuleService.upsertServiceZones([ * { * id: "serzo_123", * name: "US", * }, * { * name: "US", * fulfillment_set_id: "fuset_123", * }, * ]) */ upsertServiceZones(data: UpsertServiceZoneDTO[], sharedContext?: Context): Promise<ServiceZoneDTO[]>; /** * This method deletes service zones by their IDs. * * @param {string[]} ids - The IDs of the service zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void>} Resolves when the service zones are deleted. * * @example * await fulfillmentModuleService.deleteServiceZones([ * "serzo_123", * "serzo_321", * ]) */ deleteServiceZones(ids: string[], sharedContext?: Context): Promise<void>; /** * This method deletes a service zone by its ID. * * @param {string} id - The ID of the service zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void>} Resolves when the service zone is deleted. * * @example * await fulfillmentModuleService.deleteServiceZones("serzo_123") */ deleteServiceZones(id: string, sharedContext?: Context): Promise<void>; /** * This method soft deletes service zones by their IDs. * * @param {string[]} serviceZoneIds - The IDs of the service zones. * @param {SoftDeleteReturn<TReturnableLinkableKeys>} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were also soft deleted. * If there are no related records, the promise resolves to `void`. * * @example * await fulfillmentModuleService.softDeleteServiceZones([ * "serzo_123", * "serzo_321", * ]) */ softDeleteServiceZones<TReturnableLinkableKeys extends string = string>(serviceZoneIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>; /** * This method restores a soft deleted service zones by their IDs. * * @param {string[]} serviceZoneIds - The IDs of the service zones. * @param {RestoreReturn<TReturnableLinkableKeys>} config - Configurations determining which relations to restore along with each of the service zones. You can pass to its `returnLinkableKeys` * property any of the service zone's relation attribute names, such as `{type relation name}`. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were restored. * If there are no related records restored, the promise resolves to `void`. * * @example * await fulfillmentModuleService.restoreServiceZones([ * "serzo_123", * "serzo_321", * ]) */ restoreServiceZones<TReturnableLinkableKeys extends string = string>(serviceZoneIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>; /** * This method retrieves a geo zone by its ID. * * @param {string} id - The ID of the geo zone. * @param {FindConfig<GeoZoneDTO>} config - The configurations determining how the geo zone is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a geo zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<GeoZoneDTO>} The retrieved geo zone. * * @example * A simple example that retrieves a geo zone by its ID: * * ```ts * const geoZone = * await fulfillmentModuleService.retrieveGeoZone("fgz_123") * ``` * * To specify relations that should be retrieved: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const geoZone = * await fulfillmentModuleService.retrieveGeoZone("fgz_123", { * relations: ["service_zone"], * }) * ``` */ retrieveGeoZone(id: string, config?: FindConfig<GeoZoneDTO>, sharedContext?: Context): Promise<GeoZoneDTO>; /** * This method retrieves a paginated list of geo zones based on optional filters and configuration. * * @param {FilterableGeoZoneProps} filters - The filters to apply on the retrieved geo zones. * @param {FindConfig<GeoZoneDTO>} config - The configurations determining how the geo zone is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a geo zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<GeoZoneDTO[]>} The list of geo zones. * * @example * To retrieve a list of geo zones using their IDs: * * ```ts * const geoZones = await fulfillmentModuleService.listGeoZones({ * id: ["fgz_123", "fgz_321"], * }) * ``` * * To specify relations that should be retrieved within the geo zone: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const geoZones = await fulfillmentModuleService.listGeoZones( * { * id: ["fgz_123", "fgz_321"], * }, * { * relations: ["service_zone"], * } * ) * ``` * * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: * * ```ts * const geoZones = await fulfillmentModuleService.listGeoZones( * { * id: ["fgz_123", "fgz_321"], * }, * { * relations: ["service_zone"], * take: 20, * skip: 2, * } * ) * ``` */ listGeoZones(filters?: FilterableGeoZoneProps, config?: FindConfig<GeoZoneDTO>, sharedContext?: Context): Promise<GeoZoneDTO[]>; /** * This method retrieves a paginated list of geo zones along with the total count of available geo zones satisfying the provided filters. * * @param {FilterableGeoZoneProps} filters - The filters to apply on the retrieved geo zones. * @param {FindConfig<GeoZoneDTO>} config - The configurations determining how the geo zone is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a geo zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<[GeoZoneDTO[], number]>} The list of geo zones along with their total count. * * @example * To retrieve a list of geo zones using their IDs: * * ```ts * const [geoZones, count] = * await fulfillmentModuleService.listAndCountGeoZones({ * id: ["fgz_123", "fgz_321"], * }) * ``` * * To specify relations that should be retrieved within the geo zone: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const [geoZones, count] = * await fulfillmentModuleService.listAndCountGeoZones( * { * id: ["fgz_123", "fgz_321"], * }, * { * relations: ["service_zone"], * } * ) * ``` * * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: * * ```ts * const [geoZones, count] = * await fulfillmentModuleService.listAndCountGeoZones( * { * id: ["fgz_123", "fgz_321"], * }, * { * relations: ["service_zone"], * take: 20, * skip: 2, * } * ) * ``` */ listAndCountGeoZones(filters?: FilterableGeoZoneProps, config?: FindConfig<GeoZoneDTO>, sharedContext?: Context): Promise<[GeoZoneDTO[], number]>; /** * This method creates geo zones. * * @param {CreateGeoZoneDTO[]} data - The geo zones to be created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<GeoZoneDTO[]>} The created geo zones. * * @example * const geoZones = * await fulfillmentModuleService.createGeoZones([ * { * type: "country", * service_zone_id: "serzo_123", * country_code: "us", * }, * { * type: "city", * service_zone_id: "serzo_321", * province_code: "us-vt", * city: "Vermont", * country_code: "us", * }, * ]) */ createGeoZones(data: CreateGeoZoneDTO[], sharedContext?: Context): Promise<GeoZoneDTO[]>; /** * This method creates a geo zones. * * @param {CreateGeoZoneDTO} data - The geo zone to be created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<GeoZoneDTO>} The created geo zones. * * @example * const geoZones = * await fulfillmentModuleService.createGeoZones({ * type: "country", * service_zone_id: "serzo_123", * country_code: "us", * }) */ createGeoZones(data: CreateGeoZoneDTO, sharedContext?: Context): Promise<GeoZoneDTO>; /** * This method updates existing geo zones. * * @param {UpdateGeoZoneDTO[]} data - The attributes to update in the geo zones. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<GeoZoneDTO[]>} The updated geo zones. * * @example * const geoZones = * await fulfillmentModuleService.updateGeoZones([ * { * id: "fgz_123", * type: "country", * country_code: "us", * }, * { * id: "fgz_321", * type: "city", * province_code: "us-vt", * }, * ]) */ updateGeoZones(data: UpdateGeoZoneDTO[], sharedContext?: Context): Promise<GeoZoneDTO[]>; /** * This method updates an existing fulfillment. * * @param {UpdateGeoZoneDTO} data - The attributes to update in the geo zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<GeoZoneDTO>} The updated fulfillment. * * @example * const geoZones = * await fulfillmentModuleService.updateGeoZones({ * id: "fgz_123", * type: "country", * country_code: "us", * }) */ updateGeoZones(data: UpdateGeoZoneDTO, sharedContext?: Context): Promise<GeoZoneDTO>; /** * This method deletes geo zones by their IDs. * * @param {string[]} ids - The IDs of the geo zones. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void>} Resolves when the geo zones are deleted. * * @example * await fulfillmentModuleService.deleteGeoZones([ * "fgz_123", * "fgz_321", * ]) */ deleteGeoZones(ids: string[], sharedContext?: Context): Promise<void>; /** * This method deletes a geo zone by its ID. * * @param {string} id - The ID of the geo zone. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void>} Resolves when the geo zone is deleted. * * @example * await fulfillmentModuleService.deleteGeoZones("fgz_123") */ deleteGeoZones(id: string, sharedContext?: Context): Promise<void>; /** * This method soft deletes geo zones by their IDs. * * @param {string[]} geoZoneIds - The IDs of the geo zones. * @param {SoftDeleteReturn<TReturnableLinkableKeys>} config - An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were also soft deleted. * If there are no related records, the promise resolves to `void`. * * @example * await fulfillmentModuleService.softDeleteGeoZones([ * "fgz_123", * "fgz_321", * ]) */ softDeleteGeoZones<TReturnableLinkableKeys extends string = string>(geoZoneIds: string[], config?: SoftDeleteReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>; /** * This method restores soft deleted geo zones by their IDs. * * @param {string[]} geoZoneIds - The IDs of the geo zones. * @param {RestoreReturn<TReturnableLinkableKeys>} config - Configurations determining which relations to restore along with each of the geo zones. You can pass to its `returnLinkableKeys` * property any of the geo zone's relation attribute names, such as `{type relation name}`. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<void | Record<string, string[]>>} An object that includes the IDs of related records that were restored. * If there are no related records restored, the promise resolves to `void`. * * @example * await fulfillmentModuleService.restoreGeoZones([ * "fgz_123", * "fgz_321", * ]) */ restoreGeoZones<TReturnableLinkableKeys extends string = string>(geoZoneIds: string[], config?: RestoreReturn<TReturnableLinkableKeys>, sharedContext?: Context): Promise<Record<string, string[]> | void>; /** * This method retrieves a shipping option by its ID. * * @param {string} id - The ID of the shipping option. * @param {FindConfig<ShippingOptionDTO>} config - The configurations determining how the shipping option is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a shipping option. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ShippingOptionDTO>} The retrieved shipping option. * * @example * A simple example that retrieves a shipping option by its ID: * * ```ts * const shippingOption = * await fulfillmentModuleService.retrieveShippingOption( * "so_123" * ) * ``` * * To specify relations that should be retrieved: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const shippingOption = * await fulfillmentModuleService.retrieveShippingOption( * "so_123", * { * relations: ["fulfillments"], * } * ) * ``` */ retrieveShippingOption(id: string, config?: FindConfig<ShippingOptionDTO>, sharedContext?: Context): Promise<ShippingOptionDTO>; /** * This method retrieves a paginated list of shipping options based on optional filters and configuration. * * @param {FilterableShippingOptionProps} filters - The filters to apply on the retrieved shipping options. * @param {FindConfig<ShippingOptionDTO>} config - The configurations determining how the shipping option is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a shipping option. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ShippingOptionDTO[]>} The list of shipping options. * * @example * To retrieve a list of shipping options using their IDs: * * ```ts * const shippingOptions = * await fulfillmentModuleService.listShippingOptions({ * id: ["so_123", "so_321"], * }) * ``` * * To specify relations that should be retrieved within the shipping option: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const shippingOptions = * await fulfillmentModuleService.listShippingOptions( * { * id: ["so_123", "so_321"], * }, * { * relations: ["fulfillments"], * } * ) * ``` * * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: * * ```ts * const shippingOptions = * await fulfillmentModuleService.listShippingOptions( * { * id: ["so_123", "so_321"], * }, * { * relations: ["fulfillments"], * take: 20, * skip: 2, * } * ) * ``` */ listShippingOptions(filters?: FilterableShippingOptionForContextProps, config?: FindConfig<ShippingOptionDTO>, sharedContext?: Context): Promise<ShippingOptionDTO[]>; /** * This method retrieves a paginated list of shipping options based on the provided context. * * @param {FilterableShippingOptionForContextProps} filters - The context of the how the shipping option is being used. It * acts as a filter for the retrieved shipping options. * @param {FindConfig<ShippingOptionDTO>} config - The configurations determining how the shipping option is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a shipping option. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ShippingOptionDTO[]>} The list of shipping options. * * @example * To retrieve a list of shipping options matching a context: * * ```ts * const shippingOptions = * await fulfillmentModuleService.listShippingOptionsForContext( * { * fulfillment_set_id: ["fuset_123"], * address: { * country_code: "us", * }, * } * ) * ``` * * To specify relations that should be retrieved within the shipping option: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const shippingOptions = * await fulfillmentModuleService.listShippingOptionsForContext( * { * fulfillment_set_id: ["fuset_123"], * address: { * country_code: "us", * }, * }, * { * relations: ["fulfillments"], * } * ) * ``` * * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: * * ```ts * const shippingOptions = * await fulfillmentModuleService.listShippingOptionsForContext( * { * fulfillment_set_id: ["fuset_123"], * address: { * country_code: "us", * }, * }, * { * relations: ["fulfillments"], * take: 20, * skip: 2, * } * ) * ``` */ listShippingOptionsForContext(filters: FilterableShippingOptionForContextProps, config?: FindConfig<ShippingOptionDTO>, sharedContext?: Context): Promise<ShippingOptionDTO[]>; /** * This method retrieves a paginated list of shipping options along with the total count of available shipping options satisfying the provided filters. * * @param {Omit<FilterableShippingOptionProps, "context">} filters - Construct a type with the properties of T except for those in type K. * @param {FindConfig<ShippingOptionDTO>} config - The configurations determining how the shipping option is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a shipping option. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<[ShippingOptionDTO[], number]>} The list of shipping options along with their total count. * * @example * To retrieve a list of shipping options using their IDs: * * ```ts * const [shippingOptions, count] = * await fulfillmentModuleService.listAndCountShippingOptions({ * id: ["so_123", "so_321"], * }) * ``` * * To specify relations that should be retrieved within the shipping option: * * :::note * * You can only retrieve data models defined in the same module. To retrieve linked data models * from other modules, use [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query) instead. * * ::: * * ```ts * const [shippingOptions, count] = * await fulfillmentModuleService.listAndCountShippingOptions( * { * id: ["so_123", "so_321"], * }, * { * relations: ["fulfillments"], * } * ) * ``` * * By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: * * ```ts * const [shippingOptions, count] = * await fulfillmentModuleService.listAndCountShippingOptions( * { * id: ["so_123", "so_321"], * }, * { * relations: ["fulfillments"], * take: 20, * skip: 2, * } * ) * ``` */ listAndCountShippingOptions(filters?: Omit<FilterableShippingOptionProps, "context">, config?: FindConfig<ShippingOptionDTO>, sharedContext?: Context): Promise<[ShippingOptionDTO[], number]>; /** * This method creates shipping options. * * @param {CreateShippingOptionDTO[]} data - The shipping options to be created. * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. * @returns {Promise<ShippingOptionDTO[]>} The created shipping options. * * @example * const shippingOptions = * await fulfillmentModuleService.createShippingOptions([ * { * name: "DHL Express Shipping", * price_type: "flat", * service_zone_id: "serzo_123", * shipping_profile_id: "sp_123", * provider_id: "dhl", * type: { * label: "Express", * description: "Ship in 24 hours", * code: "express", * }, * }, * { * name: "Webshipper Shipping", * price_type: "flat", * service_zone_id: "serzo_321", * shipping_profile_id: "sp_321", * provider_id: "webshipper", * type: { * label: "Express", * description: "Ship in 24 hours", * code: "express", * }, * }, * ]) */ createShippingO