Info and infos
This commit is contained in:
parent
db873e407e
commit
1ddf36fdb7
|
@ -25,8 +25,6 @@ release:
|
|||
GOOGLE_APPLICATION_CREDENTIALS: /secret.json
|
||||
script:
|
||||
- cat $GCS_SERVICE_ACCOUNT_KEY > /secret.json
|
||||
- cat /secret.json
|
||||
- ls dist/
|
||||
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination eu.gcr.io/qpa-staging-237606/api:$CI_COMMIT_TAG
|
||||
only:
|
||||
- tags
|
||||
|
|
|
@ -59,7 +59,8 @@ declare namespace GQL {
|
|||
__typename: 'CalendarEvent';
|
||||
id: string;
|
||||
owner: IUser;
|
||||
info: Array<IEventInformation | null>;
|
||||
infos: Array<IEventInformation | null>;
|
||||
info: IEventInformation | null;
|
||||
time: IEventTime;
|
||||
status: any;
|
||||
location: ILocation;
|
||||
|
@ -67,6 +68,10 @@ declare namespace GQL {
|
|||
meta: IEventMeta | null;
|
||||
}
|
||||
|
||||
interface IInfoOnCalendarEventArguments {
|
||||
lang: string;
|
||||
}
|
||||
|
||||
interface IEventInformation {
|
||||
__typename: 'EventInformation';
|
||||
language: string;
|
||||
|
@ -198,7 +203,7 @@ declare namespace GQL {
|
|||
|
||||
interface ICreateEventInput {
|
||||
time: IEventTimeInput;
|
||||
info: Array<IEventInformationInput | null>;
|
||||
infos: Array<IEventInformationInput | null>;
|
||||
location: IEventLocationInput;
|
||||
meta: IEventMetaInput;
|
||||
status: string;
|
||||
|
@ -230,7 +235,7 @@ declare namespace GQL {
|
|||
interface IUpdateEventInput {
|
||||
id: string;
|
||||
time?: IEventTimeInput | null;
|
||||
info?: Array<IEventInformationInput> | null;
|
||||
infos?: Array<IEventInformationInput> | null;
|
||||
location?: IEventLocationInput | null;
|
||||
meta?: IEventMetaInput | null;
|
||||
status?: string | null;
|
||||
|
|
|
@ -1,245 +1 @@
|
|||
export type EventStatus = 'confirmed' | 'canceled'
|
||||
// tslint:disable
|
||||
// graphql typescript definitions
|
||||
|
||||
declare namespace GQL {
|
||||
interface IGraphQLResponseRoot {
|
||||
data?: IQuery | IMutation;
|
||||
errors?: Array<IGraphQLResponseError>;
|
||||
}
|
||||
|
||||
interface IGraphQLResponseError {
|
||||
/** Required for all errors */
|
||||
message: string;
|
||||
locations?: Array<IGraphQLResponseErrorLocation>;
|
||||
/** 7.2.2 says 'GraphQL servers may provide additional entries to error' */
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
interface IGraphQLResponseErrorLocation {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
interface IQuery {
|
||||
__typename: 'Query';
|
||||
me: IUser | null;
|
||||
event: ICalendarEvent | null;
|
||||
events: Array<ICalendarEvent | null> | null;
|
||||
occurrences: Array<IEventOccurrence | null> | null;
|
||||
occurrence: IEventOccurrence | null;
|
||||
}
|
||||
|
||||
interface IEventOnQueryArguments {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface IEventsOnQueryArguments {
|
||||
filter: IEventsQueryFilter;
|
||||
}
|
||||
|
||||
interface IOccurrencesOnQueryArguments {
|
||||
filter: IOccurrencesQueryFilter;
|
||||
}
|
||||
|
||||
interface IOccurrenceOnQueryArguments {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface IUser {
|
||||
__typename: 'User';
|
||||
name: string;
|
||||
username: string | null;
|
||||
email: string;
|
||||
id: string;
|
||||
events: Array<ICalendarEvent | null>;
|
||||
roles: Array<IUserRole> | null;
|
||||
}
|
||||
|
||||
interface ICalendarEvent {
|
||||
__typename: 'CalendarEvent';
|
||||
id: string;
|
||||
owner: IUser;
|
||||
info: Array<IEventInformation | null>;
|
||||
time: IEventTime;
|
||||
status: any;
|
||||
location: ILocation;
|
||||
occurrences: Array<IEventOccurrence | null> | null;
|
||||
meta: IEventMeta | null;
|
||||
}
|
||||
|
||||
interface IEventInformation {
|
||||
__typename: 'EventInformation';
|
||||
language: string;
|
||||
title: string;
|
||||
description: string | null;
|
||||
}
|
||||
|
||||
interface IEventTime {
|
||||
__typename: 'EventTime';
|
||||
timeZone: any | null;
|
||||
start: any | null;
|
||||
end: any | null;
|
||||
recurrence: string | null;
|
||||
exceptions: string | null;
|
||||
}
|
||||
|
||||
interface ILocation {
|
||||
__typename: 'Location';
|
||||
address: string | null;
|
||||
name: string | null;
|
||||
}
|
||||
|
||||
interface IEventOccurrence {
|
||||
__typename: 'EventOccurrence';
|
||||
id: string;
|
||||
event: ICalendarEvent;
|
||||
start: string;
|
||||
end: string;
|
||||
}
|
||||
|
||||
interface IEventMeta {
|
||||
__typename: 'EventMeta';
|
||||
tags: Array<string | null>;
|
||||
}
|
||||
|
||||
interface IUserRole {
|
||||
__typename: 'UserRole';
|
||||
user: IUser;
|
||||
type: any;
|
||||
}
|
||||
|
||||
interface IEventsQueryFilter {
|
||||
owner?: string | null;
|
||||
limit?: number | null;
|
||||
from?: any | null;
|
||||
to?: any | null;
|
||||
categories?: Array<any | null> | null;
|
||||
}
|
||||
|
||||
interface IOccurrencesQueryFilter {
|
||||
from?: any | null;
|
||||
to?: any | null;
|
||||
timeZone?: any | null;
|
||||
categories?: Array<any | null> | null;
|
||||
limit?: number | null;
|
||||
}
|
||||
|
||||
interface IMutation {
|
||||
__typename: 'Mutation';
|
||||
signup: Array<IError | null> | null;
|
||||
signin: IUserSession;
|
||||
requestInvite: boolean;
|
||||
grantRole: IUser;
|
||||
revokeRole: IUser;
|
||||
createEvent: ICalendarEvent | null;
|
||||
updateEvent: ICalendarEvent | null;
|
||||
}
|
||||
|
||||
interface ISignupOnMutationArguments {
|
||||
input: ISignupInput;
|
||||
}
|
||||
|
||||
interface ISigninOnMutationArguments {
|
||||
input: ISigninInput;
|
||||
}
|
||||
|
||||
interface IRequestInviteOnMutationArguments {
|
||||
input: IRequestInviteInput;
|
||||
}
|
||||
|
||||
interface IGrantRoleOnMutationArguments {
|
||||
input: IGrantRoleInput;
|
||||
}
|
||||
|
||||
interface IRevokeRoleOnMutationArguments {
|
||||
input: IGrantRoleInput;
|
||||
}
|
||||
|
||||
interface ICreateEventOnMutationArguments {
|
||||
input: ICreateEventInput;
|
||||
}
|
||||
|
||||
interface IUpdateEventOnMutationArguments {
|
||||
input: IUpdateEventInput;
|
||||
}
|
||||
|
||||
interface ISignupInput {
|
||||
email: string;
|
||||
username: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface IError {
|
||||
__typename: 'Error';
|
||||
path: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface ISigninInput {
|
||||
hash: string;
|
||||
}
|
||||
|
||||
interface IUserSession {
|
||||
__typename: 'UserSession';
|
||||
hash: string;
|
||||
user: IUser;
|
||||
ctime: any;
|
||||
isValid: boolean;
|
||||
}
|
||||
|
||||
interface IRequestInviteInput {
|
||||
email: string;
|
||||
}
|
||||
|
||||
interface IGrantRoleInput {
|
||||
userId: string;
|
||||
roleType: any;
|
||||
}
|
||||
|
||||
interface ICreateEventInput {
|
||||
time: IEventTimeInput;
|
||||
info: Array<IEventInformationInput | null>;
|
||||
location: IEventLocationInput;
|
||||
meta: IEventMetaInput;
|
||||
status: string;
|
||||
}
|
||||
|
||||
interface IEventTimeInput {
|
||||
timeZone: any;
|
||||
start: any;
|
||||
end: any;
|
||||
recurrence?: string | null;
|
||||
}
|
||||
|
||||
interface IEventInformationInput {
|
||||
language: string;
|
||||
title: string;
|
||||
description?: string | null;
|
||||
}
|
||||
|
||||
interface IEventLocationInput {
|
||||
address?: string | null;
|
||||
name?: string | null;
|
||||
}
|
||||
|
||||
interface IEventMetaInput {
|
||||
tags: Array<string | null>;
|
||||
}
|
||||
|
||||
interface IUpdateEventInput {
|
||||
id: string;
|
||||
time?: IEventTimeInput | null;
|
||||
info?: Array<IEventInformationInput> | null;
|
||||
location?: IEventLocationInput | null;
|
||||
meta?: IEventMetaInput | null;
|
||||
status?: string | null;
|
||||
}
|
||||
|
||||
interface IRevokeRoleInput {
|
||||
userId: string;
|
||||
roleType: any;
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:enable
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import SessionManager, { SessionAlreadyValidatedError } from "./SessionManager"
|
||||
import { User } from "./User.entity"
|
||||
import { PostOffice } from "../post_office"
|
||||
import {GQL} from "../../@types"
|
||||
import {Context} from "../@types/graphql-utils"
|
||||
import UserRole from "./UserRole.entity";
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ export class Event extends BaseEntity {
|
|||
@OneToMany(type => EventInformation, eventInfo => eventInfo.event, {
|
||||
cascade: true
|
||||
})
|
||||
info: Promise<EventInformation[]>
|
||||
infos: Promise<EventInformation[]>
|
||||
|
||||
@Column(type => EventTime)
|
||||
time: EventTime
|
||||
|
@ -138,7 +138,7 @@ export class EventInformation {
|
|||
title: string
|
||||
@Column({nullable: true})
|
||||
description: string
|
||||
@ManyToOne(type => Event, event => event.info)
|
||||
@ManyToOne(type => Event, event => event.infos)
|
||||
event: Event
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ describe("Recurring events", () => {
|
|||
info.title = "Weekly testing event"
|
||||
info.description = "This event takes place every monday at 2pm"
|
||||
|
||||
event.info = Promise.resolve([info])
|
||||
event.infos = Promise.resolve([info])
|
||||
event.owner = owner
|
||||
|
||||
// from 2019-03-04 to 2019-03-25 every monday
|
||||
|
|
|
@ -27,10 +27,11 @@ const createKiteflyingEvent = async () => {
|
|||
|
||||
const event = new Event()
|
||||
event.owner = owner
|
||||
event.info = {
|
||||
event.infos = [{
|
||||
language: "en",
|
||||
title: "Kite Flying Test Event",
|
||||
description: "Description for test event starting at 3pm"
|
||||
}
|
||||
}]
|
||||
event.time = {
|
||||
timeZone: "Europe/Madrid",
|
||||
start: "2019-10-10T13:00",
|
||||
|
@ -55,10 +56,11 @@ const createKinttingEvent = async () => {
|
|||
|
||||
const event = new Event()
|
||||
event.owner = owner
|
||||
event.info = {
|
||||
event.infos = [{
|
||||
language: "en",
|
||||
title: "Knitting Test Event",
|
||||
description: "Description for test event starting at 3pm"
|
||||
}
|
||||
}]
|
||||
event.time = {
|
||||
timeZone: "Europe/Madrid",
|
||||
start: "2019-10-10T14:00",
|
||||
|
|
|
@ -32,7 +32,7 @@ describe('Occurrences', async () => {
|
|||
await session.save()
|
||||
|
||||
const event = new Event()
|
||||
event.owner = owner
|
||||
event.owner = Promise.resolve(owner)
|
||||
|
||||
const info = new EventInformation()
|
||||
info.language = "en"
|
||||
|
@ -40,12 +40,12 @@ describe('Occurrences', async () => {
|
|||
info.description = "Event happening every monday at 13:00"
|
||||
info.event = event
|
||||
|
||||
event.info = Promise.resolve([info])
|
||||
event.infos = Promise.resolve([info])
|
||||
|
||||
event.time = {
|
||||
timeZone: "Europe/Madrid",
|
||||
start: new Date("2019-03-01T13:00Z"),
|
||||
end: new Date("2019-03-01T14:00Z"),
|
||||
start: "2019-03-01T13:00Z",
|
||||
end: "2019-03-01T13:00Z",
|
||||
recurrence: new RRule({
|
||||
freq: Frequency.WEEKLY,
|
||||
interval: 1,
|
||||
|
|
|
@ -4,7 +4,6 @@ import {
|
|||
EventOccurrence
|
||||
} from "../Calendar/Event.entity"
|
||||
import { Context, ResolverMap } from "../@types/graphql-utils"
|
||||
import {GQL} from "../../@types"
|
||||
import EventsService from './EventsService'
|
||||
import { equals } from 'ramda'
|
||||
|
||||
|
@ -47,9 +46,13 @@ const resolvers: ResolverMap = {
|
|||
owner: async (event: Event) => {
|
||||
return event.owner
|
||||
},
|
||||
info: async (event: Event) => {
|
||||
return event.info
|
||||
}
|
||||
infos: async (event: Event) => {
|
||||
return event.infos
|
||||
},
|
||||
info: async (event: Event, req: GQL.IInfoOnCalendarEventArguments) => {
|
||||
const infos = await event.infos
|
||||
return infos.find(info => info.language === req.lang)
|
||||
},
|
||||
},
|
||||
|
||||
EventOccurrence: {
|
||||
|
@ -72,8 +75,8 @@ const resolvers: ResolverMap = {
|
|||
}
|
||||
const event = new Event()
|
||||
event.owner = Promise.resolve(context.user)
|
||||
event.info = Promise.resolve(
|
||||
input.info.map(infoInput => {
|
||||
event.infos = Promise.resolve(
|
||||
input.infos.map(infoInput => {
|
||||
const eventInformation = new EventInformation()
|
||||
eventInformation.language = infoInput.language
|
||||
eventInformation.title = infoInput.title
|
||||
|
@ -119,9 +122,9 @@ const resolvers: ResolverMap = {
|
|||
await Promise.all(existingOccurrences.map(occ => EventOccurrence.delete(occ.id)))
|
||||
event.occurrences = Promise.resolve(event.getOccurrences())
|
||||
}
|
||||
if (input.info) {
|
||||
event.info = Promise.resolve(
|
||||
input.info.map(inputInfo => {
|
||||
if (input.infos) {
|
||||
event.infos = Promise.resolve(
|
||||
input.infos.map(inputInfo => {
|
||||
const newInfo = new EventInformation()
|
||||
Object.keys(inputInfo).forEach(inputInfoKey => {
|
||||
newInfo[inputInfoKey] = inputInfo[inputInfoKey]
|
||||
|
|
|
@ -43,7 +43,8 @@ input RequestInviteInput {
|
|||
type CalendarEvent {
|
||||
id: ID!
|
||||
owner: User!
|
||||
info: [EventInformation]!
|
||||
infos: [EventInformation]!
|
||||
info(lang: String!): EventInformation
|
||||
time: EventTime!
|
||||
status: EventStatus!
|
||||
location: Location!
|
||||
|
@ -137,7 +138,7 @@ input EventMetaInput {
|
|||
|
||||
input CreateEventInput {
|
||||
time: EventTimeInput!
|
||||
info: [EventInformationInput]!
|
||||
infos: [EventInformationInput]!
|
||||
location: EventLocationInput!
|
||||
meta: EventMetaInput!
|
||||
status: String!
|
||||
|
@ -146,7 +147,7 @@ input CreateEventInput {
|
|||
input UpdateEventInput {
|
||||
id: ID!
|
||||
time: EventTimeInput
|
||||
info: [EventInformationInput!]
|
||||
infos: [EventInformationInput!]
|
||||
location: EventLocationInput
|
||||
meta: EventMetaInput
|
||||
status: String
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"src"
|
||||
],
|
||||
"files": [
|
||||
"@types/index.d.ts"
|
||||
"@types/index.d.ts", "@types/graphql.d.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"**/*.spec.ts", "node_modules", "__tests__"
|
||||
|
|
Loading…
Reference in New Issue