@stainless-api/docs-ui 0.1.0-beta.9 → 0.1.0-beta.90

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 (162) hide show
  1. package/dist/breadcrumbs-DC2_z7nh.d.ts +25 -0
  2. package/dist/chunk-pbuEa-1d.js +13 -0
  3. package/dist/component-generics-DYxBWv1v.js +42 -0
  4. package/dist/component-generics-q-ujwX4P.d.ts +30 -0
  5. package/dist/components/MaskedInput.d.ts +14 -0
  6. package/dist/components/MaskedInput.js +74 -0
  7. package/dist/components/breadcrumbs.d.ts +2 -0
  8. package/dist/components/breadcrumbs.js +62 -0
  9. package/dist/components/icons.d.ts +72 -0
  10. package/dist/components/icons.js +953 -0
  11. package/dist/components/index.d.ts +10 -0
  12. package/dist/components/index.js +73 -0
  13. package/dist/components/method.d.ts +2 -0
  14. package/dist/components/method.js +95 -0
  15. package/dist/components/overview.d.ts +2 -0
  16. package/dist/components/overview.js +140 -0
  17. package/dist/components/primitives.d.ts +2 -0
  18. package/dist/components/primitives.js +251 -0
  19. package/dist/components/properties.d.ts +2 -0
  20. package/dist/components/properties.js +144 -0
  21. package/dist/components/sdk-sidebar.d.ts +2 -0
  22. package/dist/components/sdk-sidebar.js +50 -0
  23. package/dist/components/sdk.d.ts +2 -0
  24. package/dist/components/sdk.js +488 -0
  25. package/dist/components/snippets.d.ts +2 -0
  26. package/dist/components/snippets.js +184 -0
  27. package/dist/components/stl-sidebar.d.ts +2 -0
  28. package/dist/components/stl-sidebar.js +112 -0
  29. package/dist/contexts/component-generics.d.ts +2 -0
  30. package/dist/contexts/component-generics.js +2 -0
  31. package/dist/contexts/component-types.d.ts +6 -0
  32. package/dist/contexts/component-types.js +0 -0
  33. package/dist/contexts/component.d.ts +20 -0
  34. package/dist/contexts/component.js +21 -0
  35. package/dist/contexts/docs.d.ts +2 -0
  36. package/dist/contexts/docs.js +89 -0
  37. package/dist/contexts/index.d.ts +6 -0
  38. package/dist/contexts/index.js +43 -0
  39. package/dist/contexts/markdown.d.ts +2 -0
  40. package/dist/contexts/markdown.js +62 -0
  41. package/dist/contexts/navigation.d.ts +2 -0
  42. package/dist/contexts/navigation.js +21 -0
  43. package/dist/contexts/use-components.d.ts +5 -0
  44. package/dist/contexts/use-components.js +5 -0
  45. package/dist/docs-DSjdvCh5.d.ts +62 -0
  46. package/dist/index-DFr9Mesr.d.ts +1776 -0
  47. package/dist/index-gGDaf6FK.d.ts +464 -0
  48. package/dist/index.d.ts +5 -0
  49. package/dist/index.js +8 -7542
  50. package/dist/languages/cli.d.ts +2 -0
  51. package/dist/languages/cli.js +165 -0
  52. package/dist/languages/csharp.d.ts +2 -0
  53. package/dist/languages/csharp.js +282 -0
  54. package/dist/languages/go.d.ts +2 -0
  55. package/dist/languages/go.js +302 -0
  56. package/dist/languages/http.d.ts +2 -0
  57. package/dist/languages/http.js +385 -0
  58. package/dist/languages/index.d.ts +2 -0
  59. package/dist/languages/index.js +31 -0
  60. package/dist/languages/java.d.ts +2 -0
  61. package/dist/languages/java.js +402 -0
  62. package/dist/languages/php.d.ts +2 -0
  63. package/dist/languages/php.js +311 -0
  64. package/dist/languages/python.d.ts +2 -0
  65. package/dist/languages/python.js +268 -0
  66. package/dist/languages/ruby.d.ts +2 -0
  67. package/dist/languages/ruby.js +386 -0
  68. package/dist/languages/terraform.d.ts +2 -0
  69. package/dist/languages/terraform.js +259 -0
  70. package/dist/languages/typescript.d.ts +2 -0
  71. package/dist/languages/typescript.js +448 -0
  72. package/dist/markdown/index.d.ts +11 -0
  73. package/dist/markdown/index.js +87 -0
  74. package/dist/markdown/md.d.ts +15 -0
  75. package/dist/markdown/md.js +39 -0
  76. package/dist/markdown/printer.d.ts +13 -0
  77. package/dist/markdown/printer.js +74 -0
  78. package/dist/markdown/utils.d.ts +28 -0
  79. package/dist/markdown/utils.js +31 -0
  80. package/dist/markdown-Cwdboi_V.d.ts +33 -0
  81. package/dist/method-CNRMOUfn.d.ts +59 -0
  82. package/dist/navigation-C9ckAfpV.d.ts +29 -0
  83. package/dist/overview-CDvh184n.d.ts +39 -0
  84. package/dist/primitives-DFE_4MvV.d.ts +107 -0
  85. package/dist/properties-CVwrzWVa.d.ts +54 -0
  86. package/dist/routing-yTSG7nWM.d.ts +61 -0
  87. package/dist/routing.d.ts +2 -0
  88. package/dist/routing.js +174 -150
  89. package/dist/sdk-BkW3MDco.d.ts +128 -0
  90. package/dist/sdk-sidebar-BpDlOMat.d.ts +15 -0
  91. package/dist/spec.d.ts +65 -0
  92. package/dist/spec.js +165 -0
  93. package/dist/stl-sidebar-CKrR5ZGs.d.ts +58 -0
  94. package/dist/style.d.ts +178 -0
  95. package/dist/style.js +178 -0
  96. package/dist/styles/main.css +765 -755
  97. package/dist/styles/primitives.css +359 -442
  98. package/dist/styles/resets.css +25 -41
  99. package/dist/styles/search.css +187 -270
  100. package/dist/styles/sidebar.css +155 -69
  101. package/dist/styles/variables.css +23 -89
  102. package/dist/styles.css +3171 -0
  103. package/dist/utils.d.ts +20 -0
  104. package/dist/utils.js +52 -0
  105. package/package.json +75 -22
  106. package/dist/mcp.js +0 -16003
  107. package/dist/styles/snippets.css +0 -132
  108. package/src/components/breadcrumbs.tsx +0 -94
  109. package/src/components/chat.tsx +0 -154
  110. package/src/components/dropdown.tsx +0 -91
  111. package/src/components/icons.tsx +0 -584
  112. package/src/components/index.ts +0 -9
  113. package/src/components/method.tsx +0 -146
  114. package/src/components/overview.tsx +0 -160
  115. package/src/components/primitives.tsx +0 -284
  116. package/src/components/properties.tsx +0 -130
  117. package/src/components/scripts/dropdown.ts +0 -78
  118. package/src/components/sdk.tsx +0 -403
  119. package/src/components/sidebar.tsx +0 -99
  120. package/src/components/snippets.tsx +0 -180
  121. package/src/contexts/component-generics.tsx +0 -48
  122. package/src/contexts/component-types.tsx +0 -5
  123. package/src/contexts/component.tsx +0 -32
  124. package/src/contexts/docs.tsx +0 -75
  125. package/src/contexts/index.tsx +0 -17
  126. package/src/contexts/markdown.tsx +0 -43
  127. package/src/contexts/navigation.tsx +0 -44
  128. package/src/contexts/search.tsx +0 -28
  129. package/src/contexts/use-components.tsx +0 -4
  130. package/src/index.ts +0 -6
  131. package/src/languages/go.tsx +0 -281
  132. package/src/languages/http.tsx +0 -321
  133. package/src/languages/index.ts +0 -26
  134. package/src/languages/java.tsx +0 -358
  135. package/src/languages/python.tsx +0 -255
  136. package/src/languages/ruby.tsx +0 -320
  137. package/src/languages/typescript.tsx +0 -393
  138. package/src/markdown/index.ts +0 -107
  139. package/src/markdown/md.ts +0 -45
  140. package/src/markdown/utils.ts +0 -49
  141. package/src/routing.ts +0 -238
  142. package/src/search/form.tsx +0 -127
  143. package/src/search/index.tsx +0 -1
  144. package/src/search/indexer.ts +0 -246
  145. package/src/search/mcp.ts +0 -61
  146. package/src/search/printer.tsx +0 -86
  147. package/src/search/providers/algolia.ts +0 -88
  148. package/src/search/providers/fuse.ts +0 -19
  149. package/src/search/providers/pagefind.ts +0 -17
  150. package/src/search/providers/walker.ts +0 -30
  151. package/src/search/results.tsx +0 -182
  152. package/src/search/state.ts +0 -64
  153. package/src/search/types.ts +0 -116
  154. package/src/style.ts +0 -196
  155. package/src/styles/main.css +0 -986
  156. package/src/styles/primitives.css +0 -580
  157. package/src/styles/resets.css +0 -39
  158. package/src/styles/search.css +0 -341
  159. package/src/styles/sidebar.css +0 -85
  160. package/src/styles/snippets.css +0 -130
  161. package/src/styles/variables.css +0 -86
  162. package/src/utils.ts +0 -41
