Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
despadam committed Jul 31, 2024
1 parent fb59df0 commit ec5cf4f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
25 changes: 12 additions & 13 deletions src/common/handlebars-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export const jsonify = (context: unknown): string => {
return JSON.stringify(context, null, 3);
};


type DatasetIdV3 = {
pid: string;
files: string[];
Expand All @@ -97,27 +96,27 @@ interface JobV3 {
*/
export const job_v3 = (job: JobClass): JobV3 => {
let datasetList: DatasetIdV3[];
if(JobsConfigSchema.DatasetIds in job.jobParams) {
if (JobsConfigSchema.DatasetIds in job.jobParams) {
const datasetIds = job.jobParams[JobsConfigSchema.DatasetIds] as string[];
datasetList = datasetIds.map(pid => ({
datasetList = datasetIds.map((pid) => ({
pid: pid,
files: [],
}));
} else {
datasetList = [];
}
return {
"id": job.id,
"emailJobInitiator": job.contactEmail,
"type": job.type,
"creationTime": job.createdAt,
"jobParams": {
id: job.id,
emailJobInitiator: job.contactEmail,
type: job.type,
creationTime: job.createdAt,
jobParams: {
...job.jobParams,
"username": job.createdBy
username: job.createdBy

Check failure on line 115 in src/common/handlebars-helpers.ts

View workflow job for this annotation

GitHub Actions / eslint

Insert `,`
},
//v3 statusMessages were generally concise, so use the statusCode
"jobStatusMessage": job.statusCode,
"datasetList": datasetList,
jobStatusMessage: job.statusCode,
datasetList: datasetList,
};
};

Expand All @@ -128,7 +127,7 @@ export const job_v3 = (job: JobClass): JobV3 => {
*/
export const urlencode = (context: string): string => {
return encodeURIComponent(context);
}
};

/**
* Base64 encode input
Expand All @@ -137,4 +136,4 @@ export const urlencode = (context: string): string => {
*/
export const base64enc = (context: string): string => {
return btoa(context);
}
};
23 changes: 19 additions & 4 deletions src/jobs/actions/urlaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ const jobTemplateOptions = {
* @param obj
* @returns
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isStringRecord(obj: any): obj is Record<string, string> {
return typeof obj === 'object' && obj !== null &&
Object.keys(obj).every(key => typeof key === 'string' && typeof obj[key] === 'string');
return (

Check failure on line 28 in src/jobs/actions/urlaction.ts

View workflow job for this annotation

GitHub Actions / eslint

Delete `·`
typeof obj === "object" &&
obj !== null &&
Object.keys(obj).every(
(key) => typeof key === "string" && typeof obj[key] === "string"

Check failure on line 32 in src/jobs/actions/urlaction.ts

View workflow job for this annotation

GitHub Actions / eslint

Insert `,`
)
);
}

/**
Expand All @@ -52,7 +58,12 @@ export class URLAction<T> implements JobAction<T> {

const response = await fetch(url, {
method: this.method,
headers: this.headerTemplates ? Object.fromEntries(Object.entries(this.headerTemplates).map(([key, template]) => [key, template(job, jobTemplateOptions)])): undefined,
headers: this.headerTemplates ?

Check failure on line 61 in src/jobs/actions/urlaction.ts

View workflow job for this annotation

GitHub Actions / eslint

Delete `·?·`
Object.fromEntries(

Check failure on line 62 in src/jobs/actions/urlaction.ts

View workflow job for this annotation

GitHub Actions / eslint

Replace `·······` with `?`
Object.entries(this.headerTemplates).map(

Check failure on line 63 in src/jobs/actions/urlaction.ts

View workflow job for this annotation

GitHub Actions / eslint

Replace `··················Object.entries(this.headerTemplates).map(⏎····················([key,·template])·=>·[key,·template(job,·jobTemplateOptions)]` with `············Object.entries(this.headerTemplates).map(([key,·template])·=>·[⏎··············key,⏎··············template(job,·jobTemplateOptions),`
([key, template]) => [key, template(job, jobTemplateOptions)]
)

Check failure on line 65 in src/jobs/actions/urlaction.ts

View workflow job for this annotation

GitHub Actions / eslint

Insert `]),⏎····`
) : undefined,

Check failure on line 66 in src/jobs/actions/urlaction.ts

View workflow job for this annotation

GitHub Actions / eslint

Delete `·········)`
body: this.bodyTemplate ? this.bodyTemplate(job, jobTemplateOptions) : undefined,

Check failure on line 67 in src/jobs/actions/urlaction.ts

View workflow job for this annotation

GitHub Actions / eslint

Replace `·?·this.bodyTemplate(job,·jobTemplateOptions)` with `⏎········?·this.bodyTemplate(job,·jobTemplateOptions)⏎·······`
});

Expand Down Expand Up @@ -94,7 +105,11 @@ export class URLAction<T> implements JobAction<T> {
if(!isStringRecord(data.headers)) {
throw new NotFoundException("Param 'headers' should map strings to strings");
}
this.headerTemplates = Object.fromEntries(Object.entries(data.headers).map(([key, value]) => [key, Handlebars.compile(value)]));
this.headerTemplates = Object.fromEntries(
Object.entries(data.headers).map(
([key, value]) => [key, Handlebars.compile(value)]
)
);
}
if (data["body"]) {
this.bodyTemplate = Handlebars.compile(data["body"]);
Expand Down

0 comments on commit ec5cf4f

Please sign in to comment.