feat: deprecate remote link (#10768)
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
1 parent
1e6d56bc18
commit
bbf790ea44
25 files changed
+74
-79
No files matched your search
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/core-flows": patch
|
||||||
|
"@medusajs/framework": patch
|
||||||
|
"@medusajs/modules-sdk": patch
|
||||||
|
"@medusajs/utils": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Refactor/deprecate remote link
|
||||||
+2
-2
@@ -13,7 +13,7 @@ export const linkSalesChannelsToApiKeyStepId = "link-sales-channels-to-api-key"
|
|||||||
export const linkSalesChannelsToApiKeyStep = createStep(
|
export const linkSalesChannelsToApiKeyStep = createStep(
|
||||||
linkSalesChannelsToApiKeyStepId,
|
linkSalesChannelsToApiKeyStepId,
|
||||||
async (input: LinkWorkflowInput, { container }) => {
|
async (input: LinkWorkflowInput, { container }) => {
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
if (!input || (!input.add?.length && !input.remove?.length)) {
|
if (!input || (!input.add?.length && !input.remove?.length)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ export const linkSalesChannelsToApiKeyStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
if (prevData.linksToCreate.length) {
|
if (prevData.linksToCreate.length) {
|
||||||
await remoteLink.dismiss(prevData.linksToCreate)
|
await remoteLink.dismiss(prevData.linksToCreate)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const updateCartPromotionsStep = createStep(
|
|||||||
updateCartPromotionsStepId,
|
updateCartPromotionsStepId,
|
||||||
async (data: UpdateCartPromotionStepInput, { container }) => {
|
async (data: UpdateCartPromotionStepInput, { container }) => {
|
||||||
const { promo_codes = [], id, action = PromotionActions.ADD } = data
|
const { promo_codes = [], id, action = PromotionActions.ADD } = data
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
const remoteQuery = container.resolve(
|
const remoteQuery = container.resolve(
|
||||||
ContainerRegistrationKeys.REMOTE_QUERY
|
ContainerRegistrationKeys.REMOTE_QUERY
|
||||||
)
|
)
|
||||||
@@ -94,7 +94,7 @@ export const updateCartPromotionsStep = createStep(
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
async (revertData, { container }) => {
|
async (revertData, { container }) => {
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
|
|
||||||
if (revertData?.dismissedLinks?.length) {
|
if (revertData?.dismissedLinks?.length) {
|
||||||
await remoteLink.create(revertData.dismissedLinks)
|
await remoteLink.create(revertData.dismissedLinks)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RemoteLink } from "@medusajs/framework/modules-sdk"
|
import { Link } from "@medusajs/framework/modules-sdk"
|
||||||
import { LinkDefinition } from "@medusajs/framework/types"
|
import { LinkDefinition } from "@medusajs/framework/types"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||||
@@ -37,9 +37,7 @@ export const createLinksStepId = "create-remote-links"
|
|||||||
export const createRemoteLinkStep = createStep(
|
export const createRemoteLinkStep = createStep(
|
||||||
createLinksStepId,
|
createLinksStepId,
|
||||||
async (data: LinkDefinition[], { container }) => {
|
async (data: LinkDefinition[], { container }) => {
|
||||||
const link = container.resolve<RemoteLink>(
|
const link = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!data.length) {
|
if (!data.length) {
|
||||||
return new StepResponse([], [])
|
return new StepResponse([], [])
|
||||||
@@ -54,9 +52,7 @@ export const createRemoteLinkStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = container.resolve<RemoteLink>(
|
const link = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
await link.dismiss(createdLinks)
|
await link.dismiss(createdLinks)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RemoteLink } from "@medusajs/framework/modules-sdk"
|
import { Link } from "@medusajs/framework/modules-sdk"
|
||||||
import { LinkDefinition } from "@medusajs/framework/types"
|
import { LinkDefinition } from "@medusajs/framework/types"
|
||||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||||
|
|
||||||
@@ -47,9 +47,7 @@ export const dismissRemoteLinkStep = createStep(
|
|||||||
return new StepResponse([], [])
|
return new StepResponse([], [])
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = container.resolve<RemoteLink>(
|
const link = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
|
|
||||||
// Our current revert strategy for dismissed links are to recreate it again.
|
// Our current revert strategy for dismissed links are to recreate it again.
|
||||||
// This works when its just the primary keys, but when you have additional data
|
// This works when its just the primary keys, but when you have additional data
|
||||||
@@ -67,9 +65,7 @@ export const dismissRemoteLinkStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = container.resolve<RemoteLink>(
|
const link = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
|
|
||||||
await link.create(dataBeforeDismiss)
|
await link.create(dataBeforeDismiss)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DeleteEntityInput, RemoteLink } from "@medusajs/framework/modules-sdk"
|
import { DeleteEntityInput, Link } from "@medusajs/framework/modules-sdk"
|
||||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||||
|
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||||
@@ -62,9 +62,7 @@ export const removeRemoteLinkStep = createStep(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = container.resolve<RemoteLink>(
|
const link = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
await link.delete(grouped)
|
await link.delete(grouped)
|
||||||
|
|
||||||
return new StepResponse(grouped, grouped)
|
return new StepResponse(grouped, grouped)
|
||||||
@@ -74,9 +72,7 @@ export const removeRemoteLinkStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = container.resolve<RemoteLink>(
|
const link = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
await link.restore(removedLinks)
|
await link.restore(removedLinks)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RemoteLink } from "@medusajs/framework/modules-sdk"
|
import { Link } from "@medusajs/framework/modules-sdk"
|
||||||
import { LinkDefinition } from "@medusajs/framework/types"
|
import { LinkDefinition } from "@medusajs/framework/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
@@ -14,9 +14,7 @@ export const updateRemoteLinksStep = createStep(
|
|||||||
return new StepResponse([], [])
|
return new StepResponse([], [])
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = container.resolve<RemoteLink>(
|
const link = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
|
|
||||||
// Fetch all existing links and throw an error if any weren't found
|
// Fetch all existing links and throw an error if any weren't found
|
||||||
const dataBeforeUpdate = (await link.list(data, {
|
const dataBeforeUpdate = (await link.list(data, {
|
||||||
@@ -43,9 +41,7 @@ export const updateRemoteLinksStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = container.resolve<RemoteLink>(
|
const link = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
|
|
||||||
await link.create(dataBeforeUpdate)
|
await link.create(dataBeforeUpdate)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RemoteLink } from "@medusajs/framework/modules-sdk"
|
import { Link } from "@medusajs/framework/modules-sdk"
|
||||||
import { RemoteQueryFunction } from "@medusajs/framework/types"
|
import { RemoteQueryFunction } from "@medusajs/framework/types"
|
||||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||||
import {
|
import {
|
||||||
@@ -70,9 +70,7 @@ export const setShippingOptionsPriceSetsStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve<RemoteLink>(
|
const remoteLink = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
const remoteQuery = container.resolve<RemoteQueryFunction>(
|
const remoteQuery = container.resolve<RemoteQueryFunction>(
|
||||||
ContainerRegistrationKeys.REMOTE_QUERY
|
ContainerRegistrationKeys.REMOTE_QUERY
|
||||||
)
|
)
|
||||||
@@ -152,9 +150,7 @@ export const setShippingOptionsPriceSetsStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve<RemoteLink>(
|
const remoteLink = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
|
|
||||||
const promises: Promise<unknown[]>[] = []
|
const promises: Promise<unknown[]>[] = []
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const attachInventoryItemToVariants = createStep(
|
|||||||
}[],
|
}[],
|
||||||
{ container }
|
{ container }
|
||||||
) => {
|
) => {
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
|
|
||||||
const linkDefinitions = input
|
const linkDefinitions = input
|
||||||
.filter(({ tag }) => !!tag)
|
.filter(({ tag }) => !!tag)
|
||||||
@@ -38,7 +38,7 @@ export const attachInventoryItemToVariants = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
|
|
||||||
await remoteLink.dismiss(linkDefinitions)
|
await remoteLink.dismiss(linkDefinitions)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ export const validateInventoryItemsForCreate = createStep(
|
|||||||
}[],
|
}[],
|
||||||
{ container }
|
{ container }
|
||||||
) => {
|
) => {
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
|
|
||||||
const linkService = remoteLink.getLinkModule(
|
const linkService = remoteLink.getLinkModule(
|
||||||
Modules.PRODUCT,
|
Modules.PRODUCT,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const createVariantPricingLinkStepId = "create-variant-pricing-link"
|
|||||||
export const createVariantPricingLinkStep = createStep(
|
export const createVariantPricingLinkStep = createStep(
|
||||||
createVariantPricingLinkStepId,
|
createVariantPricingLinkStepId,
|
||||||
async (data: CreateVariantPricingLinkStepInput, { container }) => {
|
async (data: CreateVariantPricingLinkStepInput, { container }) => {
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
await remoteLink.create(
|
await remoteLink.create(
|
||||||
data.links.map((entry) => ({
|
data.links.map((entry) => ({
|
||||||
[Modules.PRODUCT]: {
|
[Modules.PRODUCT]: {
|
||||||
@@ -34,7 +34,7 @@ export const createVariantPricingLinkStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
const links = data.links.map((entry) => ({
|
const links = data.links.map((entry) => ({
|
||||||
[Modules.PRODUCT]: {
|
[Modules.PRODUCT]: {
|
||||||
variant_id: entry.variant_id,
|
variant_id: entry.variant_id,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export const getVariantPricingLinkStep = createStep(
|
|||||||
return new StepResponse([])
|
return new StepResponse([])
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
|
|
||||||
const linkService = remoteLink.getLinkModule(
|
const linkService = remoteLink.getLinkModule(
|
||||||
Modules.PRODUCT,
|
Modules.PRODUCT,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RemoteLink } from "@medusajs/framework/modules-sdk"
|
import { Link } from "@medusajs/framework/modules-sdk"
|
||||||
import {
|
import {
|
||||||
IPaymentModuleService,
|
IPaymentModuleService,
|
||||||
RemoteQueryFunction,
|
RemoteQueryFunction,
|
||||||
@@ -107,9 +107,7 @@ export const setRegionsPaymentProvidersStep = createStep(
|
|||||||
const paymentService = container.resolve<IPaymentModuleService>(
|
const paymentService = container.resolve<IPaymentModuleService>(
|
||||||
Modules.PAYMENT
|
Modules.PAYMENT
|
||||||
)
|
)
|
||||||
const remoteLink = container.resolve<RemoteLink>(
|
const remoteLink = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
const remoteQuery = container.resolve<RemoteQueryFunction>(
|
const remoteQuery = container.resolve<RemoteQueryFunction>(
|
||||||
ContainerRegistrationKeys.REMOTE_QUERY
|
ContainerRegistrationKeys.REMOTE_QUERY
|
||||||
)
|
)
|
||||||
@@ -199,9 +197,7 @@ export const setRegionsPaymentProvidersStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve<RemoteLink>(
|
const remoteLink = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
|
|
||||||
const promises: Promise<unknown[]>[] = []
|
const promises: Promise<unknown[]>[] = []
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -21,7 +21,7 @@ export const associateLocationsWithSalesChannelsStep = createStep(
|
|||||||
return new StepResponse([], [])
|
return new StepResponse([], [])
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
const links = data.links.map((link) => {
|
const links = data.links.map((link) => {
|
||||||
return {
|
return {
|
||||||
[Modules.SALES_CHANNEL]: {
|
[Modules.SALES_CHANNEL]: {
|
||||||
@@ -41,7 +41,7 @@ export const associateLocationsWithSalesChannelsStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
await remoteLink.dismiss(links)
|
await remoteLink.dismiss(links)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
+2
-2
@@ -20,7 +20,7 @@ export const associateProductsWithSalesChannelsStep = createStep(
|
|||||||
return new StepResponse([], [])
|
return new StepResponse([], [])
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
const links = input.links.map((link) => {
|
const links = input.links.map((link) => {
|
||||||
return {
|
return {
|
||||||
[Modules.PRODUCT]: {
|
[Modules.PRODUCT]: {
|
||||||
@@ -40,7 +40,7 @@ export const associateProductsWithSalesChannelsStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
|
|
||||||
await remoteLink.dismiss(links)
|
await remoteLink.dismiss(links)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RemoteLink } from "@medusajs/framework/modules-sdk"
|
import { Link } from "@medusajs/framework/modules-sdk"
|
||||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||||
|
|
||||||
import { ContainerRegistrationKeys, Modules } from "@medusajs/framework/utils"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/framework/utils"
|
||||||
@@ -22,9 +22,7 @@ export const detachLocationsFromSalesChannelsStep = createStep(
|
|||||||
return new StepResponse([], [])
|
return new StepResponse([], [])
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve<RemoteLink>(
|
const remoteLink = container.resolve<Link>(ContainerRegistrationKeys.LINK)
|
||||||
ContainerRegistrationKeys.REMOTE_LINK
|
|
||||||
)
|
|
||||||
|
|
||||||
const links = data.links.map((link) => {
|
const links = data.links.map((link) => {
|
||||||
return {
|
return {
|
||||||
@@ -45,7 +43,7 @@ export const detachLocationsFromSalesChannelsStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
await remoteLink.create(links)
|
await remoteLink.create(links)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
+2
-2
@@ -20,7 +20,7 @@ export const detachProductsFromSalesChannelsStep = createStep(
|
|||||||
return new StepResponse(void 0, [])
|
return new StepResponse(void 0, [])
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
const links = input.links.map((link) => {
|
const links = input.links.map((link) => {
|
||||||
return {
|
return {
|
||||||
[Modules.PRODUCT]: {
|
[Modules.PRODUCT]: {
|
||||||
@@ -41,7 +41,7 @@ export const detachProductsFromSalesChannelsStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
|
|
||||||
await remoteLink.create(links)
|
await remoteLink.create(links)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ export const associateFulfillmentSetsWithLocationStep = createStep(
|
|||||||
return new StepResponse([], [])
|
return new StepResponse([], [])
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
|
|
||||||
const links = data.input
|
const links = data.input
|
||||||
.map((link) => {
|
.map((link) => {
|
||||||
@@ -49,7 +49,7 @@ export const associateFulfillmentSetsWithLocationStep = createStep(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK)
|
const remoteLink = container.resolve(ContainerRegistrationKeys.LINK)
|
||||||
|
|
||||||
await remoteLink.dismiss(links)
|
await remoteLink.dismiss(links)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { pgConnectionLoader } from "./database"
|
import { pgConnectionLoader } from "./database"
|
||||||
|
|
||||||
import { asValue } from "awilix"
|
import { aliasTo, asValue } from "awilix"
|
||||||
import { configManager } from "./config"
|
import { configManager } from "./config"
|
||||||
import {
|
import {
|
||||||
container,
|
container,
|
||||||
@@ -236,9 +236,10 @@ export class MedusaAppLoader {
|
|||||||
ContainerRegistrationKeys.QUERY,
|
ContainerRegistrationKeys.QUERY,
|
||||||
asValue(undefined)
|
asValue(undefined)
|
||||||
)
|
)
|
||||||
|
this.#container.register(ContainerRegistrationKeys.LINK, asValue(undefined))
|
||||||
this.#container.register(
|
this.#container.register(
|
||||||
ContainerRegistrationKeys.REMOTE_LINK,
|
ContainerRegistrationKeys.REMOTE_LINK,
|
||||||
asValue(undefined)
|
aliasTo(ContainerRegistrationKeys.LINK)
|
||||||
)
|
)
|
||||||
|
|
||||||
const configModules = this.mergeDefaultModules(configModule.modules)
|
const configModules = this.mergeDefaultModules(configModule.modules)
|
||||||
@@ -257,9 +258,13 @@ export class MedusaAppLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.#container.register(
|
this.#container.register(
|
||||||
ContainerRegistrationKeys.REMOTE_LINK,
|
ContainerRegistrationKeys.LINK,
|
||||||
asValue(medusaApp.link)
|
asValue(medusaApp.link)
|
||||||
)
|
)
|
||||||
|
this.#container.register(
|
||||||
|
ContainerRegistrationKeys.REMOTE_LINK,
|
||||||
|
aliasTo(ContainerRegistrationKeys.LINK)
|
||||||
|
)
|
||||||
this.#container.register(
|
this.#container.register(
|
||||||
ContainerRegistrationKeys.REMOTE_QUERY,
|
ContainerRegistrationKeys.REMOTE_QUERY,
|
||||||
asValue(medusaApp.query)
|
asValue(medusaApp.query)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { RemoteLink } from "@medusajs/modules-sdk"
|
import { Link } from "@medusajs/modules-sdk"
|
||||||
import {
|
import {
|
||||||
ConfigModule,
|
ConfigModule,
|
||||||
IApiKeyModuleService,
|
IApiKeyModuleService,
|
||||||
@@ -35,7 +35,11 @@ import { AwilixContainer, ResolveOptions } from "awilix"
|
|||||||
|
|
||||||
declare module "@medusajs/types" {
|
declare module "@medusajs/types" {
|
||||||
export interface ModuleImplementations {
|
export interface ModuleImplementations {
|
||||||
[ContainerRegistrationKeys.REMOTE_LINK]: RemoteLink
|
/**
|
||||||
|
* @deprecated. Instead use "link"
|
||||||
|
*/
|
||||||
|
[ContainerRegistrationKeys.REMOTE_LINK]: Link
|
||||||
|
[ContainerRegistrationKeys.LINK]: Link
|
||||||
[ContainerRegistrationKeys.CONFIG_MODULE]: ConfigModule
|
[ContainerRegistrationKeys.CONFIG_MODULE]: ConfigModule
|
||||||
[ContainerRegistrationKeys.PG_CONNECTION]: Knex<any>
|
[ContainerRegistrationKeys.PG_CONNECTION]: Knex<any>
|
||||||
[ContainerRegistrationKeys.REMOTE_QUERY]: RemoteQueryFunction
|
[ContainerRegistrationKeys.REMOTE_QUERY]: RemoteQueryFunction
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { ProductInventoryLinkModule } from "../__mocks__/product-inventory-link"
|
|||||||
import { ProductModule } from "../__mocks__/product-module"
|
import { ProductModule } from "../__mocks__/product-module"
|
||||||
import { StockLocationModule } from "../__mocks__/stock-location-module"
|
import { StockLocationModule } from "../__mocks__/stock-location-module"
|
||||||
|
|
||||||
import { RemoteLink } from "../remote-link"
|
import { Link } from "../link"
|
||||||
|
|
||||||
const allModules = [
|
const allModules = [
|
||||||
// modules
|
// modules
|
||||||
@@ -17,7 +17,7 @@ const allModules = [
|
|||||||
]
|
]
|
||||||
describe("Remote Link", function () {
|
describe("Remote Link", function () {
|
||||||
it("Should get all loaded modules and compose their relationships", async function () {
|
it("Should get all loaded modules and compose their relationships", async function () {
|
||||||
const remoteLink = new RemoteLink(allModules as any)
|
const remoteLink = new Link(allModules as any)
|
||||||
|
|
||||||
const relations = remoteLink.getRelationships()
|
const relations = remoteLink.getRelationships()
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ describe("Remote Link", function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("Should call the correct link module to create relation between 2 keys", async function () {
|
it("Should call the correct link module to create relation between 2 keys", async function () {
|
||||||
const remoteLink = new RemoteLink(allModules as any)
|
const remoteLink = new Link(allModules as any)
|
||||||
|
|
||||||
await remoteLink.create([
|
await remoteLink.create([
|
||||||
{
|
{
|
||||||
@@ -123,7 +123,7 @@ describe("Remote Link", function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("Should call delete in cascade all the modules involved in the link", async function () {
|
it("Should call delete in cascade all the modules involved in the link", async function () {
|
||||||
const remoteLink = new RemoteLink(allModules as any)
|
const remoteLink = new Link(allModules as any)
|
||||||
|
|
||||||
ProductInventoryLinkModule.softDelete.mockImplementation(() => {
|
ProductInventoryLinkModule.softDelete.mockImplementation(() => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export * from "./definitions"
|
|||||||
export * from "./loaders"
|
export * from "./loaders"
|
||||||
export * from "./medusa-app"
|
export * from "./medusa-app"
|
||||||
export * from "./medusa-module"
|
export * from "./medusa-module"
|
||||||
export * from "./remote-link"
|
export * from "./link"
|
||||||
export * from "./remote-query"
|
export * from "./remote-query"
|
||||||
export * from "./types"
|
export * from "./types"
|
||||||
export * from "./utils"
|
export * from "./utils"
|
||||||
+1
-1
@@ -48,7 +48,7 @@ type LinkDataConfig = {
|
|||||||
moduleBKey: string
|
moduleBKey: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RemoteLink {
|
export class Link {
|
||||||
private modulesMap: Map<string, LoadedLinkModule> = new Map()
|
private modulesMap: Map<string, LoadedLinkModule> = new Map()
|
||||||
private relationsPairs: Map<string, LoadedLinkModule> = new Map()
|
private relationsPairs: Map<string, LoadedLinkModule> = new Map()
|
||||||
private relations: Map<string, Map<string, RemoteRelationship[]>> = new Map()
|
private relations: Map<string, Map<string, RemoteRelationship[]>> = new Map()
|
||||||
@@ -33,7 +33,7 @@ import {
|
|||||||
ModuleBootstrapOptions,
|
ModuleBootstrapOptions,
|
||||||
RegisterModuleJoinerConfig,
|
RegisterModuleJoinerConfig,
|
||||||
} from "./medusa-module"
|
} from "./medusa-module"
|
||||||
import { RemoteLink } from "./remote-link"
|
import { Link } from "./link"
|
||||||
import { createQuery, RemoteQuery } from "./remote-query"
|
import { createQuery, RemoteQuery } from "./remote-query"
|
||||||
import { MODULE_SCOPE } from "./types"
|
import { MODULE_SCOPE } from "./types"
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ async function initializeLinks({
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
remoteLink: new RemoteLink(),
|
remoteLink: new Link(),
|
||||||
linkResolution,
|
linkResolution,
|
||||||
getMigrationPlanner,
|
getMigrationPlanner,
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ function registerCustomJoinerConfigs(servicesConfig: ModuleJoinerConfig[]) {
|
|||||||
|
|
||||||
export type MedusaAppOutput = {
|
export type MedusaAppOutput = {
|
||||||
modules: Record<string, LoadedModule | LoadedModule[]>
|
modules: Record<string, LoadedModule | LoadedModule[]>
|
||||||
link: RemoteLink | undefined
|
link: Link | undefined
|
||||||
query: RemoteQueryFunction
|
query: RemoteQueryFunction
|
||||||
entitiesMap?: Record<string, any>
|
entitiesMap?: Record<string, any>
|
||||||
gqlSchema?: GraphQLUtils.GraphQLSchema
|
gqlSchema?: GraphQLUtils.GraphQLSchema
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ export const ContainerRegistrationKeys = {
|
|||||||
LOGGER: "logger",
|
LOGGER: "logger",
|
||||||
REMOTE_QUERY: "remoteQuery",
|
REMOTE_QUERY: "remoteQuery",
|
||||||
QUERY: "query",
|
QUERY: "query",
|
||||||
|
/**
|
||||||
|
* @deprecated. Instead use "ContainerRegistrationKeys.LINK"
|
||||||
|
*/
|
||||||
REMOTE_LINK: "remoteLink",
|
REMOTE_LINK: "remoteLink",
|
||||||
|
LINK: "link",
|
||||||
FEATURE_FLAG_ROUTER: "featureFlagRouter",
|
FEATURE_FLAG_ROUTER: "featureFlagRouter",
|
||||||
} as const
|
} as const
|
||||||
Reference in new issue
Block a user