oapiex 0.3.3 → 0.3.5
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/bin/cli.mjs +3 -3
- package/dist/index.cjs +18 -22
- package/dist/index.d.ts +56 -2
- package/dist/index.mjs +18 -22
- package/package.json +2 -3
package/bin/cli.mjs
CHANGED
|
@@ -176,9 +176,9 @@ import{JSDOM as e}from"jsdom";import{Window as t}from"happy-dom";import n from"a
|
|
|
176
176
|
{--b|base-url? : Base URL used to resolve sidebar links when crawling from a local file}
|
|
177
177
|
`;description=`Generate artifacts such as SDK packages from documentation sources or parsed TypeScript outputs`;async handle(){let e=this.app.getConfig(),t=String(this.argument(`artifact`,``)).trim().toLowerCase(),n=String(this.argument(`source`,``)).trim(),i=String(this.option(`browser`,e.browser)).trim().toLowerCase(),a=String(this.option(`timeout`,``)).trim(),o=this.option(`crawl`),s=String(this.option(`baseUrl`,``)).trim()||null,c=await this.resolveOutputDirectory(n),l=this.spinner(`Generating ${t} artifact...`).start(),u=!1;try{let d=Date.now();if(!j(i))throw Error(`Unsupported browser: ${i}`);if(t!==`sdk`)throw Error(`Unsupported artifact: ${t}`);if(!n)throw Error(`The sdk artifact requires a source argument`);if(!this.isTypeScriptArtifactSource(n)&&!j(i))throw Error(`Unsupported browser: ${i}`);let f=this.resolveTimeoutOverride(a,e.requestTimeout),p=this.parseNamespaceStrategy(this.option(`namespaceStrategy`,`smart`)),m=this.parseMethodStrategy(this.option(`methodStrategy`,`smart`)),h=this.parseOutputMode(this.option(`outputMode`,`both`)),g=this.parseSignatureStyle(this.option(`signatureStyle`,`grouped`)),_=String(this.option(`rootTypeName`,`ExtractedApiDocument`)).trim()||`ExtractedApiDocument`;this.app.configure({browser:i,requestTimeout:f}),!this.isTypeScriptArtifactSource(n)&&o&&(await D(this.app.getConfig()),u=!0);let v=await this.resolveSdkSource({source:n,crawl:o,baseUrl:s,rootTypeName:_,namespaceStrategy:p,methodStrategy:m}),y=this.resolvePackageName(c),b=new Ze().generate(v.document,{outputMode:h,signatureStyle:g,rootTypeName:_,namespaceStrategy:p,methodStrategy:m,schemaModule:v.schemaModule,packageName:String(this.option(`name`,``)).trim()||y});await this.writePackageFiles(c,b);let x=Date.now()-d;r.twoColumnDetail(r.log([[`Generated`,`green`],[`${x/1e3}s`,`gray`]],` `,!1),c.replace(process.cwd(),`.`)),l.succeed(`Artifact generation completed`)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;l.fail(`Failed to generate artifact: ${t}`),process.exitCode=1}finally{u&&await O()}}async resolveSdkSource(e){if(this.isTypeScriptArtifactSource(e.source))return this.loadSdkSourceFromTypeScriptArtifact(e.source);let t=P(await this.app.loadHtmlSource(e.source,!0)),n=e.crawl?await this.app.crawlReadmeOperations(e.source,t,e.baseUrl):t,r=this.buildOpenApiPayload(n);return{document:r,schemaModule:await l.format(Z.generateModule(r,e.rootTypeName,{namespaceStrategy:e.namespaceStrategy,methodStrategy:e.methodStrategy}),{parser:`typescript`,semi:!1,singleQuote:!0})}}async loadSdkSourceFromTypeScriptArtifact(e){let t=i.resolve(process.cwd(),e),n=await a.readFile(t,`utf8`),r=await import(`${u(t).href}?t=${Date.now()}`),o=r.default??Object.values(r).find(e=>this.isOpenApiDocumentLike(e));if(!this.isOpenApiDocumentLike(o))throw Error(`The provided TypeScript source does not export an OpenAPI document`);return{document:o,schemaModule:n}}buildOpenApiPayload(e){return`operations`in e?$.createDocument(e.operations,`Extracted API`,`0.0.0`):$.createDocument([e],`Extracted API`,`0.0.0`)}resolveTimeoutOverride(e,t){if(!e)return t;let n=Number(e);if(!Number.isFinite(n)||n<=0)throw Error(`Invalid timeout override: ${e}`);return n}async resolveOutputDirectory(e,t){t??=String(this.option(`dir`,``)).trim();let n=t?i.resolve(process.cwd(),t):Q.buildArtifactDirectory(process.cwd(),e,`sdk`);if(d(n)&&f(n).length>0)switch(await this.choice(`Output directory (${t}) already exists and is not empty, what would you like to do?`,[{name:`Overwrite`,value:`overwrite`},{name:`Try to merge`,value:`merge`},{name:`Choose a different directory`,value:`choose`},{name:`Cancel`,value:`cancel`}])){case`overwrite`:await a.rm(n,{recursive:!0,force:!0});break;case`choose`:{let n=await this.ask(`Please enter a new output directory (relative to current directory):`,t);return this.resolveOutputDirectory(e,n)}case`cancel`:return this.info(`Operation cancelled by user`),process.exit(0);default:break}return n}resolvePackageName(e){return String(this.option(`name`,``)).trim()||i.basename(e).replace(/[^a-zA-Z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)||`generated-sdk`}parseOutputMode(e){let t=String(e??`both`).trim().toLowerCase();if(t===`runtime`||t===`classes`||t===`both`)return t;throw Error(`Unsupported sdk output mode: ${t}`)}parseSignatureStyle(e){let t=String(e??`grouped`).trim().toLowerCase();if(t===`flat`||t===`grouped`)return t;throw Error(`Unsupported signature style: ${t}`)}parseNamespaceStrategy(e){let t=String(e??`smart`).trim().toLowerCase();if(t===`smart`||t===`scoped`)return t;throw Error(`Unsupported namespace strategy: ${t}`)}parseMethodStrategy(e){let t=String(e??`smart`).trim().toLowerCase();if(t===`smart`||t===`operation-id`)return t;throw Error(`Unsupported method strategy: ${t}`)}isTypeScriptArtifactSource(e){return/\.(?:[cm]?ts|[cm]?js)$/i.test(e)}isOpenApiDocumentLike(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e,n=t.info;return t.openapi===`3.1.0`&&typeof n==`object`&&!!n&&!Array.isArray(n)&&typeof n.title==`string`&&typeof n.version==`string`&&typeof t.paths==`object`&&t.paths!==null&&!Array.isArray(t.paths)}async writePackageFiles(e,t){await Promise.all(Object.entries(t).map(async([t,n])=>{let r=i.join(e,t);await a.mkdir(i.dirname(r),{recursive:!0}),await a.writeFile(r,n,`utf8`)}))}};const $e=p(import.meta.url);var et=class extends s{signature=`init
|
|
178
178
|
{--f|force : Overwrite existing config}
|
|
179
|
-
{--
|
|
180
|
-
`;description=`Generate a default oapiex.config.ts in the current directory`;async handle(){let e=process.cwd(),t=i.join(e,`oapiex.config.js`),n=this.option(`force`,!1),r=this.option(`
|
|
181
|
-
`)}buildSdkConfigTemplate(){return[`
|
|
179
|
+
{--S|sdk-kit : Also include default SDK config values.}
|
|
180
|
+
`;description=`Generate a default oapiex.config.ts in the current directory`;async handle(){let e=process.cwd(),t=i.join(e,`oapiex.config.js`),n=this.option(`force`,!1),r=this.option(`sdkKit`,!1),o=this.buildConfigTemplate(r);try{await a.access(t),n||(this.error(`Config file already exists at ${t}. Use --force to overwrite.`),process.exit(1))}catch{}await a.writeFile(t,o,`utf8`),this.line(`Created ${t} `)}buildConfigTemplate(e=!1){let t=g;return[`import { defineConfig } from '${$e.includes(`node_modules`)?`oapiex`:`./src/Manager`}'`,``,`/**`,` * See https://toneflix.github.io/oapiex/configuration for docs`,` */`,`export default defineConfig({`,` outputFormat: '${t.outputFormat}',`,` outputShape: '${t.outputShape}',`,` browser: '${t.browser}',`,` requestTimeout: ${t.requestTimeout},`,` maxRedirects: ${t.maxRedirects},`,` userAgent: '${t.userAgent}',`,` retryCount: ${t.retryCount},`,` retryDelay: ${t.retryDelay},`,e?this.buildSdkConfigTemplate():void 0,`})`].filter(Boolean).join(`
|
|
181
|
+
`)}buildSdkConfigTemplate(){return[` sdkKit: {`,` clientId: 'your-client-id',`,` clientSecret: 'your-client-secret',`,` encryptionKey: 'your-encryption-key',`,` environment: 'sandbox',`,` urls: {`,` live: 'https://live.oapiex.com',`,` sandbox: 'https://sandbox.oapiex.com',`,` },`,` debugLevel: 0,`,` },`].join(`
|
|
182
182
|
`)}},tt=class extends s{signature=`parse
|
|
183
183
|
{source : Local HTML file path or remote URL}
|
|
184
184
|
{--O|output=pretty : Output format [pretty,json,js,ts]}
|
package/dist/index.cjs
CHANGED
|
@@ -3707,19 +3707,15 @@ const __filename$1 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filen
|
|
|
3707
3707
|
var InitCommand = class extends _h3ravel_musket.Command {
|
|
3708
3708
|
signature = `init
|
|
3709
3709
|
{--f|force : Overwrite existing config}
|
|
3710
|
-
{--
|
|
3710
|
+
{--S|sdk-kit : Also include default SDK config values.}
|
|
3711
3711
|
`;
|
|
3712
3712
|
description = "Generate a default oapiex.config.ts in the current directory";
|
|
3713
3713
|
async handle() {
|
|
3714
3714
|
const cwd = process.cwd();
|
|
3715
3715
|
const configPath = node_path.default.join(cwd, "oapiex.config.js");
|
|
3716
3716
|
const force = this.option("force", false);
|
|
3717
|
-
const
|
|
3718
|
-
const configTemplate =
|
|
3719
|
-
base: this.buildConfigTemplate(),
|
|
3720
|
-
sdk: this.buildSdkConfigTemplate()
|
|
3721
|
-
};
|
|
3722
|
-
if (!["base", "sdk"].includes(pkg)) return void this.error(`Invalid package option: ${pkg}`);
|
|
3717
|
+
const sdkKit = this.option("sdkKit", false);
|
|
3718
|
+
const configTemplate = this.buildConfigTemplate(sdkKit);
|
|
3723
3719
|
try {
|
|
3724
3720
|
await node_fs_promises.default.access(configPath);
|
|
3725
3721
|
if (!force) {
|
|
@@ -3727,10 +3723,10 @@ var InitCommand = class extends _h3ravel_musket.Command {
|
|
|
3727
3723
|
process.exit(1);
|
|
3728
3724
|
}
|
|
3729
3725
|
} catch {}
|
|
3730
|
-
await node_fs_promises.default.writeFile(configPath, configTemplate
|
|
3726
|
+
await node_fs_promises.default.writeFile(configPath, configTemplate, "utf8");
|
|
3731
3727
|
this.line(`Created ${configPath} `);
|
|
3732
3728
|
}
|
|
3733
|
-
buildConfigTemplate() {
|
|
3729
|
+
buildConfigTemplate(addSdkConfig = false) {
|
|
3734
3730
|
const def = defaultConfig;
|
|
3735
3731
|
return [
|
|
3736
3732
|
`import { defineConfig } from '${__filename$1.includes("node_modules") ? "oapiex" : "./src/Manager"}'`,
|
|
@@ -3747,23 +3743,23 @@ var InitCommand = class extends _h3ravel_musket.Command {
|
|
|
3747
3743
|
` userAgent: '${def.userAgent}',`,
|
|
3748
3744
|
` retryCount: ${def.retryCount},`,
|
|
3749
3745
|
` retryDelay: ${def.retryDelay},`,
|
|
3746
|
+
addSdkConfig ? this.buildSdkConfigTemplate() : void 0,
|
|
3750
3747
|
"})"
|
|
3751
|
-
].join("\n");
|
|
3748
|
+
].filter(Boolean).join("\n");
|
|
3752
3749
|
}
|
|
3753
3750
|
buildSdkConfigTemplate() {
|
|
3754
3751
|
return [
|
|
3755
|
-
"
|
|
3756
|
-
"",
|
|
3757
|
-
"
|
|
3758
|
-
"
|
|
3759
|
-
"
|
|
3760
|
-
"
|
|
3761
|
-
"
|
|
3762
|
-
"
|
|
3763
|
-
"
|
|
3764
|
-
"
|
|
3765
|
-
" },"
|
|
3766
|
-
"})"
|
|
3752
|
+
" sdkKit: {",
|
|
3753
|
+
" clientId: 'your-client-id',",
|
|
3754
|
+
" clientSecret: 'your-client-secret',",
|
|
3755
|
+
" encryptionKey: 'your-encryption-key',",
|
|
3756
|
+
" environment: 'sandbox',",
|
|
3757
|
+
" urls: {",
|
|
3758
|
+
" live: 'https://live.oapiex.com',",
|
|
3759
|
+
" sandbox: 'https://sandbox.oapiex.com',",
|
|
3760
|
+
" },",
|
|
3761
|
+
" debugLevel: 0,",
|
|
3762
|
+
" },"
|
|
3767
3763
|
].join("\n");
|
|
3768
3764
|
}
|
|
3769
3765
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,58 @@ import { Browser, Page } from "puppeteer";
|
|
|
4
4
|
|
|
5
5
|
//#region src/types/app.d.ts
|
|
6
6
|
type BrowserName = 'axios' | 'happy-dom' | 'jsdom' | 'puppeteer';
|
|
7
|
+
type SdkKitEnvironment = 'sandbox' | 'live';
|
|
8
|
+
type SdkKitDebugLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
type SdkKitHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
10
|
+
interface SdkKitUrls {
|
|
11
|
+
live?: string;
|
|
12
|
+
sandbox?: string;
|
|
13
|
+
}
|
|
14
|
+
interface SdkKitBearerAuthConfig {
|
|
15
|
+
type: 'bearer';
|
|
16
|
+
token: string;
|
|
17
|
+
prefix?: string;
|
|
18
|
+
}
|
|
19
|
+
interface SdkKitOAuth2AuthConfig {
|
|
20
|
+
type: 'oauth2';
|
|
21
|
+
accessToken: string;
|
|
22
|
+
tokenType?: string;
|
|
23
|
+
}
|
|
24
|
+
interface SdkKitBasicAuthConfig {
|
|
25
|
+
type: 'basic';
|
|
26
|
+
username: string;
|
|
27
|
+
password: string;
|
|
28
|
+
}
|
|
29
|
+
interface SdkKitApiKeyAuthConfig {
|
|
30
|
+
type: 'apiKey';
|
|
31
|
+
name: string;
|
|
32
|
+
value: string;
|
|
33
|
+
in?: 'header' | 'query' | 'cookie';
|
|
34
|
+
prefix?: string;
|
|
35
|
+
}
|
|
36
|
+
interface SdkKitAuthRequestConfig {
|
|
37
|
+
url: string;
|
|
38
|
+
method: SdkKitHttpMethod;
|
|
39
|
+
headers: Record<string, string>;
|
|
40
|
+
params: Record<string, unknown>;
|
|
41
|
+
body?: unknown;
|
|
42
|
+
}
|
|
43
|
+
interface SdkKitCustomAuthConfig {
|
|
44
|
+
type: 'custom';
|
|
45
|
+
apply: (request: SdkKitAuthRequestConfig) => SdkKitAuthRequestConfig | Promise<SdkKitAuthRequestConfig>;
|
|
46
|
+
}
|
|
47
|
+
type SdkKitAuthConfig = SdkKitBearerAuthConfig | SdkKitOAuth2AuthConfig | SdkKitBasicAuthConfig | SdkKitApiKeyAuthConfig | SdkKitCustomAuthConfig;
|
|
48
|
+
interface SdkKitConfig {
|
|
49
|
+
clientId?: string;
|
|
50
|
+
clientSecret?: string;
|
|
51
|
+
encryptionKey?: string;
|
|
52
|
+
environment?: SdkKitEnvironment;
|
|
53
|
+
urls?: SdkKitUrls;
|
|
54
|
+
headers?: Record<string, string>;
|
|
55
|
+
timeout?: number;
|
|
56
|
+
auth?: SdkKitAuthConfig | SdkKitAuthConfig[];
|
|
57
|
+
debugLevel?: SdkKitDebugLevel;
|
|
58
|
+
}
|
|
7
59
|
interface UserConfig {
|
|
8
60
|
outputFormat: 'pretty' | 'json' | 'js' | 'ts';
|
|
9
61
|
outputShape: 'raw' | 'openapi';
|
|
@@ -18,6 +70,8 @@ interface UserConfig {
|
|
|
18
70
|
headless?: boolean;
|
|
19
71
|
args?: string[];
|
|
20
72
|
};
|
|
73
|
+
sdkKit?: SdkKitConfig;
|
|
74
|
+
sdk?: SdkKitConfig;
|
|
21
75
|
}
|
|
22
76
|
//#endregion
|
|
23
77
|
//#region src/types/base.d.ts
|
|
@@ -318,7 +372,7 @@ declare class InitCommand extends Command {
|
|
|
318
372
|
protected signature: string;
|
|
319
373
|
protected description: string;
|
|
320
374
|
handle(): Promise<void>;
|
|
321
|
-
buildConfigTemplate(): string;
|
|
375
|
+
buildConfigTemplate(addSdkConfig?: boolean): string;
|
|
322
376
|
buildSdkConfigTemplate(): string;
|
|
323
377
|
}
|
|
324
378
|
//#endregion
|
|
@@ -687,4 +741,4 @@ interface ReadmeCrawledOperation extends ReadmeOperation {
|
|
|
687
741
|
}
|
|
688
742
|
declare const resolveReadmeSidebarUrls: (operation: Pick<ReadmeOperation, "sidebarLinks">, baseUrl: string) => string[];
|
|
689
743
|
//#endregion
|
|
690
|
-
export { Application, AttributeQueryNode, AttributedNode, BrowserName, Declaration, GenerateCommand, GeneratorContext, InitCommand, InterfaceAliasDeclaration, InterfaceDeclaration, JsonLike, JsonRepair, OpenApiDocumentLike, OpenApiMediaType, OpenApiOauthFlowLike, OpenApiOperationLike, OpenApiParameterLike, OpenApiResponse, OpenApiSchema, OpenApiSecurityRequirementLike, OpenApiSecuritySchemeLike, OpenApiTransformer, OperationTypeRefs, OutputGenerator, ParseCommand, PayloadSchemaCandidate, QueryableNode, ReadmeCodeSnippet, ReadmeCrawledOperation, ReadmeNormalizedRequestExample, ReadmeOperation, ReadmeParameter, ReadmeResponseBody, ReadmeResponseSchema, ReadmeSidebarLink, SdkGroupManifest, SdkManifest, SdkMethodNamingStrategy, SdkNamespaceNamingStrategy, SdkNamingStrategyOptions, SdkOperationManifest, SdkPackageGenerator, SdkPackageGeneratorOptions, SdkParameterManifest, SdkSecurityRequirementManifest, SdkSecurityRequirementSchemeManifest, SdkSecuritySchemeManifest, SemanticModel, ShapeAliasDeclaration, ShapeNode, ShapeProperty, TextNodeLike, TypeReferenceAliasDeclaration, TypeScriptGenerator, UserConfig, browser, buildOperationUrl, closeActiveBrowserResources, defaultConfig, defineConfig, endBrowserSession, escapeSelector, extractBalancedSegment, extractButtonText, extractCodeMirrorText, extractCodeSnippets, extractFetchBody, extractFetchHeaders, extractObjectPropertyValue, extractOperationDescription, extractOperationParametersFromOpenApi, extractParameterDescription, extractReadmeOperationFromHtml, extractReadmeOperationFromSsrProps, extractRequestCodeSnippets, extractRequestParams, extractRequestParamsFromOpenApi, extractRequestSnippetLabel, extractResponseBodies, extractResponseBodiesFromOpenApi, extractResponseContentTypes, extractResponseLabels, extractResponseSchemas, extractResponseSchemasFromOpenApi, extractSidebarLinkLabel, extractSidebarLinks, extractStablePageHtml, extractStringLiteralValue, findParameterRoot, flattenOpenApiSchemaProperties, getBrowserSession, globalConfig, inferParameterLocation, inferParameterLocationFromText, inferParameterPath, inferParameterType, isRecord, isRequiredParameter, isSupportedBrowser, loadUserConfig, mergeReadmeOperations, mergeSsrPropsIntoRenderedHtml, normalizeCurlSnippet, normalizeFetchSnippet, normalizeRequestCodeSnippet, normalizeResponseBody, normalizeStructuredRequestBody, parseLooseStructuredValue, readInputValue, readText, readTexts, registerActiveBrowserCloser, resolveConfig, resolveOpenApiMediaExample, resolveParameterInput, resolveReadmeSidebarUrls, resolveSsrOperation, startBrowserSession, supportedBrowsers, transformer };
|
|
744
|
+
export { Application, AttributeQueryNode, AttributedNode, BrowserName, Declaration, GenerateCommand, GeneratorContext, InitCommand, InterfaceAliasDeclaration, InterfaceDeclaration, JsonLike, JsonRepair, OpenApiDocumentLike, OpenApiMediaType, OpenApiOauthFlowLike, OpenApiOperationLike, OpenApiParameterLike, OpenApiResponse, OpenApiSchema, OpenApiSecurityRequirementLike, OpenApiSecuritySchemeLike, OpenApiTransformer, OperationTypeRefs, OutputGenerator, ParseCommand, PayloadSchemaCandidate, QueryableNode, ReadmeCodeSnippet, ReadmeCrawledOperation, ReadmeNormalizedRequestExample, ReadmeOperation, ReadmeParameter, ReadmeResponseBody, ReadmeResponseSchema, ReadmeSidebarLink, SdkGroupManifest, SdkKitApiKeyAuthConfig, SdkKitAuthConfig, SdkKitAuthRequestConfig, SdkKitBasicAuthConfig, SdkKitBearerAuthConfig, SdkKitConfig, SdkKitCustomAuthConfig, SdkKitDebugLevel, SdkKitEnvironment, SdkKitHttpMethod, SdkKitOAuth2AuthConfig, SdkKitUrls, SdkManifest, SdkMethodNamingStrategy, SdkNamespaceNamingStrategy, SdkNamingStrategyOptions, SdkOperationManifest, SdkPackageGenerator, SdkPackageGeneratorOptions, SdkParameterManifest, SdkSecurityRequirementManifest, SdkSecurityRequirementSchemeManifest, SdkSecuritySchemeManifest, SemanticModel, ShapeAliasDeclaration, ShapeNode, ShapeProperty, TextNodeLike, TypeReferenceAliasDeclaration, TypeScriptGenerator, UserConfig, browser, buildOperationUrl, closeActiveBrowserResources, defaultConfig, defineConfig, endBrowserSession, escapeSelector, extractBalancedSegment, extractButtonText, extractCodeMirrorText, extractCodeSnippets, extractFetchBody, extractFetchHeaders, extractObjectPropertyValue, extractOperationDescription, extractOperationParametersFromOpenApi, extractParameterDescription, extractReadmeOperationFromHtml, extractReadmeOperationFromSsrProps, extractRequestCodeSnippets, extractRequestParams, extractRequestParamsFromOpenApi, extractRequestSnippetLabel, extractResponseBodies, extractResponseBodiesFromOpenApi, extractResponseContentTypes, extractResponseLabels, extractResponseSchemas, extractResponseSchemasFromOpenApi, extractSidebarLinkLabel, extractSidebarLinks, extractStablePageHtml, extractStringLiteralValue, findParameterRoot, flattenOpenApiSchemaProperties, getBrowserSession, globalConfig, inferParameterLocation, inferParameterLocationFromText, inferParameterPath, inferParameterType, isRecord, isRequiredParameter, isSupportedBrowser, loadUserConfig, mergeReadmeOperations, mergeSsrPropsIntoRenderedHtml, normalizeCurlSnippet, normalizeFetchSnippet, normalizeRequestCodeSnippet, normalizeResponseBody, normalizeStructuredRequestBody, parseLooseStructuredValue, readInputValue, readText, readTexts, registerActiveBrowserCloser, resolveConfig, resolveOpenApiMediaExample, resolveParameterInput, resolveReadmeSidebarUrls, resolveSsrOperation, startBrowserSession, supportedBrowsers, transformer };
|
package/dist/index.mjs
CHANGED
|
@@ -3675,19 +3675,15 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
3675
3675
|
var InitCommand = class extends Command {
|
|
3676
3676
|
signature = `init
|
|
3677
3677
|
{--f|force : Overwrite existing config}
|
|
3678
|
-
{--
|
|
3678
|
+
{--S|sdk-kit : Also include default SDK config values.}
|
|
3679
3679
|
`;
|
|
3680
3680
|
description = "Generate a default oapiex.config.ts in the current directory";
|
|
3681
3681
|
async handle() {
|
|
3682
3682
|
const cwd = process.cwd();
|
|
3683
3683
|
const configPath = path.join(cwd, "oapiex.config.js");
|
|
3684
3684
|
const force = this.option("force", false);
|
|
3685
|
-
const
|
|
3686
|
-
const configTemplate =
|
|
3687
|
-
base: this.buildConfigTemplate(),
|
|
3688
|
-
sdk: this.buildSdkConfigTemplate()
|
|
3689
|
-
};
|
|
3690
|
-
if (!["base", "sdk"].includes(pkg)) return void this.error(`Invalid package option: ${pkg}`);
|
|
3685
|
+
const sdkKit = this.option("sdkKit", false);
|
|
3686
|
+
const configTemplate = this.buildConfigTemplate(sdkKit);
|
|
3691
3687
|
try {
|
|
3692
3688
|
await fs.access(configPath);
|
|
3693
3689
|
if (!force) {
|
|
@@ -3695,10 +3691,10 @@ var InitCommand = class extends Command {
|
|
|
3695
3691
|
process.exit(1);
|
|
3696
3692
|
}
|
|
3697
3693
|
} catch {}
|
|
3698
|
-
await fs.writeFile(configPath, configTemplate
|
|
3694
|
+
await fs.writeFile(configPath, configTemplate, "utf8");
|
|
3699
3695
|
this.line(`Created ${configPath} `);
|
|
3700
3696
|
}
|
|
3701
|
-
buildConfigTemplate() {
|
|
3697
|
+
buildConfigTemplate(addSdkConfig = false) {
|
|
3702
3698
|
const def = defaultConfig;
|
|
3703
3699
|
return [
|
|
3704
3700
|
`import { defineConfig } from '${__filename.includes("node_modules") ? "oapiex" : "./src/Manager"}'`,
|
|
@@ -3715,23 +3711,23 @@ var InitCommand = class extends Command {
|
|
|
3715
3711
|
` userAgent: '${def.userAgent}',`,
|
|
3716
3712
|
` retryCount: ${def.retryCount},`,
|
|
3717
3713
|
` retryDelay: ${def.retryDelay},`,
|
|
3714
|
+
addSdkConfig ? this.buildSdkConfigTemplate() : void 0,
|
|
3718
3715
|
"})"
|
|
3719
|
-
].join("\n");
|
|
3716
|
+
].filter(Boolean).join("\n");
|
|
3720
3717
|
}
|
|
3721
3718
|
buildSdkConfigTemplate() {
|
|
3722
3719
|
return [
|
|
3723
|
-
"
|
|
3724
|
-
"",
|
|
3725
|
-
"
|
|
3726
|
-
"
|
|
3727
|
-
"
|
|
3728
|
-
"
|
|
3729
|
-
"
|
|
3730
|
-
"
|
|
3731
|
-
"
|
|
3732
|
-
"
|
|
3733
|
-
" },"
|
|
3734
|
-
"})"
|
|
3720
|
+
" sdkKit: {",
|
|
3721
|
+
" clientId: 'your-client-id',",
|
|
3722
|
+
" clientSecret: 'your-client-secret',",
|
|
3723
|
+
" encryptionKey: 'your-encryption-key',",
|
|
3724
|
+
" environment: 'sandbox',",
|
|
3725
|
+
" urls: {",
|
|
3726
|
+
" live: 'https://live.oapiex.com',",
|
|
3727
|
+
" sandbox: 'https://sandbox.oapiex.com',",
|
|
3728
|
+
" },",
|
|
3729
|
+
" debugLevel: 0,",
|
|
3730
|
+
" },"
|
|
3735
3731
|
].join("\n");
|
|
3736
3732
|
}
|
|
3737
3733
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oapiex",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.5",
|
|
5
5
|
"description": "CLI and TypeScript toolkit for turning documentation pages into usable developer artifacts.",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"private": false,
|
|
@@ -69,13 +69,12 @@
|
|
|
69
69
|
"@eslint/markdown": "^7.5.1",
|
|
70
70
|
"@types/jsdom": "^28.0.1",
|
|
71
71
|
"@types/node": "^20.14.5",
|
|
72
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
72
73
|
"barrelize": "^1.7.4",
|
|
73
74
|
"eslint": "^9.39.2",
|
|
74
75
|
"tsx": "^4.20.3",
|
|
75
76
|
"typescript": "^5.4.5",
|
|
76
|
-
"@vitest/coverage-v8": "3.2.4",
|
|
77
77
|
"typescript-eslint": "^8.53.0",
|
|
78
|
-
"vite-tsconfig-paths": "^5.1.4",
|
|
79
78
|
"vitepress": "^1.5.0",
|
|
80
79
|
"vitest": "^3.2.4",
|
|
81
80
|
"vue": "^3.5.13"
|