zudoku 0.3.0-dev.54 → 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.
- package/lib/AnchorLink-BaXHjhF-.js +989 -0
- package/lib/{AnchorLink-BCN_a_Uz.js.map → AnchorLink-BaXHjhF-.js.map} +1 -1
- package/lib/Combination-BfufJFkX.js +1365 -0
- package/lib/{Combination-B0Iu6mhJ.js.map → Combination-BfufJFkX.js.map} +1 -1
- package/lib/DevPortalProvider-GjdO0Xr-.js +1610 -0
- package/lib/{DevPortalProvider-Do9oJqme.js.map → DevPortalProvider-GjdO0Xr-.js.map} +1 -1
- package/lib/Markdown-B8nPVql1.js +19708 -0
- package/lib/Markdown-B8nPVql1.js.map +1 -0
- package/lib/MdxPage-Dlujuj-J.js +223 -0
- package/lib/{MdxPage-Bsc79cD-.js.map → MdxPage-Dlujuj-J.js.map} +1 -1
- package/lib/OperationList-krPgt6sE.js +8041 -0
- package/lib/{OperationList-K-JWBxau.js.map → OperationList-krPgt6sE.js.map} +1 -1
- package/lib/Playground-DOHxca0P.js +539 -0
- package/lib/{Playground-Czy7ha9z.js.map → Playground-DOHxca0P.js.map} +1 -1
- package/lib/Route-CR6TEwVC.js +13 -0
- package/lib/{Route-D-egsGHx.js.map → Route-CR6TEwVC.js.map} +1 -1
- package/lib/Select-Boi_pe3L.js +5298 -0
- package/lib/{Select-CcBbwJ2R.js.map → Select-Boi_pe3L.js.map} +1 -1
- package/lib/Spinner-oU0QJmi_.js +16 -0
- package/lib/{Spinner-C9_Opdev.js.map → Spinner-oU0QJmi_.js.map} +1 -1
- package/lib/_commonjsHelpers-BxmBWJD2.js +34 -0
- package/lib/_commonjsHelpers-BxmBWJD2.js.map +1 -0
- package/lib/assets/index-CpIig0AX.js +6341 -0
- package/lib/{index-pI9JkN46.js.map → assets/index-CpIig0AX.js.map} +1 -1
- package/lib/assets/worker-B5k2aBV9.js +18921 -0
- package/lib/assets/{worker-BjPv-hjP.js.map → worker-B5k2aBV9.js.map} +1 -1
- package/lib/context-BoN_3uxi.js +17 -0
- package/lib/{context-_fYfJFgk.js.map → context-BoN_3uxi.js.map} +1 -1
- package/lib/hook-CIuFuyBT.js +90 -0
- package/lib/{hook-CKqQERWo.js.map → hook-CIuFuyBT.js.map} +1 -1
- package/lib/index-BL1P4Gqq.js +280 -0
- package/lib/{index-ByHya67R.js.map → index-BL1P4Gqq.js.map} +1 -1
- package/lib/index-Bn03IPZt.js +6341 -0
- package/lib/{assets/index-BPdJm2ty.js.map → index-Bn03IPZt.js.map} +1 -1
- package/lib/{index-jsFBaizC.js → index-Dih8IAqw.js} +103 -83
- package/lib/{index-jsFBaizC.js.map → index-Dih8IAqw.js.map} +1 -1
- package/lib/index-FprhHF51.js +253 -0
- package/lib/{index-DseBZFJ-.js.map → index-FprhHF51.js.map} +1 -1
- package/lib/jsx-runtime-DvZ6OKMM.js +2110 -0
- package/lib/{jsx-runtime-CJZJivg2.js.map → jsx-runtime-DvZ6OKMM.js.map} +1 -1
- package/lib/mutation-DWY9x2Uc.js +250 -0
- package/lib/{mutation-DjbQSHzT.js.map → mutation-DWY9x2Uc.js.map} +1 -1
- package/lib/prism-bash.min-BtBk0onv.js +7 -0
- package/lib/{prism-bash.min-DadFsM4Z.js.map → prism-bash.min-BtBk0onv.js.map} +1 -1
- package/lib/prism-csharp.min-Cv7D49bv.js +30 -0
- package/lib/{prism-csharp.min-Yizuc34Y.js.map → prism-csharp.min-Cv7D49bv.js.map} +1 -1
- package/lib/prism-java.min-tNK-JX6x.js +7 -0
- package/lib/{prism-java.min-d5iT_mOd.js.map → prism-java.min-tNK-JX6x.js.map} +1 -1
- package/lib/prism-json.min-Cdtv-CME.js +2 -0
- package/lib/{prism-json.min-B1GJqK1k.js.map → prism-json.min-Cdtv-CME.js.map} +1 -1
- package/lib/prism-markup-templating-iotg2sCU.js +94 -0
- package/lib/{prism-markup-templating-DZrrEs0A.js.map → prism-markup-templating-iotg2sCU.js.map} +1 -1
- package/lib/prism-objectivec.min-CY4WGixz.js +2 -0
- package/lib/{prism-objectivec.min-BXSWqpJJ.js.map → prism-objectivec.min-CY4WGixz.js.map} +1 -1
- package/lib/prism-php.min-T6sIVgED.js +11 -0
- package/lib/{prism-php.min-o7FpoMP_.js.map → prism-php.min-T6sIVgED.js.map} +1 -1
- package/lib/prism-ruby.min-B-2KAa4y.js +8 -0
- package/lib/{prism-ruby.min-C7LwcKyz.js.map → prism-ruby.min-B-2KAa4y.js.map} +1 -1
- package/lib/router-ButO1QyY.js +4062 -0
- package/lib/{router-CBw2vqJE.js.map → router-ButO1QyY.js.map} +1 -1
- package/lib/slugify-CmS97Vy8.js +50 -0
- package/lib/{slugify-CiPVjteN.js.map → slugify-CmS97Vy8.js.map} +1 -1
- package/lib/state-CmGfNKhR.js +436 -0
- package/lib/{state-DKdaQzvh.js.map → state-CmGfNKhR.js.map} +1 -1
- package/lib/urql-DtVKPBx_.js +2567 -0
- package/lib/{urql-DEKdguFl.js.map → urql-DtVKPBx_.js.map} +1 -1
- package/lib/util-B5KX4h4M.js +55 -0
- package/lib/{util-_jwUlTBU.js.map → util-B5KX4h4M.js.map} +1 -1
- package/lib/zudoku.auth-auth0.js +24 -18
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +43 -34
- package/lib/zudoku.auth-clerk.js.map +1 -1
- package/lib/zudoku.auth-openid.js +1121 -734
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +1076 -823
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +13776 -9681
- package/lib/zudoku.openapi-worker.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +206 -165
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-markdown.js +41 -33
- package/lib/zudoku.plugin-markdown.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +6 -6
- package/lib/zudoku.plugin-redirect.js +10 -8
- package/lib/zudoku.plugin-redirect.js.map +1 -1
- package/package.json +1 -1
- package/lib/AnchorLink-BCN_a_Uz.js +0 -705
- package/lib/Combination-B0Iu6mhJ.js +0 -915
- package/lib/DevPortalProvider-Do9oJqme.js +0 -1081
- package/lib/Markdown-aE_XoLNs.js +0 -15030
- package/lib/Markdown-aE_XoLNs.js.map +0 -1
- package/lib/MdxPage-Bsc79cD-.js +0 -190
- package/lib/OperationList-K-JWBxau.js +0 -5091
- package/lib/Playground-Czy7ha9z.js +0 -502
- package/lib/Route-D-egsGHx.js +0 -13
- package/lib/Select-CcBbwJ2R.js +0 -3667
- package/lib/Spinner-C9_Opdev.js +0 -15
- package/lib/_commonjsHelpers-BVfed4GL.js +0 -29
- package/lib/_commonjsHelpers-BVfed4GL.js.map +0 -1
- package/lib/assets/index-BPdJm2ty.js +0 -4765
- package/lib/assets/worker-BjPv-hjP.js +0 -14897
- package/lib/context-_fYfJFgk.js +0 -14
- package/lib/hook-CKqQERWo.js +0 -77
- package/lib/index-ByHya67R.js +0 -207
- package/lib/index-DseBZFJ-.js +0 -170
- package/lib/index-pI9JkN46.js +0 -4765
- package/lib/jsx-runtime-CJZJivg2.js +0 -1526
- package/lib/mutation-DjbQSHzT.js +0 -208
- package/lib/prism-bash.min-DadFsM4Z.js +0 -7
- package/lib/prism-csharp.min-Yizuc34Y.js +0 -35
- package/lib/prism-java.min-d5iT_mOd.js +0 -7
- package/lib/prism-json.min-B1GJqK1k.js +0 -2
- package/lib/prism-markup-templating-DZrrEs0A.js +0 -62
- package/lib/prism-objectivec.min-BXSWqpJJ.js +0 -2
- package/lib/prism-php.min-o7FpoMP_.js +0 -11
- package/lib/prism-ruby.min-C7LwcKyz.js +0 -10
- package/lib/router-CBw2vqJE.js +0 -2973
- package/lib/slugify-CiPVjteN.js +0 -28
- package/lib/state-DKdaQzvh.js +0 -288
- package/lib/urql-DEKdguFl.js +0 -1592
- package/lib/util-_jwUlTBU.js +0 -41
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "./jsx-runtime-DvZ6OKMM.js";
|
|
2
|
+
import { g as useFieldArray, h as useWatch, i as useFormContext, C as Controller, u as useForm, a as useMutation, F as FormProvider, S as Select, b as SelectTrigger, c as SelectValue, d as SelectContent, f as SelectItem } from "./Select-Boi_pe3L.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { forwardRef, Fragment } from "react";
|
|
5
|
+
import { a as useQuery } from "./urql-DtVKPBx_.js";
|
|
6
|
+
import { v as useApiIdentities } from "./DevPortalProvider-GjdO0Xr-.js";
|
|
7
|
+
import { S as Spinner } from "./Spinner-oU0QJmi_.js";
|
|
8
|
+
import { e as cn, j as TriangleAlert, S as SyntaxHighlight } from "./Markdown-B8nPVql1.js";
|
|
9
|
+
import { B as Button } from "./Combination-BfufJFkX.js";
|
|
10
|
+
import { X, u as usePastellizedColor, D as DATA_ATTR, C as ColorizedParam, T as Tabs, a as TabsList, b as TabsTrigger, c as TabsContent } from "./OperationList-krPgt6sE.js";
|
|
11
|
+
import { u as useOasConfig } from "./context-BoN_3uxi.js";
|
|
12
|
+
import { g as graphql } from "./index-Dih8IAqw.js";
|
|
13
|
+
import { S as Slot } from "./index-BL1P4Gqq.js";
|
|
14
|
+
const Card = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
ref,
|
|
18
|
+
className: cn(
|
|
19
|
+
"rounded-xl border border-border bg-card text-card-foreground shadow",
|
|
20
|
+
className
|
|
21
|
+
),
|
|
22
|
+
...props
|
|
23
|
+
}
|
|
24
|
+
));
|
|
25
|
+
Card.displayName = "Card";
|
|
26
|
+
const CardHeader = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
ref,
|
|
30
|
+
className: cn("flex flex-col space-y-1.5 p-6", className),
|
|
31
|
+
...props
|
|
32
|
+
}
|
|
33
|
+
));
|
|
34
|
+
CardHeader.displayName = "CardHeader";
|
|
35
|
+
const CardTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
36
|
+
"h3",
|
|
37
|
+
{
|
|
38
|
+
ref,
|
|
39
|
+
className: cn("font-semibold leading-none tracking-tight", className),
|
|
40
|
+
...props
|
|
41
|
+
}
|
|
42
|
+
));
|
|
43
|
+
CardTitle.displayName = "CardTitle";
|
|
44
|
+
const CardDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
45
|
+
"p",
|
|
46
|
+
{
|
|
47
|
+
ref,
|
|
48
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
49
|
+
...props
|
|
50
|
+
}
|
|
51
|
+
));
|
|
52
|
+
CardDescription.displayName = "CardDescription";
|
|
53
|
+
const CardContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
|
|
54
|
+
CardContent.displayName = "CardContent";
|
|
55
|
+
const CardFooter = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
ref,
|
|
59
|
+
className: cn("flex items-center p-6 pt-0", className),
|
|
60
|
+
...props
|
|
61
|
+
}
|
|
62
|
+
));
|
|
63
|
+
CardFooter.displayName = "CardFooter";
|
|
64
|
+
const createUrl = (host, path, data) => {
|
|
65
|
+
const url = new URL(
|
|
66
|
+
host + path.split("/").map(
|
|
67
|
+
(v) => {
|
|
68
|
+
var _a;
|
|
69
|
+
return v.startsWith("{") && v.endsWith("}") ? ((_a = data.pathParams.find((part) => part.name === v.slice(1, -1))) == null ? void 0 : _a.value) ?? v : v;
|
|
70
|
+
}
|
|
71
|
+
).join("/")
|
|
72
|
+
);
|
|
73
|
+
data.queryParams.forEach((param) => {
|
|
74
|
+
url.searchParams.set(param.name, param.value);
|
|
75
|
+
});
|
|
76
|
+
return url;
|
|
77
|
+
};
|
|
78
|
+
const createVariantComponent = (tag, cvx) => {
|
|
79
|
+
const MyVariant = React.forwardRef(({ className, asChild, ...props }, ref) => {
|
|
80
|
+
const Comp = asChild ? Slot : tag;
|
|
81
|
+
return React.createElement(Comp, {
|
|
82
|
+
...props,
|
|
83
|
+
ref,
|
|
84
|
+
className: cn(cvx, className)
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
MyVariant.displayName = `VariantComponent(${tag})`;
|
|
88
|
+
return MyVariant;
|
|
89
|
+
};
|
|
90
|
+
const InlineInput = createVariantComponent(
|
|
91
|
+
"input",
|
|
92
|
+
"px-2 bg-transparent h-6 font-mono text-xs m-2"
|
|
93
|
+
);
|
|
94
|
+
const Headers = ({
|
|
95
|
+
control,
|
|
96
|
+
register
|
|
97
|
+
}) => {
|
|
98
|
+
const { fields, append, remove } = useFieldArray({
|
|
99
|
+
control,
|
|
100
|
+
name: "headers"
|
|
101
|
+
});
|
|
102
|
+
const selectedIdentity = useWatch({ name: "identity", control });
|
|
103
|
+
const liveHeaders = useWatch({ name: "headers", control });
|
|
104
|
+
const disableAuth = selectedIdentity !== NO_IDENTITY;
|
|
105
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-[1fr_1fr_auto]", children: [
|
|
106
|
+
fields.map((header, i) => {
|
|
107
|
+
var _a;
|
|
108
|
+
const isDisabledByAuth = disableAuth && ((_a = liveHeaders.at(i)) == null ? void 0 : _a.name) === "Authorization";
|
|
109
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
className: cn(
|
|
113
|
+
"grid-cols-subgrid col-span-full grid items-center gap-x-2 has-[:focus]:bg-muted hover:bg-muted rounded overflow-hidden group",
|
|
114
|
+
isDisabledByAuth && "line-through"
|
|
115
|
+
),
|
|
116
|
+
title: isDisabledByAuth ? "This header is disabled because authentication was selected" : void 0,
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 items-center", children: [
|
|
119
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
120
|
+
InlineInput,
|
|
121
|
+
{
|
|
122
|
+
...register(`headers.${i}.name`),
|
|
123
|
+
placeholder: "Name",
|
|
124
|
+
className: "peer",
|
|
125
|
+
autoComplete: "off"
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
isDisabledByAuth && /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleAlert, { size: 16, className: "text-amber-500" })
|
|
129
|
+
] }),
|
|
130
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
131
|
+
InlineInput,
|
|
132
|
+
{
|
|
133
|
+
placeholder: "Value",
|
|
134
|
+
className: "peer",
|
|
135
|
+
...register(`headers.${i}.value`),
|
|
136
|
+
autoComplete: "off"
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
140
|
+
"button",
|
|
141
|
+
{
|
|
142
|
+
className: "hover:bg-black/5 p-1 rounded mr-2 text-muted-foreground invisible group-hover:visible peer-focus:visible",
|
|
143
|
+
onClick: () => {
|
|
144
|
+
remove(i);
|
|
145
|
+
},
|
|
146
|
+
type: "button",
|
|
147
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { size: 16 })
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "col-span-full border-b border-border" })
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
header.id
|
|
154
|
+
);
|
|
155
|
+
}),
|
|
156
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
157
|
+
Button,
|
|
158
|
+
{
|
|
159
|
+
className: "col-span-full mt-4",
|
|
160
|
+
onClick: () => append({ name: "", value: "" }),
|
|
161
|
+
type: "button",
|
|
162
|
+
children: "Add header"
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
] });
|
|
166
|
+
};
|
|
167
|
+
const ParameterValue = forwardRef(
|
|
168
|
+
function ParameterValue2({ part, className, ...props }, ref) {
|
|
169
|
+
const color = usePastellizedColor(part);
|
|
170
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
171
|
+
InlineInput,
|
|
172
|
+
{
|
|
173
|
+
...props,
|
|
174
|
+
ref,
|
|
175
|
+
className: cn(className, "opacity-80 data-[active=true]:opacity-100"),
|
|
176
|
+
style: {
|
|
177
|
+
// color: `hsl(${color})`,
|
|
178
|
+
outlineColor: `hsl(${color})`
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
const PathParams = ({
|
|
185
|
+
control,
|
|
186
|
+
register
|
|
187
|
+
}) => {
|
|
188
|
+
const { fields } = useFieldArray({
|
|
189
|
+
control,
|
|
190
|
+
name: "pathParams"
|
|
191
|
+
});
|
|
192
|
+
return fields.map((part, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
193
|
+
"div",
|
|
194
|
+
{
|
|
195
|
+
className: "grid-cols-subgrid col-span-full grid items-center gap-x-2 has-[:focus]:bg-muted hover:bg-muted rounded overflow-hidden group",
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
198
|
+
InlineInput,
|
|
199
|
+
{
|
|
200
|
+
...register(`pathParams.${i}.name`),
|
|
201
|
+
disabled: true,
|
|
202
|
+
placeholder: "Name",
|
|
203
|
+
className: "peer"
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
207
|
+
ParameterValue,
|
|
208
|
+
{
|
|
209
|
+
...register(`pathParams.${i}.value`),
|
|
210
|
+
part: part.name,
|
|
211
|
+
...{ [DATA_ATTR]: part.name },
|
|
212
|
+
placeholder: "Value",
|
|
213
|
+
className: "peer"
|
|
214
|
+
}
|
|
215
|
+
),
|
|
216
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "col-span-full border-b border-border" })
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
part.id
|
|
220
|
+
));
|
|
221
|
+
};
|
|
222
|
+
const QueryParams = ({
|
|
223
|
+
control
|
|
224
|
+
}) => {
|
|
225
|
+
const { fields } = useFieldArray({
|
|
226
|
+
control,
|
|
227
|
+
name: "queryParams"
|
|
228
|
+
});
|
|
229
|
+
const form = useFormContext();
|
|
230
|
+
const requiredFields = form.getValues(`queryParams`).map((param) => param.isRequired);
|
|
231
|
+
return fields.map((field, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
className: "px-2 grid-cols-subgrid col-span-full grid items-center gap-x-2 has-[:focus]:bg-muted hover:bg-accent rounded overflow-hidden group",
|
|
235
|
+
children: [
|
|
236
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
237
|
+
Controller,
|
|
238
|
+
{
|
|
239
|
+
control,
|
|
240
|
+
name: `queryParams.${i}.active`,
|
|
241
|
+
render: ({ field: field2 }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
242
|
+
"input",
|
|
243
|
+
{
|
|
244
|
+
type: "checkbox",
|
|
245
|
+
id: `queryParams.${i}.active`,
|
|
246
|
+
checked: field2.value,
|
|
247
|
+
onChange: field2.onChange
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
),
|
|
252
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
253
|
+
Controller,
|
|
254
|
+
{
|
|
255
|
+
control,
|
|
256
|
+
render: ({ field: field2 }) => {
|
|
257
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(InlineInput, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
258
|
+
"label",
|
|
259
|
+
{
|
|
260
|
+
className: "flex items-center",
|
|
261
|
+
htmlFor: `queryParams.${i}.active`,
|
|
262
|
+
title: requiredFields[i] ? "Required field" : void 0,
|
|
263
|
+
children: [
|
|
264
|
+
field2.value,
|
|
265
|
+
requiredFields[i] && /* @__PURE__ */ jsxRuntimeExports.jsx("sup", { className: "text-destructive", children: "*" })
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
) });
|
|
269
|
+
},
|
|
270
|
+
name: `queryParams.${i}.name`
|
|
271
|
+
}
|
|
272
|
+
),
|
|
273
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
274
|
+
Controller,
|
|
275
|
+
{
|
|
276
|
+
control,
|
|
277
|
+
render: ({ field: field2 }) => {
|
|
278
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(InlineInput, { ...field2, placeholder: "Value", className: "peer" });
|
|
279
|
+
},
|
|
280
|
+
name: `queryParams.${i}.value`
|
|
281
|
+
}
|
|
282
|
+
),
|
|
283
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
284
|
+
Controller,
|
|
285
|
+
{
|
|
286
|
+
control,
|
|
287
|
+
render: ({ field: field2 }) => {
|
|
288
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
289
|
+
"button",
|
|
290
|
+
{
|
|
291
|
+
type: "button",
|
|
292
|
+
className: cn(
|
|
293
|
+
"hover:bg-black/5 p-1 rounded mr-2 text-muted-foreground invisible group-hover:visible peer-focus:visible",
|
|
294
|
+
field2.value.length === 0 && "opacity-0 pointer-events-none"
|
|
295
|
+
),
|
|
296
|
+
onClick: () => field2.onChange(""),
|
|
297
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { size: 16 })
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
},
|
|
301
|
+
name: `queryParams.${i}.value`
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mx-2 col-span-full border-b border-border" })
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
field.id
|
|
308
|
+
));
|
|
309
|
+
};
|
|
310
|
+
const NO_IDENTITY = "__none";
|
|
311
|
+
const GetServerQuery = graphql(
|
|
312
|
+
/* GraphQL */
|
|
313
|
+
`
|
|
314
|
+
query getServerQuery($input: JSON!, $type: SchemaType!) {
|
|
315
|
+
schema(input: $input, type: $type) {
|
|
316
|
+
url
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
`
|
|
320
|
+
);
|
|
321
|
+
function mimeTypeToLanguage(mimeType) {
|
|
322
|
+
var _a;
|
|
323
|
+
const mimeTypeMapping = {
|
|
324
|
+
"application/json": "json",
|
|
325
|
+
"text/json": "json",
|
|
326
|
+
"text/html": "html",
|
|
327
|
+
"text/css": "css",
|
|
328
|
+
"text/javascript": "javascript",
|
|
329
|
+
"application/xml": "xml",
|
|
330
|
+
"application/xhtml+xml": "xhtml",
|
|
331
|
+
"text/plain": "plain"
|
|
332
|
+
};
|
|
333
|
+
return (_a = Object.entries(mimeTypeMapping).find(
|
|
334
|
+
([mime]) => mimeType.includes(mime)
|
|
335
|
+
)) == null ? void 0 : _a[0][1];
|
|
336
|
+
}
|
|
337
|
+
const statusCodeMap = {
|
|
338
|
+
200: "OK",
|
|
339
|
+
201: "Created",
|
|
340
|
+
202: "Accepted",
|
|
341
|
+
204: "No Content",
|
|
342
|
+
400: "Bad Request",
|
|
343
|
+
401: "Unauthorized",
|
|
344
|
+
403: "Forbidden",
|
|
345
|
+
404: "Not Found",
|
|
346
|
+
405: "Method Not Allowed",
|
|
347
|
+
500: "Internal Server Error"
|
|
348
|
+
};
|
|
349
|
+
const Playground = ({
|
|
350
|
+
url,
|
|
351
|
+
method,
|
|
352
|
+
headers = [{ name: "", value: "" }],
|
|
353
|
+
queryParams = [],
|
|
354
|
+
pathParams = [],
|
|
355
|
+
hasParams
|
|
356
|
+
}) => {
|
|
357
|
+
var _a, _b, _c;
|
|
358
|
+
const variables = useOasConfig();
|
|
359
|
+
const [server] = useQuery({ query: GetServerQuery, variables });
|
|
360
|
+
const { register, control, handleSubmit, watch, ...form } = useForm({
|
|
361
|
+
defaultValues: {
|
|
362
|
+
body: "",
|
|
363
|
+
queryParams,
|
|
364
|
+
headers,
|
|
365
|
+
pathParams,
|
|
366
|
+
identity: NO_IDENTITY
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
const formState = watch();
|
|
370
|
+
const identities = useApiIdentities();
|
|
371
|
+
const queryMutation = useMutation({
|
|
372
|
+
mutationFn: async (data) => {
|
|
373
|
+
var _a2, _b2, _c2;
|
|
374
|
+
const requestUrl = createUrl(((_a2 = server.data) == null ? void 0 : _a2.schema.url) ?? "", url, data);
|
|
375
|
+
const start = performance.now();
|
|
376
|
+
const request = new Request(requestUrl, {
|
|
377
|
+
method: method.toUpperCase(),
|
|
378
|
+
headers: Object.fromEntries(
|
|
379
|
+
data.headers.filter((h) => h.name).map((header) => [header.name, header.value])
|
|
380
|
+
)
|
|
381
|
+
});
|
|
382
|
+
if (data.identity !== NO_IDENTITY) {
|
|
383
|
+
(_c2 = (_b2 = identities.data) == null ? void 0 : _b2.find((i) => i.id === data.identity)) == null ? void 0 : _c2.authorizeRequest(request);
|
|
384
|
+
}
|
|
385
|
+
const response = await fetch(request);
|
|
386
|
+
const body = await response.text();
|
|
387
|
+
return {
|
|
388
|
+
status: response.status,
|
|
389
|
+
headers: response.headers,
|
|
390
|
+
size: body.length,
|
|
391
|
+
body,
|
|
392
|
+
time: performance.now() - start
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
const path = url.split("/").map((part, i, arr) => {
|
|
397
|
+
var _a2;
|
|
398
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Fragment, { children: [
|
|
399
|
+
part.startsWith("{") && part.endsWith("}") ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
400
|
+
ColorizedParam,
|
|
401
|
+
{
|
|
402
|
+
name: part,
|
|
403
|
+
backgroundOpacity: "0",
|
|
404
|
+
slug: part.slice(1, -1),
|
|
405
|
+
children: (_a2 = formState.pathParams.find((p) => p.name === part.slice(1, -1))) == null ? void 0 : _a2.value
|
|
406
|
+
}
|
|
407
|
+
) : part,
|
|
408
|
+
i < arr.length - 1 && "/",
|
|
409
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("wbr", {})
|
|
410
|
+
] }, part);
|
|
411
|
+
});
|
|
412
|
+
const lang = mimeTypeToLanguage(
|
|
413
|
+
((_a = queryMutation.data) == null ? void 0 : _a.headers.get("Content-Type")) ?? ""
|
|
414
|
+
);
|
|
415
|
+
const headerEntries = Array.from(((_b = queryMutation.data) == null ? void 0 : _b.headers.entries()) ?? []);
|
|
416
|
+
const urlQueryParams = formState.queryParams.filter((p) => p.active).map((p) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Fragment, { children: [
|
|
417
|
+
p.name,
|
|
418
|
+
"=",
|
|
419
|
+
p.value,
|
|
420
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("wbr", {})
|
|
421
|
+
] }, p.name));
|
|
422
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(FormProvider, { ...{ register, control, handleSubmit, watch, ...form }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("form", { onSubmit: handleSubmit((data) => queryMutation.mutateAsync(data)), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 text-sm h-full", children: [
|
|
423
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-4 p-8 bg-muted/50 after:bg-muted-foreground/20 relative after:absolute after:w-px after:inset-0 after:left-auto", children: [
|
|
424
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 items-stretch", children: [
|
|
425
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-1 items-center w-full border rounded-md border-border", children: [
|
|
426
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "border-r border-border p-2 bg-muted rounded-l-md self-stretch font-semibold font-mono", children: method.toUpperCase() }),
|
|
427
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-2 font-mono text-xs", children: [
|
|
428
|
+
path,
|
|
429
|
+
urlQueryParams.length > 0 ? "?" : "",
|
|
430
|
+
urlQueryParams
|
|
431
|
+
] })
|
|
432
|
+
] }),
|
|
433
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", className: "h-auto flex gap-1", children: "Send" })
|
|
434
|
+
] }),
|
|
435
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { defaultValue: hasParams ? "parameters" : "headers", children: [
|
|
436
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
|
|
437
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { children: [
|
|
438
|
+
hasParams && /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "parameters", children: "Parameters" }),
|
|
439
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "headers", children: [
|
|
440
|
+
"Headers",
|
|
441
|
+
" ",
|
|
442
|
+
formState.headers.length > 0 && `(${formState.headers.length})`
|
|
443
|
+
] }),
|
|
444
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
445
|
+
TabsTrigger,
|
|
446
|
+
{
|
|
447
|
+
value: "body",
|
|
448
|
+
disabled: ["POST", "PUT", "PATCH", "DELETE"].includes(
|
|
449
|
+
method.toUpperCase()
|
|
450
|
+
),
|
|
451
|
+
children: "Body"
|
|
452
|
+
}
|
|
453
|
+
)
|
|
454
|
+
] }),
|
|
455
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 items-center", children: [
|
|
456
|
+
"Auth:",
|
|
457
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
458
|
+
Select,
|
|
459
|
+
{
|
|
460
|
+
onValueChange: (value) => form.setValue("identity", value),
|
|
461
|
+
defaultValue: formState.identity,
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { className: "w-[180px] flex", children: identities.isPending ? /* @__PURE__ */ jsxRuntimeExports.jsx(Spinner, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
|
|
464
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { align: "center", children: [
|
|
465
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: NO_IDENTITY, children: "None" }),
|
|
466
|
+
(_c = identities.data) == null ? void 0 : _c.map((identity) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: identity.id, children: identity.label }, identity.id))
|
|
467
|
+
] })
|
|
468
|
+
]
|
|
469
|
+
}
|
|
470
|
+
)
|
|
471
|
+
] })
|
|
472
|
+
] }),
|
|
473
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "headers", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Headers, { control, register }) }),
|
|
474
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "parameters", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-[min-content_1fr_1fr_auto]", children: [
|
|
475
|
+
pathParams.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-semibold my-3 col-span-3", children: "Path Parameters" }),
|
|
476
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(PathParams, { control, register }),
|
|
477
|
+
queryParams.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold my-3 col-span-3", children: "Query Parameters" }),
|
|
478
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(QueryParams, { control })
|
|
479
|
+
] }) }),
|
|
480
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "body", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
481
|
+
"textarea",
|
|
482
|
+
{
|
|
483
|
+
...register("body"),
|
|
484
|
+
className: "border border-border w-full rounded p-2 bg-muted h-40"
|
|
485
|
+
}
|
|
486
|
+
) })
|
|
487
|
+
] })
|
|
488
|
+
] }),
|
|
489
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-4 p-8 bg-muted/70", children: queryMutation.error ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: queryMutation.error.message }) : queryMutation.data ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
490
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex text-xs gap-6", children: [
|
|
491
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
492
|
+
"Status: ",
|
|
493
|
+
queryMutation.data.status,
|
|
494
|
+
" ",
|
|
495
|
+
statusCodeMap[queryMutation.data.status] ?? ""
|
|
496
|
+
] }),
|
|
497
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
498
|
+
"Time: ",
|
|
499
|
+
queryMutation.data.time.toFixed(0),
|
|
500
|
+
"ms"
|
|
501
|
+
] }),
|
|
502
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
503
|
+
"Size: ",
|
|
504
|
+
queryMutation.data.size,
|
|
505
|
+
" B"
|
|
506
|
+
] })
|
|
507
|
+
] }) }),
|
|
508
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { defaultValue: "response", children: [
|
|
509
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { children: [
|
|
510
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "response", children: "Response" }),
|
|
511
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "headers", children: headerEntries.length ? `Headers (${headerEntries.length})` : "No headers" })
|
|
512
|
+
] }),
|
|
513
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "response", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "shadow-none p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
514
|
+
SyntaxHighlight,
|
|
515
|
+
{
|
|
516
|
+
language: lang ?? "json",
|
|
517
|
+
noBackground: true,
|
|
518
|
+
className: "overflow-x-auto ",
|
|
519
|
+
code: queryMutation.data.body ?? JSON.stringify("")
|
|
520
|
+
}
|
|
521
|
+
) }) }),
|
|
522
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "headers", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "grid grid-cols-2 w-full gap-2.5 font-mono text-xs shadow-none p-4", children: [
|
|
523
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Key" }),
|
|
524
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Value" }),
|
|
525
|
+
headerEntries.map(([key, value]) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Fragment, { children: [
|
|
526
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: key }),
|
|
527
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: value })
|
|
528
|
+
] }, key))
|
|
529
|
+
] }) })
|
|
530
|
+
] })
|
|
531
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid place-items-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[16px] font-semibold text-muted-foreground", children: queryMutation.isPending ? /* @__PURE__ */ jsxRuntimeExports.jsx(Spinner, {}) : "Send a request first to see the response here" }) }) })
|
|
532
|
+
] }) }) });
|
|
533
|
+
};
|
|
534
|
+
export {
|
|
535
|
+
NO_IDENTITY,
|
|
536
|
+
Playground,
|
|
537
|
+
Playground as default
|
|
538
|
+
};
|
|
539
|
+
//# sourceMappingURL=Playground-DOHxca0P.js.map
|