index.ts (hoppscotch-2.2.1) | : | index.ts (hoppscotch-3.0.0) | ||
---|---|---|---|---|
import cloneDeep from "lodash/cloneDeep" | import cloneDeep from "lodash/cloneDeep" | |||
import * as Eq from "fp-ts/Eq" | ||||
import * as S from "fp-ts/string" | ||||
import { ValidContentTypes } from "./content-types" | import { ValidContentTypes } from "./content-types" | |||
import { HoppRESTAuth } from "./HoppRESTAuth" | import { HoppRESTAuth } from "./HoppRESTAuth" | |||
import { lodashIsEqualEq, mapThenEq, undefinedEq } from "../utils/eq" | ||||
export * from "./content-types" | export * from "./content-types" | |||
export * from "./HoppRESTAuth" | export * from "./HoppRESTAuth" | |||
export const RESTReqSchemaVersion = "1" | export const RESTReqSchemaVersion = "1" | |||
export type HoppRESTParam = { | export type HoppRESTParam = { | |||
key: string | key: string | |||
value: string | value: string | |||
active: boolean | active: boolean | |||
skipping to change at line 60 | skipping to change at line 63 | |||
params: HoppRESTParam[] | params: HoppRESTParam[] | |||
headers: HoppRESTHeader[] | headers: HoppRESTHeader[] | |||
preRequestScript: string | preRequestScript: string | |||
testScript: string | testScript: string | |||
auth: HoppRESTAuth | auth: HoppRESTAuth | |||
body: HoppRESTReqBody | body: HoppRESTReqBody | |||
} | } | |||
export const HoppRESTRequestEq = Eq.struct<HoppRESTRequest>({ | ||||
id: undefinedEq(S.Eq), | ||||
v: S.Eq, | ||||
auth: lodashIsEqualEq, | ||||
body: lodashIsEqualEq, | ||||
endpoint: S.Eq, | ||||
headers: mapThenEq( | ||||
(arr) => arr.filter((h) => h.key !== "" && h.value !== ""), | ||||
lodashIsEqualEq | ||||
), | ||||
params: mapThenEq( | ||||
(arr) => arr.filter((p) => p.key !== "" && p.value !== ""), | ||||
lodashIsEqualEq | ||||
), | ||||
method: S.Eq, | ||||
name: S.Eq, | ||||
preRequestScript: S.Eq, | ||||
testScript: S.Eq, | ||||
}) | ||||
export const isEqualHoppRESTRequest = HoppRESTRequestEq.equals | ||||
/** | /** | |||
* Safely tries to extract REST Request data from an unknown value. | * Safely tries to extract REST Request data from an unknown value. | |||
* If we fail to detect certain bits, we just resolve it to the default value | * If we fail to detect certain bits, we just resolve it to the default value | |||
* @param x The value to extract REST Request data from | * @param x The value to extract REST Request data from | |||
* @param defaultReq The default REST Request to source from | * @param defaultReq The default REST Request to source from | |||
*/ | */ | |||
export function safelyExtractRESTRequest( | export function safelyExtractRESTRequest( | |||
x: unknown, | x: unknown, | |||
defaultReq: HoppRESTRequest | defaultReq: HoppRESTRequest | |||
): HoppRESTRequest { | ): HoppRESTRequest { | |||
End of changes. 3 change blocks. | ||||
0 lines changed or deleted | 25 lines changed or added |