import { type CompleteSelfServiceOrganizationSetupResponse as CompleteSelfServiceOrganizationSetupResponseType, type CompleteOrganizationUserSetupResponse as CompleteOrganizationUserSetupResponseType, type OrganizationUserSetupDelivery as OrganizationUserSetupDeliveryType, type OrganizationUserSetupPreview as OrganizationUserSetupPreviewType } from "@opengeni/contracts"; import type { Database } from "./database.js"; export declare function getSelfServiceOrganizationOnboardingState(db: Database, input: { authUserId: string; email: string; emailVerified: boolean; }): Promise<"required" | "invitation_pending" | "unavailable" | "complete">; export declare function preflightOrganizationUserSetup(db: Database, tokenDigest: string): Promise<"pending" | "completed" | "unavailable">; export declare function completeSelfServiceOrganizationSetup(db: Database, input: { authUserId: string; actorSubjectId: string; organizationName: string; operationId: string; requestFingerprint: string; /** Legacy compatibility flag; eligibility issuance is unconditional after migration 0845. */ trialCreditsEnabled?: boolean; trialCreditModelIds?: string[] | undefined; }): Promise; /** Keyed hashes of the trusted client network; never the address itself. */ export type SignupNetworkSource = { addressHash: string; prefixHash: string; }; /** * Whether the owner's mail address is a disposable inbox (its domain or MX * host is a temporary-inbox service, migration 1493), as the API found at * setup. Only this flag is recorded, never the domain or the MX host. */ export type SignupMailSignal = "disposable" | "clear"; /** * Hands the setup trigger the owner's mail signal for this transaction * (migration 1493). Transaction-local and set by the trusted API; null * records nothing (unknown). */ export declare function setSignupMailSignalForSetup(txDb: Database, signal: SignupMailSignal | null | undefined): Promise; /** * Hands the setup receipt trigger the signup network (migration 1354) for * this transaction. Every route that can create a self-serve organization * must call it before the receipt is written, so the network rate limit and * velocity rule see the organization. Transaction-local and set by the * trusted API, never from the request body. Null records nothing. */ export declare function setSignupNetworkSourceForSetup(txDb: Database, signupNetwork: SignupNetworkSource | null | undefined): Promise; /** * Accounts the setup receipt trigger of this transaction asked to evaluate * after commit (this one first, then recent same-network organizations). * Empty for a replay of a committed setup or when detection is off. */ export declare function readSignupNetworkEvaluateAccounts(txDb: Database): Promise; /** * {@link completeSelfServiceOrganizationSetup} that also hands the setup * receipt trigger the signup network (migration 1354). A new self-serve * organization records it and may be refused with SQLSTATE OG429 by the * network rate limit; an idempotent replay records and refuses nothing. * `evaluateAccountIds` lists the accounts to evaluate after commit (this one * first, then recent same-network organizations), empty when detection is off. */ export declare function completeSelfServiceOrganizationSetupWithSignupNetwork(db: Database, input: { authUserId: string; actorSubjectId: string; organizationName: string; operationId: string; requestFingerprint: string; /** Legacy compatibility flag; eligibility issuance is unconditional after migration 0845. */ trialCreditsEnabled?: boolean; trialCreditModelIds?: string[] | undefined; signupNetwork?: SignupNetworkSource | null; signupMailSignal?: SignupMailSignal | null; }): Promise<{ setup: CompleteSelfServiceOrganizationSetupResponseType; evaluateAccountIds: string[]; }>; export declare function ensureOrganizationUserSetupIntent(db: Database, input: { organizationId: string; actorSubjectId: string; invitationId: string; tokenDigest: string; expiresAt: string; }): Promise<{ status: "pending" | "completed"; }>; export type OrganizationUserSetupDeliveryClaim = { claimed: false; delivery: OrganizationUserSetupDeliveryType; } | { claimed: true; delivery: OrganizationUserSetupDeliveryType; attemptId: string; claimHolderId: string; invitationId: string; providerKey: string; recipientEmail: string; recipientName: string | null; organizationName: string; organizationRole: "owner" | "admin" | "member"; sharedWorkspaceAccess: Array<{ workspaceId: string; workspaceName: string; role: "viewer" | "member" | "admin"; }>; expiresAt: string; setupTokenTransport: "fragment" | "query" | null; payloadDigest: string | null; }; export declare function claimOrganizationUserSetupDelivery(db: Database, input: { organizationId: string; actorSubjectId: string; invitationId: string; invitationOperationId?: string; operationId: string; }): Promise; export declare function prepareOrganizationUserSetupDelivery(db: Database, input: { organizationId: string; actorSubjectId: string; deliveryId: string; attemptId: string; claimHolderId: string; tokenDigest: string; payloadDigest: string; setupTokenTransport: "fragment" | "query"; providerIdempotencyScope: string; providerIdempotencyRetentionSeconds: number; }): Promise; export declare function settleOrganizationUserSetupDelivery(db: Database, input: { organizationId: string; actorSubjectId: string; deliveryId: string; attemptId: string; claimHolderId: string; outcome: "sent" | "failed" | "outcome_unknown"; errorClass?: string; providerMessageId?: string | null; }): Promise; export declare function previewOrganizationUserSetup(db: Database, tokenDigest: string): Promise; export declare function completeOrganizationUserSetup(db: Database, input: { tokenDigest: string; operationId: string; requestFingerprint: string; authUserId: string; name: string; passwordHash: string; }): Promise;