Skip to content
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
365 changes: 299 additions & 66 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@
"test": "jest --coverage"
},
"devDependencies": {
"@readme/eslint-config": "^10.5.3",
"@types/eslint": "^8.40.0",
"@readme/eslint-config": "^10.6.0",
"@types/eslint": "^8.40.2",
"@types/event-stream": "^4.0.1",
"@types/har-format": "^1.2.8",
"@types/har-format": "^1.2.11",
"@types/jest": "^29.5.2",
"@types/node": "^20.2.5",
"@types/node": "^20.3.1",
"@types/qs": "^6.9.7",
"@types/stringify-object": "^4.0.2",
"eslint": "^8.41.0",
"eslint": "^8.43.0",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"require-directory": "^2.1.1",
"ts-jest": "^29.1.0",
"type-fest": "^3.11.1",
"type-fest": "^3.12.0",
"typescript": "^5.1.3"
},
"dependencies": {
Expand Down
10 changes: 5 additions & 5 deletions src/fixtures/runCustomFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import path from 'path';
import { HTTPSnippet } from '..';

export interface CustomFixture {
targetId: TargetId;
clientId: ClientId;
targetId: TargetId;
tests: {
it: string;
input: Request;
options: any;

/** a file path pointing to the expected custom fixture result */
expected: string;

input: Request;
it: string;
options: any;
}[];
}

Expand Down
2 changes: 1 addition & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ describe('HTTPSnippet', () => {
expected: 'text/plain',
},
] as {
input: keyof typeof mimetypes;
expected: string;
input: keyof typeof mimetypes;
}[])('mimetype conversion of $input to $output', ({ input, expected }) => {
const snippet = new HTTPSnippet(mimetypes[input]);
const request = snippet.requests[0];
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ const debug = {
* Then, in addition to that, it really adds to complexity with TypeScript (TypeScript takes this constraint very very seriously) in a way that's not actually super useful. So, we treat this object as though it could have both or either of `params` and/or `text`.
*/
type PostDataBase = PostDataCommon & {
text?: string;
params?: Param[];
text?: string;
};

export type HarRequest = Omit<NpmHarRequest, 'postData'> & { postData: PostDataBase };

export interface RequestExtras {
allHeaders: ReducedHelperObject;
cookiesObj: ReducedHelperObject;
fullUrl: string;
headersObj: ReducedHelperObject;
postData: PostDataBase & {
boundary?: string;
jsonObj?: ReducedHelperObject;
paramsObj?: ReducedHelperObject;
boundary?: string;
};
fullUrl: string;
queryObj: ReducedHelperObject;
headersObj: ReducedHelperObject;
uriObj: UrlWithParsedQuery;
cookiesObj: ReducedHelperObject;
allHeaders: ReducedHelperObject;
}

export type Request = HarRequest & RequestExtras;
Expand All @@ -60,12 +60,12 @@ interface Entry {

interface HarEntry {
log: {
version: string;
creator: {
name: string;
version: string;
};
entries: Entry[];
version: string;
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/targets/go/native/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { CodeBuilder } from '../../../helpers/code-builder';
import { escapeForDoubleQuotes } from '../../../helpers/escape';

export interface GoNativeOptions {
showBoilerplate?: boolean;
checkErrors?: boolean;
printBody?: boolean;
showBoilerplate?: boolean;
timeout?: number;
}

Expand Down
4 changes: 2 additions & 2 deletions src/targets/node/request/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export const request: Client = {
}

let attachment: {
value?: string;
options?: {
filename: string;
contentType: string | null;
filename: string;
};
value?: string;
} = {};

if (param.fileName) {
Expand Down
4 changes: 2 additions & 2 deletions src/targets/php/guzzle/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export const guzzle: Client<GuzzleOptions> = {

case 'multipart/form-data': {
interface MultipartField {
name: string;
filename?: string;
contents: string | undefined;
filename?: string;
headers?: Record<string, string>;
name: string;
}

const fields: MultipartField[] = [];
Expand Down
6 changes: 3 additions & 3 deletions src/targets/php/http2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ export const http2: Client<Http2Options> = {
}

const files: {
[anything: string]: string | undefined;
data: string | undefined;
file: string;
name: string;
type: string | undefined;
file: string;
data: string | undefined;
[anything: string]: string | undefined;
}[] = [];
const fields: Record<string, any> = {};
postData.params.forEach(({ name, fileName, value, contentType }) => {
Expand Down
14 changes: 7 additions & 7 deletions src/targets/targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export type TargetId = keyof typeof targets;
export type ClientId = string;

export interface ClientInfo {
description: string;
key: ClientId;
title: string;
link: string;
description: string;
title: string;
}

export type Converter<T extends Record<string, any>> = (
Expand All @@ -38,23 +38,23 @@ export type Converter<T extends Record<string, any>> = (
) => string;

export interface Client<T extends Record<string, any> = Record<string, any>> {
info: ClientInfo;
convert: Converter<T>;
info: ClientInfo;
}

export type Extension = `.${string}` | null;

export interface TargetInfo {
cli?: string;
default: string;
extname: Extension;
key: TargetId;
title: string;
extname: Extension;
default: string;
cli?: string;
}

export interface Target {
info: TargetInfo;
clientsById: Record<ClientId, Client>;
info: TargetInfo;
}

export const targets = {
Expand Down