createInvitation
@nmi-agro/fdm-source / fdm-core/src / createInvitation
Function: createInvitation()
createInvitation(
fdm,resource,resource_id,inviter_id,target,role,expires?):Promise<void>
Defined in: fdm-core/src/invitation.ts:44
Creates an invitation for a principal or email address to access a resource.
If the target is a registered principal, a principal-based invitation is created. If the target is a valid email address, an email-based invitation is created for unregistered users; access will be auto-granted upon registration and email verification.
The inviter must have the necessary permission (enforced by the caller).
Parameters
fdm
any
The FDM instance providing the connection to the database.
resource
Resource
The resource type (e.g. 'farm', 'field').
resource_id
string
The identifier of the resource.
inviter_id
string
The ID of the principal creating the invitation.
target
string
The username, email, or slug of the invitee.
role
Role
The role to grant upon acceptance.
expires?
Date
Optional expiry date; defaults to 7 days from now.
Returns
Promise<void>
Throws
If the target is already a member, or target is invalid.