@sellout/models 0.0.56 → 0.0.57

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 (68) hide show
  1. package/.dist/graphql/fragments/event.fragment.js +7 -0
  2. package/.dist/graphql/fragments/event.fragment.js.map +1 -1
  3. package/.dist/graphql/mutations/createArtist.mutation.d.ts +2 -0
  4. package/.dist/graphql/mutations/createArtist.mutation.js +52 -0
  5. package/.dist/graphql/mutations/createArtist.mutation.js.map +1 -0
  6. package/.dist/graphql/mutations/createFee.mutation.d.ts +2 -0
  7. package/.dist/graphql/mutations/createFee.mutation.js +30 -0
  8. package/.dist/graphql/mutations/createFee.mutation.js.map +1 -0
  9. package/.dist/graphql/mutations/deleteFee.mutation.d.ts +2 -0
  10. package/.dist/graphql/mutations/deleteFee.mutation.js +13 -0
  11. package/.dist/graphql/mutations/deleteFee.mutation.js.map +1 -0
  12. package/.dist/graphql/mutations/updateArtist.mutation.d.ts +2 -0
  13. package/.dist/graphql/mutations/updateArtist.mutation.js +52 -0
  14. package/.dist/graphql/mutations/updateArtist.mutation.js.map +1 -0
  15. package/.dist/graphql/mutations/updateFee.mutation.d.ts +2 -0
  16. package/.dist/graphql/mutations/updateFee.mutation.js +30 -0
  17. package/.dist/graphql/mutations/updateFee.mutation.js.map +1 -0
  18. package/.dist/graphql/queries/artist.query.js +11 -2
  19. package/.dist/graphql/queries/artist.query.js.map +1 -1
  20. package/.dist/graphql/queries/artists.query.js +11 -10
  21. package/.dist/graphql/queries/artists.query.js.map +1 -1
  22. package/.dist/graphql/queries/fee.query.d.ts +2 -0
  23. package/.dist/graphql/queries/fee.query.js +30 -0
  24. package/.dist/graphql/queries/fee.query.js.map +1 -0
  25. package/.dist/interfaces/IArtist.d.ts +9 -0
  26. package/.dist/interfaces/IArtist.js +9 -0
  27. package/.dist/interfaces/IArtist.js.map +1 -1
  28. package/.dist/interfaces/IArtistPressKit.d.ts +1 -0
  29. package/.dist/interfaces/IEvent.js +1 -1
  30. package/.dist/interfaces/IEvent.js.map +1 -1
  31. package/.dist/interfaces/IEventPromotion.d.ts +12 -2
  32. package/.dist/interfaces/IEventPromotion.js +9 -3
  33. package/.dist/interfaces/IEventPromotion.js.map +1 -1
  34. package/.dist/interfaces/IFee.d.ts +5 -6
  35. package/.dist/interfaces/IFee.js +1 -1
  36. package/.dist/interfaces/IFee.js.map +1 -1
  37. package/.dist/interfaces/IPerformance.d.ts +1 -1
  38. package/.dist/schemas/Artist.d.ts +12 -0
  39. package/.dist/schemas/Artist.js +12 -0
  40. package/.dist/schemas/Artist.js.map +1 -1
  41. package/.dist/schemas/Event.d.ts +31 -0
  42. package/.dist/schemas/Event.js +39 -8
  43. package/.dist/schemas/Event.js.map +1 -1
  44. package/.dist/sellout-proto.js +236 -38
  45. package/.dist/utils/EventUtil.d.ts +4 -0
  46. package/.dist/utils/EventUtil.js +39 -36
  47. package/.dist/utils/EventUtil.js.map +1 -1
  48. package/package.json +4 -4
  49. package/src/graphql/fragments/event.fragment.ts +7 -0
  50. package/src/graphql/mutations/createArtist.mutation.ts +48 -0
  51. package/src/graphql/mutations/createFee.mutation.ts +26 -0
  52. package/src/graphql/mutations/deleteFee.mutation.ts +9 -0
  53. package/src/graphql/mutations/updateArtist.mutation.ts +48 -0
  54. package/src/graphql/mutations/updateFee.mutation.ts +25 -0
  55. package/src/graphql/queries/artist.query.ts +11 -2
  56. package/src/graphql/queries/artists.query.ts +12 -10
  57. package/src/graphql/queries/fee.query.ts +26 -0
  58. package/src/interfaces/IArtist.ts +11 -1
  59. package/src/interfaces/IArtistPressKit.ts +1 -0
  60. package/src/interfaces/IEvent.ts +1 -1
  61. package/src/interfaces/IEventPromotion.ts +13 -2
  62. package/src/interfaces/IFee.ts +5 -5
  63. package/src/interfaces/IPerformance.ts +1 -1
  64. package/src/proto/artist.proto +9 -7
  65. package/src/proto/event.proto +11 -4
  66. package/src/schemas/Artist.ts +12 -0
  67. package/src/schemas/Event.ts +39 -8
  68. package/src/utils/EventUtil.ts +96 -44
