@stainless-api/docs 0.1.0-beta.96 → 0.1.0-beta.98

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,20 @@
1
1
  # @stainless-api/docs
2
2
 
3
+ ## 0.1.0-beta.98
4
+
5
+ ### Minor Changes
6
+
7
+ - ba39673: Makes sidebar keys truly unique
8
+
9
+ ## 0.1.0-beta.97
10
+
11
+ ### Patch Changes
12
+
13
+ - 415629f: Allow displaying a user-provided snippet as the “default” in single-snippet
14
+ - Updated dependencies [415629f]
15
+ - @stainless-api/docs-ui@0.1.0-beta.74
16
+ - @stainless-api/docs-search@0.1.0-beta.27
17
+
3
18
  ## 0.1.0-beta.96
4
19
 
5
20
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/docs",
3
- "version": "0.1.0-beta.96",
3
+ "version": "0.1.0-beta.98",
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.26",
60
- "@stainless-api/docs-ui": "0.1.0-beta.73",
59
+ "@stainless-api/docs-search": "0.1.0-beta.27",
60
+ "@stainless-api/docs-ui": "0.1.0-beta.74",
61
61
  "@stainless-api/ui-primitives": "0.1.0-beta.47"
62
62
  },
63
63
  "devDependencies": {
@@ -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
  }