zudoku 0.35.3 → 0.35.5

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 (47) hide show
  1. package/dist/lib/components/Layout.js +1 -1
  2. package/dist/lib/components/Layout.js.map +1 -1
  3. package/dist/lib/plugins/openapi/OperationList.js +1 -0
  4. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  5. package/dist/lib/plugins/openapi/ParamInfos.d.ts +6 -0
  6. package/dist/lib/plugins/openapi/ParamInfos.js +34 -0
  7. package/dist/lib/plugins/openapi/ParamInfos.js.map +1 -0
  8. package/dist/lib/plugins/openapi/ParameterListItem.js +7 -4
  9. package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
  10. package/dist/lib/plugins/openapi/graphql/gql.d.ts +1 -1
  11. package/dist/lib/plugins/openapi/graphql/gql.js +1 -1
  12. package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
  13. package/dist/lib/plugins/openapi/graphql/graphql.d.ts +1 -0
  14. package/dist/lib/plugins/openapi/graphql/graphql.js +2 -0
  15. package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
  16. package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js +9 -8
  17. package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js.map +1 -1
  18. package/dist/lib/ui/Button.d.ts +2 -2
  19. package/dist/lib/ui/Button.js +1 -0
  20. package/dist/lib/ui/Button.js.map +1 -1
  21. package/lib/{OasProvider-7Z9UwS9y.js → OasProvider-CJ8KOnsH.js} +2 -2
  22. package/lib/{OasProvider-7Z9UwS9y.js.map → OasProvider-CJ8KOnsH.js.map} +1 -1
  23. package/lib/{OperationList-a7wnHdXv.js → OperationList-C4rpJdcE.js} +1081 -1049
  24. package/lib/OperationList-C4rpJdcE.js.map +1 -0
  25. package/lib/{Spinner-1KrEmx1V.js → Spinner-C6n4eOvh.js} +13 -12
  26. package/lib/Spinner-C6n4eOvh.js.map +1 -0
  27. package/lib/{index-UmhI2mj7.js → index-Dowg8c_k.js} +7 -5
  28. package/lib/index-Dowg8c_k.js.map +1 -0
  29. package/lib/ui/ActionButton.js +1 -1
  30. package/lib/ui/Button.js +12 -11
  31. package/lib/ui/Button.js.map +1 -1
  32. package/lib/zudoku.components.js +2 -2
  33. package/lib/zudoku.components.js.map +1 -1
  34. package/lib/zudoku.plugin-openapi.js +1 -1
  35. package/package.json +1 -1
  36. package/src/app/main.css +4 -0
  37. package/src/lib/components/Layout.tsx +1 -1
  38. package/src/lib/plugins/openapi/OperationList.tsx +1 -0
  39. package/src/lib/plugins/openapi/ParamInfos.tsx +64 -0
  40. package/src/lib/plugins/openapi/ParameterListItem.tsx +26 -22
  41. package/src/lib/plugins/openapi/graphql/gql.ts +3 -3
  42. package/src/lib/plugins/openapi/graphql/graphql.ts +3 -0
  43. package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +22 -34
  44. package/src/lib/ui/Button.tsx +3 -1
  45. package/lib/OperationList-a7wnHdXv.js.map +0 -1
  46. package/lib/Spinner-1KrEmx1V.js.map +0 -1
  47. package/lib/index-UmhI2mj7.js.map +0 -1
@@ -5,7 +5,7 @@ import "./chunk-HA7DTUK3-ZGg2W6yV.js";
5
5
  import "./hook-CfCFKZ-2.js";
6
6
  import "./ui/Button.js";
7
7
  import "./joinUrl-10po2Jdj.js";
