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

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 (214) hide show
  1. package/dist/breadcrumbs-7G1MoVzo.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-DhMMZoiU.js +166 -0
  6. package/dist/component-Drp93QK-.js +23 -0
  7. package/dist/component-generics-5cSjFCLn.d.ts +30 -0
  8. package/dist/component-generics-POFirVVb.js +45 -0
  9. package/dist/component-generics-t_S0Wc9i.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-BbJAAdUU.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---kdT2w-.d.ts +48 -0
  54. package/dist/docs-BmOB2f-I.js +61 -0
  55. package/dist/docs-CceV-0oK.d.ts +48 -0
  56. package/dist/go-COaHV3Hc.js +303 -0
  57. package/dist/http-DVyJ-D6t.js +389 -0
  58. package/dist/icons-BYKn5X8E.js +885 -0
  59. package/dist/index-Bc1tYWPC.d.ts +347 -0
  60. package/dist/index-Cuw1pZs8.d.ts +16 -0
  61. package/dist/index-CwjGm9zX.d.ts +1722 -0
  62. package/dist/index-DIchpgQZ.d.ts +16 -0
  63. package/dist/index-DSeLOs29.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-C8iNdbjN.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-HJXGh2Yn.d.ts +22 -0
  99. package/dist/method-DPnfsySL.d.ts +59 -0
  100. package/dist/method-R97dH39J.d.ts +59 -0
  101. package/dist/method-iAV6cZjF.js +96 -0
  102. package/dist/navigation-QXH2ufM3.d.ts +29 -0
  103. package/dist/navigation-aoYZ_tl4.js +24 -0
  104. package/dist/navigation-dh0gX_lm.d.ts +29 -0
  105. package/dist/overview-BR3WhCoz.d.ts +39 -0
  106. package/dist/overview-DQIrvYJr.js +138 -0
  107. package/dist/overview-Ddh84S6_.d.ts +39 -0
  108. package/dist/primitives-D0h4FgbU.d.ts +105 -0
  109. package/dist/primitives-DJEqe_r1.js +250 -0
  110. package/dist/primitives-xbTKYFgQ.d.ts +105 -0
  111. package/dist/properties-CjUi1Cjx.d.ts +54 -0
  112. package/dist/properties-PNuJPLqP.js +138 -0
  113. package/dist/properties-q3XaAaRo.d.ts +54 -0
  114. package/dist/python-DsTuWCKE.js +269 -0
  115. package/dist/routing-C64k4fmX.js +205 -0
  116. package/dist/routing-utiR5mY3.d.ts +61 -0
  117. package/dist/routing.d.ts +2 -0
  118. package/dist/routing.js +3 -180
  119. package/dist/ruby-BncKp6hd.js +387 -0
  120. package/dist/sdk-Bw99eXxA.js +399 -0
  121. package/dist/sdk-CSKStkB5.d.ts +122 -0
  122. package/dist/sdk-D3U444dU.d.ts +122 -0
  123. package/dist/sdk-sidebar-Cf04O8rR.d.ts +15 -0
  124. package/dist/sdk-sidebar-V_MTkVw8.js +50 -0
  125. package/dist/sdk-sidebar-f7SS4xxq.d.ts +15 -0
  126. package/dist/snippets-BehbU3rt.js +164 -0
  127. package/dist/snippets-CMtWGDSE.d.ts +53 -0
  128. package/dist/snippets-DZAozdda.d.ts +53 -0
  129. package/dist/spec.d.ts +65 -0
  130. package/dist/spec.js +167 -0
  131. package/dist/stl-sidebar-CItXFC3n.d.ts +58 -0
  132. package/dist/stl-sidebar-DpnXVa_V.d.ts +58 -0
  133. package/dist/stl-sidebar-WtimNrk1.js +106 -0
  134. package/dist/style-HpXpcJ9v.js +172 -0
  135. package/dist/style.d.ts +171 -0
  136. package/dist/style.js +3 -0
  137. package/dist/styles/main.css +750 -754
  138. package/dist/styles/main.js +0 -0
  139. package/dist/styles/primitives.css +327 -458
  140. package/dist/styles/primitives.js +0 -0
  141. package/dist/styles/resets.css +32 -41
  142. package/dist/styles/resets.js +0 -0
  143. package/dist/styles/search.css +192 -270
  144. package/dist/styles/search.js +0 -0
  145. package/dist/styles/sidebar.css +170 -69
  146. package/dist/styles/sidebar.js +0 -0
  147. package/dist/styles/variables.css +26 -89
  148. package/dist/styles/variables.js +0 -0
  149. package/dist/styles.css +3279 -0
  150. package/dist/styles.mjs +1 -0
  151. package/dist/terraform-B95X4rNK.js +243 -0
  152. package/dist/typescript-n46M9OtL.js +449 -0
  153. package/dist/use-components-BUz3GbO4.js +7 -0
  154. package/dist/utils-DPbkW1Tz.js +54 -0
  155. package/dist/utils.d.ts +20 -0
  156. package/dist/utils.js +3 -0
  157. package/package.json +74 -22
  158. package/dist/mcp.js +0 -16003
  159. package/dist/styles/snippets.css +0 -132
  160. package/src/components/breadcrumbs.tsx +0 -94
  161. package/src/components/chat.tsx +0 -154
  162. package/src/components/dropdown.tsx +0 -91
  163. package/src/components/icons.tsx +0 -584
  164. package/src/components/index.ts +0 -9
  165. package/src/components/method.tsx +0 -144
  166. package/src/components/overview.tsx +0 -159
  167. package/src/components/primitives.tsx +0 -284
  168. package/src/components/properties.tsx +0 -130
  169. package/src/components/scripts/dropdown.ts +0 -78
  170. package/src/components/sdk.tsx +0 -402
  171. package/src/components/sidebar.tsx +0 -99
  172. package/src/components/snippets.tsx +0 -179
  173. package/src/contexts/component-generics.tsx +0 -48
  174. package/src/contexts/component-types.tsx +0 -5
  175. package/src/contexts/component.tsx +0 -32
  176. package/src/contexts/docs.tsx +0 -75
  177. package/src/contexts/index.tsx +0 -17
  178. package/src/contexts/markdown.tsx +0 -43
  179. package/src/contexts/navigation.tsx +0 -44
  180. package/src/contexts/search.tsx +0 -28
  181. package/src/contexts/use-components.tsx +0 -4
  182. package/src/index.ts +0 -6
  183. package/src/languages/go.tsx +0 -281
  184. package/src/languages/http.tsx +0 -321
  185. package/src/languages/index.ts +0 -26
  186. package/src/languages/java.tsx +0 -358
  187. package/src/languages/python.tsx +0 -255
  188. package/src/languages/ruby.tsx +0 -320
  189. package/src/languages/typescript.tsx +0 -393
  190. package/src/markdown/index.ts +0 -107
  191. package/src/markdown/md.ts +0 -45
  192. package/src/markdown/utils.ts +0 -49
  193. package/src/routing.ts +0 -238
  194. package/src/search/form.tsx +0 -127
  195. package/src/search/index.tsx +0 -1
  196. package/src/search/indexer.ts +0 -246
  197. package/src/search/mcp.ts +0 -61
  198. package/src/search/printer.tsx +0 -86
  199. package/src/search/providers/algolia.ts +0 -88
  200. package/src/search/providers/fuse.ts +0 -19
  201. package/src/search/providers/pagefind.ts +0 -17
  202. package/src/search/providers/walker.ts +0 -30
  203. package/src/search/results.tsx +0 -181
  204. package/src/search/state.ts +0 -64
  205. package/src/search/types.ts +0 -116
  206. package/src/style.ts +0 -197
  207. package/src/styles/main.css +0 -993
  208. package/src/styles/primitives.css +0 -572
  209. package/src/styles/resets.css +0 -47
  210. package/src/styles/search.css +0 -342
  211. package/src/styles/sidebar.css +0 -87
  212. package/src/styles/snippets.css +0 -132
  213. package/src/styles/variables.css +0 -90
  214. package/src/utils.ts +0 -41
@@ -0,0 +1,50 @@
1
+ import { n as useNavigation } from "./navigation-aoYZ_tl4.js";
2
+ import { i as isResourceEmpty } from "./utils-DPbkW1Tz.js";
3
+ import { t as StlSidebar } from "./stl-sidebar-WtimNrk1.js";
4
+ import * as React$1 from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { Badge, getHttpMethod } from "@stainless-api/ui-primitives";
7
+
8
+ //#region src/components/sdk-sidebar.tsx
9
+ function resourceToEntry(resource, selectedPath) {
10
+ const result = {
11
+ type: "group",
12
+ collapsed: false,
13
+ label: resource.title,
14
+ entries: [],
15
+ target: {
16
+ type: "stainlessPath",
17
+ stainlessPath: resource.stainlessPath
18
+ },
19
+ isCurrent: selectedPath === resource.stainlessPath
20
+ };
21
+ for (const method of Object.values(resource.methods)) {
22
+ const httpMethod = getHttpMethod(method.httpMethod);
23
+ result.entries.push({
24
+ type: "link",
25
+ target: {
26
+ type: "stainlessPath",
27
+ stainlessPath: method.stainlessPath
28
+ },
29
+ label: method.title,
30
+ isCurrent: selectedPath === method.stainlessPath,
31
+ icon: httpMethod ? /* @__PURE__ */ jsx(Badge.HTTP, {
32
+ method: httpMethod,
33
+ iconOnly: true,
34
+ size: "sm"
35
+ }) : void 0
36
+ });
37
+ }
38
+ for (const subresource of Object.values(resource.subresources ?? {})) result.entries.push(resourceToEntry(subresource, selectedPath));
39
+ return result;
40
+ }
41
+ /**
42
+ * Given some SDKJSON.Resources, calls into StlSidebar with the appropriate sidebar entries.
43
+ */
44
+ function SDKSidebar({ resources }) {
45
+ const { selectedPath } = useNavigation();
46
+ return /* @__PURE__ */ jsx(StlSidebar, { entries: React$1.useMemo(() => resources.filter((resource) => !isResourceEmpty(resource)).map((resource) => resourceToEntry(resource, selectedPath)), [resources, selectedPath]) });
47
+ }
48
+
49
+ //#endregion
50
+ export { SDKSidebar as t };
@@ -0,0 +1,15 @@
1
+ import { m as Resource } from "./index-CwjGm9zX.js";
2
+ import * as react_jsx_runtime43 from "react/jsx-runtime";
3
+
4
+ //#region src/components/sdk-sidebar.d.ts
5
+ type SDKSidebarProps = {
6
+ resources: Resource[];
7
+ };
8
+ /**
9
+ * Given some SDKJSON.Resources, calls into StlSidebar with the appropriate sidebar entries.
10
+ */
11
+ declare function SDKSidebar({
12
+ resources
13
+ }: SDKSidebarProps): react_jsx_runtime43.JSX.Element;
14
+ //#endregion
15
+ export { SDKSidebarProps as n, SDKSidebar as t };
@@ -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-D3U444dU.js";
3
+ import * as React$1 from "react";
4
+ import * as react_jsx_runtime72 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_runtime72.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_runtime72.JSX.Element;
29
+ type SnippetRequestContainerProps = {
30
+ children?: React$1.ReactNode;
31
+ signature?: string;
32
+ };
33
+ declare function SnippetRequestContainer({
34
+ children
35
+ }: SnippetRequestContainerProps): react_jsx_runtime72.JSX.Element;
36
+ declare function Snippet({
37
+ requestTitle,
38
+ method,
39
+ transformRequestSnippet
40
+ }: SnippetProps): react_jsx_runtime72.JSX.Element | null;
41
+ declare function SnippetButtons({
42
+ content
43
+ }: {
44
+ content: string;
45
+ }): react_jsx_runtime72.JSX.Element;
46
+ declare function SnippetFooter(): React$1.ReactNode;
47
+ declare function SnippetResponse({
48
+ responses
49
+ }: {
50
+ responses: Method['exampleResponses'];
51
+ }): react_jsx_runtime72.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-CSKStkB5.js";
3
+ import * as React$1 from "react";
4
+ import * as react_jsx_runtime61 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_runtime61.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_runtime61.JSX.Element;
29
+ type SnippetRequestContainerProps = {
30
+ children?: React$1.ReactNode;
31
+ signature?: string;
32
+ };
33
+ declare function SnippetRequestContainer({
34
+ children
35
+ }: SnippetRequestContainerProps): react_jsx_runtime61.JSX.Element;
36
+ declare function Snippet({
37
+ requestTitle,
38
+ method,
39
+ transformRequestSnippet
40
+ }: SnippetProps): react_jsx_runtime61.JSX.Element | null;
41
+ declare function SnippetButtons({
42
+ content
43
+ }: {
44
+ content: string;
45
+ }): react_jsx_runtime61.JSX.Element;
46
+ declare function SnippetFooter(): React$1.ReactNode;
47
+ declare function SnippetResponse({
48
+ responses
49
+ }: {
50
+ responses: Method['exampleResponses'];
51
+ }): react_jsx_runtime61.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-utiR5mY3.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: "cli" | "csharp" | "go" | "http" | "java" | "kotlin" | "node" | "php" | "python" | "ruby" | "terraform" | "typescript";
40
+ spec: Partial<Spec>;
41
+ }[];
42
+ declare function split(spec: Spec, transforms?: SpecTransforms): {
43
+ resources: ReturnType<typeof transform>;
44
+ navigation: {
45
+ languages: ("go" | "http" | "java" | "kotlin" | "node" | "python" | "ruby" | "terraform" | "typescript")[] | 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_runtime78 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_runtime78.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_runtime67 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_runtime67.JSX.Element;
57
+ //#endregion
58
+ export { StlSidebarProps as a, StlSidebarLink as i, StlSidebarEntry as n, StlSidebarTarget as o, StlSidebarGroup as r, StlSidebar as t };