-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshowrunner.ts
executable file
·539 lines (472 loc) · 15.2 KB
/
showrunner.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
export default class Client {
conferences: conferences.ServiceClient
constructor(environment: string = "production", token?: string) {
const base = new BaseClient(environment, token)
this.conferences = new conferences.ServiceClient(base)
}
}
export namespace conferences {
/**
* AddPaperParams defines the inputs used by the AddPaper API method
*/
export interface AddPaperParams {
Paper: Paper
}
/**
* AddPaperResponse defines the output returned by the AddPaper API method
*/
export interface AddPaperResponse {
PaperID: number
}
/**
* Conference is an instance like GopherCon 2020
*/
export interface Conference {
ID: number
Name: string
Slug: string
StartDate: string
EndDate: string
Venue: Venue
}
/**
* ConferenceSlot holds information for any sellable/giftable slot we have in the event for
* a Talk or any other activity that requires admission.
* store: "interface"
*/
export interface ConferenceSlot {
ID: number
Name: string
Description: string
Cost: number
Capacity: number
StartDate: string
EndDate: string
/**
* DependsOn means that these two Slots need to be acquired together, user must either buy
* both Slots or pre-own one of the one it depends on.
*/
DependsOn: number
/**
* PurchaseableFrom indicates when this item is on sale, for instance early bird tickets are the first
* ones to go on sale.
*/
PurchaseableFrom: string
/**
* PuchaseableUntil indicates when this item stops being on sale, for instance early bird tickets can
* no loger be purchased N months before event.
*/
PurchaseableUntil: string
/**
* AvailableToPublic indicates is this is something that will appear on the tickets purchase page (ie, we can
* issue sponsor tickets and those cannot be bought individually)
*/
AvailableToPublic: boolean
Location: Location
ConferenceID: number
}
/**
* ContactRole defines the type that encapsulates the different contact roles
*/
export type ContactRole = number
/**
* CreateJobParams defines the inputs used by the CreateJob API method
*/
export interface CreateJobParams {
Job: Job
}
/**
* CreateJobResponse defines the output returned by the CreateJob API method
*/
export interface CreateJobResponse {
Job: Job
}
/**
* DeleteJobParams defines the input used by
* the DeleteJob API method
*/
export interface DeleteJobParams {
JobID: number
}
/**
* Event is a brand like GopherCon
*/
export interface Event {
ID: number
Name: string
Slug: string
Conferences: Conference[]
}
/**
* GetAllParams defines the inputs used by the GetAll API method
*/
export interface GetAllParams {
}
/**
* GetAllResponse defines the output returned by the GetAll API method
*/
export interface GetAllResponse {
Events: Event[]
}
/**
* GetConferenceSlotsParams defines the inputs used by the GetConferenceSlots API method
*/
export interface GetConferenceSlotsParams {
ConferenceID: number
}
/**
* GetConferenceSlotsResponse defines the output returned by the GetConferenceSlots API method
*/
export interface GetConferenceSlotsResponse {
ConferenceSlots: ConferenceSlot[]
}
/**
* GetConferenceSponsorsParams defines the inputs used by the GetConferenceSponsors API method
*/
export interface GetConferenceSponsorsParams {
ConferenceID: number
}
/**
* GetConferenceSponsorsResponse defines the output returned by the GetConferenceSponsors API method
*/
export interface GetConferenceSponsorsResponse {
Sponsors: Sponsor[]
}
/**
* GetCurrentByEventParams defines the inputs used by the GetCurrentByEvent API method
*/
export interface GetCurrentByEventParams {
EventID: number
}
/**
* GetCurrentByEventResponse defines the output returned by the GetCurrentByEvent API method
*/
export interface GetCurrentByEventResponse {
Event: Event
}
/**
* GetJobParams defines the inputs used by the GetJob API method
*/
export interface GetJobParams {
JobID: number
}
/**
* GetJobResponse defines the output returned by the GetJob API method
*/
export interface GetJobResponse {
Job: Job
}
/**
* GetPaperParams defines the inputs used by the GetPaper API method
*/
export interface GetPaperParams {
PaperID: number
}
/**
* GetPaperResponse defines the output returned by the GetPaper API method
*/
export interface GetPaperResponse {
Paper: Paper
}
/**
* Job represents the necessary information for a Job
*/
export interface Job {
ID: number
CompanyName: string
Title: string
Description: string
Link: string
Discord: string
Rank: number
Approved: boolean
}
/**
* ListApprovedJobsResponse defines the output returned
* by the ListApprovedJobs API method
*/
export interface ListApprovedJobsResponse {
Jobs: Job[]
}
/**
* ListJobsResponse defines the output returned
* by the ListJobs API method
*/
export interface ListJobsResponse {
Jobs: Job[]
}
/**
* ListPapersParams defines the inputs used by the ListPapers API method
*/
export interface ListPapersParams {
ConferenceID: number
}
/**
* ListPapersResponse defines the output returned by the ListPapers API method
*/
export interface ListPapersResponse {
Papers: Paper[]
}
/**
* Location defines a location for a venue, such as a room or event space
*/
export interface Location {
ID: number
Name: string
Description: string
Address: string
Directions: string
GoogleMapsURL: string
Capacity: number
VenueID: number
}
/**
* Paper holds information about a paper submitted to a conference
*/
export interface Paper {
ID: number
UserID: number
ConferenceID: number
Title: string
ElevatorPitch: string
Description: string
Notes: string
}
/**
* Sponsor defines a conference sponsor, such as Google
*/
export interface Sponsor {
ID: number
Name: string
Address: string
Website: string
SponsorshipLevel: SponsorshipLevel
Contacts: SponsorContactInformation[]
ConferenceID: number
}
/**
* SponsorContactInformation defines a contact
* and their information for a sponsor
*/
export interface SponsorContactInformation {
ID: number
Name: string
Role: ContactRole
Email: string
Phone: string
}
/**
* SponsorshipLevel defines the type that encapsulates the different sponsorship levels
*/
export type SponsorshipLevel = number
/**
* UpdateApproveJobParams defines the inputs used by the
* UpdateApproveJob API method
*/
export interface UpdateApproveJobParams {
JobID: number
ApprovedStatus: boolean
}
/**
* UpdateApproveJobResponse defines the output the returned
* by the ApproveJob API method
*/
export interface UpdateApproveJobResponse {
Job: Job
}
/**
* UpdateJobParams defines the input used by
* the UpdateJob API method
*/
export interface UpdateJobParams {
Job: Job
}
/**
* UpdateJobResponse defines the output returned
* by the UpdateJob API method
*/
export interface UpdateJobResponse {
Job: Job
}
/**
* UpdatePaperParams defines the inputs used by the GetPaper API method
*/
export interface UpdatePaperParams {
Paper: Paper
}
/**
* UpdatePaperResponse defines the output received by the UpdatePaper API method
*/
export interface UpdatePaperResponse {
Paper: Paper
}
/**
* UpdateSponsorContactParams defines the inputs used by the UpdateSponsorContactParams API method
*/
export interface UpdateSponsorContactParams {
SponsorContactInformation: SponsorContactInformation
}
/**
* UpdateSponsorContactResponse defines the output returned by the UpdateSponsorContactResponse API method
*/
export interface UpdateSponsorContactResponse {
}
/**
* Venue defines a venue that hosts a conference, such as DisneyWorld
*/
export interface Venue {
ID: number
Name: string
Description: string
Address: string
Directions: string
GoogleMapsURL: string
Capacity: number
}
export class ServiceClient {
private baseClient: BaseClient
constructor(baseClient: BaseClient) {
this.baseClient = baseClient
}
/**
* AddPaper inserts a paper into the paper_submissions table
*/
public AddPaper(params: AddPaperParams): Promise<AddPaperResponse> {
return this.baseClient.do<AddPaperResponse>("conferences.AddPaper", params)
}
/**
* CreateJob inserts a job into the job_board table
*/
public CreateJob(params: CreateJobParams): Promise<CreateJobResponse> {
return this.baseClient.do<CreateJobResponse>("conferences.CreateJob", params)
}
/**
* DeleteJob deletes a job by id from the
* job_board table
*/
public DeleteJob(params: DeleteJobParams): Promise<void> {
return this.baseClient.doVoid("conferences.DeleteJob", params)
}
/**
* GetAll retrieves all conferences and events
*/
public GetAll(params: GetAllParams): Promise<GetAllResponse> {
return this.baseClient.do<GetAllResponse>("conferences.GetAll", params)
}
/**
* GetConferenceSlots retrieves all event slots for a specific event id
*/
public GetConferenceSlots(params: GetConferenceSlotsParams): Promise<GetConferenceSlotsResponse> {
return this.baseClient.do<GetConferenceSlotsResponse>("conferences.GetConferenceSlots", params)
}
/**
* GetConferenceSponsors retrieves the sponsors for a specific conference
*/
public GetConferenceSponsors(params: GetConferenceSponsorsParams): Promise<GetConferenceSponsorsResponse> {
return this.baseClient.do<GetConferenceSponsorsResponse>("conferences.GetConferenceSponsors", params)
}
/**
* GetCurrentByEvent retrieves the current conference and event information for a specific event
*/
public GetCurrentByEvent(params: GetCurrentByEventParams): Promise<GetCurrentByEventResponse> {
return this.baseClient.do<GetCurrentByEventResponse>("conferences.GetCurrentByEvent", params)
}
/**
* GetJob retrieves a job posting by JobID
*/
public GetJob(params: GetJobParams): Promise<GetJobResponse> {
return this.baseClient.do<GetJobResponse>("conferences.GetJob", params)
}
/**
* GetPaper retrieves information for a specific paper id
*/
public GetPaper(params: GetPaperParams): Promise<GetPaperResponse> {
return this.baseClient.do<GetPaperResponse>("conferences.GetPaper", params)
}
/**
* ListApprovedJobs retrieves all jobs (approved or not) from
* the job_board table
*/
public ListApprovedJobs(): Promise<ListApprovedJobsResponse> {
return this.baseClient.do<ListApprovedJobsResponse>("conferences.ListApprovedJobs")
}
/**
* ListJobs retrieves all jobs (approved or not) from
* the job_board table
*/
public ListJobs(): Promise<ListJobsResponse> {
return this.baseClient.do<ListJobsResponse>("conferences.ListJobs")
}
/**
* ListPapers retrieves all the papers submitted for a specific conference
*/
public ListPapers(params: ListPapersParams): Promise<ListPapersResponse> {
return this.baseClient.do<ListPapersResponse>("conferences.ListPapers", params)
}
/**
* UpdateApproveJob sets the approval of a job to true
* or false depending on input
*/
public UpdateApproveJob(params: UpdateApproveJobParams): Promise<UpdateApproveJobResponse> {
return this.baseClient.do<UpdateApproveJobResponse>("conferences.UpdateApproveJob", params)
}
/**
* UpdateJob updates a job entry based on id in the
* job_board table
*/
public UpdateJob(params: UpdateJobParams): Promise<UpdateJobResponse> {
return this.baseClient.do<UpdateJobResponse>("conferences.UpdateJob", params)
}
/**
* UpdatePaper updates a paper submission for a specific paper id
*/
public UpdatePaper(params: UpdatePaperParams): Promise<UpdatePaperResponse> {
return this.baseClient.do<UpdatePaperResponse>("conferences.UpdatePaper", params)
}
/**
* UpdateSponsorContact retrieves all conferences and events
*/
public UpdateSponsorContact(params: UpdateSponsorContactParams): Promise<UpdateSponsorContactResponse> {
return this.baseClient.do<UpdateSponsorContactResponse>("conferences.UpdateSponsorContact", params)
}
}
}
class BaseClient {
baseURL: string
headers: {[key: string]: string}
constructor(environment: string, token?: string) {
this.headers = {"Content-Type": "application/json"}
if (token !== undefined) {
this.headers["Authorization"] = "Bearer " + token
}
if (environment === "dev") {
this.baseURL = "http://localhost:4060/"
} else {
this.baseURL = `https://showrunner-46b2.encoreapi.com/${environment}/`
}
}
public async do<T>(endpoint: string, req?: any): Promise<T> {
let response = await fetch(this.baseURL + endpoint, {
method: "POST",
headers: this.headers,
body: JSON.stringify(req || {})
})
if (!response.ok) {
let body = await response.text()
throw new Error("request failed: " + body)
}
return <T>(await response.json())
}
public async doVoid(endpoint: string, req?: any): Promise<void> {
let response = await fetch(this.baseURL + endpoint, {
method: "POST",
headers: this.headers,
body: JSON.stringify(req || {})
})
if (!response.ok) {
let body = await response.text()
throw new Error("request failed: " + body)
}
await response.text()
}
}