Info and infos
This commit is contained in:
parent
db873e407e
commit
1ddf36fdb7
|
@ -25,8 +25,6 @@ release:
|
||||||
GOOGLE_APPLICATION_CREDENTIALS: /secret.json
|
GOOGLE_APPLICATION_CREDENTIALS: /secret.json
|
||||||
script:
|
script:
|
||||||
- cat $GCS_SERVICE_ACCOUNT_KEY > /secret.json
|
- 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
|
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination eu.gcr.io/qpa-staging-237606/api:$CI_COMMIT_TAG
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
|
|
|
@ -59,7 +59,8 @@ declare namespace GQL {
|
||||||
__typename: 'CalendarEvent';
|
__typename: 'CalendarEvent';
|
||||||
id: string;
|
id: string;
|
||||||
owner: IUser;
|
owner: IUser;
|
||||||
info: Array<IEventInformation | null>;
|
infos: Array<IEventInformation | null>;
|
||||||
|
info: IEventInformation | null;
|
||||||
time: IEventTime;
|
time: IEventTime;
|
||||||
status: any;
|
status: any;
|
||||||
location: ILocation;
|
location: ILocation;
|
||||||
|
@ -67,6 +68,10 @@ declare namespace GQL {
|
||||||
meta: IEventMeta | null;
|
meta: IEventMeta | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IInfoOnCalendarEventArguments {
|
||||||
|
lang: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface IEventInformation {
|
interface IEventInformation {
|
||||||
__typename: 'EventInformation';
|
__typename: 'EventInformation';
|
||||||
language: string;
|
language: string;
|
||||||
|
@ -198,7 +203,7 @@ declare namespace GQL {
|
||||||
|
|
||||||
interface ICreateEventInput {
|
interface ICreateEventInput {
|
||||||
time: IEventTimeInput;
|
time: IEventTimeInput;
|
||||||
info: Array<IEventInformationInput | null>;
|
infos: Array<IEventInformationInput | null>;
|
||||||
location: IEventLocationInput;
|
location: IEventLocationInput;
|
||||||
meta: IEventMetaInput;
|
meta: IEventMetaInput;
|
||||||
status: string;
|
status: string;
|
||||||
|
@ -230,7 +235,7 @@ declare namespace GQL {
|
||||||
interface IUpdateEventInput {
|
interface IUpdateEventInput {
|
||||||
id: string;
|
id: string;
|
||||||
time?: IEventTimeInput | null;
|
time?: IEventTimeInput | null;
|
||||||
info?: Array<IEventInformationInput> | null;
|
infos?: Array<IEventInformationInput> | null;
|
||||||
location?: IEventLocationInput | null;
|
location?: IEventLocationInput | null;
|
||||||
meta?: IEventMetaInput | null;
|
meta?: IEventMetaInput | null;
|
||||||
status?: string | null;
|
status?: string | null;
|
||||||
|
|
|
@ -1,245 +1 @@
|
||||||
export type EventStatus = 'confirmed' | 'canceled'
|
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 SessionManager, { SessionAlreadyValidatedError } from "./SessionManager"
|
||||||
import { User } from "./User.entity"
|
import { User } from "./User.entity"
|
||||||
import { PostOffice } from "../post_office"
|
import { PostOffice } from "../post_office"
|
||||||
import {GQL} from "../../@types"
|
|
||||||
import {Context} from "../@types/graphql-utils"
|
import {Context} from "../@types/graphql-utils"
|
||||||
import UserRole from "./UserRole.entity";
|
import UserRole from "./UserRole.entity";
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ export class Event extends BaseEntity {
|
||||||
@OneToMany(type => EventInformation, eventInfo => eventInfo.event, {
|
@OneToMany(type => EventInformation, eventInfo => eventInfo.event, {
|
||||||
cascade: true
|
cascade: true
|
||||||
})
|
})
|
||||||
info: Promise<EventInformation[]>
|
infos: Promise<EventInformation[]>
|
||||||
|
|
||||||
@Column(type => EventTime)
|
@Column(type => EventTime)
|
||||||
time: EventTime
|
time: EventTime
|
||||||
|
@ -138,7 +138,7 @@ export class EventInformation {
|
||||||
title: string
|
title: string
|
||||||
@Column({nullable: true})
|
@Column({nullable: true})
|
||||||
description: string
|
description: string
|
||||||
@ManyToOne(type => Event, event => event.info)
|
@ManyToOne(type => Event, event => event.infos)
|
||||||
event: Event
|
event: Event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ describe("Recurring events", () => {
|
||||||
info.title = "Weekly testing event"
|
info.title = "Weekly testing event"
|
||||||
info.description = "This event takes place every monday at 2pm"
|
info.description = "This event takes place every monday at 2pm"
|
||||||
|
|
||||||
event.info = Promise.resolve([info])
|
event.infos = Promise.resolve([info])
|
||||||
event.owner = owner
|
event.owner = owner
|
||||||
|
|
||||||
// from 2019-03-04 to 2019-03-25 every monday
|
// from 2019-03-04 to 2019-03-25 every monday
|
||||||
|
|
|
@ -27,10 +27,11 @@ const createKiteflyingEvent = async () => {
|
||||||
|
|
||||||
const event = new Event()
|
const event = new Event()
|
||||||
event.owner = owner
|
event.owner = owner
|
||||||
event.info = {
|
event.infos = [{
|
||||||
|
language: "en",
|
||||||
title: "Kite Flying Test Event",
|
title: "Kite Flying Test Event",
|
||||||
description: "Description for test event starting at 3pm"
|
description: "Description for test event starting at 3pm"
|
||||||
}
|
}]
|
||||||
event.time = {
|
event.time = {
|
||||||
timeZone: "Europe/Madrid",
|
timeZone: "Europe/Madrid",
|
||||||
start: "2019-10-10T13:00",
|
start: "2019-10-10T13:00",
|
||||||
|
@ -55,10 +56,11 @@ const createKinttingEvent = async () => {
|
||||||
|
|
||||||
const event = new Event()
|
const event = new Event()
|
||||||
event.owner = owner
|
event.owner = owner
|
||||||
event.info = {
|
event.infos = [{
|
||||||
|
language: "en",
|
||||||
title: "Knitting Test Event",
|
title: "Knitting Test Event",
|
||||||
description: "Description for test event starting at 3pm"
|
description: "Description for test event starting at 3pm"
|
||||||
}
|
}]
|
||||||
event.time = {
|
event.time = {
|
||||||
timeZone: "Europe/Madrid",
|
timeZone: "Europe/Madrid",
|
||||||
start: "2019-10-10T14:00",
|
start: "2019-10-10T14:00",
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe('Occurrences', async () => {
|
||||||
await session.save()
|
await session.save()
|
||||||
|
|
||||||
const event = new Event()
|
const event = new Event()
|
||||||
event.owner = owner
|
event.owner = Promise.resolve(owner)
|
||||||
|
|
||||||
const info = new EventInformation()
|
const info = new EventInformation()
|
||||||
info.language = "en"
|
info.language = "en"
|
||||||
|
@ -40,12 +40,12 @@ describe('Occurrences', async () => {
|
||||||
info.description = "Event happening every monday at 13:00"
|
info.description = "Event happening every monday at 13:00"
|
||||||
info.event = event
|
info.event = event
|
||||||
|
|
||||||
event.info = Promise.resolve([info])
|
event.infos = Promise.resolve([info])
|
||||||
|
|
||||||
event.time = {
|
event.time = {
|
||||||
timeZone: "Europe/Madrid",
|
timeZone: "Europe/Madrid",
|
||||||
start: new Date("2019-03-01T13:00Z"),
|
start: "2019-03-01T13:00Z",
|
||||||
end: new Date("2019-03-01T14:00Z"),
|
end: "2019-03-01T13:00Z",
|
||||||
recurrence: new RRule({
|
recurrence: new RRule({
|
||||||
freq: Frequency.WEEKLY,
|
freq: Frequency.WEEKLY,
|
||||||
interval: 1,
|
interval: 1,
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
EventOccurrence
|
EventOccurrence
|
||||||
} from "../Calendar/Event.entity"
|
} from "../Calendar/Event.entity"
|
||||||
import { Context, ResolverMap } from "../@types/graphql-utils"
|
import { Context, ResolverMap } from "../@types/graphql-utils"
|
||||||
import {GQL} from "../../@types"
|
|
||||||
import EventsService from './EventsService'
|
import EventsService from './EventsService'
|
||||||
import { equals } from 'ramda'
|
import { equals } from 'ramda'
|
||||||
|
|
||||||
|
@ -47,9 +46,13 @@ const resolvers: ResolverMap = {
|
||||||
owner: async (event: Event) => {
|
owner: async (event: Event) => {
|
||||||
return event.owner
|
return event.owner
|
||||||
},
|
},
|
||||||
info: async (event: Event) => {
|
infos: async (event: Event) => {
|
||||||
return event.info
|
return event.infos
|
||||||
}
|
},
|
||||||
|
info: async (event: Event, req: GQL.IInfoOnCalendarEventArguments) => {
|
||||||
|
const infos = await event.infos
|
||||||
|
return infos.find(info => info.language === req.lang)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
EventOccurrence: {
|
EventOccurrence: {
|
||||||
|
@ -72,8 +75,8 @@ const resolvers: ResolverMap = {
|
||||||
}
|
}
|
||||||
const event = new Event()
|
const event = new Event()
|
||||||
event.owner = Promise.resolve(context.user)
|
event.owner = Promise.resolve(context.user)
|
||||||
event.info = Promise.resolve(
|
event.infos = Promise.resolve(
|
||||||
input.info.map(infoInput => {
|
input.infos.map(infoInput => {
|
||||||
const eventInformation = new EventInformation()
|
const eventInformation = new EventInformation()
|
||||||
eventInformation.language = infoInput.language
|
eventInformation.language = infoInput.language
|
||||||
eventInformation.title = infoInput.title
|
eventInformation.title = infoInput.title
|
||||||
|
@ -119,9 +122,9 @@ const resolvers: ResolverMap = {
|
||||||
await Promise.all(existingOccurrences.map(occ => EventOccurrence.delete(occ.id)))
|
await Promise.all(existingOccurrences.map(occ => EventOccurrence.delete(occ.id)))
|
||||||
event.occurrences = Promise.resolve(event.getOccurrences())
|
event.occurrences = Promise.resolve(event.getOccurrences())
|
||||||
}
|
}
|
||||||
if (input.info) {
|
if (input.infos) {
|
||||||
event.info = Promise.resolve(
|
event.infos = Promise.resolve(
|
||||||
input.info.map(inputInfo => {
|
input.infos.map(inputInfo => {
|
||||||
const newInfo = new EventInformation()
|
const newInfo = new EventInformation()
|
||||||
Object.keys(inputInfo).forEach(inputInfoKey => {
|
Object.keys(inputInfo).forEach(inputInfoKey => {
|
||||||
newInfo[inputInfoKey] = inputInfo[inputInfoKey]
|
newInfo[inputInfoKey] = inputInfo[inputInfoKey]
|
||||||
|
|
|
@ -43,7 +43,8 @@ input RequestInviteInput {
|
||||||
type CalendarEvent {
|
type CalendarEvent {
|
||||||
id: ID!
|
id: ID!
|
||||||
owner: User!
|
owner: User!
|
||||||
info: [EventInformation]!
|
infos: [EventInformation]!
|
||||||
|
info(lang: String!): EventInformation
|
||||||
time: EventTime!
|
time: EventTime!
|
||||||
status: EventStatus!
|
status: EventStatus!
|
||||||
location: Location!
|
location: Location!
|
||||||
|
@ -137,7 +138,7 @@ input EventMetaInput {
|
||||||
|
|
||||||
input CreateEventInput {
|
input CreateEventInput {
|
||||||
time: EventTimeInput!
|
time: EventTimeInput!
|
||||||
info: [EventInformationInput]!
|
infos: [EventInformationInput]!
|
||||||
location: EventLocationInput!
|
location: EventLocationInput!
|
||||||
meta: EventMetaInput!
|
meta: EventMetaInput!
|
||||||
status: String!
|
status: String!
|
||||||
|
@ -146,7 +147,7 @@ input CreateEventInput {
|
||||||
input UpdateEventInput {
|
input UpdateEventInput {
|
||||||
id: ID!
|
id: ID!
|
||||||
time: EventTimeInput
|
time: EventTimeInput
|
||||||
info: [EventInformationInput!]
|
infos: [EventInformationInput!]
|
||||||
location: EventLocationInput
|
location: EventLocationInput
|
||||||
meta: EventMetaInput
|
meta: EventMetaInput
|
||||||
status: String
|
status: String
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
"src"
|
"src"
|
||||||
],
|
],
|
||||||
"files": [
|
"files": [
|
||||||
"@types/index.d.ts"
|
"@types/index.d.ts", "@types/graphql.d.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"**/*.spec.ts", "node_modules", "__tests__"
|
"**/*.spec.ts", "node_modules", "__tests__"
|
||||||
|
|
Loading…
Reference in New Issue