@chevre/domain 21.27.0-alpha.9 → 21.27.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 (58) hide show
  1. package/example/src/chevre/{aggregateEventReservation.ts → aggregation/aggregateEventReservation.ts} +2 -3
  2. package/example/src/chevre/aggregation/aggregateOffersOnEvent.ts +82 -0
  3. package/example/src/chevre/{aggregateAllEvents.ts → aggregation/createAggregateEventTasks.ts} +26 -13
  4. package/example/src/chevre/aggregation/searchAggregateReservations.ts +33 -0
  5. package/example/src/chevre/searchEvents.ts +4 -4
  6. package/example/src/chevre/transaction/processPlaceOrder.ts +1 -2
  7. package/example/src/chevre/unsetUnnecessaryFields.ts +4 -4
  8. package/lib/chevre/credentials.d.ts +7 -0
  9. package/lib/chevre/credentials.js +10 -6
  10. package/lib/chevre/repo/action.d.ts +2 -2
  11. package/lib/chevre/repo/action.js +64 -49
  12. package/lib/chevre/repo/aggregateReservation.d.ts +68 -0
  13. package/lib/chevre/repo/aggregateReservation.js +135 -0
  14. package/lib/chevre/repo/event.d.ts +16 -14
  15. package/lib/chevre/repo/event.js +62 -20
  16. package/lib/chevre/repo/mongoose/schemas/action.js +18 -0
  17. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +5 -0
  18. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +84 -0
  19. package/lib/chevre/repo/mongoose/schemas/event.js +1 -1
  20. package/lib/chevre/repo/offer.d.ts +5 -0
  21. package/lib/chevre/repository.d.ts +5 -0
  22. package/lib/chevre/repository.js +15 -2
  23. package/lib/chevre/service/aggregation/event/aggregateOffers.d.ts +31 -0
  24. package/lib/chevre/service/aggregation/event/aggregateOffers.js +290 -0
  25. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +3 -4
  26. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +33 -238
  27. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +2 -0
  28. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +19 -15
  29. package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +2 -2
  30. package/lib/chevre/service/aggregation/event/findEventOffers.js +0 -2
  31. package/lib/chevre/service/aggregation/event.d.ts +2 -1
  32. package/lib/chevre/service/aggregation/event.js +3 -1
  33. package/lib/chevre/service/assetTransaction/pay.d.ts +4 -1
  34. package/lib/chevre/service/assetTransaction/pay.js +53 -27
  35. package/lib/chevre/service/assetTransaction/reserve.js +2 -1
  36. package/lib/chevre/service/event.js +16 -23
  37. package/lib/chevre/service/notification.js +0 -102
  38. package/lib/chevre/service/offer/onEventChanged.d.ts +25 -0
  39. package/lib/chevre/service/offer/onEventChanged.js +232 -0
  40. package/lib/chevre/service/offer.d.ts +0 -40
  41. package/lib/chevre/service/offer.js +1 -184
  42. package/lib/chevre/service/payment/any.d.ts +4 -2
  43. package/lib/chevre/service/payment/any.js +76 -48
  44. package/lib/chevre/service/payment/creditCard.js +14 -7
  45. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -9
  46. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -2
  47. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -2
  48. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -2
  49. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -2
  50. package/lib/chevre/service/task/aggregateOffers.d.ts +7 -0
  51. package/lib/chevre/service/task/aggregateOffers.js +47 -0
  52. package/lib/chevre/service/task/aggregateScreeningEvent.js +0 -2
  53. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +2 -0
  54. package/lib/chevre/service/task/onEventChanged.js +2 -2
  55. package/lib/chevre/service/transaction/returnOrder/preStart.js +0 -18
  56. package/lib/chevre/settings.d.ts +1 -0
  57. package/lib/chevre/settings.js +2 -1
  58. package/package.json +3 -3
@@ -22,7 +22,7 @@ class MongoRepository {
22
22
  }
