diff --git a/src/transformers/jq_transformer.ts b/src/transformers/jq_transformer.ts index cb3c653..1da932d 100644 --- a/src/transformers/jq_transformer.ts +++ b/src/transformers/jq_transformer.ts @@ -11,28 +11,21 @@ import { toArray } from "../utils"; const filterStringsWrap = Object.fromEntries( fs.readdirSync(Path.resolve(`${__dirname}/../../data/jq/wrap`)).map(file => { const filePath = Path.resolve(`${__dirname}/../../data/jq/wrap/${file}`); - return [ - Path.parse(filePath).name, - fs.readFileSync(filePath, { encoding: "utf8" }), - ]; + return [Path.parse(filePath).name, fs.readFileSync(filePath, { encoding: "utf8" })]; }), ); const filterStringsPair = Object.fromEntries( fs.readdirSync(Path.resolve(`${__dirname}/../../data/jq/pair`)).map(file => { const filePath = Path.resolve(`${__dirname}/../../data/jq/pair/${file}`); - return [ - Path.parse(filePath).name, - fs.readFileSync(filePath, { encoding: "utf8" }), - ]; + return [Path.parse(filePath).name, fs.readFileSync(filePath, { encoding: "utf8" })]; }), ); export default class JQTransformer extends BaseTransformer { // TODO more specific typing? async wrap(res: JSONDoc | JSONDoc[]): Promise { - let filterString: string | undefined = - this.config.wrap ?? filterStringsWrap[this.config.type]; + let filterString: string | undefined = this.config.wrap ?? filterStringsWrap[this.config.type]; if (typeof filterString === "undefined") return super.wrap(res); filterString = generateFilterString(filterString); return JSON.parse( @@ -43,10 +36,8 @@ export default class JQTransformer extends BaseTransformer { } async pairCurieWithAPIResponse(): Promise { - let filterString: string | undefined = - this.config.pair ?? filterStringsPair[this.config.type]; - if (typeof filterString === "undefined") - return super.pairCurieWithAPIResponse(); + let filterString: string | undefined = this.config.pair ?? filterStringsPair[this.config.type]; + if (typeof filterString === "undefined") return super.pairCurieWithAPIResponse(); const data = { response: this.data.response, edge: { @@ -58,10 +49,9 @@ export default class JQTransformer extends BaseTransformer { type: this.edge.association.input_type, // input is array or is object with queryInputs curies: - Array.isArray(this.edge.input) || - typeof this.edge.input === "string" + Array.isArray(this.edge.input) || typeof this.edge.input === "string" ? toArray(this.edge.input) - : this.edge.input.queryInputs, + : toArray(this.edge.input.queryInputs), }, predicate: this.edge.association.predicate, output: { @@ -71,8 +61,6 @@ export default class JQTransformer extends BaseTransformer { }, }; filterString = `.edge as $edge | ${generateFilterString(filterString)}`; - return JSON.parse( - (await jq.run(filterString, data, { input: "json" })) as string, - ); + return JSON.parse((await jq.run(filterString, data, { input: "json" })) as string); } }