import { a as CorsairInternalConfig } from './index-BpAiZmOk.js'; import { CorsairDatabase } from './db.js'; import { C as CorsairPlugin, e as CorsairSingleTenantClient, d as CorsairTenantWrapper } from './index-bq7b_mHy.js'; import 'kysely'; import './index-eydqYIn0.js'; import 'zod'; import 'pg'; import 'postgres'; import './orm.js'; import './types-Bsv_KdHs.js'; /** Plugin id → credential field → value (from CLI `field=value` pairs). */ type SetupCredentials = Record>; interface SetupCorsairOptions { /** * Tenant to provision account rows and account-level credentials for. * Optional on single-tenant instances (defaults to `"default"`). * On multi-tenant instances: required for account-level credentials and * backfill; omit when only setting integration-level credentials. */ tenantId?: string; /** * Credentials to persist during setup (integration-level fields use * `corsair.keys.`; account-level fields use the tenant client). */ credentials?: SetupCredentials; /** * When true, calls list endpoints for every plugin defined in * setup/backfill.config.ts to seed the local database with initial data. */ backfill?: boolean; /** * Whether setupCorsair is being called from the CLI or from a script. * Defaults to 'script'. When 'cli', missing-credential messages are printed * as runnable CLI flags instead of JS method calls. */ caller?: 'cli' | 'script'; /** * When true, setup messages are collected in the return value only — nothing * is written to stdout/stderr. Used for internal provisioning (e.g. Hub connect). */ silent?: boolean; } type SetupLog = (msg: string) => void; type SetupWarn = (msg: string) => void; type SetupCorsairInstance = CorsairSingleTenantClient | CorsairTenantWrapper; type SetupInternalConfig = CorsairInternalConfig & { database: CorsairDatabase; }; type SetupTenantScope = { multiTenant: boolean; tenantIdProvided: boolean; tenantId: string; provisionAccounts: boolean; }; /** * Initialises a corsair instance end-to-end: * * 1. Checks that all required corsair_* tables exist (warns if any are missing). * 2. Ensures every configured plugin has rows in `corsair_integrations` and * `corsair_accounts` for the requested tenant and issues DEKs where needed. * 3. Checks auth status for each plugin and logs guidance for any missing credentials. * When `caller` is 'cli', guidance is printed as CLI flags instead of JS calls. * 4. If `{ backfill: true }`, calls the list endpoints defined in * `setup/backfill.config.ts` for each plugin that has auth configured. * * To set credentials, use the corsair client API directly after setup: * - Integration-level (shared across all tenants): `corsair.keys.plugin.set_*(value)` * - Account-level (per-tenant): `corsair.withTenant(tenantId).plugin.keys.set_*(value)` * * Multi-tenant instances: pass `options.tenantId` for account-level work (account * rows, account credentials, backfill). Integration-only setup may omit tenantId. * * Returns a newline-separated string of all setup output. */ declare function setupCorsair(corsair: SetupCorsairInstance, options?: SetupCorsairOptions): Promise; declare function applySetupCredentials(corsair: SetupCorsairInstance, tenantScope: SetupTenantScope, credentials: SetupCredentials, internal: SetupInternalConfig, log: SetupLog, warn: SetupWarn): Promise; export { type SetupCorsairOptions, type SetupCredentials, applySetupCredentials, setupCorsair };