import { Querier, Transaction } from "@platform-modules/db";
//#region src/types.d.ts
type PromoKind = 'percentage' | 'fixed' | 'bogo';
type PromoFunder = 'platform' | 'vendor';
type PromoScope = {
  kind: 'all';
} | {
  kind: 'products';
  ids: string[];
} | {
  kind: 'categories';
  ids: string[];
} | {
  kind: 'tags';
  tags: string[];
} | {
  kind: 'vendor';
  vendorId: string;
};
interface PromoEligibility {
  firstPurchaseOnly?: boolean;
  membersOnly?: boolean;
  allowlistOnly?: boolean;
}
interface Promo {
  id: string;
  code: string;
  kind: PromoKind;
  valueBps?: number;
  valueAmount?: bigint;
  currency?: string;
  /** Percentage promos only: maximum discount granted, in minor units. */
  maxDiscountAmount?: bigint;
  bogo?: {
    buyQty: number;
    getQty: number;
  };
  scope: PromoScope;
  eligibility: PromoEligibility;
  funder: PromoFunder;
  maxUses?: number;
  perUserCap?: number;
  startsAt?: Date;
  endsAt?: Date;
  minOrderAmount?: bigint;
  /** Maximum eligible cart subtotal, in minor units; twin of minOrderAmount. */
  maxOrderAmount?: bigint;
  active: boolean;
  vendorId: string | null;
}
interface PromoContext {
  now: Date;
  userId: string | null;
  cartSubtotal: bigint;
  cartCurrency: string;
  lines: DiscountLine[];
  isFirstPurchase?: boolean;
  isMember?: boolean;
  isAllowlisted?: boolean;
  globalUses?: number;
  userRedemptionCount?: number;
}
interface DiscountLine {
  lineId: string;
  unitPrice: bigint;
  qty: number;
  vendorId: string | null;
  productId?: string;
  categoryIds?: string[];
  tags?: string[];
}
interface DiscountableCart {
  currency: string;
  lines: DiscountLine[];
}
type PromoRejectReason = 'inactive' | 'not_started' | 'expired' | 'min_order_not_met' | 'max_order_exceeded' | 'currency_mismatch' | 'out_of_scope' | 'not_first_purchase' | 'not_member' | 'not_on_allowlist' | 'quota_exhausted' | 'per_user_cap_reached';
type PromoValidation = {
  ok: true;
  promo: Promo;
} | {
  ok: false;
  reason: PromoRejectReason;
};
interface DiscountResult {
  total: bigint;
  perLine: Array<{
    lineId: string;
    amount: bigint;
  }>;
  funder: PromoFunder;
}
//#endregion
//#region src/apply.d.ts
declare function applyPromo(promo: Promo, cart: DiscountableCart): DiscountResult;
//#endregion
//#region src/errors.d.ts
declare class PromoValidationError extends Error {
  readonly field: string;
  readonly name = "PromoValidationError";
  readonly code: "PROMO_VALIDATION";
  constructor(field: string);
}
declare class PromoQuotaExhaustedError extends Error {
  readonly reason: 'global' | 'per_user';
  readonly name = "PromoQuotaExhaustedError";
  readonly code: "PROMO_QUOTA_EXHAUSTED";
  constructor(reason: 'global' | 'per_user');
}
declare function isPromoValidationError(e: unknown): e is PromoValidationError;
declare function isPromoQuotaExhaustedError(e: unknown): e is PromoQuotaExhaustedError;
//#endregion
//#region src/schema.d.ts
declare const promo: import("drizzle-orm/pg-core").PgTableWithColumns<{
  name: "promo";
  schema: undefined;
  columns: {
    id: import("drizzle-orm/pg-core").PgColumn<{
      name: "id";
      tableName: "promo";
      dataType: "string";
      columnType: "PgUUID";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: true;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    code: import("drizzle-orm/pg-core").PgColumn<{
      name: "code";
      tableName: "promo";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    kind: import("drizzle-orm/pg-core").PgColumn<{
      name: "kind";
      tableName: "promo";
      dataType: "string";
      columnType: "PgText";
      data: PromoKind;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {
      $type: PromoKind;
    }>;
    valueBps: import("drizzle-orm/pg-core").PgColumn<{
      name: "value_bps";
      tableName: "promo";
      dataType: "number";
      columnType: "PgInteger";
      data: number;
      driverParam: string | number;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    valueAmount: import("drizzle-orm/pg-core").PgColumn<{
      name: "value_amount";
      tableName: "promo";
      dataType: "bigint";
      columnType: "PgBigInt64";
      data: bigint;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    currency: import("drizzle-orm/pg-core").PgColumn<{
      name: "currency";
      tableName: "promo";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    maxDiscountAmount: import("drizzle-orm/pg-core").PgColumn<{
      name: "max_discount_amount";
      tableName: "promo";
      dataType: "bigint";
      columnType: "PgBigInt64";
      data: bigint;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    bogoBuyQty: import("drizzle-orm/pg-core").PgColumn<{
      name: "bogo_buy_qty";
      tableName: "promo";
      dataType: "number";
      columnType: "PgInteger";
      data: number;
      driverParam: string | number;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    bogoGetQty: import("drizzle-orm/pg-core").PgColumn<{
      name: "bogo_get_qty";
      tableName: "promo";
      dataType: "number";
      columnType: "PgInteger";
      data: number;
      driverParam: string | number;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    scope: import("drizzle-orm/pg-core").PgColumn<{
      name: "scope";
      tableName: "promo";
      dataType: "json";
      columnType: "PgJsonb";
      data: PromoScope;
      driverParam: unknown;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {
      $type: PromoScope;
    }>;
    eligibility: import("drizzle-orm/pg-core").PgColumn<{
      name: "eligibility";
      tableName: "promo";
      dataType: "json";
      columnType: "PgJsonb";
      data: PromoEligibility;
      driverParam: unknown;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {
      $type: PromoEligibility;
    }>;
    funder: import("drizzle-orm/pg-core").PgColumn<{
      name: "funder";
      tableName: "promo";
      dataType: "string";
      columnType: "PgText";
      data: PromoFunder;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {
      $type: PromoFunder;
    }>;
    maxUses: import("drizzle-orm/pg-core").PgColumn<{
      name: "max_uses";
      tableName: "promo";
      dataType: "number";
      columnType: "PgInteger";
      data: number;
      driverParam: string | number;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    perUserCap: import("drizzle-orm/pg-core").PgColumn<{
      name: "per_user_cap";
      tableName: "promo";
      dataType: "number";
      columnType: "PgInteger";
      data: number;
      driverParam: string | number;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    uses: import("drizzle-orm/pg-core").PgColumn<{
      name: "uses";
      tableName: "promo";
      dataType: "number";
      columnType: "PgInteger";
      data: number;
      driverParam: string | number;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    startsAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "starts_at";
      tableName: "promo";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    endsAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "ends_at";
      tableName: "promo";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    minOrderAmount: import("drizzle-orm/pg-core").PgColumn<{
      name: "min_order_amount";
      tableName: "promo";
      dataType: "bigint";
      columnType: "PgBigInt64";
      data: bigint;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    maxOrderAmount: import("drizzle-orm/pg-core").PgColumn<{
      name: "max_order_amount";
      tableName: "promo";
      dataType: "bigint";
      columnType: "PgBigInt64";
      data: bigint;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    active: import("drizzle-orm/pg-core").PgColumn<{
      name: "active";
      tableName: "promo";
      dataType: "boolean";
      columnType: "PgBoolean";
      data: boolean;
      driverParam: boolean;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    vendorId: import("drizzle-orm/pg-core").PgColumn<{
      name: "vendor_id";
      tableName: "promo";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    createdAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "created_at";
      tableName: "promo";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    updatedAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "updated_at";
      tableName: "promo";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
  };
  dialect: "pg";
}>;
declare const promoUserUsage: import("drizzle-orm/pg-core").PgTableWithColumns<{
  name: "promo_user_usage";
  schema: undefined;
  columns: {
    promoId: import("drizzle-orm/pg-core").PgColumn<{
      name: "promo_id";
      tableName: "promo_user_usage";
      dataType: "string";
      columnType: "PgUUID";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    userId: import("drizzle-orm/pg-core").PgColumn<{
      name: "user_id";
      tableName: "promo_user_usage";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    uses: import("drizzle-orm/pg-core").PgColumn<{
      name: "uses";
      tableName: "promo_user_usage";
      dataType: "number";
      columnType: "PgInteger";
      data: number;
      driverParam: string | number;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    createdAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "created_at";
      tableName: "promo_user_usage";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    updatedAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "updated_at";
      tableName: "promo_user_usage";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
  };
  dialect: "pg";
}>;
declare const promotionsSchema: {
  promo: import("drizzle-orm/pg-core").PgTableWithColumns<{
    name: "promo";
    schema: undefined;
    columns: {
      id: import("drizzle-orm/pg-core").PgColumn<{
        name: "id";
        tableName: "promo";
        dataType: "string";
        columnType: "PgUUID";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: true;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      code: import("drizzle-orm/pg-core").PgColumn<{
        name: "code";
        tableName: "promo";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      kind: import("drizzle-orm/pg-core").PgColumn<{
        name: "kind";
        tableName: "promo";
        dataType: "string";
        columnType: "PgText";
        data: PromoKind;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {
        $type: PromoKind;
      }>;
      valueBps: import("drizzle-orm/pg-core").PgColumn<{
        name: "value_bps";
        tableName: "promo";
        dataType: "number";
        columnType: "PgInteger";
        data: number;
        driverParam: string | number;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      valueAmount: import("drizzle-orm/pg-core").PgColumn<{
        name: "value_amount";
        tableName: "promo";
        dataType: "bigint";
        columnType: "PgBigInt64";
        data: bigint;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      currency: import("drizzle-orm/pg-core").PgColumn<{
        name: "currency";
        tableName: "promo";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      maxDiscountAmount: import("drizzle-orm/pg-core").PgColumn<{
        name: "max_discount_amount";
        tableName: "promo";
        dataType: "bigint";
        columnType: "PgBigInt64";
        data: bigint;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      bogoBuyQty: import("drizzle-orm/pg-core").PgColumn<{
        name: "bogo_buy_qty";
        tableName: "promo";
        dataType: "number";
        columnType: "PgInteger";
        data: number;
        driverParam: string | number;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      bogoGetQty: import("drizzle-orm/pg-core").PgColumn<{
        name: "bogo_get_qty";
        tableName: "promo";
        dataType: "number";
        columnType: "PgInteger";
        data: number;
        driverParam: string | number;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      scope: import("drizzle-orm/pg-core").PgColumn<{
        name: "scope";
        tableName: "promo";
        dataType: "json";
        columnType: "PgJsonb";
        data: PromoScope;
        driverParam: unknown;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {
        $type: PromoScope;
      }>;
      eligibility: import("drizzle-orm/pg-core").PgColumn<{
        name: "eligibility";
        tableName: "promo";
        dataType: "json";
        columnType: "PgJsonb";
        data: PromoEligibility;
        driverParam: unknown;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {
        $type: PromoEligibility;
      }>;
      funder: import("drizzle-orm/pg-core").PgColumn<{
        name: "funder";
        tableName: "promo";
        dataType: "string";
        columnType: "PgText";
        data: PromoFunder;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {
        $type: PromoFunder;
      }>;
      maxUses: import("drizzle-orm/pg-core").PgColumn<{
        name: "max_uses";
        tableName: "promo";
        dataType: "number";
        columnType: "PgInteger";
        data: number;
        driverParam: string | number;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      perUserCap: import("drizzle-orm/pg-core").PgColumn<{
        name: "per_user_cap";
        tableName: "promo";
        dataType: "number";
        columnType: "PgInteger";
        data: number;
        driverParam: string | number;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      uses: import("drizzle-orm/pg-core").PgColumn<{
        name: "uses";
        tableName: "promo";
        dataType: "number";
        columnType: "PgInteger";
        data: number;
        driverParam: string | number;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      startsAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "starts_at";
        tableName: "promo";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      endsAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "ends_at";
        tableName: "promo";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      minOrderAmount: import("drizzle-orm/pg-core").PgColumn<{
        name: "min_order_amount";
        tableName: "promo";
        dataType: "bigint";
        columnType: "PgBigInt64";
        data: bigint;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      maxOrderAmount: import("drizzle-orm/pg-core").PgColumn<{
        name: "max_order_amount";
        tableName: "promo";
        dataType: "bigint";
        columnType: "PgBigInt64";
        data: bigint;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      active: import("drizzle-orm/pg-core").PgColumn<{
        name: "active";
        tableName: "promo";
        dataType: "boolean";
        columnType: "PgBoolean";
        data: boolean;
        driverParam: boolean;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      vendorId: import("drizzle-orm/pg-core").PgColumn<{
        name: "vendor_id";
        tableName: "promo";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      createdAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "created_at";
        tableName: "promo";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      updatedAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "updated_at";
        tableName: "promo";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
    };
    dialect: "pg";
  }>;
  promoUserUsage: import("drizzle-orm/pg-core").PgTableWithColumns<{
    name: "promo_user_usage";
    schema: undefined;
    columns: {
      promoId: import("drizzle-orm/pg-core").PgColumn<{
        name: "promo_id";
        tableName: "promo_user_usage";
        dataType: "string";
        columnType: "PgUUID";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      userId: import("drizzle-orm/pg-core").PgColumn<{
        name: "user_id";
        tableName: "promo_user_usage";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      uses: import("drizzle-orm/pg-core").PgColumn<{
        name: "uses";
        tableName: "promo_user_usage";
        dataType: "number";
        columnType: "PgInteger";
        data: number;
        driverParam: string | number;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      createdAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "created_at";
        tableName: "promo_user_usage";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      updatedAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "updated_at";
        tableName: "promo_user_usage";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
    };
    dialect: "pg";
  }>;
};
type PromotionsSchema = typeof promotionsSchema;
//#endregion
//#region src/migrate.d.ts
declare class PromoMigrateError extends Error {
  readonly detail: string;
  readonly name = "PromoMigrateError";
  readonly code: "PROMO_MIGRATE";
  constructor(detail: string);
}
declare function isPromoMigrateError(e: unknown): e is PromoMigrateError;
declare function pushSchema(db: Querier<PromotionsSchema>): Promise<void>;
//#endregion
//#region src/reads.d.ts
declare function getPromoByCode(q: Querier<PromotionsSchema>, code: string, vendorId?: string | null): Promise<Promo | null>;
//#endregion
//#region src/record-redemption.d.ts
declare function recordRedemption(tx: Transaction<PromotionsSchema>, promoId: string, userId: string | null): Promise<void>;
//#endregion
//#region src/validate.d.ts
declare function validatePromo(promo: Promo, ctx: PromoContext): PromoValidation;
//#endregion
export { type DiscountLine, type DiscountResult, type DiscountableCart, type Promo, type PromoContext, type PromoEligibility, type PromoFunder, type PromoKind, PromoMigrateError, PromoQuotaExhaustedError, type PromoRejectReason, type PromoScope, type PromoValidation, PromoValidationError, type PromotionsSchema, applyPromo, getPromoByCode, isPromoMigrateError, isPromoQuotaExhaustedError, isPromoValidationError, promo, promoUserUsage, promotionsSchema, pushSchema, recordRedemption, validatePromo };