@strapi-community/plugin-better-auth-dashboard 1.0.0-beta.1 → 1.0.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.
Files changed (46) hide show
  1. package/README.md +0 -3
  2. package/dist/admin/Avatar-CdT7eBCh.js +39 -0
  3. package/dist/admin/Avatar-zlMTAZh3.mjs +40 -0
  4. package/dist/admin/{Root-2FMy-qQg.mjs → Root-CgVBJuoM.mjs} +12 -4
  5. package/dist/admin/{Root-DDi0mtve.js → Root-CsiOnzlB.js} +12 -4
  6. package/dist/admin/cs-C_jSgeON.js +416 -0
  7. package/dist/admin/cs-wtnknvBC.mjs +416 -0
  8. package/dist/admin/de-Cg5HyoCY.js +416 -0
  9. package/dist/admin/de-DnnVdUxk.mjs +416 -0
  10. package/dist/admin/en-B3utEgMT.mjs +416 -0
  11. package/dist/admin/en-Cz1IJEvp.js +416 -0
  12. package/dist/admin/es-CGA0Tslt.js +416 -0
  13. package/dist/admin/es-RoCEriJL.mjs +416 -0
  14. package/dist/admin/fr-Ca74t21t.js +416 -0
  15. package/dist/admin/fr-CtmuSfiQ.mjs +416 -0
  16. package/dist/admin/{index-BHfYu0uA.js → index-BCBu-0nr.js} +65 -10
  17. package/dist/admin/{index-D9CiI8Yr.mjs → index-BI2WIsds.mjs} +73 -18
  18. package/dist/admin/index-CPSoAbZt.js +2321 -0
  19. package/dist/admin/index-D9ttdrT3.js +2716 -0
  20. package/dist/admin/index-DQdn5s8q.js +1184 -0
  21. package/dist/admin/index-DvfwvCj0.mjs +1182 -0
  22. package/dist/admin/index-VyHXoQ6p.mjs +2321 -0
  23. package/dist/admin/index-gFqHlMLP.mjs +2716 -0
  24. package/dist/admin/index.js +1 -1
  25. package/dist/admin/index.mjs +1 -1
  26. package/dist/admin/it-BAB9hDdp.mjs +416 -0
  27. package/dist/admin/it-dYT2_ERV.js +416 -0
  28. package/dist/admin/nl-CVqSbUU9.js +416 -0
  29. package/dist/admin/nl-CYv26PHv.mjs +416 -0
  30. package/dist/admin/pl-Bc0cS2mD.mjs +416 -0
  31. package/dist/admin/pl-HYF4BxRv.js +416 -0
  32. package/dist/admin/pt-DDUGyLtb.js +416 -0
  33. package/dist/admin/pt-DZyyK3EG.mjs +416 -0
  34. package/dist/admin/{useModelSchema-CqOTI7P1.js → useModelSchema-BogQah8f.js} +309 -287
  35. package/dist/admin/{useModelSchema-B2tmzlwQ.mjs → useModelSchema-C6bxNjW4.mjs} +320 -298
  36. package/dist/server/index.js +15 -15
  37. package/dist/server/index.mjs +15 -15
  38. package/package.json +4 -4
  39. package/dist/admin/Avatar-Cvk89aMx.js +0 -67
  40. package/dist/admin/Avatar-DNczJU0i.mjs +0 -66
  41. package/dist/admin/index-BQi_BUi6.mjs +0 -1968
  42. package/dist/admin/index-BV-4M_Fp.js +0 -1970
  43. package/dist/admin/index-CANDPUGD.mjs +0 -1215
  44. package/dist/admin/index-CqR8WpOa.js +0 -1217
  45. package/dist/admin/index-D6ktNZcj.js +0 -1685
  46. package/dist/admin/index-DszX3ibA.mjs +0 -1683
@@ -1,9 +1,28 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useIntl } from "react-intl";
2
3
  import { useQuery } from "react-query";
3
4
  import { dashClient } from "@better-auth/infra/client";
