zudoku 0.3.0-dev.55 → 0.3.0-dev.56

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 (143) hide show
  1. package/dist/config/validators/validate.d.ts +12 -12
  2. package/dist/lib/components/DeveloperHint.d.ts +5 -0
  3. package/dist/lib/components/DeveloperHint.js +10 -0
  4. package/dist/lib/components/DeveloperHint.js.map +1 -0
  5. package/dist/lib/components/NotFoundPage.js +2 -2
  6. package/dist/lib/components/NotFoundPage.js.map +1 -1
  7. package/dist/lib/plugins/api-keys/ProtectedRoute.d.ts +1 -0
  8. package/dist/lib/plugins/api-keys/ProtectedRoute.js +14 -0
  9. package/dist/lib/plugins/api-keys/ProtectedRoute.js.map +1 -0
  10. package/dist/lib/plugins/api-keys/index.js +2 -12
  11. package/dist/lib/plugins/api-keys/index.js.map +1 -1
  12. package/dist/lib/plugins/openapi/OperationList.js +2 -2
  13. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  14. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +3 -3
  15. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
  16. package/lib/AnchorLink-GNsUeGSX.js +705 -0
  17. package/lib/{AnchorLink-BaXHjhF-.js.map → AnchorLink-GNsUeGSX.js.map} +1 -1
  18. package/lib/Button-DpHMZvVs.js +4571 -0
  19. package/lib/Button-DpHMZvVs.js.map +1 -0
  20. package/lib/DevPortalProvider-Do9oJqme.js +1081 -0
  21. package/lib/{DevPortalProvider-GjdO0Xr-.js.map → DevPortalProvider-Do9oJqme.js.map} +1 -1
  22. package/lib/Markdown-DtLFdxD1.js +15031 -0
  23. package/lib/Markdown-DtLFdxD1.js.map +1 -0
  24. package/lib/MdxPage-CbwYRKf5.js +190 -0
  25. package/lib/{MdxPage-Dlujuj-J.js.map → MdxPage-CbwYRKf5.js.map} +1 -1
  26. package/lib/OperationList-DpR4KzIJ.js +5570 -0
  27. package/lib/OperationList-DpR4KzIJ.js.map +1 -0
  28. package/lib/Route-C1LyvITr.js +13 -0
  29. package/lib/{Route-CR6TEwVC.js.map → Route-C1LyvITr.js.map} +1 -1
  30. package/lib/Spinner-Bhbs5aPI.js +182 -0
  31. package/lib/Spinner-Bhbs5aPI.js.map +1 -0
  32. package/lib/_commonjsHelpers-BVfed4GL.js +29 -0
  33. package/lib/_commonjsHelpers-BVfed4GL.js.map +1 -0
  34. package/lib/assets/index-BPdJm2ty.js +4765 -0
  35. package/lib/assets/{index-CpIig0AX.js.map → index-BPdJm2ty.js.map} +1 -1
  36. package/lib/assets/worker-BjPv-hjP.js +14897 -0
  37. package/lib/assets/{worker-B5k2aBV9.js.map → worker-BjPv-hjP.js.map} +1 -1
  38. package/lib/context-_fYfJFgk.js +14 -0
  39. package/lib/{context-BoN_3uxi.js.map → context-_fYfJFgk.js.map} +1 -1
  40. package/lib/hook-Biq3zYel.js +92 -0
  41. package/lib/hook-Biq3zYel.js.map +1 -0
  42. package/lib/{index-Dih8IAqw.js → index-DZ910ttL.js} +83 -103
  43. package/lib/{index-Dih8IAqw.js.map → index-DZ910ttL.js.map} +1 -1
  44. package/lib/index-gsAuUwQh.js +418 -0
  45. package/lib/index-gsAuUwQh.js.map +1 -0
  46. package/lib/index-pI9JkN46.js +4765 -0
  47. package/lib/{index-Bn03IPZt.js.map → index-pI9JkN46.js.map} +1 -1
  48. package/lib/jsx-runtime-CJZJivg2.js +1526 -0
  49. package/lib/{jsx-runtime-DvZ6OKMM.js.map → jsx-runtime-CJZJivg2.js.map} +1 -1
  50. package/lib/prism-bash.min-DadFsM4Z.js +7 -0
  51. package/lib/{prism-bash.min-BtBk0onv.js.map → prism-bash.min-DadFsM4Z.js.map} +1 -1
  52. package/lib/prism-csharp.min-Yizuc34Y.js +35 -0
  53. package/lib/{prism-csharp.min-Cv7D49bv.js.map → prism-csharp.min-Yizuc34Y.js.map} +1 -1
  54. package/lib/prism-java.min-d5iT_mOd.js +7 -0
  55. package/lib/{prism-java.min-tNK-JX6x.js.map → prism-java.min-d5iT_mOd.js.map} +1 -1
  56. package/lib/prism-json.min-B1GJqK1k.js +2 -0
  57. package/lib/{prism-json.min-Cdtv-CME.js.map → prism-json.min-B1GJqK1k.js.map} +1 -1
  58. package/lib/prism-markup-templating-DZrrEs0A.js +62 -0
  59. package/lib/{prism-markup-templating-iotg2sCU.js.map → prism-markup-templating-DZrrEs0A.js.map} +1 -1
  60. package/lib/prism-objectivec.min-BXSWqpJJ.js +2 -0
  61. package/lib/{prism-objectivec.min-CY4WGixz.js.map → prism-objectivec.min-BXSWqpJJ.js.map} +1 -1
  62. package/lib/prism-php.min-o7FpoMP_.js +11 -0
  63. package/lib/{prism-php.min-T6sIVgED.js.map → prism-php.min-o7FpoMP_.js.map} +1 -1
  64. package/lib/prism-ruby.min-C7LwcKyz.js +10 -0
  65. package/lib/{prism-ruby.min-B-2KAa4y.js.map → prism-ruby.min-C7LwcKyz.js.map} +1 -1
  66. package/lib/router-CBw2vqJE.js +2973 -0
  67. package/lib/{router-ButO1QyY.js.map → router-CBw2vqJE.js.map} +1 -1
  68. package/lib/slugify-CiPVjteN.js +28 -0
  69. package/lib/{slugify-CmS97Vy8.js.map → slugify-CiPVjteN.js.map} +1 -1
  70. package/lib/state-DKdaQzvh.js +288 -0
  71. package/lib/{state-CmGfNKhR.js.map → state-DKdaQzvh.js.map} +1 -1
  72. package/lib/urql-DMlBWUKL.js +1592 -0
  73. package/lib/{urql-DtVKPBx_.js.map → urql-DMlBWUKL.js.map} +1 -1
  74. package/lib/util-_jwUlTBU.js +41 -0
  75. package/lib/{util-B5KX4h4M.js.map → util-_jwUlTBU.js.map} +1 -1
  76. package/lib/zudoku.auth-auth0.js +18 -24
  77. package/lib/zudoku.auth-auth0.js.map +1 -1
  78. package/lib/zudoku.auth-clerk.js +34 -43
  79. package/lib/zudoku.auth-clerk.js.map +1 -1
  80. package/lib/zudoku.auth-openid.js +734 -1121
  81. package/lib/zudoku.auth-openid.js.map +1 -1
  82. package/lib/zudoku.components.js +822 -1076
  83. package/lib/zudoku.components.js.map +1 -1
  84. package/lib/zudoku.openapi-worker.js +9691 -13786
  85. package/lib/zudoku.openapi-worker.js.map +1 -1
  86. package/lib/zudoku.plugin-api-keys.js +171 -208
  87. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  88. package/lib/zudoku.plugin-markdown.js +33 -41
  89. package/lib/zudoku.plugin-markdown.js.map +1 -1
  90. package/lib/zudoku.plugin-openapi.js +6 -6
  91. package/lib/zudoku.plugin-redirect.js +8 -10
  92. package/lib/zudoku.plugin-redirect.js.map +1 -1
  93. package/package.json +1 -1
  94. package/src/lib/components/DeveloperHint.tsx +25 -0
  95. package/src/lib/components/NotFoundPage.tsx +8 -14
  96. package/src/lib/plugins/api-keys/ProtectedRoute.tsx +29 -0
  97. package/src/lib/plugins/api-keys/index.tsx +2 -21
  98. package/src/lib/plugins/openapi/OperationList.tsx +5 -8
  99. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +3 -5
  100. package/lib/AnchorLink-BaXHjhF-.js +0 -989
  101. package/lib/Combination-BfufJFkX.js +0 -1365
  102. package/lib/Combination-BfufJFkX.js.map +0 -1
  103. package/lib/DevPortalProvider-GjdO0Xr-.js +0 -1610
  104. package/lib/Markdown-B8nPVql1.js +0 -19708
  105. package/lib/Markdown-B8nPVql1.js.map +0 -1
  106. package/lib/MdxPage-Dlujuj-J.js +0 -223
  107. package/lib/OperationList-krPgt6sE.js +0 -8041
  108. package/lib/OperationList-krPgt6sE.js.map +0 -1
  109. package/lib/Playground-DOHxca0P.js +0 -539
  110. package/lib/Playground-DOHxca0P.js.map +0 -1
  111. package/lib/Route-CR6TEwVC.js +0 -13
  112. package/lib/Select-Boi_pe3L.js +0 -5298
  113. package/lib/Select-Boi_pe3L.js.map +0 -1
  114. package/lib/Spinner-oU0QJmi_.js +0 -16
  115. package/lib/Spinner-oU0QJmi_.js.map +0 -1
  116. package/lib/_commonjsHelpers-BxmBWJD2.js +0 -34
  117. package/lib/_commonjsHelpers-BxmBWJD2.js.map +0 -1
  118. package/lib/assets/index-CpIig0AX.js +0 -6341
  119. package/lib/assets/worker-B5k2aBV9.js +0 -18921
  120. package/lib/context-BoN_3uxi.js +0 -17
  121. package/lib/hook-CIuFuyBT.js +0 -90
  122. package/lib/hook-CIuFuyBT.js.map +0 -1
  123. package/lib/index-BL1P4Gqq.js +0 -280
  124. package/lib/index-BL1P4Gqq.js.map +0 -1
  125. package/lib/index-Bn03IPZt.js +0 -6341
  126. package/lib/index-FprhHF51.js +0 -253
  127. package/lib/index-FprhHF51.js.map +0 -1
  128. package/lib/jsx-runtime-DvZ6OKMM.js +0 -2110
  129. package/lib/mutation-DWY9x2Uc.js +0 -250
  130. package/lib/mutation-DWY9x2Uc.js.map +0 -1
  131. package/lib/prism-bash.min-BtBk0onv.js +0 -7
  132. package/lib/prism-csharp.min-Cv7D49bv.js +0 -30
  133. package/lib/prism-java.min-tNK-JX6x.js +0 -7
  134. package/lib/prism-json.min-Cdtv-CME.js +0 -2
  135. package/lib/prism-markup-templating-iotg2sCU.js +0 -94
  136. package/lib/prism-objectivec.min-CY4WGixz.js +0 -2
  137. package/lib/prism-php.min-T6sIVgED.js +0 -11
  138. package/lib/prism-ruby.min-B-2KAa4y.js +0 -8
  139. package/lib/router-ButO1QyY.js +0 -4062
  140. package/lib/slugify-CmS97Vy8.js +0 -50
  141. package/lib/state-CmGfNKhR.js +0 -436
  142. package/lib/urql-DtVKPBx_.js +0 -2567
  143. package/lib/util-B5KX4h4M.js +0 -55
@@ -1,18 +1,18 @@
1
- import { j as jsxRuntimeExports, a as useNavigate, O as Outlet } from "./jsx-runtime-DvZ6OKMM.js";
2
- import { R as RouterError, u as useAuth } from "./hook-CIuFuyBT.js";
3
- import { B as Button } from "./Combination-BfufJFkX.js";
4
- import { u as useForm, a as useMutation, S as Select, b as SelectTrigger, c as SelectValue, d as SelectContent, e as SelectGroup, f as SelectItem } from "./Select-Boi_pe3L.js";
5
- import { c as createLucideIcon, e as cn, L as Link } from "./Markdown-B8nPVql1.js";
6
- import { u as useDevPortal, q as useQueryClient, t as useSuspenseQuery } from "./DevPortalProvider-GjdO0Xr-.js";
7
- import * as React from "react";
8
- import { useState } from "react";
1
+ import { j as e, a as j, O as v } from "./jsx-runtime-CJZJivg2.js";
2
+ import { u as b, R as w } from "./hook-Biq3zYel.js";
3
+ import { u as k, a as h, S as N, b as K, c as E, d as A, e as S, f as p, B as o } from "./Button-DpHMZvVs.js";
4
+ import { c as l, e as m, L as x } from "./Markdown-DtLFdxD1.js";
5
+ import { u as y, q as D, t as P } from "./DevPortalProvider-Do9oJqme.js";
6
+ import * as C from "react";
7
+ import { useState as I } from "react";
8
+ import { D as R } from "./index-gsAuUwQh.js";
9
9
  /**
10
10
  * @license lucide-react v0.378.0 - ISC
11
11
  *
12
12
  * This source code is licensed under the ISC license.
13
13
  * See the LICENSE file in the root directory of this source tree.
14
14
  */
15
- const EyeOff = createLucideIcon("EyeOff", [
15
+ const O = l("EyeOff", [
16
16
  ["path", { d: "M9.88 9.88a3 3 0 1 0 4.24 4.24", key: "1jxqfv" }],
17
17
  [
18
18
  "path",
@@ -33,7 +33,7 @@ const EyeOff = createLucideIcon("EyeOff", [
33
33
  * This source code is licensed under the ISC license.
34
34
  * See the LICENSE file in the root directory of this source tree.
35
35
  */
36
- const Eye = createLucideIcon("Eye", [
36
+ const q = l("Eye", [
37
37
  ["path", { d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z", key: "rwhkz3" }],
38
38
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
39
39
  ]);
@@ -43,7 +43,7 @@ const Eye = createLucideIcon("Eye", [
43
43
  * This source code is licensed under the ISC license.
44
44
  * See the LICENSE file in the root directory of this source tree.
45
45
  */
46
- const RotateCw = createLucideIcon("RotateCw", [
46
+ const z = l("RotateCw", [
47
47
  ["path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8", key: "1p45f6" }],
48
48
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }]
49
49
  ]);
@@ -53,292 +53,255 @@ const RotateCw = createLucideIcon("RotateCw", [
53
53
  * This source code is licensed under the ISC license.
54
54
  * See the LICENSE file in the root directory of this source tree.
55
55
  */
56
- const Trash = createLucideIcon("Trash", [
56
+ const M = l("Trash", [
57
57
  ["path", { d: "M3 6h18", key: "d0wm0j" }],
58
58
  ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
59
59
  ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }]
60
60
  ]);
61
- var isProduction = process.env.NODE_ENV === "production";
62
- var prefix = "Invariant failed";
63
- function invariant(condition, message) {
64
- if (condition) {
65
- return;
61
+ var L = process.env.NODE_ENV === "production", d = "Invariant failed";
62
+ function u(t, n) {
63
+ if (!t) {
64
+ if (L)
65
+ throw new Error(d);
66
+ var a = typeof n == "function" ? n() : n, r = a ? "".concat(d, ": ").concat(a) : d;
67
+ throw new Error(r);
66
68
  }
67
- if (isProduction) {
68
- throw new Error(prefix);
69
- }
70
- var provided = typeof message === "function" ? message() : message;
71
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
72
- throw new Error(value);
73
69
  }
74
- const Input = React.forwardRef(
75
- ({ className, type, ...props }, ref) => {
76
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
77
- "input",
78
- {
79
- type,
80
- className: cn(
81
- "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
82
- className
83
- ),
84
- ref,
85
- ...props
86
- }
87
- );
88
- }
70
+ const f = C.forwardRef(
71
+ ({ className: t, type: n, ...a }, r) => /* @__PURE__ */ e.jsx(
72
+ "input",
73
+ {
74
+ type: n,
75
+ className: m(
76
+ "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
77
+ t
78
+ ),
79
+ ref: r,
80
+ ...a
81
+ }
82
+ )
89
83
  );
90
- Input.displayName = "Input";
91
- const CreateApiKey = ({ service }) => {
92
- const context = useDevPortal();
93
- const navigate = useNavigate();
94
- const form = useForm({
84
+ f.displayName = "Input";
85
+ const T = ({ service: t }) => {
86
+ const n = y(), a = j(), r = k({
95
87
  defaultValues: {
96
88
  expiresOn: "30"
97
89
  }
98
- });
99
- const createKeyMutation = useMutation({
100
- mutationFn: ({ description, expiresOn }) => {
101
- if (!service.createKey) {
90
+ }), i = h({
91
+ mutationFn: ({ description: s, expiresOn: c }) => {
92
+ if (!t.createKey)
102
93
  throw new Error("deleteKey not implemented");
103
- }
104
- const expiresOnDate = expiresOn !== "never" ? addDaysToDate(Number(expiresOn)) : void 0;
105
- return service.createKey(
106
- { description, expiresOn: expiresOnDate },
107
- context
94
+ const g = c !== "never" ? V(Number(c)) : void 0;
95
+ return t.createKey(
96
+ { description: s, expiresOn: g },
97
+ n
108
98
  );
109
99
  },
110
- onSuccess: () => navigate("/settings/api-keys/")
100
+ onSuccess: () => a("/settings/api-keys/")
111
101
  });
112
- if (!service.createKey) {
113
- return null;
114
- }
115
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-screen-lg pt-[--padding-content-top] pb-[--padding-content-bottom]", children: [
116
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex justify-between mb-4 border-b border-border pb-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "font-medium text-2xl", children: "New API Key" }) }),
117
- /* @__PURE__ */ jsxRuntimeExports.jsx(
102
+ return t.createKey ? /* @__PURE__ */ e.jsxs("div", { className: "max-w-screen-lg pt-[--padding-content-top] pb-[--padding-content-bottom]", children: [
103
+ /* @__PURE__ */ e.jsx("div", { className: "flex justify-between mb-4 border-b border-border pb-1", children: /* @__PURE__ */ e.jsx("h1", { className: "font-medium text-2xl", children: "New API Key" }) }),
104
+ /* @__PURE__ */ e.jsx(
118
105
  "form",
119
106
  {
120
- onSubmit: form.handleSubmit((data) => createKeyMutation.mutate(data)),
121
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 flex-col", children: [
107
+ onSubmit: r.handleSubmit((s) => i.mutate(s)),
108
+ children: /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 flex-col", children: [
122
109
  "Note",
123
- /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { ...form.register("description") }),
110
+ /* @__PURE__ */ e.jsx(f, { ...r.register("description") }),
124
111
  "Expiration",
125
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
126
- Select,
112
+ /* @__PURE__ */ e.jsxs(
113
+ N,
127
114
  {
128
- onValueChange: (value) => form.setValue("expiresOn", value),
129
- defaultValue: form.getValues("expiresOn"),
115
+ onValueChange: (s) => r.setValue("expiresOn", s),
116
+ defaultValue: r.getValues("expiresOn"),
130
117
  children: [
131
- /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
132
- /* @__PURE__ */ jsxRuntimeExports.jsx(SelectContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectGroup, { children: [
133
- [7, 30, 60, 90].map((option) => /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectItem, { value: String(option), children: [
134
- option,
118
+ /* @__PURE__ */ e.jsx(K, { children: /* @__PURE__ */ e.jsx(E, {}) }),
119
+ /* @__PURE__ */ e.jsx(A, { children: /* @__PURE__ */ e.jsxs(S, { children: [
120
+ [7, 30, 60, 90].map((s) => /* @__PURE__ */ e.jsxs(p, { value: String(s), children: [
121
+ s,
135
122
  " days"
136
- ] }, option)),
137
- /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "never", children: "Never" })
123
+ ] }, s)),
124
+ /* @__PURE__ */ e.jsx(p, { value: "never", children: "Never" })
138
125
  ] }) })
139
126
  ]
140
127
  }
141
128
  ),
142
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
143
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { children: "Generate Key" }),
144
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outline", asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/settings/api-keys/", children: "Cancel" }) })
129
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
130
+ /* @__PURE__ */ e.jsx(o, { children: "Generate Key" }),
131
+ /* @__PURE__ */ e.jsx(o, { variant: "outline", asChild: !0, children: /* @__PURE__ */ e.jsx(x, { to: "/settings/api-keys/", children: "Cancel" }) })
145
132
  ] })
146
133
  ] })
147
134
  }
148
135
  )
149
- ] });
150
- };
151
- const addDaysToDate = (days) => {
152
- const date = /* @__PURE__ */ new Date();
153
- date.setDate(date.getDate() + days);
154
- return date.toISOString();
155
- };
156
- const SettingsApiKeys = ({ service }) => {
157
- const context = useDevPortal();
158
- const queryClient = useQueryClient();
159
- const { data } = useSuspenseQuery({
160
- queryFn: () => service.getKeys(context),
136
+ ] }) : null;
137
+ }, V = (t) => {
138
+ const n = /* @__PURE__ */ new Date();
139
+ return n.setDate(n.getDate() + t), n.toISOString();
140
+ }, F = () => {
141
+ const t = b();
142
+ return t.isAuthEnabled && t.isPending ? null : t.isAuthenticated ? /* @__PURE__ */ e.jsx(v, {}) : t.isAuthEnabled ? /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: [
143
+ "Please login first to view this page",
144
+ /* @__PURE__ */ e.jsx(o, { onClick: () => t.login(), children: "Login" })
145
+ ] }) : /* @__PURE__ */ e.jsx("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: /* @__PURE__ */ e.jsxs(R, { className: "max-w-[600px]", children: [
146
+ "Authentication needs to be enabled for API keys to work. Enable it in your Zudoku configuration under ",
147
+ /* @__PURE__ */ e.jsx("code", { children: "authentication" }),
148
+ "."
149
+ ] }) });
150
+ }, _ = ({ service: t }) => {
151
+ const n = y(), a = D(), { data: r } = P({
152
+ queryFn: () => t.getKeys(n),
161
153
  queryKey: ["api-keys"],
162
- retry: false
163
- });
164
- const deleteKeyMutation = useMutation({
165
- mutationFn: (id) => {
166
- if (!service.deleteKey) {
154
+ retry: !1
155
+ }), i = h({
156
+ mutationFn: (s) => {
157
+ if (!t.deleteKey)
167
158
  throw new Error("deleteKey not implemented");
168
- }
169
- return service.deleteKey(id, context);
159
+ return t.deleteKey(s, n);
170
160
  },
171
161
  onSuccess: () => {
172
- void queryClient.invalidateQueries({ queryKey: ["api-keys"] });
162
+ a.invalidateQueries({ queryKey: ["api-keys"] });
173
163
  }
174
164
  });
175
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-screen-lg h-full pt-[--padding-content-top] pb-[--padding-content-bottom]", children: [
176
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between mb-4 border-b border-border pb-3", children: [
177
- /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "font-medium text-2xl", children: "API Keys" }),
178
- service.createKey && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/settings/api-keys/new", children: "Create API Key" }) })
165
+ return /* @__PURE__ */ e.jsxs("div", { className: "max-w-screen-lg h-full pt-[--padding-content-top] pb-[--padding-content-bottom]", children: [
166
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between mb-4 border-b border-border pb-3", children: [
167
+ /* @__PURE__ */ e.jsx("h1", { className: "font-medium text-2xl", children: "API Keys" }),
168
+ t.createKey && /* @__PURE__ */ e.jsx(o, { asChild: !0, children: /* @__PURE__ */ e.jsx(x, { to: "/settings/api-keys/new", children: "Create API Key" }) })
179
169
  ] }),
180
- data.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col justify-center gap-4 items-center h-1/2 my-8", children: [
181
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
170
+ r.length === 0 ? /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col justify-center gap-4 items-center h-1/2 my-8", children: [
171
+ /* @__PURE__ */ e.jsxs("div", { className: "text-center", children: [
182
172
  "No API keys created yet.",
183
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
173
+ /* @__PURE__ */ e.jsx("br", {}),
184
174
  "Get started and create the first one now"
185
175
  ] }),
186
- service.createKey && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/settings/api-keys/new", children: "Create API Key" }) })
187
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
176
+ t.createKey && /* @__PURE__ */ e.jsx(o, { asChild: !0, children: /* @__PURE__ */ e.jsx(x, { to: "/settings/api-keys/new", children: "Create API Key" }) })
177
+ ] }) : /* @__PURE__ */ e.jsx(
188
178
  "ul",
189
179
  {
190
- className: cn(
180
+ className: m(
191
181
  "grid grid-cols-1 rounded border-border border",
192
182
  "lg:grid-cols-[minmax(250px,min-content)_1fr_min-content]"
193
183
  ),
194
- children: data.map((key) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
184
+ children: r.map((s) => /* @__PURE__ */ e.jsxs(
195
185
  "li",
196
186
  {
197
187
  className: "border-b border-border p-5 grid grid-cols-subgrid col-span-full gap-2 items-center",
198
188
  children: [
199
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1 text-sm", children: [
200
- key.description ?? key.id,
201
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-muted-foreground text-xs", children: [
202
- key.createdOn && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
189
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1 text-sm", children: [
190
+ s.description ?? s.id,
191
+ /* @__PURE__ */ e.jsxs("div", { className: "text-muted-foreground text-xs", children: [
192
+ s.createdOn && /* @__PURE__ */ e.jsxs("div", { children: [
203
193
  "Created on ",
204
- new Date(key.createdOn).toLocaleDateString()
194
+ new Date(s.createdOn).toLocaleDateString()
205
195
  ] }),
206
- key.expiresOn && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
196
+ s.expiresOn && /* @__PURE__ */ e.jsxs("div", { children: [
207
197
  "Expires on ",
208
- new Date(key.expiresOn).toLocaleDateString()
198
+ new Date(s.expiresOn).toLocaleDateString()
209
199
  ] })
210
200
  ] })
211
201
  ] }),
212
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "items-center flex lg:justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RevealApiKey, { apiKey: key.key }) }),
213
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
214
- service.rollKey && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RotateCw, { size: 16 }) }),
215
- service.deleteKey && /* @__PURE__ */ jsxRuntimeExports.jsx(
216
- Button,
202
+ /* @__PURE__ */ e.jsx("div", { className: "items-center flex lg:justify-center", children: /* @__PURE__ */ e.jsx(B, { apiKey: s.key }) }),
203
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
204
+ t.rollKey && /* @__PURE__ */ e.jsx(o, { size: "icon", children: /* @__PURE__ */ e.jsx(z, { size: 16 }) }),
205
+ t.deleteKey && /* @__PURE__ */ e.jsx(
206
+ o,
217
207
  {
218
208
  variant: "ghost",
219
209
  size: "icon",
220
210
  onClick: () => {
221
- if (!confirm("Do you want to delete this key?")) {
222
- return;
223
- }
224
- deleteKeyMutation.mutate(key.id);
211
+ confirm("Do you want to delete this key?") && i.mutate(s.id);
225
212
  },
226
- disabled: deleteKeyMutation.isPending,
227
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash, { size: 16 })
213
+ disabled: i.isPending,
214
+ children: /* @__PURE__ */ e.jsx(M, { size: 16 })
228
215
  }
229
216
  )
230
217
  ] })
