@chevre/domain 21.2.0-alpha.146 → 21.2.0-alpha.148

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.
@@ -50,23 +50,43 @@ export declare class MongoRepository {
50
50
  deleteMovieTheaterById(params: {
51
51
  id: string;
52
52
  }): Promise<void>;
53
- createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>, useScreeningRoomType?: boolean): Promise<{
53
+ createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace'> & {
54
+ containedInPlace: {
55
+ branchCode: string;
56
+ };
57
+ }, useScreeningRoomType: boolean): Promise<{
54
58
  /**
55
59
  * 施設ID
56
60
  */
57
61
  id: string;
58
62
  typeOf: factory.placeType.MovieTheater;
63
+ } | {
64
+ containedInPlace: {
65
+ /**
66
+ * 施設ID
67
+ */
68
+ id: string;
69
+ };
70
+ typeOf: factory.placeType.ScreeningRoom;
59
71
  }>;
60
72
  updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace'> & {
61
73
  containedInPlace: {
62
74
  branchCode: string;
63
75
  };
64
- }, $unset: any, useScreeningRoomType?: boolean): Promise<{
76
+ }, $unset: any, useScreeningRoomType: boolean): Promise<{
65
77
  /**
66
78
  * 施設ID
67
79
  */
68
80
  id: string;
69
81
  typeOf: factory.placeType.MovieTheater;
82
+ } | {
83
+ containedInPlace: {
84
+ /**
85
+ * 施設ID
86
+ */
87
+ id: string;
88
+ };
89
+ typeOf: factory.placeType.ScreeningRoom;
70
90
  }>;
71
91
  deleteScreeningRoom(screeningRoom: {
72
92
  project: {
@@ -82,12 +102,20 @@ export declare class MongoRepository {
82
102
  */
83
103
  branchCode: string;
84
104
  };
85
- }, useScreeningRoomType?: boolean): Promise<{
105
+ }, useScreeningRoomType: boolean): Promise<{
86
106
  /**
87
107
  * 施設ID
88
108
  */
89
109
  id: string;
90
110
  typeOf: factory.placeType.MovieTheater;
111
+ } | {
112
+ containedInPlace: {
113
+ /**
114
+ * 施設ID
115
+ */
116
+ id: string;
117
+ };
118
+ typeOf: factory.placeType.ScreeningRoom;
91
119
  }>;