@@ -1,281 +0,0 @@
1
- import * as React from 'react';
2
- import type * as AST from '~/lib/json-spec-v2/GoAST';
3
-
4
- import { useComponents } from '../contexts/use-components';
5
- import { useLanguageComponents } from '../contexts';
6
- import style from '../style';
7
- import { PropertyFn } from '.';
8
-
9
- const ComplexTypes: Record<string, string> = {
10
- GoTypeMap: 'map',
11
- GoTypeArray: 'array',
12
- };
13
-
14
- const Keywords = {
15
- GoTypeAny: 'any',
16
- GoTypeUnknown: 'unknown',
17
- GoTypeInt: 'int64',
18
- GoTypeFloat: 'float64',
19
- GoTypeBool: 'bool',
20
- GoTypeError: 'error',
21
- };
22
-
23
- function isField(type: AST.GoType) {
24
- return type.kind === 'GoTypeReference' && type.typeName === 'param.Field';
25
- }
26
-
27
- export type TypeProps = {
28
- type: AST.GoType;
29
- };
30
-
31
- export function TypeName({ type }: TypeProps) {
32
- const Lang = useLanguageComponents();
33
- return isField(type) ? 'field' : (ComplexTypes[type.kind] ?? <Lang.Type type={type} />);
34
- }
35
-
36
- export function Type({ type }: TypeProps) {
37
- const Lang = useLanguageComponents();
38
- const { Join, SDKReference } = useComponents();
39
-
40
- switch (type.kind) {
41
- case 'GoTypeReference': {
42
- const params = type.typeParameters?.map((param, key) => <Lang.Type key={key} type={param} />);
43
-
44
- return (
45
- <span className={style.Type}>
46
- <SDKReference stainlessPath={type.$ref}>{type.typeName}</SDKReference>
47
- {params && params.length > 0 ? (
48
- <>
49
- <span className={style.TypeBracket}>{'['}</span>
50
- <Join items={params} limit={3}>
51
- <span className={style.TextOperator}>, </span>
52
- </Join>
53
- <span className={style.TypeBracket}>{']'}</span>
54
- </>
55
- ) : null}
56
- </span>
57
- );
58
- }
59
-
60
- case 'GoTypeAny':
61
- case 'GoTypeUnknown':
62
- case 'GoTypeInt':
63
- case 'GoTypeFloat':
64
- case 'GoTypeBool':
65
- case 'GoTypeError':
66
- return (
67
- <span className={style.Type}>
68
- <span className={style.TypeKeyword}>{Keywords[type.kind]}</span>
69
- </span>
70
- );
71
-
72
- case 'GoTypeString':
73
- return (
74
- <span className={style.Type}>
75
- <span className={style.TypeString}>string</span>
76
- </span>
77
- );
78
-
79
- case 'GoTypeArray':
80
- return (
81
- <span className={style.Type}>
82
- <span className={style.TextOperator}>[]</span>
83
- <Lang.Type type={type.elementType} />
84
- </span>
85
- );
86
-
87
- case 'GoTypeStruct':
88
- return (
89
- <span className={style.Type}>
90
- <span className={style.TypeKeyword}>{'struct{…}'}</span>
91
- </span>
92
- );
93
-
94
- case 'GoTypeInterface':
95
- return (
96
- <span className={style.Type}>
97
- <span className={style.TypeKeyword}>{'interface{…}'}</span>
98
- </span>
99
- );
100
-
101
- case 'GoTypeMap':
102
- return (
103
- <span className={style.Type}>
104
- <span className={style.TypeKeyword}>map</span>
105
- <span className={style.TypeBracket}>[</span>
106
- <Lang.Type type={type.indexType} />
107
- <span className={style.TextPunctuation}>,</span> <Lang.Type type={type.itemType} />
108
- <span className={style.TypeBracket}>]</span>
109
- </span>
110
- );
111
-
112
- case 'GoTypePointer':
113
- return (
114
- <span className={style.Type}>
115
- <span className={style.TextOperator}>*</span>
116
- <Lang.Type type={type.inner} />
117
- </span>
118
- );
119
- }
120
- }
121
-
122
- export type MethodSignatureProps = {
123
- decl: AST.GoDeclFunction;
124
- };
125
-
126
- export function MethodSignature({ decl }: MethodSignatureProps) {
127
- const Lang = useLanguageComponents();
128
- const { Join } = useComponents();
129
-
130
- const params = decl.parameters.map((param, i) => (
131
- <React.Fragment key={i}>
132
- <span className={style.TextIdentifier}>{param.ident}</span>
133
- {param.optional && <span className={style.TextPunctuation}>?</span>}
134
- </React.Fragment>
135
- ));
136
-
137
- const returns = decl.returnType.map((t, key) => <Lang.Type key={key} type={t} />);
138
-
139
- return (
140
- <div className={style.MethodSignature}>
141
- <span className={style.SignatureTitle}>
142
- {decl.async && <span className={style.TextKeyword}>async </span>}
143
- {decl.qualified && (
144
- <span className={style.SignatureQualified}>
145
- <span className={style.TextIdentifier}>{decl.qualified?.slice(0, -decl.ident.length)}</span>
146
- </span>
147
- )}
148
- {decl.kind === 'GoDeclFunction' && (
149
- <span className={style.SignatureName}>
150
- <span className={style.TextIdentifier}>{decl.ident}</span>
151
- </span>
152
- )}
153
- <span className={style.MethodSignature}>
154
- <span className={style.SignatureParen}>{'('}</span>
155
-
156
- <span className={style.SignatureParams}>
157
- <Join items={params}>
158
- <span className={style.TextOperator}>{', '}</span>
159
- </Join>
160
- </span>
161
-
162
- <span className={style.SignatureParen}>{')'} </span>
163
- {decl.returnType.length === 1 ? (
164
- returns
165
- ) : (
166
- <>
167
- <span className={style.SignatureParen}>{'('}</span>
168
- <Join items={returns}>
169
- <span className={style.TextOperator}>, </span>
170
- </Join>
171
- <span className={style.SignatureParen}>{')'}</span>
172
- </>
173
- )}
174
- </span>
175
- </span>
176
- </div>
177
- );
178
- }
179
-
180
- export type PropertyProps = {
181
- decl: AST.GoDeclaration;
182
- children?: PropertyFn;
183
- };
184
-
185
- export function Property({ decl, children }: PropertyProps) {
186
- const Docs = useComponents();
187
- const Lang = useLanguageComponents();
188
-
189
- if (!decl) return null;
190
-
191
- switch (decl.kind) {
192
- case 'GoDeclProperty':
193
- return children({
194
- name: decl.ident,
195
- typeName: <Lang.TypeName type={decl.type} />,
196
- badges: decl.optional && <Docs.Badge id="optional" />,
197
- type: (isField(decl.type) || decl.type.kind in ComplexTypes) && <Lang.Type type={decl.type} />,
198
- });
199
-
200
- case 'GoDeclConst':
201
- return children({
202
- name: decl.ident,
203
- typeName: 'const',
204
- type: <Lang.Type type={decl.type} />,
205
- });
206
-
207
- case 'GoDeclReference':
208
- return children({ type: <Lang.Type type={decl.type} /> });
209
-
210
- case 'GoDeclType':
211
- case 'GoDeclTypeAlias': {
212
- const typeName =
213
- decl.type.kind === 'GoTypeStruct'
214
- ? 'struct'
215
- : decl.type.kind === 'GoTypeInterface'
216
- ? 'interface'
217
- : decl.kind === 'GoDeclTypeAlias'
218
- ? 'alias'
219
- : 'type';
220
-
221
- return children({
222
- name: decl.ident,
223
- typeName,
224
- type: ['GoTypeStruct', 'GoTypeInterface'].includes(decl.type.kind) || <Lang.Type type={decl.type} />,
225
- });
226
- }
227
- }
228
- }
229
-
230
- export type DeclarationProps = { decl: AST.GoDeclaration };
231
-
232
- export function Declaration({ decl }: DeclarationProps) {
233
- const Lang = useLanguageComponents();
234
-
235
- if (!decl) return;
236
-
237
- switch (decl.kind) {
238
- case 'GoDeclType':
239
- return (
240
- <>
241
- <span className={style.TextKeyword}>type </span>
242
- <span className={style.TextIdentifier}>{decl.ident} </span>
243
- <Lang.Type type={decl.type} />
244
- </>
245
- );
246
-
247
- case 'GoDeclTypeAlias':
248
- return (
249
- <>
250
- <span className={style.TextKeyword}>type </span>
251
- <span className={style.TextIdentifier}>{decl.ident} </span>
252
- <span className={style.TextOperator}>= </span>
253
- <Lang.Type type={decl.type} />
254
- </>
255
- );
256
-
257
- case 'GoDeclProperty':
258
- return (
259
- <>
260
- <span className={style.TypePropertyName}>
261
- <span className={style.TextIdentifier}>{decl.ident} </span>
262
- </span>
263
- <Lang.Type type={decl.type} />
264
- </>
265
- );
266
-
267
- case 'GoDeclReference':
268
- return <Lang.Type type={decl.type} />;
269
-
270
- case 'GoDeclConst':
271
- return (
272
- <>
273
- <span className={style.TextKeyword}>const </span>
274
- <span className={style.TextIdentifier}>{decl.ident} </span>
275
- <Lang.Type type={decl.type} />
276
- <span className={style.TextOperator}> = </span>
277
- {JSON.stringify(decl.value)}
278
- </>
279
- );
280
- }
281
- }
@@ -1,321 +0,0 @@
1
- import type * as AST from '~/lib/json-spec-v2/HttpAST';
2
- import { useDeclaration, useLanguage, useLanguageComponents, useSpec } from '../contexts';
3
- import { useComponents } from '../contexts/use-components';
4
- import style from '../style';
5
- import React from 'react';
6
- import { PropertyFn } from '.';
7
- import { PropertyToggle } from '../components';
8
-
9
- const ComplexTypes: Partial<Record<AST.HttpType['kind'], string>> = {
10
- HttpTypeUnion: 'union',
11
- HttpTypeIntersection: 'intersection',
12
- };
13
-
14
- const constStyle = {
15
- string: style.LiteralString,
16
- number: style.LiteralNumeric,
17
- boolean: style.LiteralBoolean,
18
- };
19
-
20
- type TypeProps = {
21
- type: AST.HttpType;
22
- };
23
-
24
- function Identifier({ name }: { name: string }) {
25
- return (
26
- <>
27
- <span className={style.TextIdentifier}>
28
- {/^[_a-zA-Z][_a-zA-Z0-9]*$/.test(name) ? name : JSON.stringify(name)}
29
- </span>
30
- </>
31
- );
32
- }
33
-
34
- function TypePreview({ path }: { path: string }) {
35
- const spec = useSpec();
36
- const language = useLanguage();
37
- const decl = useDeclaration(path);
38
- const { Join } = useComponents();
39
-
40
- if (!(decl && 'children' in decl && decl.children.length > 0) || decl['type']?.['kind'] === 'HttpTypeUnion')
41
- return;
42
-
43
- const items = decl.children.map((prop, key) => (
44
- <span key={key} className={style.TypePropertyName}>
45
- <span className={style.TextIdentifier}>{spec?.decls?.[language]?.[prop]?.['key']}</span>
46
- </span>
47
- ));
48
-
49
- return (
50
- <span className={style.TypePreview} data-stldocs-type-preview="properties">
51
- <span className={style.TypeBrace}>{' { '}</span>
52
- <span className={style.TypePreviewContent}>
53
- <Join items={items} limit={3}>
54
- <span className={style.TextOperator}>, </span>
55
- </Join>
56
- </span>
57
- <span className={style.TypeBrace}>{' } '}</span>
58
- </span>
59
- );
60
- }
61
-
62
- export function TypeName({ type }: TypeProps) {
63
- const Lang = useLanguageComponents();
64
-
65
- if (type.kind === 'HttpTypeArray') return <>array of {<Lang.TypeName type={type.elementType} />}</>;
66
-
67
- if (type.kind === 'HttpTypeUnion' && type.types.every((t) => t.kind === 'HttpTypeLiteral')) return 'enum';
68
-
69
- if (type.kind === 'HttpTypeReference' && type.ident.split('.').at(-1) === 'Record') return 'map';
70
-
71
- return ComplexTypes[type.kind] ?? <Lang.Type type={type} />;
72
- }
73
-
74
- export function Type({ type }: TypeProps) {
75
- const Lang = useLanguageComponents();
76
- const { Join, SDKReference } = useComponents();
77
-
78
- switch (type.kind) {
79
- case 'HttpTypeUnknown':
80
- case 'HttpTypeUndefined':
81
- case 'HttpTypeNull':
82
- case 'HttpTypeBoolean':
83
- case 'HttpTypeNumber':
84
- return (
85
- <span className={style.Type}>
86
- <span className={style.TypePlain}>{type.kind.slice(8).toLowerCase()}</span>
87
- </span>
88
- );
89
-
90
- case 'HttpTypeString':
91
- return (
92
- <span className={style.Type}>
93
- <span className={style.TypePlain}>string</span>
94
- </span>
95
- );
96
-
97
- case 'HttpTypeLiteral':
98
- return (
99
- <span className={style.Type}>
100
- <span className={constStyle[typeof type.literal]}>{JSON.stringify(type.literal)}</span>
101
- </span>
102
- );
103
-
104
- case 'HttpTypeArray': {
105
- return (
106
- <span className={style.Type}>
107
- <span className={style.TypeArray}>{'array of '}</span>
108
- <Lang.Type type={type.elementType} />
109
- </span>
110
- );
111
- }
112
-
113
- case 'HttpTypeIntersection':
114
- case 'HttpTypeUnion': {
115
- const items = type.types.map((t, key) => <Lang.Type key={key} type={t} />);
116
-
117
- const delimiter = type.kind === 'HttpTypeUnion' ? 'or' : 'and';
118
-
119
- return (
120
- <span className={style.Type}>
121
- <span className={style.TypePreview} data-stldocs-type-preview="union">
122
- <span className={style.TypePreviewContent}>
123
- <Join items={items} limit={3}>
124
- <span className={style.TextOperator}> {delimiter} </span>
125
- </Join>
126
- </span>
127
- </span>
128
- </span>
129
- );
130
- }
131
-
132
- case 'HttpTypeReference': {
133
- const name = type.ident.split('.').at(-1);
134
- const params = type.typeParameters?.map((param, key) => <Lang.Type key={key} type={param} />);
135
-
136
- // TODO: come up with an unambiguous way to identify these on the sdkjson side
137
- // This is sketchy because it's possible for a user-defined type to be named "Record"
138
- if (
139
- name === 'Record' &&
140
- type.typeParameters?.length === 2 &&
141
- type.typeParameters?.at(0).kind === 'HttpTypeString'
142
- )
143
- return (
144
- <>
145
- <span className={style.TypeArray}>map</span>[{params?.[1]}]
146
- </>
147
- );
148
-
149
- return (
150
- <span className={style.Type}>
151
- <SDKReference stainlessPath={type.$ref}>{name}</SDKReference>
152
- {params && params.length > 0 && (
153
- <>
154
- <span className={style.TypeBracket}>{'<'}</span>
155
- <Join items={params} limit={3}>
156
- <span className={style.TextOperator}>, </span>
157
- </Join>
158
- <span className={style.TypeBracket}>{'>'}</span>
159
- </>
160
- )}
161
- <TypePreview path={type.$ref} />
162
- </span>
163
- );
164
- }
165
-
166
- case 'HttpTypeObject':
167
- const items = type.members.map(({ ident }) => (
168
- <span className={style.TypePropertyName}>
169
- <Identifier name={ident} />
170
- </span>
171
- ));
172
-
173
- return (
174
- <span className={style.Type}>
175
- <span className={style.TypePlain}>object</span>
176
- <span className={style.TypePreview} data-stldocs-type-preview="properties">
177
- <span className={style.TypeBrace}>{' {'}</span>
178
- <span className={style.TypePreviewContent}>
179
- {' '}
180
- <Join items={items} limit={3}>
181
- <span className={style.TextOperator}>, </span>
182
- </Join>{' '}
183
- </span>
184
- <span className={style.TypeBrace}>{'} '}</span>
185
- </span>
186
- </span>
187
- );
188
- }
189
- }
190
-
191
- export type MethodSignatureProps = {
192
- decl: AST.HttpDeclFunction;
193
- };
194
-
195
- export function MethodSignature({ decl }: MethodSignatureProps) {
196
- return null;
197
- }
198
-
199
- export function MethodInfo({ decl, children }: MethodSignatureProps & { children: React.ReactNode }) {
200
- const Docs = useComponents();
201
-
202
- const params = Object.entries(decl.paramsChildren)
203
- .filter(([_, value]) => value.length)
204
- .map(([location, value]) => (
205
- <React.Fragment key={location}>
206
- <div className={style.MethodParameters} data-stldocs-property-group={location.at(0)}>
207
- <h5>
208
- {location.at(0).toUpperCase()}
209
- {location.slice(1)} Parameters
210
- <PropertyToggle target={location.at(0)} />
211
- </h5>
212
- <Docs.SDKChildren paths={value} />
213
- </div>
214
- </React.Fragment>
215
- ));
216
-
217
- if (decl.bodyParamsChildren?.['application/json']?.length > 0)
218
- params.push(
219
- <div className={style.MethodInfoSection}>
220
- <h5>
221
- Body Parameters
222
- <PropertyToggle target="body" />
223
- </h5>
224
- <div className={style.MethodParameters} data-stldocs-property-group="body">
225
- <Docs.SDKChildren paths={decl.bodyParamsChildren?.['application/json']} />
226
- </div>
227
- </div>,
228
- );
229
-
230
- return (
231
- <div className={style.MethodInfo}>
232
- {children && <div className={style.MethodContent}>{children}</div>}
233
- {params.length > 0 && params}
234
- {decl.responseChildren.length > 0 && (
235
- <div className={style.MethodInfoSection}>
236
- <h5>
237
- Returns
238
- <PropertyToggle target="returns" />
239
- </h5>
240
- <div className={style.MethodReturns} data-stldocs-property-group="returns">
241
- <Docs.SDKChildren paths={decl.responseChildren} />
242
- </div>
243
- </div>
244
- )}
245
- </div>
246
- );
247
- }
248
-
249
- function renderVariantInfo(type: AST.HttpType) {
250
- if (
251
- type.kind === 'HttpTypeUnion' &&
252
- type.types.every((t) => t.kind === 'HttpTypeObject' || t.kind === 'HttpTypeReference')
253
- )
254
- return <>One of the following {type.types.length} object variants:</>;
255
- }
256
-
257
- export type PropertyProps = {
258
- decl: AST.HttpDeclaration;
259
- children?: PropertyFn;
260
- };
261
-
262
- export function Property({ decl, children }: PropertyProps) {
263
- const Lang = useLanguageComponents();
264
-
265
- if (!decl) return;
266
-
267
- switch (decl.kind) {
268
- case 'HttpDeclProperty': {
269
- const variants = renderVariantInfo(decl.type);
270
-
271
- return children({
272
- name: decl.key,
273
- typeName: <Lang.TypeName type={decl.type} />,
274
- type: decl.type.kind in ComplexTypes && !variants && <Lang.Type type={decl.type} />,
275
- });
276
- }
277
-
278
- case 'HttpDeclTypeAlias':
279
- return children({
280
- name: decl.ident,
281
- typeName: <Lang.TypeName type={decl.type} />,
282
- });
283
-
284
- case 'HttpDeclReference':
285
- return children({ type: <Lang.Type type={decl.type} /> });
286
- }
287
- }
288
-
289
- export type DeclarationProps = { decl: AST.HttpDeclaration };
290
-
291
- export function Declaration({ decl }: DeclarationProps) {
292
- const Lang = useLanguageComponents();
293
-
294
- if (!decl) return;
295
-
296
- switch (decl.kind) {
297
- case 'HttpDeclProperty':
298
- return (
299
- <>
300
- <span className={style.TypePropertyName}>
301
- <Identifier name={decl.key} />
302
- </span>
303
- <span className={style.TextPunctuation}>: </span>
304
- {decl.optional && <span className={style.TextPunctuation}>optional </span>}
305
- <Lang.Type type={decl.type} />
306
- </>
307
- );
308
-
309
- case 'HttpDeclTypeAlias':
310
- return (
311
- <>
312
- <Identifier name={decl.ident} />
313
- <span className={style.TextOperator}> = </span>
314
- <Lang.Type type={decl.type} />
315
- </>
316
- );
317
-
318
- case 'HttpDeclReference':
319
- return <Lang.Type type={decl.type} />;
320
- }
321
- }
@@ -1,26 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import type { DeclarationNode, Type } from '~/lib/json-spec-v2/types';
3
-
4
- import * as typescript from './typescript';
5
- import * as java from './java';
6
- import { PropertyProps } from '../components';
7
-
8
- export * as go from './go';
9
- export * as python from './python';
10
- export * as ruby from './ruby';
11
- export * as http from './http';
12
-
13
- export { typescript, java };
14
- export const node = typescript;
15
- export const kotlin = java;
16
-
17
- export type PropertyFn = (params: PropertyProps) => ReactNode;
18
-
19
- export interface LanguageComponentDefinition {
20
- Declaration(props: { decl: DeclarationNode });
21
- Property(props: { decl: DeclarationNode; children: PropertyFn });
22
- TypeName(props: { type: Type; optional?: boolean });
23
- Type(props: { type: Type; optional?: boolean });
24
- MethodSignature(props: { decl: DeclarationNode });
25
- MethodInfo?(props: { decl: DeclarationNode; children?: ReactNode });
26
- }