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:
@@ -6,10 +6,12 @@ import { withTransaction } from "@/lib/db";
|
||||
import type { Transaction } from "@shared/lib/types";
|
||||
|
||||
export const classService = {
|
||||
/** Retrieve all available classes. */
|
||||
getAllClasses: async () => {
|
||||
return await DrizzleClient.query.classes.findMany();
|
||||
},
|
||||
|
||||
/** Assign a class to a user; throws if the class does not exist. */
|
||||
assignClass: async (userId: string, classId: bigint, tx?: Transaction) => {
|
||||
return await withTransaction(async (txFn) => {
|
||||
const cls = await txFn.query.classes.findFirst({
|
||||
@@ -26,12 +28,14 @@ export const classService = {
|
||||
return user;
|
||||
}, tx);
|
||||
},
|
||||
/** Get the current balance for a class, returning 0 if not found. */
|
||||
getClassBalance: async (classId: bigint) => {
|
||||
const cls = await DrizzleClient.query.classes.findFirst({
|
||||
where: eq(classes.id, classId),
|
||||
});
|
||||
return cls?.balance || 0n;
|
||||
},
|
||||
/** Adjust a class balance by the given amount; throws if funds are insufficient for a deduction. */
|
||||
modifyClassBalance: async (classId: bigint, amount: bigint, tx?: Transaction) => {
|
||||
return await withTransaction(async (txFn) => {
|
||||
const cls = await txFn.query.classes.findFirst({
|
||||
@@ -55,6 +59,7 @@ export const classService = {
|
||||
}, tx);
|
||||
},
|
||||
|
||||
/** Update a class record with partial data. */
|
||||
updateClass: async (id: bigint, data: Partial<typeof classes.$inferInsert>, tx?: Transaction) => {
|
||||
return await withTransaction(async (txFn) => {
|
||||
const [updatedClass] = await txFn.update(classes)
|
||||
@@ -65,6 +70,7 @@ export const classService = {
|
||||
}, tx);
|
||||
},
|
||||
|
||||
/** Create a new class record. */
|
||||
createClass: async (data: typeof classes.$inferInsert, tx?: Transaction) => {
|
||||
return await withTransaction(async (txFn) => {
|
||||
const [newClass] = await txFn.insert(classes)
|
||||
@@ -74,6 +80,7 @@ export const classService = {
|
||||
}, tx);
|
||||
},
|
||||
|
||||
/** Delete a class by ID. */
|
||||
deleteClass: async (id: bigint, tx?: Transaction) => {
|
||||
return await withTransaction(async (txFn) => {
|
||||
await txFn.delete(classes).where(eq(classes.id, id));
|
||||
|
||||
Reference in New Issue
Block a user