231
218
  ]
232
219
  },
233
- key.id
220
+ s.id
234
221
  ))
235
222
  }
236
223
  )
237
224
  ] });
238
- };
239
- const RevealApiKey = ({ apiKey }) => {
240
- const [revealed, setRevealed] = useState(false);
241
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 items-center text-sm w-full", children: [
242
- /* @__PURE__ */ jsxRuntimeExports.jsx(
225
+ }, B = ({ apiKey: t }) => {
226
+ const [n, a] = I(!1);
227
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 items-center text-sm w-full", children: [
228
+ /* @__PURE__ */ e.jsx(
243
229
  "input",
244
230
  {
245
231
  className: "border border-border rounded bg-gray-100 dark:bg-gray-950 p-1 font-mono max-w-min",
246
- value: revealed ? apiKey : "•".repeat(apiKey.length)
232
+ value: n ? t : "•".repeat(t.length)
247
233
  }
248
234
  ),
249
- /* @__PURE__ */ jsxRuntimeExports.jsx(
250
- Button,
235
+ /* @__PURE__ */ e.jsx(
236
+ o,
251
237
  {
252
238
  variant: "outline",
253
- onClick: () => setRevealed((prev) => !prev),
239
+ onClick: () => a((r) => !r),
254
240
  size: "icon",
255
- children: revealed ? /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { size: 16 }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { size: 16 })
241
+ children: n ? /* @__PURE__ */ e.jsx(O, { size: 16 }) : /* @__PURE__ */ e.jsx(q, { size: 16 })
256
242
  }
257
243
  )
258
244
  ] });
