diff --git a/SCRS-Backend/build.gradle b/SCRS-Backend/build.gradle index 608eaf4..cfcc5e8 100644 --- a/SCRS-Backend/build.gradle +++ b/SCRS-Backend/build.gradle @@ -17,6 +17,8 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' runtimeOnly 'org.postgresql:postgresql' testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.mockito:mockito-core:2.+' + testImplementation 'org.mockito:mockito-junit-jupiter:2.18.3' } test { diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/ScrsApplication.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/ScrsApplication.java index 3d96c6f..c0e757c 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/ScrsApplication.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/ScrsApplication.java @@ -2,9 +2,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.SpringApplication; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; +@CrossOrigin(origins = "*") @RestController @SpringBootApplication public class ScrsApplication diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/AppointmentController.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/AppointmentController.java new file mode 100644 index 0000000..e750e70 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/AppointmentController.java @@ -0,0 +1,171 @@ +package ca.mcgill.ecse321.scrs.controller; + +import ca.mcgill.ecse321.scrs.dto.AppointmentDto; +import ca.mcgill.ecse321.scrs.dto.TimeslotDto; +import ca.mcgill.ecse321.scrs.model.Appointment; +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.model.Timeslot; +import ca.mcgill.ecse321.scrs.service.AppointmentService; +import ca.mcgill.ecse321.scrs.service.CustomerService; +import ca.mcgill.ecse321.scrs.service.TimeslotService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.sql.Date; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +import static ca.mcgill.ecse321.scrs.controller.Helper.*; + +@RestController +@RequestMapping(path = "/api/appointment", produces = MediaType.APPLICATION_JSON_VALUE) +public class AppointmentController +{ + + @Autowired + AppointmentService appointmentService; + @Autowired + CustomerService customerService; + @Autowired + TimeslotService timeslotService; + + + @GetMapping(path = {"/getall/{id}", "/getall/{id}/"}) + public ResponseEntity> getAllAppointments(@PathVariable String id) { + if(id == null)return new ResponseEntity<>(null, HttpStatus.NOT_ACCEPTABLE); + int ID = Integer.parseInt(id); + + Customer customer = customerService.getCustomerByID(ID); + if(customer == null) return new ResponseEntity<>(null, HttpStatus.NOT_ACCEPTABLE); + + List list = appointmentService.getAppointmentsByCustomer(customer); + List dtoList = new ArrayList<>(); + + if(list != null){ + for (Appointment appointment : list) + { + dtoList.add(convertToDto(appointment)); + } + } + return new ResponseEntity<>(dtoList, HttpStatus.OK); + } + + @GetMapping(path = {"/notifications/{id}", "/notifications/{id}/"}) + public ResponseEntity> notifications(@PathVariable String id) { + if(id == null)return new ResponseEntity<>(null, HttpStatus.NOT_ACCEPTABLE); + int ID = Integer.parseInt(id); + + Customer customer = customerService.getCustomerByID(ID); + if(customer == null) return new ResponseEntity<>(null, HttpStatus.NOT_ACCEPTABLE); + + List list = appointmentService.getAppointmentsByCustomer(customer); + + if(list != null){ + //finding the same date next week + Date now = new Date(LocalDate.now().toEpochDay()); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(now); + calendar.add(Calendar.DATE, 7); + Date nextWeek = new Date(calendar.getTimeInMillis()); + + List notificationList = new ArrayList<>(); + for (Appointment appointment : list) + { + List timeslots = appointment.getTimeslots(); + ArrayList newTimeslots = new ArrayList<>(); + for (Timeslot timeslot : timeslots) + { + if (timeslot.getStartDate().compareTo(now) >= 0 && timeslot.getStartDate().compareTo(nextWeek) <= 0) + { + newTimeslots.add(timeslot.getTimeSlotID()); + } + } + if (!newTimeslots.isEmpty()) + { + AppointmentDto appointmentDto = new AppointmentDto(appointment.getAppointmentID(), appointment.getAppointmentType().toString(), appointment.getService(), appointment.getNote(), appointment.getRating(), appointment.getFeedback(), appointment.getPaid(), appointment.getCustomer().getScrsUserId(), newTimeslots); + notificationList.add(appointmentDto); + } + } + + return new ResponseEntity<>(notificationList, HttpStatus.OK); + }else return new ResponseEntity<>(null, HttpStatus.OK); + } + + @PostMapping(value = {"/book", "/book/"}) + public ResponseEntity bookAppointment(@RequestBody AppointmentDto appointmentDto) + { + if (appointmentDto == null) + { + return new ResponseEntity<>(null, HttpStatus.EXPECTATION_FAILED); + } + try { + List timeslots = timeslotService.getTimeslotsById(appointmentDto.getTimeslotsId()); + if (timeslots == null) + { + return new ResponseEntity<>(null, HttpStatus.EXPECTATION_FAILED); + } + Customer customer = customerService.getCustomerByID(appointmentDto.getCustomerId()); + Appointment appointment = appointmentService.createAppointment(appointmentDto.getAppointmentType(), + appointmentDto.getService(), appointmentDto.getNote(), appointmentDto.getPaymentStatus(), + customer, timeslots.toArray(new Timeslot[0])); + return new ResponseEntity<>(convertToDto(appointment), HttpStatus.OK); + } catch (Exception e) { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PutMapping(value = {"/pay", "/pay/"}) + public ResponseEntity payAppointment(@RequestParam(name = "appointmentId") int appointmentId) + { + try + { + Appointment appointment = appointmentService.getAppointmentById(appointmentId); + if (appointment == null) { + return new ResponseEntity<>(null, HttpStatus.EXPECTATION_FAILED); + } + appointment.setPaid(true); + appointment = appointmentService.modifyAppointment(convertToDto(appointment)); + return new ResponseEntity<>(convertToDto(appointment), HttpStatus.OK); + } catch (Exception e) { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PutMapping(value = {"/rate", "/rate/"}) + public ResponseEntity rateAppointment(@RequestParam(name = "appointmentId") int appointmentId, @RequestParam(name = "rating") int rating) + { + if (rating > 10 || rating < 0) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + + try { + Appointment appointment = appointmentService.rateAppointment(appointmentId, rating); + return new ResponseEntity<>(convertToDto(appointment), HttpStatus.OK); + } catch (Exception e) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PutMapping(value = {"/modifyAppointment", "/modifyAppointment/"}) + public ResponseEntity modifyAppointment(@RequestBody AppointmentDto appointmentDto) + { + if (appointmentDto == null) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + try { + Appointment modifiedAppt = appointmentService.modifyAppointment(appointmentDto); + return new ResponseEntity<>(convertToDto(modifiedAppt), HttpStatus.OK); + } catch (Exception e) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/AssistantController.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/AssistantController.java new file mode 100644 index 0000000..0fabf78 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/AssistantController.java @@ -0,0 +1,96 @@ +package ca.mcgill.ecse321.scrs.controller; + +import ca.mcgill.ecse321.scrs.dto.AssistantDto; +import ca.mcgill.ecse321.scrs.dto.CustomerDto; +import ca.mcgill.ecse321.scrs.model.Assistant; +import ca.mcgill.ecse321.scrs.service.AssistantService; +import ca.mcgill.ecse321.scrs.service.SCRSUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import static ca.mcgill.ecse321.scrs.controller.Helper.*; + +@RestController +@RequestMapping(path = "/api/assistant") +public class AssistantController +{ + @Autowired + AssistantService assistantService; + @Autowired + SCRSUserService scrsUserService; + + @PostMapping(value = {"/create", "/create/"}) + public ResponseEntity createAssistant(@RequestBody Assistant assistant) + { + if (assistant == null) + { + return new ResponseEntity(new AssistantDto(), HttpStatus.EXPECTATION_FAILED); + // Invalid assistant. Please submit a valid assistant account to be created. + } + if (assistantService.getAssistantByEmail(assistant.getEmail()) != null) + { + return new ResponseEntity(new AssistantDto(), HttpStatus.ALREADY_REPORTED); + // Email already in use, please try a different email address. + } + Assistant newAssistant = assistantService.createAssistant(assistant.getEmail(), assistant.getName(), hash(assistant.getPassword()), assistant.getPhone()); + return new ResponseEntity<>(convertToDto(newAssistant), HttpStatus.OK); + } + + @PutMapping(value = {"/update", "/update/"}) + public ResponseEntity updateAssistant(@RequestBody Assistant assistant, @CookieValue(value = "id", defaultValue = "-1") String ID) + { + int id = Integer.parseInt(ID); + if (id == -1) + { + // TODO handle no login error with cookies (uncomment next line) + //return new ResponseEntity(new AssistantDto(), HttpStatus.UNAUTHORIZED); + // Please login to modify an assistant account. + } + if (assistant == null) + { + return new ResponseEntity(new AssistantDto(), HttpStatus.EXPECTATION_FAILED); + // Invalid assistant + } + if (!isAdmin(scrsUserService.getSCRSUserByID(id))) //does not have permission to edit. + { + // TODO handle bad login error with cookies (uncomment next line) + //return new ResponseEntity(new AssistantDto(), HttpStatus.UNAUTHORIZED); + // You do not have permission to edit an admin account. + } + if (assistantService.getAssistantByID(assistant.getScrsUserId()) == null) + { + return new ResponseEntity(new AssistantDto(), HttpStatus.NOT_ACCEPTABLE); + // No such assistant found. + } + Assistant updatedAssistant = assistantService.updateAssistantInfo(assistant); + return new ResponseEntity<>(convertToDto(updatedAssistant), HttpStatus.OK); + } + + @DeleteMapping(value = {"/delete/{id}", "/delete/{id}/"}) + public ResponseEntity deleteAssistant(@PathVariable String id, @CookieValue(value = "id", defaultValue = "-1") String ID) + { + int assistantID = Integer.parseInt(id); + int idCookie = Integer.parseInt(ID); + if (idCookie == -1) + { + // TODO handle no login error with cookies (uncomment next line) + //return new ResponseEntity(new AssistantDto(), HttpStatus.UNAUTHORIZED); + //Please login to delete an assistant account. + } + Assistant assistant = assistantService.getAssistantByID(assistantID); + if (assistant == null) + { + return new ResponseEntity(new AssistantDto(), HttpStatus.NOT_ACCEPTABLE); + // Invalid assistant. Please submit a valid assistant account to be deleted. + } + if (!isAdmin(scrsUserService.getSCRSUserByID(idCookie))) //does not have permission to edit. + { + // TODO handle bad login error with cookies (uncomment next line) + //return new ResponseEntity(new AssistantDto(), HttpStatus.UNAUTHORIZED); + // You do not have permission to edit this account. + } + return new ResponseEntity<>(convertToDto(assistantService.deleteAssistant(assistant)), HttpStatus.OK); + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/CookieController.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/CookieController.java new file mode 100644 index 0000000..19f2d33 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/CookieController.java @@ -0,0 +1,15 @@ +package ca.mcgill.ecse321.scrs.controller; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE) +public class CookieController +{ + + @GetMapping("/") + public String readCookie(@CookieValue(value = "id", defaultValue = "-1") String id){ + return id; + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/CustomerController.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/CustomerController.java new file mode 100644 index 0000000..b1cde6f --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/CustomerController.java @@ -0,0 +1,96 @@ +package ca.mcgill.ecse321.scrs.controller; + +import ca.mcgill.ecse321.scrs.dto.CustomerDto; +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.service.CustomerService; +import ca.mcgill.ecse321.scrs.service.SCRSUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import static ca.mcgill.ecse321.scrs.controller.Helper.*; + +@RestController +@RequestMapping(path = "/api/customer",produces = MediaType.APPLICATION_JSON_VALUE) +public class CustomerController +{ + @Autowired + CustomerService customerService; + @Autowired + SCRSUserService scrsUserService; + + @PostMapping(value = {"/create", "/create/"}) + public ResponseEntity createCustomer(@RequestBody Customer customer) + { + if (customer == null) + { + return new ResponseEntity(new CustomerDto(), HttpStatus.EXPECTATION_FAILED); + // Invalid customer. Please submit a valid customer account to be created. + } + if (customerService.getCustomerByEmail(customer.getEmail()) != null) + { + return new ResponseEntity(new CustomerDto(), HttpStatus.ALREADY_REPORTED); + // Email already in use, please try a different email address. + } + Customer newCustomer = customerService.createCustomer(customer.getEmail(), customer.getName(), hash(customer.getPassword()), customer.getPhone()); + return new ResponseEntity<>(convertToDto(newCustomer), HttpStatus.OK); + } + + @PutMapping(value = {"/update", "/update/"}) + public ResponseEntity updateCustomer(@RequestBody Customer customer, @CookieValue(value = "id", defaultValue = "-1") String ID) + { + int id = Integer.parseInt(ID); + if (id == -1) + { + // TODO handle no login error with cookies (uncomment next line) + //return new ResponseEntity(new CustomerDto(), HttpStatus.UNAUTHORIZED); + // Please login to modify a customer account. + } + if (customer == null) + { + return new ResponseEntity(new CustomerDto(), HttpStatus.EXPECTATION_FAILED); + // Invalid customer. + } + if (!isAdmin(scrsUserService.getSCRSUserByID(id)) && id != customer.getScrsUserId()) //does not have permission to edit. + { + // TODO handle bad login error with cookies (uncomment next line) + //return new ResponseEntity(new CustomerDto(), HttpStatus.UNAUTHORIZED); + // You cannot modify a customer account other than your own. + } + if (customerService.getCustomerByID(customer.getScrsUserId()) == null) + { + return new ResponseEntity(new CustomerDto(), HttpStatus.NOT_ACCEPTABLE); + // No such customer found. + } + Customer updatedCustomer = customerService.updateCustomerInfo(customer); + return new ResponseEntity<>(convertToDto(updatedCustomer), HttpStatus.OK); + } + + @DeleteMapping(value = {"/delete/{id}", "/delete/{id}/"}) + public ResponseEntity deleteCustomer(@PathVariable String id, @CookieValue(value = "id", defaultValue = "-1") String ID) + { + int customerID = Integer.parseInt(id); + int idCookie = Integer.parseInt(ID); + if (idCookie == -1) + { + // TODO handle no login error with cookies (uncomment next line) + //return new ResponseEntity(new CustomerDto(), HttpStatus.UNAUTHORIZED); + // Please login to delete a customer account. + } + Customer customer = customerService.getCustomerByID(customerID); + if (customer == null) + { + return new ResponseEntity(new CustomerDto(), HttpStatus.NOT_ACCEPTABLE); + // Invalid customer. Please submit a valid customer account to be deleted. + } + if (!isAdmin(scrsUserService.getSCRSUserByID(idCookie)) && idCookie != customerID) //does not have permission to edit. + { + // TODO handle bad login error with cookies (uncomment next line) + //return new ResponseEntity(new CustomerDto(), HttpStatus.UNAUTHORIZED); + // You cannot delete a customer account other than your own. + } + return new ResponseEntity<>(convertToDto(customerService.deleteCustomer(customer)), HttpStatus.OK); + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/DatabaseController.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/DatabaseController.java new file mode 100644 index 0000000..7f27265 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/DatabaseController.java @@ -0,0 +1,50 @@ +package ca.mcgill.ecse321.scrs.controller; + +import ca.mcgill.ecse321.scrs.dao.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(path = "/api/database", produces = MediaType.APPLICATION_JSON_VALUE) +public class DatabaseController +{ + @Autowired + private AppointmentRepository appointmentRepository; + @Autowired + private AssistantRepository assistantRepository; + @Autowired + private CustomerRepository customerRepository; + @Autowired + private SCRSRepository scrsRepository; + @Autowired + private SCRSUserRepository scrsUserRepository; + @Autowired + private TechnicianRepository technicianRepository; + @Autowired + private TimeslotRepository timeslotRepository; + @Autowired + private WorkspaceRepository workspaceRepository; + + public void clearDatabase() + { + appointmentRepository.deleteAll(); + timeslotRepository.deleteAll(); + assistantRepository.deleteAll(); + customerRepository.deleteAll(); + technicianRepository.deleteAll(); + scrsUserRepository.deleteAll(); + workspaceRepository.deleteAll(); + scrsRepository.deleteAll(); + } + + @DeleteMapping("/wipe") + public ResponseEntity loginCustomer() { + clearDatabase(); + return new ResponseEntity<>(true, HttpStatus.OK); + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/Helper.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/Helper.java new file mode 100644 index 0000000..0e50500 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/Helper.java @@ -0,0 +1,139 @@ +package ca.mcgill.ecse321.scrs.controller; + +import ca.mcgill.ecse321.scrs.dto.*; +import ca.mcgill.ecse321.scrs.model.*; + +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.List; + +public class Helper +{ + //helper functions + + public static String hash(String string) + { + if (string != null) + { + try + { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] encodedHash = digest.digest( + string.getBytes(StandardCharsets.UTF_8)); + return bytesToHex(encodedHash); + } catch (NoSuchAlgorithmException e) + { + System.out.println("bad algorithm"); + } + } + return "error"; + } + + // from https://www.baeldung.com/sha-256-hashing-java + private static String bytesToHex(byte[] hash) + { + StringBuilder hexString = new StringBuilder(2 * hash.length); + for (int i = 0; i < hash.length; i++) + { + String hex = Integer.toHexString(0xff & hash[i]); + if (hex.length() == 1) + { + hexString.append('0'); + } + hexString.append(hex); + } + return hexString.toString(); + } + + public static boolean isAdmin(SCRSUser user) + { + if (user == null) return false; + else return user instanceof Assistant; + } + + // ========== DTO Conversion ========== + + public static AppointmentDto convertToDto(Appointment appointment) + { + if (appointment == null) + { + throw new IllegalArgumentException("There is no such appointment!"); + } + if (appointment.getCustomer() == null) + { + throw new IllegalArgumentException("Appointment is ill-formed. Does not associate with valid customer!"); + } + if (appointment.getAppointmentType() == null) + { + throw new IllegalArgumentException("Appointment is ill-formed. Invalid appointmentType"); + } + AppointmentDto appointmentDto = new AppointmentDto(appointment.getAppointmentID(), appointment.getAppointmentType().toString(), appointment.getService(), appointment.getNote(), appointment.getRating(), appointment.getFeedback(), appointment.getPaid(), appointment.getCustomer().getScrsUserId()); + appointmentDto.setTimeslots(appointment.getTimeslots()); + return appointmentDto; + } + + public static AssistantDto convertToDto(Assistant assistant) + { + if (assistant == null) + { + throw new IllegalArgumentException("There is no such assistant!"); + } + return new AssistantDto(assistant.getScrsUserId(), assistant.getName(), assistant.getEmail(), assistant.getPhone()); + } + + public static CustomerDto convertToDto(Customer customer) + { + if (customer == null) + { + throw new IllegalArgumentException("There is no such customer!"); + } + return new CustomerDto(customer.getScrsUserId(), customer.getName(), customer.getEmail(), customer.getPhone()); + } + + public static TechnicianDto convertToDto(Technician technician) + { + if (technician == null) + { + throw new IllegalArgumentException("There is no such technician!"); + } + return new TechnicianDto(technician.getScrsUserId(), technician.getName(), technician.getEmail(), technician.getPhone()); + } + + public static TimeslotDto convertToDto(Timeslot timeslot) + { + if (timeslot == null) + { + throw new IllegalArgumentException("There is no such timeslot!"); + } + TimeslotDto timeslotDto = new TimeslotDto(timeslot.getTimeSlotID(), timeslot.getStartDate(), timeslot.getEndDate(), timeslot.getStartTime(), timeslot.getEndTime(), timeslot.getWorkspace().getWorkspaceID()); + timeslotDto.setTechnicians(timeslot.getTechnicians()); + return timeslotDto; + } + + public static List convertToDto(List timeslots) + { + if (timeslots == null) + { + throw new IllegalArgumentException("There is no such timeslot list!"); + } + ArrayList timeslotsDto = new ArrayList<>(); + for (Timeslot timeslot: timeslots) + { + timeslotsDto.add(convertToDto(timeslot)); + } + return timeslotsDto; + } + + public static WorkspaceDto convertToDto(Workspace workspace) + { + if (workspace == null) + { + throw new IllegalArgumentException("There is no such workspace!"); + } + WorkspaceDto workspaceDto = new WorkspaceDto(workspace.getWorkspaceID(), workspace.getSpaceName()); + workspaceDto.setTimeslotsId(workspace.getAvailabilities()); + return workspaceDto; + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/LoginController.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/LoginController.java new file mode 100644 index 0000000..680ec8b --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/LoginController.java @@ -0,0 +1,96 @@ +package ca.mcgill.ecse321.scrs.controller; + +import ca.mcgill.ecse321.scrs.model.Assistant; +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.model.Technician; +import ca.mcgill.ecse321.scrs.service.AssistantService; +import ca.mcgill.ecse321.scrs.service.CustomerService; +import ca.mcgill.ecse321.scrs.service.TechnicianService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; + +@RestController +@RequestMapping(path = "/api/login", produces = MediaType.APPLICATION_JSON_VALUE) +public class LoginController +{ + + @Autowired + private CustomerService customerService; + @Autowired + private AssistantService assistantService; + @Autowired + private TechnicianService technicianService; + + @PostMapping (value = {"/customer", "/customer/"}) + public ResponseEntity loginCustomer(@RequestParam("email") String email, @RequestParam("password") String password, HttpServletResponse response) { + + String hashedPassword = Helper.hash(password); + + Customer customer = customerService.getCustomerByEmail(email); + + if(customer == null || !customer.getPassword().equals(hashedPassword)) + { + return new ResponseEntity<>(false, HttpStatus.OK); + } + + String id = ((Integer)customer.getScrsUserId()).toString(); + Cookie cookie = new Cookie("id", id); + response.addCookie(cookie); + + return new ResponseEntity<>(true, HttpStatus.OK); + } + + @PostMapping (value = {"/assistant", "/assistant/"}) + public ResponseEntity loginAssistant(@RequestParam("email") String email, @RequestParam("password") String password, HttpServletResponse response) { + + String hashedPassword = Helper.hash(password); + + Assistant assistant = assistantService.getAssistantByEmail(email); + + if(assistant == null || !assistant.getPassword().equals(hashedPassword)) + { + return new ResponseEntity<>(false, HttpStatus.OK); + } + + String id = ((Integer)assistant.getScrsUserId()).toString(); + Cookie cookie = new Cookie("id", id); + response.addCookie(cookie); + + return new ResponseEntity<>(true, HttpStatus.OK); + } + + @PostMapping (value = {"/technician", "/technician/"}) + public ResponseEntity loginTechnician(@RequestParam("email") String email, @RequestParam("password") String password, HttpServletResponse response) { + + String hashedPassword = Helper.hash(password); + + Technician technician = technicianService.getTechnicianByEmail(email); + + if(technician == null || !technician.getPassword().equals(hashedPassword)) + { + return new ResponseEntity<>(false, HttpStatus.OK); + } + + String id = ((Integer)technician.getScrsUserId()).toString(); + Cookie cookie = new Cookie("id", id); + response.addCookie(cookie); + + return new ResponseEntity<>(true, HttpStatus.OK); + } + + @GetMapping(value = {"/logout", "/logout/"}) + public ResponseEntity logout(HttpServletResponse response) { + + Cookie cookie = new Cookie("id", null); + cookie.setMaxAge(0); + response.addCookie(cookie); + + return new ResponseEntity<>(true, HttpStatus.OK); + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/TechnicianController.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/TechnicianController.java new file mode 100644 index 0000000..ab4d268 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/TechnicianController.java @@ -0,0 +1,150 @@ +package ca.mcgill.ecse321.scrs.controller; + +import ca.mcgill.ecse321.scrs.dto.CustomerDto; +import ca.mcgill.ecse321.scrs.dto.TechnicianDto; +import ca.mcgill.ecse321.scrs.dto.TimeslotDto; +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.model.Technician; +import ca.mcgill.ecse321.scrs.model.Timeslot; +import ca.mcgill.ecse321.scrs.service.SCRSUserService; +import ca.mcgill.ecse321.scrs.service.TechnicianService; +import ca.mcgill.ecse321.scrs.service.TimeslotService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import java.sql.Date; +import java.util.ArrayList; +import java.util.List; + +import static ca.mcgill.ecse321.scrs.controller.Helper.*; + +@RestController +@RequestMapping(path = "/api/technician") +public class TechnicianController +{ + @Autowired + TechnicianService technicianService; + @Autowired + SCRSUserService scrsUserService; + @Autowired + TimeslotService timeslotService; + + @PostMapping(value = {"/create", "/create/"}) + public ResponseEntity createTechnician(@RequestBody Technician technician, @CookieValue(value = "id", defaultValue = "-1") String ID) + { + int id = Integer.parseInt(ID); + if (id == -1) + { + // TODO handle no login error with cookies (uncomment next line) + //return new ResponseEntity(new TechnicianDto(), HttpStatus.UNAUTHORIZED); + // Please login to create a technician account. + } + if (technician == null) + { + return new ResponseEntity(new TechnicianDto(), HttpStatus.EXPECTATION_FAILED); + // Invalid technician. Please submit a valid technician account to be created. + } + if (!isAdmin(scrsUserService.getSCRSUserByID(id))) //does not have permission to edit. + { + // TODO handle bad login error with cookies (uncomment next line) + //return new ResponseEntity(new TechnicianDto(), HttpStatus.UNAUTHORIZED); + // You do not have permission to create a technician account. + } + if (technicianService.getTechnicianByEmail(technician.getEmail()) != null) + { + return new ResponseEntity(new TechnicianDto(), HttpStatus.ALREADY_REPORTED); + // Email already in use, please try a different email address. + } + Technician newTechnician = technicianService.createTechnician(technician.getEmail(), technician.getName(), hash(technician.getPassword()), technician.getPhone()); + return new ResponseEntity<>(convertToDto(newTechnician), HttpStatus.OK); + } + + @PutMapping(value = {"/update", "/update/"}) + public ResponseEntity updateAssistant(@RequestBody Technician technician, @CookieValue(value = "id", defaultValue = "-1") String ID) + { + int id = Integer.parseInt(ID); + if (id == -1) + { + // TODO handle no login error with cookies (uncomment next line) + //return new ResponseEntity(new TechnicianDto(), HttpStatus.UNAUTHORIZED); + // Please login to modify a technician account. + } + if (technician == null) + { + return new ResponseEntity(new TechnicianDto(), HttpStatus.EXPECTATION_FAILED); + // Invalid technician. + } + if (!isAdmin(scrsUserService.getSCRSUserByID(id)) && id != technician.getScrsUserId()) //does not have permission to edit. + { + // TODO handle bad login error with cookies (uncomment next line) + //return new ResponseEntity(new TechnicianDto(), HttpStatus.UNAUTHORIZED); + // You do not have permission to create a technician account. + } + if (technicianService.getTechnicianByID(technician.getScrsUserId()) == null) + { + return new ResponseEntity(new TechnicianDto(), HttpStatus.NOT_ACCEPTABLE); + // No such technician found. + } + Technician updatedTechnician = technicianService.updateTechnicianInfo(technician); + return new ResponseEntity<>(convertToDto(updatedTechnician), HttpStatus.OK); + } + + @DeleteMapping(value = {"/delete/{id}", "/delete/{id}/"}) + public ResponseEntity deleteTechnician(@PathVariable String id, @CookieValue(value = "id", defaultValue = "-1") String ID) + { + int technicianID = Integer.parseInt(id); + int idCookie = Integer.parseInt(ID); + if (idCookie == -1) + { + // TODO handle no login error with cookies (uncomment next line) + //return new ResponseEntity(new TechnicianDto(), HttpStatus.UNAUTHORIZED); + // Please login to delete a technician account. + } + Technician technician = technicianService.getTechnicianByID(technicianID); + if (technician == null) + { + return new ResponseEntity(new TechnicianDto(), HttpStatus.NOT_ACCEPTABLE); + // Invalid technician. Please submit a valid technician account to be deleted. + } + if (!isAdmin(scrsUserService.getSCRSUserByID(idCookie)) && idCookie != technicianID) //does not have permission to edit. + { + // TODO handle bad login error with cookies (uncomment next line) + //return new ResponseEntity(new TechnicianDto(), HttpStatus.UNAUTHORIZED); + // You cannot delete a technician account other than your own. + } + return new ResponseEntity<>(convertToDto(technicianService.deleteTechnician(technician)), HttpStatus.OK); + } + + @GetMapping(path = {"/viewschedule/{id}/{startDate}/{endDate}"}) + public ResponseEntity> getAllByDate(@PathVariable("id") int technicianId, @PathVariable("startDate") String startDate, @PathVariable("endDate") String endDate)//, @CookieValue(value = "id", defaultValue = "-1") String ID) + { + + Date newStartDate=Date.valueOf(startDate); + Date newEndDate=Date.valueOf(endDate); + +// int id = Integer.parseInt(ID); +// if (id == -1) +// { +// return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); +// } +// +// if (!isAdmin(scrsUserService.getSCRSUserByID(id)) && id != technicianId) //does not have permission to view. +// { +// return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); +// } + + Technician technician = technicianService.getTechnicianByID(technicianId); + if (technician == null) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + + List timeslots = timeslotService.getTimeslotsByTechnicianBetweenDates(technician, newStartDate, newEndDate); + return new ResponseEntity<>(convertToDto(timeslots), HttpStatus.OK); + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/TimeslotController.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/TimeslotController.java new file mode 100644 index 0000000..3c8aad7 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/TimeslotController.java @@ -0,0 +1,129 @@ +package ca.mcgill.ecse321.scrs.controller; + +import ca.mcgill.ecse321.scrs.dto.TimeslotDto; +import ca.mcgill.ecse321.scrs.model.Technician; +import ca.mcgill.ecse321.scrs.model.Timeslot; +import ca.mcgill.ecse321.scrs.model.Workspace; +import ca.mcgill.ecse321.scrs.service.SCRSUserService; +import ca.mcgill.ecse321.scrs.service.TechnicianService; +import ca.mcgill.ecse321.scrs.service.TimeslotService; +import ca.mcgill.ecse321.scrs.service.WorkspaceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.sql.Date; +import java.util.List; + +import static ca.mcgill.ecse321.scrs.controller.Helper.*; + +@RestController +@RequestMapping(path = "/api/timeslot") +public class TimeslotController +{ + + @Autowired + TimeslotService timeslotService; + @Autowired + TechnicianService technicianService; + @Autowired + SCRSUserService scrsUserService; + @Autowired + WorkspaceService workspaceService; + + + @GetMapping(value = {"/getTimeslots", "/getTimeslots/"}) + public ResponseEntity> getTimeslots() + { + List timeslots = timeslotService.getAllTimeslots(); + return new ResponseEntity<>(convertToDto(timeslots), HttpStatus.OK); + } + + @GetMapping(value = {"/available/{startDate}/{endDate}", "/available/{startDate}/{endDate}/"}) + public ResponseEntity> getAvailableTimeslot(@PathVariable("startDate") String startDate, @PathVariable("endDate") String endDate) + { + try { + Date start = Date.valueOf(startDate); + Date end = Date.valueOf(endDate); + + List availableTimeslots = timeslotService.getAvailableTimeslots(start, end); + return new ResponseEntity<>(convertToDto(availableTimeslots), HttpStatus.OK); + } catch (Exception e) { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PutMapping(value = {"/assignTech", "/assignTech/"}) + public ResponseEntity assignTechnicianToTimeslot(@RequestParam(name = "timeslotId") int timeslotId, @RequestParam(name = "technicianId") int technicianId) + { + Timeslot timeslot = timeslotService.getTimeslotById(timeslotId); + if (timeslot == null) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + + try + { + Technician technician = technicianService.getTechnicianByID(technicianId); + if (technician != null) + { + List technicians = timeslot.getTechnicians(); + if (technicians != null) + { + if (technicians.stream() + .anyMatch(alreadyAssignedTech -> alreadyAssignedTech.getScrsUserId() == technicianId)) + { + // technician already assigned to timeslot + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + timeslotService.assignTechnicianToTimeslot(technician, timeslot); + return new ResponseEntity<>(convertToDto(timeslot), HttpStatus.OK); + } + } catch (Exception e) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @PostMapping(value = {"/create", "/create/"}) + public ResponseEntity createTimeslot(@RequestBody TimeslotDto timeslotDto) + { + if (timeslotDto == null) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + + Workspace workspace = workspaceService.getWorkspaceById(timeslotDto.getWorkspaceId()); + + try + { + Timeslot newTimeslot = timeslotService.createTimeslot(timeslotDto.getStartDate(), timeslotDto.getEndDate(), timeslotDto.getStartTime(), timeslotDto.getEndTime(), workspace); + if (newTimeslot == null) return new ResponseEntity<>(new TimeslotDto(), HttpStatus.EXPECTATION_FAILED); + return new ResponseEntity<>(convertToDto(newTimeslot), HttpStatus.OK); + } catch (Exception e) + { + return new ResponseEntity<>(new TimeslotDto(), HttpStatus.EXPECTATION_FAILED); + } + } + + @DeleteMapping(value = {"/delete/{id}", "/delete/{id}/"}) + public ResponseEntity deleteTimeslot(@PathVariable("id") int timeslotID) + { + try + { + Timeslot timeslot = timeslotService.getTimeslotById(timeslotID); + if (timeslot == null) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + return new ResponseEntity<>(convertToDto(timeslotService.deleteTimeslot(timeslot)), HttpStatus.OK); + } catch (Exception e) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } +} \ No newline at end of file diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/WorkspaceController.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/WorkspaceController.java new file mode 100644 index 0000000..87356d5 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/controller/WorkspaceController.java @@ -0,0 +1,73 @@ +package ca.mcgill.ecse321.scrs.controller; + +import ca.mcgill.ecse321.scrs.dto.TimeslotDto; +import ca.mcgill.ecse321.scrs.dto.WorkspaceDto; +import ca.mcgill.ecse321.scrs.model.Workspace; +import ca.mcgill.ecse321.scrs.service.SCRSUserService; +import ca.mcgill.ecse321.scrs.service.TimeslotService; +import ca.mcgill.ecse321.scrs.service.WorkspaceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +import static ca.mcgill.ecse321.scrs.controller.Helper.*; + +@RestController +@RequestMapping(path = "/api/workspace") +public class WorkspaceController +{ + @Autowired + TimeslotService timeslotService; + @Autowired + WorkspaceService workspaceService; + @Autowired + SCRSUserService scrsUserService; + + @PostMapping(value = {"/create", "/create/"}) + public ResponseEntity createWorkspace(@RequestParam(value = "name") String workspaceName) + { + if (workspaceName == null) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + try { + return new ResponseEntity<>(convertToDto(workspaceService.createWorkspace(workspaceName)), HttpStatus.OK); + } catch (Exception e) { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @DeleteMapping(value = {"/delete/{id}", "/delete/{id}/"}) + public ResponseEntity deleteWorkspace(@PathVariable("id") int workspaceId) + { + try { + Workspace workspace = workspaceService.getWorkspaceById(workspaceId); + if (workspace == null) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + return new ResponseEntity<>(convertToDto(workspaceService.deleteWorkspace(workspace)), HttpStatus.OK); + } catch (Exception e) { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @GetMapping(value = {"/availabilities/{id}","/availabilities/{id}/"}) + public ResponseEntity> getAllAvailableTimeslotsByWorkspace(@PathVariable("id") int workspaceId) + { + try { + Workspace workspace= workspaceService.getWorkspaceById(workspaceId); + if(workspace==null) + { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + return new ResponseEntity<>(convertToDto(timeslotService.getTimeslotsByWorkspace(workspace)),HttpStatus.OK); + } catch (Exception e) { + return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR); + } + + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/AppointmentRepository.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/AppointmentRepository.java index b5b927a..2535808 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/AppointmentRepository.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/AppointmentRepository.java @@ -1,6 +1,8 @@ package ca.mcgill.ecse321.scrs.dao; -import ca.mcgill.ecse321.scrs.model.*; +import ca.mcgill.ecse321.scrs.model.Appointment; +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.model.Timeslot; import org.springframework.data.repository.CrudRepository; import java.util.List; @@ -10,9 +12,15 @@ public interface AppointmentRepository extends CrudRepository findAppointmentsByAppointmentType(Appointment.AppointmentType type); List findAppointmentsByPaid(boolean aPaid); - List findAppointmentByCustomer(Customer customer); + List findAppointmentsByCustomer(Customer customer); + + List findAppointmentsByTimeslots(Timeslot timeslots); + + boolean existsByTimeslots(Timeslot timeslot); } diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/AssistantRepository.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/AssistantRepository.java index 0927917..5dca373 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/AssistantRepository.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/AssistantRepository.java @@ -7,4 +7,11 @@ public interface AssistantRepository extends CrudRepository { Assistant findByScrsUserId(int id); + + Assistant findByEmail(String email); + + Assistant findByName(String name); + + Assistant findByPhone(String phone); + } diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/CustomerRepository.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/CustomerRepository.java index a5cca73..08f71a5 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/CustomerRepository.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/CustomerRepository.java @@ -1,11 +1,19 @@ package ca.mcgill.ecse321.scrs.dao; +import ca.mcgill.ecse321.scrs.model.Appointment; import ca.mcgill.ecse321.scrs.model.Customer; import org.springframework.data.repository.CrudRepository; +import java.util.List; + public interface CustomerRepository extends CrudRepository { Customer findByScrsUserId(int id); + Customer findByEmail(String email); + + Customer findByName(String name); + + Customer findByPhone(String phone); } diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/SCRSUserRepository.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/SCRSUserRepository.java index 6117b34..8ff8480 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/SCRSUserRepository.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/SCRSUserRepository.java @@ -1,8 +1,16 @@ package ca.mcgill.ecse321.scrs.dao; +import ca.mcgill.ecse321.scrs.model.Customer; import ca.mcgill.ecse321.scrs.model.SCRSUser; import org.springframework.data.repository.CrudRepository; public interface SCRSUserRepository extends CrudRepository { + SCRSUser findByScrsUserId(int Id); + + Customer findByEmail(String email); + + Customer findByName(String name); + + Customer findByPhone(String phone); } diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/TechnicianRepository.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/TechnicianRepository.java index 5228ec6..55c4275 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/TechnicianRepository.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/TechnicianRepository.java @@ -1,9 +1,19 @@ package ca.mcgill.ecse321.scrs.dao; import ca.mcgill.ecse321.scrs.model.Technician; +import ca.mcgill.ecse321.scrs.model.Timeslot; import org.springframework.data.repository.CrudRepository; +import java.util.List; + public interface TechnicianRepository extends CrudRepository { Technician findByScrsUserId(int id); + + Technician findByEmail(String email); + + Technician findByName(String name); + + Technician findByPhone(String phone); + } diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/TimeslotRepository.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/TimeslotRepository.java index 02f1720..aafab0b 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/TimeslotRepository.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/TimeslotRepository.java @@ -1,20 +1,21 @@ package ca.mcgill.ecse321.scrs.dao; -import ca.mcgill.ecse321.scrs.model.Appointment; import ca.mcgill.ecse321.scrs.model.Technician; import ca.mcgill.ecse321.scrs.model.Timeslot; import ca.mcgill.ecse321.scrs.model.Workspace; import org.springframework.data.repository.CrudRepository; +import java.sql.Date; import java.util.List; -public interface TimeslotRepository extends CrudRepository +public interface +TimeslotRepository extends CrudRepository { Timeslot findByTimeSlotID(int id); - List findByAppointment(Appointment appt); - List findByWorkspace(Workspace ws); List findByTechnicians(Technician technicians); + + List findAllByStartDateGreaterThanEqualAndStartDateLessThanEqualOrderByStartDate(Date startDate, Date lastStartDate); } diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/WorkspaceRepository.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/WorkspaceRepository.java index c02043f..3ebd1e2 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/WorkspaceRepository.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dao/WorkspaceRepository.java @@ -5,6 +5,8 @@ import org.springframework.data.repository.CrudRepository; public interface WorkspaceRepository extends CrudRepository { + Workspace findByWorkspaceID(int id); + Workspace findBySpaceName(String name); } diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/AppointmentDto.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/AppointmentDto.java new file mode 100644 index 0000000..aa3d6e3 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/AppointmentDto.java @@ -0,0 +1,102 @@ +package ca.mcgill.ecse321.scrs.dto; + +import ca.mcgill.ecse321.scrs.model.Appointment; +import ca.mcgill.ecse321.scrs.model.Appointment.AppointmentType; +import ca.mcgill.ecse321.scrs.model.Timeslot; + +import java.util.ArrayList; +import java.util.List; + +public class AppointmentDto +{ + private int appointmentId; + private String appointmentType; + private String service; + private String note; + private int rating; + private String feedback; + private boolean paymentStatus; + private int customerId; + private ArrayList timeslotsId; + + public AppointmentDto() + { + } + + public AppointmentDto(int id, String type, String service, String note, int customerId, ArrayList timeslotsId) + { + this(id, type, service, note, -1, null, false, customerId, timeslotsId); + } + + public AppointmentDto(int id, String type, String service, String note, int rating, String feedback, boolean isPaid, int customerId) + { + this(id, type, service, note, rating, feedback, isPaid, customerId, new ArrayList()); + } + + public AppointmentDto(int id, String type, String service, String note, int rating, String feedback, boolean isPaid, int customerId, ArrayList timeslotsId) + { + appointmentId = id; + appointmentType = type; + this.service = service; + this.note = note; + this.rating = rating; + this.feedback = feedback; + paymentStatus = isPaid; + this.customerId = customerId; + this.timeslotsId = timeslotsId; + } + + public int getAppointmentId() + { + return appointmentId; + } + + public AppointmentType getAppointmentType() + { + return AppointmentType.valueOf(appointmentType); + } + + public String getService() + { + return service; + } + + public String getNote() + { + return note; + } + + public int getRating() + { + return rating; + } + + public String getFeedback() + { + return feedback; + } + + public boolean getPaymentStatus() + { + return paymentStatus; + } + + public int getCustomerId() + { + return customerId; + } + + public ArrayList getTimeslotsId() + { + return timeslotsId; + } + + public void setTimeslots(List timeslots) + { + this.timeslotsId = new ArrayList(); + for (Timeslot timeslot: timeslots) + { + timeslotsId.add(timeslot.getTimeSlotID()); + } + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/AssistantDto.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/AssistantDto.java new file mode 100644 index 0000000..32761b1 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/AssistantDto.java @@ -0,0 +1,56 @@ +package ca.mcgill.ecse321.scrs.dto; + +public class AssistantDto +{ + private int scrsUserId; + private String name; + private String email; + private String phone; + + public AssistantDto() + { + } + + public AssistantDto(int id, String name) + { + this(id, name, null, null); + } + + public AssistantDto(int id, String name, String email, String phone) + { + scrsUserId = id; + this.name = name; + this.email = email; + this.phone = phone; + } + + public int getAssistantId() + { + return scrsUserId; + } + + public String getAssistantName() + { + return name; + } + + public String getAssistantEmail() + { + return email; + } + + public String getAssistantPhone() + { + return phone; + } + + public void setAssistantEmail(String email) + { + this.email = email; + } + + public void setAssistantPhone(String phone) + { + this.phone = phone; + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/CustomerDto.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/CustomerDto.java new file mode 100644 index 0000000..723900e --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/CustomerDto.java @@ -0,0 +1,56 @@ +package ca.mcgill.ecse321.scrs.dto; + +public class CustomerDto +{ + private int scrsUserId; + private String name; + private String email; + private String phone; + + public CustomerDto() + { + } + + public CustomerDto(int id, String name) + { + this(id, name, null, null); + } + + public CustomerDto(int id, String name, String email, String phone) + { + scrsUserId = id; + this.name = name; + this.email = email; + this.phone = phone; + } + + public int getCustomerId() + { + return scrsUserId; + } + + public String getCustomerName() + { + return name; + } + + public String getCustomerEmail() + { + return email; + } + + public String getCustomerPhone() + { + return phone; + } + + public void setCustomerEmail(String email) + { + this.email = email; + } + + public void setCustomerPhone(String phone) + { + this.phone = phone; + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/TechnicianDto.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/TechnicianDto.java new file mode 100644 index 0000000..76e7c30 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/TechnicianDto.java @@ -0,0 +1,56 @@ +package ca.mcgill.ecse321.scrs.dto; + +public class TechnicianDto +{ + private int scrsUserId; + private String name; + private String email; + private String phone; + public TechnicianDto() + { + } + + public TechnicianDto(int id, String name) + { + this(id, name, null, null); + } + + public TechnicianDto(int id, String name, String email, String phone) + { + scrsUserId = id; + this.name = name; + this.email = email; + this.phone = phone; + + } + + public int getTechnicianId() + { + return scrsUserId; + } + + public String getTechnicianName() + { + return name; + } + + public String getTechnicianEmail() + { + return email; + } + + public String getTechnicianPhone() + { + return phone; + } + + public void setTechnicianEmail(String email) + { + this.email = email; + } + + public void setTechnicianPhone(String phone) + { + this.phone = phone; + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/TimeslotDto.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/TimeslotDto.java new file mode 100644 index 0000000..ae89807 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/TimeslotDto.java @@ -0,0 +1,86 @@ +package ca.mcgill.ecse321.scrs.dto; + +import ca.mcgill.ecse321.scrs.model.Technician; +import ca.mcgill.ecse321.scrs.model.Timeslot; + +import java.sql.Date; +import java.sql.Time; +import java.util.ArrayList; +import java.util.List; + +public class TimeslotDto +{ + private int timeslotId; + private Date startDate; + private Date endDate; + private Time startTime; + private Time endTime; + private int workspaceId; + private ArrayList techniciansId; + + public TimeslotDto() + { + } + + public TimeslotDto(int id, Date startDate, Date endDate, Time startTime, Time endTime, int workspaceId) { + this(id, startDate, endDate, startTime, endTime, workspaceId, new ArrayList()); + } + + public TimeslotDto(int id, Date startDate, Date endDate, Time startTime, Time endTime, int workspaceId, ArrayList techniciansId) + { + timeslotId = id; + this.startDate = startDate; + this.endDate = endDate; + this.startTime =startTime; + this.endTime = endTime; + this.workspaceId = workspaceId; + this.techniciansId = techniciansId; + } + + public int getTimeslotId() + { + return timeslotId; + } + + public Date getStartDate() + { + return startDate; + } + + public Date getEndDate() + { + return endDate; + } + + public Time getStartTime() + { + return startTime; + } + + public Time getEndTime() + { + return endTime; + } + + public int getWorkspaceId() + { + return workspaceId; + } + + public ArrayList getTechniciansId() + { + return techniciansId; + } + + public void setTechnicians(List technicians) + { + this.techniciansId = new ArrayList(); + if (technicians != null) + { + for (Technician technician: technicians) + { + techniciansId.add(technician.getScrsUserId()); + } + } + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/WorkspaceDto.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/WorkspaceDto.java new file mode 100644 index 0000000..e65d7a8 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/dto/WorkspaceDto.java @@ -0,0 +1,56 @@ +package ca.mcgill.ecse321.scrs.dto; + +import ca.mcgill.ecse321.scrs.model.Timeslot; + +import java.util.ArrayList; +import java.util.List; + +public class WorkspaceDto +{ + private int workspaceId; + private String spaceName; + private ArrayList timeslotsId; + + public WorkspaceDto() + { + } + + public WorkspaceDto(int id, String name) + { + this(id, name, new ArrayList()); + } + + public WorkspaceDto(int id, String name, ArrayList timeslotsId) + { + workspaceId = id; + spaceName = name; + this.timeslotsId = timeslotsId; + } + + public int getWorkspaceId() + { + return workspaceId; + } + + public String getSpaceName() + { + return spaceName; + } + + public List getTimeslotsId() + { + return timeslotsId; + } + + public void setTimeslotsId(List availabilities) + { + this.timeslotsId = new ArrayList(); + if (availabilities != null) + { + for (Timeslot timeslot: availabilities) + { + timeslotsId.add(timeslot.getTimeSlotID()); + } + } + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Appointment.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Appointment.java index b1ca1cc..2398e49 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Appointment.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Appointment.java @@ -28,13 +28,22 @@ public enum AppointmentType // Appointment Associations @ManyToOne private Customer customer; - @OneToMany(mappedBy = "appointment") //0..1 to 1..* + @OneToMany(fetch = FetchType.EAGER) //0..1 to 1..* private List timeslots; @ManyToOne private SCRS scrs; - protected Appointment() + public Appointment() { + appointmentType = null; + service = null; + note = null; + rating = -1; + feedback = null; + paid = false; + customer = null; + timeslots = new ArrayList(); + scrs = null; } public Appointment(AppointmentType aAppointmentType, String aService, String aNote, @@ -210,13 +219,7 @@ public boolean setCustomer(Customer aCustomer) return wasSet; } - Customer existingCustomer = customer; customer = aCustomer; - if (existingCustomer != null && !existingCustomer.equals(aCustomer)) - { - existingCustomer.removeAppointment(this); - } - customer.addAppointment(this); wasSet = true; return wasSet; } @@ -224,24 +227,12 @@ public boolean setCustomer(Customer aCustomer) /* Code from template association_AddMNToOptionalOne */ public boolean addTimeslot(Timeslot aTimeslot) { - boolean wasAdded = false; if (timeslots.contains(aTimeslot)) { return false; } - Appointment existingAppointment = aTimeslot.getAppointment(); - if (existingAppointment != null && existingAppointment.numberOfTimeslots() <= minimumNumberOfTimeslots()) - { - return wasAdded; - } - else if (existingAppointment != null) - { - existingAppointment.timeslots.remove(aTimeslot); - } timeslots.add(aTimeslot); - setAppointment(aTimeslot, this); - wasAdded = true; - return wasAdded; + return true; } public boolean removeTimeslot(Timeslot aTimeslot) @@ -250,80 +241,30 @@ public boolean removeTimeslot(Timeslot aTimeslot) if (timeslots.contains(aTimeslot) && numberOfTimeslots() > minimumNumberOfTimeslots()) { timeslots.remove(aTimeslot); - setAppointment(aTimeslot, null); wasRemoved = true; } return wasRemoved; } - /* Code from template association_SetMNToOptionalOne */ + /* Code from template association_SetUnidirectionalMStar */ public boolean setTimeslots(Timeslot... newTimeslots) { - boolean wasSet = false; - if (newTimeslots.length < minimumNumberOfTimeslots()) - { - return wasSet; - } - - ArrayList checkNewTimeslots = new ArrayList(); - HashMap appointmentToNewTimeslots = new HashMap(); + ArrayList verifiedTimeslots = new ArrayList(); for (Timeslot aTimeslot : newTimeslots) { - if (checkNewTimeslots.contains(aTimeslot)) + if (verifiedTimeslots.contains(aTimeslot)) { - return wasSet; + continue; } - else if (aTimeslot.getAppointment() != null && !this.equals(aTimeslot.getAppointment())) - { - Appointment existingAppointment = aTimeslot.getAppointment(); - if (!appointmentToNewTimeslots.containsKey(existingAppointment)) - { - appointmentToNewTimeslots.put(existingAppointment, - existingAppointment.numberOfTimeslots()); - } - Integer currentCount = appointmentToNewTimeslots.get(existingAppointment); - int nextCount = currentCount - 1; - if (nextCount < 1) - { - return wasSet; - } - appointmentToNewTimeslots.put(existingAppointment, nextCount); - } - checkNewTimeslots.add(aTimeslot); + verifiedTimeslots.add(aTimeslot); } - - timeslots.removeAll(checkNewTimeslots); - - for (Timeslot orphan : timeslots) + if (verifiedTimeslots.size() != newTimeslots.length || verifiedTimeslots.size() < minimumNumberOfTimeslots()) { - setAppointment(orphan, null); + return false; } timeslots.clear(); - for (Timeslot aTimeslot : newTimeslots) - { - if (aTimeslot.getAppointment() != null) - { - aTimeslot.getAppointment().timeslots.remove(aTimeslot); - } - setAppointment(aTimeslot, this); - timeslots.add(aTimeslot); - } - wasSet = true; - return wasSet; - } - - /* Code from template association_GetPrivate */ - private void setAppointment(Timeslot aTimeslot, Appointment aAppointment) - { - try - { - java.lang.reflect.Field mentorField = aTimeslot.getClass().getDeclaredField("appointment"); - mentorField.setAccessible(true); - mentorField.set(aTimeslot, aAppointment); - } catch (Exception e) - { - throw new RuntimeException("Issue internally setting aAppointment to aTimeslot", e); - } + timeslots.addAll(verifiedTimeslots); + return true; } /* Code from template association_AddIndexControlFunctions */ @@ -393,16 +334,7 @@ public boolean setScrs(SCRS aScrs) public void delete() { - Customer placeholderCustomer = customer; this.customer = null; - if (placeholderCustomer != null) - { - placeholderCustomer.removeAppointment(this); - } - for (Timeslot aTimeslot : timeslots) - { - setAppointment(aTimeslot, null); - } timeslots.clear(); SCRS placeholderScrs = scrs; this.scrs = null; diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Assistant.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Assistant.java index 6b2290b..e8186c3 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Assistant.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Assistant.java @@ -11,8 +11,9 @@ public Assistant(String aName, String aPassword, String aEmail, String aPhone, S super(aName, aPassword, aEmail, aPhone, aScrs); } - protected Assistant() + public Assistant() { + super(); } public String toString() diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Customer.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Customer.java index 7316b2e..1fadf2a 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Customer.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Customer.java @@ -9,146 +9,19 @@ public class Customer extends SCRSUser { // Customer Associations - @OneToMany(mappedBy = "customer") - private List appointments; public Customer(String aName, String aPassword, String aEmail, String aPhone, SCRS aScrs) { super(aName, aPassword, aEmail, aPhone, aScrs); - appointments = new ArrayList(); } - protected Customer() + public Customer() { - } - - public static int minimumNumberOfAppointments() - { - return 0; - } - - public Appointment getAppointment(int index) - { - return appointments.get(index); - } - - public List getAppointments() - { - return appointments; - } - - public void setAppointments(List appointments) - { - this.appointments = appointments; - } - - public int numberOfAppointments() - { - return appointments.size(); - } - - public boolean hasAppointments() - { - return appointments.size() > 0; - } - - public int indexOfAppointment(Appointment aAppointment) - { - return appointments.indexOf(aAppointment); - } - - public Appointment addAppointment(ca.mcgill.ecse321.scrs.model.Appointment.AppointmentType aAppointmentType, String aService, String aNote, - int aRating, String aFeedback, boolean aPaid, SCRS aScrs, Timeslot... allTimeslots) - { - return new Appointment(aAppointmentType, aService, aNote, aRating, aFeedback, aPaid, this, - aScrs, allTimeslots); - } - - public boolean addAppointment(Appointment aAppointment) - { - boolean wasAdded = false; - if (appointments.contains(aAppointment)) - { - return false; - } - Customer existingCustomer = aAppointment.getCustomer(); - boolean isNewCustomer = existingCustomer != null && !this.equals(existingCustomer); - if (isNewCustomer) - { - aAppointment.setCustomer(this); - } - else - { - appointments.add(aAppointment); - } - wasAdded = true; - return wasAdded; - } - - public boolean removeAppointment(Appointment aAppointment) - { - boolean wasRemoved = false; - // Unable to remove aAppointment, as it must always have a customer - if (!this.equals(aAppointment.getCustomer())) - { - appointments.remove(aAppointment); - wasRemoved = true; - } - return wasRemoved; - } - - /* Code from template association_AddIndexControlFunctions */ - public boolean addAppointmentAt(Appointment aAppointment, int index) - { - boolean wasAdded = false; - if (addAppointment(aAppointment)) - { - if (index < 0) - { - index = 0; - } - if (index > numberOfAppointments()) - { - index = numberOfAppointments() - 1; - } - appointments.remove(aAppointment); - appointments.add(index, aAppointment); - wasAdded = true; - } - return wasAdded; - } - - public boolean addOrMoveAppointmentAt(Appointment aAppointment, int index) - { - boolean wasAdded = false; - if (appointments.contains(aAppointment)) - { - if (index < 0) - { - index = 0; - } - if (index > numberOfAppointments()) - { - index = numberOfAppointments() - 1; - } - appointments.remove(aAppointment); - appointments.add(index, aAppointment); - wasAdded = true; - } - else - { - wasAdded = addAppointmentAt(aAppointment, index); - } - return wasAdded; + super(); } public void delete() { - for (int i = appointments.size(); i > 0; i--) - { - Appointment aAppointment = appointments.get(i - 1); - aAppointment.delete(); - } super.delete(); } diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/SCRSUser.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/SCRSUser.java index d0953fa..a04efff 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/SCRSUser.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/SCRSUser.java @@ -29,24 +29,17 @@ public SCRSUser(String aName, String aPassword, String aEmail, String aPhone, SC email = aEmail; phone = aPhone; boolean didAddScrs = setScrs(aScrs); - if (!didAddScrs) - { - throw new RuntimeException( - "Unable to create user due to scrs. See http://manual.umple.org?RE002ViolationofAssociationMultiplicity.html"); - } } protected SCRSUser() { - name = "Invalid"; - password = "Invalid"; - email = "Invalid"; - phone = "Invalid"; + name = null; + password = null; + email = null; + phone = null; scrs = null; } - ; - public int getScrsUserId() { return this.scrsUserId; diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Technician.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Technician.java index 8f16265..df19575 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Technician.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Technician.java @@ -10,88 +10,14 @@ @Entity public class Technician extends SCRSUser { - @ManyToMany - @JoinTable( - name = "technician_availabilities", - joinColumns = @JoinColumn(name = "technician_id"), - inverseJoinColumns = @JoinColumn(name = "timeslot_id") - ) - private List availabilities; - public Technician(String aName, String aPassword, String aEmail, String aPhone, SCRS aScrs) { super(aName, aPassword, aEmail, aPhone, aScrs); - availabilities = new ArrayList(); } protected Technician() { - } - - ; - - public List getAvailabilities() - { - return this.availabilities; - } - - public void setAvailabilities(List av) - { - this.availabilities = av; - } - - public boolean addAvailability(Timeslot aAvailability) - { - boolean wasAdded = false; - if (availabilities.contains(aAvailability)) - { - return false; - } - availabilities.add(aAvailability); - if (aAvailability.indexOfTechnician(this) != -1) - { - wasAdded = true; - } - else - { - wasAdded = aAvailability.addTechnician(this); - if (!wasAdded) - { - availabilities.remove(aAvailability); - } - } - return wasAdded; - } - - public int indexOfAvailability(Timeslot aAvailability) - { - int index = availabilities.indexOf(aAvailability); - return index; - } - - public boolean removeAvailability(Timeslot aAvailability) - { - boolean wasRemoved = false; - if (!availabilities.contains(aAvailability)) - { - return wasRemoved; - } - - int oldIndex = availabilities.indexOf(aAvailability); - availabilities.remove(oldIndex); - if (aAvailability.indexOfTechnician(this) == -1) - { - wasRemoved = true; - } - else - { - wasRemoved = aAvailability.removeTechnician(this); - if (!wasRemoved) - { - availabilities.add(oldIndex, aAvailability); - } - } - return wasRemoved; + super(); } public String toString() diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Timeslot.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Timeslot.java index 00b1996..9eb7764 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Timeslot.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Timeslot.java @@ -22,16 +22,9 @@ public class Timeslot private Time endTime; // Timeslot Associations - @ManyToMany - @JoinTable( - name = "technician_availabilities", - joinColumns = @JoinColumn(name = "timeslot_id"), - inverseJoinColumns = @JoinColumn(name = "technician_id") - ) + @ManyToMany(fetch = FetchType.EAGER) private List technicians; @ManyToOne - private Appointment appointment; - @ManyToOne private Workspace workspace; public Timeslot(Date aStartDate, Date aEndDate, Time aStartTime, Time aEndTime, @@ -50,12 +43,16 @@ public Timeslot(Date aStartDate, Date aEndDate, Time aStartTime, Time aEndTime, } } - protected Timeslot() + public Timeslot() { + startDate = null; + endDate = null; + startTime = null; + endTime = null; + technicians = new ArrayList<>(); + workspace = null; } - ; - public static int minimumNumberOfTechnician() { return 0; @@ -147,16 +144,6 @@ public int indexOfTechnician(Technician aTechnician) return technicians.indexOf(aTechnician); } - public Appointment getAppointment() - { - return appointment; - } - - public boolean hasAppointment() - { - return appointment != null; - } - public Workspace getWorkspace() { return workspace; @@ -165,51 +152,24 @@ public Workspace getWorkspace() /* Code from template association_AddManyToManyMethod */ public boolean addTechnician(Technician aTechnician) { - boolean wasAdded = false; if (technicians.contains(aTechnician)) { return false; } technicians.add(aTechnician); - if (aTechnician.indexOfAvailability(this) != -1) - { - wasAdded = true; - } - else - { - wasAdded = aTechnician.addAvailability(this); - if (!wasAdded) - { - technicians.remove(aTechnician); - } - } - return wasAdded; + return true; } /* Code from template association_RemoveMany */ public boolean removeTechnician(Technician aTechnician) { - boolean wasRemoved = false; if (!technicians.contains(aTechnician)) { - return wasRemoved; + return false; } - int oldIndex = technicians.indexOf(aTechnician); - technicians.remove(oldIndex); - if (aTechnician.indexOfAvailability(this) == -1) - { - wasRemoved = true; - } - else - { - wasRemoved = aTechnician.removeAvailability(this); - if (!wasRemoved) - { - technicians.add(oldIndex, aTechnician); - } - } - return wasRemoved; + technicians.remove(aTechnician); + return true; } /* Code from template association_AddIndexControlFunctions */ @@ -257,66 +217,13 @@ public boolean addOrMoveTechnicianAt(Technician aTechnician, int index) return wasAdded; } - /* Code from template association_SetOptionalOneToMandatoryMany */ - public boolean setAppointment(Appointment aAppointment) - { - // - // This source of this source generation is - // association_SetOptionalOneToMandatoryMany.jet - // This set file assumes the generation of a maximumNumberOfXXX method does not - // exist because - // it's not required (No upper bound) - // - boolean wasSet = false; - Appointment existingAppointment = appointment; - - if (existingAppointment == null) - { - if (aAppointment != null) - { - if (aAppointment.addTimeslot(this)) - { - existingAppointment = aAppointment; - wasSet = true; - } - } - } - else if (existingAppointment != null) - { - if (aAppointment == null) - { - if (Appointment.minimumNumberOfTimeslots() < existingAppointment.numberOfTimeslots()) - { - existingAppointment.removeTimeslot(this); - existingAppointment = aAppointment; // aAppointment == null - wasSet = true; - } - } - else - { - if (Appointment.minimumNumberOfTimeslots() < existingAppointment.numberOfTimeslots()) - { - existingAppointment.removeTimeslot(this); - aAppointment.addTimeslot(this); - existingAppointment = aAppointment; - wasSet = true; - } - } - } - if (wasSet) - { - appointment = existingAppointment; - } - return wasSet; - } /* Code from template association_SetOneToMany */ public boolean setWorkspace(Workspace aWorkspace) { - boolean wasSet = false; if (aWorkspace == null) { - return wasSet; + return false; } Workspace existingWorkspace = workspace; @@ -326,31 +233,12 @@ public boolean setWorkspace(Workspace aWorkspace) existingWorkspace.removeAvailability(this); } workspace.addAvailability(this); - wasSet = true; - return wasSet; + return true; } public void delete() { - ArrayList copyOfTechnician = new ArrayList(technicians); technicians.clear(); - for (Technician aTechnician : copyOfTechnician) - { - aTechnician.removeAvailability(this); - } - if (appointment != null) - { - if (appointment.numberOfTimeslots() <= 1) - { - appointment.delete(); - } - else - { - Appointment placeholderAppointment = appointment; - this.appointment = null; - placeholderAppointment.removeTimeslot(this); - } - } Workspace placeholderWorkspace = workspace; this.workspace = null; if (placeholderWorkspace != null) @@ -378,8 +266,6 @@ public String toString() + (getEndTime() != null ? !getEndTime().equals(this.endTime) ? getEndTime().toString().replaceAll(" ", " ") : "this" : "null") - + System.getProperties().getProperty("line.separator") + " " + "appointment = " - + (getAppointment() != null ? Integer.toHexString(System.identityHashCode(getAppointment())) : "null") + System.getProperties().getProperty("line.separator") + " " + "workspace = " + (getWorkspace() != null ? Integer.toHexString(System.identityHashCode(getWorkspace())) : "null"); } diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Workspace.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Workspace.java index 12cbd13..3e6af97 100644 --- a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Workspace.java +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/model/Workspace.java @@ -16,17 +16,17 @@ public class Workspace @GeneratedValue(generator = "increment") @GenericGenerator(name = "increment", strategy = "increment") private int workspaceID; - private String spaceType; + private String spaceName; // Workspace Associations - @OneToMany(mappedBy = "workspace") + @OneToMany(fetch = FetchType.EAGER, mappedBy = "workspace") private List availabilities; @ManyToOne private SCRS scrs; - public Workspace(String aSpaceType, SCRS aScrs) + public Workspace(String aSpaceName, SCRS aScrs) { - spaceType = aSpaceType; + spaceName = aSpaceName; availabilities = new ArrayList(); boolean didAddScrs = setScrs(aScrs); if (!didAddScrs) @@ -36,12 +36,12 @@ public Workspace(String aSpaceType, SCRS aScrs) } } - protected Workspace() + public Workspace() { + scrs = null; + availabilities = new ArrayList<>(); } - ; - public static int minimumNumberOfAvailabilities() { return 0; @@ -53,9 +53,9 @@ public boolean setWorkspaceID(int aWorkspaceID) return true; } - public boolean setSpaceType(String aSpaceType) + public boolean setSpaceName(String aSpaceType) { - spaceType = aSpaceType; + spaceName = aSpaceType; return true; } @@ -64,9 +64,9 @@ public int getWorkspaceID() return workspaceID; } - public String getSpaceType() + public String getSpaceName() { - return spaceType; + return spaceName; } public Timeslot getAvailability(int index) @@ -227,7 +227,7 @@ public void delete() public String toString() { return super.toString() + "[" + "workspaceID" + ":" + getWorkspaceID() + "," + "spaceType" + ":" - + getSpaceType() + "]" + System.getProperties().getProperty("line.separator") + " " + "scrs = " + + getSpaceName() + "]" + System.getProperties().getProperty("line.separator") + " " + "scrs = " + (getScrs() != null ? Integer.toHexString(System.identityHashCode(getScrs())) : "null"); } } \ No newline at end of file diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/AppointmentService.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/AppointmentService.java new file mode 100644 index 0000000..d844f71 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/AppointmentService.java @@ -0,0 +1,127 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.AppointmentRepository; +import ca.mcgill.ecse321.scrs.dao.CustomerRepository; +import ca.mcgill.ecse321.scrs.dao.TimeslotRepository; +import ca.mcgill.ecse321.scrs.dto.AppointmentDto; +import ca.mcgill.ecse321.scrs.model.Appointment; +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.model.Timeslot; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.toList; + +@Service +public class AppointmentService { + + @Autowired + AppointmentRepository appointmentRepository; + @Autowired + CustomerRepository customerRepository; + @Autowired + TimeslotRepository timeslotRepository; + + @Transactional + public Appointment createAppointment(Appointment.AppointmentType appointmentType, String service, String note, boolean paid, Customer customer, Timeslot... timeslots) { + if(appointmentType == null) throw new IllegalArgumentException("Please submit a valid appointment type."); + if(customer == null || customerRepository.findByScrsUserId(customer.getScrsUserId()) == null) throw new IllegalArgumentException("Please submit a valid customer."); + try + { + if(timeslots.length == 0 || timeslotRepository.findByTimeSlotID(timeslots[0].getTimeSlotID()) == null) throw new IllegalArgumentException("Please select at least one valid timeslot."); + } catch (NullPointerException e) + { + throw new IllegalArgumentException("Please select at least one valid timeslot."); + } + Appointment appointment = new Appointment(); + appointment.setAppointmentType(appointmentType); + appointment.setService(service); + appointment.setCustomer(customer); + appointment.setTimeslots(timeslots); + appointment.setNote(note); + appointment.setPaid(paid); + appointmentRepository.save(appointment); + return appointment; + } + + @Transactional + public List getAllAppointments() { + return toList(appointmentRepository.findAll()); + } + + @Transactional + public Appointment getAppointmentById(int id) { + return appointmentRepository.findByAppointmentID(id); + } + + @Transactional + public List getAppointmentsByCustomer(Customer customer) { + return appointmentRepository.findAppointmentsByCustomer(customer); + } + + @Transactional + public Appointment getAppointmentByTimeslot(Timeslot timeslot) { + return appointmentRepository.findByTimeslotsContains(timeslot); + } + + @Transactional + public Appointment rateAppointment(int appointmentId, int rating) { + Appointment appointment = getAppointmentById(appointmentId); + if (appointment == null) throw new IllegalArgumentException("No such appointment!"); + if (rating > 10 || rating < 0) throw new IllegalArgumentException("Invalid rating"); + appointment.setRating(rating); + appointmentRepository.save(appointment); + return appointment; + } + + @Transactional + public Appointment modifyAppointment(AppointmentDto appt) + { + if (appt == null) throw new IllegalArgumentException("Invalid appointment"); + if (appt == null) throw new IllegalArgumentException("Invalid appointment"); + if (appt.getAppointmentType() == null) throw new IllegalArgumentException("Invalid appointment type."); + if (appt.getCustomerId() == -1) throw new IllegalArgumentException("Invalid customer."); + if (appt.getTimeslotsId() == null || appt.getTimeslotsId().size() == 0) throw new IllegalArgumentException("No valid timeslots selected."); + if (appt.getRating() != -1 && (appt.getRating() > 10 || appt.getRating() < 0)) throw new IllegalArgumentException("Invalid rating"); + + Appointment apptToModify = appointmentRepository.findByAppointmentID(appt.getAppointmentId()); + if (apptToModify == null) throw new IllegalArgumentException("No such appointment exists"); + + apptToModify.setAppointmentType(appt.getAppointmentType()); + apptToModify.setService(appt.getService()); + apptToModify.setNote(appt.getNote()); + apptToModify.setRating(appt.getRating()); + apptToModify.setFeedback(appt.getFeedback()); + apptToModify.setPaid(appt.getPaymentStatus()); + + List timeslots = appt.getTimeslotsId(); + apptToModify.setTimeslots(); // clear timeslots + if (timeslots != null) + { + // if we are passed some timeslot ids. add them + for (Integer timeslotId : timeslots) + { + Timeslot timeslotToAdd = timeslotRepository.findByTimeSlotID(timeslotId); + if (timeslotToAdd != null) + { + apptToModify.addTimeslot(timeslotToAdd); + } + } + } + + apptToModify.setCustomer(customerRepository.findByScrsUserId(appt.getCustomerId())); + + appointmentRepository.save(apptToModify); + return apptToModify; + } + + @Transactional + public Appointment deleteAppointment(Appointment appt) + { + appointmentRepository.delete(appt); + return appt; + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/AssistantService.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/AssistantService.java new file mode 100644 index 0000000..eaf564a --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/AssistantService.java @@ -0,0 +1,77 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.AssistantRepository; +import ca.mcgill.ecse321.scrs.model.Assistant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.checkAccountInfoValidity; +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.toList; + +@Service +public class AssistantService +{ + @Autowired + AssistantRepository assistantRepository; + + @Transactional + public Assistant createAssistant(String email, String name, String password, String phone) + { + checkAccountInfoValidity(email, name, password, phone); + Assistant assistant = new Assistant(); + assistant.setEmail(email); + assistant.setName(name); + assistant.setPassword(password); + assistant.setPhone(phone); + assistantRepository.save(assistant); + return assistant; + } + + @Transactional + public Assistant getAssistantByID(int id) + { + return assistantRepository.findByScrsUserId(id); + } + + @Transactional + public List getAllAssistants() + { + return toList(assistantRepository.findAll()); + } + + @Transactional + public Assistant getAssistantByEmail(String email) + { + return assistantRepository.findByEmail(email); + } + + @Transactional + public Assistant getAssistantByName(String name) + { + return assistantRepository.findByName(name); + } + + @Transactional + public Assistant getAssistantByPhone(String phone) + { + return assistantRepository.findByPhone(phone); + } + + @Transactional + public Assistant updateAssistantInfo(Assistant assistant) + { + checkAccountInfoValidity(assistant); + assistantRepository.save(assistant); + return assistant; + } + + @Transactional + public Assistant deleteAssistant(Assistant assistant) + { + assistantRepository.delete(assistant); + return assistant; + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/CustomerService.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/CustomerService.java new file mode 100644 index 0000000..9ab8b62 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/CustomerService.java @@ -0,0 +1,78 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.CustomerRepository; +import ca.mcgill.ecse321.scrs.model.Customer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.checkAccountInfoValidity; +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.toList; + +@Service +public class CustomerService +{ + + @Autowired + CustomerRepository customerRepository; + + @Transactional + public Customer createCustomer(String email, String name, String password, String phone) + { + checkAccountInfoValidity(email, name, password, phone); + Customer customer = new Customer(); + customer.setEmail(email); + customer.setName(name); + customer.setPassword(password); + customer.setPhone(phone); + customerRepository.save(customer); + return customer; + } + + @Transactional + public List getAllCustomers() + { + return toList(customerRepository.findAll()); + } + + @Transactional + public Customer getCustomerByID(int id) + { + return customerRepository.findByScrsUserId(id); + } + + @Transactional + public Customer getCustomerByEmail(String email) + { + return customerRepository.findByEmail(email); + } + + @Transactional + public Customer getCustomerByName(String name) + { + return customerRepository.findByName(name); + } + + @Transactional + public Customer getCustomerByPhone(String phone) + { + return customerRepository.findByPhone(phone); + } + + @Transactional + public Customer updateCustomerInfo(Customer customer) + { + checkAccountInfoValidity(customer); + customerRepository.save(customer); + return customer; + } + + @Transactional + public Customer deleteCustomer(Customer customer) + { + customerRepository.delete(customer); + return customer; + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/SCRSService.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/SCRSService.java new file mode 100644 index 0000000..444b12e --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/SCRSService.java @@ -0,0 +1,16 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.SCRSRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +@Service +public class SCRSService { + + @Autowired + SCRSRepository scrsRepository; + + //No tests since there are no service methods in the SCRSService class + +} \ No newline at end of file diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/SCRSUserService.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/SCRSUserService.java new file mode 100644 index 0000000..dcc9341 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/SCRSUserService.java @@ -0,0 +1,50 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.SCRSUserRepository; +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.model.SCRSUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.toList; + +@Service +public class SCRSUserService +{ + + @Autowired + SCRSUserRepository scrsUserRepository; + + @Transactional + public List getAllSCRSUsers() + { + return toList(scrsUserRepository.findAll()); + } + + @Transactional + public SCRSUser getSCRSUserByID(int id) + { + return scrsUserRepository.findByScrsUserId(id); + } + + @Transactional + public Customer getSCRSUserByEmail(String email) + { + return scrsUserRepository.findByEmail(email); + } + + @Transactional + public Customer getSCRSUserByName(String name) + { + return scrsUserRepository.findByName(name); + } + + @Transactional + public Customer getSCRSUserByPhone(String phone) + { + return scrsUserRepository.findByPhone(phone); + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/ServiceHelpers.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/ServiceHelpers.java new file mode 100644 index 0000000..c44a40b --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/ServiceHelpers.java @@ -0,0 +1,49 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.model.SCRSUser; + +import java.sql.Date; +import java.sql.Time; +import java.util.ArrayList; +import java.util.List; + + +public class ServiceHelpers +{ + public static List toList(Iterable iterable){ + List resultList = new ArrayList(); + for (T t : iterable) { + resultList.add(t); + } + return resultList; + } + + public static void checkAccountInfoValidity(String email, String name, String password, String phone) + { + if(email == null || email.trim().length() == 0) throw new IllegalArgumentException("Please submit a valid email."); + if(name == null || name.trim().length() == 0) throw new IllegalArgumentException("Please submit a valid name."); + if(password == null || password.trim().length() == 0) throw new IllegalArgumentException("Please submit a valid password."); + if(phone == null || phone.trim().length() == 0) throw new IllegalArgumentException("Please submit a valid phone."); + } + + public static void checkAccountInfoValidity(SCRSUser user) + { + if (user == null) throw new IllegalArgumentException("Please submit a valid user object."); + if(user.getEmail() == null || user.getEmail().trim().length() == 0) throw new IllegalArgumentException("Please submit a valid email."); + if(user.getName() == null || user.getName().trim().length() == 0) throw new IllegalArgumentException("Please submit a valid name."); + if(user.getPassword() == null || user.getPassword().trim().length() == 0) throw new IllegalArgumentException("Please submit a valid password."); + if(user.getPhone() == null || user.getPhone().trim().length() == 0) throw new IllegalArgumentException("Please submit a valid phone."); + } + + public static void checkDateValidity(Date startDate, Date endDate) + { + if (startDate == null || endDate == null) throw new IllegalArgumentException("Please input a valid start and end date."); + if (startDate.after(endDate)) throw new IllegalArgumentException("Your start date cannot be after your end date."); + } + + public static void checkTimeValidity(Time startTime, Time endTime) + { + if (startTime == null || endTime == null) throw new IllegalArgumentException("Please input a valid start and end time."); + if (startTime.after(endTime)) throw new IllegalArgumentException("Your start time cannot be after your end time."); + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/TechnicianService.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/TechnicianService.java new file mode 100644 index 0000000..8b27a2e --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/TechnicianService.java @@ -0,0 +1,76 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.TechnicianRepository; +import ca.mcgill.ecse321.scrs.model.Technician; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Time; +import java.util.List; + +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.checkAccountInfoValidity; +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.toList; + +@Service +public class TechnicianService +{ + + @Autowired + TechnicianRepository technicianRepository; + + @Transactional + public Technician createTechnician(String email, String name, String password, String phone) + { + checkAccountInfoValidity(email, name, password, phone); + Technician technician = new Technician(name, password, email, phone, null); + technicianRepository.save(technician); + return technician; + } + + + @Transactional + public List getAllTechnicians() + { + return toList(technicianRepository.findAll()); + } + + @Transactional + public Technician getTechnicianByID(int id) + { + return technicianRepository.findByScrsUserId(id); + } + + @Transactional + public Technician getTechnicianByEmail(String email) + { + return technicianRepository.findByEmail(email); + } + + @Transactional + public Technician getTechnicianByName(String name) + { + return technicianRepository.findByName(name); + } + + @Transactional + public Technician getTechnicianByPhone(String phone) + { + return technicianRepository.findByPhone(phone); + } + + @Transactional + public Technician updateTechnicianInfo(Technician technician) + { + checkAccountInfoValidity(technician); + technicianRepository.save(technician); + return technician; + } + + @Transactional + public Technician deleteTechnician(Technician technician) + { + technicianRepository.delete(technician); + return technician; + } +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/TimeslotService.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/TimeslotService.java new file mode 100644 index 0000000..bcd2530 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/TimeslotService.java @@ -0,0 +1,122 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.AppointmentRepository; +import ca.mcgill.ecse321.scrs.dao.TechnicianRepository; +import ca.mcgill.ecse321.scrs.dao.TimeslotRepository; +import ca.mcgill.ecse321.scrs.dao.WorkspaceRepository; +import ca.mcgill.ecse321.scrs.model.Technician; +import ca.mcgill.ecse321.scrs.model.Timeslot; +import ca.mcgill.ecse321.scrs.model.Workspace; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Date; +import java.sql.Time; +import java.util.ArrayList; +import java.util.List; + +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.*; + +@Service +public class TimeslotService +{ + + @Autowired + TimeslotRepository timeslotRepository; + + @Autowired + AppointmentRepository appointmentRepository; + + @Autowired + WorkspaceRepository workspaceRepository; + + @Autowired + TechnicianRepository technicianRepository; + + @Transactional + public Timeslot createTimeslot(Date startDate, Date endDate, Time startTime, Time endTime, Workspace workspace) + { + checkDateValidity(startDate, endDate); + checkTimeValidity(startTime, endTime); + if (workspace == null || workspaceRepository.findByWorkspaceID(workspace.getWorkspaceID()) == null ) throw new IllegalArgumentException("Please input a valid workspace."); + Timeslot timeslot = new Timeslot(); + timeslot.setStartDate(startDate); + timeslot.setEndDate(endDate); + timeslot.setStartTime(startTime); + timeslot.setEndTime(endTime); + timeslot.setWorkspace(workspace); + timeslotRepository.save(timeslot); + return timeslot; + } + + @Transactional + public List getAllTimeslots() + { + return toList(timeslotRepository.findAll()); + } + + @Transactional + public Timeslot getTimeslotById(int id) + { + return timeslotRepository.findByTimeSlotID(id); + } + + @Transactional + public List getTimeslotsById(List timeslotsId) + { + if (timeslotsId == null || timeslotsId.size() == 0) throw new IllegalArgumentException("Please input at least one valid timeslot ID."); + ArrayList timeslots = new ArrayList<>(); + for (int id: timeslotsId) + { + timeslots.add(timeslotRepository.findByTimeSlotID(id)); + } + return timeslots; + } + + @Transactional + public List getTimeslotsByTechnicianBetweenDates(Technician technician, Date startDate, Date endDate) + { + checkDateValidity(startDate, endDate); + if (technician == null || technicianRepository.findByScrsUserId(technician.getScrsUserId()) == null) throw new IllegalArgumentException("Invalid technician."); + List timeslotsInPeriod = timeslotRepository.findAllByStartDateGreaterThanEqualAndStartDateLessThanEqualOrderByStartDate(startDate,endDate); + List technicianTimeslots= toList(timeslotRepository.findByTechnicians(technician)); + technicianTimeslots.retainAll(timeslotsInPeriod); + return timeslotsInPeriod; + } + + @Transactional + public List getTimeslotsByWorkspace(Workspace workspace) + { + if (workspace == null || workspaceRepository.findByWorkspaceID(workspace.getWorkspaceID()) == null) throw new IllegalArgumentException("Invalid workspace."); + return toList(timeslotRepository.findByWorkspace(workspace)); + } + + @Transactional + public List getAvailableTimeslots(Date startDate, Date endDate) + { + checkDateValidity(startDate, endDate); + List timeslotsInPeriod = timeslotRepository.findAllByStartDateGreaterThanEqualAndStartDateLessThanEqualOrderByStartDate(startDate, endDate); + timeslotsInPeriod.removeIf(timeslot -> appointmentRepository.existsByTimeslots(timeslot)); + return timeslotsInPeriod; + } + + @Transactional + public boolean assignTechnicianToTimeslot(Technician tech, Timeslot ts) + { + if (tech == null || technicianRepository.findByScrsUserId(tech.getScrsUserId()) == null) throw new IllegalArgumentException("Invalid technician."); + if (ts == null || timeslotRepository.findByTimeSlotID(ts.getTimeSlotID()) == null) throw new IllegalArgumentException("Invalid timeslot."); + if (ts.getTechnicians() != null && ts.getTechnicians().contains(tech)) return false; + ts.addTechnician(tech); + timeslotRepository.save(ts); + return true; + } + + @Transactional + public Timeslot deleteTimeslot(Timeslot timeslot) + { + timeslotRepository.delete(timeslot); + return timeslot; + } + +} diff --git a/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/WorkspaceService.java b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/WorkspaceService.java new file mode 100644 index 0000000..c8f3243 --- /dev/null +++ b/SCRS-Backend/src/main/java/ca/mcgill/ecse321/scrs/service/WorkspaceService.java @@ -0,0 +1,55 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.WorkspaceRepository; +import ca.mcgill.ecse321.scrs.model.Workspace; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +import static ca.mcgill.ecse321.scrs.service.ServiceHelpers.toList; + +@Service +public class WorkspaceService +{ + + @Autowired + WorkspaceRepository workspaceRepository; + + @Transactional + public Workspace createWorkspace(String name) + { + if (name == null || name.trim().length() == 0) throw new IllegalArgumentException("Invalid workspace name."); + Workspace workspace = new Workspace(); + workspace.setSpaceName(name); + workspaceRepository.save(workspace); + return workspace; + } + + @Transactional + public List getAllWorkspaces() + { + return toList(workspaceRepository.findAll()); + } + + @Transactional + public Workspace getWorkspaceById(int id) + { + return workspaceRepository.findByWorkspaceID(id); + } + + @Transactional + public Workspace getWorkspaceByName(String name) + { + if (name == null || name.trim().length() == 0) throw new IllegalArgumentException("Invalid workspace name."); + return workspaceRepository.findBySpaceName(name); + } + + @Transactional + public Workspace deleteWorkspace(Workspace workspace) + { + workspaceRepository.delete(workspace); + return workspace; + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/ScrsApplicationTests.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/ScrsApplicationTests.java index f102a45..e6c7da3 100644 --- a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/ScrsApplicationTests.java +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/ScrsApplicationTests.java @@ -15,4 +15,5 @@ void contextLoads() { } + } diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestAppointmentPersistence.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestAppointmentPersistence.java new file mode 100644 index 0000000..e388fcc --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestAppointmentPersistence.java @@ -0,0 +1,236 @@ +package ca.mcgill.ecse321.scrs.dao; + +import ca.mcgill.ecse321.scrs.model.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Date; +import java.sql.Time; +import java.time.LocalDate; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@ExtendWith(SpringExtension.class) +@SpringBootTest +public class TestAppointmentPersistence +{ + @Autowired + private AppointmentRepository appointmentRepository; + @Autowired + private AssistantRepository assistantRepository; + @Autowired + private CustomerRepository customerRepository; + @Autowired + private SCRSRepository scrsRepository; + @Autowired + private SCRSUserRepository scrsUserRepository; + @Autowired + private TechnicianRepository technicianRepository; + @Autowired + private TimeslotRepository timeslotRepository; + @Autowired + private WorkspaceRepository workspaceRepository; + + @AfterEach + public void clearDatabase() + { + appointmentRepository.deleteAll(); + timeslotRepository.deleteAll(); + assistantRepository.deleteAll(); + customerRepository.deleteAll(); + technicianRepository.deleteAll(); + scrsUserRepository.deleteAll(); + workspaceRepository.deleteAll(); + scrsRepository.deleteAll(); + } + + /** + * Appointment class ID test + * + * @author Alix R-L + */ + @Test + @Transactional + public void testPersistAndLoadAppointmentByID() + { + // creating objects + SCRS system = new SCRS(); + Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", system); + Workspace workspace = new Workspace("mom get out of my room I'm playing Minecraft", system); + Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); + Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", false, customer, system, timeslot); + + //saving them + scrsRepository.save(system); + customerRepository.save(customer); + workspaceRepository.save(workspace); + timeslotRepository.save(timeslot); + Appointment appointment2 = appointmentRepository.save(appointment); //for getting the ID + + //check appointment + Appointment appointment1 = appointmentRepository.findByAppointmentID(appointment2.getAppointmentID()); + assertNotNull(appointment1); + assertEquals(appointment1.getFeedback(), appointment.getFeedback()); + + //check appointment-timeslot relation + Timeslot timeslot1 = appointment.getTimeslot(0); + assertNotNull(timeslot1); + assertEquals(timeslot1.getEndTime(), timeslot.getEndTime()); + + //check appointment-customer relation + Customer customer1 = appointment.getCustomer(); + assertNotNull(customer1); + assertEquals(customer1.getName(), customer.getName()); + + } + + /** + * Association test of the Appointment class + * + * @author Alix R-L + */ + @Test + @Transactional + public void testPersistAndLoadAppointmentByAppointmentType() + { + // creating objects + SCRS system = new SCRS(); + Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", system); + Workspace workspace = new Workspace("mom get out of my room I'm playing Minecraft", system); + + //saving them + scrsRepository.save(system); + customerRepository.save(customer); + workspaceRepository.save(workspace); + for (int i = 0; i < 5; i++) + { + Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); + Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", false, customer, system, timeslot); + timeslotRepository.save(timeslot); + appointmentRepository.save(appointment); + } + for (int i = 0; i < 3; i++) + { + Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); + Appointment differentAppointment = new Appointment(Appointment.AppointmentType.Checkup, "beep", "shrimp was good", 90, "boop", false, customer, system, timeslot); + timeslotRepository.save(timeslot); + appointmentRepository.save(differentAppointment); + } + + //check appointment + List appointment1 = appointmentRepository.findAppointmentsByAppointmentType(Appointment.AppointmentType.CarWash); + assertNotNull(appointment1); + assertEquals(appointment1.size(), 5); + } + + /** + * Attribute test of the Appointment class + * + * @author Alix R-L + */ + @Test + @Transactional + public void testPersistAndLoadAppointmentByPaid() + { + // creating objects + SCRS system = new SCRS(); + Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", system); + Workspace workspace = new Workspace("mom get out of my room I'm playing Minecraft", system); + + //saving them + scrsRepository.save(system); + customerRepository.save(customer); + workspaceRepository.save(workspace); + for (int i = 0; i < 5; i++) + { + Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); + Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", true, customer, system, timeslot); + timeslotRepository.save(timeslot); + appointmentRepository.save(appointment); + } + for (int i = 0; i < 3; i++) + { + Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); + Appointment differentAppointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", false, customer, system, timeslot); + timeslotRepository.save(timeslot); + appointmentRepository.save(differentAppointment); + } + + //check appointment + List appointment1 = appointmentRepository.findAppointmentsByPaid(true); + assertNotNull(appointment1); + assertEquals(appointment1.size(), 5); + } + + /** + * Association test of the Appointment class + * + * @author Alix R-L + */ + @Test + @Transactional + public void testPersistAndLoadAppointmentByCustomer() + { + // creating objects + SCRS system = new SCRS(); + Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", system); + Workspace workspace = new Workspace("mom get out of my room I'm playing Minecraft", system); + + //saving them + scrsRepository.save(system); + customerRepository.save(customer); + workspaceRepository.save(workspace); + for (int i = 0; i < 5; i++) + { + Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); + Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", true, customer, system, timeslot); + timeslotRepository.save(timeslot); + appointmentRepository.save(appointment); + } + for (int i = 0; i < 3; i++) + { + Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); + Appointment differentAppointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", false, customer, system, timeslot); + timeslotRepository.save(timeslot); + appointmentRepository.save(differentAppointment); + } + + //check appointment + List appointment1 = appointmentRepository.findAppointmentsByCustomer(customer); + assertNotNull(appointment1); + assertEquals(appointment1.size(), 8); + } + + /** + * Association test of the Appointment class + * + * @author Simon Nakane Marcil + */ + @Test + @Transactional + public void testPersistAndExistsAppointmentByTimeslots() + { + SCRS system = new SCRS(); + Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", system); + Workspace workspace = new Workspace("mom get out of my room I'm playing Minecraft", system); + Timeslot timeslot = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), workspace); + + scrsRepository.save(system); + customerRepository.save(customer); + workspaceRepository.save(workspace); + timeslotRepository.save(timeslot); + + assertEquals(false, appointmentRepository.existsByTimeslots(timeslot)); + + Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", false, customer, system, timeslot); + appointmentRepository.save(appointment); + assertEquals(true, appointmentRepository.existsByTimeslots(timeslot)); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestAssistantPersistence.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestAssistantPersistence.java new file mode 100644 index 0000000..c940668 --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestAssistantPersistence.java @@ -0,0 +1,90 @@ +package ca.mcgill.ecse321.scrs.dao; + +import ca.mcgill.ecse321.scrs.model.Assistant; +import ca.mcgill.ecse321.scrs.model.SCRS; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; + +import static org.junit.jupiter.api.Assertions.*; + +@ExtendWith(SpringExtension.class) +@SpringBootTest +public class TestAssistantPersistence +{ + @Autowired + private AppointmentRepository appointmentRepository; + @Autowired + private AssistantRepository assistantRepository; + @Autowired + private CustomerRepository customerRepository; + @Autowired + private SCRSRepository scrsRepository; + @Autowired + private SCRSUserRepository scrsUserRepository; + @Autowired + private TechnicianRepository technicianRepository; + @Autowired + private TimeslotRepository timeslotRepository; + @Autowired + private WorkspaceRepository workspaceRepository; + + @AfterEach + public void clearDatabase() + { + appointmentRepository.deleteAll(); + timeslotRepository.deleteAll(); + assistantRepository.deleteAll(); + customerRepository.deleteAll(); + technicianRepository.deleteAll(); + scrsUserRepository.deleteAll(); + workspaceRepository.deleteAll(); + scrsRepository.deleteAll(); + } + + /** + * Test the persistence of an assistant object in the database. + * @author SimonNM + */ + @Test + @Transactional + public void testPersistAndLoadAssistant() + { + SCRS scrs = new SCRS(); + Assistant assistant = new Assistant("name", "password", "name@mail.mcgill.ca", "111-1111", scrs); + scrsRepository.save(scrs); + assistantRepository.save(assistant); + + Assistant actualAssistant = assistantRepository.findByScrsUserId(assistant.getScrsUserId()); + + assertNotNull(actualAssistant); + assertEquals(assistant.getScrsUserId(), actualAssistant.getScrsUserId()); + assertEquals(assistant.getName(), actualAssistant.getName()); + assertEquals(assistant.getPassword(), actualAssistant.getPassword()); + assertEquals(assistant.getEmail(), actualAssistant.getEmail()); + assertEquals(assistant.getPhone(), actualAssistant.getPhone()); + assertEquals(scrs.getScrsId(), actualAssistant.getScrs().getScrsId()); + } + + /** + * Test the persistence of an assistant object in the database. + * @author SimonNM + */ + @Test + @Transactional + public void testPersistAndLoadAssistantByEmail() + { + SCRS scrs = new SCRS(); + Assistant assistant = new Assistant("name", "password", "name@mail.mcgill.ca", "111-1111", scrs); + scrsRepository.save(scrs); + assistantRepository.save(assistant); + + Assistant actualAssistant = assistantRepository.findByEmail("aaaaaaaaaaaaa"); + + assertNull(actualAssistant); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestCustomerPersistence.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestCustomerPersistence.java new file mode 100644 index 0000000..d477094 --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestCustomerPersistence.java @@ -0,0 +1,89 @@ +package ca.mcgill.ecse321.scrs.dao; + +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.model.SCRS; +import ca.mcgill.ecse321.scrs.model.Timeslot; +import ca.mcgill.ecse321.scrs.model.Workspace; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Date; +import java.sql.Time; +import java.time.LocalDate; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@ExtendWith(SpringExtension.class) +@SpringBootTest +public class TestCustomerPersistence +{ + @Autowired + private AppointmentRepository appointmentRepository; + @Autowired + private AssistantRepository assistantRepository; + @Autowired + private CustomerRepository customerRepository; + @Autowired + private SCRSRepository scrsRepository; + @Autowired + private SCRSUserRepository scrsUserRepository; + @Autowired + private TechnicianRepository technicianRepository; + @Autowired + private TimeslotRepository timeslotRepository; + @Autowired + private WorkspaceRepository workspaceRepository; + + @AfterEach + public void clearDatabase() + { + appointmentRepository.deleteAll(); + timeslotRepository.deleteAll(); + assistantRepository.deleteAll(); + customerRepository.deleteAll(); + technicianRepository.deleteAll(); + scrsUserRepository.deleteAll(); + workspaceRepository.deleteAll(); + scrsRepository.deleteAll(); + } + + /** + * Test the persistence of the customer class. + * @author Adel Ahram + */ + @Test + @Transactional + public void testPersistAndLoadCustomer() + { + //create dummy scrs + SCRS scrs = new SCRS(); + + //create customer with data + Customer customer = new Customer("name", "password", "email", "phone", scrs); + + //create appointment -> timeslot -> workspace to test the association + Workspace ws = new Workspace("test", scrs); + Timeslot ts = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + + scrsRepository.save(scrs); + workspaceRepository.save(ws); + timeslotRepository.save(ts); + + //save customer + customerRepository.save(customer); + + //check test outputs + Customer actualCustomer = customerRepository.findByScrsUserId(customer.getScrsUserId()); + assertNotNull(actualCustomer); + assertEquals(customer.getName(), actualCustomer.getName()); + assertEquals(customer.getPassword(), actualCustomer.getPassword()); + assertEquals(customer.getEmail(), actualCustomer.getEmail()); + assertEquals(customer.getPhone(), actualCustomer.getPhone()); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestScrsPersistence.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestScrsPersistence.java index 3de643e..1f8e443 100644 --- a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestScrsPersistence.java +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestScrsPersistence.java @@ -1,25 +1,22 @@ package ca.mcgill.ecse321.scrs.dao; -import static org.junit.jupiter.api.Assertions.*; - -import java.beans.Transient; -import java.sql.Date; -import java.sql.Time; -import java.time.LocalDate; -import java.util.List; - +import ca.mcgill.ecse321.scrs.model.*; +import ca.mcgill.ecse321.scrs.model.Appointment.AppointmentType; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Configuration; import org.springframework.test.context.junit.jupiter.SpringExtension; - -import ca.mcgill.ecse321.scrs.model.*; -import ca.mcgill.ecse321.scrs.model.Appointment.AppointmentType; import org.springframework.transaction.annotation.Transactional; +import java.sql.Date; +import java.sql.Time; +import java.time.LocalDate; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + @ExtendWith(SpringExtension.class) @SpringBootTest public class TestScrsPersistence @@ -51,53 +48,13 @@ public void clearDatabase() technicianRepository.deleteAll(); scrsUserRepository.deleteAll(); workspaceRepository.deleteAll(); + scrsRepository.deleteAll(); } - - //=========SIMON TESTS========== (Assistant and Technician tests) - @Test - @Transactional - public void testPersistAndLoadAssistant() - { - SCRS scrs = new SCRS(); - Assistant assistant = new Assistant("name", "password", "name@mail.mcgill.ca", "111-1111", scrs); - scrsRepository.save(scrs); - assistantRepository.save(assistant); - - Assistant actualAssistant = assistantRepository.findByScrsUserId(assistant.getScrsUserId()); - - assertNotNull(actualAssistant); - assertEquals(assistant.getScrsUserId(), actualAssistant.getScrsUserId()); - assertEquals(assistant.getName(), actualAssistant.getName()); - assertEquals(assistant.getPassword(), actualAssistant.getPassword()); - assertEquals(assistant.getEmail(), actualAssistant.getEmail()); - assertEquals(assistant.getPhone(), actualAssistant.getPhone()); - assertEquals(scrs.getScrsId(), actualAssistant.getScrs().getScrsId()); - } - - @Test - @Transactional - public void testPersistAndLoadTechnician() - { - SCRS scrs = new SCRS(); - Technician technician = new Technician("name", "password", "name@mail.mcgill.ca", "111-1111", scrs); - - scrsRepository.save(scrs); - technicianRepository.save(technician); - - Technician actualTechnician = technicianRepository.findByScrsUserId(technician.getScrsUserId()); - - assertNotNull(actualTechnician); - assertEquals(technician.getScrsUserId(), actualTechnician.getScrsUserId()); - assertEquals(technician.getName(), actualTechnician.getName()); - assertEquals(technician.getPassword(), actualTechnician.getPassword()); - assertEquals(technician.getEmail(), actualTechnician.getEmail()); - assertEquals(technician.getPhone(), actualTechnician.getPhone()); - assertEquals(scrs.getScrsId(), actualTechnician.getScrs().getScrsId()); - } - - //=========ADEL TESTS========== (Customer and SCRS tests) - + /** + * Test the persistence of the SCRS class + * @author Adel Ahram + */ @Test @Transactional public void testPersistAndLoadSCRS() @@ -119,295 +76,4 @@ public void testPersistAndLoadSCRS() assertEquals(scrs.getWorkspace(0), space); //test if workspace association was properly stored/read } - @Test - @Transactional - public void testPersistAndLoadCustomer() - { - //create dummy scrs - SCRS scrs = new SCRS(); - - //create customer with data - Customer customer = new Customer("name", "password", "email", "phone", scrs); - - //create appointment -> timeslot -> workspace to test the association - Workspace ws = new Workspace("test", scrs); - Timeslot ts = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); - Appointment app = new Appointment(AppointmentType.CarWash, "service", "note", 5, "feedback", true, customer, scrs, ts); - customer.addAppointment(app); - - scrsRepository.save(scrs); - workspaceRepository.save(ws); - timeslotRepository.save(ts); - appointmentRepository.save(app); - - //save customer - customerRepository.save(customer); - - //check test outputs - Customer actualCustomer = customerRepository.findByScrsUserId(customer.getScrsUserId()); - assertNotNull(actualCustomer); - assertEquals(customer.getName(), actualCustomer.getName()); - assertEquals(customer.getPassword(), actualCustomer.getPassword()); - assertEquals(customer.getEmail(), actualCustomer.getEmail()); - assertEquals(customer.getPhone(), actualCustomer.getPhone()); - assertNotNull(actualCustomer.getAppointment(0)); - assertEquals(customer.getAppointment(0), actualCustomer.getAppointment(0)); - } - - //=========ALIX TESTS========== (Appointment tests) - @Test - @Transactional - public void testPersistAndLoadAppointmentByID() - { - // creating objects - SCRS system = new SCRS(); - Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", system); - Workspace workspace = new Workspace("mom get out of my room I'm playing Minecraft", system); - Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); - Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", false, customer, system, timeslot); - - //saving them - scrsRepository.save(system); - customerRepository.save(customer); - workspaceRepository.save(workspace); - timeslotRepository.save(timeslot); - Appointment appointment2 = appointmentRepository.save(appointment); //for getting the ID - - //check appointment - Appointment appointment1 = appointmentRepository.findByAppointmentID(appointment2.getAppointmentID()); - assertNotNull(appointment1); - assertEquals(appointment1.getFeedback(), appointment.getFeedback()); - - //check appointment-timeslot relation - Timeslot timeslot1 = appointment.getTimeslot(0); - assertNotNull(timeslot1); - assertEquals(timeslot1.getEndTime(), timeslot.getEndTime()); - - //check appointment-customer relation - Customer customer1 = appointment.getCustomer(); - assertNotNull(customer1); - assertEquals(customer1.getName(), customer.getName()); - - } - - @Test - @Transactional - public void testPersistAndLoadAppointmentByAppointmentType() - { - // creating objects - SCRS system = new SCRS(); - Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", system); - Workspace workspace = new Workspace("mom get out of my room I'm playing Minecraft", system); - - //saving them - scrsRepository.save(system); - customerRepository.save(customer); - workspaceRepository.save(workspace); - for(int i = 0 ; i < 5 ; i++){ - Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); - Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good",90, "boop", false, customer, system, timeslot ); - timeslotRepository.save(timeslot); - appointmentRepository.save(appointment); - } - for(int i = 0 ; i < 3 ; i++){ - Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); - Appointment differentAppointment = new Appointment(AppointmentType.Checkup, "beep", "shrimp was good",90, "boop", false, customer, system, timeslot ); - timeslotRepository.save(timeslot); - appointmentRepository.save(differentAppointment); - } - - //check appointment - List appointment1 = appointmentRepository.findAppointmentsByAppointmentType(AppointmentType.CarWash); - assertNotNull(appointment1); - assertEquals(appointment1.size(), 5); - } - - @Test - @Transactional - public void testPersistAndLoadAppointmentByPaid() - { - // creating objects - SCRS system = new SCRS(); - Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", system); - Workspace workspace = new Workspace("mom get out of my room I'm playing Minecraft", system); - - //saving them - scrsRepository.save(system); - customerRepository.save(customer); - workspaceRepository.save(workspace); - for(int i = 0 ; i < 5 ; i++){ - Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); - Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good",90, "boop", true, customer, system, timeslot ); - timeslotRepository.save(timeslot); - appointmentRepository.save(appointment); - } - for(int i = 0 ; i < 3 ; i++){ - Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); - Appointment differentAppointment = new Appointment(AppointmentType.CarWash, "beep", "shrimp was good",90, "boop", false, customer, system, timeslot ); - timeslotRepository.save(timeslot); - appointmentRepository.save(differentAppointment); - } - - //check appointment - List appointment1 = appointmentRepository.findAppointmentsByPaid(true); - assertNotNull(appointment1); - assertEquals(appointment1.size(), 5); - } - - @Test - @Transactional - public void testPersistAndLoadAppointmentByCustomer() - { - // creating objects - SCRS system = new SCRS(); - Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", system); - Workspace workspace = new Workspace("mom get out of my room I'm playing Minecraft", system); - - //saving them - scrsRepository.save(system); - customerRepository.save(customer); - workspaceRepository.save(workspace); - for(int i = 0 ; i < 5 ; i++){ - Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); - Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good",90, "boop", true, customer, system, timeslot ); - timeslotRepository.save(timeslot); - appointmentRepository.save(appointment); - } - for(int i = 0 ; i < 3 ; i++){ - Timeslot timeslot = new Timeslot(new Date(LocalDate.now().toEpochDay()), new Date(LocalDate.now().toEpochDay()), new Time(3333), new Time(6666), workspace); - Appointment differentAppointment = new Appointment(AppointmentType.CarWash, "beep", "shrimp was good",90, "boop", false, customer, system, timeslot ); - timeslotRepository.save(timeslot); - appointmentRepository.save(differentAppointment); - } - - //check appointment - List appointment1 = appointmentRepository.findAppointmentByCustomer(customer); - assertNotNull(appointment1); - assertEquals(appointment1.size(), 8); - } - - - //=========ROEY TESTS========== (Timeslot tests) - @Test - @Transactional - public void testPersistAndLoadTimeslotByID() - { - SCRS scrs = new SCRS(); - Workspace ws = new Workspace("test", scrs); - Timeslot ts = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); - scrsRepository.save(scrs); - workspaceRepository.save(ws); - timeslotRepository.save(ts); - - Timeslot actualTs = timeslotRepository.findByTimeSlotID(ts.getTimeSlotID()); - - assertNotNull(actualTs); - assertEquals(ts.getStartDate().toString(), actualTs.getStartDate().toString()); - assertEquals(ts.getEndDate().toString(), actualTs.getEndDate().toString()); - assertEquals(ts.getStartTime().toString(), actualTs.getStartTime().toString()); - assertEquals(ts.getEndTime().toString(), actualTs.getEndTime().toString()); - - List expectedTechs = ts.getTechnicians(); - List actualTechs = actualTs.getTechnicians(); - assertEquals(expectedTechs.size(), actualTechs.size()); - for (Technician actualTech : actualTechs) - { - assertTrue(expectedTechs.contains(actualTech)); - } - assertEquals(ts.getAppointment(), actualTs.getAppointment()); - assertEquals(ts.getWorkspace().getWorkspaceID(), actualTs.getWorkspace().getWorkspaceID()); - } - - @Test - @Transactional - public void testPersistAndLoadTimeslotByAppointment() - { - SCRS scrs = new SCRS(); - Workspace ws = new Workspace("test", scrs); - Timeslot ts = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); - Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", scrs); - Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", false, customer, scrs, ts); - scrsRepository.save(scrs); - workspaceRepository.save(ws); - timeslotRepository.save(ts); - customerRepository.save(customer); - appointmentRepository.save(appointment); - - List actualTimeslots = timeslotRepository.findByAppointment(appointment); - - assertEquals(1, actualTimeslots.size()); - Timeslot actualTimeslot = actualTimeslots.get(0); - - assertEquals(actualTimeslot.getTimeSlotID(), ts.getTimeSlotID()); - assertEquals(actualTimeslot.getWorkspace().getWorkspaceID(), ts.getWorkspace().getWorkspaceID()); - } - - @Test - @Transactional - public void testPersistAndLoadTimeslotByWorkspace() - { - SCRS scrs = new SCRS(); - Workspace ws = new Workspace("test", scrs); - Timeslot ts = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); - scrsRepository.save(scrs); - workspaceRepository.save(ws); - timeslotRepository.save(ts); - - List actualTimeslots = timeslotRepository.findByWorkspace(ws); - - assertEquals(1, actualTimeslots.size()); - Timeslot actualTimeslot = actualTimeslots.get(0); - - assertEquals(actualTimeslot.getTimeSlotID(), ts.getTimeSlotID()); - assertEquals(actualTimeslot.getWorkspace().getWorkspaceID(), ts.getWorkspace().getWorkspaceID()); - } - - @Test - @Transactional - public void testPersistAndLoadTimeslotByTechnicians() - { - SCRS scrs = new SCRS(); - Workspace ws = new Workspace("test", scrs); - Timeslot ts = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); - Technician tech = new Technician("SomeTech", "password", "email", "phone", scrs); - scrsRepository.save(scrs); - workspaceRepository.save(ws); - timeslotRepository.save(ts); - technicianRepository.save(tech); - - List actualTimeslots = timeslotRepository.findByTechnicians(tech); - - assertEquals(0, actualTimeslots.size()); - - tech.addAvailability(ts); - technicianRepository.save(tech); - - actualTimeslots = timeslotRepository.findByTechnicians(tech); - assertNotEquals(0, actualTimeslots.size()); - Timeslot actualTimeslot = actualTimeslots.get(0); - - assertEquals(actualTimeslot.getTimeSlotID(), ts.getTimeSlotID()); - assertEquals(actualTimeslot.getWorkspace().getWorkspaceID(), ts.getWorkspace().getWorkspaceID()); - } - - //=========ALEXANDRA TESTS========== (Workspace tests) - @Test - @Transactional - public void testPersistAndLoadWorkspace() - { - SCRS scrs = new SCRS(); - Workspace workspace = new Workspace("test", scrs); - Timeslot timeslot = new Timeslot(new Date(0),new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), workspace); - - scrsRepository.save(scrs); - workspaceRepository.save(workspace); - timeslotRepository.save(timeslot); - - Workspace actualWorkspace = workspaceRepository.findByWorkspaceID(workspace.getWorkspaceID()); - assertNotNull(actualWorkspace); - assertEquals(workspace.getSpaceType(), actualWorkspace.getSpaceType()); - assertNotNull(actualWorkspace.getAvailabilities().get(0)); - assertEquals(workspace.getAvailabilities().get(0), actualWorkspace.getAvailabilities().get(0)); - } - } diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestTechnicianPersistence.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestTechnicianPersistence.java new file mode 100644 index 0000000..3ffbe1f --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestTechnicianPersistence.java @@ -0,0 +1,74 @@ +package ca.mcgill.ecse321.scrs.dao; + +import ca.mcgill.ecse321.scrs.model.SCRS; +import ca.mcgill.ecse321.scrs.model.Technician; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@ExtendWith(SpringExtension.class) +@SpringBootTest +public class TestTechnicianPersistence +{ + @Autowired + private AppointmentRepository appointmentRepository; + @Autowired + private AssistantRepository assistantRepository; + @Autowired + private CustomerRepository customerRepository; + @Autowired + private SCRSRepository scrsRepository; + @Autowired + private SCRSUserRepository scrsUserRepository; + @Autowired + private TechnicianRepository technicianRepository; + @Autowired + private TimeslotRepository timeslotRepository; + @Autowired + private WorkspaceRepository workspaceRepository; + + @AfterEach + public void clearDatabase() + { + appointmentRepository.deleteAll(); + timeslotRepository.deleteAll(); + assistantRepository.deleteAll(); + customerRepository.deleteAll(); + technicianRepository.deleteAll(); + scrsUserRepository.deleteAll(); + workspaceRepository.deleteAll(); + scrsRepository.deleteAll(); + } + + /** + * Test the technician class + * @author SimonNM + */ + @Test + @Transactional + public void testPersistAndLoadTechnician() + { + SCRS scrs = new SCRS(); + Technician technician = new Technician("name", "password", "name@mail.mcgill.ca", "111-1111", scrs); + + scrsRepository.save(scrs); + technicianRepository.save(technician); + + Technician actualTechnician = technicianRepository.findByScrsUserId(technician.getScrsUserId()); + + assertNotNull(actualTechnician); + assertEquals(technician.getScrsUserId(), actualTechnician.getScrsUserId()); + assertEquals(technician.getName(), actualTechnician.getName()); + assertEquals(technician.getPassword(), actualTechnician.getPassword()); + assertEquals(technician.getEmail(), actualTechnician.getEmail()); + assertEquals(technician.getPhone(), actualTechnician.getPhone()); + assertEquals(scrs.getScrsId(), actualTechnician.getScrs().getScrsId()); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestTimeslotPersistence.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestTimeslotPersistence.java new file mode 100644 index 0000000..d745c24 --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestTimeslotPersistence.java @@ -0,0 +1,211 @@ +package ca.mcgill.ecse321.scrs.dao; + +import ca.mcgill.ecse321.scrs.model.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Date; +import java.sql.Time; +import java.time.LocalDate; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; + +@ExtendWith(SpringExtension.class) +@SpringBootTest +public class TestTimeslotPersistence +{ + @Autowired + private AppointmentRepository appointmentRepository; + @Autowired + private AssistantRepository assistantRepository; + @Autowired + private CustomerRepository customerRepository; + @Autowired + private SCRSRepository scrsRepository; + @Autowired + private SCRSUserRepository scrsUserRepository; + @Autowired + private TechnicianRepository technicianRepository; + @Autowired + private TimeslotRepository timeslotRepository; + @Autowired + private WorkspaceRepository workspaceRepository; + + @AfterEach + public void clearDatabase() + { + appointmentRepository.deleteAll(); + timeslotRepository.deleteAll(); + assistantRepository.deleteAll(); + customerRepository.deleteAll(); + technicianRepository.deleteAll(); + scrsUserRepository.deleteAll(); + workspaceRepository.deleteAll(); + scrsRepository.deleteAll(); + } + + /** + * Attribute test of the Timeslot class. + * + * @author Roey Borsteinas + */ + @Test + @Transactional + public void testPersistAndLoadTimeslotByID() + { + SCRS scrs = new SCRS(); + Workspace ws = new Workspace("test", scrs); + Timeslot ts = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + scrsRepository.save(scrs); + workspaceRepository.save(ws); + timeslotRepository.save(ts); + + Timeslot actualTs = timeslotRepository.findByTimeSlotID(ts.getTimeSlotID()); + + assertNotNull(actualTs); + assertEquals(ts.getStartDate().toString(), actualTs.getStartDate().toString()); + assertEquals(ts.getEndDate().toString(), actualTs.getEndDate().toString()); + assertEquals(ts.getStartTime().toString(), actualTs.getStartTime().toString()); + assertEquals(ts.getEndTime().toString(), actualTs.getEndTime().toString()); + + List expectedTechs = ts.getTechnicians(); + List actualTechs = actualTs.getTechnicians(); + assertEquals(expectedTechs.size(), actualTechs.size()); + for (Technician actualTech : actualTechs) + { + assertTrue(expectedTechs.contains(actualTech)); + } + assertEquals(ts.getWorkspace().getWorkspaceID(), actualTs.getWorkspace().getWorkspaceID()); + } + + /** + * Association test of the Timeslot class. + * + * @author Roey Borsteinas + */ + @Test + @Transactional + public void testPersistAndLoadTimeslotByAppointment() + { + SCRS scrs = new SCRS(); + Workspace ws = new Workspace("test", scrs); + Timeslot ts = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + Customer customer = new Customer("Rick Roll", "You just got Rick Rolled", "Ha Gottem@gmail.com", "(666) 666-6666", scrs); + Appointment appointment = new Appointment(Appointment.AppointmentType.CarWash, "beep", "shrimp was good", 90, "boop", false, customer, scrs, ts); + scrsRepository.save(scrs); + workspaceRepository.save(ws); + timeslotRepository.save(ts); + customerRepository.save(customer); + appointmentRepository.save(appointment); + + List actualTimeslots = appointmentRepository.findByAppointmentID(appointment.getAppointmentID()).getTimeslots(); + + assertEquals(1, actualTimeslots.size()); + Timeslot actualTimeslot = actualTimeslots.get(0); + + assertEquals(actualTimeslot.getTimeSlotID(), ts.getTimeSlotID()); + assertEquals(actualTimeslot.getWorkspace().getWorkspaceID(), ts.getWorkspace().getWorkspaceID()); + } + + /** + * Association test of the Timeslot class. + * + * @author Roey Borsteinas + */ + @Test + @Transactional + public void testPersistAndLoadTimeslotByWorkspace() + { + SCRS scrs = new SCRS(); + Workspace ws = new Workspace("test", scrs); + Timeslot ts = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + scrsRepository.save(scrs); + workspaceRepository.save(ws); + timeslotRepository.save(ts); + + List actualTimeslots = timeslotRepository.findByWorkspace(ws); + + assertEquals(1, actualTimeslots.size()); + Timeslot actualTimeslot = actualTimeslots.get(0); + + assertEquals(actualTimeslot.getTimeSlotID(), ts.getTimeSlotID()); + assertEquals(actualTimeslot.getWorkspace().getWorkspaceID(), ts.getWorkspace().getWorkspaceID()); + } + + /** + * Association test of the Timeslot class. + * @author Alexandra Gafencu + */ + @Test + @Transactional + public void testPersistAndLoadTimeslotByTechnician() + { + SCRS scrs = new SCRS(); + Workspace ws = new Workspace("test", scrs); + Technician technician = new Technician("name", "password", "name@mail.mcgill.ca", "111-1111", scrs); + Timeslot ts1 = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + Timeslot ts2 = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + Timeslot ts3 = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + + ts1.addTechnician(technician); + ts2.addTechnician(technician); + ts3.addTechnician(technician); + + + scrsRepository.save(scrs); + workspaceRepository.save(ws); + technicianRepository.save(technician); + timeslotRepository.save(ts1); + timeslotRepository.save(ts2); + timeslotRepository.save(ts3); + + + List actualTimeslots = timeslotRepository.findByTechnicians(technician); + + assertEquals(3, actualTimeslots.size()); + Timeslot actualTimeslot = actualTimeslots.get(0); + + assertEquals(actualTimeslot.getTimeSlotID(), ts1.getTimeSlotID()); + assertEquals(actualTimeslot.getWorkspace().getWorkspaceID(), ts1.getWorkspace().getWorkspaceID()); + } + + /** + * @author Simon Nakane Marcil + */ + @Test + @Transactional + public void testPersistAndLoadTimeslotByStartDateGreaterThanEqualAndStartDateLessThanEqual() + { + SCRS scrs = new SCRS(); + Workspace ws = new Workspace("test", scrs); + Date day = new Date(2000, 2, 21); + Date nextDay = new Date(2000, 2, 22); + Date nextMonth = new Date(2000, 3, 21); + Date previousDay = new Date(2000, 2, 20); + Timeslot ts1 = new Timeslot(day, new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + Timeslot ts2 = new Timeslot(nextDay, new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + Timeslot ts3 = new Timeslot(previousDay, new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + Timeslot ts4 = new Timeslot(nextMonth, new Date(LocalDate.now().toEpochDay()), new Time(0), new Time(LocalDate.now().toEpochDay()), ws); + scrsRepository.save(scrs); + workspaceRepository.save(ws); + timeslotRepository.save(ts2); + timeslotRepository.save(ts3); + timeslotRepository.save(ts1); + timeslotRepository.save(ts4); + + List actualTimeslots = timeslotRepository.findAllByStartDateGreaterThanEqualAndStartDateLessThanEqualOrderByStartDate(day, nextDay); + + assertEquals(2, actualTimeslots.size()); + Timeslot actualTimeslot = actualTimeslots.get(0); + + assertEquals(actualTimeslot.getTimeSlotID(), ts1.getTimeSlotID()); + assertEquals(actualTimeslot.getStartTime(), ts1.getStartTime()); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestWorkspacePersistence.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestWorkspacePersistence.java new file mode 100644 index 0000000..6210cc0 --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/dao/TestWorkspacePersistence.java @@ -0,0 +1,76 @@ +package ca.mcgill.ecse321.scrs.dao; + +import ca.mcgill.ecse321.scrs.model.SCRS; +import ca.mcgill.ecse321.scrs.model.Timeslot; +import ca.mcgill.ecse321.scrs.model.Workspace; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Date; +import java.sql.Time; +import java.time.LocalDate; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@ExtendWith(SpringExtension.class) +@SpringBootTest +public class TestWorkspacePersistence { + @Autowired + private AppointmentRepository appointmentRepository; + @Autowired + private AssistantRepository assistantRepository; + @Autowired + private CustomerRepository customerRepository; + @Autowired + private SCRSRepository scrsRepository; + @Autowired + private SCRSUserRepository scrsUserRepository; + @Autowired + private TechnicianRepository technicianRepository; + @Autowired + private TimeslotRepository timeslotRepository; + @Autowired + private WorkspaceRepository workspaceRepository; + + @AfterEach + public void clearDatabase() { + appointmentRepository.deleteAll(); + timeslotRepository.deleteAll(); + assistantRepository.deleteAll(); + customerRepository.deleteAll(); + technicianRepository.deleteAll(); + scrsUserRepository.deleteAll(); + workspaceRepository.deleteAll(); + scrsRepository.deleteAll(); + } + + /** + * Persistence test of the Workspace class. + * + * @author Alexandra Gafencu + */ + @Test + @Transactional + public void testPersistAndLoadWorkspace() { + SCRS scrs = new SCRS(); + Workspace workspace = new Workspace("test", scrs); + Timeslot timeslot = new Timeslot(new Date(0), new Date(LocalDate.now().toEpochDay()), new Time(0), + new Time(LocalDate.now().toEpochDay()), workspace); + + scrsRepository.save(scrs); + workspaceRepository.save(workspace); + timeslotRepository.save(timeslot); + + Workspace actualWorkspace = workspaceRepository.findByWorkspaceID(workspace.getWorkspaceID()); + assertNotNull(actualWorkspace); + assertEquals(workspace.getSpaceName(), actualWorkspace.getSpaceName()); + assertNotNull(actualWorkspace.getAvailabilities().get(0)); + assertEquals(workspace.getAvailabilities().get(0), actualWorkspace.getAvailabilities().get(0)); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestAppointmentService.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestAppointmentService.java new file mode 100644 index 0000000..52276cd --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestAppointmentService.java @@ -0,0 +1,674 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.AppointmentRepository; +import ca.mcgill.ecse321.scrs.dao.CustomerRepository; +import ca.mcgill.ecse321.scrs.dao.TimeslotRepository; +import ca.mcgill.ecse321.scrs.model.Appointment; +import ca.mcgill.ecse321.scrs.model.Appointment.AppointmentType; +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.model.Timeslot; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.stubbing.Answer; + +import java.sql.Date; +import java.sql.Time; +import java.util.ArrayList; + +import static java.lang.System.currentTimeMillis; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.lenient; +import static ca.mcgill.ecse321.scrs.controller.Helper.*; + +@ExtendWith(MockitoExtension.class) +public class TestAppointmentService +{ + + @Mock + private AppointmentRepository appointmentDao; + @Mock + private CustomerRepository customerRepository; + @Mock + private TimeslotRepository timeslotRepository; + + @InjectMocks + private AppointmentService service; + + private static final int testID = 1; + private static final int wrongID = 420; + private static final int testRating = 7; + private static final int wrongRating = 100; + private static final Time testTime = new Time(currentTimeMillis()); + private static final Date testDate = new Date(currentTimeMillis()); + private static final AppointmentType testType = AppointmentType.Maintenance; + private static final AppointmentType wrongType = AppointmentType.Other; + private static final Customer testCustomer = new Customer(); + private static final Timeslot testTimeslot = new Timeslot(); + private static final Timeslot wrongTimeslot = new Timeslot(); + private static final ArrayList timeslots = new ArrayList(); + + @BeforeAll + public static void instantiateVars() + { + testCustomer.setScrsUserId(testID); + testCustomer.setEmail("email"); + testCustomer.setName("name"); + testCustomer.setPassword("password"); + testCustomer.setPhone("phone"); + testTimeslot.setStartTime(testTime); + testTimeslot.setEndTime(testTime); + testTimeslot.setStartDate(testDate); + testTimeslot.setEndDate(testDate); + testTimeslot.setTimeSlotID(testID); + timeslots.add(testTimeslot); + wrongTimeslot.setStartTime(new Time(currentTimeMillis()-1000000000)); + wrongTimeslot.setEndTime(new Time(currentTimeMillis()-1000000000)); + wrongTimeslot.setStartDate(new Date(currentTimeMillis()-1000000000-1000000000-1000000000-1000000000)); + wrongTimeslot.setEndDate(new Date(currentTimeMillis()-1000000000-1000000000-1000000000-1000000000)); + wrongTimeslot.setTimeSlotID(wrongID); + } + + + @BeforeEach + public void setMockOutput() + { + lenient().when(appointmentDao.findByAppointmentID(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testID)) + { + Appointment appointment = new Appointment(); + appointment.setAppointmentID(testID); + appointment.setAppointmentType(testType); + appointment.setPaid(false); + appointment.setTimeslots(timeslots.toArray(new Timeslot[0])); + appointment.setCustomer(testCustomer); + return appointment; + } else + { + return null; + } + }); + lenient().when(appointmentDao.findAppointmentsByCustomer(any(Customer.class))).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testCustomer)) + { + ArrayList tempList = new ArrayList<>(); + Appointment appointment = new Appointment(); + appointment.setAppointmentID(testID); + appointment.setAppointmentType(testType); + appointment.setPaid(false); + appointment.setTimeslots(timeslots.toArray(new Timeslot[0])); + appointment.setCustomer(testCustomer); + tempList.add(appointment); + return tempList; + } else + { + return null; + } + }); + lenient().when(appointmentDao.findByTimeslotsContains(any(Timeslot.class))).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testTimeslot)) + { + Appointment appointment = new Appointment(); + appointment.setAppointmentID(testID); + appointment.setAppointmentType(testType); + appointment.setPaid(false); + appointment.setTimeslots(timeslots.toArray(new Timeslot[0])); + appointment.setCustomer(testCustomer); + return appointment; + } else + { + return null; + } + }); + lenient().when(appointmentDao.findAll()).thenAnswer((InvocationOnMock invocation) -> { + ArrayList tempList = new ArrayList<>(); + Appointment appointment = new Appointment(); + appointment.setAppointmentID(testID); + appointment.setAppointmentType(testType); + appointment.setPaid(false); + appointment.setTimeslots(timeslots.toArray(new Timeslot[0])); + appointment.setCustomer(testCustomer); + tempList.add(appointment); + return tempList; + }); + lenient().when(customerRepository.findByScrsUserId(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if(invocation.getArgument(0).equals(testCustomer.getScrsUserId())) + { + return testCustomer; + } else + { + return null; + } + }); + lenient().when(timeslotRepository.findByTimeSlotID(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if(invocation.getArgument(0).equals(testTimeslot.getTimeSlotID())) + { + return testTimeslot; + } else + { + return null; + } + }); + Answer returnParameterAsAnswer = (InvocationOnMock invocation) -> { + return invocation.getArgument(0); + }; + lenient().when(appointmentDao.save(any(Appointment.class))).thenAnswer(returnParameterAsAnswer); + } + + @Test + public void testCreate() + { + Appointment appointment = null; + try + { + appointment = service.createAppointment(testType, null, null, false, testCustomer, timeslots.toArray(new Timeslot[0])); + appointment.setAppointmentID(testID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(appointment); + assertEquals(testCustomer.getScrsUserId(), appointment.getCustomer().getScrsUserId()); + assertEquals(testType, appointment.getAppointmentType()); + assertEquals(testTimeslot.getTimeSlotID(), appointment.getTimeslot(0).getTimeSlotID()); + } + + @Test + public void testCreateNoType() + { + String error = null; + Appointment appointment = null; + try + { + appointment = service.createAppointment(null, null, null, false, testCustomer, timeslots.toArray(new Timeslot[0])); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(appointment); + assertEquals("Please submit a valid appointment type.", error); + } + + @Test + public void testCreateNullTimeslots() + { + String error = null; + Appointment appointment = null; + try + { + appointment = service.createAppointment(testType, null, null, false, testCustomer, (Timeslot) null); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(appointment); + assertEquals("Please select at least one valid timeslot.", error); + } + + @Test + public void testCreateEmptyTimeslots() + { + String error = null; + Appointment appointment = null; + try + { + appointment = service.createAppointment(testType, null, null, false, testCustomer); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(appointment); + assertEquals("Please select at least one valid timeslot.", error); + } + + @Test + public void testCreateNoCustomer() + { + String error = null; + Appointment appointment = null; + try + { + appointment = service.createAppointment(testType, null, null, false, null, timeslots.toArray(new Timeslot[0])); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(appointment); + assertEquals("Please submit a valid customer.", error); + } + + @Test + public void testGetAll() + { + ArrayList appointments = null; + try + { + appointments = new ArrayList<>(service.getAllAppointments()); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(appointments); + assertNotEquals(0, appointments.size()); + assertEquals(testCustomer.getScrsUserId(), appointments.get(0).getCustomer().getScrsUserId()); + assertEquals(testType, appointments.get(0).getAppointmentType()); + assertEquals(testTimeslot.getTimeSlotID(), appointments.get(0).getTimeslot(0).getTimeSlotID()); + } + + @Test + public void testGetByID() + { + Appointment appointment = null; + try + { + appointment = service.getAppointmentById(testID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(appointment); + assertEquals(testID, appointment.getAppointmentID()); + assertEquals(testCustomer, appointment.getCustomer()); + assertEquals(timeslots, appointment.getTimeslots()); + assertEquals(testType, appointment.getAppointmentType()); + } + + @Test + public void testGetByWrongID() + { + Appointment appointment = null; + try + { + appointment = service.getAppointmentById(wrongID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(appointment); + + } + + @Test + public void testGetByCustomer() + { + ArrayList appointments = null; + try + { + appointments = new ArrayList<>(service.getAppointmentsByCustomer(testCustomer)); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(appointments); + assertNotEquals(0, appointments.size()); + assertEquals(testID, appointments.get(0).getAppointmentID()); + assertEquals(testCustomer, appointments.get(0).getCustomer()); + assertEquals(timeslots, appointments.get(0).getTimeslots()); + assertEquals(testType, appointments.get(0).getAppointmentType()); + + } + + @Test + public void testGetByCustomerNull() + { + ArrayList appointments = null; + try + { + appointments = new ArrayList<>(service.getAppointmentsByCustomer(null)); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(appointments); + assertEquals(0, appointments.size()); + } + + @Test + public void testGetByWrongCustomer() + { + ArrayList appointments = null; + try + { + if (service.getAppointmentsByCustomer(new Customer()) != null) + { + appointments = new ArrayList<>(service.getAppointmentsByCustomer(new Customer())); + } + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(appointments); + } + + @Test + public void testGetByTimeslot() + { + Appointment appointment = null; + try + { + appointment = service.getAppointmentByTimeslot(testTimeslot); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(appointment); + assertEquals(testType, appointment.getAppointmentType()); + assertEquals(testID, appointment.getAppointmentID()); + assertEquals(testCustomer, appointment.getCustomer()); + assertEquals(testType, appointment.getAppointmentType()); + } + + @Test + public void testGetByTimeslotNull() + { + Appointment appointment = null; + try + { + appointment = service.getAppointmentByTimeslot(null); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(appointment); + } + + @Test + public void testGetByWrongTimeslot() + { + Appointment appointment = null; + try + { + appointment = service.getAppointmentByTimeslot(wrongTimeslot); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(appointment); + } + + @Test + public void testRate() + { + Appointment appointment = null; + try + { + appointment = service.rateAppointment(testID, testRating); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(appointment); + assertEquals(testCustomer.getScrsUserId(), appointment.getCustomer().getScrsUserId()); + assertEquals(testType, appointment.getAppointmentType()); + assertEquals(testTimeslot.getTimeSlotID(), appointment.getTimeslot(0).getTimeSlotID()); + assertEquals(testRating, appointment.getRating()); + } + + @Test + public void testRateInvalidID() + { + String error = null; + Appointment appointment = null; + try + { + appointment = service.rateAppointment(wrongID, testRating); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(appointment); + assertEquals("No such appointment!", error); + } + + @Test + public void testRateInvalidRating() + { + String error = null; + Appointment appointment = null; + try + { + appointment = service.rateAppointment(testID, wrongRating); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(appointment); + assertEquals("Invalid rating", error); + } + + @Test + public void testModify() + { + Appointment before = null; + Appointment after = null; + try + { + before = service.createAppointment(testType, null, null, false, testCustomer, timeslots.toArray(new Timeslot[0])); + before.setAppointmentID(testID); + Appointment dummy = new Appointment(); + dummy.setAppointmentID(before.getAppointmentID()); + dummy.setAppointmentType(wrongType); + dummy.setService("test"); + dummy.setNote("note"); + dummy.setPaid(true); + dummy.setRating(9); + dummy.setCustomer(before.getCustomer()); + dummy.setTimeslots(before.getTimeslots().toArray(new Timeslot[0])); + after = service.modifyAppointment(convertToDto(dummy)); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(after); + assertNotNull(before); + assertEquals(testType, before.getAppointmentType()); + assertNull(before.getService()); + assertNull(before.getNote()); + assertFalse(before.getPaid()); + assertEquals(wrongType, after.getAppointmentType()); + assertEquals("test", after.getService()); + assertEquals("note", after.getNote()); + assertTrue(after.getPaid()); + } + + @Test + public void testModifyNull() + { + String error = null; + Appointment before = null; + Appointment after = null; + try + { + before = service.createAppointment(testType, null, null, false, testCustomer, timeslots.toArray(new Timeslot[0])); + before.setAppointmentID(testID); + after = service.modifyAppointment(null); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertNotNull(before); + assertEquals(testType, before.getAppointmentType()); + assertNull(before.getService()); + assertNull(before.getNote()); + assertFalse(before.getPaid()); + assertEquals("Invalid appointment", error); + + } + + @Test + public void testModifyInvalidType() + { + String error = null; + Appointment before = null; + Appointment after = null; + try + { + before = service.createAppointment(testType, null, null, false, testCustomer, timeslots.toArray(new Timeslot[0])); + before.setAppointmentID(testID); + Appointment dummy = new Appointment(); + dummy.setAppointmentID(before.getAppointmentID()); + dummy.setAppointmentType(null); + dummy.setRating(9); + dummy.setCustomer(before.getCustomer()); + dummy.setTimeslots(before.getTimeslots().toArray(new Timeslot[0])); + after = service.modifyAppointment(convertToDto(dummy)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertNotNull(before); + assertEquals(testType, before.getAppointmentType()); + assertNull(before.getService()); + assertNull(before.getNote()); + assertFalse(before.getPaid()); + assertEquals("Appointment is ill-formed. Invalid appointmentType", error); + } + + @Test + public void testModifyInvalidRating() + { + String error = null; + Appointment before = null; + Appointment after = null; + try + { + before = service.createAppointment(testType, null, null, false, testCustomer, timeslots.toArray(new Timeslot[0])); + before.setAppointmentID(testID); + Appointment dummy = new Appointment(); + dummy.setAppointmentID(before.getAppointmentID()); + dummy.setAppointmentType(wrongType); + dummy.setRating(999); + dummy.setCustomer(before.getCustomer()); + dummy.setTimeslots(before.getTimeslots().toArray(new Timeslot[0])); + after = service.modifyAppointment(convertToDto(dummy)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertNotNull(before); + assertEquals(testType, before.getAppointmentType()); + assertNull(before.getService()); + assertNull(before.getNote()); + assertFalse(before.getPaid()); + assertEquals("Invalid rating", error); + } + + @Test + public void testModifyInvalidCustomer() + { + String error = null; + Appointment before = null; + Appointment after = null; + try + { + before = service.createAppointment(testType, null, null, false, testCustomer, timeslots.toArray(new Timeslot[0])); + before.setAppointmentID(testID); + Appointment dummy = new Appointment(); + dummy.setAppointmentID(before.getAppointmentID()); + dummy.setAppointmentType(wrongType); + dummy.setRating(9); + dummy.setTimeslots(before.getTimeslots().toArray(new Timeslot[0])); + after = service.modifyAppointment(convertToDto(dummy)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertNotNull(before); + assertEquals(testType, before.getAppointmentType()); + assertNull(before.getService()); + assertNull(before.getNote()); + assertFalse(before.getPaid()); + assertEquals("Appointment is ill-formed. Does not associate with valid customer!", error); + } + + @Test + public void testModifyInvalidTimeslots() + { + String error = null; + Appointment before = null; + Appointment after = null; + try + { + before = service.createAppointment(testType, null, null, false, testCustomer, timeslots.toArray(new Timeslot[0])); + before.setAppointmentID(testID); + Appointment dummy = new Appointment(); + dummy.setAppointmentID(before.getAppointmentID()); + dummy.setAppointmentType(wrongType); + dummy.setRating(9); + dummy.setCustomer(before.getCustomer()); + after = service.modifyAppointment(convertToDto(dummy)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertNotNull(before); + assertEquals(testType, before.getAppointmentType()); + assertNull(before.getService()); + assertNull(before.getNote()); + assertFalse(before.getPaid()); + assertEquals("No valid timeslots selected.", error); + } + + @Test + public void testDelete() + { + Appointment appointment = null; + Appointment deleted = null; + try + { + appointment = service.createAppointment(testType, null, null, false, testCustomer, timeslots.toArray(new Timeslot[0])); + deleted = service.deleteAppointment(appointment); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(deleted); + assertEquals(appointment.getAppointmentID(), deleted.getAppointmentID()); + assertEquals(appointment.getAppointmentType(), deleted.getAppointmentType()); + assertEquals(appointment.getCustomer(), deleted.getCustomer()); + assertEquals(appointment.getTimeslots(), deleted.getTimeslots()); + assertEquals(appointment.getNote(), deleted.getNote()); + } + + @Test + public void testDeleteNull() + { + Appointment deleted = null; + try + { + deleted = service.deleteAppointment(null); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(deleted); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestAssistantService.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestAssistantService.java new file mode 100644 index 0000000..51c6916 --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestAssistantService.java @@ -0,0 +1,420 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.AssistantRepository; +import ca.mcgill.ecse321.scrs.model.Assistant; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.stubbing.Answer; + +import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.lenient; + +@ExtendWith(MockitoExtension.class) +public class TestAssistantService +{ + @Mock + private AssistantRepository assistantDao; + + @InjectMocks + private AssistantService service; + + private static final int testID = 1; + private static final int wrongID = 420; + private static final String testString = "test"; + private static final String wrongString = "wrong"; + private static final String emptyString = ""; + + @BeforeEach + public void setMockOutput() + { + lenient().when(assistantDao.findByScrsUserId(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testID)) + { + Assistant assistant = new Assistant(); + assistant.setPhone(testString); + assistant.setPassword(testString); + assistant.setName(testString); + assistant.setEmail(testString); + assistant.setScrsUserId(testID); + return assistant; + } else + { + return null; + } + }); + lenient().when(assistantDao.findByName(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + Assistant assistant = new Assistant(); + assistant.setPhone(testString); + assistant.setPassword(testString); + assistant.setName(testString); + assistant.setEmail(testString); + assistant.setScrsUserId(testID); + return assistant; + } else + { + return null; + } + }); + lenient().when(assistantDao.findByEmail(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + Assistant assistant = new Assistant(); + assistant.setPhone(testString); + assistant.setPassword(testString); + assistant.setName(testString); + assistant.setEmail(testString); + assistant.setScrsUserId(testID); + return assistant; + } else + { + return null; + } + }); + lenient().when(assistantDao.findByPhone(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + Assistant assistant = new Assistant(); + assistant.setPhone(testString); + assistant.setPassword(testString); + assistant.setName(testString); + assistant.setEmail(testString); + assistant.setScrsUserId(testID); + return assistant; + } else + { + return null; + } + }); + lenient().when(assistantDao.findAll()).thenAnswer((InvocationOnMock invocation) -> { + Assistant assistant = new Assistant(); + assistant.setPhone(testString); + assistant.setPassword(testString); + assistant.setName(testString); + assistant.setEmail(testString); + assistant.setScrsUserId(testID); + ArrayList list = new ArrayList<>(); + list.add(assistant); + return list; + }); + Answer returnParameterAsAnswer = (InvocationOnMock invocation) -> { + return invocation.getArgument(0); + }; + lenient().when(assistantDao.save(any(Assistant.class))).thenAnswer(returnParameterAsAnswer); + } + + @Test + public void testCreateAssistant() + { + Assistant assistant = null; + try + { + assistant = service.createAssistant(testString, testString, testString, testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(assistant); + assertEquals(testString, assistant.getName()); + assertEquals(testString, assistant.getEmail()); + assertEquals(testString, assistant.getPhone()); + } + + @Test + public void testCreateAssistantNull() + { + String error = null; + Assistant assistant = null; + try + { + assistant = service.createAssistant(null, testString, testString, testString); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(assistant); + assertEquals("Please submit a valid email.", error); + } + + @Test + public void testCreateAssistantEmpty() + { + String error = null; + Assistant assistant = null; + try + { + assistant = service.createAssistant(emptyString, testString, testString, testString); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(assistant); + assertEquals("Please submit a valid email.", error); + } + + @Test + public void testGetAll() + { + ArrayList assistants = null; + try + { + assistants = new ArrayList(service.getAllAssistants()); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(assistants); + assertEquals(1, assistants.size()); + assertEquals(testString, assistants.get(0).getName()); + } + + @Test + public void testGetByID() + { + Assistant assistant = null; + try + { + assistant = service.getAssistantByID(testID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(assistant); + assertEquals(testString, assistant.getName()); + assertEquals(testString, assistant.getEmail()); + assertEquals(testString, assistant.getPhone()); + } + + @Test + public void testGetByWrongID() + { + Assistant assistant = null; + try + { + assistant = service.getAssistantByID(wrongID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(assistant); + } + + @Test + public void testGetByEmail() + { + Assistant assistant = null; + try + { + assistant = service.getAssistantByEmail(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(assistant); + assertEquals(testString, assistant.getName()); + assertEquals(testID, assistant.getScrsUserId()); + assertEquals(testString, assistant.getPhone()); + } + + @Test + public void testGetByWrongEmail() + { + Assistant assistant = null; + try + { + assistant = service.getAssistantByEmail(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(assistant); + } + + @Test + public void testGetByPhone() + { + Assistant assistant = null; + try + { + assistant = service.getAssistantByPhone(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(assistant); + assertEquals(testString, assistant.getName()); + assertEquals(testID, assistant.getScrsUserId()); + assertEquals(testString, assistant.getEmail()); + } + + @Test + public void testGetByWrongPhone() + { + Assistant assistant = null; + try + { + assistant = service.getAssistantByPhone(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(assistant); + } + + @Test + public void testGetByName() + { + Assistant assistant = null; + try + { + assistant = service.getAssistantByName(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(assistant); + assertEquals(testString, assistant.getEmail()); + assertEquals(testID, assistant.getScrsUserId()); + assertEquals(testString, assistant.getPhone()); + } + + @Test + public void testGetByWrongName() + { + Assistant assistant = null; + try + { + assistant = service.getAssistantByName(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(assistant); + } + + @Test + public void testUpdateAssistant() + { + Assistant before = null; + Assistant after = null; + try + { + before = service.createAssistant(wrongString, wrongString, wrongString, wrongString); + Assistant dummy = new Assistant(); + dummy.setEmail(testString); + dummy.setName(testString); + dummy.setPassword(testString); + dummy.setPhone(testString); + dummy.setScrsUserId(before.getScrsUserId()); + after = service.updateAssistantInfo(dummy); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(after); + assertEquals(wrongString, before.getName()); + assertEquals(wrongString, before.getEmail()); + assertEquals(wrongString, before.getPhone()); + assertEquals(testString, after.getName()); + assertEquals(testString, after.getEmail()); + assertEquals(testString, after.getPhone()); + } + + @Test + public void testUpdateAssistantNull() + { + String error = null; + Assistant before = null; + Assistant after = null; + try + { + before = service.createAssistant(wrongString, wrongString, wrongString, wrongString); + after = service.updateAssistantInfo(null); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertEquals("Please submit a valid user object.", error); + assertNotEquals(before, after); + } + + @Test + public void testUpdateAssistantInvalidParams() + { + String error = null; + Assistant before = null; + Assistant after = null; + try + { + before = service.createAssistant(wrongString, wrongString, wrongString, wrongString); + Assistant dummy = new Assistant(); + dummy.setEmail(null); + dummy.setName(testString); + dummy.setPassword(testString); + dummy.setPhone(testString); + dummy.setScrsUserId(before.getScrsUserId()); + after = service.updateAssistantInfo(dummy); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertEquals("Please submit a valid email.", error); + assertNotEquals(before, after); + } + + @Test + public void testDeleteAssistant() + { + Assistant assistant = null; + Assistant deleted = null; + try + { + assistant = service.createAssistant(wrongString, wrongString, wrongString, wrongString); + deleted = service.deleteAssistant(assistant); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(deleted); + assertEquals(assistant.getName(), deleted.getName()); + assertEquals(assistant.getEmail(), deleted.getEmail()); + assertEquals(assistant.getPhone(), deleted.getPhone()); + } + + @Test + public void testDeleteAssistantNull() + { + Assistant deleted = null; + try + { + deleted = service.deleteAssistant(null); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(deleted); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestCustomerService.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestCustomerService.java new file mode 100644 index 0000000..6ccf80a --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestCustomerService.java @@ -0,0 +1,421 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.CustomerRepository; +import ca.mcgill.ecse321.scrs.model.Customer; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.stubbing.Answer; + +import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.lenient; + +@ExtendWith(MockitoExtension.class) +public class TestCustomerService +{ + @Mock + private CustomerRepository customerDao; + + @InjectMocks + private CustomerService service; + + private static final int testID = 1; + private static final int wrongID = 420; + private static final String testString = "test"; + private static final String wrongString = "wrong"; + private static final String emptyString = ""; + + @BeforeEach + public void setMockOutput() + { + lenient().when(customerDao.findByScrsUserId(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testID)) + { + Customer customer = new Customer(); + customer.setPhone(testString); + customer.setPassword(testString); + customer.setName(testString); + customer.setEmail(testString); + customer.setScrsUserId(testID); + return customer; + } else + { + return null; + } + }); + lenient().when(customerDao.findByName(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + Customer customer = new Customer(); + customer.setPhone(testString); + customer.setPassword(testString); + customer.setName(testString); + customer.setEmail(testString); + customer.setScrsUserId(testID); + return customer; + } else + { + return null; + } + }); + lenient().when(customerDao.findByEmail(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + Customer customer = new Customer(); + customer.setPhone(testString); + customer.setPassword(testString); + customer.setName(testString); + customer.setEmail(testString); + customer.setScrsUserId(testID); + return customer; + } else + { + return null; + } + }); + lenient().when(customerDao.findByPhone(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + Customer customer = new Customer(); + customer.setPhone(testString); + customer.setPassword(testString); + customer.setName(testString); + customer.setEmail(testString); + customer.setScrsUserId(testID); + return customer; + } else + { + return null; + } + }); + lenient().when(customerDao.findAll()).thenAnswer((InvocationOnMock invocation) -> { + Customer customer = new Customer(); + customer.setPhone(testString); + customer.setPassword(testString); + customer.setName(testString); + customer.setEmail(testString); + customer.setScrsUserId(testID); + ArrayList list = new ArrayList<>(); + list.add(customer); + return list; + }); + Answer returnParameterAsAnswer = (InvocationOnMock invocation) -> { + return invocation.getArgument(0); + }; + lenient().when(customerDao.save(any(Customer.class))).thenAnswer(returnParameterAsAnswer); + } + + @Test + public void testCreateCustomer() + { + Customer customer = null; + try + { + customer = service.createCustomer(testString, testString, testString, testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(customer); + assertEquals(testString, customer.getName()); + assertEquals(testString, customer.getEmail()); + assertEquals(testString, customer.getPhone()); + } + + @Test + public void testCreateCustomerNull() + { + String error = null; + Customer customer = null; + try + { + customer = service.createCustomer(null, testString, testString, testString); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(customer); + assertEquals("Please submit a valid email.", error); + } + + @Test + public void testCreateCustomerEmpty() + { + String error = null; + Customer customer = null; + try + { + customer = service.createCustomer(emptyString, testString, testString, testString); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(customer); + assertEquals("Please submit a valid email.", error); + } + + @Test + public void testGetAll() + { + ArrayList customers = null; + try + { + customers = new ArrayList(service.getAllCustomers()); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(customers); + assertEquals(1, customers.size()); + assertEquals(testString, customers.get(0).getName()); + } + + @Test + public void testGetByID() + { + Customer customer = null; + try + { + customer = service.getCustomerByID(testID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(customer); + assertEquals(testString, customer.getName()); + assertEquals(testString, customer.getEmail()); + assertEquals(testString, customer.getPhone()); + } + + @Test + public void testGetByWrongID() + { + Customer customer = null; + try + { + customer = service.getCustomerByID(wrongID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(customer); + } + + @Test + public void testGetByEmail() + { + Customer customer = null; + try + { + customer = service.getCustomerByEmail(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(customer); + assertEquals(testString, customer.getName()); + assertEquals(testID, customer.getScrsUserId()); + assertEquals(testString, customer.getPhone()); + } + + @Test + public void testGetByWrongEmail() + { + Customer customer = null; + try + { + customer = service.getCustomerByEmail(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(customer); + } + + @Test + public void testGetByPhone() + { + Customer customer = null; + try + { + customer = service.getCustomerByPhone(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(customer); + assertEquals(testString, customer.getName()); + assertEquals(testID, customer.getScrsUserId()); + assertEquals(testString, customer.getEmail()); + } + + @Test + public void testGetByWrongPhone() + { + Customer customer = null; + try + { + customer = service.getCustomerByPhone(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(customer); + } + + @Test + public void testGetByName() + { + Customer customer = null; + try + { + customer = service.getCustomerByName(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(customer); + assertEquals(testString, customer.getEmail()); + assertEquals(testID, customer.getScrsUserId()); + assertEquals(testString, customer.getPhone()); + } + + @Test + public void testGetByWrongName() + { + Customer customer = null; + try + { + customer = service.getCustomerByName(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(customer); + } + + @Test + public void testUpdateCustomer() + { + Customer before = null; + Customer after = null; + try + { + before = service.createCustomer(wrongString, wrongString, wrongString, wrongString); + Customer dummy = new Customer(); + dummy.setEmail(testString); + dummy.setName(testString); + dummy.setPassword(testString); + dummy.setPhone(testString); + dummy.setScrsUserId(before.getScrsUserId()); + after = service.updateCustomerInfo(dummy); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(after); + assertEquals(wrongString, before.getName()); + assertEquals(wrongString, before.getEmail()); + assertEquals(wrongString, before.getPhone()); + assertEquals(testString, after.getName()); + assertEquals(testString, after.getEmail()); + assertEquals(testString, after.getPhone()); + } + + @Test + public void testUpdateCustomerNull() + { + String error = null; + Customer before = null; + Customer after = null; + try + { + before = service.createCustomer(wrongString, wrongString, wrongString, wrongString); + after = service.updateCustomerInfo(null); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertEquals("Please submit a valid user object.", error); + assertNotEquals(before, after); + } + + @Test + public void testUpdateCustomerInvalidParams() + { + String error = null; + Customer before = null; + Customer after = null; + try + { + before = service.createCustomer(wrongString, wrongString, wrongString, wrongString); + Customer dummy = new Customer(); + dummy.setEmail(null); + dummy.setName(testString); + dummy.setPassword(testString); + dummy.setPhone(testString); + dummy.setScrsUserId(before.getScrsUserId()); + after = service.updateCustomerInfo(dummy); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertEquals("Please submit a valid email.", error); + assertNotEquals(before, after); + } + + @Test + public void testDeleteCustomer() + { + Customer customer = null; + Customer deleted = null; + try + { + customer = service.createCustomer(wrongString, wrongString, wrongString, wrongString); + deleted = service.deleteCustomer(customer); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(deleted); + assertEquals(customer.getName(), deleted.getName()); + assertEquals(customer.getEmail(), deleted.getEmail()); + assertEquals(customer.getPhone(), deleted.getPhone()); + + } + + @Test + public void testDeleteCustomerNull() + { + Customer deleted = null; + try + { + deleted = service.deleteCustomer(null); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(deleted); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestSCRSService.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestSCRSService.java new file mode 100644 index 0000000..f31af93 --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestSCRSService.java @@ -0,0 +1,10 @@ +package ca.mcgill.ecse321.scrs.service; + +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class TestSCRSService +{ + //No service methods needed here for now. +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestSCRSUserService.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestSCRSUserService.java new file mode 100644 index 0000000..2f7fad7 --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestSCRSUserService.java @@ -0,0 +1,264 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.SCRSUserRepository; +import ca.mcgill.ecse321.scrs.model.Customer; +import ca.mcgill.ecse321.scrs.model.SCRSUser; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.stubbing.Answer; + +import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.lenient; + +@ExtendWith(MockitoExtension.class) +public class TestSCRSUserService +{ + @Mock + private SCRSUserRepository userDao; + + @InjectMocks + private SCRSUserService service; + + private static final int testID = 1; + private static final int wrongID = 420; + private static final String testString = "test"; + private static final String wrongString = "wrong"; + private static final String emptyString = ""; + + @BeforeEach + public void setMockOutput() + { + lenient().when(userDao.findByScrsUserId(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testID)) + { + SCRSUser user = new Customer(); + user.setPhone(testString); + user.setPassword(testString); + user.setName(testString); + user.setEmail(testString); + user.setScrsUserId(testID); + return user; + } else + { + return null; + } + }); + lenient().when(userDao.findByName(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + SCRSUser user = new Customer(); + user.setPhone(testString); + user.setPassword(testString); + user.setName(testString); + user.setEmail(testString); + user.setScrsUserId(testID); + return user; + } else + { + return null; + } + }); + lenient().when(userDao.findByEmail(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + SCRSUser user = new Customer(); + user.setPhone(testString); + user.setPassword(testString); + user.setName(testString); + user.setEmail(testString); + user.setScrsUserId(testID); + return user; + } else + { + return null; + } + }); + lenient().when(userDao.findByPhone(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + SCRSUser user = new Customer(); + user.setPhone(testString); + user.setPassword(testString); + user.setName(testString); + user.setEmail(testString); + user.setScrsUserId(testID); + return user; + } else + { + return null; + } + }); + lenient().when(userDao.findAll()).thenAnswer((InvocationOnMock invocation) -> { + SCRSUser user = new Customer(); + user.setPhone(testString); + user.setPassword(testString); + user.setName(testString); + user.setEmail(testString); + user.setScrsUserId(testID); + ArrayList list = new ArrayList<>(); + list.add(user); + return list; + }); + Answer returnParameterAsAnswer = (InvocationOnMock invocation) -> { + return invocation.getArgument(0); + }; + lenient().when(userDao.save(any(SCRSUser.class))).thenAnswer(returnParameterAsAnswer); + } + + @Test + public void testGetAll() + { + ArrayList users = null; + try + { + users = new ArrayList(service.getAllSCRSUsers()); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(users); + assertEquals(1, users.size()); + assertEquals(testString, users.get(0).getName()); + } + + @Test + public void testGetByID() + { + SCRSUser user = null; + try + { + user = service.getSCRSUserByID(testID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(user); + assertEquals(testString, user.getName()); + assertEquals(testString, user.getEmail()); + assertEquals(testString, user.getPhone()); + } + + @Test + public void testGetByWrongID() + { + SCRSUser user = null; + try + { + user = service.getSCRSUserByID(wrongID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(user); + } + + @Test + public void testGetByEmail() + { + SCRSUser user = null; + try + { + user = service.getSCRSUserByEmail(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(user); + assertEquals(testString, user.getName()); + assertEquals(testID, user.getScrsUserId()); + assertEquals(testString, user.getPhone()); + } + + @Test + public void testGetByWrongEmail() + { + SCRSUser user = null; + try + { + user = service.getSCRSUserByEmail(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(user); + } + + @Test + public void testGetByPhone() + { + SCRSUser user = null; + try + { + user = service.getSCRSUserByPhone(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(user); + assertEquals(testString, user.getName()); + assertEquals(testID, user.getScrsUserId()); + assertEquals(testString, user.getEmail()); + } + + @Test + public void testGetByWrongPhone() + { + SCRSUser user = null; + try + { + user = service.getSCRSUserByPhone(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(user); + } + + @Test + public void testGetByName() + { + SCRSUser user = null; + try + { + user = service.getSCRSUserByName(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(user); + assertEquals(testString, user.getEmail()); + assertEquals(testID, user.getScrsUserId()); + assertEquals(testString, user.getPhone()); + } + + @Test + public void testGetByWrongName() + { + SCRSUser user = null; + try + { + user = service.getSCRSUserByName(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(user); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestTechnicianService.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestTechnicianService.java new file mode 100644 index 0000000..6e3c0ce --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestTechnicianService.java @@ -0,0 +1,393 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.TechnicianRepository; +import ca.mcgill.ecse321.scrs.model.Technician; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.stubbing.Answer; + +import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.lenient; + +@ExtendWith(MockitoExtension.class) +public class TestTechnicianService +{ + @Mock + private TechnicianRepository technicianDao; + + @InjectMocks + private TechnicianService service; + + private static final int testID = 1; + private static final int wrongID = 420; + private static final String testString = "test"; + private static final String wrongString = "wrong"; + private static final String emptyString = ""; + + @BeforeEach + public void setMockOutput() + { + lenient().when(technicianDao.findByScrsUserId(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testID)) + { + Technician technician = new Technician(testString, testString, testString, testString, null); + technician.setScrsUserId(testID); + return technician; + } else + { + return null; + } + }); + lenient().when(technicianDao.findByName(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + Technician technician = new Technician(testString, testString, testString, testString, null); + technician.setScrsUserId(testID); + return technician; + } else + { + return null; + } + }); + lenient().when(technicianDao.findByEmail(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + Technician technician = new Technician(testString, testString, testString, testString, null); + technician.setScrsUserId(testID); + return technician; + } else + { + return null; + } + }); + lenient().when(technicianDao.findByPhone(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testString)) + { + Technician technician = new Technician(testString, testString, testString, testString, null); + technician.setScrsUserId(testID); + return technician; + } else + { + return null; + } + }); + lenient().when(technicianDao.findAll()).thenAnswer((InvocationOnMock invocation) -> { + Technician technician = new Technician(testString, testString, testString, testString, null); + technician.setScrsUserId(testID); + ArrayList list = new ArrayList<>(); + list.add(technician); + return list; + }); + Answer returnParameterAsAnswer = (InvocationOnMock invocation) -> { + return invocation.getArgument(0); + }; + lenient().when(technicianDao.save(any(Technician.class))).thenAnswer(returnParameterAsAnswer); + } + + @Test + public void testCreateTechnician() + { + Technician technician = null; + try + { + technician = service.createTechnician(testString, testString, testString, testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(technician); + assertEquals(testString, technician.getName()); + assertEquals(testString, technician.getEmail()); + assertEquals(testString, technician.getPhone()); + } + + @Test + public void testCreateTechnicianNull() + { + String error = null; + Technician technician = null; + try + { + technician = service.createTechnician(null, testString, testString, testString); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(technician); + assertEquals("Please submit a valid email.", error); + } + + @Test + public void testCreateTechnicianEmpty() + { + String error = null; + Technician technician = null; + try + { + technician = service.createTechnician(emptyString, testString, testString, testString); + + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(technician); + assertEquals("Please submit a valid email.", error); + } + + @Test + public void testGetAll() + { + ArrayList technicians = null; + try + { + technicians = new ArrayList(service.getAllTechnicians()); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(technicians); + assertEquals(1, technicians.size()); + assertEquals(testString, technicians.get(0).getName()); + } + + @Test + public void testGetByID() + { + Technician technician = null; + try + { + technician = service.getTechnicianByID(testID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(technician); + assertEquals(testString, technician.getName()); + assertEquals(testString, technician.getEmail()); + assertEquals(testString, technician.getPhone()); + } + + @Test + public void testGetByWrongID() + { + Technician technician = null; + try + { + technician = service.getTechnicianByID(wrongID); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(technician); + } + + @Test + public void testGetByEmail() + { + Technician technician = null; + try + { + technician = service.getTechnicianByEmail(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(technician); + assertEquals(testString, technician.getName()); + assertEquals(testID, technician.getScrsUserId()); + assertEquals(testString, technician.getPhone()); + } + + @Test + public void testGetByWrongEmail() + { + Technician technician = null; + try + { + technician = service.getTechnicianByEmail(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(technician); + } + + @Test + public void testGetByPhone() + { + Technician technician = null; + try + { + technician = service.getTechnicianByPhone(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(technician); + assertEquals(testString, technician.getName()); + assertEquals(testID, technician.getScrsUserId()); + assertEquals(testString, technician.getEmail()); + } + + @Test + public void testGetByWrongPhone() + { + Technician technician = null; + try + { + technician = service.getTechnicianByPhone(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(technician); + } + + @Test + public void testGetByName() + { + Technician technician = null; + try + { + technician = service.getTechnicianByName(testString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(technician); + assertEquals(testString, technician.getEmail()); + assertEquals(testID, technician.getScrsUserId()); + assertEquals(testString, technician.getPhone()); + } + + @Test + public void testGetByWrongName() + { + Technician technician = null; + try + { + technician = service.getTechnicianByName(wrongString); + + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(technician); + } + + @Test + public void testUpdateTechnician() + { + Technician before = null; + Technician after = null; + try + { + before = service.createTechnician(wrongString, wrongString, wrongString, wrongString); + Technician dummy = new Technician(testString, testString, testString, testString, null); + dummy.setScrsUserId(before.getScrsUserId()); + after = service.updateTechnicianInfo(dummy); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(after); + assertEquals(wrongString, before.getName()); + assertEquals(wrongString, before.getEmail()); + assertEquals(wrongString, before.getPhone()); + assertEquals(testString, after.getName()); + assertEquals(testString, after.getEmail()); + assertEquals(testString, after.getPhone()); + } + + @Test + public void testUpdateTechnicianNull() + { + String error = null; + Technician before = null; + Technician after = null; + try + { + before = service.createTechnician(wrongString, wrongString, wrongString, wrongString); + after = service.updateTechnicianInfo(null); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertEquals("Please submit a valid user object.", error); + assertNotEquals(before, after); + } + + @Test + public void testUpdateTechnicianInvalidParams() + { + String error = null; + Technician before = null; + Technician after = null; + try + { + before = service.createTechnician(wrongString, wrongString, wrongString, wrongString); + Technician dummy = new Technician(testString, testString, "", testString, null); + dummy.setScrsUserId(before.getScrsUserId()); + after = service.updateTechnicianInfo(dummy); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(after); + assertEquals("Please submit a valid email.", error); + assertNotEquals(before, after); + } + + @Test + public void testDeleteTechnician() + { + Technician technician = null; + Technician deleted = null; + try + { + technician = service.createTechnician(wrongString, wrongString, wrongString, wrongString); + deleted = service.deleteTechnician(technician); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(deleted); + assertEquals(technician.getName(), deleted.getName()); + assertEquals(technician.getEmail(), deleted.getEmail()); + assertEquals(technician.getPhone(), deleted.getPhone()); + + } + + @Test + public void testDeleteTechnicianNull() + { + Technician deleted = null; + try + { + deleted = service.deleteTechnician(null); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(deleted); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestTimeslotService.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestTimeslotService.java new file mode 100644 index 0000000..272d782 --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestTimeslotService.java @@ -0,0 +1,601 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.AppointmentRepository; +import ca.mcgill.ecse321.scrs.dao.TechnicianRepository; +import ca.mcgill.ecse321.scrs.dao.TimeslotRepository; +import ca.mcgill.ecse321.scrs.dao.WorkspaceRepository; +import ca.mcgill.ecse321.scrs.model.Technician; +import ca.mcgill.ecse321.scrs.model.Timeslot; +import ca.mcgill.ecse321.scrs.model.Workspace; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.stubbing.Answer; + +import java.sql.Date; +import java.sql.Time; +import java.util.ArrayList; + +import static java.lang.System.currentTimeMillis; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.lenient; + +@ExtendWith(MockitoExtension.class) +public class TestTimeslotService +{ + @Mock + private TimeslotRepository timeslotDao; + @Mock + private AppointmentRepository appointmentDao; + @Mock + private WorkspaceRepository workspaceDao; + @Mock + private TechnicianRepository technicianDao; + + @InjectMocks + private TimeslotService service; + + private static final int testID = 1; + private static final int testID2 = 2; + private static final int testID3 = 3; + private static final int wrongID = 420; + private static final Time testTime = new Time(currentTimeMillis()); + private static final Time laterTime = new Time(currentTimeMillis() + 100000000); + private static final Time latestTime = new Time(currentTimeMillis() + 900000000); + private static final Date testDate = new Date(currentTimeMillis()); + private static final Date laterDate = new Date(currentTimeMillis() + 100000000); + private static final Date latestDate = new Date(currentTimeMillis() + 900000000); + private static final Workspace testWorkspace = new Workspace(); + private static Technician testTechnician = null; + private static final Timeslot testTimeslot = new Timeslot(); + + @BeforeAll + public static void instantiateVars() + { + testWorkspace.setWorkspaceID(testID); + testWorkspace.setSpaceName("name"); + testWorkspace.setAvailabilities(new ArrayList<>()); + + testTechnician = new Technician("name", "pass", "email", "phone", null); + testTechnician.setScrsUserId(testID); + + testTimeslot.setWorkspace(testWorkspace); + testTimeslot.setStartTime(testTime); + testTimeslot.setEndTime(laterTime); + testTimeslot.setStartDate(testDate); + testTimeslot.setEndDate(laterDate); + testTimeslot.setTimeSlotID(testID); + ArrayList techs = new ArrayList<>(); + techs.add(testTechnician); + testTimeslot.setTechnicians(techs); + } + + @BeforeEach + public void setMockOutput() + { + lenient().when(timeslotDao.findByTimeSlotID(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + Timeslot timeslot = new Timeslot(); + timeslot.setWorkspace(testWorkspace); + timeslot.setStartTime(testTime); + timeslot.setEndTime(laterTime); + timeslot.setStartDate(testDate); + timeslot.setEndDate(laterDate); + if (invocation.getArgument(0).equals(testID)) + { + timeslot.setTimeSlotID(testID); + return timeslot; + } else if (invocation.getArgument(0).equals(testID2)) + { + timeslot.setTimeSlotID(testID2); + return timeslot; + } else if (invocation.getArgument(0).equals(testID3)) + { + timeslot.setTimeSlotID(testID3); + return timeslot; + } else + { + return null; + } + }); + lenient().when(timeslotDao.findAll()).thenAnswer((InvocationOnMock invocation) -> { + ArrayList list = new ArrayList<>(); + Timeslot timeslot = new Timeslot(); + timeslot.setWorkspace(testWorkspace); + timeslot.setTimeSlotID(testID); + timeslot.setStartTime(testTime); + timeslot.setEndTime(laterTime); + timeslot.setStartDate(testDate); + timeslot.setEndDate(laterDate); + list.add(timeslot); + return list; + }); + lenient().when(timeslotDao.findAllByStartDateGreaterThanEqualAndStartDateLessThanEqualOrderByStartDate(any(Date.class), any(Date.class))).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testDate) && invocation.getArgument(1).equals(laterDate)) + { + ArrayList list = new ArrayList<>(); + ArrayList technicians = new ArrayList<>(); + technicians.add(testTechnician); + list.add(testTimeslot); + Timeslot timeslot2 = new Timeslot(); + timeslot2.setWorkspace(testWorkspace); + timeslot2.setTimeSlotID(testID2); + timeslot2.setStartTime(testTime); + timeslot2.setEndTime(laterTime); + timeslot2.setStartDate(laterDate); + timeslot2.setEndDate(latestDate); + timeslot2.setTechnicians(technicians); + list.add(timeslot2); + return list; + } else + { + return null; + } + }); + lenient().when(timeslotDao.findByTechnicians(any(Technician.class))).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testTechnician)) + { + ArrayList list = new ArrayList<>(); + list.add(testTimeslot); + return list; + } else + { + return null; + } + }); + lenient().when(timeslotDao.findByWorkspace(any(Workspace.class))).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testWorkspace)) + { + Timeslot timeslot = new Timeslot(); + timeslot.setWorkspace(testWorkspace); + timeslot.setTimeSlotID(testID); + timeslot.setStartTime(testTime); + timeslot.setEndTime(laterTime); + timeslot.setStartDate(testDate); + timeslot.setEndDate(laterDate); + + ArrayList list = new ArrayList<>(); + list.add(timeslot); + return list; + } else + { + return null; + } + }); + lenient().when(workspaceDao.findByWorkspaceID(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testID)) + { + return testWorkspace; + } else + { + return null; + } + }); + lenient().when(technicianDao.findByScrsUserId(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testID)) + { + return testTechnician; + } else + { + return null; + } + }); + lenient().when(appointmentDao.existsByTimeslots(any(Timeslot.class))).thenAnswer((InvocationOnMock invocation) -> invocation.getArgument(0).equals(testTimeslot)); + Answer returnParameterAsAnswer = (InvocationOnMock invocation) -> { + return invocation.getArgument(0); + }; + lenient().when(timeslotDao.save(any(Timeslot.class))).thenAnswer(returnParameterAsAnswer); + } + + @Test + public void testCreate() + { + Timeslot timeslot = null; + try + { + timeslot = service.createTimeslot(testDate, laterDate, testTime, laterTime, testWorkspace); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(timeslot); + assertEquals(testDate, timeslot.getStartDate()); + assertEquals(testTime, timeslot.getStartTime()); + assertEquals(laterDate, timeslot.getEndDate()); + assertEquals(laterTime, timeslot.getEndTime()); + } + + @Test + public void testCreateNullDate() + { + String error = null; + Timeslot timeslot = null; + try + { + timeslot = service.createTimeslot(null, laterDate, testTime, laterTime, testWorkspace); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslot); + assertEquals("Please input a valid start and end date.", error); + } + + @Test + public void testCreateNullTime() + { + String error = null; + Timeslot timeslot = null; + try + { + timeslot = service.createTimeslot(testDate, laterDate, null, laterTime, testWorkspace); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslot); + assertEquals("Please input a valid start and end time.", error); + } + + @Test + public void testCreateNullWorkspace() + { + String error = null; + Timeslot timeslot = null; + try + { + timeslot = service.createTimeslot(testDate, laterDate, testTime, laterTime, null); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslot); + assertEquals("Please input a valid workspace.", error); + } + + @Test + public void testCreateInvalidDate() + { + String error = null; + Timeslot timeslot = null; + try + { + timeslot = service.createTimeslot(laterDate, testDate, testTime, laterTime, testWorkspace); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslot); + assertEquals("Your start date cannot be after your end date.", error); + } + + @Test + public void testCreateInvalidTime() + { + String error = null; + Timeslot timeslot = null; + try + { + timeslot = service.createTimeslot(testDate, laterDate, laterTime, testTime, testWorkspace); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslot); + assertEquals("Your start time cannot be after your end time.", error); + } + + @Test + public void testGetAll() + { + ArrayList timeslots = null; + try + { + timeslots = new ArrayList<>(service.getAllTimeslots()); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(timeslots); + assertNotEquals(0, timeslots.size()); + assertEquals(testID, timeslots.get(0).getTimeSlotID()); + assertEquals(testWorkspace, timeslots.get(0).getWorkspace()); + assertEquals(testDate, timeslots.get(0).getStartDate()); + } + + @Test + public void testGetByID() + { + Timeslot timeslot = null; + try + { + timeslot = service.getTimeslotById(testID); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(timeslot); + assertEquals(testID, timeslot.getTimeSlotID()); + assertEquals(testDate, timeslot.getStartDate()); + assertEquals(testTime, timeslot.getStartTime()); + assertEquals(testWorkspace.getWorkspaceID(), timeslot.getWorkspace().getWorkspaceID()); + } + + @Test + public void testGetMultipleByID() + { + ArrayList timeslots = null; + try + { + ArrayList ids = new ArrayList<>(); + ids.add(testID); + ids.add(testID2); + ids.add(testID3); + timeslots = new ArrayList<>(service.getTimeslotsById(ids)); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(timeslots); + assertEquals(3, timeslots.size()); + assertEquals(testID, timeslots.get(0).getTimeSlotID()); + assertEquals(testID2, timeslots.get(1).getTimeSlotID()); + assertEquals(testID3, timeslots.get(2).getTimeSlotID()); + } + + @Test + public void testGetMultipleByIDNull() + { + ArrayList timeslots = null; + String error = null; + try + { + timeslots = new ArrayList<>(service.getTimeslotsById(null)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslots); + assertEquals("Please input at least one valid timeslot ID.", error); + } + + @Test + public void testGetByTechBetween() + { + ArrayList timeslots = null; + try + { + timeslots = new ArrayList<>(service.getTimeslotsByTechnicianBetweenDates(testTechnician, testDate, laterDate)); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(timeslots); + assertEquals(2, timeslots.size()); + assertEquals(testID, timeslots.get(0).getTimeSlotID()); + assertEquals(testID2, timeslots.get(1).getTimeSlotID()); + } + + @Test + public void testGetByNullTechBetween() + { + String error = null; + ArrayList timeslots = null; + try + { + timeslots = new ArrayList<>(service.getTimeslotsByTechnicianBetweenDates(null, testDate, laterDate)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslots); + assertEquals("Invalid technician.", error); + } + + @Test + public void testGetByTechBetweenInvalid() + { + String error = null; + ArrayList timeslots = null; + try + { + timeslots = new ArrayList<>(service.getTimeslotsByTechnicianBetweenDates(testTechnician, latestDate, laterDate)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslots); + assertEquals("Your start date cannot be after your end date.", error); + } + + @Test + public void testGetByWorkspace() + { + ArrayList timeslots = null; + try + { + timeslots = new ArrayList<>(service.getTimeslotsByWorkspace(testWorkspace)); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(timeslots); + assertEquals(1, timeslots.size()); + assertEquals(testID, timeslots.get(0).getTimeSlotID()); + assertEquals(testDate, timeslots.get(0).getStartDate()); + assertEquals(testTime, timeslots.get(0).getStartTime()); + assertEquals(testWorkspace.getWorkspaceID(), timeslots.get(0).getWorkspace().getWorkspaceID()); + } + + @Test + public void testGetByWorkspaceNull() + { + String error = null; + ArrayList timeslots = null; + try + { + timeslots = new ArrayList<>(service.getTimeslotsByWorkspace(null)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslots); + assertEquals("Invalid workspace.", error); + } + + @Test + public void testGetAvailable() + { + ArrayList timeslots = null; + try + { + timeslots = new ArrayList<>(service.getAvailableTimeslots(testDate, laterDate)); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(timeslots); + assertEquals(1, timeslots.size()); + assertEquals(testID2, timeslots.get(0).getTimeSlotID()); + } + + @Test + public void testGetAvailableNull() + { + String error = null; + ArrayList timeslots = null; + try + { + timeslots = new ArrayList<>(service.getAvailableTimeslots(null, laterDate)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslots); + assertEquals("Please input a valid start and end date.", error); + } + + @Test + public void testGetAvailableInvalid() + { + String error = null; + ArrayList timeslots = null; + try + { + timeslots = new ArrayList<>(service.getAvailableTimeslots(latestDate, laterDate)); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(timeslots); + assertEquals("Your start date cannot be after your end date.", error); + } + + @Test + public void testAssign() + { + boolean assigned = false; + try + { + Timeslot timeslot = new Timeslot(); + timeslot.setTechnicians(new ArrayList<>()); + timeslot.setTimeSlotID(testID); + //not a valid timeslot, but we only test for existence, which is being mocked. + assigned = service.assignTechnicianToTimeslot(testTechnician, timeslot); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertTrue(assigned); + } + + @Test + public void testAssignAlreadyAssigned() + { + boolean assigned = false; + try + { + assigned = service.assignTechnicianToTimeslot(testTechnician, testTimeslot); + //testTechnician and testTimeslot are already assigned to each other + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertFalse(assigned); + } + + @Test + public void testAssignNullTech() + { + String error = null; + boolean assigned = false; + try + { + Timeslot timeslot = new Timeslot(); + timeslot.setTechnicians(new ArrayList<>()); + timeslot.setTimeSlotID(testID); + //not a valid timeslot, but we only test for existence, which is being mocked. + assigned = service.assignTechnicianToTimeslot(null, timeslot); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertFalse(assigned); + assertEquals("Invalid technician.", error); + } + + @Test + public void testAssignNullTimeslot() + { + String error = null; + boolean assigned = false; + try + { + assigned = service.assignTechnicianToTimeslot(testTechnician, null); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertFalse(assigned); + assertEquals("Invalid timeslot.", error); + } + + @Test + public void testDelete() + { + Timeslot timeslot = testTimeslot; + Timeslot deleted = null; + try + { + deleted = service.deleteTimeslot(testTimeslot); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNotNull(deleted); + assertEquals(timeslot.getTimeSlotID(), deleted.getTimeSlotID()); + assertEquals(timeslot.getStartDate(), deleted.getStartDate()); + assertEquals(timeslot.getTechnicians(), deleted.getTechnicians()); + } + + @Test + public void testDeleteNull() + { + + Timeslot deleted = null; + try + { + deleted = service.deleteTimeslot(null); + } catch (IllegalArgumentException e) + { + fail(); + } + assertNull(deleted); + } +} diff --git a/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestWorkspaceService.java b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestWorkspaceService.java new file mode 100644 index 0000000..95a7fa4 --- /dev/null +++ b/SCRS-Backend/src/test/java/ca/mcgill/ecse321/scrs/service/TestWorkspaceService.java @@ -0,0 +1,264 @@ +package ca.mcgill.ecse321.scrs.service; + +import ca.mcgill.ecse321.scrs.dao.WorkspaceRepository; +import ca.mcgill.ecse321.scrs.model.Workspace; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.stubbing.Answer; + +import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.lenient; + +@ExtendWith(MockitoExtension.class) +public class TestWorkspaceService +{ + @Mock + WorkspaceRepository workspaceDao; + + @InjectMocks + WorkspaceService service; + + private static final int testID = 1; + private static final int wrongID = 420; + private static final String testName = "test"; + private static final String wrongName = "wrong"; + private static final Workspace testWorkspace = new Workspace(); + + @BeforeAll + public static void instantiateVars() + { + testWorkspace.setWorkspaceID(testID); + testWorkspace.setSpaceName(testName); + } + + @BeforeEach + public void setMockOutput() + { + lenient().when(workspaceDao.findByWorkspaceID(anyInt())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testID)) + { + return testWorkspace; + } else + { + return null; + } + }); + lenient().when(workspaceDao.findBySpaceName(anyString())).thenAnswer((InvocationOnMock invocation) -> { + if (invocation.getArgument(0).equals(testName)) + { + return testWorkspace; + } else + { + return null; + } + }); + lenient().when(workspaceDao.findAll()).thenAnswer((InvocationOnMock invocation) -> { + ArrayList list = new ArrayList<>(); + list.add(testWorkspace); + return list; + }); + Answer returnParameterAsAnswer = (InvocationOnMock invocation) -> { + return invocation.getArgument(0); + }; + lenient().when(workspaceDao.save(any(Workspace.class))).thenAnswer(returnParameterAsAnswer); + } + + @Test + public void testCreate() + { + Workspace workspace = null; + try + { + workspace = service.createWorkspace(testName); + } catch (IllegalArgumentException e) + { + fail(e); + } + assertNotNull(workspace); + assertEquals(testName, workspace.getSpaceName()); + } + + @Test + public void testCreateNullName() + { + String error = null; + Workspace workspace = null; + try + { + workspace = service.createWorkspace(null); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(workspace); + assertNotNull(error); + assertEquals("Invalid workspace name.", error); + } + + @Test + public void testCreateInvalidName() + { + String error = null; + Workspace workspace = null; + try + { + workspace = service.createWorkspace(" "); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(workspace); + assertNotNull(error); + assertEquals("Invalid workspace name.", error); + } + + @Test + public void testGetAll() + { + ArrayList workspaces = null; + try + { + workspaces = new ArrayList<>(service.getAllWorkspaces()); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(workspaces); + assertEquals(1, workspaces.size()); + assertEquals(testName, workspaces.get(0).getSpaceName()); + } + + @Test + public void testGetByID() + { + Workspace workspace = null; + try + { + workspace = service.getWorkspaceById(testID); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(workspace); + assertEquals(testName, workspace.getSpaceName()); + assertEquals(testID, workspace.getWorkspaceID()); + } + + @Test + public void testGetByWrongID() + { + Workspace workspace = null; + try + { + workspace = service.getWorkspaceById(wrongID); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNull(workspace); + } + + @Test + public void testGetByName() + { + Workspace workspace = null; + try + { + workspace = service.getWorkspaceByName(testName); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(workspace); + assertEquals(testName, workspace.getSpaceName()); + assertEquals(testID, workspace.getWorkspaceID()); + } + + @Test + public void testGetByWrongName() + { + Workspace workspace = null; + try + { + workspace = service.getWorkspaceByName(wrongName); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNull(workspace); + } + + @Test + public void testGetByNullName() + { + String error = null; + Workspace workspace = null; + try + { + workspace = service.getWorkspaceByName(null); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(workspace); + assertEquals("Invalid workspace name.", error); + } + + @Test + public void testGetByInvalidName() + { + String error = null; + Workspace workspace = null; + try + { + workspace = service.getWorkspaceByName(" "); + } catch (IllegalArgumentException e) + { + error = e.getMessage(); + } + assertNull(workspace); + assertEquals("Invalid workspace name.", error); + } + + @Test + public void testDelete() + { + Workspace workspace = testWorkspace; + Workspace deleted = null; + try + { + deleted = service.deleteWorkspace(workspace); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNotNull(deleted); + assertEquals(workspace.getWorkspaceID(), deleted.getWorkspaceID()); + assertEquals(workspace.getSpaceName(), deleted.getSpaceName()); + assertEquals(workspace, deleted); + } + + @Test + public void testDeleteNull() + { + Workspace deleted = null; + try + { + deleted = service.deleteWorkspace(null); + } catch (IllegalArgumentException e) + { + fail(e.getMessage()); + } + assertNull(deleted); + } + +} diff --git a/SCRS-Backend/src/test/javascript/appointment.js b/SCRS-Backend/src/test/javascript/appointment.js new file mode 100644 index 0000000..36c82fc --- /dev/null +++ b/SCRS-Backend/src/test/javascript/appointment.js @@ -0,0 +1,622 @@ +import axios from "axios"; + +const testAppointmentBookingAndPayment = async () => { + const backend_address = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 8; + let customerIdToCheck = -1; + let timeslotIdToCheck = -1; + let appointmentDataToCheck = null; + + // ========== test setups ========== + try { + let wipeDatabaseResponse = await axios.delete( + backend_address + "/api/database/wipe" + ); + + // create customer + let createCustomerData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + let createCustomerPost = await axios.post( + backend_address + "/api/customer/create", + createCustomerData + ); + customerIdToCheck = createCustomerPost.data.customerId; + + // create workspace + let createWorkspaceData = "name=foo"; + let createWorkspacePost = await axios.post( + backend_address + "/api/workspace/create", + createWorkspaceData + ); + + // create timeslot + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: createWorkspacePost.data.workspaceId, + techniciansId: [], + }; + let createTimeslotPost = await axios.post( + backend_address + "/api/timeslot/create", + createTimeslotData); + timeslotIdToCheck = createTimeslotPost.data.timeslotId; + } catch (error) { + console.log("Setup for testAppointmentBookingAndPayment FAILED"); + } + + // ========== booking an appointment ========== + try { + let bookAppointmentData = { + appointmentType: "CarWash", + service: "Car wash", + note: "Hello world", + customerId: customerIdToCheck, + timeslotsId: [timeslotIdToCheck], + }; + + let bookAppointmentResponse = await axios.post( + backend_address + "/api/appointment/book", + bookAppointmentData + ); + + if (bookAppointmentResponse.status === 200) { + appointmentDataToCheck = bookAppointmentResponse.data; + if ( + appointmentDataToCheck.appointmentType === + bookAppointmentData.appointmentType && + appointmentDataToCheck.customerId === bookAppointmentData.customerId + ) { + scoreCounter++; + } else { + console.log("Test booking an appointment unsuccessful:"); + console.log(`returned data is erronous: ${appointmentDataToCheck}`); + } + } else { + console.log("Test booking an appointment unsuccessful:"); + console.log( + `status code not as expected: ${bookAppointmentResponse.status}` + ); + } + } catch (error) { + console.log("Test booking an appointment unsuccessful:"); + console.log(error); + } + + // ========== getting all appointments ========== + + try { + let getAppointmentResponse = await axios.get( + backend_address + `/api/appointment/getall/${customerIdToCheck}` + ); + if ( + getAppointmentResponse.data.length === 1 && + getAppointmentResponse.status === 200 + ) + scoreCounter++; + else { + console.log("Test get all appointments unsuccessful:"); + if (getAppointmentResponse.length !== 1) + console.log( + `The number of appointment is wrong: ${getAppointmentResponse.data.length}` + ); + if (getAppointmentResponse.status !== 200) + console.log( + `status code not as expected: ${getAppointmentResponse.status}` + ); + } + } catch (error) { + console.log("Test get all appointments unsuccessful:"); + console.log(error); + } + + // ========== getting all appointments with an invalid id ========== + + try { + let getAppointmentResponse = await axios.get( + backend_address + `/api/appointment/getall/${-1}` + ); + } catch (error) { + if (error.response.status === 406) scoreCounter++; + else { + console.log("Test get all appointments with invalid id unsuccessful:"); + console.log(`${error}`); + } + } + + // ========== getting appointments in the next week ========== + + try { + let getNotificationsResponse = await axios.get( + backend_address + `/api/appointment/notifications/${customerIdToCheck}` + ); + if ( + getNotificationsResponse.data.length === 0 && + getNotificationsResponse.status === 200 + ) + scoreCounter++; + else { + console.log("Test get all appointments unsuccessful:"); + if (getNotificationsResponse.length !== 0) + console.log( + `The number of appointment is wrong: ${getNotificationsResponse.data.length}` + ); + if (getNotificationsResponse.status !== 200) + console.log( + `status code not as expected: ${getNotificationsResponse.status}` + ); + } + } catch (error) { + console.log("Test get all appointments unsuccessful:"); + console.log(error); + } + + // ========== getting all notifications with an invalid id ========== + + try { + let getAppointmentResponse = await axios.get( + backend_address + `/api/appointment/notifications/${-1}` + ); + } catch (error) { + if (error.response.status === 406) scoreCounter++; + else { + console.log("Test get all notifications with invalid id unsuccessful:"); + console.log(`${error}`); + } + } + + // ========== booking an appointment with invalid timeslot ========== + try { + let bookAppointmentData = { + appointmentType: "CarWash", + service: "Car wash", + note: "Hello world", + customerId: customerIdToCheck, + timeslotsId: [-1], + }; + + let bookAppointmentResponse = await axios.post( + backend_address + "/api/appointment/book", + bookAppointmentData + ); + if (bookAppointmentResponse.status === 200) { + console.log( + "Error: booking an appointment with an invalid timeslot should be impossible" + ); + } + } catch (e) { + scoreCounter++; + } + + // ========== booking an appointment with invalid customer ========== + try { + // create timeslot + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: createWorkspacePost.data.workspaceId, + techniciansId: [], + }; + + let createTimeslotPost = await axios.post( + backend_address + "/api/timeslot/create", + createTimeslotData + ); + + let bookAppointmentData = { + appointmentType: "CarWash", + service: "Car wash", + note: "Hello world", + customerId: -1, + timeslotsId: [createTimeslotPost.data.timeslotId], + }; + + let bookAppointmentResponse = await axios.post( + backend_address + "/api/appointment/book", + bookAppointmentData + ); + if (bookAppointmentResponse.status === 200) { + console.log( + "Error: booking an appointment with an invalid timeslot should be impossible" + ); + } + } catch (e) { + scoreCounter++; + } + + // ========== paying an appointment ========== + try { + if (appointmentDataToCheck.paymentStatus) { + console.log("Test paying an appointment unsuccessful:"); + console.log("Appointment is already payed"); + } else { + let paymentData = `appointmentId=${appointmentDataToCheck.appointmentId}`; + + let paymentResponse = await axios.put( + backend_address + "/api/appointment/pay", + paymentData + ); + + if ( + paymentResponse.status === 200 && + paymentResponse.data.paymentStatus + ) { + scoreCounter++; + } else { + console.log("Test paying an appointment FAILED: "); + if (paymentResponse.status !== 200) { + console.log("\tUnexpected status code returned"); + } else if (!paymentResponse.data.paymentStatus) { + console.log( + `\tAppointment was not payed returned ${paymentResponse}` + ); + } + } + } + } catch (error) { + console.log("Test paying an appointment unsuccessful:"); + console.log(error); + } + + // ========== compiling results ========== + if (scoreCounter === numberOfTests) + console.log("All the booking tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} booking tests were successful.` + ); + console.log(""); +}; + +const testRateAppointment = async () => { + const backend_address = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 4; + let customerIdToCheck = -1; + let appointmentIDToCheck = -1; + + let wipeDatabaseResponse = await axios.delete( + backend_address + "/api/database/wipe" + ); + + // ------------ Begin setting up state for test --------------- + //creating customer account + try { + let createCustomerData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let createCustomerPost = await axios.post( + backend_address + "/api/customer/create", + createCustomerData + ); + + if (createCustomerPost.status !== 200) { + throw "Error: Failed to create customer"; + } else { + customerIdToCheck = createCustomerPost.data.customerId; + } + } catch (error) { + console.log(error); + } + + //booking an appointment + + try { + let createWorkspaceData = "name=foo"; + + let createWorkspacePost = await axios.post( + backend_address + "/api/workspace/create", + createWorkspaceData + ); + + if (createWorkspacePost.status !== 200) { + throw "Error: Failed to create workspace"; + } + + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: createWorkspacePost.data.workspaceId, + techniciansId: [], + }; + + let createTimeslotPost = await axios.post( + backend_address + "/api/timeslot/create", + createTimeslotData + ); + + if (createTimeslotPost.status !== 200) { + throw "Error: Failed to create timeslot"; + } + + let createAppointmentData = { + appointmentType: "CarWash", + service: "beep", + note: "beep", + paid: "false", + customerId: customerIdToCheck, + timeslotsId: [createTimeslotPost.data.timeslotId], + }; + + let createAppointmentPost = await axios.post( + backend_address + "/api/appointment/book", + createAppointmentData + ); + + if (createAppointmentPost.status !== 200) + throw "Booking appointment failed"; + appointmentIDToCheck = createAppointmentPost.data.appointmentId; + } catch (error) { + console.log(error); + } + + // ------------ End setting up state for test --------------- + + // Rate appointment + try { + // give the appointment we just created a rating of 10 + let rateAppointmentData = `appointmentId=${appointmentIDToCheck}&rating=10`; + + let rateAppointmentResponse = await axios.put( + backend_address + "/api/appointment/rate", + rateAppointmentData + ); + + if ( + rateAppointmentResponse.status === 200 && + rateAppointmentResponse.data.rating === 10 + ) { + scoreCounter++; + } else { + console.log("Test FAILED: "); + if (rateAppointmentResponse.status !== 200) { + console.log("\tUnexpected status code returned"); + } else if (rateAppointmentResponse.data.rating !== 10) { + console.log( + `\tUnexpected rating returned ${rateAppointmentResponse.data.rating}` + ); + } + } + } catch (error) { + console.log(error); + } + + // -------------- Test Exceptions -------------------- + + // Rating appointment with invalid rating value + try { + // give the appointment we just created a rating of -1 + let rateAppointmentData = `appointmentId=${appointmentIDToCheck}&rating=-1`; + + let rateAppointmentResponse = await axios.put( + backend_address + "/api/appointment/rate", + rateAppointmentData + ); + + if (rateAppointmentResponse.status === 200) { + scoreCounter++; + console.log("Passed -1 rating test"); + } else { + console.log("Test FAILED:"); + console.log( + `\tRating an appointment with invalid rating should not return 200 : ${rateAppointmentResponse.data}` + ); + } + } catch (error) { + scoreCounter++; + } + + try { + // give the appointment we just created a rating of 100 + let rateAppointmentData = `appointmentId=${appointmentIDToCheck}&rating=100`; + + let rateAppointmentResponse = await axios.put( + backend_address + "/api/appointment/rate", + rateAppointmentData + ); + + if (rateAppointmentResponse.status === 200) { + console.log("Test FAILED:"); + console.log( + `\tRating an appointment with invalid rating should not return 200 : ${rateAppointmentResponse.data}` + ); + } + } catch (e) { + scoreCounter++; + } + + // Rate invalid appointment + try { + // give the appointment we just created a rating of 10 + let rateAppointmentData = `appointmentId=-1&rating=10`; + + let rateAppointmentResponse = await axios.put( + backend_address + "/api/appointment/rate", + rateAppointmentData + ); + + if (rateAppointmentResponse.status === 200) { + console.log("Test FAILED:"); + console.log( + `\tRating an invalid appointment should not return 200: ${rateAppointmentResponse.data}` + ); + } + } catch (error) { + scoreCounter++; + } + + //compiling results + if (scoreCounter === numberOfTests) + console.log("All the rate appointment tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} rate appointment tests were successful.` + ); + console.log(""); +}; + +const testModifyAppointment = async () => { + const backend_address = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 2; + let customerIdToCheck = -1; + let appointmentToModify = {}; + + let wipeDatabaseResponse = await axios.delete( + backend_address + "/api/database/wipe" + ); + + // ------------ Begin setting up state for test --------------- + //creating customer account + try { + let createCustomerData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let createCustomerPost = await axios.post( + backend_address + "/api/customer/create", + createCustomerData + ); + + if (createCustomerPost.status !== 200) { + throw "Error: Failed to create customer"; + } else { + customerIdToCheck = createCustomerPost.data.customerId; + } + } catch (error) { + console.log(error); + } + + //booking an appointment + + try { + let createWorkspaceData = "name=foo"; + + let createWorkspacePost = await axios.post( + backend_address + "/api/workspace/create", + createWorkspaceData + ); + + if (createWorkspacePost.status !== 200) { + throw "Error: Failed to create workspace"; + } + + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: createWorkspacePost.data.workspaceId, + techniciansId: [], + }; + + let createTimeslotPost = await axios.post( + backend_address + "/api/timeslot/create", + createTimeslotData + ); + + if (createTimeslotPost.status !== 200) { + throw "Error: Failed to create timeslot"; + } + + let createAppointmentData = { + appointmentType: "CarWash", + service: "beep", + note: "beep", + paid: "false", + customerId: customerIdToCheck, + timeslotsId: [createTimeslotPost.data.timeslotId], + }; + + let createAppointmentPost = await axios.post( + backend_address + "/api/appointment/book", + createAppointmentData + ); + + if (createAppointmentPost.status !== 200) + throw "Booking appointment failed"; + appointmentToModify = createAppointmentPost.data; + } catch (error) { + console.log(error); + } + + // ------------ End setting up state for test --------------- + + // Modify appointment + try { + // give the appointment we just created a rating of 10 + let modifyAppointmentData = appointmentToModify; + modifyAppointmentData.rating = 10; + modifyAppointmentData.note = "Modified appointment note"; + + let modifyAppointmentResponse = await axios.put( + backend_address + "/api/appointment/modifyAppointment", + modifyAppointmentData + ); + + if ( + modifyAppointmentResponse.status === 200 && + modifyAppointmentResponse.data.note === "Modified appointment note" + ) { + scoreCounter++; + } else { + console.log("Test FAILED: "); + if (modifyAppointmentResponse.status !== 200) { + console.log("\tUnexpected status code returned"); + } + console.log( + `\tUnexpected note returned ${modifyAppointmentResponse.data.note}` + ); + } + } catch (error) { + console.log(error); + } + + try { + let modifyAppointmentData = appointmentToModify; + modifyAppointmentData.rating = 5; + modifyAppointmentData.appointmentId = -1; + + let modifyAppointmentResponse = await axios.put( + backend_address + "/api/appointment/modifyAppointment", + modifyAppointmentData + ); + + if (modifyAppointmentResponse.status === 200) + console.log("Error: Modified an invalid appointment"); + } catch (error) { + scoreCounter++; + } + + //compiling results + if (scoreCounter === numberOfTests) + console.log("All the modify appointment tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} modify appointment tests were successful.` + ); + console.log(""); +}; + +export { + testAppointmentBookingAndPayment, + testRateAppointment, + testModifyAppointment, +}; diff --git a/SCRS-Backend/src/test/javascript/assistant.js b/SCRS-Backend/src/test/javascript/assistant.js new file mode 100644 index 0000000..0061b7d --- /dev/null +++ b/SCRS-Backend/src/test/javascript/assistant.js @@ -0,0 +1,210 @@ +import axios from "axios"; + +const testAssistant = async () => { + const backend_address = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 9; + let id = 0; + + //creating assistant account test 1 + try { + let sentData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.post( + backend_address + "/api/assistant/create", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + id = responseDataPost.assistantId; + if (responseDataPost.assistantName === sentData.name && statusCode === 200) + scoreCounter++; + else { + console.log("Test 1 unsuccessful:"); + if (responseDataPost.name === sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 1 unsuccessful:"); + console.log(`${error}`); + } + + //creating assistant account test 2 + try { + let sentData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.post( + backend_address + "/api/assistant/create", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost.assistantName !== sentData.name && statusCode === 208) + scoreCounter++; + else { + console.log("Test 2 unsuccessful:"); + if (responseDataPost.name !== sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 208) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 2 unsuccessful:"); + console.log(`${error}`); + } + + //creating assistant account test 3 + try { + let sentData = null; + + let postTest = await axios.post( + backend_address + "/api/assistant/create", + sentData + ); + } catch (error) { + if (error.response.status === 415) scoreCounter++; + else { + console.log("Test 3 unsuccessful:"); + console.log(`${error}`); + } + } + + //updating assistant account test 1 + try { + let sentData = { + scrsUserId: id, + name: "Bababoo", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.put( + backend_address + "/api/assistant/update", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost.assistantName === sentData.name && statusCode === 200) + scoreCounter++; + else { + console.log("Test 4 unsuccessful:"); + if (responseDataPost.name === sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 4 unsuccessful:"); + console.log(`${error}`); + } + + //updating assistant account test 2 + try { + let sentData = { + scrsUserId: 0, + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.put( + backend_address + "/api/assistant/update", + sentData + ); + } catch (error) { + if (error.response.status === 406) scoreCounter++; + else { + console.log("Test 6 unsuccessful:"); + console.log(`${error}`); + } + } + + //updating assistant account test 3 + try { + let sentData = null; + + let postTest = await axios.put( + backend_address + "/api/assistant/update", + sentData + ); + } catch (error) { + if (error.response.status === 415) scoreCounter++; + else { + console.log("Test 6 unsuccessful:"); + console.log(`${error}`); + } + } + + //deleting account test 1 + try { + let deleteTest = await axios.delete( + backend_address + `/api/assistant/delete/${id}` + ); + + let statusCode = deleteTest.status; + if (statusCode === 200) scoreCounter++; + else { + console.log("Test 7 unsuccessful:"); + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 7 unsuccessful:"); + console.log(`${error}`); + } + + //deleting account test 2 + try { + let deleteTest = await axios.delete( + backend_address + `/api/assistant/delete/${id}` + ); + } catch (error) { + if (error.response.status === 406) scoreCounter++; + else { + console.log("Test 8 unsuccessful:"); + console.log(`${error}`); + } + } + + //wiping the database + try { + let deleteTest = await axios.delete(backend_address + "/api/database/wipe"); + + let statusCode = deleteTest.status; + if (statusCode === 200) scoreCounter++; + else { + console.log("Test 9 unsuccessful:"); + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 9 unsuccessful:"); + console.log(`${error}`); + } + + //compiling results + if (scoreCounter === numberOfTests) + console.log("All the assistant tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} assistant tests were successful.` + ); + console.log(""); +}; + +export default testAssistant; diff --git a/SCRS-Backend/src/test/javascript/customer.js b/SCRS-Backend/src/test/javascript/customer.js new file mode 100644 index 0000000..1c9f026 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/customer.js @@ -0,0 +1,210 @@ +import axios from "axios"; + +const testCustomer = async () => { + const backend_address = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 9; + let id = 0; + + //creating customer account test 1 + try { + let sentData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.post( + backend_address + "/api/customer/create", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + id = responseDataPost.customerId; + if (responseDataPost.customerName === sentData.name && statusCode === 200) + scoreCounter++; + else { + console.log("Test 1 unsuccessful:"); + if (responseDataPost.name === sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 1 unsuccessful:"); + console.log(`${error}`); + } + + //creating customer account test 2 + try { + let sentData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.post( + backend_address + "/api/customer/create", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost.customerName !== sentData.name && statusCode === 208) + scoreCounter++; + else { + console.log("Test 2 unsuccessful:"); + if (responseDataPost.name !== sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 208) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 2 unsuccessful:"); + console.log(`${error}`); + } + + //creating customer account test 3 + try { + let sentData = null; + + let postTest = await axios.post( + backend_address + "/api/customer/create", + sentData + ); + } catch (error) { + if (error.response.status === 415) scoreCounter++; + else { + console.log("Test 3 unsuccessful:"); + console.log(`${error}`); + } + } + + //updating customer account test 1 + try { + let sentData = { + scrsUserId: id, + name: "Bababoo", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.put( + backend_address + "/api/customer/update", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost.customerName === sentData.name && statusCode === 200) + scoreCounter++; + else { + console.log("Test 4 unsuccessful:"); + if (responseDataPost.name === sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 4 unsuccessful:"); + console.log(`${error}`); + } + + //updating customer account test 2 + try { + let sentData = { + scrsUserId: 0, + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.put( + backend_address + "/api/customer/update", + sentData + ); + } catch (error) { + if (error.response.status === 406) scoreCounter++; + else { + console.log("Test 6 unsuccessful:"); + console.log(`${error}`); + } + } + + //updating customer account test 3 + try { + let sentData = null; + + let postTest = await axios.put( + backend_address + "/api/customer/update", + sentData + ); + } catch (error) { + if (error.response.status === 415) scoreCounter++; + else { + console.log("Test 6 unsuccessful:"); + console.log(`${error}`); + } + } + + //deleting account test 1 + try { + let deleteTest = await axios.delete( + backend_address + `/api/customer/delete/${id}` + ); + + let statusCode = deleteTest.status; + if (statusCode === 200) scoreCounter++; + else { + console.log("Test 7 unsuccessful:"); + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 7 unsuccessful:"); + console.log(`${error}`); + } + + //deleting account test 2 + try { + let deleteTest = await axios.delete( + backend_address + `/api/customer/delete/${id}` + ); + } catch (error) { + if (error.response.status === 406) scoreCounter++; + else { + console.log("Test 8 unsuccessful:"); + console.log(`${error}`); + } + } + + //wiping the database + try { + let deleteTest = await axios.delete(backend_address + "/api/database/wipe"); + + let statusCode = deleteTest.status; + if (statusCode === 200) scoreCounter++; + else { + console.log("Test 9 unsuccessful:"); + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 9 unsuccessful:"); + console.log(`${error}`); + } + + //compiling results + if (scoreCounter === numberOfTests) + console.log("All the customer tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} customer tests were successful.` + ); + console.log(""); +}; + +export default testCustomer; diff --git a/SCRS-Backend/src/test/javascript/login.js b/SCRS-Backend/src/test/javascript/login.js new file mode 100644 index 0000000..9fe21ad --- /dev/null +++ b/SCRS-Backend/src/test/javascript/login.js @@ -0,0 +1,277 @@ +import axios from "axios"; + +const testLogin = async () => { + const backend_address = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 11; + + //wiping the database + try { + let deleteTest = await axios.delete(backend_address + "/api/database/wipe"); + + let statusCode = deleteTest.status; + if (statusCode === 200) scoreCounter++; + else { + console.log("Test 1 unsuccessful:"); + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 1 unsuccessful:"); + console.log(`${error}`); + } + + //testing customer login with non-existing account + try { + let sentData = "email=babaooey@gmail.com&password=got bababooied"; + + let postTest = await axios.post( + backend_address + "/api/login/customer", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost === false && statusCode === 200) scoreCounter++; + else { + console.log("Test 2 unsuccessful:"); + if (responseDataPost !== false) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 2 unsuccessful:"); + console.log(`${error}`); + } + + //creating customer account + try { + let sentData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.post( + backend_address + "/api/customer/create", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost.customerName === sentData.name && statusCode === 200) + scoreCounter++; + else { + console.log("Test 3 unsuccessful:"); + if (responseDataPost.name === sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 3 unsuccessful:"); + console.log(`${error}`); + } + + //creating assistant account + try { + let sentData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.post( + backend_address + "/api/assistant/create", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost.assistantName === sentData.name && statusCode === 200) + scoreCounter++; + else { + console.log("Test 4 unsuccessful:"); + if (responseDataPost.name === sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 4 unsuccessful:"); + console.log(`${error}`); + } + + //testing assistant login + try { + let sentData = "email=babaooey@gmail.com&password=got bababooied"; + + let postTest = await axios.post( + backend_address + "/api/login/assistant", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost === true && statusCode === 200) scoreCounter++; + else { + console.log("Test 5 unsuccessful:"); + if (responseDataPost !== true) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 5 unsuccessful:"); + console.log(`${error}`); + } + + //creating technician account + try { + let sentData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.post( + backend_address + "/api/technician/create", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost.technicianName === sentData.name && statusCode === 200) + scoreCounter++; + else { + console.log("Test 6 unsuccessful:"); + if (responseDataPost.name === sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 6 unsuccessful:"); + console.log(`${error}`); + } + + //testing customer login + try { + let sentData = "email=babaooey@gmail.com&password=got bababooied"; + + let postTest = await axios.post( + backend_address + "/api/login/customer", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost === true && statusCode === 200) scoreCounter++; + else { + console.log("Test 7 unsuccessful:"); + if (responseDataPost !== true) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 7 unsuccessful:"); + console.log(`${error}`); + } + + //testing technician login + try { + let sentData = "email=babaooey@gmail.com&password=got bababooied"; + + let postTest = await axios.post( + backend_address + "/api/login/technician", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost === true && statusCode === 200) scoreCounter++; + else { + console.log("Test 8 unsuccessful:"); + if (responseDataPost !== true) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 8 unsuccessful:"); + console.log(`${error}`); + } + + //testing customer login with wrong password + try { + let sentData = "email=babaooey@gmail.com&password=got rick rolled"; + + let postTest = await axios.post( + backend_address + "/api/login/customer", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost === false && statusCode === 200) scoreCounter++; + else { + console.log("Test 9 unsuccessful:"); + if (responseDataPost !== false) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 9 unsuccessful:"); + console.log(`${error}`); + } + + //testing customer login with wrong password + try { + let postTest = await axios.get(backend_address + "/api/login/logout"); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost === true && statusCode === 200) scoreCounter++; + else { + console.log("Test 10 unsuccessful:"); + if (responseDataPost !== false) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 10 unsuccessful:"); + console.log(`${error}`); + } + + //wiping the database + try { + let deleteTest = await axios.delete(backend_address + "/api/database/wipe"); + + let statusCode = deleteTest.status; + if (statusCode === 200) scoreCounter++; + else { + console.log("Test 11 unsuccessful:"); + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 11 unsuccessful:"); + console.log(`${error}`); + } + + //compiling results + if (scoreCounter === numberOfTests) + console.log("All the login tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} login tests were successful.` + ); + console.log(""); +}; + +export default testLogin; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/CHANGELOG.md b/SCRS-Backend/src/test/javascript/node_modules/axios/CHANGELOG.md new file mode 100644 index 0000000..6f11ac1 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/CHANGELOG.md @@ -0,0 +1,685 @@ +# Changelog + +### 0.21.1 (December 21, 2020) + +Fixes and Functionality: + +- Hotfix: Prevent SSRF (#3410) +- Protocol not parsed when setting proxy config from env vars (#3070) +- Updating axios in types to be lower case (#2797) +- Adding a type guard for `AxiosError` (#2949) + +Internal and Tests: + +- Remove the skipping of the `socket` http test (#3364) +- Use different socket for Win32 test (#3375) + +Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: + +- Daniel Lopretto +- Jason Kwok +- Jay +- Jonathan Foster +- Remco Haszing +- Xianming Zhong + +### 0.21.0 (October 23, 2020) + +Fixes and Functionality: + +- Fixing requestHeaders.Authorization ([#3287](https://github.com/axios/axios/pull/3287)) +- Fixing node types ([#3237](https://github.com/axios/axios/pull/3237)) +- Fixing axios.delete ignores config.data ([#3282](https://github.com/axios/axios/pull/3282)) +- Revert "Fixing overwrite Blob/File type as Content-Type in browser. (#1773)" ([#3289](https://github.com/axios/axios/pull/3289)) +- Fixing an issue that type 'null' and 'undefined' is not assignable to validateStatus when typescript strict option is enabled ([#3200](https://github.com/axios/axios/pull/3200)) + +Internal and Tests: + +- Lock travis to not use node v15 ([#3361](https://github.com/axios/axios/pull/3361)) + +Documentation: + +- Fixing simple typo, existant -> existent ([#3252](https://github.com/axios/axios/pull/3252)) +- Fixing typos ([#3309](https://github.com/axios/axios/pull/3309)) + +Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: + +- Allan Cruz <57270969+Allanbcruz@users.noreply.github.com> +- George Cheng +- Jay +- Kevin Kirsche +- Remco Haszing +- Taemin Shin +- Tim Gates +- Xianming Zhong + +### 0.20.0 (August 20, 2020) + +Release of 0.20.0-pre as a full release with no other changes. + +### 0.20.0-pre (July 15, 2020) + +Fixes and Functionality: + +- Fixing response with utf-8 BOM can not parse to json ([#2419](https://github.com/axios/axios/pull/2419)) + - fix: remove byte order marker (UTF-8 BOM) when transform response + - fix: remove BOM only utf-8 + - test: utf-8 BOM + - fix: incorrect param name +- Refactor mergeConfig without utils.deepMerge ([#2844](https://github.com/axios/axios/pull/2844)) + - Adding failing test + - Fixing #2587 default custom config persisting + - Adding Concat keys and filter duplicates + - Fixed value from CPE + - update for review feedbacks + - no deepMerge + - only merge between plain objects + - fix rename + - always merge config by mergeConfig + - extract function mergeDeepProperties + - refactor mergeConfig with all keys, and add special logic for validateStatus + - add test for resetting headers + - add lots of tests and fix a bug + - should not inherit `data` + - use simple toString +- Fixing overwrite Blob/File type as Content-Type in browser. ([#1773](https://github.com/axios/axios/pull/1773)) +- Fixing an issue that type 'null' is not assignable to validateStatus ([#2773](https://github.com/axios/axios/pull/2773)) +- Fixing special char encoding ([#1671](https://github.com/axios/axios/pull/1671)) + - removing @ character from replacement list since it is a reserved character + - Updating buildURL test to not include the @ character + - Removing console logs +- Fixing password encoding with special characters in basic authentication ([#1492](https://github.com/axios/axios/pull/1492)) + - Fixing password encoding with special characters in basic authentication + - Adding test to check if password with non-Latin1 characters pass +- Fixing 'Network Error' in react native android ([#1487](https://github.com/axios/axios/pull/1487)) + There is a bug in react native Android platform when using get method. It will trigger a 'Network Error' when passing the requestData which is an empty string to request.send function. So if the requestData is an empty string we can set it to null as well to fix the bug. +- Fixing Cookie Helper with Asyc Components ([#1105](https://github.com/axios/axios/pull/1105)) ([#1107](https://github.com/axios/axios/pull/1107)) +- Fixing 'progressEvent' type ([#2851](https://github.com/axios/axios/pull/2851)) + - Fix 'progressEvent' type + - Update axios.ts +- Fixing getting local files (file://) failed ([#2470](https://github.com/axios/axios/pull/2470)) + - fix issue #2416, #2396 + - fix Eslint warn + - Modify judgment conditions + - add unit test + - update unit test + - update unit test +- Allow PURGE method in typings ([#2191](https://github.com/axios/axios/pull/2191)) +- Adding option to disable automatic decompression ([#2661](https://github.com/axios/axios/pull/2661)) + - Adding ability to disable auto decompression + - Updating decompress documentation in README + - Fixing test\unit\adapters\http.js lint errors + - Adding test for disabling auto decompression + - Removing changes that fixed lint errors in tests + - Removing formatting change to unit test +- Add independent `maxBodyLength` option ([#2781](https://github.com/axios/axios/pull/2781)) + - Add independent option to set the maximum size of the request body + - Remove maxBodyLength check + - Update README + - Assert for error code and message +- Adding responseEncoding to mergeConfig ([#1745](https://github.com/axios/axios/pull/1745)) +- Compatible with follow-redirect aborts the request ([#2689](https://github.com/axios/axios/pull/2689)) + - Compatible with follow-redirect aborts the request + - Use the error code +- Fix merging of params ([#2656](https://github.com/axios/axios/pull/2656)) + - Name function to avoid ESLint func-names warning + - Switch params config to merge list and update tests + - Restore testing of both false and null + - Restore test cases for keys without defaults + - Include test for non-object values that aren't false-y. +- Revert `finally` as `then` ([#2683](https://github.com/axios/axios/pull/2683)) + +Internal and Tests: + +- Fix stale bot config ([#3049](https://github.com/axios/axios/pull/3049)) + - fix stale bot config + - fix multiple lines +- Add days and change name to work ([#3035](https://github.com/axios/axios/pull/3035)) +- Update close-issues.yml ([#3031](https://github.com/axios/axios/pull/3031)) + - Update close-issues.yml + Update close message to read better 😄 + - Fix use of quotations + Use single quotes as per other .yml files + - Remove user name form message +- Add GitHub actions to close stale issues/prs ([#3029](https://github.com/axios/axios/pull/3029)) + - prepare stale actions + - update messages + - Add exempt labels and lighten up comments +- Add GitHub actions to close invalid issues ([#3022](https://github.com/axios/axios/pull/3022)) + - add close actions + - fix with checkout + - update issue templates + - add reminder + - update close message +- Add test with Node.js 12 ([#2860](https://github.com/axios/axios/pull/2860)) + - test with Node.js 12 + - test with latest +- Adding console log on sandbox server startup ([#2210](https://github.com/axios/axios/pull/2210)) + - Adding console log on sandbox server startup + - Update server.js + Add server error handling + - Update server.js + Better error message, remove retry. +- Adding tests for method `options` type definitions ([#1996](https://github.com/axios/axios/pull/1996)) + Update tests. +- Add test for redirecting with too large response ([#2695](https://github.com/axios/axios/pull/2695)) +- Fixing unit test failure in Windows OS ([#2601](https://github.com/axios/axios/pull/2601)) +- Fixing issue for HEAD method and gzipped response ([#2666](https://github.com/axios/axios/pull/2666)) +- Fix tests in browsers ([#2748](https://github.com/axios/axios/pull/2748)) +- chore: add `jsdelivr` and `unpkg` support ([#2443](https://github.com/axios/axios/pull/2443)) + +Documentation: + +- Adding support for URLSearchParams in node ([#1900](https://github.com/axios/axios/pull/1900)) + - Adding support for URLSearchParams in node + - Remove un-needed code + - Update utils.js + - Make changes as suggested +- Adding table of content (preview) ([#3050](https://github.com/axios/axios/pull/3050)) + - add toc (preview) + - remove toc in toc + Signed-off-by: Moni + - fix sublinks + - fix indentation + - remove redundant table links + - update caps and indent + - remove axios +- Replace 'blacklist' with 'blocklist' ([#3006](https://github.com/axios/axios/pull/3006)) +- docs(): Detailed config options environment. ([#2088](https://github.com/axios/axios/pull/2088)) + - docs(): Detailed config options environment. + - Update README.md +- Include axios-data-unpacker in ECOSYSTEM.md ([#2080](https://github.com/axios/axios/pull/2080)) +- Allow opening examples in Gitpod ([#1958](https://github.com/axios/axios/pull/1958)) +- Remove axios.all() and axios.spread() from Readme.md ([#2727](https://github.com/axios/axios/pull/2727)) + - remove axios.all(), axios.spread() + - replace example + - axios.all() -> Promise.all() + - axios.spread(function (acct, perms)) -> function (acct, perms) + - add deprecated mark +- Update README.md ([#2887](https://github.com/axios/axios/pull/2887)) + Small change to the data attribute doc of the config. A request body can also be set for DELETE methods but this wasn't mentioned in the documentation (it only mentioned POST, PUT and PATCH). Took my some 10-20 minutes until I realized that I don't need to manipulate the request body with transformRequest in the case of DELETE. +- Include swagger-taxos-codegen in ECOSYSTEM.md ([#2162](https://github.com/axios/axios/pull/2162)) +- Add CDNJS version badge in README.md ([#878](https://github.com/axios/axios/pull/878)) + This badge will show the version on CDNJS! +- Documentation update to clear up ambiguity in code examples ([#2928](https://github.com/axios/axios/pull/2928)) + - Made an adjustment to the documentation to clear up any ambiguity around the use of "fs". This should help clear up that the code examples with "fs" cannot be used on the client side. +- Update README.md about validateStatus ([#2912](https://github.com/axios/axios/pull/2912)) + Rewrote the comment from "Reject only if the status code is greater than or equal to 500" to "Resolve only if the status code is less than 500" +- Updating documentation for usage form-data ([#2805](https://github.com/axios/axios/pull/2805)) + Closes #2049 +- Fixing CHANGELOG.md issue link ([#2784](https://github.com/axios/axios/pull/2784)) +- Include axios-hooks in ECOSYSTEM.md ([#2003](https://github.com/axios/axios/pull/2003)) +- Added Response header access instructions ([#1901](https://github.com/axios/axios/pull/1901)) + - Added Response header access instructions + - Added note about using bracket notation +- Add `onUploadProgress` and `onDownloadProgress` are browser only ([#2763](https://github.com/axios/axios/pull/2763)) + Saw in #928 and #1966 that `onUploadProgress` and `onDownloadProgress` only work in the browser and was missing that from the README. +- Update ' sign to ` in proxy spec ([#2778](https://github.com/axios/axios/pull/2778)) +- Adding jsDelivr link in README ([#1110](https://github.com/axios/axios/pull/1110)) + - Adding jsDelivr link + - Add SRI + - Remove SRI + +Huge thanks to everyone who contributed to this release via code (authors listed +below) or via reviews and triaging on GitHub: + +- Alan Wang +- Alexandru Ungureanu +- Anubhav Srivastava +- Benny Neugebauer +- Cr <631807682@qq.com> +- David +- David Ko +- David Tanner +- Emily Morehouse +- Felipe Martins +- Fonger <5862369+Fonger@users.noreply.github.com> +- Frostack +- George Cheng +- grumblerchester +- Gustavo López +- hexaez <45806662+hexaez@users.noreply.github.com> +- huangzuizui +- Ian Wijma +- Jay +- jeffjing +- jennynju <46782518+jennynju@users.noreply.github.com> +- Jimmy Liao <52391190+jimmy-liao-gogoro@users.noreply.github.com> +- Jonathan Sharpe +- JounQin +- Justin Beckwith +- Kamil Posiadała <3dcreator.pl@gmail.com> +- Lukas Drgon +- marcinx +- Martti Laine +- Michał Zarach +- Moni +- Motonori Iwata <121048+iwata@users.noreply.github.com> +- Nikita Galkin +- Petr Mares +- Philippe Recto +- Remco Haszing +- rockcs1992 +- Ryan Bown +- Samina Fu +- Simone Busoli +- Spencer von der Ohe +- Sven Efftinge +- Taegyeoung Oh +- Taemin Shin +- Thibault Ehrhart <1208424+ehrhart@users.noreply.github.com> +- Xianming Zhong +- Yasu Flores +- Zac Delventhal + +### 0.19.2 (Jan 20, 2020) + +- Remove unnecessary XSS check ([#2679](https://github.com/axios/axios/pull/2679)) (see ([#2646](https://github.com/axios/axios/issues/2646)) for discussion) + +### 0.19.1 (Jan 7, 2020) + +Fixes and Functionality: + +- Fixing invalid agent issue ([#1904](https://github.com/axios/axios/pull/1904)) +- Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582)) +- Delete useless default to hash ([#2458](https://github.com/axios/axios/pull/2458)) +- Fix HTTP/HTTPs agents passing to follow-redirect ([#1904](https://github.com/axios/axios/pull/1904)) +- Fix ignore set withCredentials false ([#2582](https://github.com/axios/axios/pull/2582)) +- Fix CI build failure ([#2570](https://github.com/axios/axios/pull/2570)) +- Remove dependency on is-buffer from package.json ([#1816](https://github.com/axios/axios/pull/1816)) +- Adding options typings ([#2341](https://github.com/axios/axios/pull/2341)) +- Adding Typescript HTTP method definition for LINK and UNLINK. ([#2444](https://github.com/axios/axios/pull/2444)) +- Update dist with newest changes, fixes Custom Attributes issue +- Change syntax to see if build passes ([#2488](https://github.com/axios/axios/pull/2488)) +- Update Webpack + deps, remove now unnecessary polyfills ([#2410](https://github.com/axios/axios/pull/2410)) +- Fix to prevent XSS, throw an error when the URL contains a JS script ([#2464](https://github.com/axios/axios/pull/2464)) +- Add custom timeout error copy in config ([#2275](https://github.com/axios/axios/pull/2275)) +- Add error toJSON example ([#2466](https://github.com/axios/axios/pull/2466)) +- Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… ([#2451](https://github.com/axios/axios/pull/2451)) +- Fixing subdomain handling on no_proxy ([#2442](https://github.com/axios/axios/pull/2442)) +- Make redirection from HTTP to HTTPS work ([#2426](https://github.com/axios/axios/pull/2426)) and ([#2547](https://github.com/axios/axios/pull/2547)) +- Add toJSON property to AxiosError type ([#2427](https://github.com/axios/axios/pull/2427)) +- Fixing socket hang up error on node side for slow response. ([#1752](https://github.com/axios/axios/pull/1752)) +- Alternative syntax to send data into the body ([#2317](https://github.com/axios/axios/pull/2317)) +- Fixing custom config options ([#2207](https://github.com/axios/axios/pull/2207)) +- Fixing set `config.method` after mergeConfig for Axios.prototype.request ([#2383](https://github.com/axios/axios/pull/2383)) +- Axios create url bug ([#2290](https://github.com/axios/axios/pull/2290)) +- Do not modify config.url when using a relative baseURL (resolves [#1628](https://github.com/axios/axios/issues/1098)) ([#2391](https://github.com/axios/axios/pull/2391)) +- Add typescript HTTP method definition for LINK and UNLINK ([#2444](https://github.com/axios/axios/pull/2444)) + +Internal: + +- Revert "Update Webpack + deps, remove now unnecessary polyfills" ([#2479](https://github.com/axios/axios/pull/2479)) +- Order of if/else blocks is causing unit tests mocking XHR. ([#2201](https://github.com/axios/axios/pull/2201)) +- Add license badge ([#2446](https://github.com/axios/axios/pull/2446)) +- Fix travis CI build [#2386](https://github.com/axios/axios/pull/2386) +- Fix cancellation error on build master. #2290 #2207 ([#2407](https://github.com/axios/axios/pull/2407)) + +Documentation: + +- Fixing typo in CHANGELOG.md: s/Functionallity/Functionality ([#2639](https://github.com/axios/axios/pull/2639)) +- Fix badge, use master branch ([#2538](https://github.com/axios/axios/pull/2538)) +- Fix typo in changelog [#2193](https://github.com/axios/axios/pull/2193) +- Document fix ([#2514](https://github.com/axios/axios/pull/2514)) +- Update docs with no_proxy change, issue #2484 ([#2513](https://github.com/axios/axios/pull/2513)) +- Fixing missing words in docs template ([#2259](https://github.com/axios/axios/pull/2259)) +- 🐛Fix request finally documentation in README ([#2189](https://github.com/axios/axios/pull/2189)) +- updating spelling and adding link to docs ([#2212](https://github.com/axios/axios/pull/2212)) +- docs: minor tweak ([#2404](https://github.com/axios/axios/pull/2404)) +- Update response interceptor docs ([#2399](https://github.com/axios/axios/pull/2399)) +- Update README.md ([#2504](https://github.com/axios/axios/pull/2504)) +- Fix word 'sintaxe' to 'syntax' in README.md ([#2432](https://github.com/axios/axios/pull/2432)) +- updating README: notes on CommonJS autocomplete ([#2256](https://github.com/axios/axios/pull/2256)) +- Fix grammar in README.md ([#2271](https://github.com/axios/axios/pull/2271)) +- Doc fixes, minor examples cleanup ([#2198](https://github.com/axios/axios/pull/2198)) + +### 0.19.0 (May 30, 2019) + +Fixes and Functionality: + +- Added support for no_proxy env variable ([#1693](https://github.com/axios/axios/pull/1693/files)) - Chance Dickson +- Unzip response body only for statuses != 204 ([#1129](https://github.com/axios/axios/pull/1129)) - drawski +- Destroy stream on exceeding maxContentLength (fixes [#1098](https://github.com/axios/axios/issues/1098)) ([#1485](https://github.com/axios/axios/pull/1485)) - Gadzhi Gadzhiev +- Makes Axios error generic to use AxiosResponse ([#1738](https://github.com/axios/axios/pull/1738)) - Suman Lama +- Fixing Mocha tests by locking follow-redirects version to 1.5.10 ([#1993](https://github.com/axios/axios/pull/1993)) - grumblerchester +- Allow uppercase methods in typings. ([#1781](https://github.com/axios/axios/pull/1781)) - Ken Powers +- Fixing building url with hash mark ([#1771](https://github.com/axios/axios/pull/1771)) - Anatoly Ryabov +- This commit fix building url with hash map (fragment identifier) when parameters are present: they must not be added after `#`, because client cut everything after `#` +- Preserve HTTP method when following redirect ([#1758](https://github.com/axios/axios/pull/1758)) - Rikki Gibson +- Add `getUri` signature to TypeScript definition. ([#1736](https://github.com/axios/axios/pull/1736)) - Alexander Trauzzi +- Adding isAxiosError flag to errors thrown by axios ([#1419](https://github.com/axios/axios/pull/1419)) - Ayush Gupta + +Internal: + +- Fixing .eslintrc without extension ([#1789](https://github.com/axios/axios/pull/1789)) - Manoel +- Fix failing SauceLabs tests by updating configuration - Emily Morehouse +- Add issue templates - Emily Morehouse + +Documentation: + +- Consistent coding style in README ([#1787](https://github.com/axios/axios/pull/1787)) - Ali Servet Donmez +- Add information about auth parameter to README ([#2166](https://github.com/axios/axios/pull/2166)) - xlaguna +- Add DELETE to list of methods that allow data as a config option ([#2169](https://github.com/axios/axios/pull/2169)) - Daniela Borges Matos de Carvalho +- Update ECOSYSTEM.md - Add Axios Endpoints ([#2176](https://github.com/axios/axios/pull/2176)) - Renan +- Add r2curl in ECOSYSTEM ([#2141](https://github.com/axios/axios/pull/2141)) - 유용우 / CX +- Update README.md - Add instructions for installing with yarn ([#2036](https://github.com/axios/axios/pull/2036)) - Victor Hermes +- Fixing spacing for README.md ([#2066](https://github.com/axios/axios/pull/2066)) - Josh McCarty +- Update README.md. - Change `.then` to `.finally` in example code ([#2090](https://github.com/axios/axios/pull/2090)) - Omar Cai +- Clarify what values responseType can have in Node ([#2121](https://github.com/axios/axios/pull/2121)) - Tyler Breisacher +- docs(ECOSYSTEM): add axios-api-versioning ([#2020](https://github.com/axios/axios/pull/2020)) - Weffe +- It seems that `responseType: 'blob'` doesn't actually work in Node (when I tried using it, response.data was a string, not a Blob, since Node doesn't have Blobs), so this clarifies that this option should only be used in the browser +- Update README.md. - Add Querystring library note ([#1896](https://github.com/axios/axios/pull/1896)) - Dmitriy Eroshenko +- Add react-hooks-axios to Libraries section of ECOSYSTEM.md ([#1925](https://github.com/axios/axios/pull/1925)) - Cody Chan +- Clarify in README that default timeout is 0 (no timeout) ([#1750](https://github.com/axios/axios/pull/1750)) - Ben Standefer + +### 0.19.0-beta.1 (Aug 9, 2018) + +**NOTE:** This is a beta version of this release. There may be functionality that is broken in +certain browsers, though we suspect that builds are hanging and not erroring. See +https://saucelabs.com/u/axios for the most up-to-date information. + +New Functionality: + +- Add getUri method ([#1712](https://github.com/axios/axios/issues/1712)) +- Add support for no_proxy env variable ([#1693](https://github.com/axios/axios/issues/1693)) +- Add toJSON to decorated Axios errors to facilitate serialization ([#1625](https://github.com/axios/axios/issues/1625)) +- Add second then on axios call ([#1623](https://github.com/axios/axios/issues/1623)) +- Typings: allow custom return types +- Add option to specify character set in responses (with http adapter) + +Fixes: + +- Fix Keep defaults local to instance ([#385](https://github.com/axios/axios/issues/385)) +- Correctly catch exception in http test ([#1475](https://github.com/axios/axios/issues/1475)) +- Fix accept header normalization ([#1698](https://github.com/axios/axios/issues/1698)) +- Fix http adapter to allow HTTPS connections via HTTP ([#959](https://github.com/axios/axios/issues/959)) +- Fix Removes usage of deprecated Buffer constructor. ([#1555](https://github.com/axios/axios/issues/1555), [#1622](https://github.com/axios/axios/issues/1622)) +- Fix defaults to use httpAdapter if available ([#1285](https://github.com/axios/axios/issues/1285)) + - Fixing defaults to use httpAdapter if available + - Use a safer, cross-platform method to detect the Node environment +- Fix Reject promise if request is cancelled by the browser ([#537](https://github.com/axios/axios/issues/537)) +- [Typescript] Fix missing type parameters on delete/head methods +- [NS]: Send `false` flag isStandardBrowserEnv for Nativescript +- Fix missing type parameters on delete/head +- Fix Default method for an instance always overwritten by get +- Fix type error when socketPath option in AxiosRequestConfig +- Capture errors on request data streams +- Decorate resolve and reject to clear timeout in all cases + +Huge thanks to everyone who contributed to this release via code (authors listed +below) or via reviews and triaging on GitHub: + +- Andrew Scott +- Anthony Gauthier +- arpit +- ascott18 +- Benedikt Rötsch +- Chance Dickson +- Dave Stewart +- Deric Cain +- Guillaume Briday +- Jacob Wejendorp +- Jim Lynch +- johntron +- Justin Beckwith +- Justin Beckwith +- Khaled Garbaya +- Lim Jing Rong +- Mark van den Broek +- Martti Laine +- mattridley +- mattridley +- Nicolas Del Valle +- Nilegfx +- pbarbiero +- Rikki Gibson +- Sako Hartounian +- Shane Fitzpatrick +- Stephan Schneider +- Steven +- Tim Garthwaite +- Tim Johns +- Yutaro Miyazaki + +### 0.18.0 (Feb 19, 2018) + +- Adding support for UNIX Sockets when running with Node.js ([#1070](https://github.com/axios/axios/pull/1070)) +- Fixing typings ([#1177](https://github.com/axios/axios/pull/1177)): + - AxiosRequestConfig.proxy: allows type false + - AxiosProxyConfig: added auth field +- Adding function signature in AxiosInstance interface so AxiosInstance can be invoked ([#1192](https://github.com/axios/axios/pull/1192), [#1254](https://github.com/axios/axios/pull/1254)) +- Allowing maxContentLength to pass through to redirected calls as maxBodyLength in follow-redirects config ([#1287](https://github.com/axios/axios/pull/1287)) +- Fixing configuration when using an instance - method can now be set ([#1342](https://github.com/axios/axios/pull/1342)) + +### 0.17.1 (Nov 11, 2017) + +- Fixing issue with web workers ([#1160](https://github.com/axios/axios/pull/1160)) +- Allowing overriding transport ([#1080](https://github.com/axios/axios/pull/1080)) +- Updating TypeScript typings ([#1165](https://github.com/axios/axios/pull/1165), [#1125](https://github.com/axios/axios/pull/1125), [#1131](https://github.com/axios/axios/pull/1131)) + +### 0.17.0 (Oct 21, 2017) + +- **BREAKING** Fixing issue with `baseURL` and interceptors ([#950](https://github.com/axios/axios/pull/950)) +- **BREAKING** Improving handing of duplicate headers ([#874](https://github.com/axios/axios/pull/874)) +- Adding support for disabling proxies ([#691](https://github.com/axios/axios/pull/691)) +- Updating TypeScript typings with generic type parameters ([#1061](https://github.com/axios/axios/pull/1061)) + +### 0.16.2 (Jun 3, 2017) + +- Fixing issue with including `buffer` in bundle ([#887](https://github.com/axios/axios/pull/887)) +- Including underlying request in errors ([#830](https://github.com/axios/axios/pull/830)) +- Convert `method` to lowercase ([#930](https://github.com/axios/axios/pull/930)) + +### 0.16.1 (Apr 8, 2017) + +- Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/axios/axios/pull/828)) +- Updating `follow-redirects` dependency ([#829](https://github.com/axios/axios/pull/829)) +- Adding support for passing `Buffer` in node ([#773](https://github.com/axios/axios/pull/773)) + +### 0.16.0 (Mar 31, 2017) + +- **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/axios/axios/issues/480)) +- Adding `options` shortcut method ([#461](https://github.com/axios/axios/pull/461)) +- Fixing issue with using `responseType: 'json'` in browsers incompatible with XHR Level 2 ([#654](https://github.com/axios/axios/pull/654)) +- Improving React Native detection ([#731](https://github.com/axios/axios/pull/731)) +- Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/axios/axios/pull/581)) +- Removing `PROTECTION_PREFIX` support ([#561](https://github.com/axios/axios/pull/561)) + +### 0.15.3 (Nov 27, 2016) + +- Fixing issue with custom instances and global defaults ([#443](https://github.com/axios/axios/issues/443)) +- Renaming `axios.d.ts` to `index.d.ts` ([#519](https://github.com/axios/axios/issues/519)) +- Adding `get`, `head`, and `delete` to `defaults.headers` ([#509](https://github.com/axios/axios/issues/509)) +- Fixing issue with `btoa` and IE ([#507](https://github.com/axios/axios/issues/507)) +- Adding support for proxy authentication ([#483](https://github.com/axios/axios/pull/483)) +- Improving HTTP adapter to use `http` protocol by default ([#493](https://github.com/axios/axios/pull/493)) +- Fixing proxy issues ([#491](https://github.com/axios/axios/pull/491)) + +### 0.15.2 (Oct 17, 2016) + +- Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/axios/axios/issues/482)) + +### 0.15.1 (Oct 14, 2016) + +- Fixing issue with UMD ([#485](https://github.com/axios/axios/issues/485)) + +### 0.15.0 (Oct 10, 2016) + +- Adding cancellation support ([#452](https://github.com/axios/axios/pull/452)) +- Moving default adapter to global defaults ([#437](https://github.com/axios/axios/pull/437)) +- Fixing issue with `file` URI scheme ([#440](https://github.com/axios/axios/pull/440)) +- Fixing issue with `params` objects that have no prototype ([#445](https://github.com/axios/axios/pull/445)) + +### 0.14.0 (Aug 27, 2016) + +- **BREAKING** Updating TypeScript definitions ([#419](https://github.com/axios/axios/pull/419)) +- **BREAKING** Replacing `agent` option with `httpAgent` and `httpsAgent` ([#387](https://github.com/axios/axios/pull/387)) +- **BREAKING** Splitting `progress` event handlers into `onUploadProgress` and `onDownloadProgress` ([#423](https://github.com/axios/axios/pull/423)) +- Adding support for `http_proxy` and `https_proxy` environment variables ([#366](https://github.com/axios/axios/pull/366)) +- Fixing issue with `auth` config option and `Authorization` header ([#397](https://github.com/axios/axios/pull/397)) +- Don't set XSRF header if `xsrfCookieName` is `null` ([#406](https://github.com/axios/axios/pull/406)) + +### 0.13.1 (Jul 16, 2016) + +- Fixing issue with response data not being transformed on error ([#378](https://github.com/axios/axios/issues/378)) + +### 0.13.0 (Jul 13, 2016) + +- **BREAKING** Improved error handling ([#345](https://github.com/axios/axios/pull/345)) +- **BREAKING** Response transformer now invoked in dispatcher not adapter ([10eb238](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)) +- **BREAKING** Request adapters now return a `Promise` ([157efd5](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)) +- Fixing issue with `withCredentials` not being overwritten ([#343](https://github.com/axios/axios/issues/343)) +- Fixing regression with request transformer being called before request interceptor ([#352](https://github.com/axios/axios/issues/352)) +- Fixing custom instance defaults ([#341](https://github.com/axios/axios/issues/341)) +- Fixing instances created from `axios.create` to have same API as default axios ([#217](https://github.com/axios/axios/issues/217)) + +### 0.12.0 (May 31, 2016) + +- Adding support for `URLSearchParams` ([#317](https://github.com/axios/axios/pull/317)) +- Adding `maxRedirects` option ([#307](https://github.com/axios/axios/pull/307)) + +### 0.11.1 (May 17, 2016) + +- Fixing IE CORS support ([#313](https://github.com/axios/axios/pull/313)) +- Fixing detection of `FormData` ([#325](https://github.com/axios/axios/pull/325)) +- Adding `Axios` class to exports ([#321](https://github.com/axios/axios/pull/321)) + +### 0.11.0 (Apr 26, 2016) + +- Adding support for Stream with HTTP adapter ([#296](https://github.com/axios/axios/pull/296)) +- Adding support for custom HTTP status code error ranges ([#308](https://github.com/axios/axios/pull/308)) +- Fixing issue with ArrayBuffer ([#299](https://github.com/axios/axios/pull/299)) + +### 0.10.0 (Apr 20, 2016) + +- Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/axios/axios/pull/250)) +- Fixing basic auth for HTTP adapter ([#252](https://github.com/axios/axios/pull/252)) +- Fixing request timeout for XHR adapter ([#227](https://github.com/axios/axios/pull/227)) +- Fixing IE8 support by using `onreadystatechange` instead of `onload` ([#249](https://github.com/axios/axios/pull/249)) +- Fixing IE9 cross domain requests ([#251](https://github.com/axios/axios/pull/251)) +- Adding `maxContentLength` option ([#275](https://github.com/axios/axios/pull/275)) +- Fixing XHR support for WebWorker environment ([#279](https://github.com/axios/axios/pull/279)) +- Adding request instance to response ([#200](https://github.com/axios/axios/pull/200)) + +### 0.9.1 (Jan 24, 2016) + +- Improving handling of request timeout in node ([#124](https://github.com/axios/axios/issues/124)) +- Fixing network errors not rejecting ([#205](https://github.com/axios/axios/pull/205)) +- Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/axios/axios/issues/201)) +- Fixing host/port when following redirects ([#198](https://github.com/axios/axios/pull/198)) + +### 0.9.0 (Jan 18, 2016) + +- Adding support for custom adapters +- Fixing Content-Type header being removed when data is false ([#195](https://github.com/axios/axios/pull/195)) +- Improving XDomainRequest implementation ([#185](https://github.com/axios/axios/pull/185)) +- Improving config merging and order of precedence ([#183](https://github.com/axios/axios/pull/183)) +- Fixing XDomainRequest support for only <= IE9 ([#182](https://github.com/axios/axios/pull/182)) + +### 0.8.1 (Dec 14, 2015) + +- Adding support for passing XSRF token for cross domain requests when using `withCredentials` ([#168](https://github.com/axios/axios/pull/168)) +- Fixing error with format of basic auth header ([#178](https://github.com/axios/axios/pull/173)) +- Fixing error with JSON payloads throwing `InvalidStateError` in some cases ([#174](https://github.com/axios/axios/pull/174)) + +### 0.8.0 (Dec 11, 2015) + +- Adding support for creating instances of axios ([#123](https://github.com/axios/axios/pull/123)) +- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/axios/axios/pull/128)) +- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/axios/axios/pull/121)) +- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/axios/axios/pull/127)) +- Adding support for following redirects in node ([#146](https://github.com/axios/axios/pull/146)) +- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/axios/axios/pull/149)) +- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/axios/axios/pull/140)) +- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/axios/axios/pull/167)) +- Adding support for baseURL option ([#160](https://github.com/axios/axios/pull/160)) + +### 0.7.0 (Sep 29, 2015) + +- Fixing issue with minified bundle in IE8 ([#87](https://github.com/axios/axios/pull/87)) +- Adding support for passing agent in node ([#102](https://github.com/axios/axios/pull/102)) +- Adding support for returning result from `axios.spread` for chaining ([#106](https://github.com/axios/axios/pull/106)) +- Fixing typescript definition ([#105](https://github.com/axios/axios/pull/105)) +- Fixing default timeout config for node ([#112](https://github.com/axios/axios/pull/112)) +- Adding support for use in web workers, and react-native ([#70](https://github.com/axios/axios/issue/70)), ([#98](https://github.com/axios/axios/pull/98)) +- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/axios/axios/issues/116)) + +### 0.6.0 (Sep 21, 2015) + +- Removing deprecated success/error aliases +- Fixing issue with array params not being properly encoded ([#49](https://github.com/axios/axios/pull/49)) +- Fixing issue with User-Agent getting overridden ([#69](https://github.com/axios/axios/issues/69)) +- Adding support for timeout config ([#56](https://github.com/axios/axios/issues/56)) +- Removing es6-promise dependency +- Fixing issue preventing `length` to be used as a parameter ([#91](https://github.com/axios/axios/pull/91)) +- Fixing issue with IE8 ([#85](https://github.com/axios/axios/pull/85)) +- Converting build to UMD + +### 0.5.4 (Apr 08, 2015) + +- Fixing issue with FormData not being sent ([#53](https://github.com/axios/axios/issues/53)) + +### 0.5.3 (Apr 07, 2015) + +- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/axios/axios/issues/55)) + +### 0.5.2 (Mar 13, 2015) + +- Adding support for `statusText` in response ([#46](https://github.com/axios/axios/issues/46)) + +### 0.5.1 (Mar 10, 2015) + +- Fixing issue using strict mode ([#45](https://github.com/axios/axios/issues/45)) +- Fixing issue with standalone build ([#47](https://github.com/axios/axios/issues/47)) + +### 0.5.0 (Jan 23, 2015) + +- Adding support for intercepetors ([#14](https://github.com/axios/axios/issues/14)) +- Updating es6-promise dependency + +### 0.4.2 (Dec 10, 2014) + +- Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/axios/axios/issues/22)) +- Adding support for TypeScript ([#25](https://github.com/axios/axios/issues/25)) +- Fixing issue with standalone build ([#29](https://github.com/axios/axios/issues/29)) +- Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/axios/axios/issues/30)) + +### 0.4.1 (Oct 15, 2014) + +- Adding error handling to request for node.js ([#18](https://github.com/axios/axios/issues/18)) + +### 0.4.0 (Oct 03, 2014) + +- Adding support for `ArrayBuffer` and `ArrayBufferView` ([#10](https://github.com/axios/axios/issues/10)) +- Adding support for utf-8 for node.js ([#13](https://github.com/axios/axios/issues/13)) +- Adding support for SSL for node.js ([#12](https://github.com/axios/axios/issues/12)) +- Fixing incorrect `Content-Type` header ([#9](https://github.com/axios/axios/issues/9)) +- Adding standalone build without bundled es6-promise ([#11](https://github.com/axios/axios/issues/11)) +- Deprecating `success`/`error` in favor of `then`/`catch` + +### 0.3.1 (Sep 16, 2014) + +- Fixing missing post body when using node.js ([#3](https://github.com/axios/axios/issues/3)) + +### 0.3.0 (Sep 16, 2014) + +- Fixing `success` and `error` to properly receive response data as individual arguments ([#8](https://github.com/axios/axios/issues/8)) +- Updating `then` and `catch` to receive response data as a single object ([#6](https://github.com/axios/axios/issues/6)) +- Fixing issue with `all` not working ([#7](https://github.com/axios/axios/issues/7)) + +### 0.2.2 (Sep 14, 2014) + +- Fixing bundling with browserify ([#4](https://github.com/axios/axios/issues/4)) + +### 0.2.1 (Sep 12, 2014) + +- Fixing build problem causing ridiculous file sizes + +### 0.2.0 (Sep 12, 2014) + +- Adding support for `all` and `spread` +- Adding support for node.js ([#1](https://github.com/axios/axios/issues/1)) + +### 0.1.0 (Aug 29, 2014) + +- Initial release diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/LICENSE b/SCRS-Backend/src/test/javascript/node_modules/axios/LICENSE new file mode 100644 index 0000000..d36c80e --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014-present Matt Zabriskie + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/README.md b/SCRS-Backend/src/test/javascript/node_modules/axios/README.md new file mode 100644 index 0000000..44264f6 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/README.md @@ -0,0 +1,800 @@ +# axios + +[![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios) +[![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios) +[![build status](https://img.shields.io/travis/axios/axios/master.svg?style=flat-square)](https://travis-ci.org/axios/axios) +[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios) +[![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios) +[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios) +[![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios) +[![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios) + +Promise based HTTP client for the browser and node.js +## Table of Contents + + - [Features](#features) + - [Browser Support](#browser-support) + - [Installing](#installing) + - [Example](#example) + - [Axios API](#axios-api) + - [Request method aliases](#request-method-aliases) + - [Concurrency (Deprecated)](#concurrency-deprecated) + - [Creating an instance](#creating-an-instance) + - [Instance methods](#instance-methods) + - [Request Config](#request-config) + - [Response Schema](#response-schema) + - [Config Defaults](#config-defaults) + - [Global axios defaults](#global-axios-defaults) + - [Custom instance defaults](#custom-instance-defaults) + - [Config order of precedence](#config-order-of-precedence) + - [Interceptors](#interceptors) + - [Handling Errors](#handling-errors) + - [Cancellation](#cancellation) + - [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format) + - [Browser](#browser) + - [Node.js](#nodejs) + - [Query string](#query-string) + - [Form data](#form-data) + - [Semver](#semver) + - [Promises](#promises) + - [TypeScript](#typescript) + - [Resources](#resources) + - [Credits](#credits) + - [License](#license) + +## Features + +- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser +- Make [http](http://nodejs.org/api/http.html) requests from node.js +- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API +- Intercept request and response +- Transform request and response data +- Cancel requests +- Automatic transforms for JSON data +- Client side support for protecting against [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) + +## Browser Support + +![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) | +--- | --- | --- | --- | --- | --- | +Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ | + +[![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios) + +## Installing + +Using npm: + +```bash +$ npm install axios +``` + +Using bower: + +```bash +$ bower install axios +``` + +Using yarn: + +```bash +$ yarn add axios +``` + +Using jsDelivr CDN: + +```html + +``` + +Using unpkg CDN: + +```html + +``` + +## Example + +### note: CommonJS usage +In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach: + +```js +const axios = require('axios').default; + +// axios. will now provide autocomplete and parameter typings +``` + +Performing a `GET` request + +```js +const axios = require('axios'); + +// Make a request for a user with a given ID +axios.get('/user?ID=12345') + .then(function (response) { + // handle success + console.log(response); + }) + .catch(function (error) { + // handle error + console.log(error); + }) + .then(function () { + // always executed + }); + +// Optionally the request above could also be done as +axios.get('/user', { + params: { + ID: 12345 + } + }) + .then(function (response) { + console.log(response); + }) + .catch(function (error) { + console.log(error); + }) + .then(function () { + // always executed + }); + +// Want to use async/await? Add the `async` keyword to your outer function/method. +async function getUser() { + try { + const response = await axios.get('/user?ID=12345'); + console.log(response); + } catch (error) { + console.error(error); + } +} +``` + +> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet +> Explorer and older browsers, so use with caution. + +Performing a `POST` request + +```js +axios.post('/user', { + firstName: 'Fred', + lastName: 'Flintstone' + }) + .then(function (response) { + console.log(response); + }) + .catch(function (error) { + console.log(error); + }); +``` + +Performing multiple concurrent requests + +```js +function getUserAccount() { + return axios.get('/user/12345'); +} + +function getUserPermissions() { + return axios.get('/user/12345/permissions'); +} + +Promise.all([getUserAccount(), getUserPermissions()]) + .then(function (results) { + const acct = results[0]; + const perm = results[1]; + }); +``` + +## axios API + +Requests can be made by passing the relevant config to `axios`. + +##### axios(config) + +```js +// Send a POST request +axios({ + method: 'post', + url: '/user/12345', + data: { + firstName: 'Fred', + lastName: 'Flintstone' + } +}); +``` + +```js +// GET request for remote image in node.js +axios({ + method: 'get', + url: 'http://bit.ly/2mTM3nY', + responseType: 'stream' +}) + .then(function (response) { + response.data.pipe(fs.createWriteStream('ada_lovelace.jpg')) + }); +``` + +##### axios(url[, config]) + +```js +// Send a GET request (default method) +axios('/user/12345'); +``` + +### Request method aliases + +For convenience aliases have been provided for all supported request methods. + +##### axios.request(config) +##### axios.get(url[, config]) +##### axios.delete(url[, config]) +##### axios.head(url[, config]) +##### axios.options(url[, config]) +##### axios.post(url[, data[, config]]) +##### axios.put(url[, data[, config]]) +##### axios.patch(url[, data[, config]]) + +###### NOTE +When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config. + +### Concurrency (Deprecated) +Please use `Promise.all` to replace the below functions. + +Helper functions for dealing with concurrent requests. + +axios.all(iterable) +axios.spread(callback) + +### Creating an instance + +You can create a new instance of axios with a custom config. + +##### axios.create([config]) + +```js +const instance = axios.create({ + baseURL: 'https://some-domain.com/api/', + timeout: 1000, + headers: {'X-Custom-Header': 'foobar'} +}); +``` + +### Instance methods + +The available instance methods are listed below. The specified config will be merged with the instance config. + +##### axios#request(config) +##### axios#get(url[, config]) +##### axios#delete(url[, config]) +##### axios#head(url[, config]) +##### axios#options(url[, config]) +##### axios#post(url[, data[, config]]) +##### axios#put(url[, data[, config]]) +##### axios#patch(url[, data[, config]]) +##### axios#getUri([config]) + +## Request Config + +These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified. + +```js +{ + // `url` is the server URL that will be used for the request + url: '/user', + + // `method` is the request method to be used when making the request + method: 'get', // default + + // `baseURL` will be prepended to `url` unless `url` is absolute. + // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs + // to methods of that instance. + baseURL: 'https://some-domain.com/api/', + + // `transformRequest` allows changes to the request data before it is sent to the server + // This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE' + // The last function in the array must return a string or an instance of Buffer, ArrayBuffer, + // FormData or Stream + // You may modify the headers object. + transformRequest: [function (data, headers) { + // Do whatever you want to transform the data + + return data; + }], + + // `transformResponse` allows changes to the response data to be made before + // it is passed to then/catch + transformResponse: [function (data) { + // Do whatever you want to transform the data + + return data; + }], + + // `headers` are custom headers to be sent + headers: {'X-Requested-With': 'XMLHttpRequest'}, + + // `params` are the URL parameters to be sent with the request + // Must be a plain object or a URLSearchParams object + params: { + ID: 12345 + }, + + // `paramsSerializer` is an optional function in charge of serializing `params` + // (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/) + paramsSerializer: function (params) { + return Qs.stringify(params, {arrayFormat: 'brackets'}) + }, + + // `data` is the data to be sent as the request body + // Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH' + // When no `transformRequest` is set, must be of one of the following types: + // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams + // - Browser only: FormData, File, Blob + // - Node only: Stream, Buffer + data: { + firstName: 'Fred' + }, + + // syntax alternative to send data into the body + // method post + // only the value is sent, not the key + data: 'Country=Brasil&City=Belo Horizonte', + + // `timeout` specifies the number of milliseconds before the request times out. + // If the request takes longer than `timeout`, the request will be aborted. + timeout: 1000, // default is `0` (no timeout) + + // `withCredentials` indicates whether or not cross-site Access-Control requests + // should be made using credentials + withCredentials: false, // default + + // `adapter` allows custom handling of requests which makes testing easier. + // Return a promise and supply a valid response (see lib/adapters/README.md). + adapter: function (config) { + /* ... */ + }, + + // `auth` indicates that HTTP Basic auth should be used, and supplies credentials. + // This will set an `Authorization` header, overwriting any existing + // `Authorization` custom headers you have set using `headers`. + // Please note that only HTTP Basic auth is configurable through this parameter. + // For Bearer tokens and such, use `Authorization` custom headers instead. + auth: { + username: 'janedoe', + password: 's00pers3cret' + }, + + // `responseType` indicates the type of data that the server will respond with + // options are: 'arraybuffer', 'document', 'json', 'text', 'stream' + // browser only: 'blob' + responseType: 'json', // default + + // `responseEncoding` indicates encoding to use for decoding responses (Node.js only) + // Note: Ignored for `responseType` of 'stream' or client-side requests + responseEncoding: 'utf8', // default + + // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token + xsrfCookieName: 'XSRF-TOKEN', // default + + // `xsrfHeaderName` is the name of the http header that carries the xsrf token value + xsrfHeaderName: 'X-XSRF-TOKEN', // default + + // `onUploadProgress` allows handling of progress events for uploads + // browser only + onUploadProgress: function (progressEvent) { + // Do whatever you want with the native progress event + }, + + // `onDownloadProgress` allows handling of progress events for downloads + // browser only + onDownloadProgress: function (progressEvent) { + // Do whatever you want with the native progress event + }, + + // `maxContentLength` defines the max size of the http response content in bytes allowed in node.js + maxContentLength: 2000, + + // `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed + maxBodyLength: 2000, + + // `validateStatus` defines whether to resolve or reject the promise for a given + // HTTP response status code. If `validateStatus` returns `true` (or is set to `null` + // or `undefined`), the promise will be resolved; otherwise, the promise will be + // rejected. + validateStatus: function (status) { + return status >= 200 && status < 300; // default + }, + + // `maxRedirects` defines the maximum number of redirects to follow in node.js. + // If set to 0, no redirects will be followed. + maxRedirects: 5, // default + + // `socketPath` defines a UNIX Socket to be used in node.js. + // e.g. '/var/run/docker.sock' to send requests to the docker daemon. + // Only either `socketPath` or `proxy` can be specified. + // If both are specified, `socketPath` is used. + socketPath: null, // default + + // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http + // and https requests, respectively, in node.js. This allows options to be added like + // `keepAlive` that are not enabled by default. + httpAgent: new http.Agent({ keepAlive: true }), + httpsAgent: new https.Agent({ keepAlive: true }), + + // `proxy` defines the hostname, port, and protocol of the proxy server. + // You can also define your proxy using the conventional `http_proxy` and + // `https_proxy` environment variables. If you are using environment variables + // for your proxy configuration, you can also define a `no_proxy` environment + // variable as a comma-separated list of domains that should not be proxied. + // Use `false` to disable proxies, ignoring environment variables. + // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and + // supplies credentials. + // This will set an `Proxy-Authorization` header, overwriting any existing + // `Proxy-Authorization` custom headers you have set using `headers`. + // If the proxy server uses HTTPS, then you must set the protocol to `https`. + proxy: { + protocol: 'https', + host: '127.0.0.1', + port: 9000, + auth: { + username: 'mikeymike', + password: 'rapunz3l' + } + }, + + // `cancelToken` specifies a cancel token that can be used to cancel the request + // (see Cancellation section below for details) + cancelToken: new CancelToken(function (cancel) { + }), + + // `decompress` indicates whether or not the response body should be decompressed + // automatically. If set to `true` will also remove the 'content-encoding' header + // from the responses objects of all decompressed responses + // - Node only (XHR cannot turn off decompression) + decompress: true // default + +} +``` + +## Response Schema + +The response for a request contains the following information. + +```js +{ + // `data` is the response that was provided by the server + data: {}, + + // `status` is the HTTP status code from the server response + status: 200, + + // `statusText` is the HTTP status message from the server response + statusText: 'OK', + + // `headers` the HTTP headers that the server responded with + // All header names are lower cased and can be accessed using the bracket notation. + // Example: `response.headers['content-type']` + headers: {}, + + // `config` is the config that was provided to `axios` for the request + config: {}, + + // `request` is the request that generated this response + // It is the last ClientRequest instance in node.js (in redirects) + // and an XMLHttpRequest instance in the browser + request: {} +} +``` + +When using `then`, you will receive the response as follows: + +```js +axios.get('/user/12345') + .then(function (response) { + console.log(response.data); + console.log(response.status); + console.log(response.statusText); + console.log(response.headers); + console.log(response.config); + }); +``` + +When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as second parameter of `then`, the response will be available through the `error` object as explained in the [Handling Errors](#handling-errors) section. + +## Config Defaults + +You can specify config defaults that will be applied to every request. + +### Global axios defaults + +```js +axios.defaults.baseURL = 'https://api.example.com'; +axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; +axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; +``` + +### Custom instance defaults + +```js +// Set config defaults when creating the instance +const instance = axios.create({ + baseURL: 'https://api.example.com' +}); + +// Alter defaults after instance has been created +instance.defaults.headers.common['Authorization'] = AUTH_TOKEN; +``` + +### Config order of precedence + +Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. + +```js +// Create an instance using the config defaults provided by the library +// At this point the timeout config value is `0` as is the default for the library +const instance = axios.create(); + +// Override timeout default for the library +// Now all requests using this instance will wait 2.5 seconds before timing out +instance.defaults.timeout = 2500; + +// Override timeout for this request as it's known to take a long time +instance.get('/longRequest', { + timeout: 5000 +}); +``` + +## Interceptors + +You can intercept requests or responses before they are handled by `then` or `catch`. + +```js +// Add a request interceptor +axios.interceptors.request.use(function (config) { + // Do something before request is sent + return config; + }, function (error) { + // Do something with request error + return Promise.reject(error); + }); + +// Add a response interceptor +axios.interceptors.response.use(function (response) { + // Any status code that lie within the range of 2xx cause this function to trigger + // Do something with response data + return response; + }, function (error) { + // Any status codes that falls outside the range of 2xx cause this function to trigger + // Do something with response error + return Promise.reject(error); + }); +``` + +If you need to remove an interceptor later you can. + +```js +const myInterceptor = axios.interceptors.request.use(function () {/*...*/}); +axios.interceptors.request.eject(myInterceptor); +``` + +You can add interceptors to a custom instance of axios. + +```js +const instance = axios.create(); +instance.interceptors.request.use(function () {/*...*/}); +``` + +## Handling Errors + +```js +axios.get('/user/12345') + .catch(function (error) { + if (error.response) { + // The request was made and the server responded with a status code + // that falls out of the range of 2xx + console.log(error.response.data); + console.log(error.response.status); + console.log(error.response.headers); + } else if (error.request) { + // The request was made but no response was received + // `error.request` is an instance of XMLHttpRequest in the browser and an instance of + // http.ClientRequest in node.js + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + console.log('Error', error.message); + } + console.log(error.config); + }); +``` + +Using the `validateStatus` config option, you can define HTTP code(s) that should throw an error. + +```js +axios.get('/user/12345', { + validateStatus: function (status) { + return status < 500; // Resolve only if the status code is less than 500 + } +}) +``` + +Using `toJSON` you get an object with more information about the HTTP error. + +```js +axios.get('/user/12345') + .catch(function (error) { + console.log(error.toJSON()); + }); +``` + +## Cancellation + +You can cancel a request using a *cancel token*. + +> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises). + +You can create a cancel token using the `CancelToken.source` factory as shown below: + +```js +const CancelToken = axios.CancelToken; +const source = CancelToken.source(); + +axios.get('/user/12345', { + cancelToken: source.token +}).catch(function (thrown) { + if (axios.isCancel(thrown)) { + console.log('Request canceled', thrown.message); + } else { + // handle error + } +}); + +axios.post('/user/12345', { + name: 'new name' +}, { + cancelToken: source.token +}) + +// cancel the request (the message parameter is optional) +source.cancel('Operation canceled by the user.'); +``` + +You can also create a cancel token by passing an executor function to the `CancelToken` constructor: + +```js +const CancelToken = axios.CancelToken; +let cancel; + +axios.get('/user/12345', { + cancelToken: new CancelToken(function executor(c) { + // An executor function receives a cancel function as a parameter + cancel = c; + }) +}); + +// cancel the request +cancel(); +``` + +> Note: you can cancel several requests with the same cancel token. + +## Using application/x-www-form-urlencoded format + +By default, axios serializes JavaScript objects to `JSON`. To send data in the `application/x-www-form-urlencoded` format instead, you can use one of the following options. + +### Browser + +In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows: + +```js +const params = new URLSearchParams(); +params.append('param1', 'value1'); +params.append('param2', 'value2'); +axios.post('/foo', params); +``` + +> Note that `URLSearchParams` is not supported by all browsers (see [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment). + +Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library: + +```js +const qs = require('qs'); +axios.post('/foo', qs.stringify({ 'bar': 123 })); +``` + +Or in another way (ES6), + +```js +import qs from 'qs'; +const data = { 'bar': 123 }; +const options = { + method: 'POST', + headers: { 'content-type': 'application/x-www-form-urlencoded' }, + data: qs.stringify(data), + url, +}; +axios(options); +``` + +### Node.js + +#### Query string + +In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: + +```js +const querystring = require('querystring'); +axios.post('http://something.com/', querystring.stringify({ foo: 'bar' })); +``` + +or ['URLSearchParams'](https://nodejs.org/api/url.html#url_class_urlsearchparams) from ['url module'](https://nodejs.org/api/url.html) as follows: + +```js +const url = require('url'); +const params = new url.URLSearchParams({ foo: 'bar' }); +axios.post('http://something.com/', params.toString()); +``` + +You can also use the [`qs`](https://github.com/ljharb/qs) library. + +###### NOTE +The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665). + +#### Form data + +In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows: + +```js +const FormData = require('form-data'); + +const form = new FormData(); +form.append('my_field', 'my value'); +form.append('my_buffer', new Buffer(10)); +form.append('my_file', fs.createReadStream('/foo/bar.jpg')); + +axios.post('https://example.com', form, { headers: form.getHeaders() }) +``` + +Alternatively, use an interceptor: + +```js +axios.interceptors.request.use(config => { + if (config.data instanceof FormData) { + Object.assign(config.headers, config.data.getHeaders()); + } + return config; +}); +``` + +## Semver + +Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes. + +## Promises + +axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises). +If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise). + +## TypeScript +axios includes [TypeScript](http://typescriptlang.org) definitions. +```typescript +import axios from 'axios'; +axios.get('/user?ID=12345'); +``` + +## Resources + +* [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) +* [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md) +* [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md) +* [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md) +* [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md) + +## Credits + +axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular. + +## License + +[MIT](LICENSE) diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/UPGRADE_GUIDE.md b/SCRS-Backend/src/test/javascript/node_modules/axios/UPGRADE_GUIDE.md new file mode 100644 index 0000000..745e804 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/UPGRADE_GUIDE.md @@ -0,0 +1,162 @@ +# Upgrade Guide + +### 0.15.x -> 0.16.0 + +#### `Promise` Type Declarations + +The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details. + +### 0.13.x -> 0.14.0 + +#### TypeScript Definitions + +The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax. + +Please use the following `import` statement to import axios in TypeScript: + +```typescript +import axios from 'axios'; + +axios.get('/foo') + .then(response => console.log(response)) + .catch(error => console.log(error)); +``` + +#### `agent` Config Option + +The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead. + +```js +{ + // Define a custom agent for HTTP + httpAgent: new http.Agent({ keepAlive: true }), + // Define a custom agent for HTTPS + httpsAgent: new https.Agent({ keepAlive: true }) +} +``` + +#### `progress` Config Option + +The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options. + +```js +{ + // Define a handler for upload progress events + onUploadProgress: function (progressEvent) { + // ... + }, + + // Define a handler for download progress events + onDownloadProgress: function (progressEvent) { + // ... + } +} +``` + +### 0.12.x -> 0.13.0 + +The `0.13.0` release contains several changes to custom adapters and error handling. + +#### Error Handling + +Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response. + +```js +axios.get('/user/12345') + .catch((error) => { + console.log(error.message); + console.log(error.code); // Not always specified + console.log(error.config); // The config that was used to make the request + console.log(error.response); // Only available if response was received from the server + }); +``` + +#### Request Adapters + +This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter. + +1. Response transformer is now called outside of adapter. +2. Request adapter returns a `Promise`. + +This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter. + +Previous code: + +```js +function myAdapter(resolve, reject, config) { + var response = { + data: transformData( + responseData, + responseHeaders, + config.transformResponse + ), + status: request.status, + statusText: request.statusText, + headers: responseHeaders + }; + settle(resolve, reject, response); +} +``` + +New code: + +```js +function myAdapter(config) { + return new Promise(function (resolve, reject) { + var response = { + data: responseData, + status: request.status, + statusText: request.statusText, + headers: responseHeaders + }; + settle(resolve, reject, response); + }); +} +``` + +See the related commits for more details: +- [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e) +- [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a) + +### 0.5.x -> 0.6.0 + +The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading. + +#### ES6 Promise Polyfill + +Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it. + +```js +require('es6-promise').polyfill(); +var axios = require('axios'); +``` + +This will polyfill the global environment, and only needs to be done once. + +#### `axios.success`/`axios.error` + +The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. + +```js +axios.get('some/url') + .then(function (res) { + /* ... */ + }) + .catch(function (err) { + /* ... */ + }); +``` + +#### UMD + +Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build. + +```js +// AMD +require(['bower_components/axios/dist/axios'], function (axios) { + /* ... */ +}); + +// CommonJS +var axios = require('axios/dist/axios'); +``` diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.js b/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.js new file mode 100644 index 0000000..6dd94bd --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.js @@ -0,0 +1,1756 @@ +/* axios v0.21.1 | (c) 2020 by Matt Zabriskie */ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["axios"] = factory(); + else + root["axios"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(1); + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + var bind = __webpack_require__(3); + var Axios = __webpack_require__(4); + var mergeConfig = __webpack_require__(22); + var defaults = __webpack_require__(10); + + /** + * Create an instance of Axios + * + * @param {Object} defaultConfig The default config for the instance + * @return {Axios} A new instance of Axios + */ + function createInstance(defaultConfig) { + var context = new Axios(defaultConfig); + var instance = bind(Axios.prototype.request, context); + + // Copy axios.prototype to instance + utils.extend(instance, Axios.prototype, context); + + // Copy context to instance + utils.extend(instance, context); + + return instance; + } + + // Create the default instance to be exported + var axios = createInstance(defaults); + + // Expose Axios class to allow class inheritance + axios.Axios = Axios; + + // Factory for creating new instances + axios.create = function create(instanceConfig) { + return createInstance(mergeConfig(axios.defaults, instanceConfig)); + }; + + // Expose Cancel & CancelToken + axios.Cancel = __webpack_require__(23); + axios.CancelToken = __webpack_require__(24); + axios.isCancel = __webpack_require__(9); + + // Expose all/spread + axios.all = function all(promises) { + return Promise.all(promises); + }; + axios.spread = __webpack_require__(25); + + // Expose isAxiosError + axios.isAxiosError = __webpack_require__(26); + + module.exports = axios; + + // Allow use of default import syntax in TypeScript + module.exports.default = axios; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var bind = __webpack_require__(3); + + /*global toString:true*/ + + // utils is a library of generic helper functions non-specific to axios + + var toString = Object.prototype.toString; + + /** + * Determine if a value is an Array + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Array, otherwise false + */ + function isArray(val) { + return toString.call(val) === '[object Array]'; + } + + /** + * Determine if a value is undefined + * + * @param {Object} val The value to test + * @returns {boolean} True if the value is undefined, otherwise false + */ + function isUndefined(val) { + return typeof val === 'undefined'; + } + + /** + * Determine if a value is a Buffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Buffer, otherwise false + */ + function isBuffer(val) { + return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) + && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); + } + + /** + * Determine if a value is an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an ArrayBuffer, otherwise false + */ + function isArrayBuffer(val) { + return toString.call(val) === '[object ArrayBuffer]'; + } + + /** + * Determine if a value is a FormData + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an FormData, otherwise false + */ + function isFormData(val) { + return (typeof FormData !== 'undefined') && (val instanceof FormData); + } + + /** + * Determine if a value is a view on an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false + */ + function isArrayBufferView(val) { + var result; + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { + result = ArrayBuffer.isView(val); + } else { + result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); + } + return result; + } + + /** + * Determine if a value is a String + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a String, otherwise false + */ + function isString(val) { + return typeof val === 'string'; + } + + /** + * Determine if a value is a Number + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Number, otherwise false + */ + function isNumber(val) { + return typeof val === 'number'; + } + + /** + * Determine if a value is an Object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Object, otherwise false + */ + function isObject(val) { + return val !== null && typeof val === 'object'; + } + + /** + * Determine if a value is a plain Object + * + * @param {Object} val The value to test + * @return {boolean} True if value is a plain Object, otherwise false + */ + function isPlainObject(val) { + if (toString.call(val) !== '[object Object]') { + return false; + } + + var prototype = Object.getPrototypeOf(val); + return prototype === null || prototype === Object.prototype; + } + + /** + * Determine if a value is a Date + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Date, otherwise false + */ + function isDate(val) { + return toString.call(val) === '[object Date]'; + } + + /** + * Determine if a value is a File + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a File, otherwise false + */ + function isFile(val) { + return toString.call(val) === '[object File]'; + } + + /** + * Determine if a value is a Blob + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Blob, otherwise false + */ + function isBlob(val) { + return toString.call(val) === '[object Blob]'; + } + + /** + * Determine if a value is a Function + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Function, otherwise false + */ + function isFunction(val) { + return toString.call(val) === '[object Function]'; + } + + /** + * Determine if a value is a Stream + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Stream, otherwise false + */ + function isStream(val) { + return isObject(val) && isFunction(val.pipe); + } + + /** + * Determine if a value is a URLSearchParams object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a URLSearchParams object, otherwise false + */ + function isURLSearchParams(val) { + return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; + } + + /** + * Trim excess whitespace off the beginning and end of a string + * + * @param {String} str The String to trim + * @returns {String} The String freed of excess whitespace + */ + function trim(str) { + return str.replace(/^\s*/, '').replace(/\s*$/, ''); + } + + /** + * Determine if we're running in a standard browser environment + * + * This allows axios to run in a web worker, and react-native. + * Both environments support XMLHttpRequest, but not fully standard globals. + * + * web workers: + * typeof window -> undefined + * typeof document -> undefined + * + * react-native: + * navigator.product -> 'ReactNative' + * nativescript + * navigator.product -> 'NativeScript' or 'NS' + */ + function isStandardBrowserEnv() { + if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || + navigator.product === 'NativeScript' || + navigator.product === 'NS')) { + return false; + } + return ( + typeof window !== 'undefined' && + typeof document !== 'undefined' + ); + } + + /** + * Iterate over an Array or an Object invoking a function for each item. + * + * If `obj` is an Array callback will be called passing + * the value, index, and complete array for each item. + * + * If 'obj' is an Object callback will be called passing + * the value, key, and complete object for each property. + * + * @param {Object|Array} obj The object to iterate + * @param {Function} fn The callback to invoke for each item + */ + function forEach(obj, fn) { + // Don't bother if no value provided + if (obj === null || typeof obj === 'undefined') { + return; + } + + // Force an array if not already something iterable + if (typeof obj !== 'object') { + /*eslint no-param-reassign:0*/ + obj = [obj]; + } + + if (isArray(obj)) { + // Iterate over array values + for (var i = 0, l = obj.length; i < l; i++) { + fn.call(null, obj[i], i, obj); + } + } else { + // Iterate over object keys + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + fn.call(null, obj[key], key, obj); + } + } + } + } + + /** + * Accepts varargs expecting each argument to be an object, then + * immutably merges the properties of each object and returns result. + * + * When multiple objects contain the same key the later object in + * the arguments list will take precedence. + * + * Example: + * + * ```js + * var result = merge({foo: 123}, {foo: 456}); + * console.log(result.foo); // outputs 456 + * ``` + * + * @param {Object} obj1 Object to merge + * @returns {Object} Result of all merge properties + */ + function merge(/* obj1, obj2, obj3, ... */) { + var result = {}; + function assignValue(val, key) { + if (isPlainObject(result[key]) && isPlainObject(val)) { + result[key] = merge(result[key], val); + } else if (isPlainObject(val)) { + result[key] = merge({}, val); + } else if (isArray(val)) { + result[key] = val.slice(); + } else { + result[key] = val; + } + } + + for (var i = 0, l = arguments.length; i < l; i++) { + forEach(arguments[i], assignValue); + } + return result; + } + + /** + * Extends object a by mutably adding to it the properties of object b. + * + * @param {Object} a The object to be extended + * @param {Object} b The object to copy properties from + * @param {Object} thisArg The object to bind function to + * @return {Object} The resulting value of object a + */ + function extend(a, b, thisArg) { + forEach(b, function assignValue(val, key) { + if (thisArg && typeof val === 'function') { + a[key] = bind(val, thisArg); + } else { + a[key] = val; + } + }); + return a; + } + + /** + * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) + * + * @param {string} content with BOM + * @return {string} content value without BOM + */ + function stripBOM(content) { + if (content.charCodeAt(0) === 0xFEFF) { + content = content.slice(1); + } + return content; + } + + module.exports = { + isArray: isArray, + isArrayBuffer: isArrayBuffer, + isBuffer: isBuffer, + isFormData: isFormData, + isArrayBufferView: isArrayBufferView, + isString: isString, + isNumber: isNumber, + isObject: isObject, + isPlainObject: isPlainObject, + isUndefined: isUndefined, + isDate: isDate, + isFile: isFile, + isBlob: isBlob, + isFunction: isFunction, + isStream: isStream, + isURLSearchParams: isURLSearchParams, + isStandardBrowserEnv: isStandardBrowserEnv, + forEach: forEach, + merge: merge, + extend: extend, + trim: trim, + stripBOM: stripBOM + }; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports) { + + 'use strict'; + + module.exports = function bind(fn, thisArg) { + return function wrap() { + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + return fn.apply(thisArg, args); + }; + }; + + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + var buildURL = __webpack_require__(5); + var InterceptorManager = __webpack_require__(6); + var dispatchRequest = __webpack_require__(7); + var mergeConfig = __webpack_require__(22); + + /** + * Create a new instance of Axios + * + * @param {Object} instanceConfig The default config for the instance + */ + function Axios(instanceConfig) { + this.defaults = instanceConfig; + this.interceptors = { + request: new InterceptorManager(), + response: new InterceptorManager() + }; + } + + /** + * Dispatch a request + * + * @param {Object} config The config specific for this request (merged with this.defaults) + */ + Axios.prototype.request = function request(config) { + /*eslint no-param-reassign:0*/ + // Allow for axios('example/url'[, config]) a la fetch API + if (typeof config === 'string') { + config = arguments[1] || {}; + config.url = arguments[0]; + } else { + config = config || {}; + } + + config = mergeConfig(this.defaults, config); + + // Set config.method + if (config.method) { + config.method = config.method.toLowerCase(); + } else if (this.defaults.method) { + config.method = this.defaults.method.toLowerCase(); + } else { + config.method = 'get'; + } + + // Hook up interceptors middleware + var chain = [dispatchRequest, undefined]; + var promise = Promise.resolve(config); + + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { + chain.unshift(interceptor.fulfilled, interceptor.rejected); + }); + + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { + chain.push(interceptor.fulfilled, interceptor.rejected); + }); + + while (chain.length) { + promise = promise.then(chain.shift(), chain.shift()); + } + + return promise; + }; + + Axios.prototype.getUri = function getUri(config) { + config = mergeConfig(this.defaults, config); + return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); + }; + + // Provide aliases for supported request methods + utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, config) { + return this.request(mergeConfig(config || {}, { + method: method, + url: url, + data: (config || {}).data + })); + }; + }); + + utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, data, config) { + return this.request(mergeConfig(config || {}, { + method: method, + url: url, + data: data + })); + }; + }); + + module.exports = Axios; + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + function encode(val) { + return encodeURIComponent(val). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%20/g, '+'). + replace(/%5B/gi, '['). + replace(/%5D/gi, ']'); + } + + /** + * Build a URL by appending params to the end + * + * @param {string} url The base of the url (e.g., http://www.google.com) + * @param {object} [params] The params to be appended + * @returns {string} The formatted url + */ + module.exports = function buildURL(url, params, paramsSerializer) { + /*eslint no-param-reassign:0*/ + if (!params) { + return url; + } + + var serializedParams; + if (paramsSerializer) { + serializedParams = paramsSerializer(params); + } else if (utils.isURLSearchParams(params)) { + serializedParams = params.toString(); + } else { + var parts = []; + + utils.forEach(params, function serialize(val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + + if (utils.isArray(val)) { + key = key + '[]'; + } else { + val = [val]; + } + + utils.forEach(val, function parseValue(v) { + if (utils.isDate(v)) { + v = v.toISOString(); + } else if (utils.isObject(v)) { + v = JSON.stringify(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + serializedParams = parts.join('&'); + } + + if (serializedParams) { + var hashmarkIndex = url.indexOf('#'); + if (hashmarkIndex !== -1) { + url = url.slice(0, hashmarkIndex); + } + + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; + } + + return url; + }; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + function InterceptorManager() { + this.handlers = []; + } + + /** + * Add a new interceptor to the stack + * + * @param {Function} fulfilled The function to handle `then` for a `Promise` + * @param {Function} rejected The function to handle `reject` for a `Promise` + * + * @return {Number} An ID used to remove interceptor later + */ + InterceptorManager.prototype.use = function use(fulfilled, rejected) { + this.handlers.push({ + fulfilled: fulfilled, + rejected: rejected + }); + return this.handlers.length - 1; + }; + + /** + * Remove an interceptor from the stack + * + * @param {Number} id The ID that was returned by `use` + */ + InterceptorManager.prototype.eject = function eject(id) { + if (this.handlers[id]) { + this.handlers[id] = null; + } + }; + + /** + * Iterate over all the registered interceptors + * + * This method is particularly useful for skipping over any + * interceptors that may have become `null` calling `eject`. + * + * @param {Function} fn The function to call for each interceptor + */ + InterceptorManager.prototype.forEach = function forEach(fn) { + utils.forEach(this.handlers, function forEachHandler(h) { + if (h !== null) { + fn(h); + } + }); + }; + + module.exports = InterceptorManager; + + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + var transformData = __webpack_require__(8); + var isCancel = __webpack_require__(9); + var defaults = __webpack_require__(10); + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + function throwIfCancellationRequested(config) { + if (config.cancelToken) { + config.cancelToken.throwIfRequested(); + } + } + + /** + * Dispatch a request to the server using the configured adapter. + * + * @param {object} config The config that is to be used for the request + * @returns {Promise} The Promise to be fulfilled + */ + module.exports = function dispatchRequest(config) { + throwIfCancellationRequested(config); + + // Ensure headers exist + config.headers = config.headers || {}; + + // Transform request data + config.data = transformData( + config.data, + config.headers, + config.transformRequest + ); + + // Flatten headers + config.headers = utils.merge( + config.headers.common || {}, + config.headers[config.method] || {}, + config.headers + ); + + utils.forEach( + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], + function cleanHeaderConfig(method) { + delete config.headers[method]; + } + ); + + var adapter = config.adapter || defaults.adapter; + + return adapter(config).then(function onAdapterResolution(response) { + throwIfCancellationRequested(config); + + // Transform response data + response.data = transformData( + response.data, + response.headers, + config.transformResponse + ); + + return response; + }, function onAdapterRejection(reason) { + if (!isCancel(reason)) { + throwIfCancellationRequested(config); + + // Transform response data + if (reason && reason.response) { + reason.response.data = transformData( + reason.response.data, + reason.response.headers, + config.transformResponse + ); + } + } + + return Promise.reject(reason); + }); + }; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + /** + * Transform the data for a request or a response + * + * @param {Object|String} data The data to be transformed + * @param {Array} headers The headers for the request or response + * @param {Array|Function} fns A single function or Array of functions + * @returns {*} The resulting transformed data + */ + module.exports = function transformData(data, headers, fns) { + /*eslint no-param-reassign:0*/ + utils.forEach(fns, function transform(fn) { + data = fn(data, headers); + }); + + return data; + }; + + +/***/ }), +/* 9 */ +/***/ (function(module, exports) { + + 'use strict'; + + module.exports = function isCancel(value) { + return !!(value && value.__CANCEL__); + }; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + var normalizeHeaderName = __webpack_require__(11); + + var DEFAULT_CONTENT_TYPE = { + 'Content-Type': 'application/x-www-form-urlencoded' + }; + + function setContentTypeIfUnset(headers, value) { + if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { + headers['Content-Type'] = value; + } + } + + function getDefaultAdapter() { + var adapter; + if (typeof XMLHttpRequest !== 'undefined') { + // For browsers use XHR adapter + adapter = __webpack_require__(12); + } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { + // For node use HTTP adapter + adapter = __webpack_require__(12); + } + return adapter; + } + + var defaults = { + adapter: getDefaultAdapter(), + + transformRequest: [function transformRequest(data, headers) { + normalizeHeaderName(headers, 'Accept'); + normalizeHeaderName(headers, 'Content-Type'); + if (utils.isFormData(data) || + utils.isArrayBuffer(data) || + utils.isBuffer(data) || + utils.isStream(data) || + utils.isFile(data) || + utils.isBlob(data) + ) { + return data; + } + if (utils.isArrayBufferView(data)) { + return data.buffer; + } + if (utils.isURLSearchParams(data)) { + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); + return data.toString(); + } + if (utils.isObject(data)) { + setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); + return JSON.stringify(data); + } + return data; + }], + + transformResponse: [function transformResponse(data) { + /*eslint no-param-reassign:0*/ + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { /* Ignore */ } + } + return data; + }], + + /** + * A timeout in milliseconds to abort a request. If set to 0 (default) a + * timeout is not created. + */ + timeout: 0, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN', + + maxContentLength: -1, + maxBodyLength: -1, + + validateStatus: function validateStatus(status) { + return status >= 200 && status < 300; + } + }; + + defaults.headers = { + common: { + 'Accept': 'application/json, text/plain, */*' + } + }; + + utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { + defaults.headers[method] = {}; + }); + + utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); + }); + + module.exports = defaults; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + module.exports = function normalizeHeaderName(headers, normalizedName) { + utils.forEach(headers, function processHeader(value, name) { + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { + headers[normalizedName] = value; + delete headers[name]; + } + }); + }; + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + var settle = __webpack_require__(13); + var cookies = __webpack_require__(16); + var buildURL = __webpack_require__(5); + var buildFullPath = __webpack_require__(17); + var parseHeaders = __webpack_require__(20); + var isURLSameOrigin = __webpack_require__(21); + var createError = __webpack_require__(14); + + module.exports = function xhrAdapter(config) { + return new Promise(function dispatchXhrRequest(resolve, reject) { + var requestData = config.data; + var requestHeaders = config.headers; + + if (utils.isFormData(requestData)) { + delete requestHeaders['Content-Type']; // Let the browser set it + } + + var request = new XMLHttpRequest(); + + // HTTP basic authentication + if (config.auth) { + var username = config.auth.username || ''; + var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); + } + + var fullPath = buildFullPath(config.baseURL, config.url); + request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); + + // Set the request timeout in MS + request.timeout = config.timeout; + + // Listen for ready state + request.onreadystatechange = function handleLoad() { + if (!request || request.readyState !== 4) { + return; + } + + // The request errored out and we didn't get a response, this will be + // handled by onerror instead + // With one exception: request that using file: protocol, most browsers + // will return status as 0 even though it's a successful request + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { + return; + } + + // Prepare the response + var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; + var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; + var response = { + data: responseData, + status: request.status, + statusText: request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // Clean up request + request = null; + }; + + // Handle browser request cancellation (as opposed to a manual cancellation) + request.onabort = function handleAbort() { + if (!request) { + return; + } + + reject(createError('Request aborted', config, 'ECONNABORTED', request)); + + // Clean up request + request = null; + }; + + // Handle low level network errors + request.onerror = function handleError() { + // Real errors are hidden from us by the browser + // onerror should only fire if it's a network error + reject(createError('Network Error', config, null, request)); + + // Clean up request + request = null; + }; + + // Handle timeout + request.ontimeout = function handleTimeout() { + var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; + if (config.timeoutErrorMessage) { + timeoutErrorMessage = config.timeoutErrorMessage; + } + reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', + request)); + + // Clean up request + request = null; + }; + + // Add xsrf header + // This is only done if running in a standard browser environment. + // Specifically not if we're in a web worker, or react-native. + if (utils.isStandardBrowserEnv()) { + // Add xsrf header + var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? + cookies.read(config.xsrfCookieName) : + undefined; + + if (xsrfValue) { + requestHeaders[config.xsrfHeaderName] = xsrfValue; + } + } + + // Add headers to the request + if ('setRequestHeader' in request) { + utils.forEach(requestHeaders, function setRequestHeader(val, key) { + if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { + // Remove Content-Type if data is undefined + delete requestHeaders[key]; + } else { + // Otherwise add header to the request + request.setRequestHeader(key, val); + } + }); + } + + // Add withCredentials to request if needed + if (!utils.isUndefined(config.withCredentials)) { + request.withCredentials = !!config.withCredentials; + } + + // Add responseType to request if needed + if (config.responseType) { + try { + request.responseType = config.responseType; + } catch (e) { + // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. + // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. + if (config.responseType !== 'json') { + throw e; + } + } + } + + // Handle progress if needed + if (typeof config.onDownloadProgress === 'function') { + request.addEventListener('progress', config.onDownloadProgress); + } + + // Not all browsers support upload events + if (typeof config.onUploadProgress === 'function' && request.upload) { + request.upload.addEventListener('progress', config.onUploadProgress); + } + + if (config.cancelToken) { + // Handle cancellation + config.cancelToken.promise.then(function onCanceled(cancel) { + if (!request) { + return; + } + + request.abort(); + reject(cancel); + // Clean up request + request = null; + }); + } + + if (!requestData) { + requestData = null; + } + + // Send the request + request.send(requestData); + }); + }; + + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var createError = __webpack_require__(14); + + /** + * Resolve or reject a Promise based on response status. + * + * @param {Function} resolve A function that resolves the promise. + * @param {Function} reject A function that rejects the promise. + * @param {object} response The response. + */ + module.exports = function settle(resolve, reject, response) { + var validateStatus = response.config.validateStatus; + if (!response.status || !validateStatus || validateStatus(response.status)) { + resolve(response); + } else { + reject(createError( + 'Request failed with status code ' + response.status, + response.config, + null, + response.request, + response + )); + } + }; + + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var enhanceError = __webpack_require__(15); + + /** + * Create an Error with the specified message, config, error code, request and response. + * + * @param {string} message The error message. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The created error. + */ + module.exports = function createError(message, config, code, request, response) { + var error = new Error(message); + return enhanceError(error, config, code, request, response); + }; + + +/***/ }), +/* 15 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Update an Error with the specified config, error code, and response. + * + * @param {Error} error The error to update. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The error. + */ + module.exports = function enhanceError(error, config, code, request, response) { + error.config = config; + if (code) { + error.code = code; + } + + error.request = request; + error.response = response; + error.isAxiosError = true; + + error.toJSON = function toJSON() { + return { + // Standard + message: this.message, + name: this.name, + // Microsoft + description: this.description, + number: this.number, + // Mozilla + fileName: this.fileName, + lineNumber: this.lineNumber, + columnNumber: this.columnNumber, + stack: this.stack, + // Axios + config: this.config, + code: this.code + }; + }; + return error; + }; + + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + module.exports = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs support document.cookie + (function standardBrowserEnv() { + return { + write: function write(name, value, expires, path, domain, secure) { + var cookie = []; + cookie.push(name + '=' + encodeURIComponent(value)); + + if (utils.isNumber(expires)) { + cookie.push('expires=' + new Date(expires).toGMTString()); + } + + if (utils.isString(path)) { + cookie.push('path=' + path); + } + + if (utils.isString(domain)) { + cookie.push('domain=' + domain); + } + + if (secure === true) { + cookie.push('secure'); + } + + document.cookie = cookie.join('; '); + }, + + read: function read(name) { + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, + + remove: function remove(name) { + this.write(name, '', Date.now() - 86400000); + } + }; + })() : + + // Non standard browser env (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return { + write: function write() {}, + read: function read() { return null; }, + remove: function remove() {} + }; + })() + ); + + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var isAbsoluteURL = __webpack_require__(18); + var combineURLs = __webpack_require__(19); + + /** + * Creates a new URL by combining the baseURL with the requestedURL, + * only when the requestedURL is not already an absolute URL. + * If the requestURL is absolute, this function returns the requestedURL untouched. + * + * @param {string} baseURL The base URL + * @param {string} requestedURL Absolute or relative URL to combine + * @returns {string} The combined full path + */ + module.exports = function buildFullPath(baseURL, requestedURL) { + if (baseURL && !isAbsoluteURL(requestedURL)) { + return combineURLs(baseURL, requestedURL); + } + return requestedURL; + }; + + +/***/ }), +/* 18 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ + module.exports = function isAbsoluteURL(url) { + // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed + // by any combination of letters, digits, plus, period, or hyphen. + return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); + }; + + +/***/ }), +/* 19 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Creates a new URL by combining the specified URLs + * + * @param {string} baseURL The base URL + * @param {string} relativeURL The relative URL + * @returns {string} The combined URL + */ + module.exports = function combineURLs(baseURL, relativeURL) { + return relativeURL + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') + : baseURL; + }; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + // Headers whose duplicates are ignored by node + // c.f. https://nodejs.org/api/http.html#http_message_headers + var ignoreDuplicateOf = [ + 'age', 'authorization', 'content-length', 'content-type', 'etag', + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', + 'last-modified', 'location', 'max-forwards', 'proxy-authorization', + 'referer', 'retry-after', 'user-agent' + ]; + + /** + * Parse headers into an object + * + * ``` + * Date: Wed, 27 Aug 2014 08:58:49 GMT + * Content-Type: application/json + * Connection: keep-alive + * Transfer-Encoding: chunked + * ``` + * + * @param {String} headers Headers needing to be parsed + * @returns {Object} Headers parsed into an object + */ + module.exports = function parseHeaders(headers) { + var parsed = {}; + var key; + var val; + var i; + + if (!headers) { return parsed; } + + utils.forEach(headers.split('\n'), function parser(line) { + i = line.indexOf(':'); + key = utils.trim(line.substr(0, i)).toLowerCase(); + val = utils.trim(line.substr(i + 1)); + + if (key) { + if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { + return; + } + if (key === 'set-cookie') { + parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); + } else { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + } + }); + + return parsed; + }; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + module.exports = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs have full support of the APIs needed to test + // whether the request URL is of the same origin as current location. + (function standardBrowserEnv() { + var msie = /(msie|trident)/i.test(navigator.userAgent); + var urlParsingNode = document.createElement('a'); + var originURL; + + /** + * Parse a URL to discover it's components + * + * @param {String} url The URL to be parsed + * @returns {Object} + */ + function resolveURL(url) { + var href = url; + + if (msie) { + // IE needs attribute set twice to normalize properties + urlParsingNode.setAttribute('href', href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') ? + urlParsingNode.pathname : + '/' + urlParsingNode.pathname + }; + } + + originURL = resolveURL(window.location.href); + + /** + * Determine if a URL shares the same origin as the current location + * + * @param {String} requestURL The URL to test + * @returns {boolean} True if URL shares the same origin, otherwise false + */ + return function isURLSameOrigin(requestURL) { + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; + return (parsed.protocol === originURL.protocol && + parsed.host === originURL.host); + }; + })() : + + // Non standard browser envs (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return function isURLSameOrigin() { + return true; + }; + })() + ); + + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(2); + + /** + * Config-specific merge-function which creates a new config-object + * by merging two configuration objects together. + * + * @param {Object} config1 + * @param {Object} config2 + * @returns {Object} New object resulting from merging config2 to config1 + */ + module.exports = function mergeConfig(config1, config2) { + // eslint-disable-next-line no-param-reassign + config2 = config2 || {}; + var config = {}; + + var valueFromConfig2Keys = ['url', 'method', 'data']; + var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; + var defaultToConfig2Keys = [ + 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', + 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', + 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', + 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', + 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' + ]; + var directMergeKeys = ['validateStatus']; + + function getMergedValue(target, source) { + if (utils.isPlainObject(target) && utils.isPlainObject(source)) { + return utils.merge(target, source); + } else if (utils.isPlainObject(source)) { + return utils.merge({}, source); + } else if (utils.isArray(source)) { + return source.slice(); + } + return source; + } + + function mergeDeepProperties(prop) { + if (!utils.isUndefined(config2[prop])) { + config[prop] = getMergedValue(config1[prop], config2[prop]); + } else if (!utils.isUndefined(config1[prop])) { + config[prop] = getMergedValue(undefined, config1[prop]); + } + } + + utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { + if (!utils.isUndefined(config2[prop])) { + config[prop] = getMergedValue(undefined, config2[prop]); + } + }); + + utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); + + utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { + if (!utils.isUndefined(config2[prop])) { + config[prop] = getMergedValue(undefined, config2[prop]); + } else if (!utils.isUndefined(config1[prop])) { + config[prop] = getMergedValue(undefined, config1[prop]); + } + }); + + utils.forEach(directMergeKeys, function merge(prop) { + if (prop in config2) { + config[prop] = getMergedValue(config1[prop], config2[prop]); + } else if (prop in config1) { + config[prop] = getMergedValue(undefined, config1[prop]); + } + }); + + var axiosKeys = valueFromConfig2Keys + .concat(mergeDeepPropertiesKeys) + .concat(defaultToConfig2Keys) + .concat(directMergeKeys); + + var otherKeys = Object + .keys(config1) + .concat(Object.keys(config2)) + .filter(function filterAxiosKeys(key) { + return axiosKeys.indexOf(key) === -1; + }); + + utils.forEach(otherKeys, mergeDeepProperties); + + return config; + }; + + +/***/ }), +/* 23 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * A `Cancel` is an object that is thrown when an operation is canceled. + * + * @class + * @param {string=} message The message. + */ + function Cancel(message) { + this.message = message; + } + + Cancel.prototype.toString = function toString() { + return 'Cancel' + (this.message ? ': ' + this.message : ''); + }; + + Cancel.prototype.__CANCEL__ = true; + + module.exports = Cancel; + + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var Cancel = __webpack_require__(23); + + /** + * A `CancelToken` is an object that can be used to request cancellation of an operation. + * + * @class + * @param {Function} executor The executor function. + */ + function CancelToken(executor) { + if (typeof executor !== 'function') { + throw new TypeError('executor must be a function.'); + } + + var resolvePromise; + this.promise = new Promise(function promiseExecutor(resolve) { + resolvePromise = resolve; + }); + + var token = this; + executor(function cancel(message) { + if (token.reason) { + // Cancellation has already been requested + return; + } + + token.reason = new Cancel(message); + resolvePromise(token.reason); + }); + } + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + CancelToken.prototype.throwIfRequested = function throwIfRequested() { + if (this.reason) { + throw this.reason; + } + }; + + /** + * Returns an object that contains a new `CancelToken` and a function that, when called, + * cancels the `CancelToken`. + */ + CancelToken.source = function source() { + var cancel; + var token = new CancelToken(function executor(c) { + cancel = c; + }); + return { + token: token, + cancel: cancel + }; + }; + + module.exports = CancelToken; + + +/***/ }), +/* 25 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Syntactic sugar for invoking a function and expanding an array for arguments. + * + * Common use case would be to use `Function.prototype.apply`. + * + * ```js + * function f(x, y, z) {} + * var args = [1, 2, 3]; + * f.apply(null, args); + * ``` + * + * With `spread` this example can be re-written. + * + * ```js + * spread(function(x, y, z) {})([1, 2, 3]); + * ``` + * + * @param {Function} callback + * @returns {Function} + */ + module.exports = function spread(callback) { + return function wrap(arr) { + return callback.apply(null, arr); + }; + }; + + +/***/ }), +/* 26 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Determines whether the payload is an error thrown by Axios + * + * @param {*} payload The value to test + * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false + */ + module.exports = function isAxiosError(payload) { + return (typeof payload === 'object') && (payload.isAxiosError === true); + }; + + +/***/ }) +/******/ ]) +}); +; +//# sourceMappingURL=axios.map \ No newline at end of file diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.map b/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.map new file mode 100644 index 0000000..6d61f7e --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 0ad9e9f79033ec4fb28f","webpack:///./index.js","webpack:///./lib/axios.js","webpack:///./lib/utils.js","webpack:///./lib/helpers/bind.js","webpack:///./lib/core/Axios.js","webpack:///./lib/helpers/buildURL.js","webpack:///./lib/core/InterceptorManager.js","webpack:///./lib/core/dispatchRequest.js","webpack:///./lib/core/transformData.js","webpack:///./lib/cancel/isCancel.js","webpack:///./lib/defaults.js","webpack:///./lib/helpers/normalizeHeaderName.js","webpack:///./lib/adapters/xhr.js","webpack:///./lib/core/settle.js","webpack:///./lib/core/createError.js","webpack:///./lib/core/enhanceError.js","webpack:///./lib/helpers/cookies.js","webpack:///./lib/core/buildFullPath.js","webpack:///./lib/helpers/isAbsoluteURL.js","webpack:///./lib/helpers/combineURLs.js","webpack:///./lib/helpers/parseHeaders.js","webpack:///./lib/helpers/isURLSameOrigin.js","webpack:///./lib/core/mergeConfig.js","webpack:///./lib/cancel/Cancel.js","webpack:///./lib/cancel/CancelToken.js","webpack:///./lib/helpers/spread.js","webpack:///./lib/helpers/isAxiosError.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtCA,yC;;;;;;ACAA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,aAAY,MAAM;AAClB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;;;;;;ACvDA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,aAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,aAAa;AACxB,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oCAAmC,OAAO;AAC1C;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAuB,SAAS,GAAG,SAAS;AAC5C,4BAA2B;AAC3B;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL,6BAA4B;AAC5B,MAAK;AACL;AACA,MAAK;AACL;AACA;AACA;;AAEA,wCAAuC,OAAO;AAC9C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,aAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,aAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC9VA;;AAEA;AACA;AACA;AACA,oBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;;;;;;;ACVA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;;AAEA;AACA;AACA;AACA,IAAG;AACH;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA,0BAAyB;AACzB,MAAK;AACL;AACA,EAAC;;AAED;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA;AACA,MAAK;AACL;AACA,EAAC;;AAED;;;;;;;AC9FA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;AACH;AACA,IAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,QAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP,MAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACrEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,SAAS;AACpB,YAAW,SAAS;AACpB;AACA,aAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;AAEA;;;;;;;ACnDA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gCAA+B;AAC/B,wCAAuC;AACvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAG;AACH;;;;;;;AC9EA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,cAAc;AACzB,YAAW,MAAM;AACjB,YAAW,eAAe;AAC1B,cAAa,EAAE;AACf;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACnBA;;AAEA;AACA;AACA;;;;;;;ACJA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAwE;AACxE;AACA;AACA;AACA,wDAAuD;AACvD;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,QAAO,YAAY;AACnB;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAC;;AAED;AACA;AACA,EAAC;;AAED;;;;;;;ACjGA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;;;;;;ACXA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,6CAA4C;AAC5C;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;AACA;;AAEA;AACA;AACA,IAAG;AACH;;;;;;;AClLA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,SAAS;AACpB,YAAW,SAAS;AACpB,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACxBA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;;;;;;;ACjBA;;AAEA;AACA;AACA;AACA,YAAW,MAAM;AACjB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACzCA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,2CAA0C;AAC1C,UAAS;;AAET;AACA,6DAA4D,wBAAwB;AACpF;AACA,UAAS;;AAET;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;AACA;AACA,mCAAkC;AAClC,gCAA+B,aAAa,EAAE;AAC9C;AACA;AACA,MAAK;AACL;;;;;;;ACpDA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACnBA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACbA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;;;;;;ACbA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAiB,eAAe;;AAEhC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACpDA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;;;;;;;ACnEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL,4BAA2B;AAC3B,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAG;;AAEH;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAK;;AAEL;;AAEA;AACA;;;;;;;ACtFA;;AAEA;AACA;AACA;AACA;AACA,YAAW,QAAQ;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;;;;;;AClBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACxDA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAA+B;AAC/B;AACA;AACA,YAAW,SAAS;AACpB,cAAa;AACb;AACA;AACA;AACA;AACA;AACA;;;;;;;AC1BA;;AAEA;AACA;AACA;AACA,YAAW,EAAE;AACb,cAAa,QAAQ;AACrB;AACA;AACA;AACA","file":"axios.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axios\"] = factory();\n\telse\n\t\troot[\"axios\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 0ad9e9f79033ec4fb28f","module.exports = require('./lib/axios');\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./index.js\n// module id = 0\n// module chunks = 0","'use strict';\n\nvar utils = require('./utils');\nvar bind = require('./helpers/bind');\nvar Axios = require('./core/Axios');\nvar mergeConfig = require('./core/mergeConfig');\nvar defaults = require('./defaults');\n\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n * @return {Axios} A new instance of Axios\n */\nfunction createInstance(defaultConfig) {\n var context = new Axios(defaultConfig);\n var instance = bind(Axios.prototype.request, context);\n\n // Copy axios.prototype to instance\n utils.extend(instance, Axios.prototype, context);\n\n // Copy context to instance\n utils.extend(instance, context);\n\n return instance;\n}\n\n// Create the default instance to be exported\nvar axios = createInstance(defaults);\n\n// Expose Axios class to allow class inheritance\naxios.Axios = Axios;\n\n// Factory for creating new instances\naxios.create = function create(instanceConfig) {\n return createInstance(mergeConfig(axios.defaults, instanceConfig));\n};\n\n// Expose Cancel & CancelToken\naxios.Cancel = require('./cancel/Cancel');\naxios.CancelToken = require('./cancel/CancelToken');\naxios.isCancel = require('./cancel/isCancel');\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\n// Expose isAxiosError\naxios.isAxiosError = require('./helpers/isAxiosError');\n\nmodule.exports = axios;\n\n// Allow use of default import syntax in TypeScript\nmodule.exports.default = axios;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/axios.js\n// module id = 1\n// module chunks = 0","'use strict';\n\nvar bind = require('./helpers/bind');\n\n/*global toString:true*/\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is a Buffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Buffer, otherwise false\n */\nfunction isBuffer(val) {\n return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)\n && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return (typeof FormData !== 'undefined') && (val instanceof FormData);\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a plain Object\n *\n * @param {Object} val The value to test\n * @return {boolean} True if value is a plain Object, otherwise false\n */\nfunction isPlainObject(val) {\n if (toString.call(val) !== '[object Object]') {\n return false;\n }\n\n var prototype = Object.getPrototypeOf(val);\n return prototype === null || prototype === Object.prototype;\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Determine if a value is a Function\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\nfunction isFunction(val) {\n return toString.call(val) === '[object Function]';\n}\n\n/**\n * Determine if a value is a Stream\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Stream, otherwise false\n */\nfunction isStream(val) {\n return isObject(val) && isFunction(val.pipe);\n}\n\n/**\n * Determine if a value is a URLSearchParams object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n */\nfunction isURLSearchParams(val) {\n return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * navigator.product -> 'ReactNative'\n * nativescript\n * navigator.product -> 'NativeScript' or 'NS'\n */\nfunction isStandardBrowserEnv() {\n if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||\n navigator.product === 'NativeScript' ||\n navigator.product === 'NS')) {\n return false;\n }\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object') {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (isPlainObject(result[key]) && isPlainObject(val)) {\n result[key] = merge(result[key], val);\n } else if (isPlainObject(val)) {\n result[key] = merge({}, val);\n } else if (isArray(val)) {\n result[key] = val.slice();\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\n/**\n * Extends object a by mutably adding to it the properties of object b.\n *\n * @param {Object} a The object to be extended\n * @param {Object} b The object to copy properties from\n * @param {Object} thisArg The object to bind function to\n * @return {Object} The resulting value of object a\n */\nfunction extend(a, b, thisArg) {\n forEach(b, function assignValue(val, key) {\n if (thisArg && typeof val === 'function') {\n a[key] = bind(val, thisArg);\n } else {\n a[key] = val;\n }\n });\n return a;\n}\n\n/**\n * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)\n *\n * @param {string} content with BOM\n * @return {string} content value without BOM\n */\nfunction stripBOM(content) {\n if (content.charCodeAt(0) === 0xFEFF) {\n content = content.slice(1);\n }\n return content;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isBuffer: isBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isPlainObject: isPlainObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isFunction: isFunction,\n isStream: isStream,\n isURLSearchParams: isURLSearchParams,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n extend: extend,\n trim: trim,\n stripBOM: stripBOM\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/utils.js\n// module id = 2\n// module chunks = 0","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/bind.js\n// module id = 3\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar buildURL = require('../helpers/buildURL');\nvar InterceptorManager = require('./InterceptorManager');\nvar dispatchRequest = require('./dispatchRequest');\nvar mergeConfig = require('./mergeConfig');\n\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n */\nfunction Axios(instanceConfig) {\n this.defaults = instanceConfig;\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\n/**\n * Dispatch a request\n *\n * @param {Object} config The config specific for this request (merged with this.defaults)\n */\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = arguments[1] || {};\n config.url = arguments[0];\n } else {\n config = config || {};\n }\n\n config = mergeConfig(this.defaults, config);\n\n // Set config.method\n if (config.method) {\n config.method = config.method.toLowerCase();\n } else if (this.defaults.method) {\n config.method = this.defaults.method.toLowerCase();\n } else {\n config.method = 'get';\n }\n\n // Hook up interceptors middleware\n var chain = [dispatchRequest, undefined];\n var promise = Promise.resolve(config);\n\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n chain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n chain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n};\n\nAxios.prototype.getUri = function getUri(config) {\n config = mergeConfig(this.defaults, config);\n return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\\?/, '');\n};\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: (config || {}).data\n }));\n };\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n});\n\nmodule.exports = Axios;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/Axios.js\n// module id = 4\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nfunction encode(val) {\n return encodeURIComponent(val).\n replace(/%3A/gi, ':').\n replace(/%24/g, '$').\n replace(/%2C/gi, ',').\n replace(/%20/g, '+').\n replace(/%5B/gi, '[').\n replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @returns {string} The formatted url\n */\nmodule.exports = function buildURL(url, params, paramsSerializer) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n\n var serializedParams;\n if (paramsSerializer) {\n serializedParams = paramsSerializer(params);\n } else if (utils.isURLSearchParams(params)) {\n serializedParams = params.toString();\n } else {\n var parts = [];\n\n utils.forEach(params, function serialize(val, key) {\n if (val === null || typeof val === 'undefined') {\n return;\n }\n\n if (utils.isArray(val)) {\n key = key + '[]';\n } else {\n val = [val];\n }\n\n utils.forEach(val, function parseValue(v) {\n if (utils.isDate(v)) {\n v = v.toISOString();\n } else if (utils.isObject(v)) {\n v = JSON.stringify(v);\n }\n parts.push(encode(key) + '=' + encode(v));\n });\n });\n\n serializedParams = parts.join('&');\n }\n\n if (serializedParams) {\n var hashmarkIndex = url.indexOf('#');\n if (hashmarkIndex !== -1) {\n url = url.slice(0, hashmarkIndex);\n }\n\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/buildURL.js\n// module id = 5\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/InterceptorManager.js\n// module id = 6\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar transformData = require('./transformData');\nvar isCancel = require('../cancel/isCancel');\nvar defaults = require('../defaults');\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nfunction throwIfCancellationRequested(config) {\n if (config.cancelToken) {\n config.cancelToken.throwIfRequested();\n }\n}\n\n/**\n * Dispatch a request to the server using the configured adapter.\n *\n * @param {object} config The config that is to be used for the request\n * @returns {Promise} The Promise to be fulfilled\n */\nmodule.exports = function dispatchRequest(config) {\n throwIfCancellationRequested(config);\n\n // Ensure headers exist\n config.headers = config.headers || {};\n\n // Transform request data\n config.data = transformData(\n config.data,\n config.headers,\n config.transformRequest\n );\n\n // Flatten headers\n config.headers = utils.merge(\n config.headers.common || {},\n config.headers[config.method] || {},\n config.headers\n );\n\n utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n function cleanHeaderConfig(method) {\n delete config.headers[method];\n }\n );\n\n var adapter = config.adapter || defaults.adapter;\n\n return adapter(config).then(function onAdapterResolution(response) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n response.data = transformData(\n response.data,\n response.headers,\n config.transformResponse\n );\n\n return response;\n }, function onAdapterRejection(reason) {\n if (!isCancel(reason)) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n if (reason && reason.response) {\n reason.response.data = transformData(\n reason.response.data,\n reason.response.headers,\n config.transformResponse\n );\n }\n }\n\n return Promise.reject(reason);\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/dispatchRequest.js\n// module id = 7\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Object|String} data The data to be transformed\n * @param {Array} headers The headers for the request or response\n * @param {Array|Function} fns A single function or Array of functions\n * @returns {*} The resulting transformed data\n */\nmodule.exports = function transformData(data, headers, fns) {\n /*eslint no-param-reassign:0*/\n utils.forEach(fns, function transform(fn) {\n data = fn(data, headers);\n });\n\n return data;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/transformData.js\n// module id = 8\n// module chunks = 0","'use strict';\n\nmodule.exports = function isCancel(value) {\n return !!(value && value.__CANCEL__);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/isCancel.js\n// module id = 9\n// module chunks = 0","'use strict';\n\nvar utils = require('./utils');\nvar normalizeHeaderName = require('./helpers/normalizeHeaderName');\n\nvar DEFAULT_CONTENT_TYPE = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nfunction setContentTypeIfUnset(headers, value) {\n if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n headers['Content-Type'] = value;\n }\n}\n\nfunction getDefaultAdapter() {\n var adapter;\n if (typeof XMLHttpRequest !== 'undefined') {\n // For browsers use XHR adapter\n adapter = require('./adapters/xhr');\n } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {\n // For node use HTTP adapter\n adapter = require('./adapters/http');\n }\n return adapter;\n}\n\nvar defaults = {\n adapter: getDefaultAdapter(),\n\n transformRequest: [function transformRequest(data, headers) {\n normalizeHeaderName(headers, 'Accept');\n normalizeHeaderName(headers, 'Content-Type');\n if (utils.isFormData(data) ||\n utils.isArrayBuffer(data) ||\n utils.isBuffer(data) ||\n utils.isStream(data) ||\n utils.isFile(data) ||\n utils.isBlob(data)\n ) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isURLSearchParams(data)) {\n setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n return data.toString();\n }\n if (utils.isObject(data)) {\n setContentTypeIfUnset(headers, 'application/json;charset=utf-8');\n return JSON.stringify(data);\n }\n return data;\n }],\n\n transformResponse: [function transformResponse(data) {\n /*eslint no-param-reassign:0*/\n if (typeof data === 'string') {\n try {\n data = JSON.parse(data);\n } catch (e) { /* Ignore */ }\n }\n return data;\n }],\n\n /**\n * A timeout in milliseconds to abort a request. If set to 0 (default) a\n * timeout is not created.\n */\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n\n maxContentLength: -1,\n maxBodyLength: -1,\n\n validateStatus: function validateStatus(status) {\n return status >= 200 && status < 300;\n }\n};\n\ndefaults.headers = {\n common: {\n 'Accept': 'application/json, text/plain, */*'\n }\n};\n\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n defaults.headers[method] = {};\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n});\n\nmodule.exports = defaults;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/defaults.js\n// module id = 10\n// module chunks = 0","'use strict';\n\nvar utils = require('../utils');\n\nmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n utils.forEach(headers, function processHeader(value, name) {\n if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n headers[normalizedName] = value;\n delete headers[name];\n }\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/normalizeHeaderName.js\n// module id = 11\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar settle = require('./../core/settle');\nvar cookies = require('./../helpers/cookies');\nvar buildURL = require('./../helpers/buildURL');\nvar buildFullPath = require('../core/buildFullPath');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar createError = require('../core/createError');\n\nmodule.exports = function xhrAdapter(config) {\n return new Promise(function dispatchXhrRequest(resolve, reject) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n var fullPath = buildFullPath(config.baseURL, config.url);\n request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n // Listen for ready state\n request.onreadystatechange = function handleLoad() {\n if (!request || request.readyState !== 4) {\n return;\n }\n\n // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n // With one exception: request that using file: protocol, most browsers\n // will return status as 0 even though it's a successful request\n if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n return;\n }\n\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n var response = {\n data: responseData,\n status: request.status,\n statusText: request.statusText,\n headers: responseHeaders,\n config: config,\n request: request\n };\n\n settle(resolve, reject, response);\n\n // Clean up request\n request = null;\n };\n\n // Handle browser request cancellation (as opposed to a manual cancellation)\n request.onabort = function handleAbort() {\n if (!request) {\n return;\n }\n\n reject(createError('Request aborted', config, 'ECONNABORTED', request));\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(createError('Network Error', config, null, request));\n\n // Clean up request\n request = null;\n };\n\n // Handle timeout\n request.ontimeout = function handleTimeout() {\n var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';\n if (config.timeoutErrorMessage) {\n timeoutErrorMessage = config.timeoutErrorMessage;\n }\n reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',\n request));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n // Add xsrf header\n var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (!utils.isUndefined(config.withCredentials)) {\n request.withCredentials = !!config.withCredentials;\n }\n\n // Add responseType to request if needed\n if (config.responseType) {\n try {\n request.responseType = config.responseType;\n } catch (e) {\n // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n if (config.responseType !== 'json') {\n throw e;\n }\n }\n }\n\n // Handle progress if needed\n if (typeof config.onDownloadProgress === 'function') {\n request.addEventListener('progress', config.onDownloadProgress);\n }\n\n // Not all browsers support upload events\n if (typeof config.onUploadProgress === 'function' && request.upload) {\n request.upload.addEventListener('progress', config.onUploadProgress);\n }\n\n if (config.cancelToken) {\n // Handle cancellation\n config.cancelToken.promise.then(function onCanceled(cancel) {\n if (!request) {\n return;\n }\n\n request.abort();\n reject(cancel);\n // Clean up request\n request = null;\n });\n }\n\n if (!requestData) {\n requestData = null;\n }\n\n // Send the request\n request.send(requestData);\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/adapters/xhr.js\n// module id = 12\n// module chunks = 0","'use strict';\n\nvar createError = require('./createError');\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n */\nmodule.exports = function settle(resolve, reject, response) {\n var validateStatus = response.config.validateStatus;\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(createError(\n 'Request failed with status code ' + response.status,\n response.config,\n null,\n response.request,\n response\n ));\n }\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/settle.js\n// module id = 13\n// module chunks = 0","'use strict';\n\nvar enhanceError = require('./enhanceError');\n\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The created error.\n */\nmodule.exports = function createError(message, config, code, request, response) {\n var error = new Error(message);\n return enhanceError(error, config, code, request, response);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/createError.js\n// module id = 14\n// module chunks = 0","'use strict';\n\n/**\n * Update an Error with the specified config, error code, and response.\n *\n * @param {Error} error The error to update.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The error.\n */\nmodule.exports = function enhanceError(error, config, code, request, response) {\n error.config = config;\n if (code) {\n error.code = code;\n }\n\n error.request = request;\n error.response = response;\n error.isAxiosError = true;\n\n error.toJSON = function toJSON() {\n return {\n // Standard\n message: this.message,\n name: this.name,\n // Microsoft\n description: this.description,\n number: this.number,\n // Mozilla\n fileName: this.fileName,\n lineNumber: this.lineNumber,\n columnNumber: this.columnNumber,\n stack: this.stack,\n // Axios\n config: this.config,\n code: this.code\n };\n };\n return error;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/enhanceError.js\n// module id = 15\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs support document.cookie\n (function standardBrowserEnv() {\n return {\n write: function write(name, value, expires, path, domain, secure) {\n var cookie = [];\n cookie.push(name + '=' + encodeURIComponent(value));\n\n if (utils.isNumber(expires)) {\n cookie.push('expires=' + new Date(expires).toGMTString());\n }\n\n if (utils.isString(path)) {\n cookie.push('path=' + path);\n }\n\n if (utils.isString(domain)) {\n cookie.push('domain=' + domain);\n }\n\n if (secure === true) {\n cookie.push('secure');\n }\n\n document.cookie = cookie.join('; ');\n },\n\n read: function read(name) {\n var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove: function remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n };\n })() :\n\n // Non standard browser env (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return {\n write: function write() {},\n read: function read() { return null; },\n remove: function remove() {}\n };\n })()\n);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/cookies.js\n// module id = 16\n// module chunks = 0","'use strict';\n\nvar isAbsoluteURL = require('../helpers/isAbsoluteURL');\nvar combineURLs = require('../helpers/combineURLs');\n\n/**\n * Creates a new URL by combining the baseURL with the requestedURL,\n * only when the requestedURL is not already an absolute URL.\n * If the requestURL is absolute, this function returns the requestedURL untouched.\n *\n * @param {string} baseURL The base URL\n * @param {string} requestedURL Absolute or relative URL to combine\n * @returns {string} The combined full path\n */\nmodule.exports = function buildFullPath(baseURL, requestedURL) {\n if (baseURL && !isAbsoluteURL(requestedURL)) {\n return combineURLs(baseURL, requestedURL);\n }\n return requestedURL;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/buildFullPath.js\n// module id = 17\n// module chunks = 0","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nmodule.exports = function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isAbsoluteURL.js\n// module id = 18\n// module chunks = 0","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n * @returns {string} The combined URL\n */\nmodule.exports = function combineURLs(baseURL, relativeURL) {\n return relativeURL\n ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n : baseURL;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/combineURLs.js\n// module id = 19\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\n// Headers whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\nvar ignoreDuplicateOf = [\n 'age', 'authorization', 'content-length', 'content-type', 'etag',\n 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n 'referer', 'retry-after', 'user-agent'\n];\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n return;\n }\n if (key === 'set-cookie') {\n parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n } else {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n }\n });\n\n return parsed;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/parseHeaders.js\n// module id = 20\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isURLSameOrigin.js\n// module id = 21\n// module chunks = 0","'use strict';\n\nvar utils = require('../utils');\n\n/**\n * Config-specific merge-function which creates a new config-object\n * by merging two configuration objects together.\n *\n * @param {Object} config1\n * @param {Object} config2\n * @returns {Object} New object resulting from merging config2 to config1\n */\nmodule.exports = function mergeConfig(config1, config2) {\n // eslint-disable-next-line no-param-reassign\n config2 = config2 || {};\n var config = {};\n\n var valueFromConfig2Keys = ['url', 'method', 'data'];\n var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];\n var defaultToConfig2Keys = [\n 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',\n 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',\n 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',\n 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',\n 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'\n ];\n var directMergeKeys = ['validateStatus'];\n\n function getMergedValue(target, source) {\n if (utils.isPlainObject(target) && utils.isPlainObject(source)) {\n return utils.merge(target, source);\n } else if (utils.isPlainObject(source)) {\n return utils.merge({}, source);\n } else if (utils.isArray(source)) {\n return source.slice();\n }\n return source;\n }\n\n function mergeDeepProperties(prop) {\n if (!utils.isUndefined(config2[prop])) {\n config[prop] = getMergedValue(config1[prop], config2[prop]);\n } else if (!utils.isUndefined(config1[prop])) {\n config[prop] = getMergedValue(undefined, config1[prop]);\n }\n }\n\n utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {\n if (!utils.isUndefined(config2[prop])) {\n config[prop] = getMergedValue(undefined, config2[prop]);\n }\n });\n\n utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);\n\n utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {\n if (!utils.isUndefined(config2[prop])) {\n config[prop] = getMergedValue(undefined, config2[prop]);\n } else if (!utils.isUndefined(config1[prop])) {\n config[prop] = getMergedValue(undefined, config1[prop]);\n }\n });\n\n utils.forEach(directMergeKeys, function merge(prop) {\n if (prop in config2) {\n config[prop] = getMergedValue(config1[prop], config2[prop]);\n } else if (prop in config1) {\n config[prop] = getMergedValue(undefined, config1[prop]);\n }\n });\n\n var axiosKeys = valueFromConfig2Keys\n .concat(mergeDeepPropertiesKeys)\n .concat(defaultToConfig2Keys)\n .concat(directMergeKeys);\n\n var otherKeys = Object\n .keys(config1)\n .concat(Object.keys(config2))\n .filter(function filterAxiosKeys(key) {\n return axiosKeys.indexOf(key) === -1;\n });\n\n utils.forEach(otherKeys, mergeDeepProperties);\n\n return config;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/mergeConfig.js\n// module id = 22\n// module chunks = 0","'use strict';\n\n/**\n * A `Cancel` is an object that is thrown when an operation is canceled.\n *\n * @class\n * @param {string=} message The message.\n */\nfunction Cancel(message) {\n this.message = message;\n}\n\nCancel.prototype.toString = function toString() {\n return 'Cancel' + (this.message ? ': ' + this.message : '');\n};\n\nCancel.prototype.__CANCEL__ = true;\n\nmodule.exports = Cancel;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/Cancel.js\n// module id = 23\n// module chunks = 0","'use strict';\n\nvar Cancel = require('./Cancel');\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @class\n * @param {Function} executor The executor function.\n */\nfunction CancelToken(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n var resolvePromise;\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n\n var token = this;\n executor(function cancel(message) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new Cancel(message);\n resolvePromise(token.reason);\n });\n}\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n};\n\n/**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\nCancelToken.source = function source() {\n var cancel;\n var token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token: token,\n cancel: cancel\n };\n};\n\nmodule.exports = CancelToken;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/CancelToken.js\n// module id = 24\n// module chunks = 0","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n * @returns {Function}\n */\nmodule.exports = function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/spread.js\n// module id = 25\n// module chunks = 0","'use strict';\n\n/**\n * Determines whether the payload is an error thrown by Axios\n *\n * @param {*} payload The value to test\n * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false\n */\nmodule.exports = function isAxiosError(payload) {\n return (typeof payload === 'object') && (payload.isAxiosError === true);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isAxiosError.js\n// module id = 26\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.min.js b/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.min.js new file mode 100644 index 0000000..fc6c8b6 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.min.js @@ -0,0 +1,3 @@ +/* axios v0.21.1 | (c) 2020 by Matt Zabriskie */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new i(e),n=s(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var o=n(2),s=n(3),i=n(4),a=n(22),u=n(10),c=r(u);c.Axios=i,c.create=function(e){return r(a(c.defaults,e))},c.Cancel=n(23),c.CancelToken=n(24),c.isCancel=n(9),c.all=function(e){return Promise.all(e)},c.spread=n(25),c.isAxiosError=n(26),e.exports=c,e.exports.default=c},function(e,t,n){"use strict";function r(e){return"[object Array]"===R.call(e)}function o(e){return"undefined"==typeof e}function s(e){return null!==e&&!o(e)&&null!==e.constructor&&!o(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function i(e){return"[object ArrayBuffer]"===R.call(e)}function a(e){return"undefined"!=typeof FormData&&e instanceof FormData}function u(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function c(e){return"string"==typeof e}function f(e){return"number"==typeof e}function p(e){return null!==e&&"object"==typeof e}function d(e){if("[object Object]"!==R.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function l(e){return"[object Date]"===R.call(e)}function h(e){return"[object File]"===R.call(e)}function m(e){return"[object Blob]"===R.call(e)}function y(e){return"[object Function]"===R.call(e)}function g(e){return p(e)&&y(e.pipe)}function v(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function x(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function w(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function b(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},s.forEach(["delete","get","head"],function(e){u.headers[e]={}}),s.forEach(["post","put","patch"],function(e){u.headers[e]=s.merge(a)}),e.exports=u},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(13),s=n(16),i=n(5),a=n(17),u=n(20),c=n(21),f=n(14);e.exports=function(e){return new Promise(function(t,n){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var h=e.auth.username||"",m=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(h+":"+m)}var y=a(e.baseURL,e.url);if(l.open(e.method.toUpperCase(),i(y,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l.onreadystatechange=function(){if(l&&4===l.readyState&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in l?u(l.getAllResponseHeaders()):null,s=e.responseType&&"text"!==e.responseType?l.response:l.responseText,i={data:s,status:l.status,statusText:l.statusText,headers:r,config:e,request:l};o(t,n,i),l=null}},l.onabort=function(){l&&(n(f("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){n(f("Network Error",e,null,l)),l=null},l.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(f(t,e,"ECONNABORTED",l)),l=null},r.isStandardBrowserEnv()){var g=(e.withCredentials||c(y))&&e.xsrfCookieName?s.read(e.xsrfCookieName):void 0;g&&(d[e.xsrfHeaderName]=g)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),r.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),e.responseType)try{l.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),n(e),l=null)}),p||(p=null),l.send(p)})}},function(e,t,n){"use strict";var r=n(14);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(15);e.exports=function(e,t,n,o,s){var i=new Error(e);return r(i,t,n,o,s)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";var r=n(18),o=n(19);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,s,i={};return e?(r.forEach(e.split("\n"),function(e){if(s=e.indexOf(":"),t=r.trim(e.substr(0,s)).toLowerCase(),n=r.trim(e.substr(s+1)),t){if(i[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?i[t]=(i[t]?i[t]:[]).concat([n]):i[t]=i[t]?i[t]+", "+n:n}}),i):i}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){function n(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function o(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(s[o]=n(void 0,e[o])):s[o]=n(e[o],t[o])}t=t||{};var s={},i=["url","method","data"],a=["headers","auth","proxy","params"],u=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],c=["validateStatus"];r.forEach(i,function(e){r.isUndefined(t[e])||(s[e]=n(void 0,t[e]))}),r.forEach(a,o),r.forEach(u,function(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(s[o]=n(void 0,e[o])):s[o]=n(void 0,t[o])}),r.forEach(c,function(r){r in t?s[r]=n(e[r],t[r]):r in e&&(s[r]=n(void 0,e[r]))});var f=i.concat(a).concat(u).concat(c),p=Object.keys(e).concat(Object.keys(t)).filter(function(e){return f.indexOf(e)===-1});return r.forEach(p,o),s}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t){"use strict";e.exports=function(e){return"object"==typeof e&&e.isAxiosError===!0}}])}); +//# sourceMappingURL=axios.min.map \ No newline at end of file diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.min.map b/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.min.map new file mode 100644 index 0000000..a897631 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/dist/axios.min.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///axios.min.js","webpack:///webpack/bootstrap 081842adca0968bb3270","webpack:///./index.js","webpack:///./lib/axios.js","webpack:///./lib/utils.js","webpack:///./lib/helpers/bind.js","webpack:///./lib/core/Axios.js","webpack:///./lib/helpers/buildURL.js","webpack:///./lib/core/InterceptorManager.js","webpack:///./lib/core/dispatchRequest.js","webpack:///./lib/core/transformData.js","webpack:///./lib/cancel/isCancel.js","webpack:///./lib/defaults.js","webpack:///./lib/helpers/normalizeHeaderName.js","webpack:///./lib/adapters/xhr.js","webpack:///./lib/core/settle.js","webpack:///./lib/core/createError.js","webpack:///./lib/core/enhanceError.js","webpack:///./lib/helpers/cookies.js","webpack:///./lib/core/buildFullPath.js","webpack:///./lib/helpers/isAbsoluteURL.js","webpack:///./lib/helpers/combineURLs.js","webpack:///./lib/helpers/parseHeaders.js","webpack:///./lib/helpers/isURLSameOrigin.js","webpack:///./lib/core/mergeConfig.js","webpack:///./lib/cancel/Cancel.js","webpack:///./lib/cancel/CancelToken.js","webpack:///./lib/helpers/spread.js","webpack:///./lib/helpers/isAxiosError.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","createInstance","defaultConfig","context","Axios","instance","bind","prototype","request","utils","extend","mergeConfig","defaults","axios","create","instanceConfig","Cancel","CancelToken","isCancel","all","promises","Promise","spread","isAxiosError","default","isArray","val","toString","isUndefined","isBuffer","constructor","isArrayBuffer","isFormData","FormData","isArrayBufferView","result","ArrayBuffer","isView","buffer","isString","isNumber","isObject","isPlainObject","Object","getPrototypeOf","isDate","isFile","isBlob","isFunction","isStream","pipe","isURLSearchParams","URLSearchParams","trim","str","replace","isStandardBrowserEnv","navigator","product","window","document","forEach","obj","fn","i","l","length","key","hasOwnProperty","merge","assignValue","slice","arguments","a","b","thisArg","stripBOM","content","charCodeAt","args","Array","apply","interceptors","InterceptorManager","response","buildURL","dispatchRequest","config","url","method","toLowerCase","chain","undefined","promise","resolve","interceptor","unshift","fulfilled","rejected","push","then","shift","getUri","params","paramsSerializer","data","encode","encodeURIComponent","serializedParams","parts","v","toISOString","JSON","stringify","join","hashmarkIndex","indexOf","handlers","use","eject","h","throwIfCancellationRequested","cancelToken","throwIfRequested","transformData","headers","transformRequest","common","adapter","transformResponse","reason","reject","fns","value","__CANCEL__","setContentTypeIfUnset","getDefaultAdapter","XMLHttpRequest","process","normalizeHeaderName","DEFAULT_CONTENT_TYPE","Content-Type","parse","e","timeout","xsrfCookieName","xsrfHeaderName","maxContentLength","maxBodyLength","validateStatus","status","Accept","normalizedName","name","toUpperCase","settle","cookies","buildFullPath","parseHeaders","isURLSameOrigin","createError","requestData","requestHeaders","auth","username","password","unescape","Authorization","btoa","fullPath","baseURL","open","onreadystatechange","readyState","responseURL","responseHeaders","getAllResponseHeaders","responseData","responseType","responseText","statusText","onabort","onerror","ontimeout","timeoutErrorMessage","xsrfValue","withCredentials","read","setRequestHeader","onDownloadProgress","addEventListener","onUploadProgress","upload","cancel","abort","send","enhanceError","message","code","error","Error","toJSON","description","number","fileName","lineNumber","columnNumber","stack","write","expires","path","domain","secure","cookie","Date","toGMTString","match","RegExp","decodeURIComponent","remove","now","isAbsoluteURL","combineURLs","requestedURL","test","relativeURL","ignoreDuplicateOf","parsed","split","line","substr","concat","resolveURL","href","msie","urlParsingNode","setAttribute","protocol","host","search","hash","hostname","port","pathname","charAt","originURL","userAgent","createElement","location","requestURL","config1","config2","getMergedValue","target","source","mergeDeepProperties","prop","valueFromConfig2Keys","mergeDeepPropertiesKeys","defaultToConfig2Keys","directMergeKeys","axiosKeys","otherKeys","keys","filter","executor","TypeError","resolvePromise","token","callback","arr","payload"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,MAAAD,IAEAD,EAAA,MAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAP,WACAS,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,QAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAAUL,EAAQD,EAASM,GEtDjCL,EAAAD,QAAAM,EAAA,IF4DM,SAAUL,EAAQD,EAASM,GG5DjC,YAcA,SAAAS,GAAAC,GACA,GAAAC,GAAA,GAAAC,GAAAF,GACAG,EAAAC,EAAAF,EAAAG,UAAAC,QAAAL,EAQA,OALAM,GAAAC,OAAAL,EAAAD,EAAAG,UAAAJ,GAGAM,EAAAC,OAAAL,EAAAF,GAEAE,EAtBA,GAAAI,GAAAjB,EAAA,GACAc,EAAAd,EAAA,GACAY,EAAAZ,EAAA,GACAmB,EAAAnB,EAAA,IACAoB,EAAApB,EAAA,IAsBAqB,EAAAZ,EAAAW,EAGAC,GAAAT,QAGAS,EAAAC,OAAA,SAAAC,GACA,MAAAd,GAAAU,EAAAE,EAAAD,SAAAG,KAIAF,EAAAG,OAAAxB,EAAA,IACAqB,EAAAI,YAAAzB,EAAA,IACAqB,EAAAK,SAAA1B,EAAA,GAGAqB,EAAAM,IAAA,SAAAC,GACA,MAAAC,SAAAF,IAAAC,IAEAP,EAAAS,OAAA9B,EAAA,IAGAqB,EAAAU,aAAA/B,EAAA,IAEAL,EAAAD,QAAA2B,EAGA1B,EAAAD,QAAAsC,QAAAX,GHmEM,SAAU1B,EAAQD,EAASM,GI1HjC,YAgBA,SAAAiC,GAAAC,GACA,yBAAAC,EAAA9B,KAAA6B,GASA,QAAAE,GAAAF,GACA,yBAAAA,GASA,QAAAG,GAAAH,GACA,cAAAA,IAAAE,EAAAF,IAAA,OAAAA,EAAAI,cAAAF,EAAAF,EAAAI,cACA,kBAAAJ,GAAAI,YAAAD,UAAAH,EAAAI,YAAAD,SAAAH,GASA,QAAAK,GAAAL,GACA,+BAAAC,EAAA9B,KAAA6B,GASA,QAAAM,GAAAN,GACA,yBAAAO,WAAAP,YAAAO,UASA,QAAAC,GAAAR,GACA,GAAAS,EAMA,OAJAA,GADA,mBAAAC,0BAAA,OACAA,YAAAC,OAAAX,GAEA,GAAAA,EAAA,QAAAA,EAAAY,iBAAAF,aAWA,QAAAG,GAAAb,GACA,sBAAAA,GASA,QAAAc,GAAAd,GACA,sBAAAA,GASA,QAAAe,GAAAf,GACA,cAAAA,GAAA,gBAAAA,GASA,QAAAgB,GAAAhB,GACA,uBAAAC,EAAA9B,KAAA6B,GACA,QAGA,IAAAnB,GAAAoC,OAAAC,eAAAlB,EACA,eAAAnB,OAAAoC,OAAApC,UASA,QAAAsC,GAAAnB,GACA,wBAAAC,EAAA9B,KAAA6B,GASA,QAAAoB,GAAApB,GACA,wBAAAC,EAAA9B,KAAA6B,GASA,QAAAqB,GAAArB,GACA,wBAAAC,EAAA9B,KAAA6B,GASA,QAAAsB,GAAAtB,GACA,4BAAAC,EAAA9B,KAAA6B,GASA,QAAAuB,GAAAvB,GACA,MAAAe,GAAAf,IAAAsB,EAAAtB,EAAAwB,MASA,QAAAC,GAAAzB,GACA,yBAAA0B,kBAAA1B,YAAA0B,iBASA,QAAAC,GAAAC,GACA,MAAAA,GAAAC,QAAA,WAAAA,QAAA,WAkBA,QAAAC,KACA,0BAAAC,YAAA,gBAAAA,UAAAC,SACA,iBAAAD,UAAAC,SACA,OAAAD,UAAAC,WAIA,mBAAAC,SACA,mBAAAC,WAgBA,QAAAC,GAAAC,EAAAC,GAEA,UAAAD,GAAA,mBAAAA,GAUA,GALA,gBAAAA,KAEAA,OAGArC,EAAAqC,GAEA,OAAAE,GAAA,EAAAC,EAAAH,EAAAI,OAAmCF,EAAAC,EAAOD,IAC1CD,EAAAlE,KAAA,KAAAiE,EAAAE,KAAAF,OAIA,QAAAK,KAAAL,GACAnB,OAAApC,UAAA6D,eAAAvE,KAAAiE,EAAAK,IACAJ,EAAAlE,KAAA,KAAAiE,EAAAK,KAAAL,GAuBA,QAAAO,KAEA,QAAAC,GAAA5C,EAAAyC,GACAzB,EAAAP,EAAAgC,KAAAzB,EAAAhB,GACAS,EAAAgC,GAAAE,EAAAlC,EAAAgC,GAAAzC,GACKgB,EAAAhB,GACLS,EAAAgC,GAAAE,KAA4B3C,GACvBD,EAAAC,GACLS,EAAAgC,GAAAzC,EAAA6C,QAEApC,EAAAgC,GAAAzC,EAIA,OAbAS,MAaA6B,EAAA,EAAAC,EAAAO,UAAAN,OAAuCF,EAAAC,EAAOD,IAC9CH,EAAAW,UAAAR,GAAAM,EAEA,OAAAnC,GAWA,QAAAzB,GAAA+D,EAAAC,EAAAC,GAQA,MAPAd,GAAAa,EAAA,SAAAhD,EAAAyC,GACAQ,GAAA,kBAAAjD,GACA+C,EAAAN,GAAA7D,EAAAoB,EAAAiD,GAEAF,EAAAN,GAAAzC,IAGA+C,EASA,QAAAG,GAAAC,GAIA,MAHA,SAAAA,EAAAC,WAAA,KACAD,IAAAN,MAAA,IAEAM,EAlUA,GAAAvE,GAAAd,EAAA,GAMAmC,EAAAgB,OAAApC,UAAAoB,QA+TAxC,GAAAD,SACAuC,UACAM,gBACAF,WACAG,aACAE,oBACAK,WACAC,WACAC,WACAC,gBACAd,cACAiB,SACAC,SACAC,SACAC,aACAC,WACAE,oBACAK,uBACAK,UACAQ,QACA3D,SACA2C,OACAuB,aJkIM,SAAUzF,EAAQD,GK/dxB,YAEAC,GAAAD,QAAA,SAAA6E,EAAAY,GACA,kBAEA,OADAI,GAAA,GAAAC,OAAAR,UAAAN,QACAF,EAAA,EAAmBA,EAAAe,EAAAb,OAAiBF,IACpCe,EAAAf,GAAAQ,UAAAR,EAEA,OAAAD,GAAAkB,MAAAN,EAAAI,MLweM,SAAU5F,EAAQD,EAASM,GMhfjC,YAaA,SAAAY,GAAAW,GACAzB,KAAAsB,SAAAG,EACAzB,KAAA4F,cACA1E,QAAA,GAAA2E,GACAC,SAAA,GAAAD,IAfA,GAAA1E,GAAAjB,EAAA,GACA6F,EAAA7F,EAAA,GACA2F,EAAA3F,EAAA,GACA8F,EAAA9F,EAAA,GACAmB,EAAAnB,EAAA,GAoBAY,GAAAG,UAAAC,QAAA,SAAA+E,GAGA,gBAAAA,IACAA,EAAAf,UAAA,OACAe,EAAAC,IAAAhB,UAAA,IAEAe,QAGAA,EAAA5E,EAAArB,KAAAsB,SAAA2E,GAGAA,EAAAE,OACAF,EAAAE,OAAAF,EAAAE,OAAAC,cACGpG,KAAAsB,SAAA6E,OACHF,EAAAE,OAAAnG,KAAAsB,SAAA6E,OAAAC,cAEAH,EAAAE,OAAA,KAIA,IAAAE,IAAAL,EAAAM,QACAC,EAAAxE,QAAAyE,QAAAP,EAUA,KARAjG,KAAA4F,aAAA1E,QAAAqD,QAAA,SAAAkC,GACAJ,EAAAK,QAAAD,EAAAE,UAAAF,EAAAG,YAGA5G,KAAA4F,aAAAE,SAAAvB,QAAA,SAAAkC,GACAJ,EAAAQ,KAAAJ,EAAAE,UAAAF,EAAAG,YAGAP,EAAAzB,QACA2B,IAAAO,KAAAT,EAAAU,QAAAV,EAAAU,QAGA,OAAAR,IAGAzF,EAAAG,UAAA+F,OAAA,SAAAf,GAEA,MADAA,GAAA5E,EAAArB,KAAAsB,SAAA2E,GACAF,EAAAE,EAAAC,IAAAD,EAAAgB,OAAAhB,EAAAiB,kBAAAjD,QAAA,WAIA9C,EAAAoD,SAAA,0CAAA4B,GAEArF,EAAAG,UAAAkF,GAAA,SAAAD,EAAAD,GACA,MAAAjG,MAAAkB,QAAAG,EAAA4E,OACAE,SACAD,MACAiB,MAAAlB,OAAyBkB,WAKzBhG,EAAAoD,SAAA,+BAAA4B,GAEArF,EAAAG,UAAAkF,GAAA,SAAAD,EAAAiB,EAAAlB,GACA,MAAAjG,MAAAkB,QAAAG,EAAA4E,OACAE,SACAD,MACAiB,aAKAtH,EAAAD,QAAAkB,GNufM,SAAUjB,EAAQD,EAASM,GOrlBjC,YAIA,SAAAkH,GAAAhF,GACA,MAAAiF,oBAAAjF,GACA6B,QAAA,aACAA,QAAA,YACAA,QAAA,aACAA,QAAA,YACAA,QAAA,aACAA,QAAA,aATA,GAAA9C,GAAAjB,EAAA,EAmBAL,GAAAD,QAAA,SAAAsG,EAAAe,EAAAC,GAEA,IAAAD,EACA,MAAAf,EAGA,IAAAoB,EACA,IAAAJ,EACAI,EAAAJ,EAAAD,OACG,IAAA9F,EAAA0C,kBAAAoD,GACHK,EAAAL,EAAA5E,eACG,CACH,GAAAkF,KAEApG,GAAAoD,QAAA0C,EAAA,SAAA7E,EAAAyC,GACA,OAAAzC,GAAA,mBAAAA,KAIAjB,EAAAgB,QAAAC,GACAyC,GAAA,KAEAzC,MAGAjB,EAAAoD,QAAAnC,EAAA,SAAAoF,GACArG,EAAAoC,OAAAiE,GACAA,IAAAC,cACStG,EAAAgC,SAAAqE,KACTA,EAAAE,KAAAC,UAAAH,IAEAD,EAAAV,KAAAO,EAAAvC,GAAA,IAAAuC,EAAAI,SAIAF,EAAAC,EAAAK,KAAA,KAGA,GAAAN,EAAA,CACA,GAAAO,GAAA3B,EAAA4B,QAAA,IACAD,MAAA,IACA3B,IAAAjB,MAAA,EAAA4C,IAGA3B,MAAA4B,QAAA,mBAAAR,EAGA,MAAApB,KP6lBM,SAAUrG,EAAQD,EAASM,GQjqBjC,YAIA,SAAA2F,KACA7F,KAAA+H,YAHA,GAAA5G,GAAAjB,EAAA,EAcA2F,GAAA5E,UAAA+G,IAAA,SAAArB,EAAAC,GAKA,MAJA5G,MAAA+H,SAAAlB,MACAF,YACAC,aAEA5G,KAAA+H,SAAAnD,OAAA,GAQAiB,EAAA5E,UAAAgH,MAAA,SAAA5H,GACAL,KAAA+H,SAAA1H,KACAL,KAAA+H,SAAA1H,GAAA,OAYAwF,EAAA5E,UAAAsD,QAAA,SAAAE,GACAtD,EAAAoD,QAAAvE,KAAA+H,SAAA,SAAAG,GACA,OAAAA,GACAzD,EAAAyD,MAKArI,EAAAD,QAAAiG,GRwqBM,SAAUhG,EAAQD,EAASM,GS3tBjC,YAUA,SAAAiI,GAAAlC,GACAA,EAAAmC,aACAnC,EAAAmC,YAAAC,mBAVA,GAAAlH,GAAAjB,EAAA,GACAoI,EAAApI,EAAA,GACA0B,EAAA1B,EAAA,GACAoB,EAAApB,EAAA,GAiBAL,GAAAD,QAAA,SAAAqG,GACAkC,EAAAlC,GAGAA,EAAAsC,QAAAtC,EAAAsC,YAGAtC,EAAAkB,KAAAmB,EACArC,EAAAkB,KACAlB,EAAAsC,QACAtC,EAAAuC,kBAIAvC,EAAAsC,QAAApH,EAAA4D,MACAkB,EAAAsC,QAAAE,WACAxC,EAAAsC,QAAAtC,EAAAE,YACAF,EAAAsC,SAGApH,EAAAoD,SACA,qDACA,SAAA4B,SACAF,GAAAsC,QAAApC,IAIA,IAAAuC,GAAAzC,EAAAyC,SAAApH,EAAAoH,OAEA,OAAAA,GAAAzC,GAAAa,KAAA,SAAAhB,GAUA,MATAqC,GAAAlC,GAGAH,EAAAqB,KAAAmB,EACAxC,EAAAqB,KACArB,EAAAyC,QACAtC,EAAA0C,mBAGA7C,GACG,SAAA8C,GAcH,MAbAhH,GAAAgH,KACAT,EAAAlC,GAGA2C,KAAA9C,WACA8C,EAAA9C,SAAAqB,KAAAmB,EACAM,EAAA9C,SAAAqB,KACAyB,EAAA9C,SAAAyC,QACAtC,EAAA0C,qBAKA5G,QAAA8G,OAAAD,OTouBM,SAAU/I,EAAQD,EAASM,GUhzBjC,YAEA,IAAAiB,GAAAjB,EAAA,EAUAL,GAAAD,QAAA,SAAAuH,EAAAoB,EAAAO,GAMA,MAJA3H,GAAAoD,QAAAuE,EAAA,SAAArE,GACA0C,EAAA1C,EAAA0C,EAAAoB,KAGApB,IVwzBM,SAAUtH,EAAQD,GW10BxB,YAEAC,GAAAD,QAAA,SAAAmJ,GACA,SAAAA,MAAAC,cXk1BM,SAAUnJ,EAAQD,EAASM,GYr1BjC,YASA,SAAA+I,GAAAV,EAAAQ,IACA5H,EAAAmB,YAAAiG,IAAApH,EAAAmB,YAAAiG,EAAA,mBACAA,EAAA,gBAAAQ,GAIA,QAAAG,KACA,GAAAR,EAQA,OAPA,mBAAAS,gBAEAT,EAAAxI,EAAA,IACG,mBAAAkJ,UAAA,qBAAA/F,OAAApC,UAAAoB,SAAA9B,KAAA6I,WAEHV,EAAAxI,EAAA,KAEAwI,EAtBA,GAAAvH,GAAAjB,EAAA,GACAmJ,EAAAnJ,EAAA,IAEAoJ,GACAC,eAAA,qCAqBAjI,GACAoH,QAAAQ,IAEAV,kBAAA,SAAArB,EAAAoB,GAGA,MAFAc,GAAAd,EAAA,UACAc,EAAAd,EAAA,gBACApH,EAAAuB,WAAAyE,IACAhG,EAAAsB,cAAA0E,IACAhG,EAAAoB,SAAA4E,IACAhG,EAAAwC,SAAAwD,IACAhG,EAAAqC,OAAA2D,IACAhG,EAAAsC,OAAA0D,GAEAA,EAEAhG,EAAAyB,kBAAAuE,GACAA,EAAAnE,OAEA7B,EAAA0C,kBAAAsD,IACA8B,EAAAV,EAAA,mDACApB,EAAA9E,YAEAlB,EAAAgC,SAAAgE,IACA8B,EAAAV,EAAA,kCACAb,KAAAC,UAAAR,IAEAA,IAGAwB,mBAAA,SAAAxB,GAEA,mBAAAA,GACA,IACAA,EAAAO,KAAA8B,MAAArC,GACO,MAAAsC,IAEP,MAAAtC,KAOAuC,QAAA,EAEAC,eAAA,aACAC,eAAA,eAEAC,kBAAA,EACAC,eAAA,EAEAC,eAAA,SAAAC,GACA,MAAAA,IAAA,KAAAA,EAAA,KAIA1I,GAAAiH,SACAE,QACAwB,OAAA,sCAIA9I,EAAAoD,SAAA,gCAAA4B,GACA7E,EAAAiH,QAAApC,QAGAhF,EAAAoD,SAAA,+BAAA4B,GACA7E,EAAAiH,QAAApC,GAAAhF,EAAA4D,MAAAuE,KAGAzJ,EAAAD,QAAA0B,GZ41BM,SAAUzB,EAAQD,EAASM,Ga77BjC,YAEA,IAAAiB,GAAAjB,EAAA,EAEAL,GAAAD,QAAA,SAAA2I,EAAA2B,GACA/I,EAAAoD,QAAAgE,EAAA,SAAAQ,EAAAoB,GACAA,IAAAD,GAAAC,EAAAC,gBAAAF,EAAAE,gBACA7B,EAAA2B,GAAAnB,QACAR,GAAA4B,Qbu8BM,SAAUtK,EAAQD,EAASM,Gc/8BjC,YAEA,IAAAiB,GAAAjB,EAAA,GACAmK,EAAAnK,EAAA,IACAoK,EAAApK,EAAA,IACA6F,EAAA7F,EAAA,GACAqK,EAAArK,EAAA,IACAsK,EAAAtK,EAAA,IACAuK,EAAAvK,EAAA,IACAwK,EAAAxK,EAAA,GAEAL,GAAAD,QAAA,SAAAqG,GACA,UAAAlE,SAAA,SAAAyE,EAAAqC,GACA,GAAA8B,GAAA1E,EAAAkB,KACAyD,EAAA3E,EAAAsC,OAEApH,GAAAuB,WAAAiI,UACAC,GAAA,eAGA,IAAA1J,GAAA,GAAAiI,eAGA,IAAAlD,EAAA4E,KAAA,CACA,GAAAC,GAAA7E,EAAA4E,KAAAC,UAAA,GACAC,EAAA9E,EAAA4E,KAAAE,SAAAC,SAAA3D,mBAAApB,EAAA4E,KAAAE,WAAA,EACAH,GAAAK,cAAA,SAAAC,KAAAJ,EAAA,IAAAC,GAGA,GAAAI,GAAAZ,EAAAtE,EAAAmF,QAAAnF,EAAAC,IA4EA,IA3EAhF,EAAAmK,KAAApF,EAAAE,OAAAiE,cAAArE,EAAAoF,EAAAlF,EAAAgB,OAAAhB,EAAAiB,mBAAA,GAGAhG,EAAAwI,QAAAzD,EAAAyD,QAGAxI,EAAAoK,mBAAA,WACA,GAAApK,GAAA,IAAAA,EAAAqK,aAQA,IAAArK,EAAA8I,QAAA9I,EAAAsK,aAAA,IAAAtK,EAAAsK,YAAA1D,QAAA,WAKA,GAAA2D,GAAA,yBAAAvK,GAAAsJ,EAAAtJ,EAAAwK,yBAAA,KACAC,EAAA1F,EAAA2F,cAAA,SAAA3F,EAAA2F,aAAA1K,EAAA4E,SAAA5E,EAAA2K,aACA/F,GACAqB,KAAAwE,EACA3B,OAAA9I,EAAA8I,OACA8B,WAAA5K,EAAA4K,WACAvD,QAAAkD,EACAxF,SACA/E,UAGAmJ,GAAA7D,EAAAqC,EAAA/C,GAGA5E,EAAA,OAIAA,EAAA6K,QAAA,WACA7K,IAIA2H,EAAA6B,EAAA,kBAAAzE,EAAA,eAAA/E,IAGAA,EAAA,OAIAA,EAAA8K,QAAA,WAGAnD,EAAA6B,EAAA,gBAAAzE,EAAA,KAAA/E,IAGAA,EAAA,MAIAA,EAAA+K,UAAA,WACA,GAAAC,GAAA,cAAAjG,EAAAyD,QAAA,aACAzD,GAAAiG,sBACAA,EAAAjG,EAAAiG,qBAEArD,EAAA6B,EAAAwB,EAAAjG,EAAA,eACA/E,IAGAA,EAAA,MAMAC,EAAA+C,uBAAA,CAEA,GAAAiI,IAAAlG,EAAAmG,iBAAA3B,EAAAU,KAAAlF,EAAA0D,eACAW,EAAA+B,KAAApG,EAAA0D,gBACArD,MAEA6F,KACAvB,EAAA3E,EAAA2D,gBAAAuC,GAuBA,GAlBA,oBAAAjL,IACAC,EAAAoD,QAAAqG,EAAA,SAAAxI,EAAAyC,GACA,mBAAA8F,IAAA,iBAAA9F,EAAAuB,oBAEAwE,GAAA/F,GAGA3D,EAAAoL,iBAAAzH,EAAAzC,KAMAjB,EAAAmB,YAAA2D,EAAAmG,mBACAlL,EAAAkL,kBAAAnG,EAAAmG,iBAIAnG,EAAA2F,aACA,IACA1K,EAAA0K,aAAA3F,EAAA2F,aACO,MAAAnC,GAGP,YAAAxD,EAAA2F,aACA,KAAAnC,GAMA,kBAAAxD,GAAAsG,oBACArL,EAAAsL,iBAAA,WAAAvG,EAAAsG,oBAIA,kBAAAtG,GAAAwG,kBAAAvL,EAAAwL,QACAxL,EAAAwL,OAAAF,iBAAA,WAAAvG,EAAAwG,kBAGAxG,EAAAmC,aAEAnC,EAAAmC,YAAA7B,QAAAO,KAAA,SAAA6F,GACAzL,IAIAA,EAAA0L,QACA/D,EAAA8D,GAEAzL,EAAA,QAIAyJ,IACAA,EAAA,MAIAzJ,EAAA2L,KAAAlC,Odw9BM,SAAU9K,EAAQD,EAASM,GexoCjC,YAEA,IAAAwK,GAAAxK,EAAA,GASAL,GAAAD,QAAA,SAAA4G,EAAAqC,EAAA/C,GACA,GAAAiE,GAAAjE,EAAAG,OAAA8D,cACAjE,GAAAkE,QAAAD,MAAAjE,EAAAkE,QAGAnB,EAAA6B,EACA,mCAAA5E,EAAAkE,OACAlE,EAAAG,OACA,KACAH,EAAA5E,QACA4E,IAPAU,EAAAV,KfypCM,SAAUjG,EAAQD,EAASM,GgBvqCjC,YAEA,IAAA4M,GAAA5M,EAAA,GAYAL,GAAAD,QAAA,SAAAmN,EAAA9G,EAAA+G,EAAA9L,EAAA4E,GACA,GAAAmH,GAAA,GAAAC,OAAAH,EACA,OAAAD,GAAAG,EAAAhH,EAAA+G,EAAA9L,EAAA4E,KhB+qCM,SAAUjG,EAAQD,GiB/rCxB,YAYAC,GAAAD,QAAA,SAAAqN,EAAAhH,EAAA+G,EAAA9L,EAAA4E,GA4BA,MA3BAmH,GAAAhH,SACA+G,IACAC,EAAAD,QAGAC,EAAA/L,UACA+L,EAAAnH,WACAmH,EAAAhL,cAAA,EAEAgL,EAAAE,OAAA,WACA,OAEAJ,QAAA/M,KAAA+M,QACA5C,KAAAnK,KAAAmK,KAEAiD,YAAApN,KAAAoN,YACAC,OAAArN,KAAAqN,OAEAC,SAAAtN,KAAAsN,SACAC,WAAAvN,KAAAuN,WACAC,aAAAxN,KAAAwN,aACAC,MAAAzN,KAAAyN,MAEAxH,OAAAjG,KAAAiG,OACA+G,KAAAhN,KAAAgN,OAGAC,IjBusCM,SAAUpN,EAAQD,EAASM,GkB/uCjC,YAEA,IAAAiB,GAAAjB,EAAA,EAEAL,GAAAD,QACAuB,EAAA+C,uBAGA,WACA,OACAwJ,MAAA,SAAAvD,EAAApB,EAAA4E,EAAAC,EAAAC,EAAAC,GACA,GAAAC,KACAA,GAAAlH,KAAAsD,EAAA,IAAA9C,mBAAA0B,IAEA5H,EAAA+B,SAAAyK,IACAI,EAAAlH,KAAA,cAAAmH,MAAAL,GAAAM,eAGA9M,EAAA8B,SAAA2K,IACAG,EAAAlH,KAAA,QAAA+G,GAGAzM,EAAA8B,SAAA4K,IACAE,EAAAlH,KAAA,UAAAgH,GAGAC,KAAA,GACAC,EAAAlH,KAAA,UAGAvC,SAAAyJ,SAAAnG,KAAA,OAGAyE,KAAA,SAAAlC,GACA,GAAA+D,GAAA5J,SAAAyJ,OAAAG,MAAA,GAAAC,QAAA,aAA4DhE,EAAA,aAC5D,OAAA+D,GAAAE,mBAAAF,EAAA,UAGAG,OAAA,SAAAlE,GACAnK,KAAA0N,MAAAvD,EAAA,GAAA6D,KAAAM,MAAA,YAMA,WACA,OACAZ,MAAA,aACArB,KAAA,WAA+B,aAC/BgC,OAAA,kBlByvCM,SAAUxO,EAAQD,EAASM,GmB1yCjC,YAEA,IAAAqO,GAAArO,EAAA,IACAsO,EAAAtO,EAAA,GAWAL,GAAAD,QAAA,SAAAwL,EAAAqD,GACA,MAAArD,KAAAmD,EAAAE,GACAD,EAAApD,EAAAqD,GAEAA,InBkzCM,SAAU5O,EAAQD,GoBp0CxB,YAQAC,GAAAD,QAAA,SAAAsG,GAIA,sCAAAwI,KAAAxI,KpB40CM,SAAUrG,EAAQD,GqBx1CxB,YASAC,GAAAD,QAAA,SAAAwL,EAAAuD,GACA,MAAAA,GACAvD,EAAAnH,QAAA,eAAA0K,EAAA1K,QAAA,WACAmH,IrBg2CM,SAAUvL,EAAQD,EAASM,GsB52CjC,YAEA,IAAAiB,GAAAjB,EAAA,GAIA0O,GACA,6DACA,kEACA,gEACA,qCAgBA/O,GAAAD,QAAA,SAAA2I,GACA,GACA1D,GACAzC,EACAsC,EAHAmK,IAKA,OAAAtG,IAEApH,EAAAoD,QAAAgE,EAAAuG,MAAA,eAAAC,GAKA,GAJArK,EAAAqK,EAAAjH,QAAA,KACAjD,EAAA1D,EAAA4C,KAAAgL,EAAAC,OAAA,EAAAtK,IAAA0B,cACAhE,EAAAjB,EAAA4C,KAAAgL,EAAAC,OAAAtK,EAAA,IAEAG,EAAA,CACA,GAAAgK,EAAAhK,IAAA+J,EAAA9G,QAAAjD,IAAA,EACA,MAEA,gBAAAA,EACAgK,EAAAhK,IAAAgK,EAAAhK,GAAAgK,EAAAhK,OAAAoK,QAAA7M,IAEAyM,EAAAhK,GAAAgK,EAAAhK,GAAAgK,EAAAhK,GAAA,KAAAzC,OAKAyM,GAnBiBA,ItBu4CX,SAAUhP,EAAQD,EAASM,GuBv6CjC,YAEA,IAAAiB,GAAAjB,EAAA,EAEAL,GAAAD,QACAuB,EAAA+C,uBAIA,WAWA,QAAAgL,GAAAhJ,GACA,GAAAiJ,GAAAjJ,CAWA,OATAkJ,KAEAC,EAAAC,aAAA,OAAAH,GACAA,EAAAE,EAAAF,MAGAE,EAAAC,aAAA,OAAAH,IAIAA,KAAAE,EAAAF,KACAI,SAAAF,EAAAE,SAAAF,EAAAE,SAAAtL,QAAA,YACAuL,KAAAH,EAAAG,KACAC,OAAAJ,EAAAI,OAAAJ,EAAAI,OAAAxL,QAAA,aACAyL,KAAAL,EAAAK,KAAAL,EAAAK,KAAAzL,QAAA,YACA0L,SAAAN,EAAAM,SACAC,KAAAP,EAAAO,KACAC,SAAA,MAAAR,EAAAQ,SAAAC,OAAA,GACAT,EAAAQ,SACA,IAAAR,EAAAQ,UAhCA,GAEAE,GAFAX,EAAA,kBAAAV,KAAAvK,UAAA6L,WACAX,EAAA/K,SAAA2L,cAAA,IA2CA,OARAF,GAAAb,EAAA7K,OAAA6L,SAAAf,MAQA,SAAAgB,GACA,GAAAtB,GAAA1N,EAAA8B,SAAAkN,GAAAjB,EAAAiB,IACA,OAAAtB,GAAAU,WAAAQ,EAAAR,UACAV,EAAAW,OAAAO,EAAAP,SAKA,WACA,kBACA,cvBi7CM,SAAU3P,EAAQD,EAASM,GwBj/CjC,YAEA,IAAAiB,GAAAjB,EAAA,EAUAL,GAAAD,QAAA,SAAAwQ,EAAAC,GAgBA,QAAAC,GAAAC,EAAAC,GACA,MAAArP,GAAAiC,cAAAmN,IAAApP,EAAAiC,cAAAoN,GACArP,EAAA4D,MAAAwL,EAAAC,GACKrP,EAAAiC,cAAAoN,GACLrP,EAAA4D,SAA2ByL,GACtBrP,EAAAgB,QAAAqO,GACLA,EAAAvL,QAEAuL,EAGA,QAAAC,GAAAC,GACAvP,EAAAmB,YAAA+N,EAAAK,IAEKvP,EAAAmB,YAAA8N,EAAAM,MACLzK,EAAAyK,GAAAJ,EAAAhK,OAAA8J,EAAAM,KAFAzK,EAAAyK,GAAAJ,EAAAF,EAAAM,GAAAL,EAAAK,IA3BAL,OACA,IAAApK,MAEA0K,GAAA,uBACAC,GAAA,mCACAC,GACA,oEACA,uFACA,sEACA,0EACA,4DAEAC,GAAA,iBAqBA3P,GAAAoD,QAAAoM,EAAA,SAAAD,GACAvP,EAAAmB,YAAA+N,EAAAK,MACAzK,EAAAyK,GAAAJ,EAAAhK,OAAA+J,EAAAK,OAIAvP,EAAAoD,QAAAqM,EAAAH,GAEAtP,EAAAoD,QAAAsM,EAAA,SAAAH,GACAvP,EAAAmB,YAAA+N,EAAAK,IAEKvP,EAAAmB,YAAA8N,EAAAM,MACLzK,EAAAyK,GAAAJ,EAAAhK,OAAA8J,EAAAM,KAFAzK,EAAAyK,GAAAJ,EAAAhK,OAAA+J,EAAAK,MAMAvP,EAAAoD,QAAAuM,EAAA,SAAAJ,GACAA,IAAAL,GACApK,EAAAyK,GAAAJ,EAAAF,EAAAM,GAAAL,EAAAK,IACKA,IAAAN,KACLnK,EAAAyK,GAAAJ,EAAAhK,OAAA8J,EAAAM,MAIA,IAAAK,GAAAJ,EACA1B,OAAA2B,GACA3B,OAAA4B,GACA5B,OAAA6B,GAEAE,EAAA3N,OACA4N,KAAAb,GACAnB,OAAA5L,OAAA4N,KAAAZ,IACAa,OAAA,SAAArM,GACA,MAAAkM,GAAAjJ,QAAAjD,MAAA,GAKA,OAFA1D,GAAAoD,QAAAyM,EAAAP,GAEAxK,IxBy/CM,SAAUpG,EAAQD,GyB9kDxB,YAQA,SAAA8B,GAAAqL,GACA/M,KAAA+M,UAGArL,EAAAT,UAAAoB,SAAA,WACA,gBAAArC,KAAA+M,QAAA,KAAA/M,KAAA+M,QAAA,KAGArL,EAAAT,UAAA+H,YAAA,EAEAnJ,EAAAD,QAAA8B,GzBqlDM,SAAU7B,EAAQD,EAASM,G0BvmDjC,YAUA,SAAAyB,GAAAwP,GACA,qBAAAA,GACA,SAAAC,WAAA,+BAGA,IAAAC,EACArR,MAAAuG,QAAA,GAAAxE,SAAA,SAAAyE,GACA6K,EAAA7K,GAGA,IAAA8K,GAAAtR,IACAmR,GAAA,SAAApE,GACAuE,EAAA1I,SAKA0I,EAAA1I,OAAA,GAAAlH,GAAAqL,GACAsE,EAAAC,EAAA1I,WA1BA,GAAAlH,GAAAxB,EAAA,GAiCAyB,GAAAV,UAAAoH,iBAAA,WACA,GAAArI,KAAA4I,OACA,KAAA5I,MAAA4I,QAQAjH,EAAA6O,OAAA,WACA,GAAA7D,GACA2E,EAAA,GAAA3P,GAAA,SAAAlB,GACAkM,EAAAlM,GAEA,QACA6Q,QACA3E,WAIA9M,EAAAD,QAAA+B,G1B8mDM,SAAU9B,EAAQD,G2BtqDxB,YAsBAC,GAAAD,QAAA,SAAA2R,GACA,gBAAAC,GACA,MAAAD,GAAA5L,MAAA,KAAA6L,M3B+qDM,SAAU3R,EAAQD,G4BvsDxB,YAQAC,GAAAD,QAAA,SAAA6R,GACA,sBAAAA,MAAAxP,gBAAA","file":"axios.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axios\"] = factory();\n\telse\n\t\troot[\"axios\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axios\"] = factory();\n\telse\n\t\troot[\"axios\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(1);\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar bind = __webpack_require__(3);\n\tvar Axios = __webpack_require__(4);\n\tvar mergeConfig = __webpack_require__(22);\n\tvar defaults = __webpack_require__(10);\n\t\n\t/**\n\t * Create an instance of Axios\n\t *\n\t * @param {Object} defaultConfig The default config for the instance\n\t * @return {Axios} A new instance of Axios\n\t */\n\tfunction createInstance(defaultConfig) {\n\t var context = new Axios(defaultConfig);\n\t var instance = bind(Axios.prototype.request, context);\n\t\n\t // Copy axios.prototype to instance\n\t utils.extend(instance, Axios.prototype, context);\n\t\n\t // Copy context to instance\n\t utils.extend(instance, context);\n\t\n\t return instance;\n\t}\n\t\n\t// Create the default instance to be exported\n\tvar axios = createInstance(defaults);\n\t\n\t// Expose Axios class to allow class inheritance\n\taxios.Axios = Axios;\n\t\n\t// Factory for creating new instances\n\taxios.create = function create(instanceConfig) {\n\t return createInstance(mergeConfig(axios.defaults, instanceConfig));\n\t};\n\t\n\t// Expose Cancel & CancelToken\n\taxios.Cancel = __webpack_require__(23);\n\taxios.CancelToken = __webpack_require__(24);\n\taxios.isCancel = __webpack_require__(9);\n\t\n\t// Expose all/spread\n\taxios.all = function all(promises) {\n\t return Promise.all(promises);\n\t};\n\taxios.spread = __webpack_require__(25);\n\t\n\t// Expose isAxiosError\n\taxios.isAxiosError = __webpack_require__(26);\n\t\n\tmodule.exports = axios;\n\t\n\t// Allow use of default import syntax in TypeScript\n\tmodule.exports.default = axios;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar bind = __webpack_require__(3);\n\t\n\t/*global toString:true*/\n\t\n\t// utils is a library of generic helper functions non-specific to axios\n\t\n\tvar toString = Object.prototype.toString;\n\t\n\t/**\n\t * Determine if a value is an Array\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Array, otherwise false\n\t */\n\tfunction isArray(val) {\n\t return toString.call(val) === '[object Array]';\n\t}\n\t\n\t/**\n\t * Determine if a value is undefined\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if the value is undefined, otherwise false\n\t */\n\tfunction isUndefined(val) {\n\t return typeof val === 'undefined';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Buffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Buffer, otherwise false\n\t */\n\tfunction isBuffer(val) {\n\t return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)\n\t && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);\n\t}\n\t\n\t/**\n\t * Determine if a value is an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBuffer(val) {\n\t return toString.call(val) === '[object ArrayBuffer]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a FormData\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an FormData, otherwise false\n\t */\n\tfunction isFormData(val) {\n\t return (typeof FormData !== 'undefined') && (val instanceof FormData);\n\t}\n\t\n\t/**\n\t * Determine if a value is a view on an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBufferView(val) {\n\t var result;\n\t if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n\t result = ArrayBuffer.isView(val);\n\t } else {\n\t result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Determine if a value is a String\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a String, otherwise false\n\t */\n\tfunction isString(val) {\n\t return typeof val === 'string';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Number\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Number, otherwise false\n\t */\n\tfunction isNumber(val) {\n\t return typeof val === 'number';\n\t}\n\t\n\t/**\n\t * Determine if a value is an Object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Object, otherwise false\n\t */\n\tfunction isObject(val) {\n\t return val !== null && typeof val === 'object';\n\t}\n\t\n\t/**\n\t * Determine if a value is a plain Object\n\t *\n\t * @param {Object} val The value to test\n\t * @return {boolean} True if value is a plain Object, otherwise false\n\t */\n\tfunction isPlainObject(val) {\n\t if (toString.call(val) !== '[object Object]') {\n\t return false;\n\t }\n\t\n\t var prototype = Object.getPrototypeOf(val);\n\t return prototype === null || prototype === Object.prototype;\n\t}\n\t\n\t/**\n\t * Determine if a value is a Date\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Date, otherwise false\n\t */\n\tfunction isDate(val) {\n\t return toString.call(val) === '[object Date]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a File\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a File, otherwise false\n\t */\n\tfunction isFile(val) {\n\t return toString.call(val) === '[object File]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Blob\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Blob, otherwise false\n\t */\n\tfunction isBlob(val) {\n\t return toString.call(val) === '[object Blob]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Function\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Function, otherwise false\n\t */\n\tfunction isFunction(val) {\n\t return toString.call(val) === '[object Function]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Stream\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Stream, otherwise false\n\t */\n\tfunction isStream(val) {\n\t return isObject(val) && isFunction(val.pipe);\n\t}\n\t\n\t/**\n\t * Determine if a value is a URLSearchParams object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n\t */\n\tfunction isURLSearchParams(val) {\n\t return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n\t}\n\t\n\t/**\n\t * Trim excess whitespace off the beginning and end of a string\n\t *\n\t * @param {String} str The String to trim\n\t * @returns {String} The String freed of excess whitespace\n\t */\n\tfunction trim(str) {\n\t return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n\t}\n\t\n\t/**\n\t * Determine if we're running in a standard browser environment\n\t *\n\t * This allows axios to run in a web worker, and react-native.\n\t * Both environments support XMLHttpRequest, but not fully standard globals.\n\t *\n\t * web workers:\n\t * typeof window -> undefined\n\t * typeof document -> undefined\n\t *\n\t * react-native:\n\t * navigator.product -> 'ReactNative'\n\t * nativescript\n\t * navigator.product -> 'NativeScript' or 'NS'\n\t */\n\tfunction isStandardBrowserEnv() {\n\t if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||\n\t navigator.product === 'NativeScript' ||\n\t navigator.product === 'NS')) {\n\t return false;\n\t }\n\t return (\n\t typeof window !== 'undefined' &&\n\t typeof document !== 'undefined'\n\t );\n\t}\n\t\n\t/**\n\t * Iterate over an Array or an Object invoking a function for each item.\n\t *\n\t * If `obj` is an Array callback will be called passing\n\t * the value, index, and complete array for each item.\n\t *\n\t * If 'obj' is an Object callback will be called passing\n\t * the value, key, and complete object for each property.\n\t *\n\t * @param {Object|Array} obj The object to iterate\n\t * @param {Function} fn The callback to invoke for each item\n\t */\n\tfunction forEach(obj, fn) {\n\t // Don't bother if no value provided\n\t if (obj === null || typeof obj === 'undefined') {\n\t return;\n\t }\n\t\n\t // Force an array if not already something iterable\n\t if (typeof obj !== 'object') {\n\t /*eslint no-param-reassign:0*/\n\t obj = [obj];\n\t }\n\t\n\t if (isArray(obj)) {\n\t // Iterate over array values\n\t for (var i = 0, l = obj.length; i < l; i++) {\n\t fn.call(null, obj[i], i, obj);\n\t }\n\t } else {\n\t // Iterate over object keys\n\t for (var key in obj) {\n\t if (Object.prototype.hasOwnProperty.call(obj, key)) {\n\t fn.call(null, obj[key], key, obj);\n\t }\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * Accepts varargs expecting each argument to be an object, then\n\t * immutably merges the properties of each object and returns result.\n\t *\n\t * When multiple objects contain the same key the later object in\n\t * the arguments list will take precedence.\n\t *\n\t * Example:\n\t *\n\t * ```js\n\t * var result = merge({foo: 123}, {foo: 456});\n\t * console.log(result.foo); // outputs 456\n\t * ```\n\t *\n\t * @param {Object} obj1 Object to merge\n\t * @returns {Object} Result of all merge properties\n\t */\n\tfunction merge(/* obj1, obj2, obj3, ... */) {\n\t var result = {};\n\t function assignValue(val, key) {\n\t if (isPlainObject(result[key]) && isPlainObject(val)) {\n\t result[key] = merge(result[key], val);\n\t } else if (isPlainObject(val)) {\n\t result[key] = merge({}, val);\n\t } else if (isArray(val)) {\n\t result[key] = val.slice();\n\t } else {\n\t result[key] = val;\n\t }\n\t }\n\t\n\t for (var i = 0, l = arguments.length; i < l; i++) {\n\t forEach(arguments[i], assignValue);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Extends object a by mutably adding to it the properties of object b.\n\t *\n\t * @param {Object} a The object to be extended\n\t * @param {Object} b The object to copy properties from\n\t * @param {Object} thisArg The object to bind function to\n\t * @return {Object} The resulting value of object a\n\t */\n\tfunction extend(a, b, thisArg) {\n\t forEach(b, function assignValue(val, key) {\n\t if (thisArg && typeof val === 'function') {\n\t a[key] = bind(val, thisArg);\n\t } else {\n\t a[key] = val;\n\t }\n\t });\n\t return a;\n\t}\n\t\n\t/**\n\t * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)\n\t *\n\t * @param {string} content with BOM\n\t * @return {string} content value without BOM\n\t */\n\tfunction stripBOM(content) {\n\t if (content.charCodeAt(0) === 0xFEFF) {\n\t content = content.slice(1);\n\t }\n\t return content;\n\t}\n\t\n\tmodule.exports = {\n\t isArray: isArray,\n\t isArrayBuffer: isArrayBuffer,\n\t isBuffer: isBuffer,\n\t isFormData: isFormData,\n\t isArrayBufferView: isArrayBufferView,\n\t isString: isString,\n\t isNumber: isNumber,\n\t isObject: isObject,\n\t isPlainObject: isPlainObject,\n\t isUndefined: isUndefined,\n\t isDate: isDate,\n\t isFile: isFile,\n\t isBlob: isBlob,\n\t isFunction: isFunction,\n\t isStream: isStream,\n\t isURLSearchParams: isURLSearchParams,\n\t isStandardBrowserEnv: isStandardBrowserEnv,\n\t forEach: forEach,\n\t merge: merge,\n\t extend: extend,\n\t trim: trim,\n\t stripBOM: stripBOM\n\t};\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = function bind(fn, thisArg) {\n\t return function wrap() {\n\t var args = new Array(arguments.length);\n\t for (var i = 0; i < args.length; i++) {\n\t args[i] = arguments[i];\n\t }\n\t return fn.apply(thisArg, args);\n\t };\n\t};\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar buildURL = __webpack_require__(5);\n\tvar InterceptorManager = __webpack_require__(6);\n\tvar dispatchRequest = __webpack_require__(7);\n\tvar mergeConfig = __webpack_require__(22);\n\t\n\t/**\n\t * Create a new instance of Axios\n\t *\n\t * @param {Object} instanceConfig The default config for the instance\n\t */\n\tfunction Axios(instanceConfig) {\n\t this.defaults = instanceConfig;\n\t this.interceptors = {\n\t request: new InterceptorManager(),\n\t response: new InterceptorManager()\n\t };\n\t}\n\t\n\t/**\n\t * Dispatch a request\n\t *\n\t * @param {Object} config The config specific for this request (merged with this.defaults)\n\t */\n\tAxios.prototype.request = function request(config) {\n\t /*eslint no-param-reassign:0*/\n\t // Allow for axios('example/url'[, config]) a la fetch API\n\t if (typeof config === 'string') {\n\t config = arguments[1] || {};\n\t config.url = arguments[0];\n\t } else {\n\t config = config || {};\n\t }\n\t\n\t config = mergeConfig(this.defaults, config);\n\t\n\t // Set config.method\n\t if (config.method) {\n\t config.method = config.method.toLowerCase();\n\t } else if (this.defaults.method) {\n\t config.method = this.defaults.method.toLowerCase();\n\t } else {\n\t config.method = 'get';\n\t }\n\t\n\t // Hook up interceptors middleware\n\t var chain = [dispatchRequest, undefined];\n\t var promise = Promise.resolve(config);\n\t\n\t this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n\t chain.unshift(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n\t chain.push(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t while (chain.length) {\n\t promise = promise.then(chain.shift(), chain.shift());\n\t }\n\t\n\t return promise;\n\t};\n\t\n\tAxios.prototype.getUri = function getUri(config) {\n\t config = mergeConfig(this.defaults, config);\n\t return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\\?/, '');\n\t};\n\t\n\t// Provide aliases for supported request methods\n\tutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, config) {\n\t return this.request(mergeConfig(config || {}, {\n\t method: method,\n\t url: url,\n\t data: (config || {}).data\n\t }));\n\t };\n\t});\n\t\n\tutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, data, config) {\n\t return this.request(mergeConfig(config || {}, {\n\t method: method,\n\t url: url,\n\t data: data\n\t }));\n\t };\n\t});\n\t\n\tmodule.exports = Axios;\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction encode(val) {\n\t return encodeURIComponent(val).\n\t replace(/%3A/gi, ':').\n\t replace(/%24/g, '$').\n\t replace(/%2C/gi, ',').\n\t replace(/%20/g, '+').\n\t replace(/%5B/gi, '[').\n\t replace(/%5D/gi, ']');\n\t}\n\t\n\t/**\n\t * Build a URL by appending params to the end\n\t *\n\t * @param {string} url The base of the url (e.g., http://www.google.com)\n\t * @param {object} [params] The params to be appended\n\t * @returns {string} The formatted url\n\t */\n\tmodule.exports = function buildURL(url, params, paramsSerializer) {\n\t /*eslint no-param-reassign:0*/\n\t if (!params) {\n\t return url;\n\t }\n\t\n\t var serializedParams;\n\t if (paramsSerializer) {\n\t serializedParams = paramsSerializer(params);\n\t } else if (utils.isURLSearchParams(params)) {\n\t serializedParams = params.toString();\n\t } else {\n\t var parts = [];\n\t\n\t utils.forEach(params, function serialize(val, key) {\n\t if (val === null || typeof val === 'undefined') {\n\t return;\n\t }\n\t\n\t if (utils.isArray(val)) {\n\t key = key + '[]';\n\t } else {\n\t val = [val];\n\t }\n\t\n\t utils.forEach(val, function parseValue(v) {\n\t if (utils.isDate(v)) {\n\t v = v.toISOString();\n\t } else if (utils.isObject(v)) {\n\t v = JSON.stringify(v);\n\t }\n\t parts.push(encode(key) + '=' + encode(v));\n\t });\n\t });\n\t\n\t serializedParams = parts.join('&');\n\t }\n\t\n\t if (serializedParams) {\n\t var hashmarkIndex = url.indexOf('#');\n\t if (hashmarkIndex !== -1) {\n\t url = url.slice(0, hashmarkIndex);\n\t }\n\t\n\t url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n\t }\n\t\n\t return url;\n\t};\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction InterceptorManager() {\n\t this.handlers = [];\n\t}\n\t\n\t/**\n\t * Add a new interceptor to the stack\n\t *\n\t * @param {Function} fulfilled The function to handle `then` for a `Promise`\n\t * @param {Function} rejected The function to handle `reject` for a `Promise`\n\t *\n\t * @return {Number} An ID used to remove interceptor later\n\t */\n\tInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n\t this.handlers.push({\n\t fulfilled: fulfilled,\n\t rejected: rejected\n\t });\n\t return this.handlers.length - 1;\n\t};\n\t\n\t/**\n\t * Remove an interceptor from the stack\n\t *\n\t * @param {Number} id The ID that was returned by `use`\n\t */\n\tInterceptorManager.prototype.eject = function eject(id) {\n\t if (this.handlers[id]) {\n\t this.handlers[id] = null;\n\t }\n\t};\n\t\n\t/**\n\t * Iterate over all the registered interceptors\n\t *\n\t * This method is particularly useful for skipping over any\n\t * interceptors that may have become `null` calling `eject`.\n\t *\n\t * @param {Function} fn The function to call for each interceptor\n\t */\n\tInterceptorManager.prototype.forEach = function forEach(fn) {\n\t utils.forEach(this.handlers, function forEachHandler(h) {\n\t if (h !== null) {\n\t fn(h);\n\t }\n\t });\n\t};\n\t\n\tmodule.exports = InterceptorManager;\n\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar transformData = __webpack_require__(8);\n\tvar isCancel = __webpack_require__(9);\n\tvar defaults = __webpack_require__(10);\n\t\n\t/**\n\t * Throws a `Cancel` if cancellation has been requested.\n\t */\n\tfunction throwIfCancellationRequested(config) {\n\t if (config.cancelToken) {\n\t config.cancelToken.throwIfRequested();\n\t }\n\t}\n\t\n\t/**\n\t * Dispatch a request to the server using the configured adapter.\n\t *\n\t * @param {object} config The config that is to be used for the request\n\t * @returns {Promise} The Promise to be fulfilled\n\t */\n\tmodule.exports = function dispatchRequest(config) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Ensure headers exist\n\t config.headers = config.headers || {};\n\t\n\t // Transform request data\n\t config.data = transformData(\n\t config.data,\n\t config.headers,\n\t config.transformRequest\n\t );\n\t\n\t // Flatten headers\n\t config.headers = utils.merge(\n\t config.headers.common || {},\n\t config.headers[config.method] || {},\n\t config.headers\n\t );\n\t\n\t utils.forEach(\n\t ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n\t function cleanHeaderConfig(method) {\n\t delete config.headers[method];\n\t }\n\t );\n\t\n\t var adapter = config.adapter || defaults.adapter;\n\t\n\t return adapter(config).then(function onAdapterResolution(response) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Transform response data\n\t response.data = transformData(\n\t response.data,\n\t response.headers,\n\t config.transformResponse\n\t );\n\t\n\t return response;\n\t }, function onAdapterRejection(reason) {\n\t if (!isCancel(reason)) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Transform response data\n\t if (reason && reason.response) {\n\t reason.response.data = transformData(\n\t reason.response.data,\n\t reason.response.headers,\n\t config.transformResponse\n\t );\n\t }\n\t }\n\t\n\t return Promise.reject(reason);\n\t });\n\t};\n\n\n/***/ }),\n/* 8 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t/**\n\t * Transform the data for a request or a response\n\t *\n\t * @param {Object|String} data The data to be transformed\n\t * @param {Array} headers The headers for the request or response\n\t * @param {Array|Function} fns A single function or Array of functions\n\t * @returns {*} The resulting transformed data\n\t */\n\tmodule.exports = function transformData(data, headers, fns) {\n\t /*eslint no-param-reassign:0*/\n\t utils.forEach(fns, function transform(fn) {\n\t data = fn(data, headers);\n\t });\n\t\n\t return data;\n\t};\n\n\n/***/ }),\n/* 9 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = function isCancel(value) {\n\t return !!(value && value.__CANCEL__);\n\t};\n\n\n/***/ }),\n/* 10 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar normalizeHeaderName = __webpack_require__(11);\n\t\n\tvar DEFAULT_CONTENT_TYPE = {\n\t 'Content-Type': 'application/x-www-form-urlencoded'\n\t};\n\t\n\tfunction setContentTypeIfUnset(headers, value) {\n\t if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n\t headers['Content-Type'] = value;\n\t }\n\t}\n\t\n\tfunction getDefaultAdapter() {\n\t var adapter;\n\t if (typeof XMLHttpRequest !== 'undefined') {\n\t // For browsers use XHR adapter\n\t adapter = __webpack_require__(12);\n\t } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {\n\t // For node use HTTP adapter\n\t adapter = __webpack_require__(12);\n\t }\n\t return adapter;\n\t}\n\t\n\tvar defaults = {\n\t adapter: getDefaultAdapter(),\n\t\n\t transformRequest: [function transformRequest(data, headers) {\n\t normalizeHeaderName(headers, 'Accept');\n\t normalizeHeaderName(headers, 'Content-Type');\n\t if (utils.isFormData(data) ||\n\t utils.isArrayBuffer(data) ||\n\t utils.isBuffer(data) ||\n\t utils.isStream(data) ||\n\t utils.isFile(data) ||\n\t utils.isBlob(data)\n\t ) {\n\t return data;\n\t }\n\t if (utils.isArrayBufferView(data)) {\n\t return data.buffer;\n\t }\n\t if (utils.isURLSearchParams(data)) {\n\t setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n\t return data.toString();\n\t }\n\t if (utils.isObject(data)) {\n\t setContentTypeIfUnset(headers, 'application/json;charset=utf-8');\n\t return JSON.stringify(data);\n\t }\n\t return data;\n\t }],\n\t\n\t transformResponse: [function transformResponse(data) {\n\t /*eslint no-param-reassign:0*/\n\t if (typeof data === 'string') {\n\t try {\n\t data = JSON.parse(data);\n\t } catch (e) { /* Ignore */ }\n\t }\n\t return data;\n\t }],\n\t\n\t /**\n\t * A timeout in milliseconds to abort a request. If set to 0 (default) a\n\t * timeout is not created.\n\t */\n\t timeout: 0,\n\t\n\t xsrfCookieName: 'XSRF-TOKEN',\n\t xsrfHeaderName: 'X-XSRF-TOKEN',\n\t\n\t maxContentLength: -1,\n\t maxBodyLength: -1,\n\t\n\t validateStatus: function validateStatus(status) {\n\t return status >= 200 && status < 300;\n\t }\n\t};\n\t\n\tdefaults.headers = {\n\t common: {\n\t 'Accept': 'application/json, text/plain, */*'\n\t }\n\t};\n\t\n\tutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n\t defaults.headers[method] = {};\n\t});\n\t\n\tutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n\t defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n\t});\n\t\n\tmodule.exports = defaults;\n\n\n/***/ }),\n/* 11 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n\t utils.forEach(headers, function processHeader(value, name) {\n\t if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n\t headers[normalizedName] = value;\n\t delete headers[name];\n\t }\n\t });\n\t};\n\n\n/***/ }),\n/* 12 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar settle = __webpack_require__(13);\n\tvar cookies = __webpack_require__(16);\n\tvar buildURL = __webpack_require__(5);\n\tvar buildFullPath = __webpack_require__(17);\n\tvar parseHeaders = __webpack_require__(20);\n\tvar isURLSameOrigin = __webpack_require__(21);\n\tvar createError = __webpack_require__(14);\n\t\n\tmodule.exports = function xhrAdapter(config) {\n\t return new Promise(function dispatchXhrRequest(resolve, reject) {\n\t var requestData = config.data;\n\t var requestHeaders = config.headers;\n\t\n\t if (utils.isFormData(requestData)) {\n\t delete requestHeaders['Content-Type']; // Let the browser set it\n\t }\n\t\n\t var request = new XMLHttpRequest();\n\t\n\t // HTTP basic authentication\n\t if (config.auth) {\n\t var username = config.auth.username || '';\n\t var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';\n\t requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n\t }\n\t\n\t var fullPath = buildFullPath(config.baseURL, config.url);\n\t request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);\n\t\n\t // Set the request timeout in MS\n\t request.timeout = config.timeout;\n\t\n\t // Listen for ready state\n\t request.onreadystatechange = function handleLoad() {\n\t if (!request || request.readyState !== 4) {\n\t return;\n\t }\n\t\n\t // The request errored out and we didn't get a response, this will be\n\t // handled by onerror instead\n\t // With one exception: request that using file: protocol, most browsers\n\t // will return status as 0 even though it's a successful request\n\t if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n\t return;\n\t }\n\t\n\t // Prepare the response\n\t var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n\t var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n\t var response = {\n\t data: responseData,\n\t status: request.status,\n\t statusText: request.statusText,\n\t headers: responseHeaders,\n\t config: config,\n\t request: request\n\t };\n\t\n\t settle(resolve, reject, response);\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle browser request cancellation (as opposed to a manual cancellation)\n\t request.onabort = function handleAbort() {\n\t if (!request) {\n\t return;\n\t }\n\t\n\t reject(createError('Request aborted', config, 'ECONNABORTED', request));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle low level network errors\n\t request.onerror = function handleError() {\n\t // Real errors are hidden from us by the browser\n\t // onerror should only fire if it's a network error\n\t reject(createError('Network Error', config, null, request));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle timeout\n\t request.ontimeout = function handleTimeout() {\n\t var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';\n\t if (config.timeoutErrorMessage) {\n\t timeoutErrorMessage = config.timeoutErrorMessage;\n\t }\n\t reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',\n\t request));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Add xsrf header\n\t // This is only done if running in a standard browser environment.\n\t // Specifically not if we're in a web worker, or react-native.\n\t if (utils.isStandardBrowserEnv()) {\n\t // Add xsrf header\n\t var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?\n\t cookies.read(config.xsrfCookieName) :\n\t undefined;\n\t\n\t if (xsrfValue) {\n\t requestHeaders[config.xsrfHeaderName] = xsrfValue;\n\t }\n\t }\n\t\n\t // Add headers to the request\n\t if ('setRequestHeader' in request) {\n\t utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n\t if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n\t // Remove Content-Type if data is undefined\n\t delete requestHeaders[key];\n\t } else {\n\t // Otherwise add header to the request\n\t request.setRequestHeader(key, val);\n\t }\n\t });\n\t }\n\t\n\t // Add withCredentials to request if needed\n\t if (!utils.isUndefined(config.withCredentials)) {\n\t request.withCredentials = !!config.withCredentials;\n\t }\n\t\n\t // Add responseType to request if needed\n\t if (config.responseType) {\n\t try {\n\t request.responseType = config.responseType;\n\t } catch (e) {\n\t // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n\t // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n\t if (config.responseType !== 'json') {\n\t throw e;\n\t }\n\t }\n\t }\n\t\n\t // Handle progress if needed\n\t if (typeof config.onDownloadProgress === 'function') {\n\t request.addEventListener('progress', config.onDownloadProgress);\n\t }\n\t\n\t // Not all browsers support upload events\n\t if (typeof config.onUploadProgress === 'function' && request.upload) {\n\t request.upload.addEventListener('progress', config.onUploadProgress);\n\t }\n\t\n\t if (config.cancelToken) {\n\t // Handle cancellation\n\t config.cancelToken.promise.then(function onCanceled(cancel) {\n\t if (!request) {\n\t return;\n\t }\n\t\n\t request.abort();\n\t reject(cancel);\n\t // Clean up request\n\t request = null;\n\t });\n\t }\n\t\n\t if (!requestData) {\n\t requestData = null;\n\t }\n\t\n\t // Send the request\n\t request.send(requestData);\n\t });\n\t};\n\n\n/***/ }),\n/* 13 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar createError = __webpack_require__(14);\n\t\n\t/**\n\t * Resolve or reject a Promise based on response status.\n\t *\n\t * @param {Function} resolve A function that resolves the promise.\n\t * @param {Function} reject A function that rejects the promise.\n\t * @param {object} response The response.\n\t */\n\tmodule.exports = function settle(resolve, reject, response) {\n\t var validateStatus = response.config.validateStatus;\n\t if (!response.status || !validateStatus || validateStatus(response.status)) {\n\t resolve(response);\n\t } else {\n\t reject(createError(\n\t 'Request failed with status code ' + response.status,\n\t response.config,\n\t null,\n\t response.request,\n\t response\n\t ));\n\t }\n\t};\n\n\n/***/ }),\n/* 14 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar enhanceError = __webpack_require__(15);\n\t\n\t/**\n\t * Create an Error with the specified message, config, error code, request and response.\n\t *\n\t * @param {string} message The error message.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t * @param {Object} [request] The request.\n\t * @param {Object} [response] The response.\n\t * @returns {Error} The created error.\n\t */\n\tmodule.exports = function createError(message, config, code, request, response) {\n\t var error = new Error(message);\n\t return enhanceError(error, config, code, request, response);\n\t};\n\n\n/***/ }),\n/* 15 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Update an Error with the specified config, error code, and response.\n\t *\n\t * @param {Error} error The error to update.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t * @param {Object} [request] The request.\n\t * @param {Object} [response] The response.\n\t * @returns {Error} The error.\n\t */\n\tmodule.exports = function enhanceError(error, config, code, request, response) {\n\t error.config = config;\n\t if (code) {\n\t error.code = code;\n\t }\n\t\n\t error.request = request;\n\t error.response = response;\n\t error.isAxiosError = true;\n\t\n\t error.toJSON = function toJSON() {\n\t return {\n\t // Standard\n\t message: this.message,\n\t name: this.name,\n\t // Microsoft\n\t description: this.description,\n\t number: this.number,\n\t // Mozilla\n\t fileName: this.fileName,\n\t lineNumber: this.lineNumber,\n\t columnNumber: this.columnNumber,\n\t stack: this.stack,\n\t // Axios\n\t config: this.config,\n\t code: this.code\n\t };\n\t };\n\t return error;\n\t};\n\n\n/***/ }),\n/* 16 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs support document.cookie\n\t (function standardBrowserEnv() {\n\t return {\n\t write: function write(name, value, expires, path, domain, secure) {\n\t var cookie = [];\n\t cookie.push(name + '=' + encodeURIComponent(value));\n\t\n\t if (utils.isNumber(expires)) {\n\t cookie.push('expires=' + new Date(expires).toGMTString());\n\t }\n\t\n\t if (utils.isString(path)) {\n\t cookie.push('path=' + path);\n\t }\n\t\n\t if (utils.isString(domain)) {\n\t cookie.push('domain=' + domain);\n\t }\n\t\n\t if (secure === true) {\n\t cookie.push('secure');\n\t }\n\t\n\t document.cookie = cookie.join('; ');\n\t },\n\t\n\t read: function read(name) {\n\t var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n\t return (match ? decodeURIComponent(match[3]) : null);\n\t },\n\t\n\t remove: function remove(name) {\n\t this.write(name, '', Date.now() - 86400000);\n\t }\n\t };\n\t })() :\n\t\n\t // Non standard browser env (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return {\n\t write: function write() {},\n\t read: function read() { return null; },\n\t remove: function remove() {}\n\t };\n\t })()\n\t);\n\n\n/***/ }),\n/* 17 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar isAbsoluteURL = __webpack_require__(18);\n\tvar combineURLs = __webpack_require__(19);\n\t\n\t/**\n\t * Creates a new URL by combining the baseURL with the requestedURL,\n\t * only when the requestedURL is not already an absolute URL.\n\t * If the requestURL is absolute, this function returns the requestedURL untouched.\n\t *\n\t * @param {string} baseURL The base URL\n\t * @param {string} requestedURL Absolute or relative URL to combine\n\t * @returns {string} The combined full path\n\t */\n\tmodule.exports = function buildFullPath(baseURL, requestedURL) {\n\t if (baseURL && !isAbsoluteURL(requestedURL)) {\n\t return combineURLs(baseURL, requestedURL);\n\t }\n\t return requestedURL;\n\t};\n\n\n/***/ }),\n/* 18 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Determines whether the specified URL is absolute\n\t *\n\t * @param {string} url The URL to test\n\t * @returns {boolean} True if the specified URL is absolute, otherwise false\n\t */\n\tmodule.exports = function isAbsoluteURL(url) {\n\t // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n\t // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n\t // by any combination of letters, digits, plus, period, or hyphen.\n\t return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n\t};\n\n\n/***/ }),\n/* 19 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Creates a new URL by combining the specified URLs\n\t *\n\t * @param {string} baseURL The base URL\n\t * @param {string} relativeURL The relative URL\n\t * @returns {string} The combined URL\n\t */\n\tmodule.exports = function combineURLs(baseURL, relativeURL) {\n\t return relativeURL\n\t ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n\t : baseURL;\n\t};\n\n\n/***/ }),\n/* 20 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t// Headers whose duplicates are ignored by node\n\t// c.f. https://nodejs.org/api/http.html#http_message_headers\n\tvar ignoreDuplicateOf = [\n\t 'age', 'authorization', 'content-length', 'content-type', 'etag',\n\t 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n\t 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n\t 'referer', 'retry-after', 'user-agent'\n\t];\n\t\n\t/**\n\t * Parse headers into an object\n\t *\n\t * ```\n\t * Date: Wed, 27 Aug 2014 08:58:49 GMT\n\t * Content-Type: application/json\n\t * Connection: keep-alive\n\t * Transfer-Encoding: chunked\n\t * ```\n\t *\n\t * @param {String} headers Headers needing to be parsed\n\t * @returns {Object} Headers parsed into an object\n\t */\n\tmodule.exports = function parseHeaders(headers) {\n\t var parsed = {};\n\t var key;\n\t var val;\n\t var i;\n\t\n\t if (!headers) { return parsed; }\n\t\n\t utils.forEach(headers.split('\\n'), function parser(line) {\n\t i = line.indexOf(':');\n\t key = utils.trim(line.substr(0, i)).toLowerCase();\n\t val = utils.trim(line.substr(i + 1));\n\t\n\t if (key) {\n\t if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n\t return;\n\t }\n\t if (key === 'set-cookie') {\n\t parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n\t } else {\n\t parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n\t }\n\t }\n\t });\n\t\n\t return parsed;\n\t};\n\n\n/***/ }),\n/* 21 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs have full support of the APIs needed to test\n\t // whether the request URL is of the same origin as current location.\n\t (function standardBrowserEnv() {\n\t var msie = /(msie|trident)/i.test(navigator.userAgent);\n\t var urlParsingNode = document.createElement('a');\n\t var originURL;\n\t\n\t /**\n\t * Parse a URL to discover it's components\n\t *\n\t * @param {String} url The URL to be parsed\n\t * @returns {Object}\n\t */\n\t function resolveURL(url) {\n\t var href = url;\n\t\n\t if (msie) {\n\t // IE needs attribute set twice to normalize properties\n\t urlParsingNode.setAttribute('href', href);\n\t href = urlParsingNode.href;\n\t }\n\t\n\t urlParsingNode.setAttribute('href', href);\n\t\n\t // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n\t return {\n\t href: urlParsingNode.href,\n\t protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n\t host: urlParsingNode.host,\n\t search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n\t hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n\t hostname: urlParsingNode.hostname,\n\t port: urlParsingNode.port,\n\t pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n\t urlParsingNode.pathname :\n\t '/' + urlParsingNode.pathname\n\t };\n\t }\n\t\n\t originURL = resolveURL(window.location.href);\n\t\n\t /**\n\t * Determine if a URL shares the same origin as the current location\n\t *\n\t * @param {String} requestURL The URL to test\n\t * @returns {boolean} True if URL shares the same origin, otherwise false\n\t */\n\t return function isURLSameOrigin(requestURL) {\n\t var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n\t return (parsed.protocol === originURL.protocol &&\n\t parsed.host === originURL.host);\n\t };\n\t })() :\n\t\n\t // Non standard browser envs (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return function isURLSameOrigin() {\n\t return true;\n\t };\n\t })()\n\t);\n\n\n/***/ }),\n/* 22 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t/**\n\t * Config-specific merge-function which creates a new config-object\n\t * by merging two configuration objects together.\n\t *\n\t * @param {Object} config1\n\t * @param {Object} config2\n\t * @returns {Object} New object resulting from merging config2 to config1\n\t */\n\tmodule.exports = function mergeConfig(config1, config2) {\n\t // eslint-disable-next-line no-param-reassign\n\t config2 = config2 || {};\n\t var config = {};\n\t\n\t var valueFromConfig2Keys = ['url', 'method', 'data'];\n\t var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];\n\t var defaultToConfig2Keys = [\n\t 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',\n\t 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',\n\t 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',\n\t 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',\n\t 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'\n\t ];\n\t var directMergeKeys = ['validateStatus'];\n\t\n\t function getMergedValue(target, source) {\n\t if (utils.isPlainObject(target) && utils.isPlainObject(source)) {\n\t return utils.merge(target, source);\n\t } else if (utils.isPlainObject(source)) {\n\t return utils.merge({}, source);\n\t } else if (utils.isArray(source)) {\n\t return source.slice();\n\t }\n\t return source;\n\t }\n\t\n\t function mergeDeepProperties(prop) {\n\t if (!utils.isUndefined(config2[prop])) {\n\t config[prop] = getMergedValue(config1[prop], config2[prop]);\n\t } else if (!utils.isUndefined(config1[prop])) {\n\t config[prop] = getMergedValue(undefined, config1[prop]);\n\t }\n\t }\n\t\n\t utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {\n\t if (!utils.isUndefined(config2[prop])) {\n\t config[prop] = getMergedValue(undefined, config2[prop]);\n\t }\n\t });\n\t\n\t utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);\n\t\n\t utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {\n\t if (!utils.isUndefined(config2[prop])) {\n\t config[prop] = getMergedValue(undefined, config2[prop]);\n\t } else if (!utils.isUndefined(config1[prop])) {\n\t config[prop] = getMergedValue(undefined, config1[prop]);\n\t }\n\t });\n\t\n\t utils.forEach(directMergeKeys, function merge(prop) {\n\t if (prop in config2) {\n\t config[prop] = getMergedValue(config1[prop], config2[prop]);\n\t } else if (prop in config1) {\n\t config[prop] = getMergedValue(undefined, config1[prop]);\n\t }\n\t });\n\t\n\t var axiosKeys = valueFromConfig2Keys\n\t .concat(mergeDeepPropertiesKeys)\n\t .concat(defaultToConfig2Keys)\n\t .concat(directMergeKeys);\n\t\n\t var otherKeys = Object\n\t .keys(config1)\n\t .concat(Object.keys(config2))\n\t .filter(function filterAxiosKeys(key) {\n\t return axiosKeys.indexOf(key) === -1;\n\t });\n\t\n\t utils.forEach(otherKeys, mergeDeepProperties);\n\t\n\t return config;\n\t};\n\n\n/***/ }),\n/* 23 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * A `Cancel` is an object that is thrown when an operation is canceled.\n\t *\n\t * @class\n\t * @param {string=} message The message.\n\t */\n\tfunction Cancel(message) {\n\t this.message = message;\n\t}\n\t\n\tCancel.prototype.toString = function toString() {\n\t return 'Cancel' + (this.message ? ': ' + this.message : '');\n\t};\n\t\n\tCancel.prototype.__CANCEL__ = true;\n\t\n\tmodule.exports = Cancel;\n\n\n/***/ }),\n/* 24 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar Cancel = __webpack_require__(23);\n\t\n\t/**\n\t * A `CancelToken` is an object that can be used to request cancellation of an operation.\n\t *\n\t * @class\n\t * @param {Function} executor The executor function.\n\t */\n\tfunction CancelToken(executor) {\n\t if (typeof executor !== 'function') {\n\t throw new TypeError('executor must be a function.');\n\t }\n\t\n\t var resolvePromise;\n\t this.promise = new Promise(function promiseExecutor(resolve) {\n\t resolvePromise = resolve;\n\t });\n\t\n\t var token = this;\n\t executor(function cancel(message) {\n\t if (token.reason) {\n\t // Cancellation has already been requested\n\t return;\n\t }\n\t\n\t token.reason = new Cancel(message);\n\t resolvePromise(token.reason);\n\t });\n\t}\n\t\n\t/**\n\t * Throws a `Cancel` if cancellation has been requested.\n\t */\n\tCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n\t if (this.reason) {\n\t throw this.reason;\n\t }\n\t};\n\t\n\t/**\n\t * Returns an object that contains a new `CancelToken` and a function that, when called,\n\t * cancels the `CancelToken`.\n\t */\n\tCancelToken.source = function source() {\n\t var cancel;\n\t var token = new CancelToken(function executor(c) {\n\t cancel = c;\n\t });\n\t return {\n\t token: token,\n\t cancel: cancel\n\t };\n\t};\n\t\n\tmodule.exports = CancelToken;\n\n\n/***/ }),\n/* 25 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Syntactic sugar for invoking a function and expanding an array for arguments.\n\t *\n\t * Common use case would be to use `Function.prototype.apply`.\n\t *\n\t * ```js\n\t * function f(x, y, z) {}\n\t * var args = [1, 2, 3];\n\t * f.apply(null, args);\n\t * ```\n\t *\n\t * With `spread` this example can be re-written.\n\t *\n\t * ```js\n\t * spread(function(x, y, z) {})([1, 2, 3]);\n\t * ```\n\t *\n\t * @param {Function} callback\n\t * @returns {Function}\n\t */\n\tmodule.exports = function spread(callback) {\n\t return function wrap(arr) {\n\t return callback.apply(null, arr);\n\t };\n\t};\n\n\n/***/ }),\n/* 26 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Determines whether the payload is an error thrown by Axios\n\t *\n\t * @param {*} payload The value to test\n\t * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false\n\t */\n\tmodule.exports = function isAxiosError(payload) {\n\t return (typeof payload === 'object') && (payload.isAxiosError === true);\n\t};\n\n\n/***/ })\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// axios.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 081842adca0968bb3270","module.exports = require('./lib/axios');\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./index.js\n// module id = 0\n// module chunks = 0","'use strict';\n\nvar utils = require('./utils');\nvar bind = require('./helpers/bind');\nvar Axios = require('./core/Axios');\nvar mergeConfig = require('./core/mergeConfig');\nvar defaults = require('./defaults');\n\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n * @return {Axios} A new instance of Axios\n */\nfunction createInstance(defaultConfig) {\n var context = new Axios(defaultConfig);\n var instance = bind(Axios.prototype.request, context);\n\n // Copy axios.prototype to instance\n utils.extend(instance, Axios.prototype, context);\n\n // Copy context to instance\n utils.extend(instance, context);\n\n return instance;\n}\n\n// Create the default instance to be exported\nvar axios = createInstance(defaults);\n\n// Expose Axios class to allow class inheritance\naxios.Axios = Axios;\n\n// Factory for creating new instances\naxios.create = function create(instanceConfig) {\n return createInstance(mergeConfig(axios.defaults, instanceConfig));\n};\n\n// Expose Cancel & CancelToken\naxios.Cancel = require('./cancel/Cancel');\naxios.CancelToken = require('./cancel/CancelToken');\naxios.isCancel = require('./cancel/isCancel');\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\n// Expose isAxiosError\naxios.isAxiosError = require('./helpers/isAxiosError');\n\nmodule.exports = axios;\n\n// Allow use of default import syntax in TypeScript\nmodule.exports.default = axios;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/axios.js\n// module id = 1\n// module chunks = 0","'use strict';\n\nvar bind = require('./helpers/bind');\n\n/*global toString:true*/\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is a Buffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Buffer, otherwise false\n */\nfunction isBuffer(val) {\n return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)\n && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return (typeof FormData !== 'undefined') && (val instanceof FormData);\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a plain Object\n *\n * @param {Object} val The value to test\n * @return {boolean} True if value is a plain Object, otherwise false\n */\nfunction isPlainObject(val) {\n if (toString.call(val) !== '[object Object]') {\n return false;\n }\n\n var prototype = Object.getPrototypeOf(val);\n return prototype === null || prototype === Object.prototype;\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Determine if a value is a Function\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\nfunction isFunction(val) {\n return toString.call(val) === '[object Function]';\n}\n\n/**\n * Determine if a value is a Stream\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Stream, otherwise false\n */\nfunction isStream(val) {\n return isObject(val) && isFunction(val.pipe);\n}\n\n/**\n * Determine if a value is a URLSearchParams object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n */\nfunction isURLSearchParams(val) {\n return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * navigator.product -> 'ReactNative'\n * nativescript\n * navigator.product -> 'NativeScript' or 'NS'\n */\nfunction isStandardBrowserEnv() {\n if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||\n navigator.product === 'NativeScript' ||\n navigator.product === 'NS')) {\n return false;\n }\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object') {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (isPlainObject(result[key]) && isPlainObject(val)) {\n result[key] = merge(result[key], val);\n } else if (isPlainObject(val)) {\n result[key] = merge({}, val);\n } else if (isArray(val)) {\n result[key] = val.slice();\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\n/**\n * Extends object a by mutably adding to it the properties of object b.\n *\n * @param {Object} a The object to be extended\n * @param {Object} b The object to copy properties from\n * @param {Object} thisArg The object to bind function to\n * @return {Object} The resulting value of object a\n */\nfunction extend(a, b, thisArg) {\n forEach(b, function assignValue(val, key) {\n if (thisArg && typeof val === 'function') {\n a[key] = bind(val, thisArg);\n } else {\n a[key] = val;\n }\n });\n return a;\n}\n\n/**\n * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)\n *\n * @param {string} content with BOM\n * @return {string} content value without BOM\n */\nfunction stripBOM(content) {\n if (content.charCodeAt(0) === 0xFEFF) {\n content = content.slice(1);\n }\n return content;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isBuffer: isBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isPlainObject: isPlainObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isFunction: isFunction,\n isStream: isStream,\n isURLSearchParams: isURLSearchParams,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n extend: extend,\n trim: trim,\n stripBOM: stripBOM\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/utils.js\n// module id = 2\n// module chunks = 0","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/bind.js\n// module id = 3\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar buildURL = require('../helpers/buildURL');\nvar InterceptorManager = require('./InterceptorManager');\nvar dispatchRequest = require('./dispatchRequest');\nvar mergeConfig = require('./mergeConfig');\n\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n */\nfunction Axios(instanceConfig) {\n this.defaults = instanceConfig;\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\n/**\n * Dispatch a request\n *\n * @param {Object} config The config specific for this request (merged with this.defaults)\n */\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = arguments[1] || {};\n config.url = arguments[0];\n } else {\n config = config || {};\n }\n\n config = mergeConfig(this.defaults, config);\n\n // Set config.method\n if (config.method) {\n config.method = config.method.toLowerCase();\n } else if (this.defaults.method) {\n config.method = this.defaults.method.toLowerCase();\n } else {\n config.method = 'get';\n }\n\n // Hook up interceptors middleware\n var chain = [dispatchRequest, undefined];\n var promise = Promise.resolve(config);\n\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n chain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n chain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n};\n\nAxios.prototype.getUri = function getUri(config) {\n config = mergeConfig(this.defaults, config);\n return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\\?/, '');\n};\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: (config || {}).data\n }));\n };\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(mergeConfig(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n});\n\nmodule.exports = Axios;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/Axios.js\n// module id = 4\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nfunction encode(val) {\n return encodeURIComponent(val).\n replace(/%3A/gi, ':').\n replace(/%24/g, '$').\n replace(/%2C/gi, ',').\n replace(/%20/g, '+').\n replace(/%5B/gi, '[').\n replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @returns {string} The formatted url\n */\nmodule.exports = function buildURL(url, params, paramsSerializer) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n\n var serializedParams;\n if (paramsSerializer) {\n serializedParams = paramsSerializer(params);\n } else if (utils.isURLSearchParams(params)) {\n serializedParams = params.toString();\n } else {\n var parts = [];\n\n utils.forEach(params, function serialize(val, key) {\n if (val === null || typeof val === 'undefined') {\n return;\n }\n\n if (utils.isArray(val)) {\n key = key + '[]';\n } else {\n val = [val];\n }\n\n utils.forEach(val, function parseValue(v) {\n if (utils.isDate(v)) {\n v = v.toISOString();\n } else if (utils.isObject(v)) {\n v = JSON.stringify(v);\n }\n parts.push(encode(key) + '=' + encode(v));\n });\n });\n\n serializedParams = parts.join('&');\n }\n\n if (serializedParams) {\n var hashmarkIndex = url.indexOf('#');\n if (hashmarkIndex !== -1) {\n url = url.slice(0, hashmarkIndex);\n }\n\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/buildURL.js\n// module id = 5\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/InterceptorManager.js\n// module id = 6\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar transformData = require('./transformData');\nvar isCancel = require('../cancel/isCancel');\nvar defaults = require('../defaults');\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nfunction throwIfCancellationRequested(config) {\n if (config.cancelToken) {\n config.cancelToken.throwIfRequested();\n }\n}\n\n/**\n * Dispatch a request to the server using the configured adapter.\n *\n * @param {object} config The config that is to be used for the request\n * @returns {Promise} The Promise to be fulfilled\n */\nmodule.exports = function dispatchRequest(config) {\n throwIfCancellationRequested(config);\n\n // Ensure headers exist\n config.headers = config.headers || {};\n\n // Transform request data\n config.data = transformData(\n config.data,\n config.headers,\n config.transformRequest\n );\n\n // Flatten headers\n config.headers = utils.merge(\n config.headers.common || {},\n config.headers[config.method] || {},\n config.headers\n );\n\n utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n function cleanHeaderConfig(method) {\n delete config.headers[method];\n }\n );\n\n var adapter = config.adapter || defaults.adapter;\n\n return adapter(config).then(function onAdapterResolution(response) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n response.data = transformData(\n response.data,\n response.headers,\n config.transformResponse\n );\n\n return response;\n }, function onAdapterRejection(reason) {\n if (!isCancel(reason)) {\n throwIfCancellationRequested(config);\n\n // Transform response data\n if (reason && reason.response) {\n reason.response.data = transformData(\n reason.response.data,\n reason.response.headers,\n config.transformResponse\n );\n }\n }\n\n return Promise.reject(reason);\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/dispatchRequest.js\n// module id = 7\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Object|String} data The data to be transformed\n * @param {Array} headers The headers for the request or response\n * @param {Array|Function} fns A single function or Array of functions\n * @returns {*} The resulting transformed data\n */\nmodule.exports = function transformData(data, headers, fns) {\n /*eslint no-param-reassign:0*/\n utils.forEach(fns, function transform(fn) {\n data = fn(data, headers);\n });\n\n return data;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/transformData.js\n// module id = 8\n// module chunks = 0","'use strict';\n\nmodule.exports = function isCancel(value) {\n return !!(value && value.__CANCEL__);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/isCancel.js\n// module id = 9\n// module chunks = 0","'use strict';\n\nvar utils = require('./utils');\nvar normalizeHeaderName = require('./helpers/normalizeHeaderName');\n\nvar DEFAULT_CONTENT_TYPE = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nfunction setContentTypeIfUnset(headers, value) {\n if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n headers['Content-Type'] = value;\n }\n}\n\nfunction getDefaultAdapter() {\n var adapter;\n if (typeof XMLHttpRequest !== 'undefined') {\n // For browsers use XHR adapter\n adapter = require('./adapters/xhr');\n } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {\n // For node use HTTP adapter\n adapter = require('./adapters/http');\n }\n return adapter;\n}\n\nvar defaults = {\n adapter: getDefaultAdapter(),\n\n transformRequest: [function transformRequest(data, headers) {\n normalizeHeaderName(headers, 'Accept');\n normalizeHeaderName(headers, 'Content-Type');\n if (utils.isFormData(data) ||\n utils.isArrayBuffer(data) ||\n utils.isBuffer(data) ||\n utils.isStream(data) ||\n utils.isFile(data) ||\n utils.isBlob(data)\n ) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isURLSearchParams(data)) {\n setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n return data.toString();\n }\n if (utils.isObject(data)) {\n setContentTypeIfUnset(headers, 'application/json;charset=utf-8');\n return JSON.stringify(data);\n }\n return data;\n }],\n\n transformResponse: [function transformResponse(data) {\n /*eslint no-param-reassign:0*/\n if (typeof data === 'string') {\n try {\n data = JSON.parse(data);\n } catch (e) { /* Ignore */ }\n }\n return data;\n }],\n\n /**\n * A timeout in milliseconds to abort a request. If set to 0 (default) a\n * timeout is not created.\n */\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n\n maxContentLength: -1,\n maxBodyLength: -1,\n\n validateStatus: function validateStatus(status) {\n return status >= 200 && status < 300;\n }\n};\n\ndefaults.headers = {\n common: {\n 'Accept': 'application/json, text/plain, */*'\n }\n};\n\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n defaults.headers[method] = {};\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n});\n\nmodule.exports = defaults;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/defaults.js\n// module id = 10\n// module chunks = 0","'use strict';\n\nvar utils = require('../utils');\n\nmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n utils.forEach(headers, function processHeader(value, name) {\n if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n headers[normalizedName] = value;\n delete headers[name];\n }\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/normalizeHeaderName.js\n// module id = 11\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\nvar settle = require('./../core/settle');\nvar cookies = require('./../helpers/cookies');\nvar buildURL = require('./../helpers/buildURL');\nvar buildFullPath = require('../core/buildFullPath');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar createError = require('../core/createError');\n\nmodule.exports = function xhrAdapter(config) {\n return new Promise(function dispatchXhrRequest(resolve, reject) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n var fullPath = buildFullPath(config.baseURL, config.url);\n request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n // Listen for ready state\n request.onreadystatechange = function handleLoad() {\n if (!request || request.readyState !== 4) {\n return;\n }\n\n // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n // With one exception: request that using file: protocol, most browsers\n // will return status as 0 even though it's a successful request\n if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n return;\n }\n\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n var response = {\n data: responseData,\n status: request.status,\n statusText: request.statusText,\n headers: responseHeaders,\n config: config,\n request: request\n };\n\n settle(resolve, reject, response);\n\n // Clean up request\n request = null;\n };\n\n // Handle browser request cancellation (as opposed to a manual cancellation)\n request.onabort = function handleAbort() {\n if (!request) {\n return;\n }\n\n reject(createError('Request aborted', config, 'ECONNABORTED', request));\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(createError('Network Error', config, null, request));\n\n // Clean up request\n request = null;\n };\n\n // Handle timeout\n request.ontimeout = function handleTimeout() {\n var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';\n if (config.timeoutErrorMessage) {\n timeoutErrorMessage = config.timeoutErrorMessage;\n }\n reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',\n request));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n // Add xsrf header\n var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (!utils.isUndefined(config.withCredentials)) {\n request.withCredentials = !!config.withCredentials;\n }\n\n // Add responseType to request if needed\n if (config.responseType) {\n try {\n request.responseType = config.responseType;\n } catch (e) {\n // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n if (config.responseType !== 'json') {\n throw e;\n }\n }\n }\n\n // Handle progress if needed\n if (typeof config.onDownloadProgress === 'function') {\n request.addEventListener('progress', config.onDownloadProgress);\n }\n\n // Not all browsers support upload events\n if (typeof config.onUploadProgress === 'function' && request.upload) {\n request.upload.addEventListener('progress', config.onUploadProgress);\n }\n\n if (config.cancelToken) {\n // Handle cancellation\n config.cancelToken.promise.then(function onCanceled(cancel) {\n if (!request) {\n return;\n }\n\n request.abort();\n reject(cancel);\n // Clean up request\n request = null;\n });\n }\n\n if (!requestData) {\n requestData = null;\n }\n\n // Send the request\n request.send(requestData);\n });\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/adapters/xhr.js\n// module id = 12\n// module chunks = 0","'use strict';\n\nvar createError = require('./createError');\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n */\nmodule.exports = function settle(resolve, reject, response) {\n var validateStatus = response.config.validateStatus;\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(createError(\n 'Request failed with status code ' + response.status,\n response.config,\n null,\n response.request,\n response\n ));\n }\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/settle.js\n// module id = 13\n// module chunks = 0","'use strict';\n\nvar enhanceError = require('./enhanceError');\n\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The created error.\n */\nmodule.exports = function createError(message, config, code, request, response) {\n var error = new Error(message);\n return enhanceError(error, config, code, request, response);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/createError.js\n// module id = 14\n// module chunks = 0","'use strict';\n\n/**\n * Update an Error with the specified config, error code, and response.\n *\n * @param {Error} error The error to update.\n * @param {Object} config The config.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n * @returns {Error} The error.\n */\nmodule.exports = function enhanceError(error, config, code, request, response) {\n error.config = config;\n if (code) {\n error.code = code;\n }\n\n error.request = request;\n error.response = response;\n error.isAxiosError = true;\n\n error.toJSON = function toJSON() {\n return {\n // Standard\n message: this.message,\n name: this.name,\n // Microsoft\n description: this.description,\n number: this.number,\n // Mozilla\n fileName: this.fileName,\n lineNumber: this.lineNumber,\n columnNumber: this.columnNumber,\n stack: this.stack,\n // Axios\n config: this.config,\n code: this.code\n };\n };\n return error;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/enhanceError.js\n// module id = 15\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs support document.cookie\n (function standardBrowserEnv() {\n return {\n write: function write(name, value, expires, path, domain, secure) {\n var cookie = [];\n cookie.push(name + '=' + encodeURIComponent(value));\n\n if (utils.isNumber(expires)) {\n cookie.push('expires=' + new Date(expires).toGMTString());\n }\n\n if (utils.isString(path)) {\n cookie.push('path=' + path);\n }\n\n if (utils.isString(domain)) {\n cookie.push('domain=' + domain);\n }\n\n if (secure === true) {\n cookie.push('secure');\n }\n\n document.cookie = cookie.join('; ');\n },\n\n read: function read(name) {\n var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove: function remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n };\n })() :\n\n // Non standard browser env (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return {\n write: function write() {},\n read: function read() { return null; },\n remove: function remove() {}\n };\n })()\n);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/cookies.js\n// module id = 16\n// module chunks = 0","'use strict';\n\nvar isAbsoluteURL = require('../helpers/isAbsoluteURL');\nvar combineURLs = require('../helpers/combineURLs');\n\n/**\n * Creates a new URL by combining the baseURL with the requestedURL,\n * only when the requestedURL is not already an absolute URL.\n * If the requestURL is absolute, this function returns the requestedURL untouched.\n *\n * @param {string} baseURL The base URL\n * @param {string} requestedURL Absolute or relative URL to combine\n * @returns {string} The combined full path\n */\nmodule.exports = function buildFullPath(baseURL, requestedURL) {\n if (baseURL && !isAbsoluteURL(requestedURL)) {\n return combineURLs(baseURL, requestedURL);\n }\n return requestedURL;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/buildFullPath.js\n// module id = 17\n// module chunks = 0","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nmodule.exports = function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isAbsoluteURL.js\n// module id = 18\n// module chunks = 0","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n * @returns {string} The combined URL\n */\nmodule.exports = function combineURLs(baseURL, relativeURL) {\n return relativeURL\n ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n : baseURL;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/combineURLs.js\n// module id = 19\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\n// Headers whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\nvar ignoreDuplicateOf = [\n 'age', 'authorization', 'content-length', 'content-type', 'etag',\n 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n 'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n 'referer', 'retry-after', 'user-agent'\n];\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {\n return;\n }\n if (key === 'set-cookie') {\n parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);\n } else {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n }\n });\n\n return parsed;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/parseHeaders.js\n// module id = 20\n// module chunks = 0","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isURLSameOrigin.js\n// module id = 21\n// module chunks = 0","'use strict';\n\nvar utils = require('../utils');\n\n/**\n * Config-specific merge-function which creates a new config-object\n * by merging two configuration objects together.\n *\n * @param {Object} config1\n * @param {Object} config2\n * @returns {Object} New object resulting from merging config2 to config1\n */\nmodule.exports = function mergeConfig(config1, config2) {\n // eslint-disable-next-line no-param-reassign\n config2 = config2 || {};\n var config = {};\n\n var valueFromConfig2Keys = ['url', 'method', 'data'];\n var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];\n var defaultToConfig2Keys = [\n 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',\n 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',\n 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',\n 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',\n 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'\n ];\n var directMergeKeys = ['validateStatus'];\n\n function getMergedValue(target, source) {\n if (utils.isPlainObject(target) && utils.isPlainObject(source)) {\n return utils.merge(target, source);\n } else if (utils.isPlainObject(source)) {\n return utils.merge({}, source);\n } else if (utils.isArray(source)) {\n return source.slice();\n }\n return source;\n }\n\n function mergeDeepProperties(prop) {\n if (!utils.isUndefined(config2[prop])) {\n config[prop] = getMergedValue(config1[prop], config2[prop]);\n } else if (!utils.isUndefined(config1[prop])) {\n config[prop] = getMergedValue(undefined, config1[prop]);\n }\n }\n\n utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {\n if (!utils.isUndefined(config2[prop])) {\n config[prop] = getMergedValue(undefined, config2[prop]);\n }\n });\n\n utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);\n\n utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {\n if (!utils.isUndefined(config2[prop])) {\n config[prop] = getMergedValue(undefined, config2[prop]);\n } else if (!utils.isUndefined(config1[prop])) {\n config[prop] = getMergedValue(undefined, config1[prop]);\n }\n });\n\n utils.forEach(directMergeKeys, function merge(prop) {\n if (prop in config2) {\n config[prop] = getMergedValue(config1[prop], config2[prop]);\n } else if (prop in config1) {\n config[prop] = getMergedValue(undefined, config1[prop]);\n }\n });\n\n var axiosKeys = valueFromConfig2Keys\n .concat(mergeDeepPropertiesKeys)\n .concat(defaultToConfig2Keys)\n .concat(directMergeKeys);\n\n var otherKeys = Object\n .keys(config1)\n .concat(Object.keys(config2))\n .filter(function filterAxiosKeys(key) {\n return axiosKeys.indexOf(key) === -1;\n });\n\n utils.forEach(otherKeys, mergeDeepProperties);\n\n return config;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/core/mergeConfig.js\n// module id = 22\n// module chunks = 0","'use strict';\n\n/**\n * A `Cancel` is an object that is thrown when an operation is canceled.\n *\n * @class\n * @param {string=} message The message.\n */\nfunction Cancel(message) {\n this.message = message;\n}\n\nCancel.prototype.toString = function toString() {\n return 'Cancel' + (this.message ? ': ' + this.message : '');\n};\n\nCancel.prototype.__CANCEL__ = true;\n\nmodule.exports = Cancel;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/Cancel.js\n// module id = 23\n// module chunks = 0","'use strict';\n\nvar Cancel = require('./Cancel');\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @class\n * @param {Function} executor The executor function.\n */\nfunction CancelToken(executor) {\n if (typeof executor !== 'function') {\n throw new TypeError('executor must be a function.');\n }\n\n var resolvePromise;\n this.promise = new Promise(function promiseExecutor(resolve) {\n resolvePromise = resolve;\n });\n\n var token = this;\n executor(function cancel(message) {\n if (token.reason) {\n // Cancellation has already been requested\n return;\n }\n\n token.reason = new Cancel(message);\n resolvePromise(token.reason);\n });\n}\n\n/**\n * Throws a `Cancel` if cancellation has been requested.\n */\nCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n if (this.reason) {\n throw this.reason;\n }\n};\n\n/**\n * Returns an object that contains a new `CancelToken` and a function that, when called,\n * cancels the `CancelToken`.\n */\nCancelToken.source = function source() {\n var cancel;\n var token = new CancelToken(function executor(c) {\n cancel = c;\n });\n return {\n token: token,\n cancel: cancel\n };\n};\n\nmodule.exports = CancelToken;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/cancel/CancelToken.js\n// module id = 24\n// module chunks = 0","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n * @returns {Function}\n */\nmodule.exports = function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/spread.js\n// module id = 25\n// module chunks = 0","'use strict';\n\n/**\n * Determines whether the payload is an error thrown by Axios\n *\n * @param {*} payload The value to test\n * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false\n */\nmodule.exports = function isAxiosError(payload) {\n return (typeof payload === 'object') && (payload.isAxiosError === true);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/helpers/isAxiosError.js\n// module id = 26\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/index.d.ts b/SCRS-Backend/src/test/javascript/node_modules/axios/index.d.ts new file mode 100644 index 0000000..c74e93c --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/index.d.ts @@ -0,0 +1,161 @@ +export interface AxiosTransformer { + (data: any, headers?: any): any; +} + +export interface AxiosAdapter { + (config: AxiosRequestConfig): AxiosPromise; +} + +export interface AxiosBasicCredentials { + username: string; + password: string; +} + +export interface AxiosProxyConfig { + host: string; + port: number; + auth?: { + username: string; + password:string; + }; + protocol?: string; +} + +export type Method = + | 'get' | 'GET' + | 'delete' | 'DELETE' + | 'head' | 'HEAD' + | 'options' | 'OPTIONS' + | 'post' | 'POST' + | 'put' | 'PUT' + | 'patch' | 'PATCH' + | 'purge' | 'PURGE' + | 'link' | 'LINK' + | 'unlink' | 'UNLINK' + +export type ResponseType = + | 'arraybuffer' + | 'blob' + | 'document' + | 'json' + | 'text' + | 'stream' + +export interface AxiosRequestConfig { + url?: string; + method?: Method; + baseURL?: string; + transformRequest?: AxiosTransformer | AxiosTransformer[]; + transformResponse?: AxiosTransformer | AxiosTransformer[]; + headers?: any; + params?: any; + paramsSerializer?: (params: any) => string; + data?: any; + timeout?: number; + timeoutErrorMessage?: string; + withCredentials?: boolean; + adapter?: AxiosAdapter; + auth?: AxiosBasicCredentials; + responseType?: ResponseType; + xsrfCookieName?: string; + xsrfHeaderName?: string; + onUploadProgress?: (progressEvent: any) => void; + onDownloadProgress?: (progressEvent: any) => void; + maxContentLength?: number; + validateStatus?: ((status: number) => boolean) | null; + maxBodyLength?: number; + maxRedirects?: number; + socketPath?: string | null; + httpAgent?: any; + httpsAgent?: any; + proxy?: AxiosProxyConfig | false; + cancelToken?: CancelToken; + decompress?: boolean; +} + +export interface AxiosResponse { + data: T; + status: number; + statusText: string; + headers: any; + config: AxiosRequestConfig; + request?: any; +} + +export interface AxiosError extends Error { + config: AxiosRequestConfig; + code?: string; + request?: any; + response?: AxiosResponse; + isAxiosError: boolean; + toJSON: () => object; +} + +export interface AxiosPromise extends Promise> { +} + +export interface CancelStatic { + new (message?: string): Cancel; +} + +export interface Cancel { + message: string; +} + +export interface Canceler { + (message?: string): void; +} + +export interface CancelTokenStatic { + new (executor: (cancel: Canceler) => void): CancelToken; + source(): CancelTokenSource; +} + +export interface CancelToken { + promise: Promise; + reason?: Cancel; + throwIfRequested(): void; +} + +export interface CancelTokenSource { + token: CancelToken; + cancel: Canceler; +} + +export interface AxiosInterceptorManager { + use(onFulfilled?: (value: V) => V | Promise, onRejected?: (error: any) => any): number; + eject(id: number): void; +} + +export interface AxiosInstance { + (config: AxiosRequestConfig): AxiosPromise; + (url: string, config?: AxiosRequestConfig): AxiosPromise; + defaults: AxiosRequestConfig; + interceptors: { + request: AxiosInterceptorManager; + response: AxiosInterceptorManager; + }; + getUri(config?: AxiosRequestConfig): string; + request> (config: AxiosRequestConfig): Promise; + get>(url: string, config?: AxiosRequestConfig): Promise; + delete>(url: string, config?: AxiosRequestConfig): Promise; + head>(url: string, config?: AxiosRequestConfig): Promise; + options>(url: string, config?: AxiosRequestConfig): Promise; + post>(url: string, data?: any, config?: AxiosRequestConfig): Promise; + put>(url: string, data?: any, config?: AxiosRequestConfig): Promise; + patch>(url: string, data?: any, config?: AxiosRequestConfig): Promise; +} + +export interface AxiosStatic extends AxiosInstance { + create(config?: AxiosRequestConfig): AxiosInstance; + Cancel: CancelStatic; + CancelToken: CancelTokenStatic; + isCancel(value: any): boolean; + all(values: (T | Promise)[]): Promise; + spread(callback: (...args: T[]) => R): (array: T[]) => R; + isAxiosError(payload: any): payload is AxiosError; +} + +declare const axios: AxiosStatic; + +export default axios; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/index.js b/SCRS-Backend/src/test/javascript/node_modules/axios/index.js new file mode 100644 index 0000000..79dfd09 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/axios'); \ No newline at end of file diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/adapters/README.md b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/adapters/README.md new file mode 100644 index 0000000..68f1118 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/adapters/README.md @@ -0,0 +1,37 @@ +# axios // adapters + +The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received. + +## Example + +```js +var settle = require('./../core/settle'); + +module.exports = function myAdapter(config) { + // At this point: + // - config has been merged with defaults + // - request transformers have already run + // - request interceptors have already run + + // Make the request using config provided + // Upon response settle the Promise + + return new Promise(function(resolve, reject) { + + var response = { + data: responseData, + status: request.status, + statusText: request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // From here: + // - response transformers will run + // - response interceptors will run + }); +} +``` diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/adapters/http.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/adapters/http.js new file mode 100644 index 0000000..f32241f --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/adapters/http.js @@ -0,0 +1,303 @@ +'use strict'; + +var utils = require('./../utils'); +var settle = require('./../core/settle'); +var buildFullPath = require('../core/buildFullPath'); +var buildURL = require('./../helpers/buildURL'); +var http = require('http'); +var https = require('https'); +var httpFollow = require('follow-redirects').http; +var httpsFollow = require('follow-redirects').https; +var url = require('url'); +var zlib = require('zlib'); +var pkg = require('./../../package.json'); +var createError = require('../core/createError'); +var enhanceError = require('../core/enhanceError'); + +var isHttps = /https:?/; + +/** + * + * @param {http.ClientRequestArgs} options + * @param {AxiosProxyConfig} proxy + * @param {string} location + */ +function setProxy(options, proxy, location) { + options.hostname = proxy.host; + options.host = proxy.host; + options.port = proxy.port; + options.path = location; + + // Basic proxy authorization + if (proxy.auth) { + var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64'); + options.headers['Proxy-Authorization'] = 'Basic ' + base64; + } + + // If a proxy is used, any redirects must also pass through the proxy + options.beforeRedirect = function beforeRedirect(redirection) { + redirection.headers.host = redirection.host; + setProxy(redirection, proxy, redirection.href); + }; +} + +/*eslint consistent-return:0*/ +module.exports = function httpAdapter(config) { + return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) { + var resolve = function resolve(value) { + resolvePromise(value); + }; + var reject = function reject(value) { + rejectPromise(value); + }; + var data = config.data; + var headers = config.headers; + + // Set User-Agent (required by some servers) + // Only set header if it hasn't been set in config + // See https://github.com/axios/axios/issues/69 + if (!headers['User-Agent'] && !headers['user-agent']) { + headers['User-Agent'] = 'axios/' + pkg.version; + } + + if (data && !utils.isStream(data)) { + if (Buffer.isBuffer(data)) { + // Nothing to do... + } else if (utils.isArrayBuffer(data)) { + data = Buffer.from(new Uint8Array(data)); + } else if (utils.isString(data)) { + data = Buffer.from(data, 'utf-8'); + } else { + return reject(createError( + 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', + config + )); + } + + // Add Content-Length header if data exists + headers['Content-Length'] = data.length; + } + + // HTTP basic authentication + var auth = undefined; + if (config.auth) { + var username = config.auth.username || ''; + var password = config.auth.password || ''; + auth = username + ':' + password; + } + + // Parse url + var fullPath = buildFullPath(config.baseURL, config.url); + var parsed = url.parse(fullPath); + var protocol = parsed.protocol || 'http:'; + + if (!auth && parsed.auth) { + var urlAuth = parsed.auth.split(':'); + var urlUsername = urlAuth[0] || ''; + var urlPassword = urlAuth[1] || ''; + auth = urlUsername + ':' + urlPassword; + } + + if (auth) { + delete headers.Authorization; + } + + var isHttpsRequest = isHttps.test(protocol); + var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; + + var options = { + path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), + method: config.method.toUpperCase(), + headers: headers, + agent: agent, + agents: { http: config.httpAgent, https: config.httpsAgent }, + auth: auth + }; + + if (config.socketPath) { + options.socketPath = config.socketPath; + } else { + options.hostname = parsed.hostname; + options.port = parsed.port; + } + + var proxy = config.proxy; + if (!proxy && proxy !== false) { + var proxyEnv = protocol.slice(0, -1) + '_proxy'; + var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()]; + if (proxyUrl) { + var parsedProxyUrl = url.parse(proxyUrl); + var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY; + var shouldProxy = true; + + if (noProxyEnv) { + var noProxy = noProxyEnv.split(',').map(function trim(s) { + return s.trim(); + }); + + shouldProxy = !noProxy.some(function proxyMatch(proxyElement) { + if (!proxyElement) { + return false; + } + if (proxyElement === '*') { + return true; + } + if (proxyElement[0] === '.' && + parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) { + return true; + } + + return parsed.hostname === proxyElement; + }); + } + + if (shouldProxy) { + proxy = { + host: parsedProxyUrl.hostname, + port: parsedProxyUrl.port, + protocol: parsedProxyUrl.protocol + }; + + if (parsedProxyUrl.auth) { + var proxyUrlAuth = parsedProxyUrl.auth.split(':'); + proxy.auth = { + username: proxyUrlAuth[0], + password: proxyUrlAuth[1] + }; + } + } + } + } + + if (proxy) { + options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : ''); + setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path); + } + + var transport; + var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true); + if (config.transport) { + transport = config.transport; + } else if (config.maxRedirects === 0) { + transport = isHttpsProxy ? https : http; + } else { + if (config.maxRedirects) { + options.maxRedirects = config.maxRedirects; + } + transport = isHttpsProxy ? httpsFollow : httpFollow; + } + + if (config.maxBodyLength > -1) { + options.maxBodyLength = config.maxBodyLength; + } + + // Create the request + var req = transport.request(options, function handleResponse(res) { + if (req.aborted) return; + + // uncompress the response body transparently if required + var stream = res; + + // return the last request in case of redirects + var lastRequest = res.req || req; + + + // if no content, is HEAD request or decompress disabled we should not decompress + if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) { + switch (res.headers['content-encoding']) { + /*eslint default-case:0*/ + case 'gzip': + case 'compress': + case 'deflate': + // add the unzipper to the body stream processing pipeline + stream = stream.pipe(zlib.createUnzip()); + + // remove the content-encoding in order to not confuse downstream operations + delete res.headers['content-encoding']; + break; + } + } + + var response = { + status: res.statusCode, + statusText: res.statusMessage, + headers: res.headers, + config: config, + request: lastRequest + }; + + if (config.responseType === 'stream') { + response.data = stream; + settle(resolve, reject, response); + } else { + var responseBuffer = []; + stream.on('data', function handleStreamData(chunk) { + responseBuffer.push(chunk); + + // make sure the content length is not over the maxContentLength if specified + if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) { + stream.destroy(); + reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', + config, null, lastRequest)); + } + }); + + stream.on('error', function handleStreamError(err) { + if (req.aborted) return; + reject(enhanceError(err, config, null, lastRequest)); + }); + + stream.on('end', function handleStreamEnd() { + var responseData = Buffer.concat(responseBuffer); + if (config.responseType !== 'arraybuffer') { + responseData = responseData.toString(config.responseEncoding); + if (!config.responseEncoding || config.responseEncoding === 'utf8') { + responseData = utils.stripBOM(responseData); + } + } + + response.data = responseData; + settle(resolve, reject, response); + }); + } + }); + + // Handle errors + req.on('error', function handleRequestError(err) { + if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return; + reject(enhanceError(err, config, null, req)); + }); + + // Handle request timeout + if (config.timeout) { + // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system. + // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET. + // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up. + // And then these socket which be hang up will devoring CPU little by little. + // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect. + req.setTimeout(config.timeout, function handleRequestTimeout() { + req.abort(); + reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req)); + }); + } + + if (config.cancelToken) { + // Handle cancellation + config.cancelToken.promise.then(function onCanceled(cancel) { + if (req.aborted) return; + + req.abort(); + reject(cancel); + }); + } + + // Send the request + if (utils.isStream(data)) { + data.on('error', function handleStreamError(err) { + reject(enhanceError(err, config, null, req)); + }).pipe(req); + } else { + req.end(data); + } + }); +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/adapters/xhr.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/adapters/xhr.js new file mode 100644 index 0000000..3027752 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/adapters/xhr.js @@ -0,0 +1,179 @@ +'use strict'; + +var utils = require('./../utils'); +var settle = require('./../core/settle'); +var cookies = require('./../helpers/cookies'); +var buildURL = require('./../helpers/buildURL'); +var buildFullPath = require('../core/buildFullPath'); +var parseHeaders = require('./../helpers/parseHeaders'); +var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); +var createError = require('../core/createError'); + +module.exports = function xhrAdapter(config) { + return new Promise(function dispatchXhrRequest(resolve, reject) { + var requestData = config.data; + var requestHeaders = config.headers; + + if (utils.isFormData(requestData)) { + delete requestHeaders['Content-Type']; // Let the browser set it + } + + var request = new XMLHttpRequest(); + + // HTTP basic authentication + if (config.auth) { + var username = config.auth.username || ''; + var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); + } + + var fullPath = buildFullPath(config.baseURL, config.url); + request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); + + // Set the request timeout in MS + request.timeout = config.timeout; + + // Listen for ready state + request.onreadystatechange = function handleLoad() { + if (!request || request.readyState !== 4) { + return; + } + + // The request errored out and we didn't get a response, this will be + // handled by onerror instead + // With one exception: request that using file: protocol, most browsers + // will return status as 0 even though it's a successful request + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { + return; + } + + // Prepare the response + var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; + var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; + var response = { + data: responseData, + status: request.status, + statusText: request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // Clean up request + request = null; + }; + + // Handle browser request cancellation (as opposed to a manual cancellation) + request.onabort = function handleAbort() { + if (!request) { + return; + } + + reject(createError('Request aborted', config, 'ECONNABORTED', request)); + + // Clean up request + request = null; + }; + + // Handle low level network errors + request.onerror = function handleError() { + // Real errors are hidden from us by the browser + // onerror should only fire if it's a network error + reject(createError('Network Error', config, null, request)); + + // Clean up request + request = null; + }; + + // Handle timeout + request.ontimeout = function handleTimeout() { + var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; + if (config.timeoutErrorMessage) { + timeoutErrorMessage = config.timeoutErrorMessage; + } + reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', + request)); + + // Clean up request + request = null; + }; + + // Add xsrf header + // This is only done if running in a standard browser environment. + // Specifically not if we're in a web worker, or react-native. + if (utils.isStandardBrowserEnv()) { + // Add xsrf header + var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? + cookies.read(config.xsrfCookieName) : + undefined; + + if (xsrfValue) { + requestHeaders[config.xsrfHeaderName] = xsrfValue; + } + } + + // Add headers to the request + if ('setRequestHeader' in request) { + utils.forEach(requestHeaders, function setRequestHeader(val, key) { + if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { + // Remove Content-Type if data is undefined + delete requestHeaders[key]; + } else { + // Otherwise add header to the request + request.setRequestHeader(key, val); + } + }); + } + + // Add withCredentials to request if needed + if (!utils.isUndefined(config.withCredentials)) { + request.withCredentials = !!config.withCredentials; + } + + // Add responseType to request if needed + if (config.responseType) { + try { + request.responseType = config.responseType; + } catch (e) { + // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. + // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. + if (config.responseType !== 'json') { + throw e; + } + } + } + + // Handle progress if needed + if (typeof config.onDownloadProgress === 'function') { + request.addEventListener('progress', config.onDownloadProgress); + } + + // Not all browsers support upload events + if (typeof config.onUploadProgress === 'function' && request.upload) { + request.upload.addEventListener('progress', config.onUploadProgress); + } + + if (config.cancelToken) { + // Handle cancellation + config.cancelToken.promise.then(function onCanceled(cancel) { + if (!request) { + return; + } + + request.abort(); + reject(cancel); + // Clean up request + request = null; + }); + } + + if (!requestData) { + requestData = null; + } + + // Send the request + request.send(requestData); + }); +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/axios.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/axios.js new file mode 100644 index 0000000..c6357b0 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/axios.js @@ -0,0 +1,56 @@ +'use strict'; + +var utils = require('./utils'); +var bind = require('./helpers/bind'); +var Axios = require('./core/Axios'); +var mergeConfig = require('./core/mergeConfig'); +var defaults = require('./defaults'); + +/** + * Create an instance of Axios + * + * @param {Object} defaultConfig The default config for the instance + * @return {Axios} A new instance of Axios + */ +function createInstance(defaultConfig) { + var context = new Axios(defaultConfig); + var instance = bind(Axios.prototype.request, context); + + // Copy axios.prototype to instance + utils.extend(instance, Axios.prototype, context); + + // Copy context to instance + utils.extend(instance, context); + + return instance; +} + +// Create the default instance to be exported +var axios = createInstance(defaults); + +// Expose Axios class to allow class inheritance +axios.Axios = Axios; + +// Factory for creating new instances +axios.create = function create(instanceConfig) { + return createInstance(mergeConfig(axios.defaults, instanceConfig)); +}; + +// Expose Cancel & CancelToken +axios.Cancel = require('./cancel/Cancel'); +axios.CancelToken = require('./cancel/CancelToken'); +axios.isCancel = require('./cancel/isCancel'); + +// Expose all/spread +axios.all = function all(promises) { + return Promise.all(promises); +}; +axios.spread = require('./helpers/spread'); + +// Expose isAxiosError +axios.isAxiosError = require('./helpers/isAxiosError'); + +module.exports = axios; + +// Allow use of default import syntax in TypeScript +module.exports.default = axios; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/cancel/Cancel.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/cancel/Cancel.js new file mode 100644 index 0000000..e0de400 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/cancel/Cancel.js @@ -0,0 +1,19 @@ +'use strict'; + +/** + * A `Cancel` is an object that is thrown when an operation is canceled. + * + * @class + * @param {string=} message The message. + */ +function Cancel(message) { + this.message = message; +} + +Cancel.prototype.toString = function toString() { + return 'Cancel' + (this.message ? ': ' + this.message : ''); +}; + +Cancel.prototype.__CANCEL__ = true; + +module.exports = Cancel; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/cancel/CancelToken.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/cancel/CancelToken.js new file mode 100644 index 0000000..6b46e66 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/cancel/CancelToken.js @@ -0,0 +1,57 @@ +'use strict'; + +var Cancel = require('./Cancel'); + +/** + * A `CancelToken` is an object that can be used to request cancellation of an operation. + * + * @class + * @param {Function} executor The executor function. + */ +function CancelToken(executor) { + if (typeof executor !== 'function') { + throw new TypeError('executor must be a function.'); + } + + var resolvePromise; + this.promise = new Promise(function promiseExecutor(resolve) { + resolvePromise = resolve; + }); + + var token = this; + executor(function cancel(message) { + if (token.reason) { + // Cancellation has already been requested + return; + } + + token.reason = new Cancel(message); + resolvePromise(token.reason); + }); +} + +/** + * Throws a `Cancel` if cancellation has been requested. + */ +CancelToken.prototype.throwIfRequested = function throwIfRequested() { + if (this.reason) { + throw this.reason; + } +}; + +/** + * Returns an object that contains a new `CancelToken` and a function that, when called, + * cancels the `CancelToken`. + */ +CancelToken.source = function source() { + var cancel; + var token = new CancelToken(function executor(c) { + cancel = c; + }); + return { + token: token, + cancel: cancel + }; +}; + +module.exports = CancelToken; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/cancel/isCancel.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/cancel/isCancel.js new file mode 100644 index 0000000..051f3ae --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/cancel/isCancel.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function isCancel(value) { + return !!(value && value.__CANCEL__); +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/Axios.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/Axios.js new file mode 100644 index 0000000..c28c413 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/Axios.js @@ -0,0 +1,95 @@ +'use strict'; + +var utils = require('./../utils'); +var buildURL = require('../helpers/buildURL'); +var InterceptorManager = require('./InterceptorManager'); +var dispatchRequest = require('./dispatchRequest'); +var mergeConfig = require('./mergeConfig'); + +/** + * Create a new instance of Axios + * + * @param {Object} instanceConfig The default config for the instance + */ +function Axios(instanceConfig) { + this.defaults = instanceConfig; + this.interceptors = { + request: new InterceptorManager(), + response: new InterceptorManager() + }; +} + +/** + * Dispatch a request + * + * @param {Object} config The config specific for this request (merged with this.defaults) + */ +Axios.prototype.request = function request(config) { + /*eslint no-param-reassign:0*/ + // Allow for axios('example/url'[, config]) a la fetch API + if (typeof config === 'string') { + config = arguments[1] || {}; + config.url = arguments[0]; + } else { + config = config || {}; + } + + config = mergeConfig(this.defaults, config); + + // Set config.method + if (config.method) { + config.method = config.method.toLowerCase(); + } else if (this.defaults.method) { + config.method = this.defaults.method.toLowerCase(); + } else { + config.method = 'get'; + } + + // Hook up interceptors middleware + var chain = [dispatchRequest, undefined]; + var promise = Promise.resolve(config); + + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { + chain.unshift(interceptor.fulfilled, interceptor.rejected); + }); + + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { + chain.push(interceptor.fulfilled, interceptor.rejected); + }); + + while (chain.length) { + promise = promise.then(chain.shift(), chain.shift()); + } + + return promise; +}; + +Axios.prototype.getUri = function getUri(config) { + config = mergeConfig(this.defaults, config); + return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); +}; + +// Provide aliases for supported request methods +utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, config) { + return this.request(mergeConfig(config || {}, { + method: method, + url: url, + data: (config || {}).data + })); + }; +}); + +utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, data, config) { + return this.request(mergeConfig(config || {}, { + method: method, + url: url, + data: data + })); + }; +}); + +module.exports = Axios; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/InterceptorManager.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/InterceptorManager.js new file mode 100644 index 0000000..50d667b --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/InterceptorManager.js @@ -0,0 +1,52 @@ +'use strict'; + +var utils = require('./../utils'); + +function InterceptorManager() { + this.handlers = []; +} + +/** + * Add a new interceptor to the stack + * + * @param {Function} fulfilled The function to handle `then` for a `Promise` + * @param {Function} rejected The function to handle `reject` for a `Promise` + * + * @return {Number} An ID used to remove interceptor later + */ +InterceptorManager.prototype.use = function use(fulfilled, rejected) { + this.handlers.push({ + fulfilled: fulfilled, + rejected: rejected + }); + return this.handlers.length - 1; +}; + +/** + * Remove an interceptor from the stack + * + * @param {Number} id The ID that was returned by `use` + */ +InterceptorManager.prototype.eject = function eject(id) { + if (this.handlers[id]) { + this.handlers[id] = null; + } +}; + +/** + * Iterate over all the registered interceptors + * + * This method is particularly useful for skipping over any + * interceptors that may have become `null` calling `eject`. + * + * @param {Function} fn The function to call for each interceptor + */ +InterceptorManager.prototype.forEach = function forEach(fn) { + utils.forEach(this.handlers, function forEachHandler(h) { + if (h !== null) { + fn(h); + } + }); +}; + +module.exports = InterceptorManager; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/README.md b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/README.md new file mode 100644 index 0000000..253bc48 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/README.md @@ -0,0 +1,7 @@ +# axios // core + +The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are: + +- Dispatching requests +- Managing interceptors +- Handling config diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/buildFullPath.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/buildFullPath.js new file mode 100644 index 0000000..00b2b05 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/buildFullPath.js @@ -0,0 +1,20 @@ +'use strict'; + +var isAbsoluteURL = require('../helpers/isAbsoluteURL'); +var combineURLs = require('../helpers/combineURLs'); + +/** + * Creates a new URL by combining the baseURL with the requestedURL, + * only when the requestedURL is not already an absolute URL. + * If the requestURL is absolute, this function returns the requestedURL untouched. + * + * @param {string} baseURL The base URL + * @param {string} requestedURL Absolute or relative URL to combine + * @returns {string} The combined full path + */ +module.exports = function buildFullPath(baseURL, requestedURL) { + if (baseURL && !isAbsoluteURL(requestedURL)) { + return combineURLs(baseURL, requestedURL); + } + return requestedURL; +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/createError.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/createError.js new file mode 100644 index 0000000..933680f --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/createError.js @@ -0,0 +1,18 @@ +'use strict'; + +var enhanceError = require('./enhanceError'); + +/** + * Create an Error with the specified message, config, error code, request and response. + * + * @param {string} message The error message. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The created error. + */ +module.exports = function createError(message, config, code, request, response) { + var error = new Error(message); + return enhanceError(error, config, code, request, response); +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/dispatchRequest.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/dispatchRequest.js new file mode 100644 index 0000000..c8267ad --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/dispatchRequest.js @@ -0,0 +1,79 @@ +'use strict'; + +var utils = require('./../utils'); +var transformData = require('./transformData'); +var isCancel = require('../cancel/isCancel'); +var defaults = require('../defaults'); + +/** + * Throws a `Cancel` if cancellation has been requested. + */ +function throwIfCancellationRequested(config) { + if (config.cancelToken) { + config.cancelToken.throwIfRequested(); + } +} + +/** + * Dispatch a request to the server using the configured adapter. + * + * @param {object} config The config that is to be used for the request + * @returns {Promise} The Promise to be fulfilled + */ +module.exports = function dispatchRequest(config) { + throwIfCancellationRequested(config); + + // Ensure headers exist + config.headers = config.headers || {}; + + // Transform request data + config.data = transformData( + config.data, + config.headers, + config.transformRequest + ); + + // Flatten headers + config.headers = utils.merge( + config.headers.common || {}, + config.headers[config.method] || {}, + config.headers + ); + + utils.forEach( + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], + function cleanHeaderConfig(method) { + delete config.headers[method]; + } + ); + + var adapter = config.adapter || defaults.adapter; + + return adapter(config).then(function onAdapterResolution(response) { + throwIfCancellationRequested(config); + + // Transform response data + response.data = transformData( + response.data, + response.headers, + config.transformResponse + ); + + return response; + }, function onAdapterRejection(reason) { + if (!isCancel(reason)) { + throwIfCancellationRequested(config); + + // Transform response data + if (reason && reason.response) { + reason.response.data = transformData( + reason.response.data, + reason.response.headers, + config.transformResponse + ); + } + } + + return Promise.reject(reason); + }); +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/enhanceError.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/enhanceError.js new file mode 100644 index 0000000..b6bc444 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/enhanceError.js @@ -0,0 +1,42 @@ +'use strict'; + +/** + * Update an Error with the specified config, error code, and response. + * + * @param {Error} error The error to update. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The error. + */ +module.exports = function enhanceError(error, config, code, request, response) { + error.config = config; + if (code) { + error.code = code; + } + + error.request = request; + error.response = response; + error.isAxiosError = true; + + error.toJSON = function toJSON() { + return { + // Standard + message: this.message, + name: this.name, + // Microsoft + description: this.description, + number: this.number, + // Mozilla + fileName: this.fileName, + lineNumber: this.lineNumber, + columnNumber: this.columnNumber, + stack: this.stack, + // Axios + config: this.config, + code: this.code + }; + }; + return error; +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/mergeConfig.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/mergeConfig.js new file mode 100644 index 0000000..5a2c10c --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/mergeConfig.js @@ -0,0 +1,87 @@ +'use strict'; + +var utils = require('../utils'); + +/** + * Config-specific merge-function which creates a new config-object + * by merging two configuration objects together. + * + * @param {Object} config1 + * @param {Object} config2 + * @returns {Object} New object resulting from merging config2 to config1 + */ +module.exports = function mergeConfig(config1, config2) { + // eslint-disable-next-line no-param-reassign + config2 = config2 || {}; + var config = {}; + + var valueFromConfig2Keys = ['url', 'method', 'data']; + var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; + var defaultToConfig2Keys = [ + 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', + 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', + 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', + 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', + 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' + ]; + var directMergeKeys = ['validateStatus']; + + function getMergedValue(target, source) { + if (utils.isPlainObject(target) && utils.isPlainObject(source)) { + return utils.merge(target, source); + } else if (utils.isPlainObject(source)) { + return utils.merge({}, source); + } else if (utils.isArray(source)) { + return source.slice(); + } + return source; + } + + function mergeDeepProperties(prop) { + if (!utils.isUndefined(config2[prop])) { + config[prop] = getMergedValue(config1[prop], config2[prop]); + } else if (!utils.isUndefined(config1[prop])) { + config[prop] = getMergedValue(undefined, config1[prop]); + } + } + + utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { + if (!utils.isUndefined(config2[prop])) { + config[prop] = getMergedValue(undefined, config2[prop]); + } + }); + + utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); + + utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { + if (!utils.isUndefined(config2[prop])) { + config[prop] = getMergedValue(undefined, config2[prop]); + } else if (!utils.isUndefined(config1[prop])) { + config[prop] = getMergedValue(undefined, config1[prop]); + } + }); + + utils.forEach(directMergeKeys, function merge(prop) { + if (prop in config2) { + config[prop] = getMergedValue(config1[prop], config2[prop]); + } else if (prop in config1) { + config[prop] = getMergedValue(undefined, config1[prop]); + } + }); + + var axiosKeys = valueFromConfig2Keys + .concat(mergeDeepPropertiesKeys) + .concat(defaultToConfig2Keys) + .concat(directMergeKeys); + + var otherKeys = Object + .keys(config1) + .concat(Object.keys(config2)) + .filter(function filterAxiosKeys(key) { + return axiosKeys.indexOf(key) === -1; + }); + + utils.forEach(otherKeys, mergeDeepProperties); + + return config; +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/settle.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/settle.js new file mode 100644 index 0000000..886adb0 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/settle.js @@ -0,0 +1,25 @@ +'use strict'; + +var createError = require('./createError'); + +/** + * Resolve or reject a Promise based on response status. + * + * @param {Function} resolve A function that resolves the promise. + * @param {Function} reject A function that rejects the promise. + * @param {object} response The response. + */ +module.exports = function settle(resolve, reject, response) { + var validateStatus = response.config.validateStatus; + if (!response.status || !validateStatus || validateStatus(response.status)) { + resolve(response); + } else { + reject(createError( + 'Request failed with status code ' + response.status, + response.config, + null, + response.request, + response + )); + } +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/transformData.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/transformData.js new file mode 100644 index 0000000..e065362 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/core/transformData.js @@ -0,0 +1,20 @@ +'use strict'; + +var utils = require('./../utils'); + +/** + * Transform the data for a request or a response + * + * @param {Object|String} data The data to be transformed + * @param {Array} headers The headers for the request or response + * @param {Array|Function} fns A single function or Array of functions + * @returns {*} The resulting transformed data + */ +module.exports = function transformData(data, headers, fns) { + /*eslint no-param-reassign:0*/ + utils.forEach(fns, function transform(fn) { + data = fn(data, headers); + }); + + return data; +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/defaults.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/defaults.js new file mode 100644 index 0000000..2b2a1a7 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/defaults.js @@ -0,0 +1,98 @@ +'use strict'; + +var utils = require('./utils'); +var normalizeHeaderName = require('./helpers/normalizeHeaderName'); + +var DEFAULT_CONTENT_TYPE = { + 'Content-Type': 'application/x-www-form-urlencoded' +}; + +function setContentTypeIfUnset(headers, value) { + if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { + headers['Content-Type'] = value; + } +} + +function getDefaultAdapter() { + var adapter; + if (typeof XMLHttpRequest !== 'undefined') { + // For browsers use XHR adapter + adapter = require('./adapters/xhr'); + } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { + // For node use HTTP adapter + adapter = require('./adapters/http'); + } + return adapter; +} + +var defaults = { + adapter: getDefaultAdapter(), + + transformRequest: [function transformRequest(data, headers) { + normalizeHeaderName(headers, 'Accept'); + normalizeHeaderName(headers, 'Content-Type'); + if (utils.isFormData(data) || + utils.isArrayBuffer(data) || + utils.isBuffer(data) || + utils.isStream(data) || + utils.isFile(data) || + utils.isBlob(data) + ) { + return data; + } + if (utils.isArrayBufferView(data)) { + return data.buffer; + } + if (utils.isURLSearchParams(data)) { + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); + return data.toString(); + } + if (utils.isObject(data)) { + setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); + return JSON.stringify(data); + } + return data; + }], + + transformResponse: [function transformResponse(data) { + /*eslint no-param-reassign:0*/ + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { /* Ignore */ } + } + return data; + }], + + /** + * A timeout in milliseconds to abort a request. If set to 0 (default) a + * timeout is not created. + */ + timeout: 0, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN', + + maxContentLength: -1, + maxBodyLength: -1, + + validateStatus: function validateStatus(status) { + return status >= 200 && status < 300; + } +}; + +defaults.headers = { + common: { + 'Accept': 'application/json, text/plain, */*' + } +}; + +utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { + defaults.headers[method] = {}; +}); + +utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); +}); + +module.exports = defaults; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/README.md b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/README.md new file mode 100644 index 0000000..4ae3419 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/README.md @@ -0,0 +1,7 @@ +# axios // helpers + +The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like: + +- Browser polyfills +- Managing cookies +- Parsing HTTP headers diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/bind.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/bind.js new file mode 100644 index 0000000..6147c60 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/bind.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function bind(fn, thisArg) { + return function wrap() { + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + return fn.apply(thisArg, args); + }; +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/buildURL.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/buildURL.js new file mode 100644 index 0000000..31595c3 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/buildURL.js @@ -0,0 +1,70 @@ +'use strict'; + +var utils = require('./../utils'); + +function encode(val) { + return encodeURIComponent(val). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%20/g, '+'). + replace(/%5B/gi, '['). + replace(/%5D/gi, ']'); +} + +/** + * Build a URL by appending params to the end + * + * @param {string} url The base of the url (e.g., http://www.google.com) + * @param {object} [params] The params to be appended + * @returns {string} The formatted url + */ +module.exports = function buildURL(url, params, paramsSerializer) { + /*eslint no-param-reassign:0*/ + if (!params) { + return url; + } + + var serializedParams; + if (paramsSerializer) { + serializedParams = paramsSerializer(params); + } else if (utils.isURLSearchParams(params)) { + serializedParams = params.toString(); + } else { + var parts = []; + + utils.forEach(params, function serialize(val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + + if (utils.isArray(val)) { + key = key + '[]'; + } else { + val = [val]; + } + + utils.forEach(val, function parseValue(v) { + if (utils.isDate(v)) { + v = v.toISOString(); + } else if (utils.isObject(v)) { + v = JSON.stringify(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + serializedParams = parts.join('&'); + } + + if (serializedParams) { + var hashmarkIndex = url.indexOf('#'); + if (hashmarkIndex !== -1) { + url = url.slice(0, hashmarkIndex); + } + + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; + } + + return url; +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/combineURLs.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/combineURLs.js new file mode 100644 index 0000000..f1b58a5 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/combineURLs.js @@ -0,0 +1,14 @@ +'use strict'; + +/** + * Creates a new URL by combining the specified URLs + * + * @param {string} baseURL The base URL + * @param {string} relativeURL The relative URL + * @returns {string} The combined URL + */ +module.exports = function combineURLs(baseURL, relativeURL) { + return relativeURL + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') + : baseURL; +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/cookies.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/cookies.js new file mode 100644 index 0000000..5a8a666 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/cookies.js @@ -0,0 +1,53 @@ +'use strict'; + +var utils = require('./../utils'); + +module.exports = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs support document.cookie + (function standardBrowserEnv() { + return { + write: function write(name, value, expires, path, domain, secure) { + var cookie = []; + cookie.push(name + '=' + encodeURIComponent(value)); + + if (utils.isNumber(expires)) { + cookie.push('expires=' + new Date(expires).toGMTString()); + } + + if (utils.isString(path)) { + cookie.push('path=' + path); + } + + if (utils.isString(domain)) { + cookie.push('domain=' + domain); + } + + if (secure === true) { + cookie.push('secure'); + } + + document.cookie = cookie.join('; '); + }, + + read: function read(name) { + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, + + remove: function remove(name) { + this.write(name, '', Date.now() - 86400000); + } + }; + })() : + + // Non standard browser env (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return { + write: function write() {}, + read: function read() { return null; }, + remove: function remove() {} + }; + })() +); diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/deprecatedMethod.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/deprecatedMethod.js new file mode 100644 index 0000000..ed40965 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/deprecatedMethod.js @@ -0,0 +1,24 @@ +'use strict'; + +/*eslint no-console:0*/ + +/** + * Supply a warning to the developer that a method they are using + * has been deprecated. + * + * @param {string} method The name of the deprecated method + * @param {string} [instead] The alternate method to use if applicable + * @param {string} [docs] The documentation URL to get further details + */ +module.exports = function deprecatedMethod(method, instead, docs) { + try { + console.warn( + 'DEPRECATED method `' + method + '`.' + + (instead ? ' Use `' + instead + '` instead.' : '') + + ' This method will be removed in a future release.'); + + if (docs) { + console.warn('For more information about usage see ' + docs); + } + } catch (e) { /* Ignore */ } +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/isAbsoluteURL.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/isAbsoluteURL.js new file mode 100644 index 0000000..d33e992 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/isAbsoluteURL.js @@ -0,0 +1,14 @@ +'use strict'; + +/** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ +module.exports = function isAbsoluteURL(url) { + // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed + // by any combination of letters, digits, plus, period, or hyphen. + return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/isAxiosError.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/isAxiosError.js new file mode 100644 index 0000000..29ff41a --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/isAxiosError.js @@ -0,0 +1,11 @@ +'use strict'; + +/** + * Determines whether the payload is an error thrown by Axios + * + * @param {*} payload The value to test + * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false + */ +module.exports = function isAxiosError(payload) { + return (typeof payload === 'object') && (payload.isAxiosError === true); +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/isURLSameOrigin.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/isURLSameOrigin.js new file mode 100644 index 0000000..f1d89ad --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/isURLSameOrigin.js @@ -0,0 +1,68 @@ +'use strict'; + +var utils = require('./../utils'); + +module.exports = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs have full support of the APIs needed to test + // whether the request URL is of the same origin as current location. + (function standardBrowserEnv() { + var msie = /(msie|trident)/i.test(navigator.userAgent); + var urlParsingNode = document.createElement('a'); + var originURL; + + /** + * Parse a URL to discover it's components + * + * @param {String} url The URL to be parsed + * @returns {Object} + */ + function resolveURL(url) { + var href = url; + + if (msie) { + // IE needs attribute set twice to normalize properties + urlParsingNode.setAttribute('href', href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') ? + urlParsingNode.pathname : + '/' + urlParsingNode.pathname + }; + } + + originURL = resolveURL(window.location.href); + + /** + * Determine if a URL shares the same origin as the current location + * + * @param {String} requestURL The URL to test + * @returns {boolean} True if URL shares the same origin, otherwise false + */ + return function isURLSameOrigin(requestURL) { + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; + return (parsed.protocol === originURL.protocol && + parsed.host === originURL.host); + }; + })() : + + // Non standard browser envs (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return function isURLSameOrigin() { + return true; + }; + })() +); diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/normalizeHeaderName.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/normalizeHeaderName.js new file mode 100644 index 0000000..738c9fe --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/normalizeHeaderName.js @@ -0,0 +1,12 @@ +'use strict'; + +var utils = require('../utils'); + +module.exports = function normalizeHeaderName(headers, normalizedName) { + utils.forEach(headers, function processHeader(value, name) { + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { + headers[normalizedName] = value; + delete headers[name]; + } + }); +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/parseHeaders.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/parseHeaders.js new file mode 100644 index 0000000..8af2cc7 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/parseHeaders.js @@ -0,0 +1,53 @@ +'use strict'; + +var utils = require('./../utils'); + +// Headers whose duplicates are ignored by node +// c.f. https://nodejs.org/api/http.html#http_message_headers +var ignoreDuplicateOf = [ + 'age', 'authorization', 'content-length', 'content-type', 'etag', + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', + 'last-modified', 'location', 'max-forwards', 'proxy-authorization', + 'referer', 'retry-after', 'user-agent' +]; + +/** + * Parse headers into an object + * + * ``` + * Date: Wed, 27 Aug 2014 08:58:49 GMT + * Content-Type: application/json + * Connection: keep-alive + * Transfer-Encoding: chunked + * ``` + * + * @param {String} headers Headers needing to be parsed + * @returns {Object} Headers parsed into an object + */ +module.exports = function parseHeaders(headers) { + var parsed = {}; + var key; + var val; + var i; + + if (!headers) { return parsed; } + + utils.forEach(headers.split('\n'), function parser(line) { + i = line.indexOf(':'); + key = utils.trim(line.substr(0, i)).toLowerCase(); + val = utils.trim(line.substr(i + 1)); + + if (key) { + if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { + return; + } + if (key === 'set-cookie') { + parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); + } else { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + } + }); + + return parsed; +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/spread.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/spread.js new file mode 100644 index 0000000..25e3cdd --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/helpers/spread.js @@ -0,0 +1,27 @@ +'use strict'; + +/** + * Syntactic sugar for invoking a function and expanding an array for arguments. + * + * Common use case would be to use `Function.prototype.apply`. + * + * ```js + * function f(x, y, z) {} + * var args = [1, 2, 3]; + * f.apply(null, args); + * ``` + * + * With `spread` this example can be re-written. + * + * ```js + * spread(function(x, y, z) {})([1, 2, 3]); + * ``` + * + * @param {Function} callback + * @returns {Function} + */ +module.exports = function spread(callback) { + return function wrap(arr) { + return callback.apply(null, arr); + }; +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/lib/utils.js b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/utils.js new file mode 100644 index 0000000..83eb1c6 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/lib/utils.js @@ -0,0 +1,351 @@ +'use strict'; + +var bind = require('./helpers/bind'); + +/*global toString:true*/ + +// utils is a library of generic helper functions non-specific to axios + +var toString = Object.prototype.toString; + +/** + * Determine if a value is an Array + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Array, otherwise false + */ +function isArray(val) { + return toString.call(val) === '[object Array]'; +} + +/** + * Determine if a value is undefined + * + * @param {Object} val The value to test + * @returns {boolean} True if the value is undefined, otherwise false + */ +function isUndefined(val) { + return typeof val === 'undefined'; +} + +/** + * Determine if a value is a Buffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Buffer, otherwise false + */ +function isBuffer(val) { + return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) + && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); +} + +/** + * Determine if a value is an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an ArrayBuffer, otherwise false + */ +function isArrayBuffer(val) { + return toString.call(val) === '[object ArrayBuffer]'; +} + +/** + * Determine if a value is a FormData + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an FormData, otherwise false + */ +function isFormData(val) { + return (typeof FormData !== 'undefined') && (val instanceof FormData); +} + +/** + * Determine if a value is a view on an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false + */ +function isArrayBufferView(val) { + var result; + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { + result = ArrayBuffer.isView(val); + } else { + result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); + } + return result; +} + +/** + * Determine if a value is a String + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a String, otherwise false + */ +function isString(val) { + return typeof val === 'string'; +} + +/** + * Determine if a value is a Number + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Number, otherwise false + */ +function isNumber(val) { + return typeof val === 'number'; +} + +/** + * Determine if a value is an Object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Object, otherwise false + */ +function isObject(val) { + return val !== null && typeof val === 'object'; +} + +/** + * Determine if a value is a plain Object + * + * @param {Object} val The value to test + * @return {boolean} True if value is a plain Object, otherwise false + */ +function isPlainObject(val) { + if (toString.call(val) !== '[object Object]') { + return false; + } + + var prototype = Object.getPrototypeOf(val); + return prototype === null || prototype === Object.prototype; +} + +/** + * Determine if a value is a Date + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Date, otherwise false + */ +function isDate(val) { + return toString.call(val) === '[object Date]'; +} + +/** + * Determine if a value is a File + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a File, otherwise false + */ +function isFile(val) { + return toString.call(val) === '[object File]'; +} + +/** + * Determine if a value is a Blob + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Blob, otherwise false + */ +function isBlob(val) { + return toString.call(val) === '[object Blob]'; +} + +/** + * Determine if a value is a Function + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Function, otherwise false + */ +function isFunction(val) { + return toString.call(val) === '[object Function]'; +} + +/** + * Determine if a value is a Stream + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Stream, otherwise false + */ +function isStream(val) { + return isObject(val) && isFunction(val.pipe); +} + +/** + * Determine if a value is a URLSearchParams object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a URLSearchParams object, otherwise false + */ +function isURLSearchParams(val) { + return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; +} + +/** + * Trim excess whitespace off the beginning and end of a string + * + * @param {String} str The String to trim + * @returns {String} The String freed of excess whitespace + */ +function trim(str) { + return str.replace(/^\s*/, '').replace(/\s*$/, ''); +} + +/** + * Determine if we're running in a standard browser environment + * + * This allows axios to run in a web worker, and react-native. + * Both environments support XMLHttpRequest, but not fully standard globals. + * + * web workers: + * typeof window -> undefined + * typeof document -> undefined + * + * react-native: + * navigator.product -> 'ReactNative' + * nativescript + * navigator.product -> 'NativeScript' or 'NS' + */ +function isStandardBrowserEnv() { + if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || + navigator.product === 'NativeScript' || + navigator.product === 'NS')) { + return false; + } + return ( + typeof window !== 'undefined' && + typeof document !== 'undefined' + ); +} + +/** + * Iterate over an Array or an Object invoking a function for each item. + * + * If `obj` is an Array callback will be called passing + * the value, index, and complete array for each item. + * + * If 'obj' is an Object callback will be called passing + * the value, key, and complete object for each property. + * + * @param {Object|Array} obj The object to iterate + * @param {Function} fn The callback to invoke for each item + */ +function forEach(obj, fn) { + // Don't bother if no value provided + if (obj === null || typeof obj === 'undefined') { + return; + } + + // Force an array if not already something iterable + if (typeof obj !== 'object') { + /*eslint no-param-reassign:0*/ + obj = [obj]; + } + + if (isArray(obj)) { + // Iterate over array values + for (var i = 0, l = obj.length; i < l; i++) { + fn.call(null, obj[i], i, obj); + } + } else { + // Iterate over object keys + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + fn.call(null, obj[key], key, obj); + } + } + } +} + +/** + * Accepts varargs expecting each argument to be an object, then + * immutably merges the properties of each object and returns result. + * + * When multiple objects contain the same key the later object in + * the arguments list will take precedence. + * + * Example: + * + * ```js + * var result = merge({foo: 123}, {foo: 456}); + * console.log(result.foo); // outputs 456 + * ``` + * + * @param {Object} obj1 Object to merge + * @returns {Object} Result of all merge properties + */ +function merge(/* obj1, obj2, obj3, ... */) { + var result = {}; + function assignValue(val, key) { + if (isPlainObject(result[key]) && isPlainObject(val)) { + result[key] = merge(result[key], val); + } else if (isPlainObject(val)) { + result[key] = merge({}, val); + } else if (isArray(val)) { + result[key] = val.slice(); + } else { + result[key] = val; + } + } + + for (var i = 0, l = arguments.length; i < l; i++) { + forEach(arguments[i], assignValue); + } + return result; +} + +/** + * Extends object a by mutably adding to it the properties of object b. + * + * @param {Object} a The object to be extended + * @param {Object} b The object to copy properties from + * @param {Object} thisArg The object to bind function to + * @return {Object} The resulting value of object a + */ +function extend(a, b, thisArg) { + forEach(b, function assignValue(val, key) { + if (thisArg && typeof val === 'function') { + a[key] = bind(val, thisArg); + } else { + a[key] = val; + } + }); + return a; +} + +/** + * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) + * + * @param {string} content with BOM + * @return {string} content value without BOM + */ +function stripBOM(content) { + if (content.charCodeAt(0) === 0xFEFF) { + content = content.slice(1); + } + return content; +} + +module.exports = { + isArray: isArray, + isArrayBuffer: isArrayBuffer, + isBuffer: isBuffer, + isFormData: isFormData, + isArrayBufferView: isArrayBufferView, + isString: isString, + isNumber: isNumber, + isObject: isObject, + isPlainObject: isPlainObject, + isUndefined: isUndefined, + isDate: isDate, + isFile: isFile, + isBlob: isBlob, + isFunction: isFunction, + isStream: isStream, + isURLSearchParams: isURLSearchParams, + isStandardBrowserEnv: isStandardBrowserEnv, + forEach: forEach, + merge: merge, + extend: extend, + trim: trim, + stripBOM: stripBOM +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/axios/package.json b/SCRS-Backend/src/test/javascript/node_modules/axios/package.json new file mode 100644 index 0000000..dcf4dc6 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/axios/package.json @@ -0,0 +1,114 @@ +{ + "_from": "axios", + "_id": "axios@0.21.1", + "_inBundle": false, + "_integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "_location": "/axios", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "axios", + "name": "axios", + "escapedName": "axios", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "_shasum": "22563481962f4d6bde9a76d516ef0e5d3c09b2b8", + "_spec": "axios", + "_where": "C:\\Users\\Alix\\Desktop\\school\\Fourth_Semester\\ECSE-321\\project-group-02\\SCRS-Backend\\src\\test\\javascript", + "author": { + "name": "Matt Zabriskie" + }, + "browser": { + "./lib/adapters/http.js": "./lib/adapters/xhr.js" + }, + "bugs": { + "url": "https://github.com/axios/axios/issues" + }, + "bundleDependencies": false, + "bundlesize": [ + { + "path": "./dist/axios.min.js", + "threshold": "5kB" + } + ], + "dependencies": { + "follow-redirects": "^1.10.0" + }, + "deprecated": false, + "description": "Promise based HTTP client for the browser and node.js", + "devDependencies": { + "bundlesize": "^0.17.0", + "coveralls": "^3.0.0", + "es6-promise": "^4.2.4", + "grunt": "^1.0.2", + "grunt-banner": "^0.6.0", + "grunt-cli": "^1.2.0", + "grunt-contrib-clean": "^1.1.0", + "grunt-contrib-watch": "^1.0.0", + "grunt-eslint": "^20.1.0", + "grunt-karma": "^2.0.0", + "grunt-mocha-test": "^0.13.3", + "grunt-ts": "^6.0.0-beta.19", + "grunt-webpack": "^1.0.18", + "istanbul-instrumenter-loader": "^1.0.0", + "jasmine-core": "^2.4.1", + "karma": "^1.3.0", + "karma-chrome-launcher": "^2.2.0", + "karma-coverage": "^1.1.1", + "karma-firefox-launcher": "^1.1.0", + "karma-jasmine": "^1.1.1", + "karma-jasmine-ajax": "^0.1.13", + "karma-opera-launcher": "^1.0.0", + "karma-safari-launcher": "^1.0.0", + "karma-sauce-launcher": "^1.2.0", + "karma-sinon": "^1.0.5", + "karma-sourcemap-loader": "^0.3.7", + "karma-webpack": "^1.7.0", + "load-grunt-tasks": "^3.5.2", + "minimist": "^1.2.0", + "mocha": "^5.2.0", + "sinon": "^4.5.0", + "typescript": "^2.8.1", + "url-search-params": "^0.10.0", + "webpack": "^1.13.1", + "webpack-dev-server": "^1.14.1" + }, + "homepage": "https://github.com/axios/axios", + "jsdelivr": "dist/axios.min.js", + "keywords": [ + "xhr", + "http", + "ajax", + "promise", + "node" + ], + "license": "MIT", + "main": "index.js", + "name": "axios", + "repository": { + "type": "git", + "url": "git+https://github.com/axios/axios.git" + }, + "scripts": { + "build": "NODE_ENV=production grunt build", + "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", + "examples": "node ./examples/server.js", + "fix": "eslint --fix lib/**/*.js", + "postversion": "git push && git push --tags", + "preversion": "npm test", + "start": "node ./sandbox/server.js", + "test": "grunt test && bundlesize", + "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json" + }, + "typings": "./index.d.ts", + "unpkg": "dist/axios.min.js", + "version": "0.21.1" +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/LICENSE b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/LICENSE new file mode 100644 index 0000000..742cbad --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/LICENSE @@ -0,0 +1,18 @@ +Copyright 2014–present Olivier Lalonde , James Talmage , Ruben Verborgh + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/README.md b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/README.md new file mode 100644 index 0000000..ea618ab --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/README.md @@ -0,0 +1,148 @@ +## Follow Redirects + +Drop-in replacement for Node's `http` and `https` modules that automatically follows redirects. + +[![npm version](https://img.shields.io/npm/v/follow-redirects.svg)](https://www.npmjs.com/package/follow-redirects) +[![Build Status](https://github.com/follow-redirects/follow-redirects/workflows/CI/badge.svg)](https://github.com/follow-redirects/follow-redirects/actions) +[![Coverage Status](https://coveralls.io/repos/follow-redirects/follow-redirects/badge.svg?branch=master)](https://coveralls.io/r/follow-redirects/follow-redirects?branch=master) +[![npm downloads](https://img.shields.io/npm/dm/follow-redirects.svg)](https://www.npmjs.com/package/follow-redirects) +[![Sponsor on GitHub](https://img.shields.io/static/v1?label=Sponsor&message=%F0%9F%92%96&logo=GitHub)](https://github.com/sponsors/RubenVerborgh) + +`follow-redirects` provides [request](https://nodejs.org/api/http.html#http_http_request_options_callback) and [get](https://nodejs.org/api/http.html#http_http_get_options_callback) + methods that behave identically to those found on the native [http](https://nodejs.org/api/http.html#http_http_request_options_callback) and [https](https://nodejs.org/api/https.html#https_https_request_options_callback) + modules, with the exception that they will seamlessly follow redirects. + +```javascript +const { http, https } = require('follow-redirects'); + +http.get('http://bit.ly/900913', response => { + response.on('data', chunk => { + console.log(chunk); + }); +}).on('error', err => { + console.error(err); +}); +``` + +You can inspect the final redirected URL through the `responseUrl` property on the `response`. +If no redirection happened, `responseUrl` is the original request URL. + +```javascript +const request = https.request({ + host: 'bitly.com', + path: '/UHfDGO', +}, response => { + console.log(response.responseUrl); + // 'http://duckduckgo.com/robots.txt' +}); +request.end(); +``` + +## Options +### Global options +Global options are set directly on the `follow-redirects` module: + +```javascript +const followRedirects = require('follow-redirects'); +followRedirects.maxRedirects = 10; +followRedirects.maxBodyLength = 20 * 1024 * 1024; // 20 MB +``` + +The following global options are supported: + +- `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted. + +- `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted. + +### Per-request options +Per-request options are set by passing an `options` object: + +```javascript +const url = require('url'); +const { http, https } = require('follow-redirects'); + +const options = url.parse('http://bit.ly/900913'); +options.maxRedirects = 10; +options.beforeRedirect = (options, { headers }) => { + // Use this to adjust the request options upon redirecting, + // to inspect the latest response headers, + // or to cancel the request by throwing an error + if (options.hostname === "example.com") { + options.auth = "user:password"; + } +}; +http.request(options); +``` + +In addition to the [standard HTTP](https://nodejs.org/api/http.html#http_http_request_options_callback) and [HTTPS options](https://nodejs.org/api/https.html#https_https_request_options_callback), +the following per-request options are supported: +- `followRedirects` (default: `true`) – whether redirects should be followed. + +- `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted. + +- `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted. + +- `beforeRedirect` (default: `undefined`) – optionally change the request `options` on redirects, or abort the request by throwing an error. + +- `agents` (default: `undefined`) – sets the `agent` option per protocol, since HTTP and HTTPS use different agents. Example value: `{ http: new http.Agent(), https: new https.Agent() }` + +- `trackRedirects` (default: `false`) – whether to store the redirected response details into the `redirects` array on the response object. + + +### Advanced usage +By default, `follow-redirects` will use the Node.js default implementations +of [`http`](https://nodejs.org/api/http.html) +and [`https`](https://nodejs.org/api/https.html). +To enable features such as caching and/or intermediate request tracking, +you might instead want to wrap `follow-redirects` around custom protocol implementations: + +```javascript +const { http, https } = require('follow-redirects').wrap({ + http: require('your-custom-http'), + https: require('your-custom-https'), +}); +``` + +Such custom protocols only need an implementation of the `request` method. + +## Browser Usage + +Due to the way the browser works, +the `http` and `https` browser equivalents perform redirects by default. + +By requiring `follow-redirects` this way: +```javascript +const http = require('follow-redirects/http'); +const https = require('follow-redirects/https'); +``` +you can easily tell webpack and friends to replace +`follow-redirect` by the built-in versions: + +```json +{ + "follow-redirects/http" : "http", + "follow-redirects/https" : "https" +} +``` + +## Contributing + +Pull Requests are always welcome. Please [file an issue](https://github.com/follow-redirects/follow-redirects/issues) + detailing your proposal before you invest your valuable time. Additional features and bug fixes should be accompanied + by tests. You can run the test suite locally with a simple `npm test` command. + +## Debug Logging + +`follow-redirects` uses the excellent [debug](https://www.npmjs.com/package/debug) for logging. To turn on logging + set the environment variable `DEBUG=follow-redirects` for debug output from just this module. When running the test + suite it is sometimes advantageous to set `DEBUG=*` to see output from the express server as well. + +## Authors + +- [Ruben Verborgh](https://ruben.verborgh.org/) +- [Olivier Lalonde](mailto:olalonde@gmail.com) +- [James Talmage](mailto:james@talmage.io) + +## License + +[MIT License](https://github.com/follow-redirects/follow-redirects/blob/master/LICENSE) diff --git a/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/debug.js b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/debug.js new file mode 100644 index 0000000..f2556d7 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/debug.js @@ -0,0 +1,14 @@ +var debug; + +module.exports = function () { + if (!debug) { + try { + /* eslint global-require: off */ + debug = require("debug")("follow-redirects"); + } + catch (error) { + debug = function () { /* */ }; + } + } + debug.apply(null, arguments); +}; diff --git a/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/http.js b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/http.js new file mode 100644 index 0000000..695e356 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/http.js @@ -0,0 +1 @@ +module.exports = require("./").http; diff --git a/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/https.js b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/https.js new file mode 100644 index 0000000..d21c921 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/https.js @@ -0,0 +1 @@ +module.exports = require("./").https; diff --git a/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/index.js b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/index.js new file mode 100644 index 0000000..0bd3af9 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/index.js @@ -0,0 +1,525 @@ +var url = require("url"); +var URL = url.URL; +var http = require("http"); +var https = require("https"); +var Writable = require("stream").Writable; +var assert = require("assert"); +var debug = require("./debug"); + +// Create handlers that pass events from native requests +var eventHandlers = Object.create(null); +["abort", "aborted", "connect", "error", "socket", "timeout"].forEach(function (event) { + eventHandlers[event] = function (arg1, arg2, arg3) { + this._redirectable.emit(event, arg1, arg2, arg3); + }; +}); + +// Error types with codes +var RedirectionError = createErrorType( + "ERR_FR_REDIRECTION_FAILURE", + "" +); +var TooManyRedirectsError = createErrorType( + "ERR_FR_TOO_MANY_REDIRECTS", + "Maximum number of redirects exceeded" +); +var MaxBodyLengthExceededError = createErrorType( + "ERR_FR_MAX_BODY_LENGTH_EXCEEDED", + "Request body larger than maxBodyLength limit" +); +var WriteAfterEndError = createErrorType( + "ERR_STREAM_WRITE_AFTER_END", + "write after end" +); + +// An HTTP(S) request that can be redirected +function RedirectableRequest(options, responseCallback) { + // Initialize the request + Writable.call(this); + this._sanitizeOptions(options); + this._options = options; + this._ended = false; + this._ending = false; + this._redirectCount = 0; + this._redirects = []; + this._requestBodyLength = 0; + this._requestBodyBuffers = []; + + // Attach a callback if passed + if (responseCallback) { + this.on("response", responseCallback); + } + + // React to responses of native requests + var self = this; + this._onNativeResponse = function (response) { + self._processResponse(response); + }; + + // Perform the first request + this._performRequest(); +} +RedirectableRequest.prototype = Object.create(Writable.prototype); + +RedirectableRequest.prototype.abort = function () { + // Abort the internal request + this._currentRequest.removeAllListeners(); + this._currentRequest.on("error", noop); + this._currentRequest.abort(); + + // Abort this request + this.emit("abort"); + this.removeAllListeners(); +}; + +// Writes buffered data to the current native request +RedirectableRequest.prototype.write = function (data, encoding, callback) { + // Writing is not allowed if end has been called + if (this._ending) { + throw new WriteAfterEndError(); + } + + // Validate input and shift parameters if necessary + if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) { + throw new TypeError("data should be a string, Buffer or Uint8Array"); + } + if (typeof encoding === "function") { + callback = encoding; + encoding = null; + } + + // Ignore empty buffers, since writing them doesn't invoke the callback + // https://github.com/nodejs/node/issues/22066 + if (data.length === 0) { + if (callback) { + callback(); + } + return; + } + // Only write when we don't exceed the maximum body length + if (this._requestBodyLength + data.length <= this._options.maxBodyLength) { + this._requestBodyLength += data.length; + this._requestBodyBuffers.push({ data: data, encoding: encoding }); + this._currentRequest.write(data, encoding, callback); + } + // Error when we exceed the maximum body length + else { + this.emit("error", new MaxBodyLengthExceededError()); + this.abort(); + } +}; + +// Ends the current native request +RedirectableRequest.prototype.end = function (data, encoding, callback) { + // Shift parameters if necessary + if (typeof data === "function") { + callback = data; + data = encoding = null; + } + else if (typeof encoding === "function") { + callback = encoding; + encoding = null; + } + + // Write data if needed and end + if (!data) { + this._ended = this._ending = true; + this._currentRequest.end(null, null, callback); + } + else { + var self = this; + var currentRequest = this._currentRequest; + this.write(data, encoding, function () { + self._ended = true; + currentRequest.end(null, null, callback); + }); + this._ending = true; + } +}; + +// Sets a header value on the current native request +RedirectableRequest.prototype.setHeader = function (name, value) { + this._options.headers[name] = value; + this._currentRequest.setHeader(name, value); +}; + +// Clears a header value on the current native request +RedirectableRequest.prototype.removeHeader = function (name) { + delete this._options.headers[name]; + this._currentRequest.removeHeader(name); +}; + +// Global timeout for all underlying requests +RedirectableRequest.prototype.setTimeout = function (msecs, callback) { + var self = this; + if (callback) { + this.on("timeout", callback); + } + + // Sets up a timer to trigger a timeout event + function startTimer() { + if (self._timeout) { + clearTimeout(self._timeout); + } + self._timeout = setTimeout(function () { + self.emit("timeout"); + clearTimer(); + }, msecs); + } + + // Prevent a timeout from triggering + function clearTimer() { + clearTimeout(this._timeout); + if (callback) { + self.removeListener("timeout", callback); + } + if (!this.socket) { + self._currentRequest.removeListener("socket", startTimer); + } + } + + // Start the timer when the socket is opened + if (this.socket) { + startTimer(); + } + else { + this._currentRequest.once("socket", startTimer); + } + + this.once("response", clearTimer); + this.once("error", clearTimer); + + return this; +}; + +// Proxy all other public ClientRequest methods +[ + "flushHeaders", "getHeader", + "setNoDelay", "setSocketKeepAlive", +].forEach(function (method) { + RedirectableRequest.prototype[method] = function (a, b) { + return this._currentRequest[method](a, b); + }; +}); + +// Proxy all public ClientRequest properties +["aborted", "connection", "socket"].forEach(function (property) { + Object.defineProperty(RedirectableRequest.prototype, property, { + get: function () { return this._currentRequest[property]; }, + }); +}); + +RedirectableRequest.prototype._sanitizeOptions = function (options) { + // Ensure headers are always present + if (!options.headers) { + options.headers = {}; + } + + // Since http.request treats host as an alias of hostname, + // but the url module interprets host as hostname plus port, + // eliminate the host property to avoid confusion. + if (options.host) { + // Use hostname if set, because it has precedence + if (!options.hostname) { + options.hostname = options.host; + } + delete options.host; + } + + // Complete the URL object when necessary + if (!options.pathname && options.path) { + var searchPos = options.path.indexOf("?"); + if (searchPos < 0) { + options.pathname = options.path; + } + else { + options.pathname = options.path.substring(0, searchPos); + options.search = options.path.substring(searchPos); + } + } +}; + + +// Executes the next native request (initial or redirect) +RedirectableRequest.prototype._performRequest = function () { + // Load the native protocol + var protocol = this._options.protocol; + var nativeProtocol = this._options.nativeProtocols[protocol]; + if (!nativeProtocol) { + this.emit("error", new TypeError("Unsupported protocol " + protocol)); + return; + } + + // If specified, use the agent corresponding to the protocol + // (HTTP and HTTPS use different types of agents) + if (this._options.agents) { + var scheme = protocol.substr(0, protocol.length - 1); + this._options.agent = this._options.agents[scheme]; + } + + // Create the native request + var request = this._currentRequest = + nativeProtocol.request(this._options, this._onNativeResponse); + this._currentUrl = url.format(this._options); + + // Set up event handlers + request._redirectable = this; + for (var event in eventHandlers) { + /* istanbul ignore else */ + if (event) { + request.on(event, eventHandlers[event]); + } + } + + // End a redirected request + // (The first request must be ended explicitly with RedirectableRequest#end) + if (this._isRedirect) { + // Write the request entity and end. + var i = 0; + var self = this; + var buffers = this._requestBodyBuffers; + (function writeNext(error) { + // Only write if this request has not been redirected yet + /* istanbul ignore else */ + if (request === self._currentRequest) { + // Report any write errors + /* istanbul ignore if */ + if (error) { + self.emit("error", error); + } + // Write the next buffer if there are still left + else if (i < buffers.length) { + var buffer = buffers[i++]; + /* istanbul ignore else */ + if (!request.finished) { + request.write(buffer.data, buffer.encoding, writeNext); + } + } + // End the request if `end` has been called on us + else if (self._ended) { + request.end(); + } + } + }()); + } +}; + +// Processes a response from the current native request +RedirectableRequest.prototype._processResponse = function (response) { + // Store the redirected response + var statusCode = response.statusCode; + if (this._options.trackRedirects) { + this._redirects.push({ + url: this._currentUrl, + headers: response.headers, + statusCode: statusCode, + }); + } + + // RFC7231§6.4: The 3xx (Redirection) class of status code indicates + // that further action needs to be taken by the user agent in order to + // fulfill the request. If a Location header field is provided, + // the user agent MAY automatically redirect its request to the URI + // referenced by the Location field value, + // even if the specific status code is not understood. + var location = response.headers.location; + if (location && this._options.followRedirects !== false && + statusCode >= 300 && statusCode < 400) { + // Abort the current request + this._currentRequest.removeAllListeners(); + this._currentRequest.on("error", noop); + this._currentRequest.abort(); + // Discard the remainder of the response to avoid waiting for data + response.destroy(); + + // RFC7231§6.4: A client SHOULD detect and intervene + // in cyclical redirections (i.e., "infinite" redirection loops). + if (++this._redirectCount > this._options.maxRedirects) { + this.emit("error", new TooManyRedirectsError()); + return; + } + + // RFC7231§6.4: Automatic redirection needs to done with + // care for methods not known to be safe, […] + // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change + // the request method from POST to GET for the subsequent request. + if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" || + // RFC7231§6.4.4: The 303 (See Other) status code indicates that + // the server is redirecting the user agent to a different resource […] + // A user agent can perform a retrieval request targeting that URI + // (a GET or HEAD request if using HTTP) […] + (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) { + this._options.method = "GET"; + // Drop a possible entity and headers related to it + this._requestBodyBuffers = []; + removeMatchingHeaders(/^content-/i, this._options.headers); + } + + // Drop the Host header, as the redirect might lead to a different host + var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) || + url.parse(this._currentUrl).hostname; + + // Create the redirected request + var redirectUrl = url.resolve(this._currentUrl, location); + debug("redirecting to", redirectUrl); + this._isRedirect = true; + var redirectUrlParts = url.parse(redirectUrl); + Object.assign(this._options, redirectUrlParts); + + // Drop the Authorization header if redirecting to another host + if (redirectUrlParts.hostname !== previousHostName) { + removeMatchingHeaders(/^authorization$/i, this._options.headers); + } + + // Evaluate the beforeRedirect callback + if (typeof this._options.beforeRedirect === "function") { + var responseDetails = { headers: response.headers }; + try { + this._options.beforeRedirect.call(null, this._options, responseDetails); + } + catch (err) { + this.emit("error", err); + return; + } + this._sanitizeOptions(this._options); + } + + // Perform the redirected request + try { + this._performRequest(); + } + catch (cause) { + var error = new RedirectionError("Redirected request failed: " + cause.message); + error.cause = cause; + this.emit("error", error); + } + } + else { + // The response is not a redirect; return it as-is + response.responseUrl = this._currentUrl; + response.redirects = this._redirects; + this.emit("response", response); + + // Clean up + this._requestBodyBuffers = []; + } +}; + +// Wraps the key/value object of protocols with redirect functionality +function wrap(protocols) { + // Default settings + var exports = { + maxRedirects: 21, + maxBodyLength: 10 * 1024 * 1024, + }; + + // Wrap each protocol + var nativeProtocols = {}; + Object.keys(protocols).forEach(function (scheme) { + var protocol = scheme + ":"; + var nativeProtocol = nativeProtocols[protocol] = protocols[scheme]; + var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol); + + // Executes a request, following redirects + function request(input, options, callback) { + // Parse parameters + if (typeof input === "string") { + var urlStr = input; + try { + input = urlToOptions(new URL(urlStr)); + } + catch (err) { + /* istanbul ignore next */ + input = url.parse(urlStr); + } + } + else if (URL && (input instanceof URL)) { + input = urlToOptions(input); + } + else { + callback = options; + options = input; + input = { protocol: protocol }; + } + if (typeof options === "function") { + callback = options; + options = null; + } + + // Set defaults + options = Object.assign({ + maxRedirects: exports.maxRedirects, + maxBodyLength: exports.maxBodyLength, + }, input, options); + options.nativeProtocols = nativeProtocols; + + assert.equal(options.protocol, protocol, "protocol mismatch"); + debug("options", options); + return new RedirectableRequest(options, callback); + } + + // Executes a GET request, following redirects + function get(input, options, callback) { + var wrappedRequest = wrappedProtocol.request(input, options, callback); + wrappedRequest.end(); + return wrappedRequest; + } + + // Expose the properties on the wrapped protocol + Object.defineProperties(wrappedProtocol, { + request: { value: request, configurable: true, enumerable: true, writable: true }, + get: { value: get, configurable: true, enumerable: true, writable: true }, + }); + }); + return exports; +} + +/* istanbul ignore next */ +function noop() { /* empty */ } + +// from https://github.com/nodejs/node/blob/master/lib/internal/url.js +function urlToOptions(urlObject) { + var options = { + protocol: urlObject.protocol, + hostname: urlObject.hostname.startsWith("[") ? + /* istanbul ignore next */ + urlObject.hostname.slice(1, -1) : + urlObject.hostname, + hash: urlObject.hash, + search: urlObject.search, + pathname: urlObject.pathname, + path: urlObject.pathname + urlObject.search, + href: urlObject.href, + }; + if (urlObject.port !== "") { + options.port = Number(urlObject.port); + } + return options; +} + +function removeMatchingHeaders(regex, headers) { + var lastValue; + for (var header in headers) { + if (regex.test(header)) { + lastValue = headers[header]; + delete headers[header]; + } + } + return lastValue; +} + +function createErrorType(code, defaultMessage) { + function CustomError(message) { + Error.captureStackTrace(this, this.constructor); + this.message = message || defaultMessage; + } + CustomError.prototype = new Error(); + CustomError.prototype.constructor = CustomError; + CustomError.prototype.name = "Error [" + code + "]"; + CustomError.prototype.code = code; + return CustomError; +} + +// Exports +module.exports = wrap({ http: http, https: https }); +module.exports.wrap = wrap; diff --git a/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/package.json b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/package.json new file mode 100644 index 0000000..28979ce --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/follow-redirects/package.json @@ -0,0 +1,95 @@ +{ + "_from": "follow-redirects@^1.10.0", + "_id": "follow-redirects@1.13.3", + "_inBundle": false, + "_integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==", + "_location": "/follow-redirects", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "follow-redirects@^1.10.0", + "name": "follow-redirects", + "escapedName": "follow-redirects", + "rawSpec": "^1.10.0", + "saveSpec": null, + "fetchSpec": "^1.10.0" + }, + "_requiredBy": [ + "/axios" + ], + "_resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz", + "_shasum": "e5598ad50174c1bc4e872301e82ac2cd97f90267", + "_spec": "follow-redirects@^1.10.0", + "_where": "C:\\Users\\Alix\\Desktop\\school\\Fourth_Semester\\ECSE-321\\project-group-02\\SCRS-Backend\\src\\test\\javascript\\node_modules\\axios", + "author": { + "name": "Ruben Verborgh", + "email": "ruben@verborgh.org", + "url": "https://ruben.verborgh.org/" + }, + "bugs": { + "url": "https://github.com/follow-redirects/follow-redirects/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Olivier Lalonde", + "email": "olalonde@gmail.com", + "url": "http://www.syskall.com" + }, + { + "name": "James Talmage", + "email": "james@talmage.io" + } + ], + "deprecated": false, + "description": "HTTP and HTTPS modules that follow redirects.", + "devDependencies": { + "concat-stream": "^2.0.0", + "eslint": "^5.16.0", + "express": "^4.16.4", + "lolex": "^3.1.0", + "mocha": "^6.0.2", + "nyc": "^14.1.1" + }, + "engines": { + "node": ">=4.0" + }, + "files": [ + "*.js" + ], + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "homepage": "https://github.com/follow-redirects/follow-redirects", + "keywords": [ + "http", + "https", + "url", + "redirect", + "client", + "location", + "utility" + ], + "license": "MIT", + "main": "index.js", + "name": "follow-redirects", + "peerDependenciesMeta": { + "debug": { + "optional": true + } + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/follow-redirects/follow-redirects.git" + }, + "scripts": { + "lint": "eslint *.js test", + "mocha": "nyc mocha", + "test": "npm run lint && npm run mocha" + }, + "version": "1.13.3" +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/inherits/LICENSE b/SCRS-Backend/src/test/javascript/node_modules/inherits/LICENSE new file mode 100644 index 0000000..dea3013 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/inherits/LICENSE @@ -0,0 +1,16 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + diff --git a/SCRS-Backend/src/test/javascript/node_modules/inherits/README.md b/SCRS-Backend/src/test/javascript/node_modules/inherits/README.md new file mode 100644 index 0000000..b1c5665 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/inherits/README.md @@ -0,0 +1,42 @@ +Browser-friendly inheritance fully compatible with standard node.js +[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor). + +This package exports standard `inherits` from node.js `util` module in +node environment, but also provides alternative browser-friendly +implementation through [browser +field](https://gist.github.com/shtylman/4339901). Alternative +implementation is a literal copy of standard one located in standalone +module to avoid requiring of `util`. It also has a shim for old +browsers with no `Object.create` support. + +While keeping you sure you are using standard `inherits` +implementation in node.js environment, it allows bundlers such as +[browserify](https://github.com/substack/node-browserify) to not +include full `util` package to your client code if all you need is +just `inherits` function. It worth, because browser shim for `util` +package is large and `inherits` is often the single function you need +from it. + +It's recommended to use this package instead of +`require('util').inherits` for any code that has chances to be used +not only in node.js but in browser too. + +## usage + +```js +var inherits = require('inherits'); +// then use exactly as the standard one +``` + +## note on version ~1.0 + +Version ~1.0 had completely different motivation and is not compatible +neither with 2.0 nor with standard node.js `inherits`. + +If you are using version ~1.0 and planning to switch to ~2.0, be +careful: + +* new version uses `super_` instead of `super` for referencing + superclass +* new version overwrites current prototype while old one preserves any + existing fields on it diff --git a/SCRS-Backend/src/test/javascript/node_modules/inherits/inherits.js b/SCRS-Backend/src/test/javascript/node_modules/inherits/inherits.js new file mode 100644 index 0000000..3b94763 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/inherits/inherits.js @@ -0,0 +1,7 @@ +try { + var util = require('util'); + if (typeof util.inherits !== 'function') throw ''; + module.exports = util.inherits; +} catch (e) { + module.exports = require('./inherits_browser.js'); +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/inherits/inherits_browser.js b/SCRS-Backend/src/test/javascript/node_modules/inherits/inherits_browser.js new file mode 100644 index 0000000..c1e78a7 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/inherits/inherits_browser.js @@ -0,0 +1,23 @@ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/inherits/package.json b/SCRS-Backend/src/test/javascript/node_modules/inherits/package.json new file mode 100644 index 0000000..b8ab836 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/inherits/package.json @@ -0,0 +1,61 @@ +{ + "_from": "inherits@2.0.3", + "_id": "inherits@2.0.3", + "_inBundle": false, + "_integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "_location": "/inherits", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "inherits@2.0.3", + "name": "inherits", + "escapedName": "inherits", + "rawSpec": "2.0.3", + "saveSpec": null, + "fetchSpec": "2.0.3" + }, + "_requiredBy": [ + "/util" + ], + "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "_shasum": "633c2c83e3da42a502f52466022480f4208261de", + "_spec": "inherits@2.0.3", + "_where": "C:\\Users\\Alix\\Desktop\\school\\Fourth_Semester\\ECSE-321\\project-group-02\\SCRS-Backend\\src\\test\\javascript\\node_modules\\util", + "browser": "./inherits_browser.js", + "bugs": { + "url": "https://github.com/isaacs/inherits/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", + "devDependencies": { + "tap": "^7.1.0" + }, + "files": [ + "inherits.js", + "inherits_browser.js" + ], + "homepage": "https://github.com/isaacs/inherits#readme", + "keywords": [ + "inheritance", + "class", + "klass", + "oop", + "object-oriented", + "inherits", + "browser", + "browserify" + ], + "license": "ISC", + "main": "./inherits.js", + "name": "inherits", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/inherits.git" + }, + "scripts": { + "test": "node test" + }, + "version": "2.0.3" +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/path/.npmignore b/SCRS-Backend/src/test/javascript/node_modules/path/.npmignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/path/.npmignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/SCRS-Backend/src/test/javascript/node_modules/path/LICENSE b/SCRS-Backend/src/test/javascript/node_modules/path/LICENSE new file mode 100644 index 0000000..e3d4e69 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/path/LICENSE @@ -0,0 +1,18 @@ +Copyright Joyent, Inc. and other Node contributors. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/SCRS-Backend/src/test/javascript/node_modules/path/README.md b/SCRS-Backend/src/test/javascript/node_modules/path/README.md new file mode 100644 index 0000000..f5227af --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/path/README.md @@ -0,0 +1,15 @@ +# path + +This is an exact copy of the NodeJS ’path’ module published to the NPM registry. + +[Documentation](http://nodejs.org/docs/latest/api/path.html) + +## Install + +```sh +$ npm install --save path +``` + +## License + +MIT diff --git a/SCRS-Backend/src/test/javascript/node_modules/path/package.json b/SCRS-Backend/src/test/javascript/node_modules/path/package.json new file mode 100644 index 0000000..1d2d07b --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/path/package.json @@ -0,0 +1,53 @@ +{ + "_from": "path", + "_id": "path@0.12.7", + "_inBundle": false, + "_integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", + "_location": "/path", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "path", + "name": "path", + "escapedName": "path", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "_shasum": "d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f", + "_spec": "path", + "_where": "C:\\Users\\Alix\\Desktop\\school\\Fourth_Semester\\ECSE-321\\project-group-02\\SCRS-Backend\\src\\test\\javascript", + "author": { + "name": "Joyent", + "url": "http://www.joyent.com" + }, + "bugs": { + "url": "https://github.com/jinder/path/issues" + }, + "bundleDependencies": false, + "dependencies": { + "process": "^0.11.1", + "util": "^0.10.3" + }, + "deprecated": false, + "description": "Node.JS path module", + "homepage": "http://nodejs.org/docs/latest/api/path.html", + "keywords": [ + "ender", + "path" + ], + "license": "MIT", + "main": "./path.js", + "name": "path", + "repository": { + "type": "git", + "url": "git://github.com/jinder/path.git" + }, + "version": "0.12.7" +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/path/path.js b/SCRS-Backend/src/test/javascript/node_modules/path/path.js new file mode 100644 index 0000000..937bc79 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/path/path.js @@ -0,0 +1,628 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + + +var isWindows = process.platform === 'win32'; +var util = require('util'); + + +// resolves . and .. elements in a path array with directory names there +// must be no slashes or device names (c:\) in the array +// (so also no leading and trailing slashes - it does not distinguish +// relative and absolute paths) +function normalizeArray(parts, allowAboveRoot) { + var res = []; + for (var i = 0; i < parts.length; i++) { + var p = parts[i]; + + // ignore empty parts + if (!p || p === '.') + continue; + + if (p === '..') { + if (res.length && res[res.length - 1] !== '..') { + res.pop(); + } else if (allowAboveRoot) { + res.push('..'); + } + } else { + res.push(p); + } + } + + return res; +} + +// returns an array with empty elements removed from either end of the input +// array or the original array if no elements need to be removed +function trimArray(arr) { + var lastIndex = arr.length - 1; + var start = 0; + for (; start <= lastIndex; start++) { + if (arr[start]) + break; + } + + var end = lastIndex; + for (; end >= 0; end--) { + if (arr[end]) + break; + } + + if (start === 0 && end === lastIndex) + return arr; + if (start > end) + return []; + return arr.slice(start, end + 1); +} + +// Regex to split a windows path into three parts: [*, device, slash, +// tail] windows-only +var splitDeviceRe = + /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; + +// Regex to split the tail part of the above into [*, dir, basename, ext] +var splitTailRe = + /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/; + +var win32 = {}; + +// Function to split a filename into [root, dir, basename, ext] +function win32SplitPath(filename) { + // Separate device+slash from tail + var result = splitDeviceRe.exec(filename), + device = (result[1] || '') + (result[2] || ''), + tail = result[3] || ''; + // Split the tail into dir, basename and extension + var result2 = splitTailRe.exec(tail), + dir = result2[1], + basename = result2[2], + ext = result2[3]; + return [device, dir, basename, ext]; +} + +function win32StatPath(path) { + var result = splitDeviceRe.exec(path), + device = result[1] || '', + isUnc = !!device && device[1] !== ':'; + return { + device: device, + isUnc: isUnc, + isAbsolute: isUnc || !!result[2], // UNC paths are always absolute + tail: result[3] + }; +} + +function normalizeUNCRoot(device) { + return '\\\\' + device.replace(/^[\\\/]+/, '').replace(/[\\\/]+/g, '\\'); +} + +// path.resolve([from ...], to) +win32.resolve = function() { + var resolvedDevice = '', + resolvedTail = '', + resolvedAbsolute = false; + + for (var i = arguments.length - 1; i >= -1; i--) { + var path; + if (i >= 0) { + path = arguments[i]; + } else if (!resolvedDevice) { + path = process.cwd(); + } else { + // Windows has the concept of drive-specific current working + // directories. If we've resolved a drive letter but not yet an + // absolute path, get cwd for that drive. We're sure the device is not + // an unc path at this points, because unc paths are always absolute. + path = process.env['=' + resolvedDevice]; + // Verify that a drive-local cwd was found and that it actually points + // to our drive. If not, default to the drive's root. + if (!path || path.substr(0, 3).toLowerCase() !== + resolvedDevice.toLowerCase() + '\\') { + path = resolvedDevice + '\\'; + } + } + + // Skip empty and invalid entries + if (!util.isString(path)) { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if (!path) { + continue; + } + + var result = win32StatPath(path), + device = result.device, + isUnc = result.isUnc, + isAbsolute = result.isAbsolute, + tail = result.tail; + + if (device && + resolvedDevice && + device.toLowerCase() !== resolvedDevice.toLowerCase()) { + // This path points to another device so it is not applicable + continue; + } + + if (!resolvedDevice) { + resolvedDevice = device; + } + if (!resolvedAbsolute) { + resolvedTail = tail + '\\' + resolvedTail; + resolvedAbsolute = isAbsolute; + } + + if (resolvedDevice && resolvedAbsolute) { + break; + } + } + + // Convert slashes to backslashes when `resolvedDevice` points to an UNC + // root. Also squash multiple slashes into a single one where appropriate. + if (isUnc) { + resolvedDevice = normalizeUNCRoot(resolvedDevice); + } + + // At this point the path should be resolved to a full absolute path, + // but handle relative paths to be safe (might happen when process.cwd() + // fails) + + // Normalize the tail path + resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/), + !resolvedAbsolute).join('\\'); + + return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) || + '.'; +}; + + +win32.normalize = function(path) { + var result = win32StatPath(path), + device = result.device, + isUnc = result.isUnc, + isAbsolute = result.isAbsolute, + tail = result.tail, + trailingSlash = /[\\\/]$/.test(tail); + + // Normalize the tail path + tail = normalizeArray(tail.split(/[\\\/]+/), !isAbsolute).join('\\'); + + if (!tail && !isAbsolute) { + tail = '.'; + } + if (tail && trailingSlash) { + tail += '\\'; + } + + // Convert slashes to backslashes when `device` points to an UNC root. + // Also squash multiple slashes into a single one where appropriate. + if (isUnc) { + device = normalizeUNCRoot(device); + } + + return device + (isAbsolute ? '\\' : '') + tail; +}; + + +win32.isAbsolute = function(path) { + return win32StatPath(path).isAbsolute; +}; + +win32.join = function() { + var paths = []; + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + if (!util.isString(arg)) { + throw new TypeError('Arguments to path.join must be strings'); + } + if (arg) { + paths.push(arg); + } + } + + var joined = paths.join('\\'); + + // Make sure that the joined path doesn't start with two slashes, because + // normalize() will mistake it for an UNC path then. + // + // This step is skipped when it is very clear that the user actually + // intended to point at an UNC path. This is assumed when the first + // non-empty string arguments starts with exactly two slashes followed by + // at least one more non-slash character. + // + // Note that for normalize() to treat a path as an UNC path it needs to + // have at least 2 components, so we don't filter for that here. + // This means that the user can use join to construct UNC paths from + // a server name and a share name; for example: + // path.join('//server', 'share') -> '\\\\server\\share\') + if (!/^[\\\/]{2}[^\\\/]/.test(paths[0])) { + joined = joined.replace(/^[\\\/]{2,}/, '\\'); + } + + return win32.normalize(joined); +}; + + +// path.relative(from, to) +// it will solve the relative path from 'from' to 'to', for instance: +// from = 'C:\\orandea\\test\\aaa' +// to = 'C:\\orandea\\impl\\bbb' +// The output of the function should be: '..\\..\\impl\\bbb' +win32.relative = function(from, to) { + from = win32.resolve(from); + to = win32.resolve(to); + + // windows is not case sensitive + var lowerFrom = from.toLowerCase(); + var lowerTo = to.toLowerCase(); + + var toParts = trimArray(to.split('\\')); + + var lowerFromParts = trimArray(lowerFrom.split('\\')); + var lowerToParts = trimArray(lowerTo.split('\\')); + + var length = Math.min(lowerFromParts.length, lowerToParts.length); + var samePartsLength = length; + for (var i = 0; i < length; i++) { + if (lowerFromParts[i] !== lowerToParts[i]) { + samePartsLength = i; + break; + } + } + + if (samePartsLength == 0) { + return to; + } + + var outputParts = []; + for (var i = samePartsLength; i < lowerFromParts.length; i++) { + outputParts.push('..'); + } + + outputParts = outputParts.concat(toParts.slice(samePartsLength)); + + return outputParts.join('\\'); +}; + + +win32._makeLong = function(path) { + // Note: this will *probably* throw somewhere. + if (!util.isString(path)) + return path; + + if (!path) { + return ''; + } + + var resolvedPath = win32.resolve(path); + + if (/^[a-zA-Z]\:\\/.test(resolvedPath)) { + // path is local filesystem path, which needs to be converted + // to long UNC path. + return '\\\\?\\' + resolvedPath; + } else if (/^\\\\[^?.]/.test(resolvedPath)) { + // path is network UNC path, which needs to be converted + // to long UNC path. + return '\\\\?\\UNC\\' + resolvedPath.substring(2); + } + + return path; +}; + + +win32.dirname = function(path) { + var result = win32SplitPath(path), + root = result[0], + dir = result[1]; + + if (!root && !dir) { + // No dirname whatsoever + return '.'; + } + + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1); + } + + return root + dir; +}; + + +win32.basename = function(path, ext) { + var f = win32SplitPath(path)[2]; + // TODO: make this comparison case-insensitive on windows? + if (ext && f.substr(-1 * ext.length) === ext) { + f = f.substr(0, f.length - ext.length); + } + return f; +}; + + +win32.extname = function(path) { + return win32SplitPath(path)[3]; +}; + + +win32.format = function(pathObject) { + if (!util.isObject(pathObject)) { + throw new TypeError( + "Parameter 'pathObject' must be an object, not " + typeof pathObject + ); + } + + var root = pathObject.root || ''; + + if (!util.isString(root)) { + throw new TypeError( + "'pathObject.root' must be a string or undefined, not " + + typeof pathObject.root + ); + } + + var dir = pathObject.dir; + var base = pathObject.base || ''; + if (!dir) { + return base; + } + if (dir[dir.length - 1] === win32.sep) { + return dir + base; + } + return dir + win32.sep + base; +}; + + +win32.parse = function(pathString) { + if (!util.isString(pathString)) { + throw new TypeError( + "Parameter 'pathString' must be a string, not " + typeof pathString + ); + } + var allParts = win32SplitPath(pathString); + if (!allParts || allParts.length !== 4) { + throw new TypeError("Invalid path '" + pathString + "'"); + } + return { + root: allParts[0], + dir: allParts[0] + allParts[1].slice(0, -1), + base: allParts[2], + ext: allParts[3], + name: allParts[2].slice(0, allParts[2].length - allParts[3].length) + }; +}; + + +win32.sep = '\\'; +win32.delimiter = ';'; + + +// Split a filename into [root, dir, basename, ext], unix version +// 'root' is just a slash, or nothing. +var splitPathRe = + /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; +var posix = {}; + + +function posixSplitPath(filename) { + return splitPathRe.exec(filename).slice(1); +} + + +// path.resolve([from ...], to) +// posix version +posix.resolve = function() { + var resolvedPath = '', + resolvedAbsolute = false; + + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path = (i >= 0) ? arguments[i] : process.cwd(); + + // Skip empty and invalid entries + if (!util.isString(path)) { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if (!path) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path[0] === '/'; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeArray(resolvedPath.split('/'), + !resolvedAbsolute).join('/'); + + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; +}; + +// path.normalize(path) +// posix version +posix.normalize = function(path) { + var isAbsolute = posix.isAbsolute(path), + trailingSlash = path && path[path.length - 1] === '/'; + + // Normalize the path + path = normalizeArray(path.split('/'), !isAbsolute).join('/'); + + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + + return (isAbsolute ? '/' : '') + path; +}; + +// posix version +posix.isAbsolute = function(path) { + return path.charAt(0) === '/'; +}; + +// posix version +posix.join = function() { + var path = ''; + for (var i = 0; i < arguments.length; i++) { + var segment = arguments[i]; + if (!util.isString(segment)) { + throw new TypeError('Arguments to path.join must be strings'); + } + if (segment) { + if (!path) { + path += segment; + } else { + path += '/' + segment; + } + } + } + return posix.normalize(path); +}; + + +// path.relative(from, to) +// posix version +posix.relative = function(from, to) { + from = posix.resolve(from).substr(1); + to = posix.resolve(to).substr(1); + + var fromParts = trimArray(from.split('/')); + var toParts = trimArray(to.split('/')); + + var length = Math.min(fromParts.length, toParts.length); + var samePartsLength = length; + for (var i = 0; i < length; i++) { + if (fromParts[i] !== toParts[i]) { + samePartsLength = i; + break; + } + } + + var outputParts = []; + for (var i = samePartsLength; i < fromParts.length; i++) { + outputParts.push('..'); + } + + outputParts = outputParts.concat(toParts.slice(samePartsLength)); + + return outputParts.join('/'); +}; + + +posix._makeLong = function(path) { + return path; +}; + + +posix.dirname = function(path) { + var result = posixSplitPath(path), + root = result[0], + dir = result[1]; + + if (!root && !dir) { + // No dirname whatsoever + return '.'; + } + + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1); + } + + return root + dir; +}; + + +posix.basename = function(path, ext) { + var f = posixSplitPath(path)[2]; + // TODO: make this comparison case-insensitive on windows? + if (ext && f.substr(-1 * ext.length) === ext) { + f = f.substr(0, f.length - ext.length); + } + return f; +}; + + +posix.extname = function(path) { + return posixSplitPath(path)[3]; +}; + + +posix.format = function(pathObject) { + if (!util.isObject(pathObject)) { + throw new TypeError( + "Parameter 'pathObject' must be an object, not " + typeof pathObject + ); + } + + var root = pathObject.root || ''; + + if (!util.isString(root)) { + throw new TypeError( + "'pathObject.root' must be a string or undefined, not " + + typeof pathObject.root + ); + } + + var dir = pathObject.dir ? pathObject.dir + posix.sep : ''; + var base = pathObject.base || ''; + return dir + base; +}; + + +posix.parse = function(pathString) { + if (!util.isString(pathString)) { + throw new TypeError( + "Parameter 'pathString' must be a string, not " + typeof pathString + ); + } + var allParts = posixSplitPath(pathString); + if (!allParts || allParts.length !== 4) { + throw new TypeError("Invalid path '" + pathString + "'"); + } + allParts[1] = allParts[1] || ''; + allParts[2] = allParts[2] || ''; + allParts[3] = allParts[3] || ''; + + return { + root: allParts[0], + dir: allParts[0] + allParts[1].slice(0, -1), + base: allParts[2], + ext: allParts[3], + name: allParts[2].slice(0, allParts[2].length - allParts[3].length) + }; +}; + + +posix.sep = '/'; +posix.delimiter = ':'; + + +if (isWindows) + module.exports = win32; +else /* posix */ + module.exports = posix; + +module.exports.posix = posix; +module.exports.win32 = win32; diff --git a/SCRS-Backend/src/test/javascript/node_modules/process/.eslintrc b/SCRS-Backend/src/test/javascript/node_modules/process/.eslintrc new file mode 100644 index 0000000..1e7aab7 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/process/.eslintrc @@ -0,0 +1,21 @@ +{ +extends: "eslint:recommended", + "env": { + "node": true, + "browser": true, + "es6" : true, + "mocha": true + }, + "rules": { + "indent": [2, 4], + "brace-style": [2, "1tbs"], + "quotes": [2, "single"], + "no-console": 0, + "no-shadow": 0, + "no-use-before-define": [2, "nofunc"], + "no-underscore-dangle": 0, + "no-constant-condition": 0, + "space-after-function-name": 0, + "consistent-return": 0 + } +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/process/LICENSE b/SCRS-Backend/src/test/javascript/node_modules/process/LICENSE new file mode 100644 index 0000000..b8c1246 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/process/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2013 Roman Shtylman + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/SCRS-Backend/src/test/javascript/node_modules/process/README.md b/SCRS-Backend/src/test/javascript/node_modules/process/README.md new file mode 100644 index 0000000..6570729 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/process/README.md @@ -0,0 +1,26 @@ +# process + +```require('process');``` just like any other module. + +Works in node.js and browsers via the browser.js shim provided with the module. + +## browser implementation + +The goal of this module is not to be a full-fledged alternative to the builtin process module. This module mostly exists to provide the nextTick functionality and little more. We keep this module lean because it will often be included by default by tools like browserify when it detects a module has used the `process` global. + +It also exposes a "browser" member (i.e. `process.browser`) which is `true` in this implementation but `undefined` in node. This can be used in isomorphic code that adjusts it's behavior depending on which environment it's running in. + +If you are looking to provide other process methods, I suggest you monkey patch them onto the process global in your app. A list of user created patches is below. + +* [hrtime](https://github.com/kumavis/browser-process-hrtime) +* [stdout](https://github.com/kumavis/browser-stdout) + +## package manager notes + +If you are writing a bundler to package modules for client side use, make sure you use the ```browser``` field hint in package.json. + +See https://gist.github.com/4339901 for details. + +The [browserify](https://github.com/substack/node-browserify) module will properly handle this field when bundling your files. + + diff --git a/SCRS-Backend/src/test/javascript/node_modules/process/browser.js b/SCRS-Backend/src/test/javascript/node_modules/process/browser.js new file mode 100644 index 0000000..d059362 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/process/browser.js @@ -0,0 +1,184 @@ +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; diff --git a/SCRS-Backend/src/test/javascript/node_modules/process/index.js b/SCRS-Backend/src/test/javascript/node_modules/process/index.js new file mode 100644 index 0000000..8d8ed7d --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/process/index.js @@ -0,0 +1,2 @@ +// for now just expose the builtin process global from node.js +module.exports = global.process; diff --git a/SCRS-Backend/src/test/javascript/node_modules/process/package.json b/SCRS-Backend/src/test/javascript/node_modules/process/package.json new file mode 100644 index 0000000..bdd5bd2 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/process/package.json @@ -0,0 +1,59 @@ +{ + "_from": "process@^0.11.1", + "_id": "process@0.11.10", + "_inBundle": false, + "_integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", + "_location": "/process", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "process@^0.11.1", + "name": "process", + "escapedName": "process", + "rawSpec": "^0.11.1", + "saveSpec": null, + "fetchSpec": "^0.11.1" + }, + "_requiredBy": [ + "/path" + ], + "_resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "_shasum": "7332300e840161bda3e69a1d1d91a7d4bc16f182", + "_spec": "process@^0.11.1", + "_where": "C:\\Users\\Alix\\Desktop\\school\\Fourth_Semester\\ECSE-321\\project-group-02\\SCRS-Backend\\src\\test\\javascript\\node_modules\\path", + "author": { + "name": "Roman Shtylman", + "email": "shtylman@gmail.com" + }, + "browser": "./browser.js", + "bugs": { + "url": "https://github.com/shtylman/node-process/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "process information for node.js and browsers", + "devDependencies": { + "mocha": "2.2.1", + "zuul": "^3.10.3" + }, + "engines": { + "node": ">= 0.6.0" + }, + "homepage": "https://github.com/shtylman/node-process#readme", + "keywords": [ + "process" + ], + "license": "MIT", + "main": "./index.js", + "name": "process", + "repository": { + "type": "git", + "url": "git://github.com/shtylman/node-process.git" + }, + "scripts": { + "browser": "zuul --no-coverage --ui mocha-bdd --local 8080 -- test.js", + "test": "mocha test.js" + }, + "version": "0.11.10" +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/process/test.js b/SCRS-Backend/src/test/javascript/node_modules/process/test.js new file mode 100644 index 0000000..8ba579c --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/process/test.js @@ -0,0 +1,199 @@ +var assert = require('assert'); +var ourProcess = require('./browser'); +describe('test against our process', function () { + test(ourProcess); +}); +if (!process.browser) { + describe('test against node', function () { + test(process); + }); + vmtest(); +} +function test (ourProcess) { + describe('test arguments', function () { + it ('works', function (done) { + var order = 0; + + + ourProcess.nextTick(function (num) { + assert.equal(num, order++, 'first one works'); + ourProcess.nextTick(function (num) { + assert.equal(num, order++, 'recursive one is 4th'); + }, 3); + }, 0); + ourProcess.nextTick(function (num) { + assert.equal(num, order++, 'second one starts'); + ourProcess.nextTick(function (num) { + assert.equal(num, order++, 'this is third'); + ourProcess.nextTick(function (num) { + assert.equal(num, order++, 'this is last'); + done(); + }, 5); + }, 4); + }, 1); + ourProcess.nextTick(function (num) { + + assert.equal(num, order++, '3rd schedualed happens after the error'); + }, 2); + }); + }); +if (!process.browser) { + describe('test errors', function (t) { + it ('works', function (done) { + var order = 0; + process.removeAllListeners('uncaughtException'); + process.once('uncaughtException', function(err) { + assert.equal(2, order++, 'error is third'); + ourProcess.nextTick(function () { + assert.equal(5, order++, 'schedualed in error is last'); + done(); + }); + }); + ourProcess.nextTick(function () { + assert.equal(0, order++, 'first one works'); + ourProcess.nextTick(function () { + assert.equal(4, order++, 'recursive one is 4th'); + }); + }); + ourProcess.nextTick(function () { + assert.equal(1, order++, 'second one starts'); + throw(new Error('an error is thrown')); + }); + ourProcess.nextTick(function () { + assert.equal(3, order++, '3rd schedualed happens after the error'); + }); + }); + }); +} + describe('rename globals', function (t) { + var oldTimeout = setTimeout; + var oldClear = clearTimeout; + + it('clearTimeout', function (done){ + + var ok = true; + clearTimeout = function () { + ok = false; + } + var ran = false; + function cleanup() { + clearTimeout = oldClear; + var err; + try { + assert.ok(ok, 'fake clearTimeout ran'); + assert.ok(ran, 'should have run'); + } catch (e) { + err = e; + } + done(err); + } + setTimeout(cleanup, 1000); + ourProcess.nextTick(function () { + ran = true; + }); + }); + it('just setTimeout', function (done){ + + + setTimeout = function () { + setTimeout = oldTimeout; + try { + assert.ok(false, 'fake setTimeout called') + } catch (e) { + done(e); + } + + } + + ourProcess.nextTick(function () { + setTimeout = oldTimeout; + done(); + }); + }); + }); +} +function vmtest() { + var vm = require('vm'); + var fs = require('fs'); + var process = fs.readFileSync('./browser.js', {encoding: 'utf8'}); + + + describe('should work in vm in strict mode with no globals', function () { + it('should parse', function (done) { + var str = '"use strict";var module = {exports:{}};'; + str += process; + str += 'this.works = process.browser;'; + var script = new vm.Script(str); + var context = { + works: false + }; + script.runInNewContext(context); + assert.ok(context.works); + done(); + }); + it('setTimeout throws error', function (done) { + var str = '"use strict";var module = {exports:{}};'; + str += process; + str += 'try {process.nextTick(function () {})} catch (e){this.works = e;}'; + var script = new vm.Script(str); + var context = { + works: false + }; + script.runInNewContext(context); + assert.ok(context.works); + done(); + }); + it('should generally work', function (done) { + var str = '"use strict";var module = {exports:{}};'; + str += process; + str += 'process.nextTick(function () {assert.ok(true);done();})'; + var script = new vm.Script(str); + var context = { + clearTimeout: clearTimeout, + setTimeout: setTimeout, + done: done, + assert: assert + }; + script.runInNewContext(context); + }); + it('late defs setTimeout', function (done) { + var str = '"use strict";var module = {exports:{}};'; + str += process; + str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {assert.ok(true);done();})'; + var script = new vm.Script(str); + var context = { + clearTimeout: clearTimeout, + hiddenSetTimeout: setTimeout, + done: done, + assert: assert + }; + script.runInNewContext(context); + }); + it('late defs clearTimeout', function (done) { + var str = '"use strict";var module = {exports:{}};'; + str += process; + str += 'var clearTimeout = hiddenClearTimeout;process.nextTick(function () {assert.ok(true);done();})'; + var script = new vm.Script(str); + var context = { + hiddenClearTimeout: clearTimeout, + setTimeout: setTimeout, + done: done, + assert: assert + }; + script.runInNewContext(context); + }); + it('late defs setTimeout and then redefine', function (done) { + var str = '"use strict";var module = {exports:{}};'; + str += process; + str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {setTimeout = function (){throw new Error("foo")};hiddenSetTimeout(function(){process.nextTick(function (){assert.ok(true);done();});});});'; + var script = new vm.Script(str); + var context = { + clearTimeout: clearTimeout, + hiddenSetTimeout: setTimeout, + done: done, + assert: assert + }; + script.runInNewContext(context); + }); + }); +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/util/LICENSE b/SCRS-Backend/src/test/javascript/node_modules/util/LICENSE new file mode 100644 index 0000000..e3d4e69 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/util/LICENSE @@ -0,0 +1,18 @@ +Copyright Joyent, Inc. and other Node contributors. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/SCRS-Backend/src/test/javascript/node_modules/util/README.md b/SCRS-Backend/src/test/javascript/node_modules/util/README.md new file mode 100644 index 0000000..1c473d2 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/util/README.md @@ -0,0 +1,15 @@ +# util + +[![Build Status](https://travis-ci.org/defunctzombie/node-util.png?branch=master)](https://travis-ci.org/defunctzombie/node-util) + +node.js [util](http://nodejs.org/api/util.html) module as a module + +## install via [npm](npmjs.org) + +```shell +npm install util +``` + +## browser support + +This module also works in modern browsers. If you need legacy browser support you will need to polyfill ES5 features. diff --git a/SCRS-Backend/src/test/javascript/node_modules/util/package.json b/SCRS-Backend/src/test/javascript/node_modules/util/package.json new file mode 100644 index 0000000..94da3d3 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/util/package.json @@ -0,0 +1,63 @@ +{ + "_from": "util@^0.10.3", + "_id": "util@0.10.4", + "_inBundle": false, + "_integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "_location": "/util", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "util@^0.10.3", + "name": "util", + "escapedName": "util", + "rawSpec": "^0.10.3", + "saveSpec": null, + "fetchSpec": "^0.10.3" + }, + "_requiredBy": [ + "/path" + ], + "_resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "_shasum": "3aa0125bfe668a4672de58857d3ace27ecb76901", + "_spec": "util@^0.10.3", + "_where": "C:\\Users\\Alix\\Desktop\\school\\Fourth_Semester\\ECSE-321\\project-group-02\\SCRS-Backend\\src\\test\\javascript\\node_modules\\path", + "author": { + "name": "Joyent", + "url": "http://www.joyent.com" + }, + "browser": { + "./support/isBuffer.js": "./support/isBufferBrowser.js" + }, + "bugs": { + "url": "https://github.com/defunctzombie/node-util/issues" + }, + "bundleDependencies": false, + "dependencies": { + "inherits": "2.0.3" + }, + "deprecated": false, + "description": "Node.JS util module", + "devDependencies": { + "zuul": "~1.0.9" + }, + "files": [ + "util.js", + "support" + ], + "homepage": "https://github.com/defunctzombie/node-util", + "keywords": [ + "util" + ], + "license": "MIT", + "main": "./util.js", + "name": "util", + "repository": { + "type": "git", + "url": "git://github.com/defunctzombie/node-util.git" + }, + "scripts": { + "test": "node test/node/*.js && zuul test/browser/*.js" + }, + "version": "0.10.4" +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/util/support/isBuffer.js b/SCRS-Backend/src/test/javascript/node_modules/util/support/isBuffer.js new file mode 100644 index 0000000..ace9ac0 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/util/support/isBuffer.js @@ -0,0 +1,3 @@ +module.exports = function isBuffer(arg) { + return arg instanceof Buffer; +} diff --git a/SCRS-Backend/src/test/javascript/node_modules/util/support/isBufferBrowser.js b/SCRS-Backend/src/test/javascript/node_modules/util/support/isBufferBrowser.js new file mode 100644 index 0000000..0e1bee1 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/util/support/isBufferBrowser.js @@ -0,0 +1,6 @@ +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; +} \ No newline at end of file diff --git a/SCRS-Backend/src/test/javascript/node_modules/util/util.js b/SCRS-Backend/src/test/javascript/node_modules/util/util.js new file mode 100644 index 0000000..e0ea321 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/node_modules/util/util.js @@ -0,0 +1,586 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + if (process.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +}; + + +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; +}; + + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = require('./support/isBuffer'); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = require('inherits'); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} diff --git a/SCRS-Backend/src/test/javascript/package-lock.json b/SCRS-Backend/src/test/javascript/package-lock.json new file mode 100644 index 0000000..580f7c4 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/package-lock.json @@ -0,0 +1,48 @@ +{ + "name": "javascript", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, + "follow-redirects": { + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz", + "integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "path": { + "version": "0.12.7", + "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", + "requires": { + "process": "^0.11.1", + "util": "^0.10.3" + } + }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" + }, + "util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "requires": { + "inherits": "2.0.3" + } + } + } +} diff --git a/SCRS-Backend/src/test/javascript/package.json b/SCRS-Backend/src/test/javascript/package.json new file mode 100644 index 0000000..1175b8f --- /dev/null +++ b/SCRS-Backend/src/test/javascript/package.json @@ -0,0 +1,16 @@ +{ + "name": "javascript", + "version": "1.0.0", + "description": "Javascript testing suite", + "main": "runTests.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "axios": "^0.21.1", + "path": "^0.12.7" + }, + "type": "module" +} diff --git a/SCRS-Backend/src/test/javascript/runTests.js b/SCRS-Backend/src/test/javascript/runTests.js new file mode 100644 index 0000000..76d2949 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/runTests.js @@ -0,0 +1,34 @@ +import testLogin from "./login.js"; +import testCustomer from "./customer.js"; +import testAssistant from "./assistant.js"; +import {testTechnician, testAssignTimeslotToTechnician, testViewTechnicianSchedule} from "./technician.js"; +import {testAppointmentBookingAndPayment, testRateAppointment, testModifyAppointment} from "./appointment.js"; +import testWorkspace from "./workspace.js"; +import {testTimeslot, testGetAvailableTimeslots} from "./timeslot.js"; + + +console.log(""); + +testLogin().then(() => { + testCustomer().then(() => { + testAssistant().then(() => { + testTechnician().then(() => { + testRateAppointment().then(() => { + testWorkspace().then(() => { + testTimeslot().then(() => { + testAssignTimeslotToTechnician().then(() => { + testViewTechnicianSchedule().then(() => { + testModifyAppointment().then(() => { + testAppointmentBookingAndPayment().then(() => { + testGetAvailableTimeslots(); + }); + }); + }); + }); + }); + }); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/SCRS-Backend/src/test/javascript/technician.js b/SCRS-Backend/src/test/javascript/technician.js new file mode 100644 index 0000000..2940166 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/technician.js @@ -0,0 +1,503 @@ +import axios from "axios"; + +const testTechnician = async () => { + const backendAddress = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 9; + let id = 0; + + //creating technician account test 1 + try { + let sentData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.post( + backendAddress + "/api/technician/create", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + id = responseDataPost.technicianId; + if (responseDataPost.technicianName === sentData.name && statusCode === 200) + scoreCounter++; + else { + console.log("Test 1 unsuccessful:"); + if (responseDataPost.name === sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 1 unsuccessful:"); + console.log(`${error}`); + } + + //creating technician account test 2 + try { + let sentData = { + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.post( + backendAddress + "/api/technician/create", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost.technicianName !== sentData.name && statusCode === 208) + scoreCounter++; + else { + console.log("Test 2 unsuccessful:"); + if (responseDataPost.name !== sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 208) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 2 unsuccessful:"); + console.log(`${error}`); + } + + //creating technician account test 3 + try { + let sentData = null; + + let postTest = await axios.post( + backendAddress + "/api/technician/create", + sentData + ); + } catch (error) { + if (error.response.status === 415) scoreCounter++; + else { + console.log("Test 3 unsuccessful:"); + console.log(`${error}`); + } + } + + //updating technician account test 1 + try { + let sentData = { + scrsUserId: id, + name: "Bababoo", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.put( + backendAddress + "/api/technician/update", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + let statusCode = postTest.status; + if (responseDataPost.technicianName === sentData.name && statusCode === 200) + scoreCounter++; + else { + console.log("Test 4 unsuccessful:"); + if (responseDataPost.name === sentData.name) + console.log(`returned data is erronous: ${responseDataPost}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 4 unsuccessful:"); + console.log(`${error}`); + } + + //updating technician account test 2 + try { + let sentData = { + scrsUserId: 0, + name: "Bababooey", + password: "got bababooied", + email: "babaooey@gmail.com", + phone: "111-111-1111", + }; + + let postTest = await axios.put( + backendAddress + "/api/technician/update", + sentData + ); + } catch (error) { + if (error.response.status === 406) scoreCounter++; + else { + console.log("Test 6 unsuccessful:"); + console.log(`${error}`); + } + } + + //updating technician account test 3 + try { + let sentData = null; + + let postTest = await axios.put( + backendAddress + "/api/technician/update", + sentData + ); + } catch (error) { + if (error.response.status === 415) scoreCounter++; + else { + console.log("Test 6 unsuccessful:"); + console.log(`${error}`); + } + } + + //deleting account test 1 + try { + let deleteTest = await axios.delete( + backendAddress + `/api/technician/delete/${id}` + ); + + let statusCode = deleteTest.status; + if (statusCode === 200) scoreCounter++; + else { + console.log("Test 7 unsuccessful:"); + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 7 unsuccessful:"); + console.log(`${error}`); + } + + //deleting account test 2 + try { + let deleteTest = await axios.delete( + backendAddress + `/api/technician/delete/${id}` + ); + } catch (error) { + if (error.response.status === 406) scoreCounter++; + else { + console.log("Test 8 unsuccessful:"); + console.log(`${error}`); + } + } + + //wiping the database + try { + let deleteTest = await axios.delete(backendAddress + "/api/database/wipe"); + + let statusCode = deleteTest.status; + if (statusCode === 200) scoreCounter++; + else { + console.log("Test 9 unsuccessful:"); + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Test 9 unsuccessful:"); + console.log(`${error}`); + } + + //compiling results + if (scoreCounter === numberOfTests) + console.log("All the technician tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} technician tests were successful.` + ); + console.log(""); +}; + +const testAssignTimeslotToTechnician = async () => { + const backendAddress = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 4; + let technicianIdToCheck = -1; // will update this value with the created technician + let timeslotIdToAssign = -1; + + let wipeDatabaseResponse = await axios.delete( + backendAddress + "/api/database/wipe" + ); + + // Set up a technician for test + try { + let createTechnicianData = { + name: "Foo", + email: "foo@bar.com", + phone: "111 111-1111", + }; + + let createTechnicianResponse = await axios.post( + backendAddress + "/api/technician/create", + createTechnicianData); + + if (createTechnicianResponse.status !== 200) + throw "Error: Failed to create technician for test 'assignTechnicianToTimeslot'"; + + technicianIdToCheck = createTechnicianResponse.data.technicianId; + + } catch (e) { + console.log("Error: Failed to create technician for test 'assignTechnicianToTimeslot'"); + console.log(e); + } + + // Set up a workspace and corresponding timeslot for test + try { + let createWorkspaceData = "name=foo"; + + let createWorkspaceResponse = await axios.post( + backendAddress + "/api/workspace/create", + createWorkspaceData); + + if (createWorkspaceResponse.status !== 200) { + throw "Error: Failed to create workspace"; + } + + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: createWorkspaceResponse.data.workspaceId, + techniciansId: [] + }; + + let createTimeslotResponse = await axios.post( + backendAddress + "/api/timeslot/create", + createTimeslotData); + + if (createTimeslotResponse.status !== 200) { + throw "Error: Failed to create timeslot for test 'assignTechnicianToTimeslot'"; + } + + + timeslotIdToAssign = createTimeslotResponse.data.timeslotId; + + } catch (e) { + console.log("Error: Failed to create timeslot for test 'assignTechnicianToTimeslot'"); + console.log(e); + } + + // test assign timeslot to technician + try { + let assignTimeslotData = `timeslotId=${timeslotIdToAssign}&technicianId=${technicianIdToCheck}`; + + let assignTimeslotResponse = await axios.put( + backendAddress + "/api/timeslot/assignTech", + assignTimeslotData); + + if (assignTimeslotResponse.status !== 200) { + throw "Error: failed to assign timeslot to technician"; + } + + scoreCounter++; + } catch (e) { + console.log("Error: Failed to assign timeslot to technician for test 'assignTechnicianToTimeslot'"); + console.log(e); + } + + // test assign timeslot to technician who already has that timeslot assigned to them + try { + let assignTimeslotData = `timeslotId=${timeslotIdToAssign}&technicianId=${technicianIdToCheck}`; + + let assignTimeslotResponse = await axios.put( + backendAddress + "/api/timeslot/assignTech", + assignTimeslotData); + + if (assignTimeslotResponse.status === 200) { + console.log("Error: duplicate timeslot assigned to technician"); + } + + } catch (e) { + scoreCounter++; + } + + // test assign timeslot to technician who doesn't exist + try { + let assignTimeslotData = `timeslotId=${timeslotIdToAssign}&technicianId=-1`; + + let assignTimeslotResponse = await axios.put( + backendAddress + "/api/timeslot/assignTech", + assignTimeslotData); + + if (assignTimeslotResponse.status === 200) { + console.log("Error: assigned timeslot to invalid technician"); + } + + } catch (e) { + scoreCounter++; + } + + // test assign timeslot which doesn't exist to technician + try { + let assignTimeslotData = `timeslotId=-1&technicianId=${technicianIdToCheck}`; + + let assignTimeslotResponse = await axios.put( + backendAddress + "/api/timeslot/assignTech", + assignTimeslotData); + + if (assignTimeslotResponse.status === 200) { + console.log("Error: assigned invalid timeslot to technician"); + } + + } catch (e) { + scoreCounter++; + } + + + //compiling results + if (scoreCounter === numberOfTests) + console.log("All the assign technician to timeslot tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} assign technician to timeslot tests were successful.` + ); + console.log(""); +}; + +const testViewTechnicianSchedule = async () => { + const backendAddress = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 2; + let id = 0; + let timeslotIdToAssign = -1; + let technicianIdToCheck = -1; + let timeslotStartDate = null; + let timeslotEndDate = null; + + let wipeDatabaseResponse = await axios.delete( + backendAddress + "/api/database/wipe" + ); + +//Set up a technician for test + try { + let createTechnicianData = { + name: "Foo", + email: "foo@bar.com", + phone: "111 111-1111", + }; + + let createTechnicianResponse = await axios.post( + backendAddress + "/api/technician/create", + createTechnicianData); + + if (createTechnicianResponse.status !== 200) + throw "Error: Failed to create technician for test 'assignTechnicianToTimeslot'"; + + technicianIdToCheck = createTechnicianResponse.data.technicianId; + + } catch (e) { + console.log("Error: Failed to create technician for test 'assignTechnicianToTimeslot'"); + console.log(e); + } + + // Set up a workspace and corresponding timeslot for test + try { + let createWorkspaceData = "name=foo"; + + let createWorkspaceResponse = await axios.post( + backendAddress + "/api/workspace/create", + createWorkspaceData); + + if (createWorkspaceResponse.status !== 200) { + throw "Error: Failed to create workspace"; + } + + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: createWorkspaceResponse.data.workspaceId, + techniciansId: [] + }; + + let createTimeslotResponse = await axios.post( + backendAddress + "/api/timeslot/create", + createTimeslotData); + + if (createTimeslotResponse.status !== 200) { + throw "Error: Failed to create timeslot for test 'assignTechnicianToTimeslot'"; + } + + + timeslotIdToAssign = createTimeslotResponse.data.timeslotId; + timeslotStartDate = createTimeslotResponse.data.startDate; + timeslotEndDate = createTimeslotResponse.data.endDate; + + + } catch (e) { + console.log("Error: Failed to create timeslot for test 'assignTechnicianToTimeslot'"); + console.log(e); + } + + // Set up assign timeslot 1 to technician + try { + let assignTimeslotData = `timeslotId=${timeslotIdToAssign}&technicianId=${technicianIdToCheck}`; + + let assignTimeslotResponse = await axios.put( + backendAddress + "/api/timeslot/assignTech", + assignTimeslotData); + + if (assignTimeslotResponse.status !== 200) { + throw "Error: failed to assign timeslot to technician"; + } + } catch (e) { + console.log("Error: Failed to assign timeslot to technician for test 'assignTechnicianToTimeslot'"); + console.log(e); + } + + //Getting timeslots assigned to the technician (Test 1) + try { + + let startDate = "2021-03-18"; + let endDate = "2021-03-19"; + + let getTechnicianSchedule = await axios.get(backendAddress + `/api/technician/viewschedule/${technicianIdToCheck}/${startDate}/${endDate}`); + + let ScheduleResponseData = getTechnicianSchedule.data; + let statusCode = getTechnicianSchedule.status; + + if (statusCode === 200 && technicianIdToCheck === ScheduleResponseData[0].techniciansId[0]) { + if (ScheduleResponseData[0].timeslotId === timeslotIdToAssign) { + scoreCounter++; + } + } + + } catch (error) { + console.log("Could not get the technician schedule"); + console.log(`${error}`); + } + + //Getting schedule of a technician that does not exist (Test 2) + try { + + let startDate = "2021-03-18"; + let endDate = "2021-03-19"; + technicianIdToCheck = -1; + + let getTechnicianSchedule = await axios.get(backendAddress + `/api/technician/viewschedule/${technicianIdToCheck}/${startDate}/${endDate}`); + + let ScheduleResponseData = getTechnicianSchedule.data; + let statusCode = getTechnicianSchedule.status; + + if (statusCode === 200 && technicianIdToCheck === ScheduleResponseData[0].techniciansId[0]) { + if (ScheduleResponseData[0].timeslotId === timeslotIdToAssign) { + } + } + + } catch (error) { + scoreCounter++; + //console.log("could not get the technician schedule"); + } + + //Compiling results + if (scoreCounter === numberOfTests) + console.log("All the View Technician Schedule tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} View Technician Schedule tests were successful.` + ); + console.log(""); + +} +export {testTechnician, testAssignTimeslotToTechnician, testViewTechnicianSchedule}; diff --git a/SCRS-Backend/src/test/javascript/template.js b/SCRS-Backend/src/test/javascript/template.js new file mode 100644 index 0000000..72d7e70 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/template.js @@ -0,0 +1,67 @@ +import axios from "axios"; + +const templates = async () => { + const backend_address = "http://localhost:8080"; + let counter = 0; + + //example of a get request from front-end + try { + let getTest = await axios.get(backend_address + "/api/somegetroute"); + + let responseDataGet = getTest.data; //do something with this for tests + } catch (err) { + console.error(err.response.data.error); //or any other message you would want + } + + //example of a post request from front-end + + try { + let sentData = { + name: "bababooey", + you: "got bababooied", + }; + + let postTest = await axios.post( + backend_address + "/api/somepostroute", + sentData + ); + + let responseDataPost = postTest.data; //do something with this for tests + } catch (err) { + console.error(err.response.data.error); //or any other message you would want + } + + //example of an update request from the front-end + + try { + const id = 1; + + let updateTest = await axios.put( + backend_address + `/api/someupdateroute/${id}`, + sentData + ); + + let responseDataUpdate = updateTest.data; //do something with this for tests + } catch (err) { + console.error(err.response.data.error); //or any other message you would want + } + + //example of a delete request from the front-end + + try { + const id = 1; + + let sentData = { + name: "bababooey", + you: "got bababooied", + }; + + let deleteTest = await axios.delete( + backend_address + `/api/somedeleteroute/${id}` + ); + + let responseDataDelete = deleteTest.data; //do something with this for tests + } catch (err) { + console.error(err.response.data.error); //or any other message you would want + } +}; diff --git a/SCRS-Backend/src/test/javascript/timeslot.js b/SCRS-Backend/src/test/javascript/timeslot.js new file mode 100644 index 0000000..1a63af4 --- /dev/null +++ b/SCRS-Backend/src/test/javascript/timeslot.js @@ -0,0 +1,194 @@ +import axios from "axios"; + +const testTimeslot = async () => { + const backend_address = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 4; + let timeslotIdToCheck = -1; + let workspaceIdToCheck = -1; + + let wipeDatabaseResponse = await axios.delete( + backend_address + "/api/database/wipe" + ); + + //Set up for Test 1 + try { + let createWorkspaceData = "name=foo"; + + let createWorkspaceResponse = await axios.post( + backend_address + "/api/workspace/create", + createWorkspaceData); + + workspaceIdToCheck = createWorkspaceResponse.data.workspaceId; + + } catch (error) { + console.log("failed to setup test 1 (timeslot)") + } + + //Create a timeslot (Test 1) + try { + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: workspaceIdToCheck, + techniciansId: [] + }; + + let createTimeslotResponse = await axios.post( + backend_address + "/api/timeslot/create", + createTimeslotData); + + timeslotIdToCheck = createTimeslotResponse.data.timeslotId; + let statusCode = createTimeslotResponse.status; + + if (createTimeslotResponse.status === 200 && createTimeslotResponse.data.workspaceId === createTimeslotData.workspaceId) { + scoreCounter++; + timeslotIdToCheck = createTimeslotResponse.data.timeslotId; + } else { + console.log("Test 1 unsuccessful:"); + if (createTimeslotResponse.workspaceId !== createTimeslotData.workspaceId) + console.log(`returned data is erronous: ${createTimeslotResponse}`); + if (statusCode !== 200) + console.log(`status code not as expected: ${statusCode}`); + } + } catch (error) { + console.log("Failed to create timeslot in test 1"); + console.log(`${error}`); + } + //Create a timeslot with an incorrect workspaceId (Test 2) + try { + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: "11111", + techniciansId: [] + }; + + let createTimeslotResponse = await axios.post( + backend_address + "/api/timeslot/create", + createTimeslotData); + + timeslotIdToCheck = createTimeslotResponse.data.timeslotId; + let statusCode = createTimeslotResponse.status; + + if(createTimeslotResponse.status===200){ + console.log("Creating timeslot with invalid workspace should not work"); + } + + } catch (error) { + scoreCounter++; + } + + //Delete timeslots (Test 3) + try { + let deleteTimeslotResponse = await axios.delete( + backend_address + `/api/timeslot/delete/${timeslotIdToCheck}`); + + let statusCode = deleteTimeslotResponse.status; + if (statusCode === 200 && deleteTimeslotResponse.data.timeslotId === timeslotIdToCheck) { + scoreCounter++; + } + + } catch (error) { + console.log("Failed to delete timeslot in test 3"); + } + + //Deleting an invalid timeslot (Test 4) + try { + let deleteTimeslotResponse = await axios.delete( + backend_address + "/api/timeslot/delete/-1"); + + console.log("Test 4 failed: ") + console.log(`\tUnexpected status code returned ${deleteTimeslotResponse.status}`); + console.log(`\tWorkspace returned ${deleteTimeslotResponse.data.timeslotId}`); + } catch (error) { + scoreCounter++; + } + + // ========== Compiling Results ========== + if (scoreCounter === numberOfTests) + console.log("All the timeslot tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} timeslots tests were successful.` + ); + console.log(""); + +}; + +const testGetAvailableTimeslots = async () => { + const backend_address = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 1; + let timeslotToCheck = null; + + // ========== test setups ========== + try { + let wipeDatabaseResponse = await axios.delete( + backend_address + "/api/database/wipe"); + + // create workspace + let createWorkspaceData = "name=foo"; + let createWorkspacePost = await axios.post( + backend_address + "/api/workspace/create", + createWorkspaceData); + + // create timeslots + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: createWorkspacePost.data.workspaceId, + techniciansId: []}; + let createTimeslotResponse = await axios.post( + backend_address + "/api/timeslot/create", + createTimeslotData); + timeslotToCheck = createTimeslotResponse.data; + } catch (error) { + console.log("Setup for testAppointmentBookingAndPayment FAILED"); + console.log(error); + } + + + // ========== get available timeslots ========== + try { + let startDate = timeslotToCheck.startDate; + let endDate = timeslotToCheck.startDate; + + let availableTimeslotResponse = await axios.get( + backend_address + `/api/timeslot/available/${startDate}/${endDate}`); + + if(availableTimeslotResponse.status === 200 && availableTimeslotResponse.data[0].timeslotId === timeslotToCheck.timeslotId) { + scoreCounter++; + } else { + console.log("Test get available timeslots unsuccessful:"); + if (availableTimeslotResponse.status !== 200) + { + console.log("\tUnexpected status code returned"); + } + else if (availableTimeslotResponse.data.timeslotId !== timeslotToCheck.timeslotId) + { + console.log(`\tUnexpected spaceName returned ${availableTimeslotResponse.data.timeslotId}`); + } + } + }catch (error) { + console.log("Test get available timeslots FAILED") + console.log(error); + } + + // ========== compiling results ========== + if (scoreCounter === numberOfTests) + console.log("All the GetAvailableTimeslots tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} GetAvailableTimeslots tests were successful.` + ); + console.log(""); +}; + +export {testTimeslot, testGetAvailableTimeslots}; \ No newline at end of file diff --git a/SCRS-Backend/src/test/javascript/workspace.js b/SCRS-Backend/src/test/javascript/workspace.js new file mode 100644 index 0000000..dc4df7a --- /dev/null +++ b/SCRS-Backend/src/test/javascript/workspace.js @@ -0,0 +1,179 @@ +import axios from "axios"; + +const testWorkspace = async () => { + const backend_address = "http://localhost:8080"; + let scoreCounter = 0; + const numberOfTests = 7; + let workspaceIdToCheck = -1; + + let wipeDatabaseResponse = await axios.delete( + backend_address + "/api/database/wipe" + ); + + // ========== Create a workspace (Test 1) ========== + try { + let createWorkspaceData = "name=foo"; + + let createWorkspaceResponse = await axios.post( + backend_address + "/api/workspace/create", + createWorkspaceData); + + if (createWorkspaceResponse.status === 200 && createWorkspaceResponse.data.spaceName === "foo") { + scoreCounter++; + workspaceIdToCheck = createWorkspaceResponse.data.workspaceId; + } else { + console.log("Test Create a workspace FAILED: ") + if (createWorkspaceResponse.status !== 200) + { + console.log("\tUnexpected status code returned"); + } + else if (createWorkspaceResponse.data.spaceName !== "foo") + { + console.log(`\tUnexpected spaceName returned ${createWorkspaceResponse.data.spaceName}`); + } + } + } catch (error) { + console.log("Test Create a workspace FAILED") + console.log(error); + } + + // ========== Creating a workspace with an invalid name (Test 2) ========== + try { + let createWorkspaceData = null; + + let createWorkspaceResponse = await axios.post( + backend_address + "/api/workspace/create", + createWorkspaceData); + + console.log("Test Creating a workspace with an invalid name FAILED: ") + console.log(`\tUnexpected status code returned ${createWorkspaceResponse.status}`); + console.log(`\tWorkspace returned ${createWorkspaceResponse.data.workspaceId}`); + } catch (error) { + scoreCounter++; + } + + + // ========== Test 3&4 setups ========== + let timeslotIdToCheck = -1; + // create timeslots + try { + let createTimeslotData = { + startDate: Date.now(), + endDate: Date.now(), + startTime: +new Date(), + endTime: +new Date(), + workspaceId: workspaceIdToCheck, + techniciansId: [ ] + }; + + let createTimeslotResponse = await axios.post( + backend_address + "/api/timeslot/create", + createTimeslotData); + + timeslotIdToCheck = createTimeslotResponse.data.timeslotId; + } catch (error) { + console.log("Faild to create timeslot in workspace tests"); + } + + // ========== Get workspace available timeslot (Test 3) ========== + try { + let getWorkspaceTimeslotResponse = await axios.get( + backend_address + `/api/workspace/availabilities/${workspaceIdToCheck}`); + + if (getWorkspaceTimeslotResponse.status === 200 && getWorkspaceTimeslotResponse.data[0].timeslotId === timeslotIdToCheck) { + scoreCounter++; + } else { + console.log("Test Get workspace available timeslot FAILED: ") + if (getWorkspaceTimeslotResponse.status !== 200) + { + console.log("\tUnexpected status code returned"); + } + else if (getWorkspaceTimeslotResponse.data[0].timeslotId === timeslotIdToCheck) + { + console.log(`\tUnexpected timeslot returned ${getWorkspaceTimeslotResponse.data[0].timeslotId}`); + } + } + } catch (error) { + console.log("Test Get workspace available timeslot FAILED") + console.log(error); + } + + // ========== Get available timeslot of invalid workspace (Test 4) ========== + try { + let deleteWorkspaceResponse = await axios.get( + backend_address + "/api/workspace/availabilities/-1"); + + console.log("Test Get available timeslot of invalid workspace FAILED: ") + console.log(`\tUnexpected status code returned ${deleteWorkspaceResponse.status}`); + console.log(`\tWorkspace returned ${deleteWorkspaceResponse.data.workspaceId}`); + } catch (error) { + scoreCounter++; + } + + // ========== Deleting an workspace with timeslot association (Test 5) ========== + try { + let deleteWorkspaceResponse = await axios.delete( + backend_address + `/api/workspace/delete/${workspaceIdToCheck}`); + + console.log("Test Deleting an workspace with timeslot association FAILED: ") + console.log(`\tUnexpected status code returned ${deleteWorkspaceResponse.status}`); + console.log(`\tWorkspace returned ${deleteWorkspaceResponse.data.workspaceId}`); + } catch (error) { + scoreCounter++; + } + + // ========== Test 6&7 setups ========== + // delete timeslots + try { + let deleteTimeslotResponse = await axios.delete( + backend_address + `/api/timeslot/delete/${timeslotIdToCheck}`); + } catch (error) { + console.log("Faild to delete timeslot in workspace test"); + } + + // ========== Deleting a workspace (Test 6) ========== + try { + let deleteWorkspaceResponse = await axios.delete( + backend_address + `/api/workspace/delete/${workspaceIdToCheck}`); + + if (deleteWorkspaceResponse.status === 200 && deleteWorkspaceResponse.data.workspaceId === workspaceIdToCheck) { + scoreCounter++; + } else { + console.log("Test Deleting a workspace FAILED: ") + if (deleteWorkspaceResponse.status !== 200) + { + console.log("\tUnexpected status code returned"); + } + else if (deleteWorkspaceResponse.data.workspaceId !== workspaceIdToCheck) + { + console.log(`\tUnexpected spaceName returned ${deleteWorkspaceResponse.data.workspaceId}`); + } + } + } catch (error) { + console.log("Test Deleting a workspace FAILED") + console.log(error); + } + + // ========== Deleting an invalid workspace (Test 7) ========== + try { + let deleteWorkspaceResponse = await axios.delete( + backend_address + "/api/workspace/delete/-1"); + + console.log("Test Deleting an invalid workspace FAILED: ") + console.log(`\tUnexpected status code returned ${deleteWorkspaceResponse.status}`); + console.log(`\tWorkspace returned ${deleteWorkspaceResponse.data.workspaceId}`); + } catch (error) { + scoreCounter++; + } + + // ========== compiling results ========== + if (scoreCounter === numberOfTests) + console.log("All the workspace tests were successful!"); + else + console.log( + `${scoreCounter}/${numberOfTests} workspace tests were successful.` + ); + console.log(""); +}; + +export default testWorkspace; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..48e341a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +}