@hartl-services/medusa-base 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +267 -0
- package/.medusa/server/src/admin/index.mjs +266 -0
- package/.medusa/server/src/api/admin/plugin-features/route.js +20 -0
- package/.medusa/server/src/api/middlewares.js +25 -0
- package/.medusa/server/src/api/plugin-features-http.js +20 -0
- package/.medusa/server/src/api/store/plugin-features/[plugin_key]/route.js +13 -0
- package/.medusa/server/src/api/store/plugin-features/route.js +13 -0
- package/.medusa/server/src/api/wire-response.js +10 -0
- package/.medusa/server/src/modules/plugin-features/index.js +14 -0
- package/.medusa/server/src/modules/plugin-features/migrations/Migration20260928155256.js +16 -0
- package/.medusa/server/src/modules/plugin-features/models/plugin-feature-state.js +29 -0
- package/.medusa/server/src/modules/plugin-features/service.js +141 -0
- package/.medusa/server/src/public/constants.js +6 -0
- package/.medusa/server/src/public/descriptor.js +54 -0
- package/.medusa/server/src/public/effective-features.js +74 -0
- package/.medusa/server/src/public/enforcement.js +51 -0
- package/.medusa/server/src/public/index.js +13 -0
- package/.medusa/server/src/public/types.js +3 -0
- package/.medusa/server/src/utils/discover-plugin-features.js +51 -0
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/public/constants.d.ts +2 -0
- package/dist/public/constants.js +5 -0
- package/dist/public/descriptor.d.ts +11 -0
- package/dist/public/descriptor.js +53 -0
- package/dist/public/effective-features.d.ts +28 -0
- package/dist/public/effective-features.js +73 -0
- package/dist/public/enforcement.d.ts +13 -0
- package/dist/public/enforcement.js +50 -0
- package/dist/public/index.d.ts +5 -0
- package/dist/public/index.js +12 -0
- package/dist/public/types.d.ts +29 -0
- package/dist/public/types.js +2 -0
- package/package.json +82 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const adminSdk = require("@medusajs/admin-sdk");
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const ui = require("@medusajs/ui");
|
|
5
|
+
const reactQuery = require("@tanstack/react-query");
|
|
6
|
+
const pluginFeatures = require("@hartl-services/medusa-food-supplements-contracts/paths/plugin-features");
|
|
7
|
+
const Medusa = require("@medusajs/js-sdk");
|
|
8
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
+
const Medusa__default = /* @__PURE__ */ _interopDefault(Medusa);
|
|
10
|
+
const texts = {
|
|
11
|
+
menu: {
|
|
12
|
+
label: "Hartl Services Plugins"
|
|
13
|
+
},
|
|
14
|
+
page: {
|
|
15
|
+
title: "Hartl Services Plugins",
|
|
16
|
+
description: "Plugins und einzelne Funktionen ein- oder ausschalten. Änderungen gelten sofort; abgeschaltete Funktionen sind im Shop nicht erreichbar."
|
|
17
|
+
},
|
|
18
|
+
states: {
|
|
19
|
+
loading: "Funktionsschalter werden geladen…",
|
|
20
|
+
error: "Funktionsschalter konnten nicht geladen werden.",
|
|
21
|
+
empty: "Keine Plugins mit Funktionsschaltern installiert.",
|
|
22
|
+
retry: "Erneut laden"
|
|
23
|
+
},
|
|
24
|
+
plugin: {
|
|
25
|
+
switchLabel: (label) => `${label} aktiv`
|
|
26
|
+
},
|
|
27
|
+
hints: {
|
|
28
|
+
pluginDisabled: "Das Plugin ist ausgeschaltet. Alle Funktionen sind inaktiv, ihre Einstellungen bleiben erhalten.",
|
|
29
|
+
parentDisabled: (parentLabel) => `Inaktiv, solange „${parentLabel}“ ausgeschaltet ist.`,
|
|
30
|
+
saving: "Wird gespeichert…"
|
|
31
|
+
},
|
|
32
|
+
toasts: {
|
|
33
|
+
saved: "Einstellung wurde gespeichert.",
|
|
34
|
+
saveFailed: "Einstellung konnte nicht gespeichert werden.",
|
|
35
|
+
conflict: "Die Einstellungen wurden zwischenzeitlich geändert und neu geladen."
|
|
36
|
+
},
|
|
37
|
+
errors: {
|
|
38
|
+
unknown: "Unbekannter Fehler"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const getErrorMessage = (error) => {
|
|
42
|
+
if (error instanceof Error && error.message) {
|
|
43
|
+
return error.message;
|
|
44
|
+
}
|
|
45
|
+
if (typeof error !== "object" || error === null) {
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
const candidate = error;
|
|
49
|
+
for (const value of [
|
|
50
|
+
candidate.response?.data?.message,
|
|
51
|
+
candidate.response?.data?.error,
|
|
52
|
+
candidate.body?.message,
|
|
53
|
+
candidate.body?.error,
|
|
54
|
+
candidate.message,
|
|
55
|
+
candidate.statusText
|
|
56
|
+
]) {
|
|
57
|
+
if (typeof value === "string" && value.trim()) {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return void 0;
|
|
62
|
+
};
|
|
63
|
+
const sdk = new Medusa__default.default({
|
|
64
|
+
baseUrl: __BACKEND_URL__ ?? "/",
|
|
65
|
+
auth: {
|
|
66
|
+
type: __AUTH_TYPE__ ?? "session",
|
|
67
|
+
jwtTokenStorageKey: __JWT_TOKEN_STORAGE_KEY__ || void 0
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const listPluginFeatures = () => sdk.client.fetch(
|
|
71
|
+
pluginFeatures.pluginFeaturesAdminPaths.get.list,
|
|
72
|
+
{ method: "GET" }
|
|
73
|
+
);
|
|
74
|
+
const updatePluginFeatures = (payload) => sdk.client.fetch(
|
|
75
|
+
pluginFeatures.pluginFeaturesAdminPaths.post.update,
|
|
76
|
+
{ method: "POST", body: payload }
|
|
77
|
+
);
|
|
78
|
+
const pluginFeatureKeys = {
|
|
79
|
+
all: ["plugin-features"],
|
|
80
|
+
list: () => [...pluginFeatureKeys.all, "list"]
|
|
81
|
+
};
|
|
82
|
+
const isConflict = (error) => typeof error === "object" && error !== null && "status" in error && error.status === 409;
|
|
83
|
+
function usePluginFeatures() {
|
|
84
|
+
return reactQuery.useQuery({
|
|
85
|
+
queryKey: pluginFeatureKeys.list(),
|
|
86
|
+
queryFn: listPluginFeatures
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function useUpdatePluginFeatures() {
|
|
90
|
+
const queryClient = reactQuery.useQueryClient();
|
|
91
|
+
return reactQuery.useMutation({
|
|
92
|
+
mutationFn: updatePluginFeatures,
|
|
93
|
+
onSuccess: ({ plugin: plugin2 }) => {
|
|
94
|
+
queryClient.setQueryData(
|
|
95
|
+
pluginFeatureKeys.list(),
|
|
96
|
+
(current) => current && {
|
|
97
|
+
plugins: current.plugins.map(
|
|
98
|
+
(entry) => entry.plugin_key === plugin2.plugin_key ? plugin2 : entry
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
ui.toast.success(texts.toasts.saved);
|
|
103
|
+
},
|
|
104
|
+
onError: async (error) => {
|
|
105
|
+
if (isConflict(error)) {
|
|
106
|
+
ui.toast.error(texts.toasts.conflict);
|
|
107
|
+
} else {
|
|
108
|
+
ui.toast.error(texts.toasts.saveFailed, {
|
|
109
|
+
description: getErrorMessage(error) ?? texts.errors.unknown
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
await queryClient.invalidateQueries({ queryKey: pluginFeatureKeys.list() });
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const configuredFeatures = (plugin2) => Object.fromEntries(
|
|
117
|
+
plugin2.features.map((feature) => [feature.key, feature.enabled])
|
|
118
|
+
);
|
|
119
|
+
const PluginFeaturesCard = ({ plugin: plugin2 }) => {
|
|
120
|
+
const mutation = useUpdatePluginFeatures();
|
|
121
|
+
const pending = mutation.isPending;
|
|
122
|
+
const labels = new Map(
|
|
123
|
+
plugin2.features.map((feature) => [feature.key, feature.label])
|
|
124
|
+
);
|
|
125
|
+
const configured = configuredFeatures(plugin2);
|
|
126
|
+
const pluginSwitchId = `plugin-features-${plugin2.plugin_key}`;
|
|
127
|
+
const save = (enabled, features) => {
|
|
128
|
+
mutation.mutate({
|
|
129
|
+
plugin_key: plugin2.plugin_key,
|
|
130
|
+
expected_version: plugin2.version,
|
|
131
|
+
enabled,
|
|
132
|
+
features
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "divide-y p-0", "aria-busy": pending, children: [
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4 px-6 py-4", children: [
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
|
|
138
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: plugin2.label }),
|
|
139
|
+
plugin2.description && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: plugin2.description }),
|
|
140
|
+
!plugin2.enabled && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted mt-1", children: texts.hints.pluginDisabled }),
|
|
141
|
+
pending && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted mt-1", children: texts.hints.saving })
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
144
|
+
ui.Switch,
|
|
145
|
+
{
|
|
146
|
+
id: pluginSwitchId,
|
|
147
|
+
"aria-label": texts.plugin.switchLabel(plugin2.label),
|
|
148
|
+
className: "shrink-0",
|
|
149
|
+
checked: plugin2.enabled,
|
|
150
|
+
disabled: pending,
|
|
151
|
+
onCheckedChange: (checked) => save(checked === true, configured)
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
] }),
|
|
155
|
+
plugin2.features.map((feature) => {
|
|
156
|
+
const switchId = `${pluginSwitchId}-${feature.key}`;
|
|
157
|
+
const parent = plugin2.features.find(
|
|
158
|
+
(candidate) => candidate.key === feature.parent_key
|
|
159
|
+
);
|
|
160
|
+
const parentOff = parent !== void 0 && !parent.enabled;
|
|
161
|
+
const locked = pending || !plugin2.enabled || parentOff;
|
|
162
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
163
|
+
"div",
|
|
164
|
+
{
|
|
165
|
+
className: `flex items-start justify-between gap-4 py-3 pr-6 ${feature.parent_key ? "pl-12" : "pl-6"}`,
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
|
|
168
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
169
|
+
ui.Label,
|
|
170
|
+
{
|
|
171
|
+
htmlFor: switchId,
|
|
172
|
+
size: "small",
|
|
173
|
+
weight: "plus",
|
|
174
|
+
className: locked ? "text-ui-fg-disabled" : void 0,
|
|
175
|
+
children: feature.label
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
feature.description && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: feature.description }),
|
|
179
|
+
plugin2.enabled && parentOff && feature.parent_key && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted mt-1", children: texts.hints.parentDisabled(
|
|
180
|
+
labels.get(feature.parent_key) ?? feature.parent_key
|
|
181
|
+
) })
|
|
182
|
+
] }),
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
184
|
+
ui.Switch,
|
|
185
|
+
{
|
|
186
|
+
id: switchId,
|
|
187
|
+
className: "shrink-0",
|
|
188
|
+
checked: feature.enabled,
|
|
189
|
+
disabled: locked,
|
|
190
|
+
onCheckedChange: (checked) => save(plugin2.enabled, {
|
|
191
|
+
...configured,
|
|
192
|
+
[feature.key]: checked === true
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
feature.key
|
|
199
|
+
);
|
|
200
|
+
})
|
|
201
|
+
] });
|
|
202
|
+
};
|
|
203
|
+
const PluginFeaturesSettingsPage = () => {
|
|
204
|
+
const query = usePluginFeatures();
|
|
205
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-3", children: [
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "px-6 py-4", children: [
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: texts.page.title }),
|
|
208
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", children: texts.page.description })
|
|
209
|
+
] }),
|
|
210
|
+
query.isPending ? /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", children: texts.states.loading }) }) : query.isError ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex flex-wrap items-center justify-between gap-3", children: [
|
|
211
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-error", children: texts.states.error }),
|
|
212
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
213
|
+
ui.Button,
|
|
214
|
+
{
|
|
215
|
+
size: "small",
|
|
216
|
+
variant: "secondary",
|
|
217
|
+
isLoading: query.isFetching,
|
|
218
|
+
onClick: () => void query.refetch(),
|
|
219
|
+
children: texts.states.retry
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
] }) : query.data.plugins.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", children: texts.states.empty }) }) : query.data.plugins.map((plugin2) => /* @__PURE__ */ jsxRuntime.jsx(PluginFeaturesCard, { plugin: plugin2 }, plugin2.plugin_key))
|
|
223
|
+
] });
|
|
224
|
+
};
|
|
225
|
+
const config = adminSdk.defineRouteConfig({
|
|
226
|
+
label: texts.menu.label
|
|
227
|
+
});
|
|
228
|
+
const widgetModule = { widgets: [] };
|
|
229
|
+
const routeModule = {
|
|
230
|
+
routes: [
|
|
231
|
+
{
|
|
232
|
+
Component: PluginFeaturesSettingsPage,
|
|
233
|
+
path: "/settings/hartl-services",
|
|
234
|
+
handle: { label: config.label, translationNs: config.translationNs }
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
};
|
|
238
|
+
const menuItemModule = {
|
|
239
|
+
menuItems: [
|
|
240
|
+
{
|
|
241
|
+
label: config.label,
|
|
242
|
+
icon: void 0,
|
|
243
|
+
path: "/settings/hartl-services",
|
|
244
|
+
nested: void 0,
|
|
245
|
+
rank: void 0,
|
|
246
|
+
translationNs: void 0
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
};
|
|
250
|
+
const formModule = { customFields: {} };
|
|
251
|
+
const displayModule = {
|
|
252
|
+
displays: {}
|
|
253
|
+
};
|
|
254
|
+
const i18nModule = { resources: {} };
|
|
255
|
+
const cellRendererModule = {};
|
|
256
|
+
const layoutModule = { layouts: [] };
|
|
257
|
+
const plugin = {
|
|
258
|
+
widgetModule,
|
|
259
|
+
routeModule,
|
|
260
|
+
menuItemModule,
|
|
261
|
+
formModule,
|
|
262
|
+
displayModule,
|
|
263
|
+
i18nModule,
|
|
264
|
+
cellRendererModule,
|
|
265
|
+
layoutModule
|
|
266
|
+
};
|
|
267
|
+
module.exports = plugin;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { defineRouteConfig } from "@medusajs/admin-sdk";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { toast, Container, Heading, Text, Switch, Label, Button } from "@medusajs/ui";
|
|
4
|
+
import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query";
|
|
5
|
+
import { pluginFeaturesAdminPaths } from "@hartl-services/medusa-food-supplements-contracts/paths/plugin-features";
|
|
6
|
+
import Medusa from "@medusajs/js-sdk";
|
|
7
|
+
const texts = {
|
|
8
|
+
menu: {
|
|
9
|
+
label: "Hartl Services Plugins"
|
|
10
|
+
},
|
|
11
|
+
page: {
|
|
12
|
+
title: "Hartl Services Plugins",
|
|
13
|
+
description: "Plugins und einzelne Funktionen ein- oder ausschalten. Änderungen gelten sofort; abgeschaltete Funktionen sind im Shop nicht erreichbar."
|
|
14
|
+
},
|
|
15
|
+
states: {
|
|
16
|
+
loading: "Funktionsschalter werden geladen…",
|
|
17
|
+
error: "Funktionsschalter konnten nicht geladen werden.",
|
|
18
|
+
empty: "Keine Plugins mit Funktionsschaltern installiert.",
|
|
19
|
+
retry: "Erneut laden"
|
|
20
|
+
},
|
|
21
|
+
plugin: {
|
|
22
|
+
switchLabel: (label) => `${label} aktiv`
|
|
23
|
+
},
|
|
24
|
+
hints: {
|
|
25
|
+
pluginDisabled: "Das Plugin ist ausgeschaltet. Alle Funktionen sind inaktiv, ihre Einstellungen bleiben erhalten.",
|
|
26
|
+
parentDisabled: (parentLabel) => `Inaktiv, solange „${parentLabel}“ ausgeschaltet ist.`,
|
|
27
|
+
saving: "Wird gespeichert…"
|
|
28
|
+
},
|
|
29
|
+
toasts: {
|
|
30
|
+
saved: "Einstellung wurde gespeichert.",
|
|
31
|
+
saveFailed: "Einstellung konnte nicht gespeichert werden.",
|
|
32
|
+
conflict: "Die Einstellungen wurden zwischenzeitlich geändert und neu geladen."
|
|
33
|
+
},
|
|
34
|
+
errors: {
|
|
35
|
+
unknown: "Unbekannter Fehler"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const getErrorMessage = (error) => {
|
|
39
|
+
if (error instanceof Error && error.message) {
|
|
40
|
+
return error.message;
|
|
41
|
+
}
|
|
42
|
+
if (typeof error !== "object" || error === null) {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
const candidate = error;
|
|
46
|
+
for (const value of [
|
|
47
|
+
candidate.response?.data?.message,
|
|
48
|
+
candidate.response?.data?.error,
|
|
49
|
+
candidate.body?.message,
|
|
50
|
+
candidate.body?.error,
|
|
51
|
+
candidate.message,
|
|
52
|
+
candidate.statusText
|
|
53
|
+
]) {
|
|
54
|
+
if (typeof value === "string" && value.trim()) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return void 0;
|
|
59
|
+
};
|
|
60
|
+
const sdk = new Medusa({
|
|
61
|
+
baseUrl: __BACKEND_URL__ ?? "/",
|
|
62
|
+
auth: {
|
|
63
|
+
type: __AUTH_TYPE__ ?? "session",
|
|
64
|
+
jwtTokenStorageKey: __JWT_TOKEN_STORAGE_KEY__ || void 0
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const listPluginFeatures = () => sdk.client.fetch(
|
|
68
|
+
pluginFeaturesAdminPaths.get.list,
|
|
69
|
+
{ method: "GET" }
|
|
70
|
+
);
|
|
71
|
+
const updatePluginFeatures = (payload) => sdk.client.fetch(
|
|
72
|
+
pluginFeaturesAdminPaths.post.update,
|
|
73
|
+
{ method: "POST", body: payload }
|
|
74
|
+
);
|
|
75
|
+
const pluginFeatureKeys = {
|
|
76
|
+
all: ["plugin-features"],
|
|
77
|
+
list: () => [...pluginFeatureKeys.all, "list"]
|
|
78
|
+
};
|
|
79
|
+
const isConflict = (error) => typeof error === "object" && error !== null && "status" in error && error.status === 409;
|
|
80
|
+
function usePluginFeatures() {
|
|
81
|
+
return useQuery({
|
|
82
|
+
queryKey: pluginFeatureKeys.list(),
|
|
83
|
+
queryFn: listPluginFeatures
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function useUpdatePluginFeatures() {
|
|
87
|
+
const queryClient = useQueryClient();
|
|
88
|
+
return useMutation({
|
|
89
|
+
mutationFn: updatePluginFeatures,
|
|
90
|
+
onSuccess: ({ plugin: plugin2 }) => {
|
|
91
|
+
queryClient.setQueryData(
|
|
92
|
+
pluginFeatureKeys.list(),
|
|
93
|
+
(current) => current && {
|
|
94
|
+
plugins: current.plugins.map(
|
|
95
|
+
(entry) => entry.plugin_key === plugin2.plugin_key ? plugin2 : entry
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
toast.success(texts.toasts.saved);
|
|
100
|
+
},
|
|
101
|
+
onError: async (error) => {
|
|
102
|
+
if (isConflict(error)) {
|
|
103
|
+
toast.error(texts.toasts.conflict);
|
|
104
|
+
} else {
|
|
105
|
+
toast.error(texts.toasts.saveFailed, {
|
|
106
|
+
description: getErrorMessage(error) ?? texts.errors.unknown
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
await queryClient.invalidateQueries({ queryKey: pluginFeatureKeys.list() });
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const configuredFeatures = (plugin2) => Object.fromEntries(
|
|
114
|
+
plugin2.features.map((feature) => [feature.key, feature.enabled])
|
|
115
|
+
);
|
|
116
|
+
const PluginFeaturesCard = ({ plugin: plugin2 }) => {
|
|
117
|
+
const mutation = useUpdatePluginFeatures();
|
|
118
|
+
const pending = mutation.isPending;
|
|
119
|
+
const labels = new Map(
|
|
120
|
+
plugin2.features.map((feature) => [feature.key, feature.label])
|
|
121
|
+
);
|
|
122
|
+
const configured = configuredFeatures(plugin2);
|
|
123
|
+
const pluginSwitchId = `plugin-features-${plugin2.plugin_key}`;
|
|
124
|
+
const save = (enabled, features) => {
|
|
125
|
+
mutation.mutate({
|
|
126
|
+
plugin_key: plugin2.plugin_key,
|
|
127
|
+
expected_version: plugin2.version,
|
|
128
|
+
enabled,
|
|
129
|
+
features
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", "aria-busy": pending, children: [
|
|
133
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4 px-6 py-4", children: [
|
|
134
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
135
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: plugin2.label }),
|
|
136
|
+
plugin2.description && /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: plugin2.description }),
|
|
137
|
+
!plugin2.enabled && /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted mt-1", children: texts.hints.pluginDisabled }),
|
|
138
|
+
pending && /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted mt-1", children: texts.hints.saving })
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
Switch,
|
|
142
|
+
{
|
|
143
|
+
id: pluginSwitchId,
|
|
144
|
+
"aria-label": texts.plugin.switchLabel(plugin2.label),
|
|
145
|
+
className: "shrink-0",
|
|
146
|
+
checked: plugin2.enabled,
|
|
147
|
+
disabled: pending,
|
|
148
|
+
onCheckedChange: (checked) => save(checked === true, configured)
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] }),
|
|
152
|
+
plugin2.features.map((feature) => {
|
|
153
|
+
const switchId = `${pluginSwitchId}-${feature.key}`;
|
|
154
|
+
const parent = plugin2.features.find(
|
|
155
|
+
(candidate) => candidate.key === feature.parent_key
|
|
156
|
+
);
|
|
157
|
+
const parentOff = parent !== void 0 && !parent.enabled;
|
|
158
|
+
const locked = pending || !plugin2.enabled || parentOff;
|
|
159
|
+
return /* @__PURE__ */ jsxs(
|
|
160
|
+
"div",
|
|
161
|
+
{
|
|
162
|
+
className: `flex items-start justify-between gap-4 py-3 pr-6 ${feature.parent_key ? "pl-12" : "pl-6"}`,
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
Label,
|
|
167
|
+
{
|
|
168
|
+
htmlFor: switchId,
|
|
169
|
+
size: "small",
|
|
170
|
+
weight: "plus",
|
|
171
|
+
className: locked ? "text-ui-fg-disabled" : void 0,
|
|
172
|
+
children: feature.label
|
|
173
|
+
}
|
|
174
|
+
),
|
|
175
|
+
feature.description && /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: feature.description }),
|
|
176
|
+
plugin2.enabled && parentOff && feature.parent_key && /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted mt-1", children: texts.hints.parentDisabled(
|
|
177
|
+
labels.get(feature.parent_key) ?? feature.parent_key
|
|
178
|
+
) })
|
|
179
|
+
] }),
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
Switch,
|
|
182
|
+
{
|
|
183
|
+
id: switchId,
|
|
184
|
+
className: "shrink-0",
|
|
185
|
+
checked: feature.enabled,
|
|
186
|
+
disabled: locked,
|
|
187
|
+
onCheckedChange: (checked) => save(plugin2.enabled, {
|
|
188
|
+
...configured,
|
|
189
|
+
[feature.key]: checked === true
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
)
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
feature.key
|
|
196
|
+
);
|
|
197
|
+
})
|
|
198
|
+
] });
|
|
199
|
+
};
|
|
200
|
+
const PluginFeaturesSettingsPage = () => {
|
|
201
|
+
const query = usePluginFeatures();
|
|
202
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-3", children: [
|
|
203
|
+
/* @__PURE__ */ jsxs(Container, { className: "px-6 py-4", children: [
|
|
204
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: texts.page.title }),
|
|
205
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.page.description })
|
|
206
|
+
] }),
|
|
207
|
+
query.isPending ? /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.states.loading }) }) : query.isError ? /* @__PURE__ */ jsxs(Container, { className: "flex flex-wrap items-center justify-between gap-3", children: [
|
|
208
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: texts.states.error }),
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
Button,
|
|
211
|
+
{
|
|
212
|
+
size: "small",
|
|
213
|
+
variant: "secondary",
|
|
214
|
+
isLoading: query.isFetching,
|
|
215
|
+
onClick: () => void query.refetch(),
|
|
216
|
+
children: texts.states.retry
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
] }) : query.data.plugins.length === 0 ? /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.states.empty }) }) : query.data.plugins.map((plugin2) => /* @__PURE__ */ jsx(PluginFeaturesCard, { plugin: plugin2 }, plugin2.plugin_key))
|
|
220
|
+
] });
|
|
221
|
+
};
|
|
222
|
+
const config = defineRouteConfig({
|
|
223
|
+
label: texts.menu.label
|
|
224
|
+
});
|
|
225
|
+
const widgetModule = { widgets: [] };
|
|
226
|
+
const routeModule = {
|
|
227
|
+
routes: [
|
|
228
|
+
{
|
|
229
|
+
Component: PluginFeaturesSettingsPage,
|
|
230
|
+
path: "/settings/hartl-services",
|
|
231
|
+
handle: { label: config.label, translationNs: config.translationNs }
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
};
|
|
235
|
+
const menuItemModule = {
|
|
236
|
+
menuItems: [
|
|
237
|
+
{
|
|
238
|
+
label: config.label,
|
|
239
|
+
icon: void 0,
|
|
240
|
+
path: "/settings/hartl-services",
|
|
241
|
+
nested: void 0,
|
|
242
|
+
rank: void 0,
|
|
243
|
+
translationNs: void 0
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
};
|
|
247
|
+
const formModule = { customFields: {} };
|
|
248
|
+
const displayModule = {
|
|
249
|
+
displays: {}
|
|
250
|
+
};
|
|
251
|
+
const i18nModule = { resources: {} };
|
|
252
|
+
const cellRendererModule = {};
|
|
253
|
+
const layoutModule = { layouts: [] };
|
|
254
|
+
const plugin = {
|
|
255
|
+
widgetModule,
|
|
256
|
+
routeModule,
|
|
257
|
+
menuItemModule,
|
|
258
|
+
formModule,
|
|
259
|
+
displayModule,
|
|
260
|
+
i18nModule,
|
|
261
|
+
cellRendererModule,
|
|
262
|
+
layoutModule
|
|
263
|
+
};
|
|
264
|
+
export {
|
|
265
|
+
plugin as default
|
|
266
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.POST = exports.GET = void 0;
|
|
4
|
+
const plugin_features_1 = require("@hartl-services/medusa-food-supplements-contracts/schemas/plugin-features");
|
|
5
|
+
const plugin_features_http_1 = require("../../plugin-features-http");
|
|
6
|
+
const wire_response_1 = require("../../wire-response");
|
|
7
|
+
const GET = async (req, res) => {
|
|
8
|
+
const service = (0, plugin_features_http_1.resolvePluginFeaturesService)(req.scope);
|
|
9
|
+
const plugins = await Promise.all((0, plugin_features_http_1.listPluginFeatureDescriptors)(req.scope).map((descriptor) => service.describePluginFeatures(descriptor)));
|
|
10
|
+
res.json((0, wire_response_1.toWireResponse)(plugin_features_1.AdminPluginFeaturesListResponseSchema, { plugins }));
|
|
11
|
+
};
|
|
12
|
+
exports.GET = GET;
|
|
13
|
+
const POST = async (req, res) => {
|
|
14
|
+
const { plugin_key, ...input } = req.validatedBody;
|
|
15
|
+
const descriptor = (0, plugin_features_http_1.requirePluginFeatureDescriptor)(req.scope, plugin_key);
|
|
16
|
+
const plugin = await (0, plugin_features_http_1.resolvePluginFeaturesService)(req.scope).updatePluginFeatures(descriptor, input);
|
|
17
|
+
res.json((0, wire_response_1.toWireResponse)(plugin_features_1.AdminPluginFeaturesResponseSchema, { plugin }));
|
|
18
|
+
};
|
|
19
|
+
exports.POST = POST;
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91dGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvYXBpL2FkbWluL3BsdWdpbi1mZWF0dXJlcy9yb3V0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFLQSwrR0FJa0Y7QUFNbEYscUVBSW1DO0FBQ25DLHVEQUFvRDtBQUk3QyxNQUFNLEdBQUcsR0FBRyxLQUFLLEVBQ3RCLEdBQStCLEVBQy9CLEdBQW9ELEVBQ3BELEVBQUU7SUFDRixNQUFNLE9BQU8sR0FBRyxJQUFBLG1EQUE0QixFQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQTtJQUN2RCxNQUFNLE9BQU8sR0FBRyxNQUFNLE9BQU8sQ0FBQyxHQUFHLENBQy9CLElBQUEsbURBQTRCLEVBQUMsR0FBRyxDQUFDLEtBQUssQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLFVBQVUsRUFBRSxFQUFFLENBQ3pELE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxVQUFVLENBQUMsQ0FDM0MsQ0FDRixDQUFBO0lBQ0QsR0FBRyxDQUFDLElBQUksQ0FBQyxJQUFBLDhCQUFjLEVBQUMsdURBQXFDLEVBQUUsRUFBRSxPQUFPLEVBQUUsQ0FBQyxDQUFDLENBQUE7QUFDOUUsQ0FBQyxDQUFBO0FBWFksUUFBQSxHQUFHLE9BV2Y7QUFFTSxNQUFNLElBQUksR0FBRyxLQUFLLEVBQ3ZCLEdBQTJDLEVBQzNDLEdBQWdELEVBQ2hELEVBQUU7SUFDRixNQUFNLEVBQUUsVUFBVSxFQUFFLEdBQUcsS0FBSyxFQUFFLEdBQUcsR0FBRyxDQUFDLGFBQWEsQ0FBQTtJQUNsRCxNQUFNLFVBQVUsR0FBRyxJQUFBLHFEQUE4QixFQUFDLEdBQUcsQ0FBQyxLQUFLLEVBQUUsVUFBVSxDQUFDLENBQUE7SUFDeEUsTUFBTSxNQUFNLEdBQUcsTUFBTSxJQUFBLG1EQUE0QixFQUMvQyxHQUFHLENBQUMsS0FBSyxDQUNWLENBQUMsb0JBQW9CLENBQUMsVUFBVSxFQUFFLEtBQUssQ0FBQyxDQUFBO0lBQ3pDLEdBQUcsQ0FBQyxJQUFJLENBQUMsSUFBQSw4QkFBYyxFQUFDLG1EQUFpQyxFQUFFLEVBQUUsTUFBTSxFQUFFLENBQUMsQ0FBQyxDQUFBO0FBQ3pFLENBQUMsQ0FBQTtBQVZZLFFBQUEsSUFBSSxRQVVoQiJ9
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const http_1 = require("@medusajs/framework/http");
|
|
4
|
+
const plugin_features_1 = require("@hartl-services/medusa-food-supplements-contracts/schemas/plugin-features");
|
|
5
|
+
// Store GETs need nothing beyond Medusa's publishable-key check on /store.
|
|
6
|
+
// Every authenticated Admin user may read and change the toggles (no RBAC by
|
|
7
|
+
// design).
|
|
8
|
+
exports.default = (0, http_1.defineMiddlewares)({
|
|
9
|
+
routes: [
|
|
10
|
+
{
|
|
11
|
+
matcher: "/admin/plugin-features",
|
|
12
|
+
methods: ["GET"],
|
|
13
|
+
middlewares: [(0, http_1.authenticate)("user", ["session", "bearer"])],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
matcher: "/admin/plugin-features",
|
|
17
|
+
methods: ["POST"],
|
|
18
|
+
middlewares: [
|
|
19
|
+
(0, http_1.authenticate)("user", ["session", "bearer"]),
|
|
20
|
+
(0, http_1.validateAndTransformBody)(plugin_features_1.UpdatePluginFeaturesSchema),
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlkZGxld2FyZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBpL21pZGRsZXdhcmVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsbURBSWlDO0FBQ2pDLCtHQUFzSDtBQUV0SCwyRUFBMkU7QUFDM0UsNkVBQTZFO0FBQzdFLFdBQVc7QUFDWCxrQkFBZSxJQUFBLHdCQUFpQixFQUFDO0lBQy9CLE1BQU0sRUFBRTtRQUNOO1lBQ0UsT0FBTyxFQUFFLHdCQUF3QjtZQUNqQyxPQUFPLEVBQUUsQ0FBQyxLQUFLLENBQUM7WUFDaEIsV0FBVyxFQUFFLENBQUMsSUFBQSxtQkFBWSxFQUFDLE1BQU0sRUFBRSxDQUFDLFNBQVMsRUFBRSxRQUFRLENBQUMsQ0FBQyxDQUFDO1NBQzNEO1FBQ0Q7WUFDRSxPQUFPLEVBQUUsd0JBQXdCO1lBQ2pDLE9BQU8sRUFBRSxDQUFDLE1BQU0sQ0FBQztZQUNqQixXQUFXLEVBQUU7Z0JBQ1gsSUFBQSxtQkFBWSxFQUFDLE1BQU0sRUFBRSxDQUFDLFNBQVMsRUFBRSxRQUFRLENBQUMsQ0FBQztnQkFDM0MsSUFBQSwrQkFBd0IsRUFBQyw0Q0FBMEIsQ0FBQzthQUNyRDtTQUNGO0tBQ0Y7Q0FDRixDQUFDLENBQUEifQ==
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requirePluginFeatureDescriptor = exports.listPluginFeatureDescriptors = exports.resolvePluginFeaturesService = void 0;
|
|
4
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
5
|
+
const constants_1 = require("../public/constants");
|
|
6
|
+
const discover_plugin_features_1 = require("../utils/discover-plugin-features");
|
|
7
|
+
const resolvePluginFeaturesService = (container) => container.resolve(constants_1.PLUGIN_FEATURES_MODULE);
|
|
8
|
+
exports.resolvePluginFeaturesService = resolvePluginFeaturesService;
|
|
9
|
+
const listPluginFeatureDescriptors = (container) => (0, discover_plugin_features_1.discoverPluginFeatureDescriptors)(container);
|
|
10
|
+
exports.listPluginFeatureDescriptors = listPluginFeatureDescriptors;
|
|
11
|
+
/** Descriptor of an installed plugin; `NOT_FOUND` for an unknown key. */
|
|
12
|
+
const requirePluginFeatureDescriptor = (container, pluginKey) => {
|
|
13
|
+
const descriptor = (0, discover_plugin_features_1.findPluginFeatureDescriptor)(container, pluginKey);
|
|
14
|
+
if (!descriptor) {
|
|
15
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `Plugin "${pluginKey}" hat keine Funktionsschalter.`);
|
|
16
|
+
}
|
|
17
|
+
return descriptor;
|
|
18
|
+
};
|
|
19
|
+
exports.requirePluginFeatureDescriptor = requirePluginFeatureDescriptor;
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2luLWZlYXR1cmVzLWh0dHAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBpL3BsdWdpbi1mZWF0dXJlcy1odHRwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLHFEQUF1RDtBQUV2RCxtREFBNEQ7QUFHNUQsZ0ZBRzBDO0FBRW5DLE1BQU0sNEJBQTRCLEdBQUcsQ0FDMUMsU0FBMEIsRUFDRyxFQUFFLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxrQ0FBc0IsQ0FBQyxDQUFBO0FBRjlELFFBQUEsNEJBQTRCLGdDQUVrQztBQUVwRSxNQUFNLDRCQUE0QixHQUFHLENBQzFDLFNBQTBCLEVBQ0MsRUFBRSxDQUFDLElBQUEsMkRBQWdDLEVBQUMsU0FBUyxDQUFDLENBQUE7QUFGOUQsUUFBQSw0QkFBNEIsZ0NBRWtDO0FBRTNFLHlFQUF5RTtBQUNsRSxNQUFNLDhCQUE4QixHQUFHLENBQzVDLFNBQTBCLEVBQzFCLFNBQWlCLEVBQ1EsRUFBRTtJQUMzQixNQUFNLFVBQVUsR0FBRyxJQUFBLHNEQUEyQixFQUFDLFNBQVMsRUFBRSxTQUFTLENBQUMsQ0FBQTtJQUNwRSxJQUFJLENBQUMsVUFBVSxFQUFFLENBQUM7UUFDaEIsTUFBTSxJQUFJLG1CQUFXLENBQ25CLG1CQUFXLENBQUMsS0FBSyxDQUFDLFNBQVMsRUFDM0IsV0FBVyxTQUFTLGdDQUFnQyxDQUNyRCxDQUFBO0lBQ0gsQ0FBQztJQUNELE9BQU8sVUFBVSxDQUFBO0FBQ25CLENBQUMsQ0FBQTtBQVpZLFFBQUEsOEJBQThCLGtDQVkxQyJ9
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GET = void 0;
|
|
4
|
+
const plugin_features_1 = require("@hartl-services/medusa-food-supplements-contracts/schemas/plugin-features");
|
|
5
|
+
const plugin_features_http_1 = require("../../../plugin-features-http");
|
|
6
|
+
const wire_response_1 = require("../../../wire-response");
|
|
7
|
+
const GET = async (req, res) => {
|
|
8
|
+
const descriptor = (0, plugin_features_http_1.requirePluginFeatureDescriptor)(req.scope, String(req.params.plugin_key));
|
|
9
|
+
const plugin = await (0, plugin_features_http_1.resolvePluginFeaturesService)(req.scope).retrieveEffectiveFeatures(descriptor);
|
|
10
|
+
res.json((0, wire_response_1.toWireResponse)(plugin_features_1.StorePluginFeaturesResponseSchema, { plugin }));
|
|
11
|
+
};
|
|
12
|
+
exports.GET = GET;
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91dGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvYXBpL3N0b3JlL3BsdWdpbi1mZWF0dXJlcy9bcGx1Z2luX2tleV0vcm91dGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsK0dBQTZIO0FBRzdILHdFQUdzQztBQUN0QywwREFBdUQ7QUFFaEQsTUFBTSxHQUFHLEdBQUcsS0FBSyxFQUN0QixHQUFrQixFQUNsQixHQUFnRCxFQUNoRCxFQUFFO0lBQ0YsTUFBTSxVQUFVLEdBQUcsSUFBQSxxREFBOEIsRUFDL0MsR0FBRyxDQUFDLEtBQUssRUFDVCxNQUFNLENBQUMsR0FBRyxDQUFDLE1BQU0sQ0FBQyxVQUFVLENBQUMsQ0FDOUIsQ0FBQTtJQUNELE1BQU0sTUFBTSxHQUNWLE1BQU0sSUFBQSxtREFBNEIsRUFBQyxHQUFHLENBQUMsS0FBSyxDQUFDLENBQUMseUJBQXlCLENBQ3JFLFVBQVUsQ0FDWCxDQUFBO0lBQ0gsR0FBRyxDQUFDLElBQUksQ0FBQyxJQUFBLDhCQUFjLEVBQUMsbURBQWlDLEVBQUUsRUFBRSxNQUFNLEVBQUUsQ0FBQyxDQUFDLENBQUE7QUFDekUsQ0FBQyxDQUFBO0FBYlksUUFBQSxHQUFHLE9BYWYifQ==
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GET = void 0;
|
|
4
|
+
const plugin_features_1 = require("@hartl-services/medusa-food-supplements-contracts/schemas/plugin-features");
|
|
5
|
+
const plugin_features_http_1 = require("../../plugin-features-http");
|
|
6
|
+
const wire_response_1 = require("../../wire-response");
|
|
7
|
+
const GET = async (req, res) => {
|
|
8
|
+
const service = (0, plugin_features_http_1.resolvePluginFeaturesService)(req.scope);
|
|
9
|
+
const plugins = await Promise.all((0, plugin_features_http_1.listPluginFeatureDescriptors)(req.scope).map((descriptor) => service.retrieveEffectiveFeatures(descriptor)));
|
|
10
|
+
res.json((0, wire_response_1.toWireResponse)(plugin_features_1.StorePluginFeaturesListResponseSchema, { plugins }));
|
|
11
|
+
};
|
|
12
|
+
exports.GET = GET;
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91dGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvYXBpL3N0b3JlL3BsdWdpbi1mZWF0dXJlcy9yb3V0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFDQSwrR0FBaUk7QUFHakkscUVBR21DO0FBQ25DLHVEQUFvRDtBQUU3QyxNQUFNLEdBQUcsR0FBRyxLQUFLLEVBQ3RCLEdBQWtCLEVBQ2xCLEdBQW9ELEVBQ3BELEVBQUU7SUFDRixNQUFNLE9BQU8sR0FBRyxJQUFBLG1EQUE0QixFQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQTtJQUN2RCxNQUFNLE9BQU8sR0FBRyxNQUFNLE9BQU8sQ0FBQyxHQUFHLENBQy9CLElBQUEsbURBQTRCLEVBQUMsR0FBRyxDQUFDLEtBQUssQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLFVBQVUsRUFBRSxFQUFFLENBQ3pELE9BQU8sQ0FBQyx5QkFBeUIsQ0FBQyxVQUFVLENBQUMsQ0FDOUMsQ0FDRixDQUFBO0lBQ0QsR0FBRyxDQUFDLElBQUksQ0FBQyxJQUFBLDhCQUFjLEVBQUMsdURBQXFDLEVBQUUsRUFBRSxPQUFPLEVBQUUsQ0FBQyxDQUFDLENBQUE7QUFDOUUsQ0FBQyxDQUFBO0FBWFksUUFBQSxHQUFHLE9BV2YifQ==
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toWireResponse = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Serializes module values exactly as HTTP JSON does, then validates and strips
|
|
6
|
+
* fields that aren't part of the deliberate public response contract.
|
|
7
|
+
*/
|
|
8
|
+
const toWireResponse = (schema, value) => schema.parse(JSON.parse(JSON.stringify(value)));
|
|
9
|
+
exports.toWireResponse = toWireResponse;
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2lyZS1yZXNwb25zZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcGkvd2lyZS1yZXNwb25zZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQTs7O0dBR0c7QUFDSSxNQUFNLGNBQWMsR0FBRyxDQUM1QixNQUFlLEVBQ2YsS0FBYyxFQUNJLEVBQUUsQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUE7QUFIekQsUUFBQSxjQUFjLGtCQUcyQyJ9
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PLUGIN_FEATURES_MODULE = void 0;
|
|
7
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
8
|
+
const constants_1 = require("../../public/constants");
|
|
9
|
+
Object.defineProperty(exports, "PLUGIN_FEATURES_MODULE", { enumerable: true, get: function () { return constants_1.PLUGIN_FEATURES_MODULE; } });
|
|
10
|
+
const service_1 = __importDefault(require("./service"));
|
|
11
|
+
exports.default = (0, utils_1.Module)(constants_1.PLUGIN_FEATURES_MODULE, {
|
|
12
|
+
service: service_1.default,
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9wbHVnaW4tZmVhdHVyZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEscURBQWtEO0FBRWxELHNEQUErRDtBQUd0RCx1R0FIQSxrQ0FBc0IsT0FHQTtBQUYvQix3REFBbUQ7QUFJbkQsa0JBQWUsSUFBQSxjQUFNLEVBQUMsa0NBQXNCLEVBQUU7SUFDNUMsT0FBTyxFQUFFLGlCQUEyQjtDQUNyQyxDQUFDLENBQUEifQ==
|