@chevre/domain 24.0.0-alpha.46 → 24.0.0-alpha.48

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 (28) hide show
  1. package/lib/chevre/repo/assetTransaction/reserve.d.ts +2 -1
  2. package/lib/chevre/repo/factory/reservation/createMongoConditions.d.ts +3 -0
  3. package/lib/chevre/repo/factory/reservation/createMongoConditions.js +771 -0
  4. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +1 -1
  5. package/lib/chevre/repo/reservation.d.ts +23 -17
  6. package/lib/chevre/repo/reservation.js +8 -752
  7. package/lib/chevre/service/assetTransaction/cancelReservation/factory.d.ts +2 -2
  8. package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
  9. package/lib/chevre/service/assetTransaction/cancelReservation/start.js +1 -1
  10. package/lib/chevre/service/assetTransaction/reserve/confirm/factory.d.ts +1 -1
  11. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.d.ts +2 -2
  12. package/lib/chevre/service/offer/event/authorize/factory.d.ts +1 -1
  13. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
  14. package/lib/chevre/service/reserve/cancelReservation.d.ts +1 -1
  15. package/lib/chevre/service/reserve/cancelReservation.js +14 -10
  16. package/lib/chevre/service/reserve/confirmReservation.js +10 -6
  17. package/lib/chevre/service/reserve/factory.d.ts +2 -2
  18. package/lib/chevre/service/reserve/findByCode.d.ts +1 -2
  19. package/lib/chevre/service/reserve/findByCode.js +1 -1
  20. package/lib/chevre/service/reserve/findReservations.d.ts +19 -0
  21. package/lib/chevre/service/reserve/findReservations.js +74 -0
  22. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +1 -1
  23. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +5 -2
  24. package/lib/chevre/service/reserve/searchByOrder.d.ts +1 -1
  25. package/lib/chevre/service/reserve/useReservation.js +1 -1
  26. package/lib/chevre/service/reserve.d.ts +2 -1
  27. package/lib/chevre/service/reserve.js +3 -1
  28. package/package.json +3 -3
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ReservationRepo = void 0;
27
27
  const reservation_1 = require("./mongoose/schemas/reservation");
28
28
  const factory = __importStar(require("../factory"));
29
+ const createMongoConditions_1 = require("./factory/reservation/createMongoConditions");
29
30
  const settings_1 = require("../settings");
30
31
  /**
31
32
  * 予約リポジトリ
@@ -36,765 +37,20 @@ class ReservationRepo {
36
37
  constructor(connection) {
37
38
  this.reservationModel = connection.model(reservation_1.modelName, (0, reservation_1.createSchema)());
38
39
  }
39
- static CREATE_MONGO_CONDITIONS(params) {
40
- // MongoDB検索条件
41
- const andConditions = [
42
- { typeOf: { $eq: params.typeOf } }
43
- ];
44
- const projectIdEq = params.project?.id?.$eq;
45
- if (typeof projectIdEq === 'string') {
46
- andConditions.push({ 'project.id': { $eq: projectIdEq } });
47
- }
48
- const providerIdEq = params.provider?.id?.$eq;
49
- if (typeof providerIdEq === 'string') {
50
- andConditions.push({ 'provider.id': { $eq: providerIdEq } });
51
- }
52
- /* istanbul ignore else */
53
- if (Array.isArray(params.ids)) {
54
- andConditions.push({ _id: { $in: params.ids } });
55
- }
56
- /* istanbul ignore else */
57
- if (params.id !== undefined && params.id !== null) {
58
- if (typeof params.id.$eq === 'string') {
59
- andConditions.push({ _id: { $eq: params.id.$eq } });
60
- }
61
- if (typeof params.id.$ne === 'string') {
62
- andConditions.push({ _id: { $ne: params.id.$ne } });
63
- }
64
- if (Array.isArray(params.id.$in)) {
65
- andConditions.push({ _id: { $in: params.id.$in } });
66
- }
67
- if (Array.isArray(params.id.$nin)) {
68
- andConditions.push({ _id: { $nin: params.id.$nin } });
69
- }
70
- }
71
- /* istanbul ignore else */
72
- if (Array.isArray(params.reservationNumbers)) {
73
- andConditions.push({
74
- reservationNumber: {
75
- $in: params.reservationNumbers
76
- }
77
- });
78
- }
79
- /* istanbul ignore else */
80
- if (params.reservationNumber !== undefined && params.reservationNumber !== null) {
81
- if (typeof params.reservationNumber === 'string') {
82
- if (params.reservationNumber.length > 0) {
83
- andConditions.push({
84
- reservationNumber: {
85
- $regex: new RegExp(params.reservationNumber)
86
- }
87
- });
88
- }
89
- }
90
- else {
91
- if (typeof params.reservationNumber.$eq === 'string') {
92
- andConditions.push({
93
- reservationNumber: {
94
- $eq: params.reservationNumber.$eq
95
- }
96
- });
97
- }
98
- if (typeof params.reservationNumber.$ne === 'string') {
99
- andConditions.push({
100
- reservationNumber: {
101
- $ne: params.reservationNumber.$ne
102
- }
103
- });
104
- }
105
- if (Array.isArray(params.reservationNumber.$in)) {
106
- andConditions.push({
107
- reservationNumber: {
108
- $in: params.reservationNumber.$in
109
- }
110
- });
111
- }
112
- if (Array.isArray(params.reservationNumber.$nin)) {
113
- andConditions.push({
114
- reservationNumber: {
115
- $nin: params.reservationNumber.$nin
116
- }
117
- });
118
- }
119
- }
120
- }
121
- /* istanbul ignore else */
122
- if (params.additionalTicketText !== undefined && params.additionalTicketText !== null) {
123
- if (typeof params.additionalTicketText === 'string') {
124
- if (params.additionalTicketText.length > 0) {
125
- andConditions.push({
126
- additionalTicketText: {
127
- $exists: true,
128
- $regex: new RegExp(params.additionalTicketText)
129
- }
130
- });
131
- }
132
- }
133
- else {
134
- if (typeof params.additionalTicketText.$eq === 'string') {
135
- andConditions.push({
136
- additionalTicketText: {
137
- $exists: true,
138
- $eq: params.additionalTicketText.$eq
139
- }
140
- });
141
- }
142
- if (typeof params.additionalTicketText.$ne === 'string') {
143
- andConditions.push({
144
- additionalTicketText: {
145
- $ne: params.additionalTicketText.$ne
146
- }
147
- });
148
- }
149
- if (Array.isArray(params.additionalTicketText.$in)) {
150
- andConditions.push({
151
- additionalTicketText: {
152
- $exists: true,
153
- $in: params.additionalTicketText.$in
154
- }
155
- });
156
- }
157
- if (Array.isArray(params.additionalTicketText.$nin)) {
158
- andConditions.push({
159
- additionalTicketText: {
160
- $nin: params.additionalTicketText.$nin
161
- }
162
- });
163
- }
164
- const additionalTicketTextRegex = params.additionalTicketText?.$regex;
165
- if (typeof additionalTicketTextRegex === 'string' && additionalTicketTextRegex.length > 0) {
166
- const additionalTicketTextOptions = params.additionalTicketText?.$options;
167
- andConditions.push({
168
- additionalTicketText: {
169
- $exists: true,
170
- $regex: new RegExp(additionalTicketTextRegex),
171
- ...(typeof additionalTicketTextOptions === 'string') ? { $options: additionalTicketTextOptions } : undefined
172
- }
173
- });
174
- }
175
- }
176
- }
177
- const reservationStatusEq = params.reservationStatus?.$eq;
178
- if (typeof reservationStatusEq === 'string') {
179
- andConditions.push({ reservationStatus: { $eq: reservationStatusEq } });
180
- }
181
- const reservationStatusNe = params.reservationStatus?.$ne;
182
- if (typeof reservationStatusNe === 'string') {
183
- andConditions.push({ reservationStatus: { $ne: reservationStatusNe } });
184
- }
185
- const reservationStatusIn = params.reservationStatus?.$in;
186
- if (Array.isArray(reservationStatusIn)) {
187
- andConditions.push({ reservationStatus: { $in: reservationStatusIn } });
188
- }
189
- /* istanbul ignore else */
190
- if (Array.isArray(params.reservationStatuses)) {
191
- andConditions.push({ reservationStatus: { $in: params.reservationStatuses } });
192
- }
193
- /* istanbul ignore else */
194
- if (params.modifiedFrom instanceof Date) {
195
- andConditions.push({
196
- modifiedTime: { $gte: params.modifiedFrom }
197
- });
198
- }
199
- /* istanbul ignore else */
200
- if (params.modifiedThrough instanceof Date) {
201
- andConditions.push({
202
- modifiedTime: { $lte: params.modifiedThrough }
203
- });
204
- }
205
- /* istanbul ignore else */
206
- if (params.bookingFrom instanceof Date) {
207
- andConditions.push({
208
- bookingTime: {
209
- $exists: true,
210
- $gte: params.bookingFrom
211
- }
212
- });
213
- }
214
- /* istanbul ignore else */
215
- if (params.bookingThrough instanceof Date) {
216
- andConditions.push({
217
- bookingTime: {
218
- $exists: true,
219
- $lte: params.bookingThrough
220
- }
221
- });
222
- }
223
- switch (params.typeOf) {
224
- // case factory.reservationType.BusReservation:
225
- // const reservationForTypeOfEq = params.reservationFor?.typeOf;
226
- // if (typeof reservationForTypeOfEq === 'string') {
227
- // andConditions.push(
228
- // {
229
- // 'reservationFor.typeOf': {
230
- // $exists: true,
231
- // $eq: reservationForTypeOfEq
232
- // }
233
- // }
234
- // );
235
- // }
236
- // const reservationForIdEq = params.reservationFor?.id?.$eq;
237
- // if (typeof reservationForIdEq === 'string') {
238
- // andConditions.push(
239
- // {
240
- // 'reservationFor.id': {
241
- // $exists: true,
242
- // $eq: reservationForIdEq
243
- // }
244
- // }
245
- // );
246
- // }
247
- // const reservationForIdIn = params.reservationFor?.id?.$in;
248
- // if (Array.isArray(reservationForIdIn)) {
249
- // andConditions.push(
250
- // {
251
- // 'reservationFor.id': {
252
- // $exists: true,
253
- // $in: reservationForIdIn
254
- // }
255
- // }
256
- // );
257
- // }
258
- // break;
259
- case factory.reservationType.EventReservation:
260
- if (typeof params.reservationFor?.id === 'string') {
261
- andConditions.push({
262
- 'reservationFor.id': {
263
- $exists: true,
264
- $eq: params.reservationFor.id
265
- }
266
- });
267
- }
268
- else {
269
- const reservationForIdEq4eventReservation = params.reservationFor?.id?.$eq;
270
- if (typeof reservationForIdEq4eventReservation === 'string') {
271
- andConditions.push({
272
- 'reservationFor.id': {
273
- $exists: true,
274
- $eq: reservationForIdEq4eventReservation
275
- }
276
- });
277
- }
278
- }
279
- /* istanbul ignore else */
280
- if (params.reservationFor !== undefined) {
281
- /* istanbul ignore else */
282
- if (params.reservationFor.typeOf !== undefined) {
283
- andConditions.push({
284
- 'reservationFor.typeOf': {
285
- $exists: true,
286
- $eq: params.reservationFor.typeOf
287
- }
288
- });
289
- }
290
- /* istanbul ignore else */
291
- if (Array.isArray(params.reservationFor.ids)) {
292
- andConditions.push({
293
- 'reservationFor.id': {
294
- $exists: true,
295
- $in: params.reservationFor.ids
296
- }
297
- });
298
- }
299
- /* istanbul ignore else */
300
- if (params.reservationFor.location !== undefined) {
301
- /* istanbul ignore else */
302
- if (Array.isArray(params.reservationFor.location.ids)) {
303
- andConditions.push({
304
- 'reservationFor.location.id': {
305
- $exists: true,
306
- $in: params.reservationFor.location.ids
307
- }
308
- });
309
- }
310
- /* istanbul ignore else */
311
- if (Array.isArray(params.reservationFor.location.branchCodes)) {
312
- andConditions.push({
313
- 'reservationFor.location.branchCode': {
314
- $exists: true,
315
- $in: params.reservationFor.location.branchCodes
316
- }
317
- });
318
- }
319
- }
320
- /* istanbul ignore else */
321
- if (params.reservationFor.startFrom instanceof Date) {
322
- andConditions.push({
323
- 'reservationFor.startDate': {
324
- $exists: true,
325
- $gte: params.reservationFor.startFrom
326
- }
327
- });
328
- }
329
- /* istanbul ignore else */
330
- if (params.reservationFor.startThrough instanceof Date) {
331
- andConditions.push({
332
- 'reservationFor.startDate': {
333
- $exists: true,
334
- $lte: params.reservationFor.startThrough
335
- }
336
- });
337
- }
338
- /* istanbul ignore else */
339
- if (params.reservationFor.endFrom instanceof Date) {
340
- andConditions.push({
341
- 'reservationFor.endDate': {
342
- $exists: true,
343
- $gte: params.reservationFor.endFrom
344
- }
345
- });
346
- }
347
- /* istanbul ignore else */
348
- if (params.reservationFor.endThrough instanceof Date) {
349
- andConditions.push({
350
- 'reservationFor.endDate': {
351
- $exists: true,
352
- $lte: params.reservationFor.endThrough
353
- }
354
- });
355
- }
356
- /* istanbul ignore else */
357
- if (params.reservationFor.superEvent !== undefined) {
358
- /* istanbul ignore else */
359
- if (params.reservationFor.superEvent.id !== undefined) {
360
- andConditions.push({
361
- 'reservationFor.superEvent.id': {
362
- $exists: true,
363
- $eq: params.reservationFor.superEvent.id
364
- }
365
- });
366
- }
367
- /* istanbul ignore else */
368
- if (Array.isArray(params.reservationFor.superEvent.ids)) {
369
- andConditions.push({
370
- 'reservationFor.superEvent.id': {
371
- $exists: true,
372
- $in: params.reservationFor.superEvent.ids
373
- }
374
- });
375
- }
376
- /* istanbul ignore else */
377
- if (params.reservationFor.superEvent.location !== undefined) {
378
- /* istanbul ignore else */
379
- if (Array.isArray(params.reservationFor.superEvent.location.ids)) {
380
- andConditions.push({
381
- 'reservationFor.superEvent.location.id': {
382
- $exists: true,
383
- $in: params.reservationFor.superEvent.location.ids
384
- }
385
- });
386
- }
387
- /* istanbul ignore else */
388
- if (Array.isArray(params.reservationFor.superEvent.location.branchCodes)) {
389
- andConditions.push({
390
- 'reservationFor.superEvent.location.branchCode': {
391
- $exists: true,
392
- $in: params.reservationFor.superEvent.location.branchCodes
393
- }
394
- });
395
- }
396
- }
397
- /* istanbul ignore else */
398
- if (params.reservationFor.superEvent.workPerformed !== undefined) {
399
- /* istanbul ignore else */
400
- if (Array.isArray(params.reservationFor.superEvent.workPerformed.ids)) {
401
- andConditions.push({
402
- 'reservationFor.superEvent.workPerformed.id': {
403
- $exists: true,
404
- $in: params.reservationFor.superEvent.workPerformed.ids
405
- }
406
- });
407
- }
408
- /* istanbul ignore else */
409
- if (Array.isArray(params.reservationFor.superEvent.workPerformed.identifiers)) {
410
- andConditions.push({
411
- 'reservationFor.superEvent.workPerformed.identifier': {
412
- $exists: true,
413
- $in: params.reservationFor.superEvent.workPerformed.identifiers
414
- }
415
- });
416
- }
417
- }
418
- }
419
- }
420
- break;
421
- case factory.reservationType.ReservationPackage:
422
- break;
423
- default:
424
- }
425
- /* istanbul ignore else */
426
- if (params.reservedTicket !== undefined) {
427
- /* istanbul ignore else */
428
- if (params.reservedTicket.ticketType !== undefined) {
429
- /* istanbul ignore else */
430
- if (Array.isArray(params.reservedTicket.ticketType.ids)) {
431
- andConditions.push({
432
- 'reservedTicket.ticketType.id': {
433
- $exists: true,
434
- $in: params.reservedTicket.ticketType.ids
435
- }
436
- });
437
- }
438
- /* istanbul ignore else */
439
- if (params.reservedTicket.ticketType.category !== undefined) {
440
- /* istanbul ignore else */
441
- if (Array.isArray(params.reservedTicket.ticketType.category.ids)) {
442
- andConditions.push({
443
- 'reservedTicket.ticketType.category.id': {
444
- $exists: true,
445
- $in: params.reservedTicket.ticketType.category.ids
446
- }
447
- });
448
- }
449
- /* istanbul ignore else */
450
- if (params.reservedTicket.ticketType.category.codeValue !== undefined
451
- && params.reservedTicket.ticketType.category !== null) {
452
- if (Array.isArray(params.reservedTicket.ticketType.category.codeValue.$in)) {
453
- andConditions.push({
454
- 'reservedTicket.ticketType.category.codeValue': {
455
- $exists: true,
456
- $in: params.reservedTicket.ticketType.category.codeValue.$in
457
- }
458
- });
459
- }
460
- }
461
- }
462
- }
463
- /* istanbul ignore else */
464
- if (params.reservedTicket.ticketedSeat !== undefined) {
465
- /* istanbul ignore else */
466
- if (Array.isArray(params.reservedTicket.ticketedSeat.seatNumbers)) {
467
- andConditions.push({
468
- 'reservedTicket.ticketedSeat.seatNumber': {
469
- $exists: true,
470
- $in: params.reservedTicket.ticketedSeat.seatNumbers
471
- }
472
- });
473
- }
474
- /* istanbul ignore else */
475
- if (Array.isArray(params.reservedTicket.ticketedSeat.seatRows)) {
476
- andConditions.push({
477
- 'reservedTicket.ticketedSeat.seatRow': {
478
- $exists: true,
479
- $in: params.reservedTicket.ticketedSeat.seatRows
480
- }
481
- });
482
- }
483
- /* istanbul ignore else */
484
- if (Array.isArray(params.reservedTicket.ticketedSeat.seatSections)) {
485
- andConditions.push({
486
- 'reservedTicket.ticketedSeat.seatSection': {
487
- $exists: true,
488
- $in: params.reservedTicket.ticketedSeat.seatSections
489
- }
490
- });
491
- }
492
- /* istanbul ignore else */
493
- const ticketedSeatSeatingTypeIn = params.reservedTicket.ticketedSeat?.seatingType?.$in;
494
- if (Array.isArray(ticketedSeatSeatingTypeIn)) {
495
- andConditions.push({
496
- 'reservedTicket.ticketedSeat.seatingType': {
497
- $exists: true,
498
- $in: ticketedSeatSeatingTypeIn
499
- }
500
- });
501
- }
502
- }
503
- }
504
- const brokerIdRegex = params.broker?.id;
505
- if (typeof brokerIdRegex === 'string' && brokerIdRegex.length > 0) {
506
- andConditions.push({
507
- 'broker.id': {
508
- $exists: true,
509
- $regex: new RegExp(brokerIdRegex)
510
- }
511
- });
512
- }
513
- const brokerIdentifierAll = params.broker?.identifier?.$all;
514
- if (Array.isArray(brokerIdentifierAll)) {
515
- andConditions.push({
516
- 'broker.identifier': {
517
- $exists: true,
518
- $all: brokerIdentifierAll
519
- }
520
- });
521
- }
522
- const brokerIdentifierIn = params.broker?.identifier?.$in;
523
- if (Array.isArray(brokerIdentifierIn)) {
524
- andConditions.push({
525
- 'broker.identifier': {
526
- $exists: true,
527
- $in: brokerIdentifierIn
528
- }
529
- });
530
- }
531
- const brokerIdentifierNin = params.broker?.identifier?.$nin;
532
- if (Array.isArray(brokerIdentifierNin)) {
533
- andConditions.push({
534
- 'broker.identifier': {
535
- $nin: brokerIdentifierNin
536
- }
537
- });
538
- }
539
- const brokerIdentifierElemMatch = params.broker?.identifier?.$elemMatch;
540
- if (brokerIdentifierElemMatch !== undefined && brokerIdentifierElemMatch !== null) {
541
- andConditions.push({
542
- 'broker.identifier': {
543
- $exists: true,
544
- $elemMatch: brokerIdentifierElemMatch
545
- }
546
- });
547
- }
548
- /* istanbul ignore else */
549
- if (params.underName !== undefined) {
550
- /* istanbul ignore else */
551
- if (typeof params.underName.id === 'string' && params.underName.id.length > 0) {
552
- andConditions.push({
553
- 'underName.id': {
554
- $exists: true,
555
- $regex: new RegExp(params.underName.id)
556
- }
557
- });
558
- }
559
- /* istanbul ignore else */
560
- if (typeof params.underName.email === 'string') {
561
- if (params.underName.email.length > 0) {
562
- andConditions.push({
563
- 'underName.email': {
564
- $exists: true,
565
- $regex: new RegExp(params.underName.email)
566
- }
567
- });
568
- }
569
- }
570
- else {
571
- const emailRegex = params.underName.email?.$regex;
572
- if (typeof emailRegex === 'string' && emailRegex.length > 0) {
573
- const emailOptions = params.underName.email?.$options;
574
- andConditions.push({
575
- 'underName.email': {
576
- $exists: true,
577
- $regex: new RegExp(emailRegex),
578
- ...(typeof emailOptions === 'string') ? { $options: emailOptions } : undefined
579
- }
580
- });
581
- }
582
- }
583
- /* istanbul ignore else */
584
- if (typeof params.underName.name === 'string') {
585
- if (params.underName.name.length > 0) {
586
- andConditions.push({
587
- 'underName.name': {
588
- $exists: true,
589
- $regex: new RegExp(params.underName.name)
590
- }
591
- });
592
- }
593
- }
594
- else {
595
- const underNameNameRegex = params.underName.name?.$regex;
596
- if (typeof underNameNameRegex === 'string' && underNameNameRegex.length > 0) {
597
- const underNameNameOptions = params.underName.name?.$options;
598
- andConditions.push({
599
- 'underName.name': {
600
- $exists: true,
601
- $regex: new RegExp(underNameNameRegex),
602
- ...(typeof underNameNameOptions === 'string') ? { $options: underNameNameOptions } : undefined
603
- }
604
- });
605
- }
606
- }
607
- /* istanbul ignore else */
608
- if (typeof params.underName.telephone === 'string' && params.underName.telephone.length > 0) {
609
- andConditions.push({
610
- 'underName.telephone': {
611
- $exists: true,
612
- $regex: new RegExp(params.underName.telephone)
613
- }
614
- });
615
- }
616
- /* istanbul ignore else */
617
- if (typeof params.underName.givenName === 'string') {
618
- if (params.underName.givenName.length > 0) {
619
- andConditions.push({
620
- 'underName.givenName': {
621
- $exists: true,
622
- $regex: new RegExp(params.underName.givenName)
623
- }
624
- });
625
- }
626
- }
627
- else {
628
- const givenNameRegex = params.underName.givenName?.$regex;
629
- if (typeof givenNameRegex === 'string' && givenNameRegex.length > 0) {
630
- const givenNameOptions = params.underName.givenName?.$options;
631
- andConditions.push({
632
- 'underName.givenName': {
633
- $exists: true,
634
- $regex: new RegExp(givenNameRegex),
635
- ...(typeof givenNameOptions === 'string') ? { $options: givenNameOptions } : undefined
636
- }
637
- });
638
- }
639
- }
640
- /* istanbul ignore else */
641
- if (typeof params.underName.familyName === 'string') {
642
- if (params.underName.familyName.length > 0) {
643
- andConditions.push({
644
- 'underName.familyName': {
645
- $exists: true,
646
- $regex: new RegExp(params.underName.familyName)
647
- }
648
- });
649
- }
650
- }
651
- else {
652
- const familyNameRegex = params.underName.familyName?.$regex;
653
- if (typeof familyNameRegex === 'string' && familyNameRegex.length > 0) {
654
- const familyNameOptions = params.underName.familyName?.$options;
655
- andConditions.push({
656
- 'underName.familyName': {
657
- $exists: true,
658
- $regex: new RegExp(familyNameRegex),
659
- ...(typeof familyNameOptions === 'string') ? { $options: familyNameOptions } : undefined
660
- }
661
- });
662
- }
663
- }
664
- /* istanbul ignore else */
665
- if (params.underName.identifier !== undefined) {
666
- if (Array.isArray(params.underName.identifier.$all)) {
667
- andConditions.push({
668
- 'underName.identifier': {
669
- $exists: true,
670
- $all: params.underName.identifier.$all
671
- }
672
- });
673
- }
674
- if (Array.isArray(params.underName.identifier.$in)) {
675
- andConditions.push({
676
- 'underName.identifier': {
677
- $exists: true,
678
- $in: params.underName.identifier.$in
679
- }
680
- });
681
- }
682
- if (Array.isArray(params.underName.identifier.$nin)) {
683
- andConditions.push({
684
- 'underName.identifier': {
685
- $nin: params.underName.identifier.$nin
686
- }
687
- });
688
- }
689
- if (params.underName.identifier.$elemMatch !== undefined) {
690
- andConditions.push({
691
- 'underName.identifier': {
692
- $exists: true,
693
- $elemMatch: params.underName.identifier.$elemMatch
694
- }
695
- });
696
- }
697
- }
698
- /* istanbul ignore else */
699
- if (Array.isArray(params.underName.identifiers)) {
700
- andConditions.push({
701
- 'underName.identifier': {
702
- $exists: true,
703
- $in: params.underName.identifiers
704
- }
705
- });
706
- }
707
- }
708
- /* istanbul ignore else */
709
- if (typeof params.attended === 'boolean') {
710
- andConditions.push({
711
- attended: params.attended
712
- });
713
- }
714
- /* istanbul ignore else */
715
- if (typeof params.checkedIn === 'boolean') {
716
- andConditions.push({
717
- checkedIn: params.checkedIn
718
- });
719
- }
720
- /* istanbul ignore else */
721
- if (params.additionalProperty !== undefined) {
722
- if (Array.isArray(params.additionalProperty.$all)) {
723
- andConditions.push({
724
- additionalProperty: {
725
- $exists: true,
726
- $all: params.additionalProperty.$all
727
- }
728
- });
729
- }
730
- if (Array.isArray(params.additionalProperty.$in)) {
731
- andConditions.push({
732
- additionalProperty: {
733
- $exists: true,
734
- $in: params.additionalProperty.$in
735
- }
736
- });
737
- }
738
- if (Array.isArray(params.additionalProperty.$nin)) {
739
- andConditions.push({
740
- additionalProperty: {
741
- $nin: params.additionalProperty.$nin
742
- }
743
- });
744
- }
745
- if (params.additionalProperty.$elemMatch !== undefined) {
746
- andConditions.push({
747
- additionalProperty: {
748
- $exists: true,
749
- $elemMatch: params.additionalProperty.$elemMatch
750
- }
751
- });
752
- }
753
- }
754
- const programMembershipUsedIdentifierEq = params.programMembershipUsed?.identifier?.$eq;
755
- if (typeof programMembershipUsedIdentifierEq === 'string') {
756
- andConditions.push({
757
- 'programMembershipUsed.identifier': {
758
- $exists: true,
759
- $eq: programMembershipUsedIdentifierEq
760
- }
761
- });
762
- }
763
- const programMembershipUsedIssuedThroughServiceTypeCodeValueEq = params.programMembershipUsed?.issuedThrough?.serviceType?.codeValue?.$eq;
764
- if (typeof programMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
765
- andConditions.push({
766
- 'programMembershipUsed.issuedThrough.serviceType.codeValue': {
767
- $exists: true,
768
- $eq: programMembershipUsedIssuedThroughServiceTypeCodeValueEq
769
- }
770
- });
771
- }
772
- const appliesToMovieTicketIdentifierEq = params.price?.priceComponent?.appliesToMovieTicket?.identifier?.$eq;
773
- if (typeof appliesToMovieTicketIdentifierEq === 'string') {
774
- andConditions.push({
775
- 'price.priceComponent.appliesToMovieTicket.identifier': {
776
- $exists: true,
777
- $eq: appliesToMovieTicketIdentifierEq
778
- }
779
- });
780
- }
781
- return andConditions;
782
- }
783
40
  /**
784
41
  * 汎用予約カウント
785
42
  */
