zudoku 0.10.0 → 0.12.0

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 (164) hide show
  1. package/README.md +121 -0
  2. package/dist/config/config.d.ts +2 -6
  3. package/dist/config/validators/InputSidebarSchema.d.ts +1 -0
  4. package/dist/config/validators/validate.d.ts +151 -37
  5. package/dist/config/validators/validate.js +14 -11
  6. package/dist/config/validators/validate.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/lib/authentication/state.d.ts +16 -0
  9. package/dist/lib/authentication/state.js +5 -0
  10. package/dist/lib/authentication/state.js.map +1 -1
  11. package/dist/lib/components/ErrorPage.js +1 -2
  12. package/dist/lib/components/ErrorPage.js.map +1 -1
  13. package/dist/lib/components/InlineCode.d.ts +2 -1
  14. package/dist/lib/components/InlineCode.js +9 -1
  15. package/dist/lib/components/InlineCode.js.map +1 -1
  16. package/dist/lib/components/Layout.js +1 -1
  17. package/dist/lib/components/Layout.js.map +1 -1
  18. package/dist/lib/oas/graphql/index.d.ts +2 -1
  19. package/dist/lib/oas/graphql/index.js +22 -10
  20. package/dist/lib/oas/graphql/index.js.map +1 -1
  21. package/dist/lib/oas/parser/index.d.ts +1 -0
  22. package/dist/lib/oas/parser/index.js.map +1 -1
  23. package/dist/lib/plugins/markdown/MdxPage.js +2 -2
  24. package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
  25. package/dist/lib/plugins/markdown/generateRoutes.d.ts +1 -1
  26. package/dist/lib/plugins/markdown/generateRoutes.js +8 -6
  27. package/dist/lib/plugins/markdown/generateRoutes.js.map +1 -1
  28. package/dist/lib/plugins/markdown/index.d.ts +2 -1
  29. package/dist/lib/plugins/markdown/index.js +2 -2
  30. package/dist/lib/plugins/markdown/index.js.map +1 -1
  31. package/dist/lib/plugins/openapi/Endpoint.d.ts +1 -3
  32. package/dist/lib/plugins/openapi/Endpoint.js +46 -8
  33. package/dist/lib/plugins/openapi/Endpoint.js.map +1 -1
  34. package/dist/lib/plugins/openapi/OperationList.js +1 -1
  35. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  36. package/dist/lib/plugins/openapi/OperationListItem.js +1 -1
  37. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  38. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.d.ts +2 -1
  39. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js +2 -2
  40. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js.map +1 -1
  41. package/dist/lib/plugins/openapi/Sidecar.js +14 -3
  42. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  43. package/dist/lib/plugins/openapi/SimpleSelect.d.ts +2 -1
  44. package/dist/lib/plugins/openapi/SimpleSelect.js +1 -1
  45. package/dist/lib/plugins/openapi/SimpleSelect.js.map +1 -1
  46. package/dist/lib/plugins/openapi/graphql/gql.d.ts +10 -2
  47. package/dist/lib/plugins/openapi/graphql/gql.js +2 -1
  48. package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
  49. package/dist/lib/plugins/openapi/graphql/graphql.d.ts +29 -3
  50. package/dist/lib/plugins/openapi/graphql/graphql.js +87 -0
  51. package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
  52. package/dist/lib/plugins/openapi/interfaces.d.ts +3 -0
  53. package/dist/lib/plugins/openapi/playground/Playground.d.ts +2 -1
  54. package/dist/lib/plugins/openapi/playground/Playground.js +13 -5
  55. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  56. package/dist/lib/plugins/openapi/playground/ResponseTab.js +1 -1
  57. package/dist/lib/plugins/openapi/playground/ResponseTab.js.map +1 -1
  58. package/dist/lib/plugins/openapi/playground/createUrl.js +3 -1
  59. package/dist/lib/plugins/openapi/playground/createUrl.js.map +1 -1
  60. package/dist/vite/config.d.ts +1 -1
  61. package/dist/vite/config.js +19 -15
  62. package/dist/vite/config.js.map +1 -1
  63. package/dist/vite/dev-server.d.ts +1 -0
  64. package/dist/vite/dev-server.js +7 -13
  65. package/dist/vite/dev-server.js.map +1 -1
  66. package/dist/vite/plugin-api.js +4 -7
  67. package/dist/vite/plugin-api.js.map +1 -1
  68. package/dist/vite/plugin-config-reload.js +9 -4
  69. package/dist/vite/plugin-config-reload.js.map +1 -1
  70. package/dist/vite/plugin-docs.js +7 -5
  71. package/dist/vite/plugin-docs.js.map +1 -1
  72. package/dist/vite/plugin-frontmatter.d.ts +2 -0
  73. package/dist/vite/plugin-frontmatter.js +30 -0
  74. package/dist/vite/plugin-frontmatter.js.map +1 -0
  75. package/dist/vite/plugin-sidebar.js +14 -1
  76. package/dist/vite/plugin-sidebar.js.map +1 -1
  77. package/dist/vite/plugin.js +2 -2
  78. package/dist/vite/plugin.js.map +1 -1
  79. package/lib/{CategoryHeading-XnFqN2lJ.js → CategoryHeading-ovR-zHRq.js} +2 -2
  80. package/lib/{CategoryHeading-XnFqN2lJ.js.map → CategoryHeading-ovR-zHRq.js.map} +1 -1
  81. package/lib/{DeveloperHint-FBb2uXJe.js → DeveloperHint-YeWHKvyr.js} +2 -2
  82. package/lib/{DeveloperHint-FBb2uXJe.js.map → DeveloperHint-YeWHKvyr.js.map} +1 -1
  83. package/lib/ErrorPage-CsZAN_za.js +16 -0
  84. package/lib/ErrorPage-CsZAN_za.js.map +1 -0
  85. package/lib/{Input-BEDZAKw0.js → Input-CtVUl3eT.js} +3 -3
  86. package/lib/{Input-BEDZAKw0.js.map → Input-CtVUl3eT.js.map} +1 -1
  87. package/lib/{Markdown-B4aR03g6.js → Markdown-DapSf3wG.js} +795 -793
  88. package/lib/Markdown-DapSf3wG.js.map +1 -0
  89. package/lib/{MdxPage-BZyQsH8Z.js → MdxPage-BqBWsXZ1.js} +23 -23
  90. package/lib/MdxPage-BqBWsXZ1.js.map +1 -0
  91. package/lib/{OperationList-2NeWEM0u.js → OperationList-CYrmxPa8.js} +151 -109
  92. package/lib/OperationList-CYrmxPa8.js.map +1 -0
  93. package/lib/{Route-BZPewmrN.js → Route-Q5mqNQrv.js} +2 -2
  94. package/lib/{Route-BZPewmrN.js.map → Route-Q5mqNQrv.js.map} +1 -1
  95. package/lib/{SidebarBadge-COz0hgfa.js → SidebarBadge-Dx7jtnoA.js} +3 -3
  96. package/lib/{SidebarBadge-COz0hgfa.js.map → SidebarBadge-Dx7jtnoA.js.map} +1 -1
  97. package/lib/{SlotletProvider-DJMaOUDs.js → SlotletProvider-D3UD5Go3.js} +4 -4
  98. package/lib/{SlotletProvider-DJMaOUDs.js.map → SlotletProvider-D3UD5Go3.js.map} +1 -1
  99. package/lib/assets/{worker-BvD7B6MG.js → worker-Bcj4NA2p.js} +3430 -1351
  100. package/lib/assets/worker-Bcj4NA2p.js.map +1 -0
  101. package/lib/{index-Dv2KZuEw.js → index-BlJ2rj99.js} +1774 -1644
  102. package/lib/index-BlJ2rj99.js.map +1 -0
  103. package/lib/index-Bn6Lc9tq.js +9 -0
  104. package/lib/index-Bn6Lc9tq.js.map +1 -0
  105. package/lib/{index-1EDgIO6b.js → index-BngPzhKn.js} +3 -3
  106. package/lib/{index-1EDgIO6b.js.map → index-BngPzhKn.js.map} +1 -1
  107. package/lib/{index-Zezcv0xb.js → index-Dolisrci.js} +3 -3
  108. package/lib/{index-Zezcv0xb.js.map → index-Dolisrci.js.map} +1 -1
  109. package/lib/index-LNp6rxyU.js +2094 -0
  110. package/lib/index-LNp6rxyU.js.map +1 -0
  111. package/lib/state-hNe1dw4B.js +548 -0
  112. package/lib/state-hNe1dw4B.js.map +1 -0
  113. package/lib/zudoku.auth-auth0.js +1 -1
  114. package/lib/zudoku.auth-clerk.js +1 -1
  115. package/lib/zudoku.auth-openid.js +4 -4
  116. package/lib/zudoku.components.js +6 -6
  117. package/lib/zudoku.components.js.map +1 -1
  118. package/lib/zudoku.openapi-worker.js +497 -489
  119. package/lib/zudoku.openapi-worker.js.map +1 -1
  120. package/lib/zudoku.plugin-api-keys.js +5 -5
  121. package/lib/zudoku.plugin-custom-page.js +1 -1
  122. package/lib/zudoku.plugin-markdown.js +18 -15
  123. package/lib/zudoku.plugin-markdown.js.map +1 -1
  124. package/lib/zudoku.plugin-openapi.js +4 -4
  125. package/package.json +14 -4
  126. package/src/lib/authentication/state.ts +17 -0
  127. package/src/lib/components/ErrorPage.tsx +0 -2
  128. package/src/lib/components/InlineCode.tsx +10 -0
  129. package/src/lib/components/Layout.tsx +1 -1
  130. package/src/lib/oas/graphql/index.ts +33 -13
  131. package/src/lib/oas/parser/index.ts +1 -0
  132. package/src/lib/plugins/markdown/MdxPage.tsx +2 -2
  133. package/src/lib/plugins/markdown/generateRoutes.tsx +8 -5
  134. package/src/lib/plugins/markdown/index.tsx +3 -1
  135. package/src/lib/plugins/openapi/Endpoint.tsx +86 -22
  136. package/src/lib/plugins/openapi/OperationList.tsx +3 -1
  137. package/src/lib/plugins/openapi/OperationListItem.tsx +1 -1
  138. package/src/lib/plugins/openapi/PlaygroundDialogWrapper.tsx +3 -0
  139. package/src/lib/plugins/openapi/Sidecar.tsx +17 -2
  140. package/src/lib/plugins/openapi/SimpleSelect.tsx +10 -2
  141. package/src/lib/plugins/openapi/graphql/gql.ts +11 -3
  142. package/src/lib/plugins/openapi/graphql/graphql.ts +116 -4
  143. package/src/lib/plugins/openapi/interfaces.ts +4 -1
  144. package/src/lib/plugins/openapi/playground/Playground.tsx +39 -5
  145. package/src/lib/plugins/openapi/playground/ResponseTab.tsx +0 -1
  146. package/src/lib/plugins/openapi/playground/createUrl.ts +6 -1
  147. package/dist/lib/util/slugify.d.ts +0 -2
  148. package/dist/lib/util/slugify.js +0 -3
  149. package/dist/lib/util/slugify.js.map +0 -1
  150. package/dist/vite/plugin-icons.d.ts +0 -3
  151. package/dist/vite/plugin-icons.js +0 -47
  152. package/dist/vite/plugin-icons.js.map +0 -1
  153. package/lib/ErrorPage-knunPbKI.js +0 -18
  154. package/lib/ErrorPage-knunPbKI.js.map +0 -1
  155. package/lib/Markdown-B4aR03g6.js.map +0 -1
  156. package/lib/MdxPage-BZyQsH8Z.js.map +0 -1
  157. package/lib/OperationList-2NeWEM0u.js.map +0 -1
  158. package/lib/assets/worker-BvD7B6MG.js.map +0 -1
  159. package/lib/index-Dv2KZuEw.js.map +0 -1
  160. package/lib/slugify-DbLhpSPt.js +0 -28
  161. package/lib/slugify-DbLhpSPt.js.map +0 -1
  162. package/lib/state-lIwt9isb.js +0 -288
  163. package/lib/state-lIwt9isb.js.map +0 -1
  164. package/src/lib/util/slugify.ts +0 -3
