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.
Files changed (131) hide show
  1. package/dist/app/entry.server.js +5 -1
  2. package/dist/app/entry.server.js.map +1 -1
  3. package/dist/config/validators/common.d.ts +176 -176
  4. package/dist/config/validators/common.js +8 -6
  5. package/dist/config/validators/common.js.map +1 -1
  6. package/dist/config/validators/validate.d.ts +63 -63
  7. package/dist/lib/authentication/providers/openid.js +11 -7
  8. package/dist/lib/authentication/providers/openid.js.map +1 -1
  9. package/dist/lib/components/AnchorLink.js +3 -2
  10. package/dist/lib/components/AnchorLink.js.map +1 -1
  11. package/dist/lib/components/Layout.js +3 -14
  12. package/dist/lib/components/Layout.js.map +1 -1
  13. package/dist/lib/components/Zudoku.js +3 -1
  14. package/dist/lib/components/Zudoku.js.map +1 -1
  15. package/dist/lib/components/cache.d.ts +7 -0
  16. package/dist/lib/components/cache.js +7 -0
  17. package/dist/lib/components/cache.js.map +1 -1
  18. package/dist/lib/components/context/ViewportAnchorContext.js +3 -6
  19. package/dist/lib/components/context/ViewportAnchorContext.js.map +1 -1
  20. package/dist/lib/components/context/ZudokuContext.d.ts +1 -1
  21. package/dist/lib/components/context/ZudokuContext.js +4 -3
  22. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  23. package/dist/lib/components/navigation/SidebarItem.js +3 -2
  24. package/dist/lib/components/navigation/SidebarItem.js.map +1 -1
  25. package/dist/lib/core/ZudokuContext.d.ts +8 -6
  26. package/dist/lib/core/ZudokuContext.js +4 -2
  27. package/dist/lib/core/ZudokuContext.js.map +1 -1
  28. package/dist/lib/core/plugins.d.ts +3 -3
  29. package/dist/lib/hooks/useEvent.test.js +1 -1
  30. package/dist/lib/hooks/useEvent.test.js.map +1 -1
  31. package/dist/lib/oas/graphql/index.d.ts +16 -4
  32. package/dist/lib/oas/graphql/index.js +59 -43
  33. package/dist/lib/oas/graphql/index.js.map +1 -1
  34. package/dist/lib/plugins/openapi/OperationList.js +19 -5
  35. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  36. package/dist/lib/plugins/openapi/OperationListItem.js +1 -1
  37. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  38. package/dist/lib/plugins/openapi/Sidecar.js +2 -2
  39. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  40. package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +1 -1
  41. package/dist/lib/plugins/openapi/client/useCreateQuery.js +2 -1
  42. package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -1
  43. package/dist/lib/plugins/openapi/graphql/gql.d.ts +4 -4
  44. package/dist/lib/plugins/openapi/graphql/gql.js +3 -3
  45. package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
  46. package/dist/lib/plugins/openapi/graphql/graphql.d.ts +34 -45
  47. package/dist/lib/plugins/openapi/graphql/graphql.js +20 -30
  48. package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
  49. package/dist/lib/plugins/openapi/index.d.ts +5 -10
  50. package/dist/lib/plugins/openapi/index.js +29 -60
  51. package/dist/lib/plugins/openapi/index.js.map +1 -1
  52. package/dist/lib/plugins/openapi/interfaces.d.ts +3 -1
  53. package/dist/lib/plugins/openapi/util/createSidebarCategory.js +5 -7
  54. package/dist/lib/plugins/openapi/util/createSidebarCategory.js.map +1 -1
  55. package/dist/lib/util/traverse.js +2 -2
  56. package/dist/lib/util/traverse.js.map +1 -1
  57. package/dist/lib/util/useScrollToAnchor.js +2 -0
  58. package/dist/lib/util/useScrollToAnchor.js.map +1 -1
  59. package/dist/vite/api/schema-codegen.js +19 -4
  60. package/dist/vite/api/schema-codegen.js.map +1 -1
  61. package/dist/vite/api/schema-codegen.test.js +61 -0
  62. package/dist/vite/api/schema-codegen.test.js.map +1 -1
  63. package/dist/vite/plugin-api.js +3 -11
  64. package/dist/vite/plugin-api.js.map +1 -1
  65. package/lib/{AuthenticationPlugin-4ip08maU.js → AuthenticationPlugin-Cr6xjOJD.js} +2 -2
  66. package/lib/{AuthenticationPlugin-4ip08maU.js.map → AuthenticationPlugin-Cr6xjOJD.js.map} +1 -1
  67. package/lib/{Markdown-hBN9vkm5.js → Markdown-BlioIqkZ.js} +313 -311
  68. package/lib/Markdown-BlioIqkZ.js.map +1 -0
  69. package/lib/{MdxPage-UCWwxhzC.js → MdxPage-7XnN9J9R.js} +3 -3
  70. package/lib/{MdxPage-UCWwxhzC.js.map → MdxPage-7XnN9J9R.js.map} +1 -1
  71. package/lib/{OasProvider-CJ8KOnsH.js → OasProvider-BaRRMSsD.js} +3 -3
  72. package/lib/{OasProvider-CJ8KOnsH.js.map → OasProvider-BaRRMSsD.js.map} +1 -1
  73. package/lib/{OperationList-C4rpJdcE.js → OperationList-BjL1hzSx.js} +988 -961
  74. package/lib/OperationList-BjL1hzSx.js.map +1 -0
  75. package/lib/{SlotletProvider-D-XPr1Wg.js → SlotletProvider-CXb3wQiR.js} +2 -2
  76. package/lib/{SlotletProvider-D-XPr1Wg.js.map → SlotletProvider-CXb3wQiR.js.map} +1 -1
  77. package/lib/{circular-v7K6lDDh.js → circular-ByJI6Mci.js} +4887 -4419
  78. package/lib/circular-ByJI6Mci.js.map +1 -0
  79. package/lib/{createServer-BEFAOb-x.js → createServer-DjgKDpGV.js} +3887 -4291
  80. package/lib/createServer-DjgKDpGV.js.map +1 -0
  81. package/lib/{hook-CfCFKZ-2.js → hook-Bo80UX00.js} +75 -74
  82. package/lib/hook-Bo80UX00.js.map +1 -0
  83. package/lib/{index-Dowg8c_k.js → index-D5m8_oyY.js} +612 -650
  84. package/lib/index-D5m8_oyY.js.map +1 -0
  85. package/lib/post-processors/traverse.js +2 -2
  86. package/lib/post-processors/traverse.js.map +1 -1
  87. package/lib/zudoku.auth-auth0.js +1 -1
  88. package/lib/zudoku.auth-clerk.js +2 -2
  89. package/lib/zudoku.auth-openid.js +283 -282
  90. package/lib/zudoku.auth-openid.js.map +1 -1
  91. package/lib/zudoku.components.js +395 -397
  92. package/lib/zudoku.components.js.map +1 -1
  93. package/lib/zudoku.hooks.js +1 -1
  94. package/lib/zudoku.plugin-api-catalog.js +2 -2
  95. package/lib/zudoku.plugin-api-keys.js +2 -2
  96. package/lib/zudoku.plugin-custom-pages.js +1 -1
  97. package/lib/zudoku.plugin-markdown.js +1 -1
  98. package/lib/zudoku.plugin-openapi.js +4 -5
  99. package/lib/zudoku.plugin-openapi.js.map +1 -1
  100. package/lib/zudoku.plugins.js.map +1 -1
  101. package/package.json +5 -5
  102. package/src/app/entry.server.tsx +7 -1
  103. package/src/lib/authentication/providers/openid.tsx +12 -9
  104. package/src/lib/components/AnchorLink.tsx +4 -2
  105. package/src/lib/components/Layout.tsx +3 -16
  106. package/src/lib/components/Zudoku.tsx +5 -1
  107. package/src/lib/components/cache.ts +8 -0
  108. package/src/lib/components/context/ViewportAnchorContext.tsx +3 -6
  109. package/src/lib/components/context/ZudokuContext.ts +5 -4
  110. package/src/lib/components/navigation/SidebarItem.tsx +3 -2
  111. package/src/lib/core/ZudokuContext.ts +11 -8
  112. package/src/lib/core/plugins.ts +4 -4
  113. package/src/lib/hooks/useEvent.test.tsx +1 -1
  114. package/src/lib/oas/graphql/index.ts +116 -76
  115. package/src/lib/plugins/openapi/OperationList.tsx +31 -37
  116. package/src/lib/plugins/openapi/OperationListItem.tsx +1 -1
  117. package/src/lib/plugins/openapi/Sidecar.tsx +2 -2
  118. package/src/lib/plugins/openapi/client/useCreateQuery.ts +2 -1
  119. package/src/lib/plugins/openapi/graphql/gql.ts +17 -17
  120. package/src/lib/plugins/openapi/graphql/graphql.ts +62 -79
  121. package/src/lib/plugins/openapi/index.tsx +40 -84
  122. package/src/lib/plugins/openapi/interfaces.ts +4 -1
  123. package/src/lib/plugins/openapi/util/createSidebarCategory.tsx +5 -7
  124. package/src/lib/util/traverse.ts +2 -2
  125. package/src/lib/util/useScrollToAnchor.ts +2 -0
  126. package/lib/Markdown-hBN9vkm5.js.map +0 -1
  127. package/lib/OperationList-C4rpJdcE.js.map +0 -1
  128. package/lib/circular-v7K6lDDh.js.map +0 -1
  129. package/lib/createServer-BEFAOb-x.js.map +0 -1
  130. package/lib/hook-CfCFKZ-2.js.map +0 -1
  131. 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
- name: Scalars["String"]["output"];
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 AllOperationsQueryVariables = Exact<{
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 AllOperationsQuery = {
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: string;
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 GetCategoriesQueryVariables = Exact<{
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 GetOperationsQuery = {
329
+ export type GetSidebarOperationsQuery = {
333
330
  __typename?: "Query";
334
331
  schema: {
335
332
  __typename?: "Schema";
336
- operations: Array<{
337
- __typename?: "OperationItem";
338
- slug: string;
339
- deprecated?: boolean | null;
340
- method: string;
341
- summary?: string | null;
342
- operationId?: string | null;
343
- path: string;
344
- tags?: Array<{ __typename?: "TagItem"; name: string }> | null;
345
- }>;
346
- untagged: Array<{
347
- __typename?: "OperationItem";
348
- slug: string;
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 AllOperationsDocument = new TypedDocumentString(`
458
- query AllOperations($input: JSON!, $type: SchemaType!, $tag: String, $untagged: Boolean) {
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
- AllOperationsQuery,
543
- AllOperationsQueryVariables
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 GetCategoriesDocument = new TypedDocumentString(`
559
- query GetCategories($input: JSON!, $type: SchemaType!) {
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
- deprecated
577
- method
578
- summary
579
- operationId
580
- path
581
- tags {
582
- name
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
- GetOperationsQuery,
597
- GetOperationsQueryVariables
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 GetCategoriesQuery = graphql(`
20
- query GetCategories($input: JSON!, $type: SchemaType!) {
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
- deprecated
36
- method
37
- summary
38
- operationId
39
- path
40
- tags {
41
- name
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 = ResultOf<
57
- typeof GetOperationsQuery
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 & InternalOasPluginConfig;
39
+ export type OpenApiPluginOptions = OasPluginConfig;
63
40
 
64
41
  export const UNTAGGED_PATH = "~endpoints";
65
42
 
66
- export const openApiPlugin = (config: OpenApiPluginOptions): ZudokuPlugin => {
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: string) => {
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, options } = config;
127
+ const { type } = config;
151
128
  const input = type === "file" ? config.input[version!] : config.input;
152
129
 
153
- const collapsible = options?.loadTags === true || config.type === "url";
154
- const collapsed = !options?.loadTags && config.type !== "url";
155
-
156
- // find tag name by slug in config.tagPages
157
- const tagName = config.tagPages?.find(
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 [tagData, operationsData] = await Promise.all([
162
- client.fetch(GetCategoriesQuery, { type, input }),
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 operations = operationsData.schema.operations.filter(
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
- // skip empty categories
184
- if (options?.loadTags && operations.length === 0) {
185
- return [];
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
- match?.params.tag !== UNTAGGED_PATH || options?.loadTags
193
- ? operations
194
- : [],
195
- collapsible,
196
- collapsed,
150
+ operations: tag.operations,
151
+ collapsed: isCollapsed,
152
+ collapsible: isCollapsible,
197
153
  });
198
154
  });
199
155
 
200
- if (operationsData.schema.untagged.length > 0) {
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
- match?.params.tag === UNTAGGED_PATH || options?.loadTags
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
- ...(operation.method && {
32
- badge: {
33
- label: operation.method,
34
- color: MethodColorMap[operation.method.toLowerCase()]!,
35
- invert: true,
36
- } as const,
37
- }),
31
+ badge: {
32
+ label: operation.method,
33
+ color: MethodColorMap[operation.method.toLowerCase()]!,
34
+ invert: true,
35
+ },
38
36
  })),
39
37
  });
@@ -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 !== null
23
+ typeof item === "object" && item != null
24
24
  ? traverse(item, transform)
25
25
  : item,
26
26
  );
27
- } else if (typeof value === "object" && value !== null) {
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
  }