@chevre/domain 23.2.0-alpha.4 → 23.2.0-alpha.41

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 (89) hide show
  1. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +1 -1
  2. package/example/src/chevre/eventSeries/migrateEventSeriesOffers.ts +75 -0
  3. package/example/src/chevre/eventSeries/migrateEventSeriesVideoFormat.ts +80 -0
  4. package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -42
  5. package/example/src/chevre/{upsertOfferCatalogItemsByIdentifier.ts → offerCatalog/upsertOfferCatalogItemsByIdentifier.ts} +6 -3
  6. package/example/src/chevre/{upsertOfferCatalogsByIdentifier.ts → offerCatalog/upsertOfferCatalogsByIdentifier.ts} +7 -3
  7. package/example/src/chevre/{upsertOffersByIdentifier.ts → offers/upsertOffersByIdentifier.ts} +5 -3
  8. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  9. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  10. package/example/src/chevre/place/findRooms.ts +24 -0
  11. package/example/src/chevre/place/findSections.ts +28 -0
  12. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  13. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  14. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  15. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  16. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  17. package/example/src/chevre/reIndex.ts +1 -1
  18. package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +49 -0
  19. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  20. package/example/src/chevre/roles/addAdminMovieTheaterReadPermissionIfNotExists.ts +34 -0
  21. package/example/src/chevre/roles/addAdminMovieTheaterWritePermissionIfNotExists.ts +34 -0
  22. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  23. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  24. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  25. package/lib/chevre/factory/event.js +5 -5
  26. package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
  27. package/lib/chevre/repo/aggregateOffer.js +11 -3
  28. package/lib/chevre/repo/aggregateOrder.js +0 -93
  29. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  30. package/lib/chevre/repo/aggregateReservation.js +0 -2
  31. package/lib/chevre/repo/creativeWork.js +9 -5
  32. package/lib/chevre/repo/event.d.ts +2 -2
  33. package/lib/chevre/repo/event.js +20 -8
  34. package/lib/chevre/repo/eventOffer.d.ts +8 -0
  35. package/lib/chevre/repo/eventOffer.js +11 -0
  36. package/lib/chevre/repo/eventSeries.d.ts +10 -4
  37. package/lib/chevre/repo/eventSeries.js +56 -28
  38. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  39. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +10 -9
  40. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +10 -0
  41. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
  42. package/lib/chevre/repo/offerCatalog.d.ts +10 -1
  43. package/lib/chevre/repo/offerCatalog.js +34 -19
  44. package/lib/chevre/repo/offerCatalogItem.d.ts +10 -1
  45. package/lib/chevre/repo/offerCatalogItem.js +32 -17
  46. package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
  47. package/lib/chevre/repo/place/entranceGate.js +172 -0
  48. package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
  49. package/lib/chevre/repo/place/movieTheater.js +77 -6
  50. package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
  51. package/lib/chevre/repo/place/screeningRoom.js +227 -135
  52. package/lib/chevre/repo/place/seat.d.ts +47 -45
  53. package/lib/chevre/repo/place/seat.js +175 -45
  54. package/lib/chevre/repo/place/section.d.ts +60 -30
  55. package/lib/chevre/repo/place/section.js +337 -127
  56. package/lib/chevre/repo/task.d.ts +1 -1
  57. package/lib/chevre/repository.d.ts +8 -0
  58. package/lib/chevre/repository.js +16 -0
  59. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +6 -3
  60. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  61. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  62. package/lib/chevre/service/event/saveScreeningEvents.d.ts +1 -1
  63. package/lib/chevre/service/event/saveScreeningEvents.js +6 -5
  64. package/lib/chevre/service/offer/event/authorize/factory.js +4 -1
  65. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  66. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  67. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  68. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +4 -13
  69. package/lib/chevre/service/offer/onEventChanged.js +7 -5
  70. package/lib/chevre/service/offer.d.ts +5 -0
  71. package/lib/chevre/service/offer.js +34 -9
  72. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  73. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  74. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  75. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
  76. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
  77. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +1 -1
  78. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  79. package/lib/chevre/service/task/onResourceDeleted.js +60 -0
  80. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +3 -7
  81. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +19 -7
  82. package/lib/chevre/service/task/onResourceUpdated.js +206 -42
  83. package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -1
  84. package/lib/chevre/service/taskHandler.js +1 -0
  85. package/package.json +4 -3
  86. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  87. package/example/src/chevre/offers/createSampleOffers.ts +0 -154
  88. package/lib/chevre/service/eventOld.d.ts +0 -60
  89. package/lib/chevre/service/eventOld.js +0 -864
