zudoku 0.35.5 → 0.36.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.server.js +5 -1
- package/dist/app/entry.server.js.map +1 -1
- package/dist/config/validators/common.d.ts +176 -176
- package/dist/config/validators/common.js +8 -6
- package/dist/config/validators/common.js.map +1 -1
- package/dist/config/validators/validate.d.ts +63 -63
- package/dist/lib/authentication/providers/openid.js +11 -7
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/components/AnchorLink.js +3 -2
- package/dist/lib/components/AnchorLink.js.map +1 -1
- package/dist/lib/components/Layout.js +3 -14
- package/dist/lib/components/Layout.js.map +1 -1
- package/dist/lib/components/Zudoku.js +3 -1
- package/dist/lib/components/Zudoku.js.map +1 -1
- package/dist/lib/components/cache.d.ts +7 -0
- package/dist/lib/components/cache.js +7 -0
- package/dist/lib/components/cache.js.map +1 -1
- package/dist/lib/components/context/ViewportAnchorContext.js +3 -6
- package/dist/lib/components/context/ViewportAnchorContext.js.map +1 -1
- package/dist/lib/components/context/ZudokuContext.d.ts +1 -1
- package/dist/lib/components/context/ZudokuContext.js +4 -3
- package/dist/lib/components/context/ZudokuContext.js.map +1 -1
- package/dist/lib/components/navigation/SidebarItem.js +3 -2
- package/dist/lib/components/navigation/SidebarItem.js.map +1 -1
- package/dist/lib/core/ZudokuContext.d.ts +8 -6
- package/dist/lib/core/ZudokuContext.js +4 -2
- package/dist/lib/core/ZudokuContext.js.map +1 -1
- package/dist/lib/core/plugins.d.ts +3 -3
- package/dist/lib/hooks/useEvent.test.js +1 -1
- package/dist/lib/hooks/useEvent.test.js.map +1 -1
- package/dist/lib/oas/graphql/index.d.ts +16 -4
- package/dist/lib/oas/graphql/index.js +59 -43
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.js +19 -5
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +2 -2
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +1 -1
- package/dist/lib/plugins/openapi/client/useCreateQuery.js +2 -1
- package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.d.ts +4 -4
- package/dist/lib/plugins/openapi/graphql/gql.js +3 -3
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +34 -45
- package/dist/lib/plugins/openapi/graphql/graphql.js +20 -30
- package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
- package/dist/lib/plugins/openapi/index.d.ts +5 -10
- package/dist/lib/plugins/openapi/index.js +29 -60
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/interfaces.d.ts +3 -1
- package/dist/lib/plugins/openapi/util/createSidebarCategory.js +5 -7
- package/dist/lib/plugins/openapi/util/createSidebarCategory.js.map +1 -1
- package/dist/lib/util/traverse.js +2 -2
- package/dist/lib/util/traverse.js.map +1 -1
- package/dist/lib/util/useScrollToAnchor.js +2 -0
- package/dist/lib/util/useScrollToAnchor.js.map +1 -1
- package/dist/vite/api/schema-codegen.js +19 -4
- package/dist/vite/api/schema-codegen.js.map +1 -1
- package/dist/vite/api/schema-codegen.test.js +61 -0
- package/dist/vite/api/schema-codegen.test.js.map +1 -1
- package/dist/vite/plugin-api.js +3 -11
- package/dist/vite/plugin-api.js.map +1 -1
- package/lib/{AuthenticationPlugin-4ip08maU.js → AuthenticationPlugin-Cr6xjOJD.js} +2 -2
- package/lib/{AuthenticationPlugin-4ip08maU.js.map → AuthenticationPlugin-Cr6xjOJD.js.map} +1 -1
- package/lib/{Markdown-hBN9vkm5.js → Markdown-BlioIqkZ.js} +313 -311
- package/lib/Markdown-BlioIqkZ.js.map +1 -0
- package/lib/{MdxPage-UCWwxhzC.js → MdxPage-7XnN9J9R.js} +3 -3
- package/lib/{MdxPage-UCWwxhzC.js.map → MdxPage-7XnN9J9R.js.map} +1 -1
- package/lib/{OasProvider-CJ8KOnsH.js → OasProvider-BaRRMSsD.js} +3 -3
- package/lib/{OasProvider-CJ8KOnsH.js.map → OasProvider-BaRRMSsD.js.map} +1 -1
- package/lib/{OperationList-C4rpJdcE.js → OperationList-BjL1hzSx.js} +988 -961
- package/lib/OperationList-BjL1hzSx.js.map +1 -0
- package/lib/{SlotletProvider-D-XPr1Wg.js → SlotletProvider-CXb3wQiR.js} +2 -2
- package/lib/{SlotletProvider-D-XPr1Wg.js.map → SlotletProvider-CXb3wQiR.js.map} +1 -1
- package/lib/{circular-v7K6lDDh.js → circular-ByJI6Mci.js} +4887 -4419
- package/lib/circular-ByJI6Mci.js.map +1 -0
- package/lib/{createServer-BEFAOb-x.js → createServer-DjgKDpGV.js} +3887 -4291
- package/lib/createServer-DjgKDpGV.js.map +1 -0
- package/lib/{hook-CfCFKZ-2.js → hook-Bo80UX00.js} +75 -74
- package/lib/hook-Bo80UX00.js.map +1 -0
- package/lib/{index-Dowg8c_k.js → index-D5m8_oyY.js} +612 -650
- package/lib/index-D5m8_oyY.js.map +1 -0
- package/lib/post-processors/traverse.js +2 -2
- package/lib/post-processors/traverse.js.map +1 -1
- package/lib/zudoku.auth-auth0.js +1 -1
- package/lib/zudoku.auth-clerk.js +2 -2
- package/lib/zudoku.auth-openid.js +283 -282
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +395 -397
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.hooks.js +1 -1
- package/lib/zudoku.plugin-api-catalog.js +2 -2
- package/lib/zudoku.plugin-api-keys.js +2 -2
- package/lib/zudoku.plugin-custom-pages.js +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +4 -5
- package/lib/zudoku.plugin-openapi.js.map +1 -1
- package/lib/zudoku.plugins.js.map +1 -1
- package/package.json +5 -5
- package/src/app/entry.server.tsx +7 -1
- package/src/lib/authentication/providers/openid.tsx +12 -9
- package/src/lib/components/AnchorLink.tsx +4 -2
- package/src/lib/components/Layout.tsx +3 -16
- package/src/lib/components/Zudoku.tsx +5 -1
- package/src/lib/components/cache.ts +8 -0
- package/src/lib/components/context/ViewportAnchorContext.tsx +3 -6
- package/src/lib/components/context/ZudokuContext.ts +5 -4
- package/src/lib/components/navigation/SidebarItem.tsx +3 -2
- package/src/lib/core/ZudokuContext.ts +11 -8
- package/src/lib/core/plugins.ts +4 -4
- package/src/lib/hooks/useEvent.test.tsx +1 -1
- package/src/lib/oas/graphql/index.ts +116 -76
- package/src/lib/plugins/openapi/OperationList.tsx +31 -37
- package/src/lib/plugins/openapi/OperationListItem.tsx +1 -1
- package/src/lib/plugins/openapi/Sidecar.tsx +2 -2
- package/src/lib/plugins/openapi/client/useCreateQuery.ts +2 -1
- package/src/lib/plugins/openapi/graphql/gql.ts +17 -17
- package/src/lib/plugins/openapi/graphql/graphql.ts +62 -79
- package/src/lib/plugins/openapi/index.tsx +40 -84
- package/src/lib/plugins/openapi/interfaces.ts +4 -1
- package/src/lib/plugins/openapi/util/createSidebarCategory.tsx +5 -7
- package/src/lib/util/traverse.ts +2 -2
- package/src/lib/util/useScrollToAnchor.ts +2 -0
- package/lib/Markdown-hBN9vkm5.js.map +0 -1
- package/lib/OperationList-C4rpJdcE.js.map +0 -1
- package/lib/circular-v7K6lDDh.js.map +0 -1
- package/lib/createServer-BEFAOb-x.js.map +0 -1
- package/lib/hook-CfCFKZ-2.js.map +0 -1
- package/lib/index-Dowg8c_k.js.map +0 -1
|
@@ -160,8 +160,10 @@ export type SchemaTagsArgs = {
|
|
|
160
160
|
export type SchemaTag = {
|
|
161
161
|
__typename?: "SchemaTag";
|
|
162
162
|
description?: Maybe<Scalars["String"]["output"]>;
|
|
163
|
-
|
|
163
|
+
extensions?: Maybe<Scalars["JSONObject"]["output"]>;
|
|
164
|
+
name?: Maybe<Scalars["String"]["output"]>;
|
|
164
165
|
operations: Array<OperationItem>;
|
|
166
|
+
slug?: Maybe<Scalars["String"]["output"]>;
|
|
165
167
|
};
|
|
166
168
|
|
|
167
169
|
export type SchemaType = "file" | "raw" | "url";
|
|
@@ -263,14 +265,24 @@ export type OperationsFragmentFragment = {
|
|
|
263
265
|
}>;
|
|
264
266
|
} & { " $fragmentName"?: "OperationsFragmentFragment" };
|
|
265
267
|
|
|
266
|
-
export type
|
|
268
|
+
export type SchemaWarmupQueryVariables = Exact<{
|
|
269
|
+
input: Scalars["JSON"]["input"];
|
|
270
|
+
type: SchemaType;
|
|
271
|
+
}>;
|
|
272
|
+
|
|
273
|
+
export type SchemaWarmupQuery = {
|
|
274
|
+
__typename?: "Query";
|
|
275
|
+
schema: { __typename?: "Schema"; openapi: string };
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export type OperationsForTagQueryVariables = Exact<{
|
|
267
279
|
input: Scalars["JSON"]["input"];
|
|
268
280
|
type: SchemaType;
|
|
269
281
|
tag?: InputMaybe<Scalars["String"]["input"]>;
|
|
270
282
|
untagged?: InputMaybe<Scalars["Boolean"]["input"]>;
|
|
271
283
|
}>;
|
|
272
284
|
|
|
273
|
-
export type
|
|
285
|
+
export type OperationsForTagQuery = {
|
|
274
286
|
__typename?: "Query";
|
|
275
287
|
schema: {
|
|
276
288
|
__typename?: "Schema";
|
|
@@ -282,7 +294,7 @@ export type AllOperationsQuery = {
|
|
|
282
294
|
servers: Array<{ __typename?: "Server"; url: string }>;
|
|
283
295
|
tags: Array<{
|
|
284
296
|
__typename?: "SchemaTag";
|
|
285
|
-
name
|
|
297
|
+
name?: string | null;
|
|
286
298
|
description?: string | null;
|
|
287
299
|
}>;
|
|
288
300
|
operations: Array<
|
|
@@ -309,48 +321,28 @@ export type GetServerQueryQuery = {
|
|
|
309
321
|
};
|
|
310
322
|
};
|
|
311
323
|
|
|
312
|
-
export type
|
|
313
|
-
input: Scalars["JSON"]["input"];
|
|
314
|
-
type: SchemaType;
|
|
315
|
-
}>;
|
|
316
|
-
|
|
317
|
-
export type GetCategoriesQuery = {
|
|
318
|
-
__typename?: "Query";
|
|
319
|
-
schema: {
|
|
320
|
-
__typename?: "Schema";
|
|
321
|
-
url?: string | null;
|
|
322
|
-
tags: Array<{ __typename?: "SchemaTag"; name: string }>;
|
|
323
|
-
};
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
export type GetOperationsQueryVariables = Exact<{
|
|
324
|
+
export type GetSidebarOperationsQueryVariables = Exact<{
|
|
327
325
|
input: Scalars["JSON"]["input"];
|
|
328
326
|
type: SchemaType;
|
|
329
|
-
tag?: InputMaybe<Scalars["String"]["input"]>;
|
|
330
327
|
}>;
|
|
331
328
|
|
|
332
|
-
export type
|
|
329
|
+
export type GetSidebarOperationsQuery = {
|
|
333
330
|
__typename?: "Query";
|
|
334
331
|
schema: {
|
|
335
332
|
__typename?: "Schema";
|
|
336
|
-
|
|
337
|
-
__typename?: "
|
|
338
|
-
slug
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
deprecated?: boolean | null;
|
|
350
|
-
method: string;
|
|
351
|
-
summary?: string | null;
|
|
352
|
-
operationId?: string | null;
|
|
353
|
-
path: string;
|
|
333
|
+
tags: Array<{
|
|
334
|
+
__typename?: "SchemaTag";
|
|
335
|
+
slug?: string | null;
|
|
336
|
+
name?: string | null;
|
|
337
|
+
extensions?: any | null;
|
|
338
|
+
operations: Array<{
|
|
339
|
+
__typename?: "OperationItem";
|
|
340
|
+
summary?: string | null;
|
|
341
|
+
slug: string;
|
|
342
|
+
method: string;
|
|
343
|
+
operationId?: string | null;
|
|
344
|
+
path: string;
|
|
345
|
+
}>;
|
|
354
346
|
}>;
|
|
355
347
|
};
|
|
356
348
|
};
|
|
@@ -360,12 +352,13 @@ export class TypedDocumentString<TResult, TVariables>
|
|
|
360
352
|
implements DocumentTypeDecoration<TResult, TVariables>
|
|
361
353
|
{
|
|
362
354
|
__apiType?: DocumentTypeDecoration<TResult, TVariables>["__apiType"];
|
|
355
|
+
private value: string;
|
|
356
|
+
public __meta__?: Record<string, any> | undefined;
|
|
363
357
|
|
|
364
|
-
constructor(
|
|
365
|
-
private value: string,
|
|
366
|
-
public __meta__?: Record<string, any> | undefined,
|
|
367
|
-
) {
|
|
358
|
+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
|
|
368
359
|
super(value);
|
|
360
|
+
this.value = value;
|
|
361
|
+
this.__meta__ = __meta__;
|
|
369
362
|
}
|
|
370
363
|
|
|
371
364
|
toString(): string & DocumentTypeDecoration<TResult, TVariables> {
|
|
@@ -454,8 +447,18 @@ export const ServersQueryDocument = new TypedDocumentString(`
|
|
|
454
447
|
ServersQueryQuery,
|
|
455
448
|
ServersQueryQueryVariables
|
|
456
449
|
>;
|
|
457
|
-
export const
|
|
458
|
-
query
|
|
450
|
+
export const SchemaWarmupDocument = new TypedDocumentString(`
|
|
451
|
+
query SchemaWarmup($input: JSON!, $type: SchemaType!) {
|
|
452
|
+
schema(input: $input, type: $type) {
|
|
453
|
+
openapi
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
`) as unknown as TypedDocumentString<
|
|
457
|
+
SchemaWarmupQuery,
|
|
458
|
+
SchemaWarmupQueryVariables
|
|
459
|
+
>;
|
|
460
|
+
export const OperationsForTagDocument = new TypedDocumentString(`
|
|
461
|
+
query OperationsForTag($input: JSON!, $type: SchemaType!, $tag: String, $untagged: Boolean) {
|
|
459
462
|
schema(input: $input, type: $type) {
|
|
460
463
|
servers {
|
|
461
464
|
url
|
|
@@ -539,8 +542,8 @@ export const AllOperationsDocument = new TypedDocumentString(`
|
|
|
539
542
|
}
|
|
540
543
|
}
|
|
541
544
|
}`) as unknown as TypedDocumentString<
|
|
542
|
-
|
|
543
|
-
|
|
545
|
+
OperationsForTagQuery,
|
|
546
|
+
OperationsForTagQueryVariables
|
|
544
547
|
>;
|
|
545
548
|
export const GetServerQueryDocument = new TypedDocumentString(`
|
|
546
549
|
query getServerQuery($input: JSON!, $type: SchemaType!) {
|
|
@@ -555,44 +558,24 @@ export const GetServerQueryDocument = new TypedDocumentString(`
|
|
|
555
558
|
GetServerQueryQuery,
|
|
556
559
|
GetServerQueryQueryVariables
|
|
557
560
|
>;
|
|
558
|
-
export const
|
|
559
|
-
query
|
|
561
|
+
export const GetSidebarOperationsDocument = new TypedDocumentString(`
|
|
562
|
+
query GetSidebarOperations($input: JSON!, $type: SchemaType!) {
|
|
560
563
|
schema(input: $input, type: $type) {
|
|
561
|
-
url
|
|
562
564
|
tags {
|
|
563
|
-
name
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
`) as unknown as TypedDocumentString<
|
|
568
|
-
GetCategoriesQuery,
|
|
569
|
-
GetCategoriesQueryVariables
|
|
570
|
-
>;
|
|
571
|
-
export const GetOperationsDocument = new TypedDocumentString(`
|
|
572
|
-
query GetOperations($input: JSON!, $type: SchemaType!, $tag: String) {
|
|
573
|
-
schema(input: $input, type: $type) {
|
|
574
|
-
operations(tag: $tag) {
|
|
575
565
|
slug
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
566
|
+
name
|
|
567
|
+
extensions
|
|
568
|
+
operations {
|
|
569
|
+
summary
|
|
570
|
+
slug
|
|
571
|
+
method
|
|
572
|
+
operationId
|
|
573
|
+
path
|
|
583
574
|
}
|
|
584
575
|
}
|
|
585
|
-
untagged: operations(untagged: true) {
|
|
586
|
-
slug
|
|
587
|
-
deprecated
|
|
588
|
-
method
|
|
589
|
-
summary
|
|
590
|
-
operationId
|
|
591
|
-
path
|
|
592
|
-
}
|
|
593
576
|
}
|
|
594
577
|
}
|
|
595
578
|
`) as unknown as TypedDocumentString<
|
|
596
|
-
|
|
597
|
-
|
|
579
|
+
GetSidebarOperationsQuery,
|
|
580
|
+
GetSidebarOperationsQueryVariables
|
|
598
581
|
>;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type { ResultOf } from "@graphql-typed-document-node/core";
|
|
2
|
-
import slugify from "@sindresorhus/slugify";
|
|
3
1
|
import { CirclePlayIcon, LogInIcon } from "lucide-react";
|
|
4
2
|
import { type ReactNode } from "react";
|
|
5
3
|
import { matchPath } from "react-router";
|
|
6
4
|
import { useAuth } from "../../authentication/hook.js";
|
|
7
5
|
import { type ZudokuPlugin } from "../../core/plugins.js";
|
|
8
|
-
import type { SchemaImports } from "../../oas/graphql/index.js";
|
|
9
6
|
import { Button } from "../../ui/Button.js";
|
|
10
7
|
import { joinUrl } from "../../util/joinUrl.js";
|
|
11
8
|
import { GraphQLClient } from "./client/GraphQLClient.js";
|
|
9
|
+
import type { GetSidebarOperationsQuery } from "./graphql/graphql.js";
|
|
12
10
|
import { graphql } from "./graphql/index.js";
|
|
13
11
|
import { type OasPluginConfig } from "./interfaces.js";
|
|
14
12
|
import type { PlaygroundContentProps } from "./playground/Playground.js";
|
|
@@ -16,54 +14,33 @@ import { PlaygroundDialog } from "./playground/PlaygroundDialog.js";
|
|
|
16
14
|
import { createSidebarCategory } from "./util/createSidebarCategory.js";
|
|
17
15
|
import { getRoutes, getVersions } from "./util/getRoutes.js";
|
|
18
16
|
|
|
19
|
-
const
|
|
20
|
-
query
|
|
17
|
+
const GetSidebarOperationsQuery = graphql(`
|
|
18
|
+
query GetSidebarOperations($input: JSON!, $type: SchemaType!) {
|
|
21
19
|
schema(input: $input, type: $type) {
|
|
22
|
-
url
|
|
23
20
|
tags {
|
|
24
|
-
name
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
`);
|
|
29
|
-
|
|
30
|
-
const GetOperationsQuery = graphql(`
|
|
31
|
-
query GetOperations($input: JSON!, $type: SchemaType!, $tag: String) {
|
|
32
|
-
schema(input: $input, type: $type) {
|
|
33
|
-
operations(tag: $tag) {
|
|
34
21
|
slug
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
name
|
|
23
|
+
extensions
|
|
24
|
+
operations {
|
|
25
|
+
summary
|
|
26
|
+
slug
|
|
27
|
+
method
|
|
28
|
+
operationId
|
|
29
|
+
path
|
|
42
30
|
}
|
|
43
31
|
}
|
|
44
|
-
untagged: operations(untagged: true) {
|
|
45
|
-
slug
|
|
46
|
-
deprecated
|
|
47
|
-
method
|
|
48
|
-
summary
|
|
49
|
-
operationId
|
|
50
|
-
path
|
|
51
|
-
}
|
|
52
32
|
}
|
|
53
33
|
}
|
|
54
34
|
`);
|
|
55
35
|
|
|
56
|
-
export type OperationResult =
|
|
57
|
-
|
|
58
|
-
>["schema"]["operations"][number];
|
|
59
|
-
|
|
60
|
-
type InternalOasPluginConfig = { schemaImports?: SchemaImports };
|
|
36
|
+
export type OperationResult =
|
|
37
|
+
GetSidebarOperationsQuery["schema"]["tags"][number]["operations"][number];
|
|
61
38
|
|
|
62
|
-
export type OpenApiPluginOptions = OasPluginConfig
|
|
39
|
+
export type OpenApiPluginOptions = OasPluginConfig;
|
|
63
40
|
|
|
64
41
|
export const UNTAGGED_PATH = "~endpoints";
|
|
65
42
|
|
|
66
|
-
export const openApiPlugin = (config:
|
|
43
|
+
export const openApiPlugin = (config: OasPluginConfig): ZudokuPlugin => {
|
|
67
44
|
const basePath = joinUrl(config.navigationId ?? "/reference");
|
|
68
45
|
const client = new GraphQLClient(config);
|
|
69
46
|
|
|
@@ -134,7 +111,7 @@ export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
|
|
|
134
111
|
);
|
|
135
112
|
},
|
|
136
113
|
}),
|
|
137
|
-
getSidebar: async (path
|
|
114
|
+
getSidebar: async (path, context) => {
|
|
138
115
|
if (!matchPath({ path: basePath, end: false }, path)) {
|
|
139
116
|
return [];
|
|
140
117
|
}
|
|
@@ -147,67 +124,46 @@ export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
|
|
|
147
124
|
try {
|
|
148
125
|
const versionParam = match?.params.version;
|
|
149
126
|
const version = versionParam ?? getVersions(config).at(0);
|
|
150
|
-
const { type
|
|
127
|
+
const { type } = config;
|
|
151
128
|
const input = type === "file" ? config.input[version!] : config.input;
|
|
152
129
|
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
(tag) => slugify(tag) === match?.params.tag,
|
|
159
|
-
);
|
|
130
|
+
const data = await context.queryClient.ensureQueryData({
|
|
131
|
+
queryKey: ["sidebar-operations-query", input],
|
|
132
|
+
queryFn: () =>
|
|
133
|
+
client.fetch(GetSidebarOperationsQuery, { type, input }),
|
|
134
|
+
});
|
|
160
135
|
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
client.fetch(GetOperationsQuery, {
|
|
164
|
-
type,
|
|
165
|
-
input,
|
|
166
|
-
tag: !options?.loadTags ? tagName : undefined,
|
|
167
|
-
}),
|
|
168
|
-
]);
|
|
169
|
-
|
|
170
|
-
const categories = tagData.schema.tags.flatMap((tag) => {
|
|
171
|
-
const categoryPath = joinUrl(
|
|
172
|
-
basePath,
|
|
173
|
-
versionParam,
|
|
174
|
-
slugify(tag.name),
|
|
175
|
-
);
|
|
136
|
+
const categories = data.schema.tags.flatMap((tag) => {
|
|
137
|
+
if (!tag.name || tag.operations.length === 0) return [];
|
|
176
138
|
|
|
177
|
-
const
|
|
178
|
-
(operation) =>
|
|
179
|
-
operation.tags?.length !== 0 &&
|
|
180
|
-
operation.tags?.map((t) => t.name).includes(tag.name),
|
|
181
|
-
);
|
|
139
|
+
const categoryPath = joinUrl(basePath, versionParam, tag.slug);
|
|
182
140
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
141
|
+
const isCollapsed =
|
|
142
|
+
tag.extensions?.["x-zudoku-collapsed"] ??
|
|
143
|
+
!config.options?.expandAllTags;
|
|
144
|
+
const isCollapsible =
|
|
145
|
+
tag.extensions?.["x-zudoku-collapsible"] ?? true;
|
|
187
146
|
|
|
188
147
|
return createSidebarCategory({
|
|
189
148
|
label: tag.name,
|
|
190
149
|
path: categoryPath,
|
|
191
|
-
operations:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
: [],
|
|
195
|
-
collapsible,
|
|
196
|
-
collapsed,
|
|
150
|
+
operations: tag.operations,
|
|
151
|
+
collapsed: isCollapsed,
|
|
152
|
+
collapsible: isCollapsible,
|
|
197
153
|
});
|
|
198
154
|
});
|
|
199
155
|
|
|
200
|
-
|
|
156
|
+
const untaggedOperations = data.schema.tags.find(
|
|
157
|
+
(tag) => !tag.name,
|
|
158
|
+
)?.operations;
|
|
159
|
+
|
|
160
|
+
if (untaggedOperations) {
|
|
201
161
|
categories.push(
|
|
202
162
|
createSidebarCategory({
|
|
203
163
|
label: "Other endpoints",
|
|
204
164
|
path: joinUrl(basePath, versionParam, UNTAGGED_PATH),
|
|
205
|
-
operations:
|
|
206
|
-
|
|
207
|
-
? operationsData.schema.untagged
|
|
208
|
-
: [],
|
|
209
|
-
collapsible,
|
|
210
|
-
collapsed,
|
|
165
|
+
operations: untaggedOperations,
|
|
166
|
+
collapsed: !config.options?.expandAllTags,
|
|
211
167
|
}),
|
|
212
168
|
);
|
|
213
169
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SchemaImports } from "../../oas/graphql/index.js";
|
|
2
|
+
|
|
1
3
|
type DynamicInput = () => Promise<unknown>;
|
|
2
4
|
|
|
3
5
|
type OasSource =
|
|
@@ -15,11 +17,12 @@ type BaseOasConfig = {
|
|
|
15
17
|
navigationId?: string;
|
|
16
18
|
skipPreload?: boolean;
|
|
17
19
|
tagPages?: Array<string>;
|
|
20
|
+
schemaImports?: SchemaImports;
|
|
18
21
|
options?: {
|
|
19
22
|
examplesLanguage?: string;
|
|
20
23
|
disablePlayground?: boolean;
|
|
21
|
-
loadTags?: boolean;
|
|
22
24
|
showVersionSelect?: "always" | "if-available" | "hide";
|
|
25
|
+
expandAllTags?: boolean;
|
|
23
26
|
};
|
|
24
27
|
};
|
|
25
28
|
|
|
@@ -28,12 +28,10 @@ export const createSidebarCategory = ({
|
|
|
28
28
|
type: "link" as const,
|
|
29
29
|
label: operation.summary ?? operation.path,
|
|
30
30
|
href: `${path}#${operation.slug}`,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} as const,
|
|
37
|
-
}),
|
|
31
|
+
badge: {
|
|
32
|
+
label: operation.method,
|
|
33
|
+
color: MethodColorMap[operation.method.toLowerCase()]!,
|
|
34
|
+
invert: true,
|
|
35
|
+
},
|
|
38
36
|
})),
|
|
39
37
|
});
|
package/src/lib/util/traverse.ts
CHANGED
|
@@ -20,11 +20,11 @@ export const traverse = <T extends JsonValue = RecordAny>(
|
|
|
20
20
|
for (const [key, value] of Object.entries(transformed)) {
|
|
21
21
|
if (Array.isArray(value)) {
|
|
22
22
|
result[key] = value.map((item) =>
|
|
23
|
-
typeof item === "object" && item
|
|
23
|
+
typeof item === "object" && item != null
|
|
24
24
|
? traverse(item, transform)
|
|
25
25
|
: item,
|
|
26
26
|
);
|
|
27
|
-
} else if (typeof value === "object" && value
|
|
27
|
+
} else if (typeof value === "object" && value != null) {
|
|
28
28
|
result[key] = traverse(value, transform);
|
|
29
29
|
} else {
|
|
30
30
|
result[key] = value;
|
|
@@ -23,6 +23,8 @@ export const useScrollToHash = () => {
|
|
|
23
23
|
if (element) {
|
|
24
24
|
element.scrollIntoView();
|
|
25
25
|
scrollIntoViewIfNeeded(link);
|
|
26
|
+
// Set the active anchor after the scroll has happened
|
|
27
|
+
// so the intersection observer doesn't trigger wrong items
|
|
26
28
|
requestIdleCallback(() => setActiveAnchor(linkHash));
|
|
27
29
|
return true;
|
|
28
30
|
}
|