import { SmrtCollection } from '@happyvertical/smrt-core'; import { Commission } from '../models/Commission.js'; import { CommissionStatus } from '../types.js'; export declare class CommissionCollection extends SmrtCollection { static readonly _itemClass: typeof Commission; /** All commissions for an earner, newest first. */ findByEarner(earnerId: string): Promise; /** All commissions derived from one earning event. */ findByEvent(earningEventId: string): Promise; /** Commissions by lifecycle status, newest first. */ findByStatus(status: CommissionStatus): Promise; /** Look up a commission by its idempotency natural key. */ findByDedupeKey(dedupeKey: string): Promise; /** * Payable commissions for an earner+currency that no payout batch has * settled yet — the rows `CommissionPayoutService.createPayoutBatch` * gathers. * * Pass `scope` to narrow the gather to one earning source (e.g. a single * ad network): only commissions whose `(sourceKind, sourceId)` match are * returned. This lets a caller cut a payout batch that claims *only* its * network's commissions, so concurrent per-network batches settle * disjoint sets instead of one sweeping the other's rows. */ findPayableUnsettled(earnerId: string, currency: string, scope?: { sourceKind: string; sourceId: string; }): Promise; /** Σ amountCents of {@link findPayableUnsettled} rows (integer cents). */ sumPayableByEarner(earnerId: string, currency: string): Promise; /** Commissions settled by one payout batch. */ findByPayout(payoutId: string): Promise; /** * Commissions settled by ANY of the given payout batches, in one `IN` * query — the batched-membership primitive behind the source-scoped * payout-history verification (one query per page instead of one per * payout). Empty input returns `[]` without querying. */ findByPayouts(payoutIds: string[]): Promise; /** * Conditionally claim rows for a payout batch: each row is re-loaded * fresh and stamped with `payoutId` only when it is still payable and * unclaimed (or already claimed by THIS payout — the idempotent-retry / * repair case). Rows claimed by a DIFFERENT payout are skipped, and every * claim is verified by a post-save re-read so a lost race never counts * toward the caller's totals. * * Reads and writes go through the model layer (`get` / `save`), so this * respects the tenancy interceptor (a cross-tenant id resolves to `null` * and is skipped, never mutated) and the DB dialect (an empty FK is `''` * on SQLite / `NULL` on the native-`uuid` Postgres/DuckDB columns — the * model normalizes both). * * This is the single place claim semantics live. It narrows the * concurrent-batch window to the re-read granularity but is NOT a * cross-row transaction — safe concurrent settlement relies on batches * using DISJOINT scopes (see `CommissionPayoutService.createPayoutBatch`); * overlapping concurrent scopes must be serialized by the caller. * * Returns the claimed rows (freshly loaded, `payoutId` verified). */ claimForPayout(commissionIds: string[], payoutId: string): Promise; } export default CommissionCollection; //# sourceMappingURL=CommissionCollection.d.ts.map