@stainless-api/docs-ui 0.1.0-beta.5 → 0.1.0-beta.51

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 (212) hide show
  1. package/dist/breadcrumbs-BdYnaHA8.d.ts +20 -0
  2. package/dist/breadcrumbs-CA7GmW_8.d.ts +20 -0
  3. package/dist/breadcrumbs-nSFZO5Gf.js +63 -0
  4. package/dist/chunk-DRcLgZ1e.js +18 -0
  5. package/dist/component-DRO8kQSp.js +23 -0
  6. package/dist/component-generics-B6Fn47Mz.js +45 -0
  7. package/dist/component-generics-BHFUK06s.d.ts +30 -0
  8. package/dist/component-generics-BJSyydZ-.d.ts +30 -0
  9. package/dist/components/MaskedInput.d.ts +14 -0
  10. package/dist/components/MaskedInput.js +76 -0
  11. package/dist/components/breadcrumbs.d.ts +2 -0
  12. package/dist/components/breadcrumbs.js +9 -0
  13. package/dist/components/icons.d.ts +55 -0
  14. package/dist/components/icons.js +3 -0
  15. package/dist/components/index.d.ts +10 -0
  16. package/dist/components/index.js +18 -0
  17. package/dist/components/method.d.ts +2 -0
  18. package/dist/components/method.js +10 -0
  19. package/dist/components/overview.d.ts +2 -0
  20. package/dist/components/overview.js +11 -0
  21. package/dist/components/primitives.d.ts +2 -0
  22. package/dist/components/primitives.js +8 -0
  23. package/dist/components/properties.d.ts +2 -0
  24. package/dist/components/properties.js +9 -0
  25. package/dist/components/sdk.d.ts +2 -0
  26. package/dist/components/sdk.js +10 -0
  27. package/dist/components/sidebar.d.ts +2 -0
  28. package/dist/components/sidebar.js +11 -0
  29. package/dist/components/snippets.d.ts +3 -0
  30. package/dist/components/snippets.js +9 -0
  31. package/dist/components-D7M-BwNI.js +71 -0
  32. package/dist/contexts/component-generics.d.ts +2 -0
  33. package/dist/contexts/component-generics.js +3 -0
  34. package/dist/contexts/component-types.d.ts +16 -0
  35. package/dist/contexts/component-types.js +0 -0
  36. package/dist/contexts/component.d.ts +29 -0
  37. package/dist/contexts/component.js +27 -0
  38. package/dist/contexts/docs.d.ts +2 -0
  39. package/dist/contexts/docs.js +3 -0
  40. package/dist/contexts/index.d.ts +16 -0
  41. package/dist/contexts/index.js +7 -0
  42. package/dist/contexts/markdown.d.ts +2 -0
  43. package/dist/contexts/markdown.js +4 -0
  44. package/dist/contexts/navigation.d.ts +2 -0
  45. package/dist/contexts/navigation.js +3 -0
  46. package/dist/contexts/use-components.d.ts +14 -0
  47. package/dist/contexts/use-components.js +4 -0
  48. package/dist/contexts-p3rRZDlM.js +39 -0
  49. package/dist/csharp-CDSxfCZE.js +283 -0
  50. package/dist/docs-BUS__I1m.d.ts +47 -0
  51. package/dist/docs-CXqi26jB.js +54 -0
  52. package/dist/docs-fKyo35eI.d.ts +47 -0
  53. package/dist/go-1c3S5ETL.js +303 -0
  54. package/dist/http-2QNWXH9t.js +330 -0
  55. package/dist/icons-Ckod9aod.js +869 -0
  56. package/dist/index-5Yl-BBg3.d.ts +15 -0
  57. package/dist/index-9LRO8R1a.d.ts +274 -0
  58. package/dist/index-CBIJwoyp.d.ts +13 -0
  59. package/dist/index-ClCZKGcw.d.ts +274 -0
  60. package/dist/index-pMKpm2Jk.d.ts +13 -0
  61. package/dist/index-q3bZhNWj.d.ts +15 -0
  62. package/dist/index.d.ts +19 -0
  63. package/dist/index.js +29 -7542
  64. package/dist/java-BbjF_oUI.js +403 -0
  65. package/dist/languages/csharp.d.ts +11 -0
  66. package/dist/languages/csharp.js +9 -0
  67. package/dist/languages/go.d.ts +11 -0
  68. package/dist/languages/go.js +9 -0
  69. package/dist/languages/http.d.ts +11 -0
  70. package/dist/languages/http.js +19 -0
  71. package/dist/languages/index.d.ts +11 -0
  72. package/dist/languages/index.js +26 -0
  73. package/dist/languages/java.d.ts +11 -0
  74. package/dist/languages/java.js +9 -0
  75. package/dist/languages/python.d.ts +11 -0
  76. package/dist/languages/python.js +9 -0
  77. package/dist/languages/ruby.d.ts +11 -0
  78. package/dist/languages/ruby.js +9 -0
  79. package/dist/languages/typescript.d.ts +11 -0
  80. package/dist/languages/typescript.js +9 -0
  81. package/dist/languages-BCYZjzuS.js +26 -0
  82. package/dist/markdown/index.d.ts +12 -0
  83. package/dist/markdown/index.js +104 -0
  84. package/dist/markdown/md.d.ts +15 -0
  85. package/dist/markdown/md.js +3 -0
  86. package/dist/markdown/printer.d.ts +2 -0
  87. package/dist/markdown/printer.js +28 -0
  88. package/dist/markdown/utils.d.ts +3 -0
  89. package/dist/markdown/utils.js +3 -0
  90. package/dist/markdown-C8o8WrwG.d.ts +22 -0
  91. package/dist/markdown-CqJohZei.d.ts +22 -0
  92. package/dist/markdown-CxdeWgjV.js +48 -0
  93. package/dist/md-oM2tUaCA.js +41 -0
  94. package/dist/method-CE08mUME.js +115 -0
  95. package/dist/method-CMt6uyix.d.ts +71 -0
  96. package/dist/method-r5UAB40b.d.ts +71 -0
  97. package/dist/navigation-9_4wRkcT.d.ts +29 -0
  98. package/dist/navigation-C5TN0SgC.js +24 -0
  99. package/dist/navigation-zuoWsXzh.d.ts +29 -0
  100. package/dist/overview-DXmLmmr7.d.ts +39 -0
  101. package/dist/overview-S2hUqPXA.js +139 -0
  102. package/dist/overview-ixhAhHj8.d.ts +39 -0
  103. package/dist/primitives-BIWfwN5L.js +258 -0
  104. package/dist/primitives-BVXfSSiS.d.ts +97 -0
  105. package/dist/primitives-Bl0wzAGo.d.ts +97 -0
  106. package/dist/printer-DBw4S_Jn.d.ts +13 -0
  107. package/dist/printer-bNxiG6UB.js +74 -0
  108. package/dist/properties-C-NU_ghj.d.ts +54 -0
  109. package/dist/properties-GT9ixNTg.d.ts +54 -0
  110. package/dist/properties-jlGW3USi.js +131 -0
  111. package/dist/python-USOwFDv_.js +279 -0
  112. package/dist/routing-CMqh1cTZ.d.ts +54 -0
  113. package/dist/routing-Wbb7YECB.js +194 -0
  114. package/dist/routing.d.ts +2 -0
  115. package/dist/routing.js +3 -180
  116. package/dist/ruby-CSvGbSLe.js +387 -0
  117. package/dist/sdk-B5W3VipN.d.ts +118 -0
  118. package/dist/sdk-CS6A3HW3.d.ts +118 -0
  119. package/dist/sdk-CSCbbn3O.js +336 -0
  120. package/dist/sidebar-C3fZrgmP.d.ts +36 -0
  121. package/dist/sidebar-CWyvCrJ0.js +81 -0
  122. package/dist/sidebar-CbCLUteD.d.ts +36 -0
  123. package/dist/snippets-BQLXEIf6.js +161 -0
  124. package/dist/snippets-C72s2IwS.d.ts +51 -0
  125. package/dist/snippets-DcFph7ir.d.ts +51 -0
  126. package/dist/spec.d.ts +65 -0
  127. package/dist/spec.js +167 -0
  128. package/dist/style-D7RO5ymE.d.ts +168 -0
  129. package/dist/style-gnVEeXFj.js +169 -0
  130. package/dist/style.d.ts +2 -0
  131. package/dist/style.js +3 -0
  132. package/dist/styles/main.css +727 -754
  133. package/dist/styles/main.js +0 -0
  134. package/dist/styles/primitives.css +317 -461
  135. package/dist/styles/primitives.js +0 -0
  136. package/dist/styles/resets.css +32 -41
  137. package/dist/styles/resets.js +0 -0
  138. package/dist/styles/search.css +175 -274
  139. package/dist/styles/search.js +0 -0
  140. package/dist/styles/sidebar.css +59 -60
  141. package/dist/styles/sidebar.js +0 -0
  142. package/dist/styles/variables.css +26 -89
  143. package/dist/styles/variables.js +0 -0
  144. package/dist/styles.css +2910 -0
  145. package/dist/styles.mjs +1 -0
  146. package/dist/typescript-DXG9psK3.js +449 -0
  147. package/dist/use-components-RWQbviGq.js +7 -0
  148. package/dist/utils-CqnL9Fc3.js +31 -0
  149. package/dist/utils-DGnJ6mcU.d.ts +21 -0
  150. package/dist/utils-D_1AWSRX.js +32 -0
  151. package/dist/utils-d8paVwKN.d.ts +14 -0
  152. package/dist/utils-uQbtk0-_.d.ts +21 -0
  153. package/dist/utils.d.ts +2 -0
  154. package/dist/utils.js +3 -0
  155. package/package.json +73 -21
  156. package/dist/mcp.js +0 -16003
  157. package/dist/styles/snippets.css +0 -132
  158. package/src/components/breadcrumbs.tsx +0 -94
  159. package/src/components/chat.tsx +0 -154
  160. package/src/components/dropdown.tsx +0 -91
  161. package/src/components/icons.tsx +0 -584
  162. package/src/components/index.ts +0 -9
  163. package/src/components/method.tsx +0 -144
  164. package/src/components/overview.tsx +0 -159
  165. package/src/components/primitives.tsx +0 -284
  166. package/src/components/properties.tsx +0 -130
  167. package/src/components/scripts/dropdown.ts +0 -78
  168. package/src/components/sdk.tsx +0 -402
  169. package/src/components/sidebar.tsx +0 -99
  170. package/src/components/snippets.tsx +0 -179
  171. package/src/contexts/component-generics.tsx +0 -48
  172. package/src/contexts/component-types.tsx +0 -5
  173. package/src/contexts/component.tsx +0 -32
  174. package/src/contexts/docs.tsx +0 -75
  175. package/src/contexts/index.tsx +0 -17
  176. package/src/contexts/markdown.tsx +0 -43
  177. package/src/contexts/navigation.tsx +0 -44
  178. package/src/contexts/search.tsx +0 -28
  179. package/src/contexts/use-components.tsx +0 -4
  180. package/src/index.ts +0 -6
  181. package/src/languages/go.tsx +0 -281
  182. package/src/languages/http.tsx +0 -321
  183. package/src/languages/index.ts +0 -26
  184. package/src/languages/java.tsx +0 -358
  185. package/src/languages/python.tsx +0 -255
  186. package/src/languages/ruby.tsx +0 -320
  187. package/src/languages/typescript.tsx +0 -393
  188. package/src/markdown/index.ts +0 -107
  189. package/src/markdown/md.ts +0 -45
  190. package/src/markdown/utils.ts +0 -49
  191. package/src/routing.ts +0 -238
  192. package/src/search/form.tsx +0 -127
  193. package/src/search/index.tsx +0 -1
  194. package/src/search/indexer.ts +0 -246
  195. package/src/search/mcp.ts +0 -61
  196. package/src/search/printer.tsx +0 -86
  197. package/src/search/providers/algolia.ts +0 -88
  198. package/src/search/providers/fuse.ts +0 -19
  199. package/src/search/providers/pagefind.ts +0 -17
  200. package/src/search/providers/walker.ts +0 -30
  201. package/src/search/results.tsx +0 -181
  202. package/src/search/state.ts +0 -64
  203. package/src/search/types.ts +0 -116
  204. package/src/style.ts +0 -197
  205. package/src/styles/main.css +0 -993
  206. package/src/styles/primitives.css +0 -573
  207. package/src/styles/resets.css +0 -47
  208. package/src/styles/search.css +0 -342
  209. package/src/styles/sidebar.css +0 -87
  210. package/src/styles/snippets.css +0 -132
  211. package/src/styles/variables.css +0 -90
  212. package/src/utils.ts +0 -41
@@ -0,0 +1,194 @@
1
+ import { t as __export } from "./chunk-DRcLgZ1e.js";
2
+
3
+ //#region src/routing.ts
4
+ var routing_exports = /* @__PURE__ */ __export({
5
+ LanguageNames: () => LanguageNames,
6
+ Languages: () => Languages,
7
+ SupportedLanguageSyntaxes: () => SupportedLanguageSyntaxes,
8
+ expandToElement: () => expandToElement,
9
+ findNavigationPath: () => findNavigationPath,
10
+ generateRoute: () => generateRoute,
11
+ generateRouteList: () => generateRouteList,
12
+ getLanguageSnippet: () => getLanguageSnippet,
13
+ getResource: () => getResource,
14
+ isSupportedLanguage: () => isSupportedLanguage,
15
+ parseRoute: () => parseRoute,
16
+ parseStainlessPath: () => parseStainlessPath,
17
+ scrollToPath: () => scrollToPath,
18
+ trimStainlessPath: () => trimStainlessPath,
19
+ updateHistory: () => updateHistory,
20
+ walkTree: () => walkTree
21
+ });
22
+ const Languages = [
23
+ "http",
24
+ "node",
25
+ "python",
26
+ "go",
27
+ "typescript",
28
+ "terraform",
29
+ "ruby",
30
+ "java",
31
+ "kotlin",
32
+ "csharp",
33
+ "php"
34
+ ];
35
+ const SupportedLanguageSyntaxes = [
36
+ "http",
37
+ "javascript",
38
+ "python",
39
+ "go",
40
+ "typescript",
41
+ "terraform",
42
+ "ruby",
43
+ "java",
44
+ "kotlin",
45
+ "csharp"
46
+ ];
47
+ const LanguageNames = {
48
+ http: "HTTP",
49
+ node: "TypeScript",
50
+ typescript: "TypeScript",
51
+ python: "Python",
52
+ go: "Go",
53
+ ruby: "Ruby",
54
+ java: "Java",
55
+ kotlin: "Kotlin",
56
+ terraform: "Terraform",
57
+ csharp: "C#",
58
+ php: "PHP"
59
+ };
60
+ function getLanguageSnippet(language) {
61
+ return language === "http" ? "http.curl" : `${language}.default`;
62
+ }
63
+ function isSupportedLanguage(language) {
64
+ return Languages.includes(language);
65
+ }
66
+ const DefaultLanguage = "http";
67
+ const StainlessPathPattern = /(\(resource\) (?<resource>[^\s]+))( > (\(method\) (?<method>[^\s]+)|\(model\) (?<model>[^\s]+))?)?/;
68
+ function parseStainlessPath(stainlessPath) {
69
+ const match = stainlessPath.match(StainlessPathPattern);
70
+ if (!match?.groups) return null;
71
+ return {
72
+ resource: match.groups.resource?.split(".") ?? null,
73
+ method: match.groups.method ?? null,
74
+ model: match.groups.model ?? null,
75
+ routable: match.groups.model ? match[1] : match[0]
76
+ };
77
+ }
78
+ function trimStainlessPath(stainlessPath) {
79
+ return stainlessPath.replace(/ > \([^\s]+\)$/, "");
80
+ }
81
+ function getResource(stainlessPath) {
82
+ return parseStainlessPath(stainlessPath)?.resource?.[0];
83
+ }
84
+ function parseRoute(basePath, route) {
85
+ if (!route.startsWith(basePath)) return {
86
+ stainlessPath: "",
87
+ language: DefaultLanguage
88
+ };
89
+ if (basePath && route.startsWith(basePath)) route = route.slice(basePath.length);
90
+ let stainlessPath = "";
91
+ let elements = route.slice(1).split("/");
92
+ let language = DefaultLanguage;
93
+ if (elements[0] && Languages.includes(elements[0])) {
94
+ language = elements[0];
95
+ elements = elements.slice(1);
96
+ }
97
+ while (elements.length > 0) switch (elements.shift()) {
98
+ case "resources":
99
+ stainlessPath += `(resource) ${elements.shift()}`;
100
+ break;
101
+ case "subresources":
102
+ stainlessPath += `.${elements.shift()}`;
103
+ break;
104
+ case "methods":
105
+ stainlessPath += ` > (method) ${elements.shift()}`;
106
+ break;
107
+ }
108
+ return {
109
+ stainlessPath,
110
+ language
111
+ };
112
+ }
113
+ function generateRoute(basePath, language, stainlessPath) {
114
+ const parsedPath = parseStainlessPath(stainlessPath);
115
+ if (!parsedPath) return null;
116
+ const path = [basePath.endsWith("/") ? basePath.slice(0, -1) : basePath];
117
+ if (language && language !== DefaultLanguage) path.push(language);
118
+ const resources = parsedPath.resource.flatMap((name, index) => [index > 0 ? "subresources" : "resources", name]);
119
+ const resourcePath = parsedPath.model ? resources.slice(0, 2) : resources;
120
+ path.push(...resourcePath);
121
+ if (parsedPath.method) path.push("methods", parsedPath.method);
122
+ return stainlessPath.length > parsedPath.routable.length ? `${path.join("/")}#${encodeURIComponent(stainlessPath)}` : path.join("/");
123
+ }
124
+ function* walkResource(resource, path, includeModels) {
125
+ yield {
126
+ data: resource,
127
+ path
128
+ };
129
+ for (const data of Object.values(resource.methods)) yield {
130
+ data,
131
+ path: [
132
+ ...path,
133
+ "methods",
134
+ data.name
135
+ ]
136
+ };
137
+ if (includeModels) for (const data of Object.values(resource.models)) yield {
138
+ data,
139
+ path: [
140
+ ...path,
141
+ "models",
142
+ data.name
143
+ ]
144
+ };
145
+ for (const data of Object.values(resource.subresources ?? {})) yield* walkResource(data, [
146
+ ...path,
147
+ "subresources",
148
+ data.name
149
+ ]);
150
+ }
151
+ function* walkTree(spec, includeModels) {
152
+ for (const data of Object.values(spec.resources)) yield* walkResource(data, ["resources", data.name], includeModels);
153
+ }
154
+ function generateRouteList({ spec, languages, excludeLanguages = [] }) {
155
+ const entries = Array.from(walkTree(spec));
156
+ return (languages ?? spec.docs?.languages ?? ["http"]).filter((lang) => Languages.includes(lang) && lang !== "terraform").filter((lang) => !excludeLanguages?.includes(lang)).flatMap((language) => entries.map(({ path, data: { title, kind, stainlessPath } }) => ({
157
+ title,
158
+ kind,
159
+ language,
160
+ stainlessPath,
161
+ slug: (language === "http" ? path : [language, ...path]).join("/")
162
+ })));
163
+ }
164
+ function findNavigationPath(items, target) {
165
+ for (const item of Object.values(items)) {
166
+ if (item.stainlessPath === target) return [item.stainlessPath];
167
+ if (item.kind === "http_method") continue;
168
+ const path = findNavigationPath([...Object.values(item.methods ?? {}), ...Object.values(item.subresources ?? {})], target);
169
+ if (path) return [item.stainlessPath, ...path];
170
+ }
171
+ }
172
+ function expandToElement(el) {
173
+ while (el) {
174
+ if (el instanceof HTMLDetailsElement) el.open = true;
175
+ el = el.parentElement;
176
+ }
177
+ }
178
+ function scrollToPath(stainlessPath) {
179
+ const el = document.getElementById(stainlessPath);
180
+ if (el) {
181
+ expandToElement(el);
182
+ el.scrollIntoView({ behavior: "smooth" });
183
+ }
184
+ }
185
+ function updateHistory(basePath, language, stainlessPath) {
186
+ const path = generateRoute(basePath, language, stainlessPath);
187
+ window.history.pushState({
188
+ stainlessPath,
189
+ language
190
+ }, "", path);
191
+ }
192
+
193
+ //#endregion
194
+ export { walkTree as _, findNavigationPath as a, getLanguageSnippet as c, parseRoute as d, parseStainlessPath as f, updateHistory as g, trimStainlessPath as h, expandToElement as i, getResource as l, scrollToPath as m, Languages as n, generateRoute as o, routing_exports as p, SupportedLanguageSyntaxes as r, generateRouteList as s, LanguageNames as t, isSupportedLanguage as u };
@@ -0,0 +1,2 @@
1
+ import { a as RouteEntry, b as updateHistory, c as expandToElement, d as generateRouteList, f as getLanguageSnippet, g as parseStainlessPath, h as parseRoute, i as ParsedStainlessPath, l as findNavigationPath, m as isSupportedLanguage, n as LanguageNames, o as SpecTreeEntry, p as getResource, r as Languages, s as SupportedLanguageSyntaxes, t as DocsLanguage, u as generateRoute, v as scrollToPath, x as walkTree, y as trimStainlessPath } from "./routing-CMqh1cTZ.js";
2
+ export { DocsLanguage, LanguageNames, Languages, ParsedStainlessPath, RouteEntry, SpecTreeEntry, SupportedLanguageSyntaxes, expandToElement, findNavigationPath, generateRoute, generateRouteList, getLanguageSnippet, getResource, isSupportedLanguage, parseRoute, parseStainlessPath, scrollToPath, trimStainlessPath, updateHistory, walkTree };
package/dist/routing.js CHANGED
@@ -1,180 +1,3 @@
1
- // src/routing.ts
2
- var Languages = [
3
- "http",
4
- "node",
5
- "python",
6
- "go",
7
- "typescript",
8
- "terraform",
9
- "ruby",
10
- "java",
11
- "kotlin"
12
- ];
13
- var SupportedLanguageSyntaxes = [
14
- "http",
15
- "javascript",
16
- "python",
17
- "go",
18
- "typescript",
19
- "terraform",
20
- "ruby",
21
- "java",
22
- "kotlin"
23
- ];
24
- var LanguageNames = {
25
- http: "HTTP",
26
- node: "TypeScript",
27
- typescript: "TypeScript",
28
- python: "Python",
29
- go: "Go",
30
- ruby: "Ruby",
31
- java: "Java",
32
- kotlin: "Kotlin",
33
- terraform: "Terraform"
34
- };
35
- function getLanguageSnippet(language) {
36
- return language === "http" ? "http.curl" : `${language}.default`;
37
- }
38
- function isSupportedLanguage(language) {
39
- return Languages.includes(language);
40
- }
41
- var DefaultLanguage = "http";
42
- var StainlessPathPattern = /(\(resource\) (?<resource>[^\s]+))( > (\(method\) (?<method>[^\s]+)|\(model\) (?<model>[^\s]+))?)?/;
43
- function parseStainlessPath(stainlessPath) {
44
- const match = stainlessPath.match(StainlessPathPattern);
45
- if (!match) return null;
46
- return {
47
- resource: match.groups.resource.split("."),
48
- method: match.groups.method ?? null,
49
- model: match.groups.model ?? null,
50
- routable: match.groups.model ? match[1] : match[0]
51
- };
52
- }
53
- function trimStainlessPath(stainlessPath) {
54
- return stainlessPath.replace(/ > \([^\s]+\)$/, "");
55
- }
56
- function getResource(stainlessPath) {
57
- const parsed = parseStainlessPath(stainlessPath);
58
- return parsed?.resource[0];
59
- }
60
- function parseRoute(basePath, route) {
61
- if (!route.startsWith(basePath)) return { stainlessPath: "", language: DefaultLanguage };
62
- if (basePath && route.startsWith(basePath)) route = route.slice(basePath.length);
63
- let stainlessPath = "";
64
- let elements = route.slice(1).split("/");
65
- let language = DefaultLanguage;
66
- if (elements[0] && Languages.includes(elements[0])) {
67
- language = elements[0];
68
- elements = elements.slice(1);
69
- }
70
- while (elements.length > 0) {
71
- const element = elements.shift();
72
- switch (element) {
73
- case "resources":
74
- stainlessPath += `(resource) ${elements.shift()}`;
75
- break;
76
- case "subresources":
77
- stainlessPath += `.${elements.shift()}`;
78
- break;
79
- case "methods":
80
- stainlessPath += ` > (method) ${elements.shift()}`;
81
- break;
82
- }
83
- }
84
- return { stainlessPath, language };
85
- }
86
- function generateRoute(basePath, language, stainlessPath) {
87
- const parsedPath = parseStainlessPath(stainlessPath);
88
- if (!parsedPath) return null;
89
- const path = [basePath.endsWith("/") ? basePath.slice(0, -1) : basePath];
90
- if (language && language !== DefaultLanguage) path.push(language);
91
- const resources = parsedPath.resource.flatMap((name, index) => [
92
- index > 0 ? "subresources" : "resources",
93
- name
94
- ]);
95
- const resourcePath = parsedPath.model ? resources.slice(0, 2) : resources;
96
- path.push(...resourcePath);
97
- if (parsedPath.method) path.push("methods", parsedPath.method);
98
- return stainlessPath.length > parsedPath.routable.length ? `${path.join("/")}#${encodeURIComponent(stainlessPath)}` : path.join("/");
99
- }
100
- function* walkResource(resource, path, includeModels) {
101
- yield { data: resource, path };
102
- for (const data of Object.values(resource.methods)) {
103
- yield { data, path: [...path, "methods", data.name] };
104
- }
105
- if (includeModels)
106
- for (const data of Object.values(resource.models)) {
107
- yield { data, path: [...path, "models", data.name] };
108
- }
109
- for (const data of Object.values(resource.subresources ?? {})) {
110
- yield* walkResource(data, [...path, "subresources", data.name]);
111
- }
112
- }
113
- function* walkTree(spec, includeModels) {
114
- for (const data of Object.values(spec.resources)) {
115
- yield* walkResource(data, ["resources", data.name], includeModels);
116
- }
117
- }
118
- function generateRouteList({
119
- spec,
120
- languages,
121
- excludeLanguages = []
122
- }) {
123
- const entries = Array.from(walkTree(spec));
124
- const langs = languages ?? spec.docs?.languages ?? ["http"];
125
- return langs.filter((lang) => Languages.includes(lang) && lang !== "terraform").filter((lang) => !excludeLanguages?.includes(lang)).flatMap(
126
- (language) => entries.map(({ path, data: { title, kind, stainlessPath } }) => ({
127
- title,
128
- kind,
129
- language,
130
- stainlessPath,
131
- slug: (language === "http" ? path : [language, ...path]).join("/")
132
- }))
133
- );
134
- }
135
- function findNavigationPath(items, target) {
136
- for (const item of Object.values(items)) {
137
- if (item.stainlessPath === target) return [item.stainlessPath];
138
- if (item.kind === "http_method") continue;
139
- const path = findNavigationPath(
140
- [...Object.values(item.methods ?? {}), ...Object.values(item.subresources ?? {})],
141
- target
142
- );
143
- if (path) return [item.stainlessPath, ...path];
144
- }
145
- }
146
- function expandToElement(el) {
147
- while (el) {
148
- if (el.tagName === "DETAILS") el["open"] = true;
149
- el = el.parentElement;
150
- }
151
- }
152
- function scrollToPath(stainlessPath) {
153
- const el = document.getElementById(stainlessPath);
154
- if (el) {
155
- expandToElement(el);
156
- el.scrollIntoView({ behavior: "smooth" });
157
- }
158
- }
159
- function updateHistory(basePath, language, stainlessPath) {
160
- const path = generateRoute(basePath, language, stainlessPath);
161
- window.history.pushState({ stainlessPath, language }, "", path);
162
- }
163
- export {
164
- LanguageNames,
165
- Languages,
166
- SupportedLanguageSyntaxes,
167
- expandToElement,
168
- findNavigationPath,
169
- generateRoute,
170
- generateRouteList,
171
- getLanguageSnippet,
172
- getResource,
173
- isSupportedLanguage,
174
- parseRoute,
175
- parseStainlessPath,
176
- scrollToPath,
177
- trimStainlessPath,
178
- updateHistory,
179
- walkTree
180
- };
1
+ import { _ as walkTree, a as findNavigationPath, c as getLanguageSnippet, d as parseRoute, f as parseStainlessPath, g as updateHistory, h as trimStainlessPath, i as expandToElement, l as getResource, m as scrollToPath, n as Languages, o as generateRoute, r as SupportedLanguageSyntaxes, s as generateRouteList, t as LanguageNames, u as isSupportedLanguage } from "./routing-Wbb7YECB.js";
2
+
3
+ export { LanguageNames, Languages, SupportedLanguageSyntaxes, expandToElement, findNavigationPath, generateRoute, generateRouteList, getLanguageSnippet, getResource, isSupportedLanguage, parseRoute, parseStainlessPath, scrollToPath, trimStainlessPath, updateHistory, walkTree };