@chevre/domain 22.3.0-alpha.2 → 22.3.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 (123) hide show
  1. package/example/src/chevre/aggregateScreeningEventMaxVersion.ts +36 -0
  2. package/example/src/chevre/aggregation/createAggregateEventTasks.ts +1 -1
  3. package/example/src/chevre/importEventsFromCOA.ts +6 -3
  4. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +126 -0
  5. package/example/src/chevre/migrateEventSeries2secondary.ts +70 -0
  6. package/example/src/chevre/projectFields.ts +5 -15
  7. package/example/src/chevre/syncEventSeries2secondary.ts +20 -0
  8. package/example/src/chevre/unsetUnnecessaryFields.ts +6 -6
  9. package/example/src/chevre/upsertScreeningEventSeriesByVersion.ts +2 -2
  10. package/lib/chevre/repo/account.d.ts +25 -1
  11. package/lib/chevre/repo/accountTitle.d.ts +4 -4
  12. package/lib/chevre/repo/accountingReport.d.ts +25 -1
  13. package/lib/chevre/repo/action.d.ts +11 -11
  14. package/lib/chevre/repo/action.js +4 -1
  15. package/lib/chevre/repo/additionalProperty.d.ts +28 -0
  16. package/lib/chevre/repo/additionalProperty.js +6 -0
  17. package/lib/chevre/repo/aggregateOffer.d.ts +26 -2
  18. package/lib/chevre/repo/aggregateReservation.d.ts +25 -1
  19. package/lib/chevre/repo/aggregation.d.ts +26 -2
  20. package/lib/chevre/repo/assetTransaction.d.ts +5 -5
  21. package/lib/chevre/repo/authorization.d.ts +25 -1
  22. package/lib/chevre/repo/categoryCode.d.ts +1 -1
  23. package/lib/chevre/repo/comment.d.ts +3 -3
  24. package/lib/chevre/repo/creativeWork.d.ts +5 -5
  25. package/lib/chevre/repo/creativeWork.js +1 -1
  26. package/lib/chevre/repo/customer.d.ts +16 -10
  27. package/lib/chevre/repo/customer.js +40 -13
  28. package/lib/chevre/repo/event.d.ts +37 -127
  29. package/lib/chevre/repo/event.js +206 -386
  30. package/lib/chevre/repo/eventSeries.d.ts +147 -0
  31. package/lib/chevre/repo/eventSeries.js +664 -0
  32. package/lib/chevre/repo/member.d.ts +4 -4
  33. package/lib/chevre/repo/merchantReturnPolicy.d.ts +3 -3
  34. package/lib/chevre/repo/message.d.ts +25 -1
  35. package/lib/chevre/repo/mongoose/schemas/account.d.ts +1 -1
  36. package/lib/chevre/repo/mongoose/schemas/account.js +29 -13
  37. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -1
  38. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +1 -1
  39. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +17 -12
  40. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +10 -12
  41. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +1 -1
  42. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +21 -23
  43. package/lib/chevre/repo/mongoose/schemas/event.js +5 -12
  44. package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +13 -0
  45. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +219 -0
  46. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +1 -1
  47. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +9 -15
  48. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +1 -1
  49. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +21 -23
  50. package/lib/chevre/repo/mongoose/schemas/place.d.ts +1 -1
  51. package/lib/chevre/repo/mongoose/schemas/place.js +21 -23
  52. package/lib/chevre/repo/mongoose/schemas/productModel.js +6 -14
  53. package/lib/chevre/repo/mongoose/schemas/trip.js +10 -4
  54. package/lib/chevre/repo/note.d.ts +25 -1
  55. package/lib/chevre/repo/offer.d.ts +8 -8
  56. package/lib/chevre/repo/offerCatalog.d.ts +4 -4
  57. package/lib/chevre/repo/offerCatalogItem.d.ts +25 -1
  58. package/lib/chevre/repo/offerItemCondition.d.ts +28 -0
  59. package/lib/chevre/repo/offerItemCondition.js +8 -1
  60. package/lib/chevre/repo/order.d.ts +5 -5
  61. package/lib/chevre/repo/orderInTransaction.d.ts +27 -3
  62. package/lib/chevre/repo/ownershipInfo.d.ts +5 -5
  63. package/lib/chevre/repo/paymentService.d.ts +25 -1
  64. package/lib/chevre/repo/paymentServiceProvider.d.ts +26 -2
  65. package/lib/chevre/repo/place/movieTheater.d.ts +8 -4
  66. package/lib/chevre/repo/place/movieTheater.js +8 -1
  67. package/lib/chevre/repo/priceSpecification.d.ts +4 -4
  68. package/lib/chevre/repo/product.d.ts +4 -4
  69. package/lib/chevre/repo/productModel.d.ts +28 -0
  70. package/lib/chevre/repo/productModel.js +6 -0
  71. package/lib/chevre/repo/productOffer.d.ts +25 -1
  72. package/lib/chevre/repo/project.d.ts +5 -5
  73. package/lib/chevre/repo/reservation.d.ts +5 -5
  74. package/lib/chevre/repo/reservation.js +6 -28
  75. package/lib/chevre/repo/seller.d.ts +5 -5
  76. package/lib/chevre/repo/serviceOutput.d.ts +25 -1
  77. package/lib/chevre/repo/task.d.ts +8 -8
  78. package/lib/chevre/repo/transaction.d.ts +4 -4
  79. package/lib/chevre/repo/trip.d.ts +28 -0
  80. package/lib/chevre/repo/trip.js +6 -0
  81. package/lib/chevre/repository.d.ts +5 -0
  82. package/lib/chevre/repository.js +15 -2
  83. package/lib/chevre/service/aggregation/event/aggregateOffers.js +2 -2
  84. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -3
  85. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
  86. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -0
  87. package/lib/chevre/service/assetTransaction/reserve/start.js +1 -1
  88. package/lib/chevre/service/event/createEvent.d.ts +2 -0
  89. package/lib/chevre/service/event/createEvent.js +1 -1
  90. package/lib/chevre/service/event.d.ts +6 -0
  91. package/lib/chevre/service/event.js +120 -43
  92. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -0
  93. package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
  94. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +3 -0
  95. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +6 -6
  96. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
  97. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +1 -1
  98. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
  99. package/lib/chevre/service/offer/onEventChanged.d.ts +2 -0
  100. package/lib/chevre/service/offer/onEventChanged.js +31 -4
  101. package/lib/chevre/service/offer.js +1 -1
  102. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +1 -1
  103. package/lib/chevre/service/payment/movieTicket/factory.js +0 -6
  104. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +1 -1
  105. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +0 -6
  106. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  107. package/lib/chevre/service/report/telemetry.js +1 -1
  108. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -1
  109. package/lib/chevre/service/task/createEvent.js +2 -0
  110. package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
  111. package/lib/chevre/service/task/onEventChanged.js +2 -0
  112. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  113. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +16 -7
  114. package/lib/chevre/service/task/onResourceUpdated.js +2 -0
  115. package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
  116. package/lib/chevre/settings.d.ts +6 -0
  117. package/package.json +6 -6
  118. package/example/src/chevre/createManyEvents.ts +0 -75
  119. package/example/src/chevre/migrateMembers2.ts +0 -74
  120. package/example/src/chevre/projectEventFields.ts +0 -39
  121. package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +0 -45
  122. package/example/src/chevre/searchEventIds.ts +0 -24
  123. package/example/src/chevre/searchScreeningEventSeries.ts +0 -34
