Skip to content

Commit d1041a5

Browse files
committed
Use @hawk.so/github-sdk and @hawk.so/utils
Replace local GitHub and time helpers with shared packages. Removed local TimeMs and GitHubService/private-key utils and switched imports to @hawk.so/utils.TimeMs and @hawk.so/github-sdk.GitHubService. Updated code to use PascalCase TimeMs members (Second/Minute/Day) and adjusted NodeCache/ttl usages. Task-manager now instantiates the SDK-backed GitHubService, validates required env vars, and implements delegate resolution + token refresh/persistence flow for Copilot assignment. Added package dependencies in package.json and updated affected worker files accordingly.
1 parent c4cc417 commit d1041a5

File tree

10 files changed

+171
-918
lines changed

10 files changed

+171
-918
lines changed

lib/utils/time.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"@babel/traverse": "7.26.9",
5757
"@hawk.so/nodejs": "^3.1.1",
5858
"@hawk.so/types": "^0.5.7",
59+
"@hawk.so/utils": "^1.0.0",
5960
"@types/amqplib": "^0.8.2",
6061
"@types/jest": "^29.5.14",
6162
"@types/mongodb": "^3.5.15",

workers/notifier/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { NotifierEvent, NotifierWorkerTask } from '../types/notifier-task';
99
import { Rule, WhatToReceive } from '../types/rule';
1010
import { SenderWorkerTask } from 'hawk-worker-sender/types/sender-task';
1111
import RuleValidator from './validator';
12-
import TimeMs from '../../../lib/utils/time';
12+
import { TimeMs } from '@hawk.so/utils';
1313
import RedisHelper from './redisHelper';
1414

1515
/**
@@ -114,10 +114,10 @@ export default class NotifierWorker extends Worker {
114114
return this.getProjectNotificationRules(projectId);
115115
},
116116
/**
117-
* TimeMs class stores time intervals in milliseconds, however NodeCache ttl needs to be specified in seconds
117+
* TimeMs enum stores time intervals in milliseconds; NodeCache ttl is in seconds
118118
*/
119119
/* eslint-disable-next-line @typescript-eslint/no-magic-numbers */
120-
TimeMs.MINUTE / 1000
120+
TimeMs.Minute / 1000
121121
);
122122
} catch (e) {
123123
this.logger.warn('Failed to get project notification rules because ', e);

workers/sender/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { DatabaseController } from '../../../lib/db/controller';
1212
import { Worker } from '../../../lib/worker';
1313
import * as pkg from '../package.json';
1414
import './env';
15-
import TimeMs from '../../../lib/utils/time';
15+
import { TimeMs } from '@hawk.so/utils';
1616

1717
import { PasswordResetNotification, PaymentSuccessNotification, TemplateEventData, WorkspaceInviteNotification } from '../types/template-variables/';
1818
import NotificationsProvider from './provider';
@@ -310,7 +310,7 @@ export default abstract class SenderWorker extends Worker {
310310
/**
311311
* Send message not often than once per day
312312
*/
313-
const throttleInterval = TimeMs.DAY;
313+
const throttleInterval = TimeMs.Day;
314314

315315
const { workspaceId, daysAfterBlock } = task.payload;
316316

@@ -372,7 +372,7 @@ export default abstract class SenderWorker extends Worker {
372372
/**
373373
* Send message not often than once per day
374374
*/
375-
const throttleInterval = TimeMs.DAY;
375+
const throttleInterval = TimeMs.Day;
376376

377377
const { workspaceId, daysLeft } = task.payload;
378378

@@ -437,7 +437,7 @@ export default abstract class SenderWorker extends Worker {
437437
/**
438438
* Send message not often than once per day
439439
*/
440-
const throttleInterval = TimeMs.DAY;
440+
const throttleInterval = TimeMs.Day;
441441

442442
const { workspaceId, eventsCount, eventsLimit } = task.payload;
443443

workers/task-manager/package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
"license": "MIT",
66
"workerType": "cron-tasks/task-manager",
77
"dependencies": {
8-
"@octokit/oauth-methods": "^4.0.0",
9-
"@octokit/rest": "^22.0.1",
10-
"@octokit/types": "^16.0.0",
11-
"jsonwebtoken": "^9.0.3"
12-
},
13-
"devDependencies": {
14-
"@types/jsonwebtoken": "^8.3.5"
8+
"@hawk.so/github-sdk": "^1.0.2"
159
}
1610
}

0 commit comments

Comments
 (0)