@ -15,115 +15,164 @@ export default {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
return dataSources . cargoBikeAPI . getCargoBikes ( offset , limit ) ;
return dataSources . cargoBikeAPI . getCargoBikes ( offset , limit ) ;
} else {
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
}
} ,
} ,
bikeEvents : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
bikeEvents : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
if ( req . permissions . includes ( Permission . ReadBike Event ) ) {
return dataSources . cargoBikeAPI . bikeEvents ( offset , limit ) ;
return dataSources . cargoBikeAPI . bikeEvents ( offset , limit ) ;
} else {
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
}
} ,
} ,
bikeEventById : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
bikeEventById : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
if ( req . permissions . includes ( Permission . ReadBike Event ) ) {
return dataSources . cargoBikeAPI . findBikeEventById ( id ) ;
return dataSources . cargoBikeAPI . findBikeEventById ( id ) ;
} else {
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
}
} ,
} ,
bikeEventTypeByd : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
bikeEventTypeByd : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
if ( req . permissions . includes ( Permission . ReadBike Event ) ) {
return dataSources . cargoBikeAPI . findBikeEventTypeById ( id ) ;
return dataSources . cargoBikeAPI . findBikeEventTypeById ( id ) ;
} else {
} else {
return new GraphQLError ( 'Insufficiant Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
bikeEventTypes : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBikeEvent ) ) {
return dataSources . cargoBikeAPI . bikeEventTypes ( offset , limit ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
} ,
} ,
equipment : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
equipment : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
if ( req . permissions . includes ( Permission . Read Equipment ) ) {
return dataSources . cargoBikeAPI . getEquipment ( offset , limit ) ;
return dataSources . cargoBikeAPI . getEquipment ( offset , limit ) ;
} else {
} else {
return new GraphQLError ( 'Insufficiant Permissions' ) ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
}
} ,
} ,
equipmentById : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
equipmentById : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Read Bike ) ) {
if ( req . permissions . includes ( Permission . Read Equipment ) ) {
return dataSources . cargoBikeAPI . equipmentById ( id ) ;
return dataSources . cargoBikeAPI . equipmentById ( id ) ;
} else {
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
}
} ,
} ,
equipmentTypes : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
equipmentTypes : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Read Bike ) ) {
if ( req . permissions . includes ( Permission . Read Equipment ) ) {
return dataSources . cargoBikeAPI . equipmentTypes ( offset , limit ) ;
return dataSources . cargoBikeAPI . equipmentTypes ( offset , limit ) ;
} else {
} else {
return new GraphQLError ( 'Insuffici a nt Permissions') ;
return new GraphQLError ( 'Insuffici e nt Permissions') ;
}
}
} ,
} ,
equipmentTypeById : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
equipmentTypeById : ( _ :any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Read Bike ) ) {
if ( req . permissions . includes ( Permission . Read Equipment ) ) {
return dataSources . cargoBikeAPI . equipmentTypeById ( id ) ;
return dataSources . cargoBikeAPI . equipmentTypeById ( id ) ;
} else {
} else {
return new GraphQLError ( 'Insufficiant Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
bikeEventTypes : ( _ :any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . ReadBike ) ) {
return dataSources . cargoBikeAPI . bikeEventTypes ( offset , limit ) ;
} else {
return new GraphQLError ( 'Insufficiant Permissions' ) ;
}
}
}
}
} ,
} ,
CargoBike : {
CargoBike : {
engagement ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
engagement ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . participantAPI . engagementByCargoBikeId ( offset , limit , parent . id ) ;
if ( req . permissions . includes ( Permission . ReadEngagement ) ) {
return dataSources . participantAPI . engagementByCargoBikeId ( offset , limit , parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
coordinator ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
coordinator ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) { // TODO should be done with engagements
dataSources . participantAPI . participantByCargoBikeId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadParticipant ) ) {
return dataSources . participantAPI . participantByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
equipment ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
equipment ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . equipmentByCargoBikeId ( offset , limit , parent . id ) ;
if ( req . permissions . includes ( Permission . ReadEquipment ) ) {
return dataSources . cargoBikeAPI . equipmentByCargoBikeId ( offset , limit , parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
lendingStation ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
lendingStation ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . lendingStationAPI . lendingStationByCargoBikeId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadLendingStation ) ) {
return dataSources . lendingStationAPI . lendingStationByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
bikeEvents ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
bikeEvents ( parent : any , { offset , limit } : { offset : number , limit : number } , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . bikeEventsByCargoBikeId ( parent . id , offset , limit ) ;
if ( req . permissions . includes ( Permission . ReadBikeEvent ) ) {
return dataSources . cargoBikeAPI . bikeEventsByCargoBikeId ( parent . id , offset , limit ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
isLocked : ( parent : any , __ : any , { dataSources , req } : { dataSources : any ; req : any } ) = > isLocked ( parent , { dataSources , req } ) ,
isLocked : ( parent : any , __ : any , { dataSources , req } : { dataSources : any ; req : any } ) = > isLocked ( parent , { dataSources , req } ) ,
lockedBy ( ) : any {
return null ;
} ,
timeFrames ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
timeFrames ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . lendingStationAPI . timeFramesByCargoBikeId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadTimeFrame ) ) {
return dataSources . lendingStationAPI . timeFramesByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
equipmentType ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
equipmentType ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . equipmentTypeByCargoBikeId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadEquipment ) ) {
return dataSources . cargoBikeAPI . equipmentTypeByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
provider ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
provider ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . providerAPI . providerByCargoBikeId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadProvider ) ) {
return dataSources . providerAPI . providerByCargoBikeId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
}
} ,
} ,
Equipment : {
Equipment : {
cargoBike ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
cargoBike ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . cargoBikeByEquipmentId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadBike ) ) {
return dataSources . cargoBikeAPI . cargoBikeByEquipmentId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
isLocked : ( parent : any , __ : any , { dataSources , req } : { dataSources : any ; req : any } ) = > isLocked ( parent , { dataSources , req } )
isLocked : ( parent : any , __ : any , { dataSources , req } : { dataSources : any ; req : any } ) = > isLocked ( parent , { dataSources , req } )
} ,
} ,
BikeEvent : {
BikeEvent : {
cargoBike ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
cargoBike ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . cargoBikeByEventId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadBike ) ) {
return dataSources . cargoBikeAPI . cargoBikeByEventId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
bikeEventType ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
bikeEventType ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . bikeEventTypeByBikeEventId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadBikeEvent ) ) {
return dataSources . cargoBikeAPI . bikeEventTypeByBikeEventId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
responsible ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
responsible ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . responsibleByBikeEventId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadParticipant ) ) {
return dataSources . cargoBikeAPI . responsibleByBikeEventId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
related ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
related ( parent : any , __ : any , { dataSources , req } : { dataSources : any , req : any } ) {
return dataSources . cargoBikeAPI . relatedByBikeEventId ( parent . id ) ;
if ( req . permissions . includes ( Permission . ReadParticipant ) ) {
return dataSources . cargoBikeAPI . relatedByBikeEventId ( parent . id ) ;
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
} ,
} ,
isLocked : ( parent : any , __ : any , { dataSources , req } : { dataSources : any ; req : any } ) = > isLocked ( parent , { dataSources , req } )
isLocked : ( parent : any , __ : any , { dataSources , req } : { dataSources : any ; req : any } ) = > isLocked ( parent , { dataSources , req } )
} ,
} ,
@ -160,49 +209,49 @@ export default {
}
}
} ,
} ,
createBikeEvent : ( _ : any , { bikeEvent } : { bikeEvent : any } , { dataSources , req } : { dataSources : any , req : any } ) = > {
createBikeEvent : ( _ : any , { bikeEvent } : { bikeEvent : any } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . WriteBike ) ) {
if ( req . permissions . includes ( Permission . WriteBike Event ) ) {
return dataSources . cargoBikeAPI . createBikeEvent ( { bikeEvent } ) ;
return dataSources . cargoBikeAPI . createBikeEvent ( { bikeEvent } ) ;
} else {
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
} ,
} ,
lockBikeEventById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
lockBikeEventById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . WriteBike ) ) {
if ( req . permissions . includes ( Permission . WriteBike Event ) ) {
return dataSources . cargoBikeAPI . lockBikeEvent ( id , req . userId ) ;
return dataSources . cargoBikeAPI . lockBikeEvent ( id , req . userId ) ;
} else {
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
} ,
} ,
unlockBikeEventById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
unlockBikeEventById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . WriteBike ) ) {
if ( req . permissions . includes ( Permission . WriteBike Event ) ) {
return dataSources . cargoBikeAPI . unlockBikeEvent ( id , req . userId ) ;
return dataSources . cargoBikeAPI . unlockBikeEvent ( id , req . userId ) ;
} else {
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
} ,
} ,
createEquipment : ( _ : any , { equipment } : { equipment : any } , { dataSources , req } : { dataSources : any , req : any } ) = > {
createEquipment : ( _ : any , { equipment } : { equipment : any } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Write Bike ) ) {
if ( req . permissions . includes ( Permission . Write Equipment ) ) {
return dataSources . cargoBikeAPI . createEquipment ( { equipment } ) ;
return dataSources . cargoBikeAPI . createEquipment ( { equipment } ) ;
} else {
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
} ,
} ,
lockEquipmentById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
lockEquipmentById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Write Bike ) ) {
if ( req . permissions . includes ( Permission . Write Equipment ) ) {
return dataSources . cargoBikeAPI . lockEquipment ( id , req . userId ) ;
return dataSources . cargoBikeAPI . lockEquipment ( id , req . userId ) ;
} else {
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
} ,
} ,
unlockEquipmentById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
unlockEquipmentById : ( _ : any , { id } : { id : number } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Write Bike ) ) {
if ( req . permissions . includes ( Permission . Write Equipment ) ) {
return dataSources . cargoBikeAPI . unlockEquipment ( id , req . userId ) ;
return dataSources . cargoBikeAPI . unlockEquipment ( id , req . userId ) ;
} else {
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;
}
}
} ,
} ,
updateEquipment : ( _ : any , { equipment } : { equipment : any } , { dataSources , req } : { dataSources : any , req : any } ) = > {
updateEquipment : ( _ : any , { equipment } : { equipment : any } , { dataSources , req } : { dataSources : any , req : any } ) = > {
if ( req . permissions . includes ( Permission . Write Bike ) ) {
if ( req . permissions . includes ( Permission . Write Equipment ) ) {
return dataSources . cargoBikeAPI . updateEquipment ( equipment , req . userId ) ;
return dataSources . cargoBikeAPI . updateEquipment ( equipment , req . userId ) ;
} else {
} else {
return new GraphQLError ( 'Insufficient Permissions' ) ;
return new GraphQLError ( 'Insufficient Permissions' ) ;