Add Hatchet workflow stubs for order and referral jobs

This commit is contained in:
Ruslan Bakiev
2026-03-30 21:41:41 +07:00
parent 67a4a8c8e8
commit 728139e617
9 changed files with 1470 additions and 13 deletions

View File

@@ -0,0 +1,38 @@
import { hatchet } from '../hatchet-client.js';
import { requestBackendGraphQL } from '../fregat-backend-client.js';
export const referralBalanceSync = hatchet.workflow({
name: 'fregat-referral-balance-sync',
});
referralBalanceSync.task({
name: 'sync-referral-balance',
fn: async (input) => {
const userId = String(input.userId || '');
if (!userId) {
throw new Error('userId is required for referral sync');
}
const data = await requestBackendGraphQL({
userId,
query: `
query ReferralStats {
referralStats {
referrerId
availableBalance
referralsCount
}
}
`,
});
const stats = data.referralStats;
console.log(`[fregat-referral-balance-sync] user=${stats.referrerId} balance=${stats.availableBalance} referrals=${stats.referralsCount}`);
return {
referrerId: stats.referrerId,
availableBalance: stats.availableBalance,
referralsCount: stats.referralsCount,
};
},
});