feat(pricing, types, utils): Soft delete pricing entities (#5858)
This commit is contained in:
1 parent
1468646b99
commit
3550750975
30 files changed
+795
-159
No files matched your search
@@ -18,7 +18,7 @@ export interface MoneyAmountDTO {
|
||||
currency_code?: string
|
||||
/**
|
||||
* The money amount's currency.
|
||||
*
|
||||
*
|
||||
* @expandable
|
||||
*/
|
||||
currency?: CurrencyDTO
|
||||
@@ -38,6 +38,18 @@ export interface MoneyAmountDTO {
|
||||
* The details of the relation between the money amount and its associated price set.
|
||||
*/
|
||||
price_set_money_amount?: PriceSetMoneyAmountDTO
|
||||
/**
|
||||
* When the money_amount was created.
|
||||
*/
|
||||
created_at: Date
|
||||
/**
|
||||
* When the money_amount was updated.
|
||||
*/
|
||||
updated_at: Date
|
||||
/**
|
||||
* When the money_amount was deleted.
|
||||
*/
|
||||
deleted_at: null | Date
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,18 @@ export interface PriceRuleDTO {
|
||||
* The ID of the associated price list.
|
||||
*/
|
||||
price_list_id: string
|
||||
/**
|
||||
* When the price_rule was created.
|
||||
*/
|
||||
created_at: Date
|
||||
/**
|
||||
* When the price_rule was updated.
|
||||
*/
|
||||
updated_at: Date
|
||||
/**
|
||||
* When the price_rule was deleted.
|
||||
*/
|
||||
deleted_at: null | Date
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
import { MoneyAmountDTO } from "./money-amount"
|
||||
import { PriceListDTO } from "./price-list"
|
||||
import { PriceRuleDTO } from "./price-rule"
|
||||
import { PriceSetDTO } from "./price-set"
|
||||
import { BaseFilterable } from "../../dal";
|
||||
import { MoneyAmountDTO } from "./money-amount";
|
||||
import { PriceListDTO } from "./price-list";
|
||||
import { PriceRuleDTO } from "./price-rule";
|
||||
import { PriceSetDTO } from "./price-set";
|
||||
|
||||
/**
|
||||
* @interface
|
||||
@@ -46,6 +46,18 @@ export interface PriceSetMoneyAmountDTO {
|
||||
* @expandable
|
||||
*/
|
||||
money_amount?: MoneyAmountDTO
|
||||
/**
|
||||
* When the price_set_money_amount was created.
|
||||
*/
|
||||
created_at: Date
|
||||
/**
|
||||
* When the price_set_money_amount was updated.
|
||||
*/
|
||||
updated_at: Date
|
||||
/**
|
||||
* When the price_set_money_amount was deleted.
|
||||
*/
|
||||
deleted_at: null | Date
|
||||
}
|
||||
|
||||
export interface UpdatePriceSetMoneyAmountDTO {
|
||||
|
||||
@@ -47,6 +47,7 @@ import {
|
||||
import { FindConfig } from "../common"
|
||||
import { ModuleJoinerConfig } from "../modules-sdk"
|
||||
import { Context } from "../shared-context"
|
||||
import { RestoreReturn } from "../dal"
|
||||
|
||||
export interface IPricingModuleService {
|
||||
/**
|
||||
@@ -1274,6 +1275,58 @@ export interface IPricingModuleService {
|
||||
*/
|
||||
deleteMoneyAmounts(ids: string[], sharedContext?: Context): Promise<void>
|
||||
|
||||
/**
|
||||
* This method soft deletes money amounts by their IDs.
|
||||
*
|
||||
* @param {string[]} ids - The IDs of the money amounts to delete.
|
||||
* @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 money amounts are successfully deleted.
|
||||
*
|
||||
* @example
|
||||
* import {
|
||||
* initialize as initializePricingModule,
|
||||
* } from "@medusajs/pricing"
|
||||
*
|
||||
* async function softDeleteMoneyAmounts (moneyAmountIds: string[]) {
|
||||
* const pricingService = await initializePricingModule()
|
||||
*
|
||||
* await pricingService.softDeleteMoneyAmounts(
|
||||
* moneyAmountIds
|
||||
* )
|
||||
* }
|
||||
*/
|
||||
softDeleteMoneyAmounts(ids: string[], sharedContext?: Context): Promise<void>
|
||||
|
||||
/**
|
||||
* This method restores soft deleted money amounts by their IDs.
|
||||
*
|
||||
* @param {string[]} ids - The IDs of the money amounts to delete.
|
||||
* @param {RestoreReturn<TReturnableLinkableKeys>} config -
|
||||
* Configurations determining which relations to restore along with each of the money amounts. You can pass to its `returnLinkableKeys`
|
||||
* property any of the money_amount's relation attribute names, such as `price_set_money_amount_id`.
|
||||
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||
* @returns {Promise<Record<string, string[]> | void>}
|
||||
* An object that includes the IDs of related records that were restored, such as the ID of associated product variants. The object's keys are the ID attribute names of the product entity's relations, such as `variant_id`, and its value is an array of strings, each being the ID of the record associated with the product through this relation, such as the IDs of associated product variants.
|
||||
*
|
||||
* @example
|
||||
* import {
|
||||
* initialize as initializePricingModule,
|
||||
* } from "@medusajs/pricing"
|
||||
*
|
||||
* async function softDeleteMoneyAmounts (moneyAmountIds: string[]) {
|
||||
* const pricingService = await initializePricingModule()
|
||||
*
|
||||
* await pricingService.softDeleteMoneyAmounts(
|
||||
* moneyAmountIds
|
||||
* )
|
||||
* }
|
||||
*/
|
||||
restoreDeletedMoneyAmounts<TReturnableLinkableKeys extends string = string>(
|
||||
ids: string[],
|
||||
config?: RestoreReturn<TReturnableLinkableKeys>,
|
||||
sharedContext?: Context
|
||||
): Promise<Record<string, string[]> | void>
|
||||
|
||||
/**
|
||||
* This method retrieves a currency by its code and and optionally based on the provided configurations.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user