@chevre/domain 20.2.0-alpha.9 → 20.2.0

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 (135) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +116 -0
  3. package/example/src/chevre/attendIfNotAttended.ts +22 -0
  4. package/example/src/chevre/createManyEventsIfNotExist.ts +209 -0
  5. package/example/src/chevre/findByOrderNumberAndReservationId.ts +20 -0
  6. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +27 -0
  7. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  8. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
  9. package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +1 -1
  10. package/example/src/chevre/migrateProjectSubscription.ts +51 -0
  11. package/example/src/chevre/ownershipInfosCsv2peopleJson.ts +2 -2
  12. package/example/src/chevre/processReserve.ts +2 -0
  13. package/example/src/chevre/searchEventIds.ts +24 -0
  14. package/example/src/chevre/searchEventTicketOffers.ts +5 -4
  15. package/example/src/chevre/searchEvents.ts +20 -41
  16. package/example/src/chevre/searchOffersByCatalog.ts +27 -0
  17. package/example/src/chevre/updateTransaction.ts +38 -0
  18. package/lib/chevre/factory/event.d.ts +2 -0
  19. package/lib/chevre/factory/event.js +2 -0
  20. package/lib/chevre/repo/action.d.ts +77 -1
  21. package/lib/chevre/repo/action.js +249 -6
  22. package/lib/chevre/repo/aggregation.d.ts +38 -0
  23. package/lib/chevre/repo/aggregation.js +68 -0
  24. package/lib/chevre/repo/assetTransaction.d.ts +32 -0
  25. package/lib/chevre/repo/assetTransaction.js +148 -0
  26. package/lib/chevre/repo/code.d.ts +13 -16
  27. package/lib/chevre/repo/code.js +33 -19
  28. package/lib/chevre/repo/creativeWork.js +13 -12
  29. package/lib/chevre/repo/event.d.ts +64 -17
  30. package/lib/chevre/repo/event.js +456 -156
  31. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  32. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  33. package/lib/chevre/repo/mongoose/model/event.js +4 -3
  34. package/lib/chevre/repo/mongoose/model/offer.js +2 -1
  35. package/lib/chevre/repo/mongoose/model/project.js +7 -1
  36. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  37. package/lib/chevre/repo/offer.d.ts +10 -0
  38. package/lib/chevre/repo/offer.js +47 -16
  39. package/lib/chevre/repo/order.d.ts +6 -0
  40. package/lib/chevre/repo/order.js +53 -7
  41. package/lib/chevre/repo/place.d.ts +26 -1
  42. package/lib/chevre/repo/place.js +216 -12
  43. package/lib/chevre/repo/product.d.ts +1 -0
  44. package/lib/chevre/repo/product.js +5 -0
  45. package/lib/chevre/repo/project.d.ts +7 -1
  46. package/lib/chevre/repo/project.js +15 -6
  47. package/lib/chevre/repo/reservation.d.ts +7 -8
  48. package/lib/chevre/repo/reservation.js +181 -76
  49. package/lib/chevre/repo/task.d.ts +31 -4
  50. package/lib/chevre/repo/task.js +146 -33
  51. package/lib/chevre/repo/transaction.d.ts +57 -5
  52. package/lib/chevre/repo/transaction.js +228 -34
  53. package/lib/chevre/repo/trip.js +33 -27
  54. package/lib/chevre/repository.d.ts +3 -0
  55. package/lib/chevre/repository.js +5 -1
  56. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +72 -60
  57. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  58. package/lib/chevre/service/aggregation/system.d.ts +100 -0
  59. package/lib/chevre/service/aggregation/system.js +409 -0
  60. package/lib/chevre/service/aggregation.d.ts +2 -0
  61. package/lib/chevre/service/aggregation.js +3 -1
  62. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  63. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +0 -3
  64. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  65. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  66. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  67. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  68. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  69. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  70. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  71. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  72. package/lib/chevre/service/assetTransaction/reserve.js +120 -94
  73. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  74. package/lib/chevre/service/code.d.ts +2 -3
  75. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  76. package/lib/chevre/service/delivery/product/factory.js +9 -3
  77. package/lib/chevre/service/event.d.ts +2 -4
  78. package/lib/chevre/service/event.js +35 -14
  79. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  80. package/lib/chevre/service/offer/event/authorize.js +33 -87
  81. package/lib/chevre/service/offer/event/cancel.js +0 -1
  82. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  83. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +14 -7
  84. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +95 -53
  85. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  86. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  87. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  88. package/lib/chevre/service/offer/factory.js +10 -3
  89. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  90. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  91. package/lib/chevre/service/offer/product.d.ts +1 -0
  92. package/lib/chevre/service/offer/product.js +7 -2
  93. package/lib/chevre/service/offer.d.ts +13 -2
  94. package/lib/chevre/service/offer.js +68 -46
  95. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +23 -26
  96. package/lib/chevre/service/order/returnOrder.js +6 -4
  97. package/lib/chevre/service/order/sendOrder.js +4 -2
  98. package/lib/chevre/service/payment/any.d.ts +9 -0
  99. package/lib/chevre/service/payment/any.js +16 -1
  100. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  101. package/lib/chevre/service/payment/movieTicket.js +8 -2
  102. package/lib/chevre/service/product.js +5 -3
  103. package/lib/chevre/service/report/telemetry.js +1 -1
  104. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  105. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  106. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  107. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  108. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  109. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +32 -35
  110. package/lib/chevre/service/reserve/useReservation.d.ts +0 -3
  111. package/lib/chevre/service/reserve/useReservation.js +58 -33
  112. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  113. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  114. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  115. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  116. package/lib/chevre/service/task/returnPayTransaction.js +10 -4
  117. package/lib/chevre/service/task.js +6 -9
  118. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  119. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +1 -1
  120. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -6
  121. package/lib/chevre/service/transaction/placeOrder.js +5 -3
  122. package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
  123. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -2
  124. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -11
  125. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +1 -1
  126. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +3 -8
  127. package/lib/chevre/service/transaction/placeOrderInProgress.js +92 -107
  128. package/lib/chevre/service/transaction/returnOrder.js +8 -6
  129. package/lib/chevre/settings.d.ts +2 -0
  130. package/lib/chevre/settings.js +20 -12
  131. package/package.json +3 -3
  132. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  133. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
  134. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.d.ts +0 -6
  135. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.js +0 -65
