Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

fix: split out type exports #241

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 1 addition & 21 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<string, any>;
formData?: Record<string, any>; // `application/x-www-form-urlencoded` requests payloads.
header?: Record<string, any>;
path?: Record<string, any>;
query?: Record<string, any>;
server?: {
selected: number;
variables?: Record<string, unknown>;
};
}

function formatter(
values: DataForHAR,
param: ParameterObject,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/lib/configure-security.ts
Original file line number Diff line number Diff line change
@@ -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<string, string | number | { pass?: string; user?: string }>;

function harValue(type: 'cookies' | 'headers' | 'queryString', value: { name: string; value: string }) {
if (!value.value) return undefined;
return { type, value };
Expand Down
19 changes: 19 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export type AuthForHAR = Record<string, string | number | { pass?: string; user?: string }>;

export interface DataForHAR {
body?: any;
cookie?: Record<string, any>;
formData?: Record<string, any>; // `application/x-www-form-urlencoded` requests payloads.
header?: Record<string, any>;
path?: Record<string, any>;
query?: Record<string, any>;
server?: {
selected: number;
variables?: Record<string, unknown>;
};
}
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;
}
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down