Skip to content

Latest commit

 

History

History
458 lines (264 loc) · 12.3 KB

README.md

File metadata and controls

458 lines (264 loc) · 12.3 KB

@letsgo/tenant

@letsgo/tenant

This package consolidates functions for managing LetsGo tenants, users, and users' memberhips in tenants, including invitations. It also support management of tenant's subscriptions and keeping track of changes in subscription plans.

Table of contents

Interfaces

Variables

Functions

Variables

IdentityTenantCategory

Const IdentityTenantCategory: "letsgo-identity-tenant"

The database category for items representing a specific tenant's users.

Defined in

tenant/src/index.ts:53


InvitationCategory

Const InvitationCategory: "letsgo-invitation"

The database category for items representing invitations for a specific tenant.

Defined in

tenant/src/index.ts:58


TenantCategory

Const TenantCategory: "letsgo-tenant"

The database category for items representing LetsGo tenants.

Defined in

tenant/src/index.ts:43


TenantIdentityCategory

Const TenantIdentityCategory: "letsgo-tenant-identity"

The database category for items representing a specific user's access to tenants.

Defined in

tenant/src/index.ts:48

Functions

addIdentityToTenant

addIdentityToTenant(options): Promise<void>

Adds a new user to a tenant.

Parameters

Name Type Description
options AddIdentityToTenantOptions Options for adding the user.

Returns

Promise<void>

Defined in

tenant/src/index.ts:734


createInvitation

createInvitation(options): Promise<Invitation>

Create an invitation to join a tenant.

Parameters

Name Type Description
options CreateInvitationOptions Options for creating the invitation.

Returns

Promise<Invitation>

New invitation

Defined in

tenant/src/index.ts:333


createTenant

createTenant(options): Promise<Tenant>

Creates a new tenant. The new tenant has a unique ID and is associated with the DefaultPlanId subscription plan defined in the @letsgo/pricing package.

Parameters

Name Type Description
options CreateTenantOptions Options for creating the tenant.

Returns

Promise<Tenant>

The newly created tenant.

Defined in

tenant/src/index.ts:460


deleteInvitation

deleteInvitation(options): Promise<void>

Revoke an inviation to join a tenant.

Parameters

Name Type Description
options DeleteInvitationOptions Options for deleting the invitation.

Returns

Promise<void>

Defined in

tenant/src/index.ts:398


deleteTenant

deleteTenant(options): Promise<Tenant | undefined>

Deletes a tenant. No data is removed from the database, but the tenant is marked as deleted.

Parameters

Name Type Description
options DeleteTenantOptions Options for deleting the tenant.

Returns

Promise<Tenant | undefined>

The deleted tenant, or undefined if the tenant was alrady deleted or does not exist.

Defined in

tenant/src/index.ts:591


getIdentitiesOfTenant

getIdentitiesOfTenant(options): Promise<Identity[]>

Get users who are members of a specific tenant.

Parameters

Name Type Description
options GetIdentitiesOfTenantOptions Options for getting the users.

Returns

Promise<Identity[]>

Array of users who are members of the tenant.

Defined in

tenant/src/index.ts:664


getInvitation

getInvitation(options): Promise<Invitation | undefined>

Gets an existing invitation to join a tenant.

Parameters

Name Type Description
options GetInvitationOptions Options for getting the invitation.

Returns

Promise<Invitation | undefined>

The invitation if it exists and has not expired, undefined otherwise.

Defined in

tenant/src/index.ts:369


getInvitations

getInvitations(options): Promise<Invitation[]>

Returns all active, non-expired invitations for a given tenant.

Parameters

Name Type Description
options GetInvitationsOptions Options for getting the invitations.

Returns

Promise<Invitation[]>

Array of active invitations.

Defined in

tenant/src/index.ts:423


getTenant

getTenant(options): Promise<Tenant | undefined>

Get an existing tenant. If the tenant is deleted, it is returned only if options.includeDeleted is true.

Parameters

Name Type Description
options GetTenantOptions Options for getting the tenant.

Returns

Promise<Tenant | undefined>

The tenant if it exists and is not deleted, undefined otherwise.

Defined in

tenant/src/index.ts:516


getTenantsOfIdentity

getTenantsOfIdentity(options): Promise<Tenant[]>

Get tenants a specific user has access to.

Parameters

Name Type Description
options GetTenantsOfIdentityOptions Options for getting the tenants.

Returns

Promise<Tenant[]>

Array of tenants the user has access to.

Defined in

tenant/src/index.ts:626


isIdentityInTenant

isIdentityInTenant(options): Promise<boolean>

Checks if a user is a member of a tenant.

Parameters

Name Type Description
options IsIdentityInTenantOptions Options for checking the membership.

Returns

Promise<boolean>

True if the user is member of the tenant, false otherwise.

Defined in

tenant/src/index.ts:705


putTenant

putTenant(options): Promise<Tenant>

Update a tenant.

Parameters

Name Type Description
options PutTenantOptions Options for updating the tenant.

Returns

Promise<Tenant>

The updated tenant.

Defined in

tenant/src/index.ts:556


reconcileSubscriptionStatus

reconcileSubscriptionStatus(tenant, identity): Promise<Tenant | undefined>

Update the status of the Stripe subscription for a LetsGo tenant based on the source of truth in Stripe.

Parameters

Name Type Description
tenant Tenant LetsGo tenant to update the subscription status for.
identity Identity The idenantity of the user who triggered the update.

Returns

Promise<Tenant | undefined>

The updated tenant if the subscription status changed, undefined if there were no changes in status.

Defined in

tenant/src/index.ts:287


removeIdentityFromTenant

removeIdentityFromTenant(options): Promise<void>

Removes a user from a tenant.

Parameters

Name Type Description
options RemoveIdentityFromTenantOptions Options for removing the user.

Returns

Promise<void>

Defined in

tenant/src/index.ts:763


setNewPlan

setNewPlan(tenant, planId, identity): void

Update the tenant with a new plan ID and record the change.

Parameters

Name Type Description
tenant Tenant The tenant to update.
planId string The new plan ID.
identity Identity The identity of the user who made the change.

Returns

void

Defined in

tenant/src/index.ts:254