import type { ClientOptions as InngestClientOptions } from './inngest/client'; import type { CompletionConsumedInput, ParsingConsumedInput, WorkflowConsumedInput } from './schemas/events'; import type { Origin } from './schemas/origin'; import type { TriggerClientOptions } from './trigger/client'; import { INNGEST_EVENT_KEY_ENV, INNGEST_SIGNING_KEY_ENV } from './inngest/client'; import { METERING_TRIGGER_SECRET_KEY_ENV } from './trigger/client'; export type MeteringTransport = 'inngest' | 'trigger'; /** * Configuration for the metering client. * * Inngest remains the default transport. When `transport` is omitted, the * client only selects Trigger.dev automatically if Trigger.dev is the only * configured transport. If both Inngest and Trigger.dev credentials are * available, Inngest wins to keep the migration safe. * * The client reads environment variables if explicit values are not provided: * * - `eventKey` falls back to `INNGEST_EVENT_KEY` * - `signingKey` falls back to `INNGEST_SIGNING_KEY` when Inngest is used * - `triggerSecretKey` falls back to `METERING_TRIGGER_SECRET_KEY` * * The client intentionally does not read the generic `TRIGGER_SECRET_KEY` * variable, so host projects that already use Trigger.dev do not accidentally * send metering events to the wrong project. */ export type ClientOptions = InngestClientOptions & TriggerClientOptions & { transport?: MeteringTransport; }; export type MeteringOptions = { inngestEnvironment?: string; }; /** * Creates a metering client for the given origin. * * By default events are sent through Inngest. When `transport` is omitted, the * client also prefers Inngest if both Inngest and Trigger.dev credentials are * present. To send through Trigger.dev explicitly, use `transport: 'trigger'` * and either pass `triggerSecretKey` or set `METERING_TRIGGER_SECRET_KEY`. * * @example * ```ts * const metering = useMetering('tela-api', { * transport: 'trigger', * triggerSecretKey: env.METERING_TRIGGER_SECRET_KEY, * }) * ``` */ export declare function useMetering(origin: Origin, options?: ClientOptions): { sendParsingConsumedEvent: (data: ParsingConsumedInput) => Promise; sendCompletionConsumedEvent: (data: CompletionConsumedInput) => Promise; sendWorkflowConsumedEvent: (data: WorkflowConsumedInput) => Promise; }; export * from './schemas/action'; export { INNGEST_EVENT_KEY_ENV, INNGEST_SIGNING_KEY_ENV, METERING_TRIGGER_SECRET_KEY_ENV, };