/** * `scai setup env ` — provision the environment-scoped CM * automation client for one environment. * * The flow is list-or-mint, keyed on the stable `scai-cm-` client * name so re-runs are idempotent: * * 1. Resolve the env profile — needs organizationId + projectId + * environmentId. * 2. Use the env's deploy token (it carries `xmclouddeploy.clients:manage`, * requested at `scai setup login`) as the clients-API credential. * 3. List the org's environment clients; look for `scai-cm-`. * 4. Reconcile: * - keychain has the secret AND the server lists it → done. * - server lists it but the keychain has no secret → orphan * (lost secret — unrecoverable); delete it, then mint fresh. * - `--rotate` → delete + * re-mint regardless. * - neither → mint. * 5. Persist the minted client: its non-secret metadata (clientId, * name, mintedAt) into the env profile's `automationClient` block in * the config file, and only the secret into the OS keychain. */ import type { SitecoreApiClientOptions } from "../auth/index.js"; import type { CommonOptions } from "../shared/cli-options.js"; import type { Logger } from "../shared/logger.js"; /** Timing knobs for {@link waitForClientActivation} — overridable for tests. */ export interface ClientActivationOptions { /** Give up after this long (default 120_000 ms). */ timeoutMs?: number; /** First backoff delay (default 2_000 ms). */ initialDelayMs?: number; /** Backoff ceiling (default 15_000 ms). */ maxDelayMs?: number; } /** * Poll a client-credentials grant until a freshly-minted automation * client activates. * * A just-created Sitecore automation client is not immediately usable — * the identity provider takes up to ~2 min to propagate it, and the * grant fails until it has. Returns `true` once a token is obtained, * `false` if the window elapses first (the client is minted regardless * and usually becomes usable shortly after). */ export declare const waitForClientActivation: (credential: SitecoreApiClientOptions, logger: Logger, options?: ClientActivationOptions) => Promise; export type SetupEnvOptions = CommonOptions & { environmentName?: string; /** Preview the action without minting or deleting anything. */ whatIf?: boolean; /** Delete and re-mint the client even if one is already provisioned. */ rotate?: boolean; }; export declare const runSetupEnv: (options: SetupEnvOptions) => Promise;