zudoku 0.3.0-dev.73 → 0.3.0-dev.75

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 (34) hide show
  1. package/dist/lib/authentication/Callback.d.ts +1 -1
  2. package/dist/lib/authentication/Callback.js +0 -1
  3. package/dist/lib/authentication/Callback.js.map +1 -1
  4. package/dist/lib/components/DevPortal.js +16 -1
  5. package/dist/lib/components/DevPortal.js.map +1 -1
  6. package/dist/lib/core/DevPortalContext.js +3 -6
  7. package/dist/lib/core/DevPortalContext.js.map +1 -1
  8. package/dist/lib/oas/graphql/index.js +3 -2
  9. package/dist/lib/oas/graphql/index.js.map +1 -1
  10. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +3 -1
  11. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
  12. package/dist/lib/plugins/openapi/SchemaListViewItem.js +4 -1
  13. package/dist/lib/plugins/openapi/SchemaListViewItem.js.map +1 -1
  14. package/lib/{OperationList-CzXPfUMy.js → OperationList-DbFAs7j0.js} +24 -21
  15. package/lib/OperationList-DbFAs7j0.js.map +1 -0
  16. package/lib/assets/{worker-BWwCA-wk.js → worker-CyHZIIfE.js} +3 -3
  17. package/lib/assets/{worker-BWwCA-wk.js.map → worker-CyHZIIfE.js.map} +1 -1
  18. package/lib/{index-D_ZoO3pi.js → index-C5qcuxqm.js} +2 -2
  19. package/lib/{index-D_ZoO3pi.js.map → index-C5qcuxqm.js.map} +1 -1
  20. package/lib/zudoku.auth-openid.js +32 -31
  21. package/lib/zudoku.auth-openid.js.map +1 -1
  22. package/lib/zudoku.components.js +367 -361
  23. package/lib/zudoku.components.js.map +1 -1
  24. package/lib/zudoku.openapi-worker.js +3 -3
  25. package/lib/zudoku.openapi-worker.js.map +1 -1
  26. package/lib/zudoku.plugin-openapi.js +1 -1
  27. package/package.json +1 -1
  28. package/src/lib/authentication/Callback.tsx +0 -2
  29. package/src/lib/components/DevPortal.tsx +17 -0
  30. package/src/lib/core/DevPortalContext.ts +2 -4
  31. package/src/lib/oas/graphql/index.ts +3 -2
  32. package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +3 -1
  33. package/src/lib/plugins/openapi/SchemaListViewItem.tsx +3 -0
  34. package/lib/OperationList-CzXPfUMy.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import "./jsx-runtime-D0NHp7nI.js";
2
- import { o as n } from "./index-D_ZoO3pi.js";
2
+ import { o as n } from "./index-C5qcuxqm.js";
3
3
  import "./urql-DMlBWUKL.js";
4
4
  import "zudoku/openapi-worker";
5
5
  import "./Markdown-CSdXDuYx.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.3.0-dev.73",
3
+ "version": "0.3.0-dev.75",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -55,6 +55,4 @@ export function Callback({
55
55
  </div>
56
56
  );
57
57
  }
58
-
59
- return <div>Loading...</div>;
60
58
  }
@@ -8,6 +8,7 @@ import {
8
8
  useContext,
9
9
  useEffect,
10
10
  useMemo,
11
+ useRef,
11
12
  useState,
12
13
  } from "react";
13
14
  import { ErrorBoundary } from "react-error-boundary";
@@ -52,8 +53,10 @@ const DevPortalInner = ({
52
53
  () => ({ ...MdxComponents, ...props.mdx?.components }),
53
54
  [props.mdx?.components],
54
55
  );
56
+ const [isInitialized, setIsInitialized] = useState(false);
55
57
  const { stagger } = useContext(StaggeredRenderContext);
56
58
  const [didNavigate, setDidNavigate] = useState(false);
59
+ const initRef = useRef<"idle" | "pending" | "done">("idle");
57
60
  const staggeredValue = useMemo(
58
61
  () => (didNavigate ? { stagger: true } : { stagger }),
59
62
  [stagger, didNavigate],
@@ -69,11 +72,25 @@ const DevPortalInner = ({
69
72
 
70
73
  const [devPortalContext] = useState(() => new DevPortalContext(props));
71
74
 
75
+ // TODO could be handled more elegantly
76
+ useEffect(() => {
77
+ if (initRef.current === "pending") return;
78
+ initRef.current = "pending";
79
+ void devPortalContext.initialize().then(() => {
80
+ initRef.current = "done";
81
+ setIsInitialized(true);
82
+ });
83
+ }, [devPortalContext]);
84
+
72
85
  const heads = props.plugins
73
86
  ?.filter(hasHead)
74
87
  // eslint-disable-next-line react/no-array-index-key
75
88
  .map((plugin, i) => <Fragment key={i}>{plugin.getHead?.()}</Fragment>);
76
89
 
90
+ if (!isInitialized) {
91
+ return null;
92
+ }
93
+
77
94
  return (
78
95
  <QueryClientProvider client={queryClient}>
79
96
  <Helmet>{heads}</Helmet>
@@ -113,16 +113,14 @@ export class DevPortalContext {
113
113
  this.authentication = config.authentication;
114
114
  this.meta = config.metadata;
115
115
  this.page = config.page;
116
-
117
- void this.initialize();
118
116
  }
119
117
 
120
118
  initialize = async () => {
121
- await Promise.all([
119
+ await Promise.all(
122
120
  this.plugins
123
121
  .filter(needsInitialization)
124
122
  .map((plugin) => plugin.initialize?.(this)),
125
- ]);
123
+ );
126
124
  };
127
125
 
128
126
  invalidateCache = async (key: DevPortalCacheKey[]) => {
@@ -39,7 +39,8 @@ export const slugifyOperation = (operation: OperationLike, tag?: string) => {
39
39
  const summary =
40
40
  operation.summary +
41
41
  (operation.operationId
42
- ? "-" + operation.operationId.slice(0, operation.summary ? 4 : 12)
42
+ ? "-" +
43
+ operation.operationId.slice(0, operation.summary ? Infinity : Infinity)
43
44
  : "");
44
45
 
45
46
  return slugify(
@@ -211,7 +212,7 @@ const MediaTypeItem = builder
211
212
  .implement({
212
213
  fields: (t) => ({
213
214
  mediaType: t.exposeString("mediaType"),
214
- schema: t.expose("schema", { type: JSONScalar }),
215
+ schema: t.expose("schema", { type: JSONScalar, nullable: true }),
215
216
  examples: t.expose("examples", { type: [ExampleItem], nullable: true }),
216
217
  encoding: t.expose("encoding", { type: [EncodingItem], nullable: true }),
217
218
  }),
@@ -25,7 +25,9 @@ export const RequestBodySidecarBox = ({ content }: { content: Content }) => {
25
25
  copyable
26
26
  className="text-xs"
27
27
  code={JSON.stringify(
28
- generateSchemaExample(content[0].schema as SchemaObject),
28
+ content.at(0)?.schema
29
+ ? generateSchemaExample(content[0].schema as SchemaObject)
30
+ : "",
29
31
  null,
30
32
  2,
31
33
  )}
@@ -17,6 +17,9 @@ export const SchemaListViewItem = ({
17
17
  property: SchemaObject;
18
18
  nestingLevel: number;
19
19
  }) => {
20
+ if (!property) {
21
+ return <div>no property</div>;
22
+ }
20
23
  return (
21
24
  <div
22
25
  key={propertyName}