@@ -22,9 +22,10 @@ function onResourceDeleted(params) {
22
22
  const useInform = params.useInform === true
23
23
  && Array.isArray(useInformResourceTypes) && useInformResourceTypes.includes(params.typeOf);
24
24
  const isDeleted = params.isDeleted === true;
25
+ const resourceType = params.typeOf;
25
26
  if (isDeleted) {
26
27
  if (useInform) {
27
- switch (params.typeOf) {
28
+ switch (resourceType) {
28
29
  case 'POS':
29
30
  yield (0, onHasPOSUpdated_1.createInformHasPOSTasks)({
30
31
  project: { id: params.project.id },
@@ -36,7 +37,7 @@ function onResourceDeleted(params) {
36
37
  // no op
37
38
  }
38
39
  }
39
- switch (params.typeOf) {
40
+ switch (resourceType) {
40
41
  case 'POS':
41
42
  break;
42
43
  case factory.eventType.ScreeningEventSeries:
@@ -78,7 +79,7 @@ function onResourceDeleted(params) {
78
79
  yield (0, syncOfferCatalog_1.syncOfferCatalog)({
79
80
  project: { id: params.project.id },
80
81
  ids: params.id,
81
- typeOf: params.typeOf,
82
+ typeOf: resourceType,
82
83
  isDeleted: true,
83
84
  isOfferCatalogItem: params.isOfferCatalogItem === true
84
85
  })(repos);
@@ -91,7 +92,7 @@ function onResourceDeleted(params) {
91
92
  yield deleteResourcesByProduct({
92
93
  project: { id: params.project.id },
93
94
  ids: params.id,
94
- typeOf: params.typeOf
95
+ typeOf: resourceType
95
96
  })(repos);
96
97
  break;
97
98
  // 区分削除に対応(2024-04-18~)
@@ -104,7 +105,7 @@ function onResourceDeleted(params) {
104
105
  break;
105
106
  default:
106
107
  // no op
107
- throw new factory.errors.NotImplemented(`${params.typeOf} onDeleted not implemented`);
108
+ throw new factory.errors.NotImplemented(`${resourceType} onDeleted not implemented`);
108
109
  }
109
110
  }
110
111
  });
@@ -146,9 +147,14 @@ function deleteResourcesByScreeningEventSeries(params) {
146
147
  }
147
148
  function deleteResourcesByScreeningRoom(params) {
148
149
  return (repos) => __awaiter(this, void 0, void 0, function* () {
150
+ // 現時点で、複数ルーム削除タスクは作成されない
151
+ const firstBranchCode = params.branchCode.at(0);
152
+ if (typeof firstBranchCode !== 'string') {
153
+ throw new factory.errors.ArgumentNull('branchCode');
154
+ }
149
155
  const deleteActionAttributes = {
150
156
  agent: { id: params.project.id, typeOf: factory.organizationType.Project },
151
- object: { branchCode: params.branchCode, containedInPlace: params.containedInPlace, typeOf: factory.placeType.ScreeningRoom },
157
+ object: { branchCode: firstBranchCode, containedInPlace: params.containedInPlace, typeOf: factory.placeType.ScreeningRoom },
152
158
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
153
159
  typeOf: factory.actionType.DeleteAction
154
160
  };
@@ -159,7 +165,7 @@ function deleteResourcesByScreeningRoom(params) {
159
165
  const deleteScreeningEventResult = yield repos.event.deleteManyEventsByScreeningRoom({
160
166
  project: { id: params.project.id },
161
167
  location: {
162
- branchCode: params.branchCode,
168
+ branchCode: firstBranchCode,
163
169
  containedInPlace: { id: params.containedInPlace.id }
164
170
  }
165
171
  });
@@ -277,8 +283,14 @@ function deleteResourcesBySeller(params) {
277
283
  project: { id: params.project.id },
278
284
  offeredBy: { id: sellerId }
279
285
  });
286
+ // イベントオファー削除(2026-01-16~)
287
+ const deleteEventOfferResult = yield repos.eventOffer.deleteEventOffersBySeller({
288
+ project: { id: params.project.id },
289
+ seller: { id: sellerId }
290
+ });
280
291
  deleteResult = {
281
292
  deleteMemberResult, deletePaymentServiceProviderResult,
293
+ deleteEventOfferResult,
282
294
  deleteProductOfferResult,
283
295
  deleteEventResult, deleteEventSeriesResult, deleteScreeningRoomResult, deleteMovieTheaterResult
284
296
  };
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  Object.defineProperty(exports, "__esModule", { value: true });
12
23
  exports.call = call;
13
24
  const factory = require("../../factory");
@@ -24,6 +35,7 @@ const unitPriceInCatalog_1 = require("../../repo/offer/unitPriceInCatalog");
24
35
  const offerCatalog_1 = require("../../repo/offerCatalog");
25
36
  const offerCatalogItem_1 = require("../../repo/offerCatalogItem");
26
37
  const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
38
+ const entranceGate_1 = require("../../repo/place/entranceGate");
27
39
  const hasPOS_1 = require("../../repo/place/hasPOS");
28
40
  const movieTheater_1 = require("../../repo/place/movieTheater");
29
41
  const screeningRoom_1 = require("../../repo/place/screeningRoom");
@@ -36,7 +48,7 @@ const onAggregateOfferUpdated_1 = require("./onResourceUpdated/onAggregateOfferU
36
48
  const onCategoryCodeUpdated_1 = require("./onResourceUpdated/onCategoryCodeUpdated");
37
49
  const onHasPOSUpdated_1 = require("./onResourceUpdated/onHasPOSUpdated");
38
50
  const onOfferCatalogUpdated_1 = require("./onResourceUpdated/onOfferCatalogUpdated");
39
- const onResourceDeleted_1 = require("./onResourceUpdated/onResourceDeleted");
51
+ // import { onResourceDeleted } from './onResourceUpdated/onResourceDeleted';
40
52
  /**
41
53
  * タスク実行関数
42
54
  */
@@ -48,6 +60,7 @@ function call(data) {
48
60
  aggregateOffer: new aggregateOffer_1.AggregateOfferRepo(connection),
49
61
  categoryCode: new categoryCode_1.CategoryCodeRepo(connection),
50
62
  creativeWork: new creativeWork_1.CreativeWorkRepo(connection),
63
+ entranceGate: new entranceGate_1.EntranceGateRepo(connection, { id: '' }), // 先の処理で明示的に指定される
51
64
  event: new event_1.EventRepo(connection),
52
65
  eventSeries: new eventSeries_1.EventSeriesRepo(connection),
53
66
  hasPOS: new hasPOS_1.HasPOSRepo(connection, { id: '' }), // 先の処理で明示的に指定される
@@ -73,7 +86,9 @@ function onResourceUpdated(params) {
73
86
  return (repos) => __awaiter(this, void 0, void 0, function* () {
74
87
  const isDeleted = params.isDeleted === true;
75
88
  if (isDeleted) {
76
- yield (0, onResourceDeleted_1.onResourceDeleted)(params)(repos);
89
+ // migrate to onResourceDeleted task(2026-01-16~)
90
+ throw new factory.errors.Argument('isDeleted', 'isDeleted must be false');
91
+ // await onResourceDeleted(params)(repos);
77
92
  }
78
93
  else {
79
94
  const setting = yield repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onResourceUpdated', 'useInformResourceTypes']);
@@ -118,6 +133,14 @@ function onResourceUpdated(params) {
118
133
  typeOf: params.typeOf
119
134
  }, setting)(repos);
120
135
  break;
136
+ // ルーム通知に対応(2026-01-16~)
137
+ case factory.placeType.ScreeningRoom:
138
+ yield createInformRoomTasks(params, setting)(repos);
139
+ break;
140
+ // 入場ゲート通知に対応(2026-01-17~)
141
+ case factory.placeType.EntranceGate:
142
+ yield createInformEntranceGateTasks(params, setting)(repos);
143
+ break;
121
144
  case 'AccountTitle':
122
145
  yield createInformAccountTitleTasks({
123
146
  project: { id: params.project.id },
@@ -397,27 +420,28 @@ function createInformCategoryCodeTasks(params, setting) {
397
420
  }
398
421
  });
399
422
  }
400
- // tslint:disable-next-line:max-func-body-length
401
423
  function createInformMovieTheaterTasks(params, setting) {
402
- return (repos
403
- // settings: Settings
404
- ) => __awaiter(this, void 0, void 0, function* () {
424
+ // tslint:disable-next-line:max-func-body-length
425
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
405
426
  var _a;
406
- if (params.ids.length !== 1) {
407
- throw new factory.errors.Argument('id', 'id.length must be 1');
427
+ // 複数対応(2026-01-18~)
428
+ // if (params.ids.length !== 1) {
429
+ // throw new factory.errors.Argument('id', 'id.length must be 1');
430
+ // }
431
+ if (params.ids.length === 0) {
432
+ return;
408
433
  }
409
- // const informResources = settings.onResourceUpdated.informResource;
410
434
  const informResources = (_a = setting === null || setting === void 0 ? void 0 : setting.onResourceUpdated) === null || _a === void 0 ? void 0 : _a.informResource;
411
435
  const movieTheaters = yield repos.movieTheater.projectFields({
412
- limit: 1,
413
- page: 1,
436
+ // limit: 1,
437
+ // page: 1,
414
438
  project: { id: { $eq: params.project.id } },
415
- id: { $eq: params.ids[0] }
439
+ // id: { $eq: params.ids[0] }
440
+ id: { $in: params.ids }
416
441
  }, [
417
442
  'additionalProperty',
418
443
  'branchCode',
419
- 'hasEntranceGate',
420
- // 'hasPOS',
444
+ // 'hasEntranceGate', // migrate to IEntranceGateAsNotification(2026-01-17~)
421
445
  'kanaName',
422
446
  'name',
423
447
  'parentOrganization',
@@ -428,23 +452,33 @@ function createInformMovieTheaterTasks(params, setting) {
428
452
  ]
429
453
  // []
430
454
  );
431
- const movieTheater = movieTheaters.shift();
432
- if (movieTheater === undefined) {
433
- throw new factory.errors.NotFound(factory.placeType.MovieTheater);
434
- }
435
- // ルームを検索
436
- const screeningRooms = yield repos.screeningRoom.searchScreeningRooms({
437
- containedInPlace: { id: { $eq: movieTheater.id } }
455
+ // const movieTheater = movieTheaters.shift();
456
+ // if (movieTheater === undefined) {
457
+ // throw new factory.errors.NotFound(factory.placeType.MovieTheater);
458
+ // }
459
+ // // ルームを検索
460
+ // const screeningRooms = await repos.screeningRoom.findRooms(
461
+ // {
462
+ // containedInPlace: { id: { $eq: movieTheater.id } }
463
+ // }
464
+ // );
465
+ // 入場ゲートを廃止(2026-01-17~)
466
+ const movieTheaters4inform = movieTheaters.map((movieTheater) => {
467
+ const { hasEntranceGate } = movieTheater, movieTheaterWithoutEntranceGates = __rest(movieTheater, ["hasEntranceGate"]);
468
+ return Object.assign({}, movieTheaterWithoutEntranceGates
469
+ // ...movieTheater
470
+ // migrate to IRoomAsNotification(2026-01-16~)
471
+ // containsPlace: screeningRooms.map((room) => {
472
+ // return {
473
+ // branchCode: room.branchCode,
474
+ // name: room.name,
475
+ // typeOf: factory.placeType.ScreeningRoom,
476
+ // additionalProperty: room.additionalProperty,
477
+ // address: room.address
478
+ // };
479
+ // })
480
+ );
438
481
  });
439
- const movieTheaters4inform = [Object.assign(Object.assign({}, movieTheater), { containsPlace: screeningRooms.map((room) => {
440
- return {
441
- branchCode: room.branchCode,
442
- name: room.name,
443
- typeOf: room.typeOf,
444
- additionalProperty: room.additionalProperty,
445
- address: room.address
446
- };
447
- }) })];
448
482
  if (movieTheaters4inform.length > 0) {
449
483
  const taskRunsAt = new Date();
450
484
  const informTasks = [];
@@ -453,8 +487,8 @@ function createInformMovieTheaterTasks(params, setting) {
453
487
  const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
454
488
  movieTheaters4inform.forEach((movieTheater4inform) => {
455
489
  var _a;
456
- // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
457
- delete movieTheater4inform._id;
490
+ // // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
491
+ // delete (<any>movieTheater4inform)._id;
458
492
  const informActionAttributes = {
459
493
  object: movieTheater4inform,
460
494
  recipient: {
@@ -488,6 +522,131 @@ function createInformMovieTheaterTasks(params, setting) {
488
522
  }
489
523
  });
490
524
  }
525
+ // tslint:disable-next-line:max-func-body-length
526
+ function createInformRoomTasks(params, setting) {
527
+ return (repos
528
+ // settings: Settings
529
+ ) => __awaiter(this, void 0, void 0, function* () {
530
+ var _a;
531
+ // const informResources = settings.onResourceUpdated.informResource;
532
+ const informResources = (_a = setting === null || setting === void 0 ? void 0 : setting.onResourceUpdated) === null || _a === void 0 ? void 0 : _a.informResource;
533
+ if (Array.isArray(params.branchCode) && params.branchCode.length > 0) {
534
+ // ルームを検索
535
+ const rooms = (yield repos.screeningRoom.findRooms({
536
+ project: { id: { $eq: params.project.id } },
537
+ branchCode: { $in: params.branchCode },
538
+ containedInPlace: { id: { $eq: params.containedInPlace.id } }
539
+ }));
540
+ const rooms4inform = rooms.map((room) => {
541
+ return {
542
+ branchCode: room.branchCode,
543
+ name: room.name,
544
+ typeOf: factory.placeType.ScreeningRoom,
545
+ additionalProperty: room.additionalProperty,
546
+ address: room.address,
547
+ containedInPlace: { id: params.containedInPlace.id },
548
+ project: { id: params.project.id }
549
+ };
550
+ });
551
+ if (rooms4inform.length > 0) {
552
+ const taskRunsAt = new Date();
553
+ const informTasks = [];
554
+ informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
555
+ var _a;
556
+ const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
557
+ rooms4inform.forEach((room4inform) => {
558
+ var _a;
559
+ const informActionAttributes = {
560
+ object: room4inform,
561
+ recipient: {
562
+ id: '',
563
+ name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
564
+ typeOf: factory.creativeWorkType.WebApplication
565
+ },
566
+ target: {
567
+ httpMethod: 'POST',
568
+ encodingType: factory.encodingFormat.Application.json,
569
+ typeOf: 'EntryPoint',
570
+ urlTemplate: informUrl
571
+ }
572
+ };
573
+ informTasks.push({
574
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
575
+ name: factory.taskName.TriggerWebhook,
576
+ status: factory.taskStatus.Ready,
577
+ runsAt: taskRunsAt,
578
+ remainingNumberOfTries: 10,
579
+ numberOfTried: 0,
580
+ executionResults: [],
581
+ data: informActionAttributes
582
+ });
583
+ });
584
+ });
585
+ if (informTasks.length > 0) {
586
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
587
+ }
588
+ }
589
+ }
590
+ });
591
+ }
592
+ // tslint:disable-next-line:max-func-body-length
593
+ function createInformEntranceGateTasks(params, setting) {
594
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
595
+ var _a;
596
+ const informResources = (_a = setting === null || setting === void 0 ? void 0 : setting.onResourceUpdated) === null || _a === void 0 ? void 0 : _a.informResource;
597
+ if (Array.isArray(params.identifier) && params.identifier.length > 0) {
598
+ // 入場ゲートを検索
599
+ repos.entranceGate.setOperatorId({ id: params.containedInPlace.id });
600
+ const entranceGates = (yield repos.entranceGate.findEntranceGates({
601
+ project: { id: { $eq: params.project.id } },
602
+ identifier: { $in: params.identifier }
603
+ }));
604
+ const entranceGatesAsNotification = [{
605
+ id: params.containedInPlace.id,
606
+ typeOf: factory.placeType.MovieTheater,
607
+ hasEntranceGate: entranceGates.map((entranceGate) => {
608
+ return Object.assign(Object.assign({}, entranceGate), { typeOf: factory.placeType.Place });
609
+ })
610
+ }];
611
+ const taskRunsAt = new Date();
612
+ const informTasks = [];
613
+ informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
614
+ var _a;
615
+ const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
616
+ entranceGatesAsNotification.forEach((entranceGateAsNotification) => {
617
+ var _a;
618
+ const informActionAttributes = {
619
+ object: entranceGateAsNotification,
620
+ recipient: {
621
+ id: '',
622
+ name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
623
+ typeOf: factory.creativeWorkType.WebApplication
624
+ },
625
+ target: {
626
+ httpMethod: 'POST',
627
+ encodingType: factory.encodingFormat.Application.json,
628
+ typeOf: 'EntryPoint',
629
+ urlTemplate: informUrl
630
+ }
631
+ };
632
+ informTasks.push({
633
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
634
+ name: factory.taskName.TriggerWebhook,
635
+ status: factory.taskStatus.Ready,
636
+ runsAt: taskRunsAt,
637
+ remainingNumberOfTries: 10,
638
+ numberOfTried: 0,
639
+ executionResults: [],
640
+ data: informActionAttributes
641
+ });
642
+ });
643
+ });
644
+ if (informTasks.length > 0) {
645
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
646
+ }
647
+ }
648
+ });
649
+ }
491
650
  function createInformAccountTitleTasks(params, setting) {
492
651
  return (repos
493
652
  // settings: Settings
@@ -566,22 +725,27 @@ function createInformAccountTitleTasks(params, setting) {
566
725
  }
567
726
  function syncMovieTheater(params) {
568
727
  return (repos) => __awaiter(this, void 0, void 0, function* () {
569
- if (params.ids.length !== 1) {
570
- throw new factory.errors.Argument('id', 'id.length must be 1');
728
+ // if (params.ids.length !== 1) {
729
+ // throw new factory.errors.Argument('id', 'id.length must be 1');
730
+ // }
731
+ if (params.ids.length === 0) {
732
+ return;
571
733
  }
572
734
  const movieTheaters = yield repos.movieTheater.projectFields({
573
- id: { $eq: params.ids[0] },
735
+ id: { $in: params.ids },
574
736
  project: { id: { $eq: params.project.id } }
575
737
  }, ['id', 'name']
576
738
  // []
577
739
  );
578
- const movieTheater = movieTheaters.shift();
579
- if (movieTheater === undefined) {
580
- throw new factory.errors.NotFound(factory.placeType.MovieTheater);
740
+ // const movieTheater = movieTheaters.shift();
741
+ // if (movieTheater === undefined) {
742
+ // throw new factory.errors.NotFound(factory.placeType.MovieTheater);
743
+ // }
744
+ for (const movieTheater of movieTheaters) {
745
+ yield repos.screeningRoom.updateScreeningRoomsByContainedInPlaceId({
746
+ project: { id: params.project.id },
747
+ containedInPlace: movieTheater
748
+ });
581
749
  }
582
- yield repos.screeningRoom.updateScreeningRoomsByContainedInPlaceId({
583
- project: { id: params.project.id },
584
- containedInPlace: movieTheater
585
- });
586
750
  });
587
751
  }
@@ -216,7 +216,7 @@ function syncEvents(params) {
216
216
  throw new factory.errors.NotFound(factory.placeType.MovieTheater);
217
217
  }
218
218
  // console.log('movieTheater:', movieTheater);
219
- const screeningRoom = (yield repos.screeningRoom.searchScreeningRooms({
219
+ const screeningRoom = (yield repos.screeningRoom.findRooms({
220
220
  project: { id: { $eq: params.project.id } },
221
221
  containedInPlace: { branchCode: { $eq: movieTheater.branchCode } },
222
222
  branchCode: { $eq: roomCode }
@@ -59,6 +59,7 @@ function executeTask(task, next) {
59
59
  case factory.taskName.ImportOffersFromCOA:
60
60
  case factory.taskName.InvalidatePaymentUrl:
61
61
  case factory.taskName.OnAuthorizationCreated:
62
+ case factory.taskName.OnResourceDeleted:
62
63
  case factory.taskName.Pay:
63
64
  case factory.taskName.PublishPaymentUrl:
64
65
  case factory.taskName.Refund:
package/package.json CHANGED
@@ -11,8 +11,8 @@
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.8",
15
- "@cinerino/sdk": "12.12.1",
14
+ "@chevre/factory": "5.4.0-alpha.25",
15
+ "@cinerino/sdk": "12.14.0-alpha.8",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.4.0-alpha.1",
18
18
  "@sendgrid/client": "8.1.4",
@@ -33,6 +33,7 @@
33
33
  "description": "Chevre Domain Library for Node.js",
34
34
  "devDependencies": {
35
35
  "@eslint/js": "9.16.0",
36
+ "@json2csv/plainjs": "7.0.6",
36
37
  "@sendgrid/helpers": "8.0.0",
37
38
  "@types/debug": "0.0.30",
38
39
  "@types/google-libphonenumber": "^7.4.19",
@@ -115,5 +116,5 @@
115
116
  "postversion": "git push origin --tags",
116
117
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
118
  },
118
- "version": "23.2.0-alpha.4"
119
+ "version": "23.2.0-alpha.41"
119
120
  }
@@ -1,191 +0,0 @@
1
- // tslint:disable:no-console no-magic-numbers
2
- import * as moment from 'moment-timezone';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../../lib/index';
6
-
7
- const project = { id: String(process.env.PROJECT_ID) };
8
- const ADDITIONAL_PROPERTY_NAME = 'sampleCreateId';
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
15
-
16
- const today = moment()
17
- .tz('Asia/Tokyo')
18
- .format('YYYY-MM-DD');
19
- const identifier = `fromSamples:${moment()
20
- .format('YYYY-MM-DD HH:mm')}`;
21
- const settingEvent: chevre.factory.event.screeningEvent.IAttributes = {
22
- identifier,
23
- additionalProperty: [
24
- { name: ADDITIONAL_PROPERTY_NAME, value: identifier }
25
- ],
26
- project: {
27
- id: project.id,
28
- typeOf: chevre.factory.organizationType.Project
29
- },
30
- organizer: {
31
- id: '59d20831e53ebc2b4e774466'
32
- },
33
- typeOf: chevre.factory.eventType.ScreeningEvent,
34
- name: {
35
- en: 'pet IMAX2D',
36
- ja: 'ペット IMAX2D'
37
- },
38
- doorTime: moment(`${today}T13:00:00Z`)
39
- .toDate(),
40
- startDate: moment(`${today}T13:00:00Z`)
41
- .toDate(),
42
- endDate: moment(`${today}T14:00:00Z`)
43
- .toDate(),
44
- eventStatus: chevre.factory.eventStatusType.EventScheduled,
45
- location: {
46
- typeOf: chevre.factory.placeType.ScreeningRoom,
47
- branchCode: '70',
48
- name: {
49
- ja: 'シネマ7',
50
- en: 'CINEMA7'
51
- },
52
- address: {
53
- ja: '',
54
- en: ''
55
- }
56
- },
57
- superEvent: {
58
- typeOf: chevre.factory.eventType.ScreeningEventSeries,
59
- id: 'al9s38bj6',
60
- videoFormat: [
61
- {
62
- typeOf: '2D',
63
- name: '2D'
64
- },
65
- {
66
- typeOf: 'IMAX',
67
- name: 'IMAX'
68
- }
69
- ],
70
- soundFormat: [],
71
- workPerformed: {
72
- typeOf: chevre.factory.creativeWorkType.Movie,
73
- identifier: '1622100',
74
- id: '5bfb841d5a78d7948369980a',
75
- name: {
76
- en: 'Pet',
77
- ja: 'ペット'
78
- },
79
- duration: 'PT2H3M'
80
- },
81
- location: {
82
- typeOf: chevre.factory.placeType.MovieTheater,
83
- id: '5bfb841d5a78d7948369979a',
84
- branchCode: '118',
85
- name: {
86
- ja: 'シネモーション赤坂 ',
87
- en: 'CineMotion Akasaka'
88
- }
89
- },
90
- kanaName: 'ペット IMAX2D',
91
- name: {
92
- en: 'pet IMAX2D',
93
- ja: 'ペット IMAX2D'
94
- },
95
- additionalProperty: [],
96
- startDate: moment('2022-09-30T15:00:00.000Z')
97
- .toDate(),
98
- endDate: moment('2029-07-31T15:00:00.000Z')
99
- .toDate(),
100
- headline: {
101
- ja: 'IMAX2D上映'
102
- }
103
- },
104
- offers: {
105
- typeOf: chevre.factory.offerType.Offer,
106
- eligibleQuantity: {
107
- typeOf: 'QuantitativeValue',
108
- unitCode: chevre.factory.unitCode.C62,
109
- maxValue: 6
110
- },
111
- itemOffered: {
112
- id: '655dc6b02cbb99d946cb6081',
113
- name: {
114
- ja: '通常興行カタログ(サブカタログ版)'
115
- },
116
- serviceOutput: {
117
- typeOf: chevre.factory.reservationType.EventReservation,
118
- reservedTicket: {
119
- typeOf: 'Ticket',
120
- ticketedSeat: {
121
- typeOf: chevre.factory.placeType.Seat
122
- }
123
- }
124
- },
125
- typeOf: chevre.factory.product.ProductType.EventService,
126
- availableChannel: {
127
- typeOf: 'ServiceChannel',
128
- serviceLocation: {
129
- typeOf: chevre.factory.placeType.ScreeningRoom,
130
- branchCode: '70',
131
- name: {
132
- ja: 'シネマ7',
133
- en: 'CINEMA7'
134
- },
135
- containedInPlace: {
136
- typeOf: chevre.factory.placeType.MovieTheater,
137
- id: '5bfb841d5a78d7948369979a',
138
- branchCode: '118',
139
- name: {
140
- ja: 'シネモーション赤坂 ',
141
- en: 'CineMotion Akasaka'
142
- }
143
- }
144
- }
145
- }
146
- },
147
- seller: {
148
- typeOf: chevre.factory.organizationType.Corporation,
149
- id: '59d20831e53ebc2b4e774466',
150
- name: {
151
- ja: 'シネモーション赤坂',
152
- en: 'CineMotion Akasaka'
153
- },
154
- makesOffer: [
155
- ]
156
- }
157
- }
158
- };
159
-
160
- const createResult = await eventRepo.upsertManyScreeningEventByIdentifier(
161
- [
162
- {
163
- $set: settingEvent,
164
- $unset: {}
165
- }
166
- ],
167
- { update: false }
168
- );
169
- // tslint:disable-next-line:no-null-keyword
170
- console.dir(createResult, { depth: null });
171
-
172
- const updateResult = await eventRepo.upsertManyScreeningEventByIdentifier(
173
- [
174
- {
175
- $set: {
176
- ...settingEvent,
177
- eventStatus: chevre.factory.eventStatusType.EventCancelled
178
- },
179
- $unset: {}
180
- }
181
- ],
182
- { update: true }
183
- );
184
- // tslint:disable-next-line:no-null-keyword
185
- console.dir(updateResult, { depth: null });
186
-
187
- }
188
-
189
- main()
190
- .then()
191
- .catch(console.error);