212 lines
4.4 KiB
TypeScript
212 lines
4.4 KiB
TypeScript
|
|
import * as data from '../data/index.js';
|
||
|
|
import * as plugins from '../loint-reception.plugins.js';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create an invitation to join an organization
|
||
|
|
*/
|
||
|
|
export interface IReq_CreateInvitation
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_CreateInvitation
|
||
|
|
> {
|
||
|
|
method: 'createInvitation';
|
||
|
|
request: {
|
||
|
|
jwt: string;
|
||
|
|
organizationId: string;
|
||
|
|
email: string;
|
||
|
|
roles: string[];
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
success: boolean;
|
||
|
|
invitation?: data.IUserInvitation;
|
||
|
|
message?: string;
|
||
|
|
/** True if a new invitation was created, false if email was added to existing */
|
||
|
|
isNew: boolean;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get pending invitations for an organization
|
||
|
|
*/
|
||
|
|
export interface IReq_GetOrgInvitations
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_GetOrgInvitations
|
||
|
|
> {
|
||
|
|
method: 'getOrgInvitations';
|
||
|
|
request: {
|
||
|
|
jwt: string;
|
||
|
|
organizationId: string;
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
invitations: data.IUserInvitation[];
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get members of an organization (users with roles)
|
||
|
|
*/
|
||
|
|
export interface IReq_GetOrgMembers
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_GetOrgMembers
|
||
|
|
> {
|
||
|
|
method: 'getOrgMembers';
|
||
|
|
request: {
|
||
|
|
jwt: string;
|
||
|
|
organizationId: string;
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
members: Array<{
|
||
|
|
user: data.IUser;
|
||
|
|
role: data.IRole;
|
||
|
|
}>;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Cancel a pending invitation
|
||
|
|
*/
|
||
|
|
export interface IReq_CancelInvitation
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_CancelInvitation
|
||
|
|
> {
|
||
|
|
method: 'cancelInvitation';
|
||
|
|
request: {
|
||
|
|
jwt: string;
|
||
|
|
organizationId: string;
|
||
|
|
invitationId: string;
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
success: boolean;
|
||
|
|
message?: string;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Resend invitation email
|
||
|
|
*/
|
||
|
|
export interface IReq_ResendInvitation
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_ResendInvitation
|
||
|
|
> {
|
||
|
|
method: 'resendInvitation';
|
||
|
|
request: {
|
||
|
|
jwt: string;
|
||
|
|
organizationId: string;
|
||
|
|
invitationId: string;
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
success: boolean;
|
||
|
|
message?: string;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Remove a member from an organization
|
||
|
|
*/
|
||
|
|
export interface IReq_RemoveMember
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_RemoveMember
|
||
|
|
> {
|
||
|
|
method: 'removeMember';
|
||
|
|
request: {
|
||
|
|
jwt: string;
|
||
|
|
organizationId: string;
|
||
|
|
userId: string;
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
success: boolean;
|
||
|
|
message?: string;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Update a member's roles
|
||
|
|
*/
|
||
|
|
export interface IReq_UpdateMemberRoles
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_UpdateMemberRoles
|
||
|
|
> {
|
||
|
|
method: 'updateMemberRoles';
|
||
|
|
request: {
|
||
|
|
jwt: string;
|
||
|
|
organizationId: string;
|
||
|
|
userId: string;
|
||
|
|
roles: string[];
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
success: boolean;
|
||
|
|
role?: data.IRole;
|
||
|
|
message?: string;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Transfer organization ownership to another member
|
||
|
|
*/
|
||
|
|
export interface IReq_TransferOwnership
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_TransferOwnership
|
||
|
|
> {
|
||
|
|
method: 'transferOwnership';
|
||
|
|
request: {
|
||
|
|
jwt: string;
|
||
|
|
organizationId: string;
|
||
|
|
newOwnerId: string;
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
success: boolean;
|
||
|
|
message?: string;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Accept an invitation (called during registration or email verification)
|
||
|
|
*/
|
||
|
|
export interface IReq_AcceptInvitation
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_AcceptInvitation
|
||
|
|
> {
|
||
|
|
method: 'acceptInvitation';
|
||
|
|
request: {
|
||
|
|
token: string;
|
||
|
|
userId: string;
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
success: boolean;
|
||
|
|
organizations?: data.IOrganization[];
|
||
|
|
roles?: data.IRole[];
|
||
|
|
message?: string;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get invitation by token (for invitation landing page)
|
||
|
|
*/
|
||
|
|
export interface IReq_GetInvitationByToken
|
||
|
|
extends plugins.typedRequestInterfaces.implementsTR<
|
||
|
|
plugins.typedRequestInterfaces.ITypedRequest,
|
||
|
|
IReq_GetInvitationByToken
|
||
|
|
> {
|
||
|
|
method: 'getInvitationByToken';
|
||
|
|
request: {
|
||
|
|
token: string;
|
||
|
|
};
|
||
|
|
response: {
|
||
|
|
invitation?: data.IUserInvitation;
|
||
|
|
organizations?: Array<{
|
||
|
|
id: string;
|
||
|
|
name: string;
|
||
|
|
}>;
|
||
|
|
isExpired: boolean;
|
||
|
|
requiresRegistration: boolean;
|
||
|
|
};
|
||
|
|
}
|