@sellout/models 0.0.430 → 0.0.432

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/.dist/graphql/fragments/event.fragment.d.ts +1 -0
  2. package/.dist/graphql/fragments/event.fragment.js +16 -0
  3. package/.dist/graphql/fragments/event.fragment.js.map +1 -1
  4. package/.dist/graphql/mutations/checkInGuestListEntry.mutation.d.ts +2 -0
  5. package/.dist/graphql/mutations/checkInGuestListEntry.mutation.js +23 -0
  6. package/.dist/graphql/mutations/checkInGuestListEntry.mutation.js.map +1 -0
  7. package/.dist/graphql/mutations/createGuestListEntry.mutation.d.ts +2 -0
  8. package/.dist/graphql/mutations/createGuestListEntry.mutation.js +23 -0
  9. package/.dist/graphql/mutations/createGuestListEntry.mutation.js.map +1 -0
  10. package/.dist/graphql/mutations/deleteGuestListEntry.mutation.d.ts +2 -0
  11. package/.dist/graphql/mutations/deleteGuestListEntry.mutation.js +23 -0
  12. package/.dist/graphql/mutations/deleteGuestListEntry.mutation.js.map +1 -0
  13. package/.dist/graphql/queries/event.query.js +2 -0
  14. package/.dist/graphql/queries/event.query.js.map +1 -1
  15. package/.dist/graphql/queries/eventGuestList.query.d.ts +2 -0
  16. package/.dist/graphql/queries/eventGuestList.query.js +40 -0
  17. package/.dist/graphql/queries/eventGuestList.query.js.map +1 -0
  18. package/.dist/interfaces/IEvent.d.ts +2 -0
  19. package/.dist/interfaces/IEvent.js.map +1 -1
  20. package/.dist/interfaces/IGuestListCheckIn.d.ts +6 -0
  21. package/.dist/interfaces/IGuestListCheckIn.js +3 -0
  22. package/.dist/interfaces/IGuestListCheckIn.js.map +1 -0
  23. package/.dist/interfaces/IGuestListEntry.d.ts +9 -0
  24. package/.dist/interfaces/IGuestListEntry.js +3 -0
  25. package/.dist/interfaces/IGuestListEntry.js.map +1 -0
  26. package/.dist/interfaces/IGuestListSession.d.ts +4 -0
  27. package/.dist/interfaces/IGuestListSession.js +3 -0
  28. package/.dist/interfaces/IGuestListSession.js.map +1 -0
  29. package/.dist/schemas/Event.d.ts +46 -0
  30. package/.dist/schemas/Event.js +48 -0
  31. package/.dist/schemas/Event.js.map +1 -1
  32. package/.dist/sellout-proto.js +7110 -3411
  33. package/.dist/utils/EventUtil.d.ts +11 -0
  34. package/.dist/utils/EventUtil.js +95 -0
  35. package/.dist/utils/EventUtil.js.map +1 -1
  36. package/package.json +3 -3
  37. package/src/graphql/fragments/event.fragment.ts +17 -0
  38. package/src/graphql/mutations/checkInGuestListEntry.mutation.ts +22 -0
  39. package/src/graphql/mutations/createGuestListEntry.mutation.ts +22 -0
  40. package/src/graphql/mutations/deleteGuestListEntry.mutation.ts +22 -0
  41. package/src/graphql/queries/event.query.ts +2 -0
  42. package/src/graphql/queries/eventGuestList.query.ts +36 -0
  43. package/src/interfaces/IEvent.ts +2 -0
  44. package/src/interfaces/IGuestListCheckIn.ts +6 -0
  45. package/src/interfaces/IGuestListEntry.ts +10 -0
  46. package/src/interfaces/IGuestListSession.ts +4 -0
  47. package/src/proto/event.proto +96 -0
  48. package/src/schemas/Event.ts +50 -0
  49. package/src/utils/EventUtil.ts +132 -0
@@ -370,6 +370,55 @@ const TicketHold = {
370
370
 
371
371
  };
372
372
 
