zudoku 0.3.0-dev.53 → 0.3.0-dev.55

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