diff --git a/package.json b/package.json index 62273c9..b984ad9 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,10 @@ "require": "./dist/lib/configure-security.cjs", "import": "./dist/lib/configure-security.js" }, + "./lib/types": { + "require": "./dist/lib/types.cjs", + "import": "./dist/lib/types.js" + }, "./package.json": "./package.json" }, "main": "dist/index.cjs", diff --git a/src/index.ts b/src/index.ts index bb649a2..0a0a3c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import type { AuthForHAR } from './lib/configure-security'; +import type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types'; import type { Extensions } from '@readme/oas-extensions'; import type { PostDataParams, Request } from 'har-format'; import type Oas from 'oas'; @@ -28,20 +28,6 @@ import { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './li const { jsonSchemaTypes, matchesMimeType } = utils; -export type { AuthForHAR } from './lib/configure-security'; -export interface DataForHAR { - body?: any; - cookie?: Record; - formData?: Record; // `application/x-www-form-urlencoded` requests payloads. - header?: Record; - path?: Record; - query?: Record; - server?: { - selected: number; - variables?: Record; - }; -} - function formatter( values: DataForHAR, param: ParameterObject, @@ -231,12 +217,6 @@ function encodeBodyForHAR(body: any) { return stringify(body); } -export interface oasToHarOptions { - // If true, the operation URL will be rewritten and prefixed with https://try.readme.io/ in - // order to funnel requests through our CORS-friendly proxy. - proxyUrl: boolean; -} - export default function oasToHar( oas: Oas, operationSchema?: Operation, diff --git a/src/lib/configure-security.ts b/src/lib/configure-security.ts index 330c819..20258da 100644 --- a/src/lib/configure-security.ts +++ b/src/lib/configure-security.ts @@ -1,9 +1,8 @@ +import type { AuthForHAR } from './types'; import type { OASDocument, SecuritySchemeObject } from 'oas/rmoas.types'; import { isRef } from 'oas/rmoas.types'; -export type AuthForHAR = Record; - function harValue(type: 'cookies' | 'headers' | 'queryString', value: { name: string; value: string }) { if (!value.value) return undefined; return { type, value }; diff --git a/src/lib/types.ts b/src/lib/types.ts new file mode 100644 index 0000000..eb10c0b --- /dev/null +++ b/src/lib/types.ts @@ -0,0 +1,19 @@ +export type AuthForHAR = Record; + +export interface DataForHAR { + body?: any; + cookie?: Record; + formData?: Record; // `application/x-www-form-urlencoded` requests payloads. + header?: Record; + path?: Record; + query?: Record; + server?: { + selected: number; + variables?: Record; + }; +} +export interface oasToHarOptions { + // If true, the operation URL will be rewritten and prefixed with https://try.readme.io/ in + // order to funnel requests through our CORS-friendly proxy. + proxyUrl: boolean; +} diff --git a/tsup.config.ts b/tsup.config.ts index aa30335..e2418ba 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -6,7 +6,7 @@ export default defineConfig(options => ({ cjsInterop: true, dts: true, - entry: ['src/index.ts', 'src/lib/configure-security.ts'], + entry: ['src/index.ts', 'src/lib/configure-security.ts', 'src/lib/types.ts'], format: ['esm', 'cjs'], shims: true, silent: !options.watch,