medusa
medusa copied to clipboard
Feat(modules-sdk): define link
defineLink(
`${Modules.CART}.cart_id`,
`${Modules.PAYMENT}.payment_collection_id`
)
defineLink(
`${Modules.CART}.cart_id`,
`${Modules.PAYMENT}.payment_collection_id[]` // isList: true
)
defineLink(
{
module: Modules.CART,
key: "cart_id",
alias: "cart_alias"
},
Modules.PAYMENT + ".payment_collection_id"
)
defineLink(
`${Modules.CART}.cart_id`,
`${Modules.PAYMENT}.payment_collection_id`,
{
database: {
table: "cart_payment_collection",
idPrefix: "capaycol",
},
}
)
🦋 Changeset detected
Latest commit: 1bd087e12bf988c2dae4aec104b92cbd5252aad3
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Name | Type |
---|---|
@medusajs/modules-sdk | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
medusa-dashboard | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 2, 2024 3:44pm |
3 Ignored Deployments
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
api-reference | ⬜️ Ignored (Inspect) | May 2, 2024 3:44pm | ||
docs-ui | ⬜️ Ignored (Inspect) | Visit Preview | May 2, 2024 3:44pm | |
medusa-docs | ⬜️ Ignored (Inspect) | Visit Preview | May 2, 2024 3:44pm |
/snapshot-this
:rocket: A snapshot release has been made for this PR
Test the snapshots by updating your package.json
with the newly published versions:
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add [email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add [email protected]
yarn add [email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
Latest commit: 3882cac622c7d14421fb56dfb88c3929ac73092c
Would it make sense to simplify the API of defineLink
to only support one way? My idea is to try to reduce the amount of decisions developers need to make in the context of link definitions. We make it easy for them and they don't have to worry about what is most appropriate.
What I have in mind was something like this:
// /src/links/index.ts
const someLink = {
modules: [
{
name: Modules.CART,
key: "cart_id",
},
{
name: Modules.PAYMENT,
key: "payment_collection_id",
isList: true,
},
],
options: { idPrefix: "capaycol" }
}
const someOtherLink = {
modules: [
{
name: Modules.CART,
key: "cart_id",
},
{
name: Modules.SALES_CHANNEL,
key: "sales_channel_id",
},
],
}
defineLink([ someLink, someOtherLink ])
Curious to hear what you think about this
cc @srindom
I like this approach too because at the end we have multiple extra properties that we'll need.
So having a proper object with all the available options, like the fieldAlias
, is good.
@carlos-r-l-rodrigues, should we reopen this and get it merged?
I think regardless of where we will load links created by external devs, we will need the utility to perform it.
I haven't applied this last format proposed. I will fix conflicts and open another PR..