@clairejs/server 3.27.4 → 3.27.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  ## Change Log
2
2
 
3
- #### 3.27.4
3
+ #### 3.27.6
4
+
5
+ - fix npm security issues
6
+
7
+ #### 3.27.5
4
8
 
5
9
  - implement job retry logic
6
10
  - use aws scheduler for jobs
@@ -29,7 +29,7 @@ export declare abstract class AbstractJobScheduler {
29
29
  * @param id The job id returned from scheduleJobAt function
30
30
  */
31
31
  protected abstract cancelJob(id: string): Promise<void>;
32
- protected abstract retryJob(payload: AbstractJob): Promise<void>;
32
+ protected retryJob(payload: AbstractJob): Promise<void>;
33
33
  /**
34
34
  * Remove the scheduled job and prevent if from running in the future
35
35
  * @param id The job id returned from scheduleJobAt function
@@ -96,6 +96,10 @@ export class AbstractJobScheduler {
96
96
  await tx.commit();
97
97
  return jobId;
98
98
  }
99
+ async retryJob(payload) {
100
+ this.logger.debug("Retrying job: ", payload);
101
+ await this._scheduleJob({ ...payload, id: `${payload.id}-retry-${payload.retryCount}` });
102
+ }
99
103
  /**
100
104
  * Remove the scheduled job and prevent if from running in the future
101
105
  * @param id The job id returned from scheduleJobAt function
@@ -15,10 +15,8 @@ export declare class AwsJobScheduler extends AbstractJobScheduler {
15
15
  constructor(logger: AbstractLogger, db: AbstractDbAdapter, jobRepo: AbstractJobRepository, apiLambdaFunctionArn: string, apiLambdaFunctionRoleArn: string, jobNamespace: string);
16
16
  handleCron(jobInfo: AbstractJob): Promise<void>;
17
17
  private convertCronToSchedulerExpression;
18
- private getJobName;
19
18
  private getOneTimeExpression;
20
19
  protected getScheduledJobs(): Promise<AbstractJob[]>;
21
- protected retryJob(payload: AbstractJob): Promise<void>;
22
20
  protected _scheduleJob(jobInfo: AbstractJob): Promise<void>;
23
21
  cancelJob(jobId: string): Promise<void>;
24
22
  }
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { AbstractLogger, Errors, LogContext } from "@clairejs/core";
11
11
  import { AbstractDbAdapter } from "@clairejs/orm";
12
- import { SchedulerClient, CreateScheduleCommand, DeleteScheduleCommand, GetScheduleCommand, ListSchedulesCommand, ScheduleState, ActionAfterCompletion, UpdateScheduleCommand } from "@aws-sdk/client-scheduler";
12
+ import { SchedulerClient, CreateScheduleCommand, DeleteScheduleCommand, GetScheduleCommand, ListSchedulesCommand, ScheduleState, ActionAfterCompletion } from "@aws-sdk/client-scheduler";
13
13
  import { AbstractJobScheduler } from "./AbstractJobScheduler";
14
14
  import { AbstractJobRepository } from "./AbstractJobRepository";
15
15
  /**
@@ -56,9 +56,6 @@ let AwsJobScheduler = class AwsJobScheduler extends AbstractJobScheduler {
56
56
  }
57
57
  return parts.join(" ");
58
58
  }
59
- getJobName(jobId) {
60
- return `${this.jobNamespace}${jobId}`;
61
- }
62
59
  getOneTimeExpression(at) {
63
60
  const date = new Date(at);
64
61
  return `at(${date.toISOString().replace(/\.\d{3}Z$/, '')})`;
@@ -96,28 +93,6 @@ let AwsJobScheduler = class AwsJobScheduler extends AbstractJobScheduler {
96
93
  return [];
97
94
  }
98
95
  }
99
- async retryJob(payload) {
100
- this.logger.debug("Retrying job: ", payload);
101
- if (payload.at) {
102
- if (payload.cron) {
103
- //- retry a cron job
104
- await this._scheduleJob({ ...payload, id: `${payload.id}-retry-${payload.retryCount}` });
105
- }
106
- else {
107
- //- retry a one-time job, update the schedule
108
- const jobName = this.getJobName(payload.id);
109
- const schedule = await this.scheduler.send(new GetScheduleCommand({
110
- Name: jobName,
111
- GroupName: schedulerGroupName,
112
- }));
113
- const updateCommand = new UpdateScheduleCommand({
114
- ...schedule,
115
- ScheduleExpression: this.getOneTimeExpression(payload.at),
116
- });
117
- await this.scheduler.send(updateCommand);
118
- }
119
- }
120
- }
121
96
  async _scheduleJob(jobInfo) {
122
97
  this.logger.debug("Scheduling job: ", jobInfo);
123
98
  if (jobInfo.cron || jobInfo.at) {
@@ -54,7 +54,6 @@ export declare class LocalJobScheduler extends AbstractJobScheduler implements I
54
54
  exit(): void;
55
55
  protected getScheduledJobs(): Promise<AbstractJob[]>;
56
56
  syncJobs(): Promise<void>;
57
- protected retryJob(payload: AbstractJob): Promise<void>;
58
57
  protected _scheduleJob(jobInfo: AbstractJob): Promise<void>;
59
58
  protected cancelJob(jobId: string): Promise<void>;
60
59
  }
@@ -80,7 +80,7 @@ let LocalJobScheduler = class LocalJobScheduler extends AbstractJobScheduler {
80
80
  return;
81
81
  }
82
82
  const jobInfo = data;
83
- await this.scheduleJob(jobInfo);
83
+ await this._scheduleJob(jobInfo);
84
84
  break;
85
85
  case CommunicationMessage.REMOVE_JOB:
86
86
  if (!this.isActive) {
@@ -154,9 +154,6 @@ let LocalJobScheduler = class LocalJobScheduler extends AbstractJobScheduler {
154
154
  }
155
155
  return;
156
156
  }
157
- async retryJob(payload) {
158
- return await this._scheduleJob(payload);
159
- }
160
157
  async _scheduleJob(jobInfo) {
161
158
  if (this.isActive) {
162
159
  //-- case each job type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/server",
3
- "version": "3.27.4",
3
+ "version": "3.27.6",
4
4
  "description": "Claire server NodeJs framework written in Typescript.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",