@stainless-api/docs-ui 0.1.0-beta.21 → 0.1.0-beta.22

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 (123) hide show
  1. package/dist/index.js +1762 -1015
  2. package/package.json +4 -4
  3. package/dist/breadcrumbs-Z-hEqjcp.d.ts +0 -19
  4. package/dist/chunk-Bp6m_JJh.js +0 -13
  5. package/dist/component-generics-DzI21jRn.js +0 -35
  6. package/dist/component-generics-q5Dqiu2D.d.ts +0 -30
  7. package/dist/components/breadcrumbs.d.ts +0 -2
  8. package/dist/components/breadcrumbs.js +0 -16
  9. package/dist/components/chat.d.ts +0 -14
  10. package/dist/components/chat.js +0 -144
  11. package/dist/components/dropdown.d.ts +0 -2
  12. package/dist/components/dropdown.js +0 -4
  13. package/dist/components/icons.d.ts +0 -50
  14. package/dist/components/icons.js +0 -3
  15. package/dist/components/index.d.ts +0 -12
  16. package/dist/components/index.js +0 -16
  17. package/dist/components/method.d.ts +0 -2
  18. package/dist/components/method.js +0 -16
  19. package/dist/components/overview.d.ts +0 -2
  20. package/dist/components/overview.js +0 -16
  21. package/dist/components/primitives.d.ts +0 -2
  22. package/dist/components/primitives.js +0 -16
  23. package/dist/components/properties.d.ts +0 -2
  24. package/dist/components/properties.js +0 -16
  25. package/dist/components/scripts/dropdown.d.ts +0 -12
  26. package/dist/components/scripts/dropdown.js +0 -50
  27. package/dist/components/sdk.d.ts +0 -3
  28. package/dist/components/sdk.js +0 -16
  29. package/dist/components/sidebar.d.ts +0 -2
  30. package/dist/components/sidebar.js +0 -16
  31. package/dist/components/snippets.d.ts +0 -4
  32. package/dist/components/snippets.js +0 -16
  33. package/dist/contexts/component-generics.d.ts +0 -2
  34. package/dist/contexts/component-generics.js +0 -3
  35. package/dist/contexts/component-types.d.ts +0 -18
  36. package/dist/contexts/component-types.js +0 -1
  37. package/dist/contexts/component.d.ts +0 -31
  38. package/dist/contexts/component.js +0 -16
  39. package/dist/contexts/docs.d.ts +0 -2
  40. package/dist/contexts/docs.js +0 -3
  41. package/dist/contexts/index.d.ts +0 -20
  42. package/dist/contexts/index.js +0 -16
  43. package/dist/contexts/markdown.d.ts +0 -2
  44. package/dist/contexts/markdown.js +0 -4
  45. package/dist/contexts/navigation.d.ts +0 -3
  46. package/dist/contexts/navigation.js +0 -3
  47. package/dist/contexts/search.d.ts +0 -4
  48. package/dist/contexts/search.js +0 -16
  49. package/dist/contexts/use-components.d.ts +0 -16
  50. package/dist/contexts/use-components.js +0 -4
  51. package/dist/contexts-DRxRO-xO.js +0 -3747
  52. package/dist/docs-Dh8kE1va.js +0 -50
  53. package/dist/docs-EUy-wfbA.d.ts +0 -43
  54. package/dist/dropdown-B7VyGMOw.d.ts +0 -43
  55. package/dist/dropdown-DtgAi6lb.js +0 -62
  56. package/dist/icons-DdKM-01E.js +0 -753
  57. package/dist/index-AicgPYKB.d.ts +0 -239
  58. package/dist/index-BhwLhiWk.d.ts +0 -14
  59. package/dist/index-YnpUtXLB.d.ts +0 -16
  60. package/dist/index.d.ts +0 -22
  61. package/dist/languages/go.d.ts +0 -13
  62. package/dist/languages/go.js +0 -16
  63. package/dist/languages/http.d.ts +0 -13
  64. package/dist/languages/http.js +0 -16
  65. package/dist/languages/index.d.ts +0 -13
  66. package/dist/languages/index.js +0 -16
  67. package/dist/languages/java.d.ts +0 -13
  68. package/dist/languages/java.js +0 -16
  69. package/dist/languages/python.d.ts +0 -13
  70. package/dist/languages/python.js +0 -16
  71. package/dist/languages/ruby.d.ts +0 -13
  72. package/dist/languages/ruby.js +0 -16
  73. package/dist/languages/typescript.d.ts +0 -13
  74. package/dist/languages/typescript.js +0 -16
  75. package/dist/markdown/index.d.ts +0 -11
  76. package/dist/markdown/index.js +0 -16
  77. package/dist/markdown/md.d.ts +0 -15
  78. package/dist/markdown/md.js +0 -3
  79. package/dist/markdown/utils.d.ts +0 -4
  80. package/dist/markdown/utils.js +0 -3
  81. package/dist/markdown-BXfX1D7C.js +0 -42
  82. package/dist/markdown-nFyAEX_K.d.ts +0 -22
  83. package/dist/mcp.js +0 -983441
  84. package/dist/md-Dg8aOyMA.js +0 -41
  85. package/dist/method-DpsVuzZW.d.ts +0 -71
  86. package/dist/navigation-aoYZ_tl4.js +0 -24
  87. package/dist/navigation-nyXBY-75.d.ts +0 -29
  88. package/dist/overview-C8e-6jGr.d.ts +0 -38
  89. package/dist/pagefind-ChrPfuVv.js +0 -15
  90. package/dist/primitives-DWz23_Ub.d.ts +0 -99
  91. package/dist/properties-CF71V58d.d.ts +0 -46
  92. package/dist/routing-DQjbRxdJ.js +0 -189
  93. package/dist/routing-qc0V00-j.d.ts +0 -51
  94. package/dist/routing.d.ts +0 -2
  95. package/dist/sdk-Zg3Rggk3.d.ts +0 -118
  96. package/dist/search/index.d.ts +0 -26
  97. package/dist/search/index.js +0 -332
  98. package/dist/search/providers/algolia.d.ts +0 -23
  99. package/dist/search/providers/algolia.js +0 -16
  100. package/dist/search/providers/fuse.d.ts +0 -17
  101. package/dist/search/providers/fuse.js +0 -31
  102. package/dist/search/providers/pagefind.d.ts +0 -7
  103. package/dist/search/providers/pagefind.js +0 -3
  104. package/dist/search/providers/walker.d.ts +0 -8
  105. package/dist/search/providers/walker.js +0 -32
  106. package/dist/search/types.d.ts +0 -3
  107. package/dist/search/types.js +0 -3
  108. package/dist/search-B6loAGmB.d.ts +0 -21
  109. package/dist/sidebar-C8KirYjg.d.ts +0 -35
  110. package/dist/snippets-EUzM4fRO.d.ts +0 -45
  111. package/dist/style-pN9hCoec.d.ts +0 -181
  112. package/dist/style-rYbbxIR_.js +0 -182
  113. package/dist/style.d.ts +0 -2
  114. package/dist/style.js +0 -3
  115. package/dist/types-CTBDtD34.d.ts +0 -82
  116. package/dist/types-DFN4M1Sp.js +0 -34
  117. package/dist/use-components-D9E85p5x.js +0 -7
  118. package/dist/utils-BHwvUDKn.js +0 -30
  119. package/dist/utils-CJfFBNgT.js +0 -32
  120. package/dist/utils-DQhEbvUC.d.ts +0 -20
  121. package/dist/utils-nDazhti8.d.ts +0 -11
  122. package/dist/utils.d.ts +0 -2
  123. package/dist/utils.js +0 -4
@@ -1,41 +0,0 @@
1
- import Markdoc from "@markdoc/markdoc";
2
-
3
- //#region src/markdown/md.ts
4
- function heading(level, children) {
5
- const content = inline(...typeof children === "string" ? [text(children)] : children);
6
- return new Markdoc.Ast.Node("heading", { level }, [content]);
7
- }
8
- function text(content) {
9
- return new Markdoc.Ast.Node("text", { content });
10
- }
11
- function code(content) {
12
- return new Markdoc.Ast.Node("code", { content });
13
- }
14
- function paragraph(...children) {
15
- const inline$1 = new Markdoc.Ast.Node("inline", {}, children);
16
- return new Markdoc.Ast.Node("paragraph", {}, [inline$1]);
17
- }
18
- function list(...children) {
19
- return new Markdoc.Ast.Node("list", { ordered: false }, children);
20
- }
21
- function item(...children) {
22
- return new Markdoc.Ast.Node("item", {}, children);
23
- }
24
- function strong(...children) {
25
- return new Markdoc.Ast.Node("strong", {}, children);
26
- }
27
- function inline(...children) {
28
- return new Markdoc.Ast.Node("inline", {}, children);
29
- }
30
- function fence(language, content) {
31
- return new Markdoc.Ast.Node("fence", {
32
- language,
33
- content
34
- });
35
- }
36
- function parse(content) {
37
- return Markdoc.parse(content).children;
38
- }
39
-
40
- //#endregion
41
- export { item as a, parse as c, inline as i, strong as l, fence as n, list as o, heading as r, paragraph as s, code as t, text as u };
@@ -1,71 +0,0 @@
1
- import * as React$1 from "react";
2
- import { ReactNode } from "react";
3
- import * as react_jsx_runtime57 from "react/jsx-runtime";
4
- import { LucideIcon } from "lucide-react";
5
-
6
- //#region src/components/method.d.ts
7
- declare const HttpMethods: string[];
8
- type HTTPMethod = (typeof HttpMethods)[number];
9
- declare const HttpMethodIcons: Record<HTTPMethod, LucideIcon>;
10
- type MethodIconProps = {
11
- httpMethod: string;
12
- showName?: boolean;
13
- };
14
- declare function MethodIconBadge({
15
- httpMethod,
16
- showName
17
- }: MethodIconProps): react_jsx_runtime57.JSX.Element | null;
18
- type MethodHeaderProps = {
19
- title: ReactNode;
20
- level?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5';
21
- signature?: ReactNode;
22
- badges?: ReactNode;
23
- children?: ReactNode;
24
- };
25
- declare function MethodHeader({
26
- title,
27
- badges,
28
- signature,
29
- children,
30
- level
31
- }: MethodHeaderProps): react_jsx_runtime57.JSX.Element;
32
- type MethodRouteProps = {
33
- httpMethod?: string;
34
- endpoint?: string | ReactNode;
35
- iconOnly?: boolean;
36
- };
37
- declare function MethodRoute({
38
- httpMethod,
39
- endpoint,
40
- iconOnly
41
- }: MethodRouteProps): react_jsx_runtime57.JSX.Element;
42
- type MethodDescriptionProps = {
43
- description?: string;
44
- };
45
- declare function MethodDescription({
46
- description
47
- }: MethodDescriptionProps): react_jsx_runtime57.JSX.Element | undefined;
48
- type MethodInfoProps = {
49
- children?: ReactNode;
50
- parameters?: ReactNode;
51
- returns?: ReactNode;
52
- };
53
- declare function MethodInfo({
54
- children,
55
- parameters,
56
- returns
57
- }: MethodInfoProps): react_jsx_runtime57.JSX.Element;
58
- type MethodProps = {
59
- id?: string;
60
- header?: ReactNode;
61
- children?: ReactNode;
62
- } & React$1.HTMLProps<HTMLDivElement>;
63
- declare function Method({
64
- id,
65
- header,
66
- children,
67
- className,
68
- ...props
69
- }: MethodProps): react_jsx_runtime57.JSX.Element;
70
- //#endregion
71
- export { MethodDescription as a, MethodHeaderProps as c, MethodInfo as d, MethodInfoProps as f, MethodRouteProps as h, Method as i, MethodIconBadge as l, MethodRoute as m, HttpMethodIcons as n, MethodDescriptionProps as o, MethodProps as p, HttpMethods as r, MethodHeader as s, HTTPMethod as t, MethodIconProps as u };
@@ -1,24 +0,0 @@
1
- import * as React$1 from "react";
2
- import { jsx } from "react/jsx-runtime";
3
-
4
- //#region src/contexts/navigation.tsx
5
- const Defaults = { basePath: "/" };
6
- const NavigationContext = React$1.createContext(Defaults);
7
- function useNavigation() {
8
- return React$1.useContext(NavigationContext);
9
- }
10
- function NavigationProvider({ basePath, selectedPath, onNavigate, children }) {
11
- const value = {
12
- ...Defaults,
13
- onNavigate,
14
- basePath,
15
- selectedPath
16
- };
17
- return /* @__PURE__ */ jsx(NavigationContext.Provider, {
18
- value,
19
- children
20
- });
21
- }
22
-
23
- //#endregion
24
- export { useNavigation as n, NavigationProvider as t };
@@ -1,29 +0,0 @@
1
- import { t as DocsLanguage } from "./routing-qc0V00-j.js";
2
- import * as React$1 from "react";
3
- import * as react_jsx_runtime39 from "react/jsx-runtime";
4
-
5
- //#region src/contexts/navigation.d.ts
6
- type NavigationHandler = (ev: React$1.MouseEvent | null, opts: {
7
- href: string;
8
- language: DocsLanguage;
9
- stainlessPath: string;
10
- scroll: boolean;
11
- }) => void;
12
- type NavigationContextType = {
13
- basePath?: string;
14
- selectedPath?: string;
15
- navigationPath?: string[];
16
- onNavigate?: NavigationHandler;
17
- };
18
- declare function useNavigation(): NavigationContextType;
19
- type NavigationProviderProps = NavigationContextType & {
20
- children: React$1.ReactNode;
21
- };
22
- declare function NavigationProvider({
23
- basePath,
24
- selectedPath,
25
- onNavigate,
26
- children
27
- }: NavigationProviderProps): react_jsx_runtime39.JSX.Element;
28
- //#endregion
29
- export { useNavigation as a, NavigationProviderProps as i, NavigationHandler as n, NavigationProvider as r, NavigationContextType as t };
@@ -1,38 +0,0 @@
1
- import * as react_jsx_runtime48 from "react/jsx-runtime";
2
-
3
- //#region src/components/overview.d.ts
4
- type SDKResourceProps = {
5
- resource: SDKJSON.Resource;
6
- parents?: SDKJSON.Resource[];
7
- };
8
- declare function SDKResourceHeader({
9
- resource,
10
- parents
11
- }: SDKResourceProps): react_jsx_runtime48.JSX.Element | null;
12
- type SDKMethodSummaryProps = {
13
- method: SDKJSON.Method;
14
- };
15
- declare function SDKMethodSummary({
16
- method
17
- }: SDKMethodSummaryProps): react_jsx_runtime48.JSX.Element;
18
- declare function SDKResource({
19
- resource,
20
- parents,
21
- showModels
22
- }: SDKResourceProps & {
23
- showModels?: boolean;
24
- }): react_jsx_runtime48.JSX.Element;
25
- type SDKOverviewProps = {
26
- resource: SDKJSON.Resource;
27
- };
28
- declare function SDKOverview({
29
- resource
30
- }: SDKOverviewProps): react_jsx_runtime48.JSX.Element;
31
- type SDKRootProps = {
32
- stainlessPath: string;
33
- };
34
- declare function SDKRoot({
35
- stainlessPath
36
- }: SDKRootProps): react_jsx_runtime48.JSX.Element | null;
37
- //#endregion
38
- export { SDKResource as a, SDKRoot as c, SDKOverviewProps as i, SDKRootProps as l, SDKMethodSummaryProps as n, SDKResourceHeader as o, SDKOverview as r, SDKResourceProps as s, SDKMethodSummary as t };
@@ -1,15 +0,0 @@
1
- //#region src/search/providers/pagefind.ts
2
- async function loadPagefind(path) {
3
- return await import(new URL(path, import.meta.url).href);
4
- }
5
- async function guideSearch(loadPath, query, limit) {
6
- const response = await (await loadPagefind(loadPath)).search(query);
7
- const items = limit ? response.results.slice(0, limit) : response.results;
8
- return Promise.all(items.map((result) => result.data().then((data) => ({
9
- ...result,
10
- data
11
- }))));
12
- }
13
-
14
- //#endregion
15
- export { guideSearch as t };
@@ -1,99 +0,0 @@
1
- import * as React$1 from "react";
2
- import { ReactNode } from "react";
3
- import * as react_jsx_runtime67 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_runtime67.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_runtime67.JSX.Element;
32
- declare function VirtualExpander({
33
- id,
34
- open: isOpen,
35
- muted,
36
- summary,
37
- children
38
- }: Omit<ExpanderProps, 'virtual'>): react_jsx_runtime67.JSX.Element;
39
- declare function Markdown({
40
- content
41
- }: {
42
- content: string;
43
- }): "" | react_jsx_runtime67.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_runtime67.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_runtime67.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_runtime67.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_runtime67.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 };
@@ -1,46 +0,0 @@
1
- import { ReactNode } from "react";
2
- import * as react_jsx_runtime45 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_runtime45.JSX.Element;
11
- type PropertyDescriptionProps = {
12
- description?: string;
13
- };
14
- declare function PropertyDescription({
15
- description
16
- }: PropertyDescriptionProps): react_jsx_runtime45.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_runtime45.JSX.Element;
45
- //#endregion
46
- export { PropertyToggle as a, PropertyProps as i, PropertyDescription as n, PropertyToggleProps as o, PropertyDescriptionProps as r, Property as t };
@@ -1,189 +0,0 @@
1
- import { t as __export } from "./chunk-Bp6m_JJh.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) return null;
66
- return {
67
- resource: match.groups.resource.split("."),
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.tagName === "DETAILS") 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 };
@@ -1,51 +0,0 @@
1
- declare namespace routing_d_exports {
2
- export { DocsLanguage, LanguageNames, Languages, ParsedStainlessPath, RouteEntry, SpecTreeEntry, SupportedLanguageSyntaxes, expandToElement, findNavigationPath, generateRoute, generateRouteList, getLanguageSnippet, getResource, isSupportedLanguage, parseRoute, parseStainlessPath, scrollToPath, trimStainlessPath, updateHistory, walkTree };
3
- }
4
- declare const Languages: readonly ["http", "node", "python", "go", "typescript", "terraform", "ruby", "java", "kotlin"];
5
- declare const SupportedLanguageSyntaxes: string[];
6
- type DocsLanguage = (typeof Languages)[number];
7
- declare const LanguageNames: Record<DocsLanguage, string>;
8
- declare function getLanguageSnippet(language: DocsLanguage): "node.default" | "go.default" | "python.default" | "terraform.default" | "http.curl" | "typescript.default" | "ruby.default" | "java.default" | "kotlin.default";
9
- declare function isSupportedLanguage(language: string): language is DocsLanguage;
10
- type ParsedStainlessPath = ReturnType<typeof parseStainlessPath>;
11
- declare function parseStainlessPath(stainlessPath: string): {
12
- resource: string[];
13
- method: string | null;
14
- model: string | null;
15
- routable: string | undefined;
16
- } | null;
17
- declare function trimStainlessPath(stainlessPath: string): string;
18
- declare function getResource(stainlessPath: string): string | undefined;
19
- declare function parseRoute(basePath: string, route: string): {
20
- stainlessPath: string;
21
- language: DocsLanguage;
22
- };
23
- declare function generateRoute(basePath: string, language: string, stainlessPath: string): string | null;
24
- type SpecTreeEntry = {
25
- data: SDKJSON.Method | SDKJSON.Resource | SDKJSON.Model;
26
- path: string[];
27
- };
28
- declare function walkTree(spec: SDKJSON.Spec, includeModels?: boolean): Generator<SpecTreeEntry, void, any>;
29
- type RouteEntry = {
30
- title: string;
31
- kind: SpecTreeEntry['data']['kind'];
32
- language: DocsLanguage;
33
- stainlessPath: string;
34
- slug: string;
35
- };
36
- declare function generateRouteList({
37
- spec,
38
- languages,
39
- excludeLanguages
40
- }: {
41
- spec: SDKJSON.Spec;
42
- languages?: DocsLanguage[];
43
- excludeLanguages?: DocsLanguage[];
44
- }): RouteEntry[];
45
- type ResourceOrMethod = SDKJSON.Resource | SDKJSON.Method;
46
- declare function findNavigationPath(items: ResourceOrMethod[], target: string): any;
47
- declare function expandToElement(el: HTMLElement): void;
48
- declare function scrollToPath(stainlessPath: string): void;
49
- declare function updateHistory(basePath: string, language: DocsLanguage, stainlessPath: string): void;
50
- //#endregion
51
- 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 };
package/dist/routing.d.ts DELETED
@@ -1,2 +0,0 @@
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-qc0V00-j.js";
2
- export { DocsLanguage, LanguageNames, Languages, ParsedStainlessPath, RouteEntry, SpecTreeEntry, SupportedLanguageSyntaxes, expandToElement, findNavigationPath, generateRoute, generateRouteList, getLanguageSnippet, getResource, isSupportedLanguage, parseRoute, parseStainlessPath, scrollToPath, trimStainlessPath, updateHistory, walkTree };