feat(medusa,types,core-flows): apply created_by values - claims, exchanges, returns, fulfillment (#8712)

what:

- Applies created_by values - claims, exchanges, returns, fulfillment

RESOLVES CC-96
This commit is contained in:
Riqwan Thamir
2024-08-21 18:15:55 +00:00
committed by GitHub
parent f00889fe4e
commit 335061d8cd
26 changed files with 121 additions and 17 deletions
@@ -1048,6 +1048,8 @@ medusaIntegrationTestRunner({
)
).data.claim
expect(baseClaim.created_by).toEqual(expect.any(String))
await api.post(
`/admin/claims/${baseClaim.id}/inbound/items`,
{
@@ -392,6 +392,8 @@ medusaIntegrationTestRunner({
adminHeaders
)
expect(result.data.exchange.created_by).toEqual(expect.any(String))
const exchangeId = result.data.exchange.id
let r2 = await api.post(
@@ -311,6 +311,8 @@ medusaIntegrationTestRunner({
adminHeaders
)
expect(result.data.return.created_by).toEqual(expect.any(String))
let r2 = await api.post(
"/admin/returns",
{
@@ -156,6 +156,7 @@ medusaIntegrationTestRunner({
shipped_at: null,
delivered_at: null,
canceled_at: null,
created_by: expect.any(String),
provider_id: "manual_test-provider",
delivery_address: expect.objectContaining({
address_1: expect.any(String),
@@ -240,6 +241,7 @@ medusaIntegrationTestRunner({
expect.objectContaining({
id: fulfillment.id,
shipped_at: expect.any(String),
marked_shipped_by: expect.any(String),
labels: [
expect.objectContaining({
id: expect.any(String),
@@ -45,6 +45,7 @@ export const beginClaimOrderWorkflow = createWorkflow(
type: input.type,
order_id: input.order_id,
metadata: input.metadata,
created_by: input.created_by,
},
])
@@ -44,6 +44,7 @@ export const beginExchangeOrderWorkflow = createWorkflow(
{
order_id: input.order_id,
metadata: input.metadata,
created_by: input.created_by,
},
])
@@ -44,6 +44,7 @@ export const beginReturnOrderWorkflow = createWorkflow(
order_id: input.order_id,
location_id: input.location_id,
metadata: input.metadata,
created_by: input.created_by,
},
])
@@ -1,9 +1,9 @@
import { ShippingOptionDTO } from "./shipping-option"
import { FulfillmentProviderDTO } from "./fulfillment-provider"
import { BaseFilterable, OperatorMap } from "../../dal"
import { FulfillmentAddressDTO } from "./address"
import { FulfillmentItemDTO } from "./fulfillment-item"
import { FulfillmentLabelDTO } from "./fulfillment-label"
import { BaseFilterable, OperatorMap } from "../../dal"
import { FulfillmentProviderDTO } from "./fulfillment-provider"
import { ShippingOptionDTO } from "./shipping-option"
/**
* The fulfillment details.
@@ -39,6 +39,16 @@ export interface FulfillmentDTO {
*/
canceled_at: Date | null
/**
* The id of the user that marked fulfillment as shipped
*/
marked_shipped_by?: string | null
/**
* The id of the user that created the fulfillment
*/
created_by?: string | null
/**
* The data necessary for the fulfillment provider to process
* the fulfillment.
@@ -22,6 +22,11 @@ export interface CreateFulfillmentDTO {
*/
shipped_at?: Date | null
/**
* The id of the user that created the fulfillment
*/
created_by?: string | null
/**
* The date the fulfillment was delivered.
*/
+10
View File
@@ -1584,6 +1584,11 @@ export interface OrderClaimDTO
* The refund amount of the claim.
*/
refund_amount?: BigNumberValue
/**
* The id of the user that creates the order claim
*/
created_by?: string | null
}
/**
@@ -1630,6 +1635,11 @@ export interface OrderExchangeDTO
* The associated return's ID.
*/
return_id?: string
/**
* The id of the user that creates the order exchange
*/
created_by?: string | null
}
/**
+16 -1
View File
@@ -890,7 +890,7 @@ export interface CreateOrderChangeDTO {
/**
* The user that created the order change.
*/
created_by?: string
created_by?: string | null
/**
* Holds custom data in key-value pairs.
@@ -1537,6 +1537,11 @@ export interface CreateOrderReturnDTO extends BaseOrderBundledActionsDTO {
* The associated exchange's ID.
*/
exchange_id?: string
/**
* The id of the user that creates the fulfillment
*/
created_by?: string | null
}
/**
@@ -1967,6 +1972,11 @@ export interface CreateOrderClaimDTO extends BaseOrderBundledActionsDTO {
* on the claim.
*/
no_notification?: boolean
/**
* The id of the user that creates the order claim
*/
created_by?: string | null
}
export interface CancelOrderClaimDTO extends BaseOrderBundledActionsDTO {
@@ -2012,6 +2022,11 @@ export interface CreateOrderExchangeDTO extends BaseOrderBundledActionsDTO {
* updates on the exchange.
*/
no_notification?: boolean
/**
* The id of the user that creates the order exchange
*/
created_by?: string | null
}
export interface CancelOrderExchangeDTO extends BaseOrderBundledActionsDTO {
@@ -131,6 +131,11 @@ export type CreateFulfillmentWorkflowInput = {
*/
shipped_at?: Date | null
/**
* The id of the user that creates the fulfillment
*/
created_by?: string | null
/**
* The date the fulfillment was delivered.
*/
@@ -13,4 +13,9 @@ export interface CreateShipmentWorkflowInput {
* The labels associated with the fulfillment.
*/
labels: CreateFulfillmentLabelWorkflowDTO[]
/**
* The id of the user that marked fulfillment as shipped
*/
marked_shipped_by?: string | null
}
@@ -22,6 +22,16 @@ export interface UpdateFulfillmentWorkflowInput {
*/
shipped_at?: Date | null
/**
* The id of the user that marked fulfillment as shipped
*/
marked_shipped_by?: string | null
/**
* The id of the user that created the fulfillment
*/
created_by?: string | null
/**
* The date the fulfillment was delivered.
*/
@@ -3,7 +3,10 @@ import { OrderClaimType } from "../../order/mutations"
export interface BeginOrderClaimWorkflowInput {
type: OrderClaimType
order_id: string
created_by?: string
/**
* The id of the user that creates the order claim
*/
created_by?: string | null
internal_note?: string
description?: string
metadata?: Record<string, unknown> | null
@@ -1,6 +1,9 @@
export interface BeginOrderExchangeWorkflowInput {
order_id: string
created_by?: string
/**
* The id of the user that creates the order exchange
*/
created_by?: string | null
internal_note?: string
description?: string
metadata?: Record<string, unknown> | null
@@ -1,7 +1,10 @@
export interface BeginOrderReturnWorkflowInput {
order_id: string
location_id?: string
created_by?: string
/**
* The id of the user that creates the return
*/
created_by?: string | null
internal_note?: string
description?: string
metadata?: Record<string, unknown> | null
@@ -6,6 +6,7 @@ export const defaultAdminClaimFields = [
"display_id",
"order_version",
"refund_amount",
"created_by",
"created_at",
"updated_at",
"canceled_at",
@@ -1,4 +1,5 @@
import { beginClaimOrderWorkflow } from "@medusajs/core-flows"
import { HttpTypes } from "@medusajs/types"
import {
ContainerRegistrationKeys,
ModuleRegistrationName,
@@ -10,7 +11,6 @@ import {
MedusaResponse,
} from "../../../types/routing"
import { AdminPostOrderClaimsReqSchemaType } from "./validators"
import { HttpTypes } from "@medusajs/types"
export const GET = async (
req: AuthenticatedMedusaRequest,
@@ -43,7 +43,11 @@ export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostOrderClaimsReqSchemaType>,
res: MedusaResponse<HttpTypes.AdminClaimOrderResponse>
) => {
const input = req.validatedBody as AdminPostOrderClaimsReqSchemaType
const input = {
...req.validatedBody,
created_by: req.auth_context.actor_id,
}
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const orderModuleService = req.scope.resolve(ModuleRegistrationName.ORDER)
@@ -5,6 +5,7 @@ export const defaultAdminExchangeFields = [
"return_id",
"display_id",
"order_version",
"created_by",
"created_at",
"updated_at",
"canceled_at",
@@ -1,4 +1,5 @@
import { beginExchangeOrderWorkflow } from "@medusajs/core-flows"
import { HttpTypes } from "@medusajs/types"
import {
ContainerRegistrationKeys,
ModuleRegistrationName,
@@ -10,7 +11,6 @@ import {
MedusaResponse,
} from "../../../types/routing"
import { AdminPostOrderExchangesReqSchemaType } from "./validators"
import { HttpTypes } from "@medusajs/types"
export const GET = async (
req: AuthenticatedMedusaRequest,
@@ -43,7 +43,11 @@ export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostOrderExchangesReqSchemaType>,
res: MedusaResponse<HttpTypes.AdminExchangeOrderResponse>
) => {
const input = req.validatedBody as AdminPostOrderExchangesReqSchemaType
const input = {
...req.validatedBody,
created_by: req.auth_context.actor_id,
}
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const orderModuleService = req.scope.resolve(ModuleRegistrationName.ORDER)
@@ -1,11 +1,11 @@
import { createShipmentWorkflow } from "@medusajs/core-flows"
import { HttpTypes } from "@medusajs/types"
import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../../../types/routing"
import { refetchFulfillment } from "../../helpers"
import { AdminCreateShipmentType } from "../../validators"
import { HttpTypes } from "@medusajs/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminCreateShipmentType>,
@@ -14,7 +14,11 @@ export const POST = async (
const { id } = req.params
await createShipmentWorkflow(req.scope).run({
input: { id, ...req.validatedBody },
input: {
...req.validatedBody,
id,
marked_shipped_by: req.auth_context.actor_id,
},
})
const fulfillment = await refetchFulfillment(
@@ -3,6 +3,8 @@ export const defaultAdminFulfillmentsFields = [
"location_id",
"packed_at",
"shipped_at",
"marked_shipped_by",
"created_by",
"delivered_at",
"canceled_at",
"data",
@@ -1,11 +1,11 @@
import { createFulfillmentWorkflow } from "@medusajs/core-flows"
import { HttpTypes } from "@medusajs/types"
import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../types/routing"
import { refetchFulfillment } from "./helpers"
import { AdminCreateFulfillmentType } from "./validators"
import { HttpTypes } from "@medusajs/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminCreateFulfillmentType>,
@@ -14,7 +14,10 @@ export const POST = async (
const { result: fullfillment } = await createFulfillmentWorkflow(
req.scope
).run({
input: req.validatedBody,
input: {
...req.validatedBody,
created_by: req.auth_context.actor_id,
},
})
const fulfillment = await refetchFulfillment(
@@ -10,6 +10,7 @@ export const defaultAdminReturnFields = [
"metadata",
"no_notification",
"refund_amount",
"created_by",
"created_at",
"updated_at",
"canceled_at",
@@ -1,4 +1,5 @@
import { beginReturnOrderWorkflow } from "@medusajs/core-flows"
import { HttpTypes } from "@medusajs/types"
import {
ContainerRegistrationKeys,
ModuleRegistrationName,
@@ -10,7 +11,6 @@ import {
MedusaResponse,
} from "../../../types/routing"
import { AdminPostReturnsReqSchemaType } from "./validators"
import { HttpTypes } from "@medusajs/types"
export const GET = async (
req: AuthenticatedMedusaRequest,
@@ -43,7 +43,11 @@ export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostReturnsReqSchemaType>,
res: MedusaResponse<HttpTypes.AdminOrderReturnResponse>
) => {
const input = req.validatedBody as AdminPostReturnsReqSchemaType
const input = {
...req.validatedBody,
created_by: req.auth_context.actor_id,
}
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
const orderModuleService = req.scope.resolve(ModuleRegistrationName.ORDER)