zudoku 0.31.1 → 0.31.3
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/lib/oas/graphql/index.js +3 -2
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/plugins/openapi/{OpenApiRoute.d.ts → OasProvider.d.ts} +1 -2
- package/dist/lib/plugins/openapi/OasProvider.js +29 -0
- package/dist/lib/plugins/openapi/OasProvider.js.map +1 -0
- package/dist/lib/plugins/openapi/index.d.ts +8 -0
- package/dist/lib/plugins/openapi/index.js +43 -110
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/util/createSidebarCategory.d.ts +9 -0
- package/dist/lib/plugins/openapi/util/createSidebarCategory.js +25 -0
- package/dist/lib/plugins/openapi/util/createSidebarCategory.js.map +1 -0
- package/dist/lib/plugins/openapi/util/getRoutes.d.ts +10 -0
- package/dist/lib/plugins/openapi/util/getRoutes.js +74 -0
- package/dist/lib/plugins/openapi/util/getRoutes.js.map +1 -0
- package/dist/lib/plugins/openapi/util/methodColorMap.d.ts +2 -0
- package/dist/lib/plugins/openapi/util/methodColorMap.js +10 -0
- package/dist/lib/plugins/openapi/util/methodColorMap.js.map +1 -0
- package/dist/vite/api/schema-codegen.js +1 -1
- package/dist/vite/api/schema-codegen.js.map +1 -1
- package/dist/vite/prerender/prerender.js +1 -1
- package/dist/vite/prerender/prerender.js.map +1 -1
- package/lib/OasProvider-DGKSXGQm.js +34 -0
- package/lib/OasProvider-DGKSXGQm.js.map +1 -0
- package/lib/{OperationList-c72qPMtm.js → OperationList-BBE1QsAN.js} +2 -2
- package/lib/{OperationList-c72qPMtm.js.map → OperationList-BBE1QsAN.js.map} +1 -1
- package/lib/{createServer-ZDNGmPfQ.js → createServer-DSQiPwjN.js} +2 -5
- package/lib/{createServer-ZDNGmPfQ.js.map → createServer-DSQiPwjN.js.map} +1 -1
- package/lib/{index-CZjcfK-H.js → index-DzaciJI0.js} +803 -769
- package/lib/index-DzaciJI0.js.map +1 -0
- package/lib/zudoku.plugin-openapi.js +3 -2
- package/package.json +1 -1
- package/src/lib/oas/graphql/index.ts +3 -2
- package/src/lib/plugins/openapi/OasProvider.tsx +51 -0
- package/src/lib/plugins/openapi/index.tsx +69 -140
- package/src/lib/plugins/openapi/util/createSidebarCategory.tsx +39 -0
- package/src/lib/plugins/openapi/util/getRoutes.tsx +123 -0
- package/src/lib/plugins/openapi/util/methodColorMap.tsx +11 -0
- package/dist/lib/plugins/openapi/OpenApiRoute.js +0 -25
- package/dist/lib/plugins/openapi/OpenApiRoute.js.map +0 -1
- package/lib/OpenApiRoute-BP9kzG5k.js +0 -36
- package/lib/OpenApiRoute-BP9kzG5k.js.map +0 -1
- package/lib/index-CZjcfK-H.js.map +0 -1
- package/src/lib/plugins/openapi/OpenApiRoute.tsx +0 -51
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import type { ResultOf } from "@graphql-typed-document-node/core";
|
|
1
2
|
import slugify from "@sindresorhus/slugify";
|
|
2
3
|
import { CirclePlayIcon, LogInIcon } from "lucide-react";
|
|
3
|
-
import { matchPath
|
|
4
|
-
import type { SidebarItem } from "../../../config/validators/SidebarSchema.js";
|
|
4
|
+
import { matchPath } from "react-router";
|
|
5
5
|
import { useAuth } from "../../authentication/hook.js";
|
|
6
|
-
import { ColorMap } from "../../components/navigation/SidebarBadge.js";
|
|
7
6
|
import { type ZudokuPlugin } from "../../core/plugins.js";
|
|
8
7
|
import type { SchemaImports } from "../../oas/graphql/index.js";
|
|
9
8
|
import { Button } from "../../ui/Button.js";
|
|
@@ -13,6 +12,8 @@ import { graphql } from "./graphql/index.js";
|
|
|
13
12
|
import { OasPluginConfig } from "./interfaces.js";
|
|
14
13
|
import type { PlaygroundContentProps } from "./playground/Playground.js";
|
|
15
14
|
import { PlaygroundDialog } from "./playground/PlaygroundDialog.js";
|
|
15
|
+
import { createSidebarCategory } from "./util/createSidebarCategory.js";
|
|
16
|
+
import { getRoutes, getVersions } from "./util/getRoutes.js";
|
|
16
17
|
|
|
17
18
|
const GetCategoriesQuery = graphql(`
|
|
18
19
|
query GetCategories($input: JSON!, $type: SchemaType!) {
|
|
@@ -51,26 +52,18 @@ const GetOperationsQuery = graphql(`
|
|
|
51
52
|
}
|
|
52
53
|
`);
|
|
53
54
|
|
|
54
|
-
type
|
|
55
|
+
export type OperationResult = ResultOf<
|
|
56
|
+
typeof GetOperationsQuery
|
|
57
|
+
>["schema"]["operations"][number];
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
get: "green",
|
|
58
|
-
post: "blue",
|
|
59
|
-
put: "yellow",
|
|
60
|
-
delete: "red",
|
|
61
|
-
patch: "purple",
|
|
62
|
-
options: "gray",
|
|
63
|
-
head: "gray",
|
|
64
|
-
};
|
|
59
|
+
type InternalOasPluginConfig = { schemaImports?: SchemaImports };
|
|
65
60
|
|
|
66
61
|
export type OpenApiPluginOptions = OasPluginConfig & InternalOasPluginConfig;
|
|
67
62
|
|
|
68
|
-
const UNTAGGED_PATH = "~endpoints";
|
|
63
|
+
export const UNTAGGED_PATH = "~endpoints";
|
|
69
64
|
|
|
70
65
|
export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
|
|
71
66
|
const basePath = joinUrl(config.navigationId ?? "/reference");
|
|
72
|
-
const versions = config.type === "file" ? Object.keys(config.input) : [];
|
|
73
|
-
|
|
74
67
|
const client = new GraphQLClient(config);
|
|
75
68
|
|
|
76
69
|
return {
|
|
@@ -138,86 +131,78 @@ export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
|
|
|
138
131
|
return [];
|
|
139
132
|
}
|
|
140
133
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const version = urlVersion ?? Object.keys(config.input).at(0);
|
|
146
|
-
|
|
147
|
-
const tagData = await client.fetch(GetCategoriesQuery, {
|
|
148
|
-
type: config.type,
|
|
149
|
-
input: config.type === "file" ? config.input[version!] : config.input,
|
|
150
|
-
});
|
|
134
|
+
const match = matchPath(
|
|
135
|
+
{ path: `${basePath}/:version?/:tag`, end: true },
|
|
136
|
+
path,
|
|
137
|
+
);
|
|
151
138
|
|
|
152
|
-
|
|
153
|
-
|
|
139
|
+
try {
|
|
140
|
+
const versionParam = match?.params.version;
|
|
141
|
+
const version = versionParam ?? getVersions(config).at(0);
|
|
142
|
+
const type = config.type;
|
|
143
|
+
const input =
|
|
144
|
+
config.type === "file" ? config.input[version!] : config.input;
|
|
145
|
+
|
|
146
|
+
const collapsible = config.loadTags === true || config.type === "url";
|
|
147
|
+
const collapsed = !config.loadTags && config.type !== "url";
|
|
148
|
+
|
|
149
|
+
// find tag name by slug in config.tagPages
|
|
150
|
+
const tagName = config.tagPages?.find(
|
|
151
|
+
(tag) => slugify(tag) === match?.params.tag,
|
|
154
152
|
);
|
|
155
153
|
|
|
156
|
-
const operationsData = await
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
154
|
+
const [tagData, operationsData] = await Promise.all([
|
|
155
|
+
client.fetch(GetCategoriesQuery, { type, input }),
|
|
156
|
+
client.fetch(GetOperationsQuery, {
|
|
157
|
+
type,
|
|
158
|
+
input,
|
|
159
|
+
tag: !config.loadTags ? tagName : undefined,
|
|
160
|
+
}),
|
|
161
|
+
]);
|
|
162
|
+
|
|
163
|
+
const categories = tagData.schema.tags.flatMap((tag) => {
|
|
164
|
+
const categoryPath = joinUrl(
|
|
165
|
+
basePath,
|
|
166
|
+
versionParam,
|
|
167
|
+
slugify(tag.name),
|
|
168
|
+
);
|
|
164
169
|
|
|
165
|
-
const operations = operationsData.schema.operations
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
)
|
|
171
|
-
.map((operation) => ({
|
|
172
|
-
type: "link" as const,
|
|
173
|
-
label: operation.summary ?? operation.path,
|
|
174
|
-
href: `${categoryLink}#${operation.slug}`,
|
|
175
|
-
badge: {
|
|
176
|
-
label: operation.method,
|
|
177
|
-
color: MethodColorMap[operation.method.toLowerCase()]!,
|
|
178
|
-
invert: true,
|
|
179
|
-
} as const,
|
|
180
|
-
}));
|
|
170
|
+
const operations = operationsData.schema.operations.filter(
|
|
171
|
+
(operation) =>
|
|
172
|
+
operation.tags?.length !== 0 &&
|
|
173
|
+
operation.tags?.map((t) => t.name).includes(tag.name),
|
|
174
|
+
);
|
|
181
175
|
|
|
176
|
+
// skip empty categories
|
|
182
177
|
if (config.loadTags && operations.length === 0) {
|
|
183
178
|
return [];
|
|
184
179
|
}
|
|
185
180
|
|
|
186
|
-
return {
|
|
187
|
-
type: "category",
|
|
181
|
+
return createSidebarCategory({
|
|
188
182
|
label: tag.name,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
collapsible
|
|
195
|
-
collapsed
|
|
196
|
-
|
|
197
|
-
};
|
|
183
|
+
path: categoryPath,
|
|
184
|
+
operations:
|
|
185
|
+
match?.params.tag !== UNTAGGED_PATH || config.loadTags
|
|
186
|
+
? operations
|
|
187
|
+
: [],
|
|
188
|
+
collapsible,
|
|
189
|
+
collapsed,
|
|
190
|
+
});
|
|
198
191
|
});
|
|
199
192
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const categoryLink = joinUrl(basePath, urlVersion, UNTAGGED_PATH);
|
|
204
|
-
|
|
205
|
-
categories.push({
|
|
206
|
-
type: "category",
|
|
207
|
-
label: "Other endpoints",
|
|
208
|
-
link: {
|
|
209
|
-
type: "doc" as const,
|
|
210
|
-
id: categoryLink,
|
|
193
|
+
if (operationsData.schema.untagged.length > 0) {
|
|
194
|
+
categories.push(
|
|
195
|
+
createSidebarCategory({
|
|
211
196
|
label: "Other endpoints",
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
})
|
|
220
|
-
|
|
197
|
+
path: joinUrl(basePath, versionParam, UNTAGGED_PATH),
|
|
198
|
+
operations:
|
|
199
|
+
match?.params.tag === UNTAGGED_PATH || config.loadTags
|
|
200
|
+
? operationsData.schema.untagged
|
|
201
|
+
: [],
|
|
202
|
+
collapsible,
|
|
203
|
+
collapsed,
|
|
204
|
+
}),
|
|
205
|
+
);
|
|
221
206
|
}
|
|
222
207
|
|
|
223
208
|
return categories;
|
|
@@ -225,62 +210,6 @@ export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
|
|
|
225
210
|
return [];
|
|
226
211
|
}
|
|
227
212
|
},
|
|
228
|
-
getRoutes: () => {
|
|
229
|
-
const versionsInPath = versions.length > 1 ? [null, ...versions] : [null];
|
|
230
|
-
|
|
231
|
-
const tagPages = (config.tagPages ?? []).map((tag) => ({
|
|
232
|
-
tag,
|
|
233
|
-
path: slugify(tag),
|
|
234
|
-
}));
|
|
235
|
-
|
|
236
|
-
return versionsInPath.map((version) => {
|
|
237
|
-
const versionPath = joinUrl(basePath, version);
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
path: versionPath,
|
|
241
|
-
async lazy() {
|
|
242
|
-
const { OpenApiRoute } = await import("./OpenApiRoute.js");
|
|
243
|
-
return {
|
|
244
|
-
element: (
|
|
245
|
-
<OpenApiRoute
|
|
246
|
-
version={version ?? undefined}
|
|
247
|
-
basePath={basePath}
|
|
248
|
-
versions={versions}
|
|
249
|
-
client={client}
|
|
250
|
-
config={config}
|
|
251
|
-
/>
|
|
252
|
-
),
|
|
253
|
-
};
|
|
254
|
-
},
|
|
255
|
-
children: [
|
|
256
|
-
{
|
|
257
|
-
index: true,
|
|
258
|
-
loader: () =>
|
|
259
|
-
redirect(
|
|
260
|
-
joinUrl(versionPath, tagPages.at(0)?.path ?? UNTAGGED_PATH),
|
|
261
|
-
),
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
path: joinUrl(versionPath, UNTAGGED_PATH),
|
|
265
|
-
async lazy() {
|
|
266
|
-
const { OperationList } = await import("./OperationList.js");
|
|
267
|
-
return { element: <OperationList untagged={true} /> };
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
...tagPages.map<RouteObject>((tag) => {
|
|
271
|
-
return {
|
|
272
|
-
path: joinUrl(versionPath, tag.path),
|
|
273
|
-
async lazy() {
|
|
274
|
-
const { OperationList } = await import("./OperationList.js");
|
|
275
|
-
return {
|
|
276
|
-
element: <OperationList tag={tag.tag} />,
|
|
277
|
-
};
|
|
278
|
-
},
|
|
279
|
-
};
|
|
280
|
-
}),
|
|
281
|
-
],
|
|
282
|
-
};
|
|
283
|
-
});
|
|
284
|
-
},
|
|
213
|
+
getRoutes: () => getRoutes({ basePath, config, client }),
|
|
285
214
|
};
|
|
286
215
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SidebarItem } from "../../../../config/validators/SidebarSchema.js";
|
|
2
|
+
import type { OperationResult } from "../index.js";
|
|
3
|
+
import { MethodColorMap } from "./methodColorMap.js";
|
|
4
|
+
|
|
5
|
+
export const createSidebarCategory = ({
|
|
6
|
+
label,
|
|
7
|
+
path,
|
|
8
|
+
operations,
|
|
9
|
+
collapsible,
|
|
10
|
+
collapsed,
|
|
11
|
+
}: {
|
|
12
|
+
label: string;
|
|
13
|
+
path: string;
|
|
14
|
+
operations: OperationResult[];
|
|
15
|
+
collapsible?: boolean;
|
|
16
|
+
collapsed?: boolean;
|
|
17
|
+
}): SidebarItem => ({
|
|
18
|
+
type: "category",
|
|
19
|
+
label,
|
|
20
|
+
link: {
|
|
21
|
+
type: "doc" as const,
|
|
22
|
+
id: path,
|
|
23
|
+
label,
|
|
24
|
+
},
|
|
25
|
+
collapsible,
|
|
26
|
+
collapsed,
|
|
27
|
+
items: operations.map((operation) => ({
|
|
28
|
+
type: "link" as const,
|
|
29
|
+
label: operation.summary ?? operation.path,
|
|
30
|
+
href: `${path}#${operation.slug}`,
|
|
31
|
+
...(operation.method && {
|
|
32
|
+
badge: {
|
|
33
|
+
label: operation.method,
|
|
34
|
+
color: MethodColorMap[operation.method.toLowerCase()]!,
|
|
35
|
+
invert: true,
|
|
36
|
+
} as const,
|
|
37
|
+
}),
|
|
38
|
+
})),
|
|
39
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import slugify from "@sindresorhus/slugify";
|
|
2
|
+
import { redirect, type RouteObject } from "react-router";
|
|
3
|
+
import { joinUrl } from "../../../util/joinUrl.js";
|
|
4
|
+
import type { GraphQLClient } from "../client/GraphQLClient.js";
|
|
5
|
+
import { type OpenApiPluginOptions, UNTAGGED_PATH } from "../index.js";
|
|
6
|
+
import type { OasPluginConfig } from "../interfaces.js";
|
|
7
|
+
|
|
8
|
+
// Creates the main provider route that wraps operation routes.
|
|
9
|
+
const createOasProvider = (opts: {
|
|
10
|
+
routePath: string;
|
|
11
|
+
basePath: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
routes: RouteObject[];
|
|
14
|
+
client: GraphQLClient;
|
|
15
|
+
config: OpenApiPluginOptions;
|
|
16
|
+
}): RouteObject => ({
|
|
17
|
+
path: opts.routePath,
|
|
18
|
+
async lazy() {
|
|
19
|
+
const { OasProvider } = await import("../OasProvider.js");
|
|
20
|
+
return {
|
|
21
|
+
element: (
|
|
22
|
+
<OasProvider
|
|
23
|
+
basePath={opts.basePath}
|
|
24
|
+
version={opts.version}
|
|
25
|
+
client={opts.client}
|
|
26
|
+
config={opts.config}
|
|
27
|
+
/>
|
|
28
|
+
),
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
children: opts.routes,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Creates a route for displaying the operation list used for both tagged and untagged operations.
|
|
35
|
+
const createRoute = ({
|
|
36
|
+
path,
|
|
37
|
+
tag,
|
|
38
|
+
untagged,
|
|
39
|
+
}: {
|
|
40
|
+
path: string;
|
|
41
|
+
tag?: string;
|
|
42
|
+
untagged?: boolean;
|
|
43
|
+
}): RouteObject => ({
|
|
44
|
+
path,
|
|
45
|
+
async lazy() {
|
|
46
|
+
const { OperationList } = await import("../OperationList.js");
|
|
47
|
+
return { element: <OperationList tag={tag} untagged={untagged} /> };
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Creates routes for a specific version, including tag-based routes and the untagged operations route.
|
|
52
|
+
const createVersionRoutes = (
|
|
53
|
+
versionPath: string,
|
|
54
|
+
tagPages: string[],
|
|
55
|
+
): RouteObject[] => {
|
|
56
|
+
const firstTagRoute = joinUrl(
|
|
57
|
+
versionPath,
|
|
58
|
+
tagPages[0] ? slugify(tagPages[0]) : UNTAGGED_PATH,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return [
|
|
62
|
+
// Redirect to first tag on the index route
|
|
63
|
+
{ index: true, loader: () => redirect(firstTagRoute) },
|
|
64
|
+
// Create routes for each tag
|
|
65
|
+
...tagPages.map((tag) =>
|
|
66
|
+
createRoute({
|
|
67
|
+
path: joinUrl(versionPath, slugify(tag)),
|
|
68
|
+
tag,
|
|
69
|
+
}),
|
|
70
|
+
),
|
|
71
|
+
// Category without tagged operations
|
|
72
|
+
createRoute({
|
|
73
|
+
path: joinUrl(versionPath, UNTAGGED_PATH),
|
|
74
|
+
untagged: true,
|
|
75
|
+
}),
|
|
76
|
+
];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const getVersions = (config: OasPluginConfig) =>
|
|
80
|
+
config.type === "file" ? Object.keys(config.input) : [];
|
|
81
|
+
|
|
82
|
+
export const getRoutes = ({
|
|
83
|
+
basePath,
|
|
84
|
+
config,
|
|
85
|
+
client,
|
|
86
|
+
}: {
|
|
87
|
+
client: GraphQLClient;
|
|
88
|
+
config: OpenApiPluginOptions;
|
|
89
|
+
basePath: string;
|
|
90
|
+
}): RouteObject[] => {
|
|
91
|
+
const tagPages = config.tagPages;
|
|
92
|
+
|
|
93
|
+
// If the config does not provide tag pages the catch-all
|
|
94
|
+
// route handles all operations on a single page
|
|
95
|
+
if (!tagPages) {
|
|
96
|
+
return [
|
|
97
|
+
createOasProvider({
|
|
98
|
+
basePath,
|
|
99
|
+
routePath: basePath,
|
|
100
|
+
routes: [createRoute({ path: basePath + "/:tag?" })],
|
|
101
|
+
client,
|
|
102
|
+
config,
|
|
103
|
+
}),
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const versions = getVersions(config);
|
|
108
|
+
// The latest version always is added as index path
|
|
109
|
+
const versionsInPath =
|
|
110
|
+
versions.length > 1 ? [undefined, ...versions] : [undefined];
|
|
111
|
+
|
|
112
|
+
return versionsInPath.map((version) => {
|
|
113
|
+
const versionPath = joinUrl(basePath, version);
|
|
114
|
+
return createOasProvider({
|
|
115
|
+
basePath,
|
|
116
|
+
version,
|
|
117
|
+
routePath: versionPath,
|
|
118
|
+
routes: createVersionRoutes(versionPath, tagPages),
|
|
119
|
+
client,
|
|
120
|
+
config,
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ColorMap } from "../../../components/navigation/SidebarBadge.js";
|
|
2
|
+
|
|
3
|
+
export const MethodColorMap: Record<string, keyof typeof ColorMap> = {
|
|
4
|
+
get: "green",
|
|
5
|
+
post: "blue",
|
|
6
|
+
put: "yellow",
|
|
7
|
+
delete: "red",
|
|
8
|
+
patch: "purple",
|
|
9
|
+
options: "gray",
|
|
10
|
+
head: "gray",
|
|
11
|
+
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Outlet } from "react-router";
|
|
3
|
-
import { joinPath } from "../../util/joinPath.js";
|
|
4
|
-
import { GraphQLProvider } from "./client/GraphQLContext.js";
|
|
5
|
-
import { OasConfigProvider } from "./context.js";
|
|
6
|
-
export const OpenApiRoute = ({ basePath, versions, version, config, client, }) => {
|
|
7
|
-
const input = config.type === "file"
|
|
8
|
-
? {
|
|
9
|
-
type: config.type,
|
|
10
|
-
input: version
|
|
11
|
-
? config.input[version]
|
|
12
|
-
: Object.values(config.input).at(0),
|
|
13
|
-
}
|
|
14
|
-
: { type: config.type, input: config.input };
|
|
15
|
-
const currentVersion = version ?? versions.at(0);
|
|
16
|
-
return (_jsx(OasConfigProvider, { value: {
|
|
17
|
-
config: {
|
|
18
|
-
...config,
|
|
19
|
-
version: currentVersion,
|
|
20
|
-
versions: Object.fromEntries(versions.map((version) => [version, joinPath(basePath, version)])),
|
|
21
|
-
...input,
|
|
22
|
-
},
|
|
23
|
-
}, children: _jsx(GraphQLProvider, { client: client, children: _jsx(Outlet, {}) }) }));
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=OpenApiRoute.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiRoute.js","sourceRoot":"","sources":["../../../../src/lib/plugins/openapi/OpenApiRoute.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,GAOP,EAAE,EAAE;IACH,MAAM,KAAK,GACT,MAAM,CAAC,IAAI,KAAK,MAAM;QACpB,CAAC,CAAC;YACE,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,OAAO;gBACZ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAE;gBACxB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE;SACvC;QACH,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IAEjD,MAAM,cAAc,GAAG,OAAO,IAAI,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEjD,OAAO,CACL,KAAC,iBAAiB,IAChB,KAAK,EAAE;YACL,MAAM,EAAE;gBACN,GAAG,MAAM;gBACT,OAAO,EAAE,cAAc;gBACvB,QAAQ,EAAE,MAAM,CAAC,WAAW,CAC1B,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAClE;gBACD,GAAG,KAAK;aACT;SACF,YAED,KAAC,eAAe,IAAC,MAAM,EAAE,MAAM,YAC7B,KAAC,MAAM,KAAG,GACM,GACA,CACrB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { j as e } from "./jsx-runtime-Bdg6XQ1m.js";
|
|
2
|
-
import { O as n } from "./chunk-SYFQ2XB5-QijJrSf0.js";
|
|
3
|
-
import { j as m } from "./hook-Dnj3SwPC.js";
|
|
4
|
-
import { O as j, G as O } from "./context-rwLGh-6_.js";
|
|
5
|
-
const h = ({
|
|
6
|
-
basePath: i,
|
|
7
|
-
versions: p,
|
|
8
|
-
version: r,
|
|
9
|
-
config: t,
|
|
10
|
-
client: a
|
|
11
|
-
}) => {
|
|
12
|
-
const o = t.type === "file" ? {
|
|
13
|
-
type: t.type,
|
|
14
|
-
input: r ? t.input[r] : Object.values(t.input).at(0)
|
|
15
|
-
} : { type: t.type, input: t.input }, u = r ?? p.at(0);
|
|
16
|
-
return /* @__PURE__ */ e.jsx(
|
|
17
|
-
j,
|
|
18
|
-
{
|
|
19
|
-
value: {
|
|
20
|
-
config: {
|
|
21
|
-
...t,
|
|
22
|
-
version: u,
|
|
23
|
-
versions: Object.fromEntries(
|
|
24
|
-
p.map((s) => [s, m(i, s)])
|
|
25
|
-
),
|
|
26
|
-
...o
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
children: /* @__PURE__ */ e.jsx(O, { client: a, children: /* @__PURE__ */ e.jsx(n, {}) })
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
export {
|
|
34
|
-
h as OpenApiRoute
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=OpenApiRoute-BP9kzG5k.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiRoute-BP9kzG5k.js","sources":["../src/lib/plugins/openapi/OpenApiRoute.tsx"],"sourcesContent":["import { Outlet } from \"react-router\";\nimport { joinPath } from \"../../util/joinPath.js\";\nimport type { GraphQLClient } from \"./client/GraphQLClient.js\";\nimport { GraphQLProvider } from \"./client/GraphQLContext.js\";\nimport { OasConfigProvider } from \"./context.js\";\nimport { type OasPluginConfig } from \"./interfaces.js\";\n\nexport const OpenApiRoute = ({\n basePath,\n versions,\n version,\n config,\n client,\n}: {\n basePath: string;\n version?: string;\n versions: string[];\n config: OasPluginConfig;\n client: GraphQLClient;\n}) => {\n const input =\n config.type === \"file\"\n ? {\n type: config.type,\n input: version\n ? config.input[version]!\n : Object.values(config.input).at(0)!,\n }\n : { type: config.type, input: config.input };\n\n const currentVersion = version ?? versions.at(0);\n\n return (\n <OasConfigProvider\n value={{\n config: {\n ...config,\n version: currentVersion,\n versions: Object.fromEntries(\n versions.map((version) => [version, joinPath(basePath, version)]),\n ),\n ...input,\n },\n }}\n >\n <GraphQLProvider client={client}>\n <Outlet />\n </GraphQLProvider>\n </OasConfigProvider>\n );\n};\n"],"names":["OpenApiRoute","basePath","versions","version","config","client","input","currentVersion","jsx","OasConfigProvider","joinPath","GraphQLProvider","Outlet"],"mappings":";;;;AAOO,MAAMA,IAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AACF,MAMM;AACE,QAAAC,IACJF,EAAO,SAAS,SACZ;AAAA,IACE,MAAMA,EAAO;AAAA,IACb,OAAOD,IACHC,EAAO,MAAMD,CAAO,IACpB,OAAO,OAAOC,EAAO,KAAK,EAAE,GAAG,CAAC;AAAA,EAAA,IAEtC,EAAE,MAAMA,EAAO,MAAM,OAAOA,EAAO,MAAM,GAEzCG,IAAiBJ,KAAWD,EAAS,GAAG,CAAC;AAG7C,SAAAM,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,QAAQ;AAAA,UACN,GAAGL;AAAA,UACH,SAASG;AAAA,UACT,UAAU,OAAO;AAAA,YACfL,EAAS,IAAI,CAACC,MAAY,CAACA,GAASO,EAAST,GAAUE,CAAO,CAAC,CAAC;AAAA,UAClE;AAAA,UACA,GAAGG;AAAA,QAAA;AAAA,MAEP;AAAA,MAEA,UAACE,gBAAAA,EAAAA,IAAAG,GAAA,EAAgB,QAAAN,GACf,UAAAG,gBAAAA,EAAA,IAACI,KAAO,EACV,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|