zudoku 0.3.0-dev.77 → 0.3.0-dev.79

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 (109) hide show
  1. package/dist/config/validators/validate.d.ts +130 -130
  2. package/dist/lib/authentication/providers/openid.d.ts +1 -1
  3. package/dist/lib/authentication/providers/openid.js +1 -1
  4. package/dist/lib/authentication/providers/openid.js.map +1 -1
  5. package/dist/lib/components/DevPortal.js +11 -2
  6. package/dist/lib/components/DevPortal.js.map +1 -1
  7. package/dist/lib/components/Heading.d.ts +1 -1
  8. package/dist/lib/core/plugins.d.ts +3 -0
  9. package/dist/lib/core/plugins.js +1 -0
  10. package/dist/lib/core/plugins.js.map +1 -1
  11. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.d.ts +2 -1
  12. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js +8 -16
  13. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js.map +1 -1
  14. package/dist/lib/plugins/openapi/Sidecar.js +18 -1
  15. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  16. package/dist/lib/plugins/openapi/graphql/gql.d.ts +6 -6
  17. package/dist/lib/plugins/openapi/graphql/gql.js +1 -1
  18. package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
  19. package/dist/lib/plugins/openapi/graphql/graphql.d.ts +15 -15
  20. package/dist/lib/plugins/openapi/graphql/graphql.js +67 -67
  21. package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
  22. package/dist/lib/plugins/openapi/index.js +7 -1
  23. package/dist/lib/plugins/openapi/index.js.map +1 -1
  24. package/dist/lib/plugins/openapi/playground/PathParams.d.ts +2 -3
  25. package/dist/lib/plugins/openapi/playground/PathParams.js +3 -4
  26. package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
  27. package/dist/lib/plugins/openapi/playground/Playground.d.ts +22 -10
  28. package/dist/lib/plugins/openapi/playground/Playground.js +40 -28
  29. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  30. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.d.ts +3 -1
  31. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
  32. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
  33. package/dist/lib/plugins/openapi/playground/QueryParams.d.ts +3 -2
  34. package/dist/lib/plugins/openapi/playground/QueryParams.js +10 -5
  35. package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
  36. package/dist/lib/plugins/openapi/playground/ResponseTab.d.ts +4 -0
  37. package/dist/lib/plugins/openapi/playground/ResponseTab.js +40 -0
  38. package/dist/lib/plugins/openapi/playground/ResponseTab.js.map +1 -0
  39. package/dist/lib/ui/Button.d.ts +5 -1
  40. package/dist/lib/ui/Button.js +24 -1
  41. package/dist/lib/ui/Button.js.map +1 -1
  42. package/dist/lib/util/fetchTimeout.d.ts +1 -0
  43. package/dist/lib/util/fetchTimeout.js +14 -0
  44. package/dist/lib/util/fetchTimeout.js.map +1 -0
  45. package/lib/{CategoryHeading-D0V23fMT.js → CategoryHeading-DCmchnA1.js} +2 -2
  46. package/lib/{CategoryHeading-D0V23fMT.js.map → CategoryHeading-DCmchnA1.js.map} +1 -1
  47. package/lib/{Combination-CgxP9BB4.js → Combination-CS4rK8IJ.js} +33 -39
  48. package/lib/Combination-CS4rK8IJ.js.map +1 -0
  49. package/lib/DeveloperHint-DQVwIery.js +10 -0
  50. package/lib/DeveloperHint-DQVwIery.js.map +1 -0
  51. package/lib/{Input-BcZoDid4.js → Input-GFpPXs5b.js} +3 -3
  52. package/lib/{Input-BcZoDid4.js.map → Input-GFpPXs5b.js.map} +1 -1
  53. package/lib/{Markdown-IsabnbGN.js → Markdown-QsZ-PHET.js} +3 -3
  54. package/lib/{Markdown-IsabnbGN.js.map → Markdown-QsZ-PHET.js.map} +1 -1
  55. package/lib/{MdxPage-B1B2Inj5.js → MdxPage-V4FCB0C_.js} +3 -3
  56. package/lib/{MdxPage-B1B2Inj5.js.map → MdxPage-V4FCB0C_.js.map} +1 -1
  57. package/lib/OperationList-C-M33Hxu.js +4368 -0
  58. package/lib/OperationList-C-M33Hxu.js.map +1 -0
  59. package/lib/{Route-D0Ub80Oa.js → Route-CogU1ofM.js} +2 -2
  60. package/lib/{Route-D0Ub80Oa.js.map → Route-CogU1ofM.js.map} +1 -1
  61. package/lib/{SlotletProvider-CJXWb2gw.js → SlotletProvider-D_Vz-7c_.js} +4 -4
  62. package/lib/{SlotletProvider-CJXWb2gw.js.map → SlotletProvider-D_Vz-7c_.js.map} +1 -1
  63. package/lib/Spinner-oNQQyp-I.js +244 -0
  64. package/lib/Spinner-oNQQyp-I.js.map +1 -0
  65. package/lib/index-D4bOMg7f.js +124 -0
  66. package/lib/index-D4bOMg7f.js.map +1 -0
  67. package/lib/index-Uqja2h2M.js +1960 -0
  68. package/lib/index-Uqja2h2M.js.map +1 -0
  69. package/lib/{urql-DMlBWUKL.js → urql-DrBfkb92.js} +2 -3
  70. package/lib/{urql-DMlBWUKL.js.map → urql-DrBfkb92.js.map} +1 -1
  71. package/lib/zudoku.auth-openid.js +1 -1
  72. package/lib/zudoku.auth-openid.js.map +1 -1
  73. package/lib/zudoku.components.js +352 -348
  74. package/lib/zudoku.components.js.map +1 -1
  75. package/lib/zudoku.openapi-worker.js +1 -1
  76. package/lib/zudoku.plugin-api-keys.js +7 -6
  77. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  78. package/lib/zudoku.plugin-custom-page.js +1 -1
  79. package/lib/zudoku.plugin-markdown.js +1 -1
  80. package/lib/zudoku.plugin-openapi.js +5 -4
  81. package/lib/zudoku.plugin-openapi.js.map +1 -1
  82. package/package.json +1 -1
  83. package/src/app/main.css +1 -1
  84. package/src/lib/authentication/providers/openid.tsx +1 -1
  85. package/src/lib/components/DevPortal.tsx +14 -5
  86. package/src/lib/core/plugins.ts +7 -0
  87. package/src/lib/plugins/openapi/PlaygroundDialogWrapper.tsx +9 -17
  88. package/src/lib/plugins/openapi/Sidecar.tsx +23 -1
  89. package/src/lib/plugins/openapi/graphql/gql.ts +8 -8
  90. package/src/lib/plugins/openapi/graphql/graphql.ts +80 -80
  91. package/src/lib/plugins/openapi/index.tsx +21 -0
  92. package/src/lib/plugins/openapi/playground/PathParams.tsx +14 -20
  93. package/src/lib/plugins/openapi/playground/Playground.tsx +76 -56
  94. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +10 -6
  95. package/src/lib/plugins/openapi/playground/QueryParams.tsx +86 -72
  96. package/src/lib/plugins/openapi/playground/ResponseTab.tsx +76 -0
  97. package/src/lib/ui/Button.tsx +32 -2
  98. package/src/lib/util/fetchTimeout.tsx +21 -0
  99. package/dist/lib/ui/button-variants.d.ts +0 -4
  100. package/dist/lib/ui/button-variants.js +0 -25
  101. package/dist/lib/ui/button-variants.js.map +0 -1
  102. package/lib/Combination-CgxP9BB4.js.map +0 -1
  103. package/lib/OperationList-B2nsuf1v.js +0 -5471
  104. package/lib/OperationList-B2nsuf1v.js.map +0 -1
  105. package/lib/Spinner-BhtSoFka.js +0 -359
  106. package/lib/Spinner-BhtSoFka.js.map +0 -1
  107. package/lib/index-BC2Ob2BR.js +0 -727
  108. package/lib/index-BC2Ob2BR.js.map +0 -1
  109. package/src/lib/ui/button-variants.ts +0 -32
