Skip to content

Commit 152df72

Browse files
committed
refactor: 💡 Updated options type for JobHandler
1 parent c6d6fb3 commit 152df72

File tree

3 files changed

+4
-27
lines changed

3 files changed

+4
-27
lines changed

‎src/constants.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,3 @@ export const queueJobAttemptsDelay = 1000;
1515

1616
/** Time interval for queue needs in milliseconds */
1717
export const queueHeartbeat = 5;
18-
19-
/**
20-
* Deal status
21-
*/
22-
export enum DealStatus {
23-
Created, // Just created
24-
Claimed, // Claimed by the supplier
25-
Rejected, // Rejected by the supplier
26-
Refunded, // Refunded by the supplier
27-
Cancelled, // Cancelled by the buyer
28-
CheckedIn, // Checked In
29-
CheckedOut, // Checked Out
30-
Disputed, // Dispute started
31-
}

‎src/shared/deal.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import { Hash } from 'viem';
2-
/**
3-
* Allowed deal states
4-
*/
5-
export enum DealState {
6-
PENDING,
7-
ACCEPTED,
8-
REJECTED,
9-
CANCELLED,
10-
CHECKED_IN,
11-
}
2+
import { DealStatus } from './contracts.js';
123

134
/**
145
* Deal data type
@@ -19,7 +10,7 @@ export interface DealData {
1910
/** Supplier Id */
2011
supplierId: Hash;
2112
/** Deal status */
22-
status: DealState;
13+
status: DealStatus;
2314
/** Deal status change reason */
2415
reason?: string;
2516
/** Deal creation date */

‎src/shared/queue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export interface Job<JobDataType = unknown> {
8282
*/
8383
export type JobHandler<OfferData = unknown, HandlerOptions extends object = object> = (
8484
job: Job<OfferData>,
85-
options?: HandlerOptions,
85+
options: HandlerOptions,
8686
) => Promise<boolean | void>;
8787

8888
/**
@@ -108,7 +108,7 @@ export const createJobHandler =
108108
<OfferData = any, HandlerOptions extends object = object>(
109109
handler: JobHandler<OfferData, HandlerOptions>,
110110
) =>
111-
(options?: HandlerOptions) =>
111+
(options: HandlerOptions) =>
112112
(job: Job<OfferData>) =>
113113
handler(job, options);
114114
/* eslint-disable @typescript-eslint/no-explicit-any */

0 commit comments

Comments
 (0)