@chevre/domain 22.5.0-alpha.44 → 22.5.0-alpha.46

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.
@@ -16,14 +16,17 @@ const factory_1 = require("../factory");
16
16
  function onPendingReservationCanceled(params) {
17
17
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
18
18
  const { project, reservationFor, reservationNumber } = params;
19
- if (typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.id) === 'string') {
20
- // 冗長な作成を避ける
21
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
22
- project: { id: project.id },
23
- reservationFor: [{ id: reservationFor.id }],
24
- force: false,
25
- identifier: `onPendingReservationCanceled:${reservationNumber}`
26
- })({ task: repos.task });
19
+ // migrate to agg(2024-10-29~)
20
+ if (!settings.useAggregationOnAggService) {
21
+ if (typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.id) === 'string') {
22
+ // 冗長な作成を避ける
23
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
24
+ project: { id: project.id },
25
+ reservationFor: [{ id: reservationFor.id }],
26
+ force: false,
27
+ identifier: `onPendingReservationCanceled:${reservationNumber}`
28
+ })({ task: repos.task });
29
+ }
27
30
  }
28
31
  // inform(2024-10-25~)
29
32
  const informReservations = settings.onReservationStatusChanged.informReservation;
@@ -102,13 +102,16 @@ reservationFor) {
102
102
  }
103
103
  }
104
104
  if (typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.id) === 'string') {
105
- // 冗長な作成を避ける
106
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
107
- project: { id: reservationFor.project.id },
108
- reservationFor: [{ id: reservationFor.id }],
109
- force: false,
110
- identifier: `onReservationCanceled:${(_a = canceledReservations === null || canceledReservations === void 0 ? void 0 : canceledReservations[0]) === null || _a === void 0 ? void 0 : _a.reservationNumber}`
111
- })({ task: repos.task });
105
+ // migrate to agg(2024-10-29~)
106
+ if (!settings.useAggregationOnAggService) {
107
+ // 冗長な作成を避ける
108
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
109
+ project: { id: reservationFor.project.id },
110
+ reservationFor: [{ id: reservationFor.id }],
111
+ force: false,
112
+ identifier: `onReservationCanceled:${(_a = canceledReservations === null || canceledReservations === void 0 ? void 0 : canceledReservations[0]) === null || _a === void 0 ? void 0 : _a.reservationNumber}`
113
+ })({ task: repos.task });
114
+ }
112
115
  }
113
116
  });
114
117
  }
@@ -107,26 +107,29 @@ function onReservationCheckedIn(params) {
107
107
  if (tasks.length > 0) {
108
108
  yield repos.task.saveMany(tasks, { emitImmediately: true });
109
109
  }
110
- // 冗長な作成を避ける
111
- const reservationForIds = (_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.ids;
112
- if (Array.isArray(reservationForIds)) {
113
- // 集計タスクを追加
114
- yield Promise.all(reservationForIds.map((reservationForId) => __awaiter(this, void 0, void 0, function* () {
115
- var _b;
116
- // すでにイベントが削除されているケースに備えて、イベント存在検証(2023-09-12~)
117
- const existingEvents = yield repos.event.projectEventFields({
118
- id: { $eq: reservationForId },
119
- typeOfIn: [factory.eventType.Event, factory.eventType.ScreeningEvent] // 指定しないとArgumentNullError
120
- }, ['typeOf']);
121
- if (existingEvents.length > 0) {
122
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
123
- project: { id: params.project.id },
124
- reservationFor: [{ id: reservationForId }],
125
- force: false,
126
- identifier: `onReservationCheckedIn:${(_b = params.purpose) === null || _b === void 0 ? void 0 : _b.code}`
127
- })({ task: repos.task });
128
- }
129
- })));
110
+ // migrate to agg(2024-10-29~)
111
+ if (!settings.useAggregationOnAggService) {
112
+ // 冗長な作成を避ける
113
+ const reservationForIds = (_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.ids;
114
+ if (Array.isArray(reservationForIds)) {
115
+ // 集計タスクを追加
116
+ yield Promise.all(reservationForIds.map((reservationForId) => __awaiter(this, void 0, void 0, function* () {
117
+ var _b;
118
+ // すでにイベントが削除されているケースに備えて、イベント存在検証(2023-09-12~)
119
+ const existingEvents = yield repos.event.projectEventFields({
120
+ id: { $eq: reservationForId },
121
+ typeOfIn: [factory.eventType.Event, factory.eventType.ScreeningEvent] // 指定しないとArgumentNullError
122
+ }, ['typeOf']);
123
+ if (existingEvents.length > 0) {
124
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
125
+ project: { id: params.project.id },
126
+ reservationFor: [{ id: reservationForId }],
127
+ force: false,
128
+ identifier: `onReservationCheckedIn:${(_b = params.purpose) === null || _b === void 0 ? void 0 : _b.code}`
129
+ })({ task: repos.task });
130
+ }
131
+ })));
132
+ }
130
133
  }
131
134
  });
132
135
  }