373
+ const GuestListCheckIn = {
374
+ _id: false,
375
+ startsAt: {
376
+ type: Number,
377
+ required: true,
378
+ },
379
+ checkedIn: {
380
+ type: Boolean,
381
+ required: true,
382
+ default: false,
383
+ },
384
+ checkedInAt: {
385
+ type: Number,
386
+ required: false,
387
+ default: null,
388
+ },
389
+ checkedInBy: {
390
+ type: String,
391
+ required: false,
392
+ default: null,
393
+ },
394
+ };
395
+
396
+ const GuestListEntry = {
397
+ _id: {
398
+ type: String,
399
+ default: shortid.generate,
400
+ },
401
+ firstName: {
402
+ type: String,
403
+ required: true,
404
+ trim: true,
405
+ },
406
+ lastName: {
407
+ type: String,
408
+ required: true,
409
+ trim: true,
410
+ },
411
+ createdAt: {
412
+ type: Number,
413
+ required: true,
414
+ },
415
+ createdBy: {
416
+ type: String,
417
+ required: false,
418
+ },
419
+ checkIns: [GuestListCheckIn],
420
+ };
421
+
373
422
  const TicketTier = {
374
423
  _id: {
375
424
  type: String,
@@ -618,6 +667,7 @@ export default {
618
667
  performances: [Performance],
619
668
  ticketTypes: [TicketType],
620
669
  holds: [TicketHold],
670
+ guestList: [GuestListEntry],
621
671
  upgrades: [EventUpgrade],
622
672
  promotions: [EventPromotion],
623
673
  customFields: [EventCustomFields],
@@ -16,6 +16,9 @@ import { DropDownEnum } from "../enums/DropDownEnum";
16
16
  import { SendQRCodeEnum } from "../interfaces/IEvent";
17
17
  import IEventSchedule from "../interfaces/IEventSchedule";
18
18
  import ITicketHold from "../interfaces/ITicketHold";
19
+ import IGuestListEntry from "../interfaces/IGuestListEntry";
20
+ import IGuestListCheckIn from "../interfaces/IGuestListCheckIn";
21
+ import IGuestListSession from "../interfaces/IGuestListSession";
19
22
  import IEmailHolders from "../interfaces/IEmailHolders";
20
23
 
21
24
  export default {
@@ -241,6 +244,135 @@ export default {
241
244
  return event?.holds.find((ticketHold) => ticketHold._id === ticketHoldId);
242
245
  },
243
246
 
247
+ /****************************************************************************************
248
+ * Guest List
249
+ ****************************************************************************************/
250
+
251
+ plainGuestEntry(value: any): any {
252
+ return value && typeof value.toObject === "function"
253
+ ? value.toObject()
254
+ : value;
255
+ },
256
+
257
+ guestListSessions(event: IEvent): IGuestListSession[] {
258
+ const scheduled = (event?.performances?.[0]?.schedule ?? [])
259
+ .filter((day) => Boolean(day?.startsAt))
260
+ .map((day) => ({
261
+ startsAt: day.startsAt as number,
262
+ endsAt: day?.endsAt ?? null,
263
+ }));
264
+
265
+ if (scheduled.length) {
266
+ const byStart = new Map<number, number | null>();
267
+
268
+ scheduled.forEach(({ startsAt, endsAt }) => {
269
+ if (!byStart.has(startsAt)) {
270
+ byStart.set(startsAt, endsAt);
271
+ return;
272
+ }
273
+
274
+ const current = byStart.get(startsAt) ?? null;
275
+ if (current === null || endsAt === null) return;
276
+ byStart.set(startsAt, Math.max(current, endsAt));
277
+ });
278
+
279
+ return Array.from(byStart.entries())
280
+ .map(([startsAt, endsAt]) => ({ startsAt, endsAt }))
281
+ .sort((a, b) => a.startsAt - b.startsAt);
282
+ }
283
+
284
+ return event?.schedule?.startsAt
285
+ ? [
286
+ {
287
+ startsAt: event.schedule.startsAt,
288
+ endsAt: event?.schedule?.endsAt ?? null,
289
+ },
290
+ ]
291
+ : [];
292
+ },
293
+
294
+ guestListDays(event: IEvent): number[] {
295
+ return this.guestListSessions(event).map((session) => session.startsAt);
296
+ },
297
+
298
+ syncGuestListDays(event: IEvent): IGuestListEntry[] {
299
+ const guestList = event?.guestList ?? [];
300
+
301
+ if (!guestList.length) return guestList;
302
+
303
+ const days = this.guestListDays(event);
304
+
305
+ if (!days.length) return guestList;
306
+
307
+ const isCurrentDay = new Set(days);
308
+
309
+ return guestList.map((hydrated) => {
310
+ const entry = this.plainGuestEntry(hydrated);
311
+ const existing: IGuestListCheckIn[] = (entry?.checkIns ?? []).map(
312
+ (checkIn) => this.plainGuestEntry(checkIn)
313
+ );
314
+ const byDay = new Map(existing.map((checkIn) => [checkIn.startsAt, checkIn]));
315
+
316
+ const current: IGuestListCheckIn[] = days.map(
317
+ (startsAt) =>
318
+ byDay.get(startsAt) ?? {
319
+ startsAt,
320
+ checkedIn: false,
321
+ checkedInAt: null,
322
+ checkedInBy: null,
323
+ }
324
+ );
325
+
326
+ const attended = existing.filter(
327
+ (checkIn) => checkIn.checkedIn && !isCurrentDay.has(checkIn.startsAt)
328
+ );
329
+
330
+ return {
331
+ ...entry,
332
+ checkIns: [...current, ...attended].sort(
333
+ (a, b) => a.startsAt - b.startsAt
334
+ ),
335
+ };
336
+ });
337
+ },
338
+
339
+ shiftGuestListDays(event: IEvent, timeDelta: number): IGuestListEntry[] {
340
+ return (event?.guestList ?? []).map((hydrated) => {
341
+ const entry = this.plainGuestEntry(hydrated);
342
+ return {
343
+ ...entry,
344
+ checkIns: (entry?.checkIns ?? []).map((checkIn) => ({
345
+ ...this.plainGuestEntry(checkIn),
346
+ startsAt: checkIn.startsAt + timeDelta,
347
+ })),
348
+ };
349
+ });
350
+ },
351
+
352
+ currentGuestListDay(
353
+ event: IEvent,
354
+ timezone: string,
355
+ at: number = Time.now()
356
+ ): number | null {
357
+ const day = (seconds: number) => Time.format(seconds, "YYYY-MM-DD", timezone);
358
+ const today = day(at);
359
+ const sessions = this.guestListSessions(event);
360
+ const running = sessions.find(
361
+ (session) =>
362
+ session.endsAt !== null &&
363
+ session.startsAt <= at &&
364
+ at < session.endsAt
365
+ );
366
+
367
+ if (running) return running.startsAt;
368
+
369
+ const scheduledToday = sessions.find(
370
+ (session) => day(session.startsAt) === today
371
+ );
372
+
373
+ return scheduledToday ? scheduledToday.startsAt : null;
374
+ },
375
+
244
376
  /****************************************************************************************
245
377
  * Tickets
246
378
  ****************************************************************************************/