@@ -9,12 +9,18 @@ import { Button } from "../../../ui/Button.js";
9
9
  import { Input } from "../../../ui/Input.js";
10
10
  import { cn } from "../../../util/cn.js";
11
11
  import { InlineInput } from "./InlineInput.js";
12
- import type { PlaygroundForm } from "./Playground.js";
12
+ import {
13
+ NO_IDENTITY,
14
+ type PlaygroundForm,
15
+ type QueryParam,
16
+ } from "./Playground.js";
13
17
 
14
18
  export const QueryParams = ({
15
19
  control,
20
+ queryParams,
16
21
  }: {
17
22
  control: Control<PlaygroundForm>;
23
+ queryParams: QueryParam[];
18
24
  }) => {
19
25
  const { fields } = useFieldArray<PlaygroundForm>({
20
26
  control,
@@ -22,93 +28,101 @@ export const QueryParams = ({
22
28
  });
23
29
  const form = useFormContext<PlaygroundForm>();
24
30
 
25
- const requiredFields = form
26
- .getValues("queryParams")
27
- .map((param) => param.isRequired);
31
+ const requiredFields = queryParams.map((param) => Boolean(param.isRequired));
32
+
33
+ const selectedIdentity = form.watch("identity");
34
+ const hasSelectedIdentity = selectedIdentity !== NO_IDENTITY;
28
35
 
29
36
  return (
30
37
  <div className="">
31
38
  <table className="w-full [&_td]:border [&_td]:p-1.5 [&_td]:px-2">
32
39
  <tbody>
33
- {fields.map((field, i) => (
34
- <tr key={field.id} className="hover:bg-accent/40">
35
- <td className="text-center">
36
- <Controller
37
- control={control}
38
- name={`queryParams.${i}.active`}
39
- render={({ field }) => (
40
- <input
41
- type="checkbox"
42
- id={`queryParams.${i}.active`}
43
- checked={field.value}
44
- onChange={field.onChange}
45
- />
46
- )}
47
- />
48
- </td>
49
- <td>
50
- <Controller
51
- control={control}
52
- render={({ field }) => (
53
- <InlineInput asChild>
54
- <label
55
- className="flex items-center cursor-pointer"
56
- htmlFor={`queryParams.${i}.active`}
57
- title={requiredFields[i] ? "Required field" : undefined}
58
- >
59
- {field.value}
60
- {requiredFields[i] && <sup>&nbsp;*</sup>}
61
- </label>
62
- </InlineInput>
63
- )}
64
- name={`queryParams.${i}.name`}
65
- />
66
- </td>
67
- <td>
68
- <div className="flex justify-between items-center">
40
+ {fields
41
+ .filter(
42
+ // TODO remove this hack for Accu or make it more generic
43
+ (field) => !(hasSelectedIdentity && field.name === "apikey"),
44
+ )
45
+ .map((field, i) => (
46
+ <tr key={field.id} className="hover:bg-accent/40">
47
+ <td className="text-center">
69
48
  <Controller
70
49
  control={control}
50
+ name={`queryParams.${i}.active`}
71
51
  render={({ field }) => (
72
- <Input
73
- {...field}
74
- onChange={(e) => {
75
- field.onChange(e.target.value);
76
- if (e.target.value.length > 0) {
77
- form.setValue(`queryParams.${i}.active`, true);
78
- }
79
- }}
80
- placeholder="Enter value"
81
- className="w-full border-0 shadow-none text-xs font-mono"
52
+ <input
53
+ type="checkbox"
54
+ id={`queryParams.${i}.active`}
55
+ checked={field.value}
56
+ onChange={field.onChange}
82
57
  />
83
58
  )}
84
- name={`queryParams.${i}.value`}
85
59
  />
60
+ </td>
61
+ <td>
86
62
  <Controller
87
63
  control={control}
88
64
  render={({ field }) => (
89
- <Button
90
- size="icon"
91
- type="button"
92
- variant="ghost"
93
- aria-label="Clear value"
94
- className={cn(
95
- "ms-2",
96
- field.value.length === 0
97
- ? "opacity-0 pointer-events-none"
98
- : "opacity-100",
99
- )}
100
- title="Clear value"
101
- onClick={() => field.onChange("")}
102
- >
103
- <EraserIcon size={16} />
104
- </Button>
65
+ <InlineInput asChild>
66
+ <label
67
+ className="flex items-center cursor-pointer"
68
+ htmlFor={`queryParams.${i}.active`}
69
+ title={
70
+ requiredFields[i] ? "Required field" : undefined
71
+ }
72
+ >
73
+ {field.value}
74
+ {requiredFields[i] && <sup>&nbsp;*</sup>}
75
+ </label>
76
+ </InlineInput>
105
77
  )}
106
- name={`queryParams.${i}.value`}
78
+ name={`queryParams.${i}.name`}
107
79
  />
108
- </div>
109
- </td>
110
- </tr>
111
- ))}
80
+ </td>
81
+ <td>
82
+ <div className="flex justify-between items-center">
83
+ <Controller
84
+ control={control}
85
+ render={({ field }) => (
86
+ <Input
87
+ {...field}
88
+ onChange={(e) => {
89
+ field.onChange(e.target.value);
90
+ if (e.target.value.length > 0) {
91
+ form.setValue(`queryParams.${i}.active`, true);
92
+ }
93
+ }}
94
+ placeholder="Enter value"
95
+ className="w-full border-0 shadow-none text-xs font-mono"
96
+ />
97
+ )}
98
+ name={`queryParams.${i}.value`}
99
+ />
100
+ <Controller
101
+ control={control}
102
+ render={({ field }) => (
103
+ <Button
104
+ size="icon"
105
+ type="button"
106
+ variant="ghost"
107
+ aria-label="Clear value"
108
+ className={cn(
109
+ "ms-2",
110
+ field.value.length === 0
111
+ ? "opacity-0 pointer-events-none"
112
+ : "opacity-100",
113
+ )}
114
+ title="Clear value"
115
+ onClick={() => field.onChange("")}
116
+ >
117
+ <EraserIcon size={16} />
118
+ </Button>
119
+ )}
120
+ name={`queryParams.${i}.value`}
121
+ />
122
+ </div>
123
+ </td>
124
+ </tr>
125
+ ))}
112
126
  </tbody>
113
127
  </table>
114
128
  </div>
@@ -0,0 +1,76 @@
1
+ import { useState } from "react";
2
+ import { SyntaxHighlight } from "../../../components/SyntaxHighlight.js";
3
+ import { Card } from "../../../ui/Card.js";
4
+ import { SimpleSelect } from "../SimpleSelect.js";
5
+
6
+ const mimeTypeToLanguage = (mimeType: string) => {
7
+ const mimeTypeMapping = {
8
+ "application/json": "json",
9
+ "text/json": "json",
10
+ "text/html": "html",
11
+ "text/css": "css",
12
+ "text/javascript": "javascript",
13
+ "application/xml": "xml",
14
+ "application/xhtml+xml": "xhtml",
15
+ };
16
+
17
+ return Object.entries(mimeTypeMapping).find(([mime]) =>
18
+ mimeType.includes(mime),
19
+ )?.[1];
20
+ };
21
+
22
+ const detectLanguage = (headers: Headers) => {
23
+ const contentType = headers.get("Content-Type") || "";
24
+ return mimeTypeToLanguage(contentType);
25
+ };
26
+
27
+ const tryParseJson = (body: string) => {
28
+ try {
29
+ return JSON.stringify(JSON.parse(body), null, 2);
30
+ } catch {
31
+ return null;
32
+ }
33
+ };
34
+
35
+ export const ResponseTab = ({
36
+ body = "",
37
+ headers,
38
+ }: {
39
+ body?: string;
40
+ headers: Headers;
41
+ }) => {
42
+ const detectedLanguage = detectLanguage(headers);
43
+ const jsonContent = tryParseJson(body);
44
+ const beautifiedBody = jsonContent || body;
45
+ const [view, setView] = useState<"formatted" | "raw">(
46
+ jsonContent ? "formatted" : "raw",
47
+ );
48
+
49
+ return (
50
+ <div className="flex flex-col gap-2">
51
+ <Card className="shadow-none">
52
+ <SyntaxHighlight
53
+ language={
54
+ view === "raw" ? (jsonContent ? "plain" : detectedLanguage) : "json"
55
+ }
56
+ noBackground
57
+ showLanguageIndicator
58
+ className="overflow-x-auto p-4 text-xs"
59
+ code={view === "raw" ? body : beautifiedBody}
60
+ />
61
+ </Card>
62
+ {jsonContent && (
63
+ <div className="flex justify-end">
64
+ <SimpleSelect
65
+ value={view}
66
+ onChange={(e) => setView(e.target.value as "formatted" | "raw")}
67
+ options={[
68
+ { value: "formatted", label: "Formatted" },
69
+ { value: "raw", label: "Raw" },
70
+ ]}
71
+ />
72
+ </div>
73
+ )}
74
+ </div>
75
+ );
76
+ };
@@ -1,8 +1,38 @@
1
1
  import { Slot } from "@radix-ui/react-slot";
2
- import { VariantProps } from "class-variance-authority";
2
+ import { cva, VariantProps } from "class-variance-authority";
3
3
  import * as React from "react";
4
4
  import { cn } from "../util/cn.js";
5
- import { buttonVariants } from "./button-variants.js";
5
+
6
+ const buttonVariants = cva(
7
+ "not-prose inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default:
12
+ "bg-primary text-primary-foreground shadow hover:bg-primary/90",
13
+ destructive:
14
+ "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
15
+ outline:
16
+ "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
17
+ secondary:
18
+ "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
19
+ ghost: "hover:bg-accent hover:text-accent-foreground",
20
+ link: "text-primary underline-offset-4 hover:underline",
21
+ },
22
+ size: {
23
+ default: "h-9 px-4 py-2",
24
+ sm: "h-8 rounded-md px-3 text-xs",
25
+ lg: "h-10 rounded-md px-8",
26
+ xl: "h-14 rounded-lg px-10 text-lg",
27
+ icon: "h-9 w-9",
28
+ },
29
+ },
30
+ defaultVariants: {
31
+ variant: "default",
32
+ size: "default",
33
+ },
34
+ },
35
+ );
6
36
 
7
37
  export interface ButtonProps
8
38
  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
@@ -0,0 +1,21 @@
1
+ export const fetchTimeout = async (
2
+ input: RequestInfo,
3
+ init?: RequestInit,
4
+ timeout = 5000,
5
+ ): Promise<Response> => {
6
+ const controller = new AbortController();
7
+ const signal = controller.signal;
8
+
9
+ const fetchPromise = fetch(input, { ...init, signal });
10
+
11
+ const timeoutPromise = new Promise<Response>((_, reject) => {
12
+ const timer = setTimeout(() => {
13
+ controller.abort("Request timed out");
14
+ reject(new Error("Request timed out"));
15
+ }, timeout);
16
+
17
+ void fetchPromise.finally(() => clearTimeout(timer));
18
+ });
19
+
20
+ return Promise.race([fetchPromise, timeoutPromise]);
21
+ };
@@ -1,4 +0,0 @@
1
- export declare const buttonVariants: (props?: ({
2
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
3
- size?: "default" | "sm" | "lg" | "xl" | "icon" | null | undefined;
4
- } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,25 +0,0 @@
1
- import { cva } from "class-variance-authority";
2
- export const buttonVariants = cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50", {
3
- variants: {
4
- variant: {
5
- default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
6
- destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
7
- outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
8
- secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
9
- ghost: "hover:bg-accent hover:text-accent-foreground",
10
- link: "text-primary underline-offset-4 hover:underline",
11
- },
12
- size: {
13
- default: "h-9 px-4 py-2",
14
- sm: "h-8 rounded-md px-3 text-xs",
15
- lg: "h-10 rounded-md px-8",
16
- xl: "h-14 rounded-lg px-10 text-lg",
17
- icon: "h-9 w-9",
18
- },
19
- },
20
- defaultVariants: {
21
- variant: "default",
22
- size: "default",
23
- },
24
- });
25
- //# sourceMappingURL=button-variants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"button-variants.js","sourceRoot":"","sources":["../../../src/lib/ui/button-variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAC/B,qOAAqO,EACrO;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EACL,+DAA+D;YACjE,WAAW,EACT,8EAA8E;YAChF,OAAO,EACL,0FAA0F;YAC5F,SAAS,EACP,wEAAwE;YAC1E,KAAK,EAAE,8CAA8C;YACrD,IAAI,EAAE,iDAAiD;SACxD;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,eAAe;YACxB,EAAE,EAAE,6BAA6B;YACjC,EAAE,EAAE,sBAAsB;YAC1B,EAAE,EAAE,+BAA+B;YACnC,IAAI,EAAE,SAAS;SAChB;KACF;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,SAAS;KAChB;CACF,CACF,CAAC"}