zudoku 0.3.0-dev.2 → 0.3.0-dev.21

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 (228) hide show
  1. package/dist/app/App.js +11 -8
  2. package/dist/app/App.js.map +1 -1
  3. package/dist/config/config.d.ts +8 -15
  4. package/dist/lib/authentication/authentication.d.ts +2 -2
  5. package/dist/lib/authentication/hook.d.ts +1 -0
  6. package/dist/lib/authentication/hook.js +1 -0
  7. package/dist/lib/authentication/hook.js.map +1 -1
  8. package/dist/lib/authentication/providers/auth0.js +1 -0
  9. package/dist/lib/authentication/providers/auth0.js.map +1 -1
  10. package/dist/lib/authentication/providers/clerk.js +2 -0
  11. package/dist/lib/authentication/providers/clerk.js.map +1 -1
  12. package/dist/lib/authentication/providers/openid.js +2 -0
  13. package/dist/lib/authentication/providers/openid.js.map +1 -1
  14. package/dist/lib/authentication/state.d.ts +1 -0
  15. package/dist/lib/authentication/state.js +1 -0
  16. package/dist/lib/authentication/state.js.map +1 -1
  17. package/dist/lib/components/DevPortal.d.ts +2 -20
  18. package/dist/lib/components/DevPortal.js +13 -9
  19. package/dist/lib/components/DevPortal.js.map +1 -1
  20. package/dist/lib/components/Header.js +4 -4
  21. package/dist/lib/components/Header.js.map +1 -1
  22. package/dist/lib/components/Heading.d.ts +9 -4
  23. package/dist/lib/components/Heading.js +17 -2
  24. package/dist/lib/components/Heading.js.map +1 -1
  25. package/dist/lib/components/Layout.js +1 -1
  26. package/dist/lib/components/Layout.js.map +1 -1
  27. package/dist/lib/components/SyntaxHighlight.js +5 -1
  28. package/dist/lib/components/SyntaxHighlight.js.map +1 -1
  29. package/dist/lib/components/context/DevPortalProvider.d.ts +1 -1
  30. package/dist/lib/components/context/DevPortalProvider.js +2 -2
  31. package/dist/lib/components/context/DevPortalProvider.js.map +1 -1
  32. package/dist/lib/components/index.d.ts +2 -0
  33. package/dist/lib/components/index.js +2 -0
  34. package/dist/lib/components/index.js.map +1 -1
  35. package/dist/lib/core/DevPortalContext.d.ts +33 -3
  36. package/dist/lib/core/DevPortalContext.js +8 -4
  37. package/dist/lib/core/DevPortalContext.js.map +1 -1
  38. package/dist/lib/core/plugins.d.ts +7 -4
  39. package/dist/lib/core/plugins.js +1 -0
  40. package/dist/lib/core/plugins.js.map +1 -1
  41. package/dist/lib/oas/graphql/index.js +1 -1
  42. package/dist/lib/oas/graphql/index.js.map +1 -1
  43. package/dist/lib/oas/parser/index.js +3 -1
  44. package/dist/lib/oas/parser/index.js.map +1 -1
  45. package/dist/lib/plugins/api-keys/CreateApiKey.d.ts +4 -0
  46. package/dist/lib/plugins/{api-key → api-keys}/CreateApiKey.js +1 -1
  47. package/dist/lib/plugins/api-keys/CreateApiKey.js.map +1 -0
  48. package/dist/lib/plugins/api-keys/SettingsApiKeys.d.ts +4 -0
  49. package/dist/lib/plugins/api-keys/SettingsApiKeys.js +38 -0
  50. package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -0
  51. package/dist/lib/plugins/api-keys/index.js +94 -0
  52. package/dist/lib/plugins/api-keys/index.js.map +1 -0
  53. package/dist/lib/plugins/markdown/MdxPage.d.ts +3 -2
  54. package/dist/lib/plugins/markdown/MdxPage.js +5 -4
  55. package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
  56. package/dist/lib/plugins/markdown/generateRoutes.d.ts +2 -2
  57. package/dist/lib/plugins/markdown/generateRoutes.js +2 -2
  58. package/dist/lib/plugins/markdown/generateRoutes.js.map +1 -1
  59. package/dist/lib/plugins/markdown/index.d.ts +4 -1
  60. package/dist/lib/plugins/markdown/index.js +2 -2
  61. package/dist/lib/plugins/markdown/index.js.map +1 -1
  62. package/dist/lib/plugins/openapi/OperationList.js +4 -3
  63. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  64. package/dist/lib/plugins/openapi/OperationListItem.js +8 -4
  65. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  66. package/dist/lib/plugins/openapi/ParameterList.js +1 -1
  67. package/dist/lib/plugins/openapi/ParameterList.js.map +1 -1
  68. package/dist/lib/plugins/openapi/ParameterListItem.js +1 -1
  69. package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
  70. package/dist/lib/plugins/openapi/{MakeRequest.d.ts → PlaygroundDialogWrapper.d.ts} +1 -1
  71. package/dist/lib/plugins/openapi/{MakeRequest.js → PlaygroundDialogWrapper.js} +4 -4
  72. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js.map +1 -0
  73. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +1 -9
  74. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
  75. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +1 -1
  76. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
  77. package/dist/lib/plugins/openapi/SchemaListView.js +4 -26
  78. package/dist/lib/plugins/openapi/SchemaListView.js.map +1 -1
  79. package/dist/lib/plugins/openapi/SchemaListViewItem.d.ts +7 -0
  80. package/dist/lib/plugins/openapi/SchemaListViewItem.js +16 -0
  81. package/dist/lib/plugins/openapi/SchemaListViewItem.js.map +1 -0
  82. package/dist/lib/plugins/openapi/SchemaListViewItemGroup.d.ts +8 -0
  83. package/dist/lib/plugins/openapi/SchemaListViewItemGroup.js +17 -0
  84. package/dist/lib/plugins/openapi/SchemaListViewItemGroup.js.map +1 -0
  85. package/dist/lib/plugins/openapi/Sidecar.js +10 -8
  86. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  87. package/dist/lib/plugins/openapi/{Select.d.ts → SimpleSelect.d.ts} +3 -2
  88. package/dist/lib/plugins/openapi/SimpleSelect.js +5 -0
  89. package/dist/lib/plugins/openapi/SimpleSelect.js.map +1 -0
  90. package/dist/lib/plugins/openapi/index.js +8 -0
  91. package/dist/lib/plugins/openapi/index.js.map +1 -1
  92. package/dist/lib/plugins/openapi/playground/Headers.d.ts +2 -3
  93. package/dist/lib/plugins/openapi/playground/Headers.js +16 -6
  94. package/dist/lib/plugins/openapi/playground/Headers.js.map +1 -1
  95. package/dist/lib/plugins/openapi/playground/Playground.d.ts +4 -3
  96. package/dist/lib/plugins/openapi/playground/Playground.js +8 -12
  97. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  98. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.d.ts +3 -0
  99. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +10 -0
  100. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -0
  101. package/dist/lib/plugins/openapi/util/prose.d.ts +1 -0
  102. package/dist/lib/plugins/openapi/util/prose.js +4 -0
  103. package/dist/lib/plugins/openapi/util/prose.js.map +1 -0
  104. package/dist/lib/plugins/openapi/worker/worker.js +25 -1
  105. package/dist/lib/plugins/openapi/worker/worker.js.map +1 -1
  106. package/dist/lib/ui/button-variants.d.ts +1 -1
  107. package/dist/lib/util/MdxComponents.js +1 -1
  108. package/dist/lib/util/MdxComponents.js.map +1 -1
  109. package/dist/lib/util/objectEntries.d.ts +4 -0
  110. package/dist/lib/util/objectEntries.js +2 -0
  111. package/dist/lib/util/objectEntries.js.map +1 -0
  112. package/dist/lib/util/renderIf.d.ts +1 -0
  113. package/dist/lib/util/renderIf.js +2 -0
  114. package/dist/lib/util/renderIf.js.map +1 -0
  115. package/dist/vite/build.js +4 -1
  116. package/dist/vite/build.js.map +1 -1
  117. package/dist/vite/config.d.ts +7 -7
  118. package/dist/vite/config.js +34 -40
  119. package/dist/vite/config.js.map +1 -1
  120. package/dist/vite/config.test.js +7 -4
  121. package/dist/vite/config.test.js.map +1 -1
  122. package/dist/vite/dev-server.js +4 -4
  123. package/dist/vite/dev-server.js.map +1 -1
  124. package/dist/vite/plugin-api-keys.js +4 -4
  125. package/dist/vite/plugin-api-keys.js.map +1 -1
  126. package/dist/vite/plugin-api.js +5 -5
  127. package/dist/vite/plugin-api.js.map +1 -1
  128. package/dist/vite/plugin-auth.js +2 -2
  129. package/dist/vite/plugin-auth.js.map +1 -1
  130. package/dist/vite/plugin-config.d.ts +1 -1
  131. package/dist/vite/plugin-config.js +7 -6
  132. package/dist/vite/plugin-config.js.map +1 -1
  133. package/dist/vite/plugin-docs.js +2 -2
  134. package/dist/vite/plugin-docs.js.map +1 -1
  135. package/dist/vite/plugin-docs.test.js +1 -1
  136. package/dist/vite/plugin-docs.test.js.map +1 -1
  137. package/dist/vite/plugin-redirect.js +4 -4
  138. package/dist/vite/plugin-redirect.js.map +1 -1
  139. package/lib/DevPortalProvider-CRKuwoXc.js +4123 -0
  140. package/lib/Markdown-5LmPZyLV.js +8620 -0
  141. package/lib/MdxComponents-DYD_QPVF.js +3017 -0
  142. package/lib/Select-DR3PiqjV.js +4569 -0
  143. package/lib/Spinner-DjQ2eBxC.js +181 -0
  144. package/lib/assets/{worker-BCcpCNJ7.js → worker-DGvzLstc.js} +9843 -9800
  145. package/lib/hook-FCY9-FHO.js +24 -0
  146. package/lib/index-By9bEW57.js +411 -0
  147. package/lib/{index-DNx3xWa2.js → index-PyGcnQFX.js} +13 -12
  148. package/lib/loglevel-CA34MiFn.js +152 -0
  149. package/lib/prism-csharp.min-Yizuc34Y.js +34 -0
  150. package/lib/prism-objectivec.min-BXSWqpJJ.js +1 -0
  151. package/lib/{state-oycsxkHz.js → state-Ds_OxRHP.js} +19 -18
  152. package/lib/util-voKLTRDG.js +740 -0
  153. package/lib/zudoku.auth-auth0.js +2 -1
  154. package/lib/zudoku.auth-clerk.js +10 -8
  155. package/lib/zudoku.auth-openid.js +442 -588
  156. package/lib/zudoku.components.js +283 -292
  157. package/lib/zudoku.openapi-worker.js +12 -12
  158. package/lib/zudoku.plugin-api-keys.js +292 -0
  159. package/lib/zudoku.plugin-markdown.js +255 -0
  160. package/lib/zudoku.plugin-openapi.js +6240 -0
  161. package/lib/zudoku.plugin-redirect.js +10 -0
  162. package/package.json +17 -5
  163. package/src/app/App.tsx +12 -8
  164. package/src/lib/authentication/authentication.ts +2 -5
  165. package/src/lib/authentication/hook.ts +1 -0
  166. package/src/lib/authentication/providers/auth0.tsx +1 -0
  167. package/src/lib/authentication/providers/clerk.tsx +2 -0
  168. package/src/lib/authentication/providers/openid.tsx +2 -0
  169. package/src/lib/authentication/state.ts +2 -0
  170. package/src/lib/components/DevPortal.tsx +12 -28
  171. package/src/lib/components/Header.tsx +25 -22
  172. package/src/lib/components/Heading.tsx +26 -7
  173. package/src/lib/components/Layout.tsx +2 -2
  174. package/src/lib/components/SyntaxHighlight.tsx +5 -1
  175. package/src/lib/components/context/DevPortalProvider.ts +2 -2
  176. package/src/lib/components/index.ts +3 -0
  177. package/src/lib/core/DevPortalContext.ts +42 -12
  178. package/src/lib/core/plugins.ts +10 -5
  179. package/src/lib/oas/graphql/index.ts +2 -2
  180. package/src/lib/oas/parser/index.ts +3 -1
  181. package/src/lib/plugins/{api-key → api-keys}/CreateApiKey.tsx +2 -8
  182. package/src/lib/plugins/{api-key → api-keys}/SettingsApiKeys.tsx +21 -14
  183. package/src/lib/plugins/{api-key → api-keys}/index.tsx +67 -18
  184. package/src/lib/plugins/markdown/MdxPage.tsx +50 -33
  185. package/src/lib/plugins/markdown/generateRoutes.tsx +12 -2
  186. package/src/lib/plugins/markdown/index.tsx +8 -1
  187. package/src/lib/plugins/openapi/OperationList.tsx +9 -3
  188. package/src/lib/plugins/openapi/OperationListItem.tsx +66 -41
  189. package/src/lib/plugins/openapi/ParameterList.tsx +1 -1
  190. package/src/lib/plugins/openapi/ParameterListItem.tsx +3 -4
  191. package/src/lib/plugins/openapi/{MakeRequest.tsx → PlaygroundDialogWrapper.tsx} +3 -3
  192. package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +2 -16
  193. package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +3 -1
  194. package/src/lib/plugins/openapi/SchemaListView.tsx +15 -182
  195. package/src/lib/plugins/openapi/SchemaListViewItem.tsx +110 -0
  196. package/src/lib/plugins/openapi/SchemaListViewItemGroup.tsx +63 -0
  197. package/src/lib/plugins/openapi/Sidecar.tsx +15 -10
  198. package/src/lib/plugins/openapi/{Select.tsx → SimpleSelect.tsx} +5 -2
  199. package/src/lib/plugins/openapi/index.tsx +17 -4
  200. package/src/lib/plugins/openapi/playground/Headers.tsx +60 -33
  201. package/src/lib/plugins/openapi/playground/Playground.tsx +158 -193
  202. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +34 -0
  203. package/src/lib/plugins/openapi/util/prose.ts +7 -0
  204. package/src/lib/plugins/openapi/worker/worker.ts +27 -1
  205. package/src/lib/util/MdxComponents.tsx +1 -1
  206. package/src/lib/util/objectEntries.ts +5 -0
  207. package/src/lib/util/renderIf.ts +4 -0
  208. package/dist/lib/plugins/api-key/CreateApiKey.d.ts +0 -5
  209. package/dist/lib/plugins/api-key/CreateApiKey.js.map +0 -1
  210. package/dist/lib/plugins/api-key/SettingsApiKeys.d.ts +0 -5
  211. package/dist/lib/plugins/api-key/SettingsApiKeys.js +0 -38
  212. package/dist/lib/plugins/api-key/SettingsApiKeys.js.map +0 -1
  213. package/dist/lib/plugins/api-key/index.js +0 -62
  214. package/dist/lib/plugins/api-key/index.js.map +0 -1
  215. package/dist/lib/plugins/index.d.ts +0 -4
  216. package/dist/lib/plugins/index.js +0 -5
  217. package/dist/lib/plugins/index.js.map +0 -1
  218. package/dist/lib/plugins/openapi/MakeRequest.js.map +0 -1
  219. package/dist/lib/plugins/openapi/Select.js +0 -5
  220. package/dist/lib/plugins/openapi/Select.js.map +0 -1
  221. package/dist/vite/common.d.ts +0 -1
  222. package/dist/vite/common.js +0 -5
  223. package/dist/vite/common.js.map +0 -1
  224. package/lib/Spinner-7LezPqGn.js +0 -8393
  225. package/lib/clerk-Wslx_mPo.js +0 -19685
  226. package/lib/zudoku.plugins.js +0 -19857
  227. package/src/lib/plugins/index.ts +0 -4
  228. /package/dist/lib/plugins/{api-key → api-keys}/index.d.ts +0 -0