259
- };
260
- const DEFAULT_API_KEY_ENDPOINT = "https://zudoku-rewiringamerica-main-ef9c9c0.d2.zuplo.dev";
261
- const createDefaultHandler = (endpoint) => {
262
- return {
263
- deleteKey: async (id, context) => {
264
- const request = new Request(endpoint + `/v1/developer/api-keys/${id}`, {
265
- method: "DELETE"
266
- });
267
- await context.signRequest(request);
268
- const response = await fetch(request);
269
- invariant(response.ok, "Failed to delete API key");
270
- },
271
- createKey: async (apiKey, context) => {
272
- const request = new Request(endpoint + `/v1/developer/api-keys`, {
273
- method: "POST",
274
- headers: {
275
- "Content-Type": "application/json"
276
- },
277
- body: JSON.stringify(apiKey)
278
- });
279
- await context.signRequest(request);
280
- const response = await fetch(request);
281
- invariant(response.ok, "Failed to create API key");
282
- },
283
- getKeys: async (context) => {
284
- const request = new Request(endpoint + `/v1/developer/api-keys`);
285
- await context.signRequest(request);
286
- const keys = await fetch(request);
287
- invariant(keys.ok, "Failed to fetch API keys");
288
- return await keys.json();
289
- }
290
- };
291
- };
292
- const ProtectedRoute = () => {
293
- const auth = useAuth();
294
- if (auth.isPending) {
295
- return null;
245
+ }, G = "https://zudoku-rewiringamerica-main-ef9c9c0.d2.zuplo.dev", H = (t) => ({
246
+ deleteKey: async (n, a) => {
247
+ const r = new Request(t + `/v1/developer/api-keys/${n}`, {
248
+ method: "DELETE"
249
+ });
250
+ await a.signRequest(r);
251
+ const i = await fetch(r);
252
+ u(i.ok, "Failed to delete API key");
253
+ },
254
+ createKey: async (n, a) => {
255
+ const r = new Request(t + "/v1/developer/api-keys", {
256
+ method: "POST",
257
+ headers: {
258
+ "Content-Type": "application/json"
259
+ },
260
+ body: JSON.stringify(n)
261
+ });
262
+ await a.signRequest(r);
263
+ const i = await fetch(r);
264
+ u(i.ok, "Failed to create API key");
265
+ },
266
+ getKeys: async (n) => {
267
+ const a = new Request(t + "/v1/developer/api-keys");
268
+ await n.signRequest(a);
269
+ const r = await fetch(a);
270
+ return u(r.ok, "Failed to fetch API keys"), await r.json();
296
271
  }
297
- return auth.isAuthenticated ? /* @__PURE__ */ jsxRuntimeExports.jsx(Outlet, {}) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2 my-12", children: [
298
- "Please login first to view this page",
299
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => auth.login(), children: "Login" })
300
- ] });
301
- };
302
- const apiKeyPlugin = (options) => {
303
- const endpoint = "endpoint" in options ? options.endpoint : DEFAULT_API_KEY_ENDPOINT;
304
- const service = "getKeys" in options ? options : createDefaultHandler(endpoint);
272
+ }), X = (t) => {
273
+ const n = "endpoint" in t ? t.endpoint : G, a = "getKeys" in t ? t : H(n);
305
274
  return {
306
- getIdentities: async (context) => {
275
+ getIdentities: async (r) => {
307
276
  try {
308
- const keys = await service.getKeys(context);
309
- return keys.map((key) => ({
310
- authorizeRequest: (request) => {
311
- request.headers.set("Authorization", `Bearer ${key.key}`);
312
- return request;
313
- },
314
- id: key.id,
315
- label: key.description ?? key.id
277
+ return (await a.getKeys(r)).map((s) => ({
278
+ authorizeRequest: (c) => (c.headers.set("Authorization", `Bearer ${s.key}`), c),
279
+ id: s.id,
280
+ label: s.description ?? s.id
316
281
  }));
317
282
  } catch {
318
283
  return [];
319
284
  }
320
285
  },
321
- getRoutes: () => {
322
- return [
323
- {
324
- element: /* @__PURE__ */ jsxRuntimeExports.jsx(ProtectedRoute, {}),
325
- errorElement: /* @__PURE__ */ jsxRuntimeExports.jsx(RouterError, {}),
326
- children: [
327
- {
328
- path: "/settings/api-keys",
329
- element: /* @__PURE__ */ jsxRuntimeExports.jsx(SettingsApiKeys, { service })
330
- },
331
- {
332
- path: "/settings/api-keys/new",
333
- element: /* @__PURE__ */ jsxRuntimeExports.jsx(CreateApiKey, { service })
334
- }
335
- ]
336
- }
337
- ];
338
- }
286
+ getRoutes: () => [
287
+ {
288
+ element: /* @__PURE__ */ e.jsx(F, {}),
289
+ errorElement: /* @__PURE__ */ e.jsx(w, {}),
290
+ children: [
291
+ {
292
+ path: "/settings/api-keys",
293
+ element: /* @__PURE__ */ e.jsx(_, { service: a })
294
+ },
295
+ {
296
+ path: "/settings/api-keys/new",
297
+ element: /* @__PURE__ */ e.jsx(T, { service: a })
298
+ }
299
+ ]
300
+ }
301
+ ]
339
302
  };
340
303
  };
341
304
  export {
342
- apiKeyPlugin
305
+ X as apiKeyPlugin
343
306
  };
344
307
  //# sourceMappingURL=zudoku.plugin-api-keys.js.map