From b04ad096bcfba478cb8deb57631094e056fd11c8 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Mon, 20 Jun 2022 14:17:48 -0300 Subject: [PATCH 001/107] Create structure for social network --- .../SocialNetworkProfileController.js | 37 ++++++++ src/models/SocialNetworkProfile.js | 36 ++++++++ src/repository/SocialNetworkRepository.js | 33 +++++++ src/routes/BaseRoutes.js | 3 +- src/routes/SocialNetworkRoutes.js | 16 ++++ src/services/SocialNetworkService.js | 86 +++++++++++++++++++ src/services/UserService.js | 5 +- 7 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 src/controllers/SocialNetworkProfileController.js create mode 100644 src/models/SocialNetworkProfile.js create mode 100644 src/repository/SocialNetworkRepository.js create mode 100644 src/routes/SocialNetworkRoutes.js create mode 100644 src/services/SocialNetworkService.js diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js new file mode 100644 index 00000000..c29d0c32 --- /dev/null +++ b/src/controllers/SocialNetworkProfileController.js @@ -0,0 +1,37 @@ +const SocialNetworkService = require('../services/SocialNetworkService'); +const saveError = require('../utils/ErrorHistory'); + +class HelpController { + constructor() { + this.socialNetworkService = new SocialNetworkService(); + } + + async followUser(req, res, next) { + const { followerId, followedId } = req.params; + try { + await this.socialNetworkService.followUser(followerId, followedId); + res.status(204).send(); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } + + async unfollowUser(req, res, next) { + const { followerId, followedId } = req.params; + try { + await this.socialNetworkService.unfollowUser(followerId, followedId); + res.status(204).send(); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } + +} + +module.exports = HelpController; diff --git a/src/models/SocialNetworkProfile.js b/src/models/SocialNetworkProfile.js new file mode 100644 index 00000000..f5ad1e19 --- /dev/null +++ b/src/models/SocialNetworkProfile.js @@ -0,0 +1,36 @@ +const mongoose = require('mongoose'); + +const SocialNetworkProfileSchema = new mongoose.Schema({ + + userId:{ + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + required: true, + unique: true, + }, + username: { + type: String, + required: true, + }, + followers: [{ + type: mongoose.Schema.Types.ObjectId, + required: false, + ref: 'socialNetworkProfile' + }], + following: [{ + type: mongoose.Schema.Types.ObjectId, + required: false, + ref: 'socialNetworkProfile' + }], + +}, { collection: 'socialNetworkProfile' }); + +SocialNetworkProfileSchema.virtual('user', { + ref: 'User', + localField: 'userId', + foreignField: '_id', + justOne: true +}); + + +module.exports = mongoose.model('socialNetworkProfile', SocialNetworkProfileSchema); diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js new file mode 100644 index 00000000..195cd9af --- /dev/null +++ b/src/repository/SocialNetworkRepository.js @@ -0,0 +1,33 @@ +const BaseRepository = require('./BaseRepository'); +const SocialNetworkProfileSchema = require('../models/SocialNetworkProfile'); +const { ObjectID } = require('mongodb'); + +class SocialNetworkRepository extends BaseRepository { + constructor() { + super(SocialNetworkProfileSchema); + } + + async create(socialNetworkProfile) { + const result = await super.$save(socialNetworkProfile); + return result; + } + + async findUserProfilebyUserId(id) { + + const matchQuery = { userId: ObjectID(id) }; + const socialNetworkProfileFields = [ + '_id', 'userId', 'username', + 'followers', 'following', + ]; + return super.$findOne( + matchQuery, + socialNetworkProfileFields + ); + } + + async updateProfile(socialNetworkProfile) { + await super.$update(socialNetworkProfile); + } +} + +module.exports = SocialNetworkRepository; diff --git a/src/routes/BaseRoutes.js b/src/routes/BaseRoutes.js index 7c9b5f78..9136439c 100644 --- a/src/routes/BaseRoutes.js +++ b/src/routes/BaseRoutes.js @@ -7,10 +7,11 @@ const categoryRoutes = require('./CategoryRoutes'); const notificationRoutes = require('./NotificationRoutes'); const helpOfferRoutes = require('./HelpOfferRoutes'); const campaignRoutes = require('./CampaignRoutes'); +const socialNetworkRoutes = require("./SocialNetworkRoutes"); const swaggerDocument = YAML.load('docs/swagger.yaml'); module.exports = (app) => { app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); - app.use('/api', [userRoutes, helpRoutes, categoryRoutes, notificationRoutes, entityRoutes, helpOfferRoutes, campaignRoutes]); + app.use('/api', [userRoutes, helpRoutes, categoryRoutes, notificationRoutes, entityRoutes, helpOfferRoutes, campaignRoutes,socialNetworkRoutes]); }; diff --git a/src/routes/SocialNetworkRoutes.js b/src/routes/SocialNetworkRoutes.js new file mode 100644 index 00000000..9676d146 --- /dev/null +++ b/src/routes/SocialNetworkRoutes.js @@ -0,0 +1,16 @@ +const express = require("express"); +const SocialNetworkProfileController = require("../controllers/SocialNetworkProfileController"); +const isAuthenticated = require("../validation/middlewares/authFirebase"); + +const routes = express.Router(); +const socialNetworkProfileController = new SocialNetworkProfileController(); + +routes.put("/socialNetworkProfile/followUser/:followerId/:followedId", /*isAuthenticated,*/ async (req, res, next) => { + socialNetworkProfileController.followUser(req, res, next); +}); + +routes.put("/socialNetworkProfile/unfollowUser/:followerId/:followedId", /*isAuthenticated,*/ async (req, res, next) => { + socialNetworkProfileController.unfollowUser(req, res, next); +}); + +module.exports = routes; diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js new file mode 100644 index 00000000..8ff1bd08 --- /dev/null +++ b/src/services/SocialNetworkService.js @@ -0,0 +1,86 @@ +const SocialNetworkRepository = require("../repository/SocialNetworkRepository"); +const EntityRepository = require("../repository/EntityRepository"); +const firebase = require("../config/authFirebase"); +const { ObjectID } = require("mongodb"); + +class SocialNetworkService { + constructor() { + this.socialNetworkRepository = new SocialNetworkRepository(); + } + + async createSocialNetworkUser(createdUser) { + + + const socialProfileData = { + username: createdUser.name, + userId: createdUser._id, + }; + + console.log(socialProfileData.username); + console.log("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + console.log(socialProfileData.userId); + + + return this.socialNetworkRepository.create(socialProfileData); + + + } + + + async followUser(followerId, followedId){ + + let followedUser = await this.socialNetworkRepository.findUserProfilebyUserId(followedId); + let followerUser = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); + + console.log(followedUser); + console.log(followerUser); + if(!followedUser){ + throw new Error ("Followed user profile not found"); + } else if (!followerUser){ + throw new Error ("Follower user profile not found"); + } + + const followerPosition = followedUser.followers.indexOf(followerId); + const followingPosition = followerUser.following.indexOf(followedId); + if (followerPosition > -1 || followingPosition > -1) { + throw new Error("Usuário já é um seguidor"); + } + + followedUser.followers.push(followerId); + followerUser.following.push(followedId); + + await this.socialNetworkRepository.updateProfile(followedUser); + await this.socialNetworkRepository.updateProfile(followerUser); + + } + + async unfollowUser(followerId, followedId){ + + let followedUser = await this.socialNetworkRepository.findUserProfilebyUserId(followedId); + let followerUser = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); + + console.log(followedUser); + console.log(followerUser); + if(!followedUser){ + throw new Error ("Followed user profile not found"); + } else if (!followerUser){ + throw new Error ("Follower user profile not found"); + } + + const followerPosition = followedUser.followers.indexOf(followerId); + const followingPosition = followerUser.following.indexOf(followedId); + if (followerPosition < 0 || followingPosition < 0) { + throw new Error("Usuário não é um seguidor"); + } + + followedUser.followers.splice(followerPosition,1); + followerUser.following.splice(followingPosition,1); + + await this.socialNetworkRepository.updateProfile(followedUser); + await this.socialNetworkRepository.updateProfile(followerUser); + + } + +} + +module.exports = SocialNetworkService; diff --git a/src/services/UserService.js b/src/services/UserService.js index caff3905..a3ef5039 100644 --- a/src/services/UserService.js +++ b/src/services/UserService.js @@ -1,5 +1,6 @@ const UserRepository = require("../repository/UserRepository"); const EntityRepository = require("../repository/EntityRepository"); +const SocialNetworkService = require("../services/SocialNetworkService"); const firebase = require("../config/authFirebase"); const { ObjectID } = require("mongodb"); @@ -7,6 +8,8 @@ class UserService { constructor() { this.userRepository = new UserRepository(); this.entityRepository = new EntityRepository(); + this.socialNetworkService = new SocialNetworkService(); + } async createUser(data) { @@ -29,7 +32,7 @@ class UserService { data.email = data.email.toLowerCase(); try { const createdUser = await this.userRepository.create(data); - + const createdSocialNetworkUser = await this.socialNetworkService.createSocialNetworkUser(createdUser); if (!data.hasUser) { // Cria o usuário no firebase await firebase From 3ace21274831d1da6f92a9fbe525e79b298eac47 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Wed, 22 Jun 2022 14:17:55 -0300 Subject: [PATCH 002/107] Add more functions to socialNetwork --- .../SocialNetworkProfileController.js | 23 +++- src/models/SocialNetworkProfile.js | 47 ++++++- src/repository/BaseRepository.js | 2 +- src/repository/SocialNetworkRepository.js | 119 ++++++++++++++++++ src/routes/SocialNetworkRoutes.js | 13 +- src/services/EntityService.js | 5 +- src/services/SocialNetworkService.js | 46 +++++-- src/services/UserService.js | 1 + 8 files changed, 233 insertions(+), 23 deletions(-) diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js index c29d0c32..6d61fa65 100644 --- a/src/controllers/SocialNetworkProfileController.js +++ b/src/controllers/SocialNetworkProfileController.js @@ -7,9 +7,9 @@ class HelpController { } async followUser(req, res, next) { - const { followerId, followedId } = req.params; + const { followerId, userId } = req.params; try { - await this.socialNetworkService.followUser(followerId, followedId); + await this.socialNetworkService.followUser(followerId, userId); res.status(204).send(); next(); } catch (err) { @@ -20,9 +20,9 @@ class HelpController { } async unfollowUser(req, res, next) { - const { followerId, followedId } = req.params; + const { followerId, userId } = req.params; try { - await this.socialNetworkService.unfollowUser(followerId, followedId); + await this.socialNetworkService.unfollowUser(followerId, userId); res.status(204).send(); next(); } catch (err) { @@ -32,6 +32,21 @@ class HelpController { } } + + + async findUsers(req, res, next) { + const { userId, username } = req.params; + try { + const result = await this.socialNetworkService.findUsers(userId, username); + res.status(200).json(result); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } + } module.exports = HelpController; diff --git a/src/models/SocialNetworkProfile.js b/src/models/SocialNetworkProfile.js index f5ad1e19..b107b01d 100644 --- a/src/models/SocialNetworkProfile.js +++ b/src/models/SocialNetworkProfile.js @@ -4,7 +4,6 @@ const SocialNetworkProfileSchema = new mongoose.Schema({ userId:{ type: mongoose.Schema.Types.ObjectId, - ref: 'User', required: true, unique: true, }, @@ -15,7 +14,7 @@ const SocialNetworkProfileSchema = new mongoose.Schema({ followers: [{ type: mongoose.Schema.Types.ObjectId, required: false, - ref: 'socialNetworkProfile' + ref: 'socialNetworkProfile', }], following: [{ type: mongoose.Schema.Types.ObjectId, @@ -23,7 +22,15 @@ const SocialNetworkProfileSchema = new mongoose.Schema({ ref: 'socialNetworkProfile' }], -}, { collection: 'socialNetworkProfile' }); +}, { + collection: 'socialNetworkProfile', + toObject: { + virtuals: true, + }, + toJSON: { + virtuals: true, + }, + }); SocialNetworkProfileSchema.virtual('user', { ref: 'User', @@ -32,5 +39,39 @@ SocialNetworkProfileSchema.virtual('user', { justOne: true }); +SocialNetworkProfileSchema.virtual('entity', { + ref: 'Entity', + localField: 'userId', + foreignField: '_id', + justOne: true +}); + +SocialNetworkProfileSchema.virtual('Followers', { + ref: 'socialNetworkProfile', + localField: 'followers', + foreignField: 'userId' +}); + +SocialNetworkProfileSchema.virtual('Following', { + ref: 'socialNetworkProfile', + localField: 'following', + foreignField: 'userId' +}); + +SocialNetworkProfileSchema.virtual('helpsOffers', { + ref: 'OfferedHelp', + localField: 'userId', + foreignField: 'ownerId' +}); + +SocialNetworkProfileSchema.virtual('userHelps', { + ref: 'Help', + localField: 'userId', + foreignField: 'ownerId' +}); + + + + module.exports = mongoose.model('socialNetworkProfile', SocialNetworkProfileSchema); diff --git a/src/repository/BaseRepository.js b/src/repository/BaseRepository.js index 81dd81cf..9dfcac29 100644 --- a/src/repository/BaseRepository.js +++ b/src/repository/BaseRepository.js @@ -70,7 +70,7 @@ class BaseRepository { return recordModel; } - async $list(query, selectedField, populate = null, sort = null) { + async $list(query, selectedField = null, populate = null, sort = null) { return this.modelClass.find(query, selectedField) .populate(populate) .sort(sort); diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 195cd9af..2e2c5fc6 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -12,6 +12,13 @@ class SocialNetworkRepository extends BaseRepository { return result; } + async destroy(id) { + const query = {}; + query._id = id; + + await super.$destroy(query); + } + async findUserProfilebyUserId(id) { const matchQuery = { userId: ObjectID(id) }; @@ -28,6 +35,118 @@ class SocialNetworkRepository extends BaseRepository { async updateProfile(socialNetworkProfile) { await super.$update(socialNetworkProfile); } + + async findUsersbyName(userId,userName) { + console.log(userId); + console.log(userName); + const query = { + userId: {$ne:ObjectID(userId)}, + username: {$regex: userName,$options:'i'} + } + + const selectField = ['userId','username']; + + const populate = { + path: 'user', + select: ['photo'] + }; + + + const result = await super.$list(query,selectField,populate); + console.log(result); + return result; + + } + + async getUserByIdWithHelpsAndOffers(id) { + const query = { userId: ObjectID(id) }; + + const networkProfileFields = [ + '_id', + 'userId', + 'username', + 'followers', + 'following', + ]; + + const user = { + path: 'user', + select: ['phone', 'name', 'birthday', 'address.city'] + }; + + const entity = { + path: 'entity', + select: ['phone', 'name', 'address.city'] + }; + + + const userHelps = { + path: 'userHelps', + select: ['title','description'] + } + + const userOffers = { + path: 'helpsOffers', + select: ['title','description'] + } + + + const populate = [user,entity,userHelps,userOffers]; + let a = await super.$findOne(query, networkProfileFields, populate); + console.log(a); + a.number_of_followers = a.followers.length; + a.number_of_following = a.following.length; + console.log('----------------------------------------------'); + console.log(a); + return a; + } + + + + + + + + async getByIdWithAggregation(id) { + const query = { userId: ObjectID(id) }; + + const networkProfileFields = [ + '_id', + 'userId', + 'username', + 'followers', + 'following', + ]; + + const user = { + path: 'user', + select: ['phone', 'name', 'birthday', 'address.city'] + }; + + const entity = { + path: 'entity', + select: ['phone', 'name', 'address.city'] + }; + + const followers = { + path: 'Followers', + select: ['_id','userId','username','followers','following'] + }; + + const following = { + path: 'Following', + select: ['_id','userId','username','followers','following'] + } + + const populate = [user,followers,following,entity]; + let a = await super.$findOne(query, networkProfileFields, populate); + console.log(a); + return a; + } + + + + } module.exports = SocialNetworkRepository; diff --git a/src/routes/SocialNetworkRoutes.js b/src/routes/SocialNetworkRoutes.js index 9676d146..39e9df99 100644 --- a/src/routes/SocialNetworkRoutes.js +++ b/src/routes/SocialNetworkRoutes.js @@ -5,12 +5,21 @@ const isAuthenticated = require("../validation/middlewares/authFirebase"); const routes = express.Router(); const socialNetworkProfileController = new SocialNetworkProfileController(); -routes.put("/socialNetworkProfile/followUser/:followerId/:followedId", /*isAuthenticated,*/ async (req, res, next) => { +routes.put("/socialNetworkProfile/followUser/:followerId/:userId", /*isAuthenticated,*/ async (req, res, next) => { socialNetworkProfileController.followUser(req, res, next); }); -routes.put("/socialNetworkProfile/unfollowUser/:followerId/:followedId", /*isAuthenticated,*/ async (req, res, next) => { +routes.put("/socialNetworkProfile/unfollowUser/:followerId/:userId",/*isAuthenticated,*/ async (req, res, next) => { socialNetworkProfileController.unfollowUser(req, res, next); }); + +routes.get("/socialNetworkProfile/findUsers/:userId/:username",/*isAuthenticated,*/ async (req, res, next) => { + socialNetworkProfileController.findUsers(req, res, next); +}); + + + + + module.exports = routes; diff --git a/src/services/EntityService.js b/src/services/EntityService.js index 0e4161f3..1de97b80 100644 --- a/src/services/EntityService.js +++ b/src/services/EntityService.js @@ -1,5 +1,6 @@ const EntityRepository = require("../repository/EntityRepository"); const UserRepository = require("../repository/UserRepository"); +const SocialNetworkService = require("../services/SocialNetworkService"); const firebase = require("../config/authFirebase"); const { ObjectID } = require("mongodb"); @@ -7,6 +8,7 @@ class EntityService { constructor() { this.entityRepository = new EntityRepository(); this.userRepository = new UserRepository(); + this.socialNetworkService = new SocialNetworkService(); } async createEntity(data) { @@ -29,7 +31,7 @@ class EntityService { data.email = data.email.toLowerCase(); try { const createdEntity = await this.entityRepository.create(data); - + const createdSocialNetworkUser = await this.socialNetworkService.createSocialNetworkUser(createdEntity); if (!data.hasUser) { console.log("Usuario Criado"); // Cria o usuário no firebase @@ -43,6 +45,7 @@ class EntityService { }) .catch(async (err) => { await this.removeEntity(data.email); + await this.socialNetworkService.removeSocialNetworkUser(createdSocialNetworkUser._id); throw err; }); } diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index 8ff1bd08..aa94f766 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -15,23 +15,34 @@ class SocialNetworkService { username: createdUser.name, userId: createdUser._id, }; + + const createdSocialNetworkUser = await this.socialNetworkRepository.create(socialProfileData); + console.log(createdSocialNetworkUser); + return createdSocialNetworkUser; + + } - console.log(socialProfileData.username); - console.log("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - console.log(socialProfileData.userId); - - return this.socialNetworkRepository.create(socialProfileData); + async removeSocialNetworkUser(id){ + await this.socialNetworkRepository.destroy(id); } - async followUser(followerId, followedId){ + async followUser(followerId, userId){ + + let a = await this.socialNetworkRepository.getUserByIdWithHelpsAndOffers(userId); + console.log(a.number_of_followers); + console.log(a.number_of_following); + return true; + + - let followedUser = await this.socialNetworkRepository.findUserProfilebyUserId(followedId); + let followedUser = await this.socialNetworkRepository.findUserProfilebyUserId(userId); let followerUser = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); + console.log(global.isUserEntity); console.log(followedUser); console.log(followerUser); if(!followedUser){ @@ -41,22 +52,22 @@ class SocialNetworkService { } const followerPosition = followedUser.followers.indexOf(followerId); - const followingPosition = followerUser.following.indexOf(followedId); + const followingPosition = followerUser.following.indexOf(userId); if (followerPosition > -1 || followingPosition > -1) { throw new Error("Usuário já é um seguidor"); } followedUser.followers.push(followerId); - followerUser.following.push(followedId); + followerUser.following.push(userId); await this.socialNetworkRepository.updateProfile(followedUser); await this.socialNetworkRepository.updateProfile(followerUser); } - async unfollowUser(followerId, followedId){ + async unfollowUser(followerId, userId){ - let followedUser = await this.socialNetworkRepository.findUserProfilebyUserId(followedId); + let followedUser = await this.socialNetworkRepository.findUserProfilebyUserId(userId); let followerUser = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); console.log(followedUser); @@ -68,7 +79,7 @@ class SocialNetworkService { } const followerPosition = followedUser.followers.indexOf(followerId); - const followingPosition = followerUser.following.indexOf(followedId); + const followingPosition = followerUser.following.indexOf(userId); if (followerPosition < 0 || followingPosition < 0) { throw new Error("Usuário não é um seguidor"); } @@ -81,6 +92,17 @@ class SocialNetworkService { } + + async findUsers(userId,username) { + + const user = await this.socialNetworkRepository.findUsersbyName(userId,username); + + if(!user){ + throw new Error("Nenhuma usuário encontrado"); + } + return user; + } + } module.exports = SocialNetworkService; diff --git a/src/services/UserService.js b/src/services/UserService.js index a3ef5039..57eec893 100644 --- a/src/services/UserService.js +++ b/src/services/UserService.js @@ -45,6 +45,7 @@ class UserService { }) .catch(async (err) => { await this.removeUser(data.email); + await this.socialNetworkService.removeSocialNetworkUser(createdSocialNetworkUser._id); throw err; }); } From 3cec8d8b36b1541a5826b1d7cfdfc6e8ce4cc406 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Wed, 6 Jul 2022 15:23:55 -0300 Subject: [PATCH 003/107] =?UTF-8?q?Adiciona=20pesquisa=20por=20usu=C3=A1ri?= =?UTF-8?q?os?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/SocialNetworkProfile.js | 8 ++++++++ src/repository/BaseRepository.js | 6 ++++-- src/repository/SocialNetworkRepository.js | 12 ++++++++---- src/routes/SocialNetworkRoutes.js | 6 +++--- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/models/SocialNetworkProfile.js b/src/models/SocialNetworkProfile.js index b107b01d..3e645cc5 100644 --- a/src/models/SocialNetworkProfile.js +++ b/src/models/SocialNetworkProfile.js @@ -71,6 +71,14 @@ SocialNetworkProfileSchema.virtual('userHelps', { }); +SocialNetworkProfileSchema.virtual('numberOfFollowers').get(function() { + return this.followers.length; +}); + +SocialNetworkProfileSchema.virtual('numberOfFollowing').get(function() { + return this.following.length; +}); + diff --git a/src/repository/BaseRepository.js b/src/repository/BaseRepository.js index 9dfcac29..c87fa1c6 100644 --- a/src/repository/BaseRepository.js +++ b/src/repository/BaseRepository.js @@ -70,10 +70,12 @@ class BaseRepository { return recordModel; } - async $list(query, selectedField = null, populate = null, sort = null) { + async $list(query, selectedField = null, populate = null, sort = null,limit = null) { return this.modelClass.find(query, selectedField) .populate(populate) - .sort(sort); + .sort(sort) + .limit(limit) + ; } async $countDocuments(query) { diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 2e2c5fc6..d390b743 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -37,14 +37,18 @@ class SocialNetworkRepository extends BaseRepository { } async findUsersbyName(userId,userName) { - console.log(userId); - console.log(userName); + const query = { userId: {$ne:ObjectID(userId)}, username: {$regex: userName,$options:'i'} } - const selectField = ['userId','username']; + const selectField = [ + 'userId', + 'username', + 'followers', + 'following', + ]; const populate = { path: 'user', @@ -53,7 +57,7 @@ class SocialNetworkRepository extends BaseRepository { const result = await super.$list(query,selectField,populate); - console.log(result); + return result; } diff --git a/src/routes/SocialNetworkRoutes.js b/src/routes/SocialNetworkRoutes.js index 39e9df99..302e6d50 100644 --- a/src/routes/SocialNetworkRoutes.js +++ b/src/routes/SocialNetworkRoutes.js @@ -5,16 +5,16 @@ const isAuthenticated = require("../validation/middlewares/authFirebase"); const routes = express.Router(); const socialNetworkProfileController = new SocialNetworkProfileController(); -routes.put("/socialNetworkProfile/followUser/:followerId/:userId", /*isAuthenticated,*/ async (req, res, next) => { +routes.put("/socialNetworkProfile/followUser/:followerId/:userId", isAuthenticated, async (req, res, next) => { socialNetworkProfileController.followUser(req, res, next); }); -routes.put("/socialNetworkProfile/unfollowUser/:followerId/:userId",/*isAuthenticated,*/ async (req, res, next) => { +routes.put("/socialNetworkProfile/unfollowUser/:followerId/:userId",isAuthenticated, async (req, res, next) => { socialNetworkProfileController.unfollowUser(req, res, next); }); -routes.get("/socialNetworkProfile/findUsers/:userId/:username",/*isAuthenticated,*/ async (req, res, next) => { +routes.get("/socialNetworkProfile/findUsers/:userId/:username",isAuthenticated, async (req, res, next) => { socialNetworkProfileController.findUsers(req, res, next); }); From b326aac2ed740d7cca5f0fbe7ea914fd5bbd20a1 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Thu, 18 Aug 2022 18:25:16 -0300 Subject: [PATCH 004/107] Add get activities, follow and unfollow functions. --- .../SocialNetworkProfileController.js | 21 ++++- src/models/SocialNetworkProfile.js | 4 +- src/repository/SocialNetworkRepository.js | 70 +++++++++------ src/routes/SocialNetworkRoutes.js | 4 + src/services/SocialNetworkService.js | 86 +++++++++++-------- 5 files changed, 114 insertions(+), 71 deletions(-) diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js index 6d61fa65..d81cc16e 100644 --- a/src/controllers/SocialNetworkProfileController.js +++ b/src/controllers/SocialNetworkProfileController.js @@ -9,8 +9,8 @@ class HelpController { async followUser(req, res, next) { const { followerId, userId } = req.params; try { - await this.socialNetworkService.followUser(followerId, userId); - res.status(204).send(); + const result = await this.socialNetworkService.followUser(followerId, userId); + res.status(200).send(result); next(); } catch (err) { saveError(err); @@ -22,8 +22,8 @@ class HelpController { async unfollowUser(req, res, next) { const { followerId, userId } = req.params; try { - await this.socialNetworkService.unfollowUser(followerId, userId); - res.status(204).send(); + const result = await this.socialNetworkService.unfollowUser(followerId, userId); + res.status(200).send(result); next(); } catch (err) { saveError(err); @@ -47,6 +47,19 @@ class HelpController { } } + async getUserActivities(req, res, next){ + const { userId } = req.params; + try { + const result = await this.socialNetworkService.getUserActivities(userId); + res.status(200).json(result); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } + } module.exports = HelpController; diff --git a/src/models/SocialNetworkProfile.js b/src/models/SocialNetworkProfile.js index 3e645cc5..d7dd2fe4 100644 --- a/src/models/SocialNetworkProfile.js +++ b/src/models/SocialNetworkProfile.js @@ -72,11 +72,11 @@ SocialNetworkProfileSchema.virtual('userHelps', { SocialNetworkProfileSchema.virtual('numberOfFollowers').get(function() { - return this.followers.length; + return this.followers? this.followers.length:null; }); SocialNetworkProfileSchema.virtual('numberOfFollowing').get(function() { - return this.following.length; + return this.following? this.following.length:null; }); diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index d390b743..b11da739 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -32,14 +32,26 @@ class SocialNetworkRepository extends BaseRepository { ); } + async findUserProfilebyProfileId(id) { + + const matchQuery = { _id: ObjectID(id) }; + const socialNetworkProfileFields = [ + '_id', 'userId', 'username', + 'followers', 'following', + ]; + return super.$findOne( + matchQuery, + socialNetworkProfileFields + ); + } + async updateProfile(socialNetworkProfile) { await super.$update(socialNetworkProfile); } - async findUsersbyName(userId,userName) { - + async findUsersbyName(userId2,userName) { const query = { - userId: {$ne:ObjectID(userId)}, + userId: {$ne:ObjectID(userId2)}, username: {$regex: userName,$options:'i'} } @@ -57,33 +69,42 @@ class SocialNetworkRepository extends BaseRepository { const result = await super.$list(query,selectField,populate); + + const result2 = result.map((temp) => { + const isFollowing = temp.followers.includes(userId2); + const { + _doc:{_id,username,userId}, + $$populatedVirtuals:{user:{photo}}, + numberOfFollowers,numberOfFollowing + } = temp; + const newDoc = { + _id, + username, + userId, + photo, + numberOfFollowers, + numberOfFollowing, + isFollowing + } + + return newDoc; + }) + - return result; + + + return result2; } - async getUserByIdWithHelpsAndOffers(id) { + async getUserActivitiesById(id) { const query = { userId: ObjectID(id) }; - const networkProfileFields = [ '_id', 'userId', 'username', - 'followers', - 'following', ]; - const user = { - path: 'user', - select: ['phone', 'name', 'birthday', 'address.city'] - }; - - const entity = { - path: 'entity', - select: ['phone', 'name', 'address.city'] - }; - - const userHelps = { path: 'userHelps', select: ['title','description'] @@ -94,14 +115,9 @@ class SocialNetworkRepository extends BaseRepository { select: ['title','description'] } - - const populate = [user,entity,userHelps,userOffers]; - let a = await super.$findOne(query, networkProfileFields, populate); - console.log(a); - a.number_of_followers = a.followers.length; - a.number_of_following = a.following.length; - console.log('----------------------------------------------'); - console.log(a); + const populate = [userHelps,userOffers]; + let a = await super.$list(query, networkProfileFields, populate); + return a; } diff --git a/src/routes/SocialNetworkRoutes.js b/src/routes/SocialNetworkRoutes.js index 302e6d50..1ff0ad60 100644 --- a/src/routes/SocialNetworkRoutes.js +++ b/src/routes/SocialNetworkRoutes.js @@ -18,6 +18,10 @@ routes.get("/socialNetworkProfile/findUsers/:userId/:username",isAuthenticated, socialNetworkProfileController.findUsers(req, res, next); }); +routes.get("/socialNetworkProfile/getUserActivities/:userId",isAuthenticated, async (req, res, next) => { + socialNetworkProfileController.getUserActivities(req, res, next); +}); + diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index aa94f766..dace1bbc 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -2,10 +2,15 @@ const SocialNetworkRepository = require("../repository/SocialNetworkRepository") const EntityRepository = require("../repository/EntityRepository"); const firebase = require("../config/authFirebase"); const { ObjectID } = require("mongodb"); +const HelpRepository = require("../repository/HelpRepository"); +const OfferdHelpRepository = require("../repository/HelpOfferRepository"); + class SocialNetworkService { constructor() { this.socialNetworkRepository = new SocialNetworkRepository(); + this.helpRepository = new HelpRepository(); + this.offerdHelpRepository = new OfferdHelpRepository(); } async createSocialNetworkUser(createdUser) { @@ -32,75 +37,80 @@ class SocialNetworkService { async followUser(followerId, userId){ - let a = await this.socialNetworkRepository.getUserByIdWithHelpsAndOffers(userId); - console.log(a.number_of_followers); - console.log(a.number_of_following); - return true; - - - - let followedUser = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - let followerUser = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); + let user = await this.socialNetworkRepository.findUserProfilebyProfileId(userId); + let follower = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); - console.log(global.isUserEntity); - console.log(followedUser); - console.log(followerUser); - if(!followedUser){ - throw new Error ("Followed user profile not found"); - } else if (!followerUser){ + if(!user){ + throw new Error ("User profile not found"); + } else if (!follower){ throw new Error ("Follower user profile not found"); } - const followerPosition = followedUser.followers.indexOf(followerId); - const followingPosition = followerUser.following.indexOf(userId); + const followerPosition = user.followers.indexOf(followerId); + const followingPosition = follower.following.indexOf(userId); if (followerPosition > -1 || followingPosition > -1) { throw new Error("Usuário já é um seguidor"); } - followedUser.followers.push(followerId); - followerUser.following.push(userId); + user.followers.push(followerId); + follower.following.push(userId); - await this.socialNetworkRepository.updateProfile(followedUser); - await this.socialNetworkRepository.updateProfile(followerUser); + await this.socialNetworkRepository.updateProfile(user); + await this.socialNetworkRepository.updateProfile(follower); + + return true; } async unfollowUser(followerId, userId){ - let followedUser = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - let followerUser = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); + let user = await this.socialNetworkRepository.findUserProfilebyProfileId(userId); + let follower = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); - console.log(followedUser); - console.log(followerUser); - if(!followedUser){ + if(!user){ throw new Error ("Followed user profile not found"); - } else if (!followerUser){ + } else if (!follower){ throw new Error ("Follower user profile not found"); } - const followerPosition = followedUser.followers.indexOf(followerId); - const followingPosition = followerUser.following.indexOf(userId); + const followerPosition = user.followers.indexOf(followerId); + const followingPosition = follower.following.indexOf(userId); if (followerPosition < 0 || followingPosition < 0) { throw new Error("Usuário não é um seguidor"); } - followedUser.followers.splice(followerPosition,1); - followerUser.following.splice(followingPosition,1); - - await this.socialNetworkRepository.updateProfile(followedUser); - await this.socialNetworkRepository.updateProfile(followerUser); + user.followers.splice(followerPosition,1); + follower.following.splice(followingPosition,1); + await this.socialNetworkRepository.updateProfile(user); + await this.socialNetworkRepository.updateProfile(follower); + return false; } async findUsers(userId,username) { - const user = await this.socialNetworkRepository.findUsersbyName(userId,username); + const users = await this.socialNetworkRepository.findUsersbyName(userId,username); - if(!user){ - throw new Error("Nenhuma usuário encontrado"); + if(!users){ + throw new Error("Nenhum usuário encontrado"); } - return user; + return users; + } + + async getUserActivities(userId){ + + let helper = false; + let statusList = ['waiting','on_going','finished','owner_finished','helper_finished']; + let getOtherUsers = true; + let categoryArray = null; + + let helps = await this.helpRepository.getHelpListByStatus(userId, statusList, helper); + let offers = await this.offerdHelpRepository.list(userId, categoryArray, getOtherUsers); + + let activities = {helps,offers}; + console.log(activities); + return activities; } } From 296ab1370b714545d163d62403c5e0c956c7bb01 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Sat, 20 Aug 2022 19:11:42 -0300 Subject: [PATCH 005/107] Init getFollowers --- .../SocialNetworkProfileController.js | 16 +++++++++ src/repository/SocialNetworkRepository.js | 35 +++++++++++++++---- src/routes/SocialNetworkRoutes.js | 4 +++ src/services/SocialNetworkService.js | 10 ++++++ 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js index d81cc16e..d42ffab0 100644 --- a/src/controllers/SocialNetworkProfileController.js +++ b/src/controllers/SocialNetworkProfileController.js @@ -60,6 +60,22 @@ class HelpController { } } + async getFollowers(req, res, next){ + const { userId } = req.params; + try { + console.log("getFollowers"); + const result = await this.socialNetworkService.getFollowers(userId); + res.status(200).json(result); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } + + + } module.exports = HelpController; diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index b11da739..05fb9ab3 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -121,12 +121,6 @@ class SocialNetworkRepository extends BaseRepository { return a; } - - - - - - async getByIdWithAggregation(id) { const query = { userId: ObjectID(id) }; @@ -164,6 +158,35 @@ class SocialNetworkRepository extends BaseRepository { return a; } + async getFollowers(profileId){ + + console.log(profileId); + const query = { _id: ObjectID(profileId) }; + + const selectField = [ + 'followers', + ]; + + const followers = { + path: 'Followers', + select: ['userId','username','followers','following'] + }; + + const user = { + path: 'user', + select: ['photo'] + }; + + + const populate = [followers,user]; + + console.log("repository"); + const result = await super.$list(query,selectField,populate); + console.log(result); + + + return result; + } diff --git a/src/routes/SocialNetworkRoutes.js b/src/routes/SocialNetworkRoutes.js index 1ff0ad60..111f8058 100644 --- a/src/routes/SocialNetworkRoutes.js +++ b/src/routes/SocialNetworkRoutes.js @@ -22,6 +22,10 @@ routes.get("/socialNetworkProfile/getUserActivities/:userId",isAuthenticated, as socialNetworkProfileController.getUserActivities(req, res, next); }); +routes.get("/socialNetworkProfile/getFollowers/:userId",/*isAuthenticated,*/ async (req, res, next) => { + socialNetworkProfileController.getFollowers(req, res, next); +}); + diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index dace1bbc..6bdeb1f7 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -113,6 +113,16 @@ class SocialNetworkService { return activities; } + + async getFollowers(userId){ + const followers = this.socialNetworkRepository.getFollowers(userId); + return followers; + } + + async getFollowing(userId){ + + } + } module.exports = SocialNetworkService; From 616dc0991ab46671551ae6443681792021fa5520 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Sun, 21 Aug 2022 18:42:50 -0300 Subject: [PATCH 006/107] Complete add getFollowers/getFollowing routes and rename variables --- .../SocialNetworkProfileController.js | 25 ++++-- src/models/SocialNetworkProfile.js | 8 +- src/repository/SocialNetworkRepository.js | 82 ++++++++++++++----- src/routes/SocialNetworkRoutes.js | 9 +- src/services/SocialNetworkService.js | 69 +++++++++------- 5 files changed, 129 insertions(+), 64 deletions(-) diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js index d42ffab0..8261b684 100644 --- a/src/controllers/SocialNetworkProfileController.js +++ b/src/controllers/SocialNetworkProfileController.js @@ -7,9 +7,9 @@ class HelpController { } async followUser(req, res, next) { - const { followerId, userId } = req.params; + const { selectedProfileId, userId } = req.params; try { - const result = await this.socialNetworkService.followUser(followerId, userId); + const result = await this.socialNetworkService.followUser(selectedProfileId, userId); res.status(200).send(result); next(); } catch (err) { @@ -20,9 +20,9 @@ class HelpController { } async unfollowUser(req, res, next) { - const { followerId, userId } = req.params; + const { selectedProfileId, userId } = req.params; try { - const result = await this.socialNetworkService.unfollowUser(followerId, userId); + const result = await this.socialNetworkService.unfollowUser(selectedProfileId, userId); res.status(200).send(result); next(); } catch (err) { @@ -61,10 +61,9 @@ class HelpController { } async getFollowers(req, res, next){ - const { userId } = req.params; + const { userId, selectedProfileId } = req.params; try { - console.log("getFollowers"); - const result = await this.socialNetworkService.getFollowers(userId); + const result = await this.socialNetworkService.getFollowers(userId, selectedProfileId); res.status(200).json(result); next(); } catch (err) { @@ -74,6 +73,18 @@ class HelpController { } } + async getFollowing(req, res, next){ + const { userId, selectedProfileId } = req.params; + try { + const result = await this.socialNetworkService.getFollowing(userId, selectedProfileId); + res.status(200).json(result); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } } diff --git a/src/models/SocialNetworkProfile.js b/src/models/SocialNetworkProfile.js index d7dd2fe4..490cf08a 100644 --- a/src/models/SocialNetworkProfile.js +++ b/src/models/SocialNetworkProfile.js @@ -49,13 +49,13 @@ SocialNetworkProfileSchema.virtual('entity', { SocialNetworkProfileSchema.virtual('Followers', { ref: 'socialNetworkProfile', localField: 'followers', - foreignField: 'userId' + foreignField: '_id' }); SocialNetworkProfileSchema.virtual('Following', { ref: 'socialNetworkProfile', localField: 'following', - foreignField: 'userId' + foreignField: '_id' }); SocialNetworkProfileSchema.virtual('helpsOffers', { @@ -72,11 +72,11 @@ SocialNetworkProfileSchema.virtual('userHelps', { SocialNetworkProfileSchema.virtual('numberOfFollowers').get(function() { - return this.followers? this.followers.length:null; + return this.followers? this.followers.length:0; }); SocialNetworkProfileSchema.virtual('numberOfFollowing').get(function() { - return this.following? this.following.length:null; + return this.following? this.following.length:0; }); diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 05fb9ab3..e02f7f4e 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -49,9 +49,9 @@ class SocialNetworkRepository extends BaseRepository { await super.$update(socialNetworkProfile); } - async findUsersbyName(userId2,userName) { + async findUsersbyName(userProfileId,userName) { const query = { - userId: {$ne:ObjectID(userId2)}, + _id: {$ne:ObjectID(userProfileId)}, username: {$regex: userName,$options:'i'} } @@ -71,7 +71,7 @@ class SocialNetworkRepository extends BaseRepository { const result = await super.$list(query,selectField,populate); const result2 = result.map((temp) => { - const isFollowing = temp.followers.includes(userId2); + const isFollowing = temp.followers.includes(userProfileId); const { _doc:{_id,username,userId}, $$populatedVirtuals:{user:{photo}}, @@ -90,9 +90,6 @@ class SocialNetworkRepository extends BaseRepository { return newDoc; }) - - - return result2; } @@ -154,14 +151,15 @@ class SocialNetworkRepository extends BaseRepository { const populate = [user,followers,following,entity]; let a = await super.$findOne(query, networkProfileFields, populate); - console.log(a); return a; } - async getFollowers(profileId){ + async getFollowers(userProfileId, selectedProfileId){ + + // console.log(userProfileId); + // console.log(selectedProfileId); - console.log(profileId); - const query = { _id: ObjectID(profileId) }; + const query = { _id: ObjectID(selectedProfileId) }; const selectField = [ 'followers', @@ -169,23 +167,69 @@ class SocialNetworkRepository extends BaseRepository { const followers = { path: 'Followers', + populate: { + path: 'user', + select: ['photo'] + } , select: ['userId','username','followers','following'] }; + const populate = [followers]; + + let result = await super.$list(query,selectField,populate); - const user = { - path: 'user', - select: ['photo'] - }; + // permite a adição de novos atributos no resultado + result = JSON.parse(JSON.stringify(result)) + const result2 = result[0].Followers.map((temp) => { + temp.isFollowing = temp.followers.includes(userProfileId); + temp.photo = temp.user.photo; + delete temp.user; + return temp; + }) - const populate = [followers,user]; - console.log("repository"); - const result = await super.$list(query,selectField,populate); - console.log(result); + //console.log(result2); + + return result2; + } + + async getFollowing(userProfileId, selectedProfileId){ + + // console.log(userProfileId); + // console.log(selectedProfileId); + + const query = { _id: ObjectID(selectedProfileId) }; + + const selectField = [ + 'following', + ]; + + const following = { + path: 'Following', + populate: { + path: 'user', + select: ['photo'] + } , + select: ['userId','username','followers','following'] + }; + const populate = [following]; + let result = await super.$list(query,selectField,populate); - return result; + // permite a adição de novos atributos no resultado + result = JSON.parse(JSON.stringify(result)) + + const result2 = result[0].Following.map((temp) => { + temp.isFollowing = temp.following.includes(userProfileId); + temp.photo = temp.user.photo; + delete temp.user; + return temp; + }) + + + //console.log(result2); + + return result2; } diff --git a/src/routes/SocialNetworkRoutes.js b/src/routes/SocialNetworkRoutes.js index 111f8058..6255543a 100644 --- a/src/routes/SocialNetworkRoutes.js +++ b/src/routes/SocialNetworkRoutes.js @@ -5,11 +5,11 @@ const isAuthenticated = require("../validation/middlewares/authFirebase"); const routes = express.Router(); const socialNetworkProfileController = new SocialNetworkProfileController(); -routes.put("/socialNetworkProfile/followUser/:followerId/:userId", isAuthenticated, async (req, res, next) => { +routes.put("/socialNetworkProfile/followUser/:selectedProfileId/:userId", isAuthenticated, async (req, res, next) => { socialNetworkProfileController.followUser(req, res, next); }); -routes.put("/socialNetworkProfile/unfollowUser/:followerId/:userId",isAuthenticated, async (req, res, next) => { +routes.put("/socialNetworkProfile/unfollowUser/:selectedProfileId/:userId",isAuthenticated, async (req, res, next) => { socialNetworkProfileController.unfollowUser(req, res, next); }); @@ -22,10 +22,13 @@ routes.get("/socialNetworkProfile/getUserActivities/:userId",isAuthenticated, as socialNetworkProfileController.getUserActivities(req, res, next); }); -routes.get("/socialNetworkProfile/getFollowers/:userId",/*isAuthenticated,*/ async (req, res, next) => { +routes.get("/socialNetworkProfile/getFollowers/:userId/:selectedProfileId",isAuthenticated, async (req, res, next) => { socialNetworkProfileController.getFollowers(req, res, next); }); +routes.get("/socialNetworkProfile/getFollowing/:userId/:selectedProfileId",isAuthenticated, async (req, res, next) => { + socialNetworkProfileController.getFollowing(req, res, next); +}); diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index 6bdeb1f7..e015e4ef 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -35,62 +35,63 @@ class SocialNetworkService { } - async followUser(followerId, userId){ + async followUser(selectedProfileId, userId){ - let user = await this.socialNetworkRepository.findUserProfilebyProfileId(userId); - let follower = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); + let selectedProfile = await this.socialNetworkRepository.findUserProfilebyProfileId(selectedProfileId); + let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - if(!user){ + if(!userProfile){ throw new Error ("User profile not found"); - } else if (!follower){ - throw new Error ("Follower user profile not found"); + } else if (!selectedProfile){ + throw new Error ("Selected profile not found"); } - const followerPosition = user.followers.indexOf(followerId); - const followingPosition = follower.following.indexOf(userId); + const followerPosition = selectedProfile.followers.indexOf(userProfile._id); + const followingPosition = userProfile.following.indexOf(selectedProfileId); if (followerPosition > -1 || followingPosition > -1) { throw new Error("Usuário já é um seguidor"); } - user.followers.push(followerId); - follower.following.push(userId); + selectedProfile.followers.push(userProfile._id); + userProfile.following.push(selectedProfileId); - await this.socialNetworkRepository.updateProfile(user); - await this.socialNetworkRepository.updateProfile(follower); + await this.socialNetworkRepository.updateProfile(userProfile); + await this.socialNetworkRepository.updateProfile(selectedProfile); return true; } - async unfollowUser(followerId, userId){ + async unfollowUser(selectedProfileId, userId){ - let user = await this.socialNetworkRepository.findUserProfilebyProfileId(userId); - let follower = await this.socialNetworkRepository.findUserProfilebyUserId(followerId); + let selectedProfile = await this.socialNetworkRepository.findUserProfilebyProfileId(selectedProfileId); + let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - if(!user){ - throw new Error ("Followed user profile not found"); - } else if (!follower){ - throw new Error ("Follower user profile not found"); + if(!userProfile){ + throw new Error ("User profile not found"); + } else if (!selectedProfile){ + throw new Error ("Selected profile not found"); } - const followerPosition = user.followers.indexOf(followerId); - const followingPosition = follower.following.indexOf(userId); + const followerPosition = selectedProfile.followers.indexOf(userProfile._id); + const followingPosition = userProfile.following.indexOf(selectedProfileId); if (followerPosition < 0 || followingPosition < 0) { throw new Error("Usuário não é um seguidor"); } - user.followers.splice(followerPosition,1); - follower.following.splice(followingPosition,1); + selectedProfile.followers.splice(followerPosition,1); + userProfile.following.splice(followingPosition,1); - await this.socialNetworkRepository.updateProfile(user); - await this.socialNetworkRepository.updateProfile(follower); + await this.socialNetworkRepository.updateProfile(selectedProfile); + await this.socialNetworkRepository.updateProfile(userProfile); return false; } async findUsers(userId,username) { - const users = await this.socialNetworkRepository.findUsersbyName(userId,username); + let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const users = await this.socialNetworkRepository.findUsersbyName(userProfile._id,username); if(!users){ throw new Error("Nenhum usuário encontrado"); @@ -109,18 +110,24 @@ class SocialNetworkService { let offers = await this.offerdHelpRepository.list(userId, categoryArray, getOtherUsers); let activities = {helps,offers}; - console.log(activities); + //console.log(activities); return activities; } - async getFollowers(userId){ - const followers = this.socialNetworkRepository.getFollowers(userId); + async getFollowers(userId, selectedProfileId){ + + let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const followers = await this.socialNetworkRepository.getFollowers(userProfile._id, selectedProfileId); + return followers; } - async getFollowing(userId){ - + async getFollowing(userId, selectedProfileId){ + let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const following = await this.socialNetworkRepository.getFollowing(userProfile._id, selectedProfileId); + + return following; } } From f78b029064f706d60eedd4947449168b6d389a74 Mon Sep 17 00:00:00 2001 From: darmsDD Date: Mon, 22 Aug 2022 19:01:46 -0300 Subject: [PATCH 007/107] Add follow/following counter to user profile --- src/controllers/SocialNetworkProfileController.js | 13 +++++++++++++ src/repository/SocialNetworkRepository.js | 8 +------- src/routes/SocialNetworkRoutes.js | 3 +++ src/services/SocialNetworkService.js | 10 +++++++--- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js index 8261b684..e64d621d 100644 --- a/src/controllers/SocialNetworkProfileController.js +++ b/src/controllers/SocialNetworkProfileController.js @@ -86,6 +86,19 @@ class HelpController { } } + async getUserProfile(req, res, next){ + const { userId} = req.params; + try { + const result = await this.socialNetworkService.getUserProfile(userId); + res.status(200).json(result); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } + } diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index e02f7f4e..0c524900 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -195,9 +195,6 @@ class SocialNetworkRepository extends BaseRepository { async getFollowing(userProfileId, selectedProfileId){ - // console.log(userProfileId); - // console.log(selectedProfileId); - const query = { _id: ObjectID(selectedProfileId) }; const selectField = [ @@ -220,15 +217,12 @@ class SocialNetworkRepository extends BaseRepository { result = JSON.parse(JSON.stringify(result)) const result2 = result[0].Following.map((temp) => { - temp.isFollowing = temp.following.includes(userProfileId); + temp.isFollowing = temp.followers.includes(userProfileId); temp.photo = temp.user.photo; delete temp.user; return temp; }) - - //console.log(result2); - return result2; } diff --git a/src/routes/SocialNetworkRoutes.js b/src/routes/SocialNetworkRoutes.js index 6255543a..e2956caa 100644 --- a/src/routes/SocialNetworkRoutes.js +++ b/src/routes/SocialNetworkRoutes.js @@ -31,6 +31,9 @@ routes.get("/socialNetworkProfile/getFollowing/:userId/:selectedProfileId",isAut }); +routes.get("/socialNetworkProfile/getUserProfile/:userId",isAuthenticated, async (req, res, next) => { + socialNetworkProfileController.getUserProfile(req, res, next); +}); module.exports = routes; diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index e015e4ef..6660c647 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -91,7 +91,7 @@ class SocialNetworkService { async findUsers(userId,username) { let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - const users = await this.socialNetworkRepository.findUsersbyName(userProfile._id,username); + const users = await this.socialNetworkRepository.findUsersbyName(userProfile.id,username); if(!users){ throw new Error("Nenhum usuário encontrado"); @@ -118,18 +118,22 @@ class SocialNetworkService { async getFollowers(userId, selectedProfileId){ let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - const followers = await this.socialNetworkRepository.getFollowers(userProfile._id, selectedProfileId); + const followers = await this.socialNetworkRepository.getFollowers(userProfile.id, selectedProfileId); return followers; } async getFollowing(userId, selectedProfileId){ let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - const following = await this.socialNetworkRepository.getFollowing(userProfile._id, selectedProfileId); + const following = await this.socialNetworkRepository.getFollowing(userProfile.id, selectedProfileId); return following; } + async getUserProfile(userId){ + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + return userProfile; + } } module.exports = SocialNetworkService; From 145870ef84006f6fc3b7ce4e3ca82e1c460b2c7a Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 20:38:40 -0300 Subject: [PATCH 008/107] feat: create offers seed --- src/config/database.js | 2 +- .../seed/{HelpSeed.js => HelpAndOfferSeed.js} | 45 +++++++++++++------ 2 files changed, 32 insertions(+), 15 deletions(-) rename src/utils/seed/{HelpSeed.js => HelpAndOfferSeed.js} (57%) diff --git a/src/config/database.js b/src/config/database.js index 04f9fc63..cdaccde1 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -1,7 +1,7 @@ const mongoose = require('mongoose'); const CategorySeed = require('../utils/seed/CategorySeed'); const UserSeed = require('../utils/seed/UserSeed'); -const HelpSeed = require('../utils/seed/HelpSeed'); +const HelpSeed = require('../utils/seed/HelpAndOfferSeed'); const NotificationSeed = require('../utils/seed/NotificationSeed'); const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaDB'; diff --git a/src/utils/seed/HelpSeed.js b/src/utils/seed/HelpAndOfferSeed.js similarity index 57% rename from src/utils/seed/HelpSeed.js rename to src/utils/seed/HelpAndOfferSeed.js index ca00d91f..f175d730 100644 --- a/src/utils/seed/HelpSeed.js +++ b/src/utils/seed/HelpAndOfferSeed.js @@ -3,6 +3,7 @@ const faker = require('faker/locale/pt_BR'); const Category = require('../../models/Category'); const Help = require('../../models/Help'); const User = require('../../models/User'); +const HelpOffer = require('../../models/HelpOffer'); const status = [ 'waiting', @@ -17,14 +18,16 @@ const seedHelp = async () => { const categoryCollection = await Category.find(); const userCollection = await User.find(); const helpCollection = await Help.find(); + const helpOfferCollection = await HelpOffer.find(); // this condition avoid populate duplicate users - if (helpCollection.length > 0) { + if (helpCollection.length > 0 || helpOfferCollection.length >0) { return; } const quantity = 100; - const helps = []; + const requests = []; + const offers = []; for (let i = 0; i < quantity; i += 1) { const sampleStatus = lodash.sample(status); const sampleCategory = lodash.sample(categoryCollection); @@ -37,29 +40,43 @@ const seedHelp = async () => { samplePossibleHelpers.forEach((item) => { samplePossibleHelpsID.push(item._id); }); - - helps.push( + const sharedInfo = { + title: faker.lorem.lines(1), + description: faker.lorem.lines(1), + status: sampleStatus, + categoryId: [sampleCategory._id], + ownerId: sampleUsers[0]._id, + finishedDate: faker.date.future(), + }; + requests.push( new Help({ - title: faker.lorem.lines(1), - description: faker.lorem.lines(1), - status: sampleStatus, + ...sharedInfo, possibleHelpers: samplePossibleHelpsID, - categoryId: [sampleCategory._id], - ownerId: sampleUsers[0]._id, - finishedDate: faker.date.future(), }), ); + + offers.push( + new HelpOffer({ + ...sharedInfo, + possibleHelpedUsers: samplePossibleHelpsID, + }) + ) } await Help.deleteMany({}); + await HelpOffer.deleteMany({}); + + requests.forEach((request) => { + Help.create(request); + }); - helps.forEach((help) => { - Help.create(help); + offers.forEach((offer) => { + HelpOffer.create(offer); }); - console.log('Ajudas populadas com sucesso!'); + console.log('Pedidos e ofertas populados com sucesso!'); } catch (error) { - console.log('Não foi possível popular as ajudas na base de dados!'); + console.log('Não foi possível pedidos e ofertas na base de dados!'); console.log(error); } }; From 63df9cce1a7401f2b96da1985495863ee0dc4007 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 20:38:53 -0300 Subject: [PATCH 009/107] feat: create entity seed --- src/utils/seed/UserSeed.js | 63 +++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/utils/seed/UserSeed.js b/src/utils/seed/UserSeed.js index be045b3c..a8ce6ed1 100644 --- a/src/utils/seed/UserSeed.js +++ b/src/utils/seed/UserSeed.js @@ -1,7 +1,8 @@ const faker = require('faker/locale/pt_BR'); const lodash = require('lodash'); -const { cpf } = require('cpf-cnpj-validator'); +const { cpf, cnpj } = require('cpf-cnpj-validator'); const User = require('../../models/User'); +const Entity = require('../../models/Entity'); const diseases = ['dc', 'hiv', 'diab', 'hiperT', 'doenCardio']; let latitude = process.env.LATITUDE_ENV || -15.824544; @@ -9,52 +10,70 @@ let longitude = process.env.LONGITUDE_ENV || -48.060878; const seedUser = async () => { try { const userCollection = await User.find(); + const entityCollection = await Entity.find(); // this condition avoid populate duplicate users - if (userCollection.length > 0) { + if (userCollection.length > 0 || entityCollection > 0) { return; } const users = []; + const entities = []; const quantity = 100; for (let i = 0; i < quantity; i += 1) { const sampleRiskGroup = lodash.sampleSize(diseases, faker.random.number(5)); longitude = Number(longitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); latitude = Number(latitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); + const sharedInfo = { + name: faker.name.findName(), + email: faker.internet.email(), + photo: faker.image.avatar(), + address: { + cep: faker.address.zipCode(), + number: faker.random.number(), + city: faker.address.city(), + state: faker.address.state(), + complement: faker.lorem.lines(1), + }, + location: { + type: 'Point', + coordinates: [ + longitude, + latitude, + ], + }, + phone: faker.phone.phoneNumber('+55######-####'), + active: true, + } + users.push( new User({ - name: faker.name.findName(), + ...sharedInfo, birthday: Date.parse(faker.date.between('1940-01-01', '2020-01-01')), cpf: cpf.generate(), - email: faker.internet.email(), - photo: faker.image.avatar(), - address: { - cep: faker.address.zipCode(), - number: faker.random.number(), - city: faker.address.city(), - state: faker.address.state(), - complement: faker.lorem.lines(1), - }, - location: { - type: 'Point', - coordinates: [ - longitude, - latitude, - ], - }, riskGroup: sampleRiskGroup, ismentalHealthProfessional: faker.random.boolean(), - phone: faker.phone.phoneNumber('+55######-####'), - active: true, + }), + ); + + entities.push( + new Entity({ + ...sharedInfo, + cnpj: cnpj.generate(), }), ); } await User.deleteMany({}); + await Entity.deleteMany({}); users.forEach((user) => { User.create(user); }); - console.log('Usuários populados com sucesso!'); + + entities.forEach((entity) => { + Entity.create(entity); + }); + console.log('Usuários e entidades populados com sucesso!'); } catch (error) { console.log('Não foi possível popular os usuáriios na base de dados!'); console.log(error); From 2a05e5efd5eeacbd2f481da48c3c3ee481849ae3 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 20:48:59 -0300 Subject: [PATCH 010/107] feat: create campaign seed --- src/config/database.js | 2 +- ...dOfferSeed.js => HelpOfferCampaignSeed.js} | 25 ++++++++++++++----- src/utils/seed/UserSeed.js | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) rename src/utils/seed/{HelpAndOfferSeed.js => HelpOfferCampaignSeed.js} (78%) diff --git a/src/config/database.js b/src/config/database.js index cdaccde1..c7626547 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -1,7 +1,7 @@ const mongoose = require('mongoose'); const CategorySeed = require('../utils/seed/CategorySeed'); const UserSeed = require('../utils/seed/UserSeed'); -const HelpSeed = require('../utils/seed/HelpAndOfferSeed'); +const HelpSeed = require('../utils/seed/HelpOfferCampaignSeed'); const NotificationSeed = require('../utils/seed/NotificationSeed'); const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaDB'; diff --git a/src/utils/seed/HelpAndOfferSeed.js b/src/utils/seed/HelpOfferCampaignSeed.js similarity index 78% rename from src/utils/seed/HelpAndOfferSeed.js rename to src/utils/seed/HelpOfferCampaignSeed.js index f175d730..0b5ac88d 100644 --- a/src/utils/seed/HelpAndOfferSeed.js +++ b/src/utils/seed/HelpOfferCampaignSeed.js @@ -3,6 +3,8 @@ const faker = require('faker/locale/pt_BR'); const Category = require('../../models/Category'); const Help = require('../../models/Help'); const User = require('../../models/User'); +const Entity = require('../../models/Entity'); +const Campaign = require('../../models/Campaign'); const HelpOffer = require('../../models/HelpOffer'); const status = [ @@ -17,21 +19,24 @@ const seedHelp = async () => { try { const categoryCollection = await Category.find(); const userCollection = await User.find(); + const entityCollection = await Entity.find(); const helpCollection = await Help.find(); const helpOfferCollection = await HelpOffer.find(); // this condition avoid populate duplicate users - if (helpCollection.length > 0 || helpOfferCollection.length >0) { + if (helpCollection.length > 0 || helpOfferCollection.length > 0) { return; } const quantity = 100; const requests = []; const offers = []; + const campaigns = []; for (let i = 0; i < quantity; i += 1) { const sampleStatus = lodash.sample(status); const sampleCategory = lodash.sample(categoryCollection); const sampleUsers = lodash.sampleSize(userCollection, 2); + const sampleEntities = lodash.sampleSize(entityCollection, 2); const samplePossibleHelpers = lodash.sampleSize( userCollection, faker.random.number(5), @@ -48,19 +53,27 @@ const seedHelp = async () => { ownerId: sampleUsers[0]._id, finishedDate: faker.date.future(), }; + requests.push( new Help({ ...sharedInfo, possibleHelpers: samplePossibleHelpsID, }), ); - + offers.push( new HelpOffer({ ...sharedInfo, possibleHelpedUsers: samplePossibleHelpsID, - }) - ) + }), + ); + + campaigns.push( + new Campaign({ + ...sharedInfo, + ownerId: sampleEntities[0]._id, + }), + ); } await Help.deleteMany({}); @@ -74,9 +87,9 @@ const seedHelp = async () => { HelpOffer.create(offer); }); - console.log('Pedidos e ofertas populados com sucesso!'); + console.log('Pedidos, ofertas e campanhas populados com sucesso!'); } catch (error) { - console.log('Não foi possível pedidos e ofertas na base de dados!'); + console.log('Não foi possível criar pedidos, ofertas e campanhas na base de dados!'); console.log(error); } }; diff --git a/src/utils/seed/UserSeed.js b/src/utils/seed/UserSeed.js index a8ce6ed1..45d996a3 100644 --- a/src/utils/seed/UserSeed.js +++ b/src/utils/seed/UserSeed.js @@ -44,7 +44,7 @@ const seedUser = async () => { }, phone: faker.phone.phoneNumber('+55######-####'), active: true, - } + }; users.push( new User({ From 4503566c225f03bbb32bc4d19d051a9631806bc5 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 20:55:38 -0300 Subject: [PATCH 011/107] Revert "feat: create campaign seed" This reverts commit 2a05e5efd5eeacbd2f481da48c3c3ee481849ae3. --- src/config/database.js | 2 +- ...ferCampaignSeed.js => HelpAndOfferSeed.js} | 25 +++++-------------- src/utils/seed/UserSeed.js | 2 +- 3 files changed, 8 insertions(+), 21 deletions(-) rename src/utils/seed/{HelpOfferCampaignSeed.js => HelpAndOfferSeed.js} (78%) diff --git a/src/config/database.js b/src/config/database.js index c7626547..cdaccde1 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -1,7 +1,7 @@ const mongoose = require('mongoose'); const CategorySeed = require('../utils/seed/CategorySeed'); const UserSeed = require('../utils/seed/UserSeed'); -const HelpSeed = require('../utils/seed/HelpOfferCampaignSeed'); +const HelpSeed = require('../utils/seed/HelpAndOfferSeed'); const NotificationSeed = require('../utils/seed/NotificationSeed'); const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaDB'; diff --git a/src/utils/seed/HelpOfferCampaignSeed.js b/src/utils/seed/HelpAndOfferSeed.js similarity index 78% rename from src/utils/seed/HelpOfferCampaignSeed.js rename to src/utils/seed/HelpAndOfferSeed.js index 0b5ac88d..f175d730 100644 --- a/src/utils/seed/HelpOfferCampaignSeed.js +++ b/src/utils/seed/HelpAndOfferSeed.js @@ -3,8 +3,6 @@ const faker = require('faker/locale/pt_BR'); const Category = require('../../models/Category'); const Help = require('../../models/Help'); const User = require('../../models/User'); -const Entity = require('../../models/Entity'); -const Campaign = require('../../models/Campaign'); const HelpOffer = require('../../models/HelpOffer'); const status = [ @@ -19,24 +17,21 @@ const seedHelp = async () => { try { const categoryCollection = await Category.find(); const userCollection = await User.find(); - const entityCollection = await Entity.find(); const helpCollection = await Help.find(); const helpOfferCollection = await HelpOffer.find(); // this condition avoid populate duplicate users - if (helpCollection.length > 0 || helpOfferCollection.length > 0) { + if (helpCollection.length > 0 || helpOfferCollection.length >0) { return; } const quantity = 100; const requests = []; const offers = []; - const campaigns = []; for (let i = 0; i < quantity; i += 1) { const sampleStatus = lodash.sample(status); const sampleCategory = lodash.sample(categoryCollection); const sampleUsers = lodash.sampleSize(userCollection, 2); - const sampleEntities = lodash.sampleSize(entityCollection, 2); const samplePossibleHelpers = lodash.sampleSize( userCollection, faker.random.number(5), @@ -53,27 +48,19 @@ const seedHelp = async () => { ownerId: sampleUsers[0]._id, finishedDate: faker.date.future(), }; - requests.push( new Help({ ...sharedInfo, possibleHelpers: samplePossibleHelpsID, }), ); - + offers.push( new HelpOffer({ ...sharedInfo, possibleHelpedUsers: samplePossibleHelpsID, - }), - ); - - campaigns.push( - new Campaign({ - ...sharedInfo, - ownerId: sampleEntities[0]._id, - }), - ); + }) + ) } await Help.deleteMany({}); @@ -87,9 +74,9 @@ const seedHelp = async () => { HelpOffer.create(offer); }); - console.log('Pedidos, ofertas e campanhas populados com sucesso!'); + console.log('Pedidos e ofertas populados com sucesso!'); } catch (error) { - console.log('Não foi possível criar pedidos, ofertas e campanhas na base de dados!'); + console.log('Não foi possível pedidos e ofertas na base de dados!'); console.log(error); } }; diff --git a/src/utils/seed/UserSeed.js b/src/utils/seed/UserSeed.js index 45d996a3..a8ce6ed1 100644 --- a/src/utils/seed/UserSeed.js +++ b/src/utils/seed/UserSeed.js @@ -44,7 +44,7 @@ const seedUser = async () => { }, phone: faker.phone.phoneNumber('+55######-####'), active: true, - }; + } users.push( new User({ From 16bbd961821254bb5ad1ed12f4402fa4f746738d Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 20:56:02 -0300 Subject: [PATCH 012/107] Revert "feat: create entity seed" This reverts commit 63df9cce1a7401f2b96da1985495863ee0dc4007. --- src/utils/seed/UserSeed.js | 63 +++++++++++++------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/src/utils/seed/UserSeed.js b/src/utils/seed/UserSeed.js index a8ce6ed1..be045b3c 100644 --- a/src/utils/seed/UserSeed.js +++ b/src/utils/seed/UserSeed.js @@ -1,8 +1,7 @@ const faker = require('faker/locale/pt_BR'); const lodash = require('lodash'); -const { cpf, cnpj } = require('cpf-cnpj-validator'); +const { cpf } = require('cpf-cnpj-validator'); const User = require('../../models/User'); -const Entity = require('../../models/Entity'); const diseases = ['dc', 'hiv', 'diab', 'hiperT', 'doenCardio']; let latitude = process.env.LATITUDE_ENV || -15.824544; @@ -10,70 +9,52 @@ let longitude = process.env.LONGITUDE_ENV || -48.060878; const seedUser = async () => { try { const userCollection = await User.find(); - const entityCollection = await Entity.find(); // this condition avoid populate duplicate users - if (userCollection.length > 0 || entityCollection > 0) { + if (userCollection.length > 0) { return; } const users = []; - const entities = []; const quantity = 100; for (let i = 0; i < quantity; i += 1) { const sampleRiskGroup = lodash.sampleSize(diseases, faker.random.number(5)); longitude = Number(longitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); latitude = Number(latitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); - const sharedInfo = { - name: faker.name.findName(), - email: faker.internet.email(), - photo: faker.image.avatar(), - address: { - cep: faker.address.zipCode(), - number: faker.random.number(), - city: faker.address.city(), - state: faker.address.state(), - complement: faker.lorem.lines(1), - }, - location: { - type: 'Point', - coordinates: [ - longitude, - latitude, - ], - }, - phone: faker.phone.phoneNumber('+55######-####'), - active: true, - } - users.push( new User({ - ...sharedInfo, + name: faker.name.findName(), birthday: Date.parse(faker.date.between('1940-01-01', '2020-01-01')), cpf: cpf.generate(), + email: faker.internet.email(), + photo: faker.image.avatar(), + address: { + cep: faker.address.zipCode(), + number: faker.random.number(), + city: faker.address.city(), + state: faker.address.state(), + complement: faker.lorem.lines(1), + }, + location: { + type: 'Point', + coordinates: [ + longitude, + latitude, + ], + }, riskGroup: sampleRiskGroup, ismentalHealthProfessional: faker.random.boolean(), - }), - ); - - entities.push( - new Entity({ - ...sharedInfo, - cnpj: cnpj.generate(), + phone: faker.phone.phoneNumber('+55######-####'), + active: true, }), ); } await User.deleteMany({}); - await Entity.deleteMany({}); users.forEach((user) => { User.create(user); }); - - entities.forEach((entity) => { - Entity.create(entity); - }); - console.log('Usuários e entidades populados com sucesso!'); + console.log('Usuários populados com sucesso!'); } catch (error) { console.log('Não foi possível popular os usuáriios na base de dados!'); console.log(error); From 7ab0883a0c1cbbe1814b763b353292789993e2aa Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 20:56:14 -0300 Subject: [PATCH 013/107] Revert "feat: create offers seed" This reverts commit 145870ef84006f6fc3b7ce4e3ca82e1c460b2c7a. --- src/config/database.js | 2 +- .../seed/{HelpAndOfferSeed.js => HelpSeed.js} | 45 ++++++------------- 2 files changed, 15 insertions(+), 32 deletions(-) rename src/utils/seed/{HelpAndOfferSeed.js => HelpSeed.js} (57%) diff --git a/src/config/database.js b/src/config/database.js index cdaccde1..04f9fc63 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -1,7 +1,7 @@ const mongoose = require('mongoose'); const CategorySeed = require('../utils/seed/CategorySeed'); const UserSeed = require('../utils/seed/UserSeed'); -const HelpSeed = require('../utils/seed/HelpAndOfferSeed'); +const HelpSeed = require('../utils/seed/HelpSeed'); const NotificationSeed = require('../utils/seed/NotificationSeed'); const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaDB'; diff --git a/src/utils/seed/HelpAndOfferSeed.js b/src/utils/seed/HelpSeed.js similarity index 57% rename from src/utils/seed/HelpAndOfferSeed.js rename to src/utils/seed/HelpSeed.js index f175d730..ca00d91f 100644 --- a/src/utils/seed/HelpAndOfferSeed.js +++ b/src/utils/seed/HelpSeed.js @@ -3,7 +3,6 @@ const faker = require('faker/locale/pt_BR'); const Category = require('../../models/Category'); const Help = require('../../models/Help'); const User = require('../../models/User'); -const HelpOffer = require('../../models/HelpOffer'); const status = [ 'waiting', @@ -18,16 +17,14 @@ const seedHelp = async () => { const categoryCollection = await Category.find(); const userCollection = await User.find(); const helpCollection = await Help.find(); - const helpOfferCollection = await HelpOffer.find(); // this condition avoid populate duplicate users - if (helpCollection.length > 0 || helpOfferCollection.length >0) { + if (helpCollection.length > 0) { return; } const quantity = 100; - const requests = []; - const offers = []; + const helps = []; for (let i = 0; i < quantity; i += 1) { const sampleStatus = lodash.sample(status); const sampleCategory = lodash.sample(categoryCollection); @@ -40,43 +37,29 @@ const seedHelp = async () => { samplePossibleHelpers.forEach((item) => { samplePossibleHelpsID.push(item._id); }); - const sharedInfo = { - title: faker.lorem.lines(1), - description: faker.lorem.lines(1), - status: sampleStatus, - categoryId: [sampleCategory._id], - ownerId: sampleUsers[0]._id, - finishedDate: faker.date.future(), - }; - requests.push( + + helps.push( new Help({ - ...sharedInfo, + title: faker.lorem.lines(1), + description: faker.lorem.lines(1), + status: sampleStatus, possibleHelpers: samplePossibleHelpsID, + categoryId: [sampleCategory._id], + ownerId: sampleUsers[0]._id, + finishedDate: faker.date.future(), }), ); - - offers.push( - new HelpOffer({ - ...sharedInfo, - possibleHelpedUsers: samplePossibleHelpsID, - }) - ) } await Help.deleteMany({}); - await HelpOffer.deleteMany({}); - - requests.forEach((request) => { - Help.create(request); - }); - offers.forEach((offer) => { - HelpOffer.create(offer); + helps.forEach((help) => { + Help.create(help); }); - console.log('Pedidos e ofertas populados com sucesso!'); + console.log('Ajudas populadas com sucesso!'); } catch (error) { - console.log('Não foi possível pedidos e ofertas na base de dados!'); + console.log('Não foi possível popular as ajudas na base de dados!'); console.log(error); } }; From a4b388861ea286e98d10a174b3ae55420d7170f6 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 20:58:12 -0300 Subject: [PATCH 014/107] feat: create offers seed --- src/config/database.js | 2 +- .../seed/{HelpSeed.js => HelpAndOfferSeed.js} | 45 +++++++++++++------ 2 files changed, 32 insertions(+), 15 deletions(-) rename src/utils/seed/{HelpSeed.js => HelpAndOfferSeed.js} (57%) diff --git a/src/config/database.js b/src/config/database.js index 04f9fc63..cdaccde1 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -1,7 +1,7 @@ const mongoose = require('mongoose'); const CategorySeed = require('../utils/seed/CategorySeed'); const UserSeed = require('../utils/seed/UserSeed'); -const HelpSeed = require('../utils/seed/HelpSeed'); +const HelpSeed = require('../utils/seed/HelpAndOfferSeed'); const NotificationSeed = require('../utils/seed/NotificationSeed'); const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaDB'; diff --git a/src/utils/seed/HelpSeed.js b/src/utils/seed/HelpAndOfferSeed.js similarity index 57% rename from src/utils/seed/HelpSeed.js rename to src/utils/seed/HelpAndOfferSeed.js index ca00d91f..f175d730 100644 --- a/src/utils/seed/HelpSeed.js +++ b/src/utils/seed/HelpAndOfferSeed.js @@ -3,6 +3,7 @@ const faker = require('faker/locale/pt_BR'); const Category = require('../../models/Category'); const Help = require('../../models/Help'); const User = require('../../models/User'); +const HelpOffer = require('../../models/HelpOffer'); const status = [ 'waiting', @@ -17,14 +18,16 @@ const seedHelp = async () => { const categoryCollection = await Category.find(); const userCollection = await User.find(); const helpCollection = await Help.find(); + const helpOfferCollection = await HelpOffer.find(); // this condition avoid populate duplicate users - if (helpCollection.length > 0) { + if (helpCollection.length > 0 || helpOfferCollection.length >0) { return; } const quantity = 100; - const helps = []; + const requests = []; + const offers = []; for (let i = 0; i < quantity; i += 1) { const sampleStatus = lodash.sample(status); const sampleCategory = lodash.sample(categoryCollection); @@ -37,29 +40,43 @@ const seedHelp = async () => { samplePossibleHelpers.forEach((item) => { samplePossibleHelpsID.push(item._id); }); - - helps.push( + const sharedInfo = { + title: faker.lorem.lines(1), + description: faker.lorem.lines(1), + status: sampleStatus, + categoryId: [sampleCategory._id], + ownerId: sampleUsers[0]._id, + finishedDate: faker.date.future(), + }; + requests.push( new Help({ - title: faker.lorem.lines(1), - description: faker.lorem.lines(1), - status: sampleStatus, + ...sharedInfo, possibleHelpers: samplePossibleHelpsID, - categoryId: [sampleCategory._id], - ownerId: sampleUsers[0]._id, - finishedDate: faker.date.future(), }), ); + + offers.push( + new HelpOffer({ + ...sharedInfo, + possibleHelpedUsers: samplePossibleHelpsID, + }) + ) } await Help.deleteMany({}); + await HelpOffer.deleteMany({}); + + requests.forEach((request) => { + Help.create(request); + }); - helps.forEach((help) => { - Help.create(help); + offers.forEach((offer) => { + HelpOffer.create(offer); }); - console.log('Ajudas populadas com sucesso!'); + console.log('Pedidos e ofertas populados com sucesso!'); } catch (error) { - console.log('Não foi possível popular as ajudas na base de dados!'); + console.log('Não foi possível pedidos e ofertas na base de dados!'); console.log(error); } }; From ae3612795c4f1247b548727615d2a8007a1c9fef Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 20:58:23 -0300 Subject: [PATCH 015/107] feat: create entity seed --- src/utils/seed/UserSeed.js | 63 +++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/utils/seed/UserSeed.js b/src/utils/seed/UserSeed.js index be045b3c..a8ce6ed1 100644 --- a/src/utils/seed/UserSeed.js +++ b/src/utils/seed/UserSeed.js @@ -1,7 +1,8 @@ const faker = require('faker/locale/pt_BR'); const lodash = require('lodash'); -const { cpf } = require('cpf-cnpj-validator'); +const { cpf, cnpj } = require('cpf-cnpj-validator'); const User = require('../../models/User'); +const Entity = require('../../models/Entity'); const diseases = ['dc', 'hiv', 'diab', 'hiperT', 'doenCardio']; let latitude = process.env.LATITUDE_ENV || -15.824544; @@ -9,52 +10,70 @@ let longitude = process.env.LONGITUDE_ENV || -48.060878; const seedUser = async () => { try { const userCollection = await User.find(); + const entityCollection = await Entity.find(); // this condition avoid populate duplicate users - if (userCollection.length > 0) { + if (userCollection.length > 0 || entityCollection > 0) { return; } const users = []; + const entities = []; const quantity = 100; for (let i = 0; i < quantity; i += 1) { const sampleRiskGroup = lodash.sampleSize(diseases, faker.random.number(5)); longitude = Number(longitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); latitude = Number(latitude) + (faker.random.number({ min: -999, max: 999 }) / 100000); + const sharedInfo = { + name: faker.name.findName(), + email: faker.internet.email(), + photo: faker.image.avatar(), + address: { + cep: faker.address.zipCode(), + number: faker.random.number(), + city: faker.address.city(), + state: faker.address.state(), + complement: faker.lorem.lines(1), + }, + location: { + type: 'Point', + coordinates: [ + longitude, + latitude, + ], + }, + phone: faker.phone.phoneNumber('+55######-####'), + active: true, + } + users.push( new User({ - name: faker.name.findName(), + ...sharedInfo, birthday: Date.parse(faker.date.between('1940-01-01', '2020-01-01')), cpf: cpf.generate(), - email: faker.internet.email(), - photo: faker.image.avatar(), - address: { - cep: faker.address.zipCode(), - number: faker.random.number(), - city: faker.address.city(), - state: faker.address.state(), - complement: faker.lorem.lines(1), - }, - location: { - type: 'Point', - coordinates: [ - longitude, - latitude, - ], - }, riskGroup: sampleRiskGroup, ismentalHealthProfessional: faker.random.boolean(), - phone: faker.phone.phoneNumber('+55######-####'), - active: true, + }), + ); + + entities.push( + new Entity({ + ...sharedInfo, + cnpj: cnpj.generate(), }), ); } await User.deleteMany({}); + await Entity.deleteMany({}); users.forEach((user) => { User.create(user); }); - console.log('Usuários populados com sucesso!'); + + entities.forEach((entity) => { + Entity.create(entity); + }); + console.log('Usuários e entidades populados com sucesso!'); } catch (error) { console.log('Não foi possível popular os usuáriios na base de dados!'); console.log(error); From e93008fe9f55fcf8c1d1c5ac87752efd46dfe759 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 20:58:33 -0300 Subject: [PATCH 016/107] feat: create campaign seed --- src/config/database.js | 2 +- ...dOfferSeed.js => HelpOfferCampaignSeed.js} | 25 ++++++++++++++----- src/utils/seed/UserSeed.js | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) rename src/utils/seed/{HelpAndOfferSeed.js => HelpOfferCampaignSeed.js} (78%) diff --git a/src/config/database.js b/src/config/database.js index cdaccde1..c7626547 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -1,7 +1,7 @@ const mongoose = require('mongoose'); const CategorySeed = require('../utils/seed/CategorySeed'); const UserSeed = require('../utils/seed/UserSeed'); -const HelpSeed = require('../utils/seed/HelpAndOfferSeed'); +const HelpSeed = require('../utils/seed/HelpOfferCampaignSeed'); const NotificationSeed = require('../utils/seed/NotificationSeed'); const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaDB'; diff --git a/src/utils/seed/HelpAndOfferSeed.js b/src/utils/seed/HelpOfferCampaignSeed.js similarity index 78% rename from src/utils/seed/HelpAndOfferSeed.js rename to src/utils/seed/HelpOfferCampaignSeed.js index f175d730..0b5ac88d 100644 --- a/src/utils/seed/HelpAndOfferSeed.js +++ b/src/utils/seed/HelpOfferCampaignSeed.js @@ -3,6 +3,8 @@ const faker = require('faker/locale/pt_BR'); const Category = require('../../models/Category'); const Help = require('../../models/Help'); const User = require('../../models/User'); +const Entity = require('../../models/Entity'); +const Campaign = require('../../models/Campaign'); const HelpOffer = require('../../models/HelpOffer'); const status = [ @@ -17,21 +19,24 @@ const seedHelp = async () => { try { const categoryCollection = await Category.find(); const userCollection = await User.find(); + const entityCollection = await Entity.find(); const helpCollection = await Help.find(); const helpOfferCollection = await HelpOffer.find(); // this condition avoid populate duplicate users - if (helpCollection.length > 0 || helpOfferCollection.length >0) { + if (helpCollection.length > 0 || helpOfferCollection.length > 0) { return; } const quantity = 100; const requests = []; const offers = []; + const campaigns = []; for (let i = 0; i < quantity; i += 1) { const sampleStatus = lodash.sample(status); const sampleCategory = lodash.sample(categoryCollection); const sampleUsers = lodash.sampleSize(userCollection, 2); + const sampleEntities = lodash.sampleSize(entityCollection, 2); const samplePossibleHelpers = lodash.sampleSize( userCollection, faker.random.number(5), @@ -48,19 +53,27 @@ const seedHelp = async () => { ownerId: sampleUsers[0]._id, finishedDate: faker.date.future(), }; + requests.push( new Help({ ...sharedInfo, possibleHelpers: samplePossibleHelpsID, }), ); - + offers.push( new HelpOffer({ ...sharedInfo, possibleHelpedUsers: samplePossibleHelpsID, - }) - ) + }), + ); + + campaigns.push( + new Campaign({ + ...sharedInfo, + ownerId: sampleEntities[0]._id, + }), + ); } await Help.deleteMany({}); @@ -74,9 +87,9 @@ const seedHelp = async () => { HelpOffer.create(offer); }); - console.log('Pedidos e ofertas populados com sucesso!'); + console.log('Pedidos, ofertas e campanhas populados com sucesso!'); } catch (error) { - console.log('Não foi possível pedidos e ofertas na base de dados!'); + console.log('Não foi possível criar pedidos, ofertas e campanhas na base de dados!'); console.log(error); } }; diff --git a/src/utils/seed/UserSeed.js b/src/utils/seed/UserSeed.js index a8ce6ed1..45d996a3 100644 --- a/src/utils/seed/UserSeed.js +++ b/src/utils/seed/UserSeed.js @@ -44,7 +44,7 @@ const seedUser = async () => { }, phone: faker.phone.phoneNumber('+55######-####'), active: true, - } + }; users.push( new User({ From f60f6d944cd80561df059df6f3bfdcd66e90c2a6 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 8 Sep 2022 21:05:23 -0300 Subject: [PATCH 017/107] feat: add campaign create code --- src/utils/seed/HelpOfferCampaignSeed.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/seed/HelpOfferCampaignSeed.js b/src/utils/seed/HelpOfferCampaignSeed.js index 0b5ac88d..7e34d1ed 100644 --- a/src/utils/seed/HelpOfferCampaignSeed.js +++ b/src/utils/seed/HelpOfferCampaignSeed.js @@ -22,9 +22,10 @@ const seedHelp = async () => { const entityCollection = await Entity.find(); const helpCollection = await Help.find(); const helpOfferCollection = await HelpOffer.find(); + const campaignCollection = await Campaign.find(); // this condition avoid populate duplicate users - if (helpCollection.length > 0 || helpOfferCollection.length > 0) { + if (helpCollection.length > 0 || helpOfferCollection.length > 0 || campaignCollection.length > 0) { return; } @@ -78,6 +79,7 @@ const seedHelp = async () => { await Help.deleteMany({}); await HelpOffer.deleteMany({}); + await Campaign.deleteMany({}); requests.forEach((request) => { Help.create(request); @@ -87,6 +89,10 @@ const seedHelp = async () => { HelpOffer.create(offer); }); + campaigns.forEach((campaign) => { + Campaign.create(campaign); + }); + console.log('Pedidos, ofertas e campanhas populados com sucesso!'); } catch (error) { console.log('Não foi possível criar pedidos, ofertas e campanhas na base de dados!'); From f4145cf54db9a3d32e07d3ba832957dc314c4bd8 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 10 Sep 2022 06:59:01 -0300 Subject: [PATCH 018/107] fix: :broom: lint --- src/utils/seed/HelpOfferCampaignSeed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/seed/HelpOfferCampaignSeed.js b/src/utils/seed/HelpOfferCampaignSeed.js index 7e34d1ed..d3e94080 100644 --- a/src/utils/seed/HelpOfferCampaignSeed.js +++ b/src/utils/seed/HelpOfferCampaignSeed.js @@ -25,7 +25,7 @@ const seedHelp = async () => { const campaignCollection = await Campaign.find(); // this condition avoid populate duplicate users - if (helpCollection.length > 0 || helpOfferCollection.length > 0 || campaignCollection.length > 0) { + if (helpCollection.length > 0 || helpOfferCollection.length > 0 || campaignCollection.length > 0) { return; } From 7fd5a3490f784e21f749ebe27fc73f25c1c82cea Mon Sep 17 00:00:00 2001 From: ivandobbin Date: Wed, 2 Nov 2022 16:45:14 -0300 Subject: [PATCH 019/107] =?UTF-8?q?Adiciona=20notifica=C3=A7=C3=A3o=20para?= =?UTF-8?q?=20os=20seguidores(n=C3=A3o=20testado)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/repository/SocialNetworkRepository.js | 2 +- src/services/HelpService.js | 39 +++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 0c524900..d9b1dcd8 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -169,7 +169,7 @@ class SocialNetworkRepository extends BaseRepository { path: 'Followers', populate: { path: 'user', - select: ['photo'] + select: ['photo','deviceId'] } , select: ['userId','username','followers','following'] }; diff --git a/src/services/HelpService.js b/src/services/HelpService.js index cb9cd153..d817874a 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -8,6 +8,7 @@ const { findConnections, sendMessage } = require("../../websocket"); const NotificationMixin = require("../utils/NotificationMixin"); const helpStatusEnum = require("../utils/enums/helpStatusEnum"); const saveError = require("../utils/ErrorHistory"); +const SocialNetworkService = require("../services/SocialNetworkService"); class HelpService { constructor() { @@ -17,6 +18,7 @@ class HelpService { this.CategoryService = new CategoryService(); this.NotificationService = new NotificationService(); this.NotificationMixin = new NotificationMixin(); + this.socialNetworkService = new SocialNetworkService(); } async createHelp(data) { @@ -34,6 +36,43 @@ class HelpService { JSON.parse(JSON.stringify(createdHelp.ownerId)) ); sendMessage(sendSocketMessageTo, 'new-help', createdHelp); + + notificationToFollowers(createdHelp.ownerId, createdHelp.id) + } + + async notificationToFollowers(profileId,help_id){ + + + + followers = await this.socialNetworkService.getFollowers(profileId,profileId); + + if (followers) { + const ownerTitle = "Pedido de ajuda criado por uma pessoa que você segue."; + const ownerBody = `Uma das pessoas que você está seguindo, criou uma ajuda.`; + + for(let i=0;i Date: Mon, 23 Jan 2023 12:40:09 -0300 Subject: [PATCH 020/107] chore: change title and description in seeds to pt-br --- src/utils/seed/HelpOfferCampaignSeed.js | 13 +- src/utils/seed/mockedInfos/mockedHelpInfo.js | 20 + src/utils/seed/mockedInfos/mockedOfferInfo.js | 20 + yarn.lock | 1699 +++++++---------- 4 files changed, 791 insertions(+), 961 deletions(-) create mode 100644 src/utils/seed/mockedInfos/mockedHelpInfo.js create mode 100644 src/utils/seed/mockedInfos/mockedOfferInfo.js diff --git a/src/utils/seed/HelpOfferCampaignSeed.js b/src/utils/seed/HelpOfferCampaignSeed.js index d3e94080..1401c68a 100644 --- a/src/utils/seed/HelpOfferCampaignSeed.js +++ b/src/utils/seed/HelpOfferCampaignSeed.js @@ -6,6 +6,8 @@ const User = require('../../models/User'); const Entity = require('../../models/Entity'); const Campaign = require('../../models/Campaign'); const HelpOffer = require('../../models/HelpOffer'); +const mockedOfferInfo = require('./mockedInfos/mockedOfferInfo'); +const mockedHelpInfo = require('./mockedInfos/mockedHelpInfo'); const status = [ 'waiting', @@ -29,7 +31,7 @@ const seedHelp = async () => { return; } - const quantity = 100; + const quantity = 10; const requests = []; const offers = []; const campaigns = []; @@ -38,17 +40,18 @@ const seedHelp = async () => { const sampleCategory = lodash.sample(categoryCollection); const sampleUsers = lodash.sampleSize(userCollection, 2); const sampleEntities = lodash.sampleSize(entityCollection, 2); + const randomNum = faker.random.number(5); const samplePossibleHelpers = lodash.sampleSize( userCollection, - faker.random.number(5), + randomNum, ); const samplePossibleHelpsID = []; samplePossibleHelpers.forEach((item) => { samplePossibleHelpsID.push(item._id); }); const sharedInfo = { - title: faker.lorem.lines(1), - description: faker.lorem.lines(1), + title: mockedOfferInfo.titles[randomNum], + description: mockedOfferInfo.descriptions[randomNum], status: sampleStatus, categoryId: [sampleCategory._id], ownerId: sampleUsers[0]._id, @@ -59,6 +62,8 @@ const seedHelp = async () => { new Help({ ...sharedInfo, possibleHelpers: samplePossibleHelpsID, + title: mockedHelpInfo.titles[randomNum], + description: mockedHelpInfo.descriptions[randomNum], }), ); diff --git a/src/utils/seed/mockedInfos/mockedHelpInfo.js b/src/utils/seed/mockedInfos/mockedHelpInfo.js new file mode 100644 index 00000000..952cc949 --- /dev/null +++ b/src/utils/seed/mockedInfos/mockedHelpInfo.js @@ -0,0 +1,20 @@ +const mockedHelpInfo = { + "titles": [ + "Preciso de Ajuda", + "Alguém pode me Ajudar?", + "Baile Beneficente", + "Preciso de comida", + "Apoio Social", + "Preciso de Agasalhos", + ], + "descriptions":[ + "Preciso de novas mascáras", + "A água aqui de casa acabou", + "Precisando de voluntário para organizar baile beneficente", + "Alguém pode me ajudar dando arroz?", + "Estou me sentido sozinho durante esse isolamento.", + "Estou passando muito frio.", + ], +} + +module.exports = mockedHelpInfo; \ No newline at end of file diff --git a/src/utils/seed/mockedInfos/mockedOfferInfo.js b/src/utils/seed/mockedInfos/mockedOfferInfo.js new file mode 100644 index 00000000..cc149665 --- /dev/null +++ b/src/utils/seed/mockedInfos/mockedOfferInfo.js @@ -0,0 +1,20 @@ +const mockedOfferInfo = { + "titles": [ + "Doando comida", + "Cestas básicas", + "Cuidador de idosos", + "Consultas grátis", + "Agasalhos sobrando", + "Carona", + ], + "descriptions":[ + "Tenho arroz e feijão para doar", + "Tenho 7 cestas básicas sobrando aqui", + "Estou ofertando meu serviço de cuidador de idosos gratuitamente", + "Precisando de ajuda psicológica? Posso te ajudar.", + "Estou com alguns agasalhos prontos para doação.", + "Posso ajudar na locomoção de idosos", + ], +} + +module.exports = mockedOfferInfo; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 29151eb5..d2bd9f4e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17,49 +17,50 @@ dependencies: "@babel/highlight" "^7.18.6" -"@babel/compat-data@^7.18.8": - version "7.18.8" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.18.8.tgz#2483f565faca607b8535590e84e7de323f27764d" - integrity sha512-HSmX4WZPPK3FUxYp7g2T6EyO8j96HlZJlxmKPSh6KAcqwyDrfx7hKjXpAW/0FhFfTJsR0Yt4lAjLI2coMptIHQ== +"@babel/compat-data@^7.20.5": + version "7.20.10" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.10.tgz#9d92fa81b87542fff50e848ed585b4212c1d34ec" + integrity sha512-sEnuDPpOJR/fcafHMjpcpGN5M2jbUGUHwmuWKM/YdPzeEDJg8bgmbcWQFUfE32MQjti1koACvoPVsDe8Uq+idg== "@babel/core@^7.11.6", "@babel/core@^7.12.3": - version "7.18.10" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.18.10.tgz#39ad504991d77f1f3da91be0b8b949a5bc466fb8" - integrity sha512-JQM6k6ENcBFKVtWvLavlvi/mPcpYZ3+R+2EySDEMSMbp7Mn4FexlbbJVrx2R7Ijhr01T8gyqrOaABWIOgxeUyw== + version "7.20.12" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.12.tgz#7930db57443c6714ad216953d1356dac0eb8496d" + integrity sha512-XsMfHovsUYHFMdrIHkZphTN/2Hzzi78R08NuHfDBehym2VsPDL6Zn/JAD/JQdnRvbSsbQc4mVaU1m6JgtTEElg== dependencies: "@ampproject/remapping" "^2.1.0" "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.18.10" - "@babel/helper-compilation-targets" "^7.18.9" - "@babel/helper-module-transforms" "^7.18.9" - "@babel/helpers" "^7.18.9" - "@babel/parser" "^7.18.10" - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.18.10" - "@babel/types" "^7.18.10" + "@babel/generator" "^7.20.7" + "@babel/helper-compilation-targets" "^7.20.7" + "@babel/helper-module-transforms" "^7.20.11" + "@babel/helpers" "^7.20.7" + "@babel/parser" "^7.20.7" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.12" + "@babel/types" "^7.20.7" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" - json5 "^2.2.1" + json5 "^2.2.2" semver "^6.3.0" -"@babel/generator@^7.18.10", "@babel/generator@^7.7.2": - version "7.18.12" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.18.12.tgz#fa58daa303757bd6f5e4bbca91b342040463d9f4" - integrity sha512-dfQ8ebCN98SvyL7IxNMCUtZQSq5R7kxgN+r8qYTGDmmSion1hX2C0zq2yo1bsCDhXixokv1SAWTZUMYbO/V5zg== +"@babel/generator@^7.20.7", "@babel/generator@^7.7.2": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.7.tgz#f8ef57c8242665c5929fe2e8d82ba75460187b4a" + integrity sha512-7wqMOJq8doJMZmP4ApXTzLxSr7+oO2jroJURrVEp6XShrQUObV8Tq/D0NCcoYg2uHqUrjzO0zwBjoYzelxK+sw== dependencies: - "@babel/types" "^7.18.10" + "@babel/types" "^7.20.7" "@jridgewell/gen-mapping" "^0.3.2" jsesc "^2.5.1" -"@babel/helper-compilation-targets@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz#69e64f57b524cde3e5ff6cc5a9f4a387ee5563bf" - integrity sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg== +"@babel/helper-compilation-targets@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz#a6cd33e93629f5eb473b021aac05df62c4cd09bb" + integrity sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ== dependencies: - "@babel/compat-data" "^7.18.8" + "@babel/compat-data" "^7.20.5" "@babel/helper-validator-option" "^7.18.6" - browserslist "^4.20.2" + browserslist "^4.21.3" + lru-cache "^5.1.1" semver "^6.3.0" "@babel/helper-environment-visitor@^7.18.9": @@ -67,13 +68,13 @@ resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz#0c0cee9b35d2ca190478756865bb3528422f51be" integrity sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg== -"@babel/helper-function-name@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz#940e6084a55dee867d33b4e487da2676365e86b0" - integrity sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A== +"@babel/helper-function-name@^7.19.0": + version "7.19.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz#941574ed5390682e872e52d3f38ce9d1bef4648c" + integrity sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w== dependencies: - "@babel/template" "^7.18.6" - "@babel/types" "^7.18.9" + "@babel/template" "^7.18.10" + "@babel/types" "^7.19.0" "@babel/helper-hoist-variables@^7.18.6": version "7.18.6" @@ -89,31 +90,31 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-module-transforms@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz#5a1079c005135ed627442df31a42887e80fcb712" - integrity sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g== +"@babel/helper-module-transforms@^7.20.11": + version "7.20.11" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.11.tgz#df4c7af713c557938c50ea3ad0117a7944b2f1b0" + integrity sha512-uRy78kN4psmji1s2QtbtcCSaj/LILFDp0f/ymhpQH5QY3nljUZCaNWz9X1dEj/8MBdBEFECs7yRhKn8i7NjZgg== dependencies: "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-module-imports" "^7.18.6" - "@babel/helper-simple-access" "^7.18.6" + "@babel/helper-simple-access" "^7.20.2" "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/helper-validator-identifier" "^7.18.6" - "@babel/template" "^7.18.6" - "@babel/traverse" "^7.18.9" - "@babel/types" "^7.18.9" + "@babel/helper-validator-identifier" "^7.19.1" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.10" + "@babel/types" "^7.20.7" -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.8.0": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.18.9.tgz#4b8aea3b069d8cb8a72cdfe28ddf5ceca695ef2f" - integrity sha512-aBXPT3bmtLryXaoJLyYPXPlSD4p1ld9aYeR+sJNOZjJJGiOpb+fKfh3NkcCu7J54nUJwCERPBExCCpyCOHnu/w== +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.19.0", "@babel/helper-plugin-utils@^7.8.0": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz#d1b9000752b18d0877cff85a5c376ce5c3121629" + integrity sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ== -"@babel/helper-simple-access@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz#d6d8f51f4ac2978068df934b569f08f29788c7ea" - integrity sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g== +"@babel/helper-simple-access@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9" + integrity sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA== dependencies: - "@babel/types" "^7.18.6" + "@babel/types" "^7.20.2" "@babel/helper-split-export-declaration@^7.18.6": version "7.18.6" @@ -122,29 +123,29 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-string-parser@^7.18.10": - version "7.18.10" - resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz#181f22d28ebe1b3857fa575f5c290b1aaf659b56" - integrity sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw== +"@babel/helper-string-parser@^7.19.4": + version "7.19.4" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63" + integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw== -"@babel/helper-validator-identifier@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz#9c97e30d31b2b8c72a1d08984f2ca9b574d7a076" - integrity sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g== +"@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1": + version "7.19.1" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" + integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== "@babel/helper-validator-option@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz#bf0d2b5a509b1f336099e4ff36e1a63aa5db4db8" integrity sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw== -"@babel/helpers@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.18.9.tgz#4bef3b893f253a1eced04516824ede94dcfe7ff9" - integrity sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ== +"@babel/helpers@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.7.tgz#04502ff0feecc9f20ecfaad120a18f011a8e6dce" + integrity sha512-PBPjs5BppzsGaxHQCDKnZ6Gd9s6xl8bBCluz3vEInLGRJmnZan4F6BYCeqtyXqkk4W5IlPmjK4JlOuZkpJ3xZA== dependencies: - "@babel/template" "^7.18.6" - "@babel/traverse" "^7.18.9" - "@babel/types" "^7.18.9" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.7" + "@babel/types" "^7.20.7" "@babel/highlight@^7.18.6": version "7.18.6" @@ -155,10 +156,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.18.10", "@babel/parser@^7.18.11": - version "7.18.11" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.18.11.tgz#68bb07ab3d380affa9a3f96728df07969645d2d9" - integrity sha512-9JKn5vN+hDt0Hdqn1PiJ2guflwP+B6Ga8qbDuoF0PzzVhrzsKIJo8yGqVk6CmMHiMei9w1C1Bp9IMJSIK+HPIQ== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.7.tgz#66fe23b3c8569220817d5feb8b9dcdc95bb4f71b" + integrity sha512-T3Z9oHybU+0vZlY9CiDSJQTD5ZapcW18ZctFMi0MOAl/4BjFF4ul7NVSARLdbGO5vDqy9eQiGTV0LtKfvCYvcg== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -245,44 +246,44 @@ "@babel/helper-plugin-utils" "^7.14.5" "@babel/plugin-syntax-typescript@^7.7.2": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.18.6.tgz#1c09cd25795c7c2b8a4ba9ae49394576d4133285" - integrity sha512-mAWAuq4rvOepWCBid55JuRNvpTNf2UGVgoz4JV0fXEKolsVZDzsa4NqCef758WZJj/GDu0gVGItjKFiClTAmZA== + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz#4e9a0cfc769c85689b77a2e642d24e9f697fc8c7" + integrity sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.19.0" -"@babel/template@^7.18.10", "@babel/template@^7.18.6", "@babel/template@^7.3.3": - version "7.18.10" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.18.10.tgz#6f9134835970d1dbf0835c0d100c9f38de0c5e71" - integrity sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA== +"@babel/template@^7.18.10", "@babel/template@^7.20.7", "@babel/template@^7.3.3": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.20.7.tgz#a15090c2839a83b02aa996c0b4994005841fd5a8" + integrity sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw== dependencies: "@babel/code-frame" "^7.18.6" - "@babel/parser" "^7.18.10" - "@babel/types" "^7.18.10" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" -"@babel/traverse@^7.18.10", "@babel/traverse@^7.18.9", "@babel/traverse@^7.7.2": - version "7.18.11" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.18.11.tgz#3d51f2afbd83ecf9912bcbb5c4d94e3d2ddaa16f" - integrity sha512-TG9PiM2R/cWCAy6BPJKeHzNbu4lPzOSZpeMfeNErskGpTJx6trEvFaVCbDvpcxwy49BKWmEPwiW8mrysNiDvIQ== +"@babel/traverse@^7.20.10", "@babel/traverse@^7.20.12", "@babel/traverse@^7.20.7", "@babel/traverse@^7.7.2": + version "7.20.12" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.12.tgz#7f0f787b3a67ca4475adef1f56cb94f6abd4a4b5" + integrity sha512-MsIbFN0u+raeja38qboyF8TIT7K0BFzz/Yd/77ta4MsUsmP2RAnidIlwq7d5HFQrH/OZJecGV6B71C4zAgpoSQ== dependencies: "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.18.10" + "@babel/generator" "^7.20.7" "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-function-name" "^7.18.9" + "@babel/helper-function-name" "^7.19.0" "@babel/helper-hoist-variables" "^7.18.6" "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/parser" "^7.18.11" - "@babel/types" "^7.18.10" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.3.0", "@babel/types@^7.3.3": - version "7.18.10" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.18.10.tgz#4908e81b6b339ca7c6b7a555a5fc29446f26dde6" - integrity sha512-MJvnbEiiNkpjo+LknnmRrqbY1GPUUggjv+wQVjetM/AONoupqRALB7I6jGqNUAZsKcRIEu2J6FRFvsczljjsaQ== +"@babel/types@^7.0.0", "@babel/types@^7.18.6", "@babel/types@^7.19.0", "@babel/types@^7.20.2", "@babel/types@^7.20.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.7.tgz#54ec75e252318423fc07fb644dc6a58a64c09b7f" + integrity sha512-69OnhBxSSgK0OzTJai4kyPDiKTIe3j+ctaHdIGVbRahTLAT7L3R9oeXHC2aVSuGYt3cVnoAMDmOCgJ2yaiLMvg== dependencies: - "@babel/helper-string-parser" "^7.18.10" - "@babel/helper-validator-identifier" "^7.18.6" + "@babel/helper-string-parser" "^7.19.4" + "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" "@bcoe/v8-coverage@^0.2.3": @@ -290,15 +291,15 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@eslint/eslintrc@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.0.tgz#29f92c30bb3e771e4a2048c95fa6855392dfac4f" - integrity sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw== +"@eslint/eslintrc@^1.4.1": + version "1.4.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.1.tgz#af58772019a2d271b7e2d4c23ff4ddcba3ccfb3e" + integrity sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^9.3.2" - globals "^13.15.0" + espree "^9.4.0" + globals "^13.19.0" ignore "^5.2.0" import-fresh "^3.2.1" js-yaml "^4.1.0" @@ -482,19 +483,19 @@ dependencies: "@hapi/hoek" "^9.0.0" -"@humanwhocodes/config-array@^0.10.4": - version "0.10.4" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.10.4.tgz#01e7366e57d2ad104feea63e72248f22015c520c" - integrity sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw== +"@humanwhocodes/config-array@^0.11.8": + version "0.11.8" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9" + integrity sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g== dependencies: "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" - minimatch "^3.0.4" + minimatch "^3.0.5" -"@humanwhocodes/gitignore-to-minimatch@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz#316b0a63b91c10e53f242efb4ace5c3b34e8728d" - integrity sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA== +"@humanwhocodes/module-importer@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" + integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== "@humanwhocodes/object-schema@^1.2.1": version "1.2.1" @@ -727,7 +728,7 @@ "@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/trace-mapping" "^0.3.9" -"@jridgewell/resolve-uri@^3.0.3": +"@jridgewell/resolve-uri@3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== @@ -737,18 +738,54 @@ resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== -"@jridgewell/sourcemap-codec@^1.4.10": +"@jridgewell/sourcemap-codec@1.4.14", "@jridgewell/sourcemap-codec@^1.4.10": version "1.4.14" resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== "@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.13", "@jridgewell/trace-mapping@^0.3.9": - version "0.3.14" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" - integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ== + version "0.3.17" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz#793041277af9073b0951a7fe0f0d8c4c98c36985" + integrity sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g== dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/resolve-uri" "3.1.0" + "@jridgewell/sourcemap-codec" "1.4.14" + +"@mapbox/node-pre-gyp@^1.0.10": + version "1.0.10" + resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz#8e6735ccebbb1581e5a7e652244cadc8a844d03c" + integrity sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA== + dependencies: + detect-libc "^2.0.0" + https-proxy-agent "^5.0.0" + make-dir "^3.1.0" + node-fetch "^2.6.7" + nopt "^5.0.0" + npmlog "^5.0.1" + rimraf "^3.0.2" + semver "^7.3.5" + tar "^6.1.11" + +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.8": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": version "1.1.2" @@ -883,19 +920,14 @@ tslib "^1.9.3" "@sinclair/typebox@^0.24.1": - version "0.24.27" - resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.27.tgz#d55643516a1546174e10da681a8aaa81e757452d" - integrity sha512-K7C7IlQ3zLePEZleUN21ceBA2aLcMnLHTLph8QWk1JK37L90obdpY+QGY8bXMKxf1ht1Z0MNewvXxWv0oGDYFg== - -"@sindresorhus/is@^0.14.0": - version "0.14.0" - resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz" - integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== + version "0.24.51" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.51.tgz#645f33fe4e02defe26f2f5c0410e1c094eac7f5f" + integrity sha512-1P1OROm/rdubP5aFDSZQILU0vrLCJ4fvHt6EoqHEM+2D/G5MK3bIaymUKLit8Js9gbns5UyJnkP/TZROLw4tUA== "@sinonjs/commons@^1.7.0": - version "1.8.3" - resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d" - integrity sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ== + version "1.8.6" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.6.tgz#80c516a4dc264c2a69115e7578d62581ff455ed9" + integrity sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ== dependencies: type-detect "4.0.8" @@ -906,25 +938,18 @@ dependencies: "@sinonjs/commons" "^1.7.0" -"@szmarczak/http-timer@^1.1.2": - version "1.1.2" - resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz" - integrity sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA== - dependencies: - defer-to-connect "^1.0.1" - "@tootallnate/once@1": version "1.1.2" resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== "@types/babel__core@^7.1.14": - version "7.1.19" - resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.19.tgz#7b497495b7d1b4812bdb9d02804d0576f43ee460" - integrity sha512-WEOTgRsbYkvA/KCsDwVEGkd7WAr1e3g31VHQ8zy5gul/V1qKullU/BU5I68X5v7V3GnB9eotmom4v5a5gjxorw== + version "7.20.0" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.0.tgz#61bc5a4cae505ce98e1e36c5445e4bee060d8891" + integrity sha512-+n8dL/9GWblDO0iU6eZAwEIJVr5DWigtle+Q6HLOrh/pdbXOhOtqzq8VPPE2zvNJzSKY4vH/z3iT3tn0A3ypiQ== dependencies: - "@babel/parser" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" "@types/babel__generator" "*" "@types/babel__template" "*" "@types/babel__traverse" "*" @@ -945,12 +970,26 @@ "@babel/types" "^7.0.0" "@types/babel__traverse@*", "@types/babel__traverse@^7.0.6": - version "7.18.0" - resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.18.0.tgz#8134fd78cb39567465be65b9fdc16d378095f41f" - integrity sha512-v4Vwdko+pgymgS+A2UIaJru93zQd85vIGWObM5ekZNdXCKtDYqATlEYnWgfo86Q6I1Lh0oXnksDnMU1cwmlPDw== + version "7.18.3" + resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.18.3.tgz#dfc508a85781e5698d5b33443416b6268c4b3e8d" + integrity sha512-1kbcJ40lLB7MHsj39U4Sh1uTd2E7rLEa79kmDpI6cy+XiXsteB3POdQomoq4FxszMrO3ZYchkhYJw7A2862b3w== dependencies: "@babel/types" "^7.3.0" +"@types/bson@*": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@types/bson/-/bson-4.2.0.tgz#a2f71e933ff54b2c3bf267b67fa221e295a33337" + integrity sha512-ELCPqAdroMdcuxqwMgUpifQyRoTpyYCNr1V9xKyF40VsBobsj+BbWNRvwGchMgBPGqkw655ypkjj2MEF5ywVwg== + dependencies: + bson "*" + +"@types/bson@1.x || 4.0.x": + version "4.0.5" + resolved "https://registry.yarnpkg.com/@types/bson/-/bson-4.0.5.tgz#9e0e1d1a6f8866483f96868a9b33bc804926b1fc" + integrity sha512-vVLwMUqhYJSQ/WKcE60eFqcyuWse5fGH+NMAXHuKrUAPoryq3ATxk5o4bgYNtg5aOM4APVg7Hnb3ASqUYG0PKg== + dependencies: + "@types/node" "*" + "@types/fs-extra@^8.0.1": version "8.1.2" resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.2.tgz#7125cc2e4bdd9bd2fc83005ffdb1d0ba00cca61f" @@ -959,9 +998,9 @@ "@types/node" "*" "@types/graceful-fs@^4.1.3": - version "4.1.5" - resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15" - integrity sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw== + version "4.1.6" + resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.6.tgz#e14b2576a1c25026b7f02ede1de3b84c3a1efeae" + integrity sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw== dependencies: "@types/node" "*" @@ -1003,9 +1042,9 @@ "@types/node" "*" "@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0": - version "18.7.3" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.3.tgz#432c89796eab539b7a30b7b8801a727b585238a4" - integrity sha512-LJgzOEwWuMTBxHzgBR/fhhBOWrvBjvO+zPteUgbbuQi80rYIZHrk1mNbRUqPZqSLP2H7Rwt1EFLL/tNLD1Xx/w== + version "18.11.18" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f" + integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA== "@types/node@^8.10.59": version "8.10.66" @@ -1013,9 +1052,9 @@ integrity sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw== "@types/prettier@^2.1.5": - version "2.7.0" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.0.tgz#ea03e9f0376a4446f44797ca19d9c46c36e352dc" - integrity sha512-RI1L7N4JnW5gQw2spvL7Sllfuf1SaHdrZpCHiBlCXjIlufi1SMNnbu2teze3/QE67Fg2tBlH7W+mi4hVNk4p0A== + version "2.7.2" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.2.tgz#6c2324641cc4ba050a8c710b2b251b377581fbf0" + integrity sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg== "@types/stack-utils@^2.0.0": version "2.0.1" @@ -1028,9 +1067,9 @@ integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA== "@types/yargs@^17.0.8": - version "17.0.11" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.11.tgz#5e10ca33e219807c0eee0f08b5efcba9b6a42c06" - integrity sha512-aB4y9UDUXTSMxmM4MH+YnuR0g5Cph3FLQBoWoMB21DSvFVAxRVEHEMx3TLh+zUZYMCQtKiqazz0Q4Rre31f/OA== + version "17.0.20" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.20.tgz#107f0fcc13bd4a524e352b41c49fe88aab5c54d5" + integrity sha512-eknWrTHofQuPk2iuqDm1waA7V6xPlbgBoaaXEgYkClhLOnB0TtbW+srJaOToAgawPxPlHQzwypFA2bhZaUGP5A== dependencies: "@types/yargs-parser" "*" @@ -1060,9 +1099,9 @@ acorn-jsx@^5.3.2: integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== acorn@^8.8.0: - version "8.8.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8" - integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w== + version "8.8.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73" + integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA== after@0.8.2: version "0.8.2" @@ -1091,13 +1130,6 @@ ajv@^6.10.0, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ansi-align@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz" - integrity sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w== - dependencies: - string-width "^4.1.0" - ansi-escapes@^4.2.1: version "4.3.2" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" @@ -1105,11 +1137,6 @@ ansi-escapes@^4.2.1: dependencies: type-fest "^0.21.3" -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - integrity sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA== - ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" @@ -1134,10 +1161,10 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== -anymatch@^3.0.3, anymatch@~3.1.1: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== +anymatch@^3.0.3, anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== dependencies: normalize-path "^3.0.0" picomatch "^2.0.4" @@ -1172,30 +1199,35 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== -array-includes@^3.1.4: - version "3.1.5" - resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.5.tgz#2c320010db8d31031fd2a5f6b3bbd4b1aad31bdb" - integrity sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ== +array-includes@^3.1.6: + version "3.1.6" + resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.6.tgz#9e9e720e194f198266ba9e18c29e6a9b0e4b225f" + integrity sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw== dependencies: call-bind "^1.0.2" define-properties "^1.1.4" - es-abstract "^1.19.5" - get-intrinsic "^1.1.1" + es-abstract "^1.20.4" + get-intrinsic "^1.1.3" is-string "^1.0.7" -array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== +array.prototype.flat@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz#ffc6576a7ca3efc2f46a143b9d1dda9b4b3cf5e2" + integrity sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + es-shim-unscopables "^1.0.0" -array.prototype.flat@^1.2.5: - version "1.3.0" - resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz#0b0c1567bf57b38b56b4c97b8aa72ab45e4adc7b" - integrity sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw== +array.prototype.flatmap@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz#1aae7903c2100433cb8261cd4ed310aab5c4a183" + integrity sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ== dependencies: call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" es-shim-unscopables "^1.0.0" arraybuffer.slice@~0.0.7: @@ -1299,17 +1331,17 @@ base64id@2.0.0: integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== bcrypt@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/bcrypt/-/bcrypt-5.0.1.tgz#f1a2c20f208e2ccdceea4433df0c8b2c54ecdf71" - integrity sha512-9BTgmrhZM2t1bNuDtrtIMVSmmxZBrJ71n8Wg+YgdjHuIWYF7SjjmCPZFB+/5i/o/PIeRpwVJR3P+NrpIItUjqw== + version "5.1.0" + resolved "https://registry.yarnpkg.com/bcrypt/-/bcrypt-5.1.0.tgz#bbb27665dbc400480a524d8991ac7434e8529e17" + integrity sha512-RHBS7HI5N5tEnGTmtR/pppX0mmDSBpQ4aCBsj7CEQfYXDcO74A8sIBYcJMuCsis2E81zDxeENYhv66oZwLiA+Q== dependencies: - "@mapbox/node-pre-gyp" "^1.0.0" - node-addon-api "^3.1.0" + "@mapbox/node-pre-gyp" "^1.0.10" + node-addon-api "^5.0.0" bignumber.js@^9.0.0: - version "9.1.0" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.0.tgz#8d340146107fe3a6cb8d40699643c302e8773b62" - integrity sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A== + version "9.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6" + integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig== binary-extensions@^2.0.0: version "2.2.0" @@ -1334,10 +1366,10 @@ bluebird@3.5.1: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== -body-parser@1.20.0, body-parser@^1.19.0: - version "1.20.0" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.0.tgz#3de69bd89011c11573d7bfee6a64f11b6bd27cc5" - integrity sha512-DfJ+q6EPcGKZD1QWUjSpqp+Q7bDQTsQIF4zfUAtZ6qk+H/3/QRhg9CEp39ss+/T2vw0+HaidC0ecJj/DRLIaKg== +body-parser@1.20.1, body-parser@^1.19.0: + version "1.20.1" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.1.tgz#b1812a8912c195cd371a3ee5e66faa2338a5c668" + integrity sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw== dependencies: bytes "3.1.2" content-type "~1.0.4" @@ -1347,7 +1379,7 @@ body-parser@1.20.0, body-parser@^1.19.0: http-errors "2.0.0" iconv-lite "0.4.24" on-finished "2.4.1" - qs "6.10.3" + qs "6.11.0" raw-body "2.5.1" type-is "~1.6.18" unpipe "1.0.0" @@ -1360,22 +1392,22 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^3.0.2, braces@^3.0.2, braces@~3.0.2: +braces@^3.0.2, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== dependencies: fill-range "^7.0.1" -browserslist@^4.20.2: - version "4.21.3" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.3.tgz#5df277694eb3c48bc5c4b05af3e8b7e09c5a6d1a" - integrity sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ== +browserslist@^4.21.3: + version "4.21.4" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.4.tgz#e7496bbc67b9e39dd0f98565feccdcb0d4ff6987" + integrity sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw== dependencies: - caniuse-lite "^1.0.30001370" - electron-to-chromium "^1.4.202" + caniuse-lite "^1.0.30001400" + electron-to-chromium "^1.4.251" node-releases "^2.0.6" - update-browserslist-db "^1.0.5" + update-browserslist-db "^1.0.9" bser@2.1.1: version "2.1.1" @@ -1384,6 +1416,13 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" +bson@*: + version "4.7.2" + resolved "https://registry.yarnpkg.com/bson/-/bson-4.7.2.tgz#320f4ad0eaf5312dd9b45dc369cc48945e2a5f2e" + integrity sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ== + dependencies: + buffer "^5.6.0" + bson@^1.1.4: version "1.1.6" resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.6.tgz#fb819be9a60cd677e0853aee4ca712a785d6618a" @@ -1434,7 +1473,7 @@ callsites@^3.0.0: camelcase@^5.3.1: version "5.3.1" - resolved "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== camelcase@^6.2.0: @@ -1442,10 +1481,10 @@ camelcase@^6.2.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -caniuse-lite@^1.0.30001370: - version "1.0.30001374" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001374.tgz#3dab138e3f5485ba2e74bd13eca7fe1037ce6f57" - integrity sha512-mWvzatRx3w+j5wx/mpFN5v5twlPrabG8NqX2c6e45LCpymdoGqNvRkRutFUqpRTXKFQFNQJasvK0YT7suW6/Hw== +caniuse-lite@^1.0.30001400: + version "1.0.30001446" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001446.tgz#6d4ba828ab19f49f9bcd14a8430d30feebf1e0c5" + integrity sha512-fEoga4PrImGcwUUGEol/PoFCSBnSkA9drgdkxXkJLsUBOnJ8rs3zDv6ApqYXGQFOyMPsjh79naWhF4DAxbF8rw== chalk@^2.0.0, chalk@^2.4.2: version "2.4.2" @@ -1469,10 +1508,10 @@ char-regex@^1.0.2: resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== -chokidar@^3.2.2: - version "3.4.0" - resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.4.0.tgz" - integrity sha512-aXAaho2VJtisB/1fg1+3nlLJqGOuewTzQpd/Tz0yTg2R0e4IGtshYvtjowyEumcBv2z+y4+kc75Mz7j5xJskcQ== +chokidar@^3.5.2: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== dependencies: anymatch "~3.1.2" braces "~3.0.2" @@ -1484,57 +1523,35 @@ chokidar@^3.2.2: optionalDependencies: fsevents "~2.3.2" -chownr@^1.1.4: - version "1.1.4" - resolved "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz" - integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== - -ci-info@^2.0.0: +chownr@^2.0.0: version "2.0.0" - resolved "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz" - integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece" + integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== ci-info@^3.2.0: - version "3.3.2" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.2.tgz#6d2967ffa407466481c6c90b6e16b3098f080128" - integrity sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg== + version "3.7.1" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.7.1.tgz#708a6cdae38915d597afdf3b145f2f8e1ff55f3f" + integrity sha512-4jYS4MOAaCIStSRwiuxc4B8MYhIe676yO1sYGzARnjXkWpmzZMMYxY6zu8WYWDhSuth5zhrQ1rhNSibyyvv4/w== cjs-module-lexer@^1.0.0: version "1.2.2" resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz#9f84ba3244a512f3a54e5277e8eef4c489864e40" integrity sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA== -cli-boxes@^2.2.0: - version "2.2.1" - resolved "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.1.tgz" - integrity sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw== - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== dependencies: string-width "^4.2.0" - strip-ansi "^6.0.0" + strip-ansi "^6.0.1" wrap-ansi "^7.0.0" -clone-response@^1.0.2: - version "1.0.2" - resolved "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz" - integrity sha512-yjLXh88P599UOyPTFX0POsd7WxnbsVsGohcwzHOLspIhhpalPw1BcqED8NblyZLKcGrL8dTgMlcaZxV2jAD41Q== - dependencies: - mimic-response "^1.0.0" - co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz" - integrity sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA== - collect-v8-coverage@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59" @@ -1646,11 +1663,9 @@ content-type@~1.0.4: integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" - integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== - dependencies: - safe-buffer "~5.1.1" + version "1.9.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" + integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== cookie-signature@1.0.6: version "1.0.6" @@ -1719,7 +1734,7 @@ date-and-time@^0.14.2: resolved "https://registry.yarnpkg.com/date-and-time/-/date-and-time-0.14.2.tgz#a4266c3dead460f6c231fe9674e585908dac354e" integrity sha512-EFTCh9zRSEpGPmJaexg7HTuzZHh6cnJj1ui7IGCFNXzd2QdpsNh05Db5TF3xzJm30YN+A8/6xHSuRcQqoc3kFA== -debug@2.6.9, debug@^2.6.9: +debug@2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -1733,7 +1748,7 @@ debug@3.1.0, debug@~3.1.0: dependencies: ms "2.0.0" -debug@4, debug@^4.1.1, debug@^4.3.2: +debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== @@ -1747,19 +1762,12 @@ debug@^3.2.7: dependencies: ms "^2.1.1" -debug@^4.1.0, debug@^4.3.2: - version "4.3.4" - resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -decompress-response@^3.3.0: - version "3.3.0" - resolved "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz" - integrity sha512-BzRPQuY1ip+qDonAOz42gRm/pg9F768C+npV/4JOsxRC2sq+Rlk+Q4ZCAsOhnIaMrgarILY+RMUIvMmmX1qAEA== +debug@~4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== dependencies: - mimic-response "^1.0.0" + ms "^2.1.1" dedent@^0.7.0: version "0.7.0" @@ -1767,25 +1775,27 @@ dedent@^0.7.0: integrity sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA== deep-equal@^2.0.0: - version "2.0.5" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.5.tgz#55cd2fe326d83f9cbf7261ef0e060b3f724c5cb9" - integrity sha512-nPiRgmbAtm1a3JsnLCf6/SLfXcjyN5v8L1TXzdCmHrXJ4hx+gW/w1YCcn7z8gJtSiDArZCgYtbao3QqLm/N1Sw== + version "2.2.0" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.2.0.tgz#5caeace9c781028b9ff459f33b779346637c43e6" + integrity sha512-RdpzE0Hv4lhowpIUKKMJfeH6C1pXdtT1/it80ubgWqwI3qpuxUBpC1S4hnHg+zjnuOoDkzUtUCEEkG+XG5l3Mw== dependencies: - call-bind "^1.0.0" - es-get-iterator "^1.1.1" - get-intrinsic "^1.0.1" - is-arguments "^1.0.4" - is-date-object "^1.0.2" - is-regex "^1.1.1" + call-bind "^1.0.2" + es-get-iterator "^1.1.2" + get-intrinsic "^1.1.3" + is-arguments "^1.1.1" + is-array-buffer "^3.0.1" + is-date-object "^1.0.5" + is-regex "^1.1.4" + is-shared-array-buffer "^1.0.2" isarray "^2.0.5" - object-is "^1.1.4" + object-is "^1.1.5" object-keys "^1.1.1" - object.assign "^4.1.2" - regexp.prototype.flags "^1.3.0" - side-channel "^1.0.3" - which-boxed-primitive "^1.0.1" + object.assign "^4.1.4" + regexp.prototype.flags "^1.4.3" + side-channel "^1.0.4" + which-boxed-primitive "^1.0.2" which-collection "^1.0.1" - which-typed-array "^1.1.2" + which-typed-array "^1.1.9" deep-is@^0.1.3: version "0.1.4" @@ -1797,19 +1807,7 @@ deepmerge@^4.2.2: resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== -defer-to-connect@^1.0.1: - version "1.1.3" - resolved "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.3.tgz" - integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== - -define-properties@^1.1.2, define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -define-properties@^1.1.4: +define-properties@^1.1.3, define-properties@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.4.tgz#0b14d7bd7fbeb2f3572c3a7eda80ea5d57fb05b1" integrity sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA== @@ -1837,15 +1835,10 @@ destroy@1.2.0: resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== -destroy@~1.0.4: - version "1.0.4" - resolved "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz" - integrity sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg== - -detect-libc@^1.0.2: - version "1.0.3" - resolved "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz" - integrity sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg== +detect-libc@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.1.tgz#e1897aa88fa6ad197862937fbc0441ef352ee0cd" + integrity sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w== detect-newline@^3.0.0: version "3.1.0" @@ -1930,10 +1923,10 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== -electron-to-chromium@^1.4.202: - version "1.4.213" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.213.tgz#a0d0f535e4fbddc25196c91ff2964b5660932297" - integrity sha512-+3DbGHGOCHTVB/Ms63bGqbyC1b8y7Fk86+7ltssB8NQrZtSCvZG6eooSl9U2Q0yw++fL2DpHKOdTU0NVEkFObg== +electron-to-chromium@^1.4.251: + version "1.4.284" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz#61046d1e4cab3a25238f6bf7413795270f125592" + integrity sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA== emittery@^0.10.2: version "0.10.2" @@ -1958,9 +1951,9 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1: once "^1.4.0" engine.io-client@~3.5.0: - version "3.5.2" - resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.5.2.tgz#0ef473621294004e9ceebe73cef0af9e36f2f5fa" - integrity sha512-QEqIp+gJ/kMHeUun7f5Vv3bteRHppHH/FMBQX/esFj/fuYfjyUKWGMo3VCvIP/V8bE9KcjHmRZrhIz2Z9oNsDA== + version "3.5.3" + resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.5.3.tgz#3254f61fdbd53503dc9a6f9d46a52528871ca0d7" + integrity sha512-qsgyc/CEhJ6cgMUwxRRtOndGVhIu5hpL5tR4umSpmX/MvkFoIxUTM7oFMDQumHNzlNLwSVy6qhstFPoWTf7dOw== dependencies: component-emitter "~1.3.0" component-inherit "0.0.3" @@ -1986,9 +1979,9 @@ engine.io-parser@~2.2.0: has-binary2 "~1.0.2" engine.io@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.6.0.tgz#8760e8cd5b8454bd0f422b6466426ac6f598f296" - integrity sha512-Kc8fo5bbg8F4a2f3HPHTEpGyq/IRIQpyeHu3H1ThR14XDD7VrLcsGBo16HUpahgp8YkHJDaU5gNxJZbuGcuueg== + version "3.6.1" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.6.1.tgz#7ca4c7779c20865e30d208751bde08ca1e800256" + integrity sha512-dfs8EVg/i7QjFsXxn7cCRQ+Wai1G1TlEvHhdYEi80fxn5R1vZ2K661O6v/rezj1FP234SZ14r9CmJke99iYDGg== dependencies: accepts "~1.3.4" base64id "2.0.0" @@ -2002,6 +1995,11 @@ ent@^2.2.0: resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" integrity sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA== +err-code@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/err-code/-/err-code-2.0.3.tgz#23c2f3b756ffdfc608d30e27c9a941024807e7f9" + integrity sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA== + error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" @@ -2009,65 +2007,68 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -es-abstract@^1.17.5: - version "1.17.6" - resolved "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz" - integrity sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw== - dependencies: - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - is-callable "^1.2.0" - is-regex "^1.1.0" - object-inspect "^1.7.0" - object-keys "^1.1.1" - object.assign "^4.1.0" - string.prototype.trimend "^1.0.1" - string.prototype.trimstart "^1.0.1" - -es-abstract@^1.19.0, es-abstract@^1.19.1, es-abstract@^1.19.2, es-abstract@^1.19.5, es-abstract@^1.20.0: - version "1.20.1" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.20.1.tgz#027292cd6ef44bd12b1913b828116f54787d1814" - integrity sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA== +es-abstract@^1.19.0, es-abstract@^1.20.4: + version "1.21.1" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.21.1.tgz#e6105a099967c08377830a0c9cb589d570dd86c6" + integrity sha512-QudMsPOz86xYz/1dG1OuGBKOELjCh99IIWHLzy5znUB6j8xG2yMA7bfTV86VSqKF+Y/H08vQPR+9jyXpuC6hfg== dependencies: + available-typed-arrays "^1.0.5" call-bind "^1.0.2" + es-set-tostringtag "^2.0.1" es-to-primitive "^1.2.1" function-bind "^1.1.1" function.prototype.name "^1.1.5" - get-intrinsic "^1.1.1" + get-intrinsic "^1.1.3" get-symbol-description "^1.0.0" + globalthis "^1.0.3" + gopd "^1.0.1" has "^1.0.3" has-property-descriptors "^1.0.0" + has-proto "^1.0.1" has-symbols "^1.0.3" - internal-slot "^1.0.3" - is-callable "^1.2.4" + internal-slot "^1.0.4" + is-array-buffer "^3.0.1" + is-callable "^1.2.7" is-negative-zero "^2.0.2" is-regex "^1.1.4" is-shared-array-buffer "^1.0.2" is-string "^1.0.7" + is-typed-array "^1.1.10" is-weakref "^1.0.2" - object-inspect "^1.12.0" + object-inspect "^1.12.2" object-keys "^1.1.1" - object.assign "^4.1.2" + object.assign "^4.1.4" regexp.prototype.flags "^1.4.3" - string.prototype.trimend "^1.0.5" - string.prototype.trimstart "^1.0.5" + safe-regex-test "^1.0.0" + string.prototype.trimend "^1.0.6" + string.prototype.trimstart "^1.0.6" + typed-array-length "^1.0.4" unbox-primitive "^1.0.2" + which-typed-array "^1.1.9" -es-get-iterator@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.2.tgz#9234c54aba713486d7ebde0220864af5e2b283f7" - integrity sha512-+DTO8GYwbMCwbywjimwZMHp8AuYXOS2JZFWoi2AlPOS3ebnII9w/NLpNZtA7A0YLaVDw+O7KFCeoIV7OPvM7hQ== +es-get-iterator@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.3.tgz#3ef87523c5d464d41084b2c3c9c214f1199763d6" + integrity sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw== dependencies: call-bind "^1.0.2" - get-intrinsic "^1.1.0" - has-symbols "^1.0.1" - is-arguments "^1.1.0" + get-intrinsic "^1.1.3" + has-symbols "^1.0.3" + is-arguments "^1.1.1" is-map "^2.0.2" is-set "^2.0.2" - is-string "^1.0.5" + is-string "^1.0.7" isarray "^2.0.5" + stop-iteration-iterator "^1.0.0" + +es-set-tostringtag@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz#338d502f6f674301d710b80c8592de8a15f09cd8" + integrity sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg== + dependencies: + get-intrinsic "^1.1.3" + has "^1.0.3" + has-tostringtag "^1.0.0" es-shim-unscopables@^1.0.0: version "1.0.0" @@ -2090,11 +2091,6 @@ escalade@^3.1.1: resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== -escape-goat@^2.0.0: - version "2.1.1" - resolved "https://registry.npmjs.org/escape-goat/-/escape-goat-2.1.1.tgz" - integrity sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q== - escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -2129,15 +2125,16 @@ eslint-config-standard@^17.0.0: resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-17.0.0.tgz#fd5b6cf1dcf6ba8d29f200c461de2e19069888cf" integrity sha512-/2ks1GKyqSOkH7JFvXJicu0iMpoojkwB+f5Du/1SC0PtBL+s8v30k9njRZ21pm2drKYm2342jFnGWzttxPmZVg== -eslint-import-resolver-node@^0.3.6: - version "0.3.6" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd" - integrity sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw== +eslint-import-resolver-node@^0.3.7: + version "0.3.7" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.7.tgz#83b375187d412324a1963d84fa664377a23eb4d7" + integrity sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA== dependencies: debug "^3.2.7" - resolve "^1.20.0" + is-core-module "^2.11.0" + resolve "^1.22.1" -eslint-module-utils@^2.7.3: +eslint-module-utils@^2.7.4: version "2.7.4" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz#4f3e41116aaf13a20792261e61d3a2e7e0583974" integrity sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA== @@ -2153,42 +2150,44 @@ eslint-plugin-es@^4.1.0: regexpp "^3.0.0" eslint-plugin-import@^2.26.0: - version "2.26.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b" - integrity sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA== + version "2.27.5" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz#876a6d03f52608a3e5bb439c2550588e51dd6c65" + integrity sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow== dependencies: - array-includes "^3.1.4" - array.prototype.flat "^1.2.5" - debug "^2.6.9" + array-includes "^3.1.6" + array.prototype.flat "^1.3.1" + array.prototype.flatmap "^1.3.1" + debug "^3.2.7" doctrine "^2.1.0" - eslint-import-resolver-node "^0.3.6" - eslint-module-utils "^2.7.3" + eslint-import-resolver-node "^0.3.7" + eslint-module-utils "^2.7.4" has "^1.0.3" - is-core-module "^2.8.1" + is-core-module "^2.11.0" is-glob "^4.0.3" minimatch "^3.1.2" - object.values "^1.1.5" - resolve "^1.22.0" + object.values "^1.1.6" + resolve "^1.22.1" + semver "^6.3.0" tsconfig-paths "^3.14.1" eslint-plugin-n@^15.2.4: - version "15.2.4" - resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-15.2.4.tgz#d62021a0821ae650701ed459756aaf478a9b6056" - integrity sha512-tjnVMv2fiXYMnuiIFI8QMtyUFI42SckEEWvi8h68SWGWshfqO6SSCASy24dGMGAiy7NUk6DZt90DM0iNUsmQ5w== + version "15.6.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-15.6.1.tgz#f7e77f24abb92a550115cf11e29695da122c398c" + integrity sha512-R9xw9OtCRxxaxaszTQmQAlPgM+RdGjaL1akWuY/Fv9fRAi8Wj4CUKc6iYVG8QNRjRuo8/BqVYIpfqberJUEacA== dependencies: builtins "^5.0.1" eslint-plugin-es "^4.1.0" eslint-utils "^3.0.0" ignore "^5.1.1" - is-core-module "^2.9.0" + is-core-module "^2.11.0" minimatch "^3.1.2" - resolve "^1.10.1" - semver "^7.3.7" + resolve "^1.22.1" + semver "^7.3.8" eslint-plugin-promise@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-6.0.0.tgz#017652c07c9816413a41e11c30adc42c3d55ff18" - integrity sha512-7GPezalm5Bfi/E22PnQxDWH2iW9GTvAlUNTztemeHb6c1BniSyoeTrM87JkC0wYdi6aQrZX9p2qEiAno8aTcbw== + version "6.1.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz#269a3e2772f62875661220631bd4dafcb4083816" + integrity sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig== eslint-scope@^7.1.1: version "7.1.1" @@ -2228,13 +2227,14 @@ eslint-visitor-keys@^3.3.0: integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== eslint@^8.19.0: - version "8.21.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.21.0.tgz#1940a68d7e0573cef6f50037addee295ff9be9ef" - integrity sha512-/XJ1+Qurf1T9G2M5IHrsjp+xrGT73RZf23xA1z5wB1ZzzEAWSZKvRwhWxTFp1rvkvCfwcvAUNAP31bhKTTGfDA== - dependencies: - "@eslint/eslintrc" "^1.3.0" - "@humanwhocodes/config-array" "^0.10.4" - "@humanwhocodes/gitignore-to-minimatch" "^1.0.2" + version "8.32.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.32.0.tgz#d9690056bb6f1a302bd991e7090f5b68fbaea861" + integrity sha512-nETVXpnthqKPFyuY2FNjz/bEd6nbosRgKbkgS/y1C7LJop96gYHWpiguLecMHQ2XCPxn77DS0P+68WzG6vkZSQ== + dependencies: + "@eslint/eslintrc" "^1.4.1" + "@humanwhocodes/config-array" "^0.11.8" + "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" @@ -2244,21 +2244,21 @@ eslint@^8.19.0: eslint-scope "^7.1.1" eslint-utils "^3.0.0" eslint-visitor-keys "^3.3.0" - espree "^9.3.3" + espree "^9.4.0" esquery "^1.4.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" file-entry-cache "^6.0.1" find-up "^5.0.0" - functional-red-black-tree "^1.0.1" - glob-parent "^6.0.1" - globals "^13.15.0" - globby "^11.1.0" + glob-parent "^6.0.2" + globals "^13.19.0" grapheme-splitter "^1.0.4" ignore "^5.2.0" import-fresh "^3.0.0" imurmurhash "^0.1.4" is-glob "^4.0.0" + is-path-inside "^3.0.3" + js-sdsl "^4.1.4" js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" @@ -2270,12 +2270,11 @@ eslint@^8.19.0: strip-ansi "^6.0.1" strip-json-comments "^3.1.0" text-table "^0.2.0" - v8-compile-cache "^2.0.3" -espree@^9.3.2, espree@^9.3.3: - version "9.3.3" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.3.3.tgz#2dd37c4162bb05f433ad3c1a52ddf8a49dc08e9d" - integrity sha512-ORs1Rt/uQTqUKjDdGCyrtYxbazf5umATSf/K4qxjmZHORR6HJk+2s/2Pqe+Kk49HHINC/xNIrGfgh8sZcll0ng== +espree@^9.4.0: + version "9.4.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.1.tgz#51d6092615567a2c2cff7833445e37c28c0065bd" + integrity sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg== dependencies: acorn "^8.8.0" acorn-jsx "^5.3.2" @@ -2352,21 +2351,22 @@ expect@^28.1.3: jest-util "^28.1.3" expo-server-sdk@^3.5.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/expo-server-sdk/-/expo-server-sdk-3.6.0.tgz#b13e5e77f622d11009bdd533df857b08225a4d00" - integrity sha512-GyA0BTcFBKk/5gTEO4WOScP9hEttR+GitrcOIl7XwXwE1FHFvbluKiUc9yEjsfEYMgyd78+XhSpGVGQnutGOdA== + version "3.7.0" + resolved "https://registry.yarnpkg.com/expo-server-sdk/-/expo-server-sdk-3.7.0.tgz#65249f8d4a7797507cc884d61222c3c5a3863127" + integrity sha512-SMZuBiIWejAdMMIOTjGQlprcwvSyLfeUQlooyGB5q6GvZ8zHjp+if8Q4k7xczUBTqIqTzs5IvTZnTiqA9Oe9WA== dependencies: node-fetch "^2.6.0" promise-limit "^2.7.0" + promise-retry "^2.0.1" express@^4.17.1: - version "4.18.1" - resolved "https://registry.yarnpkg.com/express/-/express-4.18.1.tgz#7797de8b9c72c857b9cd0e14a5eea80666267caf" - integrity sha512-zZBcOX9TfehHQhtupq57OF8lFZ3UZi08Y97dwFCkD8p9d/d2Y3M+ykKcwaMDEL+4qyUolgBDX6AblpR3fL212Q== + version "4.18.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.18.2.tgz#3fabe08296e930c796c19e3c516979386ba9fd59" + integrity sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ== dependencies: accepts "~1.3.8" array-flatten "1.1.1" - body-parser "1.20.0" + body-parser "1.20.1" content-disposition "0.5.4" content-type "~1.0.4" cookie "0.5.0" @@ -2385,7 +2385,7 @@ express@^4.17.1: parseurl "~1.3.3" path-to-regexp "0.1.7" proxy-addr "~2.0.7" - qs "6.10.3" + qs "6.11.0" range-parser "~1.2.1" safe-buffer "5.2.1" send "0.18.0" @@ -2411,17 +2411,6 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.2.9: - version "3.2.11" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" - integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - fast-json-stable-stringify@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" @@ -2433,14 +2422,14 @@ fast-levenshtein@^2.0.6: integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== fast-text-encoding@^1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.4.tgz#bf1898ad800282a4e53c0ea9690704dd26e4298e" - integrity sha512-x6lDDm/tBAzX9kmsPcZsNbvDs3Zey3+scsxaZElS8xWLgUMAg/oFLeewfUz0mu1CblHhhsu15jGkraldkFh8KQ== + version "1.0.6" + resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.6.tgz#0aa25f7f638222e3396d72bf936afcf1d42d6867" + integrity sha512-VhXlQgj9ioXCqGstD37E/HBeqEGV/qOD/kmbVG8h5xKBYvM1L3lR1Zn4555cQ8GkYbJa8aJSipLPndE1k6zK2w== fastq@^1.6.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" - integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== + version "1.15.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.15.0.tgz#d04d07c6a2a68fe4599fea8d2e103a937fae6b3a" + integrity sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw== dependencies: reusify "^1.0.4" @@ -2452,9 +2441,9 @@ faye-websocket@0.11.3: websocket-driver ">=0.5.1" fb-watchman@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.1.tgz#fc84fb39d2709cf3ff6d743706157bb5708a8a85" - integrity sha512-DkPJKQeY6kKwmuMretBhr7G6Vodr7bFwDYTXIkfG1gjvNpaxBTQV3PbXg6bR1c1UP4jPOX0jHUbbHANL9vRjVg== + version "2.0.2" + resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" + integrity sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA== dependencies: bser "2.1.1" @@ -2485,13 +2474,6 @@ finalhandler@1.2.0: statuses "2.0.1" unpipe "~1.0.0" -find-up@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" - integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== - dependencies: - locate-path "^2.0.0" - find-up@^4.0.0, find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" @@ -2500,6 +2482,14 @@ find-up@^4.0.0, find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" +find-up@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + firebase-admin@^8.10.0: version "8.13.0" resolved "https://registry.yarnpkg.com/firebase-admin/-/firebase-admin-8.13.0.tgz#997d34ae8357d7dc162ba622148bbebcf7f2e923" @@ -2523,9 +2513,9 @@ flat-cache@^3.0.4: rimraf "^3.0.2" flatted@^3.1.0: - version "3.2.6" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.6.tgz#022e9218c637f9f3fc9c35ab9c9193f05add60b2" - integrity sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ== + version "3.2.7" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" + integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== for-each@^0.3.3: version "0.3.3" @@ -2556,16 +2546,11 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@^2.3.2: +fsevents@^2.3.2, fsevents@~2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -fsevents@~2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" - integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== - function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" @@ -2658,10 +2643,10 @@ get-caller-file@^2.0.5: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== -get-intrinsic@^1.0.1, get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.2.tgz#336975123e05ad0b7ba41f152ee4aadbea6cf598" - integrity sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA== +get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f" + integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q== dependencies: function-bind "^1.1.1" has "^1.0.3" @@ -2672,20 +2657,6 @@ get-package-type@^0.1.0: resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== -get-stream@^4.1.0: - version "4.1.0" - resolved "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz" - integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== - dependencies: - pump "^3.0.0" - -get-stream@^5.1.0: - version "5.2.0" - resolved "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz" - integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== - dependencies: - pump "^3.0.0" - get-stream@^6.0.0: version "6.0.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" @@ -2708,40 +2679,21 @@ git-commit-msg-linter@^3.2.6: did-you-mean "^0.0.1" supports-color "^8.1.1" -glob-parent@^5.1.2, glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob-parent@^6.0.1: +glob-parent@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== dependencies: is-glob "^4.0.3" -glob-parent@~5.1.0: +glob-parent@~5.1.2: version "5.1.2" - resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" -glob@^7.0.5, glob@^7.1.3: - version "7.1.6" - resolved "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.1.1" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@^7.1.4: +glob@^7.0.5, glob@^7.1.3, glob@^7.1.4: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -2753,36 +2705,24 @@ glob@^7.1.4: once "^1.3.0" path-is-absolute "^1.0.0" -global-dirs@^2.0.1: - version "2.1.0" - resolved "https://registry.npmjs.org/global-dirs/-/global-dirs-2.1.0.tgz" - integrity sha512-MG6kdOUh/xBnyo9cJFeIKkLEc1AyFq42QTU4XiX51i2NEdxLxLWXIjEjmqKeSuKR7pAZjTqUVoT2b2huxVLgYQ== - dependencies: - ini "1.3.7" - globals@^11.1.0: version "11.12.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== -globals@^13.15.0: - version "13.17.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.17.0.tgz#902eb1e680a41da93945adbdcb5a9f361ba69bd4" - integrity sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw== +globals@^13.19.0: + version "13.19.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.19.0.tgz#7a42de8e6ad4f7242fbcca27ea5b23aca367b5c8" + integrity sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ== dependencies: type-fest "^0.20.2" -globby@^11.1.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" - integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== +globalthis@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf" + integrity sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA== dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.2.9" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^3.0.0" + define-properties "^1.1.3" google-auth-library@^5.0.0, google-auth-library@^5.5.0: version "5.10.1" @@ -2827,22 +2767,12 @@ google-p12-pem@^2.0.0: dependencies: node-forge "^0.10.0" -got@^9.6.0: - version "9.6.0" - resolved "https://registry.npmjs.org/got/-/got-9.6.0.tgz" - integrity sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q== - dependencies: - "@sindresorhus/is" "^0.14.0" - "@szmarczak/http-timer" "^1.1.2" - cacheable-request "^6.0.0" - decompress-response "^3.3.0" - duplexer3 "^0.1.4" - get-stream "^4.1.0" - lowercase-keys "^1.0.1" - mimic-response "^1.0.1" - p-cancelable "^1.0.0" - to-readable-stream "^1.0.0" - url-parse-lax "^3.0.0" +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" graceful-fs@^4.1.2, graceful-fs@^4.2.9: version "4.2.10" @@ -2898,7 +2828,12 @@ has-property-descriptors@^1.0.0: dependencies: get-intrinsic "^1.1.1" -has-symbols@^1.0.1, has-symbols@^1.0.2, has-symbols@^1.0.3: +has-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.1.tgz#1885c1305538958aff469fef37937c22795408e0" + integrity sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg== + +has-symbols@^1.0.2, has-symbols@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== @@ -2932,22 +2867,6 @@ html-escaper@^2.0.0: resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== -http-cache-semantics@^4.0.0: - version "4.1.0" - resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz" - integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== - -http-errors@1.7.2, http-errors@~1.7.2: - version "1.7.2" - resolved "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz" - integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg== - dependencies: - depd "~1.1.2" - inherits "2.0.3" - setprototypeof "1.1.1" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.0" - http-errors@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" @@ -2994,7 +2913,7 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -iconv-lite@0.4.24, iconv-lite@^0.4.4: +iconv-lite@0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -3012,9 +2931,9 @@ ignore-by-default@^1.0.1: integrity sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA== ignore@^5.1.1, ignore@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" - integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== + version "5.2.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" + integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== import-fresh@^3.0.0, import-fresh@^3.2.1: version "3.3.0" @@ -3024,11 +2943,6 @@ import-fresh@^3.0.0, import-fresh@^3.2.1: parent-module "^1.0.0" resolve-from "^4.0.0" -import-lazy@^2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz" - integrity sha512-m7ZEHgtw69qOGw+jwxXkHlrlIPdTGkyh66zXZ1ajZbxkDBNjSY/LGbmjc7h0s2ELsUDTAhFr55TrPSSqJGPG0A== - import-local@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" @@ -3060,12 +2974,12 @@ inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, i resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -internal-slot@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.3.tgz#7347e307deeea2faac2ac6205d4bc7d34967f59c" - integrity sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA== +internal-slot@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.4.tgz#8551e7baf74a7a6ba5f749cfb16aa60722f0d6f3" + integrity sha512-tA8URYccNzMo94s5MQZgH8NB/XTa6HsOo0MLfXTKKEnHVVdegzaQoFZ7Jp44bdvLvY2waT5dc+j5ICEswhi7UQ== dependencies: - get-intrinsic "^1.1.0" + get-intrinsic "^1.1.3" has "^1.0.3" side-channel "^1.0.4" @@ -3074,7 +2988,7 @@ ipaddr.js@1.9.1: resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== -is-arguments@^1.0.4, is-arguments@^1.1.0: +is-arguments@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== @@ -3082,6 +2996,15 @@ is-arguments@^1.0.4, is-arguments@^1.1.0: call-bind "^1.0.2" has-tostringtag "^1.0.0" +is-array-buffer@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.1.tgz#deb1db4fcae48308d54ef2442706c0393997052a" + integrity sha512-ASfLknmY8Xa2XtB4wmbz13Wu202baeA18cJBCeCy0wXUHZF0IPyVEXqKEcd+t2fNSLLL1vC6k7lxZEojNbISXQ== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.3" + is-typed-array "^1.1.10" + is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" @@ -3109,19 +3032,19 @@ is-boolean-object@^1.1.0: call-bind "^1.0.2" has-tostringtag "^1.0.0" -is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945" - integrity sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w== +is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" + integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== -is-core-module@^2.8.1, is-core-module@^2.9.0: - version "2.10.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.10.0.tgz#9012ede0a91c69587e647514e1d5277019e728ed" - integrity sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg== +is-core-module@^2.11.0, is-core-module@^2.9.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" + integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== dependencies: has "^1.0.3" -is-date-object@^1.0.1, is-date-object@^1.0.2: +is-date-object@^1.0.1, is-date-object@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.5.tgz#0841d5536e724c25597bf6ea62e1bd38298df31f" integrity sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ== @@ -3143,14 +3066,7 @@ is-generator-fn@^2.0.0: resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== -is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.1" - resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz" - integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== - dependencies: - is-extglob "^2.1.1" - -is-glob@^4.0.3: +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== @@ -3192,7 +3108,12 @@ is-obj@^2.0.0: resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982" integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w== -is-regex@^1.1.1, is-regex@^1.1.4: +is-path-inside@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" + integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== + +is-regex@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== @@ -3236,15 +3157,15 @@ is-symbol@^1.0.2, is-symbol@^1.0.3: dependencies: has-symbols "^1.0.2" -is-typed-array@^1.1.9: - version "1.1.9" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.9.tgz#246d77d2871e7d9f5aeb1d54b9f52c71329ece67" - integrity sha512-kfrlnTTn8pZkfpJMUgYD7YZ3qzeJgWUn8XfVYBARc4wnmNOmLbmuuaAs3q5fvB0UJOn6yHAKaGTPM7d6ezoD/A== +is-typed-array@^1.1.10, is-typed-array@^1.1.9: + version "1.1.10" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.10.tgz#36a5b5cb4189b575d1a3e4b08536bfb485801e3f" + integrity sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A== dependencies: available-typed-arrays "^1.0.5" call-bind "^1.0.2" - es-abstract "^1.20.0" for-each "^0.3.3" + gopd "^1.0.1" has-tostringtag "^1.0.0" is-typedarray@^1.0.0: @@ -3298,9 +3219,9 @@ istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: integrity sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw== istanbul-lib-instrument@^5.0.4, istanbul-lib-instrument@^5.1.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.0.tgz#31d18bdd127f825dd02ea7bfdfd906f8ab840e9f" - integrity sha512-6Lthe1hqXHBNsqvgDzGO6l03XNeu3CrG4RqQ1KM9+l5+jNGpEJfIELx1NS3SEHmJQA8np/u+E4EPRKRiu6m19A== + version "5.2.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz#d10c8885c2125574e1c231cacadf955675e1ce3d" + integrity sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg== dependencies: "@babel/core" "^7.12.3" "@babel/parser" "^7.14.7" @@ -3519,9 +3440,9 @@ jest-mock@^28.1.3: "@types/node" "*" jest-pnp-resolver@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz#b704ac0ae028a89108a4d040b3f919dfddc8e33c" - integrity sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w== + version "1.2.3" + resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" + integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== jest-regex-util@^28.0.2: version "28.0.2" @@ -3692,6 +3613,11 @@ jest@^28.1.3: import-local "^3.0.2" jest-cli "^28.1.3" +js-sdsl@^4.1.4: + version "4.3.0" + resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.3.0.tgz#aeefe32a451f7af88425b11fdb5f58c90ae1d711" + integrity sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ== + js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -3724,11 +3650,6 @@ json-bigint@^0.3.0: dependencies: bignumber.js "^9.0.0" -json-buffer@3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz" - integrity sha512-CuUqjv0FUZIdXkHPI8MezCnFCdaTAacej1TZYulLoAg1h/PhwkdXFN4V/gzY4g+fMBCOV2xF+rp7t2XD2ns/NQ== - json-parse-even-better-errors@^2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" @@ -3745,21 +3666,21 @@ json-stable-stringify-without-jsonify@^1.0.1: integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== json5@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" - integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + version "1.0.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" + integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== dependencies: minimist "^1.2.0" -json5@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" - integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== +json5@^2.2.2: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== -jsonwebtoken@8.1.0: - version "8.1.0" - resolved "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.1.0.tgz" - integrity sha512-KGlASk0MhznKeyI16nTMla+f+Rn/w89tHPnpbRZuQfnTp221suG7FRAR/yY+FeadVSTn72WZsbqF4Yq/B583QA== +jsonwebtoken@^8.5.1: + version "8.5.1" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d" + integrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w== dependencies: jws "^3.2.2" lodash.includes "^4.3.0" @@ -3806,30 +3727,16 @@ jws@^4.0.0: jwa "^2.0.0" safe-buffer "^5.0.1" -kareem@2.3.1: - version "2.3.1" - resolved "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz" - integrity sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw== - -keyv@^3.0.0: - version "3.1.0" - resolved "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz" - integrity sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA== - dependencies: - json-buffer "3.0.0" +kareem@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.2.tgz#78c4508894985b8d38a0dc15e1a8e11078f2ca93" + integrity sha512-STHz9P7X2L4Kwn72fA4rGyqyXdmrMSdxqHx9IXon/FXluXieaFA6KJ2upcHAHxQPQ0LeM/OjLrhFxifHewOALQ== kleur@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== -latest-version@^5.0.0: - version "5.1.0" - resolved "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz" - integrity sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA== - dependencies: - package-json "^6.3.0" - leven@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" @@ -3853,14 +3760,6 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== -locate-path@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz" - integrity sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA== - dependencies: - p-locate "^2.0.0" - path-exists "^3.0.0" - locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -3868,6 +3767,13 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + lodash.at@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.at/-/lodash.at-4.6.0.tgz#93cdce664f0a1994ea33dd7cd40e23afd11b0ff8" @@ -3938,7 +3844,7 @@ long@^4.0.0: resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== -lru-cache@^5.0.0: +lru-cache@^5.0.0, lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== @@ -4004,11 +3910,6 @@ micromatch@^4.0.4: braces "^3.0.2" picomatch "^2.3.1" -mime-db@1.44.0: - version "1.44.0" - resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz" - integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== - mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": version "1.52.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" @@ -4036,19 +3937,7 @@ mimic-fn@^2.1.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== -mimic-response@^1.0.0, mimic-response@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== - -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== - dependencies: - brace-expansion "^1.1.7" - -minimatch@^3.1.1, minimatch@^3.1.2: +minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== @@ -4056,14 +3945,21 @@ minimatch@^3.1.1, minimatch@^3.1.2: brace-expansion "^1.1.7" minimist@^1.2.0, minimist@^1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" - integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== + version "1.2.7" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18" + integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g== minipass@^3.0.0: - version "3.3.4" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.3.4.tgz#ca99f95dd77c43c7a76bf51e6d200025eee0ffae" - integrity sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw== + version "3.3.6" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.3.6.tgz#7bba384db3a1520d18c9c0e5251c3444e95dd94a" + integrity sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw== + dependencies: + yallist "^4.0.0" + +minipass@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-4.0.0.tgz#7cebb0f9fa7d56f0c5b17853cbe28838a8dbbd3b" + integrity sha512-g2Uuh2jEKoht+zvO6vJqXmYpflPqzRBT+Th2h01DKh5z7wbY/AZ2gCQ78cP70YoHPyFdY30YBV5WxgLOEwOykw== dependencies: yallist "^4.0.0" @@ -4081,9 +3977,9 @@ mkdirp@^1.0.3: integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== moment-timezone@^0.5.31: - version "0.5.34" - resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.34.tgz#a75938f7476b88f155d3504a9343f7519d9a405c" - integrity sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg== + version "0.5.40" + resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.40.tgz#c148f5149fd91dd3e29bf481abc8830ecba16b89" + integrity sha512-tWfmNkRYmBkPJz5mr9GVDn9vRlVZOTe6yqY92rFxiOdWXbjaR0+9LwQnZGGuNR63X456NqmEkbskte8tWL5ePg== dependencies: moment ">= 2.9.0" @@ -4111,9 +4007,9 @@ mongoose-legacy-pluralize@1.0.2: integrity sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ== mongoose@^5.9.6: - version "5.13.14" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.13.14.tgz#ffc9704bd022dd018fbddcbe27dc802c77719fb4" - integrity sha512-j+BlQjjxgZg0iWn42kLeZTB91OejcxWpY2Z50bsZTiKJ7HHcEtcY21Godw496GMkBqJMTzmW7G/kZ04mW+Cb7Q== + version "5.13.15" + resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.13.15.tgz#ba2cd0f22c1a5dd9ae15aaf6b10f03c59a4202dd" + integrity sha512-cxp1Gbb8yUWkaEbajdhspSaKzAvsIvOtRlYD87GN/P2QEUhpd6bIvebi36T6M0tIVAMauNaK9SPA055N3PwF8Q== dependencies: "@types/bson" "1.x || 4.0.x" "@types/mongodb" "^3.5.27" @@ -4166,29 +4062,20 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== -needle@^2.5.0: - version "2.9.1" - resolved "https://registry.npmjs.org/needle/-/needle-2.9.1.tgz" - integrity sha512-6R9fqJ5Zcmf+uYaFgdIHmLwNldn5HbK8L5ybn7Uz+ylX/rnOsSp1AHcvQSrCaFN+qNM1wpymHqD7mVasEOlHGQ== - dependencies: - debug "^3.2.6" - iconv-lite "^0.4.4" - sax "^1.2.4" - -negotiator@0.6.2: - version "0.6.2" - resolved "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz" - integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw== +negotiator@0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== -node-addon-api@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.0.tgz" - integrity sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg== +node-addon-api@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.1.0.tgz#49da1ca055e109a23d537e9de43c09cca21eb762" + integrity sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA== -node-fetch@^2.2.0, node-fetch@^2.3.0, node-fetch@^2.6.0: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== +node-fetch@^2.2.0, node-fetch@^2.3.0, node-fetch@^2.6.0, node-fetch@^2.6.7: + version "2.6.8" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.8.tgz#a68d30b162bc1d8fd71a367e81b997e1f4d4937e" + integrity sha512-RZ6dBYuj8dRSfxpUSu+NsdF1dpPpluJxwOp+6IoDp/sH2QNDSvurYsAa+F1WxY2RjA1iP93xhcsUoYbF2XBqVg== dependencies: whatwg-url "^5.0.0" @@ -4197,31 +4084,20 @@ node-forge@^0.10.0: resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3" integrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA== +node-forge@^0.7.6: + version "0.7.6" + resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.7.6.tgz#fdf3b418aee1f94f0ef642cd63486c77ca9724ac" + integrity sha512-sol30LUpz1jQFBjOKwbjxijiE3b6pjd74YwfD0fJOKPjF+fONKb2Yg8rYgS6+bK6VDl+/wfr4IYpC7jDzLUIfw== + node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== -node-pre-gyp@0.15.0: - version "0.15.0" - resolved "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.15.0.tgz" - integrity sha512-7QcZa8/fpaU/BKenjcaeFF9hLz2+7S9AqyXFhlH/rilsQ/hPZKK32RtR5EQHJElgu+q5RfbJ34KriI79UWaorA== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.3" - needle "^2.5.0" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4.4.2" - node-releases@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503" - integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg== + version "2.0.8" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.8.tgz#0f349cdc8fcfa39a92ac0be9bc48b7706292b9ae" + integrity sha512-dFSmB8fFHEH/s81Xi+Y/15DQY6VHW81nXRj86EMSL3lmuTmK1e+aT4wrFCkTbm+gSwkw4KpX+rT/pMM2c1mF+A== node-schedule@^1.3.2: version "1.3.3" @@ -4233,14 +4109,14 @@ node-schedule@^1.3.2: sorted-array-functions "^1.3.0" nodemon@^2.0.2: - version "2.0.19" - resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.19.tgz#cac175f74b9cb8b57e770d47841995eebe4488bd" - integrity sha512-4pv1f2bMDj0Eeg/MhGqxrtveeQ5/G/UVe9iO6uTZzjnRluSA4PVWf8CW99LUPwGB3eNIA7zUFoP77YuI7hOc0A== + version "2.0.20" + resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.20.tgz#e3537de768a492e8d74da5c5813cb0c7486fc701" + integrity sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw== dependencies: chokidar "^3.5.2" debug "^3.2.7" ignore-by-default "^1.0.1" - minimatch "^3.0.4" + minimatch "^3.1.2" pstree.remy "^1.1.8" semver "^5.7.1" simple-update-notifier "^1.0.7" @@ -4267,32 +4143,6 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -normalize-url@^4.1.0: - version "4.5.1" - resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz" - integrity sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA== - -npm-bundled@^1.0.1: - version "1.1.2" - resolved "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.2.tgz" - integrity sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ== - dependencies: - npm-normalize-package-bin "^1.0.1" - -npm-normalize-package-bin@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz" - integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== - -npm-packlist@^1.1.6: - version "1.4.8" - resolved "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.8.tgz" - integrity sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A== - dependencies: - ignore-walk "^3.0.1" - npm-bundled "^1.0.1" - npm-normalize-package-bin "^1.0.1" - npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" @@ -4300,10 +4150,10 @@ npm-run-path@^4.0.1: dependencies: path-key "^3.0.0" -npmlog@^4.0.2: - version "4.1.2" - resolved "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz" - integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== +npmlog@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-5.0.1.tgz#f06678e80e29419ad67ab964e0fa69959c1eb8b0" + integrity sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw== dependencies: are-we-there-yet "^2.0.0" console-control-strings "^1.1.0" @@ -4315,12 +4165,12 @@ object-assign@^4, object-assign@^4.1.1: resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== -object-inspect@^1.12.0, object-inspect@^1.9.0: - version "1.12.2" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.2.tgz#c0641f26394532f28ab8d796ab954e43c009a8ea" - integrity sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ== +object-inspect@^1.12.2, object-inspect@^1.9.0: + version "1.12.3" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" + integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== -object-is@^1.1.4: +object-is@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== @@ -4333,10 +4183,10 @@ object-keys@^1.1.1: resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== -object.assign@^4.1.2: - version "4.1.3" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.3.tgz#d36b7700ddf0019abb6b1df1bb13f6445f79051f" - integrity sha512-ZFJnX3zltyjcYJL0RoCJuzb+11zWGyaDbjgxZbdV7rFEcHQuYxrZqhow67aA7xpes6LhojyFDaBKAFfogQrikA== +object.assign@^4.1.2, object.assign@^4.1.4: + version "4.1.4" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" + integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== dependencies: call-bind "^1.0.2" define-properties "^1.1.4" @@ -4344,22 +4194,22 @@ object.assign@^4.1.2: object-keys "^1.1.1" object.entries@^1.1.2: - version "1.1.5" - resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.5.tgz#e1acdd17c4de2cd96d5a08487cfb9db84d881861" - integrity sha512-TyxmjUoZggd4OrrU1W66FMDG6CuqJxsFvymeyXI51+vQLN67zYfZseptRge703kKQdo4uccgAKebXFcRCzk4+g== + version "1.1.6" + resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.6.tgz#9737d0e5b8291edd340a3e3264bb8a3b00d5fa23" + integrity sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w== dependencies: call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.1" + define-properties "^1.1.4" + es-abstract "^1.20.4" -object.values@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.5.tgz#959f63e3ce9ef108720333082131e4a459b716ac" - integrity sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg== +object.values@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.6.tgz#4abbaa71eba47d63589d402856f908243eea9b1d" + integrity sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw== dependencies: call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.1" + define-properties "^1.1.4" + es-abstract "^1.20.4" on-finished@2.4.1: version "2.4.1" @@ -4413,20 +4263,13 @@ p-limit@^2.2.0: dependencies: p-try "^2.0.0" -p-limit@^3.1.0: +p-limit@^3.0.2, p-limit@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== dependencies: yocto-queue "^0.1.0" -p-locate@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz" - integrity sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg== - dependencies: - p-limit "^1.1.0" - p-locate@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" @@ -4434,10 +4277,12 @@ p-locate@^4.1.0: dependencies: p-limit "^2.2.0" -p-try@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz" - integrity sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww== +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" p-try@^2.0.0: version "2.2.0" @@ -4476,11 +4321,6 @@ parseurl@~1.3.3: resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== -path-exists@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz" - integrity sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ== - path-exists@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" @@ -4533,11 +4373,6 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prepend-http@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz" - integrity sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA== - pretty-format@^28.1.3: version "28.1.3" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-28.1.3.tgz#c9fba8cedf99ce50963a11b27d982a9ae90970d5" @@ -4558,6 +4393,14 @@ promise-limit@^2.7.0: resolved "https://registry.yarnpkg.com/promise-limit/-/promise-limit-2.7.0.tgz#eb5737c33342a030eaeaecea9b3d3a93cb592b26" integrity sha512-7nJ6v5lnJsXwGprnGXga4wx6d1POjvi5Qmf1ivTRxTjH4Z/9Czja/UCMLVmB9N93GeWOU93XaFaEt6jbuoagNw== +promise-retry@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/promise-retry/-/promise-retry-2.0.1.tgz#ff747a13620ab57ba688f5fc67855410c370da22" + integrity sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g== + dependencies: + err-code "^2.0.2" + retry "^0.12.0" + prompts@^2.0.1: version "2.4.2" resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" @@ -4616,14 +4459,14 @@ pumpify@^2.0.0: pump "^3.0.0" punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + version "2.3.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" + integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== -qs@6.10.3: - version "6.10.3" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.3.tgz#d6cde1b2ffca87b5aa57889816c5f81535e22e8e" - integrity sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ== +qs@6.11.0: + version "6.11.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" + integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== dependencies: side-channel "^1.0.4" @@ -4647,22 +4490,12 @@ raw-body@2.5.1: iconv-lite "0.4.24" unpipe "1.0.0" -rc@1.2.8, rc@^1.2.7, rc@^1.2.8: - version "1.2.8" - resolved "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz" - integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== - dependencies: - deep-extend "^0.6.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - react-is@^18.0.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b" integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w== -"readable-stream@2 || 3", readable-stream@^3.0.2, readable-stream@^3.1.1, readable-stream@^3.4.0: +"readable-stream@2 || 3", readable-stream@^3.0.2, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== @@ -4696,7 +4529,7 @@ regexp-clone@1.0.0, regexp-clone@^1.0.0: resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-1.0.0.tgz#222db967623277056260b992626354a04ce9bf63" integrity sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw== -regexp.prototype.flags@^1.3.0, regexp.prototype.flags@^1.4.3: +regexp.prototype.flags@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac" integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA== @@ -4720,14 +4553,6 @@ require-directory@^2.1.1: resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== -require_optional@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz" - integrity sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g== - dependencies: - resolve-from "^2.0.0" - semver "^5.1.0" - resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" @@ -4735,11 +4560,6 @@ resolve-cwd@^3.0.0: dependencies: resolve-from "^5.0.0" -resolve-from@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz" - integrity sha512-qpFcKaXsq8+oRoLilkwyc7zHGF5i9Q2/25NIgLQQ/+VVv9rU4qvr6nXVAw1DsnXJyQkZsR4Ytfbtg5ehfcUssQ== - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -4751,11 +4571,11 @@ resolve-from@^5.0.0: integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== resolve.exports@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-1.1.0.tgz#5ce842b94b05146c0e03076985d1d0e7e48c90c9" - integrity sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ== + version "1.1.1" + resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-1.1.1.tgz#05cfd5b3edf641571fd46fa608b610dda9ead999" + integrity sha512-/NtpHNDN7jWhAaQ9BvBUYZ6YTXsRBgfqWFWP7BZBaoMJO/I3G5OFzvTuWNlZC3aPjins1F+TNrLKsGbH4rfsRQ== -resolve@^1.10.1, resolve@^1.20.0, resolve@^1.22.0: +resolve@^1.20.0, resolve@^1.22.1: version "1.22.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== @@ -4772,6 +4592,11 @@ retry-request@^4.0.0: debug "^4.1.1" extend "^3.0.2" +retry@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" + integrity sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow== + reusify@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" @@ -4801,6 +4626,15 @@ safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.1, resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== +safe-regex-test@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295" + integrity sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.3" + is-regex "^1.1.4" + "safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -4818,15 +4652,15 @@ semver@^5.6.0, semver@^5.7.1: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@^6.0.0: +semver@^6.0.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.0.0, semver@^7.3.5, semver@^7.3.5, semver@^7.3.7: - version "7.3.7" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" - integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== +semver@^7.0.0, semver@^7.3.5, semver@^7.3.8: + version "7.3.8" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" + integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== dependencies: lru-cache "^6.0.0" @@ -4886,7 +4720,7 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -side-channel@^1.0.3, side-channel@^1.0.4: +side-channel@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== @@ -4900,16 +4734,18 @@ sift@13.5.2: resolved "https://registry.yarnpkg.com/sift/-/sift-13.5.2.tgz#24a715e13c617b086166cd04917d204a591c9da6" integrity sha512-+gxdEOMA2J+AI+fVsCqeNn7Tgx3M9ZN9jdi95939l1IJ8cZsqS8sqpJyOkic2SJk+1+98Uwryt/gL6XDaV+UZA== -signal-exit@^3.0.0, signal-exit@^3.0.2: - version "3.0.3" - resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz" - integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== - -signal-exit@^3.0.3, signal-exit@^3.0.7: +signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: version "3.0.7" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +simple-update-notifier@^1.0.7: + version "1.1.0" + resolved "https://registry.yarnpkg.com/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz#67694c121de354af592b347cdba798463ed49c82" + integrity sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg== + dependencies: + semver "~7.0.0" + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" @@ -4953,18 +4789,18 @@ socket.io-client@2.5.0: to-array "0.1.4" socket.io-parser@~3.3.0: - version "3.3.2" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.2.tgz#ef872009d0adcf704f2fbe830191a14752ad50b6" - integrity sha512-FJvDBuOALxdCI9qwRrO/Rfp9yfndRtc1jSgVgV8FDraihmSP/MLGD5PEuJrNfjALvcQ+vMDM/33AWOYP/JSjDg== + version "3.3.3" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.3.3.tgz#3a8b84823eba87f3f7624e64a8aaab6d6318a72f" + integrity sha512-qOg87q1PMWWTeO01768Yh9ogn7chB9zkKtQnya41Y355S0UmpXgpcrFwAgjYJxu9BdKug5r5e9YtVSeWhKBUZg== dependencies: component-emitter "~1.3.0" debug "~3.1.0" isarray "2.0.1" socket.io-parser@~3.4.0: - version "3.4.1" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.4.1.tgz#b06af838302975837eab2dc980037da24054d64a" - integrity sha512-11hMgzL+WCLWf1uFtHSNvliI++tcRUWdoeYuwIl+Axvwy9z2gQM+7nJyN3STj1tLj5JyIUH8/gpDGxzAlDdi0A== + version "3.4.2" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.4.2.tgz#d70a69f34900d8290a511995d26f581828a49065" + integrity sha512-QFZBaZDNqZXeemwejc7D39jrq2eGK/qZuVDiMPKzZK1hLlNvjGilGt4ckfQZeVX4dGmuPzCytN9ZW1nQlEWjgA== dependencies: component-emitter "1.2.1" debug "~4.1.0" @@ -4982,10 +4818,10 @@ socket.io@^2.4.0: socket.io-client "2.5.0" socket.io-parser "~3.4.0" -sorted-array-functions@^1.0.0: - version "1.2.0" - resolved "https://registry.npmjs.org/sorted-array-functions/-/sorted-array-functions-1.2.0.tgz" - integrity sha512-sWpjPhIZJtqO77GN+LD8dDsDKcWZ9GCOJNqKzi1tvtjGIzwfoyuRH8S0psunmc6Z5P+qfDqztSbwYR5X/e1UTg== +sorted-array-functions@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/sorted-array-functions/-/sorted-array-functions-1.3.0.tgz#8605695563294dffb2c9796d602bd8459f7a0dd5" + integrity sha512-2sqgzeFlid6N4Z2fUQ1cvFmTOLRi/sEDzSQ0OKYchqgoPmQBVyM3959qYx3fpS6Esef80KjmpgPeEr028dP3OA== source-map-support@0.5.13: version "0.5.13" @@ -5013,9 +4849,9 @@ sprintf-js@~1.0.2: integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== stack-utils@^2.0.3: - version "2.0.5" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.5.tgz#d25265fca995154659dbbfba3b49254778d2fdd5" - integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== + version "2.0.6" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" + integrity sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ== dependencies: escape-string-regexp "^2.0.0" @@ -5024,6 +4860,13 @@ statuses@2.0.1: resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== +stop-iteration-iterator@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz#6a60be0b4ee757d1ed5254858ec66b10c49285e4" + integrity sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ== + dependencies: + internal-slot "^1.0.4" + stream-events@^1.0.1, stream-events@^1.0.4, stream-events@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/stream-events/-/stream-events-1.0.5.tgz#bbc898ec4df33a4902d892333d47da9bf1c406d5" @@ -5036,10 +4879,10 @@ stream-shift@^1.0.0: resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== -streamsearch@0.1.2: - version "0.1.2" - resolved "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz" - integrity sha512-jos8u++JKm0ARcSUTAZXOVC0mSox7Bhn6sBgty73P1f3JGf7yG2clTbBNHUdde/kdvP2FESam+vM6l8jBrNxHA== +streamsearch@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" + integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== string-length@^4.0.1: version "4.0.2" @@ -5049,25 +4892,7 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -string-width@^1.0.1: - version "1.0.2" - resolved "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz" - integrity sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw== - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" - -"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0: - version "4.2.0" - resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz" - integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string-width@^4.2.0, string-width@^4.2.3: +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -5076,23 +4901,23 @@ string-width@^4.2.0, string-width@^4.2.3: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" -string.prototype.trimend@^1.0.1, string.prototype.trimend@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz#914a65baaab25fbdd4ee291ca7dde57e869cb8d0" - integrity sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog== +string.prototype.trimend@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz#c4a27fa026d979d79c04f17397f250a462944533" + integrity sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ== dependencies: call-bind "^1.0.2" define-properties "^1.1.4" - es-abstract "^1.19.5" + es-abstract "^1.20.4" -string.prototype.trimstart@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz#5466d93ba58cfa2134839f81d7f42437e8c01fef" - integrity sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg== +string.prototype.trimstart@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz#e90ab66aa8e4007d92ef591bbf3cd422c56bdcf4" + integrity sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA== dependencies: call-bind "^1.0.2" define-properties "^1.1.4" - es-abstract "^1.19.5" + es-abstract "^1.20.4" string_decoder@^1.1.1: version "1.3.0" @@ -5108,7 +4933,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -strip-ansi@^6.0.1: +strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -5154,7 +4979,7 @@ supports-color@^7.0.0, supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -supports-color@^8.0.0: +supports-color@^8.0.0, supports-color@^8.1.1: version "8.1.1" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== @@ -5162,9 +4987,9 @@ supports-color@^8.0.0: has-flag "^4.0.0" supports-hyperlinks@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.2.0.tgz#4f77b42488765891774b70c79babd87f9bd594bb" - integrity sha512-6sXEzV5+I5j8Bmq9/vUphGRM/RJNT9SCURJLjwfOg51heRtguGWDzcaBlgAzKhQa0EVNpPEKzQuBwZ8S8WaCeQ== + version "2.3.0" + resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz#3943544347c1ff90b15effb03fc14ae45ec10624" + integrity sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA== dependencies: has-flag "^4.0.0" supports-color "^7.0.0" @@ -5175,25 +5000,25 @@ supports-preserve-symlinks-flag@^1.0.0: integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== swagger-ui-dist@>=4.11.0: - version "4.13.2" - resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-4.13.2.tgz#fb814efd51bf06aa8630c0a0af6e3caa48ac6552" - integrity sha512-jHL6UyIYpvEI7NsuWd0R3hJaPQTg6Oo4qSBo+oVfOEkv6rrQm/475RGSMmZgV6ajp+Sgrp9CqrDjQYAgQqiv1A== + version "4.15.5" + resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-4.15.5.tgz#cda226a79db2a9192579cc1f37ec839398a62638" + integrity sha512-V3eIa28lwB6gg7/wfNvAbjwJYmDXy1Jo1POjyTzlB6wPcHiGlRxq39TSjYGVjQrUSAzpv+a7nzp7mDxgNy57xA== swagger-ui-express@^4.1.4: - version "4.5.0" - resolved "https://registry.yarnpkg.com/swagger-ui-express/-/swagger-ui-express-4.5.0.tgz#feb1314627092eb9c7e6b65ee018927011445530" - integrity sha512-DHk3zFvsxrkcnurGvQlAcLuTDacAVN1JHKDgcba/gr2NFRE4HGwP1YeHIXMiGznkWR4AeS7X5vEblNn4QljuNA== + version "4.6.0" + resolved "https://registry.yarnpkg.com/swagger-ui-express/-/swagger-ui-express-4.6.0.tgz#fc297d80c614c80f5d7def3dab50b56428cfe1c9" + integrity sha512-ZxpQFp1JR2RF8Ar++CyJzEDdvufa08ujNUJgMVTMWPi86CuQeVdBtvaeO/ysrz6dJAYXf9kbVNhWD7JWocwqsA== dependencies: swagger-ui-dist ">=4.11.0" tar@^6.1.11: - version "6.1.11" - resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" - integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== + version "6.1.13" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.13.tgz#46e22529000f612180601a6fe0680e7da508847b" + integrity sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw== dependencies: chownr "^2.0.0" fs-minipass "^2.0.0" - minipass "^3.0.0" + minipass "^4.0.0" minizlib "^2.1.1" mkdirp "^1.0.3" yallist "^4.0.0" @@ -5209,11 +5034,6 @@ teeny-request@^6.0.0: stream-events "^1.0.5" uuid "^7.0.0" -term-size@^2.1.0: - version "2.2.1" - resolved "https://registry.npmjs.org/term-size/-/term-size-2.2.1.tgz" - integrity sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg== - terminal-link@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" @@ -5259,11 +5079,6 @@ to-fast-properties@^2.0.0: resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" integrity sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog== -to-readable-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz" - integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q== - to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -5325,12 +5140,7 @@ type-fest@^0.21.3: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== -type-fest@^0.8.1: - version "0.8.1" - resolved "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz" - integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== - -type-is@~1.6.17, type-is@~1.6.18: +type-is@~1.6.18: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== @@ -5338,6 +5148,15 @@ type-is@~1.6.17, type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" +typed-array-length@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.4.tgz#89d83785e5c4098bec72e08b319651f0eac9c1bb" + integrity sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng== + dependencies: + call-bind "^1.0.2" + for-each "^0.3.3" + is-typed-array "^1.1.9" + typedarray-to-buffer@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" @@ -5366,9 +5185,9 @@ undefsafe@^2.0.5: integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA== underscore@*: - version "1.13.4" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.4.tgz#7886b46bbdf07f768e0052f1828e1dcab40c0dee" - integrity sha512-BQFnUDuAQ4Yf/cYY5LNrK9NCJFKriaRbD9uR1fTeXnBeoa97W0i41qkZfGO9pSo8I5KzjAcSY2XYtdf0oKd7KQ== + version "1.13.6" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441" + integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A== unique-string@^2.0.0: version "2.0.0" @@ -5382,33 +5201,14 @@ unpipe@1.0.0, unpipe@~1.0.0: resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== -update-browserslist-db@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz#be06a5eedd62f107b7c19eb5bcefb194411abf38" - integrity sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q== +update-browserslist-db@^1.0.9: + version "1.0.10" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz#0f54b876545726f17d00cd9a2561e6dade943ff3" + integrity sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ== dependencies: escalade "^3.1.1" picocolors "^1.0.0" -update-notifier@^4.0.0: - version "4.1.0" - resolved "https://registry.npmjs.org/update-notifier/-/update-notifier-4.1.0.tgz" - integrity sha512-w3doE1qtI0/ZmgeoDoARmI5fjDoT93IfKgEGqm26dGUOh8oNpaSTsGNdYRN/SjOuo10jcJGwkEL3mroKzktkew== - dependencies: - boxen "^4.2.0" - chalk "^3.0.0" - configstore "^5.0.1" - has-yarn "^2.1.0" - import-lazy "^2.1.0" - is-ci "^2.0.0" - is-installed-globally "^0.3.1" - is-npm "^4.0.0" - is-yarn-global "^0.3.0" - latest-version "^5.0.0" - pupa "^2.0.1" - semver-diff "^3.1.1" - xdg-basedir "^4.0.0" - uri-js@^4.2.2: version "4.4.1" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" @@ -5431,11 +5231,6 @@ uuid@^7.0.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b" integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg== -v8-compile-cache@^2.0.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== - v8-to-istanbul@^9.0.1: version "9.0.1" resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.0.1.tgz#b6f994b0b5d4ef255e17a0d17dc444a9f5132fa4" @@ -5489,7 +5284,7 @@ whatwg-url@^5.0.0: tr46 "~0.0.3" webidl-conversions "^3.0.0" -which-boxed-primitive@^1.0.1, which-boxed-primitive@^1.0.2: +which-boxed-primitive@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== @@ -5510,17 +5305,17 @@ which-collection@^1.0.1: is-weakmap "^2.0.1" is-weakset "^2.0.1" -which-typed-array@^1.1.2: - version "1.1.8" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.8.tgz#0cfd53401a6f334d90ed1125754a42ed663eb01f" - integrity sha512-Jn4e5PItbcAHyLoRDwvPj1ypu27DJbtdYXUa5zsinrUx77Uvfb0cXwwnGMTn7cjUfhhqgVQnVJCwF+7cgU7tpw== +which-typed-array@^1.1.9: + version "1.1.9" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.9.tgz#307cf898025848cf995e795e8423c7f337efbde6" + integrity sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA== dependencies: available-typed-arrays "^1.0.5" call-bind "^1.0.2" - es-abstract "^1.20.0" for-each "^0.3.3" + gopd "^1.0.1" has-tostringtag "^1.0.0" - is-typed-array "^1.1.9" + is-typed-array "^1.1.10" which@^2.0.1: version "2.0.2" @@ -5566,9 +5361,9 @@ write-file-atomic@^3.0.0: typedarray-to-buffer "^3.1.5" write-file-atomic@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-4.0.1.tgz#9faa33a964c1c85ff6f849b80b42a88c2c537c8f" - integrity sha512-nSKUxgAbyioruk6hU87QzVbY279oYT6uiwgDoujth2ju4mJ+TZau7SQBhtbTmUyuNYTuXnSyRn66FV0+eCgcrQ== + version "4.0.2" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-4.0.2.tgz#a9df01ae5b77858a027fd2e80768ee433555fcfd" + integrity sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg== dependencies: imurmurhash "^0.1.4" signal-exit "^3.0.7" @@ -5588,17 +5383,12 @@ xmlhttprequest-ssl@~1.6.2: resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.6.3.tgz#03b713873b01659dfa2c1c5d056065b27ddc2de6" integrity sha512-3XfeQE/wNkvrIktn2Kf0869fC0BN6UpydVasGIeSm2B1Llihf7/0UfZM+eCkOw3P7bP4+qPgqhm7ZoxuJtFU0Q== -xtend@^4.0.1: - version "4.0.2" - resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - y18n@^5.0.5: version "5.0.8" resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yallist@^3.0.0, yallist@^3.0.2, yallist@^3.1.1: +yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== @@ -5616,23 +5406,23 @@ yamljs@^0.3.0: argparse "^1.0.7" glob "^7.0.5" -yargs-parser@^21.0.0: +yargs-parser@^21.1.1: version "21.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== yargs@^17.3.1: - version "17.5.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.5.1.tgz#e109900cab6fcb7fd44b1d8249166feb0b36e58e" - integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA== + version "17.6.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.6.2.tgz#2e23f2944e976339a1ee00f18c77fedee8332541" + integrity sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw== dependencies: - cliui "^7.0.2" + cliui "^8.0.1" escalade "^3.1.1" get-caller-file "^2.0.5" require-directory "^2.1.1" string-width "^4.2.3" y18n "^5.0.5" - yargs-parser "^21.0.0" + yargs-parser "^21.1.1" yeast@0.1.2: version "0.1.2" @@ -5643,8 +5433,3 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== - -yocto-queue@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From 08ca7dca828b3ea59e53cdbd9e7df4cd9b1a4292 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Mon, 23 Jan 2023 12:44:18 -0300 Subject: [PATCH 021/107] fix: correct lint --- src/utils/seed/mockedInfos/mockedHelpInfo.js | 36 +++++++++---------- src/utils/seed/mockedInfos/mockedOfferInfo.js | 36 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/utils/seed/mockedInfos/mockedHelpInfo.js b/src/utils/seed/mockedInfos/mockedHelpInfo.js index 952cc949..5c4507b3 100644 --- a/src/utils/seed/mockedInfos/mockedHelpInfo.js +++ b/src/utils/seed/mockedInfos/mockedHelpInfo.js @@ -1,20 +1,20 @@ const mockedHelpInfo = { - "titles": [ - "Preciso de Ajuda", - "Alguém pode me Ajudar?", - "Baile Beneficente", - "Preciso de comida", - "Apoio Social", - "Preciso de Agasalhos", - ], - "descriptions":[ - "Preciso de novas mascáras", - "A água aqui de casa acabou", - "Precisando de voluntário para organizar baile beneficente", - "Alguém pode me ajudar dando arroz?", - "Estou me sentido sozinho durante esse isolamento.", - "Estou passando muito frio.", - ], -} + titles: [ + 'Preciso de Ajuda', + 'Alguém pode me Ajudar?', + 'Baile Beneficente', + 'Preciso de comida', + 'Apoio Social', + 'Preciso de Agasalhos', + ], + descriptions: [ + 'Preciso de novas mascáras', + 'A água aqui de casa acabou', + 'Precisando de voluntário para organizar baile beneficente', + 'Alguém pode me ajudar dando arroz?', + 'Estou me sentido sozinho durante esse isolamento.', + 'Estou passando muito frio.', + ], +}; -module.exports = mockedHelpInfo; \ No newline at end of file +module.exports = mockedHelpInfo; diff --git a/src/utils/seed/mockedInfos/mockedOfferInfo.js b/src/utils/seed/mockedInfos/mockedOfferInfo.js index cc149665..1ecb1aa6 100644 --- a/src/utils/seed/mockedInfos/mockedOfferInfo.js +++ b/src/utils/seed/mockedInfos/mockedOfferInfo.js @@ -1,20 +1,20 @@ const mockedOfferInfo = { - "titles": [ - "Doando comida", - "Cestas básicas", - "Cuidador de idosos", - "Consultas grátis", - "Agasalhos sobrando", - "Carona", - ], - "descriptions":[ - "Tenho arroz e feijão para doar", - "Tenho 7 cestas básicas sobrando aqui", - "Estou ofertando meu serviço de cuidador de idosos gratuitamente", - "Precisando de ajuda psicológica? Posso te ajudar.", - "Estou com alguns agasalhos prontos para doação.", - "Posso ajudar na locomoção de idosos", - ], -} + titles: [ + 'Doando comida', + 'Cestas básicas', + 'Cuidador de idosos', + 'Consultas grátis', + 'Agasalhos sobrando', + 'Carona', + ], + descriptions: [ + 'Tenho arroz e feijão para doar', + 'Tenho 7 cestas básicas sobrando aqui', + 'Estou ofertando meu serviço de cuidador de idosos gratuitamente', + 'Precisando de ajuda psicológica? Posso te ajudar.', + 'Estou com alguns agasalhos prontos para doação.', + 'Posso ajudar na locomoção de idosos', + ], +}; -module.exports = mockedOfferInfo; \ No newline at end of file +module.exports = mockedOfferInfo; From d9570c5b3e9a4ed3418c015b423ef05aa3cf4140 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 18 Feb 2023 20:48:26 -0300 Subject: [PATCH 022/107] chore: fix get followers logic --- src/repository/SocialNetworkRepository.js | 39 +++++++++++------------ src/services/HelpService.js | 2 +- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index d9b1dcd8..0d47baa1 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -15,7 +15,7 @@ class SocialNetworkRepository extends BaseRepository { async destroy(id) { const query = {}; query._id = id; - + await super.$destroy(query); } @@ -66,14 +66,14 @@ class SocialNetworkRepository extends BaseRepository { path: 'user', select: ['photo'] }; - - const result = await super.$list(query,selectField,populate); + const result = await super.$list(query,selectField,populate); + console.log(result) const result2 = result.map((temp) => { - const isFollowing = temp.followers.includes(userProfileId); + const isFollowing = temp.followers.includes(userProfileId); const { - _doc:{_id,username,userId}, + _doc:{_id,username,userId}, $$populatedVirtuals:{user:{photo}}, numberOfFollowers,numberOfFollowing } = temp; @@ -114,13 +114,13 @@ class SocialNetworkRepository extends BaseRepository { const populate = [userHelps,userOffers]; let a = await super.$list(query, networkProfileFields, populate); - + return a; } async getByIdWithAggregation(id) { const query = { userId: ObjectID(id) }; - + const networkProfileFields = [ '_id', 'userId', @@ -174,21 +174,20 @@ class SocialNetworkRepository extends BaseRepository { select: ['userId','username','followers','following'] }; const populate = [followers]; - + let result = await super.$list(query,selectField,populate); // permite a adição de novos atributos no resultado result = JSON.parse(JSON.stringify(result)) - - const result2 = result[0].Followers.map((temp) => { - temp.isFollowing = temp.followers.includes(userProfileId); - temp.photo = temp.user.photo; - delete temp.user; - return temp; - }) - - - //console.log(result2); + let result2 = 0; + if(result.length > 0){ + result2 = result[0].Followers.map((temp) => { + temp.isFollowing = temp.followers.includes(userProfileId); + temp.photo = temp.user.photo; + delete temp.user; + return temp; + }) + } return result2; } @@ -210,7 +209,7 @@ class SocialNetworkRepository extends BaseRepository { select: ['userId','username','followers','following'] }; const populate = [following]; - + let result = await super.$list(query,selectField,populate); // permite a adição de novos atributos no resultado @@ -219,7 +218,7 @@ class SocialNetworkRepository extends BaseRepository { const result2 = result[0].Following.map((temp) => { temp.isFollowing = temp.followers.includes(userProfileId); temp.photo = temp.user.photo; - delete temp.user; + delete temp.user; return temp; }) diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 81eb2525..98d62ce1 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -43,7 +43,7 @@ class HelpService { async notificationToFollowers(profileId,help_id){ - followers = await this.socialNetworkService.getFollowers(profileId,profileId); + const followers = await this.socialNetworkService.getFollowers(profileId,profileId); if (followers) { const ownerTitle = "Pedido de ajuda criado por uma pessoa que você segue."; From 6d759bdef1532043f5795edbddba1f8866e2774e Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 18 Feb 2023 20:53:32 -0300 Subject: [PATCH 023/107] chore: run lint fix --- .../SocialNetworkProfileController.js | 15 +-- src/models/SocialNetworkProfile.js | 48 ++++---- src/repository/BaseRepository.js | 5 +- src/repository/SocialNetworkRepository.js | 106 ++++++++--------- src/routes/BaseRoutes.js | 4 +- src/routes/SocialNetworkRoutes.js | 20 ++-- src/services/EntityService.js | 10 +- src/services/HelpService.js | 42 ++++--- src/services/SocialNetworkService.js | 109 ++++++++---------- src/services/UserService.js | 11 +- 10 files changed, 171 insertions(+), 199 deletions(-) diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js index e64d621d..bb1f227d 100644 --- a/src/controllers/SocialNetworkProfileController.js +++ b/src/controllers/SocialNetworkProfileController.js @@ -9,7 +9,7 @@ class HelpController { async followUser(req, res, next) { const { selectedProfileId, userId } = req.params; try { - const result = await this.socialNetworkService.followUser(selectedProfileId, userId); + const result = await this.socialNetworkService.followUser(selectedProfileId, userId); res.status(200).send(result); next(); } catch (err) { @@ -33,7 +33,6 @@ class HelpController { } - async findUsers(req, res, next) { const { userId, username } = req.params; try { @@ -47,7 +46,7 @@ class HelpController { } } - async getUserActivities(req, res, next){ + async getUserActivities(req, res, next) { const { userId } = req.params; try { const result = await this.socialNetworkService.getUserActivities(userId); @@ -60,7 +59,7 @@ class HelpController { } } - async getFollowers(req, res, next){ + async getFollowers(req, res, next) { const { userId, selectedProfileId } = req.params; try { const result = await this.socialNetworkService.getFollowers(userId, selectedProfileId); @@ -73,7 +72,7 @@ class HelpController { } } - async getFollowing(req, res, next){ + async getFollowing(req, res, next) { const { userId, selectedProfileId } = req.params; try { const result = await this.socialNetworkService.getFollowing(userId, selectedProfileId); @@ -86,8 +85,8 @@ class HelpController { } } - async getUserProfile(req, res, next){ - const { userId} = req.params; + async getUserProfile(req, res, next) { + const { userId } = req.params; try { const result = await this.socialNetworkService.getUserProfile(userId); res.status(200).json(result); @@ -98,8 +97,6 @@ class HelpController { next(); } } - - } module.exports = HelpController; diff --git a/src/models/SocialNetworkProfile.js b/src/models/SocialNetworkProfile.js index 490cf08a..dd89df03 100644 --- a/src/models/SocialNetworkProfile.js +++ b/src/models/SocialNetworkProfile.js @@ -1,8 +1,8 @@ const mongoose = require('mongoose'); const SocialNetworkProfileSchema = new mongoose.Schema({ - - userId:{ + + userId: { type: mongoose.Schema.Types.ObjectId, required: true, unique: true, @@ -19,67 +19,65 @@ const SocialNetworkProfileSchema = new mongoose.Schema({ following: [{ type: mongoose.Schema.Types.ObjectId, required: false, - ref: 'socialNetworkProfile' + ref: 'socialNetworkProfile', }], - -}, { - collection: 'socialNetworkProfile', - toObject: { - virtuals: true, - }, - toJSON: { - virtuals: true, - }, - }); + +}, { + collection: 'socialNetworkProfile', + toObject: { + virtuals: true, + }, + toJSON: { + virtuals: true, + }, +}); SocialNetworkProfileSchema.virtual('user', { ref: 'User', localField: 'userId', foreignField: '_id', - justOne: true + justOne: true, }); SocialNetworkProfileSchema.virtual('entity', { ref: 'Entity', localField: 'userId', foreignField: '_id', - justOne: true + justOne: true, }); SocialNetworkProfileSchema.virtual('Followers', { ref: 'socialNetworkProfile', localField: 'followers', - foreignField: '_id' + foreignField: '_id', }); SocialNetworkProfileSchema.virtual('Following', { ref: 'socialNetworkProfile', localField: 'following', - foreignField: '_id' + foreignField: '_id', }); SocialNetworkProfileSchema.virtual('helpsOffers', { ref: 'OfferedHelp', localField: 'userId', - foreignField: 'ownerId' + foreignField: 'ownerId', }); SocialNetworkProfileSchema.virtual('userHelps', { ref: 'Help', localField: 'userId', - foreignField: 'ownerId' + foreignField: 'ownerId', }); -SocialNetworkProfileSchema.virtual('numberOfFollowers').get(function() { - return this.followers? this.followers.length:0; +SocialNetworkProfileSchema.virtual('numberOfFollowers').get(function () { + return this.followers ? this.followers.length : 0; }); -SocialNetworkProfileSchema.virtual('numberOfFollowing').get(function() { - return this.following? this.following.length:0; +SocialNetworkProfileSchema.virtual('numberOfFollowing').get(function () { + return this.following ? this.following.length : 0; }); - - module.exports = mongoose.model('socialNetworkProfile', SocialNetworkProfileSchema); diff --git a/src/repository/BaseRepository.js b/src/repository/BaseRepository.js index 6db9f203..8bf467cf 100644 --- a/src/repository/BaseRepository.js +++ b/src/repository/BaseRepository.js @@ -70,12 +70,11 @@ class BaseRepository { return recordModel; } - async $list(query, selectedField = null, populate = null, sort = null,limit = null) { + async $list(query, selectedField = null, populate = null, sort = null, limit = null) { return this.ModelClass.find(query, selectedField) .populate(populate) .sort(sort) - .limit(limit) - ; + .limit(limit); } async $countDocuments(query) { diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 0d47baa1..5647d187 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -1,6 +1,6 @@ +const { ObjectID } = require('mongodb'); const BaseRepository = require('./BaseRepository'); const SocialNetworkProfileSchema = require('../models/SocialNetworkProfile'); -const { ObjectID } = require('mongodb'); class SocialNetworkRepository extends BaseRepository { constructor() { @@ -20,7 +20,6 @@ class SocialNetworkRepository extends BaseRepository { } async findUserProfilebyUserId(id) { - const matchQuery = { userId: ObjectID(id) }; const socialNetworkProfileFields = [ '_id', 'userId', 'username', @@ -28,12 +27,11 @@ class SocialNetworkRepository extends BaseRepository { ]; return super.$findOne( matchQuery, - socialNetworkProfileFields + socialNetworkProfileFields, ); } async findUserProfilebyProfileId(id) { - const matchQuery = { _id: ObjectID(id) }; const socialNetworkProfileFields = [ '_id', 'userId', 'username', @@ -41,7 +39,7 @@ class SocialNetworkRepository extends BaseRepository { ]; return super.$findOne( matchQuery, - socialNetworkProfileFields + socialNetworkProfileFields, ); } @@ -49,11 +47,11 @@ class SocialNetworkRepository extends BaseRepository { await super.$update(socialNetworkProfile); } - async findUsersbyName(userProfileId,userName) { + async findUsersbyName(userProfileId, userName) { const query = { - _id: {$ne:ObjectID(userProfileId)}, - username: {$regex: userName,$options:'i'} - } + _id: { $ne: ObjectID(userProfileId) }, + username: { $regex: userName, $options: 'i' }, + }; const selectField = [ 'userId', @@ -62,21 +60,21 @@ class SocialNetworkRepository extends BaseRepository { 'following', ]; - const populate = { + const populate = { path: 'user', - select: ['photo'] + select: ['photo'], }; - const result = await super.$list(query,selectField,populate); - console.log(result) + const result = await super.$list(query, selectField, populate); + console.log(result); const result2 = result.map((temp) => { const isFollowing = temp.followers.includes(userProfileId); const { - _doc:{_id,username,userId}, - $$populatedVirtuals:{user:{photo}}, - numberOfFollowers,numberOfFollowing - } = temp; + _doc: { _id, username, userId }, + $$populatedVirtuals: { user: { photo } }, + numberOfFollowers, numberOfFollowing, + } = temp; const newDoc = { _id, username, @@ -84,14 +82,13 @@ class SocialNetworkRepository extends BaseRepository { photo, numberOfFollowers, numberOfFollowing, - isFollowing - } + isFollowing, + }; return newDoc; - }) + }); return result2; - } async getUserActivitiesById(id) { @@ -104,16 +101,16 @@ class SocialNetworkRepository extends BaseRepository { const userHelps = { path: 'userHelps', - select: ['title','description'] - } + select: ['title', 'description'], + }; const userOffers = { path: 'helpsOffers', - select: ['title','description'] - } + select: ['title', 'description'], + }; - const populate = [userHelps,userOffers]; - let a = await super.$list(query, networkProfileFields, populate); + const populate = [userHelps, userOffers]; + const a = await super.$list(query, networkProfileFields, populate); return a; } @@ -131,31 +128,30 @@ class SocialNetworkRepository extends BaseRepository { const user = { path: 'user', - select: ['phone', 'name', 'birthday', 'address.city'] + select: ['phone', 'name', 'birthday', 'address.city'], }; const entity = { path: 'entity', - select: ['phone', 'name', 'address.city'] + select: ['phone', 'name', 'address.city'], }; const followers = { path: 'Followers', - select: ['_id','userId','username','followers','following'] + select: ['_id', 'userId', 'username', 'followers', 'following'], }; const following = { path: 'Following', - select: ['_id','userId','username','followers','following'] - } + select: ['_id', 'userId', 'username', 'followers', 'following'], + }; - const populate = [user,followers,following,entity]; - let a = await super.$findOne(query, networkProfileFields, populate); + const populate = [user, followers, following, entity]; + const a = await super.$findOne(query, networkProfileFields, populate); return a; } - async getFollowers(userProfileId, selectedProfileId){ - + async getFollowers(userProfileId, selectedProfileId) { // console.log(userProfileId); // console.log(selectedProfileId); @@ -165,68 +161,64 @@ class SocialNetworkRepository extends BaseRepository { 'followers', ]; - const followers = { + const followers = { path: 'Followers', populate: { path: 'user', - select: ['photo','deviceId'] - } , - select: ['userId','username','followers','following'] + select: ['photo', 'deviceId'], + }, + select: ['userId', 'username', 'followers', 'following'], }; const populate = [followers]; - let result = await super.$list(query,selectField,populate); + let result = await super.$list(query, selectField, populate); // permite a adição de novos atributos no resultado - result = JSON.parse(JSON.stringify(result)) + result = JSON.parse(JSON.stringify(result)); let result2 = 0; - if(result.length > 0){ - result2 = result[0].Followers.map((temp) => { + if (result.length > 0) { + result2 = result[0].Followers.map((temp) => { temp.isFollowing = temp.followers.includes(userProfileId); temp.photo = temp.user.photo; delete temp.user; return temp; - }) + }); } return result2; } - async getFollowing(userProfileId, selectedProfileId){ - + async getFollowing(userProfileId, selectedProfileId) { const query = { _id: ObjectID(selectedProfileId) }; const selectField = [ 'following', ]; - const following = { + const following = { path: 'Following', populate: { path: 'user', - select: ['photo'] - } , - select: ['userId','username','followers','following'] + select: ['photo'], + }, + select: ['userId', 'username', 'followers', 'following'], }; const populate = [following]; - let result = await super.$list(query,selectField,populate); + let result = await super.$list(query, selectField, populate); // permite a adição de novos atributos no resultado - result = JSON.parse(JSON.stringify(result)) + result = JSON.parse(JSON.stringify(result)); const result2 = result[0].Following.map((temp) => { temp.isFollowing = temp.followers.includes(userProfileId); temp.photo = temp.user.photo; delete temp.user; return temp; - }) + }); return result2; } - - - } module.exports = SocialNetworkRepository; diff --git a/src/routes/BaseRoutes.js b/src/routes/BaseRoutes.js index 9136439c..a1400cdf 100644 --- a/src/routes/BaseRoutes.js +++ b/src/routes/BaseRoutes.js @@ -7,11 +7,11 @@ const categoryRoutes = require('./CategoryRoutes'); const notificationRoutes = require('./NotificationRoutes'); const helpOfferRoutes = require('./HelpOfferRoutes'); const campaignRoutes = require('./CampaignRoutes'); -const socialNetworkRoutes = require("./SocialNetworkRoutes"); +const socialNetworkRoutes = require('./SocialNetworkRoutes'); const swaggerDocument = YAML.load('docs/swagger.yaml'); module.exports = (app) => { app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); - app.use('/api', [userRoutes, helpRoutes, categoryRoutes, notificationRoutes, entityRoutes, helpOfferRoutes, campaignRoutes,socialNetworkRoutes]); + app.use('/api', [userRoutes, helpRoutes, categoryRoutes, notificationRoutes, entityRoutes, helpOfferRoutes, campaignRoutes, socialNetworkRoutes]); }; diff --git a/src/routes/SocialNetworkRoutes.js b/src/routes/SocialNetworkRoutes.js index e2956caa..69689154 100644 --- a/src/routes/SocialNetworkRoutes.js +++ b/src/routes/SocialNetworkRoutes.js @@ -1,37 +1,37 @@ -const express = require("express"); -const SocialNetworkProfileController = require("../controllers/SocialNetworkProfileController"); -const isAuthenticated = require("../validation/middlewares/authFirebase"); +const express = require('express'); +const SocialNetworkProfileController = require('../controllers/SocialNetworkProfileController'); +const isAuthenticated = require('../validation/middlewares/authFirebase'); const routes = express.Router(); const socialNetworkProfileController = new SocialNetworkProfileController(); -routes.put("/socialNetworkProfile/followUser/:selectedProfileId/:userId", isAuthenticated, async (req, res, next) => { +routes.put('/socialNetworkProfile/followUser/:selectedProfileId/:userId', isAuthenticated, async (req, res, next) => { socialNetworkProfileController.followUser(req, res, next); }); -routes.put("/socialNetworkProfile/unfollowUser/:selectedProfileId/:userId",isAuthenticated, async (req, res, next) => { +routes.put('/socialNetworkProfile/unfollowUser/:selectedProfileId/:userId', isAuthenticated, async (req, res, next) => { socialNetworkProfileController.unfollowUser(req, res, next); }); -routes.get("/socialNetworkProfile/findUsers/:userId/:username",isAuthenticated, async (req, res, next) => { +routes.get('/socialNetworkProfile/findUsers/:userId/:username', isAuthenticated, async (req, res, next) => { socialNetworkProfileController.findUsers(req, res, next); }); -routes.get("/socialNetworkProfile/getUserActivities/:userId",isAuthenticated, async (req, res, next) => { +routes.get('/socialNetworkProfile/getUserActivities/:userId', isAuthenticated, async (req, res, next) => { socialNetworkProfileController.getUserActivities(req, res, next); }); -routes.get("/socialNetworkProfile/getFollowers/:userId/:selectedProfileId",isAuthenticated, async (req, res, next) => { +routes.get('/socialNetworkProfile/getFollowers/:userId/:selectedProfileId', isAuthenticated, async (req, res, next) => { socialNetworkProfileController.getFollowers(req, res, next); }); -routes.get("/socialNetworkProfile/getFollowing/:userId/:selectedProfileId",isAuthenticated, async (req, res, next) => { +routes.get('/socialNetworkProfile/getFollowing/:userId/:selectedProfileId', isAuthenticated, async (req, res, next) => { socialNetworkProfileController.getFollowing(req, res, next); }); -routes.get("/socialNetworkProfile/getUserProfile/:userId",isAuthenticated, async (req, res, next) => { +routes.get('/socialNetworkProfile/getUserProfile/:userId', isAuthenticated, async (req, res, next) => { socialNetworkProfileController.getUserProfile(req, res, next); }); diff --git a/src/services/EntityService.js b/src/services/EntityService.js index 21acfded..5d92f67a 100644 --- a/src/services/EntityService.js +++ b/src/services/EntityService.js @@ -1,8 +1,8 @@ -const EntityRepository = require("../repository/EntityRepository"); -const UserRepository = require("../repository/UserRepository"); -const SocialNetworkService = require("../services/SocialNetworkService"); -const firebase = require("../config/authFirebase"); -const { ObjectID } = require("mongodb"); +const { ObjectID } = require('mongodb'); +const EntityRepository = require('../repository/EntityRepository'); +const UserRepository = require('../repository/UserRepository'); +const SocialNetworkService = require('./SocialNetworkService'); +const firebase = require('../config/authFirebase'); class EntityService { constructor() { diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 98d62ce1..b39988ce 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -1,14 +1,14 @@ -const HelpRepository = require("../repository/HelpRepository"); -const NotificationService = require("./NotificationService"); -const { notificationTypesEnum } = require("../models/Notification"); -const UserService = require("./UserService"); -const EntityService = require("./EntityService"); -const CategoryService = require("./CategoryService"); -const { findConnections, sendMessage } = require("../../websocket"); -const NotificationMixin = require("../utils/NotificationMixin"); -const helpStatusEnum = require("../utils/enums/helpStatusEnum"); -const saveError = require("../utils/ErrorHistory"); -const SocialNetworkService = require("../services/SocialNetworkService"); +const HelpRepository = require('../repository/HelpRepository'); +const NotificationService = require('./NotificationService'); +const { notificationTypesEnum } = require('../models/Notification'); +const UserService = require('./UserService'); +const EntityService = require('./EntityService'); +const CategoryService = require('./CategoryService'); +const { findConnections, sendMessage } = require('../../websocket'); +const NotificationMixin = require('../utils/NotificationMixin'); +const helpStatusEnum = require('../utils/enums/helpStatusEnum'); +const saveError = require('../utils/ErrorHistory'); +const SocialNetworkService = require('./SocialNetworkService'); class HelpService { constructor() { @@ -37,19 +37,17 @@ class HelpService { ); sendMessage(sendSocketMessageTo, 'new-help', createdHelp); - this.notificationToFollowers(createdHelp.ownerId, createdHelp.id) + this.notificationToFollowers(createdHelp.ownerId, createdHelp.id); } - async notificationToFollowers(profileId,help_id){ - - - const followers = await this.socialNetworkService.getFollowers(profileId,profileId); + async notificationToFollowers(profileId, help_id) { + const followers = await this.socialNetworkService.getFollowers(profileId, profileId); if (followers) { - const ownerTitle = "Pedido de ajuda criado por uma pessoa que você segue."; - const ownerBody = `Uma das pessoas que você está seguindo, criou uma ajuda.`; + const ownerTitle = 'Pedido de ajuda criado por uma pessoa que você segue.'; + const ownerBody = 'Uma das pessoas que você está seguindo, criou uma ajuda.'; - for(let i=0;i -1 || followingPosition > -1) { - throw new Error("Usuário já é um seguidor"); + throw new Error('Usuário já é um seguidor'); } - + selectedProfile.followers.push(userProfile._id); userProfile.following.push(selectedProfileId); @@ -59,28 +53,26 @@ class SocialNetworkService { await this.socialNetworkRepository.updateProfile(selectedProfile); return true; - } - async unfollowUser(selectedProfileId, userId){ - - let selectedProfile = await this.socialNetworkRepository.findUserProfilebyProfileId(selectedProfileId); - let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - - if(!userProfile){ - throw new Error ("User profile not found"); - } else if (!selectedProfile){ - throw new Error ("Selected profile not found"); + async unfollowUser(selectedProfileId, userId) { + const selectedProfile = await this.socialNetworkRepository.findUserProfilebyProfileId(selectedProfileId); + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + + if (!userProfile) { + throw new Error('User profile not found'); + } else if (!selectedProfile) { + throw new Error('Selected profile not found'); } const followerPosition = selectedProfile.followers.indexOf(userProfile._id); const followingPosition = userProfile.following.indexOf(selectedProfileId); - if (followerPosition < 0 || followingPosition < 0) { - throw new Error("Usuário não é um seguidor"); + if (followerPosition < 0 || followingPosition < 0) { + throw new Error('Usuário não é um seguidor'); } - - selectedProfile.followers.splice(followerPosition,1); - userProfile.following.splice(followingPosition,1); + + selectedProfile.followers.splice(followerPosition, 1); + userProfile.following.splice(followingPosition, 1); await this.socialNetworkRepository.updateProfile(selectedProfile); await this.socialNetworkRepository.updateProfile(userProfile); @@ -88,49 +80,46 @@ class SocialNetworkService { } - async findUsers(userId,username) { - - let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - const users = await this.socialNetworkRepository.findUsersbyName(userProfile.id,username); + async findUsers(userId, username) { + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const users = await this.socialNetworkRepository.findUsersbyName(userProfile.id, username); - if(!users){ - throw new Error("Nenhum usuário encontrado"); + if (!users) { + throw new Error('Nenhum usuário encontrado'); } return users; } - async getUserActivities(userId){ + async getUserActivities(userId) { + const helper = false; + const statusList = ['waiting', 'on_going', 'finished', 'owner_finished', 'helper_finished']; + const getOtherUsers = true; + const categoryArray = null; - let helper = false; - let statusList = ['waiting','on_going','finished','owner_finished','helper_finished']; - let getOtherUsers = true; - let categoryArray = null; - - let helps = await this.helpRepository.getHelpListByStatus(userId, statusList, helper); - let offers = await this.offerdHelpRepository.list(userId, categoryArray, getOtherUsers); + const helps = await this.helpRepository.getHelpListByStatus(userId, statusList, helper); + const offers = await this.offerdHelpRepository.list(userId, categoryArray, getOtherUsers); - let activities = {helps,offers}; - //console.log(activities); + const activities = { helps, offers }; + // console.log(activities); return activities; } - async getFollowers(userId, selectedProfileId){ - - let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + async getFollowers(userId, selectedProfileId) { + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); const followers = await this.socialNetworkRepository.getFollowers(userProfile.id, selectedProfileId); return followers; } - async getFollowing(userId, selectedProfileId){ - let userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + async getFollowing(userId, selectedProfileId) { + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); const following = await this.socialNetworkRepository.getFollowing(userProfile.id, selectedProfileId); return following; } - async getUserProfile(userId){ + async getUserProfile(userId) { const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); return userProfile; } diff --git a/src/services/UserService.js b/src/services/UserService.js index b0982047..4a2a4ba6 100644 --- a/src/services/UserService.js +++ b/src/services/UserService.js @@ -1,15 +1,14 @@ -const UserRepository = require("../repository/UserRepository"); -const EntityRepository = require("../repository/EntityRepository"); -const SocialNetworkService = require("../services/SocialNetworkService"); -const firebase = require("../config/authFirebase"); -const { ObjectID } = require("mongodb"); +const { ObjectID } = require('mongodb'); +const UserRepository = require('../repository/UserRepository'); +const EntityRepository = require('../repository/EntityRepository'); +const SocialNetworkService = require('./SocialNetworkService'); +const firebase = require('../config/authFirebase'); class UserService { constructor() { this.userRepository = new UserRepository(); this.entityRepository = new EntityRepository(); this.socialNetworkService = new SocialNetworkService(); - } async createUser(data) { From c91f8e208da369066553bfc476d1a10332d44b64 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 18 Feb 2023 20:58:50 -0300 Subject: [PATCH 024/107] fix: fix eslint --- src/services/HelpService.js | 48 +++++++++++++++------------- src/services/SocialNetworkService.js | 3 -- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/services/HelpService.js b/src/services/HelpService.js index b39988ce..db1d5d49 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -40,35 +40,37 @@ class HelpService { this.notificationToFollowers(createdHelp.ownerId, createdHelp.id); } - async notificationToFollowers(profileId, help_id) { + async notificationToFollowers(profileId, helpId) { const followers = await this.socialNetworkService.getFollowers(profileId, profileId); if (followers) { const ownerTitle = 'Pedido de ajuda criado por uma pessoa que você segue.'; const ownerBody = 'Uma das pessoas que você está seguindo, criou uma ajuda.'; - for (let i = 0; i < followers.length; i++) { - const followersNotificationHistory = { - userId: followers[i].id, - helpId: help_id, - title: ownerTitle, - body: ownerBody, - notificationType: notificationTypesEnum.outros, - }; - try { - await this.NotificationMixin.sendNotification( - followers.deviceId, - ownerTitle, - ownerBody, - ); - await this.NotificationService.createNotification( - ownerNotificationHistory, - ); - } catch (err) { - console.log('Não foi possível enviar a notificação!'); - saveError(err); - } - } + /* eslint-disable no-await-in-loop */ + // for (let i = 0; i < followers.length; i++) { + // const followersNotificationHistory = { + // userId: followers[i].id, + // helpId: helpId, + // title: ownerTitle, + // body: ownerBody, + // notificationType: notificationTypesEnum.outros, + // }; + // console.log(followersNotificationHistory) + // try { + // await this.NotificationMixin.sendNotification( + // followers.deviceId, + // ownerTitle, + // ownerBody, + // ); + // await this.NotificationService.createNotification( + // ownerNotificationHistory, + // ); + // } catch (err) { + // console.log('Não foi possível enviar a notificação!'); + // saveError(err); + // } + // } } } diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index 294a7761..d2fcdd9c 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -1,7 +1,4 @@ -const { ObjectID } = require('mongodb'); const SocialNetworkRepository = require('../repository/SocialNetworkRepository'); -const EntityRepository = require('../repository/EntityRepository'); -const firebase = require('../config/authFirebase'); const HelpRepository = require('../repository/HelpRepository'); const OfferdHelpRepository = require('../repository/HelpOfferRepository'); From b065fc9c6c95c04dfb3295f97037d8a09891b631 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 18 Feb 2023 21:02:13 -0300 Subject: [PATCH 025/107] chore: lint again --- src/services/HelpService.js | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/services/HelpService.js b/src/services/HelpService.js index db1d5d49..6ab785ec 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -48,29 +48,29 @@ class HelpService { const ownerBody = 'Uma das pessoas que você está seguindo, criou uma ajuda.'; /* eslint-disable no-await-in-loop */ - // for (let i = 0; i < followers.length; i++) { - // const followersNotificationHistory = { - // userId: followers[i].id, - // helpId: helpId, - // title: ownerTitle, - // body: ownerBody, - // notificationType: notificationTypesEnum.outros, - // }; - // console.log(followersNotificationHistory) - // try { - // await this.NotificationMixin.sendNotification( - // followers.deviceId, - // ownerTitle, - // ownerBody, - // ); - // await this.NotificationService.createNotification( - // ownerNotificationHistory, - // ); - // } catch (err) { - // console.log('Não foi possível enviar a notificação!'); - // saveError(err); - // } - // } + for (let i = 0; i < followers.length; i++) { + const followersNotificationHistory = { + userId: followers[i].id, + helpId, + title: ownerTitle, + body: ownerBody, + notificationType: notificationTypesEnum.outros, + }; + console.log(followersNotificationHistory); + // try { + // await this.NotificationMixin.sendNotification( + // followers.deviceId, + // ownerTitle, + // ownerBody, + // ); + // await this.NotificationService.createNotification( + // ownerNotificationHistory, + // ); + // } catch (err) { + // console.log('Não foi possível enviar a notificação!'); + // saveError(err); + // } + } } } From e08964ddddc0bed7d1e79e2ed67d05591157deb4 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 18 Feb 2023 21:04:42 -0300 Subject: [PATCH 026/107] chore: this rule doesnt make any sense =) --- src/services/HelpService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 6ab785ec..f828dceb 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -48,7 +48,7 @@ class HelpService { const ownerBody = 'Uma das pessoas que você está seguindo, criou uma ajuda.'; /* eslint-disable no-await-in-loop */ - for (let i = 0; i < followers.length; i++) { + for (let i = 0; i < followers.length; i+=1) { const followersNotificationHistory = { userId: followers[i].id, helpId, From e429db70563a3c693a401318a6b9f702bdca71dc Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 18 Feb 2023 21:06:27 -0300 Subject: [PATCH 027/107] chore: tired of eslint --- src/services/HelpService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/HelpService.js b/src/services/HelpService.js index f828dceb..12cf4390 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -48,7 +48,7 @@ class HelpService { const ownerBody = 'Uma das pessoas que você está seguindo, criou uma ajuda.'; /* eslint-disable no-await-in-loop */ - for (let i = 0; i < followers.length; i+=1) { + for (let i = 0; i < followers.length; i += 1) { const followersNotificationHistory = { userId: followers[i].id, helpId, From 3f39985db99f54adc360c50b3b46c739cddbd570 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Tue, 21 Feb 2023 01:37:24 -0300 Subject: [PATCH 028/107] chore: removing console logs --- src/repository/SocialNetworkRepository.js | 3 --- src/services/HelpService.js | 33 ++++++++++++----------- src/services/SocialNetworkService.js | 2 -- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 5647d187..1ce4bd9f 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -67,7 +67,6 @@ class SocialNetworkRepository extends BaseRepository { const result = await super.$list(query, selectField, populate); - console.log(result); const result2 = result.map((temp) => { const isFollowing = temp.followers.includes(userProfileId); const { @@ -152,8 +151,6 @@ class SocialNetworkRepository extends BaseRepository { } async getFollowers(userProfileId, selectedProfileId) { - // console.log(userProfileId); - // console.log(selectedProfileId); const query = { _id: ObjectID(selectedProfileId) }; diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 12cf4390..2c0b3ec2 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -37,9 +37,10 @@ class HelpService { ); sendMessage(sendSocketMessageTo, 'new-help', createdHelp); - this.notificationToFollowers(createdHelp.ownerId, createdHelp.id); + // this.notificationToFollowers(createdHelp.ownerId, createdHelp.id); } + /* TODO: Create logic to notificate the followers async notificationToFollowers(profileId, helpId) { const followers = await this.socialNetworkService.getFollowers(profileId, profileId); @@ -47,7 +48,7 @@ class HelpService { const ownerTitle = 'Pedido de ajuda criado por uma pessoa que você segue.'; const ownerBody = 'Uma das pessoas que você está seguindo, criou uma ajuda.'; - /* eslint-disable no-await-in-loop */ + eslint-disable no-await-in-loop for (let i = 0; i < followers.length; i += 1) { const followersNotificationHistory = { userId: followers[i].id, @@ -57,22 +58,24 @@ class HelpService { notificationType: notificationTypesEnum.outros, }; console.log(followersNotificationHistory); - // try { - // await this.NotificationMixin.sendNotification( - // followers.deviceId, - // ownerTitle, - // ownerBody, - // ); - // await this.NotificationService.createNotification( - // ownerNotificationHistory, - // ); - // } catch (err) { - // console.log('Não foi possível enviar a notificação!'); - // saveError(err); - // } + try { + await this.NotificationMixin.sendNotification( + followers.deviceId, + ownerTitle, + ownerBody, + ); + await this.NotificationService.createNotification( + ownerNotificationHistory, + ); + } catch (err) { + console.log('Não foi possível enviar a notificação!'); + saveError(err); + } } } } + */ + async getHelpByid(id) { const Help = await this.HelpRepository.getById(id); diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index d2fcdd9c..7db86e44 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -17,7 +17,6 @@ class SocialNetworkService { }; const createdSocialNetworkUser = await this.socialNetworkRepository.create(socialProfileData); - console.log(createdSocialNetworkUser); return createdSocialNetworkUser; } @@ -97,7 +96,6 @@ class SocialNetworkService { const offers = await this.offerdHelpRepository.list(userId, categoryArray, getOtherUsers); const activities = { helps, offers }; - // console.log(activities); return activities; } From 2c6d7688c7e3d2cb5a0b408233659d0787445eea Mon Sep 17 00:00:00 2001 From: sudjoao Date: Tue, 21 Feb 2023 01:39:37 -0300 Subject: [PATCH 029/107] chore: fix lint --- src/repository/SocialNetworkRepository.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 1ce4bd9f..0dc66b50 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -151,7 +151,6 @@ class SocialNetworkRepository extends BaseRepository { } async getFollowers(userProfileId, selectedProfileId) { - const query = { _id: ObjectID(selectedProfileId) }; const selectField = [ From b488e39797270dd62b345157a56c7dc0db5cafb3 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Wed, 1 Mar 2023 00:04:19 -0300 Subject: [PATCH 030/107] refactor: pass commom fields to help user query --- src/repository/HelpOfferRepository.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index 8efd7202..e8c055fc 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -17,6 +17,7 @@ class OfferdHelpRepository extends BaseRepository { } async getByIdWithAggregation(id) { + const commomUserFields = ['_id', 'name', 'photo', 'birthday', 'phone', 'address.city', 'address.state'] const query = { _id: ObjectID(id) }; const helpOfferFields = [ '_id', @@ -33,7 +34,7 @@ class OfferdHelpRepository extends BaseRepository { ]; const user = { path: 'user', - select: ['photo', 'phone', 'name', 'birthday', 'address.city'], + select: commomUserFields, }; const categories = { path: 'categories', @@ -41,15 +42,15 @@ class OfferdHelpRepository extends BaseRepository { }; const possibleHelpedUsers = { path: 'possibleHelpedUsers', - select: ['_id', 'name', 'photo', 'birthday', 'phone', 'address.city'], + select: commomUserFields }; const possibleEntities = { path: 'possibleEntities', - select: ['_id', 'name', 'photo', 'birthday', 'address.city'], + select: commomUserFields, }; const helpedUsers = { path: 'helpedUsers', - select: ['_id', 'name', 'photo', 'birthday', 'phone', 'address.city'], + select: commomUserFields }; const populate = [user, categories, possibleHelpedUsers, possibleEntities, helpedUsers]; From b8e36206b8b633d4563d99728e849d2289333787 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Wed, 1 Mar 2023 22:32:57 -0300 Subject: [PATCH 031/107] chore: add missing parameter --- src/services/SocialNetworkService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index 7db86e44..9ae907ce 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -93,7 +93,7 @@ class SocialNetworkService { const categoryArray = null; const helps = await this.helpRepository.getHelpListByStatus(userId, statusList, helper); - const offers = await this.offerdHelpRepository.list(userId, categoryArray, getOtherUsers); + const offers = await this.offerdHelpRepository.list(userId, false, categoryArray, getOtherUsers); const activities = { helps, offers }; return activities; From 106057348159df6e464b559a4a94977c15dfb49a Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 2 Apr 2023 20:08:33 -0300 Subject: [PATCH 032/107] chore: change finduser param to query --- .../SocialNetworkProfileController.js | 26 +++++-- src/routes/SocialNetworkRoutes.js | 73 +++++++++++++------ 2 files changed, 68 insertions(+), 31 deletions(-) diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js index bb1f227d..9422f30a 100644 --- a/src/controllers/SocialNetworkProfileController.js +++ b/src/controllers/SocialNetworkProfileController.js @@ -9,7 +9,10 @@ class HelpController { async followUser(req, res, next) { const { selectedProfileId, userId } = req.params; try { - const result = await this.socialNetworkService.followUser(selectedProfileId, userId); + const result = await this.socialNetworkService.followUser( + selectedProfileId, + userId, + ); res.status(200).send(result); next(); } catch (err) { @@ -22,7 +25,10 @@ class HelpController { async unfollowUser(req, res, next) { const { selectedProfileId, userId } = req.params; try { - const result = await this.socialNetworkService.unfollowUser(selectedProfileId, userId); + const result = await this.socialNetworkService.unfollowUser( + selectedProfileId, + userId, + ); res.status(200).send(result); next(); } catch (err) { @@ -32,11 +38,11 @@ class HelpController { } } - async findUsers(req, res, next) { - const { userId, username } = req.params; + const { userId } = req.params; + const { name } = req.query; try { - const result = await this.socialNetworkService.findUsers(userId, username); + const result = await this.socialNetworkService.findUsers(userId, name); res.status(200).json(result); next(); } catch (err) { @@ -62,7 +68,10 @@ class HelpController { async getFollowers(req, res, next) { const { userId, selectedProfileId } = req.params; try { - const result = await this.socialNetworkService.getFollowers(userId, selectedProfileId); + const result = await this.socialNetworkService.getFollowers( + userId, + selectedProfileId, + ); res.status(200).json(result); next(); } catch (err) { @@ -75,7 +84,10 @@ class HelpController { async getFollowing(req, res, next) { const { userId, selectedProfileId } = req.params; try { - const result = await this.socialNetworkService.getFollowing(userId, selectedProfileId); + const result = await this.socialNetworkService.getFollowing( + userId, + selectedProfileId, + ); res.status(200).json(result); next(); } catch (err) { diff --git a/src/routes/SocialNetworkRoutes.js b/src/routes/SocialNetworkRoutes.js index 69689154..382a46b4 100644 --- a/src/routes/SocialNetworkRoutes.js +++ b/src/routes/SocialNetworkRoutes.js @@ -5,35 +5,60 @@ const isAuthenticated = require('../validation/middlewares/authFirebase'); const routes = express.Router(); const socialNetworkProfileController = new SocialNetworkProfileController(); -routes.put('/socialNetworkProfile/followUser/:selectedProfileId/:userId', isAuthenticated, async (req, res, next) => { - socialNetworkProfileController.followUser(req, res, next); -}); +routes.put( + '/socialNetworkProfile/followUser/:selectedProfileId/:userId', + isAuthenticated, + async (req, res, next) => { + socialNetworkProfileController.followUser(req, res, next); + }, +); -routes.put('/socialNetworkProfile/unfollowUser/:selectedProfileId/:userId', isAuthenticated, async (req, res, next) => { - socialNetworkProfileController.unfollowUser(req, res, next); -}); +routes.put( + '/socialNetworkProfile/unfollowUser/:selectedProfileId/:userId', + isAuthenticated, + async (req, res, next) => { + socialNetworkProfileController.unfollowUser(req, res, next); + }, +); +routes.get( + '/socialNetworkProfile/findUsers/:userId', + isAuthenticated, + async (req, res, next) => { + socialNetworkProfileController.findUsers(req, res, next); + }, +); -routes.get('/socialNetworkProfile/findUsers/:userId/:username', isAuthenticated, async (req, res, next) => { - socialNetworkProfileController.findUsers(req, res, next); -}); +routes.get( + '/socialNetworkProfile/getUserActivities/:userId', + isAuthenticated, + async (req, res, next) => { + socialNetworkProfileController.getUserActivities(req, res, next); + }, +); -routes.get('/socialNetworkProfile/getUserActivities/:userId', isAuthenticated, async (req, res, next) => { - socialNetworkProfileController.getUserActivities(req, res, next); -}); +routes.get( + '/socialNetworkProfile/getFollowers/:userId/:selectedProfileId', + isAuthenticated, + async (req, res, next) => { + socialNetworkProfileController.getFollowers(req, res, next); + }, +); -routes.get('/socialNetworkProfile/getFollowers/:userId/:selectedProfileId', isAuthenticated, async (req, res, next) => { - socialNetworkProfileController.getFollowers(req, res, next); -}); - -routes.get('/socialNetworkProfile/getFollowing/:userId/:selectedProfileId', isAuthenticated, async (req, res, next) => { - socialNetworkProfileController.getFollowing(req, res, next); -}); - - -routes.get('/socialNetworkProfile/getUserProfile/:userId', isAuthenticated, async (req, res, next) => { - socialNetworkProfileController.getUserProfile(req, res, next); -}); +routes.get( + '/socialNetworkProfile/getFollowing/:userId/:selectedProfileId', + isAuthenticated, + async (req, res, next) => { + socialNetworkProfileController.getFollowing(req, res, next); + }, +); +routes.get( + '/socialNetworkProfile/getUserProfile/:userId', + isAuthenticated, + async (req, res, next) => { + socialNetworkProfileController.getUserProfile(req, res, next); + }, +); module.exports = routes; From b808a606ddad9734da7334b1400421ce1e5ba418 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 2 Apr 2023 20:09:23 -0300 Subject: [PATCH 033/107] feat: add index in username --- src/models/User.js | 134 +++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 65 deletions(-) diff --git a/src/models/User.js b/src/models/User.js index 8e9447cd..000b1bc8 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -3,79 +3,83 @@ const { cpf } = require('cpf-cnpj-validator'); const Point = require('./Point'); const { riskGroupsEnum } = require('./RiskGroup'); -const userSchema = new mongoose.Schema({ - name: { - type: String, - required: true, - }, - deviceId: { - type: String, - required: false, - }, - email: { - type: String, - required: true, - unique: true, - index: true, - }, - birthday: { - type: Date, - required: true, - }, - cpf: { - type: String, - required: true, - unique: true, - index: true, - validate: { - validator: (v) => cpf.isValid(v), - message: (props) => `${props.value} não é um cpf válido`, +const userSchema = new mongoose.Schema( + { + name: { + type: String, + required: true, + index: true, }, - }, - riskGroup: { - type: [String], - enum: [...Object.keys(riskGroupsEnum)], - }, - photo: { - type: String, - }, - notificationToken: { - type: String, - }, - address: { - cep: { + deviceId: { + type: String, + required: false, + }, + email: { type: String, + required: true, + unique: true, + index: true, }, - number: { - type: Number, + birthday: { + type: Date, + required: true, }, - city: { + cpf: { type: String, + required: true, + unique: true, + index: true, + validate: { + validator: (v) => cpf.isValid(v), + message: (props) => `${props.value} não é um cpf válido`, + }, + }, + riskGroup: { + type: [String], + enum: [...Object.keys(riskGroupsEnum)], }, - state: { + photo: { type: String, }, - complement: String, - }, - ismentalHealthProfessional: { - type: Boolean, - default: false, - }, - location: { - type: Point, - index: '2dsphere', - }, - phone: { - type: String, - }, - registerDate: { - type: Date, - default: Date.now, - }, - active: { - default: true, - type: Boolean, + notificationToken: { + type: String, + }, + address: { + cep: { + type: String, + }, + number: { + type: Number, + }, + city: { + type: String, + }, + state: { + type: String, + }, + complement: String, + }, + ismentalHealthProfessional: { + type: Boolean, + default: false, + }, + location: { + type: Point, + index: '2dsphere', + }, + phone: { + type: String, + }, + registerDate: { + type: Date, + default: Date.now, + }, + active: { + default: true, + type: Boolean, + }, }, -}, { collection: 'user' }); + { collection: 'user' }, +); module.exports = mongoose.model('User', userSchema); From 3c2903edec777f54894e77167086c1674d13d242 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 7 Apr 2023 17:47:37 -0300 Subject: [PATCH 034/107] chore: refact social network repository and add nullable operator --- src/repository/SocialNetworkRepository.js | 134 ++++++++++------------ 1 file changed, 58 insertions(+), 76 deletions(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 0dc66b50..03ea614d 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -1,6 +1,6 @@ -const { ObjectID } = require('mongodb'); -const BaseRepository = require('./BaseRepository'); -const SocialNetworkProfileSchema = require('../models/SocialNetworkProfile'); +const { ObjectID } = require("mongodb"); +const BaseRepository = require("./BaseRepository"); +const SocialNetworkProfileSchema = require("../models/SocialNetworkProfile"); class SocialNetworkRepository extends BaseRepository { constructor() { @@ -22,25 +22,25 @@ class SocialNetworkRepository extends BaseRepository { async findUserProfilebyUserId(id) { const matchQuery = { userId: ObjectID(id) }; const socialNetworkProfileFields = [ - '_id', 'userId', 'username', - 'followers', 'following', + "_id", + "userId", + "username", + "followers", + "following", ]; - return super.$findOne( - matchQuery, - socialNetworkProfileFields, - ); + return super.$findOne(matchQuery, socialNetworkProfileFields); } async findUserProfilebyProfileId(id) { const matchQuery = { _id: ObjectID(id) }; const socialNetworkProfileFields = [ - '_id', 'userId', 'username', - 'followers', 'following', + "_id", + "userId", + "username", + "followers", + "following", ]; - return super.$findOne( - matchQuery, - socialNetworkProfileFields, - ); + return super.$findOne(matchQuery, socialNetworkProfileFields); } async updateProfile(socialNetworkProfile) { @@ -50,62 +50,48 @@ class SocialNetworkRepository extends BaseRepository { async findUsersbyName(userProfileId, userName) { const query = { _id: { $ne: ObjectID(userProfileId) }, - username: { $regex: userName, $options: 'i' }, + username: { $regex: userName, $options: "i" }, }; - const selectField = [ - 'userId', - 'username', - 'followers', - 'following', - ]; + const selectField = ["userId", "username", "followers", "following"]; const populate = { - path: 'user', - select: ['photo'], + path: "user", + select: ["photo"], }; + const users = await super.$list(query, selectField, populate); - const result = await super.$list(query, selectField, populate); - const result2 = result.map((temp) => { - const isFollowing = temp.followers.includes(userProfileId); - const { - _doc: { _id, username, userId }, - $$populatedVirtuals: { user: { photo } }, - numberOfFollowers, numberOfFollowing, - } = temp; - const newDoc = { - _id, - username, - userId, - photo, + const mappedUsers = users.map((queryUser) => { + const isFollowing = queryUser.followers.includes(userProfileId); + const { numberOfFollowers, numberOfFollowing } = queryUser; + const mappedUser = { + _id: queryUser._id, + username: queryUser.username, + userId: queryUser.userId, + photo: queryUser.user?.photo, numberOfFollowers, numberOfFollowing, isFollowing, }; - - return newDoc; + return mappedUser; }); - return result2; + return mappedUsers; } async getUserActivitiesById(id) { const query = { userId: ObjectID(id) }; - const networkProfileFields = [ - '_id', - 'userId', - 'username', - ]; + const networkProfileFields = ["_id", "userId", "username"]; const userHelps = { - path: 'userHelps', - select: ['title', 'description'], + path: "userHelps", + select: ["title", "description"], }; const userOffers = { - path: 'helpsOffers', - select: ['title', 'description'], + path: "helpsOffers", + select: ["title", "description"], }; const populate = [userHelps, userOffers]; @@ -118,31 +104,31 @@ class SocialNetworkRepository extends BaseRepository { const query = { userId: ObjectID(id) }; const networkProfileFields = [ - '_id', - 'userId', - 'username', - 'followers', - 'following', + "_id", + "userId", + "username", + "followers", + "following", ]; const user = { - path: 'user', - select: ['phone', 'name', 'birthday', 'address.city'], + path: "user", + select: ["phone", "name", "birthday", "address.city"], }; const entity = { - path: 'entity', - select: ['phone', 'name', 'address.city'], + path: "entity", + select: ["phone", "name", "address.city"], }; const followers = { - path: 'Followers', - select: ['_id', 'userId', 'username', 'followers', 'following'], + path: "Followers", + select: ["_id", "userId", "username", "followers", "following"], }; const following = { - path: 'Following', - select: ['_id', 'userId', 'username', 'followers', 'following'], + path: "Following", + select: ["_id", "userId", "username", "followers", "following"], }; const populate = [user, followers, following, entity]; @@ -153,17 +139,15 @@ class SocialNetworkRepository extends BaseRepository { async getFollowers(userProfileId, selectedProfileId) { const query = { _id: ObjectID(selectedProfileId) }; - const selectField = [ - 'followers', - ]; + const selectField = ["followers"]; const followers = { - path: 'Followers', + path: "Followers", populate: { - path: 'user', - select: ['photo', 'deviceId'], + path: "user", + select: ["photo", "deviceId"], }, - select: ['userId', 'username', 'followers', 'following'], + select: ["userId", "username", "followers", "following"], }; const populate = [followers]; @@ -187,17 +171,15 @@ class SocialNetworkRepository extends BaseRepository { async getFollowing(userProfileId, selectedProfileId) { const query = { _id: ObjectID(selectedProfileId) }; - const selectField = [ - 'following', - ]; + const selectField = ["following"]; const following = { - path: 'Following', + path: "Following", populate: { - path: 'user', - select: ['photo'], + path: "user", + select: ["photo"], }, - select: ['userId', 'username', 'followers', 'following'], + select: ["userId", "username", "followers", "following"], }; const populate = [following]; From a8d17e6311f37a48e516e3b6796d2445a8cb0f97 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 7 Apr 2023 22:57:05 -0300 Subject: [PATCH 035/107] chore: add photo to user profile return --- src/repository/SocialNetworkRepository.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 03ea614d..2a4c3e16 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -28,7 +28,12 @@ class SocialNetworkRepository extends BaseRepository { "followers", "following", ]; - return super.$findOne(matchQuery, socialNetworkProfileFields); + + const populate = { + path: "user", + select: ["photo"], + }; + return super.$findOne(matchQuery, socialNetworkProfileFields, populate); } async findUserProfilebyProfileId(id) { From a7c8bc9a4fa8320f2f34f9a55877c8273f7e19d8 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 9 Apr 2023 07:47:31 -0300 Subject: [PATCH 036/107] chore: return users cpf --- src/repository/SocialNetworkRepository.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 2a4c3e16..8e2e8af8 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -62,7 +62,7 @@ class SocialNetworkRepository extends BaseRepository { const populate = { path: "user", - select: ["photo"], + select: ["photo", "cnpj", "cpf"], }; const users = await super.$list(query, selectField, populate); @@ -75,6 +75,8 @@ class SocialNetworkRepository extends BaseRepository { username: queryUser.username, userId: queryUser.userId, photo: queryUser.user?.photo, + cpf: queryUser.user?.cpf, + cnpj: queryUser.user?.cnpj, numberOfFollowers, numberOfFollowing, isFollowing, From c013c4d40c92fb9723616ef03c638b76dce31a35 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 9 Apr 2023 07:48:07 -0300 Subject: [PATCH 037/107] chore: return creationdate in getByIdWithAggregation --- src/repository/HelpRepository.js | 129 ++++++++++++++++++------------- 1 file changed, 74 insertions(+), 55 deletions(-) diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index a74cb86f..24a967cb 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -1,8 +1,8 @@ // eslint-disable-next-line import/no-unresolved -const { ObjectID } = require('mongodb'); -const BaseRepository = require('./BaseRepository'); -const HelpSchema = require('../models/Help'); -const getLocation = require('../utils/getLocation'); +const { ObjectID } = require("mongodb"); +const BaseRepository = require("./BaseRepository"); +const HelpSchema = require("../models/Help"); +const getLocation = require("../utils/getLocation"); class HelpRepository extends BaseRepository { constructor() { @@ -13,12 +13,12 @@ class HelpRepository extends BaseRepository { const doc = await super.$save(help); const populate = [ { - path: 'user', - select: ['name', 'riskGroup'], + path: "user", + select: ["name", "riskGroup"], }, { - path: 'categories', - select: ['name'], + path: "categories", + select: ["name"], }, ]; const result = await super.$populateExistingDoc(doc, populate); @@ -41,32 +41,47 @@ class HelpRepository extends BaseRepository { async getByIdWithAggregation(id) { const matchQuery = { _id: ObjectID(id) }; const helpFields = [ - '_id', 'ownerId', 'categoryId', - 'possibleHelpers', 'possibleEntities', - 'description', 'helperId', 'status', 'title', - 'location', + "_id", + "ownerId", + "categoryId", + "possibleHelpers", + "possibleEntities", + "description", + "helperId", + "status", + "title", + "location", + "creationDate", ]; const user = { - path: 'user', - select: ['photo', 'name', 'phone', 'birthday', 'address.city', 'location.coordinates'], + path: "user", + select: [ + "photo", + "name", + "phone", + "birthday", + "address.city", + "location.coordinates", + ], }; const categories = { - path: 'categories', - select: ['_id', 'name'], + path: "categories", + select: ["_id", "name"], }; const possibleHelpers = { - path: 'possibleHelpers', - select: ['_id', 'name', 'phone', 'photo', 'birthday', 'address.city'], + path: "possibleHelpers", + select: ["_id", "name", "phone", "photo", "birthday", "address.city"], }; const possibleEntities = { - path: 'possibleEntities', - select: ['_id', 'name', 'photo', 'address.city'], + path: "possibleEntities", + select: ["_id", "name", "photo", "address.city"], }; - return super.$findOne( - matchQuery, - helpFields, - [user, categories, possibleHelpers, possibleEntities], - ); + return super.$findOne(matchQuery, helpFields, [ + user, + categories, + possibleHelpers, + possibleEntities, + ]); } async update(help) { @@ -77,7 +92,7 @@ class HelpRepository extends BaseRepository { const matchQuery = { active: true, ownerId: { $ne: ObjectID(id) }, - status: 'waiting', + status: "waiting", }; if (isUserEntity) { @@ -91,14 +106,22 @@ class HelpRepository extends BaseRepository { $in: categoryArray.map((categoryString) => ObjectID(categoryString)), }; } - const helpFields = ['_id', 'title', 'description', 'categoryId', 'ownerId', 'creationDate', 'location']; + const helpFields = [ + "_id", + "title", + "description", + "categoryId", + "ownerId", + "creationDate", + "location", + ]; const user = { - path: 'user', - select: ['name', 'riskGroup', 'location.coordinates'], + path: "user", + select: ["name", "riskGroup", "location.coordinates"], }; const categories = { - path: 'categories', - select: ['_id', 'name'], + path: "categories", + select: ["_id", "name"], }; const helps = await super.$list(matchQuery, helpFields, [user, categories]); const helpsWithDistance = helps.map((help) => { @@ -116,7 +139,7 @@ class HelpRepository extends BaseRepository { const query = {}; query.ownerId = id; query.active = true; - query.status = { $ne: 'finished' }; + query.status = { $ne: "finished" }; const result = await super.$countDocuments(query); return result; @@ -141,28 +164,28 @@ class HelpRepository extends BaseRepository { }; const fields = [ - '_id', - 'description', - 'title', - 'status', - 'ownerId', - 'categoryId', + "_id", + "description", + "title", + "status", + "ownerId", + "categoryId", ]; const user = { - path: 'user', - select: ['photo', 'phone', 'name', 'birthday', 'address.city'], + path: "user", + select: ["photo", "phone", "name", "birthday", "address.city"], }; const categories = { - path: 'categories', - select: ['_id', 'name'], + path: "categories", + select: ["_id", "name"], }; const populate = [user, categories]; if (helper) { - user.select.push('location.coordinates'); + user.select.push("location.coordinates"); matchQuery.$or = [ { possibleHelpers: { $in: [ObjectID(userId)] }, @@ -173,16 +196,16 @@ class HelpRepository extends BaseRepository { ]; } else { const possibleHelpers = { - path: 'possibleHelpers', - select: ['_id', 'photo', 'name', 'birthday', 'address.city'], + path: "possibleHelpers", + select: ["_id", "photo", "name", "birthday", "address.city"], }; const possibleEntities = { - path: 'possibleEntities', - select: ['_id', 'photo', 'name', 'birthday', 'address.city'], + path: "possibleEntities", + select: ["_id", "photo", "name", "birthday", "address.city"], }; - fields.push('helperId'); + fields.push("helperId"); populate.push(possibleHelpers); populate.push(possibleEntities); @@ -198,8 +221,8 @@ class HelpRepository extends BaseRepository { const matchQuery = { _id: ObjectID(helpId) }; const populate = { - path: 'user', - select: ['photo', 'birthday', 'address.city'], + path: "user", + select: ["photo", "birthday", "address.city"], }; const projection = { @@ -207,11 +230,7 @@ class HelpRepository extends BaseRepository { _id: 0, }; - return super.$findOne( - matchQuery, - projection, - populate, - ); + return super.$findOne(matchQuery, projection, populate); } } From 31cac1455849510c0b7ed4dbbb5306bf6d74157f Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 15 Apr 2023 11:57:23 -0300 Subject: [PATCH 038/107] refactor: improve social network repository logics --- src/repository/SocialNetworkRepository.js | 62 +++++++---------------- src/utils/mapSocialNetworkUser.js | 18 +++++++ 2 files changed, 36 insertions(+), 44 deletions(-) create mode 100644 src/utils/mapSocialNetworkUser.js diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 8e2e8af8..2ff761b6 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -1,6 +1,7 @@ const { ObjectID } = require("mongodb"); const BaseRepository = require("./BaseRepository"); const SocialNetworkProfileSchema = require("../models/SocialNetworkProfile"); +const mapSocialNetworkUser = require("../utils/mapSocialNetworkUser"); class SocialNetworkRepository extends BaseRepository { constructor() { @@ -67,22 +68,9 @@ class SocialNetworkRepository extends BaseRepository { const users = await super.$list(query, selectField, populate); - const mappedUsers = users.map((queryUser) => { - const isFollowing = queryUser.followers.includes(userProfileId); - const { numberOfFollowers, numberOfFollowing } = queryUser; - const mappedUser = { - _id: queryUser._id, - username: queryUser.username, - userId: queryUser.userId, - photo: queryUser.user?.photo, - cpf: queryUser.user?.cpf, - cnpj: queryUser.user?.cnpj, - numberOfFollowers, - numberOfFollowing, - isFollowing, - }; - return mappedUser; - }); + const mappedUsers = users.map((user) => + mapSocialNetworkUser(user, userProfileId) + ); return mappedUsers; } @@ -154,25 +142,16 @@ class SocialNetworkRepository extends BaseRepository { path: "user", select: ["photo", "deviceId"], }, - select: ["userId", "username", "followers", "following"], + select: ["userId", "username", "followers", "following", "cpf"], }; const populate = [followers]; - let result = await super.$list(query, selectField, populate); - - // permite a adição de novos atributos no resultado - result = JSON.parse(JSON.stringify(result)); - let result2 = 0; - if (result.length > 0) { - result2 = result[0].Followers.map((temp) => { - temp.isFollowing = temp.followers.includes(userProfileId); - temp.photo = temp.user.photo; - delete temp.user; - return temp; - }); - } - - return result2; + const userInfo = await super.$findOne(query, selectField, populate); + if (!userInfo.Followers) return []; + const followersInfo = userInfo.Followers.map((follower) => + mapSocialNetworkUser(follower, userProfileId) + ); + return followersInfo; } async getFollowing(userProfileId, selectedProfileId) { @@ -190,19 +169,14 @@ class SocialNetworkRepository extends BaseRepository { }; const populate = [following]; - let result = await super.$list(query, selectField, populate); - - // permite a adição de novos atributos no resultado - result = JSON.parse(JSON.stringify(result)); - - const result2 = result[0].Following.map((temp) => { - temp.isFollowing = temp.followers.includes(userProfileId); - temp.photo = temp.user.photo; - delete temp.user; - return temp; - }); + const userInfo = await super.$findOne(query, selectField, populate); - return result2; + console.log(userInfo.Following); + if (!userInfo.Following) return []; + const followingInfo = userInfo.Following.map((followed) => + mapSocialNetworkUser(followed, userProfileId) + ); + return followingInfo; } } diff --git a/src/utils/mapSocialNetworkUser.js b/src/utils/mapSocialNetworkUser.js new file mode 100644 index 00000000..09146af7 --- /dev/null +++ b/src/utils/mapSocialNetworkUser.js @@ -0,0 +1,18 @@ +const mapSocialNetworkUser = (socialNetworkUser, userProfileId) => { + const isFollowing = socialNetworkUser.followers.includes(userProfileId); + const { numberOfFollowers, numberOfFollowing } = socialNetworkUser; + const mappedUser = { + _id: socialNetworkUser._id, + username: socialNetworkUser.username, + userId: socialNetworkUser.userId, + photo: socialNetworkUser.user?.photo, + cpf: socialNetworkUser.user?.cpf, + cnpj: socialNetworkUser.user?.cnpj, + numberOfFollowers, + numberOfFollowing, + isFollowing, + }; + return mappedUser; +}; + +module.exports = mapSocialNetworkUser; From e5efd33762c428c0f2a73fde0624f23ffae3171b Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 15 Apr 2023 16:07:27 -0300 Subject: [PATCH 039/107] chore: refact some logics in order to return the right data to front --- .../SocialNetworkProfileController.js | 18 +-- src/services/SocialNetworkService.js | 105 ++++++++++++------ src/utils/mapSocialNetworkUser.js | 5 + 3 files changed, 89 insertions(+), 39 deletions(-) diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js index 9422f30a..08508d28 100644 --- a/src/controllers/SocialNetworkProfileController.js +++ b/src/controllers/SocialNetworkProfileController.js @@ -1,5 +1,5 @@ -const SocialNetworkService = require('../services/SocialNetworkService'); -const saveError = require('../utils/ErrorHistory'); +const SocialNetworkService = require("../services/SocialNetworkService"); +const saveError = require("../utils/ErrorHistory"); class HelpController { constructor() { @@ -11,7 +11,7 @@ class HelpController { try { const result = await this.socialNetworkService.followUser( selectedProfileId, - userId, + userId ); res.status(200).send(result); next(); @@ -27,7 +27,7 @@ class HelpController { try { const result = await this.socialNetworkService.unfollowUser( selectedProfileId, - userId, + userId ); res.status(200).send(result); next(); @@ -70,7 +70,7 @@ class HelpController { try { const result = await this.socialNetworkService.getFollowers( userId, - selectedProfileId, + selectedProfileId ); res.status(200).json(result); next(); @@ -86,7 +86,7 @@ class HelpController { try { const result = await this.socialNetworkService.getFollowing( userId, - selectedProfileId, + selectedProfileId ); res.status(200).json(result); next(); @@ -99,8 +99,12 @@ class HelpController { async getUserProfile(req, res, next) { const { userId } = req.params; + const senderEmail = req.decodedToken.email; try { - const result = await this.socialNetworkService.getUserProfile(userId); + const result = await this.socialNetworkService.getUserProfile( + userId, + senderEmail + ); res.status(200).json(result); next(); } catch (err) { diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index 9ae907ce..576b4fc8 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -1,7 +1,8 @@ -const SocialNetworkRepository = require('../repository/SocialNetworkRepository'); -const HelpRepository = require('../repository/HelpRepository'); -const OfferdHelpRepository = require('../repository/HelpOfferRepository'); - +const SocialNetworkRepository = require("../repository/SocialNetworkRepository"); +const HelpRepository = require("../repository/HelpRepository"); +const OfferdHelpRepository = require("../repository/HelpOfferRepository"); +const UserRepository = require("../repository/UserRepository"); +const mapSocialNetworkUser = require("../utils/mapSocialNetworkUser"); class SocialNetworkService { constructor() { @@ -16,30 +17,34 @@ class SocialNetworkService { userId: createdUser._id, }; - const createdSocialNetworkUser = await this.socialNetworkRepository.create(socialProfileData); + const createdSocialNetworkUser = await this.socialNetworkRepository.create( + socialProfileData + ); return createdSocialNetworkUser; } - async removeSocialNetworkUser(id) { await this.socialNetworkRepository.destroy(id); } - async followUser(selectedProfileId, userId) { - const selectedProfile = await this.socialNetworkRepository.findUserProfilebyProfileId(selectedProfileId); - const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const selectedProfile = + await this.socialNetworkRepository.findUserProfilebyProfileId( + selectedProfileId + ); + const userProfile = + await this.socialNetworkRepository.findUserProfilebyUserId(userId); if (!userProfile) { - throw new Error('User profile not found'); + throw new Error("User profile not found"); } else if (!selectedProfile) { - throw new Error('Selected profile not found'); + throw new Error("Selected profile not found"); } const followerPosition = selectedProfile.followers.indexOf(userProfile._id); const followingPosition = userProfile.following.indexOf(selectedProfileId); if (followerPosition > -1 || followingPosition > -1) { - throw new Error('Usuário já é um seguidor'); + throw new Error("Usuário já é um seguidor"); } selectedProfile.followers.push(userProfile._id); @@ -52,19 +57,23 @@ class SocialNetworkService { } async unfollowUser(selectedProfileId, userId) { - const selectedProfile = await this.socialNetworkRepository.findUserProfilebyProfileId(selectedProfileId); - const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const selectedProfile = + await this.socialNetworkRepository.findUserProfilebyProfileId( + selectedProfileId + ); + const userProfile = + await this.socialNetworkRepository.findUserProfilebyUserId(userId); if (!userProfile) { - throw new Error('User profile not found'); + throw new Error("User profile not found"); } else if (!selectedProfile) { - throw new Error('Selected profile not found'); + throw new Error("Selected profile not found"); } const followerPosition = selectedProfile.followers.indexOf(userProfile._id); const followingPosition = userProfile.following.indexOf(selectedProfileId); if (followerPosition < 0 || followingPosition < 0) { - throw new Error('Usuário não é um seguidor'); + throw new Error("Usuário não é um seguidor"); } selectedProfile.followers.splice(followerPosition, 1); @@ -75,48 +84,80 @@ class SocialNetworkService { return false; } - async findUsers(userId, username) { - const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - const users = await this.socialNetworkRepository.findUsersbyName(userProfile.id, username); + const userProfile = + await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const users = await this.socialNetworkRepository.findUsersbyName( + userProfile.id, + username + ); if (!users) { - throw new Error('Nenhum usuário encontrado'); + throw new Error("Nenhum usuário encontrado"); } return users; } async getUserActivities(userId) { const helper = false; - const statusList = ['waiting', 'on_going', 'finished', 'owner_finished', 'helper_finished']; + const statusList = [ + "waiting", + "on_going", + "finished", + "owner_finished", + "helper_finished", + ]; const getOtherUsers = true; const categoryArray = null; - const helps = await this.helpRepository.getHelpListByStatus(userId, statusList, helper); - const offers = await this.offerdHelpRepository.list(userId, false, categoryArray, getOtherUsers); + const helps = await this.helpRepository.getHelpListByStatus( + userId, + statusList, + helper + ); + const offers = await this.offerdHelpRepository.list( + userId, + false, + categoryArray, + getOtherUsers + ); const activities = { helps, offers }; return activities; } - async getFollowers(userId, selectedProfileId) { - const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - const followers = await this.socialNetworkRepository.getFollowers(userProfile.id, selectedProfileId); + const userProfile = + await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const followers = await this.socialNetworkRepository.getFollowers( + userProfile.id, + selectedProfileId + ); return followers; } async getFollowing(userId, selectedProfileId) { - const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - const following = await this.socialNetworkRepository.getFollowing(userProfile.id, selectedProfileId); + const userProfile = + await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const following = await this.socialNetworkRepository.getFollowing( + userProfile.id, + selectedProfileId + ); return following; } - async getUserProfile(userId) { - const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); - return userProfile; + async getUserProfile(userId, senderEmail) { + const userRepository = new UserRepository(); + const senderUser = await userRepository.getUserByEmail(senderEmail); + const senderProfile = + await this.socialNetworkRepository.findUserProfilebyUserId( + senderUser._id + ); + const userProfile = + await this.socialNetworkRepository.findUserProfilebyUserId(userId); + return mapSocialNetworkUser(userProfile, senderProfile.id); } } diff --git a/src/utils/mapSocialNetworkUser.js b/src/utils/mapSocialNetworkUser.js index 09146af7..7ee02e07 100644 --- a/src/utils/mapSocialNetworkUser.js +++ b/src/utils/mapSocialNetworkUser.js @@ -1,16 +1,21 @@ const mapSocialNetworkUser = (socialNetworkUser, userProfileId) => { const isFollowing = socialNetworkUser.followers.includes(userProfileId); + const followsYou = socialNetworkUser.following.includes(userProfileId); const { numberOfFollowers, numberOfFollowing } = socialNetworkUser; const mappedUser = { _id: socialNetworkUser._id, + id: socialNetworkUser._id, username: socialNetworkUser.username, userId: socialNetworkUser.userId, photo: socialNetworkUser.user?.photo, cpf: socialNetworkUser.user?.cpf, cnpj: socialNetworkUser.user?.cnpj, + followers: socialNetworkUser.followers, + following: socialNetworkUser.following, numberOfFollowers, numberOfFollowing, isFollowing, + followsYou, }; return mappedUser; }; From 62b072ce82856ce5a26d308665f175e8852d60e9 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 15 Apr 2023 16:14:29 -0300 Subject: [PATCH 040/107] chore: fix lint --- .../SocialNetworkProfileController.js | 14 +- src/repository/HelpRepository.js | 126 +++++++++--------- src/repository/SocialNetworkRepository.js | 108 +++++++-------- src/services/SocialNetworkService.js | 85 ++++++------ 4 files changed, 159 insertions(+), 174 deletions(-) diff --git a/src/controllers/SocialNetworkProfileController.js b/src/controllers/SocialNetworkProfileController.js index 08508d28..687a7677 100644 --- a/src/controllers/SocialNetworkProfileController.js +++ b/src/controllers/SocialNetworkProfileController.js @@ -1,5 +1,5 @@ -const SocialNetworkService = require("../services/SocialNetworkService"); -const saveError = require("../utils/ErrorHistory"); +const SocialNetworkService = require('../services/SocialNetworkService'); +const saveError = require('../utils/ErrorHistory'); class HelpController { constructor() { @@ -11,7 +11,7 @@ class HelpController { try { const result = await this.socialNetworkService.followUser( selectedProfileId, - userId + userId, ); res.status(200).send(result); next(); @@ -27,7 +27,7 @@ class HelpController { try { const result = await this.socialNetworkService.unfollowUser( selectedProfileId, - userId + userId, ); res.status(200).send(result); next(); @@ -70,7 +70,7 @@ class HelpController { try { const result = await this.socialNetworkService.getFollowers( userId, - selectedProfileId + selectedProfileId, ); res.status(200).json(result); next(); @@ -86,7 +86,7 @@ class HelpController { try { const result = await this.socialNetworkService.getFollowing( userId, - selectedProfileId + selectedProfileId, ); res.status(200).json(result); next(); @@ -103,7 +103,7 @@ class HelpController { try { const result = await this.socialNetworkService.getUserProfile( userId, - senderEmail + senderEmail, ); res.status(200).json(result); next(); diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index 24a967cb..df31db66 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -1,8 +1,8 @@ // eslint-disable-next-line import/no-unresolved -const { ObjectID } = require("mongodb"); -const BaseRepository = require("./BaseRepository"); -const HelpSchema = require("../models/Help"); -const getLocation = require("../utils/getLocation"); +const { ObjectID } = require('mongodb'); +const BaseRepository = require('./BaseRepository'); +const HelpSchema = require('../models/Help'); +const getLocation = require('../utils/getLocation'); class HelpRepository extends BaseRepository { constructor() { @@ -13,12 +13,12 @@ class HelpRepository extends BaseRepository { const doc = await super.$save(help); const populate = [ { - path: "user", - select: ["name", "riskGroup"], + path: 'user', + select: ['name', 'riskGroup'], }, { - path: "categories", - select: ["name"], + path: 'categories', + select: ['name'], }, ]; const result = await super.$populateExistingDoc(doc, populate); @@ -41,40 +41,40 @@ class HelpRepository extends BaseRepository { async getByIdWithAggregation(id) { const matchQuery = { _id: ObjectID(id) }; const helpFields = [ - "_id", - "ownerId", - "categoryId", - "possibleHelpers", - "possibleEntities", - "description", - "helperId", - "status", - "title", - "location", - "creationDate", + '_id', + 'ownerId', + 'categoryId', + 'possibleHelpers', + 'possibleEntities', + 'description', + 'helperId', + 'status', + 'title', + 'location', + 'creationDate', ]; const user = { - path: "user", + path: 'user', select: [ - "photo", - "name", - "phone", - "birthday", - "address.city", - "location.coordinates", + 'photo', + 'name', + 'phone', + 'birthday', + 'address.city', + 'location.coordinates', ], }; const categories = { - path: "categories", - select: ["_id", "name"], + path: 'categories', + select: ['_id', 'name'], }; const possibleHelpers = { - path: "possibleHelpers", - select: ["_id", "name", "phone", "photo", "birthday", "address.city"], + path: 'possibleHelpers', + select: ['_id', 'name', 'phone', 'photo', 'birthday', 'address.city'], }; const possibleEntities = { - path: "possibleEntities", - select: ["_id", "name", "photo", "address.city"], + path: 'possibleEntities', + select: ['_id', 'name', 'photo', 'address.city'], }; return super.$findOne(matchQuery, helpFields, [ user, @@ -92,7 +92,7 @@ class HelpRepository extends BaseRepository { const matchQuery = { active: true, ownerId: { $ne: ObjectID(id) }, - status: "waiting", + status: 'waiting', }; if (isUserEntity) { @@ -107,21 +107,21 @@ class HelpRepository extends BaseRepository { }; } const helpFields = [ - "_id", - "title", - "description", - "categoryId", - "ownerId", - "creationDate", - "location", + '_id', + 'title', + 'description', + 'categoryId', + 'ownerId', + 'creationDate', + 'location', ]; const user = { - path: "user", - select: ["name", "riskGroup", "location.coordinates"], + path: 'user', + select: ['name', 'riskGroup', 'location.coordinates'], }; const categories = { - path: "categories", - select: ["_id", "name"], + path: 'categories', + select: ['_id', 'name'], }; const helps = await super.$list(matchQuery, helpFields, [user, categories]); const helpsWithDistance = helps.map((help) => { @@ -139,7 +139,7 @@ class HelpRepository extends BaseRepository { const query = {}; query.ownerId = id; query.active = true; - query.status = { $ne: "finished" }; + query.status = { $ne: 'finished' }; const result = await super.$countDocuments(query); return result; @@ -164,28 +164,28 @@ class HelpRepository extends BaseRepository { }; const fields = [ - "_id", - "description", - "title", - "status", - "ownerId", - "categoryId", + '_id', + 'description', + 'title', + 'status', + 'ownerId', + 'categoryId', ]; const user = { - path: "user", - select: ["photo", "phone", "name", "birthday", "address.city"], + path: 'user', + select: ['photo', 'phone', 'name', 'birthday', 'address.city'], }; const categories = { - path: "categories", - select: ["_id", "name"], + path: 'categories', + select: ['_id', 'name'], }; const populate = [user, categories]; if (helper) { - user.select.push("location.coordinates"); + user.select.push('location.coordinates'); matchQuery.$or = [ { possibleHelpers: { $in: [ObjectID(userId)] }, @@ -196,16 +196,16 @@ class HelpRepository extends BaseRepository { ]; } else { const possibleHelpers = { - path: "possibleHelpers", - select: ["_id", "photo", "name", "birthday", "address.city"], + path: 'possibleHelpers', + select: ['_id', 'photo', 'name', 'birthday', 'address.city'], }; const possibleEntities = { - path: "possibleEntities", - select: ["_id", "photo", "name", "birthday", "address.city"], + path: 'possibleEntities', + select: ['_id', 'photo', 'name', 'birthday', 'address.city'], }; - fields.push("helperId"); + fields.push('helperId'); populate.push(possibleHelpers); populate.push(possibleEntities); @@ -221,8 +221,8 @@ class HelpRepository extends BaseRepository { const matchQuery = { _id: ObjectID(helpId) }; const populate = { - path: "user", - select: ["photo", "birthday", "address.city"], + path: 'user', + select: ['photo', 'birthday', 'address.city'], }; const projection = { diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 2ff761b6..8420f751 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -1,7 +1,7 @@ -const { ObjectID } = require("mongodb"); -const BaseRepository = require("./BaseRepository"); -const SocialNetworkProfileSchema = require("../models/SocialNetworkProfile"); -const mapSocialNetworkUser = require("../utils/mapSocialNetworkUser"); +const { ObjectID } = require('mongodb'); +const BaseRepository = require('./BaseRepository'); +const SocialNetworkProfileSchema = require('../models/SocialNetworkProfile'); +const mapSocialNetworkUser = require('../utils/mapSocialNetworkUser'); class SocialNetworkRepository extends BaseRepository { constructor() { @@ -23,16 +23,16 @@ class SocialNetworkRepository extends BaseRepository { async findUserProfilebyUserId(id) { const matchQuery = { userId: ObjectID(id) }; const socialNetworkProfileFields = [ - "_id", - "userId", - "username", - "followers", - "following", + '_id', + 'userId', + 'username', + 'followers', + 'following', ]; const populate = { - path: "user", - select: ["photo"], + path: 'user', + select: ['photo'], }; return super.$findOne(matchQuery, socialNetworkProfileFields, populate); } @@ -40,11 +40,11 @@ class SocialNetworkRepository extends BaseRepository { async findUserProfilebyProfileId(id) { const matchQuery = { _id: ObjectID(id) }; const socialNetworkProfileFields = [ - "_id", - "userId", - "username", - "followers", - "following", + '_id', + 'userId', + 'username', + 'followers', + 'following', ]; return super.$findOne(matchQuery, socialNetworkProfileFields); } @@ -56,37 +56,35 @@ class SocialNetworkRepository extends BaseRepository { async findUsersbyName(userProfileId, userName) { const query = { _id: { $ne: ObjectID(userProfileId) }, - username: { $regex: userName, $options: "i" }, + username: { $regex: userName, $options: 'i' }, }; - const selectField = ["userId", "username", "followers", "following"]; + const selectField = ['userId', 'username', 'followers', 'following']; const populate = { - path: "user", - select: ["photo", "cnpj", "cpf"], + path: 'user', + select: ['photo', 'cnpj', 'cpf'], }; const users = await super.$list(query, selectField, populate); - const mappedUsers = users.map((user) => - mapSocialNetworkUser(user, userProfileId) - ); + const mappedUsers = users.map((user) => mapSocialNetworkUser(user, userProfileId)); return mappedUsers; } async getUserActivitiesById(id) { const query = { userId: ObjectID(id) }; - const networkProfileFields = ["_id", "userId", "username"]; + const networkProfileFields = ['_id', 'userId', 'username']; const userHelps = { - path: "userHelps", - select: ["title", "description"], + path: 'userHelps', + select: ['title', 'description'], }; const userOffers = { - path: "helpsOffers", - select: ["title", "description"], + path: 'helpsOffers', + select: ['title', 'description'], }; const populate = [userHelps, userOffers]; @@ -99,31 +97,31 @@ class SocialNetworkRepository extends BaseRepository { const query = { userId: ObjectID(id) }; const networkProfileFields = [ - "_id", - "userId", - "username", - "followers", - "following", + '_id', + 'userId', + 'username', + 'followers', + 'following', ]; const user = { - path: "user", - select: ["phone", "name", "birthday", "address.city"], + path: 'user', + select: ['phone', 'name', 'birthday', 'address.city'], }; const entity = { - path: "entity", - select: ["phone", "name", "address.city"], + path: 'entity', + select: ['phone', 'name', 'address.city'], }; const followers = { - path: "Followers", - select: ["_id", "userId", "username", "followers", "following"], + path: 'Followers', + select: ['_id', 'userId', 'username', 'followers', 'following'], }; const following = { - path: "Following", - select: ["_id", "userId", "username", "followers", "following"], + path: 'Following', + select: ['_id', 'userId', 'username', 'followers', 'following'], }; const populate = [user, followers, following, entity]; @@ -134,38 +132,36 @@ class SocialNetworkRepository extends BaseRepository { async getFollowers(userProfileId, selectedProfileId) { const query = { _id: ObjectID(selectedProfileId) }; - const selectField = ["followers"]; + const selectField = ['followers']; const followers = { - path: "Followers", + path: 'Followers', populate: { - path: "user", - select: ["photo", "deviceId"], + path: 'user', + select: ['photo', 'deviceId'], }, - select: ["userId", "username", "followers", "following", "cpf"], + select: ['userId', 'username', 'followers', 'following', 'cpf'], }; const populate = [followers]; const userInfo = await super.$findOne(query, selectField, populate); if (!userInfo.Followers) return []; - const followersInfo = userInfo.Followers.map((follower) => - mapSocialNetworkUser(follower, userProfileId) - ); + const followersInfo = userInfo.Followers.map((follower) => mapSocialNetworkUser(follower, userProfileId)); return followersInfo; } async getFollowing(userProfileId, selectedProfileId) { const query = { _id: ObjectID(selectedProfileId) }; - const selectField = ["following"]; + const selectField = ['following']; const following = { - path: "Following", + path: 'Following', populate: { - path: "user", - select: ["photo"], + path: 'user', + select: ['photo'], }, - select: ["userId", "username", "followers", "following"], + select: ['userId', 'username', 'followers', 'following'], }; const populate = [following]; @@ -173,9 +169,7 @@ class SocialNetworkRepository extends BaseRepository { console.log(userInfo.Following); if (!userInfo.Following) return []; - const followingInfo = userInfo.Following.map((followed) => - mapSocialNetworkUser(followed, userProfileId) - ); + const followingInfo = userInfo.Following.map((followed) => mapSocialNetworkUser(followed, userProfileId)); return followingInfo; } } diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index 576b4fc8..e0d16107 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -1,8 +1,8 @@ -const SocialNetworkRepository = require("../repository/SocialNetworkRepository"); -const HelpRepository = require("../repository/HelpRepository"); -const OfferdHelpRepository = require("../repository/HelpOfferRepository"); -const UserRepository = require("../repository/UserRepository"); -const mapSocialNetworkUser = require("../utils/mapSocialNetworkUser"); +const SocialNetworkRepository = require('../repository/SocialNetworkRepository'); +const HelpRepository = require('../repository/HelpRepository'); +const OfferdHelpRepository = require('../repository/HelpOfferRepository'); +const UserRepository = require('../repository/UserRepository'); +const mapSocialNetworkUser = require('../utils/mapSocialNetworkUser'); class SocialNetworkService { constructor() { @@ -18,7 +18,7 @@ class SocialNetworkService { }; const createdSocialNetworkUser = await this.socialNetworkRepository.create( - socialProfileData + socialProfileData, ); return createdSocialNetworkUser; } @@ -28,23 +28,21 @@ class SocialNetworkService { } async followUser(selectedProfileId, userId) { - const selectedProfile = - await this.socialNetworkRepository.findUserProfilebyProfileId( - selectedProfileId - ); - const userProfile = - await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const selectedProfile = await this.socialNetworkRepository.findUserProfilebyProfileId( + selectedProfileId, + ); + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); if (!userProfile) { - throw new Error("User profile not found"); + throw new Error('User profile not found'); } else if (!selectedProfile) { - throw new Error("Selected profile not found"); + throw new Error('Selected profile not found'); } const followerPosition = selectedProfile.followers.indexOf(userProfile._id); const followingPosition = userProfile.following.indexOf(selectedProfileId); if (followerPosition > -1 || followingPosition > -1) { - throw new Error("Usuário já é um seguidor"); + throw new Error('Usuário já é um seguidor'); } selectedProfile.followers.push(userProfile._id); @@ -57,23 +55,21 @@ class SocialNetworkService { } async unfollowUser(selectedProfileId, userId) { - const selectedProfile = - await this.socialNetworkRepository.findUserProfilebyProfileId( - selectedProfileId - ); - const userProfile = - await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const selectedProfile = await this.socialNetworkRepository.findUserProfilebyProfileId( + selectedProfileId, + ); + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); if (!userProfile) { - throw new Error("User profile not found"); + throw new Error('User profile not found'); } else if (!selectedProfile) { - throw new Error("Selected profile not found"); + throw new Error('Selected profile not found'); } const followerPosition = selectedProfile.followers.indexOf(userProfile._id); const followingPosition = userProfile.following.indexOf(selectedProfileId); if (followerPosition < 0 || followingPosition < 0) { - throw new Error("Usuário não é um seguidor"); + throw new Error('Usuário não é um seguidor'); } selectedProfile.followers.splice(followerPosition, 1); @@ -85,15 +81,14 @@ class SocialNetworkService { } async findUsers(userId, username) { - const userProfile = - await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); const users = await this.socialNetworkRepository.findUsersbyName( userProfile.id, - username + username, ); if (!users) { - throw new Error("Nenhum usuário encontrado"); + throw new Error('Nenhum usuário encontrado'); } return users; } @@ -101,11 +96,11 @@ class SocialNetworkService { async getUserActivities(userId) { const helper = false; const statusList = [ - "waiting", - "on_going", - "finished", - "owner_finished", - "helper_finished", + 'waiting', + 'on_going', + 'finished', + 'owner_finished', + 'helper_finished', ]; const getOtherUsers = true; const categoryArray = null; @@ -113,13 +108,13 @@ class SocialNetworkService { const helps = await this.helpRepository.getHelpListByStatus( userId, statusList, - helper + helper, ); const offers = await this.offerdHelpRepository.list( userId, false, categoryArray, - getOtherUsers + getOtherUsers, ); const activities = { helps, offers }; @@ -127,22 +122,20 @@ class SocialNetworkService { } async getFollowers(userId, selectedProfileId) { - const userProfile = - await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); const followers = await this.socialNetworkRepository.getFollowers( userProfile.id, - selectedProfileId + selectedProfileId, ); return followers; } async getFollowing(userId, selectedProfileId) { - const userProfile = - await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); const following = await this.socialNetworkRepository.getFollowing( userProfile.id, - selectedProfileId + selectedProfileId, ); return following; @@ -151,12 +144,10 @@ class SocialNetworkService { async getUserProfile(userId, senderEmail) { const userRepository = new UserRepository(); const senderUser = await userRepository.getUserByEmail(senderEmail); - const senderProfile = - await this.socialNetworkRepository.findUserProfilebyUserId( - senderUser._id - ); - const userProfile = - await this.socialNetworkRepository.findUserProfilebyUserId(userId); + const senderProfile = await this.socialNetworkRepository.findUserProfilebyUserId( + senderUser._id, + ); + const userProfile = await this.socialNetworkRepository.findUserProfilebyUserId(userId); return mapSocialNetworkUser(userProfile, senderProfile.id); } } From 2497a673d804878323d1c1da518a30938f428a2a Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 15 Apr 2023 17:09:18 -0300 Subject: [PATCH 041/107] chore: removing unnecessary console --- src/repository/SocialNetworkRepository.js | 109 +++++++++++----------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 8420f751..bd4b1836 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -1,7 +1,7 @@ -const { ObjectID } = require('mongodb'); -const BaseRepository = require('./BaseRepository'); -const SocialNetworkProfileSchema = require('../models/SocialNetworkProfile'); -const mapSocialNetworkUser = require('../utils/mapSocialNetworkUser'); +const { ObjectID } = require("mongodb"); +const BaseRepository = require("./BaseRepository"); +const SocialNetworkProfileSchema = require("../models/SocialNetworkProfile"); +const mapSocialNetworkUser = require("../utils/mapSocialNetworkUser"); class SocialNetworkRepository extends BaseRepository { constructor() { @@ -23,16 +23,16 @@ class SocialNetworkRepository extends BaseRepository { async findUserProfilebyUserId(id) { const matchQuery = { userId: ObjectID(id) }; const socialNetworkProfileFields = [ - '_id', - 'userId', - 'username', - 'followers', - 'following', + "_id", + "userId", + "username", + "followers", + "following", ]; const populate = { - path: 'user', - select: ['photo'], + path: "user", + select: ["photo"], }; return super.$findOne(matchQuery, socialNetworkProfileFields, populate); } @@ -40,11 +40,11 @@ class SocialNetworkRepository extends BaseRepository { async findUserProfilebyProfileId(id) { const matchQuery = { _id: ObjectID(id) }; const socialNetworkProfileFields = [ - '_id', - 'userId', - 'username', - 'followers', - 'following', + "_id", + "userId", + "username", + "followers", + "following", ]; return super.$findOne(matchQuery, socialNetworkProfileFields); } @@ -56,35 +56,37 @@ class SocialNetworkRepository extends BaseRepository { async findUsersbyName(userProfileId, userName) { const query = { _id: { $ne: ObjectID(userProfileId) }, - username: { $regex: userName, $options: 'i' }, + username: { $regex: userName, $options: "i" }, }; - const selectField = ['userId', 'username', 'followers', 'following']; + const selectField = ["userId", "username", "followers", "following"]; const populate = { - path: 'user', - select: ['photo', 'cnpj', 'cpf'], + path: "user", + select: ["photo", "cnpj", "cpf"], }; const users = await super.$list(query, selectField, populate); - const mappedUsers = users.map((user) => mapSocialNetworkUser(user, userProfileId)); + const mappedUsers = users.map((user) => + mapSocialNetworkUser(user, userProfileId) + ); return mappedUsers; } async getUserActivitiesById(id) { const query = { userId: ObjectID(id) }; - const networkProfileFields = ['_id', 'userId', 'username']; + const networkProfileFields = ["_id", "userId", "username"]; const userHelps = { - path: 'userHelps', - select: ['title', 'description'], + path: "userHelps", + select: ["title", "description"], }; const userOffers = { - path: 'helpsOffers', - select: ['title', 'description'], + path: "helpsOffers", + select: ["title", "description"], }; const populate = [userHelps, userOffers]; @@ -97,31 +99,31 @@ class SocialNetworkRepository extends BaseRepository { const query = { userId: ObjectID(id) }; const networkProfileFields = [ - '_id', - 'userId', - 'username', - 'followers', - 'following', + "_id", + "userId", + "username", + "followers", + "following", ]; const user = { - path: 'user', - select: ['phone', 'name', 'birthday', 'address.city'], + path: "user", + select: ["phone", "name", "birthday", "address.city"], }; const entity = { - path: 'entity', - select: ['phone', 'name', 'address.city'], + path: "entity", + select: ["phone", "name", "address.city"], }; const followers = { - path: 'Followers', - select: ['_id', 'userId', 'username', 'followers', 'following'], + path: "Followers", + select: ["_id", "userId", "username", "followers", "following"], }; const following = { - path: 'Following', - select: ['_id', 'userId', 'username', 'followers', 'following'], + path: "Following", + select: ["_id", "userId", "username", "followers", "following"], }; const populate = [user, followers, following, entity]; @@ -132,44 +134,47 @@ class SocialNetworkRepository extends BaseRepository { async getFollowers(userProfileId, selectedProfileId) { const query = { _id: ObjectID(selectedProfileId) }; - const selectField = ['followers']; + const selectField = ["followers"]; const followers = { - path: 'Followers', + path: "Followers", populate: { - path: 'user', - select: ['photo', 'deviceId'], + path: "user", + select: ["photo", "deviceId"], }, - select: ['userId', 'username', 'followers', 'following', 'cpf'], + select: ["userId", "username", "followers", "following", "cpf"], }; const populate = [followers]; const userInfo = await super.$findOne(query, selectField, populate); if (!userInfo.Followers) return []; - const followersInfo = userInfo.Followers.map((follower) => mapSocialNetworkUser(follower, userProfileId)); + const followersInfo = userInfo.Followers.map((follower) => + mapSocialNetworkUser(follower, userProfileId) + ); return followersInfo; } async getFollowing(userProfileId, selectedProfileId) { const query = { _id: ObjectID(selectedProfileId) }; - const selectField = ['following']; + const selectField = ["following"]; const following = { - path: 'Following', + path: "Following", populate: { - path: 'user', - select: ['photo'], + path: "user", + select: ["photo"], }, - select: ['userId', 'username', 'followers', 'following'], + select: ["userId", "username", "followers", "following"], }; const populate = [following]; const userInfo = await super.$findOne(query, selectField, populate); - console.log(userInfo.Following); if (!userInfo.Following) return []; - const followingInfo = userInfo.Following.map((followed) => mapSocialNetworkUser(followed, userProfileId)); + const followingInfo = userInfo.Following.map((followed) => + mapSocialNetworkUser(followed, userProfileId) + ); return followingInfo; } } From 772a86ae6c59df65187eb9adbbadd4f82c4d538c Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 15 Apr 2023 17:12:34 -0300 Subject: [PATCH 042/107] chore: auto lint of vscode is different of backend lint :poop: --- src/repository/SocialNetworkRepository.js | 108 ++++++++++------------ 1 file changed, 51 insertions(+), 57 deletions(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index bd4b1836..869cc970 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -1,7 +1,7 @@ -const { ObjectID } = require("mongodb"); -const BaseRepository = require("./BaseRepository"); -const SocialNetworkProfileSchema = require("../models/SocialNetworkProfile"); -const mapSocialNetworkUser = require("../utils/mapSocialNetworkUser"); +const { ObjectID } = require('mongodb'); +const BaseRepository = require('./BaseRepository'); +const SocialNetworkProfileSchema = require('../models/SocialNetworkProfile'); +const mapSocialNetworkUser = require('../utils/mapSocialNetworkUser'); class SocialNetworkRepository extends BaseRepository { constructor() { @@ -23,16 +23,16 @@ class SocialNetworkRepository extends BaseRepository { async findUserProfilebyUserId(id) { const matchQuery = { userId: ObjectID(id) }; const socialNetworkProfileFields = [ - "_id", - "userId", - "username", - "followers", - "following", + '_id', + 'userId', + 'username', + 'followers', + 'following', ]; const populate = { - path: "user", - select: ["photo"], + path: 'user', + select: ['photo'], }; return super.$findOne(matchQuery, socialNetworkProfileFields, populate); } @@ -40,11 +40,11 @@ class SocialNetworkRepository extends BaseRepository { async findUserProfilebyProfileId(id) { const matchQuery = { _id: ObjectID(id) }; const socialNetworkProfileFields = [ - "_id", - "userId", - "username", - "followers", - "following", + '_id', + 'userId', + 'username', + 'followers', + 'following', ]; return super.$findOne(matchQuery, socialNetworkProfileFields); } @@ -56,37 +56,35 @@ class SocialNetworkRepository extends BaseRepository { async findUsersbyName(userProfileId, userName) { const query = { _id: { $ne: ObjectID(userProfileId) }, - username: { $regex: userName, $options: "i" }, + username: { $regex: userName, $options: 'i' }, }; - const selectField = ["userId", "username", "followers", "following"]; + const selectField = ['userId', 'username', 'followers', 'following']; const populate = { - path: "user", - select: ["photo", "cnpj", "cpf"], + path: 'user', + select: ['photo', 'cnpj', 'cpf'], }; const users = await super.$list(query, selectField, populate); - const mappedUsers = users.map((user) => - mapSocialNetworkUser(user, userProfileId) - ); + const mappedUsers = users.map((user) => mapSocialNetworkUser(user, userProfileId)); return mappedUsers; } async getUserActivitiesById(id) { const query = { userId: ObjectID(id) }; - const networkProfileFields = ["_id", "userId", "username"]; + const networkProfileFields = ['_id', 'userId', 'username']; const userHelps = { - path: "userHelps", - select: ["title", "description"], + path: 'userHelps', + select: ['title', 'description'], }; const userOffers = { - path: "helpsOffers", - select: ["title", "description"], + path: 'helpsOffers', + select: ['title', 'description'], }; const populate = [userHelps, userOffers]; @@ -99,31 +97,31 @@ class SocialNetworkRepository extends BaseRepository { const query = { userId: ObjectID(id) }; const networkProfileFields = [ - "_id", - "userId", - "username", - "followers", - "following", + '_id', + 'userId', + 'username', + 'followers', + 'following', ]; const user = { - path: "user", - select: ["phone", "name", "birthday", "address.city"], + path: 'user', + select: ['phone', 'name', 'birthday', 'address.city'], }; const entity = { - path: "entity", - select: ["phone", "name", "address.city"], + path: 'entity', + select: ['phone', 'name', 'address.city'], }; const followers = { - path: "Followers", - select: ["_id", "userId", "username", "followers", "following"], + path: 'Followers', + select: ['_id', 'userId', 'username', 'followers', 'following'], }; const following = { - path: "Following", - select: ["_id", "userId", "username", "followers", "following"], + path: 'Following', + select: ['_id', 'userId', 'username', 'followers', 'following'], }; const populate = [user, followers, following, entity]; @@ -134,47 +132,43 @@ class SocialNetworkRepository extends BaseRepository { async getFollowers(userProfileId, selectedProfileId) { const query = { _id: ObjectID(selectedProfileId) }; - const selectField = ["followers"]; + const selectField = ['followers']; const followers = { - path: "Followers", + path: 'Followers', populate: { - path: "user", - select: ["photo", "deviceId"], + path: 'user', + select: ['photo', 'deviceId'], }, - select: ["userId", "username", "followers", "following", "cpf"], + select: ['userId', 'username', 'followers', 'following', 'cpf'], }; const populate = [followers]; const userInfo = await super.$findOne(query, selectField, populate); if (!userInfo.Followers) return []; - const followersInfo = userInfo.Followers.map((follower) => - mapSocialNetworkUser(follower, userProfileId) - ); + const followersInfo = userInfo.Followers.map((follower) => mapSocialNetworkUser(follower, userProfileId)); return followersInfo; } async getFollowing(userProfileId, selectedProfileId) { const query = { _id: ObjectID(selectedProfileId) }; - const selectField = ["following"]; + const selectField = ['following']; const following = { - path: "Following", + path: 'Following', populate: { - path: "user", - select: ["photo"], + path: 'user', + select: ['photo'], }, - select: ["userId", "username", "followers", "following"], + select: ['userId', 'username', 'followers', 'following'], }; const populate = [following]; const userInfo = await super.$findOne(query, selectField, populate); if (!userInfo.Following) return []; - const followingInfo = userInfo.Following.map((followed) => - mapSocialNetworkUser(followed, userProfileId) - ); + const followingInfo = userInfo.Following.map((followed) => mapSocialNetworkUser(followed, userProfileId)); return followingInfo; } } From 580f84d76f314428cae7ddca1624908deb41cb0d Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 15 Apr 2023 17:14:44 -0300 Subject: [PATCH 043/107] chore: update lint version --- .eslintrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 3de4ce5e..7d5c78d2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,7 +12,7 @@ "SharedArrayBuffer": "readonly" }, "parserOptions": { - "ecmaVersion": 2018 + "ecmaVersion": 2020 }, "rules": { "indent": [ From 45954a3ea808c7a205053c53f143b5d6f56f129e Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Thu, 20 Apr 2023 20:04:11 -0300 Subject: [PATCH 044/107] refactor: refact populate logic in aggregation --- src/repository/HelpOfferRepository.js | 28 +++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index e8c055fc..6dc1be43 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -32,28 +32,22 @@ class OfferdHelpRepository extends BaseRepository { 'creationDate', 'location', ]; - const user = { - path: 'user', - select: commomUserFields, - }; + + const userInfo = {user: null, possibleHelpedUsers : null, possibleEntities: null, helpedUsers: null} + + Object.keys(userInfo).forEach(key=> { + userInfo[key] = { + path: key, + select: commomUserFields, + } + }) + const categories = { path: 'categories', select: ['_id', 'name'], }; - const possibleHelpedUsers = { - path: 'possibleHelpedUsers', - select: commomUserFields - }; - const possibleEntities = { - path: 'possibleEntities', - select: commomUserFields, - }; - const helpedUsers = { - path: 'helpedUsers', - select: commomUserFields - }; - const populate = [user, categories, possibleHelpedUsers, possibleEntities, helpedUsers]; + const populate = [userInfo["user"], categories, userInfo["possibleHelpedUsers"], userInfo["possibleEntities"], userInfo["helpedUsers"]]; return super.$findOne(query, helpOfferFields, populate); } From e24f369a86524f8c62df846cd15d087f2b6af38d Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 21 Apr 2023 14:49:39 -0300 Subject: [PATCH 045/107] chore: fix lint --- src/repository/HelpOfferRepository.js | 51 ++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index 6dc1be43..40b21a32 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -17,7 +17,15 @@ class OfferdHelpRepository extends BaseRepository { } async getByIdWithAggregation(id) { - const commomUserFields = ['_id', 'name', 'photo', 'birthday', 'phone', 'address.city', 'address.state'] + const commomUserFields = [ + '_id', + 'name', + 'photo', + 'birthday', + 'phone', + 'address.city', + 'address.state', + ]; const query = { _id: ObjectID(id) }; const helpOfferFields = [ '_id', @@ -33,21 +41,32 @@ class OfferdHelpRepository extends BaseRepository { 'location', ]; - const userInfo = {user: null, possibleHelpedUsers : null, possibleEntities: null, helpedUsers: null} + const userInfo = { + user: null, + possibleHelpedUsers: null, + possibleEntities: null, + helpedUsers: null, + }; - Object.keys(userInfo).forEach(key=> { - userInfo[key] = { + Object.keys(userInfo).forEach((key) => { + userInfo[key] = { path: key, select: commomUserFields, - } - }) + }; + }); const categories = { path: 'categories', select: ['_id', 'name'], }; - const populate = [userInfo["user"], categories, userInfo["possibleHelpedUsers"], userInfo["possibleEntities"], userInfo["helpedUsers"]]; + const populate = [ + userInfo.user, + categories, + userInfo.possibleHelpedUsers, + userInfo.possibleEntities, + userInfo.helpedUsers, + ]; return super.$findOne(query, helpOfferFields, populate); } @@ -59,7 +78,15 @@ class OfferdHelpRepository extends BaseRepository { getOtherUsers, categoryArray, ); - const helpOfferFields = ['_id', 'title', 'categoryId', 'ownerId', 'helpedUserId', 'creationDate', 'location']; + const helpOfferFields = [ + '_id', + 'title', + 'categoryId', + 'ownerId', + 'helpedUserId', + 'creationDate', + 'location', + ]; const sort = { creationDate: -1 }; const user = { path: 'user', @@ -83,7 +110,13 @@ class OfferdHelpRepository extends BaseRepository { return super.$list(matchQuery, helpOfferFields, populate, sort); } - getHelpOfferListQuery(userId, isUserEntity, active, getOtherUsers, categoryArray) { + getHelpOfferListQuery( + userId, + isUserEntity, + active, + getOtherUsers, + categoryArray, + ) { const matchQuery = { active }; if (!getOtherUsers) { matchQuery.ownerId = { $ne: ObjectID(userId) }; From 7693eca6152922f7c3125d93201c682744be260d Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 21 Apr 2023 15:31:09 -0300 Subject: [PATCH 046/107] feat: create initial badge structure --- src/controllers/BadgeController.js | 23 +++++++++++++++++ src/models/Badge.js | 41 ++++++++++++++++++++++++++++++ src/models/BadgeInstance.js | 23 +++++++++++++++++ src/repository/BadgeRepository.js | 25 ++++++++++++++++++ src/routes/BadgeRoutes.js | 11 ++++++++ src/routes/BaseRoutes.js | 13 +++++++++- src/services/BadgeService.js | 16 ++++++++++++ 7 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 src/controllers/BadgeController.js create mode 100644 src/models/Badge.js create mode 100644 src/models/BadgeInstance.js create mode 100644 src/repository/BadgeRepository.js create mode 100644 src/routes/BadgeRoutes.js create mode 100644 src/services/BadgeService.js diff --git a/src/controllers/BadgeController.js b/src/controllers/BadgeController.js new file mode 100644 index 00000000..4bd63287 --- /dev/null +++ b/src/controllers/BadgeController.js @@ -0,0 +1,23 @@ +const BadgeService = require('../services/BadgeService'); +const saveError = require('../utils/ErrorHistory'); + +class BadgeController { + constructor() { + this.BadgeService = new BadgeService(); + } + + async getBadgeList(req, res, next) { + const userId = req.query.userId || null; + try { + const result = await this.BadgeService.getBadgeList(userId); + res.status(200).json(result); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } +} + +module.exports = BadgeController; diff --git a/src/models/Badge.js b/src/models/Badge.js new file mode 100644 index 00000000..0ca2b8cf --- /dev/null +++ b/src/models/Badge.js @@ -0,0 +1,41 @@ +const mongoose = require('mongoose'); + +const badgeSchema = new mongoose.Schema( + { + name: { + type: String, + required: true, + }, + description: { + type: String, + required: true, + }, + iconName: { + type: String, + required: true, + }, + title: { + type: String, + required: true, + }, + neededValue: { + type: Number, + required: true, + }, + rank: { + type: Number, + required: true, + }, + category: { + type: String, + required: true, + }, + nextBadge: { + type: [mongoose.Schema.Types.ObjectId], + ref: 'Badge', + }, + }, + { collection: 'badge' }, +); + +module.exports = mongoose.model('Badge', badgeSchema); diff --git a/src/models/BadgeInstance.js b/src/models/BadgeInstance.js new file mode 100644 index 00000000..61891b16 --- /dev/null +++ b/src/models/BadgeInstance.js @@ -0,0 +1,23 @@ +const mongoose = require('mongoose'); + +const badgeInstanceSchema = new mongoose.Schema( + { + currentValue: { + type: Number, + default: 1, + }, + badge: { + type: [mongoose.Schema.Types.ObjectId], + ref: 'Badge', + required: true, + }, + user: { + type: [mongoose.Schema.Types.ObjectId], + ref: 'User', + required: true, + }, + }, + { collection: 'badgeInstance' }, +); + +module.exports = mongoose.model('BadgeInstance', badgeInstanceSchema); diff --git a/src/repository/BadgeRepository.js b/src/repository/BadgeRepository.js new file mode 100644 index 00000000..48b837e7 --- /dev/null +++ b/src/repository/BadgeRepository.js @@ -0,0 +1,25 @@ +const BaseRepository = require('./BaseRepository'); +const BadgeInstanceSchema = require('../models/BadgeInstance'); + +class BadgeRepository extends BaseRepository { + constructor() { + super(BadgeInstanceSchema); + } + + async getByUserId(userId) { + const result = await super.$findOne({ user: userId }); + return result; + } + + async listByUserId(userId) { + const result = await super.$list({ user: userId }); + return result; + } + + async update(badge) { + const result = await super.$update(badge); + return result; + } +} + +module.exports = BadgeRepository; diff --git a/src/routes/BadgeRoutes.js b/src/routes/BadgeRoutes.js new file mode 100644 index 00000000..4bcac50c --- /dev/null +++ b/src/routes/BadgeRoutes.js @@ -0,0 +1,11 @@ +const express = require('express'); +const BadgeController = require('../controllers/BadgeController'); + +const badgeController = new BadgeController(); +const routes = express.Router(); + +routes.get('/badges', async (req, res, next) => { + badgeController.getBadgeList(req, res, next); +}); + +module.exports = routes; diff --git a/src/routes/BaseRoutes.js b/src/routes/BaseRoutes.js index a1400cdf..a5dd7c99 100644 --- a/src/routes/BaseRoutes.js +++ b/src/routes/BaseRoutes.js @@ -8,10 +8,21 @@ const notificationRoutes = require('./NotificationRoutes'); const helpOfferRoutes = require('./HelpOfferRoutes'); const campaignRoutes = require('./CampaignRoutes'); const socialNetworkRoutes = require('./SocialNetworkRoutes'); +const badgeRoutes = require('./BadgeRoutes'); const swaggerDocument = YAML.load('docs/swagger.yaml'); module.exports = (app) => { app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); - app.use('/api', [userRoutes, helpRoutes, categoryRoutes, notificationRoutes, entityRoutes, helpOfferRoutes, campaignRoutes, socialNetworkRoutes]); + app.use('/api', [ + userRoutes, + helpRoutes, + categoryRoutes, + notificationRoutes, + entityRoutes, + helpOfferRoutes, + campaignRoutes, + socialNetworkRoutes, + badgeRoutes, + ]); }; diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js new file mode 100644 index 00000000..85c4fcbf --- /dev/null +++ b/src/services/BadgeService.js @@ -0,0 +1,16 @@ +const BadgeRepository = require('../repository/BadgeRepository'); + +class BadgeService { + constructor() { + this.BadgeRepository = new BadgeRepository(); + } + + // TODO: Querys parecem idênticas + + async getBadgeList(userId) { + const BadgeList = await this.BadgeRepository.listByUserId(userId); + return BadgeList; + } +} + +module.exports = BadgeService; From 761be8c76b73fd44217563da37f104201c3e6df4 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 21 Apr 2023 16:30:35 -0300 Subject: [PATCH 047/107] chore: update file names --- src/models/Badge.js | 40 ++++++++++------------------------- src/models/BadgeInstance.js | 23 -------------------- src/models/BadgeTemplate.js | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 52 deletions(-) delete mode 100644 src/models/BadgeInstance.js create mode 100644 src/models/BadgeTemplate.js diff --git a/src/models/Badge.js b/src/models/Badge.js index 0ca2b8cf..47252e5c 100644 --- a/src/models/Badge.js +++ b/src/models/Badge.js @@ -1,41 +1,23 @@ -const mongoose = require('mongoose'); +const mongoose = require("mongoose"); const badgeSchema = new mongoose.Schema( { - name: { - type: String, - required: true, - }, - description: { - type: String, - required: true, - }, - iconName: { - type: String, - required: true, - }, - title: { - type: String, - required: true, - }, - neededValue: { + currentValue: { type: Number, - required: true, + default: 1, }, - rank: { - type: Number, - required: true, - }, - category: { - type: String, + template: { + type: [mongoose.Schema.Types.ObjectId], + ref: "BadgeTemplate", required: true, }, - nextBadge: { + user: { type: [mongoose.Schema.Types.ObjectId], - ref: 'Badge', + ref: "User", + required: true, }, }, - { collection: 'badge' }, + { collection: "badge" } ); -module.exports = mongoose.model('Badge', badgeSchema); +module.exports = mongoose.model("Badge", badgeSchema); diff --git a/src/models/BadgeInstance.js b/src/models/BadgeInstance.js deleted file mode 100644 index 61891b16..00000000 --- a/src/models/BadgeInstance.js +++ /dev/null @@ -1,23 +0,0 @@ -const mongoose = require('mongoose'); - -const badgeInstanceSchema = new mongoose.Schema( - { - currentValue: { - type: Number, - default: 1, - }, - badge: { - type: [mongoose.Schema.Types.ObjectId], - ref: 'Badge', - required: true, - }, - user: { - type: [mongoose.Schema.Types.ObjectId], - ref: 'User', - required: true, - }, - }, - { collection: 'badgeInstance' }, -); - -module.exports = mongoose.model('BadgeInstance', badgeInstanceSchema); diff --git a/src/models/BadgeTemplate.js b/src/models/BadgeTemplate.js new file mode 100644 index 00000000..61516322 --- /dev/null +++ b/src/models/BadgeTemplate.js @@ -0,0 +1,42 @@ +const mongoose = require("mongoose"); + +const badgeTemplateSchema = new mongoose.Schema( + { + name: { + type: String, + required: true, + }, + description: { + type: String, + required: true, + }, + iconName: { + type: String, + required: true, + }, + title: { + type: String, + required: true, + }, + neededValue: { + type: Number, + required: true, + }, + rank: { + type: Number, + required: true, + }, + category: { + type: String, + required: true, + enum: ["help", "offer", "share"], + }, + nextBadge: { + type: [mongoose.Schema.Types.ObjectId], + ref: "BadgeTemplate", + }, + }, + { collection: "badgeTemplate" } +); + +module.exports = mongoose.model("BadgeTemplate", badgeTemplateSchema); From 8c5703b244bc606d76e4978e869c131d489d83c6 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 21 Apr 2023 16:31:07 -0300 Subject: [PATCH 048/107] feat: create logic to create badges --- src/repository/BadgeRepository.js | 13 ++++++++---- src/repository/BadgeTemplateRepository.js | 25 +++++++++++++++++++++++ src/services/BadgeService.js | 18 ++++++++++++---- 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 src/repository/BadgeTemplateRepository.js diff --git a/src/repository/BadgeRepository.js b/src/repository/BadgeRepository.js index 48b837e7..0ecc69f7 100644 --- a/src/repository/BadgeRepository.js +++ b/src/repository/BadgeRepository.js @@ -1,9 +1,14 @@ -const BaseRepository = require('./BaseRepository'); -const BadgeInstanceSchema = require('../models/BadgeInstance'); +const BaseRepository = require("./BaseRepository"); +const BadgeSchema = require("../models/Badge"); class BadgeRepository extends BaseRepository { constructor() { - super(BadgeInstanceSchema); + super(BadgeSchema); + } + + async create(badge) { + const result = await super.$save(badge); + return result; } async getByUserId(userId) { @@ -12,7 +17,7 @@ class BadgeRepository extends BaseRepository { } async listByUserId(userId) { - const result = await super.$list({ user: userId }); + const result = await super.$list({ user: userId }, null, "template"); return result; } diff --git a/src/repository/BadgeTemplateRepository.js b/src/repository/BadgeTemplateRepository.js new file mode 100644 index 00000000..6501753c --- /dev/null +++ b/src/repository/BadgeTemplateRepository.js @@ -0,0 +1,25 @@ +const BaseRepository = require("./BaseRepository"); +const badgeTemplateSchema = require("../models/BadgeTemplate"); + +class BadgeTemplateRepository extends BaseRepository { + constructor() { + super(badgeTemplateSchema); + } + + async getById(id) { + const result = await super.$getById(id); + return result; + } + + async listByCategory(category) { + const result = await super.$list({ category: category }); + return result; + } + + async getFirstRankByCategory(category) { + const result = await super.$findOne({ category: category, rank: 1 }); + return result; + } +} + +module.exports = BadgeTemplateRepository; diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index 85c4fcbf..ef7832d0 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -1,15 +1,25 @@ -const BadgeRepository = require('../repository/BadgeRepository'); +const BadgeRepository = require("../repository/BadgeRepository"); +const BadgeTemplateRepository = require("../repository/BadgeTemplateRepository"); class BadgeService { constructor() { this.BadgeRepository = new BadgeRepository(); + this.BadgeTemplateRepository = new BadgeTemplateRepository(); } - // TODO: Querys parecem idênticas + async createBadge(userId, category) { + const referenceBadge = + await this.BadgeTemplateRepository.getFirstRankByCategory(category); + const badge = await this.BadgeRepository.create({ + user: userId, + template: referenceBadge._id, + }); + return badge; + } async getBadgeList(userId) { - const BadgeList = await this.BadgeRepository.listByUserId(userId); - return BadgeList; + const badgeList = await this.BadgeRepository.listByUserId(userId); + return badgeList; } } From 6fb814a6b084de4e18de5c928751a15ef6373654 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 21 Apr 2023 16:54:01 -0300 Subject: [PATCH 049/107] feat: create badges seed --- src/config/database.js | 7 ++++- src/models/Badge.js | 10 +++---- src/models/BadgeTemplate.js | 14 ++++------ src/repository/BadgeRepository.js | 6 ++-- src/repository/BadgeTemplateRepository.js | 8 +++--- src/services/BadgeService.js | 7 ++--- src/utils/seed/BadgeTemplateSeed.js | 28 +++++++++++++++++++ .../seed/mockedInfos/mockedBadgesInfo.js | 28 +++++++++++++++++++ 8 files changed, 82 insertions(+), 26 deletions(-) create mode 100644 src/utils/seed/BadgeTemplateSeed.js create mode 100644 src/utils/seed/mockedInfos/mockedBadgesInfo.js diff --git a/src/config/database.js b/src/config/database.js index c7626547..4eb074fa 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -3,13 +3,17 @@ const CategorySeed = require('../utils/seed/CategorySeed'); const UserSeed = require('../utils/seed/UserSeed'); const HelpSeed = require('../utils/seed/HelpOfferCampaignSeed'); const NotificationSeed = require('../utils/seed/NotificationSeed'); +const BadgeSeed = require('../utils/seed/BadgeTemplateSeed'); const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaDB'; const envType = process.env.NODE_ENV || 'development'; const databaseConnect = async () => { try { - await mongoose.connect(databaseURL, { useNewUrlParser: true, useUnifiedTopology: true }); + await mongoose.connect(databaseURL, { + useNewUrlParser: true, + useUnifiedTopology: true, + }); console.log('Banco de dados conectado!'); mongoose.set('useFindAndModify', false); @@ -19,6 +23,7 @@ const databaseConnect = async () => { await UserSeed(); await HelpSeed(); await NotificationSeed(); + await BadgeSeed(); } } catch (err) { console.log('Não foi possível inicicializar corretamente a base de dados!'); diff --git a/src/models/Badge.js b/src/models/Badge.js index 47252e5c..dee9cbf2 100644 --- a/src/models/Badge.js +++ b/src/models/Badge.js @@ -1,4 +1,4 @@ -const mongoose = require("mongoose"); +const mongoose = require('mongoose'); const badgeSchema = new mongoose.Schema( { @@ -8,16 +8,16 @@ const badgeSchema = new mongoose.Schema( }, template: { type: [mongoose.Schema.Types.ObjectId], - ref: "BadgeTemplate", + ref: 'BadgeTemplate', required: true, }, user: { type: [mongoose.Schema.Types.ObjectId], - ref: "User", + ref: 'User', required: true, }, }, - { collection: "badge" } + { collection: 'badge' }, ); -module.exports = mongoose.model("Badge", badgeSchema); +module.exports = mongoose.model('Badge', badgeSchema); diff --git a/src/models/BadgeTemplate.js b/src/models/BadgeTemplate.js index 61516322..e290c7a0 100644 --- a/src/models/BadgeTemplate.js +++ b/src/models/BadgeTemplate.js @@ -1,4 +1,4 @@ -const mongoose = require("mongoose"); +const mongoose = require('mongoose'); const badgeTemplateSchema = new mongoose.Schema( { @@ -14,10 +14,6 @@ const badgeTemplateSchema = new mongoose.Schema( type: String, required: true, }, - title: { - type: String, - required: true, - }, neededValue: { type: Number, required: true, @@ -29,14 +25,14 @@ const badgeTemplateSchema = new mongoose.Schema( category: { type: String, required: true, - enum: ["help", "offer", "share"], + enum: ['help', 'offer', 'share'], }, nextBadge: { type: [mongoose.Schema.Types.ObjectId], - ref: "BadgeTemplate", + ref: 'BadgeTemplate', }, }, - { collection: "badgeTemplate" } + { collection: 'badgeTemplate' }, ); -module.exports = mongoose.model("BadgeTemplate", badgeTemplateSchema); +module.exports = mongoose.model('BadgeTemplate', badgeTemplateSchema); diff --git a/src/repository/BadgeRepository.js b/src/repository/BadgeRepository.js index 0ecc69f7..66b4a308 100644 --- a/src/repository/BadgeRepository.js +++ b/src/repository/BadgeRepository.js @@ -1,5 +1,5 @@ -const BaseRepository = require("./BaseRepository"); -const BadgeSchema = require("../models/Badge"); +const BaseRepository = require('./BaseRepository'); +const BadgeSchema = require('../models/Badge'); class BadgeRepository extends BaseRepository { constructor() { @@ -17,7 +17,7 @@ class BadgeRepository extends BaseRepository { } async listByUserId(userId) { - const result = await super.$list({ user: userId }, null, "template"); + const result = await super.$list({ user: userId }, null, 'template'); return result; } diff --git a/src/repository/BadgeTemplateRepository.js b/src/repository/BadgeTemplateRepository.js index 6501753c..1a700ba6 100644 --- a/src/repository/BadgeTemplateRepository.js +++ b/src/repository/BadgeTemplateRepository.js @@ -1,5 +1,5 @@ -const BaseRepository = require("./BaseRepository"); -const badgeTemplateSchema = require("../models/BadgeTemplate"); +const BaseRepository = require('./BaseRepository'); +const badgeTemplateSchema = require('../models/BadgeTemplate'); class BadgeTemplateRepository extends BaseRepository { constructor() { @@ -12,12 +12,12 @@ class BadgeTemplateRepository extends BaseRepository { } async listByCategory(category) { - const result = await super.$list({ category: category }); + const result = await super.$list({ category }); return result; } async getFirstRankByCategory(category) { - const result = await super.$findOne({ category: category, rank: 1 }); + const result = await super.$findOne({ category, rank: 1 }); return result; } } diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index ef7832d0..46c3c784 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -1,5 +1,5 @@ -const BadgeRepository = require("../repository/BadgeRepository"); -const BadgeTemplateRepository = require("../repository/BadgeTemplateRepository"); +const BadgeRepository = require('../repository/BadgeRepository'); +const BadgeTemplateRepository = require('../repository/BadgeTemplateRepository'); class BadgeService { constructor() { @@ -8,8 +8,7 @@ class BadgeService { } async createBadge(userId, category) { - const referenceBadge = - await this.BadgeTemplateRepository.getFirstRankByCategory(category); + const referenceBadge = await this.BadgeTemplateRepository.getFirstRankByCategory(category); const badge = await this.BadgeRepository.create({ user: userId, template: referenceBadge._id, diff --git a/src/utils/seed/BadgeTemplateSeed.js b/src/utils/seed/BadgeTemplateSeed.js new file mode 100644 index 00000000..cbd1b004 --- /dev/null +++ b/src/utils/seed/BadgeTemplateSeed.js @@ -0,0 +1,28 @@ +const BadgeTemplate = require('../../models/BadgeTemplate'); +const mockedBadges = require('./mockedInfos/mockedBadgesInfo'); + +const seedBadges = async () => { + try { + await BadgeTemplate.deleteMany({}); + + const badgeCollection = await BadgeTemplate.find(); + + if (badgeCollection.length > 0) { + return; + } + + const badges = mockedBadges.map((badge) => new BadgeTemplate(badge)); + + await BadgeTemplate.deleteMany({}); + + badges.forEach((badge) => { + BadgeTemplate.create(badge); + }); + console.log('Conquistas populadas com sucesso!'); + } catch (error) { + console.log('Não foi possível popular as categorias na base de dados!'); + console.log(error); + } +}; + +module.exports = seedBadges; diff --git a/src/utils/seed/mockedInfos/mockedBadgesInfo.js b/src/utils/seed/mockedInfos/mockedBadgesInfo.js new file mode 100644 index 00000000..eb89bf8e --- /dev/null +++ b/src/utils/seed/mockedInfos/mockedBadgesInfo.js @@ -0,0 +1,28 @@ +const mockedBadges = [ + { + name: 'Ajudante da Comunidade 1', + description: 'Criou uma oferta no aplicativo', + iconName: 'volunteer_activism', + neededValue: 1, + rank: 1, + category: 'offer', + }, + { + name: 'Ajudante da Comunidade 2', + description: 'Criou cinco ofertas no aplicativo', + iconName: 'volunteer_activism', + neededValue: 5, + rank: 2, + category: 'offer', + }, + { + name: 'Ajudante da Comunidade 3', + description: 'Realizou dez ofertas no aplicativo', + iconName: 'volunteer_activism', + neededValue: 5, + rank: 3, + category: 'offer', + }, +]; + +module.exports = mockedBadges; From 26be4a39273da0518550b4d29b8a982bb1ac682d Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 21 Apr 2023 18:08:43 -0300 Subject: [PATCH 050/107] chore: create logic to update or create a new badge --- src/controllers/BadgeController.js | 17 +++++++++++++++++ src/models/Badge.js | 6 +++--- src/models/BadgeTemplate.js | 2 +- src/repository/BadgeRepository.js | 2 +- src/routes/BadgeRoutes.js | 4 ++++ src/services/BadgeService.js | 25 ++++++++++++++++--------- src/utils/seed/BadgeTemplateSeed.js | 2 -- 7 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/controllers/BadgeController.js b/src/controllers/BadgeController.js index 4bd63287..e3998f9b 100644 --- a/src/controllers/BadgeController.js +++ b/src/controllers/BadgeController.js @@ -6,6 +6,23 @@ class BadgeController { this.BadgeService = new BadgeService(); } + async updateOrCreateBadge(req, res, next) { + const { userId, category } = req.body; + + try { + const result = await this.BadgeService.createOrUpdateBadge( + userId, + category, + ); + res.status(201).json(result); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } + async getBadgeList(req, res, next) { const userId = req.query.userId || null; try { diff --git a/src/models/Badge.js b/src/models/Badge.js index dee9cbf2..b4b433f7 100644 --- a/src/models/Badge.js +++ b/src/models/Badge.js @@ -4,15 +4,15 @@ const badgeSchema = new mongoose.Schema( { currentValue: { type: Number, - default: 1, + default: 0, }, template: { - type: [mongoose.Schema.Types.ObjectId], + type: mongoose.Schema.Types.ObjectId, ref: 'BadgeTemplate', required: true, }, user: { - type: [mongoose.Schema.Types.ObjectId], + type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true, }, diff --git a/src/models/BadgeTemplate.js b/src/models/BadgeTemplate.js index e290c7a0..70bbdcc1 100644 --- a/src/models/BadgeTemplate.js +++ b/src/models/BadgeTemplate.js @@ -28,7 +28,7 @@ const badgeTemplateSchema = new mongoose.Schema( enum: ['help', 'offer', 'share'], }, nextBadge: { - type: [mongoose.Schema.Types.ObjectId], + type: mongoose.Schema.Types.ObjectId, ref: 'BadgeTemplate', }, }, diff --git a/src/repository/BadgeRepository.js b/src/repository/BadgeRepository.js index 66b4a308..155fc5fd 100644 --- a/src/repository/BadgeRepository.js +++ b/src/repository/BadgeRepository.js @@ -12,7 +12,7 @@ class BadgeRepository extends BaseRepository { } async getByUserId(userId) { - const result = await super.$findOne({ user: userId }); + const result = await super.$findOne({ user: userId }, null, 'template'); return result; } diff --git a/src/routes/BadgeRoutes.js b/src/routes/BadgeRoutes.js index 4bcac50c..9958485c 100644 --- a/src/routes/BadgeRoutes.js +++ b/src/routes/BadgeRoutes.js @@ -4,6 +4,10 @@ const BadgeController = require('../controllers/BadgeController'); const badgeController = new BadgeController(); const routes = express.Router(); +routes.post('/badges', async (req, res, next) => { + badgeController.updateOrCreateBadge(req, res, next); +}); + routes.get('/badges', async (req, res, next) => { badgeController.getBadgeList(req, res, next); }); diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index 46c3c784..26f056ef 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -1,5 +1,5 @@ -const BadgeRepository = require('../repository/BadgeRepository'); -const BadgeTemplateRepository = require('../repository/BadgeTemplateRepository'); +const BadgeRepository = require("../repository/BadgeRepository"); +const BadgeTemplateRepository = require("../repository/BadgeTemplateRepository"); class BadgeService { constructor() { @@ -7,13 +7,20 @@ class BadgeService { this.BadgeTemplateRepository = new BadgeTemplateRepository(); } - async createBadge(userId, category) { - const referenceBadge = await this.BadgeTemplateRepository.getFirstRankByCategory(category); - const badge = await this.BadgeRepository.create({ - user: userId, - template: referenceBadge._id, - }); - return badge; + async createOrUpdateBadge(userId, category) { + const badges = await this.BadgeRepository.listByUserId(userId); + let badge = badges.find((item) => item.template.category === category); + if (!badge) { + const referenceBadge = + await this.BadgeTemplateRepository.getFirstRankByCategory(category); + badge = await this.BadgeRepository.create({ + user: userId, + template: referenceBadge._id, + }); + } + badge.currentValue += 1; + const updatedBadge = await this.BadgeRepository.update(badge); + return updatedBadge; } async getBadgeList(userId) { diff --git a/src/utils/seed/BadgeTemplateSeed.js b/src/utils/seed/BadgeTemplateSeed.js index cbd1b004..8acea62b 100644 --- a/src/utils/seed/BadgeTemplateSeed.js +++ b/src/utils/seed/BadgeTemplateSeed.js @@ -3,8 +3,6 @@ const mockedBadges = require('./mockedInfos/mockedBadgesInfo'); const seedBadges = async () => { try { - await BadgeTemplate.deleteMany({}); - const badgeCollection = await BadgeTemplate.find(); if (badgeCollection.length > 0) { From eecd09a65417e442b5eb8379eaead32de9a05fa8 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 21 Apr 2023 18:39:22 -0300 Subject: [PATCH 051/107] feat: create logic to update badge reference --- src/controllers/BadgeController.js | 8 +++++++- src/repository/BadgeRepository.js | 15 +++++++++++++-- src/services/BadgeService.js | 13 +++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/controllers/BadgeController.js b/src/controllers/BadgeController.js index e3998f9b..dedc0a36 100644 --- a/src/controllers/BadgeController.js +++ b/src/controllers/BadgeController.js @@ -10,10 +10,16 @@ class BadgeController { const { userId, category } = req.body; try { - const result = await this.BadgeService.createOrUpdateBadge( + let result = await this.BadgeService.createOrUpdateBadge( userId, category, ); + if ( + result.template.nextBadge + && result.currentValue >= result.template.nextBadge.neededValue + ) { + result = await this.BadgeService.updateBadgeReference(result); + } res.status(201).json(result); next(); } catch (err) { diff --git a/src/repository/BadgeRepository.js b/src/repository/BadgeRepository.js index 155fc5fd..56bf1b7e 100644 --- a/src/repository/BadgeRepository.js +++ b/src/repository/BadgeRepository.js @@ -4,6 +4,13 @@ const BadgeSchema = require('../models/Badge'); class BadgeRepository extends BaseRepository { constructor() { super(BadgeSchema); + this.populateData = { + path: 'template', + populate: { + path: 'nextBadge', + model: 'BadgeTemplate', + }, + }; } async create(badge) { @@ -12,12 +19,16 @@ class BadgeRepository extends BaseRepository { } async getByUserId(userId) { - const result = await super.$findOne({ user: userId }, null, 'template'); + const result = await super.$findOne( + { user: userId }, + null, + this.populateData, + ); return result; } async listByUserId(userId) { - const result = await super.$list({ user: userId }, null, 'template'); + const result = await super.$list({ user: userId }, null, this.populateData); return result; } diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index 26f056ef..39cbfa1d 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -1,5 +1,5 @@ -const BadgeRepository = require("../repository/BadgeRepository"); -const BadgeTemplateRepository = require("../repository/BadgeTemplateRepository"); +const BadgeRepository = require('../repository/BadgeRepository'); +const BadgeTemplateRepository = require('../repository/BadgeTemplateRepository'); class BadgeService { constructor() { @@ -11,8 +11,7 @@ class BadgeService { const badges = await this.BadgeRepository.listByUserId(userId); let badge = badges.find((item) => item.template.category === category); if (!badge) { - const referenceBadge = - await this.BadgeTemplateRepository.getFirstRankByCategory(category); + const referenceBadge = await this.BadgeTemplateRepository.getFirstRankByCategory(category); badge = await this.BadgeRepository.create({ user: userId, template: referenceBadge._id, @@ -23,6 +22,12 @@ class BadgeService { return updatedBadge; } + async updateBadgeReference(badge) { + badge.template = badge.template.nextBadge; + const updatedBadge = await this.BadgeRepository.update(badge); + return updatedBadge; + } + async getBadgeList(userId) { const badgeList = await this.BadgeRepository.listByUserId(userId); return badgeList; From 33565f794ffe93e78f1f8770e3cf9ca4fc37ae5e Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 22 Apr 2023 10:23:30 -0300 Subject: [PATCH 052/107] feat: create logic to get badge history --- src/controllers/BadgeController.js | 14 +++++++++++ src/models/BadgeTemplate.js | 2 +- src/repository/BadgeTemplateRepository.js | 9 +++++++ src/routes/BadgeRoutes.js | 4 ++++ src/services/BadgeService.js | 5 ++++ .../seed/mockedInfos/mockedBadgesInfo.js | 24 +++++++++++++++++++ 6 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/controllers/BadgeController.js b/src/controllers/BadgeController.js index dedc0a36..e9b89a3c 100644 --- a/src/controllers/BadgeController.js +++ b/src/controllers/BadgeController.js @@ -41,6 +41,20 @@ class BadgeController { next(); } } + + async getBadgeHistory(req, res, next) { + const userId = req.query.userId || null; + try { + const userBadges = await this.BadgeService.getBadgeList(userId); + const allBadges = await this.BadgeService.getAllBadges(); + res.status(200).json({ userBadges, allBadges }); + next(); + } catch (err) { + saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } } module.exports = BadgeController; diff --git a/src/models/BadgeTemplate.js b/src/models/BadgeTemplate.js index 70bbdcc1..2a7b1385 100644 --- a/src/models/BadgeTemplate.js +++ b/src/models/BadgeTemplate.js @@ -25,7 +25,7 @@ const badgeTemplateSchema = new mongoose.Schema( category: { type: String, required: true, - enum: ['help', 'offer', 'share'], + enum: ['help', 'offer', 'share', 'tester'], }, nextBadge: { type: mongoose.Schema.Types.ObjectId, diff --git a/src/repository/BadgeTemplateRepository.js b/src/repository/BadgeTemplateRepository.js index 1a700ba6..9781c60c 100644 --- a/src/repository/BadgeTemplateRepository.js +++ b/src/repository/BadgeTemplateRepository.js @@ -20,6 +20,15 @@ class BadgeTemplateRepository extends BaseRepository { const result = await super.$findOne({ category, rank: 1 }); return result; } + + async listAllSorted() { + const sort = { + category: 1, + rank: 1, + }; + const result = await super.$list({}, null, null, sort); + return result; + } } module.exports = BadgeTemplateRepository; diff --git a/src/routes/BadgeRoutes.js b/src/routes/BadgeRoutes.js index 9958485c..1d190900 100644 --- a/src/routes/BadgeRoutes.js +++ b/src/routes/BadgeRoutes.js @@ -12,4 +12,8 @@ routes.get('/badges', async (req, res, next) => { badgeController.getBadgeList(req, res, next); }); +routes.get('/badges/history', async (req, res, next) => { + badgeController.getBadgeHistory(req, res, next); +}); + module.exports = routes; diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index 39cbfa1d..77707479 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -32,6 +32,11 @@ class BadgeService { const badgeList = await this.BadgeRepository.listByUserId(userId); return badgeList; } + + async getAllBadges() { + const badges = this.BadgeTemplateRepository.listAllSorted(); + return badges; + } } module.exports = BadgeService; diff --git a/src/utils/seed/mockedInfos/mockedBadgesInfo.js b/src/utils/seed/mockedInfos/mockedBadgesInfo.js index eb89bf8e..a632a428 100644 --- a/src/utils/seed/mockedInfos/mockedBadgesInfo.js +++ b/src/utils/seed/mockedInfos/mockedBadgesInfo.js @@ -1,4 +1,12 @@ const mockedBadges = [ + { + name: 'Testador Beta 1', + description: 'Paritcipou do beta do app', + iconName: 'volunteer_activism', + neededValue: 1, + rank: 1, + category: 'tester', + }, { name: 'Ajudante da Comunidade 1', description: 'Criou uma oferta no aplicativo', @@ -23,6 +31,22 @@ const mockedBadges = [ rank: 3, category: 'offer', }, + { + name: 'Testador Beta 3', + description: 'Paritcipou do beta do app', + iconName: 'volunteer_activism', + neededValue: 15, + rank: 3, + category: 'tester', + }, + { + name: 'Testador Beta 2', + description: 'Paritcipou do beta do app', + iconName: 'volunteer_activism', + neededValue: 5, + rank: 2, + category: 'tester', + }, ]; module.exports = mockedBadges; From 6573a16fbe7d0c1b15adcae883f6f33ae021b66a Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 22 Apr 2023 12:01:56 -0300 Subject: [PATCH 053/107] chore: fix iconnames in mocked badge --- src/utils/seed/mockedInfos/mockedBadgesInfo.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/seed/mockedInfos/mockedBadgesInfo.js b/src/utils/seed/mockedInfos/mockedBadgesInfo.js index a632a428..28c16f2b 100644 --- a/src/utils/seed/mockedInfos/mockedBadgesInfo.js +++ b/src/utils/seed/mockedInfos/mockedBadgesInfo.js @@ -2,7 +2,7 @@ const mockedBadges = [ { name: 'Testador Beta 1', description: 'Paritcipou do beta do app', - iconName: 'volunteer_activism', + iconName: 'home', neededValue: 1, rank: 1, category: 'tester', @@ -10,7 +10,7 @@ const mockedBadges = [ { name: 'Ajudante da Comunidade 1', description: 'Criou uma oferta no aplicativo', - iconName: 'volunteer_activism', + iconName: 'volunteer-activism', neededValue: 1, rank: 1, category: 'offer', @@ -18,7 +18,7 @@ const mockedBadges = [ { name: 'Ajudante da Comunidade 2', description: 'Criou cinco ofertas no aplicativo', - iconName: 'volunteer_activism', + iconName: 'volunteer-activism', neededValue: 5, rank: 2, category: 'offer', @@ -26,7 +26,7 @@ const mockedBadges = [ { name: 'Ajudante da Comunidade 3', description: 'Realizou dez ofertas no aplicativo', - iconName: 'volunteer_activism', + iconName: 'volunteer-activism', neededValue: 5, rank: 3, category: 'offer', @@ -34,7 +34,7 @@ const mockedBadges = [ { name: 'Testador Beta 3', description: 'Paritcipou do beta do app', - iconName: 'volunteer_activism', + iconName: 'home', neededValue: 15, rank: 3, category: 'tester', @@ -42,7 +42,7 @@ const mockedBadges = [ { name: 'Testador Beta 2', description: 'Paritcipou do beta do app', - iconName: 'volunteer_activism', + iconName: 'home', neededValue: 5, rank: 2, category: 'tester', From 31d3fe6107fc4eab74e25052e6a7b090ac7bdffa Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 23 Apr 2023 18:51:50 -0300 Subject: [PATCH 054/107] chore: create logic to parse badges by category --- src/services/BadgeService.js | 5 +++-- src/utils/parseBadgeByCategory.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/utils/parseBadgeByCategory.js diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index 77707479..7ace92c2 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -1,5 +1,6 @@ const BadgeRepository = require('../repository/BadgeRepository'); const BadgeTemplateRepository = require('../repository/BadgeTemplateRepository'); +const parseBadgeByCategory = require('../utils/parseBadgeByCategory'); class BadgeService { constructor() { @@ -34,8 +35,8 @@ class BadgeService { } async getAllBadges() { - const badges = this.BadgeTemplateRepository.listAllSorted(); - return badges; + const badges = await this.BadgeTemplateRepository.listAllSorted(); + return parseBadgeByCategory(badges); } } diff --git a/src/utils/parseBadgeByCategory.js b/src/utils/parseBadgeByCategory.js new file mode 100644 index 00000000..6ee3585b --- /dev/null +++ b/src/utils/parseBadgeByCategory.js @@ -0,0 +1,17 @@ +const parseBadgeByCategory = (badgeList) => { + const parsedBadges = badgeList.reduce((obj, current) => { + const { category } = current; + console.log(Object.keys(obj)); + if (!Object.keys(obj).includes(category)) { + obj[category] = { + badges: [], + title: current.name.split(' ').slice(0, -1).join(' '), + }; + } + obj[category].badges.push(current); + return obj; + }, {}); + return parsedBadges; +}; + +module.exports = parseBadgeByCategory; From 869ac70896a624c18f954907448a5ddf280a3d53 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 23 Apr 2023 19:22:38 -0300 Subject: [PATCH 055/107] chore: removing console.log --- src/utils/parseBadgeByCategory.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/parseBadgeByCategory.js b/src/utils/parseBadgeByCategory.js index 6ee3585b..aed0e31c 100644 --- a/src/utils/parseBadgeByCategory.js +++ b/src/utils/parseBadgeByCategory.js @@ -1,7 +1,6 @@ const parseBadgeByCategory = (badgeList) => { const parsedBadges = badgeList.reduce((obj, current) => { const { category } = current; - console.log(Object.keys(obj)); if (!Object.keys(obj).includes(category)) { obj[category] = { badges: [], From 2ab9c684e725df460bf374d6b5b6a1f854cdaa2b Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 23 Apr 2023 19:43:25 -0300 Subject: [PATCH 056/107] chore: change badge ids to number to make the logic easier --- src/models/Badge.js | 2 +- src/models/BadgeTemplate.js | 6 ++- .../seed/mockedInfos/mockedBadgesInfo.js | 46 +++++++++++-------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/models/Badge.js b/src/models/Badge.js index b4b433f7..76cef641 100644 --- a/src/models/Badge.js +++ b/src/models/Badge.js @@ -7,7 +7,7 @@ const badgeSchema = new mongoose.Schema( default: 0, }, template: { - type: mongoose.Schema.Types.ObjectId, + type: Number, ref: 'BadgeTemplate', required: true, }, diff --git a/src/models/BadgeTemplate.js b/src/models/BadgeTemplate.js index 2a7b1385..b927b2d8 100644 --- a/src/models/BadgeTemplate.js +++ b/src/models/BadgeTemplate.js @@ -2,6 +2,10 @@ const mongoose = require('mongoose'); const badgeTemplateSchema = new mongoose.Schema( { + _id: { + type: Number, + required: true, + }, name: { type: String, required: true, @@ -28,7 +32,7 @@ const badgeTemplateSchema = new mongoose.Schema( enum: ['help', 'offer', 'share', 'tester'], }, nextBadge: { - type: mongoose.Schema.Types.ObjectId, + type: Number, ref: 'BadgeTemplate', }, }, diff --git a/src/utils/seed/mockedInfos/mockedBadgesInfo.js b/src/utils/seed/mockedInfos/mockedBadgesInfo.js index 28c16f2b..a02df62f 100644 --- a/src/utils/seed/mockedInfos/mockedBadgesInfo.js +++ b/src/utils/seed/mockedInfos/mockedBadgesInfo.js @@ -1,51 +1,61 @@ const mockedBadges = [ { - name: 'Testador Beta 1', - description: 'Paritcipou do beta do app', - iconName: 'home', - neededValue: 1, - rank: 1, - category: 'tester', - }, - { - name: 'Ajudante da Comunidade 1', - description: 'Criou uma oferta no aplicativo', + _id: 3, + name: 'Ajudante da Comunidade 3', + description: 'Realizou dez ofertas no aplicativo', iconName: 'volunteer-activism', - neededValue: 1, - rank: 1, + neededValue: 5, + rank: 3, category: 'offer', }, { + _id: 2, name: 'Ajudante da Comunidade 2', description: 'Criou cinco ofertas no aplicativo', iconName: 'volunteer-activism', neededValue: 5, rank: 2, category: 'offer', + nextBadge: 3, }, { - name: 'Ajudante da Comunidade 3', - description: 'Realizou dez ofertas no aplicativo', + _id: 1, + name: 'Ajudante da Comunidade 1', + description: 'Criou uma oferta no aplicativo', iconName: 'volunteer-activism', - neededValue: 5, - rank: 3, + neededValue: 1, + rank: 1, category: 'offer', + nextBadge: 2, }, { + _id: 6, name: 'Testador Beta 3', description: 'Paritcipou do beta do app', iconName: 'home', - neededValue: 15, + neededValue: 5, rank: 3, category: 'tester', }, { + _id: 5, name: 'Testador Beta 2', description: 'Paritcipou do beta do app', iconName: 'home', - neededValue: 5, + neededValue: 3, rank: 2, category: 'tester', + nextBadge: 6, + }, + { + _id: 4, + name: 'Testador Beta 1', + description: 'Paritcipou do beta do app', + iconName: 'home', + neededValue: 1, + rank: 1, + category: 'tester', + nextBadge: 5, }, ]; From 27df25ee77d0f2fa6eba5d4abe249cc5ac1d7c44 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 23 Apr 2023 20:24:50 -0300 Subject: [PATCH 057/107] chore: create a new badge parser --- src/controllers/BadgeController.js | 4 +++- src/services/BadgeService.js | 4 ++-- src/utils/parseBadgeByCategory.js | 12 ++++-------- src/utils/parseBadgeTemplateByCategory.js | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 src/utils/parseBadgeTemplateByCategory.js diff --git a/src/controllers/BadgeController.js b/src/controllers/BadgeController.js index e9b89a3c..b349e6d7 100644 --- a/src/controllers/BadgeController.js +++ b/src/controllers/BadgeController.js @@ -1,5 +1,6 @@ const BadgeService = require('../services/BadgeService'); const saveError = require('../utils/ErrorHistory'); +const parseBadgeByCategory = require('../utils/parseBadgeByCategory'); class BadgeController { constructor() { @@ -47,7 +48,8 @@ class BadgeController { try { const userBadges = await this.BadgeService.getBadgeList(userId); const allBadges = await this.BadgeService.getAllBadges(); - res.status(200).json({ userBadges, allBadges }); + const parsedUserBadges = parseBadgeByCategory(userBadges); + res.status(200).json({ userBadges: parsedUserBadges, allBadges }); next(); } catch (err) { saveError(err); diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index 7ace92c2..9d220301 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -1,6 +1,6 @@ const BadgeRepository = require('../repository/BadgeRepository'); const BadgeTemplateRepository = require('../repository/BadgeTemplateRepository'); -const parseBadgeByCategory = require('../utils/parseBadgeByCategory'); +const parseBadgeTemplateByCategory = require('../utils/parseBadgeTemplateByCategory'); class BadgeService { constructor() { @@ -36,7 +36,7 @@ class BadgeService { async getAllBadges() { const badges = await this.BadgeTemplateRepository.listAllSorted(); - return parseBadgeByCategory(badges); + return parseBadgeTemplateByCategory(badges); } } diff --git a/src/utils/parseBadgeByCategory.js b/src/utils/parseBadgeByCategory.js index aed0e31c..fff45e55 100644 --- a/src/utils/parseBadgeByCategory.js +++ b/src/utils/parseBadgeByCategory.js @@ -1,13 +1,9 @@ const parseBadgeByCategory = (badgeList) => { const parsedBadges = badgeList.reduce((obj, current) => { - const { category } = current; - if (!Object.keys(obj).includes(category)) { - obj[category] = { - badges: [], - title: current.name.split(' ').slice(0, -1).join(' '), - }; - } - obj[category].badges.push(current); + const { category } = current.template; + obj[category] = { + badge: current, + }; return obj; }, {}); return parsedBadges; diff --git a/src/utils/parseBadgeTemplateByCategory.js b/src/utils/parseBadgeTemplateByCategory.js new file mode 100644 index 00000000..b02e0ceb --- /dev/null +++ b/src/utils/parseBadgeTemplateByCategory.js @@ -0,0 +1,16 @@ +const parseBadgeTemplateByCategory = (badgeList) => { + const parsedBadges = badgeList.reduce((obj, current) => { + const { category } = current; + if (!Object.keys(obj).includes(category)) { + obj[category] = { + badges: [], + title: current.name.split(' ').slice(0, -1).join(' '), + }; + } + obj[category].badges.push(current); + return obj; + }, {}); + return parsedBadges; +}; + +module.exports = parseBadgeTemplateByCategory; From f37ec508e8db5f9f6f3cc389e7f64c524e05a3c7 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 29 Apr 2023 09:45:49 -0300 Subject: [PATCH 058/107] chore: add biography to user model and to edit user route --- src/controllers/UserController.js | 1 + src/models/User.js | 4 ++++ src/repository/SocialNetworkRepository.js | 2 +- src/services/UserService.js | 11 +++++++++-- src/utils/mapSocialNetworkUser.js | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/controllers/UserController.js b/src/controllers/UserController.js index 231db5fb..47e770e4 100644 --- a/src/controllers/UserController.js +++ b/src/controllers/UserController.js @@ -33,6 +33,7 @@ class UserController { notificationToken: req.body.notificationToken, deviceId: req.body.deviceId, address: req.body.address, + biography: req.body.biography, }; try { const result = await this.userService.editUserById(data); diff --git a/src/models/User.js b/src/models/User.js index 000b1bc8..bc1ca358 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -78,6 +78,10 @@ const userSchema = new mongoose.Schema( default: true, type: Boolean, }, + biography: { + type: String, + default: '-', + }, }, { collection: 'user' }, ); diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 869cc970..93278844 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -32,7 +32,7 @@ class SocialNetworkRepository extends BaseRepository { const populate = { path: 'user', - select: ['photo'], + select: ['photo', 'biography'], }; return super.$findOne(matchQuery, socialNetworkProfileFields, populate); } diff --git a/src/services/UserService.js b/src/services/UserService.js index 4a2a4ba6..95f4c163 100644 --- a/src/services/UserService.js +++ b/src/services/UserService.js @@ -44,7 +44,9 @@ class UserService { }) .catch(async (err) => { await this.removeUser(data.email); - await this.socialNetworkService.removeSocialNetworkUser(createdSocialNetworkUser._id); + await this.socialNetworkService.removeSocialNetworkUser( + createdSocialNetworkUser._id, + ); throw err; }); } @@ -105,6 +107,7 @@ class UserService { notificationToken, address, deviceId, + biography, }) { const user = await this.getUser({ email }); @@ -113,6 +116,7 @@ class UserService { user.phone = phone || user.phone; user.notificationToken = notificationToken || user.notificationToken; user.address = address || user.address; + user.biography = biography || user.biography; user.deviceId = deviceId || user.deviceId; const result = await this.userRepository.update(user); @@ -181,7 +185,10 @@ class UserService { async findOneUserWithProjection(userId, projection) { const query = { _id: ObjectID(userId) }; - const user = await this.userRepository.findOneUserWithProjection(query, projection); + const user = await this.userRepository.findOneUserWithProjection( + query, + projection, + ); return user; } diff --git a/src/utils/mapSocialNetworkUser.js b/src/utils/mapSocialNetworkUser.js index 7ee02e07..a84d25b1 100644 --- a/src/utils/mapSocialNetworkUser.js +++ b/src/utils/mapSocialNetworkUser.js @@ -10,6 +10,7 @@ const mapSocialNetworkUser = (socialNetworkUser, userProfileId) => { photo: socialNetworkUser.user?.photo, cpf: socialNetworkUser.user?.cpf, cnpj: socialNetworkUser.user?.cnpj, + biography: socialNetworkUser.user?.biography, followers: socialNetworkUser.followers, following: socialNetworkUser.following, numberOfFollowers, From 80a5cd3b4f1a8e83604c9d02e4e38d311a242068 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 29 Apr 2023 14:37:53 -0300 Subject: [PATCH 059/107] chore: add biography to entity model and to edit entity route --- src/controllers/EntityController.js | 5 +- src/models/Entity.js | 113 +++++++++++++++------------- src/services/EntityService.js | 11 ++- 3 files changed, 73 insertions(+), 56 deletions(-) diff --git a/src/controllers/EntityController.js b/src/controllers/EntityController.js index 7255d5d8..7f8a9e56 100644 --- a/src/controllers/EntityController.js +++ b/src/controllers/EntityController.js @@ -32,6 +32,7 @@ class EntityController { notificationToken: req.body.notificationToken, deviceId: req.body.deviceId, address: req.body.address, + biography: req.body.biography, }; try { const result = await this.entityService.editEntityById(data); @@ -122,7 +123,9 @@ class EntityController { } try { - const result = await this.entityService.checkEntityExistence(entityIdentifier); + const result = await this.entityService.checkEntityExistence( + entityIdentifier, + ); res.status(200).json(result); next(); } catch (err) { diff --git a/src/models/Entity.js b/src/models/Entity.js index 2f0196e6..e744c3a6 100644 --- a/src/models/Entity.js +++ b/src/models/Entity.js @@ -2,67 +2,74 @@ const mongoose = require('mongoose'); const { cnpj } = require('cpf-cnpj-validator'); const Point = require('./Point'); -const entitySchema = new mongoose.Schema({ - name: { - type: String, - required: true, - }, - deviceId: { - type: String, - required: false, - }, - email: { - type: String, - required: true, - unique: true, - index: true, - }, - cnpj: { - type: String, - required: true, - unique: true, - index: true, - validate: { - validator: (v) => cnpj.isValid(v), - message: (props) => `${props.value} não é um cnpj válido`, +const entitySchema = new mongoose.Schema( + { + name: { + type: String, + required: true, }, - }, - photo: { - type: String, - }, - notificationToken: { - type: String, - }, - address: { - cep: { + deviceId: { type: String, + required: false, }, - number: { - type: Number, + email: { + type: String, + required: true, + unique: true, + index: true, }, - city: { + cnpj: { type: String, + required: true, + unique: true, + index: true, + validate: { + validator: (v) => cnpj.isValid(v), + message: (props) => `${props.value} não é um cnpj válido`, + }, }, - state: { + photo: { + type: String, + }, + notificationToken: { + type: String, + }, + address: { + cep: { + type: String, + }, + number: { + type: Number, + }, + city: { + type: String, + }, + state: { + type: String, + }, + complement: String, + }, + location: { + type: Point, + index: '2dsphere', + }, + phone: { + type: String, + }, + registerDate: { + type: Date, + default: Date.now, + }, + active: { + default: true, + type: Boolean, + }, + biography: { + default: '-', type: String, }, - complement: String, - }, - location: { - type: Point, - index: '2dsphere', - }, - phone: { - type: String, - }, - registerDate: { - type: Date, - default: Date.now, - }, - active: { - default: true, - type: Boolean, }, -}, { collection: 'entity' }); + { collection: 'entity' }, +); module.exports = mongoose.model('Entity', entitySchema); diff --git a/src/services/EntityService.js b/src/services/EntityService.js index 5d92f67a..38fce263 100644 --- a/src/services/EntityService.js +++ b/src/services/EntityService.js @@ -45,7 +45,9 @@ class EntityService { }) .catch(async (err) => { await this.removeEntity(data.email); - await this.socialNetworkService.removeSocialNetworkUser(createdSocialNetworkUser._id); + await this.socialNetworkService.removeSocialNetworkUser( + createdSocialNetworkUser._id, + ); throw err; }); } @@ -81,6 +83,7 @@ class EntityService { notificationToken, deviceId, address, + biography, }) { const entity = await this.getEntity({ email }); @@ -90,6 +93,7 @@ class EntityService { entity.notificationToken = notificationToken || entity.notificationToken; entity.deviceId = deviceId || entity.deviceId; entity.address = address || entity.address; + entity.biography = biography || entity.biography; const result = await this.entityRepository.update(entity); @@ -158,7 +162,10 @@ class EntityService { async findOneEntityWithProjection(entityId, projection) { const query = { _id: ObjectID(entityId) }; - const entity = await this.entityRepository.findOneEntityWithProjection(query, projection); + const entity = await this.entityRepository.findOneEntityWithProjection( + query, + projection, + ); return entity; } From 7cb7b8285f41adb20c717078b2d413cca4068123 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 29 Apr 2023 15:24:45 -0300 Subject: [PATCH 060/107] feat: return list of campaigns to user profile --- src/repository/BaseRepository.js | 19 +++++++++++++------ src/repository/CampaignRepository.js | 6 ++++-- src/services/SocialNetworkService.js | 7 ++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/repository/BaseRepository.js b/src/repository/BaseRepository.js index 8bf467cf..67e18869 100644 --- a/src/repository/BaseRepository.js +++ b/src/repository/BaseRepository.js @@ -37,7 +37,9 @@ class BaseRepository { } async $listAggregate(aggregationPipeline) { - const aggregatedPipeline = await this.ModelClass.aggregate(aggregationPipeline).exec(); + const aggregatedPipeline = await this.ModelClass.aggregate( + aggregationPipeline, + ).exec(); return aggregatedPipeline; } @@ -46,7 +48,7 @@ class BaseRepository { * @param {Boolean} [active = true] se vou pegar ou não elementos deletados, * Se for false, mesmo elementos removidos serão exibidos. */ - async $getById(id, active = true) { + async $getById(id, active = true, populate = null) { let finalIdFormat = id; if (typeof id === 'string') { @@ -65,12 +67,18 @@ class BaseRepository { query.active = true; } - const recordModel = await this.ModelClass.findOne(query); + const recordModel = await this.ModelClass.findOne(query).populate(populate); return recordModel; } - async $list(query, selectedField = null, populate = null, sort = null, limit = null) { + async $list( + query, + selectedField = null, + populate = null, + sort = null, + limit = null, + ) { return this.ModelClass.find(query, selectedField) .populate(populate) .sort(sort) @@ -83,8 +91,7 @@ class BaseRepository { } async $findOne(query, projection, populate = null) { - return this.ModelClass.findOne(query, projection) - .populate(populate); + return this.ModelClass.findOne(query, projection).populate(populate); } async $destroy(query) { diff --git a/src/repository/CampaignRepository.js b/src/repository/CampaignRepository.js index e5466385..052cf689 100644 --- a/src/repository/CampaignRepository.js +++ b/src/repository/CampaignRepository.js @@ -23,12 +23,14 @@ class CampaignRepository extends BaseRepository { async listByOwnerId(ownerId) { const query = { ownerId }; - const campaigns = await super.$list(query); + const populate = ['entity', 'categories']; + const campaigns = await super.$list(query, {}, populate); return campaigns; } async getById(id) { - const campaign = await super.$getById(id); + const populate = ['entity', 'categories']; + const campaign = await super.$getById(id, true, populate); return campaign; } diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index e0d16107..fffd7868 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -3,12 +3,14 @@ const HelpRepository = require('../repository/HelpRepository'); const OfferdHelpRepository = require('../repository/HelpOfferRepository'); const UserRepository = require('../repository/UserRepository'); const mapSocialNetworkUser = require('../utils/mapSocialNetworkUser'); +const CampaignRepository = require('../repository/CampaignRepository'); class SocialNetworkService { constructor() { this.socialNetworkRepository = new SocialNetworkRepository(); this.helpRepository = new HelpRepository(); this.offerdHelpRepository = new OfferdHelpRepository(); + this.campaignRepository = new CampaignRepository(); } async createSocialNetworkUser(createdUser) { @@ -110,6 +112,7 @@ class SocialNetworkService { statusList, helper, ); + const offers = await this.offerdHelpRepository.list( userId, false, @@ -117,7 +120,9 @@ class SocialNetworkService { getOtherUsers, ); - const activities = { helps, offers }; + const campaigns = await this.campaignRepository.listByOwnerId(userId); + + const activities = { helps, offers, campaigns }; return activities; } From ebac5fe74f17b932adb10e3a07156d4ede5f93da Mon Sep 17 00:00:00 2001 From: sudjoao Date: Wed, 3 May 2023 22:20:02 -0300 Subject: [PATCH 061/107] chore: update seeds --- src/utils/seed/HelpOfferCampaignSeed.js | 22 ++++++++++++++++--- .../seed/mockedInfos/mockedBadgesInfo.js | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/utils/seed/HelpOfferCampaignSeed.js b/src/utils/seed/HelpOfferCampaignSeed.js index 1401c68a..bbd51ecd 100644 --- a/src/utils/seed/HelpOfferCampaignSeed.js +++ b/src/utils/seed/HelpOfferCampaignSeed.js @@ -27,15 +27,25 @@ const seedHelp = async () => { const campaignCollection = await Campaign.find(); // this condition avoid populate duplicate users - if (helpCollection.length > 0 || helpOfferCollection.length > 0 || campaignCollection.length > 0) { + if ( + helpCollection.length > 0 + || helpOfferCollection.length > 0 + || campaignCollection.length > 0 + ) { return; } - const quantity = 10; + const quantity = 40; const requests = []; const offers = []; const campaigns = []; for (let i = 0; i < quantity; i += 1) { + let latitude = process.env.LATITUDE_ENV || -15.824544; + let longitude = process.env.LONGITUDE_ENV || -48.060878; + longitude = Number(longitude) + + faker.random.number({ min: -999, max: 999 }) / 100000; + latitude = Number(latitude) + + faker.random.number({ min: -999, max: 999 }) / 100000; const sampleStatus = lodash.sample(status); const sampleCategory = lodash.sample(categoryCollection); const sampleUsers = lodash.sampleSize(userCollection, 2); @@ -56,6 +66,10 @@ const seedHelp = async () => { categoryId: [sampleCategory._id], ownerId: sampleUsers[0]._id, finishedDate: faker.date.future(), + location: { + type: 'Point', + coordinates: [longitude, latitude], + }, }; requests.push( @@ -100,7 +114,9 @@ const seedHelp = async () => { console.log('Pedidos, ofertas e campanhas populados com sucesso!'); } catch (error) { - console.log('Não foi possível criar pedidos, ofertas e campanhas na base de dados!'); + console.log( + 'Não foi possível criar pedidos, ofertas e campanhas na base de dados!', + ); console.log(error); } }; diff --git a/src/utils/seed/mockedInfos/mockedBadgesInfo.js b/src/utils/seed/mockedInfos/mockedBadgesInfo.js index a02df62f..48a35201 100644 --- a/src/utils/seed/mockedInfos/mockedBadgesInfo.js +++ b/src/utils/seed/mockedInfos/mockedBadgesInfo.js @@ -42,7 +42,7 @@ const mockedBadges = [ name: 'Testador Beta 2', description: 'Paritcipou do beta do app', iconName: 'home', - neededValue: 3, + neededValue: 2, rank: 2, category: 'tester', nextBadge: 6, From a6c629acb73f605d82aae7b1871bbb4558042ff0 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Wed, 3 May 2023 22:20:37 -0300 Subject: [PATCH 062/107] feat: create logic to populate badge --- src/controllers/BadgeController.js | 6 +++--- src/repository/BadgeRepository.js | 9 +++++++-- src/services/BadgeService.js | 6 ++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/controllers/BadgeController.js b/src/controllers/BadgeController.js index b349e6d7..d6e16f86 100644 --- a/src/controllers/BadgeController.js +++ b/src/controllers/BadgeController.js @@ -16,10 +16,10 @@ class BadgeController { category, ); if ( - result.template.nextBadge - && result.currentValue >= result.template.nextBadge.neededValue + result.badge.template.nextBadge + && result.badge.currentValue >= result.badge.template.nextBadge.neededValue ) { - result = await this.BadgeService.updateBadgeReference(result); + result = await this.BadgeService.updateBadgeReference(result.badge); } res.status(201).json(result); next(); diff --git a/src/repository/BadgeRepository.js b/src/repository/BadgeRepository.js index 56bf1b7e..e221ac96 100644 --- a/src/repository/BadgeRepository.js +++ b/src/repository/BadgeRepository.js @@ -14,7 +14,7 @@ class BadgeRepository extends BaseRepository { } async create(badge) { - const result = await super.$save(badge); + const result = await super.$save(badge, {}, ['template']); return result; } @@ -33,7 +33,12 @@ class BadgeRepository extends BaseRepository { } async update(badge) { - const result = await super.$update(badge); + const savedBadge = await super.$update(badge); + const result = await super.$getById( + savedBadge._id, + null, + this.populateData, + ); return result; } } diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index 9d220301..4a4cda95 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -11,22 +11,24 @@ class BadgeService { async createOrUpdateBadge(userId, category) { const badges = await this.BadgeRepository.listByUserId(userId); let badge = badges.find((item) => item.template.category === category); + let recentUpdated = false; if (!badge) { const referenceBadge = await this.BadgeTemplateRepository.getFirstRankByCategory(category); badge = await this.BadgeRepository.create({ user: userId, template: referenceBadge._id, }); + recentUpdated = true; } badge.currentValue += 1; const updatedBadge = await this.BadgeRepository.update(badge); - return updatedBadge; + return { badge: updatedBadge, recentUpdated }; } async updateBadgeReference(badge) { badge.template = badge.template.nextBadge; const updatedBadge = await this.BadgeRepository.update(badge); - return updatedBadge; + return { badge: updatedBadge, recentUpdated: true }; } async getBadgeList(userId) { From c5b1bf92ef2d9e58e97eb461b5c028e875f8b8ba Mon Sep 17 00:00:00 2001 From: sudjoao Date: Wed, 3 May 2023 22:29:40 -0300 Subject: [PATCH 063/107] chore: add await to save erorr async func --- src/controllers/BadgeController.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/BadgeController.js b/src/controllers/BadgeController.js index d6e16f86..2b929c3e 100644 --- a/src/controllers/BadgeController.js +++ b/src/controllers/BadgeController.js @@ -24,7 +24,7 @@ class BadgeController { res.status(201).json(result); next(); } catch (err) { - saveError(err); + await saveError(err); res.status(400).json({ error: err.message }); next(); } @@ -37,7 +37,7 @@ class BadgeController { res.status(200).json(result); next(); } catch (err) { - saveError(err); + await saveError(err); res.status(400).json({ error: err.message }); next(); } @@ -52,7 +52,7 @@ class BadgeController { res.status(200).json({ userBadges: parsedUserBadges, allBadges }); next(); } catch (err) { - saveError(err); + await saveError(err); res.status(400).json({ error: err.message }); next(); } From e8e67965362adc4398406f3ddc294c43ac50e1d7 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 7 May 2023 11:23:41 -0300 Subject: [PATCH 064/107] chore: return help creation date --- src/repository/HelpRepository.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index df31db66..8987728b 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -170,6 +170,7 @@ class HelpRepository extends BaseRepository { 'status', 'ownerId', 'categoryId', + 'creationDate', ]; const user = { From 7559fde8a50cdb8d6c2244cab7450ce98dede491 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Fri, 12 May 2023 23:43:26 -0300 Subject: [PATCH 065/107] feat: add address state to return in help API --- src/repository/HelpRepository.js | 126 +++++++++++++++---------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index df31db66..30d7ec04 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -1,8 +1,8 @@ // eslint-disable-next-line import/no-unresolved -const { ObjectID } = require('mongodb'); -const BaseRepository = require('./BaseRepository'); -const HelpSchema = require('../models/Help'); -const getLocation = require('../utils/getLocation'); +const { ObjectID } = require("mongodb"); +const BaseRepository = require("./BaseRepository"); +const HelpSchema = require("../models/Help"); +const getLocation = require("../utils/getLocation"); class HelpRepository extends BaseRepository { constructor() { @@ -13,12 +13,12 @@ class HelpRepository extends BaseRepository { const doc = await super.$save(help); const populate = [ { - path: 'user', - select: ['name', 'riskGroup'], + path: "user", + select: ["name", "riskGroup"], }, { - path: 'categories', - select: ['name'], + path: "categories", + select: ["name"], }, ]; const result = await super.$populateExistingDoc(doc, populate); @@ -41,40 +41,40 @@ class HelpRepository extends BaseRepository { async getByIdWithAggregation(id) { const matchQuery = { _id: ObjectID(id) }; const helpFields = [ - '_id', - 'ownerId', - 'categoryId', - 'possibleHelpers', - 'possibleEntities', - 'description', - 'helperId', - 'status', - 'title', - 'location', - 'creationDate', + "_id", + "ownerId", + "categoryId", + "possibleHelpers", + "possibleEntities", + "description", + "helperId", + "status", + "title", + "location", + "creationDate", ]; const user = { - path: 'user', + path: "user", select: [ - 'photo', - 'name', - 'phone', - 'birthday', - 'address.city', - 'location.coordinates', + "photo", + "name", + "phone", + "birthday", + "address.city", + "location.coordinates", ], }; const categories = { - path: 'categories', - select: ['_id', 'name'], + path: "categories", + select: ["_id", "name"], }; const possibleHelpers = { - path: 'possibleHelpers', - select: ['_id', 'name', 'phone', 'photo', 'birthday', 'address.city'], + path: "possibleHelpers", + select: ["_id", "name", "phone", "photo", "birthday", "address.city", "address.state"], }; const possibleEntities = { - path: 'possibleEntities', - select: ['_id', 'name', 'photo', 'address.city'], + path: "possibleEntities", + select: ["_id", "name", "photo", "address.city", "address.state"], }; return super.$findOne(matchQuery, helpFields, [ user, @@ -92,7 +92,7 @@ class HelpRepository extends BaseRepository { const matchQuery = { active: true, ownerId: { $ne: ObjectID(id) }, - status: 'waiting', + status: "waiting", }; if (isUserEntity) { @@ -107,21 +107,21 @@ class HelpRepository extends BaseRepository { }; } const helpFields = [ - '_id', - 'title', - 'description', - 'categoryId', - 'ownerId', - 'creationDate', - 'location', + "_id", + "title", + "description", + "categoryId", + "ownerId", + "creationDate", + "location", ]; const user = { - path: 'user', - select: ['name', 'riskGroup', 'location.coordinates'], + path: "user", + select: ["name", "riskGroup", "location.coordinates"], }; const categories = { - path: 'categories', - select: ['_id', 'name'], + path: "categories", + select: ["_id", "name"], }; const helps = await super.$list(matchQuery, helpFields, [user, categories]); const helpsWithDistance = helps.map((help) => { @@ -139,7 +139,7 @@ class HelpRepository extends BaseRepository { const query = {}; query.ownerId = id; query.active = true; - query.status = { $ne: 'finished' }; + query.status = { $ne: "finished" }; const result = await super.$countDocuments(query); return result; @@ -164,28 +164,28 @@ class HelpRepository extends BaseRepository { }; const fields = [ - '_id', - 'description', - 'title', - 'status', - 'ownerId', - 'categoryId', + "_id", + "description", + "title", + "status", + "ownerId", + "categoryId", ]; const user = { - path: 'user', - select: ['photo', 'phone', 'name', 'birthday', 'address.city'], + path: "user", + select: ["photo", "phone", "name", "birthday", "address.city"], }; const categories = { - path: 'categories', - select: ['_id', 'name'], + path: "categories", + select: ["_id", "name"], }; const populate = [user, categories]; if (helper) { - user.select.push('location.coordinates'); + user.select.push("location.coordinates"); matchQuery.$or = [ { possibleHelpers: { $in: [ObjectID(userId)] }, @@ -196,16 +196,16 @@ class HelpRepository extends BaseRepository { ]; } else { const possibleHelpers = { - path: 'possibleHelpers', - select: ['_id', 'photo', 'name', 'birthday', 'address.city'], + path: "possibleHelpers", + select: ["_id", "photo", "name", "birthday", "address.city"], }; const possibleEntities = { - path: 'possibleEntities', - select: ['_id', 'photo', 'name', 'birthday', 'address.city'], + path: "possibleEntities", + select: ["_id", "photo", "name", "birthday", "address.city"], }; - fields.push('helperId'); + fields.push("helperId"); populate.push(possibleHelpers); populate.push(possibleEntities); @@ -221,8 +221,8 @@ class HelpRepository extends BaseRepository { const matchQuery = { _id: ObjectID(helpId) }; const populate = { - path: 'user', - select: ['photo', 'birthday', 'address.city'], + path: "user", + select: ["photo", "birthday", "address.city"], }; const projection = { From 1ff2fcee3af28b9e37b8987307ba4416665adc14 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Thu, 18 May 2023 21:30:01 -0300 Subject: [PATCH 066/107] fix: fixing lint --- src/repository/HelpRepository.js | 126 +++++++++++++++---------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index 30d7ec04..9bdf6136 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -1,8 +1,8 @@ // eslint-disable-next-line import/no-unresolved -const { ObjectID } = require("mongodb"); -const BaseRepository = require("./BaseRepository"); -const HelpSchema = require("../models/Help"); -const getLocation = require("../utils/getLocation"); +const { ObjectID } = require('mongodb'); +const BaseRepository = require('./BaseRepository'); +const HelpSchema = require('../models/Help'); +const getLocation = require('../utils/getLocation'); class HelpRepository extends BaseRepository { constructor() { @@ -13,12 +13,12 @@ class HelpRepository extends BaseRepository { const doc = await super.$save(help); const populate = [ { - path: "user", - select: ["name", "riskGroup"], + path: 'user', + select: ['name', 'riskGroup'], }, { - path: "categories", - select: ["name"], + path: 'categories', + select: ['name'], }, ]; const result = await super.$populateExistingDoc(doc, populate); @@ -41,40 +41,40 @@ class HelpRepository extends BaseRepository { async getByIdWithAggregation(id) { const matchQuery = { _id: ObjectID(id) }; const helpFields = [ - "_id", - "ownerId", - "categoryId", - "possibleHelpers", - "possibleEntities", - "description", - "helperId", - "status", - "title", - "location", - "creationDate", + '_id', + 'ownerId', + 'categoryId', + 'possibleHelpers', + 'possibleEntities', + 'description', + 'helperId', + 'status', + 'title', + 'location', + 'creationDate', ]; const user = { - path: "user", + path: 'user', select: [ - "photo", - "name", - "phone", - "birthday", - "address.city", - "location.coordinates", + 'photo', + 'name', + 'phone', + 'birthday', + 'address.city', + 'location.coordinates', ], }; const categories = { - path: "categories", - select: ["_id", "name"], + path: 'categories', + select: ['_id', 'name'], }; const possibleHelpers = { - path: "possibleHelpers", - select: ["_id", "name", "phone", "photo", "birthday", "address.city", "address.state"], + path: 'possibleHelpers', + select: ['_id', 'name', 'phone', 'photo', 'birthday', 'address.city', 'address.state'], }; const possibleEntities = { - path: "possibleEntities", - select: ["_id", "name", "photo", "address.city", "address.state"], + path: 'possibleEntities', + select: ['_id', 'name', 'photo', 'address.city', 'address.state'], }; return super.$findOne(matchQuery, helpFields, [ user, @@ -92,7 +92,7 @@ class HelpRepository extends BaseRepository { const matchQuery = { active: true, ownerId: { $ne: ObjectID(id) }, - status: "waiting", + status: 'waiting', }; if (isUserEntity) { @@ -107,21 +107,21 @@ class HelpRepository extends BaseRepository { }; } const helpFields = [ - "_id", - "title", - "description", - "categoryId", - "ownerId", - "creationDate", - "location", + '_id', + 'title', + 'description', + 'categoryId', + 'ownerId', + 'creationDate', + 'location', ]; const user = { - path: "user", - select: ["name", "riskGroup", "location.coordinates"], + path: 'user', + select: ['name', 'riskGroup', 'location.coordinates'], }; const categories = { - path: "categories", - select: ["_id", "name"], + path: 'categories', + select: ['_id', 'name'], }; const helps = await super.$list(matchQuery, helpFields, [user, categories]); const helpsWithDistance = helps.map((help) => { @@ -139,7 +139,7 @@ class HelpRepository extends BaseRepository { const query = {}; query.ownerId = id; query.active = true; - query.status = { $ne: "finished" }; + query.status = { $ne: 'finished' }; const result = await super.$countDocuments(query); return result; @@ -164,28 +164,28 @@ class HelpRepository extends BaseRepository { }; const fields = [ - "_id", - "description", - "title", - "status", - "ownerId", - "categoryId", + '_id', + 'description', + 'title', + 'status', + 'ownerId', + 'categoryId', ]; const user = { - path: "user", - select: ["photo", "phone", "name", "birthday", "address.city"], + path: 'user', + select: ['photo', 'phone', 'name', 'birthday', 'address.city'], }; const categories = { - path: "categories", - select: ["_id", "name"], + path: 'categories', + select: ['_id', 'name'], }; const populate = [user, categories]; if (helper) { - user.select.push("location.coordinates"); + user.select.push('location.coordinates'); matchQuery.$or = [ { possibleHelpers: { $in: [ObjectID(userId)] }, @@ -196,16 +196,16 @@ class HelpRepository extends BaseRepository { ]; } else { const possibleHelpers = { - path: "possibleHelpers", - select: ["_id", "photo", "name", "birthday", "address.city"], + path: 'possibleHelpers', + select: ['_id', 'photo', 'name', 'birthday', 'address.city'], }; const possibleEntities = { - path: "possibleEntities", - select: ["_id", "photo", "name", "birthday", "address.city"], + path: 'possibleEntities', + select: ['_id', 'photo', 'name', 'birthday', 'address.city'], }; - fields.push("helperId"); + fields.push('helperId'); populate.push(possibleHelpers); populate.push(possibleEntities); @@ -221,8 +221,8 @@ class HelpRepository extends BaseRepository { const matchQuery = { _id: ObjectID(helpId) }; const populate = { - path: "user", - select: ["photo", "birthday", "address.city"], + path: 'user', + select: ['photo', 'birthday', 'address.city'], }; const projection = { From 0f312877d83bdc072d3b439e11b4d75ce1efbf38 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Fri, 19 May 2023 11:06:29 -0300 Subject: [PATCH 067/107] feat: returns from backend the offer distance --- src/controllers/HelpOfferController.js | 3 ++- src/models/HelpOffer.js | 21 +++++++++++++++++++++ src/repository/HelpOfferRepository.js | 16 ++++++++++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/controllers/HelpOfferController.js b/src/controllers/HelpOfferController.js index c5fd063f..39c3d42b 100644 --- a/src/controllers/HelpOfferController.js +++ b/src/controllers/HelpOfferController.js @@ -35,8 +35,9 @@ class OfferedHelpController { const { userId } = req.query; const getOtherUsers = req.query.getOtherUsers === 'true'; const { isUserEntity } = global; + const coords = req.query.coords.split(',').map((coord) => Number(coord)); try { - const helpOffers = await this.HelpOfferService.listHelpsOffers(userId, isUserEntity, null, getOtherUsers); + const helpOffers = await this.HelpOfferService.listHelpsOffers(coords, userId, isUserEntity, null, getOtherUsers); return res.json(helpOffers); } catch (error) { return res.status(400).json({ error: error.message }); diff --git a/src/models/HelpOffer.js b/src/models/HelpOffer.js index a70371b4..ebe7a29a 100644 --- a/src/models/HelpOffer.js +++ b/src/models/HelpOffer.js @@ -1,6 +1,7 @@ const { Schema, model } = require('mongoose'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); const Point = require('./Point'); +const { calculateDistance, getDistance } = require('../utils/geolocation/calculateDistance'); const offeredHelpSchema = new Schema( { @@ -90,4 +91,24 @@ offeredHelpSchema.virtual('helpedUsers', { foreignField: '_id', }); +offeredHelpSchema.virtual('distances') + .set(({ userCoords, coords }) => { + userCoords = { + longitude: userCoords[0], + latitude: userCoords[1], + }; + const coordinates = { + longitude: coords[0], + latitude: coords[1], + }; + this.distanceValue = calculateDistance(coordinates, userCoords); + this.distance = getDistance(coordinates, userCoords); + }); + +offeredHelpSchema.virtual('distanceValue') + .get(() => this.distanceValue); + +offeredHelpSchema.virtual('distance') + .get(() => this.distance); + module.exports = model('OfferedHelp', offeredHelpSchema); diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index 40b21a32..5de341ca 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -1,6 +1,7 @@ const { ObjectID } = require('mongodb'); const BaseRepository = require('./BaseRepository'); const OfferedHelp = require('../models/HelpOffer'); +const getLocation = require('../utils/getLocation'); class OfferdHelpRepository extends BaseRepository { constructor() { @@ -70,7 +71,7 @@ class OfferdHelpRepository extends BaseRepository { return super.$findOne(query, helpOfferFields, populate); } - async list(userId, isUserEntity, categoryArray, getOtherUsers) { + async list(coords, userId, isUserEntity, categoryArray, getOtherUsers) { const matchQuery = this.getHelpOfferListQuery( userId, isUserEntity, @@ -86,6 +87,7 @@ class OfferdHelpRepository extends BaseRepository { 'helpedUserId', 'creationDate', 'location', + 'description', ]; const sort = { creationDate: -1 }; const user = { @@ -107,7 +109,17 @@ class OfferdHelpRepository extends BaseRepository { const populate = [user, categories, possibleHelpedUsers, possibleEntities]; - return super.$list(matchQuery, helpOfferFields, populate, sort); + const helpOffer = await super.$list(matchQuery, helpOfferFields, populate, sort); + + const helpOffersWithDistances = helpOffer.map((offer) => { + const offerLocation = getLocation(offer); + offer.distances = { userCoords: offerLocation, coords }; + return offer.toObject(); + }); + + helpOffersWithDistances.sort((a, b) => a.distanceValue - b.distanceValue); + + return helpOffersWithDistances; } getHelpOfferListQuery( From 52044d854d2945d961b4386ee0a2d50afba42ba9 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Sat, 20 May 2023 11:07:36 -0300 Subject: [PATCH 068/107] feat: returns from backend the activity type --- src/services/CampaignService.js | 3 ++- src/services/HelpOfferService.js | 14 +++++++++++--- src/services/HelpService.js | 3 ++- src/utils/addHelpTypeToList.js | 2 ++ 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 src/utils/addHelpTypeToList.js diff --git a/src/services/CampaignService.js b/src/services/CampaignService.js index d371b2b1..efa3440d 100644 --- a/src/services/CampaignService.js +++ b/src/services/CampaignService.js @@ -1,6 +1,7 @@ const CampaignRepository = require('../repository/CampaignRepository'); const CategoryService = require('./CategoryService'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); +const addHelpTypeToList = require('../utils/addHelpTypeToList'); class CampaignService { constructor() { @@ -49,7 +50,7 @@ class CampaignService { ); } - return CampaignList; + return addHelpTypeToList(CampaignList, 'campaign'); } async getCampaignById(id) { diff --git a/src/services/HelpOfferService.js b/src/services/HelpOfferService.js index 2bea7335..36251e5c 100644 --- a/src/services/HelpOfferService.js +++ b/src/services/HelpOfferService.js @@ -7,6 +7,7 @@ const NotificationMixin = require('../utils/NotificationMixin'); const { notificationTypesEnum } = require('../models/Notification'); const saveError = require('../utils/ErrorHistory'); const { findConnections, sendMessage } = require('../../websocket'); +const addHelpTypeToList = require('../utils/addHelpTypeToList'); class OfferedHelpService { constructor() { @@ -34,9 +35,16 @@ class OfferedHelpService { return help; } - async listHelpsOffers(userId, isUserEntity, categoryArray, getOtherUsers) { - const helpOffers = await this.OfferedHelpRepository.list(userId, isUserEntity, categoryArray, getOtherUsers); - return helpOffers; + async listHelpsOffers(coords, userId, isUserEntity, categoryArray, getOtherUsers) { + const helpOffers = await this.OfferedHelpRepository.list( + coords, + userId, + isUserEntity, + categoryArray, + getOtherUsers, + ); + const helpOffersList = addHelpTypeToList(helpOffers, 'offer'); + return helpOffersList; } async listHelpsOffersByOwnerId(ownerId) { diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 2c0b3ec2..e96597d5 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -9,6 +9,7 @@ const NotificationMixin = require('../utils/NotificationMixin'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); const saveError = require('../utils/ErrorHistory'); const SocialNetworkService = require('./SocialNetworkService'); +const addHelpTypeToList = require('../utils/addHelpTypeToList'); class HelpService { constructor() { @@ -110,7 +111,7 @@ class HelpService { ); } - return Helplist; + return addHelpTypeToList(Helplist, 'help'); } async deleteHelpLogically(id) { diff --git a/src/utils/addHelpTypeToList.js b/src/utils/addHelpTypeToList.js new file mode 100644 index 00000000..c826c3c3 --- /dev/null +++ b/src/utils/addHelpTypeToList.js @@ -0,0 +1,2 @@ +const addHelpTypeToList = (helpList, type) => helpList.map((help) => ({ ...help, type })); +module.exports = addHelpTypeToList; From 9680463afa4fa58607cd9702620199631cd308a5 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 3 Jun 2023 22:22:15 -0300 Subject: [PATCH 069/107] chore: create feedback initial structure --- src/controllers/FeedbackController.js | 39 +++++++++++++++++++++++++++ src/models/Feedback.js | 23 ++++++++++++++++ src/repository/FeedbackRepository.js | 20 ++++++++++++++ src/routes/BaseRoutes.js | 2 ++ src/routes/FeedbackRoutes.js | 15 +++++++++++ src/services/FeedbackService.js | 19 +++++++++++++ 6 files changed, 118 insertions(+) create mode 100644 src/controllers/FeedbackController.js create mode 100644 src/models/Feedback.js create mode 100644 src/repository/FeedbackRepository.js create mode 100644 src/routes/FeedbackRoutes.js create mode 100644 src/services/FeedbackService.js diff --git a/src/controllers/FeedbackController.js b/src/controllers/FeedbackController.js new file mode 100644 index 00000000..0f479548 --- /dev/null +++ b/src/controllers/FeedbackController.js @@ -0,0 +1,39 @@ +const FeedbackService = require('../services/FeedbackService'); +const saveError = require('../utils/ErrorHistory'); + +class FeedbackController { + constructor() { + this.FeedbackService = new FeedbackService(); + } + + async create(req, res) { + try { + const { body, senderId, receiverId } = req.body; + const feedback = { + senderId, + receiverId, + body, + }; + const newFeedback = await this.FeedbackService.create(feedback); + res.status(200).json(newFeedback); + } catch (error) { + saveError(error); + res.status(500).json({ error: 'Erro ao criar feedback' }); + } + } + + async listByReceiver(req, res) { + try { + const { receiverId } = req.params; + const feedbacks = await this.FeedbackService.listByReceiver( + receiverId, + ); + res.status(200).json(feedbacks); + } catch (error) { + saveError(error); + res.status(500).json({ error: 'Erro ao listar feedbacks' }); + } + } +} + +module.exports = FeedbackController; diff --git a/src/models/Feedback.js b/src/models/Feedback.js new file mode 100644 index 00000000..82b8e0b6 --- /dev/null +++ b/src/models/Feedback.js @@ -0,0 +1,23 @@ +const mongoose = require('mongoose'); + +const feedbackSchema = new mongoose.Schema( + { + senderId: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + required: true, + }, + receiverId: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + required: true, + }, + body: { + type: String, + required: true, + }, + }, + { collection: 'feedback' }, +); + +module.exports = mongoose.model('Feedback', feedbackSchema); diff --git a/src/repository/FeedbackRepository.js b/src/repository/FeedbackRepository.js new file mode 100644 index 00000000..336d4376 --- /dev/null +++ b/src/repository/FeedbackRepository.js @@ -0,0 +1,20 @@ +const BaseRepository = require('./BaseRepository'); +const feedbackSchema = require('../models/Feedback'); + +class FeedbackRepository extends BaseRepository { + constructor() { + super(feedbackSchema); + } + + async create(feedback) { + const newFeedback = await super.$save(feedback); + return newFeedback; + } + + async listByReceiver(receiverId) { + const result = await super.$list({ receiverId }); + return result; + } +} + +module.exports = FeedbackRepository; diff --git a/src/routes/BaseRoutes.js b/src/routes/BaseRoutes.js index a5dd7c99..6df36130 100644 --- a/src/routes/BaseRoutes.js +++ b/src/routes/BaseRoutes.js @@ -9,6 +9,7 @@ const helpOfferRoutes = require('./HelpOfferRoutes'); const campaignRoutes = require('./CampaignRoutes'); const socialNetworkRoutes = require('./SocialNetworkRoutes'); const badgeRoutes = require('./BadgeRoutes'); +const feedbackRoutes = require('./FeedbackRoutes'); const swaggerDocument = YAML.load('docs/swagger.yaml'); @@ -24,5 +25,6 @@ module.exports = (app) => { campaignRoutes, socialNetworkRoutes, badgeRoutes, + feedbackRoutes, ]); }; diff --git a/src/routes/FeedbackRoutes.js b/src/routes/FeedbackRoutes.js new file mode 100644 index 00000000..00077fa0 --- /dev/null +++ b/src/routes/FeedbackRoutes.js @@ -0,0 +1,15 @@ +const express = require('express'); +const FeedbackController = require('../controllers/FeedbackController'); + +const badgeController = new FeedbackController(); +const routes = express.Router(); + +routes.post('/feedback', (req, res) => { + badgeController.create(req, res); +}); + +routes.get('/feedback/:receiverId', (req, res) => { + badgeController.listByReceiver(req, res); +}); + +module.exports = routes; diff --git a/src/services/FeedbackService.js b/src/services/FeedbackService.js new file mode 100644 index 00000000..6102d537 --- /dev/null +++ b/src/services/FeedbackService.js @@ -0,0 +1,19 @@ +const FeedbackRepository = require('../repository/FeedbackRepository'); + +class FeedbackService { + constructor() { + this.FeedbackRepository = new FeedbackRepository(); + } + + async create(feedback) { + const newFeedback = await this.FeedbackRepository.create(feedback); + return newFeedback; + } + + async listByReceiver(receiverId) { + const result = await this.FeedbackRepository.listByReceiver(receiverId); + return result; + } +} + +module.exports = FeedbackService; From 7effb7bf3b3fa97141f00274121c13c992db264d Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 4 Jun 2023 09:39:28 -0300 Subject: [PATCH 070/107] feat: improve feedback model and methods returns --- src/controllers/FeedbackController.js | 12 ++++++------ src/models/Feedback.js | 10 +++++++--- src/repository/FeedbackRepository.js | 2 +- src/services/FeedbackService.js | 4 ++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/controllers/FeedbackController.js b/src/controllers/FeedbackController.js index 0f479548..31ef3872 100644 --- a/src/controllers/FeedbackController.js +++ b/src/controllers/FeedbackController.js @@ -8,11 +8,11 @@ class FeedbackController { async create(req, res) { try { - const { body, senderId, receiverId } = req.body; + const { message, sender, receiver } = req.body; const feedback = { - senderId, - receiverId, - body, + sender, + receiver, + message, }; const newFeedback = await this.FeedbackService.create(feedback); res.status(200).json(newFeedback); @@ -24,9 +24,9 @@ class FeedbackController { async listByReceiver(req, res) { try { - const { receiverId } = req.params; + const { receiver } = req.params; const feedbacks = await this.FeedbackService.listByReceiver( - receiverId, + receiver, ); res.status(200).json(feedbacks); } catch (error) { diff --git a/src/models/Feedback.js b/src/models/Feedback.js index 82b8e0b6..46781aa1 100644 --- a/src/models/Feedback.js +++ b/src/models/Feedback.js @@ -2,17 +2,21 @@ const mongoose = require('mongoose'); const feedbackSchema = new mongoose.Schema( { - senderId: { + sender: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true, }, - receiverId: { + receiver: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true, }, - body: { + creationDate: { + type: Date, + default: Date.now, + }, + message: { type: String, required: true, }, diff --git a/src/repository/FeedbackRepository.js b/src/repository/FeedbackRepository.js index 336d4376..9a9c1015 100644 --- a/src/repository/FeedbackRepository.js +++ b/src/repository/FeedbackRepository.js @@ -12,7 +12,7 @@ class FeedbackRepository extends BaseRepository { } async listByReceiver(receiverId) { - const result = await super.$list({ receiverId }); + const result = await super.$list({ receiverId }, null, ['sender', 'photo', 'name']); return result; } } diff --git a/src/services/FeedbackService.js b/src/services/FeedbackService.js index 6102d537..5d205b1d 100644 --- a/src/services/FeedbackService.js +++ b/src/services/FeedbackService.js @@ -10,8 +10,8 @@ class FeedbackService { return newFeedback; } - async listByReceiver(receiverId) { - const result = await this.FeedbackRepository.listByReceiver(receiverId); + async listByReceiver(receiver) { + const result = await this.FeedbackRepository.listByReceiver(receiver); return result; } } From baafeac56a43941c74c058c0b5d063057bf02698 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 4 Jun 2023 17:00:56 -0300 Subject: [PATCH 071/107] chore: fix filter --- src/repository/FeedbackRepository.js | 4 ++-- src/routes/FeedbackRoutes.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/repository/FeedbackRepository.js b/src/repository/FeedbackRepository.js index 9a9c1015..35a28752 100644 --- a/src/repository/FeedbackRepository.js +++ b/src/repository/FeedbackRepository.js @@ -11,8 +11,8 @@ class FeedbackRepository extends BaseRepository { return newFeedback; } - async listByReceiver(receiverId) { - const result = await super.$list({ receiverId }, null, ['sender', 'photo', 'name']); + async listByReceiver(receiver) { + const result = await super.$list({ receiver }, null, ['sender']); return result; } } diff --git a/src/routes/FeedbackRoutes.js b/src/routes/FeedbackRoutes.js index 00077fa0..e1aae52c 100644 --- a/src/routes/FeedbackRoutes.js +++ b/src/routes/FeedbackRoutes.js @@ -8,7 +8,7 @@ routes.post('/feedback', (req, res) => { badgeController.create(req, res); }); -routes.get('/feedback/:receiverId', (req, res) => { +routes.get('/feedback/:receiver', (req, res) => { badgeController.listByReceiver(req, res); }); From 39879d79e2d75f904ccea002dd5714b620f6d302 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 10 Jun 2023 19:31:27 -0300 Subject: [PATCH 072/107] chore: add location to the user, again --- .DS_Store | Bin 8196 -> 6148 bytes src/controllers/UserController.js | 1 + src/services/UserService.js | 2 ++ 3 files changed, 3 insertions(+) diff --git a/.DS_Store b/.DS_Store index e8402f0a9264af26c4987a61e665b10ed1a3c823..27af52e795045dd4dc64bf57894461ef6d32cf6a 100644 GIT binary patch delta 108 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50$jG-bU^g=(-(((vxtk4yteG|z uD>E);=im@z2C4!A0d64S3evE#@H_Klei=`Yb_OPhQ6SS9HplbKVFm!q1Q7iI delta 460 zcmZoMXmOBWU|?W$DortDU;r^WfEYvza8E20o2aMAD6}zPH}hr%jz7$c**Q2SHn1=X zP3B>lThGCe%#hDe#*oTT#E{64&XDSvlb@WFlb;0A3^cMENbCIv10V}zFq-YCcRnP9&#Ff!Ue z7!3SS8b-|mGBCVa7F?8 Date: Sat, 10 Jun 2023 19:32:27 -0300 Subject: [PATCH 073/107] chore: create logic to notify users when a request is created --- src/repository/UserRepository.js | 9 +++-- src/services/HelpService.js | 42 ++++++++++++++++++++-- src/services/UserService.js | 10 ++++-- src/utils/geolocation/calculateDistance.js | 15 +++++--- 4 files changed, 65 insertions(+), 11 deletions(-) diff --git a/src/repository/UserRepository.js b/src/repository/UserRepository.js index 0fc596c3..472987cd 100644 --- a/src/repository/UserRepository.js +++ b/src/repository/UserRepository.js @@ -57,12 +57,17 @@ class UserRepository extends BaseRepository { await super.$destroy(query); } - async getUsersWithDevice() { - const users = await super.$list({ deviceId: { $ne: null } }); + async getUsersWithDevice({ query = {}, fields = '' }) { + const users = await super.$list({ ...query, deviceId: { $ne: null } }, fields); return users; } + async listUsers({ query = {}, fields = '' }) { + const users = await super.$list(query, fields); + return users; + } + async findOneUserWithProjection(query, projection) { const user = await super.$findOne(query, projection); return user; diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 2c0b3ec2..f35e0789 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -9,6 +9,7 @@ const NotificationMixin = require('../utils/NotificationMixin'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); const saveError = require('../utils/ErrorHistory'); const SocialNetworkService = require('./SocialNetworkService'); +const { getDistance } = require('../utils/geolocation/calculateDistance'); class HelpService { constructor() { @@ -23,7 +24,7 @@ class HelpService { async createHelp(data) { const countHelp = await this.HelpRepository.countDocuments(data.ownerId); - if (countHelp >= 5) { + if (countHelp >= 20) { throw new Error('Limite máximo de pedidos atingido'); } @@ -36,10 +37,47 @@ class HelpService { JSON.parse(JSON.stringify(createdHelp.ownerId)), ); sendMessage(sendSocketMessageTo, 'new-help', createdHelp); - + this.notifyNearUsers(createdHelp); // this.notificationToFollowers(createdHelp.ownerId, createdHelp.id); } + async notifyNearUsers(helpInfo) { + const users = await this.UserService.getUsersWithDevice({ fields: 'location deviceId' }); + const currentUser = await this.UserService.getUser({ id: helpInfo.ownerId }); + const usersWithLocation = users.filter((user) => !!user.location?.coordinates); + const nearUsers = usersWithLocation.filter((user) => { + const distance = getDistance( + this.buildLatlongObject(currentUser.location.coordinates), + this.buildLatlongObject(user.location.coordinates), + false, + ); + return distance < 5000000; + }); + nearUsers.forEach((user) => this.notifyUser(user)); + } + + async notifyUser(user) { + const title = 'Pedido criado próxima a você'; + const body = 'Entre no aplicativo para conferir.'; + try { + await this.NotificationMixin.sendNotification( + user.deviceId, + title, + body, + ); + } catch (err) { + console.log('Não foi possível enviar a notificação!'); + saveError(err); + } + } + + buildLatlongObject(coords) { + return { + longitude: coords[0], + latitude: coords[1], + }; + } + /* TODO: Create logic to notificate the followers async notificationToFollowers(profileId, helpId) { const followers = await this.socialNetworkService.getFollowers(profileId, profileId); diff --git a/src/services/UserService.js b/src/services/UserService.js index 7ec36d58..cbe6b379 100644 --- a/src/services/UserService.js +++ b/src/services/UserService.js @@ -57,9 +57,9 @@ class UserService { } } - async getUsersWithDevice() { + async getUsersWithDevice({ query = {}, fields = '' }) { try { - const users = await this.userRepository.getUsersWithDevice(); + const users = await this.userRepository.getUsersWithDevice({ query, fields }); return users; } catch (err) { throw err; @@ -194,6 +194,12 @@ class UserService { return user; } + + async listUsers({ query = {}, fields = '' }) { + const users = await this.userRepository.listUsers({ query, fields }); + + return users; + } } module.exports = UserService; diff --git a/src/utils/geolocation/calculateDistance.js b/src/utils/geolocation/calculateDistance.js index 456edf15..7df304aa 100644 --- a/src/utils/geolocation/calculateDistance.js +++ b/src/utils/geolocation/calculateDistance.js @@ -13,9 +13,9 @@ function calculateDistance(centerCoordinates, pointCoordinates) { const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(deg2rad(lat1)) - * Math.cos(deg2rad(lat2)) - * Math.sin(dLon / 2) - * Math.sin(dLon / 2); + * Math.cos(deg2rad(lat2)) + * Math.sin(dLon / 2) + * Math.sin(dLon / 2); const center = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); const distance = radius * center; @@ -24,15 +24,20 @@ function calculateDistance(centerCoordinates, pointCoordinates) { } function convertDistance(distance) { + return distance.toFixed(2); +} + +function convertDistanceToString(distance) { return distance > 1 ? `${distance.toFixed(2)} km` : `${(distance * 1000).toFixed(0)} m`; } -function getDistance(centerCoordinates, pointCoordinates) { + +function getDistance(centerCoordinates, pointCoordinates, convertToString = true) { let distance = calculateDistance(centerCoordinates, pointCoordinates); - distance = convertDistance(distance); + distance = convertToString ? convertDistanceToString(distance) : convertDistance(distance); return distance; } From 2d4e3cb42f73fb54c154ce7abd8fc8aa3d8eb3d7 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 10 Jun 2023 19:47:10 -0300 Subject: [PATCH 074/107] chore: move notify logic to notification service --- src/services/HelpOfferService.js | 3 ++ src/services/HelpService.js | 41 ++-------------------------- src/services/NotificationService.js | 32 ++++++++++++++++++++++ src/utils/geolocation/buildLatLng.js | 6 ++++ 4 files changed, 44 insertions(+), 38 deletions(-) create mode 100644 src/utils/geolocation/buildLatLng.js diff --git a/src/services/HelpOfferService.js b/src/services/HelpOfferService.js index 2bea7335..f49d6ee6 100644 --- a/src/services/HelpOfferService.js +++ b/src/services/HelpOfferService.js @@ -21,6 +21,9 @@ class OfferedHelpService { const newOfferdHelp = await this.OfferedHelpRepository.create( offeredHelpInfo, ); + const title = 'Oferta criada próximo a você'; + const body = 'Entre no aplicativo para conferir.'; + this.NotificationService.notifyNearUsers(title, body, newOfferdHelp.ownerId); return newOfferdHelp; } diff --git a/src/services/HelpService.js b/src/services/HelpService.js index f35e0789..ee9de69c 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -9,7 +9,6 @@ const NotificationMixin = require('../utils/NotificationMixin'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); const saveError = require('../utils/ErrorHistory'); const SocialNetworkService = require('./SocialNetworkService'); -const { getDistance } = require('../utils/geolocation/calculateDistance'); class HelpService { constructor() { @@ -37,45 +36,11 @@ class HelpService { JSON.parse(JSON.stringify(createdHelp.ownerId)), ); sendMessage(sendSocketMessageTo, 'new-help', createdHelp); - this.notifyNearUsers(createdHelp); - // this.notificationToFollowers(createdHelp.ownerId, createdHelp.id); - } - - async notifyNearUsers(helpInfo) { - const users = await this.UserService.getUsersWithDevice({ fields: 'location deviceId' }); - const currentUser = await this.UserService.getUser({ id: helpInfo.ownerId }); - const usersWithLocation = users.filter((user) => !!user.location?.coordinates); - const nearUsers = usersWithLocation.filter((user) => { - const distance = getDistance( - this.buildLatlongObject(currentUser.location.coordinates), - this.buildLatlongObject(user.location.coordinates), - false, - ); - return distance < 5000000; - }); - nearUsers.forEach((user) => this.notifyUser(user)); - } - async notifyUser(user) { - const title = 'Pedido criado próxima a você'; + const title = 'Pedido criado próximo a você'; const body = 'Entre no aplicativo para conferir.'; - try { - await this.NotificationMixin.sendNotification( - user.deviceId, - title, - body, - ); - } catch (err) { - console.log('Não foi possível enviar a notificação!'); - saveError(err); - } - } - - buildLatlongObject(coords) { - return { - longitude: coords[0], - latitude: coords[1], - }; + this.NotificationService.notifyNearUsers(title, body, createdHelp.ownerId); + // this.notificationToFollowers(createdHelp.ownerId, createdHelp.id); } /* TODO: Create logic to notificate the followers diff --git a/src/services/NotificationService.js b/src/services/NotificationService.js index 4502a21f..dcd0c08c 100644 --- a/src/services/NotificationService.js +++ b/src/services/NotificationService.js @@ -1,11 +1,15 @@ const { notificationTypesEnum } = require('../models/Notification'); const NotificationRepository = require('../repository/NotificationRepository'); +const saveError = require('../utils/ErrorHistory'); const notify = require('../utils/Notification'); +const buildLatLong = require('../utils/geolocation/buildLatLng'); +const { getDistance } = require('../utils/geolocation/calculateDistance'); const UserService = require('./UserService').default; class NotificationService { constructor() { this.notificationRepository = new NotificationRepository(); + this.UserService = new UserService(); } async getUserNotificationsById(id) { @@ -20,6 +24,34 @@ class NotificationService { return notificationCreated; } + async notifyNearUsers(title, body, ownerId) { + const users = await this.UserService.getUsersWithDevice({ fields: 'location deviceId' }); + const currentUser = await this.UserService.getUser({ id: ownerId }); + const usersWithLocation = users.filter((user) => !!user.location?.coordinates); + const nearUsers = usersWithLocation.filter((user) => { + const distance = getDistance( + buildLatLong(currentUser.location.coordinates), + buildLatLong(user.location.coordinates), + false, + ); + return distance < 5000000; + }); + nearUsers.forEach((user) => this.notifyUser(user, title, body)); + } + + async notifyUser(user, title, body) { + try { + await this.NotificationMixin.sendNotification( + user.deviceId, + title, + body, + ); + } catch (err) { + console.log('Não foi possível enviar a notificação!'); + saveError(err); + } + } + async createAndSendNotifications(title, body) { const userService = new UserService(); const users = await userService.getUsersWithDevice(); diff --git a/src/utils/geolocation/buildLatLng.js b/src/utils/geolocation/buildLatLng.js new file mode 100644 index 00000000..2a8dc540 --- /dev/null +++ b/src/utils/geolocation/buildLatLng.js @@ -0,0 +1,6 @@ +const buildLatLong = (coords) => ({ + longitude: coords[0], + latitude: coords[1], +}); + +module.exports = buildLatLong; From faaa5098d88586da7a3e1ecb3cd155695283653c Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 10 Jun 2023 20:19:04 -0300 Subject: [PATCH 075/107] chore: fix lint --- src/services/HelpService.js | 2 +- src/services/NotificationService.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/services/HelpService.js b/src/services/HelpService.js index ee9de69c..6420ac38 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -23,7 +23,7 @@ class HelpService { async createHelp(data) { const countHelp = await this.HelpRepository.countDocuments(data.ownerId); - if (countHelp >= 20) { + if (countHelp >= 5) { throw new Error('Limite máximo de pedidos atingido'); } diff --git a/src/services/NotificationService.js b/src/services/NotificationService.js index dcd0c08c..d662a027 100644 --- a/src/services/NotificationService.js +++ b/src/services/NotificationService.js @@ -4,12 +4,14 @@ const saveError = require('../utils/ErrorHistory'); const notify = require('../utils/Notification'); const buildLatLong = require('../utils/geolocation/buildLatLng'); const { getDistance } = require('../utils/geolocation/calculateDistance'); -const UserService = require('./UserService').default; +const UserService = require('./UserService'); +const NotificationMixin = require('../utils/NotificationMixin'); class NotificationService { constructor() { this.notificationRepository = new NotificationRepository(); this.UserService = new UserService(); + this.NotificationMixin = new NotificationMixin(); } async getUserNotificationsById(id) { @@ -36,7 +38,12 @@ class NotificationService { ); return distance < 5000000; }); - nearUsers.forEach((user) => this.notifyUser(user, title, body)); + nearUsers.forEach((user) => { + console.log(user._id.toString(), ownerId.toString()); + if (user._id.toString() !== ownerId.toString()) { + this.notifyUser(user, title, body); + } + }); } async notifyUser(user, title, body) { From 69476e4bad5bf874563c5fe40a4710309ece20f7 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 10 Jun 2023 20:46:34 -0300 Subject: [PATCH 076/107] chore: i dont know why this file were here --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 27af52e795045dd4dc64bf57894461ef6d32cf6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%T60H6g?&pN+=456`M-)14QZ{OhXXL0xFfV4tX_d84^T5z;5>ahyFspudDXl zYYW*kfh9udUdcWl`#yY+$Kx>o*Snj30(JqkSOl9}tk#H(OR335=;;uh`dHx>LktJS za#GW_4r9O=cxw#E-fhXA<<6ZU+P~vsIp&yr7(TOf|EaJAY+`~X7Wj@In9E*|bpKRz zcW{U=IK?-7#Q;5=vo+xJF}k?IG_`ggE7p6MGSUQ>oZAf!H0~9y*|%a(7mxH&q&_z0 z6(3vZM?PfE1!k#@X81eGuo>d6DteM#tkBYi)m3 zVr?_hQezF7wY2UelUmHbHM?t!l*19`${OcM`$d|Y@)pmv%@sQ$Gku&8*Q}PX<~k8; z4f?&oB=rk&mS}C`p0gP19Q?}OuFaqCLSonEYLDoDLG8k?Xd20pvBZKzn7qIM&uo#_ z2ai@81IB>ma$PtS3rbKV*!WF}L zbM|LJFArFH^yYBk^5H^c7j7s{qtkz;>TtP7tBnC;AZ4K8A9v;aKYITDpBmYdF<=b5 zD+XM%f7b6YrEs>^l9RJGW4T}v5xvr*ny?DTu{Pu=-e*zaSSAf(9 Date: Sat, 10 Jun 2023 20:48:25 -0300 Subject: [PATCH 077/107] chore: ooops, a wild console log appears --- src/services/NotificationService.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/NotificationService.js b/src/services/NotificationService.js index d662a027..228b2418 100644 --- a/src/services/NotificationService.js +++ b/src/services/NotificationService.js @@ -39,7 +39,6 @@ class NotificationService { return distance < 5000000; }); nearUsers.forEach((user) => { - console.log(user._id.toString(), ownerId.toString()); if (user._id.toString() !== ownerId.toString()) { this.notifyUser(user, title, body); } From 8d1573d4ac94537d11844fa9b99edb056a8efea1 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Tue, 20 Jun 2023 07:18:57 -0300 Subject: [PATCH 078/107] chore: update mocked badges --- .../seed/mockedInfos/mockedBadgesInfo.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/utils/seed/mockedInfos/mockedBadgesInfo.js b/src/utils/seed/mockedInfos/mockedBadgesInfo.js index 48a35201..df057830 100644 --- a/src/utils/seed/mockedInfos/mockedBadgesInfo.js +++ b/src/utils/seed/mockedInfos/mockedBadgesInfo.js @@ -30,31 +30,31 @@ const mockedBadges = [ }, { _id: 6, - name: 'Testador Beta 3', - description: 'Paritcipou do beta do app', - iconName: 'home', + name: 'Mudando Vidas 3', + description: 'Finalizou dez ofertas no aplicativo', + iconName: 'stars', neededValue: 5, rank: 3, - category: 'tester', + category: 'help', }, { _id: 5, - name: 'Testador Beta 2', - description: 'Paritcipou do beta do app', - iconName: 'home', - neededValue: 2, + name: 'Mudando Vidas 2', + description: 'Finalizou cinco ofertas no aplicativo', + iconName: 'stars', + neededValue: 5, rank: 2, - category: 'tester', + category: 'help', nextBadge: 6, }, { _id: 4, - name: 'Testador Beta 1', - description: 'Paritcipou do beta do app', - iconName: 'home', + name: 'Mudando Vidas 1', + description: 'Criou uma oferta no aplicativo', + iconName: 'stars', neededValue: 1, rank: 1, - category: 'tester', + category: 'help', nextBadge: 5, }, ]; From 384648bc45b365b9ef2479341b470f340f2004a7 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Tue, 20 Jun 2023 07:19:39 -0300 Subject: [PATCH 079/107] feat: add new fields in badge model and create logic to mark as viewed --- src/controllers/BadgeController.js | 25 +++++++++++++++++++------ src/models/Badge.js | 7 +++++++ src/repository/BadgeRepository.js | 5 +++++ src/routes/BadgeRoutes.js | 8 ++++++++ src/services/BadgeService.js | 13 ++++++++++--- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/controllers/BadgeController.js b/src/controllers/BadgeController.js index 2b929c3e..59939a9c 100644 --- a/src/controllers/BadgeController.js +++ b/src/controllers/BadgeController.js @@ -30,6 +30,21 @@ class BadgeController { } } + async getBadgeHistory(req, res, next) { + const userId = req.query.userId || null; + try { + const userBadges = await this.BadgeService.getBadgeList(userId); + const allBadges = await this.BadgeService.getAllBadges(); + const parsedUserBadges = parseBadgeByCategory(userBadges); + res.status(200).json({ userBadges: parsedUserBadges, allBadges }); + next(); + } catch (err) { + await saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } + async getBadgeList(req, res, next) { const userId = req.query.userId || null; try { @@ -43,13 +58,11 @@ class BadgeController { } } - async getBadgeHistory(req, res, next) { - const userId = req.query.userId || null; + async markBadgeAsViewed(req, res, next) { + const { badgeId } = req.params; try { - const userBadges = await this.BadgeService.getBadgeList(userId); - const allBadges = await this.BadgeService.getAllBadges(); - const parsedUserBadges = parseBadgeByCategory(userBadges); - res.status(200).json({ userBadges: parsedUserBadges, allBadges }); + await this.BadgeService.markBadgeAsViewed(badgeId); + res.status(200).json({ message: 'Badge visualized' }); next(); } catch (err) { await saveError(err); diff --git a/src/models/Badge.js b/src/models/Badge.js index 76cef641..b9fae208 100644 --- a/src/models/Badge.js +++ b/src/models/Badge.js @@ -16,6 +16,13 @@ const badgeSchema = new mongoose.Schema( ref: 'User', required: true, }, + updatedAt: { + type: Date, + default: Date.now, + }, + visualizedAt: { + type: Date, + }, }, { collection: 'badge' }, ); diff --git a/src/repository/BadgeRepository.js b/src/repository/BadgeRepository.js index e221ac96..4f0cb5e1 100644 --- a/src/repository/BadgeRepository.js +++ b/src/repository/BadgeRepository.js @@ -41,6 +41,11 @@ class BadgeRepository extends BaseRepository { ); return result; } + + async getById(id) { + const result = await super.$getById(id, null, this.populateData); + return result; + } } module.exports = BadgeRepository; diff --git a/src/routes/BadgeRoutes.js b/src/routes/BadgeRoutes.js index 1d190900..321748a5 100644 --- a/src/routes/BadgeRoutes.js +++ b/src/routes/BadgeRoutes.js @@ -16,4 +16,12 @@ routes.get('/badges/history', async (req, res, next) => { badgeController.getBadgeHistory(req, res, next); }); +routes.put('/badges/:badgeId', async (req, res, next) => { + badgeController.markBadgeAsViewed(req, res, next); +}); + +routes.get('/badges/list', async (req, res, next) => { + badgeController.getBadgeList(req, res, next); +}); + module.exports = routes; diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index 4a4cda95..2d0ee1f3 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -11,22 +11,21 @@ class BadgeService { async createOrUpdateBadge(userId, category) { const badges = await this.BadgeRepository.listByUserId(userId); let badge = badges.find((item) => item.template.category === category); - let recentUpdated = false; if (!badge) { const referenceBadge = await this.BadgeTemplateRepository.getFirstRankByCategory(category); badge = await this.BadgeRepository.create({ user: userId, template: referenceBadge._id, }); - recentUpdated = true; } badge.currentValue += 1; const updatedBadge = await this.BadgeRepository.update(badge); - return { badge: updatedBadge, recentUpdated }; + return { badge: updatedBadge }; } async updateBadgeReference(badge) { badge.template = badge.template.nextBadge; + badge.updatedAt = Date.now(); const updatedBadge = await this.BadgeRepository.update(badge); return { badge: updatedBadge, recentUpdated: true }; } @@ -40,6 +39,14 @@ class BadgeService { const badges = await this.BadgeTemplateRepository.listAllSorted(); return parseBadgeTemplateByCategory(badges); } + + async markBadgeAsViewed(badgeId) { + const badge = await this.BadgeRepository.getById(badgeId); + console.log(badge); + console.log(Date.now()); + badge.visualizedAt = Date.now(); + await this.BadgeRepository.update(badge); + } } module.exports = BadgeService; From 70e638e24ee11673e37dea61984ce0c518ebe803 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Thu, 22 Jun 2023 06:42:34 -0300 Subject: [PATCH 080/107] chore: removing consoles --- src/services/BadgeService.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/services/BadgeService.js b/src/services/BadgeService.js index 2d0ee1f3..0aced093 100644 --- a/src/services/BadgeService.js +++ b/src/services/BadgeService.js @@ -42,8 +42,6 @@ class BadgeService { async markBadgeAsViewed(badgeId) { const badge = await this.BadgeRepository.getById(badgeId); - console.log(badge); - console.log(Date.now()); badge.visualizedAt = Date.now(); await this.BadgeRepository.update(badge); } From 38ad36e5e976dbe5c4a1c851d4032f7c85f0c1e2 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Fri, 23 Jun 2023 02:48:32 -0300 Subject: [PATCH 081/107] fix: fix missing category array --- src/controllers/HelpOfferController.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/HelpOfferController.js b/src/controllers/HelpOfferController.js index 39c3d42b..c1e3dc07 100644 --- a/src/controllers/HelpOfferController.js +++ b/src/controllers/HelpOfferController.js @@ -36,8 +36,15 @@ class OfferedHelpController { const getOtherUsers = req.query.getOtherUsers === 'true'; const { isUserEntity } = global; const coords = req.query.coords.split(',').map((coord) => Number(coord)); + const categoryArray = req.query.categoryId ? req.query.categoryId.split(',') : null; try { - const helpOffers = await this.HelpOfferService.listHelpsOffers(coords, userId, isUserEntity, null, getOtherUsers); + const helpOffers = await this.HelpOfferService.listHelpsOffers( + coords, + userId, + isUserEntity, + categoryArray, + getOtherUsers, + ); return res.json(helpOffers); } catch (error) { return res.status(400).json({ error: error.message }); From c546824cc3689dcd5422e098ff3131789af07a1b Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 23 Jun 2023 22:54:39 -0300 Subject: [PATCH 082/107] feat: create timeline event structure --- src/config/database.js | 2 + src/controllers/TimelineEventController.js | 24 +++++++++++ src/models/TimelineEvent.js | 23 ++++++++++ src/models/TimelineEventTemplate.js | 25 +++++++++++ src/repository/TimelineEventRepository.js | 26 ++++++++++++ src/routes/BaseRoutes.js | 2 + src/routes/TimelineEventRoutes.js | 11 +++++ src/services/TimelineEventService.js | 22 ++++++++++ src/utils/enums/timelineEnum.js | 10 +++++ src/utils/seed/TimelineEventTemplateSeed.js | 23 ++++++++++ .../mockedTimelineEventTemplatesInfo.js | 42 +++++++++++++++++++ 11 files changed, 210 insertions(+) create mode 100644 src/controllers/TimelineEventController.js create mode 100644 src/models/TimelineEvent.js create mode 100644 src/models/TimelineEventTemplate.js create mode 100644 src/repository/TimelineEventRepository.js create mode 100644 src/routes/TimelineEventRoutes.js create mode 100644 src/services/TimelineEventService.js create mode 100644 src/utils/enums/timelineEnum.js create mode 100644 src/utils/seed/TimelineEventTemplateSeed.js create mode 100644 src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js diff --git a/src/config/database.js b/src/config/database.js index 4eb074fa..35c7f164 100644 --- a/src/config/database.js +++ b/src/config/database.js @@ -4,6 +4,7 @@ const UserSeed = require('../utils/seed/UserSeed'); const HelpSeed = require('../utils/seed/HelpOfferCampaignSeed'); const NotificationSeed = require('../utils/seed/NotificationSeed'); const BadgeSeed = require('../utils/seed/BadgeTemplateSeed'); +const TimelineEventTemplateSeed = require('../utils/seed/TimelineEventTemplateSeed'); const databaseURL = process.env.DATABASE_URL || 'mongodb://mongo:27017/miaAjudaDB'; const envType = process.env.NODE_ENV || 'development'; @@ -24,6 +25,7 @@ const databaseConnect = async () => { await HelpSeed(); await NotificationSeed(); await BadgeSeed(); + await TimelineEventTemplateSeed(); } } catch (err) { console.log('Não foi possível inicicializar corretamente a base de dados!'); diff --git a/src/controllers/TimelineEventController.js b/src/controllers/TimelineEventController.js new file mode 100644 index 00000000..4c940ead --- /dev/null +++ b/src/controllers/TimelineEventController.js @@ -0,0 +1,24 @@ + +const saveError = require('../utils/ErrorHistory'); +const TimelineEventService = require('../services/TimelineEventService'); + +class TimelineEventController { + constructor() { + this.TimelineEventService = new TimelineEventService(); + } + + async getTimelineEvents(req, res, next) { + const userId = req.query.userId || null; + try { + const result = await this.TimelineEventService.listByUserId(userId); + res.status(200).json(result); + next(); + } catch (err) { + await saveError(err); + res.status(400).json({ error: err.message }); + next(); + } + } +} + +module.exports = TimelineEventController; diff --git a/src/models/TimelineEvent.js b/src/models/TimelineEvent.js new file mode 100644 index 00000000..8e5c0c1f --- /dev/null +++ b/src/models/TimelineEvent.js @@ -0,0 +1,23 @@ +const mongoose = require('mongoose'); + +const timelineEventSchema = new mongoose.Schema( + { + template: { + type: Number, + ref: 'TimelineEventTemplate', + required: true, + }, + createdAt: { + type: Date, + default: Date.now, + }, + user: { + type: String, + ref: 'User', + required: true, + } + }, + { collection: 'timelineEvent' }, +); + +module.exports = mongoose.model('TimelineEvent', timelineEventSchema); diff --git a/src/models/TimelineEventTemplate.js b/src/models/TimelineEventTemplate.js new file mode 100644 index 00000000..9321a994 --- /dev/null +++ b/src/models/TimelineEventTemplate.js @@ -0,0 +1,25 @@ +const mongoose = require('mongoose'); + +const timelineEventTemplateSchema = new mongoose.Schema( + { + _id: { + type: Number, + required: true, + }, + title: { + type: String, + required: true, + }, + description: { + type: String, + required: true, + }, + iconName: { + type: String, + required: true, + }, + }, + { collection: 'timelineEventTemplate' }, +); + +module.exports = mongoose.model('TimelineEventTemplate', timelineEventTemplateSchema); diff --git a/src/repository/TimelineEventRepository.js b/src/repository/TimelineEventRepository.js new file mode 100644 index 00000000..2f0ddf84 --- /dev/null +++ b/src/repository/TimelineEventRepository.js @@ -0,0 +1,26 @@ +const BaseRepository = require('./BaseRepository'); +const TimelineEventSchema = require('../models/TimelineEvent'); + +class TimelineEventRepository extends BaseRepository { + constructor() { + super(TimelineEventSchema); + this.populateData = ['template']; + } + + async create(timelineEvent) { + const result = await super.$save(timelineEvent, {}, this.populateData); + return result; + } + + async getUserEvent(userId, templateId) { + const result = await super.$findOne({ user: userId, template: templateId }, null, this.populateData); + return result; + } + + async listByUserId(userId) { + const result = await super.$list({ user: userId }, null, this.populateData); + return result; + } +} + +module.exports = TimelineEventRepository; diff --git a/src/routes/BaseRoutes.js b/src/routes/BaseRoutes.js index 6df36130..c6325a1e 100644 --- a/src/routes/BaseRoutes.js +++ b/src/routes/BaseRoutes.js @@ -10,6 +10,7 @@ const campaignRoutes = require('./CampaignRoutes'); const socialNetworkRoutes = require('./SocialNetworkRoutes'); const badgeRoutes = require('./BadgeRoutes'); const feedbackRoutes = require('./FeedbackRoutes'); +const timelineEventRoutes = require('./TimelineEventRoutes'); const swaggerDocument = YAML.load('docs/swagger.yaml'); @@ -26,5 +27,6 @@ module.exports = (app) => { socialNetworkRoutes, badgeRoutes, feedbackRoutes, + timelineEventRoutes, ]); }; diff --git a/src/routes/TimelineEventRoutes.js b/src/routes/TimelineEventRoutes.js new file mode 100644 index 00000000..802ce8fe --- /dev/null +++ b/src/routes/TimelineEventRoutes.js @@ -0,0 +1,11 @@ +const express = require('express'); +const TimelineEventController = require('../controllers/TimelineEventController'); + +const timelineEventController = new TimelineEventController(); +const routes = express.Router(); + +routes.get('/timeline', async (req, res, next) => { + timelineEventController.getTimelineEvents(req, res, next); +}); + +module.exports = routes; diff --git a/src/services/TimelineEventService.js b/src/services/TimelineEventService.js new file mode 100644 index 00000000..ff6c91dd --- /dev/null +++ b/src/services/TimelineEventService.js @@ -0,0 +1,22 @@ +const TimelineEventRepository = require('../repository/TimelineEventRepository'); + +class TimelineEventService { + constructor() { + this.TimeLineEventRepository = new TimelineEventRepository(); + } + async create(timelineEvent) { + const { user, template } = timelineEvent; + const userEvent = await this.TimeLineEventRepository.getUserEvent(user, template); + if (userEvent) { + return + } + const result = await this.TimeLineEventRepository.create(timelineEvent); + return result; + } + async listByUserId(userId) { + const result = await this.TimeLineEventRepository.listByUserId(userId); + return result; + } +} + +module.exports = TimelineEventService; diff --git a/src/utils/enums/timelineEnum.js b/src/utils/enums/timelineEnum.js new file mode 100644 index 00000000..828c1f2a --- /dev/null +++ b/src/utils/enums/timelineEnum.js @@ -0,0 +1,10 @@ +const timelineEnum = { + register: 1, + offerHelp: 2, + createRequest: 3, + finishRequest: 4, + feedback: 5, + offer: 6, +} + +module.exports = timelineEnum; \ No newline at end of file diff --git a/src/utils/seed/TimelineEventTemplateSeed.js b/src/utils/seed/TimelineEventTemplateSeed.js new file mode 100644 index 00000000..bf4d1891 --- /dev/null +++ b/src/utils/seed/TimelineEventTemplateSeed.js @@ -0,0 +1,23 @@ +const TimelineEventTemplate = require('../../models/TimelineEventTemplate'); +const mockedTimelineEventTemplates = require('./mockedInfos/mockedTimelineEventTemplatesInfo'); + +const seedTimelineEventTemplates = async () => { + try { + const timelineEventTemplateCollection = await TimelineEventTemplate.find(); + if (timelineEventTemplateCollection.length > 0) { + return; + } + const timelineEventTemplates = mockedTimelineEventTemplates.map((timelineEventTemplate) => new TimelineEventTemplate(timelineEventTemplate)); + await TimelineEventTemplate.deleteMany({}); + timelineEventTemplates.forEach((timelineEventTemplate) => { + TimelineEventTemplate.create(timelineEventTemplate); + } + ); + console.log('Templates de eventos de linha do tempo populados com sucesso!'); + } catch (error) { + console.log('Não foi possível popular os templates de eventos de linha do tempo na base de dados!'); + console.log(error); + } +} + +module.exports = seedTimelineEventTemplates; diff --git a/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js b/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js new file mode 100644 index 00000000..f55a90bb --- /dev/null +++ b/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js @@ -0,0 +1,42 @@ +const timelineEnum = require("../../enums/timelineEnum"); + +const mockedTimelineEventTemplates = [ + { + _id: timelineEnum.register, + title: 'Se cadastrou no aplicativo', + description: 'Começou a fazer parte da comunidade para ajudar pessoas ou ser ajudado.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.offerHelp, + title: 'Ofereceu ajuda a um pedido', + description: 'Você tentou fazer a diferença na vida de uma pessoa pela primeira vez utilizando o aplicativo Mia Ajuda.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.createRequest, + title: 'Criou um pedido de ajuda', + description: 'Você conseguiu criar um pedido de ajuda no aplicativo.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.finishRequest, + title: 'Finalizou um pedido de ajuda', + description: 'Alguém conseguiu te ajudar e seu pedido foi finalizado.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.feedback, + title: 'Deixou um feedback', + description: 'Você deixou um feedback para uma pessoa que te ajudou, mostrando para ela a importância de sua ajuda.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.offer, + title: 'Realizou uma oferta', + description: 'Você realizou uma oferta de ajuda para uma pessoa que precisava.', + iconName: 'hand-wave', + } +] + +module.exports = mockedTimelineEventTemplates; \ No newline at end of file From 548b09e7ba7f571383fb177debc262afecadf128 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 23 Jun 2023 22:55:00 -0300 Subject: [PATCH 083/107] feat: create help timeline events --- src/controllers/HelpController.js | 6 +++++- src/services/HelpService.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controllers/HelpController.js b/src/controllers/HelpController.js index f089040a..bd399c60 100644 --- a/src/controllers/HelpController.js +++ b/src/controllers/HelpController.js @@ -1,20 +1,23 @@ const HelpService = require('../services/HelpService'); const UserService = require('../services/UserService'); +const TimelineEventService = require('../services/TimelineEventService'); const saveError = require('../utils/ErrorHistory'); +const timelineEnum = require('../utils/enums/timelineEnum'); class HelpController { constructor() { this.HelpService = new HelpService(); this.UserService = new UserService(); + this.TimelineEventService = new TimelineEventService(); } async createHelp(req, res, next) { const data = { ...req.body, }; - try { await this.HelpService.createHelp(data); + await this.TimelineEventService.create({user: data.ownerId, template: timelineEnum.createRequest}) res.status(201).send(); next(); } catch (err) { @@ -119,6 +122,7 @@ class HelpController { try { await this.HelpService.ownerConfirmation(data); + await this.TimelineEventService.create({user: data.ownerId, template: timelineEnum.finishRequest}) res.status(204).send(); next(); } catch (err) { diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 6420ac38..2128db19 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -23,7 +23,7 @@ class HelpService { async createHelp(data) { const countHelp = await this.HelpRepository.countDocuments(data.ownerId); - if (countHelp >= 5) { + if (countHelp >= 15) { throw new Error('Limite máximo de pedidos atingido'); } From 6e36d0d6d2a6b9fb70aabbeb9b48df9439a2a3b5 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Fri, 23 Jun 2023 22:56:40 -0300 Subject: [PATCH 084/107] chore: fix lint --- src/controllers/HelpController.js | 4 +- src/controllers/TimelineEventController.js | 28 +++---- src/models/TimelineEvent.js | 2 +- src/routes/TimelineEventRoutes.js | 2 +- src/services/TimelineEventService.js | 4 +- src/utils/enums/timelineEnum.js | 16 ++-- src/utils/seed/TimelineEventTemplateSeed.js | 33 ++++---- .../mockedTimelineEventTemplatesInfo.js | 78 +++++++++---------- 8 files changed, 85 insertions(+), 82 deletions(-) diff --git a/src/controllers/HelpController.js b/src/controllers/HelpController.js index bd399c60..ae2277a7 100644 --- a/src/controllers/HelpController.js +++ b/src/controllers/HelpController.js @@ -17,7 +17,7 @@ class HelpController { }; try { await this.HelpService.createHelp(data); - await this.TimelineEventService.create({user: data.ownerId, template: timelineEnum.createRequest}) + await this.TimelineEventService.create({ user: data.ownerId, template: timelineEnum.createRequest }); res.status(201).send(); next(); } catch (err) { @@ -122,7 +122,7 @@ class HelpController { try { await this.HelpService.ownerConfirmation(data); - await this.TimelineEventService.create({user: data.ownerId, template: timelineEnum.finishRequest}) + await this.TimelineEventService.create({ user: data.ownerId, template: timelineEnum.finishRequest }); res.status(204).send(); next(); } catch (err) { diff --git a/src/controllers/TimelineEventController.js b/src/controllers/TimelineEventController.js index 4c940ead..9bdcc296 100644 --- a/src/controllers/TimelineEventController.js +++ b/src/controllers/TimelineEventController.js @@ -3,22 +3,22 @@ const saveError = require('../utils/ErrorHistory'); const TimelineEventService = require('../services/TimelineEventService'); class TimelineEventController { - constructor() { - this.TimelineEventService = new TimelineEventService(); - } + constructor() { + this.TimelineEventService = new TimelineEventService(); + } - async getTimelineEvents(req, res, next) { - const userId = req.query.userId || null; - try { - const result = await this.TimelineEventService.listByUserId(userId); - res.status(200).json(result); - next(); - } catch (err) { - await saveError(err); - res.status(400).json({ error: err.message }); - next(); - } + async getTimelineEvents(req, res, next) { + const userId = req.query.userId || null; + try { + const result = await this.TimelineEventService.listByUserId(userId); + res.status(200).json(result); + next(); + } catch (err) { + await saveError(err); + res.status(400).json({ error: err.message }); + next(); } + } } module.exports = TimelineEventController; diff --git a/src/models/TimelineEvent.js b/src/models/TimelineEvent.js index 8e5c0c1f..675c75ce 100644 --- a/src/models/TimelineEvent.js +++ b/src/models/TimelineEvent.js @@ -15,7 +15,7 @@ const timelineEventSchema = new mongoose.Schema( type: String, ref: 'User', required: true, - } + }, }, { collection: 'timelineEvent' }, ); diff --git a/src/routes/TimelineEventRoutes.js b/src/routes/TimelineEventRoutes.js index 802ce8fe..e89af7f8 100644 --- a/src/routes/TimelineEventRoutes.js +++ b/src/routes/TimelineEventRoutes.js @@ -5,7 +5,7 @@ const timelineEventController = new TimelineEventController(); const routes = express.Router(); routes.get('/timeline', async (req, res, next) => { - timelineEventController.getTimelineEvents(req, res, next); + timelineEventController.getTimelineEvents(req, res, next); }); module.exports = routes; diff --git a/src/services/TimelineEventService.js b/src/services/TimelineEventService.js index ff6c91dd..7c5227e1 100644 --- a/src/services/TimelineEventService.js +++ b/src/services/TimelineEventService.js @@ -4,15 +4,17 @@ class TimelineEventService { constructor() { this.TimeLineEventRepository = new TimelineEventRepository(); } + async create(timelineEvent) { const { user, template } = timelineEvent; const userEvent = await this.TimeLineEventRepository.getUserEvent(user, template); if (userEvent) { - return + return userEvent; } const result = await this.TimeLineEventRepository.create(timelineEvent); return result; } + async listByUserId(userId) { const result = await this.TimeLineEventRepository.listByUserId(userId); return result; diff --git a/src/utils/enums/timelineEnum.js b/src/utils/enums/timelineEnum.js index 828c1f2a..e049daca 100644 --- a/src/utils/enums/timelineEnum.js +++ b/src/utils/enums/timelineEnum.js @@ -1,10 +1,10 @@ const timelineEnum = { - register: 1, - offerHelp: 2, - createRequest: 3, - finishRequest: 4, - feedback: 5, - offer: 6, -} + register: 1, + offerHelp: 2, + createRequest: 3, + finishRequest: 4, + feedback: 5, + offer: 6, +}; -module.exports = timelineEnum; \ No newline at end of file +module.exports = timelineEnum; diff --git a/src/utils/seed/TimelineEventTemplateSeed.js b/src/utils/seed/TimelineEventTemplateSeed.js index bf4d1891..a8b6b235 100644 --- a/src/utils/seed/TimelineEventTemplateSeed.js +++ b/src/utils/seed/TimelineEventTemplateSeed.js @@ -2,22 +2,23 @@ const TimelineEventTemplate = require('../../models/TimelineEventTemplate'); const mockedTimelineEventTemplates = require('./mockedInfos/mockedTimelineEventTemplatesInfo'); const seedTimelineEventTemplates = async () => { - try { - const timelineEventTemplateCollection = await TimelineEventTemplate.find(); - if (timelineEventTemplateCollection.length > 0) { - return; - } - const timelineEventTemplates = mockedTimelineEventTemplates.map((timelineEventTemplate) => new TimelineEventTemplate(timelineEventTemplate)); - await TimelineEventTemplate.deleteMany({}); - timelineEventTemplates.forEach((timelineEventTemplate) => { - TimelineEventTemplate.create(timelineEventTemplate); - } - ); - console.log('Templates de eventos de linha do tempo populados com sucesso!'); - } catch (error) { - console.log('Não foi possível popular os templates de eventos de linha do tempo na base de dados!'); - console.log(error); + try { + const timelineEventTemplateCollection = await TimelineEventTemplate.find(); + if (timelineEventTemplateCollection.length > 0) { + return; } -} + const timelineEventTemplates = mockedTimelineEventTemplates.map( + (timelineEventTemplate) => new TimelineEventTemplate(timelineEventTemplate), + ); + await TimelineEventTemplate.deleteMany({}); + timelineEventTemplates.forEach((timelineEventTemplate) => { + TimelineEventTemplate.create(timelineEventTemplate); + }); + console.log('Templates de eventos de linha do tempo populados com sucesso!'); + } catch (error) { + console.log('Não foi possível popular os templates de eventos de linha do tempo na base de dados!'); + console.log(error); + } +}; module.exports = seedTimelineEventTemplates; diff --git a/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js b/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js index f55a90bb..0ea303bc 100644 --- a/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js +++ b/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js @@ -1,42 +1,42 @@ -const timelineEnum = require("../../enums/timelineEnum"); +const timelineEnum = require('../../enums/timelineEnum'); const mockedTimelineEventTemplates = [ - { - _id: timelineEnum.register, - title: 'Se cadastrou no aplicativo', - description: 'Começou a fazer parte da comunidade para ajudar pessoas ou ser ajudado.', - iconName: 'hand-wave', - }, - { - _id: timelineEnum.offerHelp, - title: 'Ofereceu ajuda a um pedido', - description: 'Você tentou fazer a diferença na vida de uma pessoa pela primeira vez utilizando o aplicativo Mia Ajuda.', - iconName: 'hand-wave', - }, - { - _id: timelineEnum.createRequest, - title: 'Criou um pedido de ajuda', - description: 'Você conseguiu criar um pedido de ajuda no aplicativo.', - iconName: 'hand-wave', - }, - { - _id: timelineEnum.finishRequest, - title: 'Finalizou um pedido de ajuda', - description: 'Alguém conseguiu te ajudar e seu pedido foi finalizado.', - iconName: 'hand-wave', - }, - { - _id: timelineEnum.feedback, - title: 'Deixou um feedback', - description: 'Você deixou um feedback para uma pessoa que te ajudou, mostrando para ela a importância de sua ajuda.', - iconName: 'hand-wave', - }, - { - _id: timelineEnum.offer, - title: 'Realizou uma oferta', - description: 'Você realizou uma oferta de ajuda para uma pessoa que precisava.', - iconName: 'hand-wave', - } -] + { + _id: timelineEnum.register, + title: 'Se cadastrou no aplicativo', + description: 'Começou a fazer parte da comunidade para ajudar pessoas ou ser ajudado.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.offerHelp, + title: 'Ofereceu ajuda a um pedido', + description: 'Você tentou fazer a diferença na vida de uma pessoa pela primeira vez utilizando o aplicativo Mia Ajuda.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.createRequest, + title: 'Criou um pedido de ajuda', + description: 'Você conseguiu criar um pedido de ajuda no aplicativo.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.finishRequest, + title: 'Finalizou um pedido de ajuda', + description: 'Alguém conseguiu te ajudar e seu pedido foi finalizado.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.feedback, + title: 'Deixou um feedback', + description: 'Você deixou um feedback para uma pessoa que te ajudou, mostrando para ela a importância de sua ajuda.', + iconName: 'hand-wave', + }, + { + _id: timelineEnum.offer, + title: 'Realizou uma oferta', + description: 'Você realizou uma oferta de ajuda para uma pessoa que precisava.', + iconName: 'hand-wave', + }, +]; -module.exports = mockedTimelineEventTemplates; \ No newline at end of file +module.exports = mockedTimelineEventTemplates; From 859ce938d2edd363568586a1ea30d35992adf746 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 24 Jun 2023 00:02:41 -0300 Subject: [PATCH 085/107] feat: add more timeline events creations --- src/controllers/FeedbackController.js | 4 ++++ src/controllers/HelpController.js | 1 + src/controllers/HelpOfferController.js | 4 ++++ src/controllers/UserController.js | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/src/controllers/FeedbackController.js b/src/controllers/FeedbackController.js index 31ef3872..c0174dee 100644 --- a/src/controllers/FeedbackController.js +++ b/src/controllers/FeedbackController.js @@ -1,9 +1,12 @@ const FeedbackService = require('../services/FeedbackService'); +const TimelineEventService = require('../services/TimelineEventService'); const saveError = require('../utils/ErrorHistory'); +const timelineEnum = require('../utils/enums/timelineEnum'); class FeedbackController { constructor() { this.FeedbackService = new FeedbackService(); + this.TimelineEventService = new TimelineEventService(); } async create(req, res) { @@ -15,6 +18,7 @@ class FeedbackController { message, }; const newFeedback = await this.FeedbackService.create(feedback); + await this.TimelineEventService.create({ user: sender, template: timelineEnum.feedback }); res.status(200).json(newFeedback); } catch (error) { saveError(error); diff --git a/src/controllers/HelpController.js b/src/controllers/HelpController.js index ae2277a7..402592aa 100644 --- a/src/controllers/HelpController.js +++ b/src/controllers/HelpController.js @@ -151,6 +151,7 @@ class HelpController { try { await this.HelpService.addPossibleHelpers(id, idHelper); + await this.TimelineEventService.create({ user: idHelper, template: timelineEnum.offerHelp }); res.status(204).send(); next(); } catch (err) { diff --git a/src/controllers/HelpOfferController.js b/src/controllers/HelpOfferController.js index c5fd063f..623296ee 100644 --- a/src/controllers/HelpOfferController.js +++ b/src/controllers/HelpOfferController.js @@ -1,9 +1,12 @@ const HelpOfferService = require('../services/HelpOfferService'); +const TimelineEventService = require('../services/TimelineEventService'); const saveError = require('../utils/ErrorHistory'); +const timelineEnum = require('../utils/enums/timelineEnum'); class OfferedHelpController { constructor() { this.HelpOfferService = new HelpOfferService(); + this.TimelineEventService = new TimelineEventService(); } async createHelpOffer(req, res) { @@ -11,6 +14,7 @@ class OfferedHelpController { const newHelpOffer = await this.HelpOfferService.createNewHelpOffer( req.body, ); + await this.TimelineEventService.create({ user: req.body.ownerId, template: timelineEnum.offer }); return res.json(newHelpOffer); } catch (error) { return res.status(400).json({ error: error.message }); diff --git a/src/controllers/UserController.js b/src/controllers/UserController.js index 67f05124..5f12d0e3 100644 --- a/src/controllers/UserController.js +++ b/src/controllers/UserController.js @@ -1,10 +1,13 @@ const UserService = require('../services/UserService'); const { riskGroups } = require('../models/RiskGroup'); const saveError = require('../utils/ErrorHistory'); +const TimelineEventService = require('../services/TimelineEventService'); +const timelineEnum = require('../utils/enums/timelineEnum'); class UserController { constructor() { this.userService = new UserService(); + this.TimelineEventService = new TimelineEventService(); } async createUser(req, res, next) { @@ -15,6 +18,7 @@ class UserController { try { const result = await this.userService.createUser(data); + await this.TimelineEventService.create({ user: result._id, template: timelineEnum.register }); res.status(201).json(result); next(); } catch (err) { From f602b06382d8c2067893d85e45f8469f632489b6 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Sun, 25 Jun 2023 18:30:14 -0300 Subject: [PATCH 086/107] feat: create activity api --- src/controllers/ActivityController.js | 36 ++++++++ src/routes/ActivityRoutes.js | 12 +++ src/routes/BaseRoutes.js | 2 + src/services/ActivityService.js | 122 ++++++++++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 src/controllers/ActivityController.js create mode 100644 src/routes/ActivityRoutes.js create mode 100644 src/services/ActivityService.js diff --git a/src/controllers/ActivityController.js b/src/controllers/ActivityController.js new file mode 100644 index 00000000..cc0bbbb3 --- /dev/null +++ b/src/controllers/ActivityController.js @@ -0,0 +1,36 @@ +const ActivityService = require("../services/ActivityService"); + +class ActivityController { + constructor() { + this.ActivityService = new ActivityService(); + } + + async fetchActivityList(req, res) { + const { id } = req.query; + const { isUserEntity } = global; + const coords = req.query.coords.split(",").map((coord) => Number(coord)); + const categoryArray = req.query.categoryId + ? req.query.categoryId.split(",") + : null; + const activitiesArray = req.query.activityId + ? req.query.activityId.split(",") + : ["getAll"]; + const getOtherUsers = req.query.getOtherUsers === "true"; + + try { + const activityList = await this.ActivityService.fetchActivityList( + coords, + id, + isUserEntity, + categoryArray, + activitiesArray, + getOtherUsers + ); + return res.json(activityList); + } catch (error) { + return res.status(400).json({ error: error.message }); + } + } +} + +module.exports = ActivityController; diff --git a/src/routes/ActivityRoutes.js b/src/routes/ActivityRoutes.js new file mode 100644 index 00000000..5d2f8a0a --- /dev/null +++ b/src/routes/ActivityRoutes.js @@ -0,0 +1,12 @@ +const express = require('express'); +const ActivityController = require('../controllers/ActivityController'); +const isAuthenticated = require('../validation/middlewares/authFirebase'); + +const activityController = new ActivityController(); +const routes = express.Router(); + +routes.get('/activity/list', isAuthenticated, (req, res) => { + activityController.fetchActivityList(req, res); +}); + +module.exports = routes; diff --git a/src/routes/BaseRoutes.js b/src/routes/BaseRoutes.js index 6df36130..3cd1a342 100644 --- a/src/routes/BaseRoutes.js +++ b/src/routes/BaseRoutes.js @@ -10,6 +10,7 @@ const campaignRoutes = require('./CampaignRoutes'); const socialNetworkRoutes = require('./SocialNetworkRoutes'); const badgeRoutes = require('./BadgeRoutes'); const feedbackRoutes = require('./FeedbackRoutes'); +const activityRoutes = require('./ActivityRoutes'); const swaggerDocument = YAML.load('docs/swagger.yaml'); @@ -26,5 +27,6 @@ module.exports = (app) => { socialNetworkRoutes, badgeRoutes, feedbackRoutes, + activityRoutes, ]); }; diff --git a/src/services/ActivityService.js b/src/services/ActivityService.js new file mode 100644 index 00000000..f9c64a3c --- /dev/null +++ b/src/services/ActivityService.js @@ -0,0 +1,122 @@ +const CampaignRepository = require("../repository/CampaignRepository"); +const OfferdHelpRepository = require("../repository/HelpOfferRepository"); +const HelpRepository = require("../repository/HelpRepository"); +const addHelpTypeToList = require("../utils/addHelpTypeToList"); +const sortActivitiesByDistance = require("../utils/sortActivitiesByDistance"); + +class ActivityService { + constructor() { + this.OfferedHelpRepository = new OfferdHelpRepository(); + this.HelpRepository = new HelpRepository(); + this.CampaignRepository = new CampaignRepository(); + } + + async getHelpList(coords, id, isUserEntity, categoryArray) { + const Helplist = await this.HelpRepository.shortList( + coords, + id, + isUserEntity, + categoryArray + ); + if (!Helplist) { + throw new Error( + "Pedidos de ajuda não encontrados no seu raio de distância" + ); + } + + return addHelpTypeToList(Helplist, "help"); + } + + async getHelpOfferList( + coords, + id, + isUserEntity, + categoryArray, + getOtherUsers + ) { + const helpOffers = await this.OfferedHelpRepository.list( + coords, + id, + isUserEntity, + categoryArray, + getOtherUsers + ); + const helpOffersList = addHelpTypeToList(helpOffers, "offer"); + return helpOffersList; + } + + async getCampaignList(coords, except, id, categoryArray) { + const CampaignList = await this.CampaignRepository.listNear( + coords, + except, + id, + categoryArray + ); + if (!CampaignList) { + throw new Error( + "Nenhuma campanha foi encontrada no seu raio de distância" + ); + } + + return addHelpTypeToList(CampaignList, "campaign"); + } + + async fetchActivityList( + coords, + id, + isUserEntity, + categoryArray, + activitiesArray, + getOtherUsers + ) { + const activitiesList = []; + + for (const activity of activitiesArray) { + switch (activity) { + case "help": + activitiesList.push( + await this.getHelpList(coords, id, isUserEntity, categoryArray) + ); + break; + + case "helpOffer": + activitiesList.push( + await this.getHelpOfferList( + coords, + id, + isUserEntity, + categoryArray, + getOtherUsers + ) + ); + break; + + case "campaign": + activitiesList.push( + await this.getCampaignList(coords, null, id, categoryArray) + ); + break; + + default: + const [campaignList, helpOfferList, helpList] = await Promise.all([ + this.getCampaignList(coords, true, id, categoryArray), + this.getHelpOfferList( + coords, + id, + isUserEntity, + categoryArray, + getOtherUsers + ), + this.getHelpList(coords, id, isUserEntity, categoryArray), + ]); + activitiesList.push(...campaignList, ...helpOfferList, ...helpList); + } + } + + const flattedList = activitiesList.flat(); + + return sortActivitiesByDistance({ helpList: flattedList }); + } +} + +module.exports = ActivityService; From ffae23cade70e9062669cff84684470edc5144e1 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Sun, 25 Jun 2023 18:31:01 -0300 Subject: [PATCH 087/107] feat: handle with distance in help offer --- src/models/HelpOffer.js | 21 +++++++++++++++++++++ src/repository/HelpOfferRepository.js | 16 ++++++++++++++-- src/services/HelpOfferService.js | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/models/HelpOffer.js b/src/models/HelpOffer.js index a70371b4..ebe7a29a 100644 --- a/src/models/HelpOffer.js +++ b/src/models/HelpOffer.js @@ -1,6 +1,7 @@ const { Schema, model } = require('mongoose'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); const Point = require('./Point'); +const { calculateDistance, getDistance } = require('../utils/geolocation/calculateDistance'); const offeredHelpSchema = new Schema( { @@ -90,4 +91,24 @@ offeredHelpSchema.virtual('helpedUsers', { foreignField: '_id', }); +offeredHelpSchema.virtual('distances') + .set(({ userCoords, coords }) => { + userCoords = { + longitude: userCoords[0], + latitude: userCoords[1], + }; + const coordinates = { + longitude: coords[0], + latitude: coords[1], + }; + this.distanceValue = calculateDistance(coordinates, userCoords); + this.distance = getDistance(coordinates, userCoords); + }); + +offeredHelpSchema.virtual('distanceValue') + .get(() => this.distanceValue); + +offeredHelpSchema.virtual('distance') + .get(() => this.distance); + module.exports = model('OfferedHelp', offeredHelpSchema); diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index 40b21a32..5de341ca 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -1,6 +1,7 @@ const { ObjectID } = require('mongodb'); const BaseRepository = require('./BaseRepository'); const OfferedHelp = require('../models/HelpOffer'); +const getLocation = require('../utils/getLocation'); class OfferdHelpRepository extends BaseRepository { constructor() { @@ -70,7 +71,7 @@ class OfferdHelpRepository extends BaseRepository { return super.$findOne(query, helpOfferFields, populate); } - async list(userId, isUserEntity, categoryArray, getOtherUsers) { + async list(coords, userId, isUserEntity, categoryArray, getOtherUsers) { const matchQuery = this.getHelpOfferListQuery( userId, isUserEntity, @@ -86,6 +87,7 @@ class OfferdHelpRepository extends BaseRepository { 'helpedUserId', 'creationDate', 'location', + 'description', ]; const sort = { creationDate: -1 }; const user = { @@ -107,7 +109,17 @@ class OfferdHelpRepository extends BaseRepository { const populate = [user, categories, possibleHelpedUsers, possibleEntities]; - return super.$list(matchQuery, helpOfferFields, populate, sort); + const helpOffer = await super.$list(matchQuery, helpOfferFields, populate, sort); + + const helpOffersWithDistances = helpOffer.map((offer) => { + const offerLocation = getLocation(offer); + offer.distances = { userCoords: offerLocation, coords }; + return offer.toObject(); + }); + + helpOffersWithDistances.sort((a, b) => a.distanceValue - b.distanceValue); + + return helpOffersWithDistances; } getHelpOfferListQuery( diff --git a/src/services/HelpOfferService.js b/src/services/HelpOfferService.js index f49d6ee6..657b6392 100644 --- a/src/services/HelpOfferService.js +++ b/src/services/HelpOfferService.js @@ -38,7 +38,7 @@ class OfferedHelpService { } async listHelpsOffers(userId, isUserEntity, categoryArray, getOtherUsers) { - const helpOffers = await this.OfferedHelpRepository.list(userId, isUserEntity, categoryArray, getOtherUsers); + const helpOffers = await this.OfferedHelpRepository.list(null, userId, isUserEntity, categoryArray, getOtherUsers); return helpOffers; } From f4f0ae109b1ea8489bf72bd1c686b88a68707b1c Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Sun, 25 Jun 2023 18:31:35 -0300 Subject: [PATCH 088/107] feat: create util to sort activities by distance --- src/utils/sortActivitiesByDistance.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/utils/sortActivitiesByDistance.js diff --git a/src/utils/sortActivitiesByDistance.js b/src/utils/sortActivitiesByDistance.js new file mode 100644 index 00000000..65fe9d07 --- /dev/null +++ b/src/utils/sortActivitiesByDistance.js @@ -0,0 +1,14 @@ +const sortActivitiesByDistance = ({ + helpList = [], + helpOfferList = [], + campaignList = [], + limit, +}) => { + let list = [...helpList, ...helpOfferList, ...campaignList]; + + list = list.sort((a, b) => a.distanceValue - b.distanceValue); + + return limit ? list.slice(0, 15) : list; +} + +module.exports = sortActivitiesByDistance; From f1a8c4aad129fa3ee1c6540df74f84088e58925a Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Sun, 25 Jun 2023 18:31:50 -0300 Subject: [PATCH 089/107] feat: create util to add help type to list --- src/utils/addHelpTypeToList.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/utils/addHelpTypeToList.js diff --git a/src/utils/addHelpTypeToList.js b/src/utils/addHelpTypeToList.js new file mode 100644 index 00000000..c826c3c3 --- /dev/null +++ b/src/utils/addHelpTypeToList.js @@ -0,0 +1,2 @@ +const addHelpTypeToList = (helpList, type) => helpList.map((help) => ({ ...help, type })); +module.exports = addHelpTypeToList; From d25b199747b239a04eeaa05ec49578e00df1e3bd Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 25 Jun 2023 19:41:31 -0300 Subject: [PATCH 090/107] chore: change icons --- .../mockedInfos/mockedTimelineEventTemplatesInfo.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js b/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js index 0ea303bc..e29f2b66 100644 --- a/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js +++ b/src/utils/seed/mockedInfos/mockedTimelineEventTemplatesInfo.js @@ -5,37 +5,37 @@ const mockedTimelineEventTemplates = [ _id: timelineEnum.register, title: 'Se cadastrou no aplicativo', description: 'Começou a fazer parte da comunidade para ajudar pessoas ou ser ajudado.', - iconName: 'hand-wave', + iconName: 'sign-direction', }, { _id: timelineEnum.offerHelp, title: 'Ofereceu ajuda a um pedido', description: 'Você tentou fazer a diferença na vida de uma pessoa pela primeira vez utilizando o aplicativo Mia Ajuda.', - iconName: 'hand-wave', + iconName: 'hand-heart', }, { _id: timelineEnum.createRequest, title: 'Criou um pedido de ajuda', description: 'Você conseguiu criar um pedido de ajuda no aplicativo.', - iconName: 'hand-wave', + iconName: 'hand-back-right', }, { _id: timelineEnum.finishRequest, title: 'Finalizou um pedido de ajuda', description: 'Alguém conseguiu te ajudar e seu pedido foi finalizado.', - iconName: 'hand-wave', + iconName: 'hands-pray', }, { _id: timelineEnum.feedback, title: 'Deixou um feedback', description: 'Você deixou um feedback para uma pessoa que te ajudou, mostrando para ela a importância de sua ajuda.', - iconName: 'hand-wave', + iconName: 'message', }, { _id: timelineEnum.offer, title: 'Realizou uma oferta', description: 'Você realizou uma oferta de ajuda para uma pessoa que precisava.', - iconName: 'hand-wave', + iconName: 'star', }, ]; From 1bdaba62d48a9851bec59083c35970257cbc6102 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Mon, 26 Jun 2023 00:41:01 -0300 Subject: [PATCH 091/107] feat: add coords to help offers list api --- src/controllers/HelpOfferController.js | 3 ++- src/repository/HelpOfferRepository.js | 7 +++++++ src/services/HelpOfferService.js | 10 ++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/controllers/HelpOfferController.js b/src/controllers/HelpOfferController.js index c5fd063f..27a7dc67 100644 --- a/src/controllers/HelpOfferController.js +++ b/src/controllers/HelpOfferController.js @@ -35,8 +35,9 @@ class OfferedHelpController { const { userId } = req.query; const getOtherUsers = req.query.getOtherUsers === 'true'; const { isUserEntity } = global; + const coords = req.query.coords ? req.query.coords.split(',').map((coord) => Number(coord)) : ''; try { - const helpOffers = await this.HelpOfferService.listHelpsOffers(userId, isUserEntity, null, getOtherUsers); + const helpOffers = await this.HelpOfferService.listHelpsOffers(coords, userId, isUserEntity, null, getOtherUsers); return res.json(helpOffers); } catch (error) { return res.status(400).json({ error: error.message }); diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index 5de341ca..f8671ae3 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -2,10 +2,12 @@ const { ObjectID } = require('mongodb'); const BaseRepository = require('./BaseRepository'); const OfferedHelp = require('../models/HelpOffer'); const getLocation = require('../utils/getLocation'); +const UserRepository = require('./UserRepository'); class OfferdHelpRepository extends BaseRepository { constructor() { super(OfferedHelp); + this.userRepository = new UserRepository(); } async create(offeredHelp) { @@ -72,6 +74,11 @@ class OfferdHelpRepository extends BaseRepository { } async list(coords, userId, isUserEntity, categoryArray, getOtherUsers) { + if (!coords) { + const user = await this.userRepository.$getById(userId); + coords = user.location.coordinates; + } + const matchQuery = this.getHelpOfferListQuery( userId, isUserEntity, diff --git a/src/services/HelpOfferService.js b/src/services/HelpOfferService.js index 657b6392..17a83157 100644 --- a/src/services/HelpOfferService.js +++ b/src/services/HelpOfferService.js @@ -37,8 +37,14 @@ class OfferedHelpService { return help; } - async listHelpsOffers(userId, isUserEntity, categoryArray, getOtherUsers) { - const helpOffers = await this.OfferedHelpRepository.list(null, userId, isUserEntity, categoryArray, getOtherUsers); + async listHelpsOffers(coords, userId, isUserEntity, categoryArray, getOtherUsers) { + const helpOffers = await this.OfferedHelpRepository.list( + coords, + userId, + isUserEntity, + categoryArray, + getOtherUsers, + ); return helpOffers; } From 308775a6b8bf2ed670e51807c37c0f995dd7a7d0 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Mon, 26 Jun 2023 00:41:18 -0300 Subject: [PATCH 092/107] fix: add missing method param --- src/services/SocialNetworkService.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index fffd7868..df72c992 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -114,6 +114,7 @@ class SocialNetworkService { ); const offers = await this.offerdHelpRepository.list( + null, userId, false, categoryArray, From cdbb14ca7f13676e2124971a85341e62075427bb Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Mon, 26 Jun 2023 01:00:16 -0300 Subject: [PATCH 093/107] fix: lint fixes --- src/controllers/ActivityController.js | 14 ++-- src/services/ActivityService.js | 111 ++++++++++++++------------ src/utils/sortActivitiesByDistance.js | 2 +- 3 files changed, 66 insertions(+), 61 deletions(-) diff --git a/src/controllers/ActivityController.js b/src/controllers/ActivityController.js index cc0bbbb3..c3961b11 100644 --- a/src/controllers/ActivityController.js +++ b/src/controllers/ActivityController.js @@ -1,4 +1,4 @@ -const ActivityService = require("../services/ActivityService"); +const ActivityService = require('../services/ActivityService'); class ActivityController { constructor() { @@ -8,14 +8,14 @@ class ActivityController { async fetchActivityList(req, res) { const { id } = req.query; const { isUserEntity } = global; - const coords = req.query.coords.split(",").map((coord) => Number(coord)); + const coords = req.query.coords.split(',').map((coord) => Number(coord)); const categoryArray = req.query.categoryId - ? req.query.categoryId.split(",") + ? req.query.categoryId.split(',') : null; const activitiesArray = req.query.activityId - ? req.query.activityId.split(",") - : ["getAll"]; - const getOtherUsers = req.query.getOtherUsers === "true"; + ? req.query.activityId.split(',') + : ['getAll']; + const getOtherUsers = req.query.getOtherUsers === 'true'; try { const activityList = await this.ActivityService.fetchActivityList( @@ -24,7 +24,7 @@ class ActivityController { isUserEntity, categoryArray, activitiesArray, - getOtherUsers + getOtherUsers, ); return res.json(activityList); } catch (error) { diff --git a/src/services/ActivityService.js b/src/services/ActivityService.js index f9c64a3c..0ee27be0 100644 --- a/src/services/ActivityService.js +++ b/src/services/ActivityService.js @@ -1,8 +1,8 @@ -const CampaignRepository = require("../repository/CampaignRepository"); -const OfferdHelpRepository = require("../repository/HelpOfferRepository"); -const HelpRepository = require("../repository/HelpRepository"); -const addHelpTypeToList = require("../utils/addHelpTypeToList"); -const sortActivitiesByDistance = require("../utils/sortActivitiesByDistance"); +const CampaignRepository = require('../repository/CampaignRepository'); +const OfferdHelpRepository = require('../repository/HelpOfferRepository'); +const HelpRepository = require('../repository/HelpRepository'); +const addHelpTypeToList = require('../utils/addHelpTypeToList'); +const sortActivitiesByDistance = require('../utils/sortActivitiesByDistance'); class ActivityService { constructor() { @@ -16,15 +16,15 @@ class ActivityService { coords, id, isUserEntity, - categoryArray + categoryArray, ); if (!Helplist) { throw new Error( - "Pedidos de ajuda não encontrados no seu raio de distância" + 'Pedidos de ajuda não encontrados no seu raio de distância', ); } - return addHelpTypeToList(Helplist, "help"); + return addHelpTypeToList(Helplist, 'help'); } async getHelpOfferList( @@ -32,16 +32,16 @@ class ActivityService { id, isUserEntity, categoryArray, - getOtherUsers + getOtherUsers, ) { const helpOffers = await this.OfferedHelpRepository.list( coords, id, isUserEntity, categoryArray, - getOtherUsers + getOtherUsers, ); - const helpOffersList = addHelpTypeToList(helpOffers, "offer"); + const helpOffersList = addHelpTypeToList(helpOffers, 'offer'); return helpOffersList; } @@ -50,15 +50,15 @@ class ActivityService { coords, except, id, - categoryArray + categoryArray, ); if (!CampaignList) { throw new Error( - "Nenhuma campanha foi encontrada no seu raio de distância" + 'Nenhuma campanha foi encontrada no seu raio de distância', ); } - return addHelpTypeToList(CampaignList, "campaign"); + return addHelpTypeToList(CampaignList, 'campaign'); } async fetchActivityList( @@ -67,53 +67,58 @@ class ActivityService { isUserEntity, categoryArray, activitiesArray, - getOtherUsers + getOtherUsers, ) { - const activitiesList = []; + const promises = []; - for (const activity of activitiesArray) { + activitiesArray.forEach((activity) => { switch (activity) { - case "help": - activitiesList.push( - await this.getHelpList(coords, id, isUserEntity, categoryArray) - ); - break; + case 'help': { + promises.push( + this.getHelpList(coords, id, isUserEntity, categoryArray), + ); + break; + } - case "helpOffer": - activitiesList.push( - await this.getHelpOfferList( - coords, - id, - isUserEntity, - categoryArray, - getOtherUsers - ) - ); - break; + case 'helpOffer': { + promises.push( + this.getHelpOfferList( + coords, + id, + isUserEntity, + categoryArray, + getOtherUsers, + ), + ); + break; + } - case "campaign": - activitiesList.push( - await this.getCampaignList(coords, null, id, categoryArray) - ); - break; + case 'campaign': { + promises.push( + this.getCampaignList(coords, null, id, categoryArray), + ); + break; + } - default: - const [campaignList, helpOfferList, helpList] = await Promise.all([ - this.getCampaignList(coords, true, id, categoryArray), - this.getHelpOfferList( - coords, - id, - isUserEntity, - categoryArray, - getOtherUsers - ), - this.getHelpList(coords, id, isUserEntity, categoryArray), - ]); - activitiesList.push(...campaignList, ...helpOfferList, ...helpList); + default: { + const promisesList = Promise.all([ + this.getCampaignList(coords, true, id, categoryArray), + this.getHelpOfferList( + coords, + id, + isUserEntity, + categoryArray, + getOtherUsers, + ), + this.getHelpList(coords, id, isUserEntity, categoryArray), + ]); + promises.push(promisesList); } - } + } + }); + const activitiesList = await Promise.all(promises); - const flattedList = activitiesList.flat(); + const flattedList = activitiesList.flat(2); return sortActivitiesByDistance({ helpList: flattedList }); } diff --git a/src/utils/sortActivitiesByDistance.js b/src/utils/sortActivitiesByDistance.js index 65fe9d07..40cf7318 100644 --- a/src/utils/sortActivitiesByDistance.js +++ b/src/utils/sortActivitiesByDistance.js @@ -9,6 +9,6 @@ const sortActivitiesByDistance = ({ list = list.sort((a, b) => a.distanceValue - b.distanceValue); return limit ? list.slice(0, 15) : list; -} +}; module.exports = sortActivitiesByDistance; From 07495fc757c04ee531b2378367099ab698790e70 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Mon, 26 Jun 2023 02:54:07 -0300 Subject: [PATCH 094/107] fix: fix activity coords in other users profile --- src/repository/HelpOfferRepository.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index f8671ae3..9b3fe2a2 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -74,11 +74,6 @@ class OfferdHelpRepository extends BaseRepository { } async list(coords, userId, isUserEntity, categoryArray, getOtherUsers) { - if (!coords) { - const user = await this.userRepository.$getById(userId); - coords = user.location.coordinates; - } - const matchQuery = this.getHelpOfferListQuery( userId, isUserEntity, @@ -118,15 +113,19 @@ class OfferdHelpRepository extends BaseRepository { const helpOffer = await super.$list(matchQuery, helpOfferFields, populate, sort); - const helpOffersWithDistances = helpOffer.map((offer) => { - const offerLocation = getLocation(offer); - offer.distances = { userCoords: offerLocation, coords }; - return offer.toObject(); - }); + if (coords) { + const helpOffersWithDistances = helpOffer.map((offer) => { + const offerLocation = getLocation(offer); + offer.distances = { userCoords: offerLocation, coords }; + return offer.toObject(); + }); - helpOffersWithDistances.sort((a, b) => a.distanceValue - b.distanceValue); + helpOffersWithDistances.sort((a, b) => a.distanceValue - b.distanceValue); - return helpOffersWithDistances; + return helpOffersWithDistances; + } + + return helpOffer; } getHelpOfferListQuery( From d893e14eb3a9a9a148c4fe0a693e975d123aea1f Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Wed, 28 Jun 2023 14:22:02 -0300 Subject: [PATCH 095/107] fix: fix requested changes --- src/controllers/ActivityController.js | 12 +-- src/controllers/HelpOfferController.js | 4 +- src/repository/CampaignRepository.js | 3 +- src/repository/HelpOfferRepository.js | 13 ++- src/repository/HelpRepository.js | 3 +- src/services/ActivityService.js | 115 ++++--------------------- src/services/HelpOfferService.js | 4 +- 7 files changed, 37 insertions(+), 117 deletions(-) diff --git a/src/controllers/ActivityController.js b/src/controllers/ActivityController.js index c3961b11..74192508 100644 --- a/src/controllers/ActivityController.js +++ b/src/controllers/ActivityController.js @@ -8,14 +8,10 @@ class ActivityController { async fetchActivityList(req, res) { const { id } = req.query; const { isUserEntity } = global; - const coords = req.query.coords.split(',').map((coord) => Number(coord)); - const categoryArray = req.query.categoryId - ? req.query.categoryId.split(',') - : null; - const activitiesArray = req.query.activityId - ? req.query.activityId.split(',') - : ['getAll']; - const getOtherUsers = req.query.getOtherUsers === 'true'; + const coords = req.query.coords.split(",").map((coord) => Number(coord)); + const categoryArray = req.query.categoryId?.split(',') + const activitiesArray = req.query.activityId?.split(",") || ["getAll"]; + const getOtherUsers = req.query.getOtherUsers === "true"; try { const activityList = await this.ActivityService.fetchActivityList( diff --git a/src/controllers/HelpOfferController.js b/src/controllers/HelpOfferController.js index 27a7dc67..2a6284c3 100644 --- a/src/controllers/HelpOfferController.js +++ b/src/controllers/HelpOfferController.js @@ -35,9 +35,9 @@ class OfferedHelpController { const { userId } = req.query; const getOtherUsers = req.query.getOtherUsers === 'true'; const { isUserEntity } = global; - const coords = req.query.coords ? req.query.coords.split(',').map((coord) => Number(coord)) : ''; + const coords = req.query.coords?.split(',')?.map((coord) => Number(coord)) || ''; try { - const helpOffers = await this.HelpOfferService.listHelpsOffers(coords, userId, isUserEntity, null, getOtherUsers); + const helpOffers = await this.HelpOfferService.listHelpsOffers(userId, isUserEntity, null, getOtherUsers, coords); return res.json(helpOffers); } catch (error) { return res.status(400).json({ error: error.message }); diff --git a/src/repository/CampaignRepository.js b/src/repository/CampaignRepository.js index 052cf689..8f0ae4cb 100644 --- a/src/repository/CampaignRepository.js +++ b/src/repository/CampaignRepository.js @@ -3,6 +3,7 @@ const BaseRepository = require('./BaseRepository'); const Campaign = require('../models/Campaign'); const EntitySchema = require('../models/Entity'); const getLocation = require('../utils/getLocation'); +const addHelpTypeToList = require('../utils/addHelpTypeToList'); class CampaignRepository extends BaseRepository { constructor() { @@ -66,7 +67,7 @@ class CampaignRepository extends BaseRepository { campaignsWithDistances.sort((a, b) => a.distanceValue - b.distanceValue); - return campaignsWithDistances; + return addHelpTypeToList(campaignsWithDistances, 'campaign'); } async getCampaignListByStatus(userId, statusList) { diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index 9b3fe2a2..b5ed0cad 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -2,12 +2,11 @@ const { ObjectID } = require('mongodb'); const BaseRepository = require('./BaseRepository'); const OfferedHelp = require('../models/HelpOffer'); const getLocation = require('../utils/getLocation'); -const UserRepository = require('./UserRepository'); +const addHelpTypeToList = require('../utils/addHelpTypeToList'); class OfferdHelpRepository extends BaseRepository { constructor() { super(OfferedHelp); - this.userRepository = new UserRepository(); } async create(offeredHelp) { @@ -73,7 +72,7 @@ class OfferdHelpRepository extends BaseRepository { return super.$findOne(query, helpOfferFields, populate); } - async list(coords, userId, isUserEntity, categoryArray, getOtherUsers) { + async list(userId, isUserEntity, categoryArray, getOtherUsers, coords) { const matchQuery = this.getHelpOfferListQuery( userId, isUserEntity, @@ -111,10 +110,10 @@ class OfferdHelpRepository extends BaseRepository { const populate = [user, categories, possibleHelpedUsers, possibleEntities]; - const helpOffer = await super.$list(matchQuery, helpOfferFields, populate, sort); + let helpOffers = await super.$list(matchQuery, helpOfferFields, populate, sort); if (coords) { - const helpOffersWithDistances = helpOffer.map((offer) => { + const helpOffersWithDistances = helpOffers.map((offer) => { const offerLocation = getLocation(offer); offer.distances = { userCoords: offerLocation, coords }; return offer.toObject(); @@ -122,10 +121,10 @@ class OfferdHelpRepository extends BaseRepository { helpOffersWithDistances.sort((a, b) => a.distanceValue - b.distanceValue); - return helpOffersWithDistances; + helpOffers = helpOffersWithDistances; } - return helpOffer; + return addHelpTypeToList(helpOffers, 'offer'); } getHelpOfferListQuery( diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index ab9a9132..f869a370 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -3,6 +3,7 @@ const { ObjectID } = require('mongodb'); const BaseRepository = require('./BaseRepository'); const HelpSchema = require('../models/Help'); const getLocation = require('../utils/getLocation'); +const addHelpTypeToList = require('../utils/addHelpTypeToList'); class HelpRepository extends BaseRepository { constructor() { @@ -132,7 +133,7 @@ class HelpRepository extends BaseRepository { helpsWithDistance.sort((a, b) => a.distanceValue - b.distanceValue); - return helpsWithDistance; + return addHelpTypeToList(helpsWithDistance, 'help'); } async countDocuments(id) { diff --git a/src/services/ActivityService.js b/src/services/ActivityService.js index 0ee27be0..f0d365aa 100644 --- a/src/services/ActivityService.js +++ b/src/services/ActivityService.js @@ -1,7 +1,6 @@ const CampaignRepository = require('../repository/CampaignRepository'); const OfferdHelpRepository = require('../repository/HelpOfferRepository'); const HelpRepository = require('../repository/HelpRepository'); -const addHelpTypeToList = require('../utils/addHelpTypeToList'); const sortActivitiesByDistance = require('../utils/sortActivitiesByDistance'); class ActivityService { @@ -11,56 +10,6 @@ class ActivityService { this.CampaignRepository = new CampaignRepository(); } - async getHelpList(coords, id, isUserEntity, categoryArray) { - const Helplist = await this.HelpRepository.shortList( - coords, - id, - isUserEntity, - categoryArray, - ); - if (!Helplist) { - throw new Error( - 'Pedidos de ajuda não encontrados no seu raio de distância', - ); - } - - return addHelpTypeToList(Helplist, 'help'); - } - - async getHelpOfferList( - coords, - id, - isUserEntity, - categoryArray, - getOtherUsers, - ) { - const helpOffers = await this.OfferedHelpRepository.list( - coords, - id, - isUserEntity, - categoryArray, - getOtherUsers, - ); - const helpOffersList = addHelpTypeToList(helpOffers, 'offer'); - return helpOffersList; - } - - async getCampaignList(coords, except, id, categoryArray) { - const CampaignList = await this.CampaignRepository.listNear( - coords, - except, - id, - categoryArray, - ); - if (!CampaignList) { - throw new Error( - 'Nenhuma campanha foi encontrada no seu raio de distância', - ); - } - - return addHelpTypeToList(CampaignList, 'campaign'); - } - async fetchActivityList( coords, id, @@ -71,51 +20,25 @@ class ActivityService { ) { const promises = []; - activitiesArray.forEach((activity) => { - switch (activity) { - case 'help': { - promises.push( - this.getHelpList(coords, id, isUserEntity, categoryArray), - ); - break; - } - - case 'helpOffer': { - promises.push( - this.getHelpOfferList( - coords, - id, - isUserEntity, - categoryArray, - getOtherUsers, - ), - ); - break; - } - - case 'campaign': { - promises.push( - this.getCampaignList(coords, null, id, categoryArray), - ); - break; - } - - default: { - const promisesList = Promise.all([ - this.getCampaignList(coords, true, id, categoryArray), - this.getHelpOfferList( - coords, - id, - isUserEntity, - categoryArray, - getOtherUsers, - ), - this.getHelpList(coords, id, isUserEntity, categoryArray), - ]); - promises.push(promisesList); - } - } - }); + const mappedActivitiesRepositories = { + help: this.HelpRepository.shortList(coords, id, isUserEntity, categoryArray), + helpOffer: this.OfferedHelpRepository.list(id, isUserEntity, categoryArray, getOtherUsers, coords), + campaign: this.CampaignRepository.listNear(coords, null, id, categoryArray), + }; + + for (const activity in activitiesArray) { + if (mappedActivitiesRepositories[activity]) promises.push(mappedActivitiesRepositories[activity]); + }; + + if (!promises.length) { + const promisesList = Promise.all([ + this.HelpRepository.shortList(coords, id, isUserEntity, categoryArray), + this.OfferedHelpRepository.list(id, isUserEntity, categoryArray, getOtherUsers, coords), + this.CampaignRepository.listNear(coords, null, id, categoryArray), + ]); + promises.push(promisesList); + }; + const activitiesList = await Promise.all(promises); const flattedList = activitiesList.flat(2); diff --git a/src/services/HelpOfferService.js b/src/services/HelpOfferService.js index 17a83157..4ff7af09 100644 --- a/src/services/HelpOfferService.js +++ b/src/services/HelpOfferService.js @@ -37,13 +37,13 @@ class OfferedHelpService { return help; } - async listHelpsOffers(coords, userId, isUserEntity, categoryArray, getOtherUsers) { + async listHelpsOffers(userId, isUserEntity, categoryArray, getOtherUsers, coords) { const helpOffers = await this.OfferedHelpRepository.list( - coords, userId, isUserEntity, categoryArray, getOtherUsers, + coords, ); return helpOffers; } From b78d2786823e658e6165b2e19c3a2c758df2b155 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Wed, 28 Jun 2023 15:45:24 -0300 Subject: [PATCH 096/107] fix: fixing lint --- src/controllers/ActivityController.js | 8 ++++---- src/controllers/HelpOfferController.js | 2 +- src/services/ActivityService.js | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/controllers/ActivityController.js b/src/controllers/ActivityController.js index 74192508..1cd5c1a2 100644 --- a/src/controllers/ActivityController.js +++ b/src/controllers/ActivityController.js @@ -8,10 +8,10 @@ class ActivityController { async fetchActivityList(req, res) { const { id } = req.query; const { isUserEntity } = global; - const coords = req.query.coords.split(",").map((coord) => Number(coord)); - const categoryArray = req.query.categoryId?.split(',') - const activitiesArray = req.query.activityId?.split(",") || ["getAll"]; - const getOtherUsers = req.query.getOtherUsers === "true"; + const coords = req.query.coords.split(',').map((coord) => Number(coord)); + const categoryArray = req.query.categoryId?.split(','); + const activitiesArray = req.query.activityId?.split(',') || ['getAll']; + const getOtherUsers = req.query.getOtherUsers === 'true'; try { const activityList = await this.ActivityService.fetchActivityList( diff --git a/src/controllers/HelpOfferController.js b/src/controllers/HelpOfferController.js index 2a6284c3..01432d4c 100644 --- a/src/controllers/HelpOfferController.js +++ b/src/controllers/HelpOfferController.js @@ -35,7 +35,7 @@ class OfferedHelpController { const { userId } = req.query; const getOtherUsers = req.query.getOtherUsers === 'true'; const { isUserEntity } = global; - const coords = req.query.coords?.split(',')?.map((coord) => Number(coord)) || ''; + const coords = req.query.coords?.split(',')?.map((coord) => Number(coord)) || ''; try { const helpOffers = await this.HelpOfferService.listHelpsOffers(userId, isUserEntity, null, getOtherUsers, coords); return res.json(helpOffers); diff --git a/src/services/ActivityService.js b/src/services/ActivityService.js index f0d365aa..e23babe9 100644 --- a/src/services/ActivityService.js +++ b/src/services/ActivityService.js @@ -26,9 +26,9 @@ class ActivityService { campaign: this.CampaignRepository.listNear(coords, null, id, categoryArray), }; - for (const activity in activitiesArray) { + activitiesArray.forEach((activity) => { if (mappedActivitiesRepositories[activity]) promises.push(mappedActivitiesRepositories[activity]); - }; + }); if (!promises.length) { const promisesList = Promise.all([ @@ -37,8 +37,8 @@ class ActivityService { this.CampaignRepository.listNear(coords, null, id, categoryArray), ]); promises.push(promisesList); - }; - + } + const activitiesList = await Promise.all(promises); const flattedList = activitiesList.flat(2); From 600f659acef76bf8cb737138a28be52b0a27d76d Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Wed, 28 Jun 2023 20:29:09 -0300 Subject: [PATCH 097/107] fix: fix duplicated code --- src/services/ActivityService.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/ActivityService.js b/src/services/ActivityService.js index e23babe9..efa3d2d4 100644 --- a/src/services/ActivityService.js +++ b/src/services/ActivityService.js @@ -32,9 +32,9 @@ class ActivityService { if (!promises.length) { const promisesList = Promise.all([ - this.HelpRepository.shortList(coords, id, isUserEntity, categoryArray), - this.OfferedHelpRepository.list(id, isUserEntity, categoryArray, getOtherUsers, coords), - this.CampaignRepository.listNear(coords, null, id, categoryArray), + mappedActivitiesRepositories.help, + mappedActivitiesRepositories.helpOffer, + mappedActivitiesRepositories.campaign, ]); promises.push(promisesList); } From 59a0065bdcca98b754982fc7e1de68dae92b6f0d Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Thu, 29 Jun 2023 18:46:55 -0300 Subject: [PATCH 098/107] fix: add arrow function to activities hash --- src/services/ActivityService.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/services/ActivityService.js b/src/services/ActivityService.js index efa3d2d4..f8d58c17 100644 --- a/src/services/ActivityService.js +++ b/src/services/ActivityService.js @@ -21,20 +21,20 @@ class ActivityService { const promises = []; const mappedActivitiesRepositories = { - help: this.HelpRepository.shortList(coords, id, isUserEntity, categoryArray), - helpOffer: this.OfferedHelpRepository.list(id, isUserEntity, categoryArray, getOtherUsers, coords), - campaign: this.CampaignRepository.listNear(coords, null, id, categoryArray), + help: () => this.HelpRepository.shortList(coords, id, isUserEntity, categoryArray), + helpOffer: () => this.OfferedHelpRepository.list(id, isUserEntity, categoryArray, getOtherUsers, coords), + campaign: () => this.CampaignRepository.listNear(coords, null, id, categoryArray), }; activitiesArray.forEach((activity) => { - if (mappedActivitiesRepositories[activity]) promises.push(mappedActivitiesRepositories[activity]); + if (mappedActivitiesRepositories[activity]) promises.push(mappedActivitiesRepositories[activity]()); }); if (!promises.length) { const promisesList = Promise.all([ - mappedActivitiesRepositories.help, - mappedActivitiesRepositories.helpOffer, - mappedActivitiesRepositories.campaign, + mappedActivitiesRepositories.help(), + mappedActivitiesRepositories.helpOffer(), + mappedActivitiesRepositories.campaign(), ]); promises.push(promisesList); } From 418dedd670276fbb9a0a75a132639b7658a978d2 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Sun, 2 Jul 2023 03:32:48 -0300 Subject: [PATCH 099/107] fix: fix campaign query method param --- src/services/ActivityService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/ActivityService.js b/src/services/ActivityService.js index f8d58c17..412918c7 100644 --- a/src/services/ActivityService.js +++ b/src/services/ActivityService.js @@ -23,7 +23,7 @@ class ActivityService { const mappedActivitiesRepositories = { help: () => this.HelpRepository.shortList(coords, id, isUserEntity, categoryArray), helpOffer: () => this.OfferedHelpRepository.list(id, isUserEntity, categoryArray, getOtherUsers, coords), - campaign: () => this.CampaignRepository.listNear(coords, null, id, categoryArray), + campaign: () => this.CampaignRepository.listNear(coords, true, id, categoryArray), }; activitiesArray.forEach((activity) => { From afa330ba51af1509f7c8757d7a70c90456afdc25 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Sun, 2 Jul 2023 03:33:21 -0300 Subject: [PATCH 100/107] feat: add index to each activity array --- src/utils/addHelpTypeToList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/addHelpTypeToList.js b/src/utils/addHelpTypeToList.js index c826c3c3..d5261695 100644 --- a/src/utils/addHelpTypeToList.js +++ b/src/utils/addHelpTypeToList.js @@ -1,2 +1,2 @@ -const addHelpTypeToList = (helpList, type) => helpList.map((help) => ({ ...help, type })); +const addHelpTypeToList = (helpList, type) => helpList.map((help, index) => ({ ...help, type, index: index + 1 })); module.exports = addHelpTypeToList; From 924772fd3cf1e52fb5487a239ccde91fb0da6cf4 Mon Sep 17 00:00:00 2001 From: Guilherme Barbosa Ferreira Date: Sun, 2 Jul 2023 03:52:41 -0300 Subject: [PATCH 101/107] fix: removing unnecessary method --- src/services/CampaignService.js | 7 +++---- src/services/HelpService.js | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/services/CampaignService.js b/src/services/CampaignService.js index efa3440d..1d46aebd 100644 --- a/src/services/CampaignService.js +++ b/src/services/CampaignService.js @@ -1,7 +1,6 @@ const CampaignRepository = require('../repository/CampaignRepository'); const CategoryService = require('./CategoryService'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); -const addHelpTypeToList = require('../utils/addHelpTypeToList'); class CampaignService { constructor() { @@ -38,19 +37,19 @@ class CampaignService { } async getNearCampaignList(coords, except, id, categoryArray) { - const CampaignList = await this.CampaignRepository.listNear( + const campaignList = await this.CampaignRepository.listNear( coords, except, id, categoryArray, ); - if (!CampaignList) { + if (!campaignList) { throw new Error( 'Nenhuma campanha foi encontrada no seu raio de distância', ); } - return addHelpTypeToList(CampaignList, 'campaign'); + return campaignList; } async getCampaignById(id) { diff --git a/src/services/HelpService.js b/src/services/HelpService.js index 14d2c662..d219ed03 100644 --- a/src/services/HelpService.js +++ b/src/services/HelpService.js @@ -9,7 +9,6 @@ const NotificationMixin = require('../utils/NotificationMixin'); const helpStatusEnum = require('../utils/enums/helpStatusEnum'); const saveError = require('../utils/ErrorHistory'); const SocialNetworkService = require('./SocialNetworkService'); -const addHelpTypeToList = require('../utils/addHelpTypeToList'); class HelpService { constructor() { @@ -102,19 +101,19 @@ class HelpService { } async getHelpList(coords, id, isUserEntity, categoryArray) { - const Helplist = await this.HelpRepository.shortList( + const helplist = await this.HelpRepository.shortList( coords, id, isUserEntity, categoryArray, ); - if (!Helplist) { + if (!helplist) { throw new Error( 'Pedidos de ajuda não encontrados no seu raio de distância', ); } - return addHelpTypeToList(Helplist, 'help'); + return helplist; } async deleteHelpLogically(id) { From a5c10b710326b6bcc26d8603099493186db01351 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 2 Jul 2023 07:34:40 -0300 Subject: [PATCH 102/107] chore: improve logic to not return virtual to front --- src/repository/HelpOfferRepository.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index b5ed0cad..844b7e2c 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -110,7 +110,7 @@ class OfferdHelpRepository extends BaseRepository { const populate = [user, categories, possibleHelpedUsers, possibleEntities]; - let helpOffers = await super.$list(matchQuery, helpOfferFields, populate, sort); + const helpOffers = await super.$list(matchQuery, helpOfferFields, populate, sort); if (coords) { const helpOffersWithDistances = helpOffers.map((offer) => { @@ -121,10 +121,9 @@ class OfferdHelpRepository extends BaseRepository { helpOffersWithDistances.sort((a, b) => a.distanceValue - b.distanceValue); - helpOffers = helpOffersWithDistances; + return addHelpTypeToList(helpOffersWithDistances, 'offer'); } - - return addHelpTypeToList(helpOffers, 'offer'); + return helpOffers; } getHelpOfferListQuery( From 099e0de7c20dcf0544e9e4189374c4f39be37348 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sun, 2 Jul 2023 07:36:13 -0300 Subject: [PATCH 103/107] chore: create virtual to avoid unnecessary loop --- src/models/Campaign.js | 4 ++++ src/models/Help.js | 4 ++++ src/models/HelpOffer.js | 2 ++ src/repository/CampaignRepository.js | 3 +-- src/repository/HelpOfferRepository.js | 3 +-- src/repository/HelpRepository.js | 3 +-- src/utils/addHelpTypeToList.js | 2 -- 7 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 src/utils/addHelpTypeToList.js diff --git a/src/models/Campaign.js b/src/models/Campaign.js index 36d871a7..44719fe1 100644 --- a/src/models/Campaign.js +++ b/src/models/Campaign.js @@ -91,7 +91,11 @@ campaignSchema.virtual('distances') campaignSchema.virtual('distanceValue') .get(() => this.distanceValue); + campaignSchema.virtual('distance') .get(() => this.distance); +campaignSchema.virtual('type') + .get(() => 'campaign'); + module.exports = mongoose.model('Campaign', campaignSchema); diff --git a/src/models/Help.js b/src/models/Help.js index cbbc9ec4..79e80377 100644 --- a/src/models/Help.js +++ b/src/models/Help.js @@ -103,7 +103,11 @@ helpSchema.virtual('distances') helpSchema.virtual('distanceValue') .get(() => this.distanceValue); + helpSchema.virtual('distance') .get(() => this.distance); +helpSchema.virtual('type') + .get(() => 'help'); + module.exports = mongoose.model('Help', helpSchema); diff --git a/src/models/HelpOffer.js b/src/models/HelpOffer.js index ebe7a29a..5524acc1 100644 --- a/src/models/HelpOffer.js +++ b/src/models/HelpOffer.js @@ -111,4 +111,6 @@ offeredHelpSchema.virtual('distanceValue') offeredHelpSchema.virtual('distance') .get(() => this.distance); +offeredHelpSchema.virtual('type').get(() => 'offer'); + module.exports = model('OfferedHelp', offeredHelpSchema); diff --git a/src/repository/CampaignRepository.js b/src/repository/CampaignRepository.js index 8f0ae4cb..052cf689 100644 --- a/src/repository/CampaignRepository.js +++ b/src/repository/CampaignRepository.js @@ -3,7 +3,6 @@ const BaseRepository = require('./BaseRepository'); const Campaign = require('../models/Campaign'); const EntitySchema = require('../models/Entity'); const getLocation = require('../utils/getLocation'); -const addHelpTypeToList = require('../utils/addHelpTypeToList'); class CampaignRepository extends BaseRepository { constructor() { @@ -67,7 +66,7 @@ class CampaignRepository extends BaseRepository { campaignsWithDistances.sort((a, b) => a.distanceValue - b.distanceValue); - return addHelpTypeToList(campaignsWithDistances, 'campaign'); + return campaignsWithDistances; } async getCampaignListByStatus(userId, statusList) { diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index 844b7e2c..8cbd7994 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -2,7 +2,6 @@ const { ObjectID } = require('mongodb'); const BaseRepository = require('./BaseRepository'); const OfferedHelp = require('../models/HelpOffer'); const getLocation = require('../utils/getLocation'); -const addHelpTypeToList = require('../utils/addHelpTypeToList'); class OfferdHelpRepository extends BaseRepository { constructor() { @@ -121,7 +120,7 @@ class OfferdHelpRepository extends BaseRepository { helpOffersWithDistances.sort((a, b) => a.distanceValue - b.distanceValue); - return addHelpTypeToList(helpOffersWithDistances, 'offer'); + return helpOffersWithDistances; } return helpOffers; } diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index f869a370..ab9a9132 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -3,7 +3,6 @@ const { ObjectID } = require('mongodb'); const BaseRepository = require('./BaseRepository'); const HelpSchema = require('../models/Help'); const getLocation = require('../utils/getLocation'); -const addHelpTypeToList = require('../utils/addHelpTypeToList'); class HelpRepository extends BaseRepository { constructor() { @@ -133,7 +132,7 @@ class HelpRepository extends BaseRepository { helpsWithDistance.sort((a, b) => a.distanceValue - b.distanceValue); - return addHelpTypeToList(helpsWithDistance, 'help'); + return helpsWithDistance; } async countDocuments(id) { diff --git a/src/utils/addHelpTypeToList.js b/src/utils/addHelpTypeToList.js deleted file mode 100644 index c826c3c3..00000000 --- a/src/utils/addHelpTypeToList.js +++ /dev/null @@ -1,2 +0,0 @@ -const addHelpTypeToList = (helpList, type) => helpList.map((help) => ({ ...help, type })); -module.exports = addHelpTypeToList; From a8d9f42d2754abe0972c9575b6ba25055b97c9a6 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 8 Jul 2023 08:47:26 -0300 Subject: [PATCH 104/107] chore: create index field in activities --- src/models/Campaign.js | 5 +++++ src/models/Help.js | 5 +++++ src/models/HelpOffer.js | 5 +++++ src/repository/HelpOfferRepository.js | 1 + src/repository/HelpRepository.js | 1 + 5 files changed, 17 insertions(+) diff --git a/src/models/Campaign.js b/src/models/Campaign.js index 44719fe1..7fbe5b1d 100644 --- a/src/models/Campaign.js +++ b/src/models/Campaign.js @@ -52,6 +52,11 @@ const campaignSchema = new mongoose.Schema({ index: '2dsphere', required: false, }, + index: { + type: Number, + default: 0, + unique: false, + }, }, { collection: 'campaign', diff --git a/src/models/Help.js b/src/models/Help.js index 79e80377..2154d3f8 100644 --- a/src/models/Help.js +++ b/src/models/Help.js @@ -63,6 +63,11 @@ const helpSchema = new mongoose.Schema( index: '2dsphere', required: false, }, + index: { + type: Number, + default: 0, + unique: false, + }, }, { collection: 'userHelp', diff --git a/src/models/HelpOffer.js b/src/models/HelpOffer.js index 5524acc1..28ee5a65 100644 --- a/src/models/HelpOffer.js +++ b/src/models/HelpOffer.js @@ -60,6 +60,11 @@ const offeredHelpSchema = new Schema( index: '2dsphere', required: false, }, + index: { + type: Number, + default: 0, + unique: false, + }, }, { collection: 'helpOffer', diff --git a/src/repository/HelpOfferRepository.js b/src/repository/HelpOfferRepository.js index 8cbd7994..8d6ab784 100644 --- a/src/repository/HelpOfferRepository.js +++ b/src/repository/HelpOfferRepository.js @@ -88,6 +88,7 @@ class OfferdHelpRepository extends BaseRepository { 'creationDate', 'location', 'description', + 'index', ]; const sort = { creationDate: -1 }; const user = { diff --git a/src/repository/HelpRepository.js b/src/repository/HelpRepository.js index ab9a9132..faac47c3 100644 --- a/src/repository/HelpRepository.js +++ b/src/repository/HelpRepository.js @@ -114,6 +114,7 @@ class HelpRepository extends BaseRepository { 'ownerId', 'creationDate', 'location', + 'index', ]; const user = { path: 'user', From 21b612491e1a11a242eb7c732567b23a5f02c7e4 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 8 Jul 2023 08:47:44 -0300 Subject: [PATCH 105/107] chore: create function to populate index in old activities --- src/utils/seed/HelpOfferCampaignSeed.js | 5 +++++ src/utils/seed/addIndexToOldActivities.js | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 src/utils/seed/addIndexToOldActivities.js diff --git a/src/utils/seed/HelpOfferCampaignSeed.js b/src/utils/seed/HelpOfferCampaignSeed.js index bbd51ecd..8e86f096 100644 --- a/src/utils/seed/HelpOfferCampaignSeed.js +++ b/src/utils/seed/HelpOfferCampaignSeed.js @@ -8,6 +8,7 @@ const Campaign = require('../../models/Campaign'); const HelpOffer = require('../../models/HelpOffer'); const mockedOfferInfo = require('./mockedInfos/mockedOfferInfo'); const mockedHelpInfo = require('./mockedInfos/mockedHelpInfo'); +const addIndexToOldActivities = require('./addIndexToOldActivities'); const status = [ 'waiting', @@ -32,6 +33,10 @@ const seedHelp = async () => { || helpOfferCollection.length > 0 || campaignCollection.length > 0 ) { + // this will be removed after first run in production + addIndexToOldActivities(helpCollection); + addIndexToOldActivities(helpOfferCollection); + addIndexToOldActivities(campaignCollection); return; } diff --git a/src/utils/seed/addIndexToOldActivities.js b/src/utils/seed/addIndexToOldActivities.js new file mode 100644 index 00000000..8254655a --- /dev/null +++ b/src/utils/seed/addIndexToOldActivities.js @@ -0,0 +1,7 @@ +const addIndexToOldActivities = async (activityList) => { + activityList.forEach(async (activity, index) => { + activity.index = index; + await activity.save(); + }); +}; +module.exports = addIndexToOldActivities; From 1f9ab283ba4088def0f1f1fef79b182b4d9ee5fe Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 8 Jul 2023 16:35:52 -0300 Subject: [PATCH 106/107] chore: remove unecessary null --- src/services/SocialNetworkService.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/SocialNetworkService.js b/src/services/SocialNetworkService.js index df72c992..fffd7868 100644 --- a/src/services/SocialNetworkService.js +++ b/src/services/SocialNetworkService.js @@ -114,7 +114,6 @@ class SocialNetworkService { ); const offers = await this.offerdHelpRepository.list( - null, userId, false, categoryArray, From 37f484b84ea21e139f7356e72a31f975ad2a0987 Mon Sep 17 00:00:00 2001 From: sudjoao Date: Sat, 8 Jul 2023 16:43:17 -0300 Subject: [PATCH 107/107] chore: change index --- src/models/Campaign.js | 4 ++-- src/models/Help.js | 4 ++-- src/models/HelpOffer.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/models/Campaign.js b/src/models/Campaign.js index 7fbe5b1d..4a7cdd9a 100644 --- a/src/models/Campaign.js +++ b/src/models/Campaign.js @@ -54,8 +54,8 @@ const campaignSchema = new mongoose.Schema({ }, index: { type: Number, - default: 0, - unique: false, + default: 1, + unique: true, }, }, { diff --git a/src/models/Help.js b/src/models/Help.js index 2154d3f8..340b2175 100644 --- a/src/models/Help.js +++ b/src/models/Help.js @@ -65,8 +65,8 @@ const helpSchema = new mongoose.Schema( }, index: { type: Number, - default: 0, - unique: false, + default: 1, + unique: true, }, }, { diff --git a/src/models/HelpOffer.js b/src/models/HelpOffer.js index 28ee5a65..7db11275 100644 --- a/src/models/HelpOffer.js +++ b/src/models/HelpOffer.js @@ -62,8 +62,8 @@ const offeredHelpSchema = new Schema( }, index: { type: Number, - default: 0, - unique: false, + default: 1, + unique: true, }, }, {