import type { RemoteCustomerRole } from "./remote-profile.js";
export type RemoteWorkspaceInvitation = {
id: string;
organizationId: string;
email: string;
role: RemoteCustomerRole;
generation: number;
status: "pending" | "expired" | "accepted" | "revoked";
expiresAt: string;
createdAt: string;
delivery: {
state: "queued" | "sending" | "uncertain" | "provider_accepted" | "failed" | "cancelled";
attempts: number;
};
};
export type RemoteWorkspaceInvitationsPage = {
organizationId: string;
invitations: RemoteWorkspaceInvitation[];
nextCursor: string | null;
};
export type RemoteWorkspaceInvitationResult = {
invitation: RemoteWorkspaceInvitation;
changed: boolean;
};
export type RemoteWorkspaceInvitationAcceptance = {
organizationId: string;
membershipId: string;
accepted: true;
changed: boolean;
};
export type ListRemoteWorkspaceInvitations = Readonly<{
after?: string;
}>;
export type IssueRemoteWorkspaceInvitation = Readonly<{
email: string;
role: RemoteCustomerRole;
idempotencyKey: string;
confirm: true;
}>;
export type ResendRemoteWorkspaceInvitation = Readonly<{
expectedGeneration: number;
idempotencyKey: string;
confirm: true;
}>;
export type RevokeRemoteWorkspaceInvitation = Readonly<{
expectedGeneration: number;
confirm: true;
}>;
/** Secret input, never returned or persisted by the client. Acceptance does not select the new membership. */
export type AcceptRemoteWorkspaceInvitation = Readonly<{
token: string;
confirm: true;
}>;
export declare class WorkspaceInvitationInputError extends Error {
readonly code = "INVITATION_INPUT_INVALID";
constructor();
}
export declare const invitationFailures: {
readonly INVALID_REQUEST: readonly [400, "Invitation parameters were refused."];
readonly ACCOUNT_UNAVAILABLE: readonly [403, "Account is unavailable."];
readonly INTERACTIVE_SESSION_REQUIRED: readonly [403, "Fresh interactive sign-in is required."];
readonly WORKSPACE_ADMIN_REQUIRED: readonly [403, "A current workspace owner or admin is required."];
readonly INVITATION_FORBIDDEN: readonly [403, "Your current role cannot manage this invitation."];
readonly INVITATION_UNAVAILABLE: readonly [404, "Invitation is unavailable for this account."];
readonly INVITATION_CHANGED: readonly [409, "Invitation changed. Read its current generation before another action."];
readonly INVITATION_EXISTS: readonly [409, "A pending invitation already exists. Read current invitations."];
readonly ALREADY_MEMBER: readonly [409, "An active membership already exists. An invitation cannot change its role."];
readonly IDEMPOTENCY_CONFLICT: readonly [409, "This request key was used for different invitation parameters. Reconcile the original request."];
readonly INVITATION_LIMIT: readonly [429, "Invitation limit reached. Wait before issuing or resending."];
readonly INVITATION_BUSY: readonly [503, "Invitation is busy. Read its state before another action."];
readonly INVITATION_DELIVERY_UNAVAILABLE: readonly [503, "Invitation email delivery is unavailable."];
};
export type RemoteWorkspaceInvitationErrorCode = keyof typeof invitationFailures;
export declare class RemoteWorkspaceInvitationError extends Error {
readonly code: RemoteWorkspaceInvitationErrorCode;
readonly status: number;
constructor(code: RemoteWorkspaceInvitationErrorCode);
}
export declare class RemoteWorkspaceInvitationUnconfirmedError extends Error {
readonly code = "INVITATION_UNCONFIRMED";
constructor();
}
export declare class RemoteWorkspaceInvitationReadError extends Error {
readonly code = "INVITATION_READ_FAILED";
constructor();
}
export declare function invitationFailure(value: unknown, status: number): "ACCOUNT_UNAVAILABLE" | "INTERACTIVE_SESSION_REQUIRED" | "INVALID_REQUEST" | "WORKSPACE_ADMIN_REQUIRED" | "INVITATION_FORBIDDEN" | "INVITATION_UNAVAILABLE" | "INVITATION_CHANGED" | "INVITATION_EXISTS" | "ALREADY_MEMBER" | "IDEMPOTENCY_CONFLICT" | "INVITATION_LIMIT" | "INVITATION_BUSY" | "INVITATION_DELIVERY_UNAVAILABLE" | null;
export type InvitationAction = "list" | "get" | "issue" | "resend" | "revoke" | "accept";
export type InvitationInputs = {
list: ListRemoteWorkspaceInvitations;
get: Readonly<{
invitationId: string;
}>;
issue: IssueRemoteWorkspaceInvitation;
resend: ResendRemoteWorkspaceInvitation & Readonly<{
invitationId: string;
}>;
revoke: RevokeRemoteWorkspaceInvitation & Readonly<{
invitationId: string;
}>;
accept: AcceptRemoteWorkspaceInvitation & Readonly<{
invitationId: string;
}>;
};
export type InvitationResults = {
list: RemoteWorkspaceInvitationsPage;
get: {
invitation: RemoteWorkspaceInvitation;
};
issue: RemoteWorkspaceInvitationResult;
resend: RemoteWorkspaceInvitationResult;
revoke: RemoteWorkspaceInvitationResult;
accept: RemoteWorkspaceInvitationAcceptance;
};
export declare function invitationId(value: unknown): string;
/** Capture and validate all caller values before authentication or other awaits. */
export declare function invitationInput(action: A, input: InvitationInputs[A]): InvitationInputs[A];
export declare function invitationRequest(action: A, input: InvitationInputs[A]): {
path: string;
method: string;
body?: undefined;
} | {
path: string;
method: string;
body: string;
};
/** Project only validated contract fields; never surface arbitrary response metadata. */
export declare function parseInvitationResult(action: A, value: unknown, input: InvitationInputs[A], organizationId: string): InvitationResults[A];