@chevre/domain 20.2.0-alpha.2 → 20.2.0-alpha.21

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 (67) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +82 -0
  3. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  4. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +90 -0
  5. package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -5
  6. package/example/src/chevre/migratePaymentServicePaymentUrlExpiresInSeconds.ts +77 -0
  7. package/lib/chevre/repo/action.d.ts +58 -0
  8. package/lib/chevre/repo/action.js +187 -0
  9. package/lib/chevre/repo/aggregation.d.ts +34 -0
  10. package/lib/chevre/repo/aggregation.js +64 -0
  11. package/lib/chevre/repo/event.d.ts +0 -1
  12. package/lib/chevre/repo/event.js +124 -105
  13. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  14. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  15. package/lib/chevre/repo/mongoose/model/event.js +2 -2
  16. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  17. package/lib/chevre/repo/order.d.ts +9 -0
  18. package/lib/chevre/repo/order.js +49 -0
  19. package/lib/chevre/repo/place.d.ts +15 -1
  20. package/lib/chevre/repo/place.js +205 -52
  21. package/lib/chevre/repo/product.d.ts +1 -0
  22. package/lib/chevre/repo/product.js +5 -0
  23. package/lib/chevre/repo/reservation.d.ts +0 -6
  24. package/lib/chevre/repo/reservation.js +106 -66
  25. package/lib/chevre/repo/transaction.d.ts +29 -0
  26. package/lib/chevre/repo/transaction.js +133 -0
  27. package/lib/chevre/repo/trip.js +33 -27
  28. package/lib/chevre/repository.d.ts +3 -0
  29. package/lib/chevre/repository.js +5 -1
  30. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
  31. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +34 -13
  32. package/lib/chevre/service/aggregation/system.d.ts +74 -0
  33. package/lib/chevre/service/aggregation/system.js +266 -0
  34. package/lib/chevre/service/aggregation.d.ts +2 -0
  35. package/lib/chevre/service/aggregation.js +3 -1
  36. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  37. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  38. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  39. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  40. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  41. package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -2
  42. package/lib/chevre/service/assetTransaction/reserve.js +33 -51
  43. package/lib/chevre/service/delivery/factory.js +1 -0
  44. package/lib/chevre/service/event.d.ts +2 -4
  45. package/lib/chevre/service/event.js +21 -10
  46. package/lib/chevre/service/offer/event/cancel.js +0 -1
  47. package/lib/chevre/service/offer/event/factory.js +25 -5
  48. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +116 -4
  49. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  50. package/lib/chevre/service/offer.js +28 -20
  51. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
  52. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  53. package/lib/chevre/service/order/placeOrder.js +16 -0
  54. package/lib/chevre/service/payment/any.d.ts +5 -0
  55. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  56. package/lib/chevre/service/reserve/useReservation.js +2 -1
  57. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  58. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  59. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  60. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  61. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
  62. package/lib/chevre/settings.d.ts +2 -0
  63. package/lib/chevre/settings.js +7 -2
  64. package/package.json +3 -3
  65. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  66. package/example/src/chevre/migrateEventProjectAttributes.ts +0 -57
  67. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