786
43
  async count(params) {
787
- const conditions = ReservationRepo.CREATE_MONGO_CONDITIONS(params);
44
+ const conditions = (0, createMongoConditions_1.CREATE_MONGO_CONDITIONS)(params);
788
45
  return this.reservationModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
789
46
  .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
790
47
  .exec();
791
48
  }
792
49
  /**
793
50
  * 予約検索
794
- * TODO reimplement
795
51
  */
796
52
  async findReservations(params, inclusion) {
797
- const conditions = ReservationRepo.CREATE_MONGO_CONDITIONS(params);
53
+ const conditions = (0, createMongoConditions_1.CREATE_MONGO_CONDITIONS)(params);
798
54
  let projection;
799
55
  if (inclusion !== undefined && inclusion !== null) {
800
56
  projection = {
@@ -850,7 +106,7 @@ class ReservationRepo {
850
106
  .lean()
851
107
  .exec();
852
108
  }
853
- async projectFieldsById(params) {
109
+ async findReservationById(params) {
854
110
  let projection = {};
855
111
  if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
856
112
  projection = {
@@ -868,7 +124,7 @@ class ReservationRepo {
868
124
  throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
869
125
  }
870
126
  const doc = await this.reservationModel.findById(params.id, projection)
871
- .lean() // 2024-08-08~
127
+ .lean()
872
128
  .exec();
873
129
  if (doc === null) {
874
130
  throw new factory.errors.NotFound(this.reservationModel.modelName);
@@ -884,7 +140,7 @@ class ReservationRepo {
884
140
  switch (subReservation.typeOf) {
885
141
  case factory.reservationType.EventReservation:
886
142
  setOnInsert = {
887
- ...subReservation, // priceは廃止予定だが、互換性維持対応としてひとまず型を強制的に合わせる
143
+ ...subReservation,
888
144
  _id: subReservation.id,
889
145
  bookingTime: params.bookingTime,
890
146
  checkedIn: false,
@@ -946,7 +202,7 @@ class ReservationRepo {
946
202
  .exec();
947
203
  // NotFoundであれば状態確認
948
204
  if (doc === null) {
949
- const { reservationStatus } = await this.projectFieldsById({ id: String(params.id), inclusion: ['reservationStatus'] });
205
+ const { reservationStatus } = await this.findReservationById({ id: String(params.id), inclusion: ['reservationStatus'] });
950
206
  if (reservationStatus === factory.reservationStatusType.ReservationCancelled) {
951
207
  // すでに取消済の場合
952
208
  return;
@@ -1058,7 +314,7 @@ class ReservationRepo {
1058
314
  // .select({ __v: 0, createdAt: 0, updatedAt: 0 })
1059
315
  .exec();
1060
316
  if (doc === null) {
1061
- return this.projectFieldsById({
317
+ return this.findReservationById({
1062
318
  id: params.id,
1063
319
  inclusion: [
1064
320
  'typeOf', 'project', 'modifiedTime', 'reservedTicket.dateUsed', 'reservationFor.id', 'reservationFor.typeOf'