File tree Expand file tree Collapse file tree 7 files changed +69
-0
lines changed
medusa/src/api/admin/plugins Expand file tree Collapse file tree 7 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @medusajs/types " : patch
3+ " @medusajs/medusa " : patch
4+ " @medusajs/js-sdk " : patch
5+ ---
6+
7+ feat(medusa,types,js-sdk): add enabled plugins route
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import { Order } from "./order"
1717import { OrderEdit } from "./order-edit"
1818import { Payment } from "./payment"
1919import { PaymentCollection } from "./payment-collection"
20+ import { Plugin } from "./plugin"
2021import { PriceList } from "./price-list"
2122import { PricePreference } from "./price-preference"
2223import { Product } from "./product"
@@ -211,6 +212,10 @@ export class Admin {
211212 * @tags promotion
212213 */
213214 public campaign : Campaign
215+ /**
216+ * @tags plugin
217+ */
218+ public plugin : Plugin
214219
215220 constructor ( client : Client ) {
216221 this . invite = new Invite ( client )
@@ -255,5 +260,6 @@ export class Admin {
255260 this . customerGroup = new CustomerGroup ( client )
256261 this . promotion = new Promotion ( client )
257262 this . campaign = new Campaign ( client )
263+ this . plugin = new Plugin ( client )
258264 }
259265}
Original file line number Diff line number Diff line change 1+ import { HttpTypes } from "@medusajs/types"
2+ import { Client } from "../client"
3+ import { ClientHeaders } from "../types"
4+
5+ export class Plugin {
6+ private client : Client
7+
8+ constructor ( client : Client ) {
9+ this . client = client
10+ }
11+
12+ async list ( headers ?: ClientHeaders ) {
13+ return await this . client . fetch < HttpTypes . AdminPluginsListResponse > (
14+ `/admin/plugins` ,
15+ {
16+ headers,
17+ query : { } ,
18+ }
19+ )
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ export * from "./notification"
2222export * from "./order"
2323export * from "./order-edit"
2424export * from "./payment"
25+ export * from "./plugins"
2526export * from "./price-list"
2627export * from "./pricing"
2728export * from "./product"
Original file line number Diff line number Diff line change 1+ export interface AdminPlugin {
2+ name : string
3+ }
4+
5+ export interface AdminPluginsListResponse {
6+ /**
7+ * The plugin's details.
8+ */
9+ plugins : AdminPlugin [ ]
10+ }
Original file line number Diff line number Diff line change 1+ export * from "./admin/responses"
Original file line number Diff line number Diff line change 1+ import { MedusaRequest , MedusaResponse } from "@medusajs/framework/http"
2+ import { HttpTypes } from "@medusajs/framework/types"
3+ import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
4+ import { isString } from "lodash"
5+
6+ export const GET = async (
7+ req : MedusaRequest < unknown > ,
8+ res : MedusaResponse < HttpTypes . AdminPluginsListResponse >
9+ ) => {
10+ const configModule = req . scope . resolve (
11+ ContainerRegistrationKeys . CONFIG_MODULE
12+ )
13+
14+ const configPlugins = configModule . plugins ?? [ ]
15+
16+ const plugins = configPlugins . map ( ( plugin ) => ( {
17+ name : isString ( plugin ) ? plugin : plugin . resolve ,
18+ } ) )
19+
20+ res . json ( {
21+ plugins,
22+ } )
23+ }
You can’t perform that action at this time.
0 commit comments