@sellout/models 0.0.430 → 0.0.431
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.
- package/.dist/graphql/fragments/event.fragment.d.ts +1 -0
- package/.dist/graphql/fragments/event.fragment.js +16 -0
- package/.dist/graphql/fragments/event.fragment.js.map +1 -1
- package/.dist/graphql/mutations/checkInGuestListEntry.mutation.d.ts +2 -0
- package/.dist/graphql/mutations/checkInGuestListEntry.mutation.js +23 -0
- package/.dist/graphql/mutations/checkInGuestListEntry.mutation.js.map +1 -0
- package/.dist/graphql/mutations/createGuestListEntry.mutation.d.ts +2 -0
- package/.dist/graphql/mutations/createGuestListEntry.mutation.js +23 -0
- package/.dist/graphql/mutations/createGuestListEntry.mutation.js.map +1 -0
- package/.dist/graphql/mutations/deleteGuestListEntry.mutation.d.ts +2 -0
- package/.dist/graphql/mutations/deleteGuestListEntry.mutation.js +23 -0
- package/.dist/graphql/mutations/deleteGuestListEntry.mutation.js.map +1 -0
- package/.dist/graphql/queries/event.query.js +2 -0
- package/.dist/graphql/queries/event.query.js.map +1 -1
- package/.dist/graphql/queries/eventGuestList.query.d.ts +2 -0
- package/.dist/graphql/queries/eventGuestList.query.js +40 -0
- package/.dist/graphql/queries/eventGuestList.query.js.map +1 -0
- package/.dist/interfaces/IEvent.d.ts +2 -0
- package/.dist/interfaces/IEvent.js.map +1 -1
- package/.dist/interfaces/IGuestListCheckIn.d.ts +6 -0
- package/.dist/interfaces/IGuestListCheckIn.js +3 -0
- package/.dist/interfaces/IGuestListCheckIn.js.map +1 -0
- package/.dist/interfaces/IGuestListEntry.d.ts +9 -0
- package/.dist/interfaces/IGuestListEntry.js +3 -0
- package/.dist/interfaces/IGuestListEntry.js.map +1 -0
- package/.dist/schemas/Event.d.ts +46 -0
- package/.dist/schemas/Event.js +48 -0
- package/.dist/schemas/Event.js.map +1 -1
- package/.dist/sellout-proto.js +7110 -3411
- package/.dist/utils/EventUtil.d.ts +9 -0
- package/.dist/utils/EventUtil.js +59 -0
- package/.dist/utils/EventUtil.js.map +1 -1
- package/package.json +3 -3
- package/src/graphql/fragments/event.fragment.ts +17 -0
- package/src/graphql/mutations/checkInGuestListEntry.mutation.ts +22 -0
- package/src/graphql/mutations/createGuestListEntry.mutation.ts +22 -0
- package/src/graphql/mutations/deleteGuestListEntry.mutation.ts +22 -0
- package/src/graphql/queries/event.query.ts +2 -0
- package/src/graphql/queries/eventGuestList.query.ts +36 -0
- package/src/interfaces/IEvent.ts +2 -0
- package/src/interfaces/IGuestListCheckIn.ts +6 -0
- package/src/interfaces/IGuestListEntry.ts +10 -0
- package/src/proto/event.proto +96 -0
- package/src/schemas/Event.ts +50 -0
- package/src/utils/EventUtil.ts +92 -0
package/src/utils/EventUtil.ts
CHANGED
|
@@ -16,6 +16,8 @@ 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";
|
|
19
21
|
import IEmailHolders from "../interfaces/IEmailHolders";
|
|
20
22
|
|
|
21
23
|
export default {
|
|
@@ -241,6 +243,96 @@ export default {
|
|
|
241
243
|
return event?.holds.find((ticketHold) => ticketHold._id === ticketHoldId);
|
|
242
244
|
},
|
|
243
245
|
|
|
246
|
+
/****************************************************************************************
|
|
247
|
+
* Guest List
|
|
248
|
+
****************************************************************************************/
|
|
249
|
+
|
|
250
|
+
plainGuestEntry(value: any): any {
|
|
251
|
+
return value && typeof value.toObject === "function"
|
|
252
|
+
? value.toObject()
|
|
253
|
+
: value;
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
guestListDays(event: IEvent): number[] {
|
|
257
|
+
const scheduled = (event?.performances?.[0]?.schedule ?? [])
|
|
258
|
+
.map((day) => day?.startsAt)
|
|
259
|
+
.filter((startsAt): startsAt is number => Boolean(startsAt));
|
|
260
|
+
|
|
261
|
+
if (scheduled.length) {
|
|
262
|
+
return Array.from(new Set(scheduled)).sort((a, b) => a - b);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return event?.schedule?.startsAt ? [event.schedule.startsAt] : [];
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
syncGuestListDays(event: IEvent): IGuestListEntry[] {
|
|
269
|
+
const guestList = event?.guestList ?? [];
|
|
270
|
+
|
|
271
|
+
if (!guestList.length) return guestList;
|
|
272
|
+
|
|
273
|
+
const days = this.guestListDays(event);
|
|
274
|
+
|
|
275
|
+
if (!days.length) return guestList;
|
|
276
|
+
|
|
277
|
+
const isCurrentDay = new Set(days);
|
|
278
|
+
|
|
279
|
+
return guestList.map((hydrated) => {
|
|
280
|
+
const entry = this.plainGuestEntry(hydrated);
|
|
281
|
+
const existing: IGuestListCheckIn[] = (entry?.checkIns ?? []).map(
|
|
282
|
+
(checkIn) => this.plainGuestEntry(checkIn)
|
|
283
|
+
);
|
|
284
|
+
const byDay = new Map(existing.map((checkIn) => [checkIn.startsAt, checkIn]));
|
|
285
|
+
|
|
286
|
+
const current: IGuestListCheckIn[] = days.map(
|
|
287
|
+
(startsAt) =>
|
|
288
|
+
byDay.get(startsAt) ?? {
|
|
289
|
+
startsAt,
|
|
290
|
+
checkedIn: false,
|
|
291
|
+
checkedInAt: null,
|
|
292
|
+
checkedInBy: null,
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
const attended = existing.filter(
|
|
297
|
+
(checkIn) => checkIn.checkedIn && !isCurrentDay.has(checkIn.startsAt)
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
...entry,
|
|
302
|
+
checkIns: [...current, ...attended].sort(
|
|
303
|
+
(a, b) => a.startsAt - b.startsAt
|
|
304
|
+
),
|
|
305
|
+
};
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
shiftGuestListDays(event: IEvent, timeDelta: number): IGuestListEntry[] {
|
|
310
|
+
return (event?.guestList ?? []).map((hydrated) => {
|
|
311
|
+
const entry = this.plainGuestEntry(hydrated);
|
|
312
|
+
return {
|
|
313
|
+
...entry,
|
|
314
|
+
checkIns: (entry?.checkIns ?? []).map((checkIn) => ({
|
|
315
|
+
...this.plainGuestEntry(checkIn),
|
|
316
|
+
startsAt: checkIn.startsAt + timeDelta,
|
|
317
|
+
})),
|
|
318
|
+
};
|
|
319
|
+
});
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
currentGuestListDay(
|
|
323
|
+
event: IEvent,
|
|
324
|
+
timezone: string,
|
|
325
|
+
at: number = Time.now()
|
|
326
|
+
): number | null {
|
|
327
|
+
const day = (seconds: number) => Time.format(seconds, "YYYY-MM-DD", timezone);
|
|
328
|
+
const today = day(at);
|
|
329
|
+
|
|
330
|
+
return (
|
|
331
|
+
this.guestListDays(event).find((startsAt) => day(startsAt) === today) ??
|
|
332
|
+
null
|
|
333
|
+
);
|
|
334
|
+
},
|
|
335
|
+
|
|
244
336
|
/****************************************************************************************
|
|
245
337
|
* Tickets
|
|
246
338
|
****************************************************************************************/
|