@@ -20,11 +20,26 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  return t;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.MongoRepository = void 0;
23
+ exports.MongoRepository = exports.PROJECTION_MINIMIZED_EVENT = void 0;
24
24
  const uniqid = require("uniqid");
25
25
  const factory = require("../factory");
26
26
  const event_1 = require("./mongoose/model/event");
27
- const USE_DEPRECATED_EVENT_SEARCH_CONDITIONS = process.env.USE_DEPRECATED_EVENT_SEARCH_CONDITIONS === '1';
27
+ exports.PROJECTION_MINIMIZED_EVENT = {
28
+ project: 1,
29
+ _id: 1,
30
+ typeOf: 1,
31
+ additionalProperty: 1,
32
+ name: 1,
33
+ doorTime: 1,
34
+ endDate: 1,
35
+ eventStatus: 1,
36
+ location: 1,
37
+ startDate: 1,
38
+ superEvent: 1,
39
+ offers: 1,
40
+ coaInfo: 1,
41
+ identifier: 1
42
+ };
28
43
  /**
29
44
  * イベントリポジトリ
30
45
  */
@@ -34,7 +49,7 @@ class MongoRepository {
34
49
  }
35
50
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
36
51
  static CREATE_MONGO_CONDITIONS(conditions) {
37
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
52
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _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;
38
53
  const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
39
54
  const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
40
55
  if (typeof projectIdEq === 'string') {
@@ -131,8 +146,96 @@ class MongoRepository {
131
146
  let params;
132
147
  switch (conditions.typeOf) {
133
148
  case factory.eventType.Event:
134
- // no op
135
- // params = conditions;
149
+ params = conditions;
150
+ // tslint:disable-next-line:no-single-line-block-comment
151
+ /* istanbul ignore else */
152
+ if (params.offers !== undefined) {
153
+ const itemOfferedIdIn4event = (_k = (_j = params.offers.itemOffered) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$in;
154
+ if (Array.isArray(itemOfferedIdIn4event)) {
155
+ andConditions.push({
156
+ 'offers.itemOffered.id': {
157
+ $exists: true,
158
+ $in: itemOfferedIdIn4event
159
+ }
160
+ });
161
+ }
162
+ // tslint:disable-next-line:no-single-line-block-comment
163
+ /* istanbul ignore else */
164
+ if (params.offers.itemOffered !== undefined) {
165
+ // tslint:disable-next-line:no-single-line-block-comment
166
+ /* istanbul ignore else */
167
+ if (params.offers.itemOffered.serviceOutput !== undefined) {
168
+ // tslint:disable-next-line:no-single-line-block-comment
169
+ /* istanbul ignore else */
170
+ if (params.offers.itemOffered.serviceOutput.reservedTicket !== undefined) {
171
+ // tslint:disable-next-line:no-single-line-block-comment
172
+ /* istanbul ignore else */
173
+ if (params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat !== undefined) {
174
+ // tslint:disable-next-line:no-single-line-block-comment
175
+ /* istanbul ignore else */
176
+ if (Array.isArray(params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOfs)) {
177
+ andConditions.push({
178
+ 'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
179
+ $exists: true,
180
+ $in: params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOfs
181
+ }
182
+ });
183
+ }
184
+ }
185
+ }
186
+ }
187
+ // tslint:disable-next-line:no-single-line-block-comment
188
+ /* istanbul ignore else */
189
+ if (params.offers.itemOffered.serviceType !== undefined) {
190
+ // tslint:disable-next-line:no-single-line-block-comment
191
+ /* istanbul ignore else */
192
+ if (Array.isArray(params.offers.itemOffered.serviceType.ids)) {
193
+ andConditions.push({
194
+ 'offers.itemOffered.serviceType.id': {
195
+ $exists: true,
196
+ $in: params.offers.itemOffered.serviceType.ids
197
+ }
198
+ });
199
+ }
200
+ }
201
+ }
202
+ }
203
+ const sellerMakesOfferElemMatch4event = (_o = (_m = (_l = params.offers) === null || _l === void 0 ? void 0 : _l.seller) === null || _m === void 0 ? void 0 : _m.makesOffer) === null || _o === void 0 ? void 0 : _o.$elemMatch;
204
+ if (typeof ((_p = sellerMakesOfferElemMatch4event === null || sellerMakesOfferElemMatch4event === void 0 ? void 0 : sellerMakesOfferElemMatch4event['availableAtOrFrom.id']) === null || _p === void 0 ? void 0 : _p.$eq) === 'string') {
205
+ andConditions.push({
206
+ 'offers.seller.makesOffer': {
207
+ $exists: true,
208
+ $elemMatch: sellerMakesOfferElemMatch4event
209
+ }
210
+ });
211
+ }
212
+ const reservationForIdentifierEq = (_u = (_t = (_s = (_r = (_q = params.offers) === null || _q === void 0 ? void 0 : _q.itemOffered) === null || _r === void 0 ? void 0 : _r.serviceOutput) === null || _s === void 0 ? void 0 : _s.reservationFor) === null || _t === void 0 ? void 0 : _t.identifier) === null || _u === void 0 ? void 0 : _u.$eq;
213
+ if (typeof reservationForIdentifierEq === 'string') {
214
+ andConditions.push({
215
+ 'offers.itemOffered.serviceOutput.reservationFor.identifier': {
216
+ $exists: true,
217
+ $eq: reservationForIdentifierEq
218
+ }
219
+ });
220
+ }
221
+ const reservationForArrivalBusStopBranchCodeEq = (_0 = (_z = (_y = (_x = (_w = (_v = params.offers) === null || _v === void 0 ? void 0 : _v.itemOffered) === null || _w === void 0 ? void 0 : _w.serviceOutput) === null || _x === void 0 ? void 0 : _x.reservationFor) === null || _y === void 0 ? void 0 : _y.arrivalBusStop) === null || _z === void 0 ? void 0 : _z.branchCode) === null || _0 === void 0 ? void 0 : _0.$eq;
222
+ if (typeof reservationForArrivalBusStopBranchCodeEq === 'string') {
223
+ andConditions.push({
224
+ 'offers.itemOffered.serviceOutput.reservationFor.arrivalBusStop.branchCode': {
225
+ $exists: true,
226
+ $eq: reservationForArrivalBusStopBranchCodeEq
227
+ }
228
+ });
229
+ }
230
+ const reservationForDepartureBusStopBranchCodeEq = (_6 = (_5 = (_4 = (_3 = (_2 = (_1 = params.offers) === null || _1 === void 0 ? void 0 : _1.itemOffered) === null || _2 === void 0 ? void 0 : _2.serviceOutput) === null || _3 === void 0 ? void 0 : _3.reservationFor) === null || _4 === void 0 ? void 0 : _4.departureBusStop) === null || _5 === void 0 ? void 0 : _5.branchCode) === null || _6 === void 0 ? void 0 : _6.$eq;
231
+ if (typeof reservationForDepartureBusStopBranchCodeEq === 'string') {
232
+ andConditions.push({
233
+ 'offers.itemOffered.serviceOutput.reservationFor.departureBusStop.branchCode': {
234
+ $exists: true,
235
+ $eq: reservationForDepartureBusStopBranchCodeEq
236
+ }
237
+ });
238
+ }
136
239
  break;
137
240
  case factory.eventType.ScreeningEvent:
138
241
  params = conditions;
@@ -158,7 +261,7 @@ class MongoRepository {
158
261
  }
159
262
  // tslint:disable-next-line:no-single-line-block-comment
160
263
  /* istanbul ignore else */
161
- const superEventLocationIdEq = (_l = (_k = (_j = params.superEvent) === null || _j === void 0 ? void 0 : _j.location) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
264
+ const superEventLocationIdEq = (_9 = (_8 = (_7 = params.superEvent) === null || _7 === void 0 ? void 0 : _7.location) === null || _8 === void 0 ? void 0 : _8.id) === null || _9 === void 0 ? void 0 : _9.$eq;
162
265
  if (typeof superEventLocationIdEq === 'string') {
163
266
  andConditions.push({
164
267
  'superEvent.location.id': {
@@ -201,103 +304,35 @@ class MongoRepository {
201
304
  });
202
305
  }
203
306
  }
204
- // tslint:disable-next-line:no-single-line-block-comment
205
- /* istanbul ignore else */
206
- if (params.offers !== undefined) {
207
- if (USE_DEPRECATED_EVENT_SEARCH_CONDITIONS) {
208
- // tslint:disable-next-line:no-single-line-block-comment
209
- /* istanbul ignore else */
210
- if (params.offers.availableFrom instanceof Date) {
211
- andConditions.push({
212
- 'offers.availabilityEnds': {
213
- $exists: true,
214
- $gte: params.offers.availableFrom
215
- }
216
- });
217
- }
218
- // tslint:disable-next-line:no-single-line-block-comment
219
- /* istanbul ignore else */
220
- if (params.offers.availableThrough instanceof Date) {
221
- andConditions.push({
222
- 'offers.availabilityStarts': {
223
- $exists: true,
224
- $lte: params.offers.availableThrough
225
- }
226
- });
227
- }
228
- // tslint:disable-next-line:no-single-line-block-comment
229
- /* istanbul ignore else */
230
- if (params.offers.validFrom instanceof Date) {
231
- andConditions.push({
232
- 'offers.validThrough': {
233
- $exists: true,
234
- $gte: params.offers.validFrom
235
- }
236
- });
237
- }
238
- // tslint:disable-next-line:no-single-line-block-comment
239
- /* istanbul ignore else */
240
- if (params.offers.validThrough instanceof Date) {
241
- andConditions.push({
242
- 'offers.validFrom': {
243
- $exists: true,
244
- $lte: params.offers.validThrough
245
- }
246
- });
307
+ const itemOfferedIdIn = (_12 = (_11 = (_10 = params.offers) === null || _10 === void 0 ? void 0 : _10.itemOffered) === null || _11 === void 0 ? void 0 : _11.id) === null || _12 === void 0 ? void 0 : _12.$in;
308
+ if (Array.isArray(itemOfferedIdIn)) {
309
+ andConditions.push({
310
+ 'offers.itemOffered.id': {
311
+ $exists: true,
312
+ $in: itemOfferedIdIn
247
313
  }
248
- }
249
- const itemOfferedIdIn = (_o = (_m = params.offers.itemOffered) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$in;
250
- if (Array.isArray(itemOfferedIdIn)) {
251
- andConditions.push({
252
- 'offers.itemOffered.id': {
253
- $exists: true,
254
- $in: itemOfferedIdIn
255
- }
256
- });
257
- }
258
- // tslint:disable-next-line:no-single-line-block-comment
259
- /* istanbul ignore else */
260
- if (params.offers.itemOffered !== undefined) {
261
- // tslint:disable-next-line:no-single-line-block-comment
262
- /* istanbul ignore else */
263
- if (params.offers.itemOffered.serviceOutput !== undefined) {
264
- // tslint:disable-next-line:no-single-line-block-comment
265
- /* istanbul ignore else */
266
- if (params.offers.itemOffered.serviceOutput.reservedTicket !== undefined) {
267
- // tslint:disable-next-line:no-single-line-block-comment
268
- /* istanbul ignore else */
269
- if (params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat !== undefined) {
270
- // tslint:disable-next-line:no-single-line-block-comment
271
- /* istanbul ignore else */
272
- if (Array.isArray(params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOfs)) {
273
- andConditions.push({
274
- 'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
275
- $exists: true,
276
- $in: params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOfs
277
- }
278
- });
279
- }
280
- }
281
- }
314
+ });
315
+ }
316
+ const itemOfferedTicketedSeatTypeOfIn = (_17 = (_16 = (_15 = (_14 = (_13 = params.offers) === null || _13 === void 0 ? void 0 : _13.itemOffered) === null || _14 === void 0 ? void 0 : _14.serviceOutput) === null || _15 === void 0 ? void 0 : _15.reservedTicket) === null || _16 === void 0 ? void 0 : _16.ticketedSeat) === null || _17 === void 0 ? void 0 : _17.typeOfs;
317
+ if (Array.isArray(itemOfferedTicketedSeatTypeOfIn)) {
318
+ andConditions.push({
319
+ 'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
320
+ $exists: true,
321
+ $in: itemOfferedTicketedSeatTypeOfIn
282
322
  }
283
- // tslint:disable-next-line:no-single-line-block-comment
284
- /* istanbul ignore else */
285
- if (params.offers.itemOffered.serviceType !== undefined) {
286
- // tslint:disable-next-line:no-single-line-block-comment
287
- /* istanbul ignore else */
288
- if (Array.isArray(params.offers.itemOffered.serviceType.ids)) {
289
- andConditions.push({
290
- 'offers.itemOffered.serviceType.id': {
291
- $exists: true,
292
- $in: params.offers.itemOffered.serviceType.ids
293
- }
294
- });
295
- }
323
+ });
324
+ }
325
+ const itemOfferedServiceTypeIdIn = (_20 = (_19 = (_18 = params.offers) === null || _18 === void 0 ? void 0 : _18.itemOffered) === null || _19 === void 0 ? void 0 : _19.serviceType) === null || _20 === void 0 ? void 0 : _20.ids;
326
+ if (Array.isArray(itemOfferedServiceTypeIdIn)) {
327
+ andConditions.push({
328
+ 'offers.itemOffered.serviceType.id': {
329
+ $exists: true,
330
+ $in: itemOfferedServiceTypeIdIn
296
331
  }
297
- }
332
+ });
298
333
  }
299
- const sellerMakesOfferElemMatch = (_r = (_q = (_p = params.offers) === null || _p === void 0 ? void 0 : _p.seller) === null || _q === void 0 ? void 0 : _q.makesOffer) === null || _r === void 0 ? void 0 : _r.$elemMatch;
300
- if (typeof ((_s = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _s === void 0 ? void 0 : _s.$eq) === 'string') {
334
+ const sellerMakesOfferElemMatch = (_23 = (_22 = (_21 = params.offers) === null || _21 === void 0 ? void 0 : _21.seller) === null || _22 === void 0 ? void 0 : _22.makesOffer) === null || _23 === void 0 ? void 0 : _23.$elemMatch;
335
+ if (typeof ((_24 = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _24 === void 0 ? void 0 : _24.$eq) === 'string') {
301
336
  andConditions.push({
302
337
  'offers.seller.makesOffer': {
303
338
  $exists: true,
@@ -334,7 +369,7 @@ class MongoRepository {
334
369
  ]
335
370
  });
336
371
  }
337
- const locationIdEq = (_u = (_t = params.location) === null || _t === void 0 ? void 0 : _t.id) === null || _u === void 0 ? void 0 : _u.$eq;
372
+ const locationIdEq = (_26 = (_25 = params.location) === null || _25 === void 0 ? void 0 : _25.id) === null || _26 === void 0 ? void 0 : _26.$eq;
338
373
  // tslint:disable-next-line:no-single-line-block-comment
339
374
  /* istanbul ignore else */
340
375
  if (typeof locationIdEq === 'string') {
@@ -356,7 +391,7 @@ class MongoRepository {
356
391
  });
357
392
  }
358
393
  }
359
- const workPerformedIdentifierIn = (_v = params.workPerformed) === null || _v === void 0 ? void 0 : _v.identifiers;
394
+ const workPerformedIdentifierIn = (_27 = params.workPerformed) === null || _27 === void 0 ? void 0 : _27.identifiers;
360
395
  // tslint:disable-next-line:no-single-line-block-comment
361
396
  /* istanbul ignore else */
362
397
  if (Array.isArray(workPerformedIdentifierIn)) {
@@ -367,7 +402,7 @@ class MongoRepository {
367
402
  }
368
403
  });
369
404
  }
370
- const videoFormatTypeOfEq = (_x = (_w = params.videoFormat) === null || _w === void 0 ? void 0 : _w.typeOf) === null || _x === void 0 ? void 0 : _x.$eq;
405
+ const videoFormatTypeOfEq = (_29 = (_28 = params.videoFormat) === null || _28 === void 0 ? void 0 : _28.typeOf) === null || _29 === void 0 ? void 0 : _29.$eq;
371
406
  if (typeof videoFormatTypeOfEq === 'string') {
372
407
  andConditions.push({
373
408
  'videoFormat.typeOf': {
@@ -376,7 +411,7 @@ class MongoRepository {
376
411
  }
377
412
  });
378
413
  }
379
- const videoFormatTypeOfIn = (_z = (_y = params.videoFormat) === null || _y === void 0 ? void 0 : _y.typeOf) === null || _z === void 0 ? void 0 : _z.$in;
414
+ const videoFormatTypeOfIn = (_31 = (_30 = params.videoFormat) === null || _30 === void 0 ? void 0 : _30.typeOf) === null || _31 === void 0 ? void 0 : _31.$in;
380
415
  if (Array.isArray(videoFormatTypeOfIn)) {
381
416
  andConditions.push({
382
417
  'videoFormat.typeOf': {
@@ -385,7 +420,7 @@ class MongoRepository {
385
420
  }
386
421
  });
387
422
  }
388
- const soundFormatTypeOfEq = (_1 = (_0 = params.soundFormat) === null || _0 === void 0 ? void 0 : _0.typeOf) === null || _1 === void 0 ? void 0 : _1.$eq;
423
+ const soundFormatTypeOfEq = (_33 = (_32 = params.soundFormat) === null || _32 === void 0 ? void 0 : _32.typeOf) === null || _33 === void 0 ? void 0 : _33.$eq;
389
424
  if (typeof soundFormatTypeOfEq === 'string') {
390
425
  andConditions.push({
391
426
  'soundFormat.typeOf': {
@@ -394,7 +429,7 @@ class MongoRepository {
394
429
  }
395
430
  });
396
431
  }
397
- const soundFormatTypeOfIn = (_3 = (_2 = params.soundFormat) === null || _2 === void 0 ? void 0 : _2.typeOf) === null || _3 === void 0 ? void 0 : _3.$in;
432
+ const soundFormatTypeOfIn = (_35 = (_34 = params.soundFormat) === null || _34 === void 0 ? void 0 : _34.typeOf) === null || _35 === void 0 ? void 0 : _35.$in;
398
433
  if (Array.isArray(soundFormatTypeOfIn)) {
399
434
  andConditions.push({
400
435
  'soundFormat.typeOf': {
@@ -413,12 +448,51 @@ class MongoRepository {
413
448
  */
414
449
  createMany(params) {
415
450
  return __awaiter(this, void 0, void 0, function* () {
416
- const docs = yield this.eventModel.insertMany(params.map((p) => {
451
+ const docs = yield this.eventModel.insertMany(params.attributes.map((p) => {
417
452
  return Object.assign({ _id: uniqid() }, p);
418
453
  }));
454
+ if (params.expectsNoContent) {
455
+ return;
456
+ }
419
457
  return docs.map((doc) => doc.toObject());
420
458
  });
421
459
  }
460
+ /**
461
+ * 特定の追加特性をキーにして、なければ作成する(複数対応)
462
+ */
463
+ createManyIfNotExist(params) {
464
+ return __awaiter(this, void 0, void 0, function* () {
465
+ const bulkWriteOps = [];
466
+ if (Array.isArray(params)) {
467
+ params.forEach((creatingEventParams) => {
468
+ var _a, _b;
469
+ const additionalPropertyValue = (_b = (_a = creatingEventParams.attributes.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((property) => property.name === creatingEventParams.filter.name)) === null || _b === void 0 ? void 0 : _b.value;
470
+ if (typeof additionalPropertyValue !== 'string') {
471
+ throw new factory.errors.NotFound('additionalProperty.value');
472
+ }
473
+ bulkWriteOps.push({
474
+ updateOne: {
475
+ filter: {
476
+ typeOf: creatingEventParams.attributes.typeOf,
477
+ // 追加特性をキーに更新
478
+ additionalProperty: {
479
+ $exists: true,
480
+ $all: [{ name: creatingEventParams.filter.name, value: additionalPropertyValue }]
481
+ }
482
+ },
483
+ update: {
484
+ $setOnInsert: Object.assign({ _id: uniqid() }, creatingEventParams.attributes)
485
+ },
486
+ upsert: true
487
+ }
488
+ });
489
+ });
490
+ }
491
+ if (bulkWriteOps.length > 0) {
492
+ return this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
493
+ }
494
+ });
495
+ }
422
496
  /**
423
497
  * イベント部分更新
424
498
  */
@@ -472,52 +546,40 @@ class MongoRepository {
472
546
  const bulkWriteOps = [];
473
547
  if (Array.isArray(params)) {
474
548
  params.forEach((p) => {
475
- if (p.id === undefined) {
476
- const id = uniqid();
549
+ const upsert = p.upsert === true;
550
+ if (p.attributes.typeOf === factory.eventType.ScreeningEvent) {
551
+ // 上書き禁止属性を除外(2022-08-24~)
552
+ const _a = p.attributes, { identifier, project, typeOf, remainingAttendeeCapacity } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf", "remainingAttendeeCapacity"]);
477
553
  bulkWriteOps.push({
478
- insertOne: {
479
- document: Object.assign(Object.assign({}, p.attributes), { _id: id })
554
+ updateOne: {
555
+ filter: {
556
+ _id: p.id,
557
+ typeOf: p.attributes.typeOf
558
+ },
559
+ // upsertの場合、createがありうるので属性を除外しない
560
+ update: Object.assign({ $setOnInsert: Object.assign(Object.assign({ typeOf: p.attributes.typeOf, project: p.attributes.project }, (typeof p.attributes.identifier === 'string')
561
+ ? { identifier: p.attributes.identifier } : undefined), (typeof p.attributes.remainingAttendeeCapacity === 'number')
562
+ ? { remainingAttendeeCapacity: p.attributes.remainingAttendeeCapacity }
563
+ : undefined), $set: updateFields }, (p.$unset !== undefined) ? { $unset: p.$unset } : undefined),
564
+ upsert
480
565
  }
481
566
  });
482
567
  }
483
- else {
484
- const upsert = p.upsert === true;
485
- if (p.attributes.typeOf === factory.eventType.ScreeningEvent) {
486
- // 上書き禁止属性を除外(2022-08-24~)
487
- const _a = p.attributes, { identifier, project, typeOf, remainingAttendeeCapacity } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf", "remainingAttendeeCapacity"]);
488
- bulkWriteOps.push({
489
- updateOne: {
490
- filter: {
491
- _id: p.id,
492
- typeOf: p.attributes.typeOf
493
- },
494
- // upsertの場合、createがありうるので属性を除外しない
495
- update: Object.assign({ $setOnInsert: Object.assign(Object.assign(Object.assign({ typeOf: p.attributes.typeOf }, (p.attributes.project !== undefined)
496
- ? { project: p.attributes.project } : undefined), (p.attributes.identifier !== undefined)
497
- ? { identifier: p.attributes.identifier } : undefined), (typeof p.attributes.remainingAttendeeCapacity === 'number')
498
- ? { remainingAttendeeCapacity: p.attributes.remainingAttendeeCapacity }
499
- : undefined), $set: updateFields }, (p.$unset !== undefined) ? { $unset: p.$unset } : undefined),
500
- upsert
501
- }
502
- });
503
- }
504
- else if (p.attributes.typeOf === factory.eventType.ScreeningEventSeries) {
505
- // 上書き禁止属性を除外(2022-08-24~)
506
- const _b = p.attributes, { identifier, project, typeOf } = _b, updateFields = __rest(_b, ["identifier", "project", "typeOf"]);
507
- bulkWriteOps.push({
508
- updateOne: {
509
- filter: {
510
- _id: p.id,
511
- typeOf: p.attributes.typeOf
512
- },
513
- // upsertの場合、createがありうるので属性を除外しない
514
- update: Object.assign({ $setOnInsert: Object.assign(Object.assign({ typeOf: p.attributes.typeOf }, (p.attributes.project !== undefined)
515
- ? { project: p.attributes.project } : undefined), (p.attributes.identifier !== undefined)
516
- ? { identifier: p.attributes.identifier } : undefined), $set: updateFields }, (p.$unset !== undefined) ? { $unset: p.$unset } : undefined),
517
- upsert
518
- }
519
- });
520
- }
568
+ else if (p.attributes.typeOf === factory.eventType.ScreeningEventSeries) {
569
+ // 上書き禁止属性を除外(2022-08-24~)
570
+ const _b = p.attributes, { identifier, project, typeOf } = _b, updateFields = __rest(_b, ["identifier", "project", "typeOf"]);
571
+ bulkWriteOps.push({
572
+ updateOne: {
573
+ filter: {
574
+ _id: p.id,
575
+ typeOf: p.attributes.typeOf
576
+ },
577
+ // upsertの場合、createがありうるので属性を除外しない
578
+ update: Object.assign({ $setOnInsert: Object.assign({ typeOf: p.attributes.typeOf, project: p.attributes.project }, (typeof p.attributes.identifier === 'string')
579
+ ? { identifier: p.attributes.identifier } : undefined), $set: updateFields }, (p.$unset !== undefined) ? { $unset: p.$unset } : undefined),
580
+ upsert
581
+ }
582
+ });
521
583
  }
522
584
  });
523
585
  }
@@ -530,7 +592,7 @@ class MongoRepository {
530
592
  return __awaiter(this, void 0, void 0, function* () {
531
593
  let doc;
532
594
  const _a = params.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
533
- const id = (params.useOldEventId) ? params.oldEventId : uniqid();
595
+ const id = uniqid();
534
596
  doc = yield this.eventModel.findOneAndUpdate({
535
597
  typeOf: params.attributes.typeOf,
536
598
  // 追加特性をキーに更新
@@ -569,7 +631,15 @@ class MongoRepository {
569
631
  search(params, projection) {
570
632
  return __awaiter(this, void 0, void 0, function* () {
571
633
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
572
- const query = this.eventModel.find({ $and: conditions }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
634
+ const positiveProjectionExists = (projection !== undefined && projection !== null)
635
+ ? Object.keys(projection)
636
+ .some((key) => projection[key] !== 0)
637
+ : false;
638
+ const query = this.eventModel.find({ $and: conditions },
639
+ // :1対応(2023-01-25~)
640
+ (positiveProjectionExists)
641
+ ? projection
642
+ : Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
573
643
  if (typeof params.limit === 'number') {
574
644
  const page = (typeof params.page === 'number') ? params.page : 1;
575
645
  query.limit(params.limit)
@@ -593,11 +663,35 @@ class MongoRepository {
593
663
  .then((docs) => docs.map((doc) => doc.toObject()));
594
664
  });
595
665
  }
666
+ searchIds(params) {
667
+ return __awaiter(this, void 0, void 0, function* () {
668
+ const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
669
+ const query = this.eventModel.distinct('_id', { $and: conditions });
670
+ return query.setOptions({ maxTimeMS: 10000 })
671
+ .exec();
672
+ });
673
+ }
596
674
  findById(params, projection) {
597
675
  return __awaiter(this, void 0, void 0, function* () {
598
- const doc = yield this.eventModel.findOne({
599
- _id: params.id
600
- }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
676
+ const positiveProjectionExists = (projection !== undefined && projection !== null)
677
+ ? Object.keys(projection)
678
+ .some((key) => projection[key] !== 0)
679
+ : false;
680
+ const doc = yield this.eventModel.findOne({ _id: params.id },
681
+ // :1対応(2023-01-25~)
682
+ (positiveProjectionExists)
683
+ ? projection
684
+ : Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
685
+ .exec();
686
+ if (doc === null) {
687
+ throw new factory.errors.NotFound(this.eventModel.modelName);
688
+ }
689
+ return doc.toObject();
690
+ });
691
+ }
692
+ findMinimizedIndividualEventById(params) {
693
+ return __awaiter(this, void 0, void 0, function* () {
694
+ const doc = yield this.eventModel.findOne({ _id: params.id }, exports.PROJECTION_MINIMIZED_EVENT)
601
695
  .exec();
602
696
  if (doc === null) {
603
697
  throw new factory.errors.NotFound(this.eventModel.modelName);
@@ -610,9 +704,7 @@ class MongoRepository {
610
704
  */
611
705
  cancel(params) {
612
706
  return __awaiter(this, void 0, void 0, function* () {
613
- yield this.eventModel.findOneAndUpdate({
614
- _id: params.id
615
- }, { eventStatus: factory.eventStatusType.EventCancelled }, { new: true })
707
+ yield this.eventModel.findOneAndUpdate({ _id: params.id }, { eventStatus: factory.eventStatusType.EventCancelled })
616
708
  .exec();
617
709
  });
618
710
  }
@@ -668,5 +760,213 @@ class MongoRepository {
668
760
  .exec();
669
761
  });
670
762
  }
763
+ aggregateEvent(params) {
764
+ return __awaiter(this, void 0, void 0, function* () {
765
+ const statuses = yield Promise.all([
766
+ factory.eventStatusType.EventScheduled,
767
+ factory.eventStatusType.EventCancelled,
768
+ factory.eventStatusType.EventPostponed
769
+ ].map((eventStatus) => __awaiter(this, void 0, void 0, function* () {
770
+ var _a, _b;
771
+ const matchConditions = Object.assign({ startDate: {
772
+ $gte: params.startFrom,
773
+ $lte: params.startThrough
774
+ }, typeOf: { $eq: params.typeOf }, eventStatus: { $eq: eventStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
775
+ ? { 'project.id': { $ne: params.project.id.$ne } }
776
+ : undefined);
777
+ return this.agggregateByStatus({ matchConditions, status: eventStatus });
778
+ })));
779
+ return { statuses };
780
+ });
781
+ }
782
+ // tslint:disable-next-line:max-func-body-length
783
+ agggregateByStatus(params) {
784
+ return __awaiter(this, void 0, void 0, function* () {
785
+ const matchConditions = params.matchConditions;
786
+ const eventStatus = params.status;
787
+ const aggregations = yield this.eventModel.aggregate([
788
+ {
789
+ $match: matchConditions
790
+ },
791
+ {
792
+ $project: {
793
+ remainingCapacityRate: {
794
+ $cond: {
795
+ if: {
796
+ $and: [
797
+ { $isNumber: '$maximumAttendeeCapacity' },
798
+ { $isNumber: '$remainingAttendeeCapacity' }
799
+ ]
800
+ },
801
+ then: {
802
+ $cond: {
803
+ if: { $gt: ['$maximumAttendeeCapacity', 0] },
804
+ then: {
805
+ $multiply: [
806
+ { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
807
+ // tslint:disable-next-line:no-magic-numbers
808
+ 100
809
+ ]
810
+ },
811
+ else: 0
812
+ }
813
+ },
814
+ else: 0
815
+ }
816
+ },
817
+ eventStatus: '$eventStatus',
818
+ startDate: '$startDate',
819
+ endDate: '$endDate',
820
+ typeOf: '$typeOf',
821
+ maximumAttendeeCapacity: {
822
+ $cond: {
823
+ if: { $isNumber: '$maximumAttendeeCapacity' },
824
+ then: '$maximumAttendeeCapacity',
825
+ else: 0
826
+ }
827
+ },
828
+ remainingAttendeeCapacity: {
829
+ $cond: {
830
+ if: { $isNumber: '$remainingAttendeeCapacity' },
831
+ then: '$remainingAttendeeCapacity',
832
+ else: 0
833
+ }
834
+ },
835
+ reservationCount: {
836
+ $cond: {
837
+ if: { $isNumber: '$aggregateReservation.reservationCount' },
838
+ then: '$aggregateReservation.reservationCount',
839
+ else: 0
840
+ }
841
+ },
842
+ offerCount: {
843
+ $cond: {
844
+ if: { $isNumber: '$aggregateOffer.offerCount' },
845
+ then: '$aggregateOffer.offerCount',
846
+ else: 0
847
+ }
848
+ }
849
+ }
850
+ },
851
+ {
852
+ $group: {
853
+ _id: '$typeOf',
854
+ eventCount: { $sum: 1 },
855
+ reservationCount: { $sum: '$reservationCount' },
856
+ avgOfferCount: { $avg: '$offerCount' },
857
+ maximumAttendeeCapacity: { $sum: '$maximumAttendeeCapacity' },
858
+ remainingAttendeeCapacity: { $sum: '$remainingAttendeeCapacity' },
859
+ avgRemainingCapacityRate: { $avg: '$remainingCapacityRate' },
860
+ maxRemainingCapacityRate: { $max: '$remainingCapacityRate' },
861
+ minRemainingCapacityRate: { $min: '$remainingCapacityRate' }
862
+ }
863
+ },
864
+ {
865
+ $project: {
866
+ _id: 0,
867
+ eventCount: '$eventCount',
868
+ reservationCount: '$reservationCount',
869
+ avgOfferCount: '$avgOfferCount',
870
+ maximumAttendeeCapacity: '$maximumAttendeeCapacity',
871
+ remainingAttendeeCapacity: '$remainingAttendeeCapacity',
872
+ avgRemainingCapacityRate: '$avgRemainingCapacityRate',
873
+ maxRemainingCapacityRate: '$maxRemainingCapacityRate',
874
+ minRemainingCapacityRate: '$minRemainingCapacityRate'
875
+ }
876
+ }
877
+ ])
878
+ .exec();
879
+ // tslint:disable-next-line:no-magic-numbers
880
+ const percents = [50, 95, 99];
881
+ if (aggregations.length === 0) {
882
+ return {
883
+ status: eventStatus,
884
+ aggregation: {
885
+ eventCount: 0,
886
+ reservationCount: 0,
887
+ avgOfferCount: 0,
888
+ maximumAttendeeCapacity: 0,
889
+ remainingAttendeeCapacity: 0,
890
+ avgRemainingCapacityRate: 0,
891
+ maxRemainingCapacityRate: 0,
892
+ minRemainingCapacityRate: 0,
893
+ percentilesRemainingCapacityRate: percents.map((percent) => {
894
+ return {
895
+ name: String(percent),
896
+ value: 0
897
+ };
898
+ })
899
+ }
900
+ };
901
+ }
902
+ const ranks4percentile = percents.map((percentile) => {
903
+ return {
904
+ percentile,
905
+ // tslint:disable-next-line:no-magic-numbers
906
+ rank: Math.floor(aggregations[0].eventCount * percentile / 100)
907
+ };
908
+ });
909
+ const aggregations2 = yield this.eventModel.aggregate([
910
+ {
911
+ $match: matchConditions
912
+ },
913
+ {
914
+ $project: {
915
+ remainingCapacityRate: {
916
+ $cond: {
917
+ if: {
918
+ $and: [
919
+ { $isNumber: '$maximumAttendeeCapacity' },
920
+ { $isNumber: '$remainingAttendeeCapacity' }
921
+ ]
922
+ },
923
+ then: {
924
+ $cond: {
925
+ if: { $gt: ['$maximumAttendeeCapacity', 0] },
926
+ then: {
927
+ $multiply: [
928
+ { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
929
+ // tslint:disable-next-line:no-magic-numbers
930
+ 100
931
+ ]
932
+ },
933
+ else: 0
934
+ }
935
+ },
936
+ else: 0
937
+ }
938
+ },
939
+ eventStatus: '$eventStatus',
940
+ startDate: '$startDate',
941
+ endDate: '$endDate',
942
+ typeOf: '$typeOf'
943
+ }
944
+ },
945
+ { $sort: { remainingCapacityRate: 1 } },
946
+ {
947
+ $group: {
948
+ _id: '$typeOf',
949
+ remainingCapacityRates: { $push: '$remainingCapacityRate' }
950
+ }
951
+ },
952
+ {
953
+ $project: {
954
+ _id: 0,
955
+ percentilesRemainingCapacityRate: ranks4percentile.map((rank) => {
956
+ return {
957
+ name: String(rank.percentile),
958
+ value: { $arrayElemAt: ['$remainingCapacityRates', rank.rank] }
959
+ };
960
+ })
961
+ }
962
+ }
963
+ ])
964
+ .exec();
965
+ return {
966
+ status: eventStatus,
967
+ aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
968
+ };
969
+ });
970
+ }
671
971
  }
672
972
  exports.MongoRepository = MongoRepository;