zudoku 0.41.2 → 0.41.4
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/main.js +3 -1
- package/dist/app/main.js.map +1 -1
- package/dist/lib/components/BuildCheck.js +18 -3
- package/dist/lib/components/BuildCheck.js.map +1 -1
- package/dist/lib/oas/parser/index.d.ts +1 -1
- package/dist/lib/oas/parser/index.js +3 -3
- package/dist/lib/oas/parser/index.js.map +1 -1
- package/dist/lib/oas/parser/upgrade/index.d.ts +9 -0
- package/dist/lib/oas/parser/upgrade/index.js +90 -0
- package/dist/lib/oas/parser/upgrade/index.js.map +1 -0
- package/lib/{MdxPage-B7MyVLV5.js → MdxPage-OSMru6r8.js} +3 -3
- package/lib/{MdxPage-B7MyVLV5.js.map → MdxPage-OSMru6r8.js.map} +1 -1
- package/lib/{OasProvider-DY8kA-9x.js → OasProvider-CHYfqkG3.js} +2 -2
- package/lib/{OasProvider-DY8kA-9x.js.map → OasProvider-CHYfqkG3.js.map} +1 -1
- package/lib/{OperationList-BNneqYos.js → OperationList-jzJUa4hl.js} +4 -4
- package/lib/{OperationList-BNneqYos.js.map → OperationList-jzJUa4hl.js.map} +1 -1
- package/lib/{Pagination-9TA5cwCh.js → Pagination-BcY_siMl.js} +2 -2
- package/lib/{Pagination-9TA5cwCh.js.map → Pagination-BcY_siMl.js.map} +1 -1
- package/lib/{SchemaList-CbFxph_p.js → SchemaList-DcWTacAj.js} +2 -2
- package/lib/{SchemaList-CbFxph_p.js.map → SchemaList-DcWTacAj.js.map} +1 -1
- package/lib/{createServer-D_5UkLtY.js → createServer-IW7v5hWm.js} +1485 -1459
- package/lib/createServer-IW7v5hWm.js.map +1 -0
- package/lib/index-DMYbZ3i6.js +5031 -0
- package/lib/index-DMYbZ3i6.js.map +1 -0
- package/lib/{index-pAogBEk7.js → index-DNFEg0uU.js} +5 -5
- package/lib/{index-pAogBEk7.js.map → index-DNFEg0uU.js.map} +1 -1
- package/lib/{public-api-CrAQFYc4.js → index-DcHeSvkE.js} +684 -651
- package/lib/index-DcHeSvkE.js.map +1 -0
- package/lib/zudoku.components.js +1 -1
- package/lib/zudoku.plugin-api-catalog.js +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +1 -1
- package/package.json +1 -1
- package/src/app/main.tsx +7 -3
- package/src/lib/components/BuildCheck.tsx +20 -7
- package/src/lib/oas/parser/index.ts +3 -4
- package/src/lib/oas/parser/upgrade/index.ts +103 -0
- package/lib/createServer-D_5UkLtY.js.map +0 -1
- package/lib/index-BPmAnNGI.js +0 -2054
- package/lib/index-BPmAnNGI.js.map +0 -1
- package/lib/index-BpThvE5R.js +0 -66
- package/lib/index-BpThvE5R.js.map +0 -1
- package/lib/index-ueM1dihS.js +0 -247
- package/lib/index-ueM1dihS.js.map +0 -1
- package/lib/public-api-CrAQFYc4.js.map +0 -1
package/lib/zudoku.components.js
CHANGED
|
@@ -3,7 +3,7 @@ import "./index-DwT-v3zK.js";
|
|
|
3
3
|
import "./chunk-KNED5TY2-BUPjb3LQ.js";
|
|
4
4
|
import "./hook-pPrHCB6G.js";
|
|
5
5
|
import "./SlotletProvider-p4XaFFOh.js";
|
|
6
|
-
import { e as d, f as k, n as l, B as S, C as h, j as B, l as c, H as E, d as H, L, M, g as R, R as Z, S as f, k as g, i as y, Z as A, a as b, h as j, c as v, m as w, b as x } from "./index-
|
|
6
|
+
import { e as d, f as k, n as l, B as S, C as h, j as B, l as c, H as E, d as H, L, M, g as R, R as Z, S as f, k as g, i as y, Z as A, a as b, h as j, c as v, m as w, b as x } from "./index-DMYbZ3i6.js";
|
|
7
7
|
import "./ui/Button.js";
|
|
8
8
|
import "./ui/Callout.js";
|
|
9
9
|
import "./ClientOnly-E7hGysn1.js";
|
|
@@ -3,7 +3,7 @@ import { s as h } from "./index-LNp6rxyU.js";
|
|
|
3
3
|
import { d as b, m as x } from "./chunk-KNED5TY2-BUPjb3LQ.js";
|
|
4
4
|
import { u as j, d as y, f as p } from "./hook-pPrHCB6G.js";
|
|
5
5
|
import { H as v } from "./RouteGuard-BZ_VsiXc.js";
|
|
6
|
-
import { L as N } from "./index-
|
|
6
|
+
import { L as N } from "./index-DMYbZ3i6.js";
|
|
7
7
|
import { H as S, M as w } from "./Markdown-DqDbGCj2.js";
|
|
8
8
|
const H = ({
|
|
9
9
|
items: r,
|
|
@@ -53,7 +53,7 @@ const P = (e) => ({
|
|
|
53
53
|
const u = {
|
|
54
54
|
path: r,
|
|
55
55
|
lazy: async () => {
|
|
56
|
-
const { MdxPage: p } = await import("./MdxPage-
|
|
56
|
+
const { MdxPage: p } = await import("./MdxPage-OSMru6r8.js"), { default: f, ...l } = await i();
|
|
57
57
|
return {
|
|
58
58
|
element: /* @__PURE__ */ d.jsx(
|
|
59
59
|
p,
|
|
@@ -3,7 +3,7 @@ import "lucide-react";
|
|
|
3
3
|
import "./chunk-KNED5TY2-BUPjb3LQ.js";
|
|
4
4
|
import "./hook-pPrHCB6G.js";
|
|
5
5
|
import "./ui/Button.js";
|
|
6
|
-
import { U as a, o as e } from "./index-
|
|
6
|
+
import { U as a, o as e } from "./index-DNFEg0uU.js";
|
|
7
7
|
export {
|
|
8
8
|
a as UNTAGGED_PATH,
|
|
9
9
|
e as openApiPlugin
|
package/package.json
CHANGED
package/src/app/main.tsx
CHANGED
|
@@ -129,9 +129,13 @@ export const getRoutesByConfig = (config: ZudokuConfig): RouteObject[] => {
|
|
|
129
129
|
{
|
|
130
130
|
element: (
|
|
131
131
|
<Zudoku {...options}>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
<BuildCheck
|
|
133
|
+
buildId={
|
|
134
|
+
import.meta.env.IS_ZUPLO && import.meta.env.ZUPLO_BUILD_ID
|
|
135
|
+
? import.meta.env.ZUPLO_BUILD_ID
|
|
136
|
+
: undefined
|
|
137
|
+
}
|
|
138
|
+
/>
|
|
135
139
|
<Layout />
|
|
136
140
|
</Zudoku>
|
|
137
141
|
),
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
|
2
2
|
import { CircleFadingArrowUpIcon, LoaderCircleIcon } from "lucide-react";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import { Button } from "../ui/Button.js";
|
|
4
5
|
|
|
6
|
+
const BuildStatusSchema = z.object({
|
|
7
|
+
buildId: z.string(),
|
|
8
|
+
timestamp: z.string(),
|
|
9
|
+
status: z.enum(["in-progress", "completed", "failed"]),
|
|
10
|
+
});
|
|
11
|
+
|
|
5
12
|
export const BuildCheck = ({
|
|
6
13
|
buildId,
|
|
7
14
|
endpoint = "/__zuplo/docs",
|
|
@@ -13,19 +20,25 @@ export const BuildCheck = ({
|
|
|
13
20
|
queryKey: ["zuplo-build-check", buildId, endpoint],
|
|
14
21
|
refetchInterval: 2000,
|
|
15
22
|
enabled: !!buildId,
|
|
23
|
+
retry: false,
|
|
16
24
|
queryFn: () =>
|
|
17
|
-
fetch(endpoint
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
fetch(endpoint, { signal: AbortSignal.timeout(2000) })
|
|
26
|
+
.then((res) => {
|
|
27
|
+
if (!res.ok) throw new Error("Failed to fetch build status");
|
|
28
|
+
return res.json();
|
|
29
|
+
})
|
|
30
|
+
.then((data) => BuildStatusSchema.parse(data)),
|
|
22
31
|
});
|
|
23
32
|
|
|
24
|
-
if (
|
|
33
|
+
if (
|
|
34
|
+
buildStatusQuery.isError ||
|
|
35
|
+
!buildStatusQuery.data ||
|
|
36
|
+
buildStatusQuery.data.buildId === buildId
|
|
37
|
+
) {
|
|
25
38
|
return null;
|
|
26
39
|
}
|
|
27
40
|
|
|
28
|
-
const isCompleted = buildStatusQuery.data
|
|
41
|
+
const isCompleted = buildStatusQuery.data.status === "completed";
|
|
29
42
|
|
|
30
43
|
return (
|
|
31
44
|
<div className="fixed flex flex-col gap-3 p-4 rounded-xl w-96 border z-20 bg-background left-0 right-0 top-4 mx-auto shadow-lg">
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GraphQLError } from "graphql/error/index.js";
|
|
2
2
|
import { OpenAPIV3, type OpenAPIV3_1 } from "openapi-types";
|
|
3
3
|
import { dereference, type JSONSchema } from "./dereference/index.js";
|
|
4
|
+
import { upgradeSchema } from "./upgrade/index.js";
|
|
4
5
|
|
|
5
6
|
// Must be an interface (not a type) to allow merging with OpenAPI types with index signatures
|
|
6
7
|
interface WithRef {
|
|
@@ -94,10 +95,8 @@ export const validate = async (schemaInput: unknown) => {
|
|
|
94
95
|
throw new GraphQLError("OpenAPI version is not defined");
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
const { upgrade } = await import("@scalar/openapi-parser");
|
|
98
|
-
|
|
99
98
|
const dereferenced = await dereference(schema);
|
|
100
|
-
const upgraded =
|
|
99
|
+
const upgraded = upgradeSchema(dereferenced);
|
|
101
100
|
|
|
102
|
-
return upgraded
|
|
101
|
+
return upgraded;
|
|
103
102
|
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { type RecordAny, traverse } from "../../../util/traverse.js";
|
|
3
|
+
import type { OpenAPIDocument } from "../index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Upgrade from OpenAPI 3.0.x to 3.1.0
|
|
6
|
+
*
|
|
7
|
+
* Taken from https://github.com/scalar/openapi-parser/blob/main/packages/openapi-parser/src/utils/upgradeFromThreeToThreeOne.ts
|
|
8
|
+
* https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const upgradeSchema = (schema: RecordAny): OpenAPIDocument => {
|
|
12
|
+
if (schema.openapi?.startsWith("3.0")) {
|
|
13
|
+
schema.openapi = "3.1.0";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
schema = traverse(schema, (sub) => {
|
|
17
|
+
if (typeof sub.type !== "undefined" && sub.nullable === true) {
|
|
18
|
+
sub.type = ["null", sub.type];
|
|
19
|
+
delete sub.nullable;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return sub;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
schema = traverse(schema, (sub) => {
|
|
26
|
+
if (sub.exclusiveMinimum === true) {
|
|
27
|
+
sub.exclusiveMinimum = sub.minimum;
|
|
28
|
+
delete sub.minimum;
|
|
29
|
+
} else if (sub.exclusiveMinimum === false) {
|
|
30
|
+
delete sub.exclusiveMinimum;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (sub.exclusiveMaximum === true) {
|
|
34
|
+
sub.exclusiveMaximum = sub.maximum;
|
|
35
|
+
delete sub.maximum;
|
|
36
|
+
} else if (sub.exclusiveMaximum === false) {
|
|
37
|
+
delete sub.exclusiveMaximum;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return sub;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
schema = traverse(schema, (sub) => {
|
|
44
|
+
// may be null or undefined
|
|
45
|
+
if (sub.example) {
|
|
46
|
+
const isExampleObject =
|
|
47
|
+
typeof sub.example === "object" &&
|
|
48
|
+
(sub.example.summary !== undefined ||
|
|
49
|
+
sub.example.description !== undefined ||
|
|
50
|
+
sub.example.value !== undefined ||
|
|
51
|
+
sub.example.externalValue !== undefined);
|
|
52
|
+
|
|
53
|
+
const exampleValue = isExampleObject
|
|
54
|
+
? sub.example
|
|
55
|
+
: { value: sub.example };
|
|
56
|
+
|
|
57
|
+
if (!sub.examples) {
|
|
58
|
+
sub.examples = { default: exampleValue };
|
|
59
|
+
} else {
|
|
60
|
+
sub.examples = {
|
|
61
|
+
default: exampleValue,
|
|
62
|
+
...sub.examples,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
delete sub.example;
|
|
66
|
+
}
|
|
67
|
+
return sub;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
schema = traverse(schema, (sub) => {
|
|
71
|
+
if (sub.type === "object" && sub.properties !== undefined) {
|
|
72
|
+
for (const [, value] of Object.entries(sub.properties)) {
|
|
73
|
+
const v = (value ?? {}) as RecordAny;
|
|
74
|
+
if (v.type === "string" && v.format === "binary") {
|
|
75
|
+
v.contentEncoding = "application/octet-stream";
|
|
76
|
+
delete v.format;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return sub;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
schema = traverse(schema, (sub) => {
|
|
84
|
+
if (sub.type === "string" && sub.format === "binary") {
|
|
85
|
+
return undefined as any;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return sub;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
schema = traverse(schema, (sub) => {
|
|
92
|
+
if (sub.type === "string" && sub.format === "base64") {
|
|
93
|
+
return {
|
|
94
|
+
type: "string",
|
|
95
|
+
contentEncoding: "base64",
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return sub;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return schema as OpenAPIDocument;
|
|
103
|
+
};
|