@chevre/domain 23.2.0-alpha.27 → 23.2.0-alpha.29

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,6 +50,12 @@ export declare class MovieTheaterRepo {
50
50
  };
51
51
  }[], options: IUpsertOptions): Promise<{
52
52
  bulkWriteResult?: BulkWriteResult;
53
+ /**
54
+ * 追加あるいは編集された施設
55
+ */
56
+ modifiedMovieTheaters: {
57
+ id: string;
58
+ }[];
53
59
  }>;
54
60
  /**
55
61
  * 施設のpublic属性検索
@@ -146,6 +146,7 @@ class MovieTheaterRepo {
146
146
  return __awaiter(this, void 0, void 0, function* () {
147
147
  const { project, sellerId } = options;
148
148
  const bulkWriteOps = [];
149
+ const queryFilters = [];
149
150
  if (Array.isArray(params)) {
150
151
  params.forEach(({ $set, $unset }) => {
151
152
  const { branchCode, hasEntranceGate, hasPOS } = $set, // 入場ゲート,POSを決して編集しないように
@@ -175,13 +176,27 @@ class MovieTheaterRepo {
175
176
  upsert: true
176
177
  };
177
178
  bulkWriteOps.push({ updateOne });
179
+ queryFilters.push({
180
+ typeOf: { $eq: factory.placeType.MovieTheater },
181
+ 'project.id': { $eq: project.id },
182
+ branchCode: { $eq: branchCode },
183
+ // プロジェクトとコードでユニークな仕様だが、販売者も指定する -> 異なる販売者でコードが重複すればDuplicateErrorとなる
184
+ 'parentOrganization.id': { $exists: true, $eq: sellerId }
185
+ });
178
186
  });
179
187
  }
180
188
  if (bulkWriteOps.length > 0) {
181
189
  const bulkWriteResult = yield this.civicStructureModel.bulkWrite(bulkWriteOps, { ordered: false });
182
- return { bulkWriteResult };
190
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
191
+ const modifiedMovieTheaters = yield this.civicStructureModel.find({ $or: queryFilters }, {
192
+ _id: 0,
193
+ id: { $toString: '$_id' }
194
+ })
195
+ .lean()
196
+ .exec();
197
+ return { bulkWriteResult, modifiedMovieTheaters };
183
198
  }
184
- return {};
199
+ return { modifiedMovieTheaters: [] };
185
200
  });
186
201
  }
187
202
  /**
@@ -146,9 +146,14 @@ function deleteResourcesByScreeningEventSeries(params) {
146
146
  }
147
147
  function deleteResourcesByScreeningRoom(params) {
148
148
  return (repos) => __awaiter(this, void 0, void 0, function* () {
149
+ // 現時点で、複数ルーム削除タスクは作成されない
150
+ const firstBranchCode = params.branchCode.at(0);
151
+ if (typeof firstBranchCode !== 'string') {
152
+ throw new factory.errors.ArgumentNull('branchCode');
153
+ }
149
154
  const deleteActionAttributes = {
150
155
  agent: { id: params.project.id, typeOf: factory.organizationType.Project },
151
- object: { branchCode: params.branchCode, containedInPlace: params.containedInPlace, typeOf: factory.placeType.ScreeningRoom },
156
+ object: { branchCode: firstBranchCode, containedInPlace: params.containedInPlace, typeOf: factory.placeType.ScreeningRoom },
152
157
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
153
158
  typeOf: factory.actionType.DeleteAction
154
159
  };
@@ -159,7 +164,7 @@ function deleteResourcesByScreeningRoom(params) {
159
164
  const deleteScreeningEventResult = yield repos.event.deleteManyEventsByScreeningRoom({
160
165
  project: { id: params.project.id },
161
166
  location: {
162
- branchCode: params.branchCode,
167
+ branchCode: firstBranchCode,
163
168
  containedInPlace: { id: params.containedInPlace.id }
164
169
  }
165
170
  });
@@ -118,6 +118,10 @@ function onResourceUpdated(params) {
118
118
  typeOf: params.typeOf
119
119
  }, setting)(repos);
120
120
  break;
121
+ // ルーム通知に対応(2026-01-16~)
122
+ case factory.placeType.ScreeningRoom:
123
+ yield createInformRoomTasks(params, setting)(repos);
124
+ break;
121
125
  case 'AccountTitle':
122
126
  yield createInformAccountTitleTasks({
123
127
  project: { id: params.project.id },
@@ -488,6 +492,72 @@ function createInformMovieTheaterTasks(params, setting) {
488
492
  }
489
493
  });
490
494
  }
495
+ // tslint:disable-next-line:max-func-body-length
496
+ function createInformRoomTasks(params, setting) {
497
+ return (repos
498
+ // settings: Settings
499
+ ) => __awaiter(this, void 0, void 0, function* () {
500
+ var _a;
501
+ // const informResources = settings.onResourceUpdated.informResource;
502
+ const informResources = (_a = setting === null || setting === void 0 ? void 0 : setting.onResourceUpdated) === null || _a === void 0 ? void 0 : _a.informResource;
503
+ if (Array.isArray(params.branchCode) && params.branchCode.length > 0) {
504
+ // ルームを検索
505
+ const rooms = (yield repos.screeningRoom.findRooms({
506
+ project: { id: { $eq: params.project.id } },
507
+ branchCode: { $in: params.branchCode },
508
+ containedInPlace: { id: { $eq: params.containedInPlace.id } }
509
+ }));
510
+ const rooms4inform = rooms.map((room) => {
511
+ return {
512
+ branchCode: room.branchCode,
513
+ name: room.name,
514
+ typeOf: factory.placeType.ScreeningRoom,
515
+ additionalProperty: room.additionalProperty,
516
+ address: room.address,
517
+ containedInPlace: { id: params.containedInPlace.id }
518
+ };
519
+ });
520
+ if (rooms4inform.length > 0) {
521
+ const taskRunsAt = new Date();
522
+ const informTasks = [];
523
+ informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
524
+ var _a;
525
+ const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
526
+ rooms4inform.forEach((room4inform) => {
527
+ var _a;
528
+ const informActionAttributes = {
529
+ object: room4inform,
530
+ recipient: {
531
+ id: '',
532
+ name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
533
+ typeOf: factory.creativeWorkType.WebApplication
534
+ },
535
+ target: {
536
+ httpMethod: 'POST',
537
+ encodingType: factory.encodingFormat.Application.json,
538
+ typeOf: 'EntryPoint',
539
+ urlTemplate: informUrl
540
+ }
541
+ };
542
+ informTasks.push({
543
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
544
+ name: factory.taskName.TriggerWebhook,
545
+ status: factory.taskStatus.Ready,
546
+ runsAt: taskRunsAt,
547
+ remainingNumberOfTries: 10,
548
+ numberOfTried: 0,
549
+ executionResults: [],
550
+ data: informActionAttributes
551
+ });
552
+ });
553
+ });
554
+ if (informTasks.length > 0) {
555
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
556
+ }
557
+ }
558
+ }
559
+ });
560
+ }
491
561
  function createInformAccountTitleTasks(params, setting) {
492
562
  return (repos
493
563
  // settings: Settings
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "5.4.0-alpha.16",
14
+ "@chevre/factory": "5.4.0-alpha.18",
15
15
  "@cinerino/sdk": "12.13.0",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.4.0-alpha.1",
@@ -116,5 +116,5 @@
116
116
  "postversion": "git push origin --tags",
117
117
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
118
118
  },
119
- "version": "23.2.0-alpha.27"
119
+ "version": "23.2.0-alpha.29"
120
120
  }