zudoku 0.1.1-dev.44 → 0.1.1-dev.46

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 (32) hide show
  1. package/dist/lib/components/Select.d.ts +13 -0
  2. package/dist/lib/components/Select.js +27 -0
  3. package/dist/lib/components/Select.js.map +1 -0
  4. package/dist/lib/plugins/api-key/CreateApiKey.js +37 -0
  5. package/dist/lib/plugins/api-key/CreateApiKey.js.map +1 -0
  6. package/dist/lib/plugins/api-key/SettingsApiKeys.js +1 -1
  7. package/dist/lib/plugins/api-key/SettingsApiKeys.js.map +1 -1
  8. package/dist/lib/plugins/api-key/index.d.ts +1 -1
  9. package/dist/lib/plugins/api-key/index.js +1 -1
  10. package/dist/lib/plugins/api-key/index.js.map +1 -1
  11. package/dist/lib/plugins/openapi/OperationListItem.js +2 -22
  12. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  13. package/dist/lib/plugins/openapi/ParameterListItem.js +1 -1
  14. package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
  15. package/dist/lib/plugins/openapi/SchemaListView.d.ts +7 -0
  16. package/dist/lib/plugins/openapi/SchemaListView.js +43 -0
  17. package/dist/lib/plugins/openapi/SchemaListView.js.map +1 -0
  18. package/lib/{Spinner-Zry2k_pD.js → Spinner-DEkC7JSn.js} +2090 -1986
  19. package/lib/zudoku.components.js +507 -608
  20. package/lib/zudoku.plugins.js +15051 -12558
  21. package/package.json +3 -2
  22. package/src/app/main.css +1 -0
  23. package/src/lib/components/Select.tsx +157 -0
  24. package/src/lib/plugins/api-key/{CreateApiKeys.tsx → CreateApiKey.tsx} +43 -27
  25. package/src/lib/plugins/api-key/SettingsApiKeys.tsx +10 -9
  26. package/src/lib/plugins/api-key/index.tsx +2 -2
  27. package/src/lib/plugins/openapi/OperationListItem.tsx +7 -121
  28. package/src/lib/plugins/openapi/ParameterListItem.tsx +1 -1
  29. package/src/lib/plugins/openapi/SchemaListView.tsx +229 -0
  30. package/dist/lib/plugins/api-key/CreateApiKeys.js +0 -37
  31. package/dist/lib/plugins/api-key/CreateApiKeys.js.map +0 -1
  32. /package/dist/lib/plugins/api-key/{CreateApiKeys.d.ts → CreateApiKey.d.ts} +0 -0
@@ -0,0 +1,229 @@
1
+ import { SchemaObject } from "../../oas/parser/index.js";
2
+ import { useState } from "react";
3
+ import { cn } from "../../util/cn.js";
4
+ import { Markdown } from "../../components/Markdown.js";
5
+ import * as Collapsible from "@radix-ui/react-collapsible";
6
+ import { Button } from "../../ui/Button.js";
7
+ import { ListPlusIcon } from "lucide-react";
8
+
9
+ export const SchemaListView = ({
10
+ name,
11
+ schema,
12
+ level = 0,
13
+ defaultOpen = false,
14
+ }: {
15
+ level?: number;
16
+ defaultOpen?: boolean;
17
+ name?: string;
18
+ schema: SchemaObject;
19
+ }) => {
20
+ const properties = Object.entries(schema.properties ?? {});
21
+ const additionalProperties =
22
+ typeof schema.additionalProperties === "object"
23
+ ? Object.entries(schema.additionalProperties)
24
+ : [];
25
+
26
+ const combinedProperties = properties.concat(
27
+ Array.isArray(additionalProperties) ? additionalProperties : [],
28
+ );
29
+
30
+ const groups = Object.groupBy(
31
+ combinedProperties,
32
+ ([propertyName, property]) => {
33
+ return property.deprecated
34
+ ? "deprecated"
35
+ : schema.required?.includes(propertyName)
36
+ ? "required"
37
+ : "optional";
38
+ },
39
+ );
40
+
41
+ return (
42
+ <div
43
+ className={cn(
44
+ "not-prose",
45
+ level > 0 && "border border-border rounded text-sm",
46
+ )}
47
+ >
48
+ {(schema.title ?? name) && (
49
+ <div className="ml-2 my-1 font-bold">{schema.title ?? name}</div>
50
+ )}
51
+ {level === 0 && schema.description && (
52
+ <p className="prose">{schema.description}</p>
53
+ )}
54
+ <ul>
55
+ {Object.entries(groups).map(([group, properties]) => {
56
+ return (
57
+ <SchemaListViewItemGroup
58
+ defaultOpen={defaultOpen}
59
+ group={group as any}
60
+ nestingLevel={level}
61
+ properties={properties}
62
+ required={schema.required ?? []}
63
+ />
64
+ );
65
+ })}
66
+ </ul>
67
+ </div>
68
+ );
69
+ };
70
+
71
+ const SchemaListViewItemGroup = ({
72
+ group,
73
+ properties,
74
+ nestingLevel,
75
+ required,
76
+ defaultOpen = false,
77
+ }: {
78
+ group: "optional" | "required" | "deprecated";
79
+ defaultOpen?: boolean;
80
+ properties: [string, SchemaObject][];
81
+ nestingLevel: number;
82
+ required: string[];
83
+ }) => {
84
+ const notCollapsible =
85
+ defaultOpen ||
86
+ group === "required" ||
87
+ properties.length === 1 ||
88
+ nestingLevel === 0;
89
+ const [open, setOpen] = useState(notCollapsible);
90
+ if (properties.length === 0) {
91
+ return;
92
+ }
93
+
94
+ return (
95
+ <Collapsible.Root
96
+ className="CollapsibleRoot"
97
+ open={open}
98
+ onOpenChange={setOpen}
99
+ >
100
+ {!open && (
101
+ <Collapsible.Trigger
102
+ className={cn(
103
+ "py-2 hover:bg-muted w-full",
104
+ group === "optional" && "font-semibold",
105
+ group === "deprecated" && "text-muted-foreground",
106
+ )}
107
+ >
108
+ {properties.length} {group} fields
109
+ </Collapsible.Trigger>
110
+ )}
111
+
112
+ <Collapsible.Content>
113
+ {properties.map(([propertyName, property]) => (
114
+ <SchemaListViewItem
115
+ property={property}
116
+ propertyName={propertyName}
117
+ nestingLevel={nestingLevel}
118
+ isRequired={required?.includes(propertyName) ?? false}
119
+ />
120
+ ))}
121
+ </Collapsible.Content>
122
+ </Collapsible.Root>
123
+ );
124
+ };
125
+
126
+ const SchemaListViewItem = ({
127
+ propertyName,
128
+ property,
129
+ nestingLevel,
130
+ isRequired,
131
+ }: {
132
+ propertyName: string;
133
+ isRequired: boolean;
134
+ property: SchemaObject;
135
+ nestingLevel: number;
136
+ }) => {
137
+ return (
138
+ <div
139
+ key={propertyName}
140
+ className={cn(
141
+ nestingLevel > 0 ? "py-2" : "py-4",
142
+ "px-2 border-t border-border bg-border/20 hover:bg-border/30 flex gap-1 flex-col text-sm",
143
+ property.deprecated && "opacity-50",
144
+ )}
145
+ >
146
+ <div className="flex items-center gap-2 relative">
147
+ <code>
148
+ {propertyName} {property.title}
149
+ </code>
150
+
151
+ {property.type && (
152
+ <span className="text-muted-foreground">{property.type}</span>
153
+ )}
154
+ {property.deprecated && (
155
+ <span className="text-muted-foreground">Deprecated</span>
156
+ )}
157
+ {!isRequired && (
158
+ <span className="py-px px-1.5 font-medium text-xs border border-border rounded-lg">
159
+ optional {property.required}
160
+ </span>
161
+ )}
162
+ {/*{property.type === "object" && (*/}
163
+ {/* <div className="absolute right-3">+</div>*/}
164
+ {/*)}*/}
165
+ </div>
166
+ {property.description && (
167
+ <Markdown
168
+ content={property.description}
169
+ className="text-sm leading-normal line-clamp-4 "
170
+ />
171
+ )}
172
+
173
+ {property.enum && (
174
+ <span className="text-sm text-muted-foreground flex gap-1 flex-wrap items-center">
175
+ <span>Possible values</span>
176
+ {property.enum
177
+ .filter((value) => value)
178
+ .map((value) => (
179
+ <span
180
+ key={value}
181
+ className="font-mono text-xs border-border border bg-muted rounded px-1"
182
+ >
183
+ {value}
184
+ </span>
185
+ ))
186
+ .slice(0, 4)}
187
+ {property.enum.length > 4 && (
188
+ <span className="font-mono text-xs border-border border bg-muted rounded px-1">
189
+ ...
190
+ </span>
191
+ )}
192
+ </span>
193
+ )}
194
+
195
+ <Collapsible.Root className="CollapsibleRoot" defaultOpen={false}>
196
+ {property.type === "object" ||
197
+ (property.type === "array" && property.items.type === "object") ? (
198
+ <Collapsible.Trigger asChild>
199
+ <Button variant="ghost" size="sm">
200
+ Show nested fields
201
+ <ListPlusIcon size={18} className="ml-1.5" />
202
+ </Button>
203
+ </Collapsible.Trigger>
204
+ ) : null}
205
+
206
+ <Collapsible.Content>
207
+ {property.type === "object" && (
208
+ <div className="mt-2.5">
209
+ <SchemaListView
210
+ schema={property}
211
+ level={nestingLevel + 1}
212
+ defaultOpen
213
+ />
214
+ </div>
215
+ )}
216
+ {property.type === "array" && property.items.type === "object" && (
217
+ <div className="mt-2.5">
218
+ <SchemaListView
219
+ schema={property.items}
220
+ defaultOpen
221
+ level={nestingLevel + 1}
222
+ />
223
+ </div>
224
+ )}
225
+ </Collapsible.Content>
226
+ </Collapsible.Root>
227
+ </div>
228
+ );
229
+ };
@@ -1,37 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useDevPortal } from "../../components/context/DevPortalProvider.js";
3
- import { useMutation } from "@tanstack/react-query";
4
- import { Button } from "../../ui/Button.js";
5
- import { Input } from "../../components/Input.js";
6
- import { cn } from "../../util/cn.js";
7
- import { Link, useNavigate } from "react-router-dom";
8
- import { useForm } from "react-hook-form";
9
- export const CreateApiKey = ({ options, service, }) => {
10
- const context = useDevPortal();
11
- const navigate = useNavigate();
12
- const form = useForm();
13
- const createKeyMutation = useMutation({
14
- mutationFn: ({ description, expiresAt }) => {
15
- if (!service.createKey) {
16
- throw new Error("deleteKey not implemented");
17
- }
18
- return service.createKey({ description }, context);
19
- },
20
- onSuccess: () => navigate("/settings/api-keys/"),
21
- });
22
- if (!service.createKey) {
23
- return null;
24
- }
25
- return (_jsxs("div", { className: "max-w-screen-lg pt-[--padding-content-top] pb-[--padding-content-bottom]", children: [_jsx("div", { className: "flex justify-between mb-4 border-b pb-1", children: _jsx("h1", { className: "font-medium text-2xl", children: "New API Keys" }) }), _jsx("form", { onSubmit: form.handleSubmit((data) => {
26
- if (data.expiresAt === "never") {
27
- delete data.expiresAt;
28
- }
29
- createKeyMutation.mutate(data);
30
- }), children: _jsxs("div", { className: "flex gap-2 flex-col", children: ["Note", _jsx(Input, { ...form.register("description") }), "Expiration", _jsxs("select", { className: cn("row-start-1 col-start-1 border border-input text-foreground px-2 py-1 pe-6", "rounded-md appearance-none bg-zinc-50 hover:bg-white dark:bg-zinc-800 hover:dark:bg-zinc-800/75"), ...form.register("expiresAt"), children: [_jsx("option", { value: "never", children: "Never" }), [7, 30, 60, 90].map((option) => (_jsxs("option", { value: addDaysToDate(option), children: [option, " Days"] }, option)))] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { children: "Generate Key" }), _jsx(Button, { variant: "outline", asChild: true, children: _jsx(Link, { to: "/settings/api-keys/", children: "Cancel" }) })] })] }) })] }));
31
- };
32
- const addDaysToDate = (days) => {
33
- const date = new Date();
34
- date.setDate(date.getDate() + days);
35
- return date.toISOString().split("T")[0];
36
- };
37
- //# sourceMappingURL=CreateApiKeys.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateApiKeys.js","sourceRoot":"","sources":["../../../../src/lib/plugins/api-key/CreateApiKeys.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI1C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,OAAO,EACP,OAAO,GAIR,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,OAAO,EAAiB,CAAC;IACtC,MAAM,iBAAiB,GAAG,WAAW,CAAC;QACpC,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,EAAiB,EAAE,EAAE;YACxD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAC/C,CAAC;YAED,OAAO,OAAO,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,EAAE,OAAO,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