zudoku 0.42.2 → 0.43.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 (38) hide show
  1. package/dist/app/entry.client.js +21 -0
  2. package/dist/app/entry.client.js.map +1 -1
  3. package/dist/config/loader.d.ts +1 -16
  4. package/dist/config/loader.js +9 -90
  5. package/dist/config/loader.js.map +1 -1
  6. package/dist/lib/plugins/openapi/ParamInfos.js +1 -0
  7. package/dist/lib/plugins/openapi/ParamInfos.js.map +1 -1
  8. package/dist/lib/plugins/openapi/components/ConstValue.d.ts +5 -0
  9. package/dist/lib/plugins/openapi/components/ConstValue.js +6 -0
  10. package/dist/lib/plugins/openapi/components/ConstValue.js.map +1 -0
  11. package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js +4 -2
  12. package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js.map +1 -1
  13. package/dist/lib/plugins/openapi/schema/SchemaView.js +8 -5
  14. package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
  15. package/dist/lib/plugins/openapi/util/generateSchemaExample.js +40 -0
  16. package/dist/lib/plugins/openapi/util/generateSchemaExample.js.map +1 -1
  17. package/dist/vite/config.js +1 -1
  18. package/dist/vite/config.js.map +1 -1
  19. package/lib/{OasProvider-CDtbrUG_.js → OasProvider-DOs0v9u7.js} +2 -2
  20. package/lib/{OasProvider-CDtbrUG_.js.map → OasProvider-DOs0v9u7.js.map} +1 -1
  21. package/lib/{OperationList-DTyJIxKW.js → OperationList-CKac6iap.js} +107 -78
  22. package/lib/{OperationList-DTyJIxKW.js.map → OperationList-CKac6iap.js.map} +1 -1
  23. package/lib/{SchemaList-B9lvArDe.js → SchemaList-BTX2mRMW.js} +3 -3
  24. package/lib/{SchemaList-B9lvArDe.js.map → SchemaList-BTX2mRMW.js.map} +1 -1
  25. package/lib/SchemaView-BYRn_-2l.js +388 -0
  26. package/lib/SchemaView-BYRn_-2l.js.map +1 -0
  27. package/lib/{index-Ckl3s_w-.js → index-DuB48L78.js} +4 -4
  28. package/lib/{index-Ckl3s_w-.js.map → index-DuB48L78.js.map} +1 -1
  29. package/lib/zudoku.plugin-openapi.js +1 -1
  30. package/package.json +2 -2
  31. package/src/app/entry.client.tsx +26 -0
  32. package/src/lib/plugins/openapi/ParamInfos.tsx +1 -0
  33. package/src/lib/plugins/openapi/components/ConstValue.tsx +24 -0
  34. package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +4 -1
  35. package/src/lib/plugins/openapi/schema/SchemaView.tsx +31 -15
  36. package/src/lib/plugins/openapi/util/generateSchemaExample.ts +45 -0
  37. package/lib/SchemaView-DXjql-Bl.js +0 -356
  38. package/lib/SchemaView-DXjql-Bl.js.map +0 -1
@@ -3,7 +3,7 @@ import "lucide-react";
3
3
  import "./chunk-BAXFHI7N-BVBOl9s0.js";
4
4
  import "./hook-CldJlP5c.js";
5
5
  import "./ui/Button.js";