23
23
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
24
24
  static CREATE_MONGO_CONDITIONS(params) {
25
- 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, _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;
25
+ 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, _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;
26
26
  const andConditions = [];
27
27
  const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
28
28
  if (Array.isArray(idIn)) {
@@ -66,7 +66,11 @@ class MongoRepository {
66
66
  if (typeof instrumentTransactionNumberEq === 'string') {
67
67
  andConditions.push({ 'instrument.transactionNumber': { $exists: true, $eq: instrumentTransactionNumberEq } });
68
68
  }
69
- const locationIdEq = (_m = (_l = params.location) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$eq;
69
+ const instrumentTypeOfEq = (_m = (_l = params.instrument) === null || _l === void 0 ? void 0 : _l.typeOf) === null || _m === void 0 ? void 0 : _m.$eq;
70
+ if (typeof instrumentTypeOfEq === 'string') {
71
+ andConditions.push({ 'instrument.typeOf': { $exists: true, $eq: instrumentTypeOfEq } });
72
+ }
73
+ const locationIdEq = (_p = (_o = params.location) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$eq;
70
74
  // tslint:disable-next-line:no-single-line-block-comment
71
75
  /* istanbul ignore else */
72
76
  if (typeof locationIdEq === 'string') {
@@ -77,7 +81,7 @@ class MongoRepository {
77
81
  }
78
82
  });
79
83
  }
80
- const locationIdentifierEq = (_p = (_o = params.location) === null || _o === void 0 ? void 0 : _o.identifier) === null || _p === void 0 ? void 0 : _p.$eq;
84
+ const locationIdentifierEq = (_r = (_q = params.location) === null || _q === void 0 ? void 0 : _q.identifier) === null || _r === void 0 ? void 0 : _r.$eq;
81
85
  // tslint:disable-next-line:no-single-line-block-comment
82
86
  /* istanbul ignore else */
83
87
  if (typeof locationIdentifierEq === 'string') {
@@ -88,7 +92,7 @@ class MongoRepository {
88
92
  }
89
93
  });
90
94
  }
91
- const objectMovieTicketsIdentifierEq = (_s = (_r = (_q = params.object) === null || _q === void 0 ? void 0 : _q.movieTickets) === null || _r === void 0 ? void 0 : _r.identifier) === null || _s === void 0 ? void 0 : _s.$eq;
95
+ const objectMovieTicketsIdentifierEq = (_u = (_t = (_s = params.object) === null || _s === void 0 ? void 0 : _s.movieTickets) === null || _t === void 0 ? void 0 : _t.identifier) === null || _u === void 0 ? void 0 : _u.$eq;
92
96
  if (typeof objectMovieTicketsIdentifierEq === 'string') {
93
97
  andConditions.push({
94
98
  'object.movieTickets.identifier': {
@@ -97,7 +101,7 @@ class MongoRepository {
97
101
  }
98
102
  });
99
103
  }
100
- const objectMovieTicketsServiceOutputReservationForIdEq = (_x = (_w = (_v = (_u = (_t = params.object) === null || _t === void 0 ? void 0 : _t.movieTickets) === null || _u === void 0 ? void 0 : _u.serviceOutput) === null || _v === void 0 ? void 0 : _v.reservationFor) === null || _w === void 0 ? void 0 : _w.id) === null || _x === void 0 ? void 0 : _x.$eq;
104
+ const objectMovieTicketsServiceOutputReservationForIdEq = (_z = (_y = (_x = (_w = (_v = params.object) === null || _v === void 0 ? void 0 : _v.movieTickets) === null || _w === void 0 ? void 0 : _w.serviceOutput) === null || _x === void 0 ? void 0 : _x.reservationFor) === null || _y === void 0 ? void 0 : _y.id) === null || _z === void 0 ? void 0 : _z.$eq;
101
105
  if (typeof objectMovieTicketsServiceOutputReservationForIdEq === 'string') {
102
106
  andConditions.push({
103
107
  'object.movieTickets.serviceOutput.reservationFor.id': {
@@ -108,7 +112,7 @@ class MongoRepository {
108
112
  }
109
113
  // tslint:disable-next-line:no-single-line-block-comment
110
114
  /* istanbul ignore else */
111
- const objectPaymentMethodIdEq = (_z = (_y = params.object) === null || _y === void 0 ? void 0 : _y.paymentMethodId) === null || _z === void 0 ? void 0 : _z.$eq;
115
+ const objectPaymentMethodIdEq = (_1 = (_0 = params.object) === null || _0 === void 0 ? void 0 : _0.paymentMethodId) === null || _1 === void 0 ? void 0 : _1.$eq;
112
116
  if (typeof objectPaymentMethodIdEq === 'string') {
113
117
  andConditions.push({
114
118
  'object.paymentMethodId': {
@@ -117,7 +121,7 @@ class MongoRepository {
117
121
  }
118
122
  });
119
123
  }
120
- const objectObjectPaymentMethodIdEq = (_2 = (_1 = (_0 = params.object) === null || _0 === void 0 ? void 0 : _0.object) === null || _1 === void 0 ? void 0 : _1.paymentMethodId) === null || _2 === void 0 ? void 0 : _2.$eq;
124
+ const objectObjectPaymentMethodIdEq = (_4 = (_3 = (_2 = params.object) === null || _2 === void 0 ? void 0 : _2.object) === null || _3 === void 0 ? void 0 : _3.paymentMethodId) === null || _4 === void 0 ? void 0 : _4.$eq;
121
125
  if (typeof objectObjectPaymentMethodIdEq === 'string') {
122
126
  andConditions.push({
123
127
  'object.object.paymentMethodId': {
@@ -126,7 +130,7 @@ class MongoRepository {
126
130
  }
127
131
  });
128
132
  }
129
- const objectReservationForIdEq = (_5 = (_4 = (_3 = params.object) === null || _3 === void 0 ? void 0 : _3.reservationFor) === null || _4 === void 0 ? void 0 : _4.id) === null || _5 === void 0 ? void 0 : _5.$eq;
133
+ const objectReservationForIdEq = (_7 = (_6 = (_5 = params.object) === null || _5 === void 0 ? void 0 : _5.reservationFor) === null || _6 === void 0 ? void 0 : _6.id) === null || _7 === void 0 ? void 0 : _7.$eq;
130
134
  // tslint:disable-next-line:no-single-line-block-comment
131
135
  /* istanbul ignore else */
132
136
  if (typeof objectReservationForIdEq === 'string') {
@@ -137,7 +141,7 @@ class MongoRepository {
137
141
  }
138
142
  });
139
143
  }
140
- const objectReservationNumberEq = (_7 = (_6 = params.object) === null || _6 === void 0 ? void 0 : _6.reservationNumber) === null || _7 === void 0 ? void 0 : _7.$eq;
144
+ const objectReservationNumberEq = (_9 = (_8 = params.object) === null || _8 === void 0 ? void 0 : _8.reservationNumber) === null || _9 === void 0 ? void 0 : _9.$eq;
141
145
  if (typeof objectReservationNumberEq === 'string') {
142
146
  andConditions.push({
143
147
  'object.reservationNumber': {
@@ -146,7 +150,7 @@ class MongoRepository {
146
150
  }
147
151
  });
148
152
  }
149
- const objectReservationNumberIn = (_9 = (_8 = params.object) === null || _8 === void 0 ? void 0 : _8.reservationNumber) === null || _9 === void 0 ? void 0 : _9.$in;
153
+ const objectReservationNumberIn = (_11 = (_10 = params.object) === null || _10 === void 0 ? void 0 : _10.reservationNumber) === null || _11 === void 0 ? void 0 : _11.$in;
150
154
  if (Array.isArray(objectReservationNumberIn)) {
151
155
  andConditions.push({
152
156
  'object.reservationNumber': {
@@ -155,7 +159,7 @@ class MongoRepository {
155
159
  }
156
160
  });
157
161
  }
158
- const objectPaymentMethodAccountIdEq = (_12 = (_11 = (_10 = params.object) === null || _10 === void 0 ? void 0 : _10.paymentMethod) === null || _11 === void 0 ? void 0 : _11.accountId) === null || _12 === void 0 ? void 0 : _12.$eq;
162
+ const objectPaymentMethodAccountIdEq = (_14 = (_13 = (_12 = params.object) === null || _12 === void 0 ? void 0 : _12.paymentMethod) === null || _13 === void 0 ? void 0 : _13.accountId) === null || _14 === void 0 ? void 0 : _14.$eq;
159
163
  // tslint:disable-next-line:no-single-line-block-comment
160
164
  /* istanbul ignore else */
161
165
  if (typeof objectPaymentMethodAccountIdEq === 'string') {
@@ -166,7 +170,7 @@ class MongoRepository {
166
170
  }
167
171
  });
168
172
  }
169
- const objectPaymentMethodPaymentMethodIdEq = (_15 = (_14 = (_13 = params.object) === null || _13 === void 0 ? void 0 : _13.paymentMethod) === null || _14 === void 0 ? void 0 : _14.paymentMethodId) === null || _15 === void 0 ? void 0 : _15.$eq;
173
+ const objectPaymentMethodPaymentMethodIdEq = (_17 = (_16 = (_15 = params.object) === null || _15 === void 0 ? void 0 : _15.paymentMethod) === null || _16 === void 0 ? void 0 : _16.paymentMethodId) === null || _17 === void 0 ? void 0 : _17.$eq;
170
174
  // tslint:disable-next-line:no-single-line-block-comment
171
175
  /* istanbul ignore else */
172
176
  if (typeof objectPaymentMethodPaymentMethodIdEq === 'string') {
@@ -177,7 +181,7 @@ class MongoRepository {
177
181
  }
178
182
  });
179
183
  }
180
- const objectPaymentMethodPaymentMethodIdIn = (_18 = (_17 = (_16 = params.object) === null || _16 === void 0 ? void 0 : _16.paymentMethod) === null || _17 === void 0 ? void 0 : _17.paymentMethodId) === null || _18 === void 0 ? void 0 : _18.$in;
184
+ const objectPaymentMethodPaymentMethodIdIn = (_20 = (_19 = (_18 = params.object) === null || _18 === void 0 ? void 0 : _18.paymentMethod) === null || _19 === void 0 ? void 0 : _19.paymentMethodId) === null || _20 === void 0 ? void 0 : _20.$in;
181
185
  if (Array.isArray(objectPaymentMethodPaymentMethodIdIn)) {
182
186
  andConditions.push({
183
187
  'object.paymentMethod.paymentMethodId': {
@@ -186,7 +190,7 @@ class MongoRepository {
186
190
  }
187
191
  });
188
192
  }
189
- const objectPaymentMethodTypeOfEq = (_21 = (_20 = (_19 = params.object) === null || _19 === void 0 ? void 0 : _19.paymentMethod) === null || _20 === void 0 ? void 0 : _20.typeOf) === null || _21 === void 0 ? void 0 : _21.$eq;
193
+ const objectPaymentMethodTypeOfEq = (_23 = (_22 = (_21 = params.object) === null || _21 === void 0 ? void 0 : _21.paymentMethod) === null || _22 === void 0 ? void 0 : _22.typeOf) === null || _23 === void 0 ? void 0 : _23.$eq;
190
194
  // tslint:disable-next-line:no-single-line-block-comment
191
195
  /* istanbul ignore else */
192
196
  if (typeof objectPaymentMethodTypeOfEq === 'string') {
@@ -197,7 +201,7 @@ class MongoRepository {
197
201
  }
198
202
  });
199
203
  }
200
- const objectTypeOfEq = (_23 = (_22 = params.object) === null || _22 === void 0 ? void 0 : _22.typeOf) === null || _23 === void 0 ? void 0 : _23.$eq;
204
+ const objectTypeOfEq = (_25 = (_24 = params.object) === null || _24 === void 0 ? void 0 : _24.typeOf) === null || _25 === void 0 ? void 0 : _25.$eq;
201
205
  // tslint:disable-next-line:no-single-line-block-comment
202
206
  /* istanbul ignore else */
203
207
  if (typeof objectTypeOfEq === 'string') {
@@ -208,7 +212,7 @@ class MongoRepository {
208
212
  }
209
213
  });
210
214
  }
211
- const objectTypeOfIn = (_25 = (_24 = params.object) === null || _24 === void 0 ? void 0 : _24.typeOf) === null || _25 === void 0 ? void 0 : _25.$in;
215
+ const objectTypeOfIn = (_27 = (_26 = params.object) === null || _26 === void 0 ? void 0 : _26.typeOf) === null || _27 === void 0 ? void 0 : _27.$in;
212
216
  if (Array.isArray(objectTypeOfIn)) {
213
217
  andConditions.push({
214
218
  'object.typeOf': {
@@ -217,7 +221,7 @@ class MongoRepository {
217
221
  }
218
222
  });
219
223
  }
220
- const objectIdEq = (_27 = (_26 = params.object) === null || _26 === void 0 ? void 0 : _26.id) === null || _27 === void 0 ? void 0 : _27.$eq;
224
+ const objectIdEq = (_29 = (_28 = params.object) === null || _28 === void 0 ? void 0 : _28.id) === null || _29 === void 0 ? void 0 : _29.$eq;
221
225
  // tslint:disable-next-line:no-single-line-block-comment
222
226
  /* istanbul ignore else */
223
227
  if (typeof objectIdEq === 'string') {
@@ -228,7 +232,7 @@ class MongoRepository {
228
232
  }
229
233
  });
230
234
  }
