@stainless-api/docs 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.
- package/CHANGELOG.md +748 -0
- package/eslint-suppressions.json +32 -0
- package/locals.d.ts +17 -0
- package/package.json +49 -40
- package/playground-virtual-modules.d.ts +96 -0
- package/plugin/assets/languages/cli.svg +14 -0
- package/plugin/assets/languages/csharp.svg +1 -0
- package/plugin/buildAlgoliaIndex.ts +38 -11
- package/plugin/components/MethodDescription.tsx +54 -0
- package/plugin/components/RequestBuilder/ParamEditor.tsx +55 -0
- package/plugin/components/RequestBuilder/SnippetStainlessIsland.tsx +107 -0
- package/plugin/components/RequestBuilder/index.tsx +31 -0
- package/plugin/components/RequestBuilder/props.ts +9 -0
- package/plugin/components/RequestBuilder/spec-helpers.ts +50 -0
- package/plugin/components/RequestBuilder/styles.css +67 -0
- package/plugin/components/SDKSelect.astro +20 -104
- package/plugin/components/SnippetCode.tsx +111 -66
- package/plugin/components/StainlessIslands.tsx +126 -0
- package/plugin/components/search/SearchAlgolia.astro +45 -28
- package/plugin/components/search/SearchIsland.tsx +47 -29
- package/plugin/generateAPIReferenceLink.ts +2 -2
- package/plugin/globalJs/ai-dropdown-options.ts +243 -0
- package/plugin/globalJs/code-snippets.ts +15 -8
- package/plugin/globalJs/copy.ts +94 -17
- package/plugin/globalJs/create-playground.shim.ts +3 -0
- package/plugin/globalJs/method-descriptions.ts +33 -0
- package/plugin/globalJs/navigation.ts +10 -29
- package/plugin/globalJs/playground-data.shim.ts +1 -0
- package/plugin/globalJs/playground-data.ts +14 -0
- package/plugin/helpers/generateDocsRoutes.ts +27 -0
- package/plugin/helpers/getDocsLanguages.ts +9 -0
- package/plugin/index.ts +292 -116
- package/plugin/languages.ts +7 -2
- package/plugin/loadPluginConfig.ts +155 -79
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +1 -1
- package/plugin/react/Routing.tsx +204 -132
- package/plugin/referencePlaceholderUtils.ts +18 -15
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +38 -34
- package/plugin/routes/Docs.astro +65 -117
- package/plugin/routes/DocsStatic.astro +7 -4
- package/plugin/routes/Overview.astro +20 -24
- package/plugin/routes/markdown.ts +12 -11
- package/plugin/{cms → sidebar-utils}/sidebar-builder.ts +30 -54
- package/plugin/specs/fetchSpecSSR.ts +21 -0
- package/plugin/specs/generateSpec.ts +50 -0
- package/plugin/specs/index.ts +238 -0
- package/plugin/{cms → specs}/worker.ts +82 -5
- package/plugin/vendor/preview.worker.docs.js +20928 -17830
- package/plugin/vendor/templates/go.md +1 -1
- package/plugin/vendor/templates/python.md +1 -1
- package/resolveSrcFile.ts +10 -0
- package/scripts/vendor_deps.ts +5 -5
- package/shared/getProsePages.ts +42 -0
- package/shared/getSharedLogger.ts +15 -0
- package/shared/terminalUtils.ts +3 -0
- package/shared/virtualModule.ts +54 -1
- package/src/content.config.ts +9 -0
- package/stl-docs/components/AIDropdown.tsx +63 -0
- package/stl-docs/components/AiChatIsland.tsx +14 -0
- package/stl-docs/components/{content-panel/ContentBreadcrumbs.tsx → ContentBreadcrumbs.tsx} +2 -2
- package/stl-docs/components/Head.astro +20 -0
- package/stl-docs/components/Header.astro +6 -8
- package/stl-docs/components/PageFrame.astro +18 -0
- package/stl-docs/components/PageTitle.astro +82 -0
- package/stl-docs/components/TableOfContents.astro +34 -0
- package/stl-docs/components/ThemeProvider.astro +36 -0
- package/stl-docs/components/ThemeSelect.astro +84 -139
- package/stl-docs/components/content-panel/ContentPanel.astro +16 -46
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +17 -1
- package/stl-docs/components/headers/StackedHeader.astro +29 -24
- package/stl-docs/components/icons/chat-gpt.tsx +2 -2
- package/stl-docs/components/icons/cursor.tsx +10 -0
- package/stl-docs/components/icons/gemini.tsx +19 -0
- package/stl-docs/components/icons/markdown.tsx +1 -1
- package/stl-docs/components/index.ts +1 -0
- package/stl-docs/components/mintlify-compat/Accordion.astro +7 -5
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +7 -3
- package/stl-docs/components/mintlify-compat/Columns.astro +40 -42
- package/stl-docs/components/mintlify-compat/Frame.astro +16 -18
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +1 -1
- package/stl-docs/components/mintlify-compat/card.css +33 -35
- package/stl-docs/components/mintlify-compat/index.ts +2 -4
- package/stl-docs/components/nav-tabs/NavDropdown.astro +31 -70
- package/stl-docs/components/nav-tabs/NavTabs.astro +78 -80
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +15 -8
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +3 -2
- package/stl-docs/components/pagination/HomeLink.astro +10 -0
- package/stl-docs/components/pagination/Pagination.astro +175 -0
- package/stl-docs/components/pagination/PaginationLinkEmphasized.astro +22 -0
- package/stl-docs/components/pagination/PaginationLinkQuiet.astro +13 -0
- package/stl-docs/components/pagination/util.ts +71 -0
- package/stl-docs/components/scripts.ts +1 -0
- package/stl-docs/components/sidebars/BaseSidebar.astro +9 -2
- package/stl-docs/components/sidebars/SidebarWithComponents.tsx +10 -0
- package/stl-docs/components/sidebars/convertAstroSidebarToStl.tsx +62 -0
- package/stl-docs/disableCalloutSyntax.ts +36 -0
- package/stl-docs/fonts.ts +186 -0
- package/stl-docs/index.ts +153 -50
- package/stl-docs/loadStlDocsConfig.ts +51 -7
- package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +61 -0
- package/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts +41 -0
- package/stl-docs/proseMarkdown/toMarkdown.ts +158 -0
- package/stl-docs/proseSearchIndexing.ts +606 -0
- package/stl-docs/tabsMiddleware.ts +13 -4
- package/styles/code.css +128 -136
- package/styles/links.css +11 -48
- package/styles/method-descriptions.css +36 -0
- package/styles/overrides.css +49 -57
- package/styles/page.css +100 -59
- package/styles/sdk_select.css +9 -7
- package/styles/search.css +57 -69
- package/styles/sidebar.css +26 -156
- package/styles/{variables.css → sl-variables.css} +3 -2
- package/styles/stldocs-variables.css +6 -0
- package/styles/toc.css +41 -34
- package/theme.css +11 -11
- package/tsconfig.json +2 -5
- package/virtual-module.d.ts +47 -7
- package/components/variables.css +0 -135
- package/plugin/cms/client.ts +0 -62
- package/plugin/cms/server.ts +0 -268
- package/plugin/globalJs/ai-dropdown.ts +0 -57
- package/stl-docs/components/APIReferenceAIDropdown.tsx +0 -58
- package/stl-docs/components/content-panel/ProseAIDropdown.tsx +0 -55
- package/stl-docs/components/mintlify-compat/Step.astro +0 -58
- package/stl-docs/components/mintlify-compat/Steps.astro +0 -17
- package/styles/fonts.css +0 -68
- /package/{plugin/assets → assets}/fonts/geist/OFL.txt +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin.woff2 +0 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import Stainless, { APIError } from '@stainless-api/sdk';
|
|
2
|
+
import { mkdir, readdir, readFile, rm, writeFile } from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import crypto from 'crypto';
|
|
5
|
+
|
|
6
|
+
import type * as VirtualManifestModule from 'virtual:stainless-sdk-json-manifest';
|
|
7
|
+
|
|
8
|
+
import { makeAsyncVirtualModPlugin } from '../../shared/virtualModule';
|
|
9
|
+
|
|
10
|
+
import { NormalizedStainlessStarlightConfig, SDKJSONInputs } from '../loadPluginConfig';
|
|
11
|
+
|
|
12
|
+
import { generateSpecFromStrings, SpecWithAuth } from './generateSpec';
|
|
13
|
+
import previewWorkerCode from '../vendor/preview.worker.docs.js?raw';
|
|
14
|
+
import { DocsLanguage } from '@stainless-api/docs-ui/routing';
|
|
15
|
+
import { AstroIntegrationLogger } from 'astro';
|
|
16
|
+
import { bold } from '../../shared/terminalUtils';
|
|
17
|
+
|
|
18
|
+
type VirtualManifestModuleType = typeof VirtualManifestModule;
|
|
19
|
+
|
|
20
|
+
async function cleanupSpecsDirectory({
|
|
21
|
+
directory,
|
|
22
|
+
keep,
|
|
23
|
+
logger,
|
|
24
|
+
}: {
|
|
25
|
+
directory: string;
|
|
26
|
+
keep: string[];
|
|
27
|
+
logger: AstroIntegrationLogger;
|
|
28
|
+
}) {
|
|
29
|
+
const files = await readdir(directory);
|
|
30
|
+
const filesToDelete = files.filter((file) => !keep.includes(file));
|
|
31
|
+
|
|
32
|
+
if (filesToDelete.length > 0) {
|
|
33
|
+
await Promise.all(filesToDelete.map((file) => rm(path.join(directory, file))));
|
|
34
|
+
logger.info(`Removed ${filesToDelete.length} unused SDKJSON file(s)`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type ResolvedSpecInputs = {
|
|
39
|
+
oasStr: string;
|
|
40
|
+
configStr: string;
|
|
41
|
+
versions: Record<DocsLanguage, string> | null;
|
|
42
|
+
project: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
async function versionInfo(project: string, apiKey: string): Promise<Record<DocsLanguage, string>> {
|
|
46
|
+
const data = await fetch(`https://api.stainless.com/api/projects/${project}/package-versions`, {
|
|
47
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const content = await data.text();
|
|
51
|
+
return JSON.parse(content) as Record<DocsLanguage, string>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function redactApiKey(apiKey: string) {
|
|
55
|
+
return apiKey
|
|
56
|
+
.split('')
|
|
57
|
+
.map((char, index) => (index < 10 ? char : '*'))
|
|
58
|
+
.join('');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function resolveFileInputs(
|
|
62
|
+
inputs: Extract<SDKJSONInputs, { kind: 'file_inputs' }>,
|
|
63
|
+
logger: AstroIntegrationLogger,
|
|
64
|
+
) {
|
|
65
|
+
try {
|
|
66
|
+
const oasStr = await readFile(inputs.oasPath, 'utf8');
|
|
67
|
+
const configStr = await readFile(inputs.configPath, 'utf8');
|
|
68
|
+
return {
|
|
69
|
+
inputs,
|
|
70
|
+
resolved: {
|
|
71
|
+
oasStr,
|
|
72
|
+
configStr,
|
|
73
|
+
versions: null,
|
|
74
|
+
project: inputs.project,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
} catch (error) {
|
|
78
|
+
logger.error(bold('Failed to read file inputs:'));
|
|
79
|
+
logger.error(error instanceof Error ? error.message : 'Unknown error');
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function resolveStainlessApiInputs(
|
|
85
|
+
inputs: Extract<SDKJSONInputs, { kind: 'stainless_api_inputs' }>,
|
|
86
|
+
logger: AstroIntegrationLogger,
|
|
87
|
+
) {
|
|
88
|
+
try {
|
|
89
|
+
const client = new Stainless({ apiKey: inputs.apiKey.value });
|
|
90
|
+
const configs = await client.projects.configs.retrieve({
|
|
91
|
+
project: inputs.project,
|
|
92
|
+
branch: inputs.branch,
|
|
93
|
+
include: 'openapi',
|
|
94
|
+
});
|
|
95
|
+
const versions = await versionInfo(inputs.project, inputs.apiKey.value);
|
|
96
|
+
|
|
97
|
+
const configYML = Object.values(configs)[0] as { content: unknown };
|
|
98
|
+
const oasJson = Object.values(configs)[1] as { content: unknown };
|
|
99
|
+
const oasStr = oasJson['content'];
|
|
100
|
+
const configStr = configYML['content'];
|
|
101
|
+
|
|
102
|
+
if (typeof oasStr !== 'string' || typeof configStr !== 'string') {
|
|
103
|
+
throw new Error('Received invalid OAS or config from Stainless');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
inputs,
|
|
108
|
+
resolved: {
|
|
109
|
+
versions,
|
|
110
|
+
oasStr,
|
|
111
|
+
configStr,
|
|
112
|
+
project: inputs.project,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
} catch (error) {
|
|
116
|
+
logger.error(bold('Failed to fetch API reference information from Stainless:'));
|
|
117
|
+
if (error instanceof APIError && error.status >= 400 && error.status < 500) {
|
|
118
|
+
logger.error(`Requested project slug: "${inputs.project}"`);
|
|
119
|
+
logger.error(`API key: "${redactApiKey(inputs.apiKey.value)}"`);
|
|
120
|
+
logger.error(
|
|
121
|
+
`This error can usually be corrected by re-authenticating with the Stainless. Use the CLI (stl auth login) or verify that the Stainless API key you're using can access the project mentioned above.`,
|
|
122
|
+
);
|
|
123
|
+
} else {
|
|
124
|
+
logger.error(error instanceof Error ? error.message : 'Unknown error');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function resolveStringInputs(inputs: Extract<SDKJSONInputs, { kind: 'string_inputs' }>) {
|
|
132
|
+
return {
|
|
133
|
+
inputs,
|
|
134
|
+
resolved: {
|
|
135
|
+
oasStr: inputs.oasStr,
|
|
136
|
+
configStr: inputs.configStr,
|
|
137
|
+
versions: null,
|
|
138
|
+
project: inputs.project,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function resolveSpecInputs(
|
|
144
|
+
inputs: SDKJSONInputs,
|
|
145
|
+
logger: AstroIntegrationLogger,
|
|
146
|
+
): Promise<{ inputs: SDKJSONInputs; resolved: ResolvedSpecInputs }> {
|
|
147
|
+
if (inputs.kind === 'file_inputs') return resolveFileInputs(inputs, logger);
|
|
148
|
+
if (inputs.kind === 'stainless_api_inputs') return resolveStainlessApiInputs(inputs, logger);
|
|
149
|
+
if (inputs.kind === 'string_inputs') return resolveStringInputs(inputs);
|
|
150
|
+
throw new Error(`Unexpected spec inputs: ${JSON.stringify(inputs)}`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function hashResolvedSpecInputs(resolved: ResolvedSpecInputs): string {
|
|
154
|
+
return crypto
|
|
155
|
+
.createHash('sha256')
|
|
156
|
+
.update(resolved.oasStr + resolved.configStr + JSON.stringify(resolved.versions) + previewWorkerCode)
|
|
157
|
+
.digest('hex')
|
|
158
|
+
.slice(0, 10);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function readCachedSpec(specPath: string): Promise<SpecWithAuth | null> {
|
|
162
|
+
try {
|
|
163
|
+
const cachedSpec = await readFile(specPath, 'utf8');
|
|
164
|
+
return JSON.parse(cachedSpec) as SpecWithAuth;
|
|
165
|
+
} catch {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function fetchOrGenerateSpec(specPath: string, inputs: ResolvedSpecInputs) {
|
|
171
|
+
const cachedSpec = await readCachedSpec(specPath);
|
|
172
|
+
if (cachedSpec) {
|
|
173
|
+
return {
|
|
174
|
+
result: 'exists' as const,
|
|
175
|
+
specPath,
|
|
176
|
+
spec: cachedSpec,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const sdkJson = await generateSpecFromStrings({
|
|
181
|
+
oasStr: inputs.oasStr,
|
|
182
|
+
configStr: inputs.configStr,
|
|
183
|
+
projectName: inputs.project,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
if (inputs.versions) {
|
|
187
|
+
for (const [lang, version] of Object.entries(inputs.versions)) {
|
|
188
|
+
const meta = sdkJson.data.metadata[lang as DocsLanguage];
|
|
189
|
+
if (meta?.version) meta.version = version;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
await writeFile(specPath, JSON.stringify(sdkJson), 'utf8');
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
result: 'generated' as const,
|
|
197
|
+
spec: sdkJson,
|
|
198
|
+
specPath,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Runs once in the build process */
|
|
203
|
+
export async function startSpecLoader(
|
|
204
|
+
pluginConfig: NormalizedStainlessStarlightConfig,
|
|
205
|
+
logger: AstroIntegrationLogger,
|
|
206
|
+
codegenDir: URL,
|
|
207
|
+
) {
|
|
208
|
+
const specsDirectory = path.join(codegenDir.pathname, 'specs');
|
|
209
|
+
await mkdir(specsDirectory, { recursive: true });
|
|
210
|
+
// TODO: can this promise also be deferred until after this function resolves? can this whole
|
|
211
|
+
// function return synchronously?
|
|
212
|
+
// TODO: arena to remember the conceptual reason why he didn’t want this
|
|
213
|
+
const resolvedSpecInputs = await resolveSpecInputs(pluginConfig.specInputs, logger);
|
|
214
|
+
|
|
215
|
+
const inputsHash = hashResolvedSpecInputs(resolvedSpecInputs.resolved);
|
|
216
|
+
const specFileName = `${inputsHash}.json`;
|
|
217
|
+
const specPath = path.join(specsDirectory, specFileName);
|
|
218
|
+
|
|
219
|
+
const specPromise = fetchOrGenerateSpec(specPath, resolvedSpecInputs.resolved);
|
|
220
|
+
|
|
221
|
+
// don't need to await, it's just cleanup
|
|
222
|
+
cleanupSpecsDirectory({ directory: specsDirectory, keep: [specFileName], logger });
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
specPromise,
|
|
226
|
+
// this virtual module only resolves when the spec is generated
|
|
227
|
+
// this prevents the SSR module from trying to read the spec file before it's generated
|
|
228
|
+
vitePlugin: makeAsyncVirtualModPlugin<VirtualManifestModuleType>(
|
|
229
|
+
'virtual:stainless-sdk-json-manifest',
|
|
230
|
+
async () => {
|
|
231
|
+
const specResult = await specPromise;
|
|
232
|
+
return { specPath: specResult.specPath };
|
|
233
|
+
},
|
|
234
|
+
),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export type SpecLoader = Awaited<ReturnType<typeof startSpecLoader>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Worker from 'web-worker';
|
|
2
|
-
import { Languages, type DocsLanguage } from '@stainless-api/docs-ui/
|
|
3
|
-
import type * as SDKJSON from '
|
|
2
|
+
import { Languages, type DocsLanguage } from '@stainless-api/docs-ui/routing';
|
|
3
|
+
import type * as SDKJSON from '@stainless/sdk-json';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { dirname, resolve } from 'node:path';
|
|
6
6
|
import fs from 'fs/promises';
|
|
@@ -12,7 +12,81 @@ const __dirname = dirname(__filename);
|
|
|
12
12
|
const workerPath = resolve(__dirname, '..', 'vendor', 'preview.worker.docs.js');
|
|
13
13
|
|
|
14
14
|
type OpenAPIDocument = Record<string, any>;
|
|
15
|
-
type ParsedConfig =
|
|
15
|
+
export type ParsedConfig = {
|
|
16
|
+
docs:
|
|
17
|
+
| {
|
|
18
|
+
title?: string | undefined;
|
|
19
|
+
favicon?: string | undefined;
|
|
20
|
+
logo_icon?: string | undefined;
|
|
21
|
+
search?:
|
|
22
|
+
| {
|
|
23
|
+
algolia?:
|
|
24
|
+
| {
|
|
25
|
+
app_id: string;
|
|
26
|
+
index_name: string;
|
|
27
|
+
search_key: string;
|
|
28
|
+
}
|
|
29
|
+
| undefined;
|
|
30
|
+
}
|
|
31
|
+
| undefined;
|
|
32
|
+
description?: string | undefined;
|
|
33
|
+
languages?:
|
|
34
|
+
| ('node' | 'typescript' | 'python' | 'java' | 'kotlin' | 'go' | 'ruby' | 'terraform' | 'http')[]
|
|
35
|
+
| undefined;
|
|
36
|
+
snippets?:
|
|
37
|
+
| {
|
|
38
|
+
exclude_languages?: string[] | undefined;
|
|
39
|
+
}
|
|
40
|
+
| undefined;
|
|
41
|
+
show_security?: boolean | undefined;
|
|
42
|
+
show_readme?: boolean | undefined;
|
|
43
|
+
base_path?: string | undefined;
|
|
44
|
+
navigation?:
|
|
45
|
+
| {
|
|
46
|
+
menubar?:
|
|
47
|
+
| {
|
|
48
|
+
title: string;
|
|
49
|
+
icon?: string;
|
|
50
|
+
variant?: string;
|
|
51
|
+
href?: string | undefined;
|
|
52
|
+
page?: string | undefined;
|
|
53
|
+
}[]
|
|
54
|
+
| undefined;
|
|
55
|
+
sidebar?:
|
|
56
|
+
| {
|
|
57
|
+
title: string;
|
|
58
|
+
icon?: string;
|
|
59
|
+
variant?: string;
|
|
60
|
+
href?: string | undefined;
|
|
61
|
+
page?: string | undefined;
|
|
62
|
+
}[]
|
|
63
|
+
| undefined;
|
|
64
|
+
}
|
|
65
|
+
| undefined;
|
|
66
|
+
pages?: unknown;
|
|
67
|
+
resources?: unknown[] | undefined;
|
|
68
|
+
}
|
|
69
|
+
| undefined;
|
|
70
|
+
targets: Record<string, { skip?: boolean }>;
|
|
71
|
+
client_settings: {
|
|
72
|
+
opts: {
|
|
73
|
+
[x: string]: {
|
|
74
|
+
type: 'string' | 'number' | 'boolean' | 'null' | 'integer';
|
|
75
|
+
nullable: boolean;
|
|
76
|
+
description?: string | undefined;
|
|
77
|
+
example?: unknown;
|
|
78
|
+
default?: unknown;
|
|
79
|
+
read_env?: string | undefined;
|
|
80
|
+
auth?:
|
|
81
|
+
| {
|
|
82
|
+
security_scheme: string;
|
|
83
|
+
role?: 'value' | 'password' | 'username' | 'client_id' | 'client_secret' | undefined;
|
|
84
|
+
}
|
|
85
|
+
| undefined;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
16
90
|
|
|
17
91
|
function runJob({ type, signal, data }: { type: string; signal?: AbortSignal; data: any }) {
|
|
18
92
|
const stainlessWorker = new Worker(workerPath, {
|
|
@@ -22,6 +96,7 @@ function runJob({ type, signal, data }: { type: string; signal?: AbortSignal; da
|
|
|
22
96
|
|
|
23
97
|
return new Promise<any>((resolve, reject) => {
|
|
24
98
|
stainlessWorker.addEventListener('error', (e) => {
|
|
99
|
+
e.preventDefault();
|
|
25
100
|
reject(e);
|
|
26
101
|
});
|
|
27
102
|
|
|
@@ -85,10 +160,12 @@ export async function createSDKJSON({
|
|
|
85
160
|
oas,
|
|
86
161
|
config,
|
|
87
162
|
languages,
|
|
163
|
+
projectName,
|
|
88
164
|
}: {
|
|
89
165
|
oas: OpenAPIDocument;
|
|
90
166
|
config: ParsedConfig;
|
|
91
167
|
languages: DocsLanguage[];
|
|
168
|
+
projectName: string;
|
|
92
169
|
}) {
|
|
93
170
|
const templatePath = resolve(__dirname, '../vendor/templates');
|
|
94
171
|
const readmeLoader = await Promise.all(
|
|
@@ -98,7 +175,7 @@ export async function createSDKJSON({
|
|
|
98
175
|
try {
|
|
99
176
|
const content = await fs.readFile(mdfile);
|
|
100
177
|
return [language, content.toString()];
|
|
101
|
-
} catch
|
|
178
|
+
} catch {
|
|
102
179
|
return [language, null];
|
|
103
180
|
}
|
|
104
181
|
}),
|
|
@@ -113,7 +190,7 @@ export async function createSDKJSON({
|
|
|
113
190
|
config,
|
|
114
191
|
languages,
|
|
115
192
|
transform: false,
|
|
116
|
-
projectName
|
|
193
|
+
projectName,
|
|
117
194
|
readmeTemplates,
|
|
118
195
|
},
|
|
119
196
|
});
|