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

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 (65) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +80 -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 +29 -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.js +64 -29
  24. package/lib/chevre/repo/transaction.d.ts +28 -0
  25. package/lib/chevre/repo/transaction.js +125 -0
  26. package/lib/chevre/repo/trip.js +33 -27
  27. package/lib/chevre/repository.d.ts +3 -0
  28. package/lib/chevre/repository.js +5 -1
  29. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
  30. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +34 -13
  31. package/lib/chevre/service/aggregation/system.d.ts +73 -0
  32. package/lib/chevre/service/aggregation/system.js +251 -0
  33. package/lib/chevre/service/aggregation.d.ts +2 -0
  34. package/lib/chevre/service/aggregation.js +3 -1
  35. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  36. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  37. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  38. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  39. package/lib/chevre/service/assetTransaction/reserve/factory.js +29 -1
  40. package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -2
  41. package/lib/chevre/service/assetTransaction/reserve.js +33 -51
  42. package/lib/chevre/service/delivery/factory.js +1 -0
  43. package/lib/chevre/service/event.d.ts +2 -4
  44. package/lib/chevre/service/event.js +21 -10
  45. package/lib/chevre/service/offer/event/cancel.js +0 -1
  46. package/lib/chevre/service/offer/event/factory.js +25 -5
  47. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +116 -4
  48. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  49. package/lib/chevre/service/offer.js +28 -20
  50. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
  51. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  52. package/lib/chevre/service/order/placeOrder.js +16 -0
  53. package/lib/chevre/service/payment/any.d.ts +5 -0
  54. package/lib/chevre/service/reserve/useReservation.js +2 -1
  55. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  56. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  57. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  58. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  59. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
  60. package/lib/chevre/settings.d.ts +2 -0
  61. package/lib/chevre/settings.js +7 -2
  62. package/package.json +3 -3
  63. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  64. package/example/src/chevre/migrateEventProjectAttributes.ts +0 -57
  65. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
@@ -32,15 +32,89 @@ class MongoRepository {
32
32
  this.placeModel = connection.model(place_1.modelName);
33
33
  }
34
34
  // tslint:disable-next-line:max-func-body-length
35
+ static CREATE_BUS_STOP_MONGO_CONDITIONS(params) {
36
+ var _a, _b, _c, _d, _e, _f, _g, _h;
37
+ const andConditions = [{ typeOf: { $eq: factory.placeType.BusStop } }];
38
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
39
+ if (typeof projectIdEq === 'string') {
40
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
41
+ }
42
+ const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
43
+ if (typeof branchCodeEq === 'string') {
44
+ andConditions.push({
45
+ branchCode: {
46
+ $exists: true,
47
+ $eq: branchCodeEq
48
+ }
49
+ });
50
+ }
51
+ const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
52
+ if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
53
+ andConditions.push({
54
+ branchCode: {
55
+ $exists: true,
56
+ $regex: new RegExp(branchCodeRegex)
57
+ }
58
+ });
59
+ }
60
+ const branchCodeIn = (_e = params.branchCode) === null || _e === void 0 ? void 0 : _e.$in;
61
+ if (Array.isArray(branchCodeIn)) {
62
+ andConditions.push({
63
+ branchCode: {
64
+ $exists: true,
65
+ $in: branchCodeIn
66
+ }
67
+ });
68
+ }
69
+ // tslint:disable-next-line:no-single-line-block-comment
70
+ /* istanbul ignore else */
71
+ const idEq = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$eq;
72
+ if (typeof idEq === 'string') {
73
+ andConditions.push({
74
+ _id: {
75
+ $eq: idEq
76
+ }
77
+ });
78
+ }
79
+ const idIn = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$in;
80
+ if (Array.isArray(idIn)) {
81
+ andConditions.push({
82
+ _id: {
83
+ $in: idIn
84
+ }
85
+ });
86
+ }
87
+ const nameRegex = (_h = params.name) === null || _h === void 0 ? void 0 : _h.$regex;
88
+ // tslint:disable-next-line:no-single-line-block-comment
89
+ /* istanbul ignore else */
90
+ if (typeof nameRegex === 'string' && nameRegex.length > 0) {
91
+ andConditions.push({
92
+ $or: [
93
+ {
94
+ 'name.ja': {
95
+ $exists: true,
96
+ $regex: new RegExp(nameRegex)
97
+ }
98
+ },
99
+ {
100
+ 'name.en': {
101
+ $exists: true,
102
+ $regex: new RegExp(nameRegex)
103
+ }
104
+ }
105
+ ]
106
+ });
107
+ }
108
+ return andConditions;
109
+ }
110
+ // tslint:disable-next-line:max-func-body-length
35
111
  static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params) {
36
112
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
37
113
  // MongoDB検索条件
38
114
  const andConditions = [{ typeOf: { $eq: factory.placeType.MovieTheater } }];
39
115
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
40
116
  if (typeof projectIdEq === 'string') {
41
- andConditions.push({
42
- 'project.id': { $eq: projectIdEq }
43
- });
117
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
44
118
  }
45
119
  const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
46
120
  if (typeof branchCodeEq === 'string') {
@@ -173,6 +247,7 @@ class MongoRepository {
173
247
  findMovieTheaterByBranchCode(params) {
174
248
  return __awaiter(this, void 0, void 0, function* () {
175
249
  return this.placeModel.findOne({
250
+ typeOf: { $eq: factory.placeType.MovieTheater },
176
251
  'project.id': { $eq: params.project.id },
177
252
  branchCode: { $eq: params.branchCode }
178
253
  })
@@ -185,14 +260,12 @@ class MongoRepository {
185
260
  });
186
261
  });
187
262
  }
188
- countMovieTheaters(params) {
189
- return __awaiter(this, void 0, void 0, function* () {
190
- const conditions = MongoRepository.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
191
- return this.placeModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
192
- .setOptions({ maxTimeMS: 10000 })
193
- .exec();
194
- });
195
- }
263
+ // public async countMovieTheaters(params: factory.place.movieTheater.ISearchConditions): Promise<number> {
264
+ // const conditions = MongoRepository.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
265
+ // return this.placeModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
266
+ // .setOptions({ maxTimeMS: 10000 })
267
+ // .exec();
268
+ // }
196
269
  /**
197
270
  * 施設検索
198
271
  */
@@ -226,7 +299,10 @@ class MongoRepository {
226
299
  */
227
300
  findById(params, projection) {
228
301
  return __awaiter(this, void 0, void 0, function* () {
229
- const doc = yield this.placeModel.findOne({ _id: params.id }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
302
+ const doc = yield this.placeModel.findOne({
303
+ typeOf: { $eq: factory.placeType.MovieTheater },
304
+ _id: { $eq: params.id }
305
+ }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
230
306
  .exec();
231
307
  if (doc === null) {
232
308
  throw new factory.errors.NotFound(this.placeModel.modelName);
@@ -237,7 +313,8 @@ class MongoRepository {
237
313
  deleteMovieTheaterById(params) {
238
314
  return __awaiter(this, void 0, void 0, function* () {
239
315
  yield this.placeModel.findOneAndDelete({
240
- _id: params.id
316
+ typeOf: { $eq: factory.placeType.MovieTheater },
317
+ _id: { $eq: params.id }
241
318
  })
242
319
  .exec()
243
320
  .then((doc) => {
@@ -435,22 +512,17 @@ class MongoRepository {
435
512
  }
436
513
  // tslint:disable-next-line:max-func-body-length
437
514
  searchScreeningRoomSections(searchConditions) {
438
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
515
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
439
516
  return __awaiter(this, void 0, void 0, function* () {
440
- const matchStages = [];
441
- if (searchConditions.project !== undefined) {
442
- if (searchConditions.project.id !== undefined) {
443
- if (typeof searchConditions.project.id.$eq === 'string') {
444
- matchStages.push({
445
- $match: {
446
- 'project.id': { $eq: searchConditions.project.id.$eq }
447
- }
448
- });
449
- }
450
- }
517
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
518
+ const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
519
+ if (typeof projectIdEq === 'string') {
520
+ matchStages.push({
521
+ $match: { 'project.id': { $eq: projectIdEq } }
522
+ });
451
523
  }
452
524
  // 施設コード
453
- const movieTheaterBranchCodeEq = (_c = (_b = (_a = searchConditions.containedInPlace) === null || _a === void 0 ? void 0 : _a.containedInPlace) === null || _b === void 0 ? void 0 : _b.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
525
+ const movieTheaterBranchCodeEq = (_e = (_d = (_c = searchConditions.containedInPlace) === null || _c === void 0 ? void 0 : _c.containedInPlace) === null || _d === void 0 ? void 0 : _d.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
454
526
  if (typeof movieTheaterBranchCodeEq === 'string') {
455
527
  matchStages.push({
456
528
  $match: {
@@ -462,7 +534,7 @@ class MongoRepository {
462
534
  });
463
535
  }
464
536
  // スクリーンコード
465
- const containedInPlaceBranchCodeEq = (_e = (_d = searchConditions.containedInPlace) === null || _d === void 0 ? void 0 : _d.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
537
+ const containedInPlaceBranchCodeEq = (_g = (_f = searchConditions.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
466
538
  if (typeof containedInPlaceBranchCodeEq === 'string') {
467
539
  matchStages.push({
468
540
  $match: {
@@ -474,7 +546,7 @@ class MongoRepository {
474
546
  });
475
547
  }
476
548
  // セクションコード
477
- const sectionBranchCodeEq = (_f = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _f === void 0 ? void 0 : _f.$eq;
549
+ const sectionBranchCodeEq = (_h = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$eq;
478
550
  if (typeof sectionBranchCodeEq === 'string') {
479
551
  matchStages.push({
480
552
  $match: {
@@ -485,7 +557,7 @@ class MongoRepository {
485
557
  }
486
558
  });
487
559
  }
488
- const nameCodeRegex = (_g = searchConditions.name) === null || _g === void 0 ? void 0 : _g.$regex;
560
+ const nameCodeRegex = (_j = searchConditions.name) === null || _j === void 0 ? void 0 : _j.$regex;
489
561
  if (typeof nameCodeRegex === 'string') {
490
562
  matchStages.push({
491
563
  $match: {
@@ -506,7 +578,7 @@ class MongoRepository {
506
578
  }
507
579
  });
508
580
  }
509
- const branchCodeRegex = (_h = searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$regex;
581
+ const branchCodeRegex = (_k = searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$regex;
510
582
  if (typeof branchCodeRegex === 'string') {
511
583
  matchStages.push({
512
584
  $match: {
@@ -517,7 +589,7 @@ class MongoRepository {
517
589
  }
518
590
  });
519
591
  }
520
- const additionalPropertyElemMatch = (_j = searchConditions.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
592
+ const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
521
593
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
522
594
  matchStages.push({
523
595
  $match: {
@@ -543,7 +615,7 @@ class MongoRepository {
543
615
  branchCode: '$branchCode',
544
616
  name: '$name'
545
617
  }
546
- }, additionalProperty: '$containsPlace.containsPlace.additionalProperty' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.seatCount) === 1)
618
+ }, additionalProperty: '$containsPlace.containsPlace.additionalProperty' }, (((_m = searchConditions.$projection) === null || _m === void 0 ? void 0 : _m.seatCount) === 1)
547
619
  ? {
548
620
  seatCount: {
549
621
  $cond: {
@@ -595,7 +667,7 @@ class MongoRepository {
595
667
  searchScreeningRooms(searchConditions) {
596
668
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
597
669
  return __awaiter(this, void 0, void 0, function* () {
598
- const matchStages = [];
670
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
599
671
  const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
600
672
  if (typeof projectIdEq === 'string') {
601
673
  matchStages.push({
@@ -855,21 +927,16 @@ class MongoRepository {
855
927
  }
856
928
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
857
929
  searchSeats(params) {
858
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
930
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
859
931
  return __awaiter(this, void 0, void 0, function* () {
860
- const matchStages = [];
861
- if (params.project !== undefined) {
862
- if (params.project.id !== undefined) {
863
- if (typeof params.project.id.$eq === 'string') {
864
- matchStages.push({
865
- $match: {
866
- 'project.id': { $eq: params.project.id.$eq }
867
- }
868
- });
869
- }
870
- }
932
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
933
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
934
+ if (typeof projectIdEq === 'string') {
935
+ matchStages.push({
936
+ $match: { 'project.id': { $eq: projectIdEq } }
937
+ });
871
938
  }
872
- const containedInPlaceBranchCodeEq = (_b = (_a = params.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode) === null || _b === void 0 ? void 0 : _b.$eq;
939
+ const containedInPlaceBranchCodeEq = (_d = (_c = params.containedInPlace) === null || _c === void 0 ? void 0 : _c.branchCode) === null || _d === void 0 ? void 0 : _d.$eq;
873
940
  if (typeof containedInPlaceBranchCodeEq === 'string') {
874
941
  matchStages.push({
875
942
  $match: {
@@ -880,7 +947,7 @@ class MongoRepository {
880
947
  }
881
948
  });
882
949
  }
883
- const containedInPlaceBranchCodeIn = (_d = (_c = params.containedInPlace) === null || _c === void 0 ? void 0 : _c.branchCode) === null || _d === void 0 ? void 0 : _d.$in;
950
+ const containedInPlaceBranchCodeIn = (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
884
951
  if (Array.isArray(containedInPlaceBranchCodeIn)) {
885
952
  matchStages.push({
886
953
  $match: {
@@ -934,7 +1001,7 @@ class MongoRepository {
934
1001
  });
935
1002
  }
936
1003
  }
937
- const branchCodeIn = (_e = params.branchCode) === null || _e === void 0 ? void 0 : _e.$in;
1004
+ const branchCodeIn = (_g = params.branchCode) === null || _g === void 0 ? void 0 : _g.$in;
938
1005
  if (Array.isArray(branchCodeIn)) {
939
1006
  matchStages.push({
940
1007
  $match: {
@@ -945,7 +1012,7 @@ class MongoRepository {
945
1012
  }
946
1013
  });
947
1014
  }
948
- const branchCodeRegex = (_f = params.branchCode) === null || _f === void 0 ? void 0 : _f.$regex;
1015
+ const branchCodeRegex = (_h = params.branchCode) === null || _h === void 0 ? void 0 : _h.$regex;
949
1016
  if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
950
1017
  matchStages.push({
951
1018
  $match: {
@@ -956,7 +1023,7 @@ class MongoRepository {
956
1023
  }
957
1024
  });
958
1025
  }
959
- const nameRegex = (_g = params.name) === null || _g === void 0 ? void 0 : _g.$regex;
1026
+ const nameRegex = (_j = params.name) === null || _j === void 0 ? void 0 : _j.$regex;
960
1027
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
961
1028
  matchStages.push({
962
1029
  $match: {
@@ -977,7 +1044,7 @@ class MongoRepository {
977
1044
  }
978
1045
  });
979
1046
  }
980
- const seatingTypeEq = (_h = params.seatingType) === null || _h === void 0 ? void 0 : _h.$eq;
1047
+ const seatingTypeEq = (_k = params.seatingType) === null || _k === void 0 ? void 0 : _k.$eq;
981
1048
  if (typeof seatingTypeEq === 'string') {
982
1049
  matchStages.push({
983
1050
  $match: {
@@ -993,7 +1060,7 @@ class MongoRepository {
993
1060
  && params.$projection['containedInPlace.containedInPlace'] === 0) {
994
1061
  includeScreeningRooms = false;
995
1062
  }
996
- const additionalPropertyElemMatch = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
1063
+ const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
997
1064
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
998
1065
  matchStages.push({
999
1066
  $match: {
@@ -1078,6 +1145,92 @@ class MongoRepository {
1078
1145
  .exec();
1079
1146
  });
1080
1147
  }
1148
+ saveBusStop(params) {
1149
+ return __awaiter(this, void 0, void 0, function* () {
1150
+ let doc;
1151
+ if (typeof params.id !== 'string' || params.id.length === 0) {
1152
+ doc = yield this.placeModel.create(params);
1153
+ }
1154
+ else {
1155
+ // 上書き禁止属性を除外(2022-08-24~)
1156
+ const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
1157
+ doc = yield this.placeModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
1158
+ .exec();
1159
+ }
1160
+ if (doc === null) {
1161
+ throw new factory.errors.NotFound(this.placeModel.modelName);
1162
+ }
1163
+ return doc.toObject();
1164
+ });
1165
+ }
1166
+ findBusStopByBranchCode(params) {
1167
+ return __awaiter(this, void 0, void 0, function* () {
1168
+ return this.placeModel.findOne({
1169
+ typeOf: { $eq: factory.placeType.BusStop },
1170
+ 'project.id': { $eq: params.project.id },
1171
+ branchCode: { $eq: params.branchCode }
1172
+ })
1173
+ .exec()
1174
+ .then((doc) => {
1175
+ if (doc === null) {
1176
+ throw new factory.errors.NotFound(`${factory.placeType.BusStop} ${params.branchCode}`);
1177
+ }
1178
+ return doc.toObject();
1179
+ });
1180
+ });
1181
+ }
1182
+ searchBusStops(params) {
1183
+ return __awaiter(this, void 0, void 0, function* () {
1184
+ const conditions = MongoRepository.CREATE_BUS_STOP_MONGO_CONDITIONS(params);
1185
+ // containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
1186
+ const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
1187
+ __v: 0,
1188
+ createdAt: 0,
1189
+ updatedAt: 0,
1190
+ containsPlace: 0
1191
+ });
1192
+ if (typeof params.limit === 'number') {
1193
+ const page = (typeof params.page === 'number') ? params.page : 1;
1194
+ query.limit(params.limit)
1195
+ .skip(params.limit * (page - 1));
1196
+ }
1197
+ // tslint:disable-next-line:no-single-line-block-comment
1198
+ /* istanbul ignore else */
1199
+ if (params.sort !== undefined) {
1200
+ query.sort(params.sort);
1201
+ }
1202
+ return query.setOptions({ maxTimeMS: 10000 })
1203
+ .exec()
1204
+ .then((docs) => docs.map((doc) => doc.toObject()));
1205
+ });
1206
+ }
1207
+ findBusStopById(params, projection) {
1208
+ return __awaiter(this, void 0, void 0, function* () {
1209
+ const doc = yield this.placeModel.findOne({
1210
+ typeOf: { $eq: factory.placeType.BusStop },
1211
+ _id: { $eq: params.id }
1212
+ }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
1213
+ .exec();
1214
+ if (doc === null) {
1215
+ throw new factory.errors.NotFound(this.placeModel.modelName);
1216
+ }
1217
+ return doc.toObject();
1218
+ });
1219
+ }
1220
+ deleteBusStopById(params) {
1221
+ return __awaiter(this, void 0, void 0, function* () {
1222
+ yield this.placeModel.findOneAndDelete({
1223
+ typeOf: { $eq: factory.placeType.BusStop },
1224
+ _id: { $eq: params.id }
1225
+ })
1226
+ .exec()
1227
+ .then((doc) => {
1228
+ if (doc === null) {
1229
+ throw new factory.errors.NotFound(this.placeModel.modelName);
1230
+ }
1231
+ });
1232
+ });
1233
+ }
1081
1234
  getCursor(conditions, projection) {
1082
1235
  return this.placeModel.find(conditions, projection)
1083
1236
  .sort({ branchCode: factory.sortType.Ascending })
@@ -52,4 +52,5 @@ export declare class MongoRepository {
52
52
  id: string;
53
53
  };
54
54
  }): Promise<void>;
55
+ getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
55
56
  }
@@ -251,5 +251,10 @@ class MongoRepository {
251
251
  .exec();
252
252
  });
253
253
  }
254
+ getCursor(conditions, projection) {
255
+ return this.productModel.find(conditions, projection)
256
+ .sort({ productID: factory.sortType.Ascending })
257
+ .cursor();
258
+ }
254
259
  }
255
260
  exports.MongoRepository = MongoRepository;
@@ -21,7 +21,7 @@ class MongoRepository {
21
21
  }
22
22
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
23
23
  static CREATE_MONGO_CONDITIONS(params) {
24
- 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;
24
+ 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;
25
25
  // MongoDB検索条件
26
26
  const andConditions = [
27
27
  { typeOf: params.typeOf }
@@ -233,9 +233,54 @@ class MongoRepository {
233
233
  }
234
234
  switch (params.typeOf) {
235
235
  case factory.reservationType.BusReservation:
236
- // no op
236
+ const reservationForTypeOfEq = (_h = params.reservationFor) === null || _h === void 0 ? void 0 : _h.typeOf;
237
+ if (typeof reservationForTypeOfEq === 'string') {
238
+ andConditions.push({
239
+ 'reservationFor.typeOf': {
240
+ $exists: true,
241
+ $eq: reservationForTypeOfEq
242
+ }
243
+ });
244
+ }
245
+ const reservationForIdEq = (_k = (_j = params.reservationFor) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$eq;
246
+ if (typeof reservationForIdEq === 'string') {
247
+ andConditions.push({
248
+ 'reservationFor.id': {
249
+ $exists: true,
250
+ $eq: reservationForIdEq
251
+ }
252
+ });
253
+ }
254
+ const reservationForIdIn = (_m = (_l = params.reservationFor) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$in;
255
+ if (Array.isArray(reservationForIdIn)) {
256
+ andConditions.push({
257
+ 'reservationFor.id': {
258
+ $exists: true,
259
+ $in: reservationForIdIn
260
+ }
261
+ });
262
+ }
237
263
  break;
238
264
  case factory.reservationType.EventReservation:
265
+ if (typeof ((_o = params.reservationFor) === null || _o === void 0 ? void 0 : _o.id) === 'string') {
266
+ andConditions.push({
267
+ 'reservationFor.id': {
268
+ $exists: true,
269
+ $eq: params.reservationFor.id
270
+ }
271
+ });
272
+ }
273
+ else {
274
+ const reservationForIdEq4eventReservation = (_q = (_p = params.reservationFor) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
275
+ if (typeof reservationForIdEq4eventReservation === 'string') {
276
+ andConditions.push({
277
+ 'reservationFor.id': {
278
+ $exists: true,
279
+ $eq: reservationForIdEq4eventReservation
280
+ }
281
+ });
282
+ }
283
+ }
239
284
  // tslint:disable-next-line:no-single-line-block-comment
240
285
  /* istanbul ignore else */
241
286
  if (params.reservationFor !== undefined) {
@@ -251,16 +296,6 @@ class MongoRepository {
251
296
  }
252
297
  // tslint:disable-next-line:no-single-line-block-comment
253
298
  /* istanbul ignore else */
254
- if (params.reservationFor.id !== undefined) {
255
- andConditions.push({
256
- 'reservationFor.id': {
257
- $exists: true,
258
- $eq: params.reservationFor.id
259
- }
260
- });
261
- }
262
- // tslint:disable-next-line:no-single-line-block-comment
263
- /* istanbul ignore else */
264
299
  if (Array.isArray(params.reservationFor.ids)) {
265
300
  andConditions.push({
266
301
  'reservationFor.id': {
@@ -490,7 +525,7 @@ class MongoRepository {
490
525
  }
491
526
  // tslint:disable-next-line:no-single-line-block-comment
492
527
  /* istanbul ignore else */
493
- const ticketedSeatSeatingTypeIn = (_j = (_h = params.reservedTicket.ticketedSeat) === null || _h === void 0 ? void 0 : _h.seatingType) === null || _j === void 0 ? void 0 : _j.$in;
528
+ const ticketedSeatSeatingTypeIn = (_s = (_r = params.reservedTicket.ticketedSeat) === null || _r === void 0 ? void 0 : _r.seatingType) === null || _s === void 0 ? void 0 : _s.$in;
494
529
  if (Array.isArray(ticketedSeatSeatingTypeIn)) {
495
530
  andConditions.push({
496
531
  'reservedTicket.ticketedSeat.seatingType': {
@@ -501,7 +536,7 @@ class MongoRepository {
501
536
  }
502
537
  }
503
538
  }
504
- const brokerIdRegex = (_k = params.broker) === null || _k === void 0 ? void 0 : _k.id;
539
+ const brokerIdRegex = (_t = params.broker) === null || _t === void 0 ? void 0 : _t.id;
505
540
  if (typeof brokerIdRegex === 'string' && brokerIdRegex.length > 0) {
506
541
  andConditions.push({
507
542
  'broker.id': {
@@ -510,7 +545,7 @@ class MongoRepository {
510
545
  }
511
546
  });
512
547
  }
513
- const brokerIdentifierAll = (_m = (_l = params.broker) === null || _l === void 0 ? void 0 : _l.identifier) === null || _m === void 0 ? void 0 : _m.$all;
548
+ const brokerIdentifierAll = (_v = (_u = params.broker) === null || _u === void 0 ? void 0 : _u.identifier) === null || _v === void 0 ? void 0 : _v.$all;
514
549
  if (Array.isArray(brokerIdentifierAll)) {
515
550
  andConditions.push({
516
551
  'broker.identifier': {
@@ -519,7 +554,7 @@ class MongoRepository {
519
554
  }
520
555
  });
521
556
  }
522
- const brokerIdentifierIn = (_p = (_o = params.broker) === null || _o === void 0 ? void 0 : _o.identifier) === null || _p === void 0 ? void 0 : _p.$in;
557
+ const brokerIdentifierIn = (_x = (_w = params.broker) === null || _w === void 0 ? void 0 : _w.identifier) === null || _x === void 0 ? void 0 : _x.$in;
523
558
  if (Array.isArray(brokerIdentifierIn)) {
524
559
  andConditions.push({
525
560
  'broker.identifier': {
@@ -528,7 +563,7 @@ class MongoRepository {
528
563
  }
529
564
  });
530
565
  }
531
- const brokerIdentifierNin = (_r = (_q = params.broker) === null || _q === void 0 ? void 0 : _q.identifier) === null || _r === void 0 ? void 0 : _r.$nin;
566
+ const brokerIdentifierNin = (_z = (_y = params.broker) === null || _y === void 0 ? void 0 : _y.identifier) === null || _z === void 0 ? void 0 : _z.$nin;
532
567
  if (Array.isArray(brokerIdentifierNin)) {
533
568
  andConditions.push({
534
569
  'broker.identifier': {
@@ -536,7 +571,7 @@ class MongoRepository {
536
571
  }
537
572
  });
538
573
  }
539
- const brokerIdentifierElemMatch = (_t = (_s = params.broker) === null || _s === void 0 ? void 0 : _s.identifier) === null || _t === void 0 ? void 0 : _t.$elemMatch;
574
+ const brokerIdentifierElemMatch = (_1 = (_0 = params.broker) === null || _0 === void 0 ? void 0 : _0.identifier) === null || _1 === void 0 ? void 0 : _1.$elemMatch;
540
575
  if (brokerIdentifierElemMatch !== undefined && brokerIdentifierElemMatch !== null) {
541
576
  andConditions.push({
542
577
  'broker.identifier': {
@@ -571,9 +606,9 @@ class MongoRepository {
571
606
  }
572
607
  }
573
608
  else {
574
- const emailRegex = (_u = params.underName.email) === null || _u === void 0 ? void 0 : _u.$regex;
609
+ const emailRegex = (_2 = params.underName.email) === null || _2 === void 0 ? void 0 : _2.$regex;
575
610
  if (typeof emailRegex === 'string' && emailRegex.length > 0) {
576
- const emailOptions = (_v = params.underName.email) === null || _v === void 0 ? void 0 : _v.$options;
611
+ const emailOptions = (_3 = params.underName.email) === null || _3 === void 0 ? void 0 : _3.$options;
577
612
  andConditions.push({
578
613
  'underName.email': Object.assign({ $exists: true, $regex: new RegExp(emailRegex) }, (typeof emailOptions === 'string') ? { $options: emailOptions } : undefined)
579
614
  });
@@ -592,9 +627,9 @@ class MongoRepository {
592
627
  }
593
628
  }
594
629
  else {
595
- const underNameNameRegex = (_w = params.underName.name) === null || _w === void 0 ? void 0 : _w.$regex;
630
+ const underNameNameRegex = (_4 = params.underName.name) === null || _4 === void 0 ? void 0 : _4.$regex;
596
631
  if (typeof underNameNameRegex === 'string' && underNameNameRegex.length > 0) {
597
- const underNameNameOptions = (_x = params.underName.name) === null || _x === void 0 ? void 0 : _x.$options;
632
+ const underNameNameOptions = (_5 = params.underName.name) === null || _5 === void 0 ? void 0 : _5.$options;
598
633
  andConditions.push({
599
634
  'underName.name': Object.assign({ $exists: true, $regex: new RegExp(underNameNameRegex) }, (typeof underNameNameOptions === 'string') ? { $options: underNameNameOptions } : undefined)
600
635
  });
@@ -623,9 +658,9 @@ class MongoRepository {
623
658
  }
624
659
  }
625
660
  else {
626
- const givenNameRegex = (_y = params.underName.givenName) === null || _y === void 0 ? void 0 : _y.$regex;
661
+ const givenNameRegex = (_6 = params.underName.givenName) === null || _6 === void 0 ? void 0 : _6.$regex;
627
662
  if (typeof givenNameRegex === 'string' && givenNameRegex.length > 0) {
628
- const givenNameOptions = (_z = params.underName.givenName) === null || _z === void 0 ? void 0 : _z.$options;
663
+ const givenNameOptions = (_7 = params.underName.givenName) === null || _7 === void 0 ? void 0 : _7.$options;
629
664
  andConditions.push({
630
665
  'underName.givenName': Object.assign({ $exists: true, $regex: new RegExp(givenNameRegex) }, (typeof givenNameOptions === 'string') ? { $options: givenNameOptions } : undefined)
631
666
  });
@@ -644,9 +679,9 @@ class MongoRepository {
644
679
  }
645
680
  }
646
681
  else {
647
- const familyNameRegex = (_0 = params.underName.familyName) === null || _0 === void 0 ? void 0 : _0.$regex;
682
+ const familyNameRegex = (_8 = params.underName.familyName) === null || _8 === void 0 ? void 0 : _8.$regex;
648
683
  if (typeof familyNameRegex === 'string' && familyNameRegex.length > 0) {
649
- const familyNameOptions = (_1 = params.underName.familyName) === null || _1 === void 0 ? void 0 : _1.$options;
684
+ const familyNameOptions = (_9 = params.underName.familyName) === null || _9 === void 0 ? void 0 : _9.$options;
650
685
  andConditions.push({
651
686
  'underName.familyName': Object.assign({ $exists: true, $regex: new RegExp(familyNameRegex) }, (typeof familyNameOptions === 'string') ? { $options: familyNameOptions } : undefined)
652
687
  });
@@ -747,7 +782,7 @@ class MongoRepository {
747
782
  });
748
783
  }
749
784
  }
750
- const programMembershipUsedIdentifierEq = (_3 = (_2 = params.programMembershipUsed) === null || _2 === void 0 ? void 0 : _2.identifier) === null || _3 === void 0 ? void 0 : _3.$eq;
785
+ const programMembershipUsedIdentifierEq = (_11 = (_10 = params.programMembershipUsed) === null || _10 === void 0 ? void 0 : _10.identifier) === null || _11 === void 0 ? void 0 : _11.$eq;
751
786
  if (typeof programMembershipUsedIdentifierEq === 'string') {
752
787
  andConditions.push({
753
788
  'programMembershipUsed.identifier': {
@@ -756,7 +791,7 @@ class MongoRepository {
756
791
  }
757
792
  });
758
793
  }
759
- const programMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_7 = (_6 = (_5 = (_4 = params.programMembershipUsed) === null || _4 === void 0 ? void 0 : _4.issuedThrough) === null || _5 === void 0 ? void 0 : _5.serviceType) === null || _6 === void 0 ? void 0 : _6.codeValue) === null || _7 === void 0 ? void 0 : _7.$eq;
794
+ const programMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_15 = (_14 = (_13 = (_12 = params.programMembershipUsed) === null || _12 === void 0 ? void 0 : _12.issuedThrough) === null || _13 === void 0 ? void 0 : _13.serviceType) === null || _14 === void 0 ? void 0 : _14.codeValue) === null || _15 === void 0 ? void 0 : _15.$eq;
760
795
  if (typeof programMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
761
796
  andConditions.push({
762
797
  'programMembershipUsed.issuedThrough.serviceType.codeValue': {
@@ -765,7 +800,7 @@ class MongoRepository {
765
800
  }
766
801
  });
767
802
  }
768
- const appliesToMovieTicketIdentifierEq = (_11 = (_10 = (_9 = (_8 = params.price) === null || _8 === void 0 ? void 0 : _8.priceComponent) === null || _9 === void 0 ? void 0 : _9.appliesToMovieTicket) === null || _10 === void 0 ? void 0 : _10.identifier) === null || _11 === void 0 ? void 0 : _11.$eq;
803
+ const appliesToMovieTicketIdentifierEq = (_19 = (_18 = (_17 = (_16 = params.price) === null || _16 === void 0 ? void 0 : _16.priceComponent) === null || _17 === void 0 ? void 0 : _17.appliesToMovieTicket) === null || _18 === void 0 ? void 0 : _18.identifier) === null || _19 === void 0 ? void 0 : _19.$eq;
769
804
  if (typeof appliesToMovieTicketIdentifierEq === 'string') {
770
805
  andConditions.push({
771
806
  'price.priceComponent.appliesToMovieTicket.identifier': {