8
- import { U as n, o as s } from "./index-UmhI2mj7.js";
8
+ import { U as n, o as s } from "./index-Dowg8c_k.js";
9
9
  export {
10
10
  n as UNTAGGED_PATH,
11
11
  s as openApiPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.35.3",
3
+ "version": "0.35.5",
4
4
  "type": "module",
5
5
  "homepage": "https://zudoku.dev",
6
6
  "repository": {
package/src/app/main.css CHANGED
@@ -123,6 +123,10 @@
123
123
  "calt" 1;
124
124
  }
125
125
 
126
+ ::selection {
127
+ @apply bg-primary/100 text-primary-foreground;
128
+ }
129
+
126
130
  .dark {
127
131
  color-scheme: dark;
128
132
  }
@@ -12,7 +12,7 @@ import { Slotlet } from "./SlotletProvider.js";
12
12
  import { Spinner } from "./Spinner.js";
13
13
 
14
14
  const LoadingFallback = () => (
15
- <main className="col-span-full grid place-items-center">
15
+ <main className="col-span-full row-span-full grid place-items-center">
16
16
  <Spinner />
17
17
  </main>
18
18
  );
@@ -46,6 +46,7 @@ export const OperationsFragment = graphql(/* GraphQL */ `
46
46
  required
47
47
  schema
48
48
  style
49
+ explode
49
50
  examples {
50
51
  name
51
52
  description
@@ -0,0 +1,64 @@
1
+ import { isValidElement } from "react";
2
+ import { InlineCode } from "../../components/InlineCode.js";
3
+ import { type SchemaObject } from "../../oas/parser/index.js";
4
+
5
+ const getSchemaInfos = (schema?: SchemaObject) => {
6
+ if (!schema) return [];
7
+
8
+ return [
9
+ schema.type === "array" && schema.items.type
10
+ ? `${schema.items.type}[]`
11
+ : Array.isArray(schema.type)
12
+ ? schema.type.join(" | ")
13
+ : schema.type,
14
+
15
+ schema.enum && "enum",
16
+ schema.format,
17
+ schema.minimum && `min: ${schema.minimum}`,
18
+ schema.maximum && `max: ${schema.maximum}`,
19
+ schema.minLength && `minLength: ${schema.minLength}`,
20
+ schema.maxLength && `maxLength: ${schema.maxLength}`,
21
+ schema.minItems && `minItems: ${schema.minItems}`,
22
+ schema.maxItems && `maxItems: ${schema.maxItems}`,
23
+ schema.uniqueItems && "unique",
24
+ schema.minProperties && `minProps: ${schema.minProperties}`,
25
+ schema.maxProperties && `maxProps: ${schema.maxProperties}`,
26
+ schema.readOnly && "readOnly",
27
+ schema.writeOnly && "writeOnly",
28
+ schema.deprecated && "deprecated",
29
+ schema.pattern && (
30
+ <>
31
+ pattern: <InlineCode className="text-xs">{schema.pattern}</InlineCode>
32
+ </>
33
+ ),
34
+ ];
35
+ };
36
+
37
+ export const ParamInfos = ({
38
+ schema,
39
+ extraItems = [],
40
+ className,
41
+ }: {
42
+ schema?: SchemaObject;
43
+ extraItems?: unknown[];
44
+ className?: string;
45
+ }) => {
46
+ const filteredItems = [...getSchemaInfos(schema), ...extraItems].flatMap(
47
+ (item) => (typeof item === "string" || isValidElement(item) ? item : []),
48
+ );
49
+
50
+ return (
51
+ <div className={className}>
52
+ {filteredItems.map((item, index) => (
53
+ <span className="text-muted-foreground" key={index}>
54
+ {item}
55
+ {index < filteredItems.length - 1 && (
56
+ <span className="text-muted-foreground/50">
57
+ &nbsp;&middot;&nbsp;
58
+ </span>
59
+ )}
60
+ </span>
61
+ ))}
62
+ </div>
63
+ );
64
+ };
@@ -1,10 +1,11 @@
1
- import { Badge } from "zudoku/ui/Badge.js";
2
1
  import { Markdown } from "../../components/Markdown.js";
3
2
  import { type SchemaObject } from "../../oas/graphql/index.js";
4
3
  import { ColorizedParam } from "./ColorizedParam.js";
5
4
  import type { OperationListItemResult } from "./OperationList.js";
6
5
  import type { ParameterGroup } from "./OperationListItem.js";
6
+ import { ParamInfos } from "./ParamInfos.js";
7
7
  import { EnumValues } from "./components/EnumValues.js";
8
+ import { SelectOnClick } from "./components/SelectOnClick.js";
8
9
 
9
10
  const getParameterSchema = (
10
11
  parameter: ParameterListItemResult,
@@ -35,27 +36,30 @@ export const ParameterListItem = ({
35
36
  return (
36
37
  <li className="p-4 bg-border/20 text-sm flex flex-col gap-1.5">
37
38
  <div className="flex items-center gap-2">
38
- <code>
39
- {group === "path" ? (
40
- <ColorizedParam
41
- name={parameter.name}
42
- backgroundOpacity="15%"
43
- className="px-1"
44
- slug={`${id}-${parameter.name}`}
45
- />
46
- ) : (
47
- parameter.name
48
- )}
49
- </code>
50
- {paramSchema.type && (
51
- <Badge variant="muted">
52
- {paramSchema.type === "array"
53
- ? `${paramSchema.items.type}[]`
54
- : paramSchema.type}
55
- </Badge>
56
- )}
57
- {parameter.required && <Badge variant="outline">required</Badge>}
58
- {parameter.style === "form" && <Badge variant="secondary">form</Badge>}
39
+ <SelectOnClick asChild>
40
+ <code>
41
+ {group === "path" ? (
42
+ <ColorizedParam
43
+ name={parameter.name}
44
+ backgroundOpacity="15%"
45
+ className="px-2"
46
+ slug={`${id}-${parameter.name}`}
47
+ />
48
+ ) : (
49
+ parameter.name
50
+ )}
51
+ </code>
52
+ </SelectOnClick>
53
+ <ParamInfos
54
+ schema={paramSchema}
55
+ extraItems={[
56
+ parameter.required && (
57
+ <span className="text-primary">required</span>
58
+ ),
59
+ parameter.style && `style: ${parameter.style}`,
60
+ parameter.explode && `explode: ${parameter.explode}`,
61
+ ]}
62
+ />
59
63
  </div>
60
64
  {parameter.description && (
61
65
  <Markdown
@@ -14,7 +14,7 @@ import * as types from "./graphql.js";
14
14
  */
15
15
  type Documents = {
16
16
  "\n query ServersQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n": typeof types.ServersQueryDocument;
17
- "\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n deprecated\n extensions\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 examples {\n name\n description\n externalValue\n value\n summary\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n examples {\n name\n description\n externalValue\n value\n summary\n }\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n": typeof types.OperationsFragmentFragmentDoc;
17
+ "\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n deprecated\n extensions\n parameters {\n name\n in\n description\n required\n schema\n style\n explode\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 examples {\n name\n description\n externalValue\n value\n summary\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n examples {\n name\n description\n externalValue\n value\n summary\n }\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n": typeof types.OperationsFragmentFragmentDoc;
18
18
  "\n query AllOperations(\n $input: JSON!\n $type: SchemaType!\n $tag: String\n $untagged: Boolean\n ) {\n schema(input: $input, type: $type) {\n servers {\n url\n }\n description\n summary\n title\n url\n version\n tags(name: $tag) {\n name\n description\n }\n operations(tag: $tag, untagged: $untagged) {\n slug\n ...OperationsFragment\n }\n }\n }\n": typeof types.AllOperationsDocument;
19
19
  "\n query getServerQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n": typeof types.GetServerQueryDocument;
20
20
  "\n query GetCategories($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n tags {\n name\n }\n }\n }\n": typeof types.GetCategoriesDocument;
@@ -23,7 +23,7 @@ type Documents = {
23
23
  const documents: Documents = {
24
24
  "\n query ServersQuery($input: JSON!, $type: SchemaType!) {\n schema(input: $input, type: $type) {\n url\n servers {\n url\n }\n }\n }\n":
25
25
  types.ServersQueryDocument,
26
- "\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n deprecated\n extensions\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 examples {\n name\n description\n externalValue\n value\n summary\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n examples {\n name\n description\n externalValue\n value\n summary\n }\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n":
26
+ "\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n deprecated\n extensions\n parameters {\n name\n in\n description\n required\n schema\n style\n explode\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 examples {\n name\n description\n externalValue\n value\n summary\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n examples {\n name\n description\n externalValue\n value\n summary\n }\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n":
27
27
  types.OperationsFragmentFragmentDoc,
28
28
  "\n query AllOperations(\n $input: JSON!\n $type: SchemaType!\n $tag: String\n $untagged: Boolean\n ) {\n schema(input: $input, type: $type) {\n servers {\n url\n }\n description\n summary\n title\n url\n version\n tags(name: $tag) {\n name\n description\n }\n operations(tag: $tag, untagged: $untagged) {\n slug\n ...OperationsFragment\n }\n }\n }\n":
29
29
  types.AllOperationsDocument,
@@ -45,7 +45,7 @@ export function graphql(
45
45
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
46
46
  */
47
47
  export function graphql(
48
- source: "\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n deprecated\n extensions\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 examples {\n name\n description\n externalValue\n value\n summary\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n examples {\n name\n description\n externalValue\n value\n summary\n }\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n",
48
+ source: "\n fragment OperationsFragment on OperationItem {\n slug\n summary\n method\n description\n operationId\n contentTypes\n path\n deprecated\n extensions\n parameters {\n name\n in\n description\n required\n schema\n style\n explode\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 examples {\n name\n description\n externalValue\n value\n summary\n }\n schema\n }\n description\n required\n }\n responses {\n statusCode\n links\n description\n content {\n examples {\n name\n description\n externalValue\n value\n summary\n }\n mediaType\n encoding {\n name\n }\n schema\n }\n }\n }\n",
49
49
  ): typeof import("./graphql.js").OperationsFragmentFragmentDoc;
50
50
  /**
51
51
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
@@ -212,6 +212,7 @@ export type OperationsFragmentFragment = {
212
212
  required?: boolean | null;
213
213
  schema?: any | null;
214
214
  style?: string | null;
215
+ explode?: boolean | null;
215
216
  examples?: Array<{
216
217
  __typename?: "ExampleItem";
217
218
  name: string;
@@ -390,6 +391,7 @@ export const OperationsFragmentFragmentDoc = new TypedDocumentString(
390
391
  required
391
392
  schema
392
393
  style
394
+ explode
393
395
  examples {
394
396
  name
395
397
  description
@@ -490,6 +492,7 @@ export const AllOperationsDocument = new TypedDocumentString(`
490
492
  required
491
493
  schema
492
494
  style
495
+ explode
493
496
  examples {
494
497
  name
495
498
  description
@@ -1,13 +1,14 @@
1
1
  import * as Collapsible from "@radix-ui/react-collapsible";
2
- import { ListPlusIcon, RefreshCcwDotIcon } from "lucide-react";
2
+ import { MinusIcon, PlusIcon, RefreshCcwDotIcon } from "lucide-react";
3
3
  import { useCallback, useState } from "react";
4
- import { Badge } from "zudoku/ui/Badge.js";
5
4
  import { Markdown, ProseClasses } from "../../../components/Markdown.js";
6
5
  import type { SchemaObject } from "../../../oas/parser/index.js";
7
6
  import { Button } from "../../../ui/Button.js";
8
7
  import { cn } from "../../../util/cn.js";
9
8
  import { objectEntries } from "../../../util/objectEntries.js";
10
9
  import { EnumValues } from "../components/EnumValues.js";
10
+ import { SelectOnClick } from "../components/SelectOnClick.js";
11
+ import { ParamInfos } from "../ParamInfos.js";
11
12
  import { LogicalGroup } from "./LogicalGroup/LogicalGroup.js";
12
13
  import { SchemaView } from "./SchemaView.js";
13
14
  import {
@@ -43,8 +44,8 @@ export const SchemaLogicalGroup = ({
43
44
  };
44
45
 
45
46
  const RecursiveIndicator = () => (
46
- <div className="flex items-center gap-2 italic text-sm text-muted-foreground font-mono bg-muted px-2 py-0.5 rounded-md">
47
- <RefreshCcwDotIcon size={16} />
47
+ <div className="flex items-center gap-1.5 italic text-xs text-muted-foreground font-mono bg-muted px-2 py-0.5 rounded-md">
48
+ <RefreshCcwDotIcon size={13} />
48
49
  <span>circular</span>
49
50
  </div>
50
51
  );
@@ -69,11 +70,10 @@ export const SchemaPropertyItem = ({
69
70
  if (isCircularRef(schema)) {
70
71
  return (
71
72
  <li className="p-4 bg-border/20 hover:bg-border/30">
72
- <div className="flex flex-col gap-1 justify-between text-sm">
73
+ <div className="flex flex-col gap-2.5 justify-between text-sm">
73
74
  <div className="flex gap-2 items-center">
74
75
  <code>{name}</code>
75
- <Badge variant="muted">object</Badge>
76
- {group === "optional" && <Badge variant="outline">optional</Badge>}
76
+ <ParamInfos schema={schema} />
77
77
  <RecursiveIndicator />
78
78
  </div>
79
79
  </div>
@@ -83,19 +83,19 @@ export const SchemaPropertyItem = ({
83
83
 
84
84
  return (
85
85
  <li className="p-4 bg-border/20 hover:bg-border/30">
86
- <div className="flex flex-col gap-1.5 justify-between text-sm">
86
+ <div className="flex flex-col gap-2.5 justify-between text-sm">
87
87
  <div className="flex gap-2 items-center">
88
- <code>{name}</code>
89
- <Badge variant="muted">
90
- {schema.type === "array" && schema.items.type ? (
91
- <span>{schema.items.type}[]</span>
92
- ) : Array.isArray(schema.type) ? (
93
- <span>{schema.type.join(" | ")}</span>
94
- ) : (
95
- <span>{schema.type}</span>
96
- )}
97
- </Badge>
98
- {group === "optional" && <Badge variant="outline">optional</Badge>}
88
+ <SelectOnClick asChild>
89
+ <code>{name}</code>
90
+ </SelectOnClick>
91
+ <ParamInfos
92
+ schema={schema}
93
+ extraItems={[
94
+ group !== "optional" && (
95
+ <span className="text-primary">required</span>
96
+ ),
97
+ ]}
98
+ />
99
99
  {schema.type === "array" &&
100
100
  "items" in schema &&
101
101
  isCircularRef(schema.items) && <RecursiveIndicator />}
@@ -106,12 +106,6 @@ export const SchemaPropertyItem = ({
106
106
  content={schema.description}
107
107
  />
108
108
  )}
109
- {schema.format && (
110
- <div>
111
- <span className="text-sm text-muted-foreground">Format: </span>
112
- <code>{schema.format}</code>
113
- </div>
114
- )}
115
109
  {schema.enum && <EnumValues values={schema.enum} />}
116
110
 
117
111
  {(hasLogicalGroupings(schema) || isComplexType(schema)) && (
@@ -122,15 +116,9 @@ export const SchemaPropertyItem = ({
122
116
  >
123
117
  {showCollapseButton && (
124
118
  <Collapsible.Trigger asChild>
125
- <Button
126
- variant="outline"
127
- size="sm"
128
- className="mt-2 flex gap-1.5"
129
- >
130
- <ListPlusIcon size={18} />
131
- {!isOpen
132
- ? "Show nested properties"
133
- : "Hide nested properties"}
119
+ <Button variant="expand" size="sm" className="h-7">
120
+ {isOpen ? <MinusIcon size={12} /> : <PlusIcon size={12} />}
121
+ {!isOpen ? "Show properties" : "Hide properties"}
134
122
  </Button>
135
123
  </Collapsible.Trigger>
136
124
  )}
@@ -1,5 +1,5 @@
1
1
  import { Slot } from "@radix-ui/react-slot";
2
- import { cva, VariantProps } from "class-variance-authority";
2
+ import { cva, type VariantProps } from "class-variance-authority";
3
3
  import * as React from "react";
4
4
  import { cn } from "../util/cn.js";
5
5
 
@@ -18,6 +18,8 @@ export const buttonVariants = cva(
18
18
  "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
19
19
  ghost: "hover:bg-accent hover:text-accent-foreground",
20
20
  link: "text-primary underline-offset-4 hover:underline",
21
+ expand:
22
+ "flex gap-1.5 border bg-transparent rounded-xl text-muted-foreground hover:text-foreground",
21
23
  },
22
24
  size: {
23
25
  default: "h-9 px-4 py-2",