4
5
  import { createAuthClient, InferPlugin } from "better-auth/client";
5
6
  import { Page } from "@strapi/strapi/admin";
6
7
  import { createElement } from "react";
8
+ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
9
+ const v = glob[path];
10
+ if (v) {
11
+ return typeof v === "function" ? v() : Promise.resolve(v);
12
+ }
13
+ return new Promise((_, reject) => {
14
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
15
+ reject.bind(
16
+ null,
17
+ new Error(
18
+ "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
19
+ )
20
+ )
21
+ );
22
+ });
23
+ };
24
+ const PLUGIN_ID = "better-auth-dashboard";
25
+ const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
7
26
  const PluginIcon = ({
8
27
  size = 16,
9
28
  background = "transparent",
@@ -14,6 +33,7 @@ const PluginIcon = ({
14
33
  flipVertical = false,
15
34
  padding = 0
16
35
  }) => {
36
+ const { formatMessage } = useIntl();
17
37
  const transforms = [];
18
38
  if (rotation !== 0) transforms.push(`rotate(${rotation}deg)`);
19
39
  if (flipHorizontal) transforms.push("scaleX(-1)");
@@ -36,7 +56,10 @@ const PluginIcon = ({
36
56
  backgroundColor: background !== "transparent" ? background : void 0
37
57
  },
38
58
  children: [
39
- /* @__PURE__ */ jsx("title", { children: "Better Auth Logo" }),
59
+ /* @__PURE__ */ jsx("title", { children: formatMessage({
60
+ id: getTranslation("components.pluginIcon.title"),
61
+ defaultMessage: "Better Auth Logo"
62
+ }) }),
40
63
  /* @__PURE__ */ jsx(
41
64
  "path",
42
65
  {
@@ -48,7 +71,6 @@ const PluginIcon = ({
48
71
  }
49
72
  );
50
73
  };
51
- const PLUGIN_ID = "better-auth-dashboard";
52
74
  const PERMISSIONS = {
53
75
  overview: [{ action: `plugin::${PLUGIN_ID}.overview.read`, subject: null }],
54
76
  user: [
@@ -152,20 +174,34 @@ const client = createAuthClient({
152
174
  InferPlugin()
153
175
  ],
154
176
  fetchOptions: {
155
- headers: getAuthHeaders()
177
+ onRequest: ({ headers }) => {
178
+ const token = getToken();
179
+ if (token) {
180
+ headers.set("Authorization", `Bearer ${token}`);
181
+ } else {
182
+ headers.delete("Authorization");
183
+ }
184
+ }
156
185
  }
157
186
  });
158
- async function getDashConfig() {
187
+ const loadConfigError = {
188
+ id: getTranslation("common.errors.loadConfig"),
189
+ defaultMessage: "Failed to load config"
190
+ };
191
+ async function getDashConfig(formatMessage) {
159
192
  const result = await client.dash.config();
160
193
  if (result.error) {
161
- throw new Error(result.error.message ?? "Failed to load config");
194
+ throw new Error(
195
+ result.error.message ?? (formatMessage ? formatMessage(loadConfigError) : loadConfigError.defaultMessage)
196
+ );
162
197
  }
163
198
  return result.data;
164
199
  }
165
200
  function useDashConfig() {
201
+ const { formatMessage } = useIntl();
166
202
  return useQuery({
167
203
  queryKey: ["dash-config"],
168
- queryFn: getDashConfig,
204
+ queryFn: () => getDashConfig(formatMessage),
169
205
  staleTime: 5 * 60 * 1e3
170
206
  });
171
207
  }
@@ -313,6 +349,12 @@ function getEditViewSidePanels(model) {
313
349
  return p.model === model;
314
350
  });
315
351
  }
352
+ const prefixPluginTranslations = (translations) => Object.fromEntries(
353
+ Object.entries(translations).map(([key, value]) => [
354
+ `${PLUGIN_ID}.${key}`,
355
+ value
356
+ ])
357
+ );
316
358
  function captureApp(app) {
317
359
  window.__betterAuthDashApp = app;
318
360
  }
@@ -335,7 +377,7 @@ const plugin = {
335
377
  id: `${PLUGIN_ID}.plugin.name`,
336
378
  defaultMessage: "Auth Dashboard"
337
379
  },
338
- Component: async () => import("./Root-2FMy-qQg.mjs"),
380
+ Component: async () => import("./Root-CgVBJuoM.mjs"),
339
381
  permissions: [
340
382
  ...PERMISSIONS.overview,
341
383
  ...PERMISSIONS.user,
@@ -359,7 +401,7 @@ const plugin = {
359
401
  defaultMessage: "Overview"
360
402
  },
361
403
  to: "/overview",
362
- Component: () => import("./index-CANDPUGD.mjs"),
404
+ Component: () => import("./index-DvfwvCj0.mjs"),
363
405
  permissions: PERMISSIONS.overview
364
406
  });
365
407
  dash.addDashLink("general", {
@@ -369,7 +411,7 @@ const plugin = {
369
411
  defaultMessage: "User Management"
370
412
  },
371
413
  to: "/users",
372
- Component: () => import("./index-BQi_BUi6.mjs"),
414
+ Component: () => import("./index-gFqHlMLP.mjs"),
373
415
  permissions: PERMISSIONS.user
374
416
  });
375
417
  dash.addDashLink("general", {
@@ -379,24 +421,37 @@ const plugin = {
379
421
  defaultMessage: "Organization Management"
380
422
  },
381
423
  to: "/organizations",
382
- Component: () => import("./index-DszX3ibA.mjs"),
424
+ Component: () => import("./index-VyHXoQ6p.mjs"),
383
425
  permissions: PERMISSIONS.organization,
384
426
  isAvailable: async () => hasPlugin(await getDashConfig(), "organization")
385
427
  });
428
+ },
429
+ async registerTrads({ locales }) {
430
+ return Promise.all(
431
+ locales.map(async (locale) => {
432
+ try {
433
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/cs.json": () => import("./cs-wtnknvBC.mjs"), "./translations/de.json": () => import("./de-DnnVdUxk.mjs"), "./translations/en.json": () => import("./en-B3utEgMT.mjs"), "./translations/es.json": () => import("./es-RoCEriJL.mjs"), "./translations/fr.json": () => import("./fr-CtmuSfiQ.mjs"), "./translations/it.json": () => import("./it-BAB9hDdp.mjs"), "./translations/nl.json": () => import("./nl-CYv26PHv.mjs"), "./translations/pl.json": () => import("./pl-Bc0cS2mD.mjs"), "./translations/pt.json": () => import("./pt-DZyyK3EG.mjs") }), `./translations/${locale}.json`, 3);
434
+ return { data: prefixPluginTranslations(data), locale };
435
+ } catch {
436
+ return { data: {}, locale };
437
+ }
438
+ })
439
+ );
386
440
  }
387
441
  };
388
442
  export {
389
443
  DASH_LINK_AVAILABILITY_STALE_TIME as D,
390
444
  PLUGIN_ID as P,
391
- getDashLinkAvailabilityQueryKey as a,
392
- PERMISSIONS as b,
393
- client as c,
394
- getAuthHeaders as d,
395
- useOrganizationOptions as e,
396
- getMediaLibraryComponent as f,
397
- getDashLinks as g,
445
+ getDashLinks as a,
446
+ getDashLinkAvailabilityQueryKey as b,
447
+ PERMISSIONS as c,
448
+ client as d,
449
+ getAuthHeaders as e,
450
+ useOrganizationOptions as f,
451
+ getTranslation as g,
398
452
  hasPlugin as h,
399
- getEditViewSidePanels as i,
453
+ getMediaLibraryComponent as i,
454
+ getEditViewSidePanels as j,
400
455
  plugin as p,
401
456
  resolveDashLinkAvailability as r,
402
457
  useDashConfig as u