@@ -70,7 +70,6 @@ export declare class MongoRepository {
70
70
  save4ttts(params: {
71
71
  oldEventId: string;
72
72
  attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>;
73
- useOldEventId: boolean;
74
73
  }): Promise<factory.event.IEvent<factory.eventType.ScreeningEvent>>;
75
74
  count<T extends factory.eventType>(params: ISearchConditions<T>): Promise<number>;
76
75
  /**
@@ -24,7 +24,6 @@ exports.MongoRepository = 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';
28
27
  /**
29
28
  * イベントリポジトリ
30
29
  */
@@ -34,7 +33,7 @@ class MongoRepository {
34
33
  }
35
34
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
36
35
  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;
36
+ 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
37
  const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
39
38
  const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
40
39
  if (typeof projectIdEq === 'string') {
@@ -131,8 +130,96 @@ class MongoRepository {
131
130
  let params;
132
131
  switch (conditions.typeOf) {
133
132
  case factory.eventType.Event:
134
- // no op
135
- // params = conditions;
133
+ params = conditions;
134
+ // tslint:disable-next-line:no-single-line-block-comment
135
+ /* istanbul ignore else */
136
+ if (params.offers !== undefined) {
137
+ const itemOfferedIdIn4event = (_k = (_j = params.offers.itemOffered) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$in;
138
+ if (Array.isArray(itemOfferedIdIn4event)) {
139
+ andConditions.push({
140
+ 'offers.itemOffered.id': {
141
+ $exists: true,
142
+ $in: itemOfferedIdIn4event
143
+ }
144
+ });
145
+ }
146
+ // tslint:disable-next-line:no-single-line-block-comment
147
+ /* istanbul ignore else */
148
+ if (params.offers.itemOffered !== undefined) {
149
+ // tslint:disable-next-line:no-single-line-block-comment
150
+ /* istanbul ignore else */
151
+ if (params.offers.itemOffered.serviceOutput !== undefined) {
152
+ // tslint:disable-next-line:no-single-line-block-comment
153
+ /* istanbul ignore else */
154
+ if (params.offers.itemOffered.serviceOutput.reservedTicket !== undefined) {
155
+ // tslint:disable-next-line:no-single-line-block-comment
156
+ /* istanbul ignore else */
157
+ if (params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat !== undefined) {
158
+ // tslint:disable-next-line:no-single-line-block-comment
159
+ /* istanbul ignore else */
160
+ if (Array.isArray(params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOfs)) {
161
+ andConditions.push({
162
+ 'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
163
+ $exists: true,
164
+ $in: params.offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOfs
165
+ }
166
+ });
167
+ }
168
+ }
169
+ }
170
+ }
171
+ // tslint:disable-next-line:no-single-line-block-comment
172
+ /* istanbul ignore else */
173
+ if (params.offers.itemOffered.serviceType !== undefined) {
174
+ // tslint:disable-next-line:no-single-line-block-comment
175
+ /* istanbul ignore else */
176
+ if (Array.isArray(params.offers.itemOffered.serviceType.ids)) {
177
+ andConditions.push({
178
+ 'offers.itemOffered.serviceType.id': {
179
+ $exists: true,
180
+ $in: params.offers.itemOffered.serviceType.ids
181
+ }
182
+ });
183
+ }
184
+ }
185
+ }
186
+ }
187
+ 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;
188
+ if (typeof ((_p = sellerMakesOfferElemMatch4event === null || sellerMakesOfferElemMatch4event === void 0 ? void 0 : sellerMakesOfferElemMatch4event['availableAtOrFrom.id']) === null || _p === void 0 ? void 0 : _p.$eq) === 'string') {
189
+ andConditions.push({
190
+ 'offers.seller.makesOffer': {
191
+ $exists: true,
192
+ $elemMatch: sellerMakesOfferElemMatch4event
193
+ }
194
+ });
195
+ }
196
+ 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;
197
+ if (typeof reservationForIdentifierEq === 'string') {
198
+ andConditions.push({
199
+ 'offers.itemOffered.serviceOutput.reservationFor.identifier': {
200
+ $exists: true,
201
+ $eq: reservationForIdentifierEq
202
+ }
203
+ });
204
+ }
205
+ 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;
206
+ if (typeof reservationForArrivalBusStopBranchCodeEq === 'string') {
207
+ andConditions.push({
208
+ 'offers.itemOffered.serviceOutput.reservationFor.arrivalBusStop.branchCode': {
209
+ $exists: true,
210
+ $eq: reservationForArrivalBusStopBranchCodeEq
211
+ }
212
+ });
213
+ }
214
+ 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;
215
+ if (typeof reservationForDepartureBusStopBranchCodeEq === 'string') {
216
+ andConditions.push({
217
+ 'offers.itemOffered.serviceOutput.reservationFor.departureBusStop.branchCode': {
218
+ $exists: true,
219
+ $eq: reservationForDepartureBusStopBranchCodeEq
220
+ }
221
+ });
222
+ }
136
223
  break;
137
224
  case factory.eventType.ScreeningEvent:
138
225
  params = conditions;
@@ -158,7 +245,7 @@ class MongoRepository {
158
245
  }
159
246
  // tslint:disable-next-line:no-single-line-block-comment
160
247
  /* 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;
248
+ 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
249
  if (typeof superEventLocationIdEq === 'string') {
163
250
  andConditions.push({
164
251
  'superEvent.location.id': {
@@ -201,103 +288,35 @@ class MongoRepository {
201
288
  });
202
289
  }
203
290
  }
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
- });
291
+ 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;
292
+ if (Array.isArray(itemOfferedIdIn)) {
293
+ andConditions.push({
294
+ 'offers.itemOffered.id': {
295
+ $exists: true,
296
+ $in: itemOfferedIdIn
247
297
  }
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
- }
298
+ });
299
+ }
300
+ 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;
301
+ if (Array.isArray(itemOfferedTicketedSeatTypeOfIn)) {
302
+ andConditions.push({
303
+ 'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
304
+ $exists: true,
305
+ $in: itemOfferedTicketedSeatTypeOfIn
282
306
  }
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
- }
307
+ });
308
+ }
309
+ 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;
310
+ if (Array.isArray(itemOfferedServiceTypeIdIn)) {
311
+ andConditions.push({
312
+ 'offers.itemOffered.serviceType.id': {
313
+ $exists: true,
314
+ $in: itemOfferedServiceTypeIdIn
296
315
  }
297
- }
316
+ });
298
317
  }
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') {
318
+ 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;
319
+ if (typeof ((_24 = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _24 === void 0 ? void 0 : _24.$eq) === 'string') {
301
320
  andConditions.push({
302
321
  'offers.seller.makesOffer': {
303
322
  $exists: true,
@@ -334,7 +353,7 @@ class MongoRepository {
334
353
  ]
335
354
  });
336
355
  }
337
- const locationIdEq = (_u = (_t = params.location) === null || _t === void 0 ? void 0 : _t.id) === null || _u === void 0 ? void 0 : _u.$eq;
356
+ const locationIdEq = (_26 = (_25 = params.location) === null || _25 === void 0 ? void 0 : _25.id) === null || _26 === void 0 ? void 0 : _26.$eq;
338
357
  // tslint:disable-next-line:no-single-line-block-comment
339
358
  /* istanbul ignore else */
340
359
  if (typeof locationIdEq === 'string') {
@@ -356,7 +375,7 @@ class MongoRepository {
356
375
  });
357
376
  }
358
377
  }
359
- const workPerformedIdentifierIn = (_v = params.workPerformed) === null || _v === void 0 ? void 0 : _v.identifiers;
378
+ const workPerformedIdentifierIn = (_27 = params.workPerformed) === null || _27 === void 0 ? void 0 : _27.identifiers;
360
379
  // tslint:disable-next-line:no-single-line-block-comment
361
380
  /* istanbul ignore else */
362
381
  if (Array.isArray(workPerformedIdentifierIn)) {
@@ -367,7 +386,7 @@ class MongoRepository {
367
386
  }
368
387
  });
369
388
  }
370
- const videoFormatTypeOfEq = (_x = (_w = params.videoFormat) === null || _w === void 0 ? void 0 : _w.typeOf) === null || _x === void 0 ? void 0 : _x.$eq;
389
+ const videoFormatTypeOfEq = (_29 = (_28 = params.videoFormat) === null || _28 === void 0 ? void 0 : _28.typeOf) === null || _29 === void 0 ? void 0 : _29.$eq;
371
390
  if (typeof videoFormatTypeOfEq === 'string') {
372
391
  andConditions.push({
373
392
  'videoFormat.typeOf': {
@@ -376,7 +395,7 @@ class MongoRepository {
376
395
  }
377
396
  });
378
397
  }
379
- const videoFormatTypeOfIn = (_z = (_y = params.videoFormat) === null || _y === void 0 ? void 0 : _y.typeOf) === null || _z === void 0 ? void 0 : _z.$in;
398
+ const videoFormatTypeOfIn = (_31 = (_30 = params.videoFormat) === null || _30 === void 0 ? void 0 : _30.typeOf) === null || _31 === void 0 ? void 0 : _31.$in;
380
399
  if (Array.isArray(videoFormatTypeOfIn)) {
381
400
  andConditions.push({
382
401
  'videoFormat.typeOf': {
@@ -385,7 +404,7 @@ class MongoRepository {
385
404
  }
386
405
  });
387
406
  }
388
- const soundFormatTypeOfEq = (_1 = (_0 = params.soundFormat) === null || _0 === void 0 ? void 0 : _0.typeOf) === null || _1 === void 0 ? void 0 : _1.$eq;
407
+ const soundFormatTypeOfEq = (_33 = (_32 = params.soundFormat) === null || _32 === void 0 ? void 0 : _32.typeOf) === null || _33 === void 0 ? void 0 : _33.$eq;
389
408
  if (typeof soundFormatTypeOfEq === 'string') {
390
409
  andConditions.push({
391
410
  'soundFormat.typeOf': {
@@ -394,7 +413,7 @@ class MongoRepository {
394
413
  }
395
414
  });
396
415
  }
397
- const soundFormatTypeOfIn = (_3 = (_2 = params.soundFormat) === null || _2 === void 0 ? void 0 : _2.typeOf) === null || _3 === void 0 ? void 0 : _3.$in;
416
+ const soundFormatTypeOfIn = (_35 = (_34 = params.soundFormat) === null || _34 === void 0 ? void 0 : _34.typeOf) === null || _35 === void 0 ? void 0 : _35.$in;
398
417
  if (Array.isArray(soundFormatTypeOfIn)) {
399
418
  andConditions.push({
400
419
  'soundFormat.typeOf': {
@@ -530,7 +549,7 @@ class MongoRepository {
530
549
  return __awaiter(this, void 0, void 0, function* () {
531
550
  let doc;
532
551
  const _a = params.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
533
- const id = (params.useOldEventId) ? params.oldEventId : uniqid();
552
+ const id = uniqid();
534
553
  doc = yield this.eventModel.findOneAndUpdate({
535
554
  typeOf: params.attributes.typeOf,
536
555
  // 追加特性をキーに更新
@@ -0,0 +1,7 @@
1
+ import * as mongoose from 'mongoose';
2
+ declare const modelName = "Aggregation";
3
+ /**
4
+ * 集計スキーマ
5
+ */
6
+ declare const schema: mongoose.Schema<mongoose.Document<any, any, any>, mongoose.Model<mongoose.Document<any, any, any>, any, any>, undefined, {}>;
7
+ export { modelName, schema };
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = exports.modelName = void 0;
4
+ const mongoose = require("mongoose");
5
+ const modelName = 'Aggregation';
6
+ exports.modelName = modelName;
7
+ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
8
+ /**
9
+ * 集計スキーマ
10
+ */
11
+ const schema = new mongoose.Schema({}, {
12
+ collection: 'aggregations',
13
+ id: true,
14
+ read: 'primaryPreferred',
15
+ writeConcern: writeConcern,
16
+ strict: false,
17
+ useNestedStrict: true,
18
+ timestamps: {
19
+ createdAt: 'createdAt',
20
+ updatedAt: 'updatedAt'
21
+ },
22
+ toJSON: {
23
+ getters: false,
24
+ virtuals: false,
25
+ minimize: false,
26
+ versionKey: false
27
+ },
28
+ toObject: {
29
+ getters: false,
30
+ virtuals: true,
31
+ minimize: false,
32
+ versionKey: false
33
+ }
34
+ });
35
+ exports.schema = schema;
36
+ schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
37
+ schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
38
+ mongoose.model(modelName, schema)
39
+ .on('index',
40
+ // tslint:disable-next-line:no-single-line-block-comment
41
+ /* istanbul ignore next */
42
+ (error) => {
43
+ if (error !== undefined) {
44
+ // tslint:disable-next-line:no-console
45
+ console.error(error);
46
+ }
47
+ });
@@ -30,8 +30,8 @@ const schema = new mongoose.Schema({
30
30
  startDate: Date,
31
31
  workPerformed: mongoose.SchemaTypes.Mixed,
32
32
  superEvent: mongoose.SchemaTypes.Mixed,
33
- videoFormat: [mongoose.SchemaTypes.Mixed],
34
- soundFormat: [mongoose.SchemaTypes.Mixed],
33
+ videoFormat: mongoose.SchemaTypes.Mixed,
34
+ soundFormat: mongoose.SchemaTypes.Mixed,
35
35
  subtitleLanguage: mongoose.SchemaTypes.Mixed,
36
36
  dubLanguage: mongoose.SchemaTypes.Mixed,
37
37
  kanaName: String,
@@ -5,41 +5,17 @@ const mongoose = require("mongoose");
5
5
  const modelName = 'Telemetry';
6
6
  exports.modelName = modelName;
7
7
  const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
8
- const purposeSchema = new mongoose.Schema({
9
- typeOf: String
10
- }, {
11
- id: false,
12
- _id: false,
13
- strict: false
14
- });
15
- const objectSchema = new mongoose.Schema({
16
- measuredAt: Date
17
- }, {
18
- id: false,
19
- _id: false,
20
- strict: false
21
- });
22
- const resultSchema = new mongoose.Schema({}, {
23
- id: false,
24
- _id: false,
25
- strict: false
26
- });
27
- const errorSchema = new mongoose.Schema({}, {
28
- id: false,
29
- _id: false,
30
- strict: false
31
- });
32
8
  /**
33
9
  * 測定スキーマ
34
10
  */
35
11
  const schema = new mongoose.Schema({
36
12
  project: mongoose.SchemaTypes.Mixed,
37
- result: resultSchema,
38
- error: errorSchema,
39
- object: objectSchema,
13
+ result: mongoose.SchemaTypes.Mixed,
14
+ error: mongoose.SchemaTypes.Mixed,
15
+ object: mongoose.SchemaTypes.Mixed,
40
16
  startDate: Date,
41
17
  endDate: Date,
42
- purpose: purposeSchema
18
+ purpose: mongoose.SchemaTypes.Mixed
43
19
  }, {
44
20
  collection: 'telemetries',
45
21
  id: true,
@@ -76,4 +76,13 @@ export declare class MongoRepository {
76
76
  $in: string[];
77
77
  };
78
78
  }): Promise<(string)[]>;
79
+ aggregateOrder(params: factory.order.ISearchConditions): Promise<{
80
+ orderCount: number;
81
+ acceptedOfferCount: number;
82
+ avgAcceptedOfferCount: number;
83
+ totalPrice: number;
84
+ maxPrice: number;
85
+ minPrice: number;
86
+ avgPrice: number;
87
+ }>;
79
88
  }
@@ -920,5 +920,54 @@ class MongoRepository {
920
920
  return [...new Set(reservationNumbers)];
921
921
  });
922
922
  }
923
+ aggregateOrder(params) {
924
+ var _a, _b;
925
+ return __awaiter(this, void 0, void 0, function* () {
926
+ const aggregations = yield this.orderModel.aggregate([
927
+ {
928
+ $match: {
929
+ orderDate: {
930
+ $gte: (_a = params.orderDate) === null || _a === void 0 ? void 0 : _a.$gte,
931
+ $lte: (_b = params.orderDate) === null || _b === void 0 ? void 0 : _b.$lte
932
+ }
933
+ }
934
+ },
935
+ {
936
+ $group: {
937
+ _id: '$typeOf',
938
+ acceptedOfferCount: {
939
+ $sum: {
940
+ $cond: { if: { $isArray: '$acceptedOffers' }, then: { $size: '$acceptedOffers' }, else: 0 }
941
+ }
942
+ },
943
+ avgAcceptedOfferCount: {
944
+ $avg: {
945
+ $cond: { if: { $isArray: '$acceptedOffers' }, then: { $size: '$acceptedOffers' }, else: 0 }
946
+ }
947
+ },
948
+ orderCount: { $sum: 1 },
949
+ totalPrice: { $sum: '$price' },
950
+ maxPrice: { $max: '$price' },
951
+ minPrice: { $min: '$price' },
952
+ avgPrice: { $avg: '$price' }
953
+ }
954
+ },
955
+ {
956
+ $project: {
957
+ _id: 0,
958
+ acceptedOfferCount: '$acceptedOfferCount',
959
+ avgAcceptedOfferCount: '$avgAcceptedOfferCount',
960
+ orderCount: '$orderCount',
961
+ totalPrice: '$totalPrice',
962
+ maxPrice: '$maxPrice',
963
+ minPrice: '$minPrice',
964
+ avgPrice: '$avgPrice'
965
+ }
966
+ }
967
+ ])
968
+ .exec();
969
+ return aggregations[0];
970
+ });
971
+ }
923
972
  }
924
973
  exports.MongoRepository = MongoRepository;
@@ -7,6 +7,7 @@ declare type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.scre
7
7
  export declare class MongoRepository {
8
8
  private readonly placeModel;
9
9
  constructor(connection: Connection);
10
+ static CREATE_BUS_STOP_MONGO_CONDITIONS(params: factory.place.busStop.ISearchConditions): any[];
10
11
  static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params: factory.place.movieTheater.ISearchConditions): any[];
11
12
  /**
12
13
  * 施設を保管する
@@ -19,7 +20,6 @@ export declare class MongoRepository {
19
20
  };
20
21
  branchCode: string;
21
22
  }): Promise<factory.place.movieTheater.IPlace>;
22
- countMovieTheaters(params: factory.place.movieTheater.ISearchConditions): Promise<number>;
23
23
  /**
24
24
  * 施設検索
25
25
  */
@@ -114,6 +114,20 @@ export declare class MongoRepository {
114
114
  id: string;
115
115
  };
116
116
  }): Promise<void>;
117
+ saveBusStop(params: factory.place.busStop.IPlace): Promise<factory.place.busStop.IPlace>;
118
+ findBusStopByBranchCode(params: {
119
+ project: {
120
+ id: string;
121
+ };
122
+ branchCode: string;
123
+ }): Promise<factory.place.movieTheater.IPlace>;
124
+ searchBusStops(params: factory.place.busStop.ISearchConditions): Promise<factory.place.busStop.IPlace[]>;
125
+ findBusStopById(params: {
126
+ id: string;
127
+ }, projection?: any): Promise<factory.place.busStop.IPlace>;
128
+ deleteBusStopById(params: {
129
+ id: string;
130
+ }): Promise<void>;
117
131
  getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
118
132
  }
119
133
  export {};