@vulog/aima-user
Version:
User management module for the AIMA platform. This module provides comprehensive functionality to manage users, profiles, billing groups, and user-related operations.
304 lines (281 loc) • 13.5 kB
text/typescript
import { Client } from '@vulog/aima-client';
import { Service } from '@vulog/aima-config';
import { z } from 'zod';
import { PatchAction, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
declare const acceptTAndC: (client: Client, userId: string, cityId: string) => Promise<void>;
declare const assignBillingGroup: (client: Client, entityId: string, billingGroupId: string) => Promise<void>;
type Address = {
streetName?: string;
city?: string;
postalCode?: string;
region?: string;
country?: string;
number?: string;
addressAdditionalInformation?: string;
};
type IndividualBusiness = Address & {
companyName: string;
vat?: string;
};
type UserAgreement = {
cityId: string;
date: string;
hasAcceptedLatest: boolean;
};
type ProfileType = 'Single' | 'Business';
type ProfileStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'SUSPENDED' | 'INACTIVE' | 'ARCHIVED' | 'PENDING_REGISTRATION';
type ServiceStatus = {
cityId: string;
id: string;
name: string;
status: string;
visibility: string;
};
type UserProfile = {
id: string;
rfid?: string;
creationDate: string;
updateDate?: string;
entityId: string;
entityName: string;
status: ProfileStatus;
type: ProfileType;
emailConsent: boolean;
services: ServiceStatus[];
};
type ServicesRegistrationList = {
approved: string[];
incomplete: string[];
pending: string[];
rejected: string[];
suspended: string[];
unregistered: string[];
};
type ServiceRegistrationWithReason = {
serviceId: string;
reason: string;
status: string;
};
type ProfileServiceRegistration = {
profileId: string;
profileType: ProfileType;
profileStatus: ProfileStatus;
services: ServicesRegistrationList;
reasonsForChange: ServiceRegistrationWithReason[];
};
type UserServiceRegistration = {
catalog: Service[];
profiles: ProfileServiceRegistration[];
};
declare const accountStatus: readonly ["INCOMPLETE", "PENDING", "APPROVED", "REJECTED", "SUSPENDED", "ARCHIVED"];
type AccountStatus = (typeof accountStatus)[number];
type User = {
fleetId: string;
id: string;
registrationDate: string;
accountStatus?: AccountStatus;
locale: string;
agreements: UserAgreement[];
profiles: UserProfile[];
dataPrivacyConsent: boolean;
marketingConsent: boolean;
surveyConsent: boolean;
shareDataConsent: boolean;
surveyConsentUpdateDate: string;
shareDataConsentUpdateDate: string;
profilingConsent: boolean;
profilingConsentUpdateDate: string;
membershipNumber: string;
updateDate: string;
dateOfAgreements: string;
};
type UserStatus = Exclude<User, 'agreements' | 'profiles'> & {
profiles: ProfileServiceRegistration[];
};
type UserUpdateBody = Partial<Omit<User, 'id' | 'fleetId' | 'agreements' | 'profiles' | 'surveyConsentUpdateDate' | 'shareDataConsentUpdateDate' | 'profilingConsentUpdateDate'>>;
declare const personalInformationUserTypes: readonly ["IDENTITY", "USERNAME", "BIRTH", "NATIONALITY", "NOTES", "GENDER", "PERSONAL_COMPANY", "FISCAL", "ADDRESS", "MEMBERSHIP"];
declare const personalInformationUserPaths: readonly ["/identity/firstName", "/identity/lastName", "/identity/middleName", "/identity/preferredName", "/birth/birthDate", "/birth/countryBirth", "/birth/provinceBirth", "/birth/cityBirth", "/nationality", "/notes", "/gender", "/personalCompany/companyName", "/personalCompany/companyVat", "/personalCompany/companyAddress/streetName", "/personalCompany/companyAddress/city", "/personalCompany/companyAddress/postalCode", "/personalCompany/companyAddress/region", "/personalCompany/companyAddress/country", "/personalCompany/companyAddress/number", "/personalCompany/companyAddress/addressAdditionalInformation", "/fiscalInformation/fiscal", "/fiscalInformation/personalVatNumber", "/fiscalInformation/sdi", "/fiscalInformation/pecAddress", "/fiscalInformation/marketReference", "/address/streetName", "/address/city", "/address/postalCode", "/address/region", "/address/country", "/address/number", "/address/addressAdditionalInformation", "/membership"];
type PersonalInformationUserType = (typeof personalInformationUserTypes)[number];
declare const personalInformationUserTypeSchema: z.ZodEnum<["IDENTITY", "USERNAME", "BIRTH", "NATIONALITY", "NOTES", "GENDER", "PERSONAL_COMPANY", "FISCAL", "ADDRESS", "MEMBERSHIP"]>;
declare const personalInformationProfileTypes: readonly ["ID_NUMBER", "PHONE_NUMBER", "EMAIL", "BILLING_ADDRESS"];
type PersonalInformationProfileType = (typeof personalInformationProfileTypes)[number];
declare const personalInformationProfileTypeSchema: z.ZodEnum<["ID_NUMBER", "PHONE_NUMBER", "EMAIL", "BILLING_ADDRESS"]>;
type PersonalInformationIdentity = {
firstName?: string;
lastName?: string;
middleName?: string;
preferredName?: string;
};
type PersonalInformationBirth = {
birthDate?: string;
countryBirth?: string;
provinceBirth?: string;
cityBirth?: string;
};
type PersonalCompany = {
companyName?: string;
companyVat?: string;
companyAddress?: Address;
};
type FiscalInformation = {
fiscal?: string;
personalVatNumber?: string;
sdi?: string;
pecAddress?: string;
marketReference?: string;
};
type PersonalInformationUser = {
fleetId: string;
userId: string;
userName?: string;
identity?: PersonalInformationIdentity;
birth?: PersonalInformationBirth;
nationality?: string;
notes?: string;
gender?: 'MALE' | 'FEMALE' | 'UNDEFINED';
personalCompany?: PersonalCompany;
fiscalInformation?: FiscalInformation;
address?: Address;
membership?: string;
};
type PersonalInformationProfile = {
fleetId: string;
userId: string;
profileId: string;
idNumber?: string;
phoneNumber?: string;
email?: string;
billingAddress?: Address;
};
type Label = {
id: number;
name: string;
createDate: string;
};
type Entity = {
id: string;
fleetId: string;
name: string;
entityName: string;
type: 'Personal' | 'Business';
status: 'APPROVED' | 'PENDING' | 'REJECTED' | 'SUSPENDED' | 'INACTIVE' | 'ARCHIVED';
isMasterEntity: boolean;
billingGroupId: string | null;
billingGroup: string | null;
billingAddress: Address | null;
fiscalCode: string | null;
services: Service[];
};
type Profile = UserProfile & {
entity: Entity;
};
type UserFull = User & {
profiles: Profile[];
};
type BillingGroup = {
id: string;
fleetId: string;
name: string;
discount: number;
overMileageCap: number | null;
overMileageRate: number | null;
};
type CreateBusinessProfile = {
emailConsent: boolean;
email: string;
requestId: string;
costCenterId: string;
};
declare const createBusinessProfile: (client: Client, userId: string, businessId: string, data: CreateBusinessProfile) => Promise<UserProfile>;
type CreateUser = {
userName: string;
password: string;
locale: string;
email: string;
dataPrivacyConsent?: boolean;
profilingConsent?: boolean;
marketingConsent?: boolean;
phoneNumber?: string;
};
type CreateUserOptions = {
tcApproval?: boolean;
skipUserNotification?: boolean;
};
declare const createUser: (client: Client, user: CreateUser, option?: CreateUserOptions) => Promise<User>;
declare const searchTypes: readonly ["email", "username", "phoneNumber"];
type SearchType = (typeof searchTypes)[number];
type ResponseFind = {
content: PersonalInformationUser[];
};
declare const findUser: (client: Client, searchType: SearchType, searchQuery: string, types: PersonalInformationUserType[]) => Promise<ResponseFind>;
declare const getProfilePersonalInfoById: (client: Client, userId: string, profileId: string, types: PersonalInformationProfileType[]) => Promise<PersonalInformationProfile>;
declare const getRegistrationOverview: (client: Client, userId: string) => Promise<UserServiceRegistration>;
declare const getUserById: (client: Client, id: string, addAccountStatus?: boolean) => Promise<User>;
declare const getUserPersonalInfoById: (client: Client, id: string, types: PersonalInformationUserType[]) => Promise<PersonalInformationUser>;
declare const getUsersPIByIds: (client: Client, ids: string[], types: PersonalInformationUserType[]) => Promise<PersonalInformationUser[]>;
declare const getLabelsForUser: (client: Client, userId: string) => Promise<Label[]>;
declare const addLabelForUser: (client: Client, userId: string, labelId: number) => Promise<void>;
declare const removeLabelForUser: (client: Client, userId: string, labelId: number) => Promise<void>;
declare const schema: z.ZodObject<{
disableEmailNotification: z.ZodBoolean;
operatorProfileId: z.ZodString;
actions: z.ZodArray<z.ZodObject<{
reasonForChange: z.ZodString;
serviceId: z.ZodString;
status: z.ZodEnum<["APPROVED", "INCOMPLETE", "PENDING", "REJECTED", "SUSPENDED", "UNREGISTERED"]>;
}, "strip", z.ZodTypeAny, {
status: "PENDING" | "APPROVED" | "REJECTED" | "SUSPENDED" | "INCOMPLETE" | "UNREGISTERED";
reasonForChange: string;
serviceId: string;
}, {
status: "PENDING" | "APPROVED" | "REJECTED" | "SUSPENDED" | "INCOMPLETE" | "UNREGISTERED";
reasonForChange: string;
serviceId: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
disableEmailNotification: boolean;
operatorProfileId: string;
actions: {
status: "PENDING" | "APPROVED" | "REJECTED" | "SUSPENDED" | "INCOMPLETE" | "UNREGISTERED";
reasonForChange: string;
serviceId: string;
}[];
}, {
disableEmailNotification: boolean;
operatorProfileId: string;
actions: {
status: "PENDING" | "APPROVED" | "REJECTED" | "SUSPENDED" | "INCOMPLETE" | "UNREGISTERED";
reasonForChange: string;
serviceId: string;
}[];
}>;
type ServicesUpdate = z.infer<typeof schema>;
declare const setServicesStatus: (client: Client, profileId: string, servicesUpdate: ServicesUpdate) => Promise<void>;
declare const registerUserToService: (client: Client, entityId: string, serviceId: string) => Promise<void>;
declare const paths: readonly ["/phoneNumber", "/email", "/idNumber"];
type ProfilePaths = (typeof paths)[number];
declare const updateProfilePersonalInfo: (client: Client, userId: string, profileId: string, actions: PatchAction<ProfilePaths>[]) => Promise<void>;
declare const updateUser: (client: Client, id: string, user: UserUpdateBody) => Promise<User>;
type UserPaths = (typeof personalInformationUserPaths)[number];
declare const updateUserPersonalInfo: (client: Client, userId: string, actions: PatchAction<UserPaths>[]) => Promise<void>;
declare const getEntity: (client: Client, entityId: string) => Promise<Entity>;
declare const getFleetBillingGroups: (client: Client, options?: PaginableOptions) => Promise<PaginableResponse<BillingGroup>>;
declare const getUsersByIds: (client: Client, ids: string[]) => Promise<User[]>;
declare const userFiltersSchema: z.ZodObject<{
status: z.ZodOptional<z.ZodEnum<["PENDING", "INCOMPLETE", "SUSPENDED", "REJECTED", "APPROVED"]>>;
profileType: z.ZodOptional<z.ZodEnum<["Single", "Business"]>>;
serviceId: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
status?: "PENDING" | "APPROVED" | "REJECTED" | "SUSPENDED" | "INCOMPLETE" | undefined;
serviceId?: string | undefined;
profileType?: "Single" | "Business" | undefined;
}, {
status?: "PENDING" | "APPROVED" | "REJECTED" | "SUSPENDED" | "INCOMPLETE" | undefined;
serviceId?: string | undefined;
profileType?: "Single" | "Business" | undefined;
}>;
declare const sortSchema: z.ZodEnum<["registrationDate", "userName", "firstName", "lastName", "updateDate"]>;
type UserSort = z.infer<typeof sortSchema>;
type UserFilters = z.infer<typeof userFiltersSchema>;
declare const getUsers: (client: Client, options?: PaginableOptions<UserFilters, UserSort>) => Promise<PaginableResponse<UserStatus>>;
export { type AccountStatus, type Address, type BillingGroup, type CreateBusinessProfile, type CreateUser, type CreateUserOptions, type Entity, type FiscalInformation, type IndividualBusiness, type Label, type PersonalCompany, type PersonalInformationBirth, type PersonalInformationIdentity, type PersonalInformationProfile, type PersonalInformationProfileType, type PersonalInformationUser, type PersonalInformationUserType, type Profile, type ProfilePaths, type ProfileServiceRegistration, type ProfileStatus, type ProfileType, type ResponseFind, type SearchType, type ServiceRegistrationWithReason, type ServiceStatus, type ServicesRegistrationList, type ServicesUpdate, type User, type UserAgreement, type UserFilters, type UserFull, type UserPaths, type UserProfile, type UserServiceRegistration, type UserSort, type UserStatus, type UserUpdateBody, acceptTAndC, accountStatus, addLabelForUser, assignBillingGroup, createBusinessProfile, createUser, findUser, getEntity, getFleetBillingGroups, getLabelsForUser, getProfilePersonalInfoById, getRegistrationOverview, getUserById, getUserPersonalInfoById, getUsers, getUsersByIds, getUsersPIByIds, personalInformationProfileTypeSchema, personalInformationProfileTypes, personalInformationUserPaths, personalInformationUserTypeSchema, personalInformationUserTypes, registerUserToService, removeLabelForUser, setServicesStatus, updateProfilePersonalInfo, updateUser, updateUserPersonalInfo };