import { Base } from "./Base"; import { BillingPageToken, MultiStatusBody } from "./types/types"; import { BillingInfo, BillingInfoUpdateWithoutToken, BillingInfoUpdateWithToken, Invoice, SubscriptionInfo, SubscriptionSeat, SubscriptionState, User, UserAttribute } from "./UserService"; import { SSO } from "./SSOService"; import { BillingError } from "./types/billing"; /** * ^: This anchor matches the start of the string. * [A-Za-z0-9]: This matches any English letter or digit. * [A-Za-z0-9-]{2,14}: This character set matches any English letter, * digit or the - character, and repeats between 3 and 15 times. * [A-Za-z0-9]: This matches any English letter or digit. * $: This anchor matches the end of the string. */ export declare const businessHandleValidation: RegExp; export type SubscriptionCustomField = { name: string; value: string; }; export type SubscriptionChangePreview = { total?: number | null; subtotal?: number | null; tax?: number | null; unitAmount?: number | null; quantity?: number | null; balance?: number | null; credit?: number | null; taxRate?: number | null; }; /** * "Lens Business ID" */ export type Business = { /** * The business id (in uuid format) */ id: string; /** * The business name. */ name: string; /** * The business handle. */ handle: string; /** * The business address. */ address: string; /** * The business additional address (a.k.a. "address line 2"). */ additionalAddress: string | null; /** * The business country. */ country: string; /** * The business state / province. */ state: string | null; /** * The business city. */ city: string; /** * The business zip/postal code. */ zip: string; /** * The business phone number. */ phoneNumber: string; /** * The date the business was created. */ createdAt: string; /** * The user id that created the business. */ createdById: string; /** * The date the business was updated. */ updatedAt: string; /** * The users that are in the business. */ businessUsers: BusinessUser[]; /** * External is true when a business is created by external provider. */ external: boolean; /** * The website URL of the business */ websiteUrl: string; /** * The department name of the business */ department: string; /** * Recurly subscription ID for businesses migrated from Recurly. */ businessIdLiteSubscriptionId: string | null | undefined; /** * If set to true by the admin, users will be automatically added to the business when they log in via SSO. */ ssoAutoJoin?: boolean; /** * If true, the invited user will be automatically assigned to a subscription. */ automaticSeatAssignment: boolean; /** * If true, the join requests will be automatically accepted. */ autoAcceptJoinRequests: boolean; /** * True if the business is a reseller. */ reseller: boolean; /** * The email domain to do domain matching against. */ emailDomain?: string | null; /** * If set to true, users can be matched by domain to suggest joining the business. */ emailDomainMatchingEnabled?: boolean; /** * The welcome message to be shown to users when joining the business via email domain matching. */ emailDomainWelcomeMessage: string; }; /** * The subscription that have been assigned to a user (`user_subscriptions` relation) */ export type UsedSeat = { /** * The id of user_subscriptions entity */ id: string; /** * The id of subscription entity */ subscriptionId: string; /** * The created data of user_subscriptions entity in ISO format, e.g. 2022-06-28T08:13:06.000Z */ createdAt: string; /** * The updated data of user_subscriptions entity in ISO format, e.g. 2022-06-28T08:13:06.000Z */ updatedAt: string; /** * The activation data of user_subscriptions entity in ISO format, e.g. 2022-06-28T08:13:06.000Z */ activatedAt: string; /** * The de-activation data of user_subscriptions entity in ISO format, e.g. 2022-06-28T08:13:06.000Z */ deactivatedAt: string | null; /** * Subscription seat used offline */ offline: boolean; /** * The expiration data of user_subscriptions entity in ISO format, e.g. 2022-06-28T08:13:06.000Z */ expiredAt: string | null; /** * The user that is assigned to this subscription */ user: { /** * The id of the user */ id: string; /** * The username of the user */ username: string; /** * The first name of the user */ firstName: string; /** * The last name of the user */ lastName: string; /** * The full name of the user */ fullname: string; /** * User's email address */ email: string; } | null; }; export type BusinessSubscription = { /** * Subscription ID */ id: string; /** * Subscribed plan name (Recurly `subscription["plan"]["name"]`, e.g. "Pro") */ planName: string; /** * Subscribed plan code (Recurly `subscription["plan"]["code"]`, e.g. "pro-monthly") */ planCode: string; /** * Current billing period started at (Recurly subscription["currentPeriodStartedAt"] in ISO format. * e.g. 2022-06-28T08:13:06.000Z) */ currentPeriodStartedAt: string | null; /** * Current billing period ends at (Recurly subscription["currentPeriodEndsAt"] in ISO format, * e.g. 2022-06-28T08:13:06.000Z) */ currentPeriodEndsAt: string | null; trialStartedAt: string | null; trialEndsAt: string | null; companyName: string; accountCode: string; /** * State of the subscription */ state: SubscriptionState; /** * Is a business account */ isBusinessAccount: boolean; /** * string if the subscription is from a child business */ fromChildBusinessId?: Business["id"]; /** * Total number of seats in this subscription, including unassigned and assigned. (Recurly subscription["quantity"]) */ seats: number; /** * The subscription that have been assigned to a user (`user_subscriptions` relation) */ usedSeats: UsedSeat[]; /** * Subscription ID */ shortSubscriptionId: string | null; /** * Change to subscription from next billing cycle */ pendingChange: { activateAt: string | null; quantity: number | null; }; unitAmount: number | null; autoRenew?: boolean | null; customFields?: SubscriptionCustomField[]; /** * Date on which subscription expires. */ expiresAt?: string | null; /** * Date on which subscription was cancelled. */ cancelledAt?: string | null; }; export type BusinessUser = { /** * The id of the business user, `undefined` if user is invited but not yet have an account. */ id?: string; /** * The username of the business user, `undefined` if user is invited but not yet have an account. */ username?: string; /** * The email of the business user or the email of the invited user. */ email: string; /** * The fullname of the business user, `undefined` if user is invited but not yet have an account. */ fullname?: string; /** * The state of the user in the business. * - `active` if the user is in the business. * - `pendign` if the user is invited but not yet in the business. */ state: BusinessInvitationState; /** * The role of the user in the business or the role of the invited user. */ role: UserBusinessRole; /** * The createdTimestamp of the business user, `undefined` if user is invited but not yet have an account. */ createdTimestamp?: string; /** * The firstName of the business user, `undefined` if user is invited but not yet have an account. */ firstName?: string; /** * The lastName of the business user, `undefined` if user is invited but not yet have an account. */ lastName?: string; /** * The date the user was invited to the business. * `undefined` if the user is not joined via invitation. */ invitationCreatedAt?: string; /** * The users ID in business */ businessUserId?: string; /** * The timestemp of the user's last usage of Lens (lens-cloud-extension) */ lastAccess?: number; /** * The public user's attributes */ userAttributes?: UserAttribute[]; }; export type BusinessUserSubscriptionSeat = Pick & { subscription: Pick; }; /** * Business user with subscription seats */ export type BusinessUserWithSeats = BusinessUser & { /** * The user's subscription seats, populated from the user's subscriptions */ seats: BusinessUserSubscriptionSeat[]; }; export type UserBusinessRole = "Administrator" | "Member"; export type BusinessInvitationState = "pending" | "active"; export type BusinessInvitation = { /** * The business invitation ID */ id: string; /** * The role of the invited user in the business */ role: UserBusinessRole; /** * Email address of the invited user */ email: string; /** * The subscription ID of the subscription that the invited user will be assigned to */ subscriptionId?: string; /** * The state of the invitation */ state: BusinessInvitationState; /** * The date the invitation was created. */ createdAt: string; /** * The date the invitation was updated. */ updatedAt: string; /** * The userId that creates the invitation. */ createdById: string; }; /** * BusinessInvitation plus the public business info that is accessable to the invited, pending business user. */ export type BusinessInvitationWithBusinessInfo = BusinessInvitation & { business: { /** * The business id (in uuid format) */ id: string; /** * The business name. */ name: string; /** * The department name of the business */ department: string; /** * The business handle. */ handle: string; /** * The website URL of the business */ websiteUrl: string; /** * The business phone number. */ phoneNumber: string; /** * The business country. */ country: string; /** * The business state / province. */ state: string | null; /** * The business zip/postal code. */ zip: string; /** * The business city. */ city: string; /** * The business address. */ address: string; /** * The business additional address (a.ka. "address line 2"). */ additionalAddress: string | null; }; }; export type BusinessHierarchyInvitationState = "pending" | "accepted" | "rejected" | "canceled"; export type BusinessHierarchyInvitation = { /** * The id of the invitation. */ id: string; /** * The invitation state. */ state: BusinessHierarchyInvitationState; /** * The parent LBID id. */ parentBusinessId: Business["id"]; /** * The user id of the user who created the invitation */ createdById: User["id"]; /** * The date the invitation was created. */ createdAt: string; /** * The date the invitation was updated. */ updatedAt: string; /** * The token for joining as a child LBID. */ token: string; /** * The date the invitation will expire. */ expiryTime: string | null; }; export declare enum SSOType { SAML = "saml", OIDC = "oidc" } export interface BusinessSsoSamlDto { /** * SSO Identity Provider SinOn URL */ singleSignOnServiceUrl: string; /** * idpEntityId - The Entity ID, provided by SSO provider, that is used to uniquely identify. * this SAML Service Provider (from Keycloak docs) */ idpEntityId: string; /** * The public certificates to validate the signatures of SAML requests and responses */ validatingX509Certificates?: string[]; /** * SAML SSO type */ type: SSOType.SAML; } export interface BusinessSsoOidcDto { /** * OIDC client ID */ clientId: string; /** * OIDC client secret */ clientSecret: string; /** * Identity Provider Token URL */ tokenUrl: string; /** * JWKS URL */ jwksUrl: string; /** * User Info URL */ userInfoUrl: string; /** * Logout Url */ logoutUrl: string; /** * Issuer */ issuer: string; /** * Authorization URL */ authorizationUrl: string; /** * OIDC SSO type */ type: SSOType.OIDC; } export interface BusinessSSOWithIDPDetails extends SSO { business?: Business; config: BusinessSsoSamlDto | BusinessSsoOidcDto; enabled: boolean; enabledDomains: string[]; } export interface BusinessSsoDto { /** * SSO config object. */ config: BusinessSsoSamlDto | BusinessSsoOidcDto; /** * Is SSO enabled for the LBID */ enabled: boolean; /** * List of domains to enable SSO for */ enabledDomains: string[]; } export interface UpdateBusinessSsoDto { /** * SSO config object. */ config?: BusinessSsoSamlDto | BusinessSsoOidcDto; /** * Is SSO enabled for the LBID */ enabled?: boolean; /** * List of domains to enable SSO for */ enabledDomains?: string[]; } /** * Lens Business ID Feature */ export type BusinessFeature = { key: string; /** * Human readable name of the feature */ name: string; /** * An optional description of the feature */ description?: string; /** * Is the feature enabled for the LBID */ enabled: boolean; }; type Parent = Business & { /** The contact email of the LBID Recurly account */ email: undefined | null | string; }; type Child = Business & { /** The contact email of the LBID Recurly account */ email: undefined | null | string; }; export type BusinessJoinRequestState = "pending" | "accepted" | "rejected" | "canceled"; export type BusinessJoinRequest = { /** * The business join request ID */ id: string; /** * The state of the join request */ state: BusinessJoinRequestState; /** * The requesting business's id */ businessId: string; /** * The user id of the user who created the join request */ createdById: string; /** * The date the join request was created. */ createdAt: string; /** * The date the join request was updated. */ updatedAt: string; /** * The user id of the user who updated the join request */ updatedById: string; }; export type BusinessJoinRequestWithCreatedBy = BusinessJoinRequest & { /** * The user who created the join request * * @remarks Values will be undefined if the user account has been deleted. */ createdBy: { username?: string; email?: string; fullname?: string; firstName?: string; lastName?: string; }; }; export type BusinessJoinRequestMultiStatusBody = MultiStatusBody; export type BusinessSCIMToken = { /** * The business SCIM token id */ id: string; /** * TThe business entity id that the token for. */ businessId: string; /** * The user id that creates the token. */ createdById: User["id"]; /** * The date the token was created. */ createdAt: string; /** * The value of the token. */ token: string; }; /** * Billing information for a business user */ export type BusinessBillingInfo = BillingInfo & { /** * Invoice method available for the business */ invoiceMethodAvailable: boolean; }; export type BusinessBillingInfoUpdate = BillingInfoUpdateWithoutToken | BillingInfoUpdateWithToken; /** * The keys that are allowed to be updated/replaced. */ export declare const allowedUpdateBusinessKeys: Array; export type BusinessGroup = { /** * The business group id */ id: string; /** * The group name. */ name: string; /** * The business id that the group belongs to. */ businessId: string; /** * The user id that creates the group. */ createdById: string; /** * The user id that updated the group. */ updatedById: string; /** * The subscription id which all users in the groups should be assigned to. */ subscriptionId: string | null; /** * The role of the group members in the business. */ role: UserBusinessRole | null; /** * The external id of the group (from external identity provider). */ externalId: string | null; /** * The date the group was created. */ createdAt: string; /** * The date the group was updated. */ updatedAt: string; /** * The date the group was (soft) deleted. */ deletedAt: string | null; }; export type BusinessManagedDomainStatus = "verified" | "unverified"; export type BusinessManagedDomain = { /** * Id of this managed domain. */ id: string; /** * ID of the business that this domain belongs to. */ businessId: string; /** * Domain name that this managed domain represents. */ domainName: string; /** * The date the managed domain was created. */ createdAt: string; /** * The date the managed domain was last updated. */ updatedAt: string; /** * Is SSO enabled on this domain. */ ssoEnabled: boolean; /** * Is domain capture enabled on this domain. */ domainCaptureEnabled: boolean; /** * Is blocking unlicensed users from accessing Lens products enabled */ blockUnlicensedEnabled: boolean; /** * Verification status of the managed domain. */ status: BusinessManagedDomainStatus; /** * Method by which the managed domain was verified, null if managed domain is not verified. */ verificationMethod: string | null; /** * The date the managed domain was verified, null if managed domain is not verified. */ verifiedAt: string | null; /** * Number of users that registered with an email address that belongs to this domain, * but are not yet part of the Lens Business ID that owns the managed domain. * Will be null if managed domain is unverified or if domain capture is disabled. */ uncapturedUsers: number | null; }; export type BusinessManagedDomainsListOptions = { status?: BusinessManagedDomainStatus; }; export type CreateBusinessManagedDomainDto = { domainName: string; }; export type UpdateBusinessManagedDomainDto = { domainCaptureEnabled?: boolean; ssoEnabled?: boolean; blockUnlicensedEnabled?: boolean; }; declare class BusinessService extends Base { /** * Lists business entities ("Lens Business ID") that the authenticated user has explicit permissions to access. */ getMany(): Promise; /** * Get one business entity ("Lens Business ID") by id. */ getOne(id: Business["id"]): Promise; /** * Update an existing business ("Lens Business ID"). */ updateOne(id: string, business: Partial): Promise; /** * Replace an existing business ("Lens Business ID"). */ replaceOne(id: string, business: Business): Promise; /** * Disable business light activation link */ disableBusinessLightActivationLink(id: string): Promise; /** * Delete business entity ("Lens Business ID") by id. */ deleteOne(id: Business["id"]): Promise; /** * Delete user from the business. */ deleteBusinessUser(businessId: Business["id"], businessUserId: string): Promise; /** * Change existing business user role */ changeBusinessUserRole(businessId: Business["id"], businessUserId: string, role: UserBusinessRole): Promise; /** * Lists the subscriptions by id */ getSubscriptions(id: Business["id"]): Promise; /** * Create a new subscription by planCode * * @remarks only use by LBID that has a parent LBID and the parent has valid billing info. */ createSubscription(id: Business["id"], planCode: BusinessSubscription["planCode"], quantity: number): Promise; /** * Activate user business subscription seat */ activateBusinessUserSubscription({ businessId, businessSubscriptionId, businessInvitationId, userId, }: { businessId: string; businessSubscriptionId?: string; businessInvitationId?: string; userId?: string; }): Promise; /** * Deactivate user business subscription seat * Request user has to be an owner of the subscription seat or Business Administrator */ deActivateBusinessUserSubscription({ businessId, businessSubscriptionId, username, }: { businessId: string; businessSubscriptionId: string; username: string; }): Promise; /** * Change business subscription seat quantity */ changeBusinessSubscriptionSeatsQuantity({ businessId, businessSubscriptionId, quantity, }: { businessId: string; businessSubscriptionId: string; quantity: number; }): Promise; /** * Preview business subscription seat quantity change */ previewBusinessSubscriptionSeatsQuantityChange({ businessId, businessSubscriptionId, quantity, }: { businessId: string; businessSubscriptionId: string; quantity: number; }): Promise; /** * Change business subscription custom fields */ updateBusinessSubscriptionCustomField({ businessId, businessSubscriptionId, customField, }: { businessId: string; businessSubscriptionId: string; customField: SubscriptionCustomField; }): Promise; /** * Lists the users in the business by id */ getUsers(id: Business["id"]): Promise; /** * Get the list of business invitations by business id */ getInvitations(id: Business["id"]): Promise; /** * Get one business invitation by an invitation id */ getOneInvitation(businessId: Business["id"], invitationId: BusinessInvitation["id"]): Promise; /** * Create a new invitation for a user to join a business, optionally assigning them to a * subscription by given subscriptionId. * * @remarks inviter has to be the administrator of the business */ createInvitation(id: Business["id"], email: string, subscriptionId?: string, role?: string): Promise<{ id: BusinessInvitation["id"]; email: BusinessInvitation["email"]; subscriptionId: BusinessInvitation["subscriptionId"]; role: UserBusinessRole; }>; /** * Accept an invitation to join a business. */ acceptInvitation(id: Business["id"], invitationId: BusinessInvitation["id"]): Promise; /** * Delete business invitation */ deleteInvitation(id: Business["id"], invitationId: BusinessInvitation["id"]): Promise; /** * Get token for Recurly hosted pages * * @remarks user has to be the administrator of the business */ getBillingPageToken(id: Business["id"]): Promise; /** * Create token for Recurly hosted pages * * @remarks user has to be the administrator of the business */ createBillingPageToken(id: Business["id"]): Promise; /** * Get business billing information * */ getBusinessBillingInformation(id: Business["id"]): Promise; getBusinessBillingErrors(id: Business["id"]): Promise; /** * Update business billing information * */ updateBusinessBillingInformation(id: Business["id"], billingInfo: BusinessBillingInfoUpdate): Promise; /** * List all children LBIDs of a LBID. * * @remarks user has to be the administrator of the business. */ getChildren(id: Business["id"]): Promise; /** * Remove all children LBIDs of a LBID. * * @remarks user has to be the administrator of the business. */ removeAllChildren(id: Business["id"]): Promise; /** * Remove one child LBID of a LBID. * * @remarks user has to be the administrator of the business. * @returns the remaining children LBIDs. */ removeOneChild(parentId: Business["id"], childId: Business["id"]): Promise; /** * Get the parent LBID of a LBID. * * @remarks One LBID can only have one parent. * @remarks user has to be the administrator of the business. */ getParent(id: Business["id"]): Promise; /** * Remove the parent LBID of a LBID. * * @remarks user has to be the administrator of the business. */ removeParent(id: Business["id"]): Promise; /** * Create a new 'hierarchy' invitation for a LBID to join another LBID as child account. * * @remarks should be used by parent LBID admins. */ createChildInvitation(parentId: Business["id"], expiryTime?: Date): Promise; /** * List all 'hierarchy' invitations by LBID id. * * @remarks should be used by parent LBID admins. */ getManyChildrenInvitation(parentId: Business["id"]): Promise; /** * List all 'hierarchy' invitations by LBID id. * * @remarks should be used by child LBID admins. */ getOneChildrenInvitationByToken(token: BusinessHierarchyInvitation["token"]): Promise; /** * Update 'hierarchy' invitations by the invitation id and the LBID id. * * @remarks should be used by parent LBID admins. */ updateOneChildInvitation(parentId: Business["id"], invitationId: BusinessHierarchyInvitation["id"], state: "canceled"): Promise; /** * Accept or reject or confirm the 'hierarchy' invitation by `token`. * * @remarks should be used by child LBID admins. */ acceptChildInvitation(childId: Business["id"], state: "accepted" | "rejected" | "confirmed", token: BusinessHierarchyInvitation["token"]): Promise; /** * List all invoices for a business * */ getBusinessInvoices(businessId: string): Promise; /** * Get business SSO details * */ getBusinessSSO(businessId: Business["id"]): Promise; /** * Create business SSO * */ createBusinessSSO(businessID: Business["id"], ssoSettings: BusinessSsoDto): Promise; /** * Update business SSO * */ updateBusinessSSO(businessID: Business["id"], ssoSettings: UpdateBusinessSsoDto): Promise; /** * Delete business SSO * */ removeBusinessSSO(id: Business["id"]): Promise; /** * Send business SSO activation emails * */ sendBusinessSSOActivationEmail(businessID: Business["id"]): Promise; /** * Get list of Lens Business ID features */ getBusinessFeatures(businessID: Business["id"]): Promise>; /** * Update Lens Business ID features */ updateBusinessFeatures(businessID: Business["id"], features: Array>): Promise>; /** * Get list of Lens Business ID join requests. * * @remarks should be used by LBID admins. */ getBusinessJoinRequests(businessID: Business["id"]): Promise>; /** * Accept/reject/cancel a Lens Business ID join request. * * @remarks should be used by LBID admins for accept/reject, and by users for cancel. */ updateBusinessJoinRequest(businessID: Business["id"], joinRequestId: BusinessJoinRequest["id"], state: "accepted" | "rejected" | "canceled"): Promise; /** * Accept/reject/cancel multiple Lens Business ID join request. * * @remarks should be used by LBID admins for accept/reject, and by users for cancel. */ updateBusinessJoinRequests(businessID: Business["id"], data: Array>): Promise>; /** * Create a Lens Business ID join request. * * @remarks should be used to create the request to join a Lens Business ID. */ createBusinessJoinRequest(businessID: Business["id"]): Promise; /** * Get a list of Lens Business ID SCIM tokens. * * @remarks should be used by LBID admins. */ getBusinessSCIMTokens(businessID: Business["id"]): Promise>; /** * Delete a Lens Business ID SCIM token. * * @remarks should be used by LBID admins. */ deleteBusinessSCIMToken(businessID: Business["id"], tokenId: BusinessSCIMToken["id"]): Promise; /** * Create a Lens Business ID SCIM token. * * @remarks should be used by LBID admins. */ createBusinessSCIMToken(businessID: Business["id"]): Promise; getGroups(businessId: Business["id"]): Promise; createGroup(businessId: Business["id"], { name, role, subscriptionId, }: { name: BusinessGroup["name"]; subscriptionId?: BusinessGroup["subscriptionId"]; role?: BusinessGroup["role"]; }): Promise; updateGroup(businessId: Business["id"], groupID: BusinessGroup["id"], { name, subscriptionId, role, }: { name?: BusinessGroup["name"]; subscriptionId?: BusinessGroup["subscriptionId"]; role?: BusinessGroup["role"]; }): Promise; deleteGroup(businessId: Business["id"], groupID: BusinessGroup["id"]): Promise; getAllManagedDomains(businessId: Business["id"], options?: BusinessManagedDomainsListOptions): Promise; getManagedDomain(businessId: string, domainId: string): Promise; createManagedDomain(businessId: string, dto: CreateBusinessManagedDomainDto): Promise; updateManagedDomain(businessId: string, domainId: string, dto: UpdateBusinessManagedDomainDto): Promise; deleteManagedDomain(businessId: string, domainId: string): Promise; } export { BusinessService };