@@ -7,6 +7,7 @@ export const SimpleSelect = ({
7
7
  onChange,
8
8
  className,
9
9
  options,
10
+ showChevrons = true,
10
11
  }: {
11
12
  value: string;
12
13
  onChange: ChangeEventHandler<HTMLSelectElement>;
@@ -15,12 +16,14 @@ export const SimpleSelect = ({
15
16
  value: string;
16
17
  label: string;
17
18
  }[];
19
+ showChevrons?: boolean;
18
20
  }) => (
19
- <div className={cn("grid", className)}>
21
+ <div className="grid">
20
22
  <select
21
23
  className={cn(
22
24
  "row-start-1 col-start-1 border border-input text-foreground px-2 py-1 pe-6",
23
25
  "rounded-md appearance-none bg-zinc-50 hover:bg-white dark:bg-zinc-800 hover:dark:bg-zinc-800/75",
26
+ className,
24
27
  )}
25
28
  value={value}
26
29
  onChange={onChange}
@@ -31,7 +34,12 @@ export const SimpleSelect = ({
31
34
  </option>
32
35
  ))}
33
36
  </select>
34
- <div className="row-start-1 col-start-1 self-center justify-self-end relative end-2 pointer-events-none">
37
+ <div
38
+ className={cn(
39
+ !showChevrons && "hidden",
40
+ "row-start-1 col-start-1 self-center justify-self-end relative end-2 pointer-events-none",
41
+ )}
42
+ >
35
43
  <ChevronsUpDownIcon size={14} />
36
44
  </div>
37
45
  </div>
@@ -13,11 +13,13 @@ import * as types from "./graphql.js";
13
13
  * Therefore it is highly recommended to use the babel or swc plugin for production.
14
14
  */
15
15
  const documents = {
16
+ "\n query ServersQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n":
17
+ types.ServersQueryDocument,
16
18
  "\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n parameters {\n name\n in\n description\n required\n schema\n style\n examples {\n name\n description\n externalValue\n value\n summary\n }\n }\n requestBody {\n content {\n mediaType\n encoding {\n name\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n":
17
19
  types.OperationsFragmentFragmentDoc,
18
20
  "\n query AllOperations($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n description\n title\n url\n version\n tags {\n name\n description\n operations {\n slug\n ...OperationsFragment\n }\n }\n }\n }\n":
19
21
  types.AllOperationsDocument,
20
- "\n query getServerQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n }\n }\n":
22
+ "\n query getServerQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n":
21
23
  types.GetServerQueryDocument,
22
24
  "\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n tags {\n __typename\n name\n operations {\n __typename\n slug\n deprecated\n method\n summary\n operationId\n path\n }\n }\n }\n }\n":
23
25
  types.GetCategoriesDocument,
@@ -37,6 +39,12 @@ const documents = {
37
39
  */
38
40
  export function graphql(source: string): unknown;
39
41
 
42
+ /**
43
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
44
+ */
45
+ export function graphql(
46
+ source: "\n query ServersQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n",
47
+ ): (typeof documents)["\n query ServersQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n"];
40
48
  /**
41
49
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
42
50
  */
@@ -53,8 +61,8 @@ export function graphql(
53
61
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
54
62
  */
55
63
  export function graphql(
56
- source: "\n query getServerQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n }\n }\n",
57
- ): (typeof documents)["\n query getServerQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n }\n }\n"];
64
+ source: "\n query getServerQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n",
65
+ ): (typeof documents)["\n query getServerQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n"];
58
66
  /**
59
67
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
60
68
  */
@@ -119,7 +119,7 @@ export type RequestBodyObject = {
119
119
  export type ResponseItem = {
120
120
  __typename?: "ResponseItem";
121
121
  content?: Maybe<Array<MediaTypeObject>>;
122
- description: Scalars["String"]["output"];
122
+ description?: Maybe<Scalars["String"]["output"]>;
123
123
  headers?: Maybe<Scalars["JSON"]["output"]>;
124
124
  links?: Maybe<Scalars["JSON"]["output"]>;
125
125
  statusCode: Scalars["String"]["output"];
@@ -131,6 +131,7 @@ export type Schema = {
131
131
  openapi: Scalars["String"]["output"];
132
132
  operations: Array<OperationItem>;
133
133
  paths: Array<PathItem>;
134
+ servers: Array<Server>;
134
135
  tags: Array<SchemaTag>;
135
136
  title: Scalars["String"]["output"];
136
137
  url: Scalars["String"]["output"];
@@ -155,7 +156,13 @@ export type SchemaTag = {
155
156
  operations: Array<OperationItem>;
156
157
  };
157
158
 
158
- export type SchemaType = "file" | "url";
159
+ export type SchemaType = "file" | "raw" | "url";
160
+
161
+ export type Server = {
162
+ __typename?: "Server";
163
+ description?: Maybe<Scalars["String"]["output"]>;
164
+ url: Scalars["String"]["output"];
165
+ };
159
166
 
160
167
  export type TagItem = {
161
168
  __typename?: "TagItem";
@@ -163,6 +170,20 @@ export type TagItem = {
163
170
  name: Scalars["String"]["output"];
164
171
  };
165
172
 
173
+ export type ServersQueryQueryVariables = Exact<{
174
+ input: Scalars["JSON"]["input"];
175
+ type: SchemaType;
176
+ }>;
177
+
178
+ export type ServersQueryQuery = {
179
+ __typename?: "Query";
180
+ schema: {
181
+ __typename?: "Schema";
182
+ url: string;
183
+ servers: Array<{ __typename?: "Server"; url: string }>;
184
+ };
185
+ };
186
+
166
187
  export type OperationsFragmentFragment = {
167
188
  __typename?: "OperationItem";
168
189
  slug: string;
@@ -204,7 +225,7 @@ export type OperationsFragmentFragment = {
204
225
  __typename?: "ResponseItem";
205
226
  statusCode: string;
206
227
  links?: any | null;
207
- description: string;
228
+ description?: string | null;
208
229
  content?: Array<{
209
230
  __typename?: "MediaTypeObject";
210
231
  mediaType: string;
@@ -249,7 +270,11 @@ export type GetServerQueryQueryVariables = Exact<{
249
270
 
250
271
  export type GetServerQueryQuery = {
251
272
  __typename?: "Query";
252
- schema: { __typename?: "Schema"; url: string };
273
+ schema: {
274
+ __typename?: "Schema";
275
+ url: string;
276
+ servers: Array<{ __typename?: "Server"; url: string }>;
277
+ };
253
278
  };
254
279
 
255
280
  export type GetCategoriesQueryVariables = Exact<{
@@ -423,6 +448,83 @@ export const OperationsFragmentFragmentDoc = {
423
448
  },
424
449
  ],
425
450
  } as unknown as DocumentNode<OperationsFragmentFragment, unknown>;
451
+ export const ServersQueryDocument = {
452
+ kind: "Document",
453
+ definitions: [
454
+ {
455
+ kind: "OperationDefinition",
456
+ operation: "query",
457
+ name: { kind: "Name", value: "ServersQuery" },
458
+ variableDefinitions: [
459
+ {
460
+ kind: "VariableDefinition",
461
+ variable: {
462
+ kind: "Variable",
463
+ name: { kind: "Name", value: "input" },
464
+ },
465
+ type: {
466
+ kind: "NonNullType",
467
+ type: { kind: "NamedType", name: { kind: "Name", value: "JSON" } },
468
+ },
469
+ },
470
+ {
471
+ kind: "VariableDefinition",
472
+ variable: { kind: "Variable", name: { kind: "Name", value: "type" } },
473
+ type: {
474
+ kind: "NonNullType",
475
+ type: {
476
+ kind: "NamedType",
477
+ name: { kind: "Name", value: "SchemaType" },
478
+ },
479
+ },
480
+ },
481
+ ],
482
+ selectionSet: {
483
+ kind: "SelectionSet",
484
+ selections: [
485
+ {
486
+ kind: "Field",
487
+ name: { kind: "Name", value: "schema" },
488
+ arguments: [
489
+ {
490
+ kind: "Argument",
491
+ name: { kind: "Name", value: "input" },
492
+ value: {
493
+ kind: "Variable",
494
+ name: { kind: "Name", value: "input" },
495
+ },
496
+ },
497
+ {
498
+ kind: "Argument",
499
+ name: { kind: "Name", value: "type" },
500
+ value: {
501
+ kind: "Variable",
502
+ name: { kind: "Name", value: "type" },
503
+ },
504
+ },
505
+ ],
506
+ selectionSet: {
507
+ kind: "SelectionSet",
508
+ selections: [
509
+ { kind: "Field", name: { kind: "Name", value: "url" } },
510
+ {
511
+ kind: "Field",
512
+ name: { kind: "Name", value: "servers" },
513
+ selectionSet: {
514
+ kind: "SelectionSet",
515
+ selections: [
516
+ { kind: "Field", name: { kind: "Name", value: "url" } },
517
+ ],
518
+ },
519
+ },
520
+ ],
521
+ },
522
+ },
523
+ ],
524
+ },
525
+ },
526
+ ],
527
+ } as unknown as DocumentNode<ServersQueryQuery, ServersQueryQueryVariables>;
426
528
  export const AllOperationsDocument = {
427
529
  kind: "Document",
428
530
  definitions: [
@@ -727,6 +829,16 @@ export const GetServerQueryDocument = {
727
829
  kind: "SelectionSet",
728
830
  selections: [
729
831
  { kind: "Field", name: { kind: "Name", value: "url" } },
832
+ {
833
+ kind: "Field",
834
+ name: { kind: "Name", value: "servers" },
835
+ selectionSet: {
836
+ kind: "SelectionSet",
837
+ selections: [
838
+ { kind: "Field", name: { kind: "Name", value: "url" } },
839
+ ],
840
+ },
841
+ },
730
842
  ],
731
843
  },
732
844
  },
@@ -1,4 +1,7 @@
1
- type OasSource = { type: "url"; input: string } | { type: "file"; input: any };
1
+ type OasSource =
2
+ | { type: "url"; input: string }
3
+ | { type: "file"; input: any }
4
+ | { type: "raw"; input: string };
2
5
 
3
6
  export type OasPluginConfig = {
4
7
  server?: string;
@@ -1,6 +1,7 @@
1
1
  import { useMutation } from "@tanstack/react-query";
2
- import { Fragment, useEffect, useRef } from "react";
2
+ import { Fragment, useEffect, useRef, useTransition } from "react";
3
3
  import { FormProvider, useForm } from "react-hook-form";
4
+ import { useSelectedServerStore } from "../../../authentication/state.js";
4
5
  import { useApiIdentities } from "../../../components/context/ZudokuContext.js";
5
6
  import {
6
7
  Select,
@@ -62,6 +63,7 @@ export type PlaygroundForm = {
62
63
 
63
64
  export type PlaygroundContentProps = {
64
65
  server: string;
66
+ servers?: string[];
65
67
  url: string;
66
68
  method: string;
67
69
  headers?: Header[];
@@ -72,6 +74,7 @@ export type PlaygroundContentProps = {
72
74
 
73
75
  export const Playground = ({
74
76
  server,
77
+ servers,
75
78
  url,
76
79
  method,
77
80
  headers = [],
@@ -79,6 +82,8 @@ export const Playground = ({
79
82
  pathParams = [],
80
83
  defaultBody = "",
81
84
  }: PlaygroundContentProps) => {
85
+ const { selectedServer, setSelectedServer } = useSelectedServerStore();
86
+ const [, startTransition] = useTransition();
82
87
  const { register, control, handleSubmit, watch, setValue, ...form } =
83
88
  useForm<PlaygroundForm>({
84
89
  defaultValues: {
@@ -114,7 +119,7 @@ export const Playground = ({
114
119
 
115
120
  const queryMutation = useMutation({
116
121
  mutationFn: async (data: PlaygroundForm) => {
117
- const requestUrl = createUrl(server, url, data);
122
+ const requestUrl = createUrl(selectedServer ?? server, url, data);
118
123
  const start = performance.now();
119
124
 
120
125
  const request = new Request(requestUrl, {
@@ -200,19 +205,48 @@ export const Playground = ({
200
205
  </Fragment>
201
206
  ));
202
207
 
208
+ const serverSelect = (
209
+ <div className="inline-block opacity-50 hover:opacity-100 transition">
210
+ {servers && servers.length > 1 ? (
211
+ <Select
212
+ onValueChange={(value) => {
213
+ startTransition(() => {
214
+ setSelectedServer(value);
215
+ });
216
+ }}
217
+ value={selectedServer}
218
+ >
219
+ <SelectTrigger className="p-0 border-none flex-row-reverse bg-transparent text-xs gap-0.5 h-auto">
220
+ <SelectValue />
221
+ </SelectTrigger>
222
+ <SelectContent>
223
+ {servers.map((s) => (
224
+ <SelectItem key={s} value={s}>
225
+ {s.replace(/^https?:\/\//, "")}
226
+ </SelectItem>
227
+ ))}
228
+ </SelectContent>
229
+ </Select>
230
+ ) : (
231
+ <span>{server.replace(/^https?:\/\//, "")}</span>
232
+ )}
233
+ </div>
234
+ );
235
+
203
236
  return (
204
237
  <FormProvider
205
238
  {...{ register, control, handleSubmit, watch, setValue, ...form }}
206
239
  >
207
240
  <form onSubmit={handleSubmit((data) => queryMutation.mutateAsync(data))}>
208
- <div className="grid grid-cols-2 text-sm h-full">
241
+ <div className="grid grid-cols-[8fr_7fr] text-sm h-full">
209
242
  <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">
210
243
  <div className="flex gap-2 items-stretch">
211
244
  <div className="flex flex-1 items-center w-full border rounded-md">
212
245
  <div className="border-r p-2 bg-muted rounded-l-md self-stretch font-semibold font-mono">
213
246
  {method.toUpperCase()}
214
247
  </div>
215
- <div className="p-2 font-mono text-xs">
248
+ <div className="flex items-center flex-wrap p-2 font-mono text-xs">
249
+ {serverSelect}
216
250
  {path}
217
251
  {urlQueryParams.length > 0 ? "?" : ""}
218
252
  {urlQueryParams}
@@ -296,7 +330,7 @@ export const Playground = ({
296
330
  </TabsContent>
297
331
  </Tabs>
298
332
  </div>
299
- <div className="p-8 bg-muted/70">
333
+ <div className="min-w-0 p-8 bg-muted/70">
300
334
  {queryMutation.error ? (
301
335
  <div className="flex flex-col gap-2">
302
336
  {formState.pathParams.some((p) => p.value === "") && (
@@ -54,7 +54,6 @@ export const ResponseTab = ({
54
54
  view === "raw" ? (jsonContent ? "plain" : detectedLanguage) : "json"
55
55
  }
56
56
  noBackground
57
- showLanguageIndicator
58
57
  // playground dialog has h-5/6 ≈ 83.333vh
59
58
  className="overflow-x-auto p-4 text-xs max-h-[calc(83.333vh-180px)]"
60
59
  code={view === "raw" ? body : beautifiedBody}
@@ -8,7 +8,12 @@ export const createUrl = (host: string, path: string, data: PlaygroundForm) => {
8
8
  return value ?? match;
9
9
  });
10
10
 
11
- const url = new URL(filledPath, host);
11
+ // Ensure host ends with a slash and path doesn't start with one,
12
+ // so they form a correct URL, without overriding the host's path.
13
+ const url = new URL(
14
+ filledPath.replace(/^\//, ""),
15
+ host.endsWith("/") ? host : `${host}/`,
16
+ );
12
17
 
13
18
  data.queryParams
14
19
  .filter((param) => param.active)
@@ -1,2 +0,0 @@
1
- import slugify from "slugify";
2
- export default slugify;
@@ -1,3 +0,0 @@
1
- import slugify from "slugify";
2
- export default slugify;
3
- //# sourceMappingURL=slugify.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slugify.js","sourceRoot":"","sources":["../../../src/lib/util/slugify.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,eAAe,OAAO,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Plugin } from "vite";
2
- export declare const replaceSidebarIcons: (code: string) => string;
3
- export declare const viteIconsPlugin: () => Plugin;
@@ -1,47 +0,0 @@
1
- import matter from "gray-matter";
2
- import { readFile } from "node:fs/promises";
3
- const matchIconAnnotation = /"icon":\s*"(.*?)"/g;
4
- const toPascalCase = (str) => str.replace(/(^\w|-\w)/g, (match) => match.replace("-", "").toUpperCase());
5
- export const replaceSidebarIcons = (code) => {
6
- const collectedIcons = new Set();
7
- let match;
8
- while ((match = matchIconAnnotation.exec(code)) !== null) {
9
- collectedIcons.add(match[1]);
10
- }
11
- const importStatement = `import { ${[...collectedIcons].map(toPascalCase).join(", ")} } from "zudoku/icons";`;
12
- const replacedString = code.replaceAll(matchIconAnnotation,
13
- // The element will be created by the implementers side
14
- (_, iconName) => `"icon": ${toPascalCase(iconName)}`);
15
- return `${importStatement}export const configuredSidebar = ${replacedString};`;
16
- };
17
- // This plugin is responsible to restart the dev server when a sidebar icon is changed inside a markdown file.
18
- export const viteIconsPlugin = () => {
19
- const iconMap = new Map();
20
- return {
21
- enforce: "pre",
22
- name: "zudoku-icons-plugin",
23
- configureServer: ({ watcher, restart }) => {
24
- watcher.on("change", async (filePath) => {
25
- if (/\.mdx?$/.test(filePath)) {
26
- const code = await readFile(filePath, "utf-8");
27
- const { sidebar_icon: sidebarIcon } = matter(code).data;
28
- const previousIcon = iconMap.get(filePath);
29
- if ((!previousIcon && sidebarIcon) ||
30
- (previousIcon && !sidebarIcon) ||
31
- previousIcon !== sidebarIcon) {
32
- await restart();
33
- }
34
- iconMap.set(filePath, sidebarIcon);
35
- }
36
- });
37
- },
38
- async load(id) {
39
- if (/\.mdx?$/.test(id)) {
40
- const code = await readFile(id, "utf-8");
41
- const { sidebar_icon: sidebarIcon } = matter(code).data;
42
- iconMap.set(id, sidebarIcon);
43
- }
44
- },
45
- };
46
- };
47
- //# sourceMappingURL=plugin-icons.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-icons.js","sourceRoot":"","sources":["../../src/vite/plugin-icons.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEjD,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE,CACnC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,EAAE;IAClD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IAEzC,IAAI,KAAK,CAAC;IACV,OAAO,CAAC,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACzD,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,cAAc,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC;IAC9G,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CACpC,mBAAmB;IACnB,uDAAuD;IACvD,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,WAAW,YAAY,CAAC,QAAQ,CAAC,EAAE,CACrD,CAAC;IAEF,OAAO,GAAG,eAAe,oCAAoC,cAAc,GAAG,CAAC;AACjF,CAAC,CAAC;AAEF,8GAA8G;AAC9G,MAAM,CAAC,MAAM,eAAe,GAAG,GAAW,EAAE;IAC1C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEjD,OAAO;QACL,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,qBAAqB;QAC3B,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;YACxC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;gBACtC,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC7B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;oBAC/C,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;oBACxD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;oBAE3C,IACE,CAAC,CAAC,YAAY,IAAI,WAAW,CAAC;wBAC9B,CAAC,YAAY,IAAI,CAAC,WAAW,CAAC;wBAC9B,YAAY,KAAK,WAAW,EAC5B,CAAC;wBACD,MAAM,OAAO,EAAE,CAAC;oBAClB,CAAC;oBAED,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE;YACX,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;gBACzC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;gBACxD,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1,18 +0,0 @@
1
- import { j as r } from "./jsx-runtime-B6kdoens.js";
2
- import { L as a } from "./index-BG0g4WW0.js";
3
- import { C as n } from "./CategoryHeading-XnFqN2lJ.js";
4
- import { P as i, H as t } from "./Markdown-B4aR03g6.js";
5
- const p = ({
6
- title: e = "An error occurred",
7
- message: o,
8
- category: s
9
- }) => /* @__PURE__ */ r.jsxs("div", { className: i + " h-full pt-[--padding-content-top]", children: [
10
- s && /* @__PURE__ */ r.jsx(n, { children: s }),
11
- e && /* @__PURE__ */ r.jsx(t, { level: 1, className: "flex gap-3.5 items-center", children: e }),
12
- /* @__PURE__ */ r.jsx("p", { children: o }),
13
- /* @__PURE__ */ r.jsx(a, { to: "/", children: "Go back home" })
14
- ] });
15
- export {
16
- p as E
17
- };
18
- //# sourceMappingURL=ErrorPage-knunPbKI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ErrorPage-knunPbKI.js","sources":["../src/lib/components/ErrorPage.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Link } from \"react-router-dom\";\nimport { CategoryHeading } from \"./CategoryHeading.js\";\nimport { Heading } from \"./Heading.js\";\nimport { ProseClasses } from \"./Markdown.js\";\n\nexport const ErrorPage = ({\n title = \"An error occurred\",\n message,\n category,\n}: {\n title?: ReactNode;\n message?: ReactNode;\n category?: ReactNode;\n}) => {\n return (\n <div className={ProseClasses + \" h-full pt-[--padding-content-top]\"}>\n {category && <CategoryHeading>{category}</CategoryHeading>}\n {title && (\n <Heading level={1} className=\"flex gap-3.5 items-center\">\n {title}\n </Heading>\n )}\n <p>{message}</p>\n <Link to=\"/\">Go back home</Link>\n </div>\n );\n};\n"],"names":["ErrorPage","title","message","category","jsxs","ProseClasses","jsx","CategoryHeading","Heading","Link"],"mappings":";;;;AAMO,MAAMA,IAAY,CAAC;AAAA,EACxB,OAAAC,IAAQ;AAAA,EACR,SAAAC;AAAA,EACA,UAAAC;AACF,MAMKC,gBAAAA,EAAAA,KAAA,OAAA,EAAI,WAAWC,IAAe,sCAC5B,UAAA;AAAA,EAAYF,KAAAG,gBAAAA,EAAAA,IAACC,KAAiB,UAASJ,EAAA,CAAA;AAAA,EACvCF,KACEK,gBAAAA,EAAAA,IAAAE,GAAA,EAAQ,OAAO,GAAG,WAAU,6BAC1B,UACHP,GAAA;AAAA,EAEFK,gBAAAA,EAAAA,IAAC,OAAG,UAAQJ,EAAA,CAAA;AAAA,EACXI,gBAAAA,EAAA,IAAAG,GAAA,EAAK,IAAG,KAAI,UAAY,gBAAA;AAC3B,EAAA,CAAA;"}