@@ -95,10 +95,12 @@ message EventUpgrade {
95
95
  int32 remainingQty = 4;
96
96
  int32 purchaseLimit = 5;
97
97
  bool complimentary = 6;
98
- repeated string ticketTypeIds = 7;
99
- string imageUrl = 8;
100
- string description = 9;
101
- bool visible = 10;
98
+ string complimentaryWith = 7;
99
+ int32 complimentaryQty = 8;
100
+ repeated string ticketTypeIds = 9;
101
+ string imageUrl = 10;
102
+ string description = 11;
103
+ bool visible = 12;
102
104
  }
103
105
 
104
106
  message EventPromotion {
@@ -110,6 +112,11 @@ message EventPromotion {
110
112
  repeated string ticketTypeIds = 5;
111
113
  repeated string upgradeIds = 6;
112
114
  bool active = 7;
115
+ int32 startsAt = 8;
116
+ int32 endsAt = 9;
117
+ int32 useLimit = 10;
118
+ string discountType = 11;
119
+ int32 discountValue = 12;
113
120
  }
114
121
 
115
122
  message EventCustomFields {
@@ -2,6 +2,10 @@ import shortid from 'shortid';
2
2
  import Metrics from './Metrics';
3
3
 
4
4
  const ArtistPressKit = {
5
+ _id: {
6
+ type: String,
7
+ default: shortid.generate,
8
+ },
5
9
  title: {
6
10
  type: String,
7
11
  required: false,
@@ -31,6 +35,10 @@ const ArtistPressKit = {
31
35
  };
32
36
 
33
37
  const ArtistContact = {
38
+ _id: {
39
+ type: String,
40
+ default: shortid.generate,
41
+ },
34
42
  firstName: {
35
43
  type: String,
36
44
  required: false,
@@ -58,6 +66,10 @@ const ArtistContact = {
58
66
  };
59
67
 
60
68
  const SocialLink = {
69
+ _id: {
70
+ type: String,
71
+ default: shortid.generate,
72
+ },
61
73
  platform: {
62
74
  type: String,
63
75
  required: false,
@@ -1,5 +1,6 @@
1
1
  import shortid from 'shortid';
2
2
  import { EventAgeEnum, SendQRCodeEnum, EventProcessAsEnum } from '../interfaces/IEvent';
3
+ import { UpgradeTypeComplimentaryWithEnum } from "../interfaces/IEventUpgrade";
3
4
  import Address from './Address';
4
5
  import Metrics from './Metrics';
5
6
 
@@ -59,35 +60,55 @@ const EventPromotion = {
59
60
  },
60
61
  type: {
61
62
  type: String,
62
- required: true
63
+ required: true,
63
64
  },
64
65
  totalQty: {
65
66
  type: Number,
66
- required: true
67
+ required: true,
67
68
  },
68
69
  remainingQty: {
69
70
  type: Number,
70
- required: true
71
+ required: true,
71
72
  },
72
73
  ticketTypeIds: [
73
74
  {
74
75
  type: String,
75
76
  required: true,
76
- default: []
77
- }
77
+ default: [],
78
+ },
78
79
  ],
79
80
  upgradeIds: [
80
81
  {
81
82
  type: String,
82
83
  required: true,
83
- default: []
84
- }
84
+ default: [],
85
+ },
85
86
  ],
86
87
  active: {
87
88
  type: Boolean,
88
89
  required: true,
89
90
  default: true,
90
- }
91
+ },
92
+ startsAt: {
93
+ type: Number,
94
+ required: true,
95
+ },
96
+ endsAt: {
97
+ type: Number,
98
+ required: true,
99
+ },
100
+ useLimit: {
101
+ type: Number,
102
+ required: true,
103
+ },
104
+ discountType: {
105
+ type: String,
106
+ required: true,
107
+ },
108
+ discountValue: {
109
+ type: String,
110
+ required: true,
111
+ },
91
112
  };
92
113
 
93
114
  // I'm not sure why this is here or if we need it
@@ -161,6 +182,16 @@ const EventUpgrade = {
161
182
  required: true,
162
183
  default: false,
163
184
  },
185
+ complimentaryWith: {
186
+ type: String,
187
+ required: false,
188
+ default: UpgradeTypeComplimentaryWithEnum.Order,
189
+ },
190
+ complimentaryQty: {
191
+ type: String,
192
+ required: false,
193
+ default: 1,
194
+ },
164
195
  ticketTypeIds: [
165
196
  {
166
197
  type: String,
@@ -2,69 +2,86 @@ import * as Time from '@sellout/utils/.dist/time';
2
2
 
3
3
  export default {
4
4
  hasBeenAnnouced(event): boolean {
5
- const { schedule: { announceAt } } = event;
5
+ const {
6
+ schedule: { announceAt },
7
+ } = event;
6
8
  const now = Time.now();
7
9
  return announceAt < now;
8
- },
10
+ },
9
11
  isAnnounced(event): boolean {
10
- const { schedule: { announceAt, ticketsAt } } = event;
12
+ const {
13
+ schedule: { announceAt, ticketsAt },
14
+ } = event;
11
15
  const now = Time.now();
12
- return announceAt < now && now < ticketsAt;
16
+ return announceAt < now && now < ticketsAt;
13
17
  },
14
18
  isOnSale(event): boolean {
15
- const { schedule: { ticketsAt, ticketsEndAt } } = event;
19
+ const {
20
+ schedule: { ticketsAt, ticketsEndAt },
21
+ } = event;
16
22
  const now = Time.now();
17
23
  return ticketsAt < now && now < ticketsEndAt;
18
24
  },
19
25
  isInProgress(event): boolean {
20
- const { schedule: { startsAt, endsAt } } = event;
26
+ const {
27
+ schedule: { startsAt, endsAt },
28
+ } = event;
21
29
  const now = Time.now();
22
30
  return startsAt < now && now < endsAt;
23
31
  },
24
32
  saleHasEnded(event): boolean {
25
- const { schedule: { ticketsEndAt } } = event;
33
+ const {
34
+ schedule: { ticketsEndAt },
35
+ } = event;
26
36
  const now = Time.now();
27
37
  return ticketsEndAt < now;
28
38
  },
29
39
  hasEnded(event): boolean {
30
- const { schedule: { endsAt } } = event;
40
+ const {
41
+ schedule: { endsAt },
42
+ } = event;
31
43
  const now = Time.now();
32
44
  return endsAt < now;
33
45
  },
34
- hasActivePreSalePromotions(event): boolean{
35
- return event.promotions
36
- .filter(promotion => promotion.type === 'Pre-Sale Code')
37
- .filter(promotion => promotion.active)
38
- .length > 0;
46
+ hasActivePreSalePromotions(event): boolean {
47
+ return (
48
+ event.promotions
49
+ .filter((promotion) => promotion.type === "Pre-Sale Code")
50
+ .filter((promotion) => promotion.active).length > 0
51
+ );
39
52
  },
40
53
  qrCodeEmailAt(event): number {
41
- const { performances: [performance] } = event;
42
- const { schedule: { doorsAt, startsAt } } = performance;
54
+ const {
55
+ performances: [performance],
56
+ } = event;
57
+ const {
58
+ schedule: { doorsAt, startsAt },
59
+ } = performance;
43
60
 
44
- if(event.sendQRCode === 'Upon Order') {
61
+ if (event.sendQRCode === "Upon Order") {
45
62
  return Time.now();
46
63
  }
47
64
 
48
- if(event.sendQRCode === 'Two Weeks Before Show') {
65
+ if (event.sendQRCode === "Two Weeks Before Show") {
49
66
  const TWO_WEEKS = 14 * 24 * 60 * 60;
50
67
  return startsAt - TWO_WEEKS;
51
68
  }
52
69
 
53
- return doorsAt - (600);
70
+ return doorsAt - 600;
54
71
  },
55
72
  shouldSendOrderReceipt(event): boolean {
56
73
  const now = Time.now();
57
74
  const qrCodeEmailAt = this.qrCodeEmailAt(event);
58
75
 
59
- // Never send a receipt if we are
76
+ // Never send a receipt if we are
60
77
  // send a qr code upon order
61
- if (event.sendQRCode === 'Upon Order') {
78
+ if (event.sendQRCode === "Upon Order") {
62
79
  return false;
63
80
  }
64
81
 
65
82
  // Only send a receipt if QR codes for
66
83
  // the event haven't already gone out
67
- if(qrCodeEmailAt > now) {
84
+ if (qrCodeEmailAt > now) {
68
85
  return true;
69
86
  }
70
87
 
@@ -75,59 +92,61 @@ export default {
75
92
  ****************************************************************************************/
76
93
  venueIds(event): string[] {
77
94
  let venueIds = [event.venueId];
78
- event.performances.forEach(performance => {
79
- venueIds = venueIds.concat(performance.venueStageId)
95
+ event.performances.forEach((performance) => {
96
+ venueIds = venueIds.concat(performance.venueStageId);
80
97
  });
81
98
  venueIds = [...new Set(venueIds)];
82
- venueIds = venueIds.filter(v => !!v);
99
+ venueIds = venueIds.filter((v) => !!v);
83
100
  return venueIds;
84
101
  },
85
102
  seatingId(event): string {
86
- return event._id.replace('_', 'SAMH');
103
+ return event._id.replace("_", "SAMH");
87
104
  },
88
105
  /****************************************************************************************
89
106
  Artist
90
107
  ****************************************************************************************/
91
108
  artistIds(event): string[] {
92
109
  let artistIds = [];
93
- event.performances.forEach(performance => {
110
+ event.performances.forEach((performance) => {
94
111
  artistIds = artistIds
95
112
  .concat(performance.headliningArtistIds)
96
113
  .concat(performance.openingArtistIds);
97
- });
114
+ });
98
115
  artistIds = [...new Set(artistIds)];
99
- artistIds = artistIds.filter(a => !!a);
116
+ artistIds = artistIds.filter((a) => !!a);
100
117
  return artistIds;
101
118
  },
102
119
  headliningArtistIds(event): string[] {
103
120
  let artistIds = [];
104
- event.performances.forEach(performance => {
105
- artistIds = artistIds
106
- .concat(performance.headliningArtistIds)
121
+ event.performances.forEach((performance) => {
122
+ artistIds = artistIds.concat(performance.headliningArtistIds);
107
123
  });
108
124
  artistIds = [...new Set(artistIds)];
109
- artistIds = artistIds.filter(a => !!a);
125
+ artistIds = artistIds.filter((a) => !!a);
110
126
  return artistIds;
111
127
  },
112
128
  openingArtistIds(event): string[] {
113
129
  let artistIds = [];
114
- event.performances.forEach(performance => {
115
- artistIds = artistIds
116
- .concat(performance.openingArtistIds);
130
+ event.performances.forEach((performance) => {
131
+ artistIds = artistIds.concat(performance.openingArtistIds);
117
132
  });
118
133
  artistIds = [...new Set(artistIds)];
119
- artistIds = artistIds.filter(a => !!a);
134
+ artistIds = artistIds.filter((a) => !!a);
120
135
  return artistIds;
121
136
  },
122
137
  /****************************************************************************************
123
138
  Tickets
124
139
  ****************************************************************************************/
125
140
  ticketType(event, ticketTypeId): any {
126
- return event.ticketTypes.find(ticketType => ticketType._id === ticketTypeId);
141
+ return event.ticketTypes.find(
142
+ (ticketType) => ticketType._id === ticketTypeId
143
+ );
127
144
  },
128
145
  remainingTicketQty(event, ticketTypeId: string | null = null): number {
129
146
  if (ticketTypeId) {
130
- let ticketType = event.ticketTypes.find(ticketType => ticketType._id === ticketTypeId);
147
+ let ticketType = event.ticketTypes.find(
148
+ (ticketType) => ticketType._id === ticketTypeId
149
+ );
131
150
  if (!ticketType) return 0;
132
151
  else return ticketType.remainingQty;
133
152
  } else {
@@ -149,20 +168,24 @@ export default {
149
168
  }, {});
150
169
  },
151
170
  getCurrentTierId(event, ticketTypeId: string): string {
152
- const ticketType = event.ticketTypes.find(t => t._id.toString() === ticketTypeId);
171
+ const ticketType = event.ticketTypes.find(
172
+ (t) => t._id.toString() === ticketTypeId
173
+ );
153
174
  const now = Time.now();
154
- const tier = ticketType.tiers.find(tier => tier.startsAt < now && now < tier.endsAt);
175
+ const tier = ticketType.tiers.find(
176
+ (tier) => tier.startsAt < now && now < tier.endsAt
177
+ );
155
178
  return tier._id;
156
- },
179
+ },
157
180
  /****************************************************************************************
158
181
  Upgrades
159
182
  ****************************************************************************************/
160
183
  upgrade(event, upgradeId): any {
161
- return event.upgrades.find(upgrades => upgrades._id === upgradeId);
184
+ return event.upgrades.find((upgrades) => upgrades._id === upgradeId);
162
185
  },
163
186
  remainingUpgradeQty(event, upgradeId: string | null = null): number {
164
187
  if (upgradeId) {
165
- let upgrade = event.upgrades.find(upgrade => upgrade._id === upgradeId);
188
+ let upgrade = event.upgrades.find((upgrade) => upgrade._id === upgradeId);
166
189
  if (!upgrade) return 0;
167
190
  else return upgrade.remainingQty;
168
191
  } else {
@@ -183,4 +206,33 @@ export default {
183
206
  return cur;
184
207
  }, {});
185
208
  },
186
- }
209
+ /****************************************************************************************
210
+ Promotion
211
+ ****************************************************************************************/
212
+ promotion(event, promotionId): any {
213
+ return event.promotions.find((promotions) => promotions._id === promotionId);
214
+ },
215
+ // remainingUpgradeQty(event, upgradeId: string | null = null): number {
216
+ // if (upgradeId) {
217
+ // let upgrade = event.upgrades.find((upgrade) => upgrade._id === upgradeId);
218
+ // if (!upgrade) return 0;
219
+ // else return upgrade.remainingQty;
220
+ // } else {
221
+ // return event.upgrades.reduce((cur, next) => {
222
+ // return cur + next.remainingQty;
223
+ // }, 0);
224
+ // }
225
+ // },
226
+ // remainingQtyByUpgrades(event): object {
227
+ // return event.upgrades.reduce((cur, upgrade) => {
228
+ // cur[upgrade._id] = this.remainingUpgradeQty(event, upgrade._id);
229
+ // return cur;
230
+ // }, {});
231
+ // },
232
+ // purchaseLimitByUpgrades(event): object {
233
+ // return event.upgrades.reduce((cur, upgrade) => {
234
+ // cur[upgrade._id] = upgrade.purchaseLimit;
235
+ // return cur;
236
+ // }, {});
237
+ // },
238
+ };