zudoku 0.0.0-monetization-standalone.zada7f04c → 0.0.0-money-plugin.z605c614d

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 (241) hide show
  1. package/dist/config/create-plugin.d.ts +2 -2
  2. package/dist/config/create-plugin.js.map +1 -1
  3. package/dist/config/validators/InputNavigationSchema.d.ts +174 -124
  4. package/dist/config/validators/InputNavigationSchema.js +17 -0
  5. package/dist/config/validators/InputNavigationSchema.js.map +1 -1
  6. package/dist/config/validators/NavigationSchema.d.ts +10 -2
  7. package/dist/config/validators/NavigationSchema.js +7 -0
  8. package/dist/config/validators/NavigationSchema.js.map +1 -1
  9. package/dist/config/validators/validate.d.ts +4 -4
  10. package/dist/flat-config.d.ts +35 -24
  11. package/dist/lib/components/Heading.d.ts +1 -1
  12. package/dist/lib/components/MobileTopNavigation.js +2 -1
  13. package/dist/lib/components/MobileTopNavigation.js.map +1 -1
  14. package/dist/lib/components/TopNavigation.d.ts +7 -1
  15. package/dist/lib/components/TopNavigation.js +7 -2
  16. package/dist/lib/components/TopNavigation.js.map +1 -1
  17. package/dist/lib/components/context/ZudokuContext.d.ts +8 -1
  18. package/dist/lib/components/context/ZudokuContext.js +2 -0
  19. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  20. package/dist/lib/components/index.d.ts +18 -76
  21. package/dist/lib/components/index.js +19 -36
  22. package/dist/lib/components/index.js.map +1 -1
  23. package/dist/lib/components/navigation/Navigation.js +4 -3
  24. package/dist/lib/components/navigation/Navigation.js.map +1 -1
  25. package/dist/lib/components/navigation/NavigationCategory.js +8 -0
  26. package/dist/lib/components/navigation/NavigationCategory.js.map +1 -1
  27. package/dist/lib/components/navigation/NavigationFilterContext.d.ts +8 -0
  28. package/dist/lib/components/navigation/NavigationFilterContext.js +12 -0
  29. package/dist/lib/components/navigation/NavigationFilterContext.js.map +1 -0
  30. package/dist/lib/components/navigation/NavigationFilterInput.d.ts +3 -0
  31. package/dist/lib/components/navigation/NavigationFilterInput.js +9 -0
  32. package/dist/lib/components/navigation/NavigationFilterInput.js.map +1 -0
  33. package/dist/lib/components/navigation/NavigationItem.js +11 -1
  34. package/dist/lib/components/navigation/NavigationItem.js.map +1 -1
  35. package/dist/lib/components/navigation/utils.d.ts +2 -1
  36. package/dist/lib/components/navigation/utils.js +22 -1
  37. package/dist/lib/components/navigation/utils.js.map +1 -1
  38. package/dist/lib/core/__internal.d.ts +1 -1
  39. package/dist/lib/core/transform-config.d.ts +2 -2
  40. package/dist/lib/core/transform-config.js.map +1 -1
  41. package/dist/lib/hooks/index.d.ts +7 -30
  42. package/dist/lib/hooks/index.js +7 -15
  43. package/dist/lib/hooks/index.js.map +1 -1
  44. package/dist/lib/oas/graphql/circular.d.ts +1 -1
  45. package/dist/lib/oas/graphql/circular.js +18 -35
  46. package/dist/lib/oas/graphql/circular.js.map +1 -1
  47. package/dist/lib/oas/graphql/circular.test.js +33 -2
  48. package/dist/lib/oas/graphql/circular.test.js.map +1 -1
  49. package/dist/lib/oas/parser/index.js +14 -5
  50. package/dist/lib/oas/parser/index.js.map +1 -1
  51. package/dist/lib/plugins/openapi/playground/fileUtils.d.ts +1 -0
  52. package/dist/lib/plugins/openapi/playground/fileUtils.js +3 -0
  53. package/dist/lib/plugins/openapi/playground/fileUtils.js.map +1 -1
  54. package/dist/lib/plugins/openapi/playground/result-panel/AudioPlayer.d.ts +6 -0
  55. package/dist/lib/plugins/openapi/playground/result-panel/AudioPlayer.js +20 -0
  56. package/dist/lib/plugins/openapi/playground/result-panel/AudioPlayer.js.map +1 -0
  57. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +7 -2
  58. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -1
  59. package/dist/lib/ui/Alert.d.ts +3 -2
  60. package/dist/lib/ui/Alert.js +9 -5
  61. package/dist/lib/ui/Alert.js.map +1 -1
  62. package/dist/lib/ui/InputGroup.d.ts +16 -0
  63. package/dist/lib/ui/InputGroup.js +65 -0
  64. package/dist/lib/ui/InputGroup.js.map +1 -0
  65. package/dist/lib/util/flattenAllOf.d.ts +0 -2
  66. package/dist/lib/util/flattenAllOf.js +0 -46
  67. package/dist/lib/util/flattenAllOf.js.map +1 -1
  68. package/dist/lib/util/flattenAllOf.test.js +2 -1
  69. package/dist/lib/util/flattenAllOf.test.js.map +1 -1
  70. package/dist/lib/util/flattenAllOfProcessor.d.ts +2 -0
  71. package/dist/lib/util/flattenAllOfProcessor.js +48 -0
  72. package/dist/lib/util/flattenAllOfProcessor.js.map +1 -0
  73. package/dist/lib/util/readFrontmatter.js +2 -1
  74. package/dist/lib/util/readFrontmatter.js.map +1 -1
  75. package/dist/vite/api/SchemaManager.js +1 -1
  76. package/dist/vite/api/SchemaManager.js.map +1 -1
  77. package/dist/vite/api/SchemaManager.test.js +1 -1
  78. package/dist/vite/api/SchemaManager.test.js.map +1 -1
  79. package/dist/vite/build.js +91 -73
  80. package/dist/vite/build.js.map +1 -1
  81. package/dist/vite/mdx/remark-inject-filepath.js +5 -1
  82. package/dist/vite/mdx/remark-inject-filepath.js.map +1 -1
  83. package/dist/vite/mdx/remark-link-rewrite.js +3 -2
  84. package/dist/vite/mdx/remark-link-rewrite.js.map +1 -1
  85. package/dist/vite/plugin-docs.js +9 -7
  86. package/dist/vite/plugin-docs.js.map +1 -1
  87. package/dist/vite/plugin-markdown-export.js +4 -2
  88. package/dist/vite/plugin-markdown-export.js.map +1 -1
  89. package/dist/vite/prerender/prerender.js +3 -1
  90. package/dist/vite/prerender/prerender.js.map +1 -1
  91. package/dist/vite/prerender/worker.js +3 -1
  92. package/dist/vite/prerender/worker.js.map +1 -1
  93. package/lib/{ClaudeLogo-K64Qm6gS.js → ClaudeLogo-DP6JOmz1.js} +26 -22
  94. package/lib/{ClaudeLogo-K64Qm6gS.js.map → ClaudeLogo-DP6JOmz1.js.map} +1 -1
  95. package/lib/{HydrationBoundary-CNF2ZV3E.js → HydrationBoundary-CJu4vUlG.js} +6 -6
  96. package/lib/{HydrationBoundary-CNF2ZV3E.js.map → HydrationBoundary-CJu4vUlG.js.map} +1 -1
  97. package/lib/{MdxPage-Cr99RARi.js → MdxPage-BR_7-0cT.js} +8 -8
  98. package/lib/{MdxPage-Cr99RARi.js.map → MdxPage-BR_7-0cT.js.map} +1 -1
  99. package/lib/Mermaid-DAWm9rzb.js +104 -0
  100. package/lib/Mermaid-DAWm9rzb.js.map +1 -0
  101. package/lib/{OAuthErrorPage-BRXS5AMu.js → OAuthErrorPage-l0orKh-A.js} +22 -19
  102. package/lib/{OAuthErrorPage-BRXS5AMu.js.map → OAuthErrorPage-l0orKh-A.js.map} +1 -1
  103. package/lib/{OasProvider-sP_SqSM7.js → OasProvider-DPW0x8dk.js} +3 -3
  104. package/lib/{OasProvider-sP_SqSM7.js.map → OasProvider-DPW0x8dk.js.map} +1 -1
  105. package/lib/{OperationList-DR0APPhk.js → OperationList-Dcm9TZG7.js} +952 -948
  106. package/lib/OperationList-Dcm9TZG7.js.map +1 -0
  107. package/lib/{RouteGuard-CZuPjknT.js → RouteGuard-CVs3yvEs.js} +5 -5
  108. package/lib/{RouteGuard-CZuPjknT.js.map → RouteGuard-CVs3yvEs.js.map} +1 -1
  109. package/lib/{SchemaList-DgqAAHSI.js → SchemaList-B7RzviG5.js} +8 -8
  110. package/lib/{SchemaList-DgqAAHSI.js.map → SchemaList-B7RzviG5.js.map} +1 -1
  111. package/lib/{SchemaView-7IyQYEqk.js → SchemaView-Dt5-T06r.js} +3 -3
  112. package/lib/{SchemaView-7IyQYEqk.js.map → SchemaView-Dt5-T06r.js.map} +1 -1
  113. package/lib/{Secret-BE7V0Vb5.js → Secret-DUpgv4V3.js} +4 -4
  114. package/lib/{Secret-BE7V0Vb5.js.map → Secret-DUpgv4V3.js.map} +1 -1
  115. package/lib/{SignUp-D3zhMk7q.js → SignUp-CifBTCq4.js} +31 -26
  116. package/lib/{SignUp-D3zhMk7q.js.map → SignUp-CifBTCq4.js.map} +1 -1
  117. package/lib/{SyntaxHighlight-paLQ8NP8.js → SyntaxHighlight-BMu0b_hF.js} +3 -3
  118. package/lib/{SyntaxHighlight-paLQ8NP8.js.map → SyntaxHighlight-BMu0b_hF.js.map} +1 -1
  119. package/lib/{Toc-GluXkcIk.js → Toc-CeMXYWgp.js} +2 -2
  120. package/lib/{Toc-GluXkcIk.js.map → Toc-CeMXYWgp.js.map} +1 -1
  121. package/lib/{index-DYfX9H7i.js → Zudoku-B5YsolG1.js} +2869 -2710
  122. package/lib/Zudoku-B5YsolG1.js.map +1 -0
  123. package/lib/ZudokuContext-CYyb_PB_.js +175 -0
  124. package/lib/ZudokuContext-CYyb_PB_.js.map +1 -0
  125. package/lib/ZudokuReactContext-DGJAP1sN.js +222 -0
  126. package/lib/ZudokuReactContext-DGJAP1sN.js.map +1 -0
  127. package/lib/{circular-Bunzbpsy.js → circular-BV9K7T3F.js} +1327 -1346
  128. package/lib/{circular-Bunzbpsy.js.map → circular-BV9K7T3F.js.map} +1 -1
  129. package/lib/createServer-DYUdwZG4.js +13036 -0
  130. package/lib/createServer-DYUdwZG4.js.map +1 -0
  131. package/lib/{errors-D2NINcVk.js → errors-C3XsqYso.js} +3 -3
  132. package/lib/{errors-D2NINcVk.js.map → errors-C3XsqYso.js.map} +1 -1
  133. package/lib/{firebase-BVAmGV_v.js → firebase-CL9aCRn0.js} +26 -25
  134. package/lib/firebase-CL9aCRn0.js.map +1 -0
  135. package/lib/{hook-Da8QTnPd.js → hook-Dz_n9SoE.js} +16 -15
  136. package/lib/{hook-Da8QTnPd.js.map → hook-Dz_n9SoE.js.map} +1 -1
  137. package/lib/{index-DTjrb36R.js → index-CFW_9FdI.js} +2 -2
  138. package/lib/{index-DTjrb36R.js.map → index-CFW_9FdI.js.map} +1 -1
  139. package/lib/index-DAWHN3cH.js +86 -0
  140. package/lib/index-DAWHN3cH.js.map +1 -0
  141. package/lib/{index-BfTLawvZ.js → index-DywuWe2u.js} +589 -551
  142. package/lib/index-DywuWe2u.js.map +1 -0
  143. package/lib/{index.esm-B_0dvNjB.js → index.esm-Ca5zvoff.js} +20 -20
  144. package/lib/{index.esm-B_0dvNjB.js.map → index.esm-Ca5zvoff.js.map} +1 -1
  145. package/lib/{index.esm-GMDd_9gw.js → index.esm-ld_S_9qs.js} +2 -2
  146. package/lib/index.esm-ld_S_9qs.js.map +1 -0
  147. package/lib/{invariant-BJAl77rw.js → invariant-B_t_F2s_.js} +3 -3
  148. package/lib/{invariant-BJAl77rw.js.map → invariant-B_t_F2s_.js.map} +1 -1
  149. package/lib/{mutation-BISOc7OM.js → mutation-B7eFBLZY.js} +2 -2
  150. package/lib/{mutation-BISOc7OM.js.map → mutation-B7eFBLZY.js.map} +1 -1
  151. package/lib/ui/Alert.js +36 -24
  152. package/lib/ui/Alert.js.map +1 -1
  153. package/lib/ui/InputGroup.js +155 -0
  154. package/lib/ui/InputGroup.js.map +1 -0
  155. package/lib/ui/SyntaxHighlight.js +3 -3
  156. package/lib/useExposedProps-CzTDfXfq.js +30 -0
  157. package/lib/useExposedProps-CzTDfXfq.js.map +1 -0
  158. package/lib/{useMutation-CFMGlAMW.js → useMutation-CErliDZ9.js} +5 -5
  159. package/lib/{useMutation-CFMGlAMW.js.map → useMutation-CErliDZ9.js.map} +1 -1
  160. package/lib/{useSuspenseQuery-CSB_rVek.js → useQuery-ht7aWJ3S.js} +432 -446
  161. package/lib/useQuery-ht7aWJ3S.js.map +1 -0
  162. package/lib/useSuspenseQuery-DQH4Bmc2.js +18 -0
  163. package/lib/useSuspenseQuery-DQH4Bmc2.js.map +1 -0
  164. package/lib/zudoku.__internal.js +1504 -1041
  165. package/lib/zudoku.__internal.js.map +1 -1
  166. package/lib/zudoku.auth-auth0.js +6 -5
  167. package/lib/zudoku.auth-auth0.js.map +1 -1
  168. package/lib/zudoku.auth-azureb2c.js +14 -13
  169. package/lib/zudoku.auth-azureb2c.js.map +1 -1
  170. package/lib/zudoku.auth-clerk.js +2 -2
  171. package/lib/zudoku.auth-firebase.js +5 -5
  172. package/lib/zudoku.auth-openid.js +8 -7
  173. package/lib/zudoku.auth-openid.js.map +1 -1
  174. package/lib/zudoku.auth-supabase.js +4 -4
  175. package/lib/zudoku.components.js +31 -29
  176. package/lib/zudoku.components.js.map +1 -1
  177. package/lib/zudoku.hooks.js +24 -11
  178. package/lib/zudoku.hooks.js.map +1 -1
  179. package/lib/zudoku.mermaid.js +5 -4
  180. package/lib/zudoku.mermaid.js.map +1 -1
  181. package/lib/zudoku.plugin-api-catalog.js +41 -36
  182. package/lib/zudoku.plugin-api-catalog.js.map +1 -1
  183. package/lib/zudoku.plugin-api-keys.js +156 -153
  184. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  185. package/lib/zudoku.plugin-custom-pages.js +1 -1
  186. package/lib/zudoku.plugin-markdown.js +1 -1
  187. package/lib/zudoku.plugin-openapi.js +2 -2
  188. package/lib/zudoku.plugin-search-pagefind.js +19 -18
  189. package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
  190. package/lib/zudoku.react-query.js +26 -25
  191. package/lib/zudoku.react-query.js.map +1 -1
  192. package/package.json +5 -4
  193. package/src/app/defaultTheme.css +4 -0
  194. package/src/app/main.css +2 -0
  195. package/src/lib/components/MobileTopNavigation.tsx +13 -8
  196. package/src/lib/components/TopNavigation.tsx +25 -7
  197. package/src/lib/components/context/ZudokuContext.ts +1 -0
  198. package/src/lib/components/index.ts +19 -39
  199. package/src/lib/components/navigation/Navigation.tsx +4 -3
  200. package/src/lib/components/navigation/NavigationCategory.tsx +9 -0
  201. package/src/lib/components/navigation/NavigationFilterContext.tsx +28 -0
  202. package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -0
  203. package/src/lib/components/navigation/NavigationItem.tsx +17 -1
  204. package/src/lib/components/navigation/utils.ts +32 -1
  205. package/src/lib/core/transform-config.ts +5 -5
  206. package/src/lib/hooks/index.ts +7 -16
  207. package/src/lib/oas/graphql/circular.test.ts +37 -2
  208. package/src/lib/oas/graphql/circular.ts +25 -51
  209. package/src/lib/oas/parser/index.ts +17 -6
  210. package/src/lib/plugins/openapi/playground/fileUtils.ts +4 -0
  211. package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -0
  212. package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +33 -17
  213. package/src/lib/ui/Alert.tsx +17 -5
  214. package/src/lib/ui/InputGroup.tsx +168 -0
  215. package/src/lib/util/flattenAllOf.test.ts +2 -1
  216. package/src/lib/util/flattenAllOf.ts +0 -57
  217. package/src/lib/util/flattenAllOfProcessor.ts +58 -0
  218. package/src/lib/util/readFrontmatter.ts +2 -1
  219. package/src/zuplo/enrich-with-zuplo-mcp.ts +168 -0
  220. package/src/zuplo/enrich-with-zuplo.ts +254 -0
  221. package/src/zuplo/policy-types.ts +46 -0
  222. package/src/zuplo/with-zuplo-processors.ts +35 -0
  223. package/src/zuplo/with-zuplo.ts +14 -0
  224. package/lib/Mermaid-DEztDKFw.js +0 -102
  225. package/lib/Mermaid-DEztDKFw.js.map +0 -1
  226. package/lib/OperationList-DR0APPhk.js.map +0 -1
  227. package/lib/Separator-BXt1LYnm.js +0 -27
  228. package/lib/Separator-BXt1LYnm.js.map +0 -1
  229. package/lib/ZudokuContext-CnEI8jPU.js +0 -389
  230. package/lib/ZudokuContext-CnEI8jPU.js.map +0 -1
  231. package/lib/___vite-browser-external_commonjs-proxy-BttVsNON.js +0 -9
  232. package/lib/___vite-browser-external_commonjs-proxy-BttVsNON.js.map +0 -1
  233. package/lib/createServer-Dl4Xwsm4.js +0 -16693
  234. package/lib/createServer-Dl4Xwsm4.js.map +0 -1
  235. package/lib/firebase-BVAmGV_v.js.map +0 -1
  236. package/lib/index-Ba6RP577.js +0 -133
  237. package/lib/index-Ba6RP577.js.map +0 -1
  238. package/lib/index-BfTLawvZ.js.map +0 -1
  239. package/lib/index-DYfX9H7i.js.map +0 -1
  240. package/lib/index.esm-GMDd_9gw.js.map +0 -1
  241. package/lib/useSuspenseQuery-CSB_rVek.js.map +0 -1
@@ -0,0 +1,254 @@
1
+ import type { OpenAPIV3_1 } from "openapi-types";
2
+ import type { ProcessorArg } from "../config/validators/BuildSchema.js";
3
+ import { objectEntries } from "../lib/util/objectEntries.js";
4
+ import type { RecordAny } from "../lib/util/traverse.js";
5
+ import type {
6
+ PoliciesConfigFile,
7
+ PolicyConfigurationFragment,
8
+ } from "./policy-types.js";
9
+
10
+ const API_KEY_REPLACEMENT_STRING = "YOUR_KEY_HERE";
11
+
12
+ const enrichWithApiKeyData = (
13
+ operationObject: RecordAny,
14
+ apiKeyPolicies: PolicyConfigurationFragment[],
15
+ ) => {
16
+ if (apiKeyPolicies.length === 0) {
17
+ return operationObject;
18
+ }
19
+
20
+ const firstPolicy = apiKeyPolicies[0];
21
+ const authorizationHeader =
22
+ (firstPolicy?.handler.options?.authHeader as string) || "Authorization";
23
+ const authorizationScheme = (firstPolicy?.handler.options?.authScheme ??
24
+ "Bearer") as string;
25
+ const authSchemeExample =
26
+ authorizationScheme !== ""
27
+ ? `${authorizationScheme} ${API_KEY_REPLACEMENT_STRING}`
28
+ : API_KEY_REPLACEMENT_STRING;
29
+
30
+ // Add API key header parameter
31
+ const apiKeyHeader: OpenAPIV3_1.ParameterObject = {
32
+ name: authorizationHeader,
33
+ in: "header",
34
+ required: true,
35
+ example: authSchemeExample,
36
+ schema: {
37
+ type: "string",
38
+ },
39
+ description: `The \`${authorizationHeader}\` header is used to authenticate with the API using your API key. Value is of the format \`${authSchemeExample}\`.`,
40
+ };
41
+
42
+ const parameters = operationObject.parameters || [];
43
+ if (
44
+ !parameters.some((param: RecordAny) => param.name === authorizationHeader)
45
+ ) {
46
+ operationObject.parameters = [apiKeyHeader, ...parameters];
47
+ }
48
+
49
+ // Add security scheme and requirement
50
+ const apiSecuritySchemeId = "api_key";
51
+ const apiKeySecurityRequirement = { [apiSecuritySchemeId]: [] };
52
+
53
+ if (!operationObject.security) {
54
+ operationObject.security = [apiKeySecurityRequirement];
55
+ } else if (
56
+ !operationObject.security.some((req: RecordAny) => req[apiSecuritySchemeId])
57
+ ) {
58
+ operationObject.security = [
59
+ apiKeySecurityRequirement,
60
+ ...operationObject.security,
61
+ ];
62
+ }
63
+
64
+ return operationObject;
65
+ };
66
+
67
+ const enrichWithRateLimitData = (
68
+ operationObject: RecordAny,
69
+ rateLimitPolicies: PolicyConfigurationFragment[],
70
+ ) => {
71
+ if (rateLimitPolicies.length === 0) {
72
+ return operationObject;
73
+ }
74
+
75
+ const shouldIncludeHeader = rateLimitPolicies.some(
76
+ (policy) => policy.handler.options?.headerMode !== "none",
77
+ );
78
+
79
+ if (!operationObject.responses) {
80
+ operationObject.responses = {};
81
+ }
82
+
83
+ if (!operationObject.responses["429"]) {
84
+ operationObject.responses["429"] = {
85
+ $ref: shouldIncludeHeader
86
+ ? "#/components/responses/RateLimitWithRetryAfter"
87
+ : "#/components/responses/RateLimitNoRetryAfter",
88
+ };
89
+ }
90
+
91
+ return operationObject;
92
+ };
93
+
94
+ // biome-ignore format: for readability
95
+ export const operations = [
96
+ "get", "put", "post", "delete",
97
+ "options", "head", "patch", "trace",
98
+ ];
99
+
100
+ const rateLimitingResponse: OpenAPIV3_1.ResponseObject = {
101
+ description: "Rate Limiting Response",
102
+ content: {
103
+ "application/json": {
104
+ schema: {
105
+ type: "object",
106
+ required: ["type", "title", "status"],
107
+ examples: [
108
+ {
109
+ type: "https://httpproblems.com/http-status/429",
110
+ title: "Too Many Requests",
111
+ status: 429,
112
+ instance: "/foo/bar",
113
+ },
114
+ ],
115
+ properties: {
116
+ type: {
117
+ type: "string",
118
+ example: "https://httpproblems.com/http-status/429",
119
+ description: "A URI reference that identifies the problem.",
120
+ },
121
+ title: {
122
+ type: "string",
123
+ example: "Too Many Requests",
124
+ description: "A short, human-readable summary of the problem.",
125
+ },
126
+ status: {
127
+ type: "number",
128
+ example: 429,
129
+ description: "The HTTP status code.",
130
+ },
131
+ instance: {
132
+ type: "string",
133
+ example: "/foo/bar",
134
+ },
135
+ },
136
+ },
137
+ },
138
+ },
139
+ };
140
+
141
+ const rateLimitingResponseWithHeader: OpenAPIV3_1.ResponseObject = {
142
+ ...rateLimitingResponse,
143
+ headers: {
144
+ "retry-after": {
145
+ description: "The number of seconds to wait before making a new request.",
146
+ schema: {
147
+ type: "integer",
148
+ example: 60,
149
+ },
150
+ },
151
+ },
152
+ };
153
+
154
+ export const enrichWithZuploData = ({
155
+ policiesConfig,
156
+ }: {
157
+ policiesConfig: PoliciesConfigFile;
158
+ }) => {
159
+ return ({ schema }: ProcessorArg) => {
160
+ if (!schema.paths) return schema;
161
+
162
+ let hasRateLimitPolicies = false;
163
+
164
+ for (const [, pathItem] of objectEntries<RecordAny>(schema.paths)) {
165
+ for (const method of operations) {
166
+ const operation = pathItem[method];
167
+ if (!operation?.["x-zuplo-route"]) continue;
168
+
169
+ const inboundPolicies = operation[
170
+ "x-zuplo-route"
171
+ ]?.policies?.inbound?.reduce((acc: string[], policyName: string) => {
172
+ const policy = policiesConfig.policies?.find(
173
+ ({ name }) => name === policyName,
174
+ );
175
+ if (!policy) return acc;
176
+
177
+ // Handle composite policies
178
+ if (policy.handler.export === "CompositeInboundPolicy") {
179
+ const childPolicies = policy.handler.options?.policies as
180
+ | string[]
181
+ | undefined;
182
+ return childPolicies ? [...acc, ...childPolicies] : acc;
183
+ }
184
+
185
+ return [...acc, policyName];
186
+ }, []);
187
+
188
+ if (!inboundPolicies) continue;
189
+
190
+ // Find API key policies
191
+ const apiKeyPolicies =
192
+ policiesConfig.policies?.filter(
193
+ (policy) =>
194
+ inboundPolicies.includes(policy.name) &&
195
+ (policy.handler.export === "ApiAuthKeyInboundPolicy" ||
196
+ policy.handler.export === "ApiKeyInboundPolicy") &&
197
+ !policy.handler.options
198
+ ?.disableAutomaticallyAddingKeyHeaderToOpenApi,
199
+ ) ?? [];
200
+
201
+ // Find rate limit policies
202
+ const rateLimitPolicies =
203
+ policiesConfig.policies?.filter(
204
+ (policy) =>
205
+ inboundPolicies.includes(policy.name) &&
206
+ (policy.handler.export === "RateLimitInboundPolicy" ||
207
+ policy.handler.export === "ComplexRateLimitInboundPolicy"),
208
+ ) ?? [];
209
+
210
+ if (rateLimitPolicies.length > 0) {
211
+ hasRateLimitPolicies = true;
212
+ }
213
+
214
+ // Apply enrichments directly to the operation
215
+ pathItem[method] = enrichWithApiKeyData(operation, apiKeyPolicies);
216
+ pathItem[method] = enrichWithRateLimitData(
217
+ pathItem[method],
218
+ rateLimitPolicies,
219
+ );
220
+ }
221
+ }
222
+
223
+ // Add security scheme if we have API key policies
224
+ if (
225
+ policiesConfig.policies?.some(
226
+ (policy) =>
227
+ policy.handler.export === "ApiAuthKeyInboundPolicy" ||
228
+ policy.handler.export === "ApiKeyInboundPolicy",
229
+ )
230
+ ) {
231
+ if (!schema.components) schema.components = {};
232
+ if (!schema.components.securitySchemes)
233
+ schema.components.securitySchemes = {};
234
+
235
+ if (!schema.components.securitySchemes.api_key) {
236
+ schema.components.securitySchemes.api_key = {
237
+ type: "http",
238
+ scheme: "bearer",
239
+ };
240
+ }
241
+ }
242
+
243
+ // Add rate limiting responses only if we found rate limiting policies
244
+ if (hasRateLimitPolicies) {
245
+ if (!schema.components) schema.components = {};
246
+ if (!schema.components.responses) schema.components.responses = {};
247
+ schema.components.responses.RateLimitNoRetryAfter = rateLimitingResponse;
248
+ schema.components.responses.RateLimitWithRetryAfter =
249
+ rateLimitingResponseWithHeader;
250
+ }
251
+
252
+ return schema;
253
+ };
254
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * This file was automatically generated by json-schema-to-typescript.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and run json-schema-to-typescript to regenerate this file.
5
+ */
6
+
7
+ export interface PoliciesConfigFile {
8
+ policies?: PolicyConfigurationFragment[];
9
+ corsPolicies?: CorsPolicyConfiguration[];
10
+ }
11
+ export interface PolicyConfigurationFragment {
12
+ name: string;
13
+ policyType: string;
14
+ handler: HandlerDefinition;
15
+ options?: {
16
+ [k: string]: unknown;
17
+ };
18
+ }
19
+ export interface HandlerDefinition {
20
+ module: string;
21
+ export: string;
22
+ options?: {
23
+ [k: string]: unknown;
24
+ };
25
+ }
26
+ export interface CorsPolicyConfiguration {
27
+ name: string;
28
+ allowCredentials?: boolean;
29
+ maxAge?: number;
30
+ allowedOrigins: string[] | string;
31
+ allowedMethods?:
32
+ | (
33
+ | "GET"
34
+ | "HEAD"
35
+ | "POST"
36
+ | "PUT"
37
+ | "DELETE"
38
+ | "CONNECT"
39
+ | "OPTIONS"
40
+ | "TRACE"
41
+ | "PATCH"
42
+ )[]
43
+ | string;
44
+ allowedHeaders?: string[] | string;
45
+ exposeHeaders?: string[] | string;
46
+ }
@@ -0,0 +1,35 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { ZuploEnv } from "../app/env.js";
4
+ import type {
5
+ Processor,
6
+ ProcessorArg,
7
+ } from "../config/validators/BuildSchema.js";
8
+ import { removeExtensions } from "../lib/plugins/openapi/processors/removeExtensions.js";
9
+ import { removeParameters } from "../lib/plugins/openapi/processors/removeParameters.js";
10
+ import { removePaths } from "../lib/plugins/openapi/processors/removePaths.js";
11
+ import { enrichWithZuploData } from "./enrich-with-zuplo.js";
12
+ import { enrichWithZuploMcpServerData } from "./enrich-with-zuplo-mcp.js";
13
+
14
+ export const getProcessors = async (rootDir: string): Promise<Processor[]> => {
15
+ const policiesConfig = JSON.parse(
16
+ await fs.readFile(path.join(rootDir, "../config/policies.json"), "utf-8"),
17
+ );
18
+
19
+ return [
20
+ removePaths({ shouldRemove: ({ operation }) => operation["x-internal"] }),
21
+ removeParameters({
22
+ shouldRemove: ({ parameter }) => parameter["x-internal"],
23
+ }),
24
+ enrichWithZuploData({ policiesConfig }),
25
+ enrichWithZuploMcpServerData({ rootDir }),
26
+ ({ schema }: ProcessorArg) => {
27
+ const url = ZuploEnv.serverUrl;
28
+ if (!url) return schema;
29
+ return { ...schema, servers: [{ url }] };
30
+ },
31
+ removeExtensions({ shouldRemove: (key) => key.startsWith("x-zuplo") }),
32
+ ];
33
+ };
34
+
35
+ export default getProcessors;
@@ -0,0 +1,14 @@
1
+ import type { ZudokuConfig } from "../config/validators/validate.js";
2
+
3
+ /**
4
+ * @deprecated `withZuplo` is no longer needed and will automatically be applied. It will be removed in a future version.
5
+ */
6
+ const withZuplo = (config: ZudokuConfig): ZudokuConfig => {
7
+ // biome-ignore lint/suspicious/noConsole: Logging allowed here
8
+ console.warn(
9
+ "`withZuplo` is no longer needed and will automatically be applied. It will be removed in a future version.",
10
+ );
11
+ return config;
12
+ };
13
+
14
+ export default withZuplo;
@@ -1,102 +0,0 @@
1
- import { j as r } from "./jsx-runtime-BzflLqGi.js";
2
- import { e as f } from "./useSuspenseQuery-CSB_rVek.js";
3
- import { useId as p } from "react";
4
- import { c as g } from "./index-DI5SPFK9.js";
5
- import { c as i } from "./cn-5-Gd1Dss.js";
6
- import { a as v } from "./index-Ba6RP577.js";
7
- import { S as x } from "./Spinner-CI6bRyZw.js";
8
- const h = g(
9
- "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
10
- {
11
- variants: {
12
- variant: {
13
- default: "bg-card text-card-foreground",
14
- destructive: "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"
15
- }
16
- },
17
- defaultVariants: {
18
- variant: "default"
19
- }
20
- }
21
- );
22
- function w({
23
- className: e,
24
- variant: t,
25
- ...a
26
- }) {
27
- return /* @__PURE__ */ r.jsx(
28
- "div",
29
- {
30
- "data-slot": "alert",
31
- role: "alert",
32
- className: i(h({ variant: t }), e),
33
- ...a
34
- }
35
- );
36
- }
37
- function y({ className: e, ...t }) {
38
- return /* @__PURE__ */ r.jsx(
39
- "div",
40
- {
41
- "data-slot": "alert-title",
42
- className: i(
43
- "col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
44
- e
45
- ),
46
- ...t
47
- }
48
- );
49
- }
50
- function j({
51
- className: e,
52
- ...t
53
- }) {
54
- return /* @__PURE__ */ r.jsx(
55
- "div",
56
- {
57
- "data-slot": "alert-description",
58
- className: i(
59
- "text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",
60
- e
61
- ),
62
- ...t
63
- }
64
- );
65
- }
66
- let s = null;
67
- const b = () => (s || (s = import("mermaid").then((e) => e.default).catch((e) => {
68
- throw new Error(
69
- "Mermaid is not installed. Please install it with: npm install mermaid",
70
- { cause: e }
71
- );
72
- })), s), P = ({ chart: e, config: t, ...a }) => {
73
- const d = p(), n = v(), {
74
- data: m,
75
- error: o,
76
- isPending: c
77
- } = f({
78
- queryKey: ["mermaid", e, t, n.resolvedTheme],
79
- queryFn: async () => {
80
- const l = await b();
81
- l.initialize({
82
- theme: n.resolvedTheme === "dark" ? "dark" : "base",
83
- ...t
84
- });
85
- const { svg: u } = await l.render(d, e);
86
- return u;
87
- },
88
- enabled: typeof window < "u",
89
- retry: !1
90
- });
91
- return o ? /* @__PURE__ */ r.jsxs(w, { className: "flex flex-col gap-2", variant: "destructive", children: [
92
- /* @__PURE__ */ r.jsx(y, { children: "Mermaid Error" }),
93
- /* @__PURE__ */ r.jsx(j, { className: "overflow-auto wrap-break-word whitespace-pre-wrap font-mono text-xs", children: o.message })
94
- ] }) : c ? /* @__PURE__ */ r.jsx(x, {}) : /* @__PURE__ */ r.jsx("div", { ...a, dangerouslySetInnerHTML: { __html: m } });
95
- };
96
- export {
97
- w as A,
98
- P as M,
99
- y as a,
100
- j as b
101
- };
102
- //# sourceMappingURL=Mermaid-DEztDKFw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Mermaid-DEztDKFw.js","sources":["../src/lib/ui/Alert.tsx","../src/lib/components/Mermaid.tsx"],"sourcesContent":["import { cva, type VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\nimport { cn } from \"../util/cn.js\";\n\nconst alertVariants = cva(\n \"relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current\",\n {\n variants: {\n variant: {\n default: \"bg-card text-card-foreground\",\n destructive:\n \"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n },\n);\n\nfunction Alert({\n className,\n variant,\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof alertVariants>) {\n return (\n <div\n data-slot=\"alert\"\n role=\"alert\"\n className={cn(alertVariants({ variant }), className)}\n {...props}\n />\n );\n}\n\nfunction AlertTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-title\"\n className={cn(\n \"col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDescription({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"alert-description\"\n className={cn(\n \"text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Alert, AlertDescription, AlertTitle };\n","import { useQuery } from \"@tanstack/react-query\";\nimport type { MermaidConfig } from \"mermaid\";\nimport type { ComponentProps } from \"react\";\nimport { useId } from \"react\";\nimport { Alert, AlertDescription, AlertTitle } from \"zudoku/ui/Alert.js\";\nimport { useTheme } from \"../hooks/index.js\";\nimport { Spinner } from \"./Spinner.js\";\n\nexport type MermaidProps = {\n chart: string;\n config?: MermaidConfig;\n} & ComponentProps<\"div\">;\n\nlet mermaidPromise: Promise<typeof import(\"mermaid\").default> | null = null;\n\nconst loadMermaid = () => {\n if (!mermaidPromise) {\n mermaidPromise = import(\"mermaid\")\n .then((mod) => mod.default)\n .catch((error) => {\n throw new Error(\n \"Mermaid is not installed. Please install it with: npm install mermaid\",\n { cause: error },\n );\n });\n }\n return mermaidPromise;\n};\n\nexport const Mermaid = ({ chart, config, ...props }: MermaidProps) => {\n const id = useId();\n const theme = useTheme();\n\n const {\n data: svg,\n error,\n isPending,\n } = useQuery({\n queryKey: [\"mermaid\", chart, config, theme.resolvedTheme],\n queryFn: async () => {\n const mermaid = await loadMermaid();\n mermaid.initialize({\n theme: theme.resolvedTheme === \"dark\" ? \"dark\" : \"base\",\n ...config,\n });\n\n const { svg } = await mermaid.render(id, chart);\n return svg;\n },\n enabled: typeof window !== \"undefined\",\n retry: false,\n });\n\n if (error)\n return (\n <Alert className=\"flex flex-col gap-2\" variant=\"destructive\">\n <AlertTitle>Mermaid Error</AlertTitle>\n <AlertDescription className=\"overflow-auto wrap-break-word whitespace-pre-wrap font-mono text-xs\">\n {error.message}\n </AlertDescription>\n </Alert>\n );\n\n if (isPending) return <Spinner />;\n\n // biome-ignore lint/security/noDangerouslySetInnerHtml: Mermaid generates valid SVG\n return <div {...props} dangerouslySetInnerHTML={{ __html: svg }} />;\n};\n"],"names":["alertVariants","cva","Alert","className","variant","props","jsx","cn","AlertTitle","AlertDescription","mermaidPromise","loadMermaid","mod","error","Mermaid","chart","config","id","useId","theme","useTheme","svg","isPending","useQuery","mermaid","jsxs","Spinner"],"mappings":";;;;;;;AAIA,MAAMA,IAAgBC;AAAA,EACpB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,aACE;AAAA,MAAA;AAAA,IACJ;AAAA,IAEF,iBAAiB;AAAA,MACf,SAAS;AAAA,IAAA;AAAA,EACX;AAEJ;AAEA,SAASC,EAAM;AAAA,EACb,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,GAAGC;AACL,GAAqE;AACnE,SACEC,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,MAAK;AAAA,MACL,WAAWC,EAAGP,EAAc,EAAE,SAAAI,EAAA,CAAS,GAAGD,CAAS;AAAA,MAClD,GAAGE;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAASG,EAAW,EAAE,WAAAL,GAAW,GAAGE,KAAsC;AACxE,SACEC,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAWC;AAAA,QACT;AAAA,QACAJ;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAASI,EAAiB;AAAA,EACxB,WAAAN;AAAA,EACA,GAAGE;AACL,GAAgC;AAC9B,SACEC,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAWC;AAAA,QACT;AAAA,QACAJ;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,IAAA;AAAA,EAAA;AAGV;ACjDA,IAAIK,IAAmE;AAEvE,MAAMC,IAAc,OACbD,MACHA,IAAiB,OAAO,SAAS,EAC9B,KAAK,CAACE,MAAQA,EAAI,OAAO,EACzB,MAAM,CAACC,MAAU;AAChB,QAAM,IAAI;AAAA,IACR;AAAA,IACA,EAAE,OAAOA,EAAA;AAAA,EAAM;AAEnB,CAAC,IAEEH,IAGII,IAAU,CAAC,EAAE,OAAAC,GAAO,QAAAC,GAAQ,GAAGX,QAA0B;AACpE,QAAMY,IAAKC,EAAA,GACLC,IAAQC,EAAA,GAER;AAAA,IACJ,MAAMC;AAAA,IACN,OAAAR;AAAA,IACA,WAAAS;AAAA,EAAA,IACEC,EAAS;AAAA,IACX,UAAU,CAAC,WAAWR,GAAOC,GAAQG,EAAM,aAAa;AAAA,IACxD,SAAS,YAAY;AACnB,YAAMK,IAAU,MAAMb,EAAA;AACtB,MAAAa,EAAQ,WAAW;AAAA,QACjB,OAAOL,EAAM,kBAAkB,SAAS,SAAS;AAAA,QACjD,GAAGH;AAAA,MAAA,CACJ;AAED,YAAM,EAAE,KAAAK,EAAAA,IAAQ,MAAMG,EAAQ,OAAOP,GAAIF,CAAK;AAC9C,aAAOM;AAAAA,IACT;AAAA,IACA,SAAS,OAAO,SAAW;AAAA,IAC3B,OAAO;AAAA,EAAA,CACR;AAED,SAAIR,IAEAY,gBAAAA,EAAAA,KAACvB,GAAA,EAAM,WAAU,uBAAsB,SAAQ,eAC7C,UAAA;AAAA,IAAAI,gBAAAA,EAAAA,IAACE,KAAW,UAAA,gBAAA,CAAa;AAAA,IACzBF,gBAAAA,EAAAA,IAACG,GAAA,EAAiB,WAAU,uEACzB,YAAM,QAAA,CACT;AAAA,EAAA,GACF,IAGAa,IAAkBhB,gBAAAA,MAACoB,GAAA,CAAA,CAAQ,IAGxBpB,gBAAAA,EAAAA,IAAC,SAAK,GAAGD,GAAO,yBAAyB,EAAE,QAAQgB,KAAO;AACnE;"}