import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes } from 'sequelize'; import type { LiteralUnion } from 'type-fest'; import { TenantModel } from '../tenant-model'; import { GroupedBN, GroupedStrList, MeterEventPayload, MeterEventStatus, SourceData } from './types'; export declare const nextMeterEventId: (size?: number) => string; export declare class MeterEvent extends TenantModel, InferCreationAttributes> { id: CreationOptional; event_name: string; payload: MeterEventPayload; identifier: string; timestamp: number; livemode: boolean; instance_did?: string; status: MeterEventStatus; processed_at?: number; attempt_count: number; next_attempt?: number; credit_consumed: string; credit_pending: string; metadata?: Record; source_data?: SourceData; created_by?: string; created_via: LiteralUnion<'api' | 'dashboard' | 'webhook' | 'batch', string>; created_at: CreationOptional; updated_at: CreationOptional; static readonly GENESIS_ATTRIBUTES: { id: { type: DataTypes.StringDataType; primaryKey: boolean; allowNull: boolean; defaultValue: (size?: number) => string; }; event_name: { type: DataTypes.StringDataType; allowNull: boolean; }; timestamp: { type: DataTypes.IntegerDataTypeConstructor; allowNull: boolean; }; payload: { type: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; validate: { hasRequiredFields(value: any): void; }; }; identifier: { type: DataTypes.StringDataType; allowNull: boolean; }; livemode: { type: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; status: { type: DataTypes.EnumDataType<"completed" | "pending" | "processing" | "requires_action" | "requires_capture" | "canceled">; defaultValue: string; allowNull: boolean; }; attempt_count: { type: DataTypes.IntegerDataTypeConstructor; defaultValue: number; allowNull: boolean; }; next_attempt: { type: DataTypes.IntegerDataTypeConstructor; allowNull: boolean; }; processed_at: { type: DataTypes.IntegerDataTypeConstructor; allowNull: boolean; }; credit_consumed: { type: DataTypes.StringDataType; defaultValue: string; allowNull: boolean; }; credit_pending: { type: DataTypes.StringDataType; defaultValue: string; allowNull: boolean; }; metadata: { type: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; created_by: { type: DataTypes.StringDataType; allowNull: boolean; }; created_via: { type: DataTypes.EnumDataType<"api" | "dashboard" | "webhook" | "batch">; allowNull: boolean; }; created_at: { type: DataTypes.DateDataTypeConstructor; defaultValue: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; updated_at: { type: DataTypes.DateDataTypeConstructor; defaultValue: DataTypes.AbstractDataTypeConstructor; allowNull: boolean; }; }; markAsCompleted(): Promise; markAsProcessing(): Promise; markAsRequiresCapture(errorMessage: string, nextAttemptTime: number): Promise; markAsRequiresAction(errorMessage: string): Promise; markAsCanceled(reason: string): Promise; getCustomerId(): string; getValue(): string; getSubscriptionId(): string | undefined; static initialize(sequelize: any): void; static processUnprocessedEvents(eventName?: string, limit?: number): Promise; static isEventExists(identifier: string): Promise; static getEventStats(eventName: string, startTime?: Date, endTime?: Date): Promise<{ total_events: number; processed_events: number; pending_events: number; total_value: number; }>; static expand(events: MeterEvent[], livemode?: boolean, options?: { customer?: boolean; subscription?: boolean; meter?: boolean; }): Promise; private static _getPendingAmounts; static getPendingAmounts({ subscriptionId, livemode, currencyId, status, customerId, }: { subscriptionId?: string; livemode?: boolean; currencyId?: string; status?: MeterEventStatus | MeterEventStatus[]; customerId?: string; }): Promise<[GroupedBN, GroupedStrList, MeterEvent[]]>; } export type TMeterEvent = InferAttributes;