@sourceloop/ctrl-plane-tenant-management-service
Version:
Tenant Management microservice for SaaS control plane
58 lines (57 loc) • 3.22 kB
TypeScript
import { ILogger } from '@sourceloop/core';
import { Lead, Tenant, TenantOnboardDTO } from '../models';
import { CreateLeadDTO } from '../models/dtos/create-lead-dto.model';
import { AddressRepository, ContactRepository, LeadRepository, TenantRepository } from '../repositories';
import { LeadUser } from '../types';
import { LeadAuthenticator } from './lead-authenticator.service';
/**
* Helper service for onboarding tenants.
*/
export declare class OnboardingService {
private leadRepository;
private tenantRepository;
private contactRepository;
private addressRepository;
private leadAuthenticator;
private logger;
/**
* Constructs a new instance of the OnboardingService.
* @param {LeadRepository} leadRepository - Repository for managing leads.
* @param {TenantRepository} tenantRepository - Repository for managing tenants.
* @param {ContactRepository} contactRepository - Repository for managing contacts.
* @param {AddressRepository} addressRepository - Repository for managing addresses.
* @param {LeadAuthenticator} leadAuthenticator - Service for authenticating leads.
* @param {ILogger} logger - Logger service for logging messages.
*/
constructor(leadRepository: LeadRepository, tenantRepository: TenantRepository, contactRepository: ContactRepository, addressRepository: AddressRepository, leadAuthenticator: LeadAuthenticator, logger: ILogger);
/**
* The addLead function creates a new lead, triggers a validation email, and
* returns the new lead.
* @param lead - The `lead` parameter is an object of type `Lead` with the `id`
* property omitted.
* @returns The `addLead` function is returning the newly created lead object.
*/
addLead(lead: Omit<CreateLeadDTO, 'isValidated' | 'addressId' | 'id'>): Promise<{
key: string;
id: string;
}>;
/**
* The startOnboarding function checks if a lead user exists and is validated, and
* if not, updates the lead user's validation status and triggers tenant creation.
* @param {LeadUser} lead - The `lead` parameter is an object of type `LeadUser`.
* It represents a lead user who is going through the onboarding process.
*/
onboardForLead(dto: Omit<TenantOnboardDTO, 'contact'>, lead: LeadUser): Promise<Tenant>;
/**
* The `setupTenant` function creates a new tenant with the provided information and an optional lead,
* and returns the created tenant.
* @param {TenantOnboardDTO} dto - The `dto` parameter is an object of type `TenantOnboardDTO` which
* contains the necessary information to onboard a new tenant. It includes properties such as `key`,
* `country`, `address`, `city`, `state`, `zip`, and `name`.
* @param {Lead} [lead] - The `lead` parameter is an optional parameter of type `Lead`. It represents
* the lead associated with the tenant being onboarded. If a lead is provided, their information will
* be used to create a contact for the tenant. If no lead is provided, the contact will not be created.
* @returns a Promise that resolves to a Tenant object.
*/
onboard(dto: TenantOnboardDTO, lead?: Lead): Promise<Tenant>;
}