/** * Admin identity — the `adminContext` plugin. Worker-safe (no env, no OS). * * Every context gets `ctx.adminId` (the PRIMARY admin: the single approve/deny + notification * target) and `ctx.isAdmin` (true for ANY admin). `accessControl` and the payments refund flow * declare a gramio dependency on this plugin's name (`@adriangalilea/utils/bot/admin`), so they * inherit whatever this derives. * * The admin ids are a SOURCE, not a snapshot. Pass a live resolver (a function) and it is consulted * PER UPDATE, so changing where the ids come from — a db row a console writes, a runtime toggle — * is effective on the very next update with NO restart. Static id(s) work too. This reads no env and * touches no OS: the caller owns where the ids come from. That is what keeps it Worker-safe, and it * is why env is a *fallback the caller composes into the source*, never a coupling in here (a Node * bot passes `kev.int("TELEGRAM_ADMIN_ID", fallback)`; a Worker bot passes a db-backed resolver that * falls back to its own env). * * Peer dep: `gramio`. * * @example * // Worker bot: live from the db — the console writes it, effective next update, no redeploy. * bot.extend(adminContext(() => store.readAdminIds())) * // Node bot: env with a hardcoded fallback, resolved at the call site. * bot.extend(adminContext(kev.int("TELEGRAM_ADMIN_ID", 123456789))) * // Static, one or many. * bot.extend(adminContext(123456789)) * bot.extend(adminContext([123456789, 42])) */ import { Plugin } from "gramio"; type MaybePromise = T | Promise; /** * Where admin ids come from. A number or array is static; a function is a LIVE resolver, consulted * per update. The FIRST id is primary (`ctx.adminId`); `ctx.isAdmin` is true for any id in the set. */ export type Admins = number | readonly number[] | (() => MaybePromise); /** Parse a comma/space-separated id list from an env string ("123, 456 789") into clean * positive-integer ids — the raw material for an {@link Admins} source. Worker-safe. */ export declare function parseIdList(raw: string | undefined): number[]; export declare const adminContext: (admins: Admins) => Plugin<{}, import("gramio").DeriveDefinitions & { global: { adminId: number; isAdmin: boolean; }; }, {}>; export {}; //# sourceMappingURL=admin.d.ts.map