231
- const objectIdIn = (_29 = (_28 = params.object) === null || _28 === void 0 ? void 0 : _28.id) === null || _29 === void 0 ? void 0 : _29.$in;
235
+ const objectIdIn = (_31 = (_30 = params.object) === null || _30 === void 0 ? void 0 : _30.id) === null || _31 === void 0 ? void 0 : _31.$in;
232
236
  if (Array.isArray(objectIdIn)) {
233
237
  andConditions.push({
234
238
  'object.id': {
@@ -237,7 +241,7 @@ class MongoRepository {
237
241
  }
238
242
  });
239
243
  }
240
- const objectOrderNumberIn = (_31 = (_30 = params.object) === null || _30 === void 0 ? void 0 : _30.orderNumber) === null || _31 === void 0 ? void 0 : _31.$in;
244
+ const objectOrderNumberIn = (_33 = (_32 = params.object) === null || _32 === void 0 ? void 0 : _32.orderNumber) === null || _33 === void 0 ? void 0 : _33.$in;
241
245
  if (Array.isArray(objectOrderNumberIn)) {
242
246
  andConditions.push({
243
247
  'object.orderNumber': {
@@ -246,7 +250,7 @@ class MongoRepository {
246
250
  }
247
251
  });
248
252
  }
249
- const objectEventIdIn = (_34 = (_33 = (_32 = params.object) === null || _32 === void 0 ? void 0 : _32.event) === null || _33 === void 0 ? void 0 : _33.id) === null || _34 === void 0 ? void 0 : _34.$in;
253
+ const objectEventIdIn = (_36 = (_35 = (_34 = params.object) === null || _34 === void 0 ? void 0 : _34.event) === null || _35 === void 0 ? void 0 : _35.id) === null || _36 === void 0 ? void 0 : _36.$in;
250
254
  if (Array.isArray(objectEventIdIn)) {
251
255
  andConditions.push({
252
256
  'object.event.id': {
@@ -255,7 +259,7 @@ class MongoRepository {
255
259
  }
256
260
  });
257
261
  }
258
- const objectAcceptedOfferSeatNumberIn = (_41 = (_40 = (_39 = (_38 = (_37 = (_36 = (_35 = params.object) === null || _35 === void 0 ? void 0 : _35.acceptedOffer) === null || _36 === void 0 ? void 0 : _36.itemOffered) === null || _37 === void 0 ? void 0 : _37.serviceOutput) === null || _38 === void 0 ? void 0 : _38.reservedTicket) === null || _39 === void 0 ? void 0 : _39.ticketedSeat) === null || _40 === void 0 ? void 0 : _40.seatNumber) === null || _41 === void 0 ? void 0 : _41.$in;
262
+ const objectAcceptedOfferSeatNumberIn = (_43 = (_42 = (_41 = (_40 = (_39 = (_38 = (_37 = params.object) === null || _37 === void 0 ? void 0 : _37.acceptedOffer) === null || _38 === void 0 ? void 0 : _38.itemOffered) === null || _39 === void 0 ? void 0 : _39.serviceOutput) === null || _40 === void 0 ? void 0 : _40.reservedTicket) === null || _41 === void 0 ? void 0 : _41.ticketedSeat) === null || _42 === void 0 ? void 0 : _42.seatNumber) === null || _43 === void 0 ? void 0 : _43.$in;
259
263
  if (Array.isArray(objectAcceptedOfferSeatNumberIn)) {
260
264
  andConditions.push({
261
265
  'object.acceptedOffer.itemOffered.serviceOutput.reservedTicket.ticketedSeat.seatNumber': {
@@ -264,6 +268,10 @@ class MongoRepository {
264
268
  }
265
269
  });
266
270
  }
271
+ const objectTransactionNumberEq = (_45 = (_44 = params.object) === null || _44 === void 0 ? void 0 : _44.transactionNumber) === null || _45 === void 0 ? void 0 : _45.$eq;
272
+ if (typeof objectTransactionNumberEq === 'string') {
273
+ andConditions.push({ 'object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
274
+ }
267
275
  // tslint:disable-next-line:no-single-line-block-comment
268
276
  /* istanbul ignore else */
269
277
  if (typeof params.typeOf === 'string') {
@@ -272,7 +280,7 @@ class MongoRepository {
272
280
  });
273
281
  }
274
282
  else {
275
- const typeOfEq = (_42 = params.typeOf) === null || _42 === void 0 ? void 0 : _42.$eq;
283
+ const typeOfEq = (_46 = params.typeOf) === null || _46 === void 0 ? void 0 : _46.$eq;
276
284
  // tslint:disable-next-line:no-single-line-block-comment
277
285
  /* istanbul ignore else */
278
286
  if (typeof typeOfEq === 'string') {
@@ -281,7 +289,7 @@ class MongoRepository {
281
289
  });
282
290
  }
283
291
  }
284
- const actionStatusIn = (_43 = params.actionStatus) === null || _43 === void 0 ? void 0 : _43.$in;
292
+ const actionStatusIn = (_47 = params.actionStatus) === null || _47 === void 0 ? void 0 : _47.$in;
285
293
  // tslint:disable-next-line:no-single-line-block-comment
286
294
  /* istanbul ignore else */
287
295
  if (Array.isArray(actionStatusIn)) {
@@ -312,7 +320,7 @@ class MongoRepository {
312
320
  startDate: { $lte: startDateLte }
313
321
  });
314
322
  }
315
- const fromLocationTypeOfIn = (_45 = (_44 = params.fromLocation) === null || _44 === void 0 ? void 0 : _44.typeOf) === null || _45 === void 0 ? void 0 : _45.$in;
323
+ const fromLocationTypeOfIn = (_49 = (_48 = params.fromLocation) === null || _48 === void 0 ? void 0 : _48.typeOf) === null || _49 === void 0 ? void 0 : _49.$in;
316
324
  if (Array.isArray(fromLocationTypeOfIn)) {
317
325
  andConditions.push({
318
326
  'fromLocation.typeOf': {
@@ -321,7 +329,7 @@ class MongoRepository {
321
329
  }
322
330
  });
323
331
  }
324
- const fromLocationAccountNumberIn = (_47 = (_46 = params.fromLocation) === null || _46 === void 0 ? void 0 : _46.accountNumber) === null || _47 === void 0 ? void 0 : _47.$in;
332
+ const fromLocationAccountNumberIn = (_51 = (_50 = params.fromLocation) === null || _50 === void 0 ? void 0 : _50.accountNumber) === null || _51 === void 0 ? void 0 : _51.$in;
325
333
  if (Array.isArray(fromLocationAccountNumberIn)) {
326
334
  andConditions.push({
327
335
  'fromLocation.accountNumber': {
@@ -330,7 +338,7 @@ class MongoRepository {
330
338
  }
331
339
  });
332
340
  }
333
- const fromLocationAccountTypeIn = (_49 = (_48 = params.fromLocation) === null || _48 === void 0 ? void 0 : _48.accountType) === null || _49 === void 0 ? void 0 : _49.$in;
341
+ const fromLocationAccountTypeIn = (_53 = (_52 = params.fromLocation) === null || _52 === void 0 ? void 0 : _52.accountType) === null || _53 === void 0 ? void 0 : _53.$in;
334
342
  if (Array.isArray(fromLocationAccountTypeIn)) {
335
343
  andConditions.push({
336
344
  'fromLocation.accountType': {
@@ -339,7 +347,7 @@ class MongoRepository {
339
347
  }
340
348
  });
341
349
  }
342
- const toLocationTypeOfIn = (_51 = (_50 = params.toLocation) === null || _50 === void 0 ? void 0 : _50.typeOf) === null || _51 === void 0 ? void 0 : _51.$in;
350
+ const toLocationTypeOfIn = (_55 = (_54 = params.toLocation) === null || _54 === void 0 ? void 0 : _54.typeOf) === null || _55 === void 0 ? void 0 : _55.$in;
343
351
  if (Array.isArray(toLocationTypeOfIn)) {
344
352
  andConditions.push({
345
353
  'toLocation.typeOf': {
@@ -348,7 +356,7 @@ class MongoRepository {
348
356
  }
349
357
  });
350
358
  }
351
- const toLocationAccountNumberIn = (_53 = (_52 = params.toLocation) === null || _52 === void 0 ? void 0 : _52.accountNumber) === null || _53 === void 0 ? void 0 : _53.$in;
359
+ const toLocationAccountNumberIn = (_57 = (_56 = params.toLocation) === null || _56 === void 0 ? void 0 : _56.accountNumber) === null || _57 === void 0 ? void 0 : _57.$in;
352
360
  if (Array.isArray(toLocationAccountNumberIn)) {
353
361
  andConditions.push({
354
362
  'toLocation.accountNumber': {
@@ -357,7 +365,7 @@ class MongoRepository {
357
365
  }
358
366
  });
359
367
  }
360
- const toLocationAccountTypeIn = (_55 = (_54 = params.toLocation) === null || _54 === void 0 ? void 0 : _54.accountType) === null || _55 === void 0 ? void 0 : _55.$in;
368
+ const toLocationAccountTypeIn = (_59 = (_58 = params.toLocation) === null || _58 === void 0 ? void 0 : _58.accountType) === null || _59 === void 0 ? void 0 : _59.$in;
361
369
  if (Array.isArray(toLocationAccountTypeIn)) {
362
370
  andConditions.push({
363
371
  'toLocation.accountType': {
@@ -366,7 +374,7 @@ class MongoRepository {
366
374
  }
367
375
  });
368
376
  }
369
- const purposeTypeOfIn = (_57 = (_56 = params.purpose) === null || _56 === void 0 ? void 0 : _56.typeOf) === null || _57 === void 0 ? void 0 : _57.$in;
377
+ const purposeTypeOfIn = (_61 = (_60 = params.purpose) === null || _60 === void 0 ? void 0 : _60.typeOf) === null || _61 === void 0 ? void 0 : _61.$in;
370
378
  if (Array.isArray(purposeTypeOfIn)) {
371
379
  andConditions.push({
372
380
  'purpose.typeOf': {
@@ -375,7 +383,7 @@ class MongoRepository {
375
383
  }
376
384
  });
377
385
  }
378
- const purposeIdIn = (_59 = (_58 = params.purpose) === null || _58 === void 0 ? void 0 : _58.id) === null || _59 === void 0 ? void 0 : _59.$in;
386
+ const purposeIdIn = (_63 = (_62 = params.purpose) === null || _62 === void 0 ? void 0 : _62.id) === null || _63 === void 0 ? void 0 : _63.$in;
379
387
  if (Array.isArray(purposeIdIn)) {
380
388
  andConditions.push({
381
389
  'purpose.id': {
@@ -384,7 +392,7 @@ class MongoRepository {
384
392
  }
385
393
  });
386
394
  }
387
- const purposeOrderNumberIn = (_61 = (_60 = params.purpose) === null || _60 === void 0 ? void 0 : _60.orderNumber) === null || _61 === void 0 ? void 0 : _61.$in;
395
+ const purposeOrderNumberIn = (_65 = (_64 = params.purpose) === null || _64 === void 0 ? void 0 : _64.orderNumber) === null || _65 === void 0 ? void 0 : _65.$in;
388
396
  if (Array.isArray(purposeOrderNumberIn)) {
389
397
  andConditions.push({
390
398
  'purpose.orderNumber': {
@@ -393,7 +401,7 @@ class MongoRepository {
393
401
  }
394
402
  });
395
403
  }
396
- const resultTypeOfIn = (_63 = (_62 = params.result) === null || _62 === void 0 ? void 0 : _62.typeOf) === null || _63 === void 0 ? void 0 : _63.$in;
404
+ const resultTypeOfIn = (_67 = (_66 = params.result) === null || _66 === void 0 ? void 0 : _66.typeOf) === null || _67 === void 0 ? void 0 : _67.$in;
397
405
  if (Array.isArray(resultTypeOfIn)) {
398
406
  andConditions.push({
399
407
  'result.typeOf': {
@@ -402,7 +410,7 @@ class MongoRepository {
402
410
  }
403
411
  });
404
412
  }
405
- const resultIdIn = (_65 = (_64 = params.result) === null || _64 === void 0 ? void 0 : _64.id) === null || _65 === void 0 ? void 0 : _65.$in;
413
+ const resultIdIn = (_69 = (_68 = params.result) === null || _68 === void 0 ? void 0 : _68.id) === null || _69 === void 0 ? void 0 : _69.$in;
406
414
  if (Array.isArray(resultIdIn)) {
407
415
  andConditions.push({
408
416
  'result.id': {
@@ -411,7 +419,7 @@ class MongoRepository {
411
419
  }
412
420
  });
413
421
  }
414
- const resultOrderNumberIn = (_67 = (_66 = params.result) === null || _66 === void 0 ? void 0 : _66.orderNumber) === null || _67 === void 0 ? void 0 : _67.$in;
422
+ const resultOrderNumberIn = (_71 = (_70 = params.result) === null || _70 === void 0 ? void 0 : _70.orderNumber) === null || _71 === void 0 ? void 0 : _71.$in;
415
423
  if (Array.isArray(resultOrderNumberIn)) {
416
424
  andConditions.push({
417
425
  'result.orderNumber': {
@@ -420,7 +428,7 @@ class MongoRepository {
420
428
  }
421
429
  });
422
430
  }
423
- const resultCodeIn = (_69 = (_68 = params.result) === null || _68 === void 0 ? void 0 : _68.code) === null || _69 === void 0 ? void 0 : _69.$in;
431
+ const resultCodeIn = (_73 = (_72 = params.result) === null || _72 === void 0 ? void 0 : _72.code) === null || _73 === void 0 ? void 0 : _73.$in;
424
432
  if (Array.isArray(resultCodeIn)) {
425
433
  andConditions.push({
426
434
  'result.code': {
@@ -540,14 +548,18 @@ class MongoRepository {
540
548
  */
541
549
  giveUpWithObject(params) {
542
550
  return __awaiter(this, void 0, void 0, function* () {
543
- const actionError = Object.assign(Object.assign({}, params.error), { message: params.error.message, name: params.error.name });
551
+ const actionError = (Array.isArray(params.error))
552
+ ? params.error.map((e) => (Object.assign(Object.assign({}, e), { message: e.message, name: e.name })))
553
+ : Object.assign(Object.assign({}, params.error), { message: params.error.message, name: params.error.name });
544
554
  const doc = yield this.actionModel.findOneAndUpdate({
545
- typeOf: params.typeOf,
546
- _id: params.id
555
+ typeOf: { $eq: params.typeOf },
556
+ _id: { $eq: params.id }
547
557
  }, {
548
- actionStatus: factory.actionStatusType.FailedActionStatus,
549
- error: actionError,
550
- endDate: new Date()
558
+ $set: {
559
+ actionStatus: factory.actionStatusType.FailedActionStatus,
560
+ error: actionError,
561
+ endDate: new Date()
562
+ }
551
563
  }, { new: true })
552
564
  .select({ __v: 0, createdAt: 0, updatedAt: 0 })
553
565
  .exec();
@@ -562,21 +574,24 @@ class MongoRepository {
562
574
  */
563
575
  giveUp(params) {
564
576
  return __awaiter(this, void 0, void 0, function* () {
565
- const actionError = Object.assign(Object.assign({}, params.error), { message: params.error.message, name: params.error.name });
577
+ const actionError = (Array.isArray(params.error))
578
+ ? params.error.map((e) => (Object.assign(Object.assign({}, e), { message: e.message, name: e.name })))
579
+ : Object.assign(Object.assign({}, params.error), { message: params.error.message, name: params.error.name });
566
580
  const doc = yield this.actionModel.findOneAndUpdate({
567
- typeOf: params.typeOf,
568
- _id: params.id
581
+ typeOf: { $eq: params.typeOf },
582
+ _id: { $eq: params.id }
569
583
  }, {
570
- actionStatus: factory.actionStatusType.FailedActionStatus,
571
- error: actionError,
572
- endDate: new Date()
584
+ $set: {
585
+ actionStatus: factory.actionStatusType.FailedActionStatus,
586
+ error: actionError,
587
+ endDate: new Date()
588
+ }
573
589
  }, { new: true })
574
590
  .select({ _id: 1 })
575
591
  .exec();
576
592
  if (doc === null) {
577
593
  throw new factory.errors.NotFound(this.actionModel.modelName);
578
594
  }
579
- // return doc.toObject();
580
595
  });
581
596
  }
582
597
  /**
@@ -0,0 +1,68 @@
1
+ import type { Connection, PipelineStage } from 'mongoose';
2
+ import * as factory from '../factory';
3
+ type IMatchStage = PipelineStage.Match;
4
+ export interface IAggregateReservation {
5
+ project: {
6
+ id: string;
7
+ typeOf: factory.organizationType.Project;
8
+ };
9
+ typeOf: 'AggregateReservation';
10
+ reservationFor: {
11
+ id: string;
12
+ typeOf: factory.eventType;
13
+ startDate: Date;
14
+ };
15
+ aggregateEntranceGate?: factory.event.event.IAggregateEntranceGate;
16
+ aggregateOffer?: factory.event.event.IAggregateOffer;
17
+ }
18
+ export interface IUpdateAggregateReservationParams {
19
+ $set: {
20
+ aggregateOffer?: factory.event.event.IAggregateOffer;
21
+ aggregateEntranceGate?: factory.event.event.IAggregateEntranceGate;
22
+ };
23
+ }
24
+ type ISearchWithReservationForIdResult = Pick<IAggregateReservation, 'aggregateEntranceGate' | 'aggregateOffer'> & {
25
+ /**
26
+ * イベントID
27
+ */
28
+ id: string;
29
+ };
30
+ export interface ISortOrder {
31
+ 'reservationFor.startDate'?: factory.sortType;
32
+ }
33
+ export interface ISearchConditions {
34
+ limit?: number;
35
+ page?: number;
36
+ sort?: ISortOrder;
37
+ project?: {
38
+ id?: {
39
+ $eq?: string;
40
+ };
41
+ };
42
+ reservationFor?: {
43
+ id?: {
44
+ $eq?: string;
45
+ $in?: string[];
46
+ };
47
+ typeOf?: factory.eventType;
48
+ startFrom?: Date;
49
+ startThrough?: Date;
50
+ };
51
+ }
52
+ /**
53
+ * 予約集計リポジトリ
54
+ */
55
+ export declare class MongoRepository {
56
+ private readonly aggregateReservationModel;
57
+ constructor(connection: Connection);
58
+ static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): IMatchStage[];
59
+ /**
60
+ * 予約集計を検索する
61
+ */
62
+ searchWithReservationForId(params: ISearchConditions, inclusion: ('aggregateEntranceGate' | 'aggregateOffer')[]): Promise<ISearchWithReservationForIdResult[]>;
63
+ /**
64
+ * 予約集計を保管する
65
+ */
66
+ save(filter: Pick<IAggregateReservation, 'project' | 'reservationFor'>, update: IUpdateAggregateReservationParams): Promise<void>;
67
+ }
68
+ export {};
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MongoRepository = void 0;
13
+ const factory = require("../factory");
14
+ const settings_1 = require("../settings");
15
+ const aggregateReservation_1 = require("./mongoose/schemas/aggregateReservation");
16
+ /**
17
+ * 予約集計リポジトリ
18
+ */
19
+ class MongoRepository {
20
+ constructor(connection) {
21
+ this.aggregateReservationModel = connection.model(aggregateReservation_1.modelName, (0, aggregateReservation_1.createSchema)());
22
+ }
23
+ static CREATE_MONGO_CONDITIONS(conditions) {
24
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
25
+ const matchStages = [];
26
+ const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
27
+ if (typeof projectIdEq === 'string') {
28
+ matchStages.push({
29
+ $match: { 'project.id': { $eq: projectIdEq } }
30
+ });
31
+ }
32
+ const typeOfEq = (_c = conditions.reservationFor) === null || _c === void 0 ? void 0 : _c.typeOf;
33
+ if (typeof typeOfEq === 'string') {
34
+ matchStages.push({
35
+ $match: { 'reservationFor.typeOf': { $eq: typeOfEq } }
36
+ });
37
+ }
38
+ const idEq = (_e = (_d = conditions.reservationFor) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
39
+ if (typeof idEq === 'string') {
40
+ matchStages.push({
41
+ $match: { 'reservationFor.id': { $eq: idEq } }
42
+ });
43
+ }
44
+ const idIn = (_g = (_f = conditions.reservationFor) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$in;
45
+ if (Array.isArray(idIn)) {
46
+ matchStages.push({
47
+ $match: { 'reservationFor.id': { $in: idIn } }
48
+ });
49
+ }
50
+ const reservationForStartDateGte = (_h = conditions.reservationFor) === null || _h === void 0 ? void 0 : _h.startFrom;
51
+ if (reservationForStartDateGte instanceof Date) {
52
+ matchStages.push({
53
+ $match: { 'reservationFor.startDate': { $gte: reservationForStartDateGte } }
54
+ });
55
+ }
56
+ const reservationForStartDateLte = (_j = conditions.reservationFor) === null || _j === void 0 ? void 0 : _j.startThrough;
57
+ if (reservationForStartDateLte instanceof Date) {
58
+ matchStages.push({
59
+ $match: { 'reservationFor.startDate': { $lte: reservationForStartDateLte } }
60
+ });
61
+ }
62
+ return matchStages;
63
+ }
64
+ /**
65
+ * 予約集計を検索する
66
+ */
67
+ searchWithReservationForId(params, inclusion) {
68
+ var _a;
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const matchStages = MongoRepository.CREATE_MONGO_CONDITIONS(params);
71
+ let projection = {
72
+ _id: 0,
73
+ id: '$reservationFor.id'
74
+ };
75
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
76
+ inclusion.forEach((field) => {
77
+ projection[field] = 1;
78
+ });
79
+ }
80
+ else {
81
+ projection = {
82
+ _id: 0,
83
+ id: '$reservationFor.id',
84
+ aggregateEntranceGate: 1,
85
+ aggregateOffer: 1
86
+ };
87
+ }
88
+ const sortByStartDate = (_a = params.sort) === null || _a === void 0 ? void 0 : _a['reservationFor.startDate'];
89
+ const aggregate = this.aggregateReservationModel.aggregate([
90
+ ...matchStages,
91
+ ...(typeof sortByStartDate === 'number')
92
+ ? [{ $sort: { 'reservationFor.startDate': sortByStartDate } }]
93
+ : [],
94
+ { $project: projection }
95
+ ]);
96
+ if (typeof params.limit === 'number' && params.limit > 0) {
97
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
98
+ aggregate.limit(params.limit * page)
99
+ .skip(params.limit * (page - 1));
100
+ }
101
+ return aggregate
102
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
103
+ .exec();
104
+ });
105
+ }
106
+ /**
107
+ * 予約集計を保管する
108
+ */
109
+ save(filter, update) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ const { $set } = update;
112
+ const setOnInsert = {
113
+ project: { id: filter.project.id, typeOf: factory.organizationType.Project },
114
+ typeOf: 'AggregateReservation',
115
+ reservationFor: filter.reservationFor
116
+ };
117
+ const doc = yield this.aggregateReservationModel.findOneAndUpdate({
118
+ 'project.id': { $eq: filter.project.id },
119
+ 'reservationFor.id': { $eq: filter.reservationFor.id }
120
+ }, {
121
+ $set: Object.assign({ updatedAt: new Date() }, $set),
122
+ $setOnInsert: setOnInsert
123
+ }, {
124
+ new: true,
125
+ upsert: true,
126
+ projection: { _id: 1 }
127
+ })
128
+ .exec();
129
+ if (doc === null) {
130
+ throw new factory.errors.NotFound(this.aggregateReservationModel.modelName);
131
+ }
132
+ });
133
+ }
134
+ }
135
+ exports.MongoRepository = MongoRepository;