/opt/canhelp/apps/api/src/lib
NameSizeModeActions
activity.ts13240644editdlrm
apple-client-secret.ts40730644editdlrm
balance.ts35060644editdlrm
daily-limits.ts42820644editdlrm
email.ts527080644editdlrm
fomo.ts113660644editdlrm
google-oauth.ts105260644editdlrm
helper-capability.ts42070644editdlrm
messaging-rules.ts31230644editdlrm
nameUtils.ts7090644editdlrm
notif.ts189290644editdlrm
plan-history.ts10200644editdlrm
push.ts63860644editdlrm
referral.ts61100644editdlrm
telegram.ts62070644editdlrm
turnstile.ts7410644editdlrm
Edit: /opt/canhelp/apps/api/src/lib/plan-history.ts (1020B)
import { db } from '../db.js' import { planHistory } from '@canhelp/db' export type PlanHistoryEvent = | 'activated' | 'renewed' | 'downgraded' | 'referral_reward' | 'admin_change' | 'expired' export async function logPlanHistory(input: { userId: string event: PlanHistoryEvent planId: string planName: string previousPlanId?: string | null previousPlanName?: string | null expiresAt?: Date | null daysAdded?: number | null referralRewardId?: string | null note?: string | null }): Promise { await db.insert(planHistory).values({ userId: input.userId, event: input.event, planId: input.planId, planName: input.planName, previousPlanId: input.previousPlanId ?? null, previousPlanName: input.previousPlanName ?? null, expiresAt: input.expiresAt ?? null, daysAdded: input.daysAdded ?? null, referralRewardId: input.referralRewardId ?? null, note: input.note ?? null, }).catch((err) => console.error('[planHistory] failed to log:', err)) }