@@ -66,7 +66,7 @@ class EventRepo {
66
66
  }
67
67
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
68
68
  static CREATE_MONGO_CONDITIONS(conditions) {
69
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42;
69
+ 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;
70
70
  const andConditions = [];
71
71
  const typeOfEq = conditions.typeOf;
72
72
  if (typeof typeOfEq === 'string') {
@@ -372,106 +372,107 @@ class EventRepo {
372
372
  }
373
373
  break;
374
374
  case factory.eventType.ScreeningEventSeries:
375
- params = conditions;
376
- // tslint:disable-next-line:no-single-line-block-comment
377
- /* istanbul ignore else */
378
- if (typeof params.name === 'string' && params.name.length > 0) {
379
- andConditions.push({
380
- $or: [
381
- {
382
- 'name.ja': {
383
- $exists: true,
384
- $regex: new RegExp(params.name)
385
- }
386
- },
387
- {
388
- 'name.en': {
389
- $exists: true,
390
- $regex: new RegExp(params.name)
391
- }
392
- },
393
- {
394
- kanaName: {
395
- $exists: true,
396
- $regex: new RegExp(params.name)
397
- }
398
- }
399
- ]
400
- });
401
- }
402
- const locationIdEq = (_31 = (_30 = params.location) === null || _30 === void 0 ? void 0 : _30.id) === null || _31 === void 0 ? void 0 : _31.$eq;
403
- // tslint:disable-next-line:no-single-line-block-comment
404
- /* istanbul ignore else */
405
- if (typeof locationIdEq === 'string') {
406
- andConditions.push({
407
- 'location.id': { $exists: true, $eq: locationIdEq }
408
- });
409
- }
410
- // tslint:disable-next-line:no-single-line-block-comment
411
- /* istanbul ignore else */
412
- if (params.location !== undefined) {
413
- // tslint:disable-next-line:no-single-line-block-comment
414
- /* istanbul ignore else */
415
- if (Array.isArray(params.location.branchCodes)) {
416
- andConditions.push({
417
- 'location.branchCode': {
418
- $exists: true,
419
- $in: params.location.branchCodes
420
- }
421
- });
422
- }
423
- }
424
- const workPerformedIdentifierIn = (_32 = params.workPerformed) === null || _32 === void 0 ? void 0 : _32.identifiers;
425
- // tslint:disable-next-line:no-single-line-block-comment
426
- /* istanbul ignore else */
427
- if (Array.isArray(workPerformedIdentifierIn)) {
428
- andConditions.push({
429
- 'workPerformed.identifier': { $exists: true, $in: workPerformedIdentifierIn }
430
- });
431
- }
432
- const workPerformedVersionEq = (_34 = (_33 = params.workPerformed) === null || _33 === void 0 ? void 0 : _33.version) === null || _34 === void 0 ? void 0 : _34.$eq;
433
- if (typeof workPerformedVersionEq === 'string') {
434
- andConditions.push({
435
- 'workPerformed.version': { $exists: true, $eq: workPerformedVersionEq }
436
- });
437
- }
438
- const videoFormatTypeOfEq = (_36 = (_35 = params.videoFormat) === null || _35 === void 0 ? void 0 : _35.typeOf) === null || _36 === void 0 ? void 0 : _36.$eq;
439
- if (typeof videoFormatTypeOfEq === 'string') {
440
- andConditions.push({
441
- 'videoFormat.typeOf': {
442
- $exists: true,
443
- $eq: videoFormatTypeOfEq
444
- }
445
- });
446
- }
447
- const videoFormatTypeOfIn = (_38 = (_37 = params.videoFormat) === null || _37 === void 0 ? void 0 : _37.typeOf) === null || _38 === void 0 ? void 0 : _38.$in;
448
- if (Array.isArray(videoFormatTypeOfIn)) {
449
- andConditions.push({
450
- 'videoFormat.typeOf': {
451
- $exists: true,
452
- $in: videoFormatTypeOfIn
453
- }
454
- });
455
- }
456
- const soundFormatTypeOfEq = (_40 = (_39 = params.soundFormat) === null || _39 === void 0 ? void 0 : _39.typeOf) === null || _40 === void 0 ? void 0 : _40.$eq;
457
- if (typeof soundFormatTypeOfEq === 'string') {
458
- andConditions.push({
459
- 'soundFormat.typeOf': {
460
- $exists: true,
461
- $eq: soundFormatTypeOfEq
462
- }
463
- });
464
- }
465
- const soundFormatTypeOfIn = (_42 = (_41 = params.soundFormat) === null || _41 === void 0 ? void 0 : _41.typeOf) === null || _42 === void 0 ? void 0 : _42.$in;
466
- if (Array.isArray(soundFormatTypeOfIn)) {
467
- andConditions.push({
468
- 'soundFormat.typeOf': {
469
- $exists: true,
470
- $in: soundFormatTypeOfIn
471
- }
472
- });
473
- }
474
- break;
375
+ throw new factory.errors.Internal('typeOf: ScreeningEventSeries discontinued');
376
+ // params = conditions;
377
+ // // tslint:disable-next-line:no-single-line-block-comment
378
+ // /* istanbul ignore else */
379
+ // if (typeof params.name === 'string' && params.name.length > 0) {
380
+ // andConditions.push({
381
+ // $or: [
382
+ // {
383
+ // 'name.ja': {
384
+ // $exists: true,
385
+ // $regex: new RegExp(params.name)
386
+ // }
387
+ // },
388
+ // {
389
+ // 'name.en': {
390
+ // $exists: true,
391
+ // $regex: new RegExp(params.name)
392
+ // }
393
+ // },
394
+ // {
395
+ // kanaName: {
396
+ // $exists: true,
397
+ // $regex: new RegExp(params.name)
398
+ // }
399
+ // }
400
+ // ]
401
+ // });
402
+ // }
403
+ // const locationIdEq = params.location?.id?.$eq;
404
+ // // tslint:disable-next-line:no-single-line-block-comment
405
+ // /* istanbul ignore else */
406
+ // if (typeof locationIdEq === 'string') {
407
+ // andConditions.push({
408
+ // 'location.id': { $exists: true, $eq: locationIdEq }
409
+ // });
410
+ // }
411
+ // // tslint:disable-next-line:no-single-line-block-comment
412
+ // /* istanbul ignore else */
413
+ // if (params.location !== undefined) {
414
+ // // tslint:disable-next-line:no-single-line-block-comment
415
+ // /* istanbul ignore else */
416
+ // if (Array.isArray(params.location.branchCodes)) {
417
+ // andConditions.push({
418
+ // 'location.branchCode': {
419
+ // $exists: true,
420
+ // $in: params.location.branchCodes
421
+ // }
422
+ // });
423
+ // }
424
+ // }
425
+ // const workPerformedIdentifierIn = params.workPerformed?.identifiers;
426
+ // // tslint:disable-next-line:no-single-line-block-comment
427
+ // /* istanbul ignore else */
428
+ // if (Array.isArray(workPerformedIdentifierIn)) {
429
+ // andConditions.push({
430
+ // 'workPerformed.identifier': { $exists: true, $in: workPerformedIdentifierIn }
431
+ // });
432
+ // }
433
+ // const workPerformedVersionEq = params.workPerformed?.version?.$eq;
434
+ // if (typeof workPerformedVersionEq === 'string') {
435
+ // andConditions.push({
436
+ // 'workPerformed.version': { $exists: true, $eq: workPerformedVersionEq }
437
+ // });
438
+ // }
439
+ // const videoFormatTypeOfEq = params.videoFormat?.typeOf?.$eq;
440
+ // if (typeof videoFormatTypeOfEq === 'string') {
441
+ // andConditions.push({
442
+ // 'videoFormat.typeOf': {
443
+ // $exists: true,
444
+ // $eq: videoFormatTypeOfEq
445
+ // }
446
+ // });
447
+ // }
448
+ // const videoFormatTypeOfIn = params.videoFormat?.typeOf?.$in;
449
+ // if (Array.isArray(videoFormatTypeOfIn)) {
450
+ // andConditions.push({
451
+ // 'videoFormat.typeOf': {
452
+ // $exists: true,
453
+ // $in: videoFormatTypeOfIn
454
+ // }
455
+ // });
456
+ // }
457
+ // const soundFormatTypeOfEq = params.soundFormat?.typeOf?.$eq;
458
+ // if (typeof soundFormatTypeOfEq === 'string') {
459
+ // andConditions.push({
460
+ // 'soundFormat.typeOf': {
461
+ // $exists: true,
462
+ // $eq: soundFormatTypeOfEq
463
+ // }
464
+ // });
465
+ // }
466
+ // const soundFormatTypeOfIn = params.soundFormat?.typeOf?.$in;
467
+ // if (Array.isArray(soundFormatTypeOfIn)) {
468
+ // andConditions.push({
469
+ // 'soundFormat.typeOf': {
470
+ // $exists: true,
471
+ // $in: soundFormatTypeOfIn
472
+ // }
473
+ // });
474
+ // }
475
+ // break;
475
476
  default:
476
477
  }
477
478
  return andConditions;
@@ -479,7 +480,7 @@ class EventRepo {
479
480
  /**
480
481
  * 複数イベントを作成する
481
482
  */
482
- createMany(params) {
483
+ createManyEvents(params) {
483
484
  return __awaiter(this, void 0, void 0, function* () {
484
485
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
485
486
  // let docs: HydratedDocument<factory.event.IEvent<T>>[];
@@ -568,119 +569,6 @@ class EventRepo {
568
569
  }
569
570
  });
570
571
  }
571
- /**
572
- * コンテンツ+バージョンをキーにして、なければ作成する(複数対応)
573
- */
574
- createScreeningEventSeriesIfNotExistByWorkPerformed(params) {
575
- return __awaiter(this, void 0, void 0, function* () {
576
- const uniqid = yield Promise.resolve().then(() => require('uniqid'));
577
- const bulkWriteOps = [];
578
- if (Array.isArray(params)) {
579
- params.forEach((creatingEventParams) => {
580
- const version = creatingEventParams.attributes.workPerformed.version;
581
- if (typeof version !== 'string') {
582
- throw new factory.errors.ArgumentNull('workPerformed.version');
583
- }
584
- const setOnInsertFields = creatingEventParams.attributes;
585
- bulkWriteOps.push({
586
- updateOne: {
587
- filter: {
588
- typeOf: creatingEventParams.attributes.typeOf,
589
- 'project.id': { $eq: creatingEventParams.attributes.project.id },
590
- 'location.branchCode': {
591
- $exists: true,
592
- $eq: creatingEventParams.attributes.location.branchCode
593
- },
594
- 'workPerformed.identifier': {
595
- $exists: true,
596
- $eq: creatingEventParams.attributes.workPerformed.identifier
597
- },
598
- 'workPerformed.version': {
599
- $exists: true,
600
- $eq: version
601
- }
602
- },
603
- update: {
604
- $setOnInsert: Object.assign(Object.assign({}, setOnInsertFields), { _id: uniqid() })
605
- // 変更可能な属性のみ上書き
606
- // $set: {}
607
- },
608
- upsert: true
609
- }
610
- });
611
- });
612
- }
613
- if (bulkWriteOps.length > 0) {
614
- return this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
615
- }
616
- });
617
- }
618
- /**
619
- * コンテンツ+バージョンをキーにして冪等置換
620
- */
621
- // tslint:disable-next-line:max-func-body-length
622
- upsertScreeningEventSeriesByVersion(params
623
- // options?: {
624
- // }
625
- ) {
626
- return __awaiter(this, void 0, void 0, function* () {
627
- const uniqid = yield Promise.resolve().then(() => require('uniqid'));
628
- const bulkWriteOps4insert = [];
629
- // const bulkWriteOps: AnyBulkWriteOperation<factory.event.IAttributes<factory.eventType.ScreeningEventSeries>>[] = [];
630
- const queryFilters = [];
631
- if (Array.isArray(params)) {
632
- params.forEach(({ $set, $unset }) => {
633
- const version = $set.workPerformed.version;
634
- if (typeof version !== 'string' || version.length === 0) {
635
- throw new factory.errors.ArgumentNull('workPerformed.version');
636
- }
637
- // リソースのユニークネスを保証するfilter
638
- const filter = {
639
- typeOf: $set.typeOf,
640
- 'project.id': { $eq: $set.project.id },
641
- 'location.branchCode': { $exists: true, $eq: $set.location.branchCode },
642
- 'workPerformed.identifier': { $exists: true, $eq: $set.workPerformed.identifier },
643
- 'workPerformed.version': { $exists: true, $eq: version }
644
- };
645
- queryFilters.push({
646
- typeOf: $set.typeOf,
647
- 'project.id': { $eq: $set.project.id },
648
- 'location.branchCode': { $exists: true, $eq: $set.location.branchCode },
649
- 'workPerformed.identifier': { $exists: true, $eq: $set.workPerformed.identifier },
650
- 'workPerformed.version': { $exists: true, $eq: version }
651
- });
652
- const { identifier, project, typeOf } = $set, setFields = __rest($set, ["identifier", "project", "typeOf"]);
653
- const setOnInsert = {
654
- project,
655
- typeOf,
656
- _id: uniqid()
657
- };
658
- const updateOne = {
659
- filter,
660
- update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
661
- upsert: true
662
- };
663
- bulkWriteOps4insert.push({ updateOne });
664
- // updateOneで再実装
665
- // const replacement: WithoutId<factory.event.IAttributes<factory.eventType.ScreeningEventSeries>> = attributes;
666
- // const replaceOne: ReplaceOneModel<factory.event.IAttributes<factory.eventType.ScreeningEventSeries>> = {
667
- // filter,
668
- // replacement,
669
- // upsert: true
670
- // };
671
- // bulkWriteOps.push({ replaceOne });
672
- });
673
- }
674
- if (bulkWriteOps4insert.length > 0) {
675
- const bulkWriteResult4insert = yield this.eventModel.bulkWrite(bulkWriteOps4insert, { ordered: false });
676
- // const bulkWriteResult = await this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
677
- // modifiedの場合upsertedIdsに含まれないので、idを検索する
678
- const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, { _id: 1 })
679
- .exec();
680
- return { bulkWriteResult4insert, modifiedEvents };
681
- }
682
- });
683
- }
684
572
  /**
685
573
  * イベント部分更新
686
574
  */
@@ -709,7 +597,7 @@ class EventRepo {
709
597
  /**
710
598
  * イベントを保管する
711
599
  */
712
- save(params) {
600
+ saveEvent(params) {
713
601
  return __awaiter(this, void 0, void 0, function* () {
714
602
  let savedEventId;
715
603
  let doc;
@@ -753,7 +641,7 @@ class EventRepo {
753
641
  // return doc.toObject();
754
642
  });
755
643
  }
756
- saveMany(params) {
644
+ saveManyEvents(params) {
757
645
  return __awaiter(this, void 0, void 0, function* () {
758
646
  const bulkWriteOps = [];
759
647
  if (Array.isArray(params)) {
@@ -778,20 +666,30 @@ class EventRepo {
778
666
  });
779
667
  }
780
668
  else if (p.attributes.typeOf === factory.eventType.ScreeningEventSeries) {
669
+ throw new factory.errors.Internal('typeOf: ScreeningEventSeries discontinued');
781
670
  // 上書き禁止属性を除外(2022-08-24~)
782
- const _b = p.attributes, { identifier, project, typeOf } = _b, updateFields = __rest(_b, ["identifier", "project", "typeOf"]);
783
- bulkWriteOps.push({
784
- updateOne: {
785
- filter: {
786
- _id: p.id,
787
- typeOf: p.attributes.typeOf
788
- },
789
- // upsertの場合、createがありうるので属性を除外しない
790
- update: Object.assign({ $setOnInsert: Object.assign({ typeOf: p.attributes.typeOf, project: p.attributes.project }, (typeof p.attributes.identifier === 'string')
791
- ? { identifier: p.attributes.identifier } : undefined), $set: updateFields }, (p.$unset !== undefined) ? { $unset: p.$unset } : undefined),
792
- upsert
793
- }
794
- });
671
+ // const { identifier, project, typeOf, ...updateFields } = p.attributes;
672
+ // bulkWriteOps.push({
673
+ // updateOne: {
674
+ // filter: {
675
+ // _id: p.id,
676
+ // typeOf: p.attributes.typeOf
677
+ // },
678
+ // // upsertの場合、createがありうるので属性を除外しない
679
+ // update: {
680
+ // $setOnInsert: {
681
+ // typeOf: p.attributes.typeOf,
682
+ // project: p.attributes.project,
683
+ // ...(typeof p.attributes.identifier === 'string')
684
+ // ? { identifier: p.attributes.identifier } : undefined
685
+ // },
686
+ // $set: updateFields,
687
+ // // $unsetに対応(2022-08-31~)
688
+ // ...(p.$unset !== undefined) ? { $unset: p.$unset } : undefined
689
+ // },
690
+ // upsert
691
+ // }
692
+ // });
795
693
  }
796
694
  });
797
695
  }
@@ -830,49 +728,10 @@ class EventRepo {
830
728
  // return <factory.event.IEvent<factory.eventType.ScreeningEvent>>doc.toObject();
831
729
  });
832
730
  }
833
- // migrate to projectFields
834
- // public async search<T extends factory.eventType>(
835
- // params: ISearchConditions<T>,
836
- // inclusion: IKeyOfProjection<T>[],
837
- // exclusion?: IKeyOfProjection<T>[]
838
- // ): Promise<Omit<factory.event.IEvent<T>, 'aggregateEntranceGate' | 'aggregateOffer'>[]> {
839
- // const conditions = EventRepo.CREATE_MONGO_CONDITIONS<T>(params);
840
- // let projection: IProjection<T> = {};
841
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
842
- // inclusion.forEach((field) => {
843
- // projection[field] = 1;
844
- // });
845
- // } else {
846
- // projection = {
847
- // __v: 0,
848
- // createdAt: 0,
849
- // updatedAt: 0
850
- // };
851
- // if (Array.isArray(exclusion) && exclusion.length > 0) {
852
- // exclusion.forEach((field) => {
853
- // projection[field] = 0;
854
- // });
855
- // }
856
- // }
857
- // const query = this.eventModel.find<HydratedDocument<factory.event.IEvent<T>>>({ $and: conditions }, projection);
858
- // if (typeof params.limit === 'number' && params.limit > 0) {
859
- // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
860
- // query.limit(params.limit)
861
- // .skip(params.limit * (page - 1));
862
- // }
863
- // // tslint:disable-next-line:no-single-line-block-comment
864
- // /* istanbul ignore else */
865
- // if (params.sort?.startDate !== undefined) {
866
- // query.sort({ startDate: params.sort.startDate });
867
- // }
868
- // return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
869
- // .exec()
870
- // .then((docs) => docs.map((doc) => doc.toObject()));
871
- // }
872
731
  /**
873
732
  * イベントを検索する(inclusion projection)
874
733
  */
875
- projectFields(params, inclusion) {
734
+ projectEventFields(params, inclusion) {
876
735
  var _a;
877
736
  return __awaiter(this, void 0, void 0, function* () {
878
737
  const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
@@ -918,7 +777,7 @@ class EventRepo {
918
777
  findAnyEventById(params) {
919
778
  var _a;
920
779
  return __awaiter(this, void 0, void 0, function* () {
921
- const doc = yield this.eventModel.findOne(Object.assign({ _id: { $eq: params.id.$eq }, 'project.id': { $eq: params.project.id.$eq } }, (typeof ((_a = params.organizer) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
780
+ const doc = yield this.eventModel.findOne(Object.assign({ _id: { $eq: params.id.$eq }, 'project.id': { $eq: params.project.id.$eq }, typeOf: { $in: [factory.eventType.Event, factory.eventType.ScreeningEvent] } }, (typeof ((_a = params.organizer) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
922
781
  ? { 'organizer.id': { $exists: true, $eq: params.organizer.id.$eq } }
923
782
  : undefined), {
924
783
  __v: 0,
@@ -937,7 +796,7 @@ class EventRepo {
937
796
  return doc.toObject();
938
797
  });
939
798
  }
940
- searchIds(params) {
799
+ searchEventIds(params) {
941
800
  return __awaiter(this, void 0, void 0, function* () {
942
801
  const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
943
802
  const query = this.eventModel.distinct('_id', { $and: conditions });
@@ -949,7 +808,7 @@ class EventRepo {
949
808
  * 特定イベントから指定フィールドのみ取得する
950
809
  * イベント IDは必ず返ります
951
810
  */
952
- projectFieldsById(params, inclusion // add projection(2024-07-18~)
811
+ projectEventFieldsById(params, inclusion // add projection(2024-07-18~)
953
812
  ) {
954
813
  return __awaiter(this, void 0, void 0, function* () {
955
814
  const projection = {
@@ -981,7 +840,7 @@ class EventRepo {
981
840
  /**
982
841
  * イベントをキャンセルする
983
842
  */
984
- cancel(params) {
843
+ cancelEvent(params) {
985
844
  return __awaiter(this, void 0, void 0, function* () {
986
845
  yield this.eventModel.updateOne({
987
846
  _id: { $eq: params.id },
@@ -995,26 +854,35 @@ class EventRepo {
995
854
  */
996
855
  syncScreeningEventSeries2screeningEvents(params) {
997
856
  return __awaiter(this, void 0, void 0, function* () {
998
- const superEvents = yield this.projectFields({
999
- limit: 1,
1000
- page: 1,
1001
- typeOf: factory.eventType.ScreeningEventSeries,
1002
- id: { $eq: params.superEvent.id },
1003
- project: { id: { $eq: params.project.id } }
1004
- }, [
1005
- 'additionalProperty', 'alternativeHeadline', 'description', 'dubLanguage',
1006
- 'endDate', 'headline', 'kanaName', 'location', 'name',
1007
- 'soundFormat', 'startDate', 'subtitleLanguage', 'typeOf', 'videoFormat', 'workPerformed'
1008
- ]);
1009
- const superEventFromDB = superEvents.shift();
1010
- if (superEventFromDB === undefined) {
1011
- throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
1012
- }
1013
- const superEvent = EventFactory.minimizeSuperEvent({ superEventFromDB });
857
+ // const superEvents = <Pick<
858
+ // factory.event.screeningEventSeries.IEvent,
859
+ // 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage'
860
+ // | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name'
861
+ // | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'videoFormat' | 'workPerformed'
862
+ // >[]>
863
+ // await this.projectFields<factory.eventType.ScreeningEventSeries>(
864
+ // {
865
+ // limit: 1,
866
+ // page: 1,
867
+ // typeOf: factory.eventType.ScreeningEventSeries,
868
+ // id: { $eq: params.superEvent.id },
869
+ // project: { id: { $eq: params.project.id } }
870
+ // },
871
+ // [
872
+ // 'additionalProperty', 'alternativeHeadline', 'description', 'dubLanguage',
873
+ // 'endDate', 'headline', 'kanaName', 'location', 'name',
874
+ // 'soundFormat', 'startDate', 'subtitleLanguage', 'typeOf', 'videoFormat', 'workPerformed'
875
+ // ]
876
+ // );
877
+ // const superEventFromDB = superEvents.shift();
878
+ // if (superEventFromDB === undefined) {
879
+ // throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
880
+ // }
881
+ const superEvent = EventFactory.minimizeSuperEvent({ superEventFromDB: params.superEventFromDB });
1014
882
  yield this.eventModel.updateMany({
1015
883
  typeOf: { $eq: factory.eventType.ScreeningEvent },
1016
884
  'project.id': { $eq: params.project.id },
1017
- 'superEvent.id': { $exists: true, $eq: params.superEvent.id },
885
+ 'superEvent.id': { $exists: true, $eq: params.superEventFromDB.id },
1018
886
  startDate: { $gte: params.startDate.$gte }
1019
887
  }, {
1020
888
  $set: {
@@ -1024,7 +892,7 @@ class EventRepo {
1024
892
  .exec();
1025
893
  });
1026
894
  }
1027
- deleteById(params) {
895
+ deleteEventById(params) {
1028
896
  return __awaiter(this, void 0, void 0, function* () {
1029
897
  yield this.eventModel.findOneAndDelete({
1030
898
  _id: params.id,
@@ -1033,33 +901,7 @@ class EventRepo {
1033
901
  .exec();
1034
902
  });
1035
903
  }
1036
- // public async deleteScreeningEventsByMovieTheaterBranchCode(params: {
1037
- // project: { id: string };
1038
- // location: { branchCode: string };
1039
- // }) {
1040
- // return this.eventModel.deleteMany(
1041
- // {
1042
- // typeOf: { $eq: factory.eventType.ScreeningEvent },
1043
- // 'project.id': { $eq: params.project.id },
1044
- // 'superEvent.location.branchCode': { $exists: true, $eq: params.location.branchCode }
1045
- // }
1046
- // )
1047
- // .exec();
1048
- // }
1049
- // public async deleteScreeningEventSeriesByMovieTheaterBranchCode(params: {
1050
- // project: { id: string };
1051
- // location: { branchCode: string };
1052
- // }) {
1053
- // return this.eventModel.deleteMany(
1054
- // {
1055
- // typeOf: { $eq: factory.eventType.ScreeningEventSeries },
1056
- // 'project.id': { $eq: params.project.id },
1057
- // 'location.branchCode': { $exists: true, $eq: params.location.branchCode }
1058
- // }
1059
- // )
1060
- // .exec();
1061
- // }
1062
- deleteManyByOrganizerId(params) {
904
+ deleteManyEventByOrganizerId(params) {
1063
905
  return __awaiter(this, void 0, void 0, function* () {
1064
906
  return this.eventModel.deleteMany({
1065
907
  'project.id': { $eq: params.project.id },
@@ -1068,16 +910,7 @@ class EventRepo {
1068
910
  .exec();
1069
911
  });
1070
912
  }
1071
- deleteManyByLocationId(params) {
1072
- return __awaiter(this, void 0, void 0, function* () {
1073
- return this.eventModel.deleteMany({
1074
- 'project.id': { $eq: params.project.id },
1075
- 'location.id': { $exists: true, $eq: params.location.id }
1076
- })
1077
- .exec();
1078
- });
1079
- }
1080
- deleteManyByScreeningRoom(params) {
913
+ deleteManyEventsByScreeningRoom(params) {
1081
914
  return __awaiter(this, void 0, void 0, function* () {
1082
915
  return this.eventModel.deleteMany({
1083
916
  'project.id': { $eq: params.project.id },
@@ -1108,7 +941,7 @@ class EventRepo {
1108
941
  /**
1109
942
  * 興行(プロダクト)から削除する
1110
943
  */
1111
- deleteManyByItemOfferedId(params) {
944
+ deleteManyEventsByItemOfferedId(params) {
1112
945
  return __awaiter(this, void 0, void 0, function* () {
1113
946
  return this.eventModel.deleteMany({
1114
947
  'project.id': { $eq: params.project.id },
@@ -1117,18 +950,33 @@ class EventRepo {
1117
950
  .exec();
1118
951
  });
1119
952
  }
1120
- deleteManyEndedByIds(params) {
953
+ /**
954
+ * 旧施設コンテンツ廃止専用メソッド
955
+ * 2024-09-11~
956
+ */
957
+ deleteOldEventSeries() {
1121
958
  return __awaiter(this, void 0, void 0, function* () {
1122
959
  return this.eventModel.deleteMany({
1123
- typeOf: { $in: params.typeOf.$in },
1124
- 'project.id': { $eq: params.project.id },
1125
- _id: { $in: params.ids },
1126
- endDate: { $lte: params.endDate.$lte }
960
+ typeOf: { $eq: factory.eventType.ScreeningEventSeries }
1127
961
  })
1128
962
  .exec();
1129
963
  });
1130
964
  }
1131
- deleteManyEndedByProject(params) {
965
+ // public async deleteManyEndedByIds(params: {
966
+ // typeOf: { $in: factory.eventType[] };
967
+ // project: { id: string };
968
+ // ids: string[];
969
+ // endDate: { $lte: Date };
970
+ // }) {
971
+ // return this.eventModel.deleteMany({
972
+ // typeOf: { $in: params.typeOf.$in },
973
+ // 'project.id': { $eq: params.project.id },
974
+ // _id: { $in: params.ids },
975
+ // endDate: { $lte: params.endDate.$lte }
976
+ // })
977
+ // .exec();
978
+ // }
979
+ deleteManyEventsEndedByProject(params) {
1132
980
  return __awaiter(this, void 0, void 0, function* () {
1133
981
  return this.eventModel.deleteMany({
1134
982
  typeOf: { $in: params.typeOf.$in },
@@ -1138,7 +986,7 @@ class EventRepo {
1138
986
  .exec();
1139
987
  });
1140
988
  }
1141
- deleteManyEnded(params) {
989
+ deleteManyEventsEnded(params) {
1142
990
  return __awaiter(this, void 0, void 0, function* () {
1143
991
  return this.eventModel.deleteMany({
1144
992
  typeOf: { $eq: params.typeOf.$eq },
@@ -1169,7 +1017,6 @@ class EventRepo {
1169
1017
  if (doc === null) {
1170
1018
  throw new factory.errors.NotFound(this.eventModel.modelName);
1171
1019
  }
1172
- // return doc.toObject();
1173
1020
  });
1174
1021
  }
1175
1022
  bulkWrite(bulkWriteOps) {
@@ -1192,60 +1039,33 @@ class EventRepo {
1192
1039
  .exec();
1193
1040
  });
1194
1041
  }
1195
- deleteAvailableAtOrFrom(params) {
1196
- return __awaiter(this, void 0, void 0, function* () {
1197
- yield this.eventModel.updateOne({ _id: { $eq: params.id } }, {
1198
- $pull: {
1199
- 'offers.seller.makesOffer': {
1200
- 'availableAtOrFrom.id': { $eq: params.offers.seller.makesOffer.availableAtOrFrom.id }
1201
- }
1202
- }
1203
- }, { rawResult: true })
1204
- .exec();
1205
- });
1206
- }
1042
+ // public async deleteAvailableAtOrFrom(params: {
1043
+ // id: string;
1044
+ // offers: {
1045
+ // seller: {
1046
+ // makesOffer: { availableAtOrFrom: { id: string } };
1047
+ // };
1048
+ // };
1049
+ // }): Promise<void> {
1050
+ // await this.eventModel.updateOne(
1051
+ // { _id: { $eq: params.id } },
1052
+ // {
1053
+ // $pull: {
1054
+ // 'offers.seller.makesOffer': {
1055
+ // 'availableAtOrFrom.id': { $eq: params.offers.seller.makesOffer.availableAtOrFrom.id }
1056
+ // }
1057
+ // }
1058
+ // },
1059
+ // { rawResult: true }
1060
+ // )
1061
+ // .exec();
1062
+ // }
1207
1063
  unsetUnnecessaryFields(params) {
1208
1064
  return __awaiter(this, void 0, void 0, function* () {
1209
1065
  return this.eventModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
1210
1066
  .exec();
1211
1067
  });
1212
1068
  }
1213
- /**
1214
- * 既存施設コンテンツの最大バージョンを集計する
1215
- */
1216
- aggregateScreeningEventMaxVersion(params) {
1217
- var _a;
1218
- return __awaiter(this, void 0, void 0, function* () {
1219
- const aggregations = yield this.eventModel.aggregate([
1220
- {
1221
- $match: {
1222
- typeOf: { $eq: factory.eventType.ScreeningEventSeries },
1223
- 'project.id': { $eq: params.project.id.$eq },
1224
- 'workPerformed.identifier': { $exists: true, $eq: params.workPerformed.identifier.$eq },
1225
- 'workPerformed.version': { $exists: true },
1226
- 'location.branchCode': { $exists: true, $in: params.location.branchCode.$in }
1227
- }
1228
- },
1229
- {
1230
- $project: {
1231
- workPerformed: '$workPerformed',
1232
- version: { $toInt: '$workPerformed.version' }
1233
- }
1234
- },
1235
- {
1236
- $group: {
1237
- _id: '$typeOf',
1238
- maxVersion: { $max: '$version' }
1239
- }
1240
- }
1241
- ])
1242
- .exec();
1243
- const maxVersion = (aggregations.length > 0)
1244
- ? String((_a = aggregations.shift()) === null || _a === void 0 ? void 0 : _a.maxVersion)
1245
- : '0';
1246
- return { maxVersion };
1247
- });
1248
- }
1249
1069
  aggregateEvent(params) {
1250
1070
  return __awaiter(this, void 0, void 0, function* () {
1251
1071
  const statuses = yield Promise.all([