Chore/rm main entity concept (#7709)
**What** Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate. This pr also includes various fixes in different modules Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
533 files changed
+6469
-9769
No files matched your search
@@ -8,7 +8,7 @@ import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
|
||||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
const variables = { code: req.params.code }
|
||||
const variables = { filters: { code: req.params.code } }
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "currency",
|
||||
|
||||
+7
-4
@@ -55,7 +55,7 @@ export const POST = async (
|
||||
)
|
||||
|
||||
// ensure fulfillment set exists and that the service zone is part of it
|
||||
const fulfillmentSet = await fulfillmentModuleService.retrieve(
|
||||
const fulfillmentSet = await fulfillmentModuleService.retrieveFulfillmentSet(
|
||||
req.params.id,
|
||||
{ relations: ["service_zones"] }
|
||||
)
|
||||
@@ -102,9 +102,12 @@ export const DELETE = async (
|
||||
)
|
||||
|
||||
// ensure fulfillment set exists and that the service zone is part of it
|
||||
const fulfillmentSet = await fulfillmentModuleService.retrieve(id, {
|
||||
relations: ["service_zones"],
|
||||
})
|
||||
const fulfillmentSet = await fulfillmentModuleService.retrieveFulfillmentSet(
|
||||
id,
|
||||
{
|
||||
relations: ["service_zones"],
|
||||
}
|
||||
)
|
||||
|
||||
if (!fulfillmentSet.service_zones.find((s) => s.id === zone_id)) {
|
||||
throw new MedusaError(
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
export const listPrices = (
|
||||
export const listPrices = async (
|
||||
ids: string[],
|
||||
scope: MedusaContainer,
|
||||
fields: string[]
|
||||
@@ -18,5 +18,5 @@ export const listPrices = (
|
||||
fields,
|
||||
})
|
||||
|
||||
return remoteQuery(queryObject)
|
||||
return await remoteQuery(queryObject)
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
|
||||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
const variables = { code: req.params.code }
|
||||
const variables = { filters: { code: req.params.code } }
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "currency",
|
||||
|
||||
@@ -17,7 +17,7 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
ModuleRegistrationName.CART
|
||||
)
|
||||
|
||||
const cart = await cartService.retrieve(cart_id, {
|
||||
const cart = await cartService.retrieveCart(cart_id, {
|
||||
select: [
|
||||
"id",
|
||||
"sales_channel_id",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
arrayIntersection,
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
arrayIntersection,
|
||||
} from "@medusajs/utils"
|
||||
import { NextFunction } from "express"
|
||||
import { MedusaRequest } from "../../types/routing"
|
||||
@@ -33,7 +33,7 @@ export function maybeApplyLinkFilter({
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint,
|
||||
fields: [resourceId],
|
||||
variables: { [filterableField]: idsToFilterBy },
|
||||
variables: { filters: { [filterableField]: idsToFilterBy } },
|
||||
})
|
||||
|
||||
const resources = await remoteQuery(queryObject)
|
||||
|
||||
@@ -42,7 +42,7 @@ export default async function ({
|
||||
Invite token: ${invite.token}
|
||||
Open the invite in Medusa Admin at: [your-admin-url]/invite?token=${invite.token}`)
|
||||
} else {
|
||||
const user = await userService.create({ email })
|
||||
const user = await userService.createUsers({ email })
|
||||
|
||||
const { authIdentity, error } = await authService.authenticate(provider, {
|
||||
body: {
|
||||
@@ -57,7 +57,7 @@ export default async function ({
|
||||
}
|
||||
|
||||
// We know the authIdentity is not undefined
|
||||
await authService.update({
|
||||
await authService.updateAuthIdentites({
|
||||
id: authIdentity!.id,
|
||||
app_metadata: {
|
||||
user_id: user.id,
|
||||
|
||||
@@ -69,7 +69,7 @@ export default async function configurableNotifications({
|
||||
|
||||
// We don't want to fail all handlers, so we catch and log errors only
|
||||
try {
|
||||
await notificationService.create(notificationData)
|
||||
await notificationService.createNotifications(notificationData)
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
`Failed to send notification for ${eventName}`,
|
||||
|
||||
Reference in new issue
Block a user