92
120
  deleteScreeningRoomsByMovieTheaterId(params: {
93
121
  project: {
@@ -106,6 +134,12 @@ export declare class MongoRepository {
106
134
  */
107
135
  id: string;
108
136
  typeOf: factory.placeType.MovieTheater;
137
+ } | {
138
+ /**
139
+ * ルームID
140
+ */
141
+ id: string;
142
+ typeOf: factory.placeType.ScreeningRoom;
109
143
  }>;
110
144
  updateScreeningRoomSection(screeningRoomSection: Omit<factory.place.screeningRoomSection.IPlace, 'containedInPlace'> & {
111
145
  containedInPlace: {
@@ -120,6 +154,12 @@ export declare class MongoRepository {
120
154
  */
121
155
  id: string;
122
156
  typeOf: factory.placeType.MovieTheater;
157
+ } | {
158
+ /**
159
+ * ルームID
160
+ */
161
+ id: string;
162
+ typeOf: factory.placeType.ScreeningRoom;
123
163
  }>;
124
164
  searchScreeningRoomSections(searchConditions: factory.place.screeningRoomSection.ISearchConditions & {
125
165
  $projection?: {
@@ -416,24 +416,45 @@ class MongoRepository {
416
416
  }
417
417
  createScreeningRoom(screeningRoom, useScreeningRoomType) {
418
418
  return __awaiter(this, void 0, void 0, function* () {
419
- if (useScreeningRoomType === true) {
420
- // tslint:disable-next-line:no-suspicious-comment
421
- // TODO implement
422
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
419
+ // 施設存在確認
420
+ let doc = yield this.placeModel.findOne({
421
+ typeOf: { $eq: factory.placeType.MovieTheater },
422
+ 'project.id': { $eq: screeningRoom.project.id },
423
+ branchCode: { $eq: screeningRoom.containedInPlace.branchCode }
424
+ }, { _id: 1, typeOf: 1, branchCode: 1, name: 1 })
425
+ .exec();
426
+ if (doc === null) {
427
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
423
428
  }
424
- else {
425
- // 施設存在確認
426
- let doc = yield this.placeModel.findOne({
427
- typeOf: { $eq: factory.placeType.MovieTheater },
428
- 'project.id': { $eq: screeningRoom.project.id },
429
- branchCode: screeningRoom.containedInPlace.branchCode
430
- }, {
431
- _id: 1
432
- })
429
+ if (useScreeningRoomType === true) {
430
+ const movieTheater = doc.toObject();
431
+ const creatingScreeningRoom = Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name, address: screeningRoom.address, additionalProperty: (Array.isArray(screeningRoom.additionalProperty)) ? screeningRoom.additionalProperty : [], containedInPlace: {
432
+ id: movieTheater.id,
433
+ typeOf: movieTheater.typeOf,
434
+ branchCode: movieTheater.branchCode,
435
+ name: movieTheater.name
436
+ }, containsPlace: [], project: screeningRoom.project }, (typeof screeningRoom.openSeatingAllowed === 'boolean')
437
+ ? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
438
+ : undefined);
439
+ const upsertScreeningRoomResult = yield this.placeModel.updateOne({
440
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
441
+ 'project.id': { $eq: creatingScreeningRoom.project.id },
442
+ 'containedInPlace.id': { $exists: true, $eq: creatingScreeningRoom.containedInPlace.id },
443
+ branchCode: { $eq: creatingScreeningRoom.branchCode }
444
+ },
445
+ // 既存であれば何もしない
446
+ { $setOnInsert: creatingScreeningRoom }, { upsert: true })
433
447
  .exec();
434
- if (doc === null) {
435
- throw new factory.errors.NotFound('containedInPlace');
448
+ // 既存であればコード重複
449
+ if (upsertScreeningRoomResult.matchedCount > 0) {
450
+ throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoom, ['branchCode']);
436
451
  }
452
+ return {
453
+ containedInPlace: { id: creatingScreeningRoom.containedInPlace.id },
454
+ typeOf: factory.placeType.ScreeningRoom
455
+ };
456
+ }
457
+ else {
437
458
  // ルームコードが存在しなければ追加する
438
459
  doc = yield this.placeModel.findOneAndUpdate({
439
460
  typeOf: { $eq: factory.placeType.MovieTheater },
@@ -454,7 +475,6 @@ class MongoRepository {
454
475
  new: true,
455
476
  projection: {
456
477
  _id: 1,
457
- // 'project.id': 1,
458
478
  branchCode: 1,
459
479
  typeOf: 1
460
480
  }
@@ -471,9 +491,33 @@ class MongoRepository {
471
491
  updateScreeningRoom(screeningRoom, $unset, useScreeningRoomType) {
472
492
  return __awaiter(this, void 0, void 0, function* () {
473
493
  if (useScreeningRoomType === true) {
474
- // tslint:disable-next-line:no-suspicious-comment
475
- // TODO implement
476
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
494
+ const doc = yield this.placeModel.findOneAndUpdate({
495
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
496
+ 'project.id': { $eq: screeningRoom.project.id },
497
+ 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
498
+ branchCode: screeningRoom.branchCode
499
+ }, Object.assign(Object.assign(Object.assign(Object.assign({ name: screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
500
+ ? { address: screeningRoom.address }
501
+ : undefined), (typeof screeningRoom.openSeatingAllowed === 'boolean')
502
+ ? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
503
+ : undefined), (Array.isArray(screeningRoom.additionalProperty))
504
+ ? { additionalProperty: screeningRoom.additionalProperty }
505
+ : undefined), (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].openSeatingAllowed']) === 1
506
+ || $unset.openSeatingAllowed === 1)
507
+ ? {
508
+ $unset: {
509
+ openSeatingAllowed: 1
510
+ }
511
+ }
512
+ : undefined), {
513
+ new: true,
514
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
515
+ })
516
+ .exec();
517
+ if (doc === null) {
518
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
519
+ }
520
+ return doc.toObject();
477
521
  }
478
522
  else {
479
523
  const doc = yield this.placeModel.findOneAndUpdate({
@@ -496,7 +540,6 @@ class MongoRepository {
496
540
  ],
497
541
  projection: {
498
542
  _id: 1,
499
- // 'project.id': 1,
500
543
  branchCode: 1,
501
544
  typeOf: 1
502
545
  }
@@ -512,9 +555,19 @@ class MongoRepository {
512
555
  deleteScreeningRoom(screeningRoom, useScreeningRoomType) {
513
556
  return __awaiter(this, void 0, void 0, function* () {
514
557
  if (useScreeningRoomType === true) {
515
- // tslint:disable-next-line:no-suspicious-comment
516
- // TODO implement
517
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
558
+ const doc = yield this.placeModel.findOneAndDelete({
559
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
560
+ 'project.id': { $eq: screeningRoom.project.id },
561
+ 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
562
+ branchCode: screeningRoom.branchCode
563
+ }, {
564
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
565
+ })
566
+ .exec();
567
+ if (doc === null) {
568
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
569
+ }
570
+ return doc.toObject();
518
571
  }
519
572
  else {
520
573
  const doc = yield this.placeModel.findOneAndUpdate({
@@ -550,39 +603,59 @@ class MongoRepository {
550
603
  .exec();
551
604
  });
552
605
  }
606
+ // tslint:disable-next-line:max-func-body-length
553
607
  createScreeningRoomSection(screeningRoomSection, useScreeningRoomType) {
554
608
  return __awaiter(this, void 0, void 0, function* () {
555
- if (useScreeningRoomType === true) {
556
- // tslint:disable-next-line:no-suspicious-comment
557
- // TODO implement
558
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
609
+ const screeningRoom = screeningRoomSection.containedInPlace;
610
+ if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
611
+ throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
559
612
  }
560
- else {
561
- const screeningRoom = screeningRoomSection.containedInPlace;
562
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
563
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
564
- }
565
- const movieTheater = screeningRoom.containedInPlace;
566
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
567
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
568
- }
569
- // 施設存在確認
570
- let doc = yield this.placeModel.findOne({
571
- typeOf: { $eq: factory.placeType.MovieTheater },
613
+ const movieTheater = screeningRoom.containedInPlace;
614
+ if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
615
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
616
+ }
617
+ // 施設存在確認
618
+ let doc = yield this.placeModel.findOne({
619
+ typeOf: { $eq: factory.placeType.MovieTheater },
620
+ 'project.id': { $eq: screeningRoomSection.project.id },
621
+ branchCode: movieTheater.branchCode,
622
+ 'containsPlace.branchCode': screeningRoom.branchCode
623
+ }, { _id: 1 })
624
+ .exec();
625
+ if (doc === null) {
626
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
627
+ }
628
+ if (useScreeningRoomType === true) {
629
+ // セクションコードが存在しなければ追加する
630
+ doc = yield this.placeModel.findOneAndUpdate({
631
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
572
632
  'project.id': { $eq: screeningRoomSection.project.id },
573
- branchCode: movieTheater.branchCode,
574
- 'containsPlace.branchCode': screeningRoom.branchCode
575
- }, { _id: 1 })
633
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
634
+ branchCode: screeningRoom.branchCode,
635
+ 'containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
636
+ }, {
637
+ $push: {
638
+ containsPlace: Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
639
+ ? { additionalProperty: screeningRoomSection.additionalProperty }
640
+ : undefined)
641
+ }
642
+ }, {
643
+ new: true,
644
+ projection: { _id: 1, typeOf: 1 }
645
+ })
576
646
  .exec();
647
+ // 存在しなければコード重複
577
648
  if (doc === null) {
578
- throw new factory.errors.NotFound(factory.placeType.MovieTheater);
649
+ throw new factory.errors.AlreadyInUse(factory.placeType.ScreeningRoomSection, ['branchCode']);
579
650
  }
651
+ return doc.toObject();
652
+ }
653
+ else {
580
654
  doc = yield this.placeModel.findOneAndUpdate({
581
655
  typeOf: { $eq: factory.placeType.MovieTheater },
582
656
  'project.id': { $eq: screeningRoomSection.project.id },
583
657
  branchCode: movieTheater.branchCode,
584
658
  'containsPlace.branchCode': screeningRoom.branchCode
585
- // 'containsPlace.containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
586
659
  }, {
587
660
  $push: {
588
661
  'containsPlace.$[screeningRoom].containsPlace': Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
@@ -611,22 +684,52 @@ class MongoRepository {
611
684
  }
612
685
  });
613
686
  }
687
+ // tslint:disable-next-line:max-func-body-length
614
688
  updateScreeningRoomSection(screeningRoomSection, $unset, useScreeningRoomType) {
615
689
  return __awaiter(this, void 0, void 0, function* () {
690
+ const screeningRoom = screeningRoomSection.containedInPlace;
691
+ if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
692
+ throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
693
+ }
694
+ const movieTheater = screeningRoom.containedInPlace;
695
+ if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
696
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
697
+ }
616
698
  if (useScreeningRoomType === true) {
617
- // tslint:disable-next-line:no-suspicious-comment
618
- // TODO implement
619
- throw new factory.errors.NotImplemented('useScreeningRoomType not implemented');
699
+ const doc = yield this.placeModel.findOneAndUpdate({
700
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
701
+ 'project.id': { $eq: screeningRoomSection.project.id },
702
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
703
+ branchCode: { $eq: screeningRoom.branchCode },
704
+ 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
705
+ }, Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
706
+ ? {
707
+ 'containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
708
+ }
709
+ : undefined), (Array.isArray(screeningRoomSection.additionalProperty))
710
+ ? {
711
+ 'containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
712
+ }
713
+ : undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
714
+ ? {
715
+ 'containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
716
+ return Object.assign(Object.assign(Object.assign({ typeOf: p.typeOf, branchCode: p.branchCode }, (p.name !== undefined && p.name !== null) ? { name: p.name } : undefined), (Array.isArray(p.seatingType)) ? { seatingType: p.seatingType } : undefined), (Array.isArray(p.additionalProperty)) ? { additionalProperty: p.additionalProperty } : undefined);
717
+ })
718
+ }
719
+ : undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
720
+ new: true,
721
+ arrayFilters: [
722
+ { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
723
+ ],
724
+ projection: { _id: 1, typeOf: 1 }
725
+ })
726
+ .exec();
727
+ if (doc === null) {
728
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
729
+ }
730
+ return doc.toObject();
620
731
  }
621
732
  else {
622
- const screeningRoom = screeningRoomSection.containedInPlace;
623
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
624
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
625
- }
626
- const movieTheater = screeningRoom.containedInPlace;
627
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
628
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
629
- }
630
733
  const doc = yield this.placeModel.findOneAndUpdate({
631
734
  typeOf: { $eq: factory.placeType.MovieTheater },
632
735
  'project.id': { $eq: screeningRoomSection.project.id },
@@ -1270,8 +1373,6 @@ class MongoRepository {
1270
1373
  findScreeningRoomsByBranchCode(params) {
1271
1374
  return __awaiter(this, void 0, void 0, function* () {
1272
1375
  if (params.useScreeningRoomType === true) {
1273
- // tslint:disable-next-line:no-suspicious-comment
1274
- // TODO implement
1275
1376
  const matchStages = [
1276
1377
  { $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } },
1277
1378
  {
@@ -67,7 +67,7 @@ exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_
67
67
  : moment('2023-08-31T15:00:00Z');
68
68
  exports.USE_NEW_STOCK_HOLDER_REPO_FROM = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_FROM === 'string')
69
69
  ? moment(process.env.USE_NEW_STOCK_HOLDER_REPO_FROM)
70
- : moment('2023-11-30T15:00:00Z');
70
+ : moment('2024-11-30T15:00:00Z');
71
71
  exports.USE_NEW_STOCK_HOLDER_REPO_IDS = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_IDS === 'string')
72
72
  ? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
73
73
  : [];
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.146"
120
+ "version": "21.2.0-alpha.148"
121
121
  }