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
|
@@ -169,8 +169,10 @@ export type SchemaTagsArgs = {
|
|
|
169
169
|
export type SchemaTag = {
|
|
170
170
|
__typename?: "SchemaTag";
|
|
171
171
|
description?: Maybe<Scalars["String"]["output"]>;
|
|
172
|
-
|
|
172
|
+
extensions?: Maybe<Scalars["JSONObject"]["output"]>;
|
|
173
|
+
name?: Maybe<Scalars["String"]["output"]>;
|
|
173
174
|
operations: Array<OperationItem>;
|
|
175
|
+
slug?: Maybe<Scalars["String"]["output"]>;
|
|
174
176
|
};
|
|
175
177
|
export type SchemaType = "file" | "raw" | "url";
|
|
176
178
|
export type Server = {
|
|
@@ -276,13 +278,24 @@ export type OperationsFragmentFragment = {
|
|
|
276
278
|
} & {
|
|
277
279
|
" $fragmentName"?: "OperationsFragmentFragment";
|
|
278
280
|
};
|
|
279
|
-
export type
|
|
281
|
+
export type SchemaWarmupQueryVariables = Exact<{
|
|
282
|
+
input: Scalars["JSON"]["input"];
|
|
283
|
+
type: SchemaType;
|
|
284
|
+
}>;
|
|
285
|
+
export type SchemaWarmupQuery = {
|
|
286
|
+
__typename?: "Query";
|
|
287
|
+
schema: {
|
|
288
|
+
__typename?: "Schema";
|
|
289
|
+
openapi: string;
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
export type OperationsForTagQueryVariables = Exact<{
|
|
280
293
|
input: Scalars["JSON"]["input"];
|
|
281
294
|
type: SchemaType;
|
|
282
295
|
tag?: InputMaybe<Scalars["String"]["input"]>;
|
|
283
296
|
untagged?: InputMaybe<Scalars["Boolean"]["input"]>;
|
|
284
297
|
}>;
|
|
285
|
-
export type
|
|
298
|
+
export type OperationsForTagQuery = {
|
|
286
299
|
__typename?: "Query";
|
|
287
300
|
schema: {
|
|
288
301
|
__typename?: "Schema";
|
|
@@ -297,7 +310,7 @@ export type AllOperationsQuery = {
|
|
|
297
310
|
}>;
|
|
298
311
|
tags: Array<{
|
|
299
312
|
__typename?: "SchemaTag";
|
|
300
|
-
name
|
|
313
|
+
name?: string | null;
|
|
301
314
|
description?: string | null;
|
|
302
315
|
}>;
|
|
303
316
|
operations: Array<{
|
|
@@ -325,64 +338,40 @@ export type GetServerQueryQuery = {
|
|
|
325
338
|
}>;
|
|
326
339
|
};
|
|
327
340
|
};
|
|
328
|
-
export type
|
|
341
|
+
export type GetSidebarOperationsQueryVariables = Exact<{
|
|
329
342
|
input: Scalars["JSON"]["input"];
|
|
330
343
|
type: SchemaType;
|
|
331
344
|
}>;
|
|
332
|
-
export type
|
|
345
|
+
export type GetSidebarOperationsQuery = {
|
|
333
346
|
__typename?: "Query";
|
|
334
347
|
schema: {
|
|
335
348
|
__typename?: "Schema";
|
|
336
|
-
url?: string | null;
|
|
337
349
|
tags: Array<{
|
|
338
350
|
__typename?: "SchemaTag";
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
schema: {
|
|
351
|
-
__typename?: "Schema";
|
|
352
|
-
operations: Array<{
|
|
353
|
-
__typename?: "OperationItem";
|
|
354
|
-
slug: string;
|
|
355
|
-
deprecated?: boolean | null;
|
|
356
|
-
method: string;
|
|
357
|
-
summary?: string | null;
|
|
358
|
-
operationId?: string | null;
|
|
359
|
-
path: string;
|
|
360
|
-
tags?: Array<{
|
|
361
|
-
__typename?: "TagItem";
|
|
362
|
-
name: string;
|
|
363
|
-
}> | null;
|
|
364
|
-
}>;
|
|
365
|
-
untagged: Array<{
|
|
366
|
-
__typename?: "OperationItem";
|
|
367
|
-
slug: string;
|
|
368
|
-
deprecated?: boolean | null;
|
|
369
|
-
method: string;
|
|
370
|
-
summary?: string | null;
|
|
371
|
-
operationId?: string | null;
|
|
372
|
-
path: string;
|
|
351
|
+
slug?: string | null;
|
|
352
|
+
name?: string | null;
|
|
353
|
+
extensions?: any | null;
|
|
354
|
+
operations: Array<{
|
|
355
|
+
__typename?: "OperationItem";
|
|
356
|
+
summary?: string | null;
|
|
357
|
+
slug: string;
|
|
358
|
+
method: string;
|
|
359
|
+
operationId?: string | null;
|
|
360
|
+
path: string;
|
|
361
|
+
}>;
|
|
373
362
|
}>;
|
|
374
363
|
};
|
|
375
364
|
};
|
|
376
365
|
export declare class TypedDocumentString<TResult, TVariables> extends String implements DocumentTypeDecoration<TResult, TVariables> {
|
|
366
|
+
__apiType?: DocumentTypeDecoration<TResult, TVariables>["__apiType"];
|
|
377
367
|
private value;
|
|
378
368
|
__meta__?: Record<string, any> | undefined;
|
|
379
|
-
__apiType?: DocumentTypeDecoration<TResult, TVariables>["__apiType"];
|
|
380
369
|
constructor(value: string, __meta__?: Record<string, any> | undefined);
|
|
381
370
|
toString(): string & DocumentTypeDecoration<TResult, TVariables>;
|
|
382
371
|
}
|
|
383
372
|
export declare const OperationsFragmentFragmentDoc: TypedDocumentString<OperationsFragmentFragment, unknown>;
|
|
384
373
|
export declare const ServersQueryDocument: TypedDocumentString<ServersQueryQuery, ServersQueryQueryVariables>;
|
|
385
|
-
export declare const
|
|
374
|
+
export declare const SchemaWarmupDocument: TypedDocumentString<SchemaWarmupQuery, SchemaWarmupQueryVariables>;
|
|
375
|
+
export declare const OperationsForTagDocument: TypedDocumentString<OperationsForTagQuery, OperationsForTagQueryVariables>;
|
|
386
376
|
export declare const GetServerQueryDocument: TypedDocumentString<GetServerQueryQuery, GetServerQueryQueryVariables>;
|
|
387
|
-
export declare const
|
|
388
|
-
export declare const GetOperationsDocument: TypedDocumentString<GetOperationsQuery, GetOperationsQueryVariables>;
|
|
377
|
+
export declare const GetSidebarOperationsDocument: TypedDocumentString<GetSidebarOperationsQuery, GetSidebarOperationsQueryVariables>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export class TypedDocumentString extends String {
|
|
2
|
+
__apiType;
|
|
2
3
|
value;
|
|
3
4
|
__meta__;
|
|
4
|
-
__apiType;
|
|
5
5
|
constructor(value, __meta__) {
|
|
6
6
|
super(value);
|
|
7
7
|
this.value = value;
|
|
@@ -87,8 +87,15 @@ export const ServersQueryDocument = new TypedDocumentString(`
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
`);
|
|
90
|
-
export const
|
|
91
|
-
query
|
|
90
|
+
export const SchemaWarmupDocument = new TypedDocumentString(`
|
|
91
|
+
query SchemaWarmup($input: JSON!, $type: SchemaType!) {
|
|
92
|
+
schema(input: $input, type: $type) {
|
|
93
|
+
openapi
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`);
|
|
97
|
+
export const OperationsForTagDocument = new TypedDocumentString(`
|
|
98
|
+
query OperationsForTag($input: JSON!, $type: SchemaType!, $tag: String, $untagged: Boolean) {
|
|
92
99
|
schema(input: $input, type: $type) {
|
|
93
100
|
servers {
|
|
94
101
|
url
|
|
@@ -182,38 +189,21 @@ export const GetServerQueryDocument = new TypedDocumentString(`
|
|
|
182
189
|
}
|
|
183
190
|
}
|
|
184
191
|
`);
|
|
185
|
-
export const
|
|
186
|
-
query
|
|
192
|
+
export const GetSidebarOperationsDocument = new TypedDocumentString(`
|
|
193
|
+
query GetSidebarOperations($input: JSON!, $type: SchemaType!) {
|
|
187
194
|
schema(input: $input, type: $type) {
|
|
188
|
-
url
|
|
189
195
|
tags {
|
|
190
|
-
name
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
`);
|
|
195
|
-
export const GetOperationsDocument = new TypedDocumentString(`
|
|
196
|
-
query GetOperations($input: JSON!, $type: SchemaType!, $tag: String) {
|
|
197
|
-
schema(input: $input, type: $type) {
|
|
198
|
-
operations(tag: $tag) {
|
|
199
196
|
slug
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
197
|
+
name
|
|
198
|
+
extensions
|
|
199
|
+
operations {
|
|
200
|
+
summary
|
|
201
|
+
slug
|
|
202
|
+
method
|
|
203
|
+
operationId
|
|
204
|
+
path
|
|
207
205
|
}
|
|
208
206
|
}
|
|
209
|
-
untagged: operations(untagged: true) {
|
|
210
|
-
slug
|
|
211
|
-
deprecated
|
|
212
|
-
method
|
|
213
|
-
summary
|
|
214
|
-
operationId
|
|
215
|
-
path
|
|
216
|
-
}
|
|
217
207
|
}
|
|
218
208
|
}
|
|
219
209
|
`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/graphql/graphql.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/graphql/graphql.ts"],"names":[],"mappings":"AA6VA,MAAM,OAAO,mBACX,SAAQ,MAAM;IAGd,SAAS,CAA4D;IAC7D,KAAK,CAAS;IACf,QAAQ,CAAmC;IAElD,YAAY,KAAa,EAAE,QAA0C;QACnE,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AACD,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,mBAAmB,CAClE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiEG,EACH,EAAE,YAAY,EAAE,oBAAoB,EAAE,CACgC,CAAC;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,mBAAmB,CAAC;;;;;;;;;KASvD,CAGJ,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,mBAAmB,CAAC;;;;;;KAMvD,CAGJ,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoF9D,CAGD,CAAC;AACF,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,mBAAmB,CAAC;;;;;;;;;KASzD,CAGJ,CAAC;AACF,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,mBAAmB,CAAC;;;;;;;;;;;;;;;;;KAiB/D,CAGJ,CAAC"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import type { ResultOf } from "@graphql-typed-document-node/core";
|
|
2
1
|
import { type ZudokuPlugin } from "../../core/plugins.js";
|
|
3
|
-
import type {
|
|
2
|
+
import type { GetSidebarOperationsQuery } from "./graphql/graphql.js";
|
|
4
3
|
import { type OasPluginConfig } from "./interfaces.js";
|
|
5
|
-
declare const
|
|
4
|
+
declare const GetSidebarOperationsQuery: import("./graphql/graphql.js").TypedDocumentString<GetSidebarOperationsQuery, import("./graphql/graphql.js").Exact<{
|
|
6
5
|
input: import("./graphql/graphql.js").Scalars["JSON"]["input"];
|
|
7
6
|
type: import("./graphql/graphql.js").SchemaType;
|
|
8
|
-
tag?: import("./graphql/graphql.js").InputMaybe<import("./graphql/graphql.js").Scalars["String"]["input"]>;
|
|
9
7
|
}>>;
|
|
10
|
-
export type OperationResult =
|
|
11
|
-
type
|
|
12
|
-
schemaImports?: SchemaImports;
|
|
13
|
-
};
|
|
14
|
-
export type OpenApiPluginOptions = OasPluginConfig & InternalOasPluginConfig;
|
|
8
|
+
export type OperationResult = GetSidebarOperationsQuery["schema"]["tags"][number]["operations"][number];
|
|
9
|
+
export type OpenApiPluginOptions = OasPluginConfig;
|
|
15
10
|
export declare const UNTAGGED_PATH = "~endpoints";
|
|
16
|
-
export declare const openApiPlugin: (config:
|
|
11
|
+
export declare const openApiPlugin: (config: OasPluginConfig) => ZudokuPlugin;
|
|
17
12
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import slugify from "@sindresorhus/slugify";
|
|
3
2
|
import { CirclePlayIcon, LogInIcon } from "lucide-react";
|
|
4
3
|
import { matchPath } from "react-router";
|
|
5
4
|
import { useAuth } from "../../authentication/hook.js";
|
|
@@ -10,38 +9,21 @@ import { graphql } from "./graphql/index.js";
|
|
|
10
9
|
import { PlaygroundDialog } from "./playground/PlaygroundDialog.js";
|
|
11
10
|
import { createSidebarCategory } from "./util/createSidebarCategory.js";
|
|
12
11
|
import { getRoutes, getVersions } from "./util/getRoutes.js";
|
|
13
|
-
const
|
|
14
|
-
query
|
|
12
|
+
const GetSidebarOperationsQuery = graphql(`
|
|
13
|
+
query GetSidebarOperations($input: JSON!, $type: SchemaType!) {
|
|
15
14
|
schema(input: $input, type: $type) {
|
|
16
|
-
url
|
|
17
15
|
tags {
|
|
18
|
-
name
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
`);
|
|
23
|
-
const GetOperationsQuery = graphql(`
|
|
24
|
-
query GetOperations($input: JSON!, $type: SchemaType!, $tag: String) {
|
|
25
|
-
schema(input: $input, type: $type) {
|
|
26
|
-
operations(tag: $tag) {
|
|
27
16
|
slug
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
name
|
|
18
|
+
extensions
|
|
19
|
+
operations {
|
|
20
|
+
summary
|
|
21
|
+
slug
|
|
22
|
+
method
|
|
23
|
+
operationId
|
|
24
|
+
path
|
|
35
25
|
}
|
|
36
26
|
}
|
|
37
|
-
untagged: operations(untagged: true) {
|
|
38
|
-
slug
|
|
39
|
-
deprecated
|
|
40
|
-
method
|
|
41
|
-
summary
|
|
42
|
-
operationId
|
|
43
|
-
path
|
|
44
|
-
}
|
|
45
27
|
}
|
|
46
28
|
}
|
|
47
29
|
`);
|
|
@@ -70,7 +52,7 @@ export const openApiPlugin = (config) => {
|
|
|
70
52
|
return (_jsx(PlaygroundDialog, { url: url ?? "/", method: method ?? "get", server: server, ...props, children: _jsx(Button, { className: "gap-2 items-center", variant: "outline", children: children ?? (_jsxs(_Fragment, { children: ["Open in Playground ", _jsx(CirclePlayIcon, { size: 16 })] })) }) }));
|
|
71
53
|
},
|
|
72
54
|
}),
|
|
73
|
-
getSidebar: async (path) => {
|
|
55
|
+
getSidebar: async (path, context) => {
|
|
74
56
|
if (!matchPath({ path: basePath, end: false }, path)) {
|
|
75
57
|
return [];
|
|
76
58
|
}
|
|
@@ -78,47 +60,34 @@ export const openApiPlugin = (config) => {
|
|
|
78
60
|
try {
|
|
79
61
|
const versionParam = match?.params.version;
|
|
80
62
|
const version = versionParam ?? getVersions(config).at(0);
|
|
81
|
-
const { type
|
|
63
|
+
const { type } = config;
|
|
82
64
|
const input = type === "file" ? config.input[version] : config.input;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
client.fetch(GetOperationsQuery, {
|
|
90
|
-
type,
|
|
91
|
-
input,
|
|
92
|
-
tag: !options?.loadTags ? tagName : undefined,
|
|
93
|
-
}),
|
|
94
|
-
]);
|
|
95
|
-
const categories = tagData.schema.tags.flatMap((tag) => {
|
|
96
|
-
const categoryPath = joinUrl(basePath, versionParam, slugify(tag.name));
|
|
97
|
-
const operations = operationsData.schema.operations.filter((operation) => operation.tags?.length !== 0 &&
|
|
98
|
-
operation.tags?.map((t) => t.name).includes(tag.name));
|
|
99
|
-
// skip empty categories
|
|
100
|
-
if (options?.loadTags && operations.length === 0) {
|
|
65
|
+
const data = await context.queryClient.ensureQueryData({
|
|
66
|
+
queryKey: ["sidebar-operations-query", input],
|
|
67
|
+
queryFn: () => client.fetch(GetSidebarOperationsQuery, { type, input }),
|
|
68
|
+
});
|
|
69
|
+
const categories = data.schema.tags.flatMap((tag) => {
|
|
70
|
+
if (!tag.name || tag.operations.length === 0)
|
|
101
71
|
return [];
|
|
102
|
-
|
|
72
|
+
const categoryPath = joinUrl(basePath, versionParam, tag.slug);
|
|
73
|
+
const isCollapsed = tag.extensions?.["x-zudoku-collapsed"] ??
|
|
74
|
+
!config.options?.expandAllTags;
|
|
75
|
+
const isCollapsible = tag.extensions?.["x-zudoku-collapsible"] ?? true;
|
|
103
76
|
return createSidebarCategory({
|
|
104
77
|
label: tag.name,
|
|
105
78
|
path: categoryPath,
|
|
106
|
-
operations:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
collapsible,
|
|
110
|
-
collapsed,
|
|
79
|
+
operations: tag.operations,
|
|
80
|
+
collapsed: isCollapsed,
|
|
81
|
+
collapsible: isCollapsible,
|
|
111
82
|
});
|
|
112
83
|
});
|
|
113
|
-
|
|
84
|
+
const untaggedOperations = data.schema.tags.find((tag) => !tag.name)?.operations;
|
|
85
|
+
if (untaggedOperations) {
|
|
114
86
|
categories.push(createSidebarCategory({
|
|
115
87
|
label: "Other endpoints",
|
|
116
88
|
path: joinUrl(basePath, versionParam, UNTAGGED_PATH),
|
|
117
|
-
operations:
|
|
118
|
-
|
|
119
|
-
: [],
|
|
120
|
-
collapsible,
|
|
121
|
-
collapsed,
|
|
89
|
+
operations: untaggedOperations,
|
|
90
|
+
collapsed: !config.options?.expandAllTags,
|
|
122
91
|
}));
|
|
123
92
|
}
|
|
124
93
|
return categories;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/plugins/openapi/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/plugins/openapi/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,C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kBAAkB,EAAE,CAAC;oBACvB,UAAU,CAAC,IAAI,CACb,qBAAqB,CAAC;wBACpB,KAAK,EAAE,iBAAiB;wBACxB,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,aAAa,CAAC;wBACpD,UAAU,EAAE,kBAAkB;wBAC9B,SAAS,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa;qBAC1C,CAAC,CACH,CAAC;gBACJ,CAAC;gBAED,OAAO,UAAU,CAAC;YACpB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SchemaImports } from "../../oas/graphql/index.js";
|
|
1
2
|
type DynamicInput = () => Promise<unknown>;
|
|
2
3
|
type OasSource = {
|
|
3
4
|
type: "url";
|
|
@@ -26,11 +27,12 @@ type BaseOasConfig = {
|
|
|
26
27
|
navigationId?: string;
|
|
27
28
|
skipPreload?: boolean;
|
|
28
29
|
tagPages?: Array<string>;
|
|
30
|
+
schemaImports?: SchemaImports;
|
|
29
31
|
options?: {
|
|
30
32
|
examplesLanguage?: string;
|
|
31
33
|
disablePlayground?: boolean;
|
|
32
|
-
loadTags?: boolean;
|
|
33
34
|
showVersionSelect?: "always" | "if-available" | "hide";
|
|
35
|
+
expandAllTags?: boolean;
|
|
34
36
|
};
|
|
35
37
|
};
|
|
36
38
|
export type OasPluginConfig = BaseOasConfig & OasSource;
|
|
@@ -13,13 +13,11 @@ export const createSidebarCategory = ({ label, path, operations, collapsible, co
|
|
|
13
13
|
type: "link",
|
|
14
14
|
label: operation.summary ?? operation.path,
|
|
15
15
|
href: `${path}#${operation.slug}`,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
}),
|
|
16
|
+
badge: {
|
|
17
|
+
label: operation.method,
|
|
18
|
+
color: MethodColorMap[operation.method.toLowerCase()],
|
|
19
|
+
invert: true,
|
|
20
|
+
},
|
|
23
21
|
})),
|
|
24
22
|
});
|
|
25
23
|
//# sourceMappingURL=createSidebarCategory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSidebarCategory.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/util/createSidebarCategory.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACpC,KAAK,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,SAAS,GAOV,EAAe,EAAE,CAAC,CAAC;IAClB,IAAI,EAAE,UAAU;IAChB,KAAK;IACL,IAAI,EAAE;QACJ,IAAI,EAAE,KAAc;QACpB,EAAE,EAAE,IAAI;QACR,KAAK;KACN;IACD,WAAW;IACX,SAAS;IACT,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,EAAE,MAAe;QACrB,KAAK,EAAE,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,IAAI;QAC1C,IAAI,EAAE,GAAG,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE;QACjC,
|
|
1
|
+
{"version":3,"file":"createSidebarCategory.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/util/createSidebarCategory.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACpC,KAAK,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,SAAS,GAOV,EAAe,EAAE,CAAC,CAAC;IAClB,IAAI,EAAE,UAAU;IAChB,KAAK;IACL,IAAI,EAAE;QACJ,IAAI,EAAE,KAAc;QACpB,EAAE,EAAE,IAAI;QACR,KAAK;KACN;IACD,WAAW;IACX,SAAS;IACT,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,EAAE,MAAe;QACrB,KAAK,EAAE,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,IAAI;QAC1C,IAAI,EAAE,GAAG,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE;QACjC,KAAK,EAAE;YACL,KAAK,EAAE,SAAS,CAAC,MAAM;YACvB,KAAK,EAAE,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAE;YACtD,MAAM,EAAE,IAAI;SACb;KACF,CAAC,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -6,11 +6,11 @@ export const traverse = (specification, transform) => {
|
|
|
6
6
|
const result = Array.isArray(transformed) ? [] : {};
|
|
7
7
|
for (const [key, value] of Object.entries(transformed)) {
|
|
8
8
|
if (Array.isArray(value)) {
|
|
9
|
-
result[key] = value.map((item) => typeof item === "object" && item
|
|
9
|
+
result[key] = value.map((item) => typeof item === "object" && item != null
|
|
10
10
|
? traverse(item, transform)
|
|
11
11
|
: item);
|
|
12
12
|
}
|
|
13
|
-
else if (typeof value === "object" && value
|
|
13
|
+
else if (typeof value === "object" && value != null) {
|
|
14
14
|
result[key] = traverse(value, transform);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverse.js","sourceRoot":"","sources":["../../../src/lib/util/traverse.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,aAAwB,EACxB,SAA0C,EAC1C,EAAE;IACF,MAAM,WAAW,GAAG,SAAS,CAAC,aAAa,CAAC,CAAC;IAC7C,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,IAAI,EA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,EAAE,SAAS,CAAC;gBAC3B,CAAC,CAAC,IAAI,CACT,CAAC;QACJ,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YACtD,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -15,6 +15,8 @@ export const useScrollToHash = () => {
|
|
|
15
15
|
if (element) {
|
|
16
16
|
element.scrollIntoView();
|
|
17
17
|
scrollIntoViewIfNeeded(link);
|
|
18
|
+
// Set the active anchor after the scroll has happened
|
|
19
|
+
// so the intersection observer doesn't trigger wrong items
|
|
18
20
|
requestIdleCallback(() => setActiveAnchor(linkHash));
|
|
19
21
|
return true;
|
|
20
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollToAnchor.js","sourceRoot":"","sources":["../../../src/lib/util/useScrollToAnchor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,EAAE,eAAe,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAEhD,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,IAAY,EAAE,EAAE;QACf,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI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|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { $RefParser } from "@apidevtools/json-schema-ref-parser";
|
|
2
|
+
import { getAllOperations, getAllSlugs } from "../../lib/oas/graphql/index.js";
|
|
1
3
|
import { traverse } from "../../lib/util/traverse.js";
|
|
2
4
|
// Find all $ref occurrences in the schema and assign them unique variable names
|
|
3
5
|
const createLocalRefMap = (obj) => {
|
|
4
6
|
const refMap = new Map();
|
|
5
7
|
let refCounter = 0;
|
|
6
8
|
traverse(obj, (node) => {
|
|
7
|
-
if (typeof node
|
|
9
|
+
if (typeof node.$ref === "string" && node.$ref.startsWith("#/")) {
|
|
8
10
|
if (!refMap.has(node.$ref)) {
|
|
9
11
|
refMap.set(node.$ref, refCounter++);
|
|
10
12
|
}
|
|
@@ -15,7 +17,7 @@ const createLocalRefMap = (obj) => {
|
|
|
15
17
|
};
|
|
16
18
|
// Replace all $ref occurrences with a special marker that will be transformed into a reference to the __refMap lookup
|
|
17
19
|
const setRefMarkers = (obj, refMap) => traverse(obj, (node) => {
|
|
18
|
-
if (node
|
|
20
|
+
if (node.$ref && typeof node.$ref === "string" && refMap.has(node.$ref)) {
|
|
19
21
|
return `__refMap:${node.$ref}`;
|
|
20
22
|
}
|
|
21
23
|
return node;
|
|
@@ -23,7 +25,7 @@ const setRefMarkers = (obj, refMap) => traverse(obj, (node) => {
|
|
|
23
25
|
// Replace the marker strings with actual __refMap lookups in the generated code
|
|
24
26
|
const replaceRefMarkers = (code) => code?.replace(/"__refMap:(.*?)"/g, '__refMap["$1"]');
|
|
25
27
|
const lookup = (schema, path) => {
|
|
26
|
-
const parts = path.split("/").slice(1);
|
|
28
|
+
const parts = path.split("/").slice(1).map(decodeURIComponent);
|
|
27
29
|
let value = schema;
|
|
28
30
|
for (const part of parts) {
|
|
29
31
|
value = value[part];
|
|
@@ -43,13 +45,20 @@ const lookup = (schema, path) => {
|
|
|
43
45
|
export const generateCode = async (schema) => {
|
|
44
46
|
const refMap = createLocalRefMap(schema);
|
|
45
47
|
const lines = [];
|
|
46
|
-
const str = (obj) => JSON.stringify(obj, null,
|
|
48
|
+
const str = (obj, indent = 2) => JSON.stringify(obj, null, indent);
|
|
47
49
|
lines.push(`const __refs = Array.from({ length: ${refMap.size} }, () => ({}));`);
|
|
48
50
|
lines.push("const __refMap = {", Array.from(refMap)
|
|
49
51
|
.map(([refPath, index]) => ` "${refPath}": __refs[${index}]`)
|
|
50
52
|
.join(",\n"), "};");
|
|
51
53
|
for (const [refPath, index] of refMap) {
|
|
52
54
|
const value = lookup(schema, refPath);
|
|
55
|
+
// This shouldn't happen but to be safe we log a warning
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
57
|
+
if (!value) {
|
|
58
|
+
// eslint-disable-next-line no-console
|
|
59
|
+
console.warn(`Could not find value for refPath: ${refPath}`);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
53
62
|
const transformedValue = setRefMarkers(value, refMap);
|
|
54
63
|
lines.push(
|
|
55
64
|
// Use assign so that the object identity is maintained and correctly resolves circular references
|
|
@@ -57,6 +66,12 @@ export const generateCode = async (schema) => {
|
|
|
57
66
|
}
|
|
58
67
|
const transformed = setRefMarkers(schema, refMap);
|
|
59
68
|
lines.push(`export const schema = ${replaceRefMarkers(str(transformed))};`);
|
|
69
|
+
// slugify is quite expensive for big schemas, so we pre-generate the slugs here to shave off time
|
|
70
|
+
const dereferencedSchema = await $RefParser.dereference(schema);
|
|
71
|
+
const slugs = getAllSlugs(getAllOperations(dereferencedSchema.paths), dereferencedSchema.tags);
|
|
72
|
+
lines.push(`export const slugs = {`);
|
|
73
|
+
lines.push(` operations: ${str(slugs.operations, 0)},`, ` tags: ${str(slugs.tags, 0)},`);
|
|
74
|
+
lines.push(`};`);
|
|
60
75
|
return lines.join("\n");
|
|
61
76
|
};
|
|
62
77
|
//# sourceMappingURL=schema-codegen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-codegen.js","sourceRoot":"","sources":["../../../src/vite/api/schema-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtE,gFAAgF;AAChF,MAAM,iBAAiB,GAAG,CAAC,GAAc,EAAE,EAAE;IAC3C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACrB,IAAI,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"schema-codegen.js","sourceRoot":"","sources":["../../../src/vite/api/schema-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAAkB,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtE,gFAAgF;AAChF,MAAM,iBAAiB,GAAG,CAAC,GAAc,EAAE,EAAE;IAC3C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACrB,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,sHAAsH;AACtH,MAAM,aAAa,GAAG,CAAC,GAA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