Skip to content

Commit

Permalink
fixes after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
despadam committed Jan 15, 2025
1 parent 8af65d1 commit 759ba2c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions jobConfig.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
from: from
subject: "[SciCat] Your {{type}} job was submitted successfully"
bodyTemplateFile: src/common/email-templates/job-template-simplified.html
statusUpdate:
update:
auth: archivemanager
actions:
- actionType: rabbitmq
Expand All @@ -39,5 +39,5 @@ jobs:
required:
- pid
- files
statusUpdate:
update:
auth: "#all"
2 changes: 1 addition & 1 deletion src/casl/casl-ability.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export class CaslAbilityFactory {
cannot(Action.JobRead, JobClass);
if (
Object.values(this.jobConfigService.allJobConfigs).some(
(j) => j.statusUpdate.auth == UpdateJobAuth.All,
(j) => j.update.auth == UpdateJobAuth.All,
)
) {
can(Action.JobUpdate, JobClass);
Expand Down
10 changes: 5 additions & 5 deletions src/config/job-config/jobconfig.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CreateJobDto } from "../../jobs/dto/create-job.dto";
import { StatusUpdateJobDto } from "../../jobs/dto/status-update-job.dto";
import { UpdateJobDto } from "../../jobs/dto/update-job.dto";
import { JobsAuth } from "../../jobs/types/jobs-auth.enum";
import { JobClass } from "../../jobs/schemas/job.schema";

Expand All @@ -20,18 +20,18 @@ export interface JobConfig {
jobType: string;
configVersion: string;
create: JobOperation<CreateJobDto>;
statusUpdate: JobOperation<StatusUpdateJobDto>;
update: JobOperation<UpdateJobDto>;
}
export interface JobConfigOptions {
jobType: string;
configVersion: string;
create: JobOperationOptions;
statusUpdate: JobOperationOptions;
update: JobOperationOptions;
}

export type JobDto = CreateJobDto | StatusUpdateJobDto;
export type JobDto = CreateJobDto | UpdateJobDto;
/**
* Encapsulates all information for a particular job operation (eg "create", "statusUpdate")
* Encapsulates all information for a particular job operation (eg "create", "update")
*/
export interface JobOperation<DtoType extends JobDto> {
auth: JobsAuth | undefined;
Expand Down
8 changes: 4 additions & 4 deletions src/config/job-config/jobconfig.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { JobConfigSchema } from "./jobconfig.schema";
import { load } from "js-yaml";
import * as fs from "fs";
import { CreateJobDto } from "../../jobs/dto/create-job.dto";
import { StatusUpdateJobDto } from "../../jobs/dto/status-update-job.dto";
import { UpdateJobDto } from "../../jobs/dto/update-job.dto";
import { ConfigService } from "@nestjs/config";

/**
Expand All @@ -32,7 +32,7 @@ export class JobConfigService {
@Inject(UPDATE_JOB_ACTION_CREATORS)
private update_creators: Record<

Check failure on line 33 in src/config/job-config/jobconfig.service.ts

View workflow job for this annotation

GitHub Actions / eslint

Replace `⏎······string,⏎······JobActionCreator<UpdateJobDto>⏎····` with `string,·JobActionCreator<UpdateJobDto>`
string,
JobActionCreator<StatusUpdateJobDto>
JobActionCreator<UpdateJobDto>
>,
configService: ConfigService,
) {
Expand Down Expand Up @@ -104,8 +104,8 @@ export class JobConfigService {
options.create,
this.create_creators,
),
statusUpdate: this.parseJobOperation<StatusUpdateJobDto>(
options.statusUpdate,
update: this.parseJobOperation<UpdateJobDto>(
options.update,
this.update_creators,
),
};
Expand Down
4 changes: 2 additions & 2 deletions src/jobs/jobs.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,14 +735,14 @@ export class JobsController {
}

// Allow actions to validate DTO
await this.validateDTO(jobConfig.statusUpdate.actions, statusUpdateJobDto);
await this.validateDTO(jobConfig.update.actions, updateJobDto);

// Update job in database
const updatedJob = await this.jobsService.update(id, updateJobDto);
// Perform the action that is specified in the update portion of the job configuration
if (updatedJob !== null) {
await this.checkConfigVersion(jobConfig, updatedJob);
await this.performActions(jobConfig.statusUpdate.actions, updatedJob);
await this.performActions(jobConfig.update.actions, updatedJob);
}
return updatedJob;
}
Expand Down

0 comments on commit 759ba2c

Please sign in to comment.