@chevre/domain 21.5.0-alpha.2 → 21.5.0-alpha.3

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.
@@ -202,6 +202,31 @@ export declare class MongoRepository {
202
202
  id: string;
203
203
  };
204
204
  }): Promise<import("mongodb").DeleteResult>;
205
+ deleteManyByScreeningRoom(params: {
206
+ project: {
207
+ id: string;
208
+ };
209
+ location: {
210
+ /**
211
+ * ルームコード
212
+ */
213
+ branchCode: string;
214
+ containedInPlace: {
215
+ /**
216
+ * 施設ID
217
+ */
218
+ id: string;
219
+ };
220
+ };
221
+ }): Promise<import("mongodb").DeleteResult>;
222
+ deleteManyBySuperEventId(params: {
223
+ project: {
224
+ id: string;
225
+ };
226
+ superEvent: {
227
+ id: string;
228
+ };
229
+ }): Promise<import("mongodb").DeleteResult>;
205
230
  deleteManyBySuperEventLocationId(params: {
206
231
  project: {
207
232
  id: string;
@@ -926,6 +926,25 @@ class MongoRepository {
926
926
  .exec();
927
927
  });
928
928
  }
929
+ deleteManyByScreeningRoom(params) {
930
+ return __awaiter(this, void 0, void 0, function* () {
931
+ return this.eventModel.deleteMany({
932
+ 'project.id': { $eq: params.project.id },
933
+ 'location.branchCode': { $exists: true, $eq: params.location.branchCode },
934
+ 'superEvent.location.id': { $exists: true, $eq: params.location.containedInPlace.id }
935
+ })
936
+ .exec();
937
+ });
938
+ }
939
+ deleteManyBySuperEventId(params) {
940
+ return __awaiter(this, void 0, void 0, function* () {
941
+ return this.eventModel.deleteMany({
942
+ 'project.id': { $eq: params.project.id },
943
+ 'superEvent.id': { $exists: true, $eq: params.superEvent.id }
944
+ })
945
+ .exec();
946
+ });
947
+ }
929
948
  deleteManyBySuperEventLocationId(params) {
930
949
  return __awaiter(this, void 0, void 0, function* () {
931
950
  return this.eventModel.deleteMany({
@@ -16,6 +16,19 @@ function onResourceDeleted(params) {
16
16
  const isDeleted = params.isDeleted === true;
17
17
  if (isDeleted) {
18
18
  switch (params.typeOf) {
19
+ case factory.eventType.ScreeningEventSeries:
20
+ yield deleteResourcesByScreeningEventSeries({
21
+ project: { id: params.project.id },
22
+ ids: params.id
23
+ })(repos);
24
+ break;
25
+ case factory.placeType.ScreeningRoom:
26
+ yield deleteResourcesByScreeningRoom({
27
+ project: { id: params.project.id },
28
+ branchCode: params.branchCode,
29
+ containedInPlace: { id: params.containedInPlace.id }
30
+ })(repos);
31
+ break;
19
32
  case factory.placeType.MovieTheater:
20
33
  yield deleteResourcesByMovieTheater({
21
34
  project: { id: params.project.id },
@@ -35,6 +48,76 @@ function onResourceDeleted(params) {
35
48
  });
36
49
  }
37
50
  exports.onResourceDeleted = onResourceDeleted;
51
+ function deleteResourcesByScreeningEventSeries(params) {
52
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
53
+ if (params.ids.length !== 1) {
54
+ throw new factory.errors.Argument('id', 'id.length must be 1');
55
+ }
56
+ for (const eventId of params.ids) {
57
+ const deleteActionAttributes = {
58
+ agent: { id: params.project.id, typeOf: factory.organizationType.Project },
59
+ object: { id: eventId, typeOf: factory.eventType.ScreeningEventSeries },
60
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
61
+ typeOf: factory.actionType.DeleteAction
62
+ };
63
+ let deleteResult;
64
+ const action = yield repos.action.start(deleteActionAttributes);
65
+ try {
66
+ // イベント削除
67
+ const deleteScreeningEventResult = yield repos.event.deleteManyBySuperEventId({
68
+ project: { id: params.project.id },
69
+ superEvent: { id: eventId }
70
+ });
71
+ deleteResult = { deleteScreeningEventResult };
72
+ }
73
+ catch (error) {
74
+ try {
75
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
76
+ yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
77
+ }
78
+ catch (_) {
79
+ // no op
80
+ }
81
+ throw error;
82
+ }
83
+ yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
84
+ }
85
+ });
86
+ }
87
+ function deleteResourcesByScreeningRoom(params) {
88
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
89
+ const deleteActionAttributes = {
90
+ agent: { id: params.project.id, typeOf: factory.organizationType.Project },
91
+ object: { branchCode: params.branchCode, containedInPlace: params.containedInPlace, typeOf: factory.placeType.ScreeningRoom },
92
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
93
+ typeOf: factory.actionType.DeleteAction
94
+ };
95
+ let deleteResult;
96
+ const action = yield repos.action.start(deleteActionAttributes);
97
+ try {
98
+ // イベント削除
99
+ const deleteScreeningEventResult = yield repos.event.deleteManyByScreeningRoom({
100
+ project: { id: params.project.id },
101
+ location: {
102
+ branchCode: params.branchCode,
103
+ containedInPlace: { id: params.containedInPlace.id }
104
+ }
105
+ });
106
+ deleteResult = { deleteScreeningEventResult };
107
+ }
108
+ catch (error) {
109
+ try {
110
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
111
+ yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
112
+ }
113
+ catch (_) {
114
+ // no op
115
+ }
116
+ throw error;
117
+ }
118
+ yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
119
+ });
120
+ }
38
121
  function deleteResourcesByMovieTheater(params) {
39
122
  return (repos) => __awaiter(this, void 0, void 0, function* () {
40
123
  if (params.ids.length !== 1) {
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.319.0",
13
- "@cinerino/sdk": "3.162.0-alpha.6",
12
+ "@chevre/factory": "4.320.0",
13
+ "@cinerino/sdk": "3.162.0-alpha.7",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -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.5.0-alpha.2"
120
+ "version": "21.5.0-alpha.3"
121
121
  }