@@ -57,12 +57,15 @@ function onReservationConfirmed(confirmedReservations) {
57
57
  if (Array.isArray(confirmedReservations) && confirmedReservations.length > 0) {
58
58
  // ひとつめの予約からReservationPackageの共有属性を取り出す
59
59
  const { bookingTime, issuedThrough, project, provider, reservationFor, reservationNumber, underName } = confirmedReservations[0];
60
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
61
- project,
62
- reservationFor: [{ id: reservationFor.id }],
63
- force: false,
64
- identifier: `onReservationConfirmed:${reservationNumber}`
65
- })({ task: repos.task });
60
+ // migrate to agg(2024-10-29~)
61
+ if (!settings.useAggregationOnAggService) {
62
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
63
+ project,
64
+ reservationFor: [{ id: reservationFor.id }],
65
+ force: false,
66
+ identifier: `onReservationConfirmed:${reservationNumber}`
67
+ })({ task: repos.task });
68
+ }
66
69
  const now = new Date();
67
70
  const taskAttributes = [];
68
71
  const subReservations4inform = confirmedReservations.map((r) => {
@@ -133,13 +133,16 @@ function onReservationUsed(attendedReservation) {
133
133
  if (tasks.length > 0) {
134
134
  yield repos.task.saveMany(tasks, { emitImmediately: true });
135
135
  }
136
- // 冗長な作成を避ける
137
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
138
- project: attendedReservation.project,
139
- reservationFor: [{ id: attendedReservation.reservationFor.id }],
140
- force: false,
141
- identifier: `onReservationUsed:${attendedReservation.id}`
142
- })({ task: repos.task });
136
+ // migrate to agg(2024-10-29~)
137
+ if (!settings.useAggregationOnAggService) {
138
+ // 冗長な作成を避ける
139
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
140
+ project: attendedReservation.project,
141
+ reservationFor: [{ id: attendedReservation.reservationFor.id }],
142
+ force: false,
143
+ identifier: `onReservationUsed:${attendedReservation.id}`
144
+ })({ task: repos.task });
145
+ }
143
146
  });
144
147
  }
145
148
  exports.onReservationUsed = onReservationUsed;
@@ -18,13 +18,16 @@ const factory_1 = require("../factory");
18
18
  */
19
19
  function onReservationsCreated(params) {
20
20
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
21
- // 集計タスク
22
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
23
- project: { id: params.project.id },
24
- reservationFor: [{ id: params.event.id }],
25
- force: false,
26
- identifier: `onReservationsCreated:${params.transaction.transactionNumber}`
27
- })({ task: repos.task });
21
+ // migrate to agg(2024-10-29~)
22
+ if (!settings.useAggregationOnAggService) {
23
+ // 集計タスク
24
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
25
+ project: { id: params.project.id },
26
+ reservationFor: [{ id: params.event.id }],
27
+ force: false,
28
+ identifier: `onReservationsCreated:${params.transaction.transactionNumber}`
29
+ })({ task: repos.task });
30
+ }
28
31
  // inform(2024-10-25~)
29
32
  const informReservations = settings.onReservationStatusChanged.informReservation;
30
33
  const now = new Date();
@@ -73,6 +73,7 @@ interface IOptions {
73
73
  */
74
74
  minIntervalBetweenPayAndRefund: number;
75
75
  };
76
+ useAggregationOnAggService?: boolean;
76
77
  useAssetTransactionSyncProcessing: boolean;
77
78
  useExperimentalFeature: boolean;
78
79
  notification: IWebhookSettings;
@@ -133,6 +134,7 @@ declare class Settings {
133
134
  */
134
135
  minIntervalBetweenPayAndRefund: number;
135
136
  };
137
+ readonly useAggregationOnAggService: boolean;
136
138
  readonly useAssetTransactionSyncProcessing: boolean;
137
139
  readonly useExperimentalFeature: boolean;
138
140
  /**
@@ -12,7 +12,7 @@ class Settings {
12
12
  // useAggregateEntranceGateProjects,
13
13
  // useAggregateOfferProjects,
14
14
  // useOfferRateLimitProjects,
15
- abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAssetTransactionSyncProcessing, useExperimentalFeature, notification } = options;
15
+ abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAggregationOnAggService, useAssetTransactionSyncProcessing, useExperimentalFeature, notification } = options;
16
16
  this.onEventChanged = onEventChanged;
17
17
  this.onOrderStatusChanged = onOrderStatusChanged;
18
18
  this.onResourceUpdated = onResourceUpdated;
@@ -30,6 +30,7 @@ class Settings {
30
30
  this.coa = coa;
31
31
  this.gmo = gmo;
32
32
  this.movieticketReserve = movieticketReserve;
33
+ this.useAggregationOnAggService = useAggregationOnAggService === true;
33
34
  this.useAssetTransactionSyncProcessing = useAssetTransactionSyncProcessing;
34
35
  this.useExperimentalFeature = useExperimentalFeature;
35
36
  this.notification = notification;
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": "4.388.0-alpha.6",
14
+ "@chevre/factory": "4.388.0-alpha.7",
15
15
  "@cinerino/sdk": "10.16.0-alpha.3",
16
16
  "@motionpicture/coa-service": "9.5.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
@@ -108,5 +108,5 @@
108
108
  "postversion": "git push origin --tags",
109
109
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
110
110
  },
111
- "version": "22.5.0-alpha.44"
111
+ "version": "22.5.0-alpha.46"
112
112
  }