UNPKG

@vulog/aima-user

Version:

238 lines (213 loc) 6.04 kB
import { Service } from '@vulog/aima-config'; import { z } from 'zod'; export type Address = { streetName?: string; city?: string; postalCode?: string; region?: string; country?: string; number?: string; addressAdditionalInformation?: string; }; export type IndividualBusiness = Address & { companyName: string; vat?: string; }; export type UserAgreement = { cityId: string; date: string; hasAcceptedLatest: boolean; }; export type ProfileType = 'Single' | 'Business'; export type ProfileStatus = | 'PENDING' | 'APPROVED' | 'REJECTED' | 'SUSPENDED' | 'INACTIVE' | 'ARCHIVED' | 'PENDING_REGISTRATION'; export type UserProfile = { id: string; rfid?: string; creationDate: string; updateDate?: string; entityId: string; entityName: string; status: ProfileStatus; type: ProfileType; emailConsent: boolean; }; export type ServicesRegistrationList = { approved: string[]; incomplete: string[]; pending: string[]; rejected: string[]; suspended: string[]; unregistered: string[]; }; export type ServiceRegistrationWithReason = { serviceId: string; reason: string; status: string; }; export type ProfileServiceRegistration = { profileId: string; profileType: ProfileType; profileStatus: ProfileStatus; services: ServicesRegistrationList; reasonsForChange: ServiceRegistrationWithReason[]; }; export type UserServiceRegistration = { catalog: Service[]; profiles: ProfileServiceRegistration[]; }; export const accountStatus = ['INCOMPLETE', 'PENDING', 'APPROVED', 'REJECTED', 'SUSPENDED', 'ARCHIVED'] as const; export type AccountStatus = (typeof accountStatus)[number]; export type User = { fleetId: string; id: 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; }; export type UserUpdateBody = Partial< Omit< User, | 'id' | 'fleetId' | 'agreements' | 'profiles' | 'surveyConsentUpdateDate' | 'shareDataConsentUpdateDate' | 'profilingConsentUpdateDate' > >; export const personalInformationUserTypes = [ 'IDENTITY', 'USERNAME', 'BIRTH', 'NATIONALITY', 'NOTES', 'GENDER', 'PERSONAL_COMPANY', 'FISCAL', 'ADDRESS', 'MEMBERSHIP', ] as const; export const personalInformationUserPaths = [ '/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', ] as const; export type PersonalInformationUserType = (typeof personalInformationUserTypes)[number]; export const personalInformationUserTypeSchema = z.enum(personalInformationUserTypes); export const personalInformationProfileTypes = ['ID_NUMBER', 'PHONE_NUMBER', 'EMAIL', 'BILLING_ADDRESS'] as const; export type PersonalInformationProfileType = (typeof personalInformationProfileTypes)[number]; export const personalInformationProfileTypeSchema = z.enum(personalInformationProfileTypes); export type PersonalInformationIdentity = { firstName?: string; lastName?: string; middleName?: string; preferredName?: string; }; export type PersonalInformationBirth = { birthDate?: string; countryBirth?: string; provinceBirth?: string; cityBirth?: string; }; export type PersonalCompany = { companyName?: string; companyVat?: string; companyAddress?: Address; }; export type FiscalInformation = { fiscal?: string; personalVatNumber?: string; sdi?: string; pecAddress?: string; marketReference?: string; }; export 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; }; export type PersonalInformationProfile = { fleetId: string; userId: string; profileId: string; idNumber?: string; phoneNumber?: string; email?: string; billingAddress?: Address; }; export type Label = { id: number; name: string; createDate: string; }; export 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[]; };