feat(types,js-sdk,medusa,fulfillment): Types and SDK methods related to Stock Locations (#7625)
This commit is contained in:
1 parent
9677daa568
commit
50ce223e4b
83 files changed
+1327
-351
No files matched your search
@@ -1,7 +1,19 @@
|
||||
import { z } from "zod"
|
||||
import { createSelectParams } from "../../utils/validators"
|
||||
import { OptionalBooleanValidator } from "../../utils/common-validators"
|
||||
import { createFindParams } from "../../utils/validators"
|
||||
|
||||
export type AdminFulfillmentProvidersParamsType = z.infer<
|
||||
typeof AdminFulfillmentProvidersParams
|
||||
>
|
||||
export const AdminFulfillmentProvidersParams = createSelectParams()
|
||||
export const AdminFulfillmentProvidersParams = createFindParams({
|
||||
limit: 50,
|
||||
offset: 0,
|
||||
})
|
||||
.merge(
|
||||
z.object({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
is_enabled: OptionalBooleanValidator,
|
||||
q: z.string().optional(),
|
||||
})
|
||||
)
|
||||
.strict()
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AdminFulfillmentSetsDeleteResponse } from "@medusajs/types"
|
||||
import { deleteFulfillmentSetsWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
res: MedusaResponse<AdminFulfillmentSetsDeleteResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminFulfillmentSetDeleteResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
|
||||
+2
-3
@@ -5,7 +5,6 @@ import {
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
AdminFulfillmentSetResponse,
|
||||
AdminServiceZoneDeleteResponse,
|
||||
AdminServiceZoneResponse,
|
||||
IFulfillmentModuleService,
|
||||
} from "@medusajs/types"
|
||||
@@ -94,7 +93,7 @@ export const POST = async (
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
res: MedusaResponse<AdminServiceZoneDeleteResponse>
|
||||
res: MedusaResponse
|
||||
) => {
|
||||
const { id, zone_id } = req.params
|
||||
|
||||
@@ -120,7 +119,7 @@ export const DELETE = async (
|
||||
|
||||
res.status(200).json({
|
||||
id: zone_id,
|
||||
object: "service-zone",
|
||||
object: "service_zone",
|
||||
deleted: true,
|
||||
parent: fulfillmentSet,
|
||||
})
|
||||
|
||||
@@ -14,11 +14,6 @@ export const retrieveTransformQueryConfig = {
|
||||
isList: false,
|
||||
}
|
||||
|
||||
export const listTransformQueryConfig = {
|
||||
...retrieveTransformQueryConfig,
|
||||
isList: true,
|
||||
}
|
||||
|
||||
export const retrieveServiceZoneTransformQueryConfig = {
|
||||
defaults: [
|
||||
"id",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod"
|
||||
import { createFindParams, createOperatorMap } from "../../utils/validators"
|
||||
import { createSelectParams } from "../../utils/validators"
|
||||
import {
|
||||
geoZoneCitySchema,
|
||||
geoZoneCountrySchema,
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
geoZoneZipSchema,
|
||||
} from "./validators/geo-zone"
|
||||
|
||||
export const AdminServiceZonesParams = createFindParams()
|
||||
export const AdminServiceZonesParams = createSelectParams()
|
||||
export type AdminServiceZonesParamsType = z.infer<
|
||||
typeof AdminServiceZonesParams
|
||||
>
|
||||
@@ -44,20 +44,7 @@ export const AdminUpdateFulfillmentSetServiceZonesSchema = z
|
||||
})
|
||||
.strict()
|
||||
|
||||
export const AdminFulfillmentSetParams = createFindParams({
|
||||
limit: 20,
|
||||
offset: 0,
|
||||
}).merge(
|
||||
z.object({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
name: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
type: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
service_zone_id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
created_at: createOperatorMap().optional(),
|
||||
updated_at: createOperatorMap().optional(),
|
||||
deleted_at: createOperatorMap().optional(),
|
||||
})
|
||||
)
|
||||
export const AdminFulfillmentSetParams = createSelectParams()
|
||||
|
||||
export type AdminCreateFulfillmentSetServiceZonesType = z.infer<
|
||||
typeof AdminCreateFulfillmentSetServiceZonesSchema
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from "zod"
|
||||
import { OptionalBooleanValidator } from "../../utils/common-validators"
|
||||
import {
|
||||
createFindParams,
|
||||
createOperatorMap,
|
||||
@@ -22,6 +23,7 @@ export const AdminGetSalesChannelsParams = createFindParams({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
name: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
description: z.string().optional(),
|
||||
is_disabled: OptionalBooleanValidator,
|
||||
created_at: createOperatorMap().optional(),
|
||||
updated_at: createOperatorMap().optional(),
|
||||
deleted_at: createOperatorMap().optional(),
|
||||
@@ -47,7 +49,7 @@ export type AdminUpdateSalesChannelType = z.infer<
|
||||
>
|
||||
export const AdminUpdateSalesChannel = z.object({
|
||||
name: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
description: z.string().nullable().optional(),
|
||||
is_disabled: z.boolean().optional(),
|
||||
metadata: z.record(z.string(), z.unknown()).optional(),
|
||||
})
|
||||
@@ -1,22 +1,18 @@
|
||||
import {
|
||||
AdminShippingOptionDeleteResponse,
|
||||
AdminShippingOptionRetrieveResponse,
|
||||
FulfillmentWorkflow,
|
||||
} from "@medusajs/types"
|
||||
import { AdminUpdateShippingOptionType } from "../validators"
|
||||
import {
|
||||
deleteShippingOptionsWorkflow,
|
||||
updateShippingOptionsWorkflow,
|
||||
} from "@medusajs/core-flows"
|
||||
import { FulfillmentWorkflow, HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../types/routing"
|
||||
import { refetchShippingOption } from "../helpers"
|
||||
import { AdminUpdateShippingOptionType } from "../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminUpdateShippingOptionType>,
|
||||
res: MedusaResponse<AdminShippingOptionRetrieveResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminShippingOptionResponse>
|
||||
) => {
|
||||
const shippingOptionPayload = req.validatedBody
|
||||
|
||||
@@ -43,7 +39,7 @@ export const POST = async (
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
res: MedusaResponse<AdminShippingOptionDeleteResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminShippingOptionDeleteResponse>
|
||||
) => {
|
||||
const shippingOptionId = req.params.id
|
||||
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
import { createShippingOptionsWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
AdminShippingOptionListResponse,
|
||||
AdminShippingOptionRetrieveResponse,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../types/routing"
|
||||
import { refetchShippingOption } from "./helpers"
|
||||
import {
|
||||
AdminCreateShippingOptionType,
|
||||
AdminGetShippingOptionsParamsType,
|
||||
} from "./validators"
|
||||
import { refetchShippingOption } from "./helpers"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<AdminGetShippingOptionsParamsType>,
|
||||
res: MedusaResponse<AdminShippingOptionListResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminShippingOptionListResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -44,7 +41,7 @@ export const GET = async (
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminCreateShippingOptionType>,
|
||||
res: MedusaResponse<AdminShippingOptionRetrieveResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminShippingOptionResponse>
|
||||
) => {
|
||||
const shippingOptionPayload = req.validatedBody
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@ import {
|
||||
ShippingOptionPriceType as ShippingOptionPriceTypeEnum,
|
||||
} from "@medusajs/utils"
|
||||
import { z } from "zod"
|
||||
import { createFindParams, createSelectParams } from "../../utils/validators"
|
||||
import {
|
||||
createFindParams,
|
||||
createOperatorMap,
|
||||
createSelectParams,
|
||||
} from "../../utils/validators"
|
||||
|
||||
export type AdminGetShippingOptionParamsType = z.infer<
|
||||
typeof AdminGetShippingOptionParams
|
||||
@@ -16,7 +20,21 @@ export type AdminGetShippingOptionsParamsType = z.infer<
|
||||
export const AdminGetShippingOptionsParams = createFindParams({
|
||||
offset: 0,
|
||||
limit: 20,
|
||||
})
|
||||
}).merge(
|
||||
z.object({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
q: z.string().optional(),
|
||||
service_zone_id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
shipping_profile_id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
provider_id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
shipping_option_type_id: z
|
||||
.union([z.string(), z.array(z.string())])
|
||||
.optional(),
|
||||
created_at: createOperatorMap().optional(),
|
||||
updated_at: createOperatorMap().optional(),
|
||||
deleted_at: createOperatorMap().optional(),
|
||||
})
|
||||
)
|
||||
|
||||
/**
|
||||
* SHIPPING OPTIONS RULES
|
||||
@@ -127,6 +145,8 @@ export const AdminUpdateShippingOption = z
|
||||
)
|
||||
.array()
|
||||
.optional(),
|
||||
rules: AdminUpdateShippingOptionRule.or(AdminCreateShippingOptionRule).array().optional(),
|
||||
rules: AdminUpdateShippingOptionRule.or(AdminCreateShippingOptionRule)
|
||||
.array()
|
||||
.optional(),
|
||||
})
|
||||
.strict()
|
||||
@@ -3,11 +3,7 @@ import {
|
||||
updateShippingProfilesWorkflow,
|
||||
} from "@medusajs/core-flows"
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
AdminShippingProfileDeleteResponse,
|
||||
AdminShippingProfileResponse,
|
||||
IFulfillmentModuleService,
|
||||
} from "@medusajs/types"
|
||||
import { HttpTypes, IFulfillmentModuleService } from "@medusajs/types"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
@@ -20,7 +16,7 @@ import {
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<AdminGetShippingProfileParamsType>,
|
||||
res: MedusaResponse<AdminShippingProfileResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminShippingProfileResponse>
|
||||
) => {
|
||||
const shippingProfile = await refetchShippingProfile(
|
||||
req.params.id,
|
||||
@@ -33,7 +29,7 @@ export const GET = async (
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
res: MedusaResponse<AdminShippingProfileDeleteResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminShippingProfileDeleteResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -57,7 +53,7 @@ export const DELETE = async (
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminUpdateShippingProfileType>,
|
||||
res: MedusaResponse<AdminShippingProfileResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminShippingProfileResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { createShippingProfilesWorkflow } from "@medusajs/core-flows"
|
||||
import {
|
||||
AdminShippingProfileResponse,
|
||||
AdminShippingProfilesResponse,
|
||||
} from "@medusajs/types"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
@@ -11,15 +8,15 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../types/routing"
|
||||
import { refetchShippingProfile } from "./helpers"
|
||||
import {
|
||||
AdminCreateShippingProfileType,
|
||||
AdminGetShippingProfilesParamsType,
|
||||
} from "./validators"
|
||||
import { refetchShippingProfile } from "./helpers"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminCreateShippingProfileType>,
|
||||
res: MedusaResponse<AdminShippingProfileResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminShippingProfileResponse>
|
||||
) => {
|
||||
const shippingProfilePayload = req.validatedBody
|
||||
|
||||
@@ -38,7 +35,7 @@ export const POST = async (
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<AdminGetShippingProfilesParamsType>,
|
||||
res: MedusaResponse<AdminShippingProfilesResponse>
|
||||
res: MedusaResponse<HttpTypes.AdminShippingProfileListResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ export const AdminGetShippingProfilesParams = createFindParams({
|
||||
offset: 0,
|
||||
}).merge(
|
||||
z.object({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
q: z.string().optional(),
|
||||
type: z.string().optional(),
|
||||
name: z.string().optional(),
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { z } from "zod"
|
||||
import { createFindParams, createSelectParams } from "../../utils/validators"
|
||||
import {
|
||||
createFindParams,
|
||||
createOperatorMap,
|
||||
createSelectParams,
|
||||
} from "../../utils/validators"
|
||||
|
||||
export type AdminGetStockLocationParamsType = z.infer<
|
||||
typeof AdminGetStockLocationParams
|
||||
@@ -19,6 +23,9 @@ export const AdminGetStockLocationsParams = createFindParams({
|
||||
name: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
address_id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
sales_channel_id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
created_at: createOperatorMap().optional(),
|
||||
updated_at: createOperatorMap().optional(),
|
||||
deleted_at: createOperatorMap().optional(),
|
||||
$and: z.lazy(() => AdminGetStockLocationsParams.array()).optional(),
|
||||
$or: z.lazy(() => AdminGetStockLocationsParams.array()).optional(),
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user