59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
|
|
import * as plugins from '../loint-reception.plugins.js';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A UserInvitation represents an invitation to join an organization.
|
||
|
|
* Key characteristics:
|
||
|
|
* - Unique by email (multiple orgs can share the same invitation)
|
||
|
|
* - Converts to real User on registration or folds into existing user
|
||
|
|
* - Auto-expires after 90 days
|
||
|
|
*/
|
||
|
|
export interface IUserInvitation {
|
||
|
|
id: string;
|
||
|
|
data: {
|
||
|
|
/** The invited email address - unique key for sharing across orgs */
|
||
|
|
email: string;
|
||
|
|
|
||
|
|
/** Secure token for invitation link validation */
|
||
|
|
token: string;
|
||
|
|
|
||
|
|
/** Current status of the invitation */
|
||
|
|
status: 'pending' | 'accepted' | 'expired' | 'cancelled';
|
||
|
|
|
||
|
|
/** When the invitation was first created */
|
||
|
|
createdAt: number;
|
||
|
|
|
||
|
|
/** When the invitation expires (createdAt + 90 days) */
|
||
|
|
expiresAt: number;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Organizations that have invited this email.
|
||
|
|
* Multiple orgs can link to the same invitation.
|
||
|
|
*/
|
||
|
|
organizationRefs: IOrganizationInvitationRef[];
|
||
|
|
|
||
|
|
/** When the invitation was accepted (user registered/folded) */
|
||
|
|
acceptedAt?: number;
|
||
|
|
|
||
|
|
/** The User ID after conversion (when accepted) */
|
||
|
|
convertedToUserId?: string;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Represents one organization's invitation to the user.
|
||
|
|
* Stored as part of IUserInvitation.organizationRefs array.
|
||
|
|
*/
|
||
|
|
export interface IOrganizationInvitationRef {
|
||
|
|
/** The organization that sent this invitation */
|
||
|
|
organizationId: string;
|
||
|
|
|
||
|
|
/** The user who sent the invitation */
|
||
|
|
invitedByUserId: string;
|
||
|
|
|
||
|
|
/** When this org invited the user */
|
||
|
|
invitedAt: number;
|
||
|
|
|
||
|
|
/** Roles to assign when the invitation is accepted */
|
||
|
|
roles: string[];
|
||
|
|
}
|