zudoku 0.42.1 → 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.
- package/dist/app/entry.client.js +21 -0
- package/dist/app/entry.client.js.map +1 -1
- package/dist/config/loader.d.ts +1 -16
- package/dist/config/loader.js +9 -90
- package/dist/config/loader.js.map +1 -1
- package/dist/lib/authentication/components/SignIn.d.ts +1 -1
- package/dist/lib/authentication/components/SignIn.js +5 -2
- package/dist/lib/authentication/components/SignIn.js.map +1 -1
- package/dist/lib/authentication/components/SignUp.d.ts +1 -1
- package/dist/lib/authentication/components/SignUp.js +4 -1
- package/dist/lib/authentication/components/SignUp.js.map +1 -1
- package/dist/lib/plugins/openapi/ParamInfos.js +1 -0
- package/dist/lib/plugins/openapi/ParamInfos.js.map +1 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js +8 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/components/ConstValue.d.ts +5 -0
- package/dist/lib/plugins/openapi/components/ConstValue.js +6 -0
- package/dist/lib/plugins/openapi/components/ConstValue.js.map +1 -0
- package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js +7 -3
- package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js +9 -6
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/utils.d.ts +1 -0
- package/dist/lib/plugins/openapi/schema/utils.js +3 -0
- package/dist/lib/plugins/openapi/schema/utils.js.map +1 -1
- package/dist/lib/plugins/openapi/util/generateSchemaExample.js +40 -0
- package/dist/lib/plugins/openapi/util/generateSchemaExample.js.map +1 -1
- package/dist/vite/config.js +1 -1
- package/dist/vite/config.js.map +1 -1
- package/lib/AuthenticationPlugin-ByDF051g.js +99 -0
- package/lib/AuthenticationPlugin-ByDF051g.js.map +1 -0
- package/lib/Card-BtheiD7j.js +61 -0
- package/lib/Card-BtheiD7j.js.map +1 -0
- package/lib/{OasProvider-CZiF_RMW.js → OasProvider-DOs0v9u7.js} +2 -2
- package/lib/{OasProvider-CZiF_RMW.js.map → OasProvider-DOs0v9u7.js.map} +1 -1
- package/lib/{OperationList-CMMzLfIZ.js → OperationList-CKac6iap.js} +1152 -1102
- package/lib/OperationList-CKac6iap.js.map +1 -0
- package/lib/{SchemaList-_d3Mf4IX.js → SchemaList-BTX2mRMW.js} +3 -3
- package/lib/{SchemaList-_d3Mf4IX.js.map → SchemaList-BTX2mRMW.js.map} +1 -1
- package/lib/SchemaView-BYRn_-2l.js +388 -0
- package/lib/SchemaView-BYRn_-2l.js.map +1 -0
- package/lib/{index-BPqJMdth.js → index-DuB48L78.js} +393 -442
- package/lib/index-DuB48L78.js.map +1 -0
- package/lib/zudoku.auth-clerk.js +1 -1
- package/lib/zudoku.auth-openid.js +1 -1
- package/lib/zudoku.plugin-openapi.js +1 -1
- package/package.json +4 -4
- package/src/app/entry.client.tsx +26 -0
- package/src/lib/authentication/components/SignIn.tsx +35 -2
- package/src/lib/authentication/components/SignUp.tsx +35 -1
- package/src/lib/plugins/openapi/ParamInfos.tsx +1 -0
- package/src/lib/plugins/openapi/ParameterListItem.tsx +30 -0
- package/src/lib/plugins/openapi/components/ConstValue.tsx +24 -0
- package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +10 -4
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +31 -20
- package/src/lib/plugins/openapi/schema/utils.ts +5 -0
- package/src/lib/plugins/openapi/util/generateSchemaExample.ts +45 -0
- package/lib/AuthenticationPlugin-DPCuR3xm.js +0 -58
- package/lib/AuthenticationPlugin-DPCuR3xm.js.map +0 -1
- package/lib/OperationList-CMMzLfIZ.js.map +0 -1
- package/lib/SchemaView-J7Srn-Iy.js +0 -357
- package/lib/SchemaView-J7Srn-Iy.js.map +0 -1
- package/lib/index-BPqJMdth.js.map +0 -1
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
-
import { useSearchParams } from "react-router";
|
|
2
|
+
import { Link, useSearchParams } from "react-router";
|
|
3
|
+
import { Button } from "zudoku/ui/Button.js";
|
|
4
|
+
import {
|
|
5
|
+
Card,
|
|
6
|
+
CardContent,
|
|
7
|
+
CardDescription,
|
|
8
|
+
CardHeader,
|
|
9
|
+
CardTitle,
|
|
10
|
+
} from "zudoku/ui/Card.js";
|
|
3
11
|
import { useZudoku } from "../../components/context/ZudokuContext.js";
|
|
4
12
|
|
|
5
13
|
export const SignIn = () => {
|
|
@@ -11,5 +19,30 @@ export const SignIn = () => {
|
|
|
11
19
|
});
|
|
12
20
|
}, [context.authentication, search]);
|
|
13
21
|
|
|
14
|
-
return
|
|
22
|
+
return (
|
|
23
|
+
<div className="flex items-center justify-center mt-8">
|
|
24
|
+
<Card className="max-w-md w-full">
|
|
25
|
+
<CardHeader>
|
|
26
|
+
<CardTitle className="text-lg">Sign in</CardTitle>
|
|
27
|
+
<CardDescription>
|
|
28
|
+
You're being redirected to our secure login provider to complete
|
|
29
|
+
your sign-in process.
|
|
30
|
+
</CardDescription>
|
|
31
|
+
</CardHeader>
|
|
32
|
+
<CardContent>
|
|
33
|
+
<div className="flex flex-col gap-2 justify-center">
|
|
34
|
+
<Button
|
|
35
|
+
onClick={() => context.authentication?.signIn()}
|
|
36
|
+
variant="default"
|
|
37
|
+
>
|
|
38
|
+
Login
|
|
39
|
+
</Button>
|
|
40
|
+
<Button variant="link" className="text-muted-foreground" asChild>
|
|
41
|
+
<Link to="/">Go home</Link>
|
|
42
|
+
</Button>
|
|
43
|
+
</div>
|
|
44
|
+
</CardContent>
|
|
45
|
+
</Card>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
15
48
|
};
|
|
@@ -1,11 +1,45 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
+
import { Button, Link } from "zudoku/components";
|
|
3
|
+
import {
|
|
4
|
+
Card,
|
|
5
|
+
CardContent,
|
|
6
|
+
CardDescription,
|
|
7
|
+
CardHeader,
|
|
8
|
+
CardTitle,
|
|
9
|
+
} from "zudoku/ui/Card.js";
|
|
2
10
|
import { useZudoku } from "../../components/context/ZudokuContext.js";
|
|
3
11
|
|
|
4
12
|
export const SignUp = () => {
|
|
5
13
|
const context = useZudoku();
|
|
14
|
+
|
|
6
15
|
useEffect(() => {
|
|
7
16
|
void (context.authentication?.signUp() ?? context.authentication?.signIn());
|
|
8
17
|
}, [context.authentication]);
|
|
9
18
|
|
|
10
|
-
return
|
|
19
|
+
return (
|
|
20
|
+
<div className="flex items-center justify-center mt-8">
|
|
21
|
+
<Card className="max-w-md w-full">
|
|
22
|
+
<CardHeader>
|
|
23
|
+
<CardTitle className="text-lg">Sign up</CardTitle>
|
|
24
|
+
<CardDescription>
|
|
25
|
+
You're being redirected to our secure login provider to complete
|
|
26
|
+
your sign up process.
|
|
27
|
+
</CardDescription>
|
|
28
|
+
</CardHeader>
|
|
29
|
+
<CardContent>
|
|
30
|
+
<div className="flex flex-col gap-2 justify-center">
|
|
31
|
+
<Button
|
|
32
|
+
onClick={() => context.authentication?.signIn()}
|
|
33
|
+
variant="default"
|
|
34
|
+
>
|
|
35
|
+
Register
|
|
36
|
+
</Button>
|
|
37
|
+
<Button variant="link" className="text-muted-foreground" asChild>
|
|
38
|
+
<Link to="/">Go home</Link>
|
|
39
|
+
</Button>
|
|
40
|
+
</div>
|
|
41
|
+
</CardContent>
|
|
42
|
+
</Card>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
11
45
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
2
|
+
import { MinusIcon, PlusIcon } from "lucide-react";
|
|
3
|
+
import { useState } from "react";
|
|
1
4
|
import { Markdown } from "../../components/Markdown.js";
|
|
2
5
|
import { type SchemaObject } from "../../oas/graphql/index.js";
|
|
6
|
+
import { Button } from "../../ui/Button.js";
|
|
3
7
|
import { ColorizedParam } from "./ColorizedParam.js";
|
|
4
8
|
import type { OperationListItemResult } from "./OperationList.js";
|
|
5
9
|
import type { ParameterGroup } from "./OperationListItem.js";
|
|
@@ -7,6 +11,8 @@ import { ParamInfos } from "./ParamInfos.js";
|
|
|
7
11
|
import { EnumValues } from "./components/EnumValues.js";
|
|
8
12
|
import { SelectOnClick } from "./components/SelectOnClick.js";
|
|
9
13
|
import { SchemaExampleAndDefault } from "./schema/SchemaExampleAndDefault.js";
|
|
14
|
+
import { SchemaView } from "./schema/SchemaView.js";
|
|
15
|
+
import { isArrayType } from "./schema/utils.js";
|
|
10
16
|
|
|
11
17
|
const getParameterSchema = (
|
|
12
18
|
parameter: ParameterListItemResult,
|
|
@@ -33,6 +39,7 @@ export const ParameterListItem = ({
|
|
|
33
39
|
id: string;
|
|
34
40
|
}) => {
|
|
35
41
|
const paramSchema = getParameterSchema(parameter);
|
|
42
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
36
43
|
|
|
37
44
|
return (
|
|
38
45
|
<li className="p-4 bg-border/20 text-sm flex flex-col gap-1.5">
|
|
@@ -74,6 +81,29 @@ export const ParameterListItem = ({
|
|
|
74
81
|
paramSchema.enum && <EnumValues values={paramSchema.enum} />
|
|
75
82
|
)}
|
|
76
83
|
<SchemaExampleAndDefault schema={paramSchema} />
|
|
84
|
+
{(paramSchema.type === "object" || isArrayType(paramSchema)) && (
|
|
85
|
+
<Collapsible.Root
|
|
86
|
+
defaultOpen={false}
|
|
87
|
+
onOpenChange={setIsOpen}
|
|
88
|
+
open={isOpen}
|
|
89
|
+
>
|
|
90
|
+
<Collapsible.Trigger asChild>
|
|
91
|
+
<Button variant="expand" size="sm">
|
|
92
|
+
{isOpen ? <MinusIcon size={12} /> : <PlusIcon size={12} />}
|
|
93
|
+
{isOpen ? "Hide properties" : "Show properties"}
|
|
94
|
+
</Button>
|
|
95
|
+
</Collapsible.Trigger>
|
|
96
|
+
<Collapsible.Content>
|
|
97
|
+
<div className="mt-2">
|
|
98
|
+
<SchemaView
|
|
99
|
+
schema={
|
|
100
|
+
"items" in paramSchema ? paramSchema.items : paramSchema
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
</Collapsible.Content>
|
|
105
|
+
</Collapsible.Root>
|
|
106
|
+
)}
|
|
77
107
|
</li>
|
|
78
108
|
);
|
|
79
109
|
};
|
|
@@ -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";
|
|
@@ -15,6 +16,7 @@ import { SchemaExampleAndDefault } from "./SchemaExampleAndDefault.js";
|
|
|
15
16
|
import { SchemaView } from "./SchemaView.js";
|
|
16
17
|
import {
|
|
17
18
|
hasLogicalGroupings,
|
|
19
|
+
isArrayType,
|
|
18
20
|
isCircularRef,
|
|
19
21
|
isComplexType,
|
|
20
22
|
LogicalSchemaTypeMap,
|
|
@@ -93,7 +95,7 @@ export const SchemaPropertyItem = ({
|
|
|
93
95
|
group !== "optional" && (
|
|
94
96
|
<span className="text-primary">required</span>
|
|
95
97
|
),
|
|
96
|
-
schema
|
|
98
|
+
isArrayType(schema) &&
|
|
97
99
|
"items" in schema &&
|
|
98
100
|
isCircularRef(schema.items) && <RecursiveIndicator />,
|
|
99
101
|
]}
|
|
@@ -108,9 +110,13 @@ export const SchemaPropertyItem = ({
|
|
|
108
110
|
{schema.type === "array" && "items" in schema && schema.items.enum && (
|
|
109
111
|
<EnumValues values={schema.items.enum} />
|
|
110
112
|
)}
|
|
113
|
+
{schema.const && <ConstValue schema={schema} hideDescription />}
|
|
111
114
|
{schema.enum && <EnumValues values={schema.enum} />}
|
|
112
115
|
<SchemaExampleAndDefault schema={schema} />
|
|
113
|
-
{(hasLogicalGroupings(schema) ||
|
|
116
|
+
{(hasLogicalGroupings(schema) ||
|
|
117
|
+
isComplexType(schema) ||
|
|
118
|
+
isArrayType(schema) ||
|
|
119
|
+
schema.additionalProperties) && (
|
|
114
120
|
<Collapsible.Root
|
|
115
121
|
defaultOpen={defaultOpen}
|
|
116
122
|
open={isOpen}
|
|
@@ -118,7 +124,7 @@ export const SchemaPropertyItem = ({
|
|
|
118
124
|
>
|
|
119
125
|
{showCollapseButton && (
|
|
120
126
|
<Collapsible.Trigger asChild>
|
|
121
|
-
<Button variant="expand" size="sm"
|
|
127
|
+
<Button variant="expand" size="sm">
|
|
122
128
|
{isOpen ? <MinusIcon size={12} /> : <PlusIcon size={12} />}
|
|
123
129
|
{!isOpen ? "Show properties" : "Hide properties"}
|
|
124
130
|
</Button>
|
|
@@ -131,7 +137,7 @@ export const SchemaPropertyItem = ({
|
|
|
131
137
|
) : schema.type === "object" ? (
|
|
132
138
|
<SchemaView schema={schema} />
|
|
133
139
|
) : (
|
|
134
|
-
schema
|
|
140
|
+
isArrayType(schema) &&
|
|
135
141
|
"items" in schema &&
|
|
136
142
|
typeof schema.items === "object" &&
|
|
137
143
|
!isCircularRef(schema.items) && (
|
|
@@ -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
|
|
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,12 +63,7 @@ export const SchemaView = ({
|
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
if (schema.type === "array" && typeof schema.items === "object") {
|
|
60
|
-
return
|
|
61
|
-
<Card className="p-4 space-y-2 text-sm">
|
|
62
|
-
<ParamInfos schema={schema} />
|
|
63
|
-
<SchemaView schema={schema.items as SchemaObject} />
|
|
64
|
-
</Card>
|
|
65
|
-
);
|
|
66
|
+
return <SchemaView schema={schema.items} />;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
if (schema.type === "object") {
|
|
@@ -78,6 +79,28 @@ export const SchemaView = ({
|
|
|
78
79
|
);
|
|
79
80
|
const groupNames = ["required", "optional", "deprecated"] as const;
|
|
80
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
|
+
|
|
81
104
|
return (
|
|
82
105
|
<Card className="divide-y overflow-hidden">
|
|
83
106
|
{groupNames.map(
|
|
@@ -96,19 +119,7 @@ export const SchemaView = ({
|
|
|
96
119
|
</ul>
|
|
97
120
|
),
|
|
98
121
|
)}
|
|
99
|
-
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (schema.additionalProperties) {
|
|
104
|
-
return (
|
|
105
|
-
<Card className="my-2">
|
|
106
|
-
<CardHeader>
|
|
107
|
-
<CardTitle>Additional Properties:</CardTitle>
|
|
108
|
-
</CardHeader>
|
|
109
|
-
<CardContent>
|
|
110
|
-
<SchemaView schema={schema.additionalProperties as SchemaObject} />
|
|
111
|
-
</CardContent>
|
|
122
|
+
{additionalProperties}
|
|
112
123
|
</Card>
|
|
113
124
|
);
|
|
114
125
|
}
|
|
@@ -7,6 +7,11 @@ export const isBasicType = (
|
|
|
7
7
|
typeof type === "string" &&
|
|
8
8
|
["string", "number", "boolean", "integer", "null"].includes(type);
|
|
9
9
|
|
|
10
|
+
export const isArrayType = (value: SchemaObject) =>
|
|
11
|
+
value.type === "array" ||
|
|
12
|
+
// schema.type might be an array of types, so we need to check if "array" is one of them
|
|
13
|
+
(Array.isArray(value.type) && value.type.includes("array"));
|
|
14
|
+
|
|
10
15
|
export const isComplexType = (value: SchemaObject) =>
|
|
11
16
|
(value.type === "object" && Object.keys(value.properties ?? {}).length > 0) ||
|
|
12
17
|
(value.type === "array" &&
|
|
@@ -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,58 +0,0 @@
|
|
|
1
|
-
import { j as o } from "./jsx-runtime-C5mzlN2N.js";
|
|
2
|
-
import { LogOutIcon as a } from "lucide-react";
|
|
3
|
-
import { useEffect as i } from "react";
|
|
4
|
-
import { b as u, a as r } from "./chunk-BAXFHI7N-BVBOl9s0.js";
|
|
5
|
-
import { e as s } from "./hook-CldJlP5c.js";
|
|
6
|
-
const c = () => {
|
|
7
|
-
const t = s(), [e] = u();
|
|
8
|
-
return i(() => {
|
|
9
|
-
var n;
|
|
10
|
-
(n = t.authentication) == null || n.signIn({
|
|
11
|
-
redirectTo: e.get("redirect") ?? void 0
|
|
12
|
-
});
|
|
13
|
-
}, [t.authentication, e]), null;
|
|
14
|
-
}, g = () => {
|
|
15
|
-
const t = s(), e = r();
|
|
16
|
-
return i(() => {
|
|
17
|
-
var n;
|
|
18
|
-
(n = t.authentication) == null || n.signOut().then(() => e("/"));
|
|
19
|
-
}, []), null;
|
|
20
|
-
}, m = () => {
|
|
21
|
-
const t = s();
|
|
22
|
-
return i(() => {
|
|
23
|
-
var e, n;
|
|
24
|
-
((e = t.authentication) == null ? void 0 : e.signUp()) ?? ((n = t.authentication) == null || n.signIn());
|
|
25
|
-
}, [t.authentication]), null;
|
|
26
|
-
};
|
|
27
|
-
class d {
|
|
28
|
-
getRoutes() {
|
|
29
|
-
return [
|
|
30
|
-
{
|
|
31
|
-
path: "/signout",
|
|
32
|
-
element: /* @__PURE__ */ o.jsx(g, {})
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
path: "/signin",
|
|
36
|
-
element: /* @__PURE__ */ o.jsx(c, {})
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
path: "/signup",
|
|
40
|
-
element: /* @__PURE__ */ o.jsx(m, {})
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
getProfileMenuItems() {
|
|
45
|
-
return [
|
|
46
|
-
{
|
|
47
|
-
label: "Logout",
|
|
48
|
-
path: "/signout",
|
|
49
|
-
category: "bottom",
|
|
50
|
-
icon: a
|
|
51
|
-
}
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
export {
|
|
56
|
-
d as A
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=AuthenticationPlugin-DPCuR3xm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticationPlugin-DPCuR3xm.js","sources":["../src/lib/authentication/components/SignIn.tsx","../src/lib/authentication/components/SignOut.tsx","../src/lib/authentication/components/SignUp.tsx","../src/lib/authentication/AuthenticationPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useSearchParams } from \"react-router\";\nimport { useZudoku } from \"../../components/context/ZudokuContext.js\";\n\nexport const SignIn = () => {\n const context = useZudoku();\n const [search] = useSearchParams();\n useEffect(() => {\n void context.authentication?.signIn({\n redirectTo: search.get(\"redirect\") ?? undefined,\n });\n }, [context.authentication, search]);\n\n return null;\n};\n","import { useEffect } from \"react\";\nimport { useNavigate } from \"react-router\";\nimport { useZudoku } from \"../../components/context/ZudokuContext.js\";\n\nexport const SignOut = () => {\n const context = useZudoku();\n const navigate = useNavigate();\n\n useEffect(() => {\n void context.authentication?.signOut().then(() => navigate(\"/\"));\n }, []);\n\n return null;\n};\n","import { useEffect } from \"react\";\nimport { useZudoku } from \"../../components/context/ZudokuContext.js\";\n\nexport const SignUp = () => {\n const context = useZudoku();\n useEffect(() => {\n void (context.authentication?.signUp() ?? context.authentication?.signIn());\n }, [context.authentication]);\n\n return null;\n};\n","import { LogOutIcon } from \"lucide-react\";\nimport {\n CommonPlugin,\n NavigationPlugin,\n ProfileMenuPlugin,\n} from \"../core/plugins.js\";\nimport { SignIn } from \"./components/SignIn.js\";\nimport { SignOut } from \"./components/SignOut.js\";\nimport { SignUp } from \"./components/SignUp.js\";\n\ntype PluginInterface = NavigationPlugin & CommonPlugin & ProfileMenuPlugin;\n\nexport class AuthenticationPlugin implements PluginInterface {\n getRoutes() {\n return [\n {\n path: \"/signout\",\n element: <SignOut />,\n },\n {\n path: \"/signin\",\n element: <SignIn />,\n },\n {\n path: \"/signup\",\n element: <SignUp />,\n },\n ];\n }\n\n getProfileMenuItems() {\n return [\n {\n label: \"Logout\",\n path: \"/signout\",\n category: \"bottom\",\n icon: LogOutIcon,\n } as const,\n ];\n }\n}\n"],"names":["SignIn","context","useZudoku","search","useSearchParams","useEffect","_a","SignOut","navigate","useNavigate","SignUp","_b","AuthenticationPlugin","LogOutIcon"],"mappings":";;;;;AAIO,MAAMA,IAAS,MAAM;AAC1B,QAAMC,IAAUC,EAAU,GACpB,CAACC,CAAM,IAAIC,EAAgB;AACjC,SAAAC,EAAU,MAAM;;AACT,KAAAC,IAAAL,EAAQ,mBAAR,QAAAK,EAAwB,OAAO;AAAA,MAClC,YAAYH,EAAO,IAAI,UAAU,KAAK;AAAA,IAAA;AAAA,EAEvC,GAAA,CAACF,EAAQ,gBAAgBE,CAAM,CAAC,GAE5B;AACT,GCVaI,IAAU,MAAM;AAC3B,QAAMN,IAAUC,EAAU,GACpBM,IAAWC,EAAY;AAE7B,SAAAJ,EAAU,MAAM;;AACT,KAAAC,IAAAL,EAAQ,mBAAR,QAAAK,EAAwB,UAAU,KAAK,MAAME,EAAS,GAAG;AAAA,EAChE,GAAG,EAAE,GAEE;AACT,GCVaE,IAAS,MAAM;AAC1B,QAAMT,IAAUC,EAAU;AAC1B,SAAAG,EAAU,MAAM;;AACd,MAAMC,IAAAL,EAAQ,mBAAR,gBAAAK,EAAwB,eAAYK,IAAAV,EAAQ,mBAAR,QAAAU,EAAwB;AAAA,EAAO,GACxE,CAACV,EAAQ,cAAc,CAAC,GAEpB;AACT;ACEO,MAAMW,EAAgD;AAAA,EAC3D,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,+BAAUL,GAAQ,CAAA,CAAA;AAAA,MACpB;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,+BAAUP,GAAO,CAAA,CAAA;AAAA,MACnB;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,+BAAUU,GAAO,CAAA,CAAA;AAAA,MAAA;AAAA,IAErB;AAAA,EAAA;AAAA,EAGF,sBAAsB;AACb,WAAA;AAAA,MACL;AAAA,QACE,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,QACV,MAAMG;AAAA,MAAA;AAAA,IAEV;AAAA,EAAA;AAEJ;"}
|