@@ -1,15 +1,7 @@
1
- import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
2
1
  import { useMutation } from "@tanstack/react-query";
3
- import { CirclePlayIcon } from "lucide-react";
4
2
  import { Fragment } from "react";
5
3
  import { FormProvider, useForm } from "react-hook-form";
6
4
  import { useApiIdentities } from "../../../components/context/DevPortalProvider.js";
7
- import {
8
- Dialog,
9
- DialogContent,
10
- DialogTitle,
11
- DialogTrigger,
12
- } from "../../../components/Dialog.js";
13
5
  import {
14
6
  Select,
15
7
  SelectContent,
@@ -28,6 +20,8 @@ import { Headers } from "./Headers.js";
28
20
  import { PathParams } from "./PathParams.js";
29
21
  import { QueryParams } from "./QueryParams.js";
30
22
 
23
+ export const NO_IDENTITY = "__none";
24
+
31
25
  function mimeTypeToLanguage(mimeType: string) {
32
26
  const mimeTypeMapping = {
33
27
  "application/json": "json",
@@ -81,17 +75,7 @@ export type PlaygroundForm = {
81
75
  identity?: string;
82
76
  };
83
77
 
84
- const NO_IDENTITY = "__none";
85
-
86
- const Playground = ({
87
- url,
88
- host,
89
- method,
90
- headers = [{ name: "", value: "" }],
91
- queryParams = [],
92
- pathParams = [],
93
- hasParams,
94
- }: {
78
+ export type PlaygroundContentProps = {
95
79
  host: string;
96
80
  url: string;
97
81
  method: string;
@@ -99,7 +83,17 @@ const Playground = ({
99
83
  queryParams?: QueryParam[];
100
84
  pathParams?: PathParam[];
101
85
  hasParams: boolean;
102
- }) => {
86
+ };
87
+
88
+ export const Playground = ({
89
+ host,
90
+ url,
91
+ method,
92
+ headers = [{ name: "", value: "" }],
93
+ queryParams = [],
94
+ pathParams = [],
95
+ hasParams,
96
+ }: PlaygroundContentProps) => {
103
97
  const { register, control, handleSubmit, watch, ...form } =
104
98
  useForm<PlaygroundForm>({
105
99
  defaultValues: {
@@ -121,7 +115,7 @@ const Playground = ({
121
115
  const request = new Request(requestUrl, {
122
116
  method: method.toUpperCase(),
123
117
  headers: Object.fromEntries(
124
- data.pathParams
118
+ data.headers
125
119
  .filter((h) => h.name)
126
120
  .map((header) => [header.name, header.value]),
127
121
  ),
@@ -129,10 +123,9 @@ const Playground = ({
129
123
 
130
124
  if (data.identity !== NO_IDENTITY) {
131
125
  identities.data
132
- .find((i) => i.id === data.identity)
126
+ ?.find((i) => i.id === data.identity)
133
127
  ?.authorizeRequest(request);
134
128
  }
135
-
136
129
  const response = await fetch(request);
137
130
 
138
131
  const body = await response.text();
@@ -182,185 +175,157 @@ const Playground = ({
182
175
  <wbr />
183
176
  </Fragment>
184
177
  ));
185
-
186
178
  return (
187
- <Dialog>
188
- <DialogTrigger asChild>
189
- <CirclePlayIcon
190
- className="cursor-pointer text-primary hover:text-primary/80"
191
- size={16}
192
- />
193
- </DialogTrigger>
194
-
195
- <DialogContent
196
- className="max-w-screen-xl w-full h-5/6 overflow-auto p-0"
197
- aria-describedby={undefined}
198
- >
199
- <VisuallyHidden>
200
- <DialogTitle>Playground</DialogTitle>
201
- </VisuallyHidden>
202
- <FormProvider {...{ register, control, handleSubmit, watch, ...form }}>
203
- <form
204
- onSubmit={handleSubmit((data) => queryMutation.mutateAsync(data))}
205
- >
206
- <div className="grid grid-cols-2 text-sm h-full">
207
- <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">
208
- <div className="flex gap-2 items-stretch">
209
- <div className="flex flex-1 items-center w-full border rounded-md border-border">
210
- <div className="border-r border-border p-2 bg-muted rounded-l-md self-stretch font-semibold font-mono">
211
- {method.toUpperCase()}
212
- </div>
213
- <div className="p-2 font-mono text-xs">
214
- {path}
215
- {urlQueryParams.length > 0 ? "?" : ""}
216
- {urlQueryParams}
179
+ <FormProvider {...{ register, control, handleSubmit, watch, ...form }}>
180
+ <form onSubmit={handleSubmit((data) => queryMutation.mutateAsync(data))}>
181
+ <div className="grid grid-cols-2 text-sm h-full">
182
+ <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">
183
+ <div className="flex gap-2 items-stretch">
184
+ <div className="flex flex-1 items-center w-full border rounded-md border-border">
185
+ <div className="border-r border-border p-2 bg-muted rounded-l-md self-stretch font-semibold font-mono">
186
+ {method.toUpperCase()}
187
+ </div>
188
+ <div className="p-2 font-mono text-xs">
189
+ {path}
190
+ {urlQueryParams.length > 0 ? "?" : ""}
191
+ {urlQueryParams}
192
+ </div>
193
+ </div>
194
+ <Button type="submit" className="h-auto flex gap-1">
195
+ Send
196
+ </Button>
197
+ </div>
198
+ <Tabs defaultValue={hasParams ? "parameters" : "headers"}>
199
+ <div className="flex justify-between">
200
+ <TabsList>
201
+ {hasParams && (
202
+ <TabsTrigger value="parameters">Parameters</TabsTrigger>
203
+ )}
204
+ <TabsTrigger value="headers">
205
+ Headers{" "}
206
+ {formState.headers.length > 0 &&
207
+ `(${formState.headers.length})`}
208
+ </TabsTrigger>
209
+ <TabsTrigger
210
+ value="body"
211
+ disabled={["POST", "PUT", "PATCH", "DELETE"].includes(
212
+ method.toUpperCase(),
213
+ )}
214
+ >
215
+ Body
216
+ </TabsTrigger>
217
+ </TabsList>
218
+ <div className="flex gap-2 items-center">
219
+ Auth:
220
+ <Select
221
+ onValueChange={(value) => form.setValue("identity", value)}
222
+ defaultValue={formState.identity}
223
+ >
224
+ <SelectTrigger className="w-[180px] flex">
225
+ {identities.isPending ? <Spinner /> : <SelectValue />}
226
+ </SelectTrigger>
227
+ <SelectContent align="center">
228
+ <SelectItem value={NO_IDENTITY}>None</SelectItem>
229
+ {identities.data?.map((identity) => (
230
+ <SelectItem key={identity.id} value={identity.id}>
231
+ {identity.label}
232
+ </SelectItem>
233
+ ))}
234
+ </SelectContent>
235
+ </Select>
236
+ </div>
237
+ </div>
238
+ <TabsContent value="headers">
239
+ <Headers control={control} register={register} />
240
+ </TabsContent>
241
+ <TabsContent value="parameters">
242
+ <div className="grid grid-cols-[min-content_1fr_1fr_auto]">
243
+ {pathParams.length > 0 && (
244
+ <div className="font-semibold my-3 col-span-3">
245
+ Path Parameters
217
246
  </div>
218
- </div>
219
- <Button type="submit" className="h-auto flex gap-1">
220
- Send
221
- </Button>
247
+ )}
248
+ <PathParams control={control} register={register} />
249
+ {queryParams.length > 0 && (
250
+ <span className="font-semibold my-3 col-span-3">
251
+ Query Parameters
252
+ </span>
253
+ )}
254
+ <QueryParams control={control} />
222
255
  </div>
223
- <Tabs defaultValue={hasParams ? "parameters" : "headers"}>
224
- <div className="flex justify-between">
225
- <TabsList>
226
- {hasParams && (
227
- <TabsTrigger value="parameters">Parameters</TabsTrigger>
228
- )}
229
- <TabsTrigger value="headers">
230
- Headers{" "}
231
- {formState.headers.length > 0 &&
232
- `(${formState.headers.length})`}
233
- </TabsTrigger>
234
- <TabsTrigger
235
- value="body"
236
- disabled={["POST", "PUT", "PATCH", "DELETE"].includes(
237
- method.toUpperCase(),
238
- )}
239
- >
240
- Body
241
- </TabsTrigger>
242
- </TabsList>
243
- <div className="flex gap-2 items-center">
244
- Auth:
245
- <Select
246
- onValueChange={(value) =>
247
- form.setValue("identity", value)
248
- }
249
- defaultValue={formState.identity}
250
- >
251
- <SelectTrigger className="w-[180px]">
252
- <SelectValue />
253
- </SelectTrigger>
254
- <SelectContent align="center">
255
- <SelectItem value={NO_IDENTITY}>None</SelectItem>
256
- {identities.data.map((identity) => (
257
- <SelectItem key={identity.id} value={identity.id}>
258
- {identity.label}
259
- </SelectItem>
260
- ))}
261
- </SelectContent>
262
- </Select>
256
+ </TabsContent>
257
+ <TabsContent value="body">
258
+ <textarea
259
+ {...register("body")}
260
+ className="border border-border w-full rounded p-2 bg-muted h-40"
261
+ />
262
+ </TabsContent>
263
+ </Tabs>
264
+ </div>
265
+ <div className="flex flex-col gap-4 p-8 bg-muted/70">
266
+ {queryMutation.error ? (
267
+ <div>{queryMutation.error.message}</div>
268
+ ) : queryMutation.data ? (
269
+ <div className="flex flex-col gap-2">
270
+ <div className="flex gap-2">
271
+ <div className="flex text-xs gap-6">
272
+ <div>
273
+ Status: {queryMutation.data.status}{" "}
274
+ {statusCodeMap[queryMutation.data.status] ?? ""}
263
275
  </div>
276
+ <div>Time: {queryMutation.data.time.toFixed(0)}ms</div>
277
+ <div>Size: {queryMutation.data.size} B</div>
264
278
  </div>
265
- <TabsContent value="headers">
266
- <Headers
267
- control={control}
268
- register={register}
269
- headers={formState.headers}
270
- />
271
- </TabsContent>
272
- <TabsContent value="parameters">
273
- <div className="grid grid-cols-[min-content_1fr_1fr_auto]">
274
- {pathParams.length > 0 && (
275
- <div className="font-semibold my-3 col-span-3">
276
- Path Parameters
277
- </div>
278
- )}
279
- <PathParams control={control} register={register} />
280
- {queryParams.length > 0 && (
281
- <span className="font-semibold my-3 col-span-3">
282
- Query Parameters
283
- </span>
284
- )}
285
- <QueryParams control={control} />
286
- </div>
279
+ </div>
280
+ {/*<UrlDisplay host={host} path={url} />*/}
281
+ <Tabs defaultValue="response">
282
+ <TabsList>
283
+ <TabsTrigger value="response">Response</TabsTrigger>
284
+ <TabsTrigger value="headers">
285
+ {headerEntries.length
286
+ ? `Headers (${headerEntries.length})`
287
+ : "No headers"}
288
+ </TabsTrigger>
289
+ </TabsList>
290
+
291
+ <TabsContent value="response">
292
+ <Card className="shadow-none p-4">
293
+ <SyntaxHighlight
294
+ language={lang ?? "json"}
295
+ noBackground
296
+ className="overflow-x-auto "
297
+ code={queryMutation.data.body ?? JSON.stringify("")}
298
+ />
299
+ </Card>
287
300
  </TabsContent>
288
- <TabsContent value="body">
289
- <textarea
290
- {...register("body")}
291
- className="border border-border w-full rounded p-2 bg-muted h-40"
292
- />
301
+ <TabsContent value="headers">
302
+ <Card className="grid grid-cols-2 w-full gap-2.5 font-mono text-xs shadow-none p-4">
303
+ <div className="font-semibold">Key</div>
304
+ <div className="font-semibold">Value</div>
305
+ {headerEntries.map(([key, value]) => (
306
+ <Fragment key={key}>
307
+ <div>{key}</div>
308
+ <div>{value}</div>
309
+ </Fragment>
310
+ ))}
311
+ </Card>
293
312
  </TabsContent>
294
313
  </Tabs>
295
314
  </div>
296
- <div className="flex flex-col gap-4 p-8 bg-muted/70">
297
- {queryMutation.error ? (
298
- <div>{queryMutation.error.message}</div>
299
- ) : queryMutation.data ? (
300
- <div className="flex flex-col gap-2">
301
- <div className="flex gap-2">
302
- <div className="flex text-xs gap-6">
303
- <div>
304
- Status: {queryMutation.data.status}{" "}
305
- {statusCodeMap[queryMutation.data.status] ?? ""}
306
- </div>
307
- <div>Time: {queryMutation.data.time.toFixed(0)}ms</div>
308
- <div>Size: {queryMutation.data.size} B</div>
309
- </div>
310
- </div>
311
- {/*<UrlDisplay host={host} path={url} />*/}
312
- <Tabs defaultValue="response">
313
- <TabsList>
314
- <TabsTrigger value="response">Response</TabsTrigger>
315
- <TabsTrigger value="headers">
316
- {headerEntries.length
317
- ? `Headers (${headerEntries.length})`
318
- : "No headers"}
319
- </TabsTrigger>
320
- </TabsList>
321
-
322
- <TabsContent value="response">
323
- <Card className="shadow-none p-4">
324
- <SyntaxHighlight
325
- language={lang ?? "json"}
326
- noBackground
327
- className="overflow-x-auto "
328
- code={queryMutation.data.body ?? JSON.stringify("")}
329
- />
330
- </Card>
331
- </TabsContent>
332
- <TabsContent value="headers">
333
- <Card className="grid grid-cols-2 w-full gap-2.5 font-mono text-xs shadow-none p-4">
334
- <div className="font-semibold">Key</div>
335
- <div className="font-semibold">Value</div>
336
- {headerEntries.map(([key, value]) => (
337
- <Fragment key={key}>
338
- <div>{key}</div>
339
- <div>{value}</div>
340
- </Fragment>
341
- ))}
342
- </Card>
343
- </TabsContent>
344
- </Tabs>
345
- </div>
346
- ) : (
347
- <div className="grid place-items-center h-full">
348
- <span className="text-[16px] font-semibold text-muted-foreground">
349
- {queryMutation.isPending ? (
350
- <Spinner />
351
- ) : (
352
- "Send a request first to see the response here"
353
- )}
354
- </span>
355
- </div>
356
- )}
315
+ ) : (
316
+ <div className="grid place-items-center h-full">
317
+ <span className="text-[16px] font-semibold text-muted-foreground">
318
+ {queryMutation.isPending ? (
319
+ <Spinner />
320
+ ) : (
321
+ "Send a request first to see the response here"
322
+ )}
323
+ </span>
357
324
  </div>
358
- </div>
359
- </form>
360
- </FormProvider>
361
- </DialogContent>
362
- </Dialog>
325
+ )}
326
+ </div>
327
+ </div>
328
+ </form>
329
+ </FormProvider>
363
330
  );
364
331
  };
365
-
366
- export { Playground };
@@ -0,0 +1,34 @@
1
+ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
2
+ import { CirclePlayIcon } from "lucide-react";
3
+ import {
4
+ Dialog,
5
+ DialogContent,
6
+ DialogTitle,
7
+ DialogTrigger,
8
+ } from "../../../components/Dialog.js";
9
+ import { Playground, type PlaygroundContentProps } from "./Playground.js";
10
+
11
+ const PlaygroundDialog = (props: PlaygroundContentProps) => {
12
+ return (
13
+ <Dialog>
14
+ <DialogTrigger asChild>
15
+ <CirclePlayIcon
16
+ className="cursor-pointer text-primary hover:text-primary/80"
17
+ size={16}
18
+ />
19
+ </DialogTrigger>
20
+
21
+ <DialogContent
22
+ className="max-w-screen-xl w-full h-5/6 overflow-auto p-0"
23
+ aria-describedby={undefined}
24
+ >
25
+ <VisuallyHidden>
26
+ <DialogTitle>Playground</DialogTitle>
27
+ </VisuallyHidden>
28
+ <Playground {...props} />
29
+ </DialogContent>
30
+ </Dialog>
31
+ );
32
+ };
33
+
34
+ export { PlaygroundDialog };
@@ -0,0 +1,7 @@
1
+ import { ProseClasses } from "../../../components/Markdown.js";
2
+ import { cn } from "../../../util/cn.js";
3
+
4
+ export const SchemaProseClasses = cn(
5
+ ProseClasses,
6
+ "max-w-full prose-img:max-w-prose",
7
+ );
@@ -1,7 +1,33 @@
1
+ import { useLogger } from "@envelop/core";
1
2
  import { createGraphQLServer } from "../../../oas/graphql/index.js";
2
3
  import { type WorkerGraphQLMessage } from "./createSharedWorkerClient.js";
3
4
 
4
- const localServer = createGraphQLServer();
5
+ const map = new Map<string, number>();
6
+
7
+ const localServer = createGraphQLServer({
8
+ plugins: [
9
+ // eslint-disable-next-line react-hooks/rules-of-hooks
10
+ useLogger({
11
+ logFn: (eventName, { args }) => {
12
+ if (import.meta.env.PROD) return;
13
+
14
+ if (eventName.endsWith("-start")) {
15
+ map.set(`${eventName}-${args.operationName}`, performance.now());
16
+ } else if (eventName.endsWith("-end")) {
17
+ const startEvent = eventName.replace("-end", "-start");
18
+ const start = map.get(`${startEvent}-${args.operationName}`);
19
+ if (start) {
20
+ // eslint-disable-next-line no-console
21
+ console.log(
22
+ `${args.operationName} query took ${performance.now() - start}ms`,
23
+ );
24
+ map.delete(`${startEvent}-${args.operationName}`);
25
+ }
26
+ }
27
+ },
28
+ }),
29
+ ],
30
+ });
5
31
 
6
32
  const worker = self as unknown as SharedWorkerGlobalScope;
7
33
 
@@ -85,7 +85,7 @@ export const MdxComponents = {
85
85
  <code
86
86
  className={cn(
87
87
  className,
88
- "font-mono border border-border p-1 py-0.5 rounded bg-border/50 dark:bg-border/70",
88
+ "font-mono border border-border p-1 py-0.5 rounded bg-border/50 dark:bg-border/70 whitespace-nowrap",
89
89
  )}
90
90
  >
91
91
  {children}
@@ -0,0 +1,5 @@
1
+ type ValueOf<T> = T[keyof T];
2
+ type Entries<T> = [keyof T, ValueOf<T>][];
3
+
4
+ export const objectEntries = <T extends object>(obj: T): Entries<T> =>
5
+ Object.entries(obj) as Entries<T>;
@@ -0,0 +1,4 @@
1
+ export const renderIf = <G, R>(
2
+ variable: G | undefined | null,
3
+ callback: (variable: G) => R,
4
+ ): R | undefined => (variable ? callback(variable) : undefined);
@@ -1,5 +0,0 @@
1
- import { type ApiKeyPluginOptions, ApiKeyService } from "./index.js";
2
- export declare const CreateApiKey: ({ options, service, }: {
3
- options: ApiKeyPluginOptions;
4
- service: ApiKeyService;
5
- }) => import("react/jsx-runtime").JSX.Element | null;
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateApiKey.js","sourceRoot":"","sources":["../../../../src/lib/plugins/api-key/CreateApiKey.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;A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C,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;AAC5B,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- import { type ApiKeyPluginOptions, ApiKeyService } from "./index.js";
2
- export declare const SettingsApiKeys: ({ options, service, }: {
3
- options: ApiKeyPluginOptions;
4
- service: ApiKeyService;
5
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,38 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMutation, useQueryClient, useSuspenseQuery, } from "@tanstack/react-query";
3
- import { EyeIcon, EyeOffIcon, RotateCwIcon, TrashIcon } from "lucide-react";
4
- import { useState } from "react";
5
- import { Link } from "react-router-dom";
6
- import { useDevPortal } from "../../components/context/DevPortalProvider.js";
7
- import { Button } from "../../ui/Button.js";
8
- import { Card } from "../../ui/Card.js";
9
- export const SettingsApiKeys = ({ options, service, }) => {
10
- const context = useDevPortal();
11
- const queryClient = useQueryClient();
12
- const { data } = useSuspenseQuery({
13
- queryFn: () => service.getKeys(context),
14
- queryKey: ["api-keys"],
15
- });
16
- const deleteKeyMutation = useMutation({
17
- mutationFn: (id) => {
18
- if (!service.deleteKey) {
19
- throw new Error("deleteKey not implemented");
20
- }
21
- return service.deleteKey(id, context);
22
- },
23
- onSuccess: () => {
24
- void queryClient.invalidateQueries({ queryKey: ["api-keys"] });
25
- },
26
- });
27
- return (_jsxs("div", { className: "max-w-screen-lg pt-[--padding-content-top] pb-[--padding-content-bottom]", children: [_jsxs("div", { className: "flex justify-between mb-4 border-b border-border pb-3", children: [_jsx("h1", { className: "font-medium text-2xl", children: "API Keys" }), service.createKey && (_jsx(Button, { asChild: true, children: _jsx(Link, { to: "/settings/api-keys/new", children: "Create API Key" }) }))] }), _jsx(Card, { children: _jsx("ul", { className: "grid grid-cols-[min-content_1fr_min-content] ", children: data.map((key) => (_jsxs("li", { className: "border-b border-border p-5 grid grid-cols-subgrid col-span-full gap-2 items-center", children: [_jsxs("div", { className: "flex flex-col gap-1 text-sm", children: [key.description ?? key.id, _jsxs("div", { className: "text-muted-foreground text-xs", children: [key.createdOn && (_jsxs("div", { children: ["Created on ", new Date(key.createdOn).toLocaleDateString()] })), key.expiresOn && (_jsxs("div", { children: ["Expires on ", new Date(key.expiresOn).toLocaleDateString()] }))] })] }), _jsx("div", { className: "items-center flex justify-center", children: _jsx(RevealApiKey, { apiKey: key.key }) }), _jsxs("div", { className: "flex gap-2", children: [service.rollKey && (_jsx(Button, { size: "icon", children: _jsx(RotateCwIcon, { size: 16 }) })), service.deleteKey && (_jsx(Button, { variant: "ghost", size: "icon", onClick: () => {
28
- if (!confirm("Do you want to delete this key?")) {
29
- return;
30
- }
31
- deleteKeyMutation.mutate(key.id);
32
- }, disabled: deleteKeyMutation.isPending, children: _jsx(TrashIcon, { size: 16 }) }))] })] }, key.id))) }) })] }));
33
- };
34
- const RevealApiKey = ({ apiKey }) => {
35
- const [revealed, setRevealed] = useState(false);
36
- return (_jsxs("div", { className: "flex gap-2 items-center text-sm", children: [_jsx("code", { className: "border border-border rounded bg-gray-100 dark:bg-gray-950 p-1 font-mono", children: revealed ? apiKey : "•".repeat(apiKey.length) }), _jsx(Button, { variant: "outline", onClick: () => setRevealed((prev) => !prev), size: "icon", children: revealed ? _jsx(EyeOffIcon, { size: 16 }) : _jsx(EyeIcon, { size: 16 }) })] }));
37
- };
38
- //# sourceMappingURL=SettingsApiKeys.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SettingsApiKeys.js","sourceRoot":"","sources":["../../../../src/lib/plugins/api-key/SettingsApiKeys.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,C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AY,GAAG,CAAC,EAAE,MAAM,EAAsB,EAAE,EAAE;IACtD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhD,OAAO,CACL,eAAK,SAAS,EAAC,iCAAiC,aAC9C,eAAM,SAAS,EAAC,yEAAyE,YACtF,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GACzC,EACP,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAC3C,IAAI,EAAC,MAAM,YAEV,QAAQ,CAAC,CAAC,CAAC,KAAC,UAAU,IAAC,IAAI,EAAE,EAAE,GAAI,CAAC,CAAC,CAAC,KAAC,OAAO,IAAC,IAAI,EAAE,EAAE,GAAI,GACrD,IACL,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -1,62 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { CreateApiKey } from "./CreateApiKey.js";
3
- import { SettingsApiKeys } from "./SettingsApiKeys.js";
4
- const DEFAULT_API_KEY_ENDPOINT = "https://zudoku-rewiringamerica-main-ef9c9c0.d2.zuplo.dev";
5
- const createDefaultHandler = (endpoint) => {
6
- return {
7
- deleteKey: async (id, context) => {
8
- const request = new Request(endpoint + `/v1/developer/api-keys/${id}`, {
9
- method: "DELETE",
10
- });
11
- await context.signRequest(request);
12
- await fetch(request);
13
- },
14
- createKey: async (apiKey, context) => {
15
- const request = new Request(endpoint + `/v1/developer/api-keys`, {
16
- method: "POST",
17
- headers: {
18
- "Content-Type": "application/json",
19
- },
20
- body: JSON.stringify(apiKey),
21
- });
22
- await context.signRequest(request);
23
- await fetch(request);
24
- },
25
- getKeys: async (context) => {
26
- const request = new Request(endpoint + `/v1/developer/api-keys`);
27
- await context.signRequest(request);
28
- const keys = await fetch(request);
29
- return await keys.json();
30
- },
31
- };
32
- };
33
- export const apiKeyPlugin = (options) => {
34
- const endpoint = "endpoint" in options ? options.endpoint : DEFAULT_API_KEY_ENDPOINT;
35
- const service = "getKeys" in options ? options : createDefaultHandler(endpoint);
36
- return {
37
- getIdentities: async (context) => {
38
- const keys = await service.getKeys(context);
39
- return keys.map((key) => ({
40
- authorizeRequest: (request) => {
41
- request.headers.set("Authorization", `Bearer ${key.key}`);
42
- return request;
43
- },
44
- id: key.id,
45
- label: key.description ?? key.id,
46
- }));
47
- },
48
- getRoutes: () => {
49
- return [
50
- {
51
- path: "/settings/api-keys",
52
- element: _jsx(SettingsApiKeys, { options: options, service: service }),
53
- },
54
- {
55
- path: "/settings/api-keys/new",
56
- element: _jsx(CreateApiKey, { options: options, service: service }),
57
- },
58
- ];
59
- },
60
- };
61
- };
62
- //# sourceMappingURL=index.js.map