6
- import { U as a, o as e } from "./index-Ckl3s_w-.js";
6
+ import { U as a, o as e } from "./index-DuB48L78.js";
7
7
  export {
8
8
  a as UNTAGGED_PATH,
9
9
  e as openApiPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.42.2",
3
+ "version": "0.43.0",
4
4
  "type": "module",
5
5
  "homepage": "https://zudoku.dev",
6
6
  "repository": {
@@ -166,7 +166,7 @@
166
166
  "@tanstack/react-query": "5.74.3",
167
167
  "@types/react": "19.1.1",
168
168
  "@types/react-dom": "19.1.2",
169
- "@vitejs/plugin-react": "4.3.4",
169
+ "@vitejs/plugin-react": "4.4.1",
170
170
  "@zudoku/httpsnippet": "10.0.9",
171
171
  "@zudoku/react-helmet-async": "2.0.5",
172
172
  "autoprefixer": "10.4.21",
@@ -34,6 +34,32 @@ if (root.childElementCount > 0) {
34
34
  void render(routes);
35
35
  }
36
36
 
37
+ // eslint-disable-next-line no-console
38
+ console.log(
39
+ "%cZUDOKU%c by Zuplo v" + window.ZUDOKU_VERSION,
40
+ [
41
+ "color: #FF00BD",
42
+ "line-height: 50px",
43
+ "font-weight: bolder",
44
+ "font-size: 30px",
45
+ "-webkit-text-stroke-width: 1px",
46
+ "-webkit-text-stroke-color: #FF00BD",
47
+ "text-transform: uppercase",
48
+ "text-align: center",
49
+ "letter-spacing: 5px",
50
+ ].join(" ;"),
51
+ [
52
+ "color: #Df0097",
53
+ "line-height: 50px",
54
+ "font-weight: bolder",
55
+ "font-size: 15px",
56
+ "text-align: center",
57
+ "letter-spacing: 5px",
58
+ ].join(" ;"),
59
+ );
60
+ // eslint-disable-next-line no-console
61
+ console.log("» Learn more about Zudoku https://zudoku.dev");
62
+
37
63
  async function hydrateLazyRoutes(routes: RouteObject[]) {
38
64
  const path = window.location.pathname;
39
65
  const lazyMatches = matchRoutes(routes, path, config.basePath)?.filter(
@@ -36,6 +36,7 @@ const getSchemaInfos = (schema?: SchemaObject) => {
36
36
  : schema.type,
37
37
 
38
38
  schema.enum && "enum",
39
+ schema.const && "const",
39
40
  schema.format,
40
41
  schema.minimum && `min: ${schema.minimum}`,
41
42
  schema.maximum && `max: ${schema.maximum}`,
@@ -0,0 +1,24 @@
1
+ import type { SchemaObject } from "../../../oas/parser/index.js";
2
+ import { SelectOnClick } from "./SelectOnClick.js";
3
+
4
+ export const ConstValue = ({
5
+ schema,
6
+ hideDescription = false,
7
+ }: {
8
+ schema: SchemaObject;
9
+ hideDescription?: boolean;
10
+ }) => {
11
+ return (
12
+ <div className="flex flex-col gap-1 text-xs">
13
+ <div>
14
+ <span className="text-muted-foreground">Const value: </span>
15
+ <SelectOnClick className="border rounded px-1 font-mono">
16
+ {schema.const}
17
+ </SelectOnClick>
18
+ {!hideDescription && schema.description && (
19
+ <div className="text-muted-foreground">{schema.description}</div>
20
+ )}
21
+ </div>
22
+ </div>
23
+ );
24
+ };
@@ -7,6 +7,7 @@ import type { SchemaObject } from "../../../oas/parser/index.js";
7
7
  import { Button } from "../../../ui/Button.js";
8
8
  import { cn } from "../../../util/cn.js";
9
9
  import { objectEntries } from "../../../util/objectEntries.js";
10
+ import { ConstValue } from "../components/ConstValue.js";
10
11
  import { EnumValues } from "../components/EnumValues.js";
11
12
  import { SelectOnClick } from "../components/SelectOnClick.js";
12
13
  import { ParamInfos } from "../ParamInfos.js";
@@ -109,11 +110,13 @@ export const SchemaPropertyItem = ({
109
110
  {schema.type === "array" && "items" in schema && schema.items.enum && (
110
111
  <EnumValues values={schema.items.enum} />
111
112
  )}
113
+ {schema.const && <ConstValue schema={schema} hideDescription />}
112
114
  {schema.enum && <EnumValues values={schema.enum} />}
113
115
  <SchemaExampleAndDefault schema={schema} />
114
116
  {(hasLogicalGroupings(schema) ||
115
117
  isComplexType(schema) ||
116
- isArrayType(schema)) && (
118
+ isArrayType(schema) ||
119
+ schema.additionalProperties) && (
117
120
  <Collapsible.Root
118
121
  defaultOpen={defaultOpen}
119
122
  open={isOpen}
@@ -1,8 +1,10 @@
1
+ import { InfoIcon } from "lucide-react";
1
2
  import { Markdown, ProseClasses } from "../../../components/Markdown.js";
2
3
  import type { SchemaObject } from "../../../oas/parser/index.js";
3
- import { Card, CardContent, CardHeader, CardTitle } from "../../../ui/Card.js";
4
+ import { Card } from "../../../ui/Card.js";
4
5
  import { cn } from "../../../util/cn.js";
5
6
  import { groupBy } from "../../../util/groupBy.js";
7
+ import { ConstValue } from "../components/ConstValue.js";
6
8
  import { EnumValues } from "../components/EnumValues.js";
7
9
  import { ParamInfos } from "../ParamInfos.js";
8
10
  import { SchemaExampleAndDefault } from "./SchemaExampleAndDefault.js";
@@ -48,6 +50,10 @@ export const SchemaView = ({
48
50
  );
49
51
  }
50
52
 
53
+ if (schema.const) {
54
+ return <ConstValue schema={schema} />;
55
+ }
56
+
51
57
  if (hasLogicalGroupings(schema)) {
52
58
  return <SchemaLogicalGroup schema={schema} />;
53
59
  }
@@ -57,7 +63,7 @@ export const SchemaView = ({
57
63
  }
58
64
 
59
65
  if (schema.type === "array" && typeof schema.items === "object") {
60
- return <SchemaView schema={schema.items as SchemaObject} />;
66
+ return <SchemaView schema={schema.items} />;
61
67
  }
62
68
 
63
69
  if (schema.type === "object") {
@@ -73,6 +79,28 @@ export const SchemaView = ({
73
79
  );
74
80
  const groupNames = ["required", "optional", "deprecated"] as const;
75
81
 
82
+ const additionalProperties =
83
+ typeof schema.additionalProperties === "object" ? (
84
+ <SchemaView schema={schema.additionalProperties} />
85
+ ) : schema.additionalProperties === true ? (
86
+ <div
87
+ className={cn(
88
+ ProseClasses,
89
+ "text-sm p-4 bg-border/20 hover:bg-border/30 flex items-center gap-1",
90
+ )}
91
+ >
92
+ <span>Additional properties are allowed</span>
93
+ <a
94
+ className="p-0.5 -m-0.5"
95
+ href="https://swagger.io/docs/specification/v3_0/data-models/dictionaries/"
96
+ rel="noopener noreferrer"
97
+ target="_blank"
98
+ >
99
+ <InfoIcon size={14} />
100
+ </a>
101
+ </div>
102
+ ) : null;
103
+
76
104
  return (
77
105
  <Card className="divide-y overflow-hidden">
78
106
  {groupNames.map(
@@ -91,19 +119,7 @@ export const SchemaView = ({
91
119
  </ul>
92
120
  ),
93
121
  )}
94
- </Card>
95
- );
96
- }
97
-
98
- if (schema.additionalProperties) {
99
- return (
100
- <Card className="my-2">
101
- <CardHeader>
102
- <CardTitle>Additional Properties:</CardTitle>
103
- </CardHeader>
104
- <CardContent>
105
- <SchemaView schema={schema.additionalProperties as SchemaObject} />
106
- </CardContent>
122
+ {additionalProperties}
107
123
  </Card>
108
124
  );
109
125
  }
@@ -24,6 +24,11 @@ export const generateSchemaExample = (
24
24
  }
25
25
  }
26
26
 
27
+ // No example needed for const values
28
+ if (schema.const !== undefined) {
29
+ return schema.const;
30
+ }
31
+
27
32
  // For object schemas with properties
28
33
  if (schema.type === "object" && schema.properties) {
29
34
  const example: Record<string, any> = {};
@@ -50,10 +55,50 @@ export const generateSchemaExample = (
50
55
  return [];
51
56
  }
52
57
 
58
+ if (schema.format !== undefined) {
59
+ // Partial implementation of JSON Schema format examples
60
+ // https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.7.3
61
+ switch (schema.format) {
62
+ case "date-time":
63
+ return "2024-08-25T15:00:00Z";
64
+ case "date":
65
+ return "2024-08-25";
66
+ case "time":
67
+ return "15:00:00";
68
+ case "email":
69
+ return "test@example.com";
70
+ case "uri":
71
+ return "https://www.example.com/path/to/resource";
72
+ case "uri-reference":
73
+ return "/path/to/resource";
74
+ case "uuid":
75
+ return "00000000-0000-0000-0000-000000000000";
76
+ }
77
+ }
78
+
53
79
  if (schema.enum) {
54
80
  return schema.enum[0];
55
81
  }
56
82
 
83
+ if (schema.oneOf) {
84
+ const randomIndex = Math.floor(Math.random() * schema.oneOf.length);
85
+ return generateSchemaExample(schema.oneOf[randomIndex] as SchemaObject);
86
+ }
87
+
88
+ if (schema.anyOf) {
89
+ // Should likely be expanded to return a partial set of values, but it would require
90
+ // detection if being used within an array or a string type.
91
+ const randomIndex = Math.floor(Math.random() * schema.anyOf.length);
92
+ return generateSchemaExample(schema.anyOf[randomIndex] as SchemaObject);
93
+ }
94
+
95
+ if (schema.allOf) {
96
+ // https://swagger.io/docs/specification/v3_0/data-models/oneof-anyof-allof-not/#allof
97
+ return schema.allOf.reduce((acc, allOfSchema) => {
98
+ return { ...acc, ...generateSchemaExample(allOfSchema as SchemaObject) };
99
+ }, {});
100
+ }
101
+
57
102
  switch (schema.type) {
58
103
  case "string":
59
104
  return name || "string";
@@ -1,356 +0,0 @@
1
- import { use as S, isValidElement as E, useState as p, useCallback as R } from "react";
2
- import { a as A } from "./context-Lrf2Y9bR.js";
3
- import { i as z, S as T, L as B, T as j, a as $, p as D, C as q } from "./circular-ByJI6Mci.js";
4
- import { j as s } from "./jsx-runtime-C5mzlN2N.js";
5
- import { I, S as u, M as k, P } from "./Markdown-mFpg_n9p.js";
6
- import { Card as c, CardHeader as G, CardTitle as M, CardContent as K } from "./ui/Card.js";
7
- import { c as d } from "./cn-qaFjX9_3.js";
8
- import { ChevronsLeftRightIcon as F, ChevronUpIcon as Q, ChevronDownIcon as v, CircleIcon as H, CircleDotIcon as J, CircleFadingPlusIcon as U, SquareMinusIcon as _, SquarePlusIcon as V, MinusIcon as W, PlusIcon as X, RefreshCcwDotIcon as Y } from "lucide-react";
9
- import { B as Z } from "./Button-BBNrKpQd.js";
10
- import * as a from "@radix-ui/react-collapsible";
11
- import { Button as ee } from "./ui/Button.js";
12
- import { o as se } from "./objectEntries-yMIkr2mI.js";
13
- function te(e) {
14
- const t = z(e) ? e : new T(e), r = t.body, i = new B(t);
15
- let n = "", o = !1;
16
- for (; i.advance().kind !== j.EOF; ) {
17
- const l = i.token, m = l.kind, C = !$(l.kind);
18
- o && (C || l.kind === j.SPREAD) && (n += " ");
19
- const L = r.slice(l.start, l.end);
20
- m === j.BLOCK_STRING ? n += D(l.value, {
21
- minimize: !0
22
- }) : n += L, o = C;
23
- }
24
- return n;
25
- }
26
- const Le = (e, ...[t]) => {
27
- const r = S(A);
28
- if (r === void 0)
29
- throw new Error("useGraphQL must be used within a GraphQLProvider");
30
- return {
31
- queryFn: () => r.fetch(e, t),
32
- queryKey: [te(e.toString()), t]
33
- };
34
- }, re = (e, t) => e.reduce(
35
- (r, i) => {
36
- const n = t(i);
37
- return r[n] || (r[n] = []), r[n].push(i), r;
38
- },
39
- {}
40
- ), ne = ({ pattern: e }) => {
41
- const [t, r] = p(!1), i = e.length > 20, n = i ? `${e.slice(0, 20)}…` : e;
42
- return /* @__PURE__ */ s.jsxs(
43
- I,
44
- {
45
- className: d("text-xs", i && "cursor-pointer"),
46
- onClick: () => r(!t),
47
- selectOnClick: !1,
48
- children: [
49
- t ? e : n,
50
- i && /* @__PURE__ */ s.jsx("button", { type: "button", className: "p-1 translate-y-[2px]", children: !t && /* @__PURE__ */ s.jsx(F, { size: 12 }) })
51
- ]
52
- }
53
- );
54
- }, ie = (e) => e ? [
55
- e.type === "array" && e.items.type ? `${e.items.type}[]` : Array.isArray(e.type) ? e.type.join(" | ") : e.type,
56
- e.enum && "enum",
57
- e.format,
58
- e.minimum && `min: ${e.minimum}`,
59
- e.maximum && `max: ${e.maximum}`,
60
- e.minLength && `minLength: ${e.minLength}`,
61
- e.maxLength && `maxLength: ${e.maxLength}`,
62
- e.minItems && `minItems: ${e.minItems}`,
63
- e.maxItems && `maxItems: ${e.maxItems}`,
64
- e.uniqueItems && "unique",
65
- e.minProperties && `minProps: ${e.minProperties}`,
66
- e.maxProperties && `maxProps: ${e.maxProperties}`,
67
- e.readOnly && "readOnly",
68
- e.writeOnly && "writeOnly",
69
- e.deprecated && "deprecated",
70
- e.pattern && /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
71
- "pattern: ",
72
- /* @__PURE__ */ s.jsx(ne, { pattern: e.pattern })
73
- ] })
74
- ] : [], g = ({
75
- schema: e,
76
- extraItems: t = [],
77
- className: r
78
- }) => {
79
- const i = [...ie(e), ...t].flatMap(
80
- (n) => typeof n == "string" || E(n) ? n : []
81
- );
82
- return /* @__PURE__ */ s.jsx("span", { className: r, children: i.map((n, o) => /* @__PURE__ */ s.jsxs("span", { className: "text-muted-foreground", children: [
83
- n,
84
- o < i.length - 1 && /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50", children: " · " })
85
- ] }, o)) });
86
- }, N = ({
87
- values: e,
88
- className: t,
89
- maxVisibleValues: r = 8
90
- }) => {
91
- const [i, n] = p(!1);
92
- if (!e.length) return null;
93
- const o = e.length > r, l = o && !i ? e.slice(0, r) : e;
94
- return /* @__PURE__ */ s.jsxs("div", { className: d("flex flex-wrap gap-1.5 text-xs", t), children: [
95
- /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground", children: "Enum values: " }),
96
- l.map((m) => /* @__PURE__ */ s.jsx("div", { children: /* @__PURE__ */ s.jsx(u, { className: "border rounded px-1 font-mono", children: m }) }, m)),
97
- o && /* @__PURE__ */ s.jsx(
98
- Z,
99
- {
100
- variant: "ghost",
101
- size: "sm",
102
- className: "h-fit px-0",
103
- onClick: () => n(!i),
104
- children: i ? /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-1", children: [
105
- /* @__PURE__ */ s.jsx(Q, { size: 12 }),
106
- /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground", children: "show less" })
107
- ] }) : /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-1", children: [
108
- /* @__PURE__ */ s.jsx(v, { size: 12 }),
109
- /* @__PURE__ */ s.jsxs("span", { className: "text-muted-foreground", children: [
110
- "show ",
111
- e.length - r,
112
- " more"
113
- ] })
114
- ] })
115
- }
116
- )
117
- ] });
118
- }, b = ({
119
- schema: e
120
- }) => {
121
- var i;
122
- const t = (i = e.examples) == null ? void 0 : i.at(0), r = e.default;
123
- return !t && !r ? null : /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col gap-1 text-xs", children: [
124
- t && /* @__PURE__ */ s.jsxs("div", { children: [
125
- /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground", children: "Example: " }),
126
- /* @__PURE__ */ s.jsx(u, { className: "border rounded px-1 font-mono", children: typeof t == "object" ? JSON.stringify(t) : t })
127
- ] }),
128
- r && /* @__PURE__ */ s.jsxs("div", { children: [
129
- /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground", children: "Default: " }),
130
- /* @__PURE__ */ s.jsx(u, { className: "border rounded px-1 font-mono", children: typeof r == "object" ? JSON.stringify(r) : r })
131
- ] })
132
- ] });
133
- }, oe = {
134
- AND: /* @__PURE__ */ s.jsx(U, { size: 16, className: "fill-card" }),
135
- OR: /* @__PURE__ */ s.jsx(J, { size: 16, className: "fill-card" }),
136
- ONE: /* @__PURE__ */ s.jsx(H, { size: 14, className: "fill-card" })
137
- }, le = {
138
- AND: "text-green-500 dark:text-green-300/60",
139
- OR: "text-blue-400 dark:text-blue-500",
140
- ONE: "text-purple-500 dark:text-purple-300/60"
141
- }, ae = ({
142
- type: e,
143
- isOpen: t,
144
- className: r,
145
- schemeName: i
146
- }) => /* @__PURE__ */ s.jsx(
147
- "div",
148
- {
149
- className: d(
150
- le[e],
151
- "relative text-sm flex py-2",
152
- "before:border-l before:absolute before:-top-2 before:-bottom-2 before:border-border before:border-dashed before:content-['']",
153
- r
154
- ),
155
- children: /* @__PURE__ */ s.jsxs("div", { className: "-translate-x-[7px] flex gap-1 items-center", children: [
156
- oe[e],
157
- /* @__PURE__ */ s.jsx(
158
- "div",
159
- {
160
- className: d(
161
- "translate-y-px mx-px opacity-0 group-hover:opacity-100 transition",
162
- !t && "-rotate-90"
163
- ),
164
- children: /* @__PURE__ */ s.jsx(v, { size: 16 })
165
- }
166
- ),
167
- /* @__PURE__ */ s.jsx("span", { className: "text-sm text-foreground", children: i })
168
- ] })
169
- }
170
- ), de = (e) => {
171
- const [t, r] = p(!0);
172
- return /* @__PURE__ */ s.jsxs(
173
- a.Root,
174
- {
175
- open: t,
176
- onOpenChange: () => r((i) => !i),
177
- className: "group",
178
- children: [
179
- /* @__PURE__ */ s.jsx(a.Trigger, { children: /* @__PURE__ */ s.jsx(
180
- ae,
181
- {
182
- type: e.type,
183
- isOpen: t,
184
- schemeName: e.schema.title
185
- }
186
- ) }),
187
- !t && /* @__PURE__ */ s.jsx("div", { className: "wavy-line bg-border translate-y-1" }),
188
- /* @__PURE__ */ s.jsx(a.Content, { children: /* @__PURE__ */ s.jsx(x, { schema: e.schema }) })
189
- ]
190
- }
191
- );
192
- }, ce = {
193
- AND: "All of",
194
- OR: "Any of",
195
- ONE: "One of"
196
- }, xe = ({
197
- schemas: e,
198
- type: t,
199
- isOpen: r,
200
- toggleOpen: i
201
- }) => /* @__PURE__ */ s.jsx(a.Root, { open: r, onOpenChange: i, asChild: !0, children: /* @__PURE__ */ s.jsxs(c, { className: "px-6", children: [
202
- /* @__PURE__ */ s.jsxs(a.Trigger, { className: "flex gap-2 items-center py-2 w-full text-sm text-muted-foreground -translate-x-1.5", children: [
203
- r ? /* @__PURE__ */ s.jsx(_, { size: 14 }) : /* @__PURE__ */ s.jsx(V, { size: 14 }),
204
- /* @__PURE__ */ s.jsx("span", { children: ce[t] })
205
- ] }),
206
- /* @__PURE__ */ s.jsx(a.Content, { className: "pb-4", children: e.map((n, o) => (
207
- // eslint-disable-next-line react/no-array-index-key
208
- /* @__PURE__ */ s.jsx(de, { type: t, schema: n }, o)
209
- )) })
210
- ] }) }), pe = (e) => typeof e == "string" && ["string", "number", "boolean", "integer", "null"].includes(e), f = (e) => e.type === "array" || // schema.type might be an array of types, so we need to check if "array" is one of them
211
- Array.isArray(e.type) && e.type.includes("array"), me = (e) => e.type === "object" && Object.keys(e.properties ?? {}).length > 0 || e.type === "array" && typeof e.items == "object" && (!e.items.type || e.items.type === "object"), h = (e) => !!(e.oneOf ?? e.allOf ?? e.anyOf), ue = {
212
- allOf: "AND",
213
- anyOf: "OR",
214
- oneOf: "ONE"
215
- }, y = (e) => e === q, w = ({ schema: e }) => {
216
- const [t, r] = p(!0), i = R(() => r((n) => !n), []);
217
- for (const [n, o] of se(ue))
218
- if (e[n])
219
- return /* @__PURE__ */ s.jsx(
220
- xe,
221
- {
222
- schemas: e[n],
223
- type: o,
224
- isOpen: t,
225
- toggleOpen: i
226
- }
227
- );
228
- }, O = () => /* @__PURE__ */ s.jsxs(
229
- I,
230
- {
231
- className: "inline-flex items-center gap-1.5 italic text-xs translate-y-0.5",
232
- selectOnClick: !1,
233
- children: [
234
- /* @__PURE__ */ s.jsx(Y, { size: 13 }),
235
- /* @__PURE__ */ s.jsx("span", { children: "circular" })
236
- ]
237
- }
238
- ), je = ({
239
- name: e,
240
- schema: t,
241
- group: r,
242
- defaultOpen: i = !1,
243
- showCollapseButton: n = !0
244
- }) => {
245
- const [o, l] = p(i);
246
- return y(t) ? /* @__PURE__ */ s.jsx("li", { className: "p-4 bg-border/20 hover:bg-border/30", children: /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col gap-2.5 justify-between text-sm", children: [
247
- /* @__PURE__ */ s.jsxs("div", { className: "space-x-2", children: [
248
- /* @__PURE__ */ s.jsx("code", { children: e }),
249
- /* @__PURE__ */ s.jsx(
250
- g,
251
- {
252
- schema: t,
253
- extraItems: [/* @__PURE__ */ s.jsx(O, {}, "circular-ref")]
254
- }
255
- )
256
- ] }),
257
- /* @__PURE__ */ s.jsx(b, { schema: t })
258
- ] }) }) : /* @__PURE__ */ s.jsx("li", { className: "p-4 bg-border/20 hover:bg-border/30", children: /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col gap-2.5 justify-between text-sm", children: [
259
- /* @__PURE__ */ s.jsxs("div", { className: "space-x-2", children: [
260
- /* @__PURE__ */ s.jsx(u, { asChild: !0, children: /* @__PURE__ */ s.jsx("code", { children: e }) }),
261
- /* @__PURE__ */ s.jsx(
262
- g,
263
- {
264
- schema: t,
265
- extraItems: [
266
- r !== "optional" && /* @__PURE__ */ s.jsx("span", { className: "text-primary", children: "required" }),
267
- f(t) && "items" in t && y(t.items) && /* @__PURE__ */ s.jsx(O, {})
268
- ]
269
- }
270
- )
271
- ] }),
272
- t.description && /* @__PURE__ */ s.jsx(
273
- k,
274
- {
275
- className: d(P, "text-sm leading-normal line-clamp-4"),
276
- content: t.description
277
- }
278
- ),
279
- t.type === "array" && "items" in t && t.items.enum && /* @__PURE__ */ s.jsx(N, { values: t.items.enum }),
280
- t.enum && /* @__PURE__ */ s.jsx(N, { values: t.enum }),
281
- /* @__PURE__ */ s.jsx(b, { schema: t }),
282
- (h(t) || me(t) || f(t)) && /* @__PURE__ */ s.jsxs(
283
- a.Root,
284
- {
285
- defaultOpen: i,
286
- open: o,
287
- onOpenChange: () => l(!o),
288
- children: [
289
- n && /* @__PURE__ */ s.jsx(a.Trigger, { asChild: !0, children: /* @__PURE__ */ s.jsxs(ee, { variant: "expand", size: "sm", children: [
290
- o ? /* @__PURE__ */ s.jsx(W, { size: 12 }) : /* @__PURE__ */ s.jsx(X, { size: 12 }),
291
- o ? "Hide properties" : "Show properties"
292
- ] }) }),
293
- /* @__PURE__ */ s.jsx(a.Content, { children: /* @__PURE__ */ s.jsx("div", { className: "mt-2", children: h(t) ? /* @__PURE__ */ s.jsx(w, { schema: t }) : t.type === "object" ? /* @__PURE__ */ s.jsx(x, { schema: t }) : f(t) && "items" in t && typeof t.items == "object" && !y(t.items) && /* @__PURE__ */ s.jsx(x, { schema: t.items }) }) })
294
- ]
295
- }
296
- )
297
- ] }) });
298
- }, fe = (e) => e && /* @__PURE__ */ s.jsx(
299
- k,
300
- {
301
- className: d(P, "text-sm leading-normal line-clamp-4"),
302
- content: e
303
- }
304
- ), ye = (e) => /* @__PURE__ */ s.jsxs(c, { className: "p-4 space-y-2", children: [
305
- /* @__PURE__ */ s.jsx("span", { className: "text-sm text-muted-foreground", children: /* @__PURE__ */ s.jsx(g, { schema: e }) }),
306
- e.enum && /* @__PURE__ */ s.jsx(N, { values: e.enum }),
307
- fe(e.description),
308
- /* @__PURE__ */ s.jsx(b, { schema: e })
309
- ] }), x = ({
310
- schema: e,
311
- defaultOpen: t = !1
312
- }) => {
313
- if (!e || Object.keys(e).length === 0)
314
- return /* @__PURE__ */ s.jsx(c, { className: "p-4", children: /* @__PURE__ */ s.jsx("span", { className: "text-sm text-muted-foreground italic", children: "No schema specified" }) });
315
- if (h(e))
316
- return /* @__PURE__ */ s.jsx(w, { schema: e });
317
- if (pe(e.type))
318
- return ye(e);
319
- if (e.type === "array" && typeof e.items == "object")
320
- return /* @__PURE__ */ s.jsx(x, { schema: e.items });
321
- if (e.type === "object") {
322
- const r = re(
323
- Object.entries(e.properties ?? {}),
324
- ([n, o]) => {
325
- var l;
326
- return o.deprecated ? "deprecated" : (l = e.required) != null && l.includes(n) ? "required" : "optional";
327
- }
328
- ), i = ["required", "optional", "deprecated"];
329
- return /* @__PURE__ */ s.jsx(c, { className: "divide-y overflow-hidden", children: i.map(
330
- (n) => r[n] && /* @__PURE__ */ s.jsx("ul", { className: "divide-y", children: r[n].map(([o, l]) => /* @__PURE__ */ s.jsx(
331
- je,
332
- {
333
- name: o,
334
- schema: l,
335
- group: n,
336
- defaultOpen: t
337
- },
338
- o
339
- )) }, n)
340
- ) });
341
- }
342
- return e.additionalProperties ? /* @__PURE__ */ s.jsxs(c, { className: "my-2", children: [
343
- /* @__PURE__ */ s.jsx(G, { children: /* @__PURE__ */ s.jsx(M, { children: "Additional Properties:" }) }),
344
- /* @__PURE__ */ s.jsx(K, { children: /* @__PURE__ */ s.jsx(x, { schema: e.additionalProperties }) })
345
- ] }) : null;
346
- };
347
- export {
348
- N as E,
349
- g as P,
350
- x as S,
351
- b as a,
352
- re as g,
353
- f as i,
354
- Le as u
355
- };
356
- //# sourceMappingURL=SchemaView-DXjql-Bl.js.map