docs: add JSDoc to service public methods
One-line JSDoc on 82 methods across 11 service files for quick scanning without reading full implementations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import { UserError } from "@shared/lib/errors";
|
||||
import { TimerKey, TimerType, TransactionType } from "@shared/lib/constants";
|
||||
|
||||
export const economyService = {
|
||||
/** Transfer currency between two users; validates sufficient balance and creates transaction records for both sides. */
|
||||
transfer: async (fromUserId: string, toUserId: string, amount: bigint, tx?: Transaction) => {
|
||||
if (amount <= 0n) {
|
||||
throw new UserError("Amount must be positive");
|
||||
@@ -69,6 +70,7 @@ export const economyService = {
|
||||
}, tx);
|
||||
},
|
||||
|
||||
/** Claim the daily reward, applying streak bonuses and weekly bonuses; enforces a UTC-midnight cooldown. */
|
||||
claimDaily: async (userId: string, tx?: Transaction) => {
|
||||
return await withTransaction(async (txFn) => {
|
||||
const now = new Date();
|
||||
@@ -164,6 +166,7 @@ export const economyService = {
|
||||
}, tx);
|
||||
},
|
||||
|
||||
/** Adjust a user's balance by the given amount and log a transaction; throws if deduction exceeds current balance. */
|
||||
modifyUserBalance: async (id: string, amount: bigint, type: string, description: string, relatedUserId?: string | null, tx?: Transaction) => {
|
||||
return await withTransaction(async (txFn) => {
|
||||
if (amount < 0n) {
|
||||
|
||||
@@ -213,12 +213,20 @@ async function clearCaches() {
|
||||
}
|
||||
|
||||
export const lootdropService = {
|
||||
/** Delete expired lootdrops from the database; optionally includes already-claimed ones. */
|
||||
cleanupExpiredLootdrops,
|
||||
/** Record a message in a channel and return whether a lootdrop should spawn based on activity and RNG. */
|
||||
trackActivity,
|
||||
/** Calculate a random lootdrop reward amount and currency, with optional overrides. */
|
||||
calculateReward,
|
||||
/** Save a spawned lootdrop to the database with a 10-minute expiration. */
|
||||
persistLootdrop,
|
||||
/** Remove a lootdrop by message ID and return its channel ID for Discord cleanup. */
|
||||
removeLootdrop,
|
||||
/** Atomically claim a lootdrop for a user; credits reward to their balance. */
|
||||
tryClaim,
|
||||
/** Get current lootdrop system state including the most active channel and spawn config. */
|
||||
getLootdropState,
|
||||
/** Clear all in-memory activity tracking and cooldown caches. */
|
||||
clearCaches,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user