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:
syntaxbullet
2026-04-02 11:36:18 +02:00
parent 5f8819bb46
commit 5bd390b4ee
11 changed files with 82 additions and 10 deletions

View File

@@ -11,6 +11,7 @@ import { TransactionType } from "@shared/lib/constants";
import { systemEvents, EVENTS } from "@shared/lib/events";
export const questService = {
/** Assign a quest to a user; enforces the maximum active quest limit. */
assignQuest: async (userId: string, questId: number, tx?: Transaction) => {
return await withTransaction(async (txFn) => {
// Check active quest limit
@@ -40,6 +41,7 @@ export const questService = {
}, tx);
},
/** Set the progress value for a user's active quest. */
updateProgress: async (userId: string, questId: number, progress: number, tx?: Transaction) => {
return await withTransaction(async (txFn) => {
return await txFn.update(userQuests)
@@ -52,6 +54,7 @@ export const questService = {
}, tx);
},
/** Process a domain event against active quests, incrementing progress and auto-completing if target is met. */
handleEvent: async (userId: string, eventName: string, weight: number = 1, tx?: Transaction) => {
return await withTransaction(async (txFn) => {
// 1. Fetch active user quests for this event
@@ -86,6 +89,7 @@ export const questService = {
}, tx);
},
/** Mark a quest as completed and distribute its XP and balance rewards. */
completeQuest: async (userId: string, questId: number, tx?: Transaction) => {
return await withTransaction(async (txFn) => {
const userQuest = await txFn.query.userQuests.findFirst({
@@ -137,6 +141,7 @@ export const questService = {
}, tx);
},
/** Get all quests assigned to a user, including quest details. */
getUserQuests: async (userId: string) => {
return await DrizzleClient.query.userQuests.findMany({
where: eq(userQuests.userId, BigInt(userId)),
@@ -146,6 +151,7 @@ export const questService = {
});
},
/** Get quests not yet assigned to a user. */
async getAvailableQuests(userId: string) {
const userQuestIds = (await DrizzleClient.query.userQuests.findMany({
where: eq(userQuests.userId, BigInt(userId)),
@@ -161,6 +167,7 @@ export const questService = {
});
},
/** Create a new quest definition with trigger event, requirements, and rewards. */
async createQuest(data: {
name: string;
description: string;
@@ -181,12 +188,14 @@ export const questService = {
}, tx);
},
/** List all quest definitions, ordered by ID. */
async getAllQuests() {
return await DrizzleClient.query.quests.findMany({
orderBy: (quests, { asc }) => [asc(quests.id)],
});
},
/** Delete a quest definition by ID. */
async deleteQuest(id: number, tx?: Transaction) {
return await withTransaction(async (txFn) => {
return await txFn.delete(quests)
@@ -195,6 +204,7 @@ export const questService = {
}, tx);
},
/** Update a quest definition with partial data. */
async updateQuest(id: number, data: {
name?: string;
description?: string;