zudoku 0.48.1 → 0.48.3
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/dist/config/loader.js +1 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js +3 -2
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -1
- package/dist/lib/plugins/api-keys/index.js +23 -2
- package/dist/lib/plugins/api-keys/index.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/ui/Alert.d.ts +5 -4
- package/dist/lib/ui/Alert.js +12 -10
- package/dist/lib/ui/Alert.js.map +1 -1
- package/dist/lib/ui/CodeBlock.d.ts +1 -2
- package/dist/lib/ui/CodeBlock.js +9 -9
- package/dist/lib/ui/CodeBlock.js.map +1 -1
- package/dist/lib/ui/EmbeddedCodeBlock.d.ts +15 -0
- package/dist/lib/ui/EmbeddedCodeBlock.js +18 -0
- package/dist/lib/ui/EmbeddedCodeBlock.js.map +1 -0
- package/dist/lib/ui/SyntaxHighlight.d.ts +3 -1
- package/dist/lib/ui/SyntaxHighlight.js +3 -2
- package/dist/lib/ui/SyntaxHighlight.js.map +1 -1
- package/dist/lib/util/MdxComponents.d.ts +3 -1
- package/dist/vite/config.js +11 -2
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/plugin-frontmatter.js +2 -0
- package/dist/vite/plugin-frontmatter.js.map +1 -1
- package/lib/{Markdown-DCAIYXF5.js → Markdown-BQ8YqLsz.js} +80 -88
- package/lib/{Markdown-DCAIYXF5.js.map → Markdown-BQ8YqLsz.js.map} +1 -1
- package/lib/{MdxPage-Cf9YXWoC.js → MdxPage-DJvKmI-r.js} +3 -3
- package/lib/{MdxPage-Cf9YXWoC.js.map → MdxPage-DJvKmI-r.js.map} +1 -1
- package/lib/{OasProvider-JMVTfG6_.js → OasProvider-BC0q5m3u.js} +2 -2
- package/lib/{OasProvider-JMVTfG6_.js.map → OasProvider-BC0q5m3u.js.map} +1 -1
- package/lib/{OperationList-m4tFCI4S.js → OperationList-Dpip6ozi.js} +6 -5
- package/lib/{OperationList-m4tFCI4S.js.map → OperationList-Dpip6ozi.js.map} +1 -1
- package/lib/{SchemaList-_wRy4aQ0.js → SchemaList-t4BIfh6Z.js} +5 -5
- package/lib/{SchemaList-_wRy4aQ0.js.map → SchemaList-t4BIfh6Z.js.map} +1 -1
- package/lib/{SchemaView-CRl_cQYH.js → SchemaView-CLxthVcA.js} +3 -3
- package/lib/{SchemaView-CRl_cQYH.js.map → SchemaView-CLxthVcA.js.map} +1 -1
- package/lib/{Slot-BkYrj_uC.js → Slot-CSEIvwwO.js} +57 -56
- package/lib/Slot-CSEIvwwO.js.map +1 -0
- package/lib/{SyntaxHighlight-CH9OUJre.js → SyntaxHighlight-C5ja40ix.js} +715 -714
- package/lib/{SyntaxHighlight-CH9OUJre.js.map → SyntaxHighlight-C5ja40ix.js.map} +1 -1
- package/lib/{Toc-DRxqEsFc.js → Toc-BS0f4GTe.js} +2 -2
- package/lib/{Toc-DRxqEsFc.js.map → Toc-BS0f4GTe.js.map} +1 -1
- package/lib/{circular-wJaV4vh_.js → circular-DfOaDE_x.js} +2 -2
- package/lib/{circular-wJaV4vh_.js.map → circular-DfOaDE_x.js.map} +1 -1
- package/lib/{createServer-DN5AJLcN.js → createServer-DjOMygls.js} +3 -3
- package/lib/{createServer-DN5AJLcN.js.map → createServer-DjOMygls.js.map} +1 -1
- package/lib/{index-DJVaRmzI.js → index-DW2qmCJa.js} +7 -7
- package/lib/{index-DJVaRmzI.js.map → index-DW2qmCJa.js.map} +1 -1
- package/lib/ui/Alert.js +54 -38
- package/lib/ui/Alert.js.map +1 -1
- package/lib/ui/CodeBlock.js +54 -62
- package/lib/ui/CodeBlock.js.map +1 -1
- package/lib/ui/EmbeddedCodeBlock.js +80 -0
- package/lib/ui/EmbeddedCodeBlock.js.map +1 -0
- package/lib/ui/SyntaxHighlight.js +3 -2
- package/lib/ui/SyntaxHighlight.js.map +1 -1
- package/lib/zudoku.components.js +2 -2
- package/lib/zudoku.plugin-api-catalog.js +1 -1
- package/lib/zudoku.plugin-api-keys.js +268 -200
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +1 -1
- package/package.json +1 -1
- package/src/app/main.css +4 -1
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +22 -3
- package/src/lib/plugins/api-keys/index.tsx +26 -4
- package/src/lib/plugins/openapi/Sidecar.tsx +1 -0
- package/src/lib/ui/Alert.tsx +44 -38
- package/src/lib/ui/CodeBlock.tsx +39 -53
- package/src/lib/ui/EmbeddedCodeBlock.tsx +94 -0
- package/src/lib/ui/SyntaxHighlight.tsx +11 -3
- package/lib/Slot-BkYrj_uC.js.map +0 -1
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-C5mzlN2N.js";
|
|
2
|
-
import { CheckIcon as
|
|
3
|
-
import { D as
|
|
4
|
-
import { i as
|
|
5
|
-
import { O as
|
|
6
|
-
import { i as
|
|
2
|
+
import { CircleSlashIcon as M, CheckIcon as V, XIcon as ae, PencilLineIcon as oe, RefreshCwIcon as le, EyeOffIcon as ce, EyeIcon as de, CopyIcon as ue, TrashIcon as fe, KeyRoundIcon as he } from "lucide-react";
|
|
3
|
+
import { D as pe, S as B, R as me } from "./Slot-CSEIvwwO.js";
|
|
4
|
+
import { i as D } from "./invariant-DAFpPywt.js";
|
|
5
|
+
import { O as xe, L as J } from "./chunk-DQRVZFIR-BblmKnHy.js";
|
|
6
|
+
import { i as ye, k as ge, e as je, d as ve } from "./hook-CHXroBFt.js";
|
|
7
7
|
import { Button as j } from "./ui/Button.js";
|
|
8
|
-
import { u as
|
|
9
|
-
import * as
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { c as
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
import { u as S } from "./useMutation-N4ockVKi.js";
|
|
9
|
+
import * as F from "react";
|
|
10
|
+
import Ce, { createContext as O, useRef as P, useLayoutEffect as we, useEffect as W, useId as Q, useContext as _, useInsertionEffect as ke, useMemo as $, useCallback as be, Children as Ee, isValidElement as Ne, useState as E } from "react";
|
|
11
|
+
import { c as Pe } from "./index-DI5SPFK9.js";
|
|
12
|
+
import { c as N } from "./cn-wvCW-ho6.js";
|
|
13
|
+
import { C as De, a as Ie } from "./Card-DPhGbYUM.js";
|
|
14
|
+
import { D as X, e as Y, a as G, b as Z, c as ee, d as te, f as se, g as A } from "./Dialog-BxpuVLh9.js";
|
|
15
|
+
import { Input as Ke } from "./ui/Input.js";
|
|
16
|
+
const Re = () => {
|
|
17
|
+
const t = ye();
|
|
18
|
+
return t.isAuthEnabled && t.isPending ? null : t.isAuthenticated ? /* @__PURE__ */ e.jsx(xe, {}) : t.isAuthEnabled ? /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: [
|
|
18
19
|
"Please login first to view this page",
|
|
19
20
|
/* @__PURE__ */ e.jsx(j, { onClick: () => t.login(), children: "Login" })
|
|
20
|
-
] }) : /* @__PURE__ */ e.jsx("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: /* @__PURE__ */ e.jsxs(
|
|
21
|
+
] }) : /* @__PURE__ */ e.jsx("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: /* @__PURE__ */ e.jsxs(pe, { className: "max-w-[600px]", children: [
|
|
21
22
|
"Authentication needs to be enabled for API keys to work. Enable it in your Zudoku configuration under ",
|
|
22
23
|
/* @__PURE__ */ e.jsx("code", { children: "authentication" }),
|
|
23
24
|
"."
|
|
24
25
|
] }) });
|
|
25
|
-
},
|
|
26
|
-
function
|
|
27
|
-
const i =
|
|
26
|
+
}, Ae = O({});
|
|
27
|
+
function ne(t) {
|
|
28
|
+
const i = P(null);
|
|
28
29
|
return i.current === null && (i.current = t()), i.current;
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
-
function
|
|
31
|
+
const Te = typeof window < "u", ze = Te ? we : W, ie = /* @__PURE__ */ O(null);
|
|
32
|
+
function Me(t) {
|
|
32
33
|
return typeof t == "object" && t !== null;
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
35
|
+
function Se(t) {
|
|
36
|
+
return Me(t) && "offsetHeight" in t;
|
|
36
37
|
}
|
|
37
|
-
const
|
|
38
|
+
const qe = O({
|
|
38
39
|
transformPagePoint: (t) => t,
|
|
39
40
|
isStatic: !1,
|
|
40
41
|
reducedMotion: "never"
|
|
41
42
|
});
|
|
42
|
-
class
|
|
43
|
+
class Le extends F.Component {
|
|
43
44
|
getSnapshotBeforeUpdate(i) {
|
|
44
45
|
const s = this.props.childRef.current;
|
|
45
46
|
if (s && i.isPresent && !this.props.isPresent) {
|
|
46
|
-
const n = s.offsetParent, o =
|
|
47
|
+
const n = s.offsetParent, o = Se(n) && n.offsetWidth || 0, r = this.props.sizeRef.current;
|
|
47
48
|
r.height = s.offsetHeight || 0, r.width = s.offsetWidth || 0, r.top = s.offsetTop, r.left = s.offsetLeft, r.right = o - r.width - r.left;
|
|
48
49
|
}
|
|
49
50
|
return null;
|
|
@@ -57,223 +58,277 @@ class Te extends S.Component {
|
|
|
57
58
|
return this.props.children;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
-
const n =
|
|
61
|
+
function $e({ children: t, isPresent: i, anchorX: s }) {
|
|
62
|
+
const n = Q(), o = P(null), r = P({
|
|
62
63
|
width: 0,
|
|
63
64
|
height: 0,
|
|
64
65
|
top: 0,
|
|
65
66
|
left: 0,
|
|
66
67
|
right: 0
|
|
67
|
-
}), { nonce: u } =
|
|
68
|
-
return
|
|
69
|
-
const { width:
|
|
70
|
-
if (i || !o.current || !
|
|
68
|
+
}), { nonce: u } = _(qe);
|
|
69
|
+
return ke(() => {
|
|
70
|
+
const { width: x, height: f, top: h, left: d, right: l } = r.current;
|
|
71
|
+
if (i || !o.current || !x || !f)
|
|
71
72
|
return;
|
|
72
|
-
const y = s === "left" ? `left: ${
|
|
73
|
+
const y = s === "left" ? `left: ${d}` : `right: ${l}`;
|
|
73
74
|
o.current.dataset.motionPopId = n;
|
|
74
|
-
const
|
|
75
|
-
return u && (
|
|
75
|
+
const p = document.createElement("style");
|
|
76
|
+
return u && (p.nonce = u), document.head.appendChild(p), p.sheet && p.sheet.insertRule(`
|
|
76
77
|
[data-motion-pop-id="${n}"] {
|
|
77
78
|
position: absolute !important;
|
|
78
|
-
width: ${
|
|
79
|
+
width: ${x}px !important;
|
|
79
80
|
height: ${f}px !important;
|
|
80
81
|
${y}px !important;
|
|
81
|
-
top: ${
|
|
82
|
+
top: ${h}px !important;
|
|
82
83
|
}
|
|
83
84
|
`), () => {
|
|
84
|
-
document.head.contains(
|
|
85
|
+
document.head.contains(p) && document.head.removeChild(p);
|
|
85
86
|
};
|
|
86
|
-
}, [i]), e.jsx(
|
|
87
|
+
}, [i]), e.jsx(Le, { isPresent: i, childRef: o, sizeRef: r, children: F.cloneElement(t, { ref: o }) });
|
|
87
88
|
}
|
|
88
|
-
const
|
|
89
|
-
const f =
|
|
90
|
-
let
|
|
91
|
-
id:
|
|
89
|
+
const Fe = ({ children: t, initial: i, isPresent: s, onExitComplete: n, custom: o, presenceAffectsLayout: r, mode: u, anchorX: x }) => {
|
|
90
|
+
const f = ne(Oe), h = Q();
|
|
91
|
+
let d = !0, l = $(() => (d = !1, {
|
|
92
|
+
id: h,
|
|
92
93
|
initial: i,
|
|
93
94
|
isPresent: s,
|
|
94
95
|
custom: o,
|
|
95
96
|
onExitComplete: (y) => {
|
|
96
97
|
f.set(y, !0);
|
|
97
|
-
for (const
|
|
98
|
-
if (!
|
|
98
|
+
for (const p of f.values())
|
|
99
|
+
if (!p)
|
|
99
100
|
return;
|
|
100
101
|
n && n();
|
|
101
102
|
},
|
|
102
103
|
register: (y) => (f.set(y, !1), () => f.delete(y))
|
|
103
104
|
}), [s, f, n]);
|
|
104
|
-
return r &&
|
|
105
|
-
f.forEach((y,
|
|
106
|
-
}, [s]),
|
|
105
|
+
return r && d && (l = { ...l }), $(() => {
|
|
106
|
+
f.forEach((y, p) => f.set(p, !1));
|
|
107
|
+
}, [s]), F.useEffect(() => {
|
|
107
108
|
!s && !f.size && n && n();
|
|
108
|
-
}, [s]), u === "popLayout" && (t = e.jsx(
|
|
109
|
+
}, [s]), u === "popLayout" && (t = e.jsx($e, { isPresent: s, anchorX: x, children: t })), e.jsx(ie.Provider, { value: l, children: t });
|
|
109
110
|
};
|
|
110
|
-
function
|
|
111
|
+
function Oe() {
|
|
111
112
|
return /* @__PURE__ */ new Map();
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
-
const i =
|
|
114
|
+
function Qe(t = !0) {
|
|
115
|
+
const i = _(ie);
|
|
115
116
|
if (i === null)
|
|
116
117
|
return [!0, null];
|
|
117
|
-
const { isPresent: s, onExitComplete: n, register: o } = i, r =
|
|
118
|
-
|
|
118
|
+
const { isPresent: s, onExitComplete: n, register: o } = i, r = Q();
|
|
119
|
+
W(() => {
|
|
119
120
|
if (t)
|
|
120
121
|
return o(r);
|
|
121
122
|
}, [t]);
|
|
122
|
-
const u =
|
|
123
|
+
const u = be(() => t && n && n(r), [r, n, t]);
|
|
123
124
|
return !s && n ? [!1, u] : [!0];
|
|
124
125
|
}
|
|
125
|
-
const
|
|
126
|
-
function
|
|
126
|
+
const I = (t) => t.key || "";
|
|
127
|
+
function U(t) {
|
|
127
128
|
const i = [];
|
|
128
|
-
return
|
|
129
|
-
|
|
129
|
+
return Ee.forEach(t, (s) => {
|
|
130
|
+
Ne(s) && i.push(s);
|
|
130
131
|
}), i;
|
|
131
132
|
}
|
|
132
|
-
const
|
|
133
|
-
const [f,
|
|
134
|
-
|
|
135
|
-
y.current = !1,
|
|
136
|
-
for (let w = 0; w <
|
|
137
|
-
const g =
|
|
138
|
-
|
|
133
|
+
const _e = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presenceAffectsLayout: o = !0, mode: r = "sync", propagate: u = !1, anchorX: x = "left" }) => {
|
|
134
|
+
const [f, h] = Qe(u), d = $(() => U(t), [t]), l = u && !f ? [] : d.map(I), y = P(!0), p = P(d), k = ne(() => /* @__PURE__ */ new Map()), [a, c] = E(d), [m, C] = E(d);
|
|
135
|
+
ze(() => {
|
|
136
|
+
y.current = !1, p.current = d;
|
|
137
|
+
for (let w = 0; w < m.length; w++) {
|
|
138
|
+
const g = I(m[w]);
|
|
139
|
+
l.includes(g) ? k.delete(g) : k.get(g) !== !0 && k.set(g, !1);
|
|
139
140
|
}
|
|
140
|
-
}, [
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
143
|
-
let w = [...
|
|
144
|
-
for (let g = 0; g <
|
|
145
|
-
const b =
|
|
146
|
-
|
|
141
|
+
}, [m, l.length, l.join("-")]);
|
|
142
|
+
const v = [];
|
|
143
|
+
if (d !== a) {
|
|
144
|
+
let w = [...d];
|
|
145
|
+
for (let g = 0; g < m.length; g++) {
|
|
146
|
+
const b = m[g], z = I(b);
|
|
147
|
+
l.includes(z) || (w.splice(g, 0, b), v.push(b));
|
|
147
148
|
}
|
|
148
|
-
return r === "wait" &&
|
|
149
|
+
return r === "wait" && v.length && (w = v), C(U(w)), c(d), null;
|
|
149
150
|
}
|
|
150
|
-
process.env.NODE_ENV !== "production" && r === "wait" &&
|
|
151
|
-
const { forceRender:
|
|
152
|
-
return e.jsx(e.Fragment, { children:
|
|
153
|
-
const g =
|
|
151
|
+
process.env.NODE_ENV !== "production" && r === "wait" && m.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
|
|
152
|
+
const { forceRender: T } = _(Ae);
|
|
153
|
+
return e.jsx(e.Fragment, { children: m.map((w) => {
|
|
154
|
+
const g = I(w), b = u && !f ? !1 : d === m || l.includes(g), z = () => {
|
|
154
155
|
if (k.has(g))
|
|
155
156
|
k.set(g, !0);
|
|
156
157
|
else
|
|
157
158
|
return;
|
|
158
|
-
let
|
|
159
|
-
k.forEach((
|
|
160
|
-
|
|
161
|
-
}),
|
|
159
|
+
let H = !0;
|
|
160
|
+
k.forEach((re) => {
|
|
161
|
+
re || (H = !1);
|
|
162
|
+
}), H && (T?.(), C(p.current), u && h?.(), n && n());
|
|
162
163
|
};
|
|
163
|
-
return e.jsx(
|
|
164
|
+
return e.jsx(Fe, { isPresent: b, initial: !y.current || s ? void 0 : !1, custom: i, presenceAffectsLayout: o, mode: r, onExitComplete: b ? void 0 : z, anchorX: x, children: w }, g);
|
|
164
165
|
}) });
|
|
165
|
-
},
|
|
166
|
-
|
|
166
|
+
}, He = Pe(
|
|
167
|
+
"relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
|
|
168
|
+
{
|
|
169
|
+
variants: {
|
|
170
|
+
variant: {
|
|
171
|
+
default: "bg-card text-card-foreground",
|
|
172
|
+
destructive: "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
defaultVariants: {
|
|
176
|
+
variant: "default"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
function q({
|
|
181
|
+
className: t,
|
|
182
|
+
variant: i,
|
|
183
|
+
...s
|
|
184
|
+
}) {
|
|
185
|
+
return /* @__PURE__ */ e.jsx(
|
|
186
|
+
"div",
|
|
187
|
+
{
|
|
188
|
+
"data-slot": "alert",
|
|
189
|
+
role: "alert",
|
|
190
|
+
className: N(He({ variant: i }), t),
|
|
191
|
+
...s
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
function L({ className: t, ...i }) {
|
|
196
|
+
return /* @__PURE__ */ e.jsx(
|
|
197
|
+
"div",
|
|
198
|
+
{
|
|
199
|
+
"data-slot": "alert-title",
|
|
200
|
+
className: N(
|
|
201
|
+
"col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
|
|
202
|
+
t
|
|
203
|
+
),
|
|
204
|
+
...i
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
const Be = ({ service: t }) => {
|
|
209
|
+
const i = ge(), s = je(), [n, o] = E(
|
|
167
210
|
null
|
|
168
|
-
), [r, u] = E(""), { data:
|
|
211
|
+
), [r, u] = E(""), { data: x, isFetching: f } = ve({
|
|
169
212
|
queryFn: () => t.getConsumers(i),
|
|
170
213
|
queryKey: ["api-keys"],
|
|
171
214
|
retry: !1
|
|
172
|
-
}),
|
|
215
|
+
}), h = S({
|
|
173
216
|
mutationFn: ({
|
|
174
217
|
consumerId: a,
|
|
175
|
-
keyId:
|
|
218
|
+
keyId: c
|
|
176
219
|
}) => {
|
|
177
220
|
if (!t.deleteKey)
|
|
178
221
|
throw new Error("deleteKey not implemented");
|
|
179
|
-
return t.deleteKey(a,
|
|
222
|
+
return t.deleteKey(a, c, i);
|
|
180
223
|
},
|
|
181
|
-
onMutate: async ({ consumerId: a, keyId:
|
|
224
|
+
onMutate: async ({ consumerId: a, keyId: c }) => {
|
|
182
225
|
await s.cancelQueries({ queryKey: ["api-keys"] });
|
|
183
|
-
const
|
|
226
|
+
const m = s.getQueryData([
|
|
184
227
|
"api-keys"
|
|
185
228
|
]);
|
|
186
|
-
return s.setQueryData(["api-keys"], (
|
|
187
|
-
...
|
|
188
|
-
apiKeys:
|
|
189
|
-
} :
|
|
229
|
+
return s.setQueryData(["api-keys"], (C) => C && C.map((v) => v.id === a ? {
|
|
230
|
+
...v,
|
|
231
|
+
apiKeys: v.apiKeys.filter((T) => T.id !== c)
|
|
232
|
+
} : v)), { previousData: m };
|
|
190
233
|
},
|
|
191
|
-
onError: (a,
|
|
192
|
-
|
|
234
|
+
onError: (a, c, m) => {
|
|
235
|
+
m?.previousData && s.setQueryData(["api-keys"], m.previousData);
|
|
193
236
|
},
|
|
194
237
|
onSuccess: () => {
|
|
195
238
|
s.invalidateQueries({ queryKey: ["api-keys"] });
|
|
196
239
|
}
|
|
197
|
-
}),
|
|
240
|
+
}), d = S({
|
|
198
241
|
mutationFn: ({
|
|
199
242
|
consumerId: a,
|
|
200
|
-
label:
|
|
243
|
+
label: c
|
|
201
244
|
}) => {
|
|
202
245
|
if (!t.updateConsumer)
|
|
203
246
|
throw new Error("updateConsumer not implemented");
|
|
204
|
-
return t.updateConsumer({ id: a, label:
|
|
247
|
+
return t.updateConsumer({ id: a, label: c }, i);
|
|
205
248
|
},
|
|
206
|
-
onMutate: async ({ consumerId: a, label:
|
|
249
|
+
onMutate: async ({ consumerId: a, label: c }) => {
|
|
207
250
|
await s.cancelQueries({ queryKey: ["api-keys"] });
|
|
208
|
-
const
|
|
209
|
-
return s.setQueryData(["api-keys"], (
|
|
210
|
-
...
|
|
211
|
-
label:
|
|
212
|
-
} :
|
|
251
|
+
const m = s.getQueryData(["api-keys"]);
|
|
252
|
+
return s.setQueryData(["api-keys"], (C) => C && C.map((v) => v.id === a ? {
|
|
253
|
+
...v,
|
|
254
|
+
label: c
|
|
255
|
+
} : v)), { previousData: m };
|
|
213
256
|
},
|
|
214
|
-
onError: (a,
|
|
215
|
-
|
|
257
|
+
onError: (a, c, m) => {
|
|
258
|
+
m?.previousData && s.setQueryData(["api-keys"], m.previousData);
|
|
216
259
|
},
|
|
217
260
|
onSuccess: () => {
|
|
218
261
|
s.invalidateQueries({ queryKey: ["api-keys"] });
|
|
219
262
|
}
|
|
220
|
-
}),
|
|
263
|
+
}), l = S({
|
|
221
264
|
mutationFn: (a) => {
|
|
222
265
|
if (!t.rollKey)
|
|
223
266
|
throw new Error("rollKey not implemented");
|
|
224
267
|
return t.rollKey(a, i);
|
|
225
268
|
},
|
|
226
269
|
onSuccess: () => s.invalidateQueries({ queryKey: ["api-keys"] })
|
|
227
|
-
}), y = (a,
|
|
228
|
-
o(a), u(
|
|
229
|
-
},
|
|
230
|
-
r.trim() &&
|
|
270
|
+
}), y = (a, c) => {
|
|
271
|
+
o(a), u(c);
|
|
272
|
+
}, p = (a) => {
|
|
273
|
+
r.trim() && d.mutate({
|
|
231
274
|
consumerId: a,
|
|
232
275
|
label: r.trim()
|
|
233
276
|
}), o(null), u("");
|
|
234
277
|
}, k = () => {
|
|
235
278
|
o(null), u("");
|
|
236
279
|
};
|
|
237
|
-
return /* @__PURE__ */ e.jsxs("div", { className: "max-w-screen-
|
|
238
|
-
/* @__PURE__ */ e.jsx(
|
|
280
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "max-w-screen-md h-full pt-(--padding-content-top) pb-(--padding-content-bottom)", children: [
|
|
281
|
+
/* @__PURE__ */ e.jsx(B.Target, { name: "api-keys-list-page" }),
|
|
239
282
|
/* @__PURE__ */ e.jsxs("div", { className: "flex justify-between pb-3", children: [
|
|
240
283
|
/* @__PURE__ */ e.jsx("h1", { className: "font-medium text-2xl", children: "API Keys" }),
|
|
241
|
-
t.createKey && /* @__PURE__ */ e.jsx(j, { asChild: !0, children: /* @__PURE__ */ e.jsx(
|
|
284
|
+
t.createKey && /* @__PURE__ */ e.jsx(j, { asChild: !0, children: /* @__PURE__ */ e.jsx(J, { to: "/settings/api-keys/new", children: "Create API Key" }) })
|
|
242
285
|
] }),
|
|
243
286
|
/* @__PURE__ */ e.jsx("p", { children: "Create, manage, and monitor your API keys" }),
|
|
244
|
-
/* @__PURE__ */ e.jsx(
|
|
287
|
+
/* @__PURE__ */ e.jsx(B.Target, { name: "api-keys-list-page-before-keys" }),
|
|
245
288
|
/* @__PURE__ */ e.jsx("div", { className: "h-8" }),
|
|
246
|
-
/* @__PURE__ */ e.
|
|
289
|
+
l.isError && /* @__PURE__ */ e.jsxs(q, { variant: "destructive", className: "mb-4", children: [
|
|
290
|
+
/* @__PURE__ */ e.jsx(M, { size: 16 }),
|
|
291
|
+
/* @__PURE__ */ e.jsx(L, { children: l.error.message })
|
|
292
|
+
] }),
|
|
293
|
+
d.isError && /* @__PURE__ */ e.jsxs(q, { variant: "destructive", className: "mb-4", children: [
|
|
294
|
+
/* @__PURE__ */ e.jsx(M, { size: 16 }),
|
|
295
|
+
/* @__PURE__ */ e.jsx(L, { children: d.error.message })
|
|
296
|
+
] }),
|
|
297
|
+
h.isError && /* @__PURE__ */ e.jsxs(q, { variant: "destructive", className: "mb-4", children: [
|
|
298
|
+
/* @__PURE__ */ e.jsx(M, { size: 16 }),
|
|
299
|
+
/* @__PURE__ */ e.jsx(L, { children: h.error.message })
|
|
300
|
+
] }),
|
|
301
|
+
/* @__PURE__ */ e.jsx("div", { className: "", children: x.length === 0 ? /* @__PURE__ */ e.jsxs("div", { className: "flex col-span-full flex-col justify-center gap-4 items-center p-8 border rounded-sm bg-muted/30 text-muted-foreground", children: [
|
|
247
302
|
/* @__PURE__ */ e.jsxs("p", { className: "text-center", children: [
|
|
248
303
|
"You have no API keys yet.",
|
|
249
304
|
/* @__PURE__ */ e.jsx("br", {}),
|
|
250
305
|
t.createKey && "Get started and create your first key."
|
|
251
306
|
] }),
|
|
252
|
-
t.createKey && /* @__PURE__ */ e.jsx(j, { asChild: !0, variant: "outline", children: /* @__PURE__ */ e.jsx(
|
|
307
|
+
t.createKey && /* @__PURE__ */ e.jsx(j, { asChild: !0, variant: "outline", children: /* @__PURE__ */ e.jsx(J, { to: "/settings/api-keys/new", children: "Create API Key" }) })
|
|
253
308
|
] }) : /* @__PURE__ */ e.jsx(
|
|
254
309
|
"ul",
|
|
255
310
|
{
|
|
256
|
-
className:
|
|
311
|
+
className: N(
|
|
257
312
|
"grid grid-cols-1 divide-y divide-border col-span-6",
|
|
258
313
|
"lg:grid-cols-[1fr_min-content]"
|
|
259
314
|
),
|
|
260
|
-
children:
|
|
261
|
-
|
|
315
|
+
children: x.map((a) => /* @__PURE__ */ e.jsxs(
|
|
316
|
+
De,
|
|
262
317
|
{
|
|
263
318
|
className: "grid grid-cols-subgrid col-span-full items-center mb-4 group",
|
|
264
319
|
children: [
|
|
265
|
-
/* @__PURE__ */ e.jsxs(
|
|
320
|
+
/* @__PURE__ */ e.jsxs(Ie, { className: "border-b col-span-full grid-cols-subgrid grid", children: [
|
|
266
321
|
/* @__PURE__ */ e.jsxs("div", { className: "h-10 flex flex-col text-sm justify-center", children: [
|
|
267
322
|
/* @__PURE__ */ e.jsxs("div", { className: "font-medium text-lg flex items-center gap-2", children: [
|
|
268
323
|
n === a.id ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 w-full", children: [
|
|
269
324
|
/* @__PURE__ */ e.jsx(
|
|
270
|
-
|
|
325
|
+
Ke,
|
|
271
326
|
{
|
|
272
327
|
maxLength: 32,
|
|
273
328
|
value: r,
|
|
274
|
-
onChange: (
|
|
275
|
-
onKeyDown: (
|
|
276
|
-
|
|
329
|
+
onChange: (c) => u(c.target.value),
|
|
330
|
+
onKeyDown: (c) => {
|
|
331
|
+
c.key === "Enter" ? p(a.id) : c.key === "Escape" && k();
|
|
277
332
|
},
|
|
278
333
|
className: "text-lg font-medium",
|
|
279
334
|
autoFocus: !0
|
|
@@ -285,9 +340,9 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
285
340
|
{
|
|
286
341
|
size: "icon",
|
|
287
342
|
variant: "ghost",
|
|
288
|
-
onClick: () =>
|
|
343
|
+
onClick: () => p(a.id),
|
|
289
344
|
disabled: !r.trim(),
|
|
290
|
-
children: /* @__PURE__ */ e.jsx(
|
|
345
|
+
children: /* @__PURE__ */ e.jsx(V, { size: 16 })
|
|
291
346
|
}
|
|
292
347
|
),
|
|
293
348
|
/* @__PURE__ */ e.jsx(
|
|
@@ -296,7 +351,7 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
296
351
|
size: "icon",
|
|
297
352
|
variant: "ghost",
|
|
298
353
|
onClick: k,
|
|
299
|
-
children: /* @__PURE__ */ e.jsx(
|
|
354
|
+
children: /* @__PURE__ */ e.jsx(ae, { size: 16 })
|
|
300
355
|
}
|
|
301
356
|
)
|
|
302
357
|
] })
|
|
@@ -322,49 +377,49 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
322
377
|
{
|
|
323
378
|
variant: "ghost",
|
|
324
379
|
onClick: () => y(a.id, a.label),
|
|
325
|
-
className:
|
|
380
|
+
className: N(
|
|
326
381
|
"flex gap-2",
|
|
327
382
|
n === a.id && "opacity-0! pointer-events-none"
|
|
328
383
|
),
|
|
329
384
|
disabled: n === a.id,
|
|
330
385
|
children: [
|
|
331
|
-
/* @__PURE__ */ e.jsx(
|
|
386
|
+
/* @__PURE__ */ e.jsx(oe, { size: 16 }),
|
|
332
387
|
"Edit label"
|
|
333
388
|
]
|
|
334
389
|
}
|
|
335
390
|
),
|
|
336
|
-
t.rollKey && /* @__PURE__ */ e.jsxs(
|
|
337
|
-
/* @__PURE__ */ e.jsx(
|
|
391
|
+
t.rollKey && /* @__PURE__ */ e.jsxs(X, { children: [
|
|
392
|
+
/* @__PURE__ */ e.jsx(Y, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
|
|
338
393
|
j,
|
|
339
394
|
{
|
|
340
395
|
title: "Roll this key",
|
|
341
396
|
variant: "ghost",
|
|
342
|
-
disabled:
|
|
397
|
+
disabled: l.isPending,
|
|
343
398
|
className: "flex items-center gap-2",
|
|
344
399
|
children: [
|
|
345
400
|
/* @__PURE__ */ e.jsx(
|
|
346
|
-
|
|
401
|
+
le,
|
|
347
402
|
{
|
|
348
403
|
size: 16,
|
|
349
|
-
className:
|
|
404
|
+
className: l.isPending ? "animate-spin" : void 0
|
|
350
405
|
}
|
|
351
406
|
),
|
|
352
407
|
"Roll key"
|
|
353
408
|
]
|
|
354
409
|
}
|
|
355
410
|
) }),
|
|
356
|
-
/* @__PURE__ */ e.jsxs(
|
|
357
|
-
/* @__PURE__ */ e.jsxs(
|
|
358
|
-
/* @__PURE__ */ e.jsx(
|
|
359
|
-
/* @__PURE__ */ e.jsx(
|
|
411
|
+
/* @__PURE__ */ e.jsxs(G, { children: [
|
|
412
|
+
/* @__PURE__ */ e.jsxs(Z, { children: [
|
|
413
|
+
/* @__PURE__ */ e.jsx(ee, { children: "Roll API Key" }),
|
|
414
|
+
/* @__PURE__ */ e.jsx(te, { children: "Are you sure you want to roll this API key?" })
|
|
360
415
|
] }),
|
|
361
|
-
/* @__PURE__ */ e.jsxs(
|
|
362
|
-
/* @__PURE__ */ e.jsx(
|
|
363
|
-
/* @__PURE__ */ e.jsx(
|
|
416
|
+
/* @__PURE__ */ e.jsxs(se, { children: [
|
|
417
|
+
/* @__PURE__ */ e.jsx(A, { asChild: !0, children: /* @__PURE__ */ e.jsx(j, { variant: "outline", children: "Cancel" }) }),
|
|
418
|
+
/* @__PURE__ */ e.jsx(A, { asChild: !0, children: /* @__PURE__ */ e.jsx(
|
|
364
419
|
j,
|
|
365
420
|
{
|
|
366
421
|
onClick: () => {
|
|
367
|
-
|
|
422
|
+
l.mutate(a.id);
|
|
368
423
|
},
|
|
369
424
|
children: "Roll Key"
|
|
370
425
|
}
|
|
@@ -374,22 +429,22 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
374
429
|
] })
|
|
375
430
|
] })
|
|
376
431
|
] }),
|
|
377
|
-
/* @__PURE__ */ e.jsx("div", { className: "col-span-full grid-cols-subgrid grid", children: /* @__PURE__ */ e.jsx(
|
|
432
|
+
/* @__PURE__ */ e.jsx("div", { className: "col-span-full grid-cols-subgrid grid", children: /* @__PURE__ */ e.jsx(_e, { children: a.apiKeys.map((c) => /* @__PURE__ */ e.jsxs(Ce.Fragment, { children: [
|
|
378
433
|
/* @__PURE__ */ e.jsx(
|
|
379
|
-
|
|
434
|
+
Ue,
|
|
380
435
|
{
|
|
381
|
-
apiKey:
|
|
436
|
+
apiKey: c,
|
|
382
437
|
onDeleteKey: () => {
|
|
383
|
-
|
|
438
|
+
h.mutate({
|
|
384
439
|
consumerId: a.id,
|
|
385
|
-
keyId:
|
|
440
|
+
keyId: c.id
|
|
386
441
|
});
|
|
387
442
|
},
|
|
388
|
-
className:
|
|
443
|
+
className: h.variables?.keyId === c.id && (h.isPending || f) ? "opacity-10!" : void 0
|
|
389
444
|
}
|
|
390
445
|
),
|
|
391
446
|
/* @__PURE__ */ e.jsx("div", { className: "col-span-full h-px bg-border" })
|
|
392
|
-
] },
|
|
447
|
+
] }, c.id)) }) })
|
|
393
448
|
]
|
|
394
449
|
},
|
|
395
450
|
a.id
|
|
@@ -397,42 +452,42 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
397
452
|
}
|
|
398
453
|
) })
|
|
399
454
|
] });
|
|
400
|
-
},
|
|
455
|
+
}, Je = (t) => {
|
|
401
456
|
const i = /* @__PURE__ */ new Date(), s = new Date(t), n = Math.floor((i.getTime() - s.getTime()) / 1e3), o = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
402
457
|
return n < 60 ? o.format(-n, "second") : n < 3600 ? o.format(-Math.floor(n / 60), "minute") : n < 86400 ? o.format(-Math.floor(n / 3600), "hour") : n < 2592e3 ? o.format(-Math.floor(n / 86400), "day") : n < 31536e3 ? o.format(-Math.floor(n / 2592e3), "month") : o.format(-Math.floor(n / 31536e3), "year");
|
|
403
|
-
},
|
|
458
|
+
}, Ue = ({
|
|
404
459
|
apiKey: t,
|
|
405
460
|
onDeleteKey: i,
|
|
406
461
|
className: s
|
|
407
462
|
}) => {
|
|
408
|
-
const [n, o] = E(!1), [r, u] = E(!1), { key:
|
|
409
|
-
(new Date(
|
|
410
|
-
) : 1 / 0, y =
|
|
411
|
-
return /* @__PURE__ */ e.jsxs("div", { className:
|
|
463
|
+
const [n, o] = E(!1), [r, u] = E(!1), { key: x, createdOn: f, expiresOn: h } = t, d = h && new Date(h) < /* @__PURE__ */ new Date(), l = h ? Math.ceil(
|
|
464
|
+
(new Date(h).getTime() - (/* @__PURE__ */ new Date()).getTime()) / (1e3 * 60 * 60 * 24)
|
|
465
|
+
) : 1 / 0, y = l <= 7 && !d;
|
|
466
|
+
return /* @__PURE__ */ e.jsxs("div", { className: N("grid col-span-full grid-cols-subgrid p-6", s), children: [
|
|
412
467
|
/* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
413
468
|
/* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 items-center text-sm border rounded-md w-fit px-1", children: [
|
|
414
469
|
/* @__PURE__ */ e.jsxs("div", { className: "font-mono truncate h-9 items-center flex px-2 text-xs gap-2", children: [
|
|
415
470
|
/* @__PURE__ */ e.jsx(
|
|
416
471
|
"div",
|
|
417
472
|
{
|
|
418
|
-
className:
|
|
473
|
+
className: N(
|
|
419
474
|
"rounded-full w-2 h-2 bg-emerald-400 mr-2",
|
|
420
|
-
(y ||
|
|
475
|
+
(y || d) && "bg-neutral-200"
|
|
421
476
|
)
|
|
422
477
|
}
|
|
423
478
|
),
|
|
424
479
|
/* @__PURE__ */ e.jsxs("span", { children: [
|
|
425
|
-
/* @__PURE__ */ e.jsx("span", { className: n ? "" : "opacity-20", children: n ?
|
|
426
|
-
/* @__PURE__ */ e.jsx("span", { children:
|
|
480
|
+
/* @__PURE__ */ e.jsx("span", { className: n ? "" : "opacity-20", children: n ? x.slice(0, -5) : "**** ".repeat(x.slice(0, -5).length / 5) + "*".repeat(x.slice(0, -5).length % 5) }),
|
|
481
|
+
/* @__PURE__ */ e.jsx("span", { children: x.slice(-5) })
|
|
427
482
|
] })
|
|
428
483
|
] }),
|
|
429
484
|
/* @__PURE__ */ e.jsx(
|
|
430
485
|
j,
|
|
431
486
|
{
|
|
432
487
|
variant: "ghost",
|
|
433
|
-
onClick: () => o((
|
|
488
|
+
onClick: () => o((p) => !p),
|
|
434
489
|
size: "icon",
|
|
435
|
-
children: n ? /* @__PURE__ */ e.jsx(
|
|
490
|
+
children: n ? /* @__PURE__ */ e.jsx(ce, { size: 16 }) : /* @__PURE__ */ e.jsx(de, { size: 16 })
|
|
436
491
|
}
|
|
437
492
|
),
|
|
438
493
|
/* @__PURE__ */ e.jsx(
|
|
@@ -440,46 +495,46 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
440
495
|
{
|
|
441
496
|
variant: "ghost",
|
|
442
497
|
onClick: () => {
|
|
443
|
-
navigator.clipboard.writeText(
|
|
498
|
+
navigator.clipboard.writeText(x).then(() => {
|
|
444
499
|
u(!0), setTimeout(() => u(!1), 2e3);
|
|
445
500
|
});
|
|
446
501
|
},
|
|
447
502
|
size: "icon",
|
|
448
|
-
children: r ? /* @__PURE__ */ e.jsx(
|
|
503
|
+
children: r ? /* @__PURE__ */ e.jsx(V, { size: 16 }) : /* @__PURE__ */ e.jsx(ue, { size: 16 })
|
|
449
504
|
}
|
|
450
505
|
)
|
|
451
506
|
] }),
|
|
452
507
|
/* @__PURE__ */ e.jsxs("div", { className: "flex gap-1 mt-0.5 text-nowrap", children: [
|
|
453
508
|
f && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
454
509
|
"Created ",
|
|
455
|
-
|
|
510
|
+
Je(f),
|
|
456
511
|
"."
|
|
457
512
|
] }),
|
|
458
513
|
" ",
|
|
459
|
-
|
|
514
|
+
h && y && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
|
|
460
515
|
"Expires in ",
|
|
461
|
-
|
|
516
|
+
l,
|
|
462
517
|
" ",
|
|
463
|
-
|
|
518
|
+
l === 1 ? "day" : "days",
|
|
464
519
|
"."
|
|
465
520
|
] }),
|
|
466
|
-
|
|
521
|
+
h && d && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
|
|
467
522
|
"Expired",
|
|
468
523
|
" ",
|
|
469
|
-
|
|
524
|
+
l === 0 ? "today." : `${l * -1} days ago.`
|
|
470
525
|
] })
|
|
471
526
|
] })
|
|
472
527
|
] }),
|
|
473
|
-
/* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children:
|
|
474
|
-
/* @__PURE__ */ e.jsx(
|
|
475
|
-
/* @__PURE__ */ e.jsxs(
|
|
476
|
-
/* @__PURE__ */ e.jsxs(
|
|
477
|
-
/* @__PURE__ */ e.jsx(
|
|
478
|
-
/* @__PURE__ */ e.jsx(
|
|
528
|
+
/* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children: h && i && /* @__PURE__ */ e.jsxs(X, { children: [
|
|
529
|
+
/* @__PURE__ */ e.jsx(Y, { asChild: !0, children: /* @__PURE__ */ e.jsx(j, { variant: "ghost", size: "icon", children: /* @__PURE__ */ e.jsx(fe, { size: 16 }) }) }),
|
|
530
|
+
/* @__PURE__ */ e.jsxs(G, { children: [
|
|
531
|
+
/* @__PURE__ */ e.jsxs(Z, { children: [
|
|
532
|
+
/* @__PURE__ */ e.jsx(ee, { children: "Delete API Key" }),
|
|
533
|
+
/* @__PURE__ */ e.jsx(te, { children: "Are you sure you want to delete this API key?" })
|
|
479
534
|
] }),
|
|
480
|
-
/* @__PURE__ */ e.jsxs(
|
|
481
|
-
/* @__PURE__ */ e.jsx(
|
|
482
|
-
/* @__PURE__ */ e.jsx(
|
|
535
|
+
/* @__PURE__ */ e.jsxs(se, { children: [
|
|
536
|
+
/* @__PURE__ */ e.jsx(A, { asChild: !0, children: /* @__PURE__ */ e.jsx(j, { variant: "outline", children: "Cancel" }) }),
|
|
537
|
+
/* @__PURE__ */ e.jsx(A, { asChild: !0, children: /* @__PURE__ */ e.jsx(
|
|
483
538
|
j,
|
|
484
539
|
{
|
|
485
540
|
onClick: () => {
|
|
@@ -492,23 +547,36 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
492
547
|
] })
|
|
493
548
|
] }) })
|
|
494
549
|
] });
|
|
495
|
-
},
|
|
550
|
+
}, K = "https://api.zuploedge.com/v2/client", Ve = async (t) => {
|
|
551
|
+
try {
|
|
552
|
+
return await t.json();
|
|
553
|
+
} catch {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
}, R = async (t) => {
|
|
557
|
+
const i = t.headers.get("content-type");
|
|
558
|
+
if (!t.ok && i?.includes("application/problem+json")) {
|
|
559
|
+
const s = await Ve(t);
|
|
560
|
+
if (s.type && s.title)
|
|
561
|
+
throw new Error(s.detail ?? s.title);
|
|
562
|
+
}
|
|
563
|
+
}, We = (t) => ({
|
|
496
564
|
deleteKey: async (i, s, n) => {
|
|
497
565
|
const o = new Request(
|
|
498
|
-
|
|
566
|
+
K + `/${t}/consumers/${i}/keys/${s}`,
|
|
499
567
|
{
|
|
500
568
|
method: "DELETE"
|
|
501
569
|
}
|
|
502
570
|
);
|
|
503
571
|
await n.signRequest(o);
|
|
504
572
|
const r = await fetch(o);
|
|
505
|
-
|
|
573
|
+
await R(r), D(r.ok, "Failed to delete API key");
|
|
506
574
|
},
|
|
507
575
|
updateConsumer: async (i, s) => {
|
|
508
576
|
const n = await fetch(
|
|
509
577
|
await s.signRequest(
|
|
510
578
|
new Request(
|
|
511
|
-
|
|
579
|
+
K + `/${t}/consumers/${i.id}`,
|
|
512
580
|
{
|
|
513
581
|
method: "PATCH",
|
|
514
582
|
headers: {
|
|
@@ -521,13 +589,13 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
521
589
|
)
|
|
522
590
|
)
|
|
523
591
|
);
|
|
524
|
-
|
|
592
|
+
await R(n), D(n.ok, "Failed to update API key description");
|
|
525
593
|
},
|
|
526
594
|
rollKey: async (i, s) => {
|
|
527
595
|
const n = await fetch(
|
|
528
596
|
await s.signRequest(
|
|
529
597
|
new Request(
|
|
530
|
-
|
|
598
|
+
K + `/${t}/consumers/${i}/roll-key`,
|
|
531
599
|
{
|
|
532
600
|
method: "POST",
|
|
533
601
|
headers: {
|
|
@@ -538,30 +606,30 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
538
606
|
)
|
|
539
607
|
)
|
|
540
608
|
);
|
|
541
|
-
|
|
609
|
+
await R(n), D(n.ok, "Failed to delete API key");
|
|
542
610
|
},
|
|
543
611
|
getConsumers: async (i) => {
|
|
544
612
|
const s = new Request(
|
|
545
|
-
|
|
613
|
+
K + `/${t}/consumers`
|
|
546
614
|
);
|
|
547
615
|
await i.signRequest(s);
|
|
548
616
|
const n = await fetch(s);
|
|
549
|
-
return
|
|
617
|
+
return await R(n), D(n.ok, "Failed to fetch API keys"), (await n.json()).data.map((r) => ({
|
|
550
618
|
id: r.id,
|
|
551
|
-
label: r.label
|
|
619
|
+
label: r.label ?? r.subject ?? "API Key",
|
|
552
620
|
apiKeys: r.apiKeys.data,
|
|
553
621
|
key: r.apiKeys.data.at(0)
|
|
554
622
|
}));
|
|
555
623
|
}
|
|
556
|
-
}),
|
|
557
|
-
const i = "deploymentName" in t ?
|
|
624
|
+
}), dt = (t) => t, ut = (t) => {
|
|
625
|
+
const i = "deploymentName" in t ? We(t.deploymentName) : t;
|
|
558
626
|
return {
|
|
559
627
|
getProfileMenuItems: () => [
|
|
560
628
|
{
|
|
561
629
|
label: "API Keys",
|
|
562
630
|
path: "/settings/api-keys",
|
|
563
631
|
category: "middle",
|
|
564
|
-
icon:
|
|
632
|
+
icon: he
|
|
565
633
|
}
|
|
566
634
|
],
|
|
567
635
|
getIdentities: async (s) => {
|
|
@@ -572,7 +640,7 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
572
640
|
`Bearer ${o.apiKeys.at(0)?.key}`
|
|
573
641
|
), r),
|
|
574
642
|
id: o.id,
|
|
575
|
-
label: o.
|
|
643
|
+
label: o.label
|
|
576
644
|
}));
|
|
577
645
|
} catch {
|
|
578
646
|
return [];
|
|
@@ -580,12 +648,12 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
580
648
|
},
|
|
581
649
|
getRoutes: () => [
|
|
582
650
|
{
|
|
583
|
-
element: /* @__PURE__ */ e.jsx(
|
|
584
|
-
errorElement: /* @__PURE__ */ e.jsx(
|
|
651
|
+
element: /* @__PURE__ */ e.jsx(Re, {}),
|
|
652
|
+
errorElement: /* @__PURE__ */ e.jsx(me, {}),
|
|
585
653
|
children: [
|
|
586
654
|
{
|
|
587
655
|
path: "/settings/api-keys",
|
|
588
|
-
element: /* @__PURE__ */ e.jsx(
|
|
656
|
+
element: /* @__PURE__ */ e.jsx(Be, { service: i })
|
|
589
657
|
}
|
|
590
658
|
// {
|
|
591
659
|
// path: "/settings/api-keys/new",
|
|
@@ -597,7 +665,7 @@ const Le = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presen
|
|
|
597
665
|
};
|
|
598
666
|
};
|
|
599
667
|
export {
|
|
600
|
-
|
|
601
|
-
|
|
668
|
+
ut as apiKeyPlugin,
|
|
669
|
+
dt as createApiKeyService
|
|
602
670
|
};
|
|
603
671
|
//# sourceMappingURL=zudoku.plugin-api-keys.js.map
|