@sensinum/strapi-plugin-multi-domain 5.1.1
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/LICENSE.md +7 -0
- package/README.md +250 -0
- package/dist/_chunks/QueryProvider-DLzv0qqi.mjs +20 -0
- package/dist/_chunks/QueryProvider-DUoM4JhC.js +1 -0
- package/dist/_chunks/Settings-BPM919an.mjs +23 -0
- package/dist/_chunks/Settings-CT4xmD8_.js +1 -0
- package/dist/_chunks/TenantCustomField-BYDxTP5y.js +1 -0
- package/dist/_chunks/TenantCustomField-CtCNZEgB.mjs +93 -0
- package/dist/_chunks/TenantEdit-BdSUNboL.mjs +494 -0
- package/dist/_chunks/TenantEdit-C4LHKCAr.js +1 -0
- package/dist/_chunks/TenantList-Cl9445sU.js +1 -0
- package/dist/_chunks/TenantList-DWA0Z3-T.mjs +272 -0
- package/dist/_chunks/en-BIUQvQi4.mjs +104 -0
- package/dist/_chunks/en-Dj_hyppO.js +1 -0
- package/dist/_chunks/index-Ck1YIRr4.js +1 -0
- package/dist/_chunks/index-D9I-QR8y.js +1 -0
- package/dist/_chunks/index-DkEjJa1n.mjs +182 -0
- package/dist/_chunks/index-Ds2z-yoa.mjs +315 -0
- package/dist/_chunks/useTenants-CE8J0EOu.mjs +93 -0
- package/dist/_chunks/useTenants-XMURO_eU.js +1 -0
- package/dist/admin/index.js +1 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/server/index.js +4 -0
- package/dist/server/index.mjs +6249 -0
- package/dist/shared/config.d.ts +7 -0
- package/dist/shared/config.d.ts.map +1 -0
- package/dist/shared/permissions.d.ts +35 -0
- package/dist/shared/permissions.d.ts.map +1 -0
- package/dist/shared/pluginIds.d.ts +9 -0
- package/dist/shared/pluginIds.d.ts.map +1 -0
- package/dist/shared/schemas/admin.d.ts +26 -0
- package/dist/shared/schemas/admin.d.ts.map +1 -0
- package/dist/shared/schemas/index.d.ts +8 -0
- package/dist/shared/schemas/index.d.ts.map +1 -0
- package/dist/shared/schemas/permision.schema.d.ts +28 -0
- package/dist/shared/schemas/permision.schema.d.ts.map +1 -0
- package/dist/shared/schemas/query-params.schema.d.ts +19 -0
- package/dist/shared/schemas/query-params.schema.d.ts.map +1 -0
- package/dist/shared/schemas/role.schema.d.ts +101 -0
- package/dist/shared/schemas/role.schema.d.ts.map +1 -0
- package/dist/shared/schemas/tenant.schema.d.ts +428 -0
- package/dist/shared/schemas/tenant.schema.d.ts.map +1 -0
- package/dist/shared/schemas/token.schema.d.ts +13 -0
- package/dist/shared/schemas/token.schema.d.ts.map +1 -0
- package/dist/shared/schemas/uniq-validation.schema.d.ts +18 -0
- package/dist/shared/schemas/uniq-validation.schema.d.ts.map +1 -0
- package/dist/shared/schemas/utils.d.ts +3 -0
- package/dist/shared/schemas/utils.d.ts.map +1 -0
- package/package.json +116 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { toSnakeCase as Q, funnel as W } from "remeda";
|
|
2
|
+
import { z as V } from "zod";
|
|
3
|
+
import { jsx as o, jsxs as m } from "react/jsx-runtime";
|
|
4
|
+
import { unstable_useContentManagerContext as J, getFetchClient as G } from "@strapi/strapi/admin";
|
|
5
|
+
import K, { useRef as X, useEffect as Y, useState as x } from "react";
|
|
6
|
+
import { CookiesProvider as O, useCookies as R } from "react-cookie";
|
|
7
|
+
import { Avatar as M, Modal as h, Box as P, Field as L, Searchbar as Z, EmptyStateLayout as ee, Table as te, Thead as ne, Tr as k, Th as C, Typography as S, Tbody as oe, Td as T, Checkbox as ie, Button as I, DesignSystemProvider as ae, lightTheme as re, darkTheme as se } from "@strapi/design-system";
|
|
8
|
+
import { createRoot as ce } from "react-dom/client";
|
|
9
|
+
import { Search as le } from "@strapi/icons";
|
|
10
|
+
import { QueryClient as de, QueryClientProvider as ue } from "@tanstack/react-query";
|
|
11
|
+
const me = {
|
|
12
|
+
name: "multi-domain"
|
|
13
|
+
}, c = V.literal("multi-domain").parse(me.name);
|
|
14
|
+
Q(c);
|
|
15
|
+
const f = "domain", E = "domain", Oe = `${f}s`, p = "domain", D = {
|
|
16
|
+
read: "read",
|
|
17
|
+
change: "change",
|
|
18
|
+
create: "create",
|
|
19
|
+
delete: "delete"
|
|
20
|
+
}, w = (e) => `plugin::${c}.${D[e]}`, he = {
|
|
21
|
+
admin: {
|
|
22
|
+
access: Object.keys(D).map((e) => ({
|
|
23
|
+
action: w(e),
|
|
24
|
+
subject: null
|
|
25
|
+
})),
|
|
26
|
+
create: [{ action: w("create"), subject: null }],
|
|
27
|
+
edit: [{ action: w("change"), subject: null }],
|
|
28
|
+
delete: [{ action: w("delete"), subject: null }]
|
|
29
|
+
}
|
|
30
|
+
}, g = `data-${f}-initialized`, pe = "strapi-super-admin", H = (e) => e?.code === pe, fe = (e) => {
|
|
31
|
+
const t = `/admin/content-manager/collection-types/${e}/create`, n = document.querySelector(`a[href*="${t}"]`);
|
|
32
|
+
n && (n.style.display = "none");
|
|
33
|
+
}, ge = () => {
|
|
34
|
+
const [{ [p]: e }] = R([p]), t = H(e), { slug: n } = J();
|
|
35
|
+
return K.useEffect(() => {
|
|
36
|
+
(t || !e) && fe(n);
|
|
37
|
+
}, [t, e, n]), null;
|
|
38
|
+
}, ye = () => /* @__PURE__ */ o(O, { children: /* @__PURE__ */ o(ge, {}) }), we = ({ setPlugin: e }) => {
|
|
39
|
+
const t = X(e);
|
|
40
|
+
return Y(() => {
|
|
41
|
+
t.current(c);
|
|
42
|
+
}, []), null;
|
|
43
|
+
}, N = {
|
|
44
|
+
en: () => import("./en-BIUQvQi4.mjs")
|
|
45
|
+
}, B = (e, t) => {
|
|
46
|
+
if (!e)
|
|
47
|
+
throw new TypeError("Prefix can't be empty");
|
|
48
|
+
return Object.keys(t).reduce(
|
|
49
|
+
(n, i) => (n[`${e}.${i}`] = t[i], n),
|
|
50
|
+
{}
|
|
51
|
+
);
|
|
52
|
+
}, A = (e, t = "") => Object.keys(e).reduce((n, i) => {
|
|
53
|
+
const a = t.length ? `${t}.` : "";
|
|
54
|
+
return typeof e[i] == "object" && e[i] !== null && !Array.isArray(e[i]) ? Object.assign(n, A(e[i], a + i)) : n[a + i] = e[i], n;
|
|
55
|
+
}, {}), be = ({ onClose: e, userData: t }) => {
|
|
56
|
+
const [{ [p]: n }, i] = R([p]), [a, d] = x(""), [r, u] = x(n || null), l = (t[E] || []).filter(
|
|
57
|
+
(s) => s.name.toLowerCase().includes(a.toLowerCase())
|
|
58
|
+
), y = (s) => {
|
|
59
|
+
u(r?.id === s.id ? null : s);
|
|
60
|
+
}, z = () => {
|
|
61
|
+
r && (i(p, JSON.stringify(r), {
|
|
62
|
+
path: "/",
|
|
63
|
+
maxAge: 60 * 60 * 24 * 30,
|
|
64
|
+
// 30 days
|
|
65
|
+
domain: window.location.hostname
|
|
66
|
+
}), window.location.reload());
|
|
67
|
+
};
|
|
68
|
+
return console.log("Avatar", M), /* @__PURE__ */ o(h.Root, { defaultOpen: !0, onOpenChange: e, children: /* @__PURE__ */ m(h.Content, { children: [
|
|
69
|
+
/* @__PURE__ */ o(h.Header, { children: /* @__PURE__ */ o(h.Title, { children: "Select Domain" }) }),
|
|
70
|
+
/* @__PURE__ */ m(h.Body, { children: [
|
|
71
|
+
/* @__PURE__ */ o(P, { paddingBottom: 4, children: /* @__PURE__ */ m(L.Root, { name: "tenant-search", children: [
|
|
72
|
+
/* @__PURE__ */ o(L.Label, { children: "Search domains" }),
|
|
73
|
+
/* @__PURE__ */ o(
|
|
74
|
+
Z,
|
|
75
|
+
{
|
|
76
|
+
name: "tenant-search",
|
|
77
|
+
onClear: () => d(""),
|
|
78
|
+
value: a,
|
|
79
|
+
onChange: (s) => d(s.target.value),
|
|
80
|
+
placeholder: "Search domains...",
|
|
81
|
+
size: "S"
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] }) }),
|
|
85
|
+
l.length === 0 ? /* @__PURE__ */ o(
|
|
86
|
+
ee,
|
|
87
|
+
{
|
|
88
|
+
icon: /* @__PURE__ */ o(le, {}),
|
|
89
|
+
content: "No domains found matching your search criteria"
|
|
90
|
+
}
|
|
91
|
+
) : /* @__PURE__ */ o(P, { maxHeight: "400px", overflow: "auto", children: /* @__PURE__ */ m(te, { colCount: 2, rowCount: l.length + 1, children: [
|
|
92
|
+
/* @__PURE__ */ o(ne, { children: /* @__PURE__ */ m(k, { children: [
|
|
93
|
+
/* @__PURE__ */ o(C, { width: "60px", children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Select" }) }),
|
|
94
|
+
/* @__PURE__ */ o(C, { width: "40px" }),
|
|
95
|
+
/* @__PURE__ */ o(C, { children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Domain name" }) })
|
|
96
|
+
] }) }),
|
|
97
|
+
/* @__PURE__ */ o(oe, { children: l.map((s) => /* @__PURE__ */ m(k, { children: [
|
|
98
|
+
/* @__PURE__ */ o(T, { width: "60px", children: /* @__PURE__ */ o(
|
|
99
|
+
ie,
|
|
100
|
+
{
|
|
101
|
+
checked: r?.id === s.id,
|
|
102
|
+
onCheckedChange: () => y(s),
|
|
103
|
+
name: `tenant-${s.id}`
|
|
104
|
+
}
|
|
105
|
+
) }),
|
|
106
|
+
/* @__PURE__ */ o(T, { width: "40px", children: s.logo?.url && /* @__PURE__ */ o(M.Item, { src: s.logo.url, alt: s.name, preview: !1 }) }),
|
|
107
|
+
/* @__PURE__ */ o(T, { children: /* @__PURE__ */ o(S, { fontWeight: "semiBold", textColor: "neutral800", children: s.name }) })
|
|
108
|
+
] }, s.id)) })
|
|
109
|
+
] }) })
|
|
110
|
+
] }),
|
|
111
|
+
/* @__PURE__ */ m(h.Footer, { children: [
|
|
112
|
+
/* @__PURE__ */ o(h.Close, { children: /* @__PURE__ */ o(I, { onClick: e, variant: "tertiary", children: "Cancel" }) }),
|
|
113
|
+
/* @__PURE__ */ o(I, { onClick: z, disabled: !r, children: "Select domain" })
|
|
114
|
+
] })
|
|
115
|
+
] }) });
|
|
116
|
+
}, Ce = new de({
|
|
117
|
+
defaultOptions: {
|
|
118
|
+
queries: {
|
|
119
|
+
retry: !1,
|
|
120
|
+
refetchOnWindowFocus: !1
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}), Se = (e, t, n, i) => {
|
|
124
|
+
const a = ce(e), d = () => {
|
|
125
|
+
document.body.removeAttribute("style"), a.unmount(), setTimeout(() => {
|
|
126
|
+
document.body.style.pointerEvents = "auto";
|
|
127
|
+
}, 0);
|
|
128
|
+
};
|
|
129
|
+
return t.remove(), a.render(
|
|
130
|
+
/* @__PURE__ */ o(ae, { theme: i === "light" ? re : se, children: /* @__PURE__ */ o(ue, { client: Ce, children: /* @__PURE__ */ o(O, { children: /* @__PURE__ */ o(be, { onClose: d, userData: n }) }) }) })
|
|
131
|
+
);
|
|
132
|
+
}, b = (e, t) => new Promise((n, i) => {
|
|
133
|
+
const r = (u = 0) => {
|
|
134
|
+
if (u > 50) {
|
|
135
|
+
i(new Error("Button not found after 50 attempts"));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const l = (t || document).querySelector(e);
|
|
139
|
+
if (l) {
|
|
140
|
+
n(l);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
setTimeout(() => r(u + 1), 250);
|
|
144
|
+
};
|
|
145
|
+
r();
|
|
146
|
+
}), U = () => {
|
|
147
|
+
try {
|
|
148
|
+
const t = document.cookie.split(";").find((n) => n.trim().startsWith(`${p}=`));
|
|
149
|
+
if (t) {
|
|
150
|
+
const n = t.split("=").at(1);
|
|
151
|
+
if (!n)
|
|
152
|
+
return null;
|
|
153
|
+
const i = decodeURIComponent(n);
|
|
154
|
+
return JSON.parse(i);
|
|
155
|
+
}
|
|
156
|
+
} catch (e) {
|
|
157
|
+
console.error("Error parsing tenant cookie:", e);
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}, Te = (e) => {
|
|
161
|
+
const t = e.firstChild, n = t?.lastChild?.cloneNode(!0);
|
|
162
|
+
if (t && n instanceof HTMLElement) {
|
|
163
|
+
const i = n.firstChild;
|
|
164
|
+
i && n.replaceChildren(i);
|
|
165
|
+
const a = n.querySelector("span");
|
|
166
|
+
if (a) {
|
|
167
|
+
const d = U();
|
|
168
|
+
a.innerText = d ? `${f.toUpperCase()}: ${d.name}` : `No ${f} selected`;
|
|
169
|
+
}
|
|
170
|
+
n.style.paddingTop = "1rem", t.appendChild(n);
|
|
171
|
+
}
|
|
172
|
+
}, $ = async () => {
|
|
173
|
+
try {
|
|
174
|
+
const e = G(), {
|
|
175
|
+
data: { data: t }
|
|
176
|
+
} = await e.get("/admin/users/me");
|
|
177
|
+
return t;
|
|
178
|
+
} catch {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}, j = async () => {
|
|
182
|
+
const e = await $(), t = document.createElement("div");
|
|
183
|
+
document.body.appendChild(t);
|
|
184
|
+
const n = await b('nav button[aria-haspopup="menu"]'), i = "aria-expanded";
|
|
185
|
+
new MutationObserver(async (d) => {
|
|
186
|
+
if (d.some((r) => r.attributeName === i) && n.getAttribute(i) === "true") {
|
|
187
|
+
const r = await b("[data-radix-menu-content]");
|
|
188
|
+
if (!(r instanceof HTMLElement))
|
|
189
|
+
return;
|
|
190
|
+
Te(r);
|
|
191
|
+
const u = await b('[role="menuitem"]', r), l = u.cloneNode(!0);
|
|
192
|
+
if (e?.[E] && e?.[E].length > 1) {
|
|
193
|
+
if (!(l instanceof HTMLElement))
|
|
194
|
+
return;
|
|
195
|
+
l.querySelector("span").innerText = `Select ${f}`, l.addEventListener("mouseenter", function() {
|
|
196
|
+
this.setAttribute("data-highlighted", "true");
|
|
197
|
+
}), l.addEventListener("mouseleave", function() {
|
|
198
|
+
this.removeAttribute("data-highlighted");
|
|
199
|
+
}), l.addEventListener("click", (y) => {
|
|
200
|
+
y.preventDefault(), y.stopPropagation(), Se(
|
|
201
|
+
t,
|
|
202
|
+
r,
|
|
203
|
+
e,
|
|
204
|
+
localStorage.getItem("STRAPI_THEME") || "dark"
|
|
205
|
+
);
|
|
206
|
+
}), u.insertAdjacentElement("afterend", l);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}).observe(n, {
|
|
210
|
+
attributes: !0
|
|
211
|
+
});
|
|
212
|
+
}, F = () => window.location.pathname === "/admin/auth/login", ve = () => window.location.pathname.startsWith("/admin/plugins/upload"), Ee = () => {
|
|
213
|
+
const e = U(), t = document.querySelector('[data-strapi-header="true"]');
|
|
214
|
+
if (!e || H(e)) {
|
|
215
|
+
const n = t?.querySelectorAll("button");
|
|
216
|
+
n && n.forEach((i) => {
|
|
217
|
+
i.style.display = "none";
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}, q = W(Ee, {
|
|
221
|
+
minQuietPeriodMs: 250
|
|
222
|
+
}), _ = async () => {
|
|
223
|
+
const e = await b('nav ul > li a[href="/admin/plugins/upload"]');
|
|
224
|
+
e && e.addEventListener("click", () => {
|
|
225
|
+
q.call();
|
|
226
|
+
}), ve() && q.call();
|
|
227
|
+
}, v = async () => {
|
|
228
|
+
if (F()) {
|
|
229
|
+
document.body.removeAttribute(g);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (await $()) {
|
|
233
|
+
document.querySelector(`[${g}]`) || (await Promise.all([j(), _()]), document.body.setAttribute(g, "true"));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
document.body.removeAttribute(g);
|
|
237
|
+
}, Ae = async () => {
|
|
238
|
+
F() || !await $() || (document.body.setAttribute(g, "true"), await Promise.all([j(), _()]));
|
|
239
|
+
}, Re = {
|
|
240
|
+
register(e) {
|
|
241
|
+
e.registerPlugin({
|
|
242
|
+
id: c,
|
|
243
|
+
initializer: we,
|
|
244
|
+
isReady: !1,
|
|
245
|
+
name: c
|
|
246
|
+
}), e.customFields.register({
|
|
247
|
+
name: `unique-by-${f}`,
|
|
248
|
+
pluginId: c,
|
|
249
|
+
type: "string",
|
|
250
|
+
intlLabel: {
|
|
251
|
+
id: `${c}.custom-fields.unique-by-domain.label`,
|
|
252
|
+
defaultMessage: "Unique by domain"
|
|
253
|
+
},
|
|
254
|
+
intlDescription: {
|
|
255
|
+
id: `${c}.custom-fields.unique-by-tenant.description`,
|
|
256
|
+
defaultMessage: "Ensures the value is unique within the domain."
|
|
257
|
+
},
|
|
258
|
+
components: {
|
|
259
|
+
Input: () => import("./TenantCustomField-CtCNZEgB.mjs")
|
|
260
|
+
}
|
|
261
|
+
}), e.addSettingsLink(
|
|
262
|
+
{
|
|
263
|
+
id: `${c}.settings`,
|
|
264
|
+
intlLabel: {
|
|
265
|
+
id: `${c}.settings.label`,
|
|
266
|
+
defaultMessage: "Multi-Domain Settings"
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
id: `${c}.settings.general`,
|
|
271
|
+
intlLabel: {
|
|
272
|
+
id: `${c}.settings.general.label`,
|
|
273
|
+
defaultMessage: "General Settings"
|
|
274
|
+
},
|
|
275
|
+
to: `/settings/${c}`,
|
|
276
|
+
Component: () => import("./Settings-BPM919an.mjs"),
|
|
277
|
+
permissions: he.admin.access
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
},
|
|
281
|
+
async registerTrads({ locales: e }) {
|
|
282
|
+
return Promise.all(
|
|
283
|
+
e.map(async (t) => t in N ? N[t]().then(({ default: i }) => ({
|
|
284
|
+
data: B(c, A(i)),
|
|
285
|
+
locale: t
|
|
286
|
+
})) : {
|
|
287
|
+
data: B(c, A({})),
|
|
288
|
+
locale: t
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
},
|
|
292
|
+
async bootstrap(e) {
|
|
293
|
+
e.getPlugin("content-manager").injectComponent("listView", "actions", {
|
|
294
|
+
name: "display-create-button",
|
|
295
|
+
Component: ye
|
|
296
|
+
});
|
|
297
|
+
let t = window.location.pathname;
|
|
298
|
+
window.addEventListener("popstate", async () => {
|
|
299
|
+
t !== window.location.pathname && (t = window.location.pathname, await v());
|
|
300
|
+
});
|
|
301
|
+
const n = history.pushState, i = history.replaceState;
|
|
302
|
+
history.pushState = function(...a) {
|
|
303
|
+
n.apply(history, a), t !== window.location.pathname && (t = window.location.pathname, v());
|
|
304
|
+
}, history.replaceState = function(...a) {
|
|
305
|
+
i.apply(history, a), t !== window.location.pathname && (t = window.location.pathname, v());
|
|
306
|
+
}, await Ae();
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
export {
|
|
310
|
+
he as a,
|
|
311
|
+
f as b,
|
|
312
|
+
Re as c,
|
|
313
|
+
Oe as m,
|
|
314
|
+
c as p
|
|
315
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as c, Fragment as f } from "react/jsx-runtime";
|
|
2
|
+
import { useFetchClient as q } from "@strapi/strapi/admin";
|
|
3
|
+
import { useQuery as o, useQueryClient as u, useMutation as l } from "@tanstack/react-query";
|
|
4
|
+
import { p as F, m as T } from "./index-Ds2z-yoa.mjs";
|
|
5
|
+
import { a as r } from "./index-DkEjJa1n.mjs";
|
|
6
|
+
const g = () => {
|
|
7
|
+
const e = q();
|
|
8
|
+
return o({
|
|
9
|
+
queryKey: ["permissions"],
|
|
10
|
+
queryFn: async () => {
|
|
11
|
+
const { data: t } = await e.get("/admin/users/me/permissions");
|
|
12
|
+
return t.data;
|
|
13
|
+
},
|
|
14
|
+
staleTime: 1e3 * 60 * 5,
|
|
15
|
+
refetchOnWindowFocus: !1,
|
|
16
|
+
retry: !1
|
|
17
|
+
});
|
|
18
|
+
}, S = ({
|
|
19
|
+
permissions: e,
|
|
20
|
+
children: t,
|
|
21
|
+
NotAllowed: s = () => null
|
|
22
|
+
}) => {
|
|
23
|
+
const { isLoading: a, data: y } = g();
|
|
24
|
+
if (a)
|
|
25
|
+
return null;
|
|
26
|
+
const d = (i) => e ? y?.some((m) => m.action === i) : !0;
|
|
27
|
+
return e && !e.every((i) => d(i.action)) ? /* @__PURE__ */ c(s, {}) : t ? /* @__PURE__ */ c(f, { children: t }) : null;
|
|
28
|
+
}, h = (e, t, { defaultMessage: s, values: a } = {}) => e(
|
|
29
|
+
{
|
|
30
|
+
id: `${F}.${t}`,
|
|
31
|
+
defaultMessage: s
|
|
32
|
+
},
|
|
33
|
+
a
|
|
34
|
+
), n = {
|
|
35
|
+
all: [T],
|
|
36
|
+
lists: () => [...n.all, "list"],
|
|
37
|
+
list: (e) => [...n.lists(), { filters: e }],
|
|
38
|
+
details: () => [...n.all, "detail"],
|
|
39
|
+
detail: (e) => [...n.details(), e]
|
|
40
|
+
}, w = (e) => o({
|
|
41
|
+
queryKey: [...n.lists(), JSON.stringify(e || {})],
|
|
42
|
+
queryFn: () => r.getTenants(e),
|
|
43
|
+
staleTime: 2 * 60 * 1e3
|
|
44
|
+
// 2 minutes
|
|
45
|
+
}), E = (e) => o({
|
|
46
|
+
queryKey: n.detail(e),
|
|
47
|
+
queryFn: () => r.getTenant(e),
|
|
48
|
+
enabled: !!e,
|
|
49
|
+
staleTime: 2 * 60 * 1e3
|
|
50
|
+
// 2 minutes
|
|
51
|
+
}), P = () => {
|
|
52
|
+
const e = u();
|
|
53
|
+
return l({
|
|
54
|
+
mutationFn: (t) => r.createTenant(t),
|
|
55
|
+
onSuccess: async () => {
|
|
56
|
+
await e.invalidateQueries({ queryKey: n.lists() });
|
|
57
|
+
},
|
|
58
|
+
onError: (t) => {
|
|
59
|
+
console.error("Failed to create tenant:", t);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}, b = () => {
|
|
63
|
+
const e = u();
|
|
64
|
+
return l({
|
|
65
|
+
mutationFn: ({ id: t, data: s }) => r.updateTenant(t, s),
|
|
66
|
+
onSuccess: (t) => {
|
|
67
|
+
e.setQueryData(n.detail(t.id), t), e.invalidateQueries({ queryKey: n.lists() });
|
|
68
|
+
},
|
|
69
|
+
onError: (t) => {
|
|
70
|
+
console.error("Failed to update tenant:", t);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}, x = () => {
|
|
74
|
+
const e = u();
|
|
75
|
+
return l({
|
|
76
|
+
mutationFn: (t) => r.deleteTenant(t),
|
|
77
|
+
onSuccess: (t, s) => {
|
|
78
|
+
e.removeQueries({ queryKey: n.detail(s) }), e.invalidateQueries({ queryKey: n.lists() });
|
|
79
|
+
},
|
|
80
|
+
onError: (t) => {
|
|
81
|
+
console.error("Failed to delete tenant:", t);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
S as C,
|
|
87
|
+
w as a,
|
|
88
|
+
E as b,
|
|
89
|
+
P as c,
|
|
90
|
+
b as d,
|
|
91
|
+
h as g,
|
|
92
|
+
x as u
|
|
93
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),q=require("@strapi/strapi/admin"),s=require("@tanstack/react-query"),l=require("./index-Ck1YIRr4.js"),u=require("./index-D9I-QR8y.js"),m=()=>{const e=q.useFetchClient();return s.useQuery({queryKey:["permissions"],queryFn:async()=>{const{data:t}=await e.get("/admin/users/me/permissions");return t.data},staleTime:1e3*60*5,refetchOnWindowFocus:!1,retry:!1})},T=({permissions:e,children:t,NotAllowed:r=()=>null})=>{const{isLoading:a,data:c}=m();if(a)return null;const y=i=>e?c?.some(d=>d.action===i):!0;return e&&!e.every(i=>y(i.action))?o.jsx(r,{}):t?o.jsx(o.Fragment,{children:t}):null},F=(e,t,{defaultMessage:r,values:a}={})=>e({id:`${l.pluginId}.${t}`,defaultMessage:r},a),n={all:[l.modelRoute],lists:()=>[...n.all,"list"],list:e=>[...n.lists(),{filters:e}],details:()=>[...n.all,"detail"],detail:e=>[...n.details(),e]},Q=e=>s.useQuery({queryKey:[...n.lists(),JSON.stringify(e||{})],queryFn:()=>u.api.getTenants(e),staleTime:2*60*1e3}),g=e=>s.useQuery({queryKey:n.detail(e),queryFn:()=>u.api.getTenant(e),enabled:!!e,staleTime:2*60*1e3}),C=()=>{const e=s.useQueryClient();return s.useMutation({mutationFn:t=>u.api.createTenant(t),onSuccess:async()=>{await e.invalidateQueries({queryKey:n.lists()})},onError:t=>{console.error("Failed to create tenant:",t)}})},f=()=>{const e=s.useQueryClient();return s.useMutation({mutationFn:({id:t,data:r})=>u.api.updateTenant(t,r),onSuccess:t=>{e.setQueryData(n.detail(t.id),t),e.invalidateQueries({queryKey:n.lists()})},onError:t=>{console.error("Failed to update tenant:",t)}})},p=()=>{const e=s.useQueryClient();return s.useMutation({mutationFn:t=>u.api.deleteTenant(t),onSuccess:(t,r)=>{e.removeQueries({queryKey:n.detail(r)}),e.invalidateQueries({queryKey:n.lists()})},onError:t=>{console.error("Failed to delete tenant:",t)}})};exports.CheckPermissions=T;exports.getMessage=F;exports.useCreateTenant=C;exports.useDeleteTenant=p;exports.useTenant=g;exports.useTenants=Q;exports.useUpdateTenant=f;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("../_chunks/index-Ck1YIRr4.js");module.exports=e.plugin;
|