Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@immomio/api-library

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@immomio/api-library - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

lib/api.d.ts

2

lib/appointments/resolver.d.ts

@@ -0,4 +1,4 @@

import { ApiRequest } from '../api';
import { FlatUrl } from '../flats';
import { ProfileUrl } from '../profiles';
import { ApiRequest } from '../types';
import { JsonHalCollection, JsonHalObject } from '../utils/jsonHal';

@@ -5,0 +5,0 @@ export interface Appointment {

@@ -42,3 +42,3 @@ "use strict";

});
const isAppointmentInFuture = (appointment) => appointment.date > new Date();
const isAppointmentAfterDate = (appointment, date = new Date()) => appointment.date > date;
const hasAppointmentFreeSlots = (appointment) => appointment.maxInviteeCount === -1 || appointment.currentInviteeCount < appointment.maxInviteeCount;

@@ -48,6 +48,6 @@ const appointmentForFlatFilter = (flat) => (appointment) => appointment.flat === flat;

exports.filterValidAppointments = (appointments, validAppointments, flat) => {
const flatAppointments = filter(validAppointments, appointmentForFlatFilter(flat), isAppointmentInFuture);
const flatAppointments = filter(validAppointments, appointmentForFlatFilter(flat), isAppointmentAfterDate);
if (flatAppointments.length > 0)
return flatAppointments;
return filter(appointments, appointmentForFlatFilter(flat), isAppointmentInFuture, hasAppointmentFreeSlots);
return filter(appointments, appointmentForFlatFilter(flat), isAppointmentAfterDate, hasAppointmentFreeSlots);
};

@@ -54,0 +54,0 @@ exports.default = {

@@ -1,2 +0,2 @@

import { ApiUrlPath } from '../types';
import { ApiUrlPath } from '../api';
export declare type FlatUrl = ApiUrlPath;

@@ -3,0 +3,0 @@ export interface Flat {

@@ -1,2 +0,2 @@

import { ApiUrlPath } from '../types';
import { ApiUrlPath } from '../api';
export declare type ProfileUrl = ApiUrlPath;

@@ -3,0 +3,0 @@ export interface Profile {

@@ -1,2 +0,2 @@

import { ApiUrlPath } from '../types';
import { ApiUrlPath } from '../api';
export declare type UserUrl = ApiUrlPath;

@@ -3,0 +3,0 @@ export interface User {

{
"name": "@immomio/api-library",
"version": "1.0.11",
"version": "1.0.12",
"description": "Immomio library to access the immomio-API",

@@ -5,0 +5,0 @@ "engineStrict": true,

import { ApiRequest } from '../api'
import { FlatUrl } from '../flats'
import { ProfileUrl } from '../profiles'
import { ApiRequest } from '../types'
import { fetch } from '../utils/fetch'

@@ -14,2 +13,4 @@ import {

// ===== Interfaces this file handles
export interface Appointment {

@@ -31,2 +32,3 @@ ID: string

// ====== Reolver - Function Parameters
export interface FindAppointmentsByFlat extends ApiRequest {

@@ -64,5 +66,3 @@ flatId: string

/**
* converts an incoming appointment resource into a standard appointment
*/
/** converts an incoming appointment resource into a standard appointment */
export const convertAppointment = (data: any): Appointment => {

@@ -76,2 +76,3 @@ const appointment = {

/** converts an appointment response to a jsonHal<Appointment> */
export const singleAppointmentResponse = async (response: Response): Promise<AppointmentResponse & JsonHalObject> => {

@@ -86,2 +87,3 @@ const data = await response.json()

/** converts an appointment response to a jsonHal<Appointment> list */
export const multiAppointmentResponse = async (

@@ -99,2 +101,3 @@ response: Response,

/** Fetches the appointments for a given flat */
export const findAppointmentsByFlat = async (locals: FindAppointmentsByFlat) => {

@@ -107,2 +110,3 @@ const url = urls.findAppointmentsByFlat

/** Fetches the appointments for a given profile */
export const findAppointmentsByProfile = async (locals: FindAppointmentsByProfile) => {

@@ -115,2 +119,3 @@ const url = urls.findAppointmentsByProfile

/** Fetches on specific appointment */
export const findAppointment = async (locals: FindAppointment) => {

@@ -123,11 +128,18 @@ const url = urls.findAppointment

const isAppointmentInFuture = (appointment: Appointment) =>
appointment.date > new Date()
/** checks if an appointment is after a given point in time */
const isAppointmentAfterDate = (appointment: Appointment, date: Date = new Date()) =>
appointment.date > date
/** checks if an appointment has a slot open */
const hasAppointmentFreeSlots = (appointment: Appointment) =>
appointment.maxInviteeCount === -1 || appointment.currentInviteeCount < appointment.maxInviteeCount
/** factory to generate functions that check if an appointment connects to a specific flat */
const appointmentForFlatFilter = (flat: FlatUrl) => (appointment: Appointment) =>
appointment.flat === flat
/**
* Applies a list of filters to each function
* returns all items that fulfill all filters
*/
const filter = <T>(list: T[], ...filters: Array<(item: T) => boolean>): T[] => list.filter((item: T) =>

@@ -148,3 +160,3 @@ filters.reduce((memo: boolean, fn: (item: T) => boolean) => memo && fn(item), true),

): Appointment[] => {
const flatAppointments = filter(validAppointments, appointmentForFlatFilter(flat), isAppointmentInFuture)
const flatAppointments = filter(validAppointments, appointmentForFlatFilter(flat), isAppointmentAfterDate)

@@ -156,3 +168,3 @@ // all appointments found in the valid appointments should be in the appointments list

// filter the appointments by validation rules for tenants
return filter(appointments, appointmentForFlatFilter(flat), isAppointmentInFuture, hasAppointmentFreeSlots)
return filter(appointments, appointmentForFlatFilter(flat), isAppointmentAfterDate, hasAppointmentFreeSlots)
}

@@ -159,0 +171,0 @@

import { ApiUrlPath } from '../types'
import { ApiUrlPath } from '../api'

@@ -4,0 +4,0 @@ export type FlatUrl = ApiUrlPath

import { ApiUrlPath } from '../types'
import { ApiUrlPath } from '../api'

@@ -4,0 +4,0 @@ export type ProfileUrl = ApiUrlPath

import { ApiUrlPath } from '../types'
import { ApiUrlPath } from '../api'

@@ -4,0 +4,0 @@ export type UserUrl = ApiUrlPath

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc