| addContact |
Default value : async (
data: IContactData
): Promise<ContactEntity> => {
const contact = getContactStub(data);
return getConnection().getRepository(ContactEntity).save(contact);
}
|
| getContactById |
Default value : async (id: number): Promise<ContactEntity> => {
return getConnection().getRepository(ContactEntity).findOne(id);
}
|
| getRandomPhoneNumber |
Default value : (): string =>
faker.datatype
.number({
min: 999,
max: 999999999999,
})
.toString()
|
| getRandomPhonePrefix |
Default value : (): number =>
faker.datatype.number({
min: 1,
max: 999,
})
|
| addContactSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object(profileSchema)
.and('prefix', 'phone')
.or('phone', 'email')
.options({
presence: 'optional',
})
|
| addFileSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object({
category: Joi.string()
.valid(...Object.values(CATEGORY))
.required(),
})
|
| addProfile |
Default value : async (
data?: IProfileData
): Promise<ProfileEntity> => {
const profile = getProfileStub(data);
return getConnection().getRepository(ProfileEntity).save(profile);
}
|
| getProfileById |
Default value : async (
userId: string
): Promise<ProfileEntity> => {
return getConnection()
.getRepository(ProfileEntity)
.findOne({ where: { userId }, relations: ["user"] });
}
|
| updateProfile |
Default value : async (
id: number,
data: {
emergencyEmailAndSms?: boolean;
}
): Promise<UpdateResult> => {
return getConnection().getRepository(ProfileEntity).update(id, data);
}
|
| getTimeSlotById |
Default value : async (id: number): Promise<TimeSlotEntity> => {
return getConnection()
.getRepository(TimeSlotEntity)
.findOne({
where: { id },
relations: ['days'],
});
}
|
| addTimeSlotSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object(
timeSlotSchema
).options({
presence: 'optional',
})
|
| addUser |
Default value : async (data?: IUserData): Promise<UserEntity> => {
const user = getUserStub(data);
return getConnection().getRepository(UserEntity).save(user);
}
|
| getUserById |
Default value : async (id: string): Promise<UserEntity> => {
return getConnection()
.getRepository(UserEntity)
.findOne({ where: { id }, relations: ['profile'] });
}
|
| getUserStub |
Default value : (data?: IUserData): UserEntity => {
const user = new UserEntity();
user.id = faker.datatype.uuid();
user.email = data?.email ?? faker.internet.email();
return user;
}
|
| authGuardMock |
Type : object
|
Default value : {
canActivate: async (context) => {
const request = context.switchToHttp().getRequest();
const token = request.headers.authorization;
if (token) {
request.user = await getConnection()
.getRepository(UserEntity)
.findOne(token);
if (!request.user) {
return false;
}
}
return true;
},
}
|
| AWSCloudFrontSignerProvider |
Type : object
|
Default value : {
provide: DICTIONARY.CLOUD_FRONT_SIGNER,
inject: [ConfigService],
useFactory: (config: ConfigService) => {
return new AWS.CloudFront.Signer(
config.get('cloudFrontSigner.accessKeyId'),
config.get('cloudFrontSigner.privateKey')
);
},
}
|
| AWSS3Provider |
Type : object
|
Default value : {
provide: DICTIONARY.S3,
inject: [ConfigService],
useFactory: (config: ConfigService) => {
return new AWS.S3({
accessKeyId: config.get('s3.accessKeyId') || undefined,
signatureVersion: 'v4',
secretAccessKey: config.get('s3.secretAccessKey') || undefined,
});
},
}
|
| cloudFrontSignerMock |
Type : object
|
Default value : {
getSignedUrl: jest.fn(() => faker.image.imageUrl()),
}
|
| cognitoIdentityServiceMock |
Type : object
|
Default value : {
adminAddUserToGroup: jest.fn(async () => ({})),
adminCreateUser: jest.fn(async () => ({})),
listUsers: jest.fn(
async (
params: AWS.CognitoIdentityServiceProvider.Types.ListUsersRequest,
callback: () => void
) => ({})
),
adminDeleteUser: jest.fn((params, cb) => cb()),
adminSetUserPassword: jest.fn(async () => ({})),
adminUpdateUserAttributes: jest.fn((params, cb) => cb()),
}
|
| CognitoIdentityServiceProvider |
Type : object
|
Default value : {
provide: AWS.CognitoIdentityServiceProvider,
inject: [ConfigService],
useFactory: (config: ConfigService) => {
AWS.config.update({
accessKeyId: config.get('authorization.accessKeyId') || undefined,
secretAccessKey: config.get('authorization.secretAccessKey') || undefined,
region: config.get('authorization.region'),
});
return new AWS.CognitoIdentityServiceProvider();
},
}
|
| config |
Default value : configuration()
|
| config |
Default value : configuration()
|
| configMock |
Type : object
|
Default value : {
get: jest.fn((key: number | string) => {
const data = flat(configuration());
return data[key];
}),
}
|
| ConfigProvider |
Type : object
|
Default value : {
provide: DICTIONARY.CONFIG,
useExisting: ConfigService,
}
|
| confirmUserEmailSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object({
code: Joi.string().guid().required(),
})
|
| connectionMock |
Type : object
|
Default value : {
createQueryRunner: jest.fn(() => ({
startTransaction: jest.fn(async () => ({})),
commitTransaction: jest.fn(async () => ({})),
rollbackTransaction: jest.fn(async () => ({})),
release: jest.fn(async () => ({})),
})),
}
|
| ConnectionProvider |
Type : object
|
Default value : {
provide: DICTIONARY.CONNECTION,
useFactory: () => getConnection(),
}
|
| CONTACT_NOT_FOUND |
Type : string
|
Default value : 'E0004'
|
| DELETE_CONTACT_FAILED |
Type : string
|
Default value : 'E0007'
|
| DELETE_FILE_FROM_DB_FAILED |
Type : string
|
Default value : 'E0037'
|
| DELETE_FILE_FROM_S3_FAILED |
Type : string
|
Default value : 'E0036'
|
| DELETE_TIME_SLOT_FAILED |
Type : string
|
Default value : 'E0026'
|
| DELETE_USER_FROM_COGNITO_FAILED |
Type : string
|
Default value : 'E0040'
|
| DELETE_USER_FROM_DB_FAILED |
Type : string
|
Default value : 'E0041'
|
| EMAIL_ALREADY_IN_USE |
Type : string
|
Default value : 'E0010'
|
| EMAIL_AND_SMS_NOT_ALLOWED |
Type : string
|
Default value : 'E0017'
|
| EXPORT_DATA_FAILED |
Type : string
|
Default value : 'E0042'
|
| FILE_CATEGORY_NOT_FOUND |
Type : string
|
Default value : 'E0033'
|
| FILE_IS_REQUIRED |
Type : string
|
Default value : 'E0030'
|
| FILE_IS_TOO_BIG |
Type : string
|
Default value : 'E0032'
|
| FILE_NOT_FOUND |
Type : string
|
Default value : 'E0035'
|
| FILE_TYPE_IS_INVALID |
Type : string
|
Default value : 'E0031'
|
| FILE_UPLOAD_FAILED |
Type : string
|
Default value : 'E0029'
|
| GET_FILE_CATEGORIES_FAILED |
Type : string
|
Default value : 'E0039'
|
| GET_FILE_CONTENT_FAILED |
Type : string
|
Default value : 'E0043'
|
| GET_FILE_URL_FAILED |
Type : string
|
Default value : 'E0038'
|
| GET_JOB_FAILED |
Type : string
|
Default value : 'E0023'
|
| JOB_REMOVE_FAILED |
Type : string
|
Default value : 'E0022'
|
| LIMIT_OF_NUMBER_OF_FILES_REACHED |
Type : string
|
Default value : 'E0048'
|
| LOCATION_DATA_IS_NEEDED |
Type : string
|
Default value : 'E0018'
|
| MESSAGE_IS_NEEDED |
Type : string
|
Default value : 'E0019'
|
| MINUTES_TO_NEXT_MESSAGE_ARE_REQUIRED |
Type : string
|
Default value : 'E0047'
|
| MISSING_AUTHENTICATION_TOKEN |
Type : string
|
Default value : 'E0002'
|
| PHONE_NUMBER_IS_INVALID |
Type : string
|
Default value : 'E0021'
|
| PHONE_NUMBER_IS_NEEDED |
Type : string
|
Default value : 'E0020'
|
| RETRIEVING_TIME_SLOTS_FAILED |
Type : string
|
Default value : 'E0027'
|
| SAVE_CONTACT_FAILED |
Type : string
|
Default value : 'E0006'
|
| SAVE_FILE_FAILED |
Type : string
|
Default value : 'E0034'
|
| SAVE_POSITIVE_INFO_FAILED |
Type : string
|
Default value : 'E0046'
|
| SAVE_PROFILE_FAILED |
Type : string
|
Default value : 'E0005'
|
| SAVE_TIME_SLOT_FAILED |
Type : string
|
Default value : 'E0024'
|
| SAVE_UNCONFIRMED_EMAIL_FAILED |
Type : string
|
Default value : 'E0008'
|
| SAVE_USER_FAILED |
Type : string
|
Default value : 'E0013'
|
| SEND_MAIL_FAILED |
Type : string
|
Default value : 'E0012'
|
| SEND_SMS_FAILED |
Type : string
|
Default value : 'E0015'
|
| TIME_SLOT_IS_UNAVAILABLE |
Type : string
|
Default value : 'E0044'
|
| TIME_SLOT_NOT_FOUND |
Type : string
|
Default value : 'E0025'
|
| UNCONFIRMED_EMAIL_NOT_FOUND |
Type : string
|
Default value : 'E0009'
|
| UNKNOWN_ERROR |
Type : string
|
Default value : 'E0001'
|
| UPDATE_CONTACT_FAILED |
Type : string
|
Default value : 'E0014'
|
| UPDATE_TIME_SLOT_FAILED |
Type : string
|
Default value : 'E0028'
|
| UPDATE_USER_DEVICE_ID_FAILED |
Type : string
|
Default value : 'E0045'
|
| UPDATE_USER_EMAIL_FAILED |
Type : string
|
Default value : 'E0011'
|
| USER_NOT_FOUND |
Type : string
|
Default value : 'E0016'
|
| VALIDATION_FAILED |
Type : string
|
Default value : 'E0003'
|
| contactRepositoryMock |
Type : object
|
Default value : {
findContactsByUserId: jest.fn(async () => []),
findManyByParams: jest.fn(async () => []),
}
|
| ContactRepositoryProvider |
Type : object
|
Default value : {
provide: ContactRepository,
useFactory: (connection: Connection) =>
connection.getCustomRepository(ContactRepository),
inject: [Connection],
}
|
| contactServiceMock |
Type : object
|
Default value : {
findActiveContactsByUserId: jest.fn(async () => ({})),
}
|
| falsyValues |
Type : []
|
Default value : [undefined, null, '']
|
| env |
Default value : process.env
|
| firebaseAccountKey |
Type : object
|
Default value : {}
|
| env |
Default value : process.env
|
| env |
Default value : process.env
|
| escapeHTML |
Default value : (value: string): string =>
value.replace(/&/g, '&').replace(/"/g, '"')
|
| exportServiceMock |
Type : object
|
Default value : {}
|
| exportUserDataSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object({
email: Joi.string().email().required(),
})
|
| extendedProfileSchema |
Type : object
|
Default value : {
name: profileSchema.name.optional(),
surname: profileSchema.surname.optional(),
prefix: profileSchema.prefix,
location: Joi.string().max(200),
timezone: Joi.string().optional().allow('').max(200),
phone: profileSchema.phone,
email: Joi.string().email(),
address: Joi.string().max(200),
dateOfBirth: Joi.date().format("DD/MM/YYYY").max("now"),
primaryPhysician: Joi.string(),
primaryPhysicianAddress: Joi.string(),
seriousMedicalIssues: Joi.boolean(),
mostRecentDiagnosis: Joi.string().allow("", null),
lastHospitalVisit: Joi.date().format("DD/MM/YYYY").allow(null).max("now"),
allowNotifications: Joi.boolean(),
tipsAndTricks: Joi.boolean(),
emergencyEmailAndSms: Joi.boolean(),
locationAccess: Joi.boolean(),
uploadedDocumentsAccess: Joi.boolean(),
readManual: Joi.boolean(),
automatedEmergency: Joi.boolean(),
emergencyMessage: Joi.string().min(10).max(1000),
regularPushNotification: Joi.boolean(),
frequencyOfRegularNotification: Joi.number().min(6).max(2880),
positiveInfoPeriod: Joi.number().min(6).max(2880),
pulseBasedTriggerIOSHealthPermissions: Joi.boolean(),
pulseBasedTriggerIOSAppleWatchPaired: Joi.boolean(),
pulseBasedTriggerGoogleFitAuthenticated: Joi.boolean(),
pulseBasedTriggerConnectedToGoogleFit: Joi.boolean(),
pulseBasedTriggerBackgroundModesEnabled: Joi.boolean(),
}
|
| Joi |
Default value : JoiLibrary.extend(JoiDate)
|
| fetch |
Default value : jest.fn(async () => ({}))
|
| twilioMock |
Type : object
|
Default value : {
messages: {
create: jest.fn(async () => ({ sid: uuid.v4(), errorCode: null })),
},
}
|
| fileCategoryRepositoryMock |
Type : object
|
Default value : {}
|
| FileCategoryRepositoryProvider |
Type : object
|
Default value : {
provide: FileCategoryRepository,
useFactory: (connection: Connection) =>
connection.getCustomRepository(FileCategoryRepository),
inject: [Connection],
}
|
| fileCategoryServiceMock |
Type : object
|
Default value : {}
|
| fileRepositoryMock |
Type : object
|
Default value : {
findByCategoryCodeAndUserId: jest.fn(async () => []),
findManyByParams: jest.fn(async () => []),
}
|
| FileRepositoryProvider |
Type : object
|
Default value : {
provide: FileRepository,
useFactory: (connection: Connection) =>
connection.getCustomRepository(FileRepository),
inject: [Connection],
}
|
| fileServiceMock |
Type : object
|
Default value : {}
|
| firebaseMock |
Type : object
|
Default value : {}
|
| FirebaseProvider |
Type : object
|
Default value : {
provide: DICTIONARY.FIREBASE,
inject: [ConfigService],
useFactory: (config: ConfigService) => {
firebase.initializeApp({
credential: firebase.credential.cert(config.get('firebase.accountKey')),
});
return firebase;
},
}
|
| getAccessTokenSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object({
email: Joi.string().email(),
password: Joi.string(),
}).options({
presence: 'required',
})
|
| getCategories |
Default value : async (): Promise<FileCategoryEntity[]> => {
return getConnection()
.getRepository(FileCategoryEntity)
.find({
order: {
id: 'ASC',
},
});
}
|
| getFileById |
Default value : async (id: number): Promise<FileEntity> => {
return getConnection().getRepository(FileEntity).findOne(id);
}
|
| getFiles |
Default value : async (id: number): Promise<FileEntity[]> => {
return getConnection().getRepository(FileEntity).find();
}
|
| getFullName |
Default value : (name: string, surname: string): string =>
`${name || ''} ${surname || ''}`.trim()
|
| getMailTemplateId |
Default value : (code: string): number => {
return MailTemplatesConstants[LANGUAGE.ENGLISH][code];
}
|
| MailTemplatesConstants |
Type : object
|
Default value : {}
|
| getNameOrEmail |
Default value : (
name: string,
surname: string,
email: string
): string => {
const fullName = getFullName(name, surname);
return fullName !== '' ? fullName : email;
}
|
| getPositiveInfoByUserId |
Default value : async (
userId: string
): Promise<PositiveInfoEntity> => {
return getConnection()
.getRepository(PositiveInfoEntity)
.findOne({ where: { userId } });
}
|
| getTimeFromDate |
Default value : (date: string): string => {
return date ? date.slice(11,16) : null;
}
|
| GoogleLibPhoneNumberProvider |
Type : object
|
Default value : {
provide: DICTIONARY.GOOGLE_PHONE_NUMBER,
useFactory: () => {
return LibPhoneNumber.PhoneNumberUtil.getInstance();
},
}
|
| googlePhoneNumberMock |
Type : object
|
Default value : {
isValidNumber: jest.fn(() => true),
parseAndKeepRawInput: jest.fn(() => ''),
}
|
| isDefined |
Default value : (value: unknown): boolean =>
value !== null && value !== undefined
|
| Joi |
Default value : JoiLibrary.extend(JoiDate)
|
| Joi |
Default value : JoiLibrary.extend(JoiDate)
|
| updateUserProfileSchema |
Type : JoiLibrary.ObjectSchema
|
Default value : JoiLibrary.object({
...extendedProfileSchema,
})
.and('prefix', 'phone')
.options({
presence: 'optional',
})
|
| mailJetMock |
Type : object
|
Default value : {
post: () => ({ request }),
}
|
| request |
Default value : jest.fn(async () => ({
body: {
Messages: [
{
Status: 'success',
},
],
},
}))
|
| MailJetProvider |
Type : object
|
Default value : {
provide: DICTIONARY.MAIL_JET,
inject: [ConfigService],
useFactory: (config: ConfigService) =>
connect(config.get('mailJet.apiKey'), config.get('mailJet.apiSecret')),
}
|
| messageServiceMock |
Type : object
|
Default value : {
addJobToQueue: jest.fn(async () => ({})),
removeJobsByUserId: jest.fn(async () => ({})),
}
|
| notePositiveInfoSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object({
minutesToNext: Joi.number().min(6).max(2880),
}).options({
presence: "optional",
})
|
| notificationServiceMock |
Type : object
|
Default value : {
prepareEmailData: jest.fn(() => ({})),
prepareSmsData: jest.fn(() => ({})),
sendEmergencyMessage: jest.fn(async () => ({})),
sendSms: jest.fn(async () => ({})),
sendEmail: jest.fn(async () => ({})),
}
|
| numberToDaysOfWeek |
Default value : new Map([
[2, 'Monday'],
[3, 'Tuesday'],
[4, 'Wednesday'],
[5, 'Thursday'],
[6, 'Friday'],
[7, 'Saturday'],
[1, 'Sunday'],
])
|
| positiveInfoRepositoryMock |
Type : object
|
Default value : {}
|
| PositiveInfoRepositoryProvider |
Type : object
|
Default value : {
provide: PositiveInfoRepository,
useFactory: (connection: Connection) =>
connection.getCustomRepository(PositiveInfoRepository),
inject: [Connection],
}
|
| positiveInfoServiceMock |
Type : object
|
Default value : {
savePositiveInfo: jest.fn()
}
|
| profileMapper |
Default value : (profile: ProfileEntity): ProfileRO => {
return plainToClass(ProfileRO, {
...profile,
...getProfileDefaultValues(profile),
});
}
|
| profileRepositoryMock |
Type : object
|
Default value : {}
|
| ProfileRepositoryProvider |
Type : object
|
Default value : {
provide: ProfileRepository,
useFactory: (connection: Connection) =>
connection.getCustomRepository(ProfileRepository),
inject: [Connection],
}
|
| profileSchema |
Type : object
|
Default value : {
name: Joi.string().max(100).required(),
surname: Joi.string().max(100).required(),
active: Joi.boolean().allow(null),
prefix: Joi.number().min(1).max(999).allow(null),
phone: Joi.string().allow(null).min(4).max(12).regex(/^\d+$/),
email: Joi.string()
.email()
.max(320)
.allow(null)
.when('phone', { is: null, then: Joi.string() }),
}
|
| profileServiceMock |
Type : object
|
Default value : {
findByUserId: jest.fn(async () => ({})),
saveProfile: jest.fn(async () => ({})),
}
|
| queueServiceMock |
Type : object
|
Default value : {
add: jest.fn(async () => ({})),
removeJobs: jest.fn(async () => ({})),
getJob: jest.fn(async () => ({})),
}
|
| redisMock |
Default value : new Redis({
data: {},
})
|
| RedisProvider |
Type : FactoryProvider<any>
|
Default value : {
provide: DICTIONARY.REDIS,
inject: [ConfigService],
useFactory: (config: ConfigService) => new Redis(config.get('redis')),
}
|
| Roles |
Default value : (args: number[]) => SetMetadata('roles', args)
|
| s3Mock |
Type : object
|
Default value : {
upload: jest.fn((params, cb) =>
cb(undefined, { Key: faker.datatype.uuid() })
),
deleteObject: jest.fn((params, cb) => cb(undefined, {})),
copyObject: jest.fn((params, cb) => cb(undefined, {})),
getSignedUrl: jest.fn(async () => faker.image.imageUrl()),
getObject: jest.fn((params, cb) =>
cb(undefined, { Body: faker.datatype.string() })
),
}
|
| sendSmsSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object({
messageType: Joi.string()
.valid(...Object.values(MESSAGE_TYPE))
.required(),
})
|
| timeSlotDayRepositoryMock |
Type : object
|
Default value : {}
|
| TimeSlotDayRepositoryProvider |
Type : object
|
Default value : {
provide: TimeSlotDayRepository,
useFactory: (connection: Connection) =>
connection.getCustomRepository(TimeSlotDayRepository),
inject: [Connection],
}
|
| timeSlotMapper |
Default value : (timeSlot: TimeSlotEntity): TimeSlotRO =>
plainToClass(TimeSlotRO, {
...timeSlot,
days: timeSlot.days.map((item) =>
getEnumKeyByValue(DAYS_OF_WEEKS, item.day)
),
})
|
| timeSlotRepositoryMock |
Type : object
|
Default value : {}
|
| TimeSlotRepositoryProvider |
Type : object
|
Default value : {
provide: TimeSlotRepository,
useFactory: (connection: Connection) =>
connection.getCustomRepository(TimeSlotRepository),
inject: [Connection],
}
|
| timeSlotSchema |
Type : object
|
Default value : {
active: Joi.boolean(),
from: Joi.date().iso().allow(null),
to: Joi.date().iso().required(),
timezone: Joi.string().required(),
days: Joi.array()
.items(
Joi.string()
.valid(...getEnumKeys(DAYS_OF_WEEKS, true))
.required()
)
.required(),
}
|
| timeSlotsMapper |
Default value : (timeSlots: TimeSlotEntity[]): TimeSlotRO[] =>
timeSlots.map((entity) => timeSlotMapper(entity))
|
| triggerTimeSlotServiceMock |
Type : object
|
Default value : {
isActiveTimeSlot: jest.fn(async () => true),
getActiveTimeSlot: jest.fn(async () => null),
}
|
| TwilioProvider |
Type : object
|
Default value : {
provide: twilio.Twilio,
inject: [ConfigService],
useFactory: (config: ConfigService) =>
twilio(config.get('twilio.accountSid'), config.get('twilio.authToken')),
}
|
| unconfirmedEmailRepositoryMock |
Type : object
|
Default value : {}
|
| UnconfirmedEmailRepositoryProvider |
Type : object
|
Default value : {
provide: UnconfirmedEmailRepository,
useFactory: (connection: Connection) =>
connection.getCustomRepository(UnconfirmedEmailRepository),
inject: [Connection],
}
|
| unconfirmedEmailServiceMock |
Type : object
|
Default value : {
saveUnconfirmedEmail: jest.fn(async () => ({})),
}
|
| updateTimeSlotSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object(
timeSlotSchema
).options({
presence: 'optional',
})
|
| updateUserDeviceIdSchema |
Type : Joi.ObjectSchema
|
Default value : Joi.object({
deviceId: Joi.string().max(200).allow(null).required(),
})
|
| User |
Default value : createParamDecorator((data, ctx: ExecutionContext) => {
const request = ctx.switchToHttp().getRequest();
return request.user;
})
|
| userRepositoryMock |
Type : object
|
Default value : {}
|
| UserRepositoryProvider |
Type : object
|
Default value : {
provide: UserRepository,
useFactory: (connection: Connection) =>
connection.getCustomRepository(UserRepository),
inject: [Connection],
}
|
| userServiceMock |
Type : object
|
Default value : {
findByIdOrFail: jest.fn(async () => ({})),
updateUserDeviceId: jest.fn(),
clearPositiveInfo: jest.fn()
}
|