@stainless-api/docs-ui 0.1.0-beta.82 → 0.1.0-beta.83

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.
@@ -58,7 +58,7 @@ type TooltipProps = {
58
58
  declare function Tooltip({
59
59
  content,
60
60
  children
61
- }: TooltipProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime0.JSX.Element | null | undefined;
61
+ }: TooltipProps): string | number | bigint | boolean | react_jsx_runtime0.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
62
62
  type LinkProps = {
63
63
  stainlessPath?: string;
64
64
  scroll?: boolean;
@@ -69,7 +69,7 @@ declare function Link({
69
69
  scroll,
70
70
  children,
71
71
  ...props
72
- }: LinkProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime0.JSX.Element | null | undefined;
72
+ }: LinkProps): string | number | bigint | boolean | react_jsx_runtime0.JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
73
73
  type InputProps = {
74
74
  left?: ReactNode;
75
75
  right?: ReactNode;
@@ -108,7 +108,7 @@ type SDKReferenceProps = {
108
108
  declare function SDKReference({
109
109
  stainlessPath,
110
110
  children
111
- }: 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_runtime0.JSX.Element | null | undefined;
111
+ }: SDKReferenceProps): string | number | bigint | boolean | react_jsx_runtime0.JSX.Element | 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> | null | undefined;
112
112
  type SDKLanguageBlockProps = {
113
113
  language: DocsLanguage;
114
114
  version: string;
@@ -47,7 +47,7 @@ declare function useDeclaration<Required extends boolean>(stainlessPath: string,
47
47
  declare function useAvailableLanguages(stainlessPath: string): SpecLanguage[];
48
48
  declare function useIgnoredResources(): string[];
49
49
  declare function useResource(name: string): Resource | undefined;
50
- declare function useLanguage(): "cli" | "csharp" | "go" | "http" | "java" | "kotlin" | "node" | "php" | "python" | "ruby" | "terraform" | "typescript";
50
+ declare function useLanguage(): "http" | "node" | "python" | "go" | "typescript" | "terraform" | "ruby" | "java" | "kotlin" | "csharp" | "php" | "cli";
51
51
  declare function useContentPanelLayout(): ContentPanelLayout;
52
52
  type DocsProviderProps = DocsContextType & {
53
53
  children: React$1.ReactNode;
@@ -1,6 +1,6 @@
1
1
  import "../use-strict-context-L0c8JKg4.js";
2
2
  import { code, fence, heading, item, list, paragraph, parse, strong, text } from "./md.js";
3
- import { getDecl, getSnippet, stripMarkup } from "./utils.js";
3
+ import { getCustomSnippetTitle, getDecl, getSnippets, stripMarkup } from "./utils.js";
4
4
  import { declaration as declaration$1, methodSignature, t as printer_exports } from "./printer.js";
5
5
  import Markdoc from "@markdoc/markdoc";
6
6
 
@@ -27,7 +27,7 @@ function renderMethod(env, method) {
27
27
  const signature = methodSignature(env.language, decl);
28
28
  const [httpMethod, endpoint] = method.endpoint.split(" ");
29
29
  const output = [
30
- heading(2, method.title),
30
+ heading(2, method.summary ?? method.title),
31
31
  ...env.language === "http" ? [] : [paragraph(code(stripMarkup(signature)))],
32
32
  paragraph(strong(text(httpMethod)), text(" "), code(endpoint))
33
33
  ];
@@ -47,8 +47,14 @@ function renderMethod(env, method) {
47
47
  }
48
48
  if ("paramsChildren" in decl && Array.isArray(decl.paramsChildren) && decl.paramsChildren.length > 0) output.push(heading(3, "Parameters"), renderChildren(env, decl.paramsChildren));
49
49
  if ("responseChildren" in decl && decl.responseChildren && decl.responseChildren.length > 0) output.push(heading(3, "Returns"), renderChildren(env, decl.responseChildren));
50
- const snippet = getSnippet(env, method.stainlessPath);
51
- if (snippet) output.push(heading(3, "Example"), fence(env.language, snippet));
50
+ const snippetEntries = getSnippets(env, method.stainlessPath);
51
+ for (const [key, { snippet, response }] of Object.entries(snippetEntries)) {
52
+ if (!snippet) continue;
53
+ let title = getCustomSnippetTitle(key);
54
+ if (title.toLowerCase() === "default") title = "Example";
55
+ output.push(heading(3, title), fence(env.language, snippet));
56
+ if (response) output.push(heading(4, "Response"), fence("json", response));
57
+ }
52
58
  return output;
53
59
  }
54
60
  function renderModel(env, model) {
@@ -15,7 +15,14 @@ type EnvironmentType = {
15
15
  };
16
16
  };
17
17
  declare function getDecl(env: EnvironmentType, path: string): LanguageDeclNodes[SpecLanguage] | undefined;
18
- declare function getSnippet(env: EnvironmentType, path: string, snippetId?: 'default' | `custom:${string}`): string | undefined;
18
+ declare const customSnippetPrefix = "custom:";
19
+ declare const getCustomSnippetTitle: (snippetId: string) => string;
20
+ declare function getSnippets(env: EnvironmentType, path: string): {
21
+ [k: string]: {
22
+ snippet: string;
23
+ response: string | undefined;
24
+ };
25
+ };
19
26
  declare function stripMarkup(content: string): string;
20
27
  //#endregion
21
- export { EnvironmentType, getDecl, getSnippet, stripMarkup };
28
+ export { EnvironmentType, customSnippetPrefix, getCustomSnippetTitle, getDecl, getSnippets, stripMarkup };
@@ -10,14 +10,16 @@ function getDecl(env, path) {
10
10
  }
11
11
  return decl;
12
12
  }
13
- function getSnippet(env, path, snippetId = "default") {
13
+ const customSnippetPrefix = "custom:";
14
+ const getCustomSnippetTitle = (snippetId) => snippetId.startsWith(customSnippetPrefix) ? snippetId.slice(7) : snippetId;
15
+ function getSnippets(env, path) {
14
16
  const lang = env.language === "http" ? "http.curl" : `${env.language}.default`;
15
- let snippet = env.spec?.snippets?.[lang]?.[path]?.[snippetId]?.content;
16
- if (snippet && env.transforms?.transformRequestSnippet) snippet = env.transforms.transformRequestSnippet({
17
- snippet,
18
- language: env.language
19
- });
20
- return snippet;
17
+ const snippets = env.spec?.snippets?.[lang]?.[path];
18
+ const responses = env.spec?.snippetResponses?.http?.[path];
19
+ return Object.fromEntries(Object.entries(snippets ?? {}).map(([key, snippet]) => [key, {
20
+ snippet: snippet.content,
21
+ response: responses?.[key]?.[0]?.content
22
+ }]));
21
23
  }
22
24
  function stripMarkup(content) {
23
25
  let output = "";
@@ -28,4 +30,4 @@ function stripMarkup(content) {
28
30
  }
29
31
 
30
32
  //#endregion
31
- export { getDecl, getSnippet, stripMarkup };
33
+ export { customSnippetPrefix, getCustomSnippetTitle, getDecl, getSnippets, stripMarkup };
package/dist/routing.d.ts CHANGED
@@ -8,7 +8,7 @@ declare const Languages: readonly ["http", "node", "python", "go", "typescript",
8
8
  declare const SupportedLanguageSyntaxes: string[];
9
9
  type DocsLanguage = (typeof Languages)[number];
10
10
  declare const LanguageNames: Record<DocsLanguage, string>;
11
- declare function getLanguageSnippet(language: DocsLanguage): "http.curl" | "cli.default" | "csharp.default" | "go.default" | "java.default" | "kotlin.default" | "node.default" | "php.default" | "python.default" | "ruby.default" | "terraform.default" | "typescript.default";
11
+ declare function getLanguageSnippet(language: DocsLanguage): "http.curl" | "node.default" | "python.default" | "go.default" | "typescript.default" | "terraform.default" | "ruby.default" | "java.default" | "kotlin.default" | "csharp.default" | "php.default" | "cli.default";
12
12
  declare function isSupportedLanguage(language: string): language is DocsLanguage;
13
13
  type ParsedStainlessPath = ReturnType<typeof parseStainlessPath>;
14
14
  declare function parseStainlessPath(stainlessPath: string): {
package/dist/spec.d.ts CHANGED
@@ -36,13 +36,13 @@ declare function generateNavigation(resource: Partial<Resource>): {
36
36
  declare function generateSpecForResource(spec: Spec, name: string, lang: DocsLanguage, transforms: SpecTransforms): Partial<Spec>;
37
37
  declare function transform(spec: Spec, transforms: SpecTransforms): {
38
38
  name: string;
39
- lang: "cli" | "csharp" | "go" | "http" | "java" | "kotlin" | "node" | "php" | "python" | "ruby" | "terraform" | "typescript";
39
+ lang: "http" | "node" | "python" | "go" | "typescript" | "terraform" | "ruby" | "java" | "kotlin" | "csharp" | "php" | "cli";
40
40
  spec: Partial<Spec>;
41
41
  }[];
42
42
  declare function split(spec: Spec, transforms?: SpecTransforms): {
43
43
  resources: ReturnType<typeof transform>;
44
44
  navigation: {
45
- languages: ("cli" | "csharp" | "go" | "http" | "java" | "kotlin" | "node" | "php" | "python" | "ruby" | "terraform" | "typescript" | "sql" | "openapi")[] | undefined;
45
+ languages: ("http" | "node" | "python" | "go" | "typescript" | "terraform" | "ruby" | "java" | "kotlin" | "csharp" | "php" | "cli" | "sql" | "openapi")[] | undefined;
46
46
  resources: {
47
47
  [k: string]: {
48
48
  title: string | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stainless-api/docs-ui",
3
3
  "private": false,
4
- "version": "0.1.0-beta.82",
4
+ "version": "0.1.0-beta.83",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },