feat(medusa,types): add enabled plugins route (#11876)
This commit is contained in:
1 parent
9dd62d93bd
commit
c3440e5e38
7 files changed
+69
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/types": patch
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
"@medusajs/js-sdk": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(medusa,types,js-sdk): add enabled plugins route
|
||||||
@@ -17,6 +17,7 @@ import { Order } from "./order"
|
|||||||
import { OrderEdit } from "./order-edit"
|
import { OrderEdit } from "./order-edit"
|
||||||
import { Payment } from "./payment"
|
import { Payment } from "./payment"
|
||||||
import { PaymentCollection } from "./payment-collection"
|
import { PaymentCollection } from "./payment-collection"
|
||||||
|
import { Plugin } from "./plugin"
|
||||||
import { PriceList } from "./price-list"
|
import { PriceList } from "./price-list"
|
||||||
import { PricePreference } from "./price-preference"
|
import { PricePreference } from "./price-preference"
|
||||||
import { Product } from "./product"
|
import { Product } from "./product"
|
||||||
@@ -211,6 +212,10 @@ export class Admin {
|
|||||||
* @tags promotion
|
* @tags promotion
|
||||||
*/
|
*/
|
||||||
public campaign: Campaign
|
public campaign: Campaign
|
||||||
|
/**
|
||||||
|
* @tags plugin
|
||||||
|
*/
|
||||||
|
public plugin: Plugin
|
||||||
|
|
||||||
constructor(client: Client) {
|
constructor(client: Client) {
|
||||||
this.invite = new Invite(client)
|
this.invite = new Invite(client)
|
||||||
@@ -255,5 +260,6 @@ export class Admin {
|
|||||||
this.customerGroup = new CustomerGroup(client)
|
this.customerGroup = new CustomerGroup(client)
|
||||||
this.promotion = new Promotion(client)
|
this.promotion = new Promotion(client)
|
||||||
this.campaign = new Campaign(client)
|
this.campaign = new Campaign(client)
|
||||||
|
this.plugin = new Plugin(client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
import { Client } from "../client"
|
||||||
|
import { ClientHeaders } from "../types"
|
||||||
|
|
||||||
|
export class Plugin {
|
||||||
|
private client: Client
|
||||||
|
|
||||||
|
constructor(client: Client) {
|
||||||
|
this.client = client
|
||||||
|
}
|
||||||
|
|
||||||
|
async list(headers?: ClientHeaders) {
|
||||||
|
return await this.client.fetch<HttpTypes.AdminPluginsListResponse>(
|
||||||
|
`/admin/plugins`,
|
||||||
|
{
|
||||||
|
headers,
|
||||||
|
query: {},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ export * from "./notification"
|
|||||||
export * from "./order"
|
export * from "./order"
|
||||||
export * from "./order-edit"
|
export * from "./order-edit"
|
||||||
export * from "./payment"
|
export * from "./payment"
|
||||||
|
export * from "./plugins"
|
||||||
export * from "./price-list"
|
export * from "./price-list"
|
||||||
export * from "./pricing"
|
export * from "./pricing"
|
||||||
export * from "./product"
|
export * from "./product"
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
export interface AdminPlugin {
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminPluginsListResponse {
|
||||||
|
/**
|
||||||
|
* The plugin's details.
|
||||||
|
*/
|
||||||
|
plugins: AdminPlugin[]
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./admin/responses"
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||||
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||||
|
import { isString } from "lodash"
|
||||||
|
|
||||||
|
export const GET = async (
|
||||||
|
req: MedusaRequest<unknown>,
|
||||||
|
res: MedusaResponse<HttpTypes.AdminPluginsListResponse>
|
||||||
|
) => {
|
||||||
|
const configModule = req.scope.resolve(
|
||||||
|
ContainerRegistrationKeys.CONFIG_MODULE
|
||||||
|
)
|
||||||
|
|
||||||
|
const configPlugins = configModule.plugins ?? []
|
||||||
|
|
||||||
|
const plugins = configPlugins.map((plugin) => ({
|
||||||
|
name: isString(plugin) ? plugin : plugin.resolve,
|
||||||
|
}))
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
plugins,
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in new issue
Block a user