@vulog/aima-user
Version:
User management — profiles, personal information, labels, billing groups, and service registration.
358 lines (357 loc) • 14.6 kB
text/typescript
import { z } from "zod";
import { PaginableOptions, PaginableResponse, PatchAction } from "@vulog/aima-core";
import { Client } from "@vulog/aima-client";
import { Service } from "@vulog/aima-config";
//#region src/acceptTAndC.d.ts
declare const acceptTAndC: (client: Client, userId: string, cityId: string) => Promise<void>;
//#endregion
//#region src/assignBillingGroup.d.ts
declare const assignBillingGroup: (client: Client, entityId: string, billingGroupId: string) => Promise<void>;
//#endregion
//#region src/unassignBillingGroup.d.ts
declare const unassignBillingGroup: (client: Client, entityId: string, billingGroupId: string) => Promise<void>;
//#endregion
//#region src/types.d.ts
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[];
};
type UserServiceRegistrationOverview = UserServiceRegistration & {
userId: string;
};
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: "IDENTITY";
USERNAME: "USERNAME";
BIRTH: "BIRTH";
NATIONALITY: "NATIONALITY";
NOTES: "NOTES";
GENDER: "GENDER";
PERSONAL_COMPANY: "PERSONAL_COMPANY";
FISCAL: "FISCAL";
ADDRESS: "ADDRESS";
MEMBERSHIP: "MEMBERSHIP";
}>;
declare const personalInformationProfileTypes: readonly ["ID_NUMBER", "PHONE_NUMBER", "EMAIL", "BILLING_ADDRESS"];
type PersonalInformationProfileType = (typeof personalInformationProfileTypes)[number];
declare const personalInformationProfileTypeSchema: z.ZodEnum<{
ID_NUMBER: "ID_NUMBER";
PHONE_NUMBER: "PHONE_NUMBER";
EMAIL: "EMAIL";
BILLING_ADDRESS: "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;
};
//#endregion
//#region src/createBusinessProfile.d.ts
type CreateBusinessProfile = {
emailConsent: boolean;
email: string;
requestId: string;
costCenterId?: string | null;
};
/** @deprecated Use `addUserToBusiness` from `@vulog/aima-business` instead */
declare const createBusinessProfile: (client: Client, userId: string, businessId: string, data: CreateBusinessProfile) => Promise<UserProfile>;
//#endregion
//#region src/createUser.d.ts
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>;
//#endregion
//#region src/findUser.d.ts
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>;
//#endregion
//#region src/getProfilePersonalInfoById.d.ts
declare const getProfilePersonalInfoById: (client: Client, userId: string, profileId: string, types: PersonalInformationProfileType[]) => Promise<PersonalInformationProfile>;
//#endregion
//#region src/getRegistrationOverview.d.ts
declare const getRegistrationOverview: (client: Client, userId: string) => Promise<UserServiceRegistration>;
//#endregion
//#region src/getUserById.d.ts
declare const getUserById: (client: Client, id: string, addAccountStatus?: boolean) => Promise<User>;
//#endregion
//#region src/getUserByEmail.d.ts
declare const getUserByEmail: (client: Client, email: string) => Promise<User>;
//#endregion
//#region src/getUserPersonalInfoById.d.ts
declare const getUserPersonalInfoById: (client: Client, id: string, types: PersonalInformationUserType[]) => Promise<PersonalInformationUser>;
//#endregion
//#region src/getUsersPIByIds.d.ts
declare const getUsersPIByIds: (client: Client, ids: string[], types: PersonalInformationUserType[]) => Promise<PersonalInformationUser[]>;
//#endregion
//#region src/label.d.ts
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>;
//#endregion
//#region src/setServicesStatus.d.ts
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<{
INCOMPLETE: "INCOMPLETE";
PENDING: "PENDING";
APPROVED: "APPROVED";
REJECTED: "REJECTED";
SUSPENDED: "SUSPENDED";
UNREGISTERED: "UNREGISTERED";
}>;
}, z.core.$strip>>;
}, z.core.$strip>;
type ServicesUpdate = z.infer<typeof schema>;
declare const setServicesStatus: (client: Client, profileId: string, servicesUpdate: ServicesUpdate) => Promise<void>;
//#endregion
//#region src/registerUserToService.d.ts
declare const registerUserToService: (client: Client, entityId: string, serviceId: string) => Promise<void>;
//#endregion
//#region src/updateProfilePersonalInfo.d.ts
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>;
//#endregion
//#region src/updateUser.d.ts
declare const updateUser: (client: Client, id: string, user: UserUpdateBody) => Promise<User>;
//#endregion
//#region src/updateUserPersonalInfo.d.ts
type UserPaths = (typeof personalInformationUserPaths)[number];
declare const updateUserPersonalInfo: (client: Client, userId: string, actions: PatchAction<UserPaths>[]) => Promise<void>;
//#endregion
//#region src/getEntity.d.ts
declare const getEntity: (client: Client, entityId: string) => Promise<Entity>;
//#endregion
//#region src/getFleetBillingGroups.d.ts
declare const getFleetBillingGroups: (client: Client, options?: PaginableOptions) => Promise<PaginableResponse<BillingGroup>>;
//#endregion
//#region src/getUsersByIds.d.ts
declare const getUsersByIds: (client: Client, ids: string[]) => Promise<User[]>;
//#endregion
//#region src/getUsers.d.ts
declare const userFiltersSchema: z.ZodObject<{
status: z.ZodOptional<z.ZodEnum<{
INCOMPLETE: "INCOMPLETE";
PENDING: "PENDING";
APPROVED: "APPROVED";
REJECTED: "REJECTED";
SUSPENDED: "SUSPENDED";
}>>;
profileType: z.ZodOptional<z.ZodEnum<{
Single: "Single";
Business: "Business";
}>>;
serviceId: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
declare const sortSchema: z.ZodEnum<{
registrationDate: "registrationDate";
updateDate: "updateDate";
userName: "userName";
firstName: "firstName";
lastName: "lastName";
}>;
type UserSort = z.infer<typeof sortSchema>;
type UserFilters = z.infer<typeof userFiltersSchema>;
declare const getUsers: (client: Client, options?: PaginableOptions<UserFilters, UserSort>) => Promise<PaginableResponse<UserStatus>>;
//#endregion
//#region src/getServiceRegistrationOverview.d.ts
/**
* Get an overview of the service registration statuses for a list of userIds.
*
* Swagger: `GET /fleets/{fleetId}/serviceRegistrationOverview` (admin-user,
* operationId `getServicesRegistrationOverview`).
*/
declare const getServiceRegistrationOverview: (client: Client, userIds: string[]) => Promise<UserServiceRegistrationOverview[]>;
//#endregion
//#region src/requestServiceRegistration.d.ts
/**
* Register a user profile to a service.
*
* Swagger: `PUT /fleets/{fleetId}/profiles/{profileId}/services/{id}` (admin-user,
* operationId `requestServiceRegistration`).
*/
declare const requestServiceRegistration: (client: Client, profileId: string, serviceId: string) => Promise<string>;
//#endregion
export { AccountStatus, Address, BillingGroup, CreateBusinessProfile, CreateUser, CreateUserOptions, Entity, FiscalInformation, IndividualBusiness, Label, PersonalCompany, PersonalInformationBirth, PersonalInformationIdentity, PersonalInformationProfile, PersonalInformationProfileType, PersonalInformationUser, PersonalInformationUserType, Profile, ProfilePaths, ProfileServiceRegistration, ProfileStatus, ProfileType, ResponseFind, SearchType, ServiceRegistrationWithReason, ServiceStatus, ServicesRegistrationList, ServicesUpdate, User, UserAgreement, UserFilters, UserFull, UserPaths, UserProfile, UserServiceRegistration, UserServiceRegistrationOverview, UserSort, UserStatus, UserUpdateBody, acceptTAndC, accountStatus, addLabelForUser, assignBillingGroup, createBusinessProfile, createUser, findUser, getEntity, getFleetBillingGroups, getLabelsForUser, getProfilePersonalInfoById, getRegistrationOverview, getServiceRegistrationOverview, getUserByEmail, getUserById, getUserPersonalInfoById, getUsers, getUsersByIds, getUsersPIByIds, personalInformationProfileTypeSchema, personalInformationProfileTypes, personalInformationUserPaths, personalInformationUserTypeSchema, personalInformationUserTypes, registerUserToService, removeLabelForUser, requestServiceRegistration, setServicesStatus, unassignBillingGroup, updateProfilePersonalInfo, updateUser, updateUserPersonalInfo };