@stainless-api/docs-ui 0.1.0-beta.4 → 0.1.0-beta.40

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 (188) hide show
  1. package/dist/breadcrumbs-CZg0Fk4V.d.ts +20 -0
  2. package/dist/chunk-Bf_Gc_jT.js +18 -0
  3. package/dist/component-generics-BLXXX1dz.d.ts +30 -0
  4. package/dist/component-generics-D3ybuN5r.js +45 -0
  5. package/dist/components/breadcrumbs.d.ts +2 -0
  6. package/dist/components/breadcrumbs.js +15 -0
  7. package/dist/components/icons.d.ts +50 -0
  8. package/dist/components/icons.js +3 -0
  9. package/dist/components/index.d.ts +11 -0
  10. package/dist/components/index.js +15 -0
  11. package/dist/components/method.d.ts +2 -0
  12. package/dist/components/method.js +15 -0
  13. package/dist/components/overview.d.ts +2 -0
  14. package/dist/components/overview.js +15 -0
  15. package/dist/components/primitives.d.ts +2 -0
  16. package/dist/components/primitives.js +15 -0
  17. package/dist/components/properties.d.ts +2 -0
  18. package/dist/components/properties.js +15 -0
  19. package/dist/components/sdk.d.ts +3 -0
  20. package/dist/components/sdk.js +15 -0
  21. package/dist/components/sidebar.d.ts +2 -0
  22. package/dist/components/sidebar.js +15 -0
  23. package/dist/components/snippets.d.ts +4 -0
  24. package/dist/components/snippets.js +15 -0
  25. package/dist/contexts/component-generics.d.ts +2 -0
  26. package/dist/contexts/component-generics.js +3 -0
  27. package/dist/contexts/component-types.d.ts +17 -0
  28. package/dist/contexts/component-types.js +0 -0
  29. package/dist/contexts/component.d.ts +30 -0
  30. package/dist/contexts/component.js +15 -0
  31. package/dist/contexts/docs.d.ts +2 -0
  32. package/dist/contexts/docs.js +3 -0
  33. package/dist/contexts/index.d.ts +19 -0
  34. package/dist/contexts/index.js +15 -0
  35. package/dist/contexts/markdown.d.ts +2 -0
  36. package/dist/contexts/markdown.js +4 -0
  37. package/dist/contexts/navigation.d.ts +3 -0
  38. package/dist/contexts/navigation.js +3 -0
  39. package/dist/contexts/search.d.ts +4 -0
  40. package/dist/contexts/search.js +15 -0
  41. package/dist/contexts/use-components.d.ts +15 -0
  42. package/dist/contexts/use-components.js +4 -0
  43. package/dist/contexts-B-OYzYpz.js +3837 -0
  44. package/dist/docs-BeJaKOCE.d.ts +46 -0
  45. package/dist/docs-CopwX9a7.js +54 -0
  46. package/dist/icons-yb-Jhkmg.js +753 -0
  47. package/dist/index-CBi59jcw.d.ts +240 -0
  48. package/dist/index-DT1wzg21.d.ts +15 -0
  49. package/dist/index-DteYqCJO.d.ts +14 -0
  50. package/dist/index.d.ts +21 -0
  51. package/dist/index.js +15 -7542
  52. package/dist/languages/go.d.ts +12 -0
  53. package/dist/languages/go.js +15 -0
  54. package/dist/languages/http.d.ts +12 -0
  55. package/dist/languages/http.js +15 -0
  56. package/dist/languages/index.d.ts +12 -0
  57. package/dist/languages/index.js +15 -0
  58. package/dist/languages/java.d.ts +12 -0
  59. package/dist/languages/java.js +15 -0
  60. package/dist/languages/python.d.ts +12 -0
  61. package/dist/languages/python.js +15 -0
  62. package/dist/languages/ruby.d.ts +12 -0
  63. package/dist/languages/ruby.js +15 -0
  64. package/dist/languages/typescript.d.ts +12 -0
  65. package/dist/languages/typescript.js +15 -0
  66. package/dist/markdown/index.d.ts +12 -0
  67. package/dist/markdown/index.js +15 -0
  68. package/dist/markdown/md.d.ts +15 -0
  69. package/dist/markdown/md.js +3 -0
  70. package/dist/markdown/utils.d.ts +4 -0
  71. package/dist/markdown/utils.js +3 -0
  72. package/dist/markdown-DTVxnxGP.d.ts +22 -0
  73. package/dist/markdown-Diyg-eof.js +48 -0
  74. package/dist/md-DxiV1_vy.js +41 -0
  75. package/dist/method-DHjDGGA_.d.ts +71 -0
  76. package/dist/navigation-CGr5_w6z.js +24 -0
  77. package/dist/navigation-rt_B_1lt.d.ts +29 -0
  78. package/dist/overview-CKJV2xUO.d.ts +39 -0
  79. package/dist/pagefind-BaK1krMe.js +15 -0
  80. package/dist/primitives-CiVFjnRA.d.ts +99 -0
  81. package/dist/properties-Z45x-uLZ.d.ts +46 -0
  82. package/dist/routing-DNN8R6bZ.d.ts +54 -0
  83. package/dist/routing-qs2YNG9o.js +189 -0
  84. package/dist/routing.d.ts +2 -0
  85. package/dist/routing.js +3 -180
  86. package/dist/sdk-DDWWoPPD.d.ts +119 -0
  87. package/dist/search/index.d.ts +26 -0
  88. package/dist/search/index.js +334 -0
  89. package/dist/search/providers/algolia.d.ts +24 -0
  90. package/dist/search/providers/algolia.js +15 -0
  91. package/dist/search/providers/fuse.d.ts +18 -0
  92. package/dist/search/providers/fuse.js +30 -0
  93. package/dist/search/providers/pagefind.d.ts +7 -0
  94. package/dist/search/providers/pagefind.js +3 -0
  95. package/dist/search/providers/walker.d.ts +9 -0
  96. package/dist/search/providers/walker.js +34 -0
  97. package/dist/search/types.d.ts +3 -0
  98. package/dist/search/types.js +3 -0
  99. package/dist/search-CCDWCiAd.d.ts +21 -0
  100. package/dist/sidebar-DrtsF85U.d.ts +36 -0
  101. package/dist/snippets-B2EEG7AK.d.ts +46 -0
  102. package/dist/spec.d.ts +65 -0
  103. package/dist/spec.js +167 -0
  104. package/dist/style-BhhgPVF6.js +165 -0
  105. package/dist/style-p4qTfnmO.d.ts +164 -0
  106. package/dist/style.d.ts +2 -0
  107. package/dist/style.js +3 -0
  108. package/dist/styles/main.css +724 -754
  109. package/dist/styles/main.js +0 -0
  110. package/dist/styles/primitives.css +287 -466
  111. package/dist/styles/primitives.js +0 -0
  112. package/dist/styles/resets.css +31 -41
  113. package/dist/styles/resets.js +0 -0
  114. package/dist/styles/search.css +175 -274
  115. package/dist/styles/search.js +0 -0
  116. package/dist/styles/sidebar.css +59 -60
  117. package/dist/styles/sidebar.js +0 -0
  118. package/dist/styles/variables.css +26 -89
  119. package/dist/styles/variables.js +0 -0
  120. package/dist/styles.css +1753 -0
  121. package/dist/styles.mjs +1 -0
  122. package/dist/types-DNSz4kuM.d.ts +83 -0
  123. package/dist/types-__XoFvJ_.js +34 -0
  124. package/dist/use-components-BHEwm0mE.js +7 -0
  125. package/dist/utils-CA3mYNaX.d.ts +21 -0
  126. package/dist/utils-D43p_yTd.d.ts +14 -0
  127. package/dist/utils-FnJ4tyuN.js +32 -0
  128. package/dist/utils-Jo_o4DX9.js +31 -0
  129. package/dist/utils.d.ts +2 -0
  130. package/dist/utils.js +4 -0
  131. package/package.json +84 -19
  132. package/dist/mcp.js +0 -16003
  133. package/dist/styles/snippets.css +0 -132
  134. package/src/components/breadcrumbs.tsx +0 -94
  135. package/src/components/chat.tsx +0 -154
  136. package/src/components/dropdown.tsx +0 -91
  137. package/src/components/icons.tsx +0 -584
  138. package/src/components/index.ts +0 -9
  139. package/src/components/method.tsx +0 -144
  140. package/src/components/overview.tsx +0 -159
  141. package/src/components/primitives.tsx +0 -284
  142. package/src/components/properties.tsx +0 -130
  143. package/src/components/scripts/dropdown.ts +0 -78
  144. package/src/components/sdk.tsx +0 -402
  145. package/src/components/sidebar.tsx +0 -99
  146. package/src/components/snippets.tsx +0 -179
  147. package/src/contexts/component-generics.tsx +0 -48
  148. package/src/contexts/component-types.tsx +0 -5
  149. package/src/contexts/component.tsx +0 -32
  150. package/src/contexts/docs.tsx +0 -75
  151. package/src/contexts/index.tsx +0 -17
  152. package/src/contexts/markdown.tsx +0 -43
  153. package/src/contexts/navigation.tsx +0 -44
  154. package/src/contexts/search.tsx +0 -28
  155. package/src/contexts/use-components.tsx +0 -4
  156. package/src/index.ts +0 -6
  157. package/src/languages/go.tsx +0 -281
  158. package/src/languages/http.tsx +0 -321
  159. package/src/languages/index.ts +0 -26
  160. package/src/languages/java.tsx +0 -358
  161. package/src/languages/python.tsx +0 -255
  162. package/src/languages/ruby.tsx +0 -320
  163. package/src/languages/typescript.tsx +0 -393
  164. package/src/markdown/index.ts +0 -107
  165. package/src/markdown/md.ts +0 -45
  166. package/src/markdown/utils.ts +0 -49
  167. package/src/routing.ts +0 -238
  168. package/src/search/form.tsx +0 -127
  169. package/src/search/index.tsx +0 -1
  170. package/src/search/indexer.ts +0 -246
  171. package/src/search/mcp.ts +0 -61
  172. package/src/search/printer.tsx +0 -86
  173. package/src/search/providers/algolia.ts +0 -88
  174. package/src/search/providers/fuse.ts +0 -19
  175. package/src/search/providers/pagefind.ts +0 -17
  176. package/src/search/providers/walker.ts +0 -30
  177. package/src/search/results.tsx +0 -181
  178. package/src/search/state.ts +0 -64
  179. package/src/search/types.ts +0 -116
  180. package/src/style.ts +0 -197
  181. package/src/styles/main.css +0 -993
  182. package/src/styles/primitives.css +0 -572
  183. package/src/styles/resets.css +0 -47
  184. package/src/styles/search.css +0 -342
  185. package/src/styles/sidebar.css +0 -87
  186. package/src/styles/snippets.css +0 -132
  187. package/src/styles/variables.css +0 -90
  188. package/src/utils.ts +0 -41
@@ -0,0 +1,99 @@
1
+ import * as React$1 from "react";
2
+ import { ReactNode } from "react";
3
+ import * as react_jsx_runtime70 from "react/jsx-runtime";
4
+
5
+ //#region src/components/primitives.d.ts
6
+ type JoinProps = {
7
+ items: ReactNode[];
8
+ limit?: number;
9
+ children: ReactNode;
10
+ };
11
+ declare function Join({
12
+ items,
13
+ limit,
14
+ children
15
+ }: JoinProps): react_jsx_runtime70.JSX.Element[];
16
+ type ExpanderProps = {
17
+ id?: string;
18
+ open?: boolean;
19
+ summary: ReactNode;
20
+ virtual?: boolean;
21
+ muted?: boolean;
22
+ children?: ReactNode;
23
+ };
24
+ declare function Expander({
25
+ id,
26
+ open,
27
+ summary,
28
+ virtual,
29
+ muted,
30
+ children
31
+ }: ExpanderProps): react_jsx_runtime70.JSX.Element;
32
+ declare function VirtualExpander({
33
+ id,
34
+ open: isOpen,
35
+ muted,
36
+ summary,
37
+ children
38
+ }: Omit<ExpanderProps, 'virtual'>): react_jsx_runtime70.JSX.Element;
39
+ declare function Markdown({
40
+ content
41
+ }: {
42
+ content: string;
43
+ }): "" | react_jsx_runtime70.JSX.Element | undefined;
44
+ type BadgeProps = {
45
+ id: string;
46
+ children?: ReactNode;
47
+ };
48
+ declare function Badge({
49
+ id,
50
+ children
51
+ }: BadgeProps): react_jsx_runtime70.JSX.Element;
52
+ type TooltipProps = {
53
+ content: ReactNode;
54
+ children: ReactNode;
55
+ };
56
+ declare function Tooltip({
57
+ content,
58
+ children
59
+ }: TooltipProps): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | react_jsx_runtime70.JSX.Element | null | undefined;
60
+ type LinkProps = {
61
+ stainlessPath: string;
62
+ scroll?: boolean;
63
+ children?: ReactNode;
64
+ } & React$1.HTMLProps<HTMLAnchorElement>;
65
+ declare function Link({
66
+ stainlessPath,
67
+ scroll,
68
+ children,
69
+ ...props
70
+ }: LinkProps): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | react_jsx_runtime70.JSX.Element | null | undefined;
71
+ type InputProps = {
72
+ left?: ReactNode;
73
+ right?: ReactNode;
74
+ } & React$1.InputHTMLAttributes<HTMLInputElement>;
75
+ declare const Input: React$1.ForwardRefExoticComponent<{
76
+ left?: ReactNode;
77
+ right?: ReactNode;
78
+ } & React$1.InputHTMLAttributes<HTMLInputElement> & React$1.RefAttributes<HTMLInputElement>>;
79
+ type ToggleButtonProps = {
80
+ children?: ReactNode;
81
+ selected?: boolean;
82
+ } & React$1.ButtonHTMLAttributes<HTMLButtonElement>;
83
+ declare const ToggleButton: React$1.ForwardRefExoticComponent<{
84
+ children?: ReactNode;
85
+ selected?: boolean;
86
+ } & React$1.ButtonHTMLAttributes<HTMLButtonElement> & React$1.RefAttributes<HTMLButtonElement>>;
87
+ type ListViewProps<TItem> = {
88
+ items: Array<TItem>;
89
+ itemDelegate: (item: TItem, selected: boolean) => React$1.ReactNode;
90
+ onSelectListItem?: (item: TItem) => void;
91
+ } & React$1.HTMLAttributes<HTMLDivElement>;
92
+ declare function ListView<TItem>({
93
+ items,
94
+ itemDelegate,
95
+ onSelectListItem,
96
+ ...rest
97
+ }: ListViewProps<TItem>): react_jsx_runtime70.JSX.Element;
98
+ //#endregion
99
+ export { Join as a, ListViewProps as c, ToggleButtonProps as d, Tooltip as f, InputProps as i, Markdown as l, Expander as n, Link as o, VirtualExpander as p, Input as r, ListView as s, Badge as t, ToggleButton as u };
@@ -0,0 +1,46 @@
1
+ import { ReactNode } from "react";
2
+ import * as react_jsx_runtime55 from "react/jsx-runtime";
3
+
4
+ //#region src/components/properties.d.ts
5
+ type PropertyToggleProps = {
6
+ target: string;
7
+ };
8
+ declare function PropertyToggle({
9
+ target
10
+ }: PropertyToggleProps): react_jsx_runtime55.JSX.Element;
11
+ type PropertyDescriptionProps = {
12
+ description?: string;
13
+ };
14
+ declare function PropertyDescription({
15
+ description
16
+ }: PropertyDescriptionProps): react_jsx_runtime55.JSX.Element | undefined;
17
+ type PropertyProps = {
18
+ id?: string;
19
+ name?: ReactNode;
20
+ typeName?: ReactNode;
21
+ badges?: ReactNode;
22
+ type?: ReactNode;
23
+ description?: string;
24
+ expand?: boolean;
25
+ deprecated?: boolean | string;
26
+ additional?: ReactNode;
27
+ declaration?: ReactNode;
28
+ constraints?: ReactNode;
29
+ children?: ReactNode;
30
+ };
31
+ declare function Property({
32
+ id,
33
+ name,
34
+ typeName,
35
+ badges,
36
+ type,
37
+ declaration,
38
+ description,
39
+ deprecated,
40
+ expand,
41
+ additional,
42
+ constraints,
43
+ children
44
+ }: PropertyProps): react_jsx_runtime55.JSX.Element;
45
+ //#endregion
46
+ export { PropertyToggle as a, PropertyProps as i, PropertyDescription as n, PropertyToggleProps as o, PropertyDescriptionProps as r, Property as t };
@@ -0,0 +1,54 @@
1
+ import * as SDKJSON from "@stainless/sdk-json";
2
+
3
+ //#region src/routing.d.ts
4
+ declare namespace routing_d_exports {
5
+ export { DocsLanguage, LanguageNames, Languages, ParsedStainlessPath, RouteEntry, SpecTreeEntry, SupportedLanguageSyntaxes, expandToElement, findNavigationPath, generateRoute, generateRouteList, getLanguageSnippet, getResource, isSupportedLanguage, parseRoute, parseStainlessPath, scrollToPath, trimStainlessPath, updateHistory, walkTree };
6
+ }
7
+ declare const Languages: readonly ["http", "node", "python", "go", "typescript", "terraform", "ruby", "java", "kotlin"];
8
+ declare const SupportedLanguageSyntaxes: string[];
9
+ type DocsLanguage = (typeof Languages)[number];
10
+ declare const LanguageNames: Record<DocsLanguage, string>;
11
+ declare function getLanguageSnippet(language: DocsLanguage): "http.curl" | "node.default" | "go.default" | "python.default" | "terraform.default" | "typescript.default" | "ruby.default" | "java.default" | "kotlin.default";
12
+ declare function isSupportedLanguage(language: string): language is DocsLanguage;
13
+ type ParsedStainlessPath = ReturnType<typeof parseStainlessPath>;
14
+ declare function parseStainlessPath(stainlessPath: string): {
15
+ resource: string[] | null;
16
+ method: string | null;
17
+ model: string | null;
18
+ routable: string | undefined;
19
+ } | null;
20
+ declare function trimStainlessPath(stainlessPath: string): string;
21
+ declare function getResource(stainlessPath: string): string | undefined;
22
+ declare function parseRoute(basePath: string, route: string): {
23
+ stainlessPath: string;
24
+ language: DocsLanguage;
25
+ };
26
+ declare function generateRoute(basePath: string, language: string, stainlessPath: string): string | null;
27
+ type SpecTreeEntry = {
28
+ data: SDKJSON.Method | SDKJSON.Resource | SDKJSON.Model;
29
+ path: string[];
30
+ };
31
+ declare function walkTree(spec: SDKJSON.Spec, includeModels?: boolean): Generator<SpecTreeEntry, void, any>;
32
+ type RouteEntry = {
33
+ title: string;
34
+ kind: SpecTreeEntry['data']['kind'];
35
+ language: DocsLanguage;
36
+ stainlessPath: string;
37
+ slug: string;
38
+ };
39
+ declare function generateRouteList({
40
+ spec,
41
+ languages,
42
+ excludeLanguages
43
+ }: {
44
+ spec: SDKJSON.Spec;
45
+ languages?: DocsLanguage[];
46
+ excludeLanguages?: DocsLanguage[];
47
+ }): RouteEntry[];
48
+ type ResourceOrMethod = SDKJSON.Resource | SDKJSON.Method;
49
+ declare function findNavigationPath(items: ResourceOrMethod[], target: string): string[] | undefined;
50
+ declare function expandToElement(el: HTMLElement | null): void;
51
+ declare function scrollToPath(stainlessPath: string): void;
52
+ declare function updateHistory(basePath: string, language: DocsLanguage, stainlessPath: string): void;
53
+ //#endregion
54
+ export { routing_d_exports as _, RouteEntry as a, updateHistory as b, expandToElement as c, generateRouteList as d, getLanguageSnippet as f, parseStainlessPath as g, parseRoute as h, ParsedStainlessPath as i, findNavigationPath as l, isSupportedLanguage as m, LanguageNames as n, SpecTreeEntry as o, getResource as p, Languages as r, SupportedLanguageSyntaxes as s, DocsLanguage as t, generateRoute as u, scrollToPath as v, walkTree as x, trimStainlessPath as y };
@@ -0,0 +1,189 @@
1
+ import { t as __export } from "./chunk-Bf_Gc_jT.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
+ ];
33
+ const SupportedLanguageSyntaxes = [
34
+ "http",
35
+ "javascript",
36
+ "python",
37
+ "go",
38
+ "typescript",
39
+ "terraform",
40
+ "ruby",
41
+ "java",
42
+ "kotlin"
43
+ ];
44
+ const LanguageNames = {
45
+ http: "HTTP",
46
+ node: "TypeScript",
47
+ typescript: "TypeScript",
48
+ python: "Python",
49
+ go: "Go",
50
+ ruby: "Ruby",
51
+ java: "Java",
52
+ kotlin: "Kotlin",
53
+ terraform: "Terraform"
54
+ };
55
+ function getLanguageSnippet(language) {
56
+ return language === "http" ? "http.curl" : `${language}.default`;
57
+ }
58
+ function isSupportedLanguage(language) {
59
+ return Languages.includes(language);
60
+ }
61
+ const DefaultLanguage = "http";
62
+ const StainlessPathPattern = /(\(resource\) (?<resource>[^\s]+))( > (\(method\) (?<method>[^\s]+)|\(model\) (?<model>[^\s]+))?)?/;
63
+ function parseStainlessPath(stainlessPath) {
64
+ const match = stainlessPath.match(StainlessPathPattern);
65
+ if (!match?.groups) return null;
66
+ return {
67
+ resource: match.groups.resource?.split(".") ?? null,
68
+ method: match.groups.method ?? null,
69
+ model: match.groups.model ?? null,
70
+ routable: match.groups.model ? match[1] : match[0]
71
+ };
72
+ }
73
+ function trimStainlessPath(stainlessPath) {
74
+ return stainlessPath.replace(/ > \([^\s]+\)$/, "");
75
+ }
76
+ function getResource(stainlessPath) {
77
+ return parseStainlessPath(stainlessPath)?.resource?.[0];
78
+ }
79
+ function parseRoute(basePath, route) {
80
+ if (!route.startsWith(basePath)) return {
81
+ stainlessPath: "",
82
+ language: DefaultLanguage
83
+ };
84
+ if (basePath && route.startsWith(basePath)) route = route.slice(basePath.length);
85
+ let stainlessPath = "";
86
+ let elements = route.slice(1).split("/");
87
+ let language = DefaultLanguage;
88
+ if (elements[0] && Languages.includes(elements[0])) {
89
+ language = elements[0];
90
+ elements = elements.slice(1);
91
+ }
92
+ while (elements.length > 0) switch (elements.shift()) {
93
+ case "resources":
94
+ stainlessPath += `(resource) ${elements.shift()}`;
95
+ break;
96
+ case "subresources":
97
+ stainlessPath += `.${elements.shift()}`;
98
+ break;
99
+ case "methods":
100
+ stainlessPath += ` > (method) ${elements.shift()}`;
101
+ break;
102
+ }
103
+ return {
104
+ stainlessPath,
105
+ language
106
+ };
107
+ }
108
+ function generateRoute(basePath, language, stainlessPath) {
109
+ const parsedPath = parseStainlessPath(stainlessPath);
110
+ if (!parsedPath) return null;
111
+ const path = [basePath.endsWith("/") ? basePath.slice(0, -1) : basePath];
112
+ if (language && language !== DefaultLanguage) path.push(language);
113
+ const resources = parsedPath.resource.flatMap((name, index) => [index > 0 ? "subresources" : "resources", name]);
114
+ const resourcePath = parsedPath.model ? resources.slice(0, 2) : resources;
115
+ path.push(...resourcePath);
116
+ if (parsedPath.method) path.push("methods", parsedPath.method);
117
+ return stainlessPath.length > parsedPath.routable.length ? `${path.join("/")}#${encodeURIComponent(stainlessPath)}` : path.join("/");
118
+ }
119
+ function* walkResource(resource, path, includeModels) {
120
+ yield {
121
+ data: resource,
122
+ path
123
+ };
124
+ for (const data of Object.values(resource.methods)) yield {
125
+ data,
126
+ path: [
127
+ ...path,
128
+ "methods",
129
+ data.name
130
+ ]
131
+ };
132
+ if (includeModels) for (const data of Object.values(resource.models)) yield {
133
+ data,
134
+ path: [
135
+ ...path,
136
+ "models",
137
+ data.name
138
+ ]
139
+ };
140
+ for (const data of Object.values(resource.subresources ?? {})) yield* walkResource(data, [
141
+ ...path,
142
+ "subresources",
143
+ data.name
144
+ ]);
145
+ }
146
+ function* walkTree(spec, includeModels) {
147
+ for (const data of Object.values(spec.resources)) yield* walkResource(data, ["resources", data.name], includeModels);
148
+ }
149
+ function generateRouteList({ spec, languages, excludeLanguages = [] }) {
150
+ const entries = Array.from(walkTree(spec));
151
+ 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 } }) => ({
152
+ title,
153
+ kind,
154
+ language,
155
+ stainlessPath,
156
+ slug: (language === "http" ? path : [language, ...path]).join("/")
157
+ })));
158
+ }
159
+ function findNavigationPath(items, target) {
160
+ for (const item of Object.values(items)) {
161
+ if (item.stainlessPath === target) return [item.stainlessPath];
162
+ if (item.kind === "http_method") continue;
163
+ const path = findNavigationPath([...Object.values(item.methods ?? {}), ...Object.values(item.subresources ?? {})], target);
164
+ if (path) return [item.stainlessPath, ...path];
165
+ }
166
+ }
167
+ function expandToElement(el) {
168
+ while (el) {
169
+ if (el instanceof HTMLDetailsElement) el.open = true;
170
+ el = el.parentElement;
171
+ }
172
+ }
173
+ function scrollToPath(stainlessPath) {
174
+ const el = document.getElementById(stainlessPath);
175
+ if (el) {
176
+ expandToElement(el);
177
+ el.scrollIntoView({ behavior: "smooth" });
178
+ }
179
+ }
180
+ function updateHistory(basePath, language, stainlessPath) {
181
+ const path = generateRoute(basePath, language, stainlessPath);
182
+ window.history.pushState({
183
+ stainlessPath,
184
+ language
185
+ }, "", path);
186
+ }
187
+
188
+ //#endregion
189
+ 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-DNN8R6bZ.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-qs2YNG9o.js";
2
+
3
+ export { LanguageNames, Languages, SupportedLanguageSyntaxes, expandToElement, findNavigationPath, generateRoute, generateRouteList, getLanguageSnippet, getResource, isSupportedLanguage, parseRoute, parseStainlessPath, scrollToPath, trimStainlessPath, updateHistory, walkTree };
@@ -0,0 +1,119 @@
1
+ import { t as DocsLanguage } from "./routing-DNN8R6bZ.js";
2
+ import * as React$1 from "react";
3
+ import * as react_jsx_runtime39 from "react/jsx-runtime";
4
+ import * as SDKJSON from "@stainless/sdk-json";
5
+
6
+ //#region src/components/sdk.d.ts
7
+ type PropertyModelContextType = {
8
+ modelPath?: string;
9
+ propertyPath?: string;
10
+ };
11
+ declare const PropertyModelContext: React$1.Context<PropertyModelContextType>;
12
+ declare function usePropertyModel(): PropertyModelContextType;
13
+ type ReferenceNestingContextType = string[];
14
+ declare const ReferenceNestingContext: React$1.Context<ReferenceNestingContextType>;
15
+ declare function useReferenceNesting(): ReferenceNestingContextType;
16
+ type SDKSnippetLanguagesType = Record<SDKJSON.SnippetLanguage, {
17
+ name: string;
18
+ icon: string;
19
+ }>;
20
+ declare const SDKSnippetLanguages: SDKSnippetLanguagesType;
21
+ type TransformRequestSnippetFn = ({
22
+ snippet,
23
+ language
24
+ }: {
25
+ snippet: string;
26
+ language: DocsLanguage;
27
+ }) => string;
28
+ type SDKChildrenProps = {
29
+ paths: SDKJSON.ID[];
30
+ expand?: boolean;
31
+ depth?: number;
32
+ };
33
+ declare function SDKChildren({
34
+ paths,
35
+ expand,
36
+ depth
37
+ }: SDKChildrenProps): react_jsx_runtime39.JSX.Element;
38
+ type SDKDeclarationProps = {
39
+ path: string;
40
+ expand?: boolean;
41
+ depth?: number;
42
+ };
43
+ declare function SDKDeclaration({
44
+ path,
45
+ expand,
46
+ depth
47
+ }: SDKDeclarationProps): react_jsx_runtime39.JSX.Element;
48
+ type SDKConstraintsProps = {
49
+ constraints?: Record<string, any>;
50
+ };
51
+ declare function SDKConstraints({
52
+ constraints
53
+ }: SDKConstraintsProps): react_jsx_runtime39.JSX.Element | undefined;
54
+ type SDKIconProps = {
55
+ language: SDKJSON.SnippetLanguage;
56
+ size?: number;
57
+ };
58
+ declare function SDKIcon({
59
+ language
60
+ }: SDKIconProps): react_jsx_runtime39.JSX.Element | null;
61
+ type SDKRequestTitleProps = {
62
+ snippetLanguage: SDKJSON.SnippetLanguage;
63
+ };
64
+ declare function SDKRequestTitle({
65
+ snippetLanguage
66
+ }: SDKRequestTitleProps): react_jsx_runtime39.JSX.Element;
67
+ type SDKExampleProps = {
68
+ method: SDKJSON.Method;
69
+ transformRequestSnippet?: TransformRequestSnippetFn;
70
+ };
71
+ declare function SDKExample({
72
+ method,
73
+ transformRequestSnippet
74
+ }: SDKExampleProps): react_jsx_runtime39.JSX.Element;
75
+ type SDKMethodProps = {
76
+ method: SDKJSON.Method;
77
+ transformRequestSnippet?: TransformRequestSnippetFn;
78
+ };
79
+ declare function SDKMethodHeader({
80
+ method
81
+ }: SDKMethodProps): react_jsx_runtime39.JSX.Element;
82
+ declare function SDKMethodInfo({
83
+ method
84
+ }: SDKMethodProps): react_jsx_runtime39.JSX.Element;
85
+ declare function SDKMethod({
86
+ method,
87
+ transformRequestSnippet
88
+ }: SDKMethodProps): react_jsx_runtime39.JSX.Element;
89
+ type SDKModelProps = {
90
+ model: SDKJSON.Model;
91
+ };
92
+ declare function SDKModel({
93
+ model
94
+ }: SDKModelProps): react_jsx_runtime39.JSX.Element | null;
95
+ type SDKReferenceProps = {
96
+ stainlessPath: string;
97
+ children?: React$1.ReactNode;
98
+ };
99
+ declare function SDKReference({
100
+ stainlessPath,
101
+ children
102
+ }: SDKReferenceProps): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | react_jsx_runtime39.JSX.Element | null | undefined;
103
+ type SDKLanguageBlockProps = {
104
+ language: DocsLanguage;
105
+ version: string;
106
+ install: string;
107
+ links: {
108
+ repo: string;
109
+ docs: string;
110
+ };
111
+ };
112
+ declare function SDKLanguageBlock({
113
+ language,
114
+ version,
115
+ install,
116
+ links
117
+ }: SDKLanguageBlockProps): react_jsx_runtime39.JSX.Element;
118
+ //#endregion
119
+ export { TransformRequestSnippetFn as C, SDKSnippetLanguagesType as S, useReferenceNesting as T, SDKModelProps as _, SDKChildren as a, SDKRequestTitleProps as b, SDKDeclaration as c, SDKLanguageBlock as d, SDKMethod as f, SDKModel as g, SDKMethodProps as h, ReferenceNestingContextType as i, SDKExample as l, SDKMethodInfo as m, PropertyModelContextType as n, SDKConstraints as o, SDKMethodHeader as p, ReferenceNestingContext as r, SDKConstraintsProps as s, PropertyModelContext as t, SDKIcon as u, SDKReference as v, usePropertyModel as w, SDKSnippetLanguages as x, SDKRequestTitle as y };