@stainless-api/docs 0.1.0-beta.97 → 0.1.0-beta.99

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @stainless-api/docs
2
2
 
3
+ ## 0.1.0-beta.99
4
+
5
+ ### Minor Changes
6
+
7
+ - e005e5c: Adds PHP to the docs
8
+
9
+ ### Patch Changes
10
+
11
+ - e7d3aaa: defer references to `navigator` until browser time
12
+ - Updated dependencies [2919b0a]
13
+ - Updated dependencies [e005e5c]
14
+ - @stainless-api/docs-ui@0.1.0-beta.75
15
+ - @stainless-api/docs-search@0.1.0-beta.28
16
+
17
+ ## 0.1.0-beta.98
18
+
19
+ ### Minor Changes
20
+
21
+ - ba39673: Makes sidebar keys truly unique
22
+
3
23
  ## 0.1.0-beta.97
4
24
 
5
25
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/docs",
3
- "version": "0.1.0-beta.97",
3
+ "version": "0.1.0-beta.99",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -56,8 +56,8 @@
56
56
  "vite-plugin-prebundle-workers": "^0.2.0",
57
57
  "web-worker": "^1.5.0",
58
58
  "yaml": "^2.8.2",
59
- "@stainless-api/docs-search": "0.1.0-beta.27",
60
- "@stainless-api/docs-ui": "0.1.0-beta.74",
59
+ "@stainless-api/docs-search": "0.1.0-beta.28",
60
+ "@stainless-api/docs-ui": "0.1.0-beta.75",
61
61
  "@stainless-api/ui-primitives": "0.1.0-beta.47"
62
62
  },
63
63
  "devDependencies": {
@@ -73,7 +73,7 @@
73
73
  "vite": "^6.4.1",
74
74
  "zod": "^4.3.5",
75
75
  "@stainless/eslint-config": "0.1.0-beta.1",
76
- "@stainless/sdk-json": "^0.1.0-beta.6"
76
+ "@stainless/sdk-json": "^0.1.0-beta.7"
77
77
  },
78
78
  "scripts": {
79
79
  "vendor-deps": "tsx scripts/vendor_deps.ts",
@@ -0,0 +1,4 @@
1
+
2
+ <svg viewBox="0 0 128 128" width="24" height="24">
3
+ <path fill="url(#a)" d="M0 64c0 18.593 28.654 33.667 64 33.667 35.346 0 64-15.074 64-33.667 0-18.593-28.655-33.667-64-33.667C28.654 30.333 0 45.407 0 64Z"></path><path fill="#777bb3" d="M64 95.167c33.965 0 61.5-13.955 61.5-31.167 0-17.214-27.535-31.167-61.5-31.167S2.5 46.786 2.5 64c0 17.212 27.535 31.167 61.5 31.167Z"></path><path d="M34.772 67.864c2.793 0 4.877-.515 6.196-1.53 1.306-1.006 2.207-2.747 2.68-5.175.44-2.27.272-3.854-.5-4.71-.788-.874-2.493-1.317-5.067-1.317h-4.464l-2.473 12.732zM20.173 83.547a.694.694 0 0 1-.68-.828l6.557-33.738a.695.695 0 0 1 .68-.561h14.134c4.442 0 7.748 1.206 9.827 3.585 2.088 2.39 2.734 5.734 1.917 9.935-.333 1.711-.905 3.3-1.7 4.724a15.818 15.818 0 0 1-3.128 3.92c-1.531 1.432-3.264 2.472-5.147 3.083-1.852.604-4.232.91-7.07.91h-5.724l-1.634 8.408a.695.695 0 0 1-.682.562z"></path><path fill="#fff" d="M34.19 55.826h3.891c3.107 0 4.186.682 4.553 1.089.607.674.723 2.097.331 4.112-.439 2.257-1.253 3.858-2.42 4.756-1.194.92-3.138 1.386-5.773 1.386h-2.786l2.205-11.342zm6.674-8.1H26.731a1.39 1.39 0 0 0-1.364 1.123L18.81 82.588a1.39 1.39 0 0 0 1.363 1.653h7.35a1.39 1.39 0 0 0 1.363-1.124l1.525-7.846h5.151c2.912 0 5.364-.318 7.287-.944 1.977-.642 3.796-1.731 5.406-3.237a16.522 16.522 0 0 0 3.259-4.087c.831-1.487 1.429-3.147 1.775-4.931.86-4.423.161-7.964-2.076-10.524-2.216-2.537-5.698-3.823-10.349-3.823zM30.301 68.557h4.471c2.963 0 5.17-.557 6.62-1.675 1.451-1.116 2.428-2.98 2.938-5.591.485-2.508.264-4.277-.665-5.308-.931-1.03-2.791-1.546-5.584-1.546h-5.036l-2.743 14.12m10.563-19.445c4.252 0 7.353 1.117 9.303 3.348 1.95 2.232 2.536 5.347 1.76 9.346-.322 1.648-.863 3.154-1.625 4.518-.764 1.366-1.76 2.614-2.991 3.747-1.468 1.373-3.097 2.352-4.892 2.935-1.794.584-4.08.875-6.857.875h-6.296l-1.743 8.97h-7.35l6.558-33.739h14.133"></path><path d="M69.459 74.577a.694.694 0 0 1-.682-.827l2.9-14.928c.277-1.42.209-2.438-.19-2.87-.245-.263-.979-.704-3.15-.704h-5.256l-3.646 18.768a.695.695 0 0 1-.683.56h-7.29a.695.695 0 0 1-.683-.826l6.558-33.739a.695.695 0 0 1 .682-.561h7.29a.695.695 0 0 1 .683.826L64.41 48.42h5.653c4.307 0 7.227.758 8.928 2.321 1.733 1.593 2.275 4.14 1.608 7.573l-3.051 15.702a.695.695 0 0 1-.682.56h-7.407z"></path><path fill="#fff" d="M65.31 38.755h-7.291a1.39 1.39 0 0 0-1.364 1.124l-6.557 33.738a1.39 1.39 0 0 0 1.363 1.654h7.291a1.39 1.39 0 0 0 1.364-1.124l3.537-18.205h4.682c2.168 0 2.624.463 2.641.484.132.14.305.795.019 2.264l-2.9 14.927a1.39 1.39 0 0 0 1.364 1.654h7.408a1.39 1.39 0 0 0 1.363-1.124l3.051-15.7c.715-3.686.103-6.45-1.82-8.217-1.836-1.686-4.91-2.505-9.398-2.505h-4.81l1.421-7.315a1.39 1.39 0 0 0-1.364-1.655zm0 1.39-1.743 8.968h6.496c4.087 0 6.907.714 8.457 2.14 1.553 1.426 2.017 3.735 1.398 6.93l-3.052 15.699h-7.407l2.901-14.928c.33-1.698.208-2.856-.365-3.474-.573-.617-1.793-.926-3.658-.926h-5.829l-3.756 19.327H51.46l6.558-33.739h7.292z"></path><path d="M92.136 67.864c2.793 0 4.878-.515 6.198-1.53 1.304-1.006 2.206-2.747 2.679-5.175.44-2.27.273-3.854-.5-4.71-.788-.874-2.493-1.317-5.067-1.317h-4.463l-2.475 12.732zM77.54 83.547a.694.694 0 0 1-.682-.828l6.557-33.738a.695.695 0 0 1 .682-.561H98.23c4.442 0 7.748 1.206 9.826 3.585 2.089 2.39 2.734 5.734 1.917 9.935a15.878 15.878 0 0 1-1.699 4.724 15.838 15.838 0 0 1-3.128 3.92c-1.53 1.432-3.265 2.472-5.147 3.083-1.852.604-4.232.91-7.071.91h-5.723l-1.633 8.408a.695.695 0 0 1-.683.562z"></path><path fill="#fff" d="M91.555 55.826h3.891c3.107 0 4.186.682 4.552 1.089.61.674.724 2.097.333 4.112-.44 2.257-1.254 3.858-2.421 4.756-1.195.92-3.139 1.386-5.773 1.386h-2.786l2.204-11.342zm6.674-8.1H84.096a1.39 1.39 0 0 0-1.363 1.123l-6.558 33.739a1.39 1.39 0 0 0 1.364 1.653h7.35a1.39 1.39 0 0 0 1.363-1.124l1.525-7.846h5.15c2.911 0 5.364-.318 7.286-.944 1.978-.642 3.797-1.731 5.408-3.238a16.52 16.52 0 0 0 3.258-4.086c.832-1.487 1.428-3.147 1.775-4.931.86-4.423.162-7.964-2.076-10.524-2.216-2.537-5.697-3.823-10.35-3.823zM87.666 68.557h4.47c2.964 0 5.17-.557 6.622-1.675 1.45-1.116 2.428-2.98 2.936-5.591.487-2.508.266-4.277-.665-5.308-.93-1.03-2.791-1.546-5.583-1.546h-5.035Zm10.563-19.445c4.251 0 7.354 1.117 9.303 3.348 1.95 2.232 2.537 5.347 1.759 9.346-.32 1.648-.862 3.154-1.624 4.518-.763 1.366-1.76 2.614-2.992 3.747-1.467 1.373-3.097 2.352-4.892 2.935-1.793.584-4.078.875-6.856.875h-6.295l-1.745 8.97h-7.35l6.558-33.739h14.133"></path><defs><radialGradient id="a" cx="0" cy="0" r="1" gradientTransform="matrix(84.04136 0 0 84.04136 38.426 42.169)" gradientUnits="userSpaceOnUse"><stop stop-color="#AEB2D5"></stop><stop offset=".3" stop-color="#AEB2D5"></stop><stop offset=".75" stop-color="#484C89"></stop><stop offset="1" stop-color="#484C89"></stop></radialGradient></defs>
4
+ </svg>
@@ -7,7 +7,7 @@ interface DropdownOptionInputProps {
7
7
  onClick: () => void;
8
8
  icon: DropdownIcon;
9
9
  primaryAction?: boolean;
10
- clientHidden?: boolean;
10
+ clientHidden?: () => boolean;
11
11
  external: boolean;
12
12
  }
13
13
 
@@ -17,7 +17,7 @@ function option(label: string[] | string, props: DropdownOptionInputProps) {
17
17
  ...props,
18
18
  label: labelArr,
19
19
  primaryAction: props.primaryAction ?? false,
20
- clientHidden: props.clientHidden ?? false,
20
+ clientHidden: props.clientHidden ?? (() => false),
21
21
  id: labelArr.join('').toLowerCase().replace(/ /g, '-'),
22
22
  };
23
23
  }
@@ -88,7 +88,7 @@ function openDeepLink({ deepLinkUrl, fallbackUrl }: { deepLinkUrl: string; fallb
88
88
  }
89
89
 
90
90
  // https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Browser_detection_using_the_user_agent#mobile_tablet_or_desktop
91
- const hasMobileUserAgent = navigator.userAgent.includes('Mobi');
91
+ const hasMobileUserAgent = () => navigator.userAgent.includes('Mobi');
92
92
 
93
93
  // 2d array of dropdown options
94
94
  // each sub-array is a group, separated by a horizontal rule in the UI
@@ -208,7 +208,7 @@ export function wireAIDropdown() {
208
208
  document.addEventListener(getPageLoadEvent(), () => {
209
209
  // we hide the Cursor option on non-desktop devices
210
210
  for (const option of flatOptions) {
211
- if (option.clientHidden === true) {
211
+ if (option.clientHidden() === true) {
212
212
  const el = document.querySelector(
213
213
  `[data-dropdown-id="ai-dropdown-button"] [data-value="${option.id}"]`,
214
214
  );
@@ -8,6 +8,7 @@ import JavaIcon from './assets/languages/java.svg';
8
8
  import GoIcon from './assets/languages/go.svg';
9
9
  import CurlIcon from './assets/languages/curl.svg';
10
10
  import CSharpIcon from './assets/languages/csharp.svg';
11
+ import PHPIcon from './assets/languages/php.svg';
11
12
  import CLIIcon from './assets/languages/cli.svg';
12
13
 
13
14
  export const Languages: Record<
@@ -33,7 +34,7 @@ export const Languages: Record<
33
34
  ruby: { name: 'Ruby', icon: RubyIcon, alt: 'Ruby logo' },
34
35
  csharp: { name: 'C#', icon: CSharpIcon, alt: 'C# logo' },
35
36
  cli: { name: 'CLI Tool', icon: CLIIcon, alt: 'CLI logo' },
36
- php: { name: 'PHP', icon: CSharpIcon, alt: 'PHP logo' }, // TODO update PHP icon
37
+ php: { name: 'PHP', icon: PHPIcon, alt: 'PHP logo' },
37
38
  };
38
39
 
39
40
  export function generatePrefix(basePath: string, language: string) {
@@ -277,7 +277,7 @@ function makeSimpleAPIConfig(
277
277
  throw new Error('You must provide a stainlessProject when using Stainless Starlight');
278
278
  }
279
279
 
280
- const excludedLanguages = ['php' as const, ...(partial.excludeLanguages ?? [])];
280
+ const excludedLanguages = partial.excludeLanguages ?? [];
281
281
 
282
282
  const apiKey = loadApiKey(partial.apiKey);
283
283
 
@@ -356,8 +356,7 @@ function normalizeConfig(partial: SomeStainlessStarlightUserConfig, astroOptions
356
356
  const configWithDefaults = {
357
357
  basePath: partial.basePath ?? '/api',
358
358
  astroBase: astroOptions.base,
359
- // TODO: why are we excluding php; do we need to
360
- excludeLanguages: ['php' as const, ...(partial.excludeLanguages ?? [])],
359
+ excludeLanguages: partial.excludeLanguages ?? [],
361
360
  defaultLanguage: partial.defaultLanguage ?? 'http',
362
361
  breadcrumbs: {
363
362
  includeCurrentPage: partial.breadcrumbs?.includeCurrentPage ?? false,
@@ -2,6 +2,19 @@ import type * as SDKJSON from '@stainless/sdk-json';
2
2
  import { generateRoute, walkTree, type DocsLanguage } from '@stainless-api/docs-ui/routing';
3
3
  import type { StarlightRouteData } from '@astrojs/starlight/route-data';
4
4
 
5
+ function makeMethodOrResourceKey(entry: SDKJSON.Method | SDKJSON.Resource): string {
6
+ if (entry.kind === 'http_method') {
7
+ if (entry.endpoint && entry.endpoint !== '') {
8
+ return entry.endpoint;
9
+ }
10
+ return entry.stainlessPath;
11
+ }
12
+ if (entry.kind === 'resource') {
13
+ return entry.stainlessPath;
14
+ }
15
+ throw new Error(`Unknown entry kind ${JSON.stringify(entry)}`);
16
+ }
17
+
5
18
  function isResourceNonEmpty(resource: SDKJSON.Resource) {
6
19
  return (
7
20
  Object.keys(resource.methods ?? {}).length > 0 ||
@@ -174,7 +187,7 @@ export class SidebarConfigItemsBuilder {
174
187
  return {
175
188
  kind: 'resource_overview_page',
176
189
  label: this.isWebhookResource(entry) ? 'Events' : 'Overview',
177
- key: entry.configRef,
190
+ key: makeMethodOrResourceKey(entry),
178
191
  badge: undefined,
179
192
  metadata: {
180
193
  subResourceCount: countKeys(entry.subresources),
@@ -188,7 +201,7 @@ export class SidebarConfigItemsBuilder {
188
201
  return {
189
202
  kind: 'method_page',
190
203
  label: entry.title,
191
- key: entry.endpoint,
204
+ key: makeMethodOrResourceKey(entry),
192
205
  badge: undefined,
193
206
  metadata: {
194
207
  deprecated: Boolean(entry.deprecated),
@@ -230,7 +243,7 @@ export class SidebarConfigItemsBuilder {
230
243
  kind: 'group',
231
244
  badge: undefined,
232
245
  label: resource.title,
233
- resourceGroupKey: resource.configRef,
246
+ resourceGroupKey: makeMethodOrResourceKey(resource),
234
247
  entries,
235
248
  collapsed,
236
249
  };
@@ -268,10 +281,10 @@ type SidebarEntry = StarlightRouteData['sidebar'][number];
268
281
 
269
282
  function getResourceOrMethod(spec: SDKJSON.Spec, endpointOrConfigRef: string) {
270
283
  for (const entry of walkTree(spec, false)) {
271
- if (entry.data.kind === 'resource' && entry.data.configRef === endpointOrConfigRef) {
272
- return entry;
284
+ if (entry.data.kind === 'model') {
285
+ continue;
273
286
  }
274
- if (entry.data.kind === 'http_method' && entry.data.endpoint === endpointOrConfigRef) {
287
+ if (makeMethodOrResourceKey(entry.data) === endpointOrConfigRef) {
275
288
  return entry;
276
289
  }
277
290
  }