Feature: hopp-cli in TypeScript (#2074)
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com> Co-authored-by: liyasthomas <liyascthomas@gmail.com> Co-authored-by: Gita Alekhya Paul <gitaalekhyapaul@gmail.com>
This commit is contained in:
36
packages/hoppscotch-cli/src/interfaces/request.ts
Normal file
36
packages/hoppscotch-cli/src/interfaces/request.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { AxiosPromise, AxiosRequestConfig } from "axios";
|
||||
import { HoppRESTRequest } from "@hoppscotch/data";
|
||||
|
||||
/**
|
||||
* Provides definition to object returned by createRequest.
|
||||
* @property {function} request Axios request promise, executed to get axios
|
||||
* response promise.
|
||||
* @property {string} path Path of request within collection file.
|
||||
* @property {string} name Name of request within collection
|
||||
* @property {string} testScript Stringified hoppscotch testScript, used while
|
||||
* running testRunner.
|
||||
*/
|
||||
export interface RequestStack {
|
||||
request: () => AxiosPromise<any>;
|
||||
path: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides definition to axios request promise's request parameter.
|
||||
* @property {boolean} supported - Boolean check for supported or unsupported requests.
|
||||
*/
|
||||
export interface RequestConfig extends AxiosRequestConfig {
|
||||
supported: boolean;
|
||||
}
|
||||
|
||||
export interface EffectiveHoppRESTRequest extends HoppRESTRequest {
|
||||
/**
|
||||
* The effective final URL.
|
||||
*
|
||||
* This contains path, params and environment variables all applied to it
|
||||
*/
|
||||
effectiveFinalURL: string;
|
||||
effectiveFinalHeaders: { key: string; value: string; active: boolean }[];
|
||||
effectiveFinalParams: { key: string; value: string; active: boolean }[];
|
||||
effectiveFinalBody: FormData | string | null;
|
||||
}
|
||||
68
packages/hoppscotch-cli/src/interfaces/response.ts
Normal file
68
packages/hoppscotch-cli/src/interfaces/response.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { TestResponse } from "@hoppscotch/js-sandbox";
|
||||
import { Method } from "axios";
|
||||
import { ExpectResult } from "../types/response";
|
||||
import { HoppEnvs } from "../types/request";
|
||||
|
||||
/**
|
||||
* Defines column headers for table stream used to write table
|
||||
* data on stdout.
|
||||
* @property {string} path Path of request within collection file.
|
||||
* @property {string} endpoint Endpoint from response config.url.
|
||||
* @property {Method} method Method from response headers.
|
||||
* @property {string} statusCode Template string concating status & statusText.
|
||||
*/
|
||||
export interface TableResponse {
|
||||
endpoint: string;
|
||||
method: Method;
|
||||
statusCode: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes additional details of HTTP response returned from
|
||||
* requestRunner.
|
||||
* @property {string} path Path of request within collection file.
|
||||
* @property {string} endpoint Endpoint from response config.url.
|
||||
* @property {Method} method Method from HTTP response headers.
|
||||
* @property {string} statusText HTTP response status text.
|
||||
*/
|
||||
export interface RequestRunnerResponse extends TestResponse {
|
||||
endpoint: string;
|
||||
method: Method;
|
||||
statusText: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes test script details.
|
||||
* @property {string} name Request name within collection.
|
||||
* @property {string} testScript Stringified hoppscotch testScript, used while
|
||||
* running testRunner.
|
||||
* @property {TestResponse} response Response structure for test script runner.
|
||||
*/
|
||||
export interface TestScriptParams {
|
||||
testScript: string;
|
||||
response: TestResponse;
|
||||
envs: HoppEnvs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe properties of test-report generated from test-runner.
|
||||
* @property {string} descriptor Test description.
|
||||
* @property {ExpectResult[]} expectResults Expected results for each
|
||||
* test-case.
|
||||
* @property {number} failing Total failing test-cases.
|
||||
* @property {number} passing Total passing test-cases;
|
||||
*/
|
||||
export interface TestReport {
|
||||
descriptor: string;
|
||||
expectResults: ExpectResult[];
|
||||
failing: number;
|
||||
passing: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes error pair for failed HTTP requests.
|
||||
* @example { 501: "Request Not Supported" }
|
||||
*/
|
||||
export interface ResponseErrorPair {
|
||||
[key: number]: string;
|
||||
}
|
||||
Reference in New Issue
Block a user