@stainless-api/docs-ui 0.1.0-beta.7 → 0.1.0-beta.70

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 (215) hide show
  1. package/dist/breadcrumbs-BhYwbXkc.d.ts +25 -0
  2. package/dist/breadcrumbs-Cvm5Ifm7.d.ts +25 -0
  3. package/dist/breadcrumbs-DA4WgDhR.js +63 -0
  4. package/dist/chunk-BN_g-Awi.js +18 -0
  5. package/dist/cli-F3kMmeoJ.js +166 -0
  6. package/dist/component-P9sn5yyG.js +23 -0
  7. package/dist/component-generics-ByGsYTc8.d.ts +30 -0
  8. package/dist/component-generics-POFirVVb.js +45 -0
  9. package/dist/component-generics-zU0Pqx8m.d.ts +30 -0
  10. package/dist/components/MaskedInput.d.ts +14 -0
  11. package/dist/components/MaskedInput.js +76 -0
  12. package/dist/components/breadcrumbs.d.ts +2 -0
  13. package/dist/components/breadcrumbs.js +9 -0
  14. package/dist/components/icons.d.ts +60 -0
  15. package/dist/components/icons.js +3 -0
  16. package/dist/components/index.d.ts +11 -0
  17. package/dist/components/index.js +19 -0
  18. package/dist/components/method.d.ts +2 -0
  19. package/dist/components/method.js +10 -0
  20. package/dist/components/overview.d.ts +2 -0
  21. package/dist/components/overview.js +11 -0
  22. package/dist/components/primitives.d.ts +2 -0
  23. package/dist/components/primitives.js +8 -0
  24. package/dist/components/properties.d.ts +2 -0
  25. package/dist/components/properties.js +9 -0
  26. package/dist/components/sdk-sidebar.d.ts +2 -0
  27. package/dist/components/sdk-sidebar.js +10 -0
  28. package/dist/components/sdk.d.ts +2 -0
  29. package/dist/components/sdk.js +10 -0
  30. package/dist/components/snippets.d.ts +3 -0
  31. package/dist/components/snippets.js +9 -0
  32. package/dist/components/stl-sidebar.d.ts +2 -0
  33. package/dist/components/stl-sidebar.js +5 -0
  34. package/dist/components-w1JmIrB0.js +71 -0
  35. package/dist/contexts/component-generics.d.ts +2 -0
  36. package/dist/contexts/component-generics.js +3 -0
  37. package/dist/contexts/component-types.d.ts +17 -0
  38. package/dist/contexts/component-types.js +0 -0
  39. package/dist/contexts/component.d.ts +30 -0
  40. package/dist/contexts/component.js +30 -0
  41. package/dist/contexts/docs.d.ts +2 -0
  42. package/dist/contexts/docs.js +3 -0
  43. package/dist/contexts/index.d.ts +23 -0
  44. package/dist/contexts/index.js +7 -0
  45. package/dist/contexts/markdown.d.ts +2 -0
  46. package/dist/contexts/markdown.js +4 -0
  47. package/dist/contexts/navigation.d.ts +2 -0
  48. package/dist/contexts/navigation.js +3 -0
  49. package/dist/contexts/use-components.d.ts +15 -0
  50. package/dist/contexts/use-components.js +4 -0
  51. package/dist/contexts-CVj20VV4.js +41 -0
  52. package/dist/csharp-D6_jlynY.js +283 -0
  53. package/dist/docs-BmOB2f-I.js +61 -0
  54. package/dist/docs-g4IPmtZr.d.ts +48 -0
  55. package/dist/docs-z3fl2eW-.d.ts +48 -0
  56. package/dist/go-COaHV3Hc.js +303 -0
  57. package/dist/http-fOPCX17A.js +389 -0
  58. package/dist/icons-BYKn5X8E.js +885 -0
  59. package/dist/index-B8Zys1C2.d.ts +347 -0
  60. package/dist/index-C5Zmb2CI.d.ts +16 -0
  61. package/dist/index-CwjGm9zX.d.ts +1722 -0
  62. package/dist/index-D7PkxNgB.d.ts +16 -0
  63. package/dist/index-DIaM6Ync.d.ts +347 -0
  64. package/dist/index.d.ts +20 -0
  65. package/dist/index.js +32 -7542
  66. package/dist/java-CxGSJVvv.js +403 -0
  67. package/dist/languages/cli.d.ts +12 -0
  68. package/dist/languages/cli.js +21 -0
  69. package/dist/languages/csharp.d.ts +12 -0
  70. package/dist/languages/csharp.js +9 -0
  71. package/dist/languages/go.d.ts +12 -0
  72. package/dist/languages/go.js +9 -0
  73. package/dist/languages/http.d.ts +12 -0
  74. package/dist/languages/http.js +20 -0
  75. package/dist/languages/index.d.ts +12 -0
  76. package/dist/languages/index.js +29 -0
  77. package/dist/languages/java.d.ts +12 -0
  78. package/dist/languages/java.js +9 -0
  79. package/dist/languages/python.d.ts +12 -0
  80. package/dist/languages/python.js +9 -0
  81. package/dist/languages/ruby.d.ts +12 -0
  82. package/dist/languages/ruby.js +9 -0
  83. package/dist/languages/terraform.d.ts +12 -0
  84. package/dist/languages/terraform.js +9 -0
  85. package/dist/languages/typescript.d.ts +12 -0
  86. package/dist/languages/typescript.js +9 -0
  87. package/dist/languages-B6eap2M6.js +30 -0
  88. package/dist/markdown/index.d.ts +12 -0
  89. package/dist/markdown/index.js +107 -0
  90. package/dist/markdown/md.d.ts +15 -0
  91. package/dist/markdown/md.js +41 -0
  92. package/dist/markdown/printer.d.ts +13 -0
  93. package/dist/markdown/printer.js +100 -0
  94. package/dist/markdown/utils.d.ts +21 -0
  95. package/dist/markdown/utils.js +31 -0
  96. package/dist/markdown-CTKHMLVr.js +49 -0
  97. package/dist/markdown-Cdh0TSHp.d.ts +22 -0
  98. package/dist/markdown-Cibv9fDR.d.ts +22 -0
  99. package/dist/method-630cPKDl.d.ts +59 -0
  100. package/dist/method-BPDUyBlD.js +96 -0
  101. package/dist/method-BzkPRXGL.d.ts +59 -0
  102. package/dist/navigation-BW-SBvb4.d.ts +29 -0
  103. package/dist/navigation-DWYqC_HX.d.ts +29 -0
  104. package/dist/navigation-aoYZ_tl4.js +24 -0
  105. package/dist/overview-Cui1XtuC.d.ts +39 -0
  106. package/dist/overview-DFwfIK6k.js +138 -0
  107. package/dist/overview-RXc9iPzz.d.ts +39 -0
  108. package/dist/primitives-DJEqe_r1.js +250 -0
  109. package/dist/primitives-DhGxFYx6.d.ts +105 -0
  110. package/dist/primitives-MsH-h0bU.d.ts +105 -0
  111. package/dist/properties-BnbBKd5a.js +132 -0
  112. package/dist/properties-Bynmj9_H.d.ts +54 -0
  113. package/dist/properties-C9W4QJ_F.d.ts +54 -0
  114. package/dist/python-DsTuWCKE.js +269 -0
  115. package/dist/routing-C64k4fmX.js +205 -0
  116. package/dist/routing-Cm_9XJiQ.d.ts +61 -0
  117. package/dist/routing-utiR5mY3.d.ts +61 -0
  118. package/dist/routing.d.ts +2 -0
  119. package/dist/routing.js +3 -180
  120. package/dist/ruby-BncKp6hd.js +387 -0
  121. package/dist/sdk-BvZeXpsj.d.ts +122 -0
  122. package/dist/sdk-Bw99eXxA.js +399 -0
  123. package/dist/sdk-GMOw94wL.d.ts +122 -0
  124. package/dist/sdk-sidebar-NCBSWuUW.d.ts +15 -0
  125. package/dist/sdk-sidebar-VNY2-O1Y.d.ts +15 -0
  126. package/dist/sdk-sidebar-V_MTkVw8.js +50 -0
  127. package/dist/snippets-BehbU3rt.js +164 -0
  128. package/dist/snippets-Bj7Ey56K.d.ts +53 -0
  129. package/dist/snippets-CQQSDvg2.d.ts +53 -0
  130. package/dist/spec.d.ts +65 -0
  131. package/dist/spec.js +167 -0
  132. package/dist/stl-sidebar-CXzs_shz.d.ts +58 -0
  133. package/dist/stl-sidebar-DSkUHwcU.d.ts +58 -0
  134. package/dist/stl-sidebar-WtimNrk1.js +106 -0
  135. package/dist/style-HpXpcJ9v.js +172 -0
  136. package/dist/style.d.ts +171 -0
  137. package/dist/style.js +3 -0
  138. package/dist/styles/main.css +744 -754
  139. package/dist/styles/main.js +0 -0
  140. package/dist/styles/primitives.css +327 -458
  141. package/dist/styles/primitives.js +0 -0
  142. package/dist/styles/resets.css +32 -41
  143. package/dist/styles/resets.js +0 -0
  144. package/dist/styles/search.css +192 -270
  145. package/dist/styles/search.js +0 -0
  146. package/dist/styles/sidebar.css +170 -69
  147. package/dist/styles/sidebar.js +0 -0
  148. package/dist/styles/variables.css +26 -89
  149. package/dist/styles/variables.js +0 -0
  150. package/dist/styles.css +3273 -0
  151. package/dist/styles.mjs +1 -0
  152. package/dist/terraform-B95X4rNK.js +243 -0
  153. package/dist/typescript-n46M9OtL.js +449 -0
  154. package/dist/use-components-BUz3GbO4.js +7 -0
  155. package/dist/utils-DPbkW1Tz.js +54 -0
  156. package/dist/utils.d.ts +20 -0
  157. package/dist/utils.js +3 -0
  158. package/package.json +74 -22
  159. package/dist/mcp.js +0 -16003
  160. package/dist/styles/snippets.css +0 -132
  161. package/src/components/breadcrumbs.tsx +0 -94
  162. package/src/components/chat.tsx +0 -154
  163. package/src/components/dropdown.tsx +0 -91
  164. package/src/components/icons.tsx +0 -584
  165. package/src/components/index.ts +0 -9
  166. package/src/components/method.tsx +0 -144
  167. package/src/components/overview.tsx +0 -159
  168. package/src/components/primitives.tsx +0 -284
  169. package/src/components/properties.tsx +0 -130
  170. package/src/components/scripts/dropdown.ts +0 -78
  171. package/src/components/sdk.tsx +0 -402
  172. package/src/components/sidebar.tsx +0 -99
  173. package/src/components/snippets.tsx +0 -179
  174. package/src/contexts/component-generics.tsx +0 -48
  175. package/src/contexts/component-types.tsx +0 -5
  176. package/src/contexts/component.tsx +0 -32
  177. package/src/contexts/docs.tsx +0 -75
  178. package/src/contexts/index.tsx +0 -17
  179. package/src/contexts/markdown.tsx +0 -43
  180. package/src/contexts/navigation.tsx +0 -44
  181. package/src/contexts/search.tsx +0 -28
  182. package/src/contexts/use-components.tsx +0 -4
  183. package/src/index.ts +0 -6
  184. package/src/languages/go.tsx +0 -281
  185. package/src/languages/http.tsx +0 -321
  186. package/src/languages/index.ts +0 -26
  187. package/src/languages/java.tsx +0 -358
  188. package/src/languages/python.tsx +0 -255
  189. package/src/languages/ruby.tsx +0 -320
  190. package/src/languages/typescript.tsx +0 -393
  191. package/src/markdown/index.ts +0 -107
  192. package/src/markdown/md.ts +0 -45
  193. package/src/markdown/utils.ts +0 -49
  194. package/src/routing.ts +0 -238
  195. package/src/search/form.tsx +0 -127
  196. package/src/search/index.tsx +0 -1
  197. package/src/search/indexer.ts +0 -246
  198. package/src/search/mcp.ts +0 -61
  199. package/src/search/printer.tsx +0 -86
  200. package/src/search/providers/algolia.ts +0 -88
  201. package/src/search/providers/fuse.ts +0 -19
  202. package/src/search/providers/pagefind.ts +0 -17
  203. package/src/search/providers/walker.ts +0 -30
  204. package/src/search/results.tsx +0 -181
  205. package/src/search/state.ts +0 -64
  206. package/src/search/types.ts +0 -116
  207. package/src/style.ts +0 -197
  208. package/src/styles/main.css +0 -993
  209. package/src/styles/primitives.css +0 -572
  210. package/src/styles/resets.css +0 -47
  211. package/src/styles/search.css +0 -342
  212. package/src/styles/sidebar.css +0 -87
  213. package/src/styles/snippets.css +0 -132
  214. package/src/styles/variables.css +0 -90
  215. package/src/utils.ts +0 -41
@@ -0,0 +1,164 @@
1
+ import { i as useDeclaration, s as useLanguage, u as useSnippet } from "./docs-BmOB2f-I.js";
2
+ import { r as useHighlight } from "./markdown-CTKHMLVr.js";
3
+ import { t as useComponents } from "./use-components-BUz3GbO4.js";
4
+ import { t as style_default } from "./style-HpXpcJ9v.js";
5
+ import * as React$1 from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import clsx from "clsx";
8
+ import { CheckIcon, CircleAlertIcon, CopyIcon } from "lucide-react";
9
+ import { Badge, Button, getHttpMethod } from "@stainless-api/ui-primitives";
10
+
11
+ //#region src/components/snippets.tsx
12
+ function SnippetCode({ content, language }) {
13
+ const lang = useLanguage();
14
+ const highlighted = useHighlight(content, language || lang);
15
+ return /* @__PURE__ */ jsx("div", {
16
+ className: style_default.SnippetCode,
17
+ "data-stldocs-copy-content": true,
18
+ dangerouslySetInnerHTML: { __html: highlighted }
19
+ });
20
+ }
21
+ function SnippetContainer({ children }) {
22
+ return /* @__PURE__ */ jsx("div", {
23
+ className: clsx(style_default.Snippet),
24
+ children
25
+ });
26
+ }
27
+ function SnippetRequestContainer({ children }) {
28
+ return /* @__PURE__ */ jsx("div", { children });
29
+ }
30
+ function Snippet({ requestTitle, method, transformRequestSnippet }) {
31
+ const Docs = useComponents();
32
+ const language = useLanguage();
33
+ const originalSnippet = useSnippet(method.stainlessPath, void 0, language === "http" ? "curl" : "default");
34
+ const decl = useDeclaration(method.stainlessPath, false);
35
+ if (!originalSnippet) {
36
+ console.warn(`Snippet not found for method '${method.stainlessPath}'`);
37
+ return null;
38
+ }
39
+ const signature = decl && "qualified" in decl ? decl.qualified : void 0;
40
+ const responses = method.exampleResponses;
41
+ const snippet = transformRequestSnippet ? transformRequestSnippet({
42
+ snippet: originalSnippet,
43
+ language
44
+ }) : originalSnippet;
45
+ const httpMethod = getHttpMethod(method.httpMethod);
46
+ return /* @__PURE__ */ jsxs(Docs.SnippetContainer, {
47
+ signature,
48
+ method,
49
+ children: [snippet && /* @__PURE__ */ jsx(Docs.SnippetRequestContainer, {
50
+ signature,
51
+ children: /* @__PURE__ */ jsxs("div", {
52
+ className: style_default.SnippetRequest,
53
+ "data-stldocs-copy-parent": true,
54
+ children: [
55
+ /* @__PURE__ */ jsxs("div", {
56
+ className: style_default.SnippetRequestTitle,
57
+ children: [
58
+ /* @__PURE__ */ jsxs("div", {
59
+ className: style_default.SnippetRequestTitleMethod,
60
+ children: [httpMethod && /* @__PURE__ */ jsx(Badge.HTTP, {
61
+ method: httpMethod,
62
+ iconOnly: true
63
+ }), /* @__PURE__ */ jsx("h3", { children: method.summary || method.title })]
64
+ }),
65
+ /* @__PURE__ */ jsx("div", {
66
+ className: style_default.SnippetRequestTitleContent,
67
+ children: requestTitle
68
+ }),
69
+ /* @__PURE__ */ jsx(Docs.SnippetButtons, { content: snippet })
70
+ ]
71
+ }),
72
+ /* @__PURE__ */ jsx(Docs.SnippetCode, {
73
+ content: snippet,
74
+ signature
75
+ }),
76
+ /* @__PURE__ */ jsx(Docs.SnippetFooter, {})
77
+ ]
78
+ })
79
+ }), responses && /* @__PURE__ */ jsx(Docs.SnippetResponse, { responses })]
80
+ });
81
+ }
82
+ function SnippetButtons({ content }) {
83
+ const [CopyButtonIcon, setCopyIcon] = React$1.useState(CopyIcon);
84
+ async function handleCopy() {
85
+ try {
86
+ await navigator.clipboard.writeText(content);
87
+ setCopyIcon(CheckIcon);
88
+ } catch {
89
+ setCopyIcon(CircleAlertIcon);
90
+ }
91
+ setTimeout(() => setCopyIcon(CopyIcon), 1e3);
92
+ }
93
+ return /* @__PURE__ */ jsx(Button, {
94
+ variant: "outline",
95
+ "data-stldocs-snippet-copy": true,
96
+ children: /* @__PURE__ */ jsx(CopyButtonIcon, {
97
+ size: 16,
98
+ className: style_default.Icon,
99
+ onClick: handleCopy
100
+ })
101
+ });
102
+ }
103
+ function SnippetFooter() {
104
+ return null;
105
+ }
106
+ function SnippetResponse({ responses }) {
107
+ const { SnippetCode } = useComponents();
108
+ if (!responses) return null;
109
+ const mappedResponses = Object.keys(responses).map((key) => {
110
+ const responseContent = responses[key];
111
+ if (!responseContent) return null;
112
+ const responseType = Object.keys(responseContent)[0];
113
+ if (!responseType) return null;
114
+ const response = responseContent[responseType];
115
+ if (!response) return null;
116
+ const examples = response?.examples;
117
+ if (!examples) return null;
118
+ const exampleType = Object.keys(examples)[0];
119
+ if (!exampleType) return null;
120
+ let value = examples[exampleType]?.value;
121
+ if (!value) return null;
122
+ let language = "none";
123
+ if (responseType === "application/json" || typeof value === "object") {
124
+ language = "json";
125
+ value = JSON.stringify(value, null, 2);
126
+ }
127
+ return {
128
+ language,
129
+ responseCode: key,
130
+ content: value
131
+ };
132
+ }).filter(Boolean);
133
+ if (mappedResponses.length === 0) return null;
134
+ return /* @__PURE__ */ jsx("div", {
135
+ className: style_default.SnippetMultiResponse,
136
+ children: /* @__PURE__ */ jsxs("div", {
137
+ className: clsx(style_default.Snippet),
138
+ children: [/* @__PURE__ */ jsx("div", {
139
+ className: clsx(style_default.SnippetResponseTab, mappedResponses.length === 1 && style_default.SnippetResponseTabSingleReturn),
140
+ children: mappedResponses.map(({ responseCode }, index) => /* @__PURE__ */ jsx("div", {
141
+ "data-snippet-response-tab-id": `snippet-response-tab-${responseCode}-${index}`,
142
+ className: clsx(style_default.SnippetResponseTabItem, index === 0 && style_default.SnippetResponseTabItemActive),
143
+ children: /* @__PURE__ */ jsxs(Button, {
144
+ disabled: mappedResponses.length === 1,
145
+ variant: "ghost",
146
+ children: [responseCode, " example"]
147
+ })
148
+ }, `snippet-response-tab-item-${responseCode}-${index}`))
149
+ }), mappedResponses.map(({ responseCode, content, language }, index) => {
150
+ return /* @__PURE__ */ jsx("div", {
151
+ className: clsx(style_default.SnippetResponsePane, index === 0 && style_default.SnippetResponsePaneActive),
152
+ "data-snippet-response-pane-id": `snippet-response-tab-${responseCode}-${index}`,
153
+ children: /* @__PURE__ */ jsx(SnippetCode, {
154
+ content,
155
+ language
156
+ })
157
+ }, `snippet-response-${responseCode}-${index}`);
158
+ })]
159
+ })
160
+ });
161
+ }
162
+
163
+ //#endregion
164
+ export { SnippetFooter as a, SnippetContainer as i, SnippetButtons as n, SnippetRequestContainer as o, SnippetCode as r, SnippetResponse as s, Snippet as t };
@@ -0,0 +1,53 @@
1
+ import { d as Method, o as HasStainlessPath } from "./index-CwjGm9zX.js";
2
+ import { w as TransformRequestSnippetFn } from "./sdk-BvZeXpsj.js";
3
+ import * as React$1 from "react";
4
+ import * as react_jsx_runtime50 from "react/jsx-runtime";
5
+
6
+ //#region src/components/snippets.d.ts
7
+ type SnippetCodeProps = {
8
+ content: string;
9
+ signature?: string;
10
+ language?: string;
11
+ };
12
+ declare function SnippetCode({
13
+ content,
14
+ language
15
+ }: SnippetCodeProps): react_jsx_runtime50.JSX.Element;
16
+ type SnippetProps = {
17
+ method: Partial<Method> & HasStainlessPath;
18
+ requestTitle?: React$1.ReactNode;
19
+ transformRequestSnippet?: TransformRequestSnippetFn;
20
+ };
21
+ type SnippetContainerProps = {
22
+ method: Partial<Method> & HasStainlessPath;
23
+ children: React$1.ReactNode;
24
+ signature?: string;
25
+ };
26
+ declare function SnippetContainer({
27
+ children
28
+ }: SnippetContainerProps): react_jsx_runtime50.JSX.Element;
29
+ type SnippetRequestContainerProps = {
30
+ children?: React$1.ReactNode;
31
+ signature?: string;
32
+ };
33
+ declare function SnippetRequestContainer({
34
+ children
35
+ }: SnippetRequestContainerProps): react_jsx_runtime50.JSX.Element;
36
+ declare function Snippet({
37
+ requestTitle,
38
+ method,
39
+ transformRequestSnippet
40
+ }: SnippetProps): react_jsx_runtime50.JSX.Element | null;
41
+ declare function SnippetButtons({
42
+ content
43
+ }: {
44
+ content: string;
45
+ }): react_jsx_runtime50.JSX.Element;
46
+ declare function SnippetFooter(): React$1.ReactNode;
47
+ declare function SnippetResponse({
48
+ responses
49
+ }: {
50
+ responses: Method['exampleResponses'];
51
+ }): react_jsx_runtime50.JSX.Element | null;
52
+ //#endregion
53
+ export { SnippetContainer as a, SnippetProps as c, SnippetResponse as d, SnippetCodeProps as i, SnippetRequestContainer as l, SnippetButtons as n, SnippetContainerProps as o, SnippetCode as r, SnippetFooter as s, Snippet as t, SnippetRequestContainerProps as u };
@@ -0,0 +1,53 @@
1
+ import { d as Method, o as HasStainlessPath } from "./index-CwjGm9zX.js";
2
+ import { w as TransformRequestSnippetFn } from "./sdk-GMOw94wL.js";
3
+ import * as React$1 from "react";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
5
+
6
+ //#region src/components/snippets.d.ts
7
+ type SnippetCodeProps = {
8
+ content: string;
9
+ signature?: string;
10
+ language?: string;
11
+ };
12
+ declare function SnippetCode({
13
+ content,
14
+ language
15
+ }: SnippetCodeProps): react_jsx_runtime0.JSX.Element;
16
+ type SnippetProps = {
17
+ method: Partial<Method> & HasStainlessPath;
18
+ requestTitle?: React$1.ReactNode;
19
+ transformRequestSnippet?: TransformRequestSnippetFn;
20
+ };
21
+ type SnippetContainerProps = {
22
+ method: Partial<Method> & HasStainlessPath;
23
+ children: React$1.ReactNode;
24
+ signature?: string;
25
+ };
26
+ declare function SnippetContainer({
27
+ children
28
+ }: SnippetContainerProps): react_jsx_runtime0.JSX.Element;
29
+ type SnippetRequestContainerProps = {
30
+ children?: React$1.ReactNode;
31
+ signature?: string;
32
+ };
33
+ declare function SnippetRequestContainer({
34
+ children
35
+ }: SnippetRequestContainerProps): react_jsx_runtime0.JSX.Element;
36
+ declare function Snippet({
37
+ requestTitle,
38
+ method,
39
+ transformRequestSnippet
40
+ }: SnippetProps): react_jsx_runtime0.JSX.Element | null;
41
+ declare function SnippetButtons({
42
+ content
43
+ }: {
44
+ content: string;
45
+ }): react_jsx_runtime0.JSX.Element;
46
+ declare function SnippetFooter(): React$1.ReactNode;
47
+ declare function SnippetResponse({
48
+ responses
49
+ }: {
50
+ responses: Method['exampleResponses'];
51
+ }): react_jsx_runtime0.JSX.Element | null;
52
+ //#endregion
53
+ export { SnippetContainer as a, SnippetProps as c, SnippetResponse as d, SnippetCodeProps as i, SnippetRequestContainer as l, SnippetButtons as n, SnippetContainerProps as o, SnippetCode as r, SnippetFooter as s, Snippet as t, SnippetRequestContainerProps as u };
package/dist/spec.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { _ as Spec, d as Method, f as Model, i as DeclarationNode, m as Resource, v as SpecLanguage } from "./index-CwjGm9zX.js";
2
+ import { t as DocsLanguage } from "./routing-Cm_9XJiQ.js";
3
+
4
+ //#region src/spec.d.ts
5
+ type SecurityScheme = Spec['security_schemes'][number];
6
+ interface SpecTransforms {
7
+ resource(resource: Resource): Resource;
8
+ method(method: Method): Method;
9
+ model(model: Model): Model;
10
+ declaration(decl: DeclarationNode, language: SpecLanguage): DeclarationNode;
11
+ securityScheme(scheme: SecurityScheme): SecurityScheme;
12
+ snippet(snippet: string, language: string): string;
13
+ markdown(content?: string): string | undefined;
14
+ }
15
+ declare function defineTransforms(transforms?: Partial<SpecTransforms>): {
16
+ resource: (resource: Resource) => Resource;
17
+ method: (method: Method) => Method;
18
+ model: (model: Model) => Model;
19
+ declaration: (decl: DeclarationNode, language: SpecLanguage) => DeclarationNode;
20
+ securityScheme: (scheme: SecurityScheme) => SecurityScheme;
21
+ snippet: (snippet: string, language: string) => string;
22
+ markdown: (content?: string) => string | undefined;
23
+ };
24
+ declare function generateNavigation(resource: Partial<Resource>): {
25
+ title: string | undefined;
26
+ name: string | undefined;
27
+ subresources: Record<string, Partial<Resource>> | undefined;
28
+ methods: Record<string, Partial<Method>> | undefined;
29
+ models: Record<string, Partial<Model>> | undefined;
30
+ stainlessPath: string | undefined;
31
+ terraform: {
32
+ Name: string;
33
+ QualifiedName: string;
34
+ } | undefined;
35
+ };
36
+ declare function generateSpecForResource(spec: Spec, name: string, lang: DocsLanguage, transforms: SpecTransforms): Partial<Spec>;
37
+ declare function transform(spec: Spec, transforms: SpecTransforms): {
38
+ name: string;
39
+ lang: "http" | "node" | "python" | "go" | "typescript" | "terraform" | "ruby" | "java" | "kotlin" | "csharp" | "php" | "cli";
40
+ spec: Partial<Spec>;
41
+ }[];
42
+ declare function split(spec: Spec, transforms?: SpecTransforms): {
43
+ resources: ReturnType<typeof transform>;
44
+ navigation: {
45
+ languages: ("http" | "node" | "python" | "go" | "typescript" | "terraform" | "ruby" | "java" | "kotlin")[] | undefined;
46
+ resources: {
47
+ [k: string]: {
48
+ title: string | undefined;
49
+ name: string | undefined;
50
+ subresources: Record<string, Partial<Resource>> | undefined;
51
+ methods: Record<string, Partial<Method>> | undefined;
52
+ models: Record<string, Partial<Model>> | undefined;
53
+ stainlessPath: string | undefined;
54
+ terraform: {
55
+ Name: string;
56
+ QualifiedName: string;
57
+ } | undefined;
58
+ };
59
+ };
60
+ };
61
+ };
62
+ declare function parseSpec(content: string): Spec | undefined;
63
+ declare function retrieve(apiKey: string, project: string, revision: string): Promise<Spec | undefined>;
64
+ //#endregion
65
+ export { SecurityScheme, SpecTransforms, defineTransforms, generateNavigation, generateSpecForResource, parseSpec, retrieve, split, transform };
package/dist/spec.js ADDED
@@ -0,0 +1,167 @@
1
+ import { n as Languages } from "./routing-C64k4fmX.js";
2
+ import { i as isResourceEmpty } from "./utils-DPbkW1Tz.js";
3
+
4
+ //#region src/spec.ts
5
+ const defaultTransforms = {
6
+ resource: (resource) => resource,
7
+ method: (method) => method,
8
+ model: (model) => model,
9
+ declaration: (decl) => decl,
10
+ securityScheme: (scheme) => scheme,
11
+ snippet: (snippet) => snippet,
12
+ markdown: (content) => content
13
+ };
14
+ function defineTransforms(transforms = {}) {
15
+ return {
16
+ ...defaultTransforms,
17
+ ...transforms
18
+ };
19
+ }
20
+ function removeStudioRefs(obj) {
21
+ if (typeof obj !== "object" || obj === null) return obj;
22
+ if (Array.isArray(obj)) return obj.map(removeStudioRefs);
23
+ const newObj = {};
24
+ for (const [key, value] of Object.entries(obj)) if (key !== "oasRef" && key !== "configRef") newObj[key] = removeStudioRefs(value);
25
+ return newObj;
26
+ }
27
+ function mapEntries({ input, fn, filter }) {
28
+ if (!input) return;
29
+ const output = {};
30
+ for (const [name, entry] of Object.entries(input)) {
31
+ if (filter && !filter(name, entry)) continue;
32
+ output[name] = fn ? fn(entry) : entry;
33
+ }
34
+ return output;
35
+ }
36
+ function transformRecursively(resource, transforms) {
37
+ return {
38
+ ...transforms.resource(resource),
39
+ methods: mapEntries({
40
+ input: resource.methods,
41
+ fn: (method) => transforms.method(method)
42
+ }) ?? {},
43
+ models: mapEntries({
44
+ input: resource.models,
45
+ fn: (model) => transforms.model(model)
46
+ }) ?? {},
47
+ subresources: mapEntries({
48
+ input: resource.subresources,
49
+ fn: (sub) => transformRecursively(sub, transforms)
50
+ }) ?? {}
51
+ };
52
+ }
53
+ function generateNavigation(resource) {
54
+ const { title, name, stainlessPath, terraform } = resource;
55
+ return {
56
+ title,
57
+ name,
58
+ subresources: mapEntries({
59
+ input: resource.subresources,
60
+ fn: generateNavigation
61
+ }),
62
+ methods: mapEntries({
63
+ input: resource.methods,
64
+ fn: (method) => ({
65
+ name: method.name,
66
+ stainlessPath: method.stainlessPath,
67
+ summary: method.summary,
68
+ httpMethod: method.httpMethod
69
+ })
70
+ }),
71
+ models: mapEntries({
72
+ input: resource.models,
73
+ fn: (model) => ({
74
+ name: model.name,
75
+ stainlessPath: model.stainlessPath
76
+ })
77
+ }),
78
+ stainlessPath,
79
+ terraform
80
+ };
81
+ }
82
+ function generateSpecForResource(spec, name, lang, transforms) {
83
+ const resource = spec.resources[name];
84
+ if (!resource) throw new Error(`Invalid resource: ${name}`);
85
+ return {
86
+ resources: {
87
+ [name]: transformRecursively(resource, transforms),
88
+ ...spec.resources["$shared"] ? { $shared: transformRecursively(spec.resources["$shared"], transforms) } : {}
89
+ },
90
+ security_schemes: spec.security_schemes?.map((scheme) => transforms.securityScheme(scheme)),
91
+ decls: { [lang]: mapEntries({
92
+ input: spec.decls[lang] ?? {},
93
+ filter: (name) => name.startsWith(resource.stainlessPath) || name.startsWith("(resource) $shared"),
94
+ fn: (decl) => transforms.declaration(decl, lang)
95
+ }) },
96
+ snippets: mapEntries({
97
+ input: spec.snippets,
98
+ filter: (name) => name.startsWith(lang),
99
+ fn: (snippets) => mapEntries({
100
+ input: snippets,
101
+ filter: (name) => name.startsWith(resource.stainlessPath),
102
+ fn: (snippet) => transforms.snippet(snippet, lang)
103
+ }) ?? {}
104
+ })
105
+ };
106
+ }
107
+ function transform(spec, transforms) {
108
+ const t = {
109
+ ...transforms,
110
+ declaration: (decl, lang) => transforms.declaration({
111
+ ...decl,
112
+ ..."docstring" in decl ? { docstring: transforms.markdown(decl.docstring) } : {}
113
+ }, lang),
114
+ method: (method) => transforms.method({
115
+ ...method,
116
+ description: transforms.markdown(method.description),
117
+ deprecated: typeof method.deprecated === "string" ? transforms.markdown(method.deprecated) : method.deprecated
118
+ }),
119
+ securityScheme: (scheme) => transforms.securityScheme({
120
+ ...scheme,
121
+ description: transforms.markdown(scheme.description)
122
+ })
123
+ };
124
+ const output = [];
125
+ for (const lang of Languages) for (const [name, resource] of Object.entries(spec.resources)) {
126
+ if (isResourceEmpty(resource)) continue;
127
+ output.push({
128
+ name,
129
+ lang,
130
+ spec: generateSpecForResource(spec, name, lang, t)
131
+ });
132
+ }
133
+ return output;
134
+ }
135
+ function split(spec, transforms) {
136
+ return {
137
+ resources: transform(spec, transforms ?? defineTransforms()).map(removeStudioRefs),
138
+ navigation: {
139
+ languages: spec.docs?.languages,
140
+ resources: Object.fromEntries(Object.entries(spec.resources).filter(([, res]) => !isResourceEmpty(res)).map(([name, res]) => [name, generateNavigation(res)]))
141
+ }
142
+ };
143
+ }
144
+ function parseSpec(content) {
145
+ const parsed = JSON.parse(content);
146
+ if (parsed && typeof parsed === "object" && "kind" in parsed && parsed.kind === "spec") return parsed;
147
+ }
148
+ async function retrieve(apiKey, project, revision) {
149
+ const data = await (await fetch("https://app.stainless.com/api/generate/spec", {
150
+ method: "POST",
151
+ headers: {
152
+ Authorization: `Bearer ${apiKey}`,
153
+ "Content-Type": "application/json"
154
+ },
155
+ body: JSON.stringify({
156
+ project,
157
+ source: {
158
+ type: "git",
159
+ revision
160
+ }
161
+ })
162
+ })).json();
163
+ if (typeof data.spec === "string") return parseSpec(data.spec);
164
+ }
165
+
166
+ //#endregion
167
+ export { defineTransforms, generateNavigation, generateSpecForResource, parseSpec, retrieve, split, transform };
@@ -0,0 +1,58 @@
1
+ import { ReactNode } from "react";
2
+ import * as react_jsx_runtime43 from "react/jsx-runtime";
3
+
4
+ //#region src/components/stl-sidebar.d.ts
5
+ declare module 'react' {
6
+ namespace JSX {
7
+ interface IntrinsicElements {
8
+ /**
9
+ * Custom element defined by Starlight's <SidebarPersister>.
10
+ */
11
+ 'sl-sidebar-restore': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
12
+ }
13
+ }
14
+ }
15
+ type StlSidebarTarget = {
16
+ type: 'href';
17
+ href: string;
18
+ } | {
19
+ type: 'stainlessPath';
20
+ stainlessPath: string;
21
+ };
22
+ interface StlSidebarLink {
23
+ type: 'link';
24
+ icon?: ReactNode;
25
+ label: string;
26
+ /** Current sidebar item is highlighted. */
27
+ isCurrent?: boolean;
28
+ target: StlSidebarTarget;
29
+ /** Additional HTML attributes that will be attached to the anchor element. */
30
+ attrs?: Record<string, unknown>;
31
+ }
32
+ interface StlSidebarGroup {
33
+ type: 'group';
34
+ icon?: ReactNode;
35
+ label: string;
36
+ entries: Array<StlSidebarLink | StlSidebarGroup>;
37
+ /** Defaults to true. */
38
+ collapsible?: boolean;
39
+ collapsed?: boolean;
40
+ /** Current sidebar item is highlighted. */
41
+ isCurrent?: boolean;
42
+ target?: StlSidebarTarget;
43
+ }
44
+ type StlSidebarEntry = StlSidebarLink | StlSidebarGroup;
45
+ type StlSidebarProps = {
46
+ entries: StlSidebarEntry[];
47
+ /**
48
+ * If set, add <sl-sidebar-restore> custom elements (as defined by Starlight's SidebarPersister)
49
+ * which are used to save/restore sidebar state.
50
+ */
51
+ withStarlightRestoration?: boolean;
52
+ };
53
+ declare function StlSidebar({
54
+ entries,
55
+ withStarlightRestoration
56
+ }: StlSidebarProps): react_jsx_runtime43.JSX.Element;
57
+ //#endregion
58
+ export { StlSidebarProps as a, StlSidebarLink as i, StlSidebarEntry as n, StlSidebarTarget as o, StlSidebarGroup as r, StlSidebar as t };
@@ -0,0 +1,58 @@
1
+ import { ReactNode } from "react";
2
+ import * as react_jsx_runtime56 from "react/jsx-runtime";
3
+
4
+ //#region src/components/stl-sidebar.d.ts
5
+ declare module 'react' {
6
+ namespace JSX {
7
+ interface IntrinsicElements {
8
+ /**
9
+ * Custom element defined by Starlight's <SidebarPersister>.
10
+ */
11
+ 'sl-sidebar-restore': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
12
+ }
13
+ }
14
+ }
15
+ type StlSidebarTarget = {
16
+ type: 'href';
17
+ href: string;
18
+ } | {
19
+ type: 'stainlessPath';
20
+ stainlessPath: string;
21
+ };
22
+ interface StlSidebarLink {
23
+ type: 'link';
24
+ icon?: ReactNode;
25
+ label: string;
26
+ /** Current sidebar item is highlighted. */
27
+ isCurrent?: boolean;
28
+ target: StlSidebarTarget;
29
+ /** Additional HTML attributes that will be attached to the anchor element. */
30
+ attrs?: Record<string, unknown>;
31
+ }
32
+ interface StlSidebarGroup {
33
+ type: 'group';
34
+ icon?: ReactNode;
35
+ label: string;
36
+ entries: Array<StlSidebarLink | StlSidebarGroup>;
37
+ /** Defaults to true. */
38
+ collapsible?: boolean;
39
+ collapsed?: boolean;
40
+ /** Current sidebar item is highlighted. */
41
+ isCurrent?: boolean;
42
+ target?: StlSidebarTarget;
43
+ }
44
+ type StlSidebarEntry = StlSidebarLink | StlSidebarGroup;
45
+ type StlSidebarProps = {
46
+ entries: StlSidebarEntry[];
47
+ /**
48
+ * If set, add <sl-sidebar-restore> custom elements (as defined by Starlight's SidebarPersister)
49
+ * which are used to save/restore sidebar state.
50
+ */
51
+ withStarlightRestoration?: boolean;
52
+ };
53
+ declare function StlSidebar({
54
+ entries,
55
+ withStarlightRestoration
56
+ }: StlSidebarProps): react_jsx_runtime56.JSX.Element;
57
+ //#endregion
58
+ export { StlSidebarProps as a, StlSidebarLink as i, StlSidebarEntry as n, StlSidebarTarget as o, StlSidebarGroup as r, StlSidebar as t };