import { s as LedgerDbBag, u as ProviderEvent } from "../index-Qle7altp.js";
import { Schema } from "@platform-modules/db";
//#region src/subscriptions/types.d.ts
type CreateSubscriptionInput = {
  idempotencyKey: string;
  planId: string;
  currentPeriod: string;
  status?: string;
};
type Subscription = {
  id: string;
  status: string;
  currentPeriod: string;
  planId: string;
};
type ParsedSubscriptionWebhook = {
  kind: 'settlement';
  subscriptionId: string;
  period: string;
  amountMinor: bigint;
  currency: string;
  eventId?: string;
} | {
  kind: 'other';
  raw: unknown;
  eventId?: string;
};
//#endregion
//#region src/subscriptions/port.d.ts
interface SubscriptionProvider {
  createSubscription(input: CreateSubscriptionInput): Promise<Subscription>;
  cancelSubscription(id: string): Promise<void>;
  getSubscription(id: string): Promise<Subscription>;
}
//#endregion
//#region src/subscriptions/ingest.d.ts
interface SubscriptionWebhookProvider extends SubscriptionProvider {
  parseWebhook(rawEvent: unknown): Promise<ParsedSubscriptionWebhook>;
}
type IngestWebhookDeps<S extends Schema = Schema> = LedgerDbBag<S> & {
  provider: SubscriptionWebhookProvider;
};
declare function buildChargeKey(subscriptionId: string, period: string): string;
declare function ingestWebhook<S extends Schema = Schema>(deps: IngestWebhookDeps<S>, rawEvent: unknown): Promise<ProviderEvent>;
//#endregion
export { type CreateSubscriptionInput, type IngestWebhookDeps, type ParsedSubscriptionWebhook, type Subscription, type SubscriptionProvider, type SubscriptionWebhookProvider, buildChargeKey, ingestWebhook };