@stainless-api/docs 0.1.0-beta.0
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.
- package/.env.example +1 -0
- package/CHANGELOG.md +13 -0
- package/README.md +11 -0
- package/components/variables.css +139 -0
- package/eslint.config.js +10 -0
- package/package.json +74 -0
- package/plugin/assets/fonts/geist/OFL.txt +93 -0
- package/plugin/assets/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-italic-latin.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-latin.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-latin.woff2 +0 -0
- package/plugin/assets/languages/curl.svg +10 -0
- package/plugin/assets/languages/go.svg +4 -0
- package/plugin/assets/languages/java.svg +7 -0
- package/plugin/assets/languages/kotlin.svg +10 -0
- package/plugin/assets/languages/powershell.svg +3 -0
- package/plugin/assets/languages/python.svg +19 -0
- package/plugin/assets/languages/ruby.svg +125 -0
- package/plugin/assets/languages/terraform.svg +5 -0
- package/plugin/assets/languages/typescript.svg +11 -0
- package/plugin/assets/stainless-logo-dark.png +0 -0
- package/plugin/assets/stainless-logo.png +0 -0
- package/plugin/buildAlgoliaIndex.ts +72 -0
- package/plugin/cms/client.ts +62 -0
- package/plugin/cms/server.ts +268 -0
- package/plugin/cms/sidebar-builder.ts +420 -0
- package/plugin/cms/worker.ts +122 -0
- package/plugin/components/SDKSelect.astro +154 -0
- package/plugin/components/SnippetCode.tsx +212 -0
- package/plugin/components/search/Search.astro +6 -0
- package/plugin/components/search/SearchAlgolia.astro +87 -0
- package/plugin/components/search/SearchIsland.tsx +100 -0
- package/plugin/generateAPIReferenceLink.ts +71 -0
- package/plugin/globalJs/ai-dropdown.ts +57 -0
- package/plugin/globalJs/code-snippets.ts +87 -0
- package/plugin/globalJs/copy.ts +37 -0
- package/plugin/globalJs/navigation.ts +81 -0
- package/plugin/globalJs/tooltip.ts +32 -0
- package/plugin/helpers/getPageLoadEvent.ts +8 -0
- package/plugin/index.ts +308 -0
- package/plugin/languages.ts +67 -0
- package/plugin/loadPluginConfig.ts +273 -0
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +5 -0
- package/plugin/middlewareBuilder/stlStarlightMiddleware.ts +5 -0
- package/plugin/react/Routing.tsx +435 -0
- package/plugin/referencePlaceholderUtils.ts +82 -0
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +50 -0
- package/plugin/routes/Docs.astro +171 -0
- package/plugin/routes/DocsStatic.astro +14 -0
- package/plugin/routes/Overview.astro +67 -0
- package/plugin/routes/markdown.ts +58 -0
- package/plugin/vendor/preview.worker.docs.js +21657 -0
- package/plugin/vendor/templates/go.md +314 -0
- package/plugin/vendor/templates/java.md +87 -0
- package/plugin/vendor/templates/kotlin.md +87 -0
- package/plugin/vendor/templates/node.md +233 -0
- package/plugin/vendor/templates/python.md +249 -0
- package/plugin/vendor/templates/ruby.md +145 -0
- package/plugin/vendor/templates/terraform.md +60 -0
- package/plugin/vendor/templates/typescript.md +317 -0
- package/scripts/vendor_deps.ts +50 -0
- package/shared/virtualModule.ts +7 -0
- package/stl-docs/components/APIReferenceAIDropdown.tsx +86 -0
- package/stl-docs/components/ClientRouterHead.astro +41 -0
- package/stl-docs/components/Header.astro +91 -0
- package/stl-docs/components/Sidebar.astro +11 -0
- package/stl-docs/components/ThemeSelect.astro +225 -0
- package/stl-docs/components/content-panel/ContentBreadcrumbs.tsx +84 -0
- package/stl-docs/components/content-panel/ContentPanel.astro +72 -0
- package/stl-docs/components/content-panel/ProseAIDropdown.tsx +64 -0
- package/stl-docs/components/headers/DefaultHeader.astro +36 -0
- package/stl-docs/components/headers/HeaderLinks.astro +16 -0
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +49 -0
- package/stl-docs/components/headers/StackedHeader.astro +75 -0
- package/stl-docs/components/mintlify-compat/Accordion.astro +46 -0
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +25 -0
- package/stl-docs/components/mintlify-compat/Card.tsx +32 -0
- package/stl-docs/components/mintlify-compat/Columns.astro +66 -0
- package/stl-docs/components/mintlify-compat/Frame.astro +37 -0
- package/stl-docs/components/mintlify-compat/Step.astro +58 -0
- package/stl-docs/components/mintlify-compat/Steps.astro +17 -0
- package/stl-docs/components/mintlify-compat/Tab.astro +13 -0
- package/stl-docs/components/mintlify-compat/Tabs.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/index.ts +9 -0
- package/stl-docs/components/mintlify-compat/card.css +44 -0
- package/stl-docs/components/mintlify-compat/index.ts +15 -0
- package/stl-docs/components/nav-tabs/NavDropdown.astro +106 -0
- package/stl-docs/components/nav-tabs/NavTabs.astro +165 -0
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +62 -0
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +14 -0
- package/stl-docs/index.ts +174 -0
- package/stl-docs/loadStlDocsConfig.ts +160 -0
- package/stl-docs/redirects.ts +33 -0
- package/stl-docs/tabsMiddleware.ts +183 -0
- package/styles/code.css +189 -0
- package/styles/fonts.css +68 -0
- package/styles/links.css +51 -0
- package/styles/mintlify-compat.css +1 -0
- package/styles/overrides.css +79 -0
- package/styles/page.css +76 -0
- package/styles/sdk_select.css +11 -0
- package/styles/search.css +85 -0
- package/styles/sidebar.css +168 -0
- package/styles/toc.css +42 -0
- package/styles/variables.css +18 -0
- package/theme.css +15 -0
- package/tsconfig.json +18 -0
- package/virtual-module.d.ts +43 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# SDK_PackageTitle API Library
|
|
2
|
+
|
|
3
|
+
[)](https://npmjs.org/package/SDK_NPMPackage) SDK_JSRShield
|
|
4
|
+
|
|
5
|
+
SDK_ReadmeOpening
|
|
6
|
+
|
|
7
|
+
SDK_ScreencastURL
|
|
8
|
+
|
|
9
|
+
SDK_DocumentationReference
|
|
10
|
+
|
|
11
|
+
SDK_GeneratedByStainless
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
SDK_NPMInstallInstructions
|
|
16
|
+
|
|
17
|
+
SDK_JSRInstallation
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
SDK_APIReference
|
|
22
|
+
|
|
23
|
+
<!-- prettier-ignore -->
|
|
24
|
+
```js
|
|
25
|
+
SDK_Usage
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
SDK_StreamingUsage
|
|
29
|
+
|
|
30
|
+
### Request & Response types
|
|
31
|
+
|
|
32
|
+
This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
|
|
33
|
+
|
|
34
|
+
<!-- prettier-ignore -->
|
|
35
|
+
```ts
|
|
36
|
+
SDK_TypeScriptUsage
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
40
|
+
|
|
41
|
+
SDK_FileUploadsUsage
|
|
42
|
+
|
|
43
|
+
SDK_BinaryUploadsUsage
|
|
44
|
+
|
|
45
|
+
## Handling errors
|
|
46
|
+
|
|
47
|
+
When the library is unable to connect to the API,
|
|
48
|
+
or if the API returns a non-success status code (i.e., 4xx or 5xx response),
|
|
49
|
+
a subclass of `APIError` will be thrown:
|
|
50
|
+
|
|
51
|
+
<!-- prettier-ignore -->
|
|
52
|
+
```ts
|
|
53
|
+
SDK_ErrorsExample
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Error codes are as follows:
|
|
57
|
+
|
|
58
|
+
| Status Code | Error Type |
|
|
59
|
+
| ----------- | -------------------------- |
|
|
60
|
+
| 400 | `BadRequestError` |
|
|
61
|
+
| 401 | `AuthenticationError` |
|
|
62
|
+
| 403 | `PermissionDeniedError` |
|
|
63
|
+
| 404 | `NotFoundError` |
|
|
64
|
+
| 422 | `UnprocessableEntityError` |
|
|
65
|
+
| 429 | `RateLimitError` |
|
|
66
|
+
| >=500 | `InternalServerError` |
|
|
67
|
+
| N/A | `APIConnectionError` |
|
|
68
|
+
|
|
69
|
+
### Retries
|
|
70
|
+
|
|
71
|
+
Certain errors will be automatically retried SDK_DefaultMaxRetries times by default, with a short exponential backoff.
|
|
72
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
|
|
73
|
+
429 Rate Limit, and >=500 Internal errors will all be retried by default.
|
|
74
|
+
|
|
75
|
+
You can use the `maxRetries` option to configure or disable this:
|
|
76
|
+
|
|
77
|
+
<!-- prettier-ignore -->
|
|
78
|
+
```js
|
|
79
|
+
SDK_RetriesExample
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Timeouts
|
|
83
|
+
|
|
84
|
+
Requests time out after SDK_HumanReadableDefaultTimeout by default. You can configure this with a `timeout` option:
|
|
85
|
+
|
|
86
|
+
<!-- prettier-ignore -->
|
|
87
|
+
```ts
|
|
88
|
+
SDK_TimeoutsExample
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
On timeout, an `APIConnectionTimeoutError` is thrown.
|
|
92
|
+
|
|
93
|
+
Note that requests which time out will be [retried twice by default](#retries).
|
|
94
|
+
|
|
95
|
+
SDK_Pagination
|
|
96
|
+
|
|
97
|
+
SDK_DefaultHeaders
|
|
98
|
+
|
|
99
|
+
## Advanced Usage
|
|
100
|
+
SDK_TreeShakingDocs
|
|
101
|
+
### Accessing raw Response data (e.g., headers)
|
|
102
|
+
|
|
103
|
+
The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
|
|
104
|
+
This method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.
|
|
105
|
+
|
|
106
|
+
You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
|
|
107
|
+
Unlike `.asResponse()` this method consumes the body, returning once it is parsed.
|
|
108
|
+
|
|
109
|
+
<!-- prettier-ignore -->
|
|
110
|
+
```ts
|
|
111
|
+
SDK_RawResponseExample
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Logging
|
|
115
|
+
|
|
116
|
+
> [!IMPORTANT]
|
|
117
|
+
> All log messages are intended for debugging only. The format and content of log messages
|
|
118
|
+
> may change between releases.
|
|
119
|
+
|
|
120
|
+
#### Log levels
|
|
121
|
+
|
|
122
|
+
The log level can be configured in two ways:
|
|
123
|
+
|
|
124
|
+
1. Via the `SDK_PackageLoggingEnvVar` environment variable
|
|
125
|
+
2. Using the `logLevel` client option (overrides the environment variable if set)
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import SDK_PackageName from 'SDK_NPMPackage';
|
|
129
|
+
|
|
130
|
+
const SDK_ClientName = new SDK_PackageName({
|
|
131
|
+
logLevel: 'debug', // Show all log messages
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Available log levels, from most to least verbose:
|
|
136
|
+
|
|
137
|
+
- `'debug'` - Show debug messages, info, warnings, and errors
|
|
138
|
+
- `'info'` - Show info messages, warnings, and errors
|
|
139
|
+
- `'warn'` - Show warnings and errors (default)
|
|
140
|
+
- `'error'` - Show only errors
|
|
141
|
+
- `'off'` - Disable all logging
|
|
142
|
+
|
|
143
|
+
At the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.
|
|
144
|
+
Some authentication-related headers are redacted, but sensitive data in request and response bodies
|
|
145
|
+
may still be visible.
|
|
146
|
+
|
|
147
|
+
#### Custom logger
|
|
148
|
+
|
|
149
|
+
By default, this library logs to `globalThis.console`. You can also provide a custom logger.
|
|
150
|
+
Most logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.
|
|
151
|
+
|
|
152
|
+
When providing a custom logger, the `logLevel` option still controls which messages are emitted, messages
|
|
153
|
+
below the configured level will not be sent to your logger.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import SDK_PackageName from 'SDK_NPMPackage';
|
|
157
|
+
import pino from 'pino';
|
|
158
|
+
|
|
159
|
+
const logger = pino();
|
|
160
|
+
|
|
161
|
+
const SDK_ClientName = new SDK_PackageName({
|
|
162
|
+
logger: logger.child({ name: 'SDK_PackageName' }),
|
|
163
|
+
logLevel: 'debug', // Send all messages to pino, allowing it to filter
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Making custom/undocumented requests
|
|
168
|
+
|
|
169
|
+
This library is typed for convenient access to the documented API. If you need to access undocumented
|
|
170
|
+
endpoints, params, or response properties, the library can still be used.
|
|
171
|
+
|
|
172
|
+
#### Undocumented endpoints
|
|
173
|
+
|
|
174
|
+
To make requests to undocumented endpoints, you can use `SDK_ClientName.get`, `SDK_ClientName.post`, and other HTTP verbs.
|
|
175
|
+
Options on the client, such as retries, will be respected when making these requests.
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
await SDK_ClientName.post('/some/path', {
|
|
179
|
+
body: { some_prop: 'foo' },
|
|
180
|
+
query: { some_query_arg: 'bar' },
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Undocumented request params
|
|
185
|
+
|
|
186
|
+
To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
|
|
187
|
+
parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
|
|
188
|
+
send will be sent as-is.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
SDK_ExampleClientMethodName({
|
|
192
|
+
// ...
|
|
193
|
+
// @ts-expect-error baz is not yet public
|
|
194
|
+
baz: 'undocumented option',
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
|
|
199
|
+
extra param in the body.
|
|
200
|
+
|
|
201
|
+
If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
|
|
202
|
+
options.
|
|
203
|
+
|
|
204
|
+
#### Undocumented response properties
|
|
205
|
+
|
|
206
|
+
To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
|
|
207
|
+
the response object, or cast the response object to the requisite type. Like the request params, we do not
|
|
208
|
+
validate or strip extra properties from the response from the API.
|
|
209
|
+
|
|
210
|
+
### Customizing the fetch client
|
|
211
|
+
|
|
212
|
+
By default, this library expects a global `fetch` function is defined.
|
|
213
|
+
|
|
214
|
+
If you want to use a different `fetch` function, you can either polyfill the global:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
import fetch from 'my-fetch';
|
|
218
|
+
|
|
219
|
+
globalThis.fetch = fetch;
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Or pass it to the client:
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
import SDK_PackageName from 'SDK_NPMPackage';
|
|
226
|
+
import fetch from 'my-fetch';
|
|
227
|
+
|
|
228
|
+
const SDK_ClientName = new SDK_PackageName({ fetch });
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Fetch options
|
|
232
|
+
|
|
233
|
+
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
import SDK_PackageName from 'SDK_NPMPackage';
|
|
237
|
+
|
|
238
|
+
const SDK_ClientName = new SDK_PackageName({
|
|
239
|
+
fetchOptions: {
|
|
240
|
+
// `RequestInit` options
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### Configuring proxies
|
|
246
|
+
|
|
247
|
+
To modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy
|
|
248
|
+
options to requests:
|
|
249
|
+
|
|
250
|
+
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
import SDK_PackageName from 'SDK_NPMPackage';
|
|
254
|
+
import * as undici from 'undici';
|
|
255
|
+
|
|
256
|
+
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
|
|
257
|
+
const SDK_ClientName = new SDK_PackageName({
|
|
258
|
+
fetchOptions: {
|
|
259
|
+
dispatcher: proxyAgent,
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
import SDK_PackageName from 'SDK_NPMPackage';
|
|
268
|
+
|
|
269
|
+
const SDK_ClientName = new SDK_PackageName({
|
|
270
|
+
fetchOptions: {
|
|
271
|
+
proxy: 'http://localhost:8888',
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
import SDK_PackageName from 'SDK_DenoSpecifier';
|
|
280
|
+
|
|
281
|
+
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
|
|
282
|
+
const SDK_ClientName = new SDK_PackageName({
|
|
283
|
+
fetchOptions: {
|
|
284
|
+
client: httpClient,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Frequently Asked Questions
|
|
290
|
+
|
|
291
|
+
## Semantic versioning
|
|
292
|
+
|
|
293
|
+
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
|
294
|
+
|
|
295
|
+
1. Changes that only affect static types, without breaking runtime behavior.
|
|
296
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
297
|
+
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
298
|
+
|
|
299
|
+
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
300
|
+
|
|
301
|
+
We are keen for your feedback; please open an [issue](SDK_GitHubRepoURL/issues) with questions, bugs, or suggestions.
|
|
302
|
+
|
|
303
|
+
## Requirements
|
|
304
|
+
|
|
305
|
+
TypeScript >= 4.9 is supported.
|
|
306
|
+
|
|
307
|
+
The following runtimes are supported:
|
|
308
|
+
|
|
309
|
+
SDK_SupportedRuntimes
|
|
310
|
+
|
|
311
|
+
Note that React Native is not supported at this time.
|
|
312
|
+
|
|
313
|
+
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
|
|
314
|
+
|
|
315
|
+
## Contributing
|
|
316
|
+
|
|
317
|
+
See [the contributing documentation](./CONTRIBUTING.md).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { config } from 'dotenv';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
import { Languages } from '@stainless-api/docs-ui/src/routing';
|
|
7
|
+
|
|
8
|
+
const DEPS_DIR = './plugin/vendor';
|
|
9
|
+
|
|
10
|
+
config();
|
|
11
|
+
|
|
12
|
+
const envSchema = z.object({
|
|
13
|
+
// absolute path to the Stainless monorepo root
|
|
14
|
+
STAINLESS_MONOREPO_PATH: z.string(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const env = envSchema.parse(process.env);
|
|
18
|
+
|
|
19
|
+
console.log(`Using Stainless monorepo at ${env.STAINLESS_MONOREPO_PATH}`);
|
|
20
|
+
|
|
21
|
+
if (fs.existsSync(DEPS_DIR)) {
|
|
22
|
+
fs.rmSync(DEPS_DIR, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fs.mkdirSync(DEPS_DIR, { recursive: true });
|
|
26
|
+
|
|
27
|
+
const previewWorkerPath = path.join(
|
|
28
|
+
env.STAINLESS_MONOREPO_PATH,
|
|
29
|
+
'/packages/preview-worker/dist/stainless/preview.worker.docs.js',
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const readmeTemplatePath = path.join(env.STAINLESS_MONOREPO_PATH, '/legacy-dir-root/templates');
|
|
33
|
+
|
|
34
|
+
fs.copyFileSync(previewWorkerPath, path.join(DEPS_DIR, 'preview.worker.docs.js'));
|
|
35
|
+
|
|
36
|
+
console.log(`✅ cp ${previewWorkerPath} -> ${path.join(DEPS_DIR, 'preview.worker.docs.js')}`);
|
|
37
|
+
|
|
38
|
+
if (fs.existsSync(readmeTemplatePath)) {
|
|
39
|
+
fs.mkdirSync(path.join(DEPS_DIR, 'templates'));
|
|
40
|
+
|
|
41
|
+
for (const language of Languages) {
|
|
42
|
+
const mdPath = path.join(readmeTemplatePath, language, 'README.md');
|
|
43
|
+
const dest = path.join(DEPS_DIR, 'templates', `${language}.md`);
|
|
44
|
+
|
|
45
|
+
if (fs.existsSync(mdPath)) {
|
|
46
|
+
fs.copyFileSync(mdPath, dest);
|
|
47
|
+
console.log(`✅ cp ${mdPath} -> ${dest}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DropdownButton,
|
|
3
|
+
DropdownButtonDivider,
|
|
4
|
+
DropdownButtonItem,
|
|
5
|
+
DropdownButtonItemIcon,
|
|
6
|
+
DropdownButtonItemText,
|
|
7
|
+
DropdownButtonItemTextSubtle,
|
|
8
|
+
DropdownButtonMenu,
|
|
9
|
+
DropdownButtonPrimaryAction,
|
|
10
|
+
DropdownButtonPrimaryActionText,
|
|
11
|
+
DropdownButtonTrigger,
|
|
12
|
+
} from '@stainless-api/ui-primitives';
|
|
13
|
+
import { CopyIcon } from 'lucide-react';
|
|
14
|
+
|
|
15
|
+
export function AIDropdownOptions() {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<DropdownButtonItem value="chat-gpt" isExternalLink>
|
|
19
|
+
<DropdownButtonItemIcon>
|
|
20
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
21
|
+
<path
|
|
22
|
+
d="M3.13924 10.6036L6.28658 8.84444L6.33924 8.69111L6.28658 8.60638H6.13266L5.60608 8.5741L3.8076 8.52568L2.2481 8.46113L0.737215 8.38043L0.356456 8.29973L0 7.83169L0.0364557 7.59766L0.356456 7.38382L0.814177 7.42416L1.82684 7.49276L3.34582 7.59766L4.4476 7.66222L6.08 7.83169H6.33924L6.3757 7.72678L6.28658 7.66222L6.21772 7.59766L4.64608 6.53649L2.94481 5.4148L2.05367 4.76922L1.57165 4.44239L1.32861 4.13574L1.22329 3.46595L1.66076 2.98581L2.2481 3.02615L2.39797 3.0665L2.99342 3.52244L4.26532 4.50292L5.92608 5.72145L6.16911 5.92319L6.26633 5.8546L6.27848 5.80618L6.16911 5.62461L5.26582 3.99856L4.30177 2.34426L3.87241 1.65833L3.75899 1.24678C3.71848 1.07731 3.69013 0.93609 3.69013 0.762591L4.18835 0.0887672L4.4638 0L5.1281 0.0887672L5.4076 0.330859L5.82076 1.27098L6.48911 2.75178L7.52608 4.76518L7.82987 5.36234L7.9919 5.91512L8.05266 6.08459H8.15797V5.98775L8.24304 4.85395L8.40101 3.46192L8.55494 1.67044L8.60759 1.16608L8.85873 0.560847L9.35696 0.234023L9.74582 0.419627L10.0658 0.875567L10.0213 1.17011L9.83089 2.40075L9.45823 4.32942L9.21519 5.62058H9.35696L9.51899 5.45918L10.1752 4.59168L11.277 3.21983L11.763 2.67512L12.3301 2.07392L12.6947 1.78745H13.3833L13.8896 2.53793L13.6628 3.31263L12.9539 4.20837L12.3666 4.96693L11.5241 6.09669L10.9975 7.0005L11.0461 7.07313L11.1716 7.06103L13.0754 6.65754L14.1043 6.47193L15.3316 6.26212L15.8866 6.52035L15.9473 6.78262L15.7286 7.31926L14.4162 7.64205L12.877 7.9487L10.5843 8.48937L10.5559 8.50954L10.5884 8.54989L11.6213 8.64673L12.0628 8.67094H13.1443L15.1575 8.82023L15.6841 9.16723L16 9.59089L15.9473 9.91368L15.1372 10.3252L14.0435 10.067L11.4916 9.46177L10.6167 9.24389H10.4952V9.31652L11.2243 10.0267L12.561 11.229L14.2339 12.7784L14.319 13.1618L14.1043 13.4644L13.8775 13.4321L12.4071 12.3306L11.84 11.8343L10.5559 10.757H10.4709V10.8699L10.7666 11.3017L12.3301 13.6419L12.4111 14.3601L12.2977 14.5941L11.8927 14.7354L11.4471 14.6547L10.5316 13.3756L9.58785 11.9352L8.82633 10.644L8.73316 10.6964L8.28354 15.5181L8.07291 15.7642L7.58684 15.9498L7.18177 15.6432L6.96709 15.1469L7.18177 14.1664L7.44101 12.8874L7.65165 11.8706L7.84203 10.6077L7.95544 10.1881L7.94734 10.1598L7.85418 10.1719L6.89823 11.4792L5.44405 13.4361L4.29367 14.6627L4.01823 14.7717L3.54025 14.5255L3.58481 14.0857L3.85215 13.6944L5.44405 11.6769L6.40405 10.4261L7.0238 9.70387L7.01975 9.59896H6.98329L2.75443 12.3346L2.00101 12.4314L1.67696 12.1288L1.71747 11.6325L1.87139 11.4711L3.14329 10.5996L3.13924 10.6036Z"
|
|
23
|
+
fill="#D97757"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
</DropdownButtonItemIcon>
|
|
27
|
+
<DropdownButtonItemText>
|
|
28
|
+
<DropdownButtonItemTextSubtle>Open in</DropdownButtonItemTextSubtle> Claude
|
|
29
|
+
</DropdownButtonItemText>
|
|
30
|
+
</DropdownButtonItem>
|
|
31
|
+
<DropdownButtonItem value="chat-gpt" isExternalLink>
|
|
32
|
+
<DropdownButtonItemIcon>
|
|
33
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
34
|
+
<g clip-path="url(#clip0_2771_126147)">
|
|
35
|
+
<path
|
|
36
|
+
d="M14.853 6.54857C15.216 5.45907 15.091 4.26557 14.5105 3.27457C13.6375 1.75457 11.8825 0.972574 10.1685 1.34057C9.40596 0.481574 8.31046 -0.00692579 7.16196 7.42116e-05C5.40996 -0.00392579 3.85546 1.12407 3.31646 2.79107C2.19096 3.02157 1.21946 3.72607 0.650955 4.72457C-0.228545 6.24057 -0.0280446 8.15157 1.14696 9.45157C0.783955 10.5411 0.908955 11.7346 1.48946 12.7256C2.36246 14.2456 4.11746 15.0276 5.83146 14.6596C6.59346 15.5186 7.68946 16.0071 8.83796 15.9996C10.591 16.0041 12.146 14.8751 12.685 13.2066C13.8105 12.9761 14.782 12.2716 15.3505 11.2731C16.229 9.75707 16.028 7.84757 14.8535 6.54757L14.853 6.54857ZM8.83896 14.9541C8.13746 14.9551 7.45796 14.7096 6.91946 14.2601C6.94396 14.2471 6.98646 14.2236 7.01396 14.2066L10.2 12.3666C10.363 12.2741 10.463 12.1006 10.462 11.9131V7.42157L11.8085 8.19907C11.823 8.20607 11.8325 8.22007 11.8345 8.23607V11.9556C11.8325 13.6096 10.493 14.9506 8.83896 14.9541ZM2.39696 12.2026C2.04546 11.5956 1.91896 10.8841 2.03946 10.1936C2.06296 10.2076 2.10446 10.2331 2.13396 10.2501L5.31996 12.0901C5.48146 12.1846 5.68146 12.1846 5.84346 12.0901L9.73296 9.84407V11.3991C9.73396 11.4151 9.72646 11.4306 9.71396 11.4406L6.49346 13.3001C5.05896 14.1261 3.22696 13.6351 2.39746 12.2026H2.39696ZM1.55846 5.24807C1.90846 4.64007 2.46096 4.17507 3.11896 3.93357C3.11896 3.96107 3.11746 4.00957 3.11746 4.04357V7.72407C3.11646 7.91107 3.21646 8.08457 3.37896 8.17707L7.26846 10.4226L5.92196 11.2001C5.90846 11.2091 5.89146 11.2106 5.87646 11.2041L2.65546 9.34307C1.22396 8.51407 0.732955 6.68257 1.55796 5.24857L1.55846 5.24807ZM12.6215 7.82257L8.73196 5.57657L10.0785 4.79957C10.092 4.79057 10.109 4.78907 10.124 4.79557L13.345 6.65507C14.779 7.48357 15.2705 9.31807 14.442 10.7521C14.0915 11.3591 13.5395 11.8241 12.882 12.0661V8.27557C12.8835 8.08857 12.784 7.91557 12.622 7.82257H12.6215ZM13.9615 5.80557C13.938 5.79107 13.8965 5.76607 13.867 5.74907L10.681 3.90907C10.5195 3.81457 10.3195 3.81457 10.1575 3.90907L6.26796 6.15507V4.60007C6.26696 4.58407 6.27446 4.56857 6.28696 4.55857L9.50746 2.70057C10.942 1.87307 12.776 2.36557 13.603 3.80057C13.9525 4.40657 14.079 5.11607 13.9605 5.80557H13.9615ZM5.53596 8.57707L4.18896 7.79957C4.17446 7.79257 4.16496 7.77857 4.16296 7.76257V4.04307C4.16396 2.38707 5.50746 1.04507 7.16346 1.04607C7.86396 1.04607 8.54196 1.29207 9.08046 1.74007C9.05596 1.75307 9.01396 1.77657 8.98596 1.79357L5.79996 3.63357C5.63696 3.72607 5.53696 3.89907 5.53796 4.08657L5.53596 8.57607V8.57707ZM6.26746 7.00007L7.99996 5.99957L9.73246 6.99957V9.00007L7.99996 10.0001L6.26746 9.00007V7.00007Z"
|
|
37
|
+
fill="#262626"
|
|
38
|
+
/>
|
|
39
|
+
</g>
|
|
40
|
+
<defs>
|
|
41
|
+
<clipPath id="clip0_2771_126147">
|
|
42
|
+
<rect width="16" height="16" fill="white" />
|
|
43
|
+
</clipPath>
|
|
44
|
+
</defs>
|
|
45
|
+
</svg>
|
|
46
|
+
</DropdownButtonItemIcon>
|
|
47
|
+
<DropdownButtonItemText>
|
|
48
|
+
<DropdownButtonItemTextSubtle>Open in</DropdownButtonItemTextSubtle> ChatGPT
|
|
49
|
+
</DropdownButtonItemText>
|
|
50
|
+
</DropdownButtonItem>
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function APIReferenceAIDropdown() {
|
|
56
|
+
return (
|
|
57
|
+
<DropdownButton id="ai-dropdown-button">
|
|
58
|
+
<DropdownButtonPrimaryAction>
|
|
59
|
+
<CopyIcon size={16} />
|
|
60
|
+
<DropdownButtonPrimaryActionText>Copy Markdown</DropdownButtonPrimaryActionText>
|
|
61
|
+
</DropdownButtonPrimaryAction>
|
|
62
|
+
<DropdownButtonTrigger />
|
|
63
|
+
<DropdownButtonMenu>
|
|
64
|
+
<AIDropdownOptions />
|
|
65
|
+
<DropdownButtonDivider />
|
|
66
|
+
<DropdownButtonItem value="copy-as-markdown" isExternalLink>
|
|
67
|
+
<DropdownButtonItemIcon>
|
|
68
|
+
<CopyIcon size={16} />
|
|
69
|
+
</DropdownButtonItemIcon>
|
|
70
|
+
<DropdownButtonItemText>Copy Markdown</DropdownButtonItemText>
|
|
71
|
+
</DropdownButtonItem>
|
|
72
|
+
<DropdownButtonItem value="view-as-markdown" isExternalLink>
|
|
73
|
+
<DropdownButtonItemIcon>
|
|
74
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
75
|
+
<path
|
|
76
|
+
d="M14.8447 3.33301C15.151 3.33301 15.4455 3.45527 15.6621 3.67188C15.8785 3.88844 16 4.18213 16 4.48828V12.0254C15.9997 12.3315 15.8777 12.6254 15.6611 12.8418C15.4446 13.0581 15.1508 13.1797 14.8447 13.1797H1.15527C0.848967 13.1797 0.55449 13.0584 0.337891 12.8418C0.121288 12.6252 0 12.3307 0 12.0244V4.48828C1.09706e-05 4.18213 0.121501 3.88844 0.337891 3.67188C0.554493 3.45527 0.848951 3.33301 1.15527 3.33301H14.8447ZM1.15527 4.10254C1.10457 4.10245 1.0537 4.11247 1.00684 4.13184C0.960202 4.15116 0.917554 4.17917 0.881836 4.21484C0.845984 4.2507 0.817213 4.29396 0.797852 4.34082C0.778601 4.38756 0.769447 4.43773 0.769531 4.48828V12.0254C0.76962 12.0759 0.779409 12.1262 0.798828 12.1729C0.81827 12.2196 0.846978 12.2621 0.882812 12.2979C0.918602 12.3335 0.961134 12.3616 1.00781 12.3809C1.05454 12.4001 1.10474 12.4102 1.15527 12.4102H14.8447C14.9467 12.4101 15.045 12.3699 15.1172 12.2979C15.1893 12.2258 15.2293 12.1274 15.2295 12.0254V4.48828C15.2296 4.43774 15.2204 4.38755 15.2012 4.34082C15.1819 4.29403 15.1529 4.25166 15.1172 4.21582C15.0814 4.17999 15.0389 4.15126 14.9922 4.13184C14.9455 4.11249 14.8952 4.10258 14.8447 4.10254H1.15527ZM5.38477 7.56348L6.92285 5.64062H8.46094V10.8721H6.92285V7.87109L5.38477 9.79492L3.8457 7.87109V10.8711H2.30762V5.63965H3.8457L5.38477 7.56348ZM12.6924 8.33301H14.2305L11.9229 10.8711L9.61523 8.33301H11.1533V5.64062H12.6924V8.33301Z"
|
|
77
|
+
fill="#262626"
|
|
78
|
+
/>
|
|
79
|
+
</svg>
|
|
80
|
+
</DropdownButtonItemIcon>
|
|
81
|
+
<DropdownButtonItemText>View as Markdown</DropdownButtonItemText>
|
|
82
|
+
</DropdownButtonItem>
|
|
83
|
+
</DropdownButtonMenu>
|
|
84
|
+
</DropdownButton>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { ClientRouter } from 'astro:transitions';
|
|
3
|
+
import Default from '@astrojs/starlight/components/Head.astro';
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<style is:global>
|
|
7
|
+
/* Disable native View Transitions animations */
|
|
8
|
+
:root::view-transition-old(root),
|
|
9
|
+
:root::view-transition-new(root) {
|
|
10
|
+
animation: none;
|
|
11
|
+
}
|
|
12
|
+
:root::view-transition-group(root) {
|
|
13
|
+
animation-duration: 0s;
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
console.log('[EXPERIMENTAL] using client router');
|
|
19
|
+
</script>
|
|
20
|
+
<script>
|
|
21
|
+
function setNavLinksMode(doc: Document) {
|
|
22
|
+
let mode = localStorage.getItem('stl-nav-links-mode');
|
|
23
|
+
// initial guess
|
|
24
|
+
if (mode === null) {
|
|
25
|
+
mode = window.innerWidth < 1000 ? 'mobile' : 'desktop';
|
|
26
|
+
}
|
|
27
|
+
doc.documentElement.classList.add('stl-nav-links-mode-' + mode);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setNavLinksMode(document);
|
|
31
|
+
|
|
32
|
+
// https://docs.astro.build/en/guides/view-transitions/#astrobefore-swap
|
|
33
|
+
|
|
34
|
+
document.addEventListener('astro:before-swap', (event) => {
|
|
35
|
+
setNavLinksMode(event.newDocument);
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<ClientRouter />
|
|
40
|
+
|
|
41
|
+
<Default />
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
import config from 'virtual:starlight/user-config';
|
|
3
|
+
|
|
4
|
+
import { HEADER_LAYOUT } from 'virtual:stl-stl-starlight-virtual-module';
|
|
5
|
+
import DefaultHeader from './headers/DefaultHeader.astro';
|
|
6
|
+
import StackedHeader from './headers/StackedHeader.astro';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Render the `Search` component if Pagefind is enabled or the default search component has been overridden.
|
|
10
|
+
*/
|
|
11
|
+
const shouldRenderSearch = !!(
|
|
12
|
+
config.pagefind || config.components.Search !== '@astrojs/starlight/components/Search.astro'
|
|
13
|
+
);
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
{
|
|
17
|
+
HEADER_LAYOUT === 'stacked' ? (
|
|
18
|
+
<StackedHeader shouldRenderSearch={shouldRenderSearch} />
|
|
19
|
+
) : (
|
|
20
|
+
<DefaultHeader shouldRenderSearch={shouldRenderSearch} />
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
<style is:global>
|
|
25
|
+
@layer starlight.core {
|
|
26
|
+
header {
|
|
27
|
+
border-color: var(--sl-color-hairline);
|
|
28
|
+
|
|
29
|
+
&.header {
|
|
30
|
+
border-bottom-color: var(--sl-color-hairline);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.header {
|
|
35
|
+
display: flex;
|
|
36
|
+
gap: var(--sl-nav-gap);
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
align-items: center;
|
|
39
|
+
height: 100%;
|
|
40
|
+
width: 100%;
|
|
41
|
+
}
|
|
42
|
+
.title-wrapper {
|
|
43
|
+
/* Prevent long titles overflowing and covering the search and menu buttons on narrow viewports. */
|
|
44
|
+
overflow: clip;
|
|
45
|
+
/* Avoid clipping focus ring around link inside title wrapper. */
|
|
46
|
+
padding: 0.25rem;
|
|
47
|
+
padding-left: 0;
|
|
48
|
+
margin: -0.25rem;
|
|
49
|
+
min-width: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.default-tabs-container {
|
|
53
|
+
justify-content: flex-end;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.split-tabs-container {
|
|
57
|
+
display: flex;
|
|
58
|
+
max-width: 480px;
|
|
59
|
+
flex: 1;
|
|
60
|
+
|
|
61
|
+
button {
|
|
62
|
+
max-width: unset;
|
|
63
|
+
width: 100%;
|
|
64
|
+
flex: 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.left-group {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: var(--sl-nav-gap);
|
|
72
|
+
flex-shrink: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.right-group,
|
|
76
|
+
.social-icons {
|
|
77
|
+
gap: var(--sl-nav-gap);
|
|
78
|
+
align-items: center;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.right-group > div {
|
|
82
|
+
gap: var(--sl-nav-gap);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@media (min-width: 50rem) {
|
|
86
|
+
.default-tabs-container {
|
|
87
|
+
min-width: 440px;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Default from '@astrojs/starlight/components/Sidebar.astro';
|
|
3
|
+
import SDKSelect from '../../plugin/components/SDKSelect.astro';
|
|
4
|
+
import HeaderLinks from './headers/HeaderLinks.astro';
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<div class="stl-sidebar-header-links">
|
|
8
|
+
<HeaderLinks />
|
|
9
|
+
</div>
|
|
10
|
+
<SDKSelect />
|
|
11
|
+
<Default><slot /></Default>
|