@chevre/domain 22.5.0-alpha.50 → 22.5.0-alpha.52

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.
@@ -27,6 +27,13 @@ function onEventChanged(params) {
27
27
  identifier: `onEventChanged`
28
28
  })(repos);
29
29
  }
30
+ // inform to agg(2024-10-30~)
31
+ yield createInform2aggTasks({
32
+ project: { id: params.project.id },
33
+ ids: params.id,
34
+ typeOf: params.typeOf,
35
+ isNew: params.isNew
36
+ })(repos, settings);
30
37
  // 通知タスク作成(2023-06-08~)
31
38
  if (params.useInform === true) {
32
39
  yield createInformTasks({
@@ -257,3 +264,49 @@ function createInformTasks(params) {
257
264
  }
258
265
  });
259
266
  }
267
+ function createInform2aggTasks(params) {
268
+ return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
269
+ let event4inform;
270
+ const informEvent2agg = settings.onEventChanged.informEvent2agg;
271
+ if (params.typeOf === factory.eventType.ScreeningEvent) {
272
+ event4inform = {
273
+ id: params.ids,
274
+ isNew: params.isNew === true,
275
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
276
+ typeOf: factory.eventType.ScreeningEvent
277
+ };
278
+ }
279
+ if (event4inform !== undefined) {
280
+ const informObject = event4inform;
281
+ if (Array.isArray(informEvent2agg)) {
282
+ const taskRunsAt = new Date();
283
+ const informTasks = informEvent2agg.map((informEvent) => {
284
+ var _a, _b;
285
+ const informUrl = String((_a = informEvent.recipient) === null || _a === void 0 ? void 0 : _a.url);
286
+ const informActionAttributes = {
287
+ object: informObject,
288
+ recipient: {
289
+ id: '',
290
+ name: String((_b = informEvent.recipient) === null || _b === void 0 ? void 0 : _b.name),
291
+ typeOf: factory.creativeWorkType.WebApplication,
292
+ url: informUrl
293
+ }
294
+ };
295
+ return {
296
+ project: informObject.project,
297
+ name: factory.taskName.TriggerWebhook,
298
+ status: factory.taskStatus.Ready,
299
+ runsAt: taskRunsAt,
300
+ remainingNumberOfTries: 10,
301
+ numberOfTried: 0,
302
+ executionResults: [],
303
+ data: informActionAttributes
304
+ };
305
+ });
306
+ if (informTasks.length > 0) {
307
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
308
+ }
309
+ }
310
+ }
311
+ });
312
+ }
@@ -11,23 +11,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.onPendingReservationCanceled = void 0;
13
13
  const factory = require("../../../factory");
14
- const onEventChanged_1 = require("../../offer/onEventChanged");
14
+ // import { createAggregateScreeningEventIfNotExist } from '../../offer/onEventChanged';
15
15
  const factory_1 = require("../factory");
16
16
  function onPendingReservationCanceled(params) {
17
17
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
18
- const { project, reservationFor, reservationNumber } = params;
18
+ const { reservationFor, reservationNumber } = params;
19
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
- }
30
- }
20
+ // if (typeof reservationFor?.id === 'string') {
21
+ // // 冗長な作成を避ける
22
+ // await createAggregateScreeningEventIfNotExist({
23
+ // project: { id: project.id },
24
+ // reservationFor: [{ id: reservationFor.id }],
25
+ // force: false,
26
+ // identifier: `onPendingReservationCanceled:${reservationNumber}`
27
+ // })({ task: repos.task });
28
+ // }
31
29
  // inform(2024-10-25~)
32
30
  const informReservations = settings.onReservationStatusChanged.informReservation;
33
31
  const now = new Date();
@@ -14,7 +14,7 @@ exports.onReservationCanceled = void 0;
14
14
  * 予約取消時アクション
15
15
  */
16
16
  const factory = require("../../../factory");
17
- const onEventChanged_1 = require("../../offer/onEventChanged");
17
+ // import { createAggregateScreeningEventIfNotExist } from '../../offer/onEventChanged';
18
18
  const factory_1 = require("../factory");
19
19
  // tslint:disable-next-line:max-func-body-length
20
20
  function onReservationCanceled(
@@ -28,7 +28,6 @@ canceledReservations,
28
28
  */
29
29
  reservationFor) {
30
30
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
31
- var _a;
32
31
  const informReservations = settings.onReservationStatusChanged.informReservation;
33
32
  if (Array.isArray(canceledReservations) && canceledReservations.length > 0) {
34
33
  const now = new Date();
@@ -77,15 +76,13 @@ reservationFor) {
77
76
  }
78
77
  if (typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.id) === 'string') {
79
78
  // migrate to agg(2024-10-29~)
80
- if (!settings.useAggregationOnAggService) {
81
- // 冗長な作成を避ける
82
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
83
- project: { id: reservationFor.project.id },
84
- reservationFor: [{ id: reservationFor.id }],
85
- force: false,
86
- identifier: `onReservationCanceled:${(_a = canceledReservations === null || canceledReservations === void 0 ? void 0 : canceledReservations[0]) === null || _a === void 0 ? void 0 : _a.reservationNumber}`
87
- })({ task: repos.task });
88
- }
79
+ // 冗長な作成を避ける
80
+ // await createAggregateScreeningEventIfNotExist({
81
+ // project: { id: reservationFor.project.id },
82
+ // reservationFor: [{ id: reservationFor.id }],
83
+ // force: false,
84
+ // identifier: `onReservationCanceled:${canceledReservations?.[0]?.reservationNumber}`
85
+ // })({ task: repos.task });
89
86
  }
90
87
  });
91
88
  }
@@ -14,13 +14,13 @@ exports.onReservationCheckedIn = void 0;
14
14
  * 予約発券時アクション
15
15
  */
16
16
  const factory = require("../../../factory");
17
- const onEventChanged_1 = require("../../offer/onEventChanged");
17
+ // import { createAggregateScreeningEventIfNotExist } from '../../offer/onEventChanged';
18
18
  const factory_1 = require("../factory");
19
19
  // tslint:disable-next-line:max-func-body-length
20
20
  function onReservationCheckedIn(params) {
21
21
  // tslint:disable-next-line:max-func-body-length
22
22
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
23
- var _a, _b;
23
+ var _a;
24
24
  const tasks = [];
25
25
  const project = { id: params.project.id, typeOf: factory.organizationType.Project };
26
26
  const informReservations = settings.onReservationStatusChanged.informReservation;
@@ -71,28 +71,29 @@ function onReservationCheckedIn(params) {
71
71
  yield repos.task.saveMany(tasks, { emitImmediately: true });
72
72
  }
73
73
  // migrate to agg(2024-10-29~)
74
- if (!settings.useAggregationOnAggService) {
75
- // 冗長な作成を避ける
76
- const reservationForIds = (_b = params.object.reservationFor) === null || _b === void 0 ? void 0 : _b.ids;
77
- if (Array.isArray(reservationForIds)) {
78
- // 集計タスクを追加
79
- yield Promise.all(reservationForIds.map((reservationForId) => __awaiter(this, void 0, void 0, function* () {
80
- // すでにイベントが削除されているケースに備えて、イベント存在検証(2023-09-12~)
81
- const existingEvents = yield repos.event.projectEventFields({
82
- id: { $eq: reservationForId },
83
- typeOfIn: [factory.eventType.Event, factory.eventType.ScreeningEvent] // 指定しないとArgumentNullError
84
- }, ['typeOf']);
85
- if (existingEvents.length > 0) {
86
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
87
- project: { id: params.project.id },
88
- reservationFor: [{ id: reservationForId }],
89
- force: false,
90
- identifier: `onReservationCheckedIn:${ticketToken}`
91
- })({ task: repos.task });
92
- }
93
- })));
94
- }
95
- }
74
+ // 冗長な作成を避ける
75
+ // const reservationForIds = params.object.reservationFor?.ids;
76
+ // if (Array.isArray(reservationForIds)) {
77
+ // // 集計タスクを追加
78
+ // await Promise.all(reservationForIds.map(async (reservationForId) => {
79
+ // // すでにイベントが削除されているケースに備えて、イベント存在検証(2023-09-12~)
80
+ // const existingEvents = <Pick<factory.event.IEvent<factory.eventType>, 'id'>[]>await repos.event.projectEventFields(
81
+ // {
82
+ // id: { $eq: reservationForId },
83
+ // typeOfIn: [factory.eventType.Event, factory.eventType.ScreeningEvent] // 指定しないとArgumentNullError
84
+ // },
85
+ // ['typeOf']
86
+ // );
87
+ // if (existingEvents.length > 0) {
88
+ // await createAggregateScreeningEventIfNotExist({
89
+ // project: { id: params.project.id },
90
+ // reservationFor: [{ id: reservationForId }],
91
+ // force: false,
92
+ // identifier: `onReservationCheckedIn:${ticketToken}`
93
+ // })({ task: repos.task });
94
+ // }
95
+ // }));
96
+ // }
96
97
  });
97
98
  }
98
99
  exports.onReservationCheckedIn = onReservationCheckedIn;
@@ -14,7 +14,7 @@ exports.onReservationConfirmed = exports.onReservationConfirmedByAction = void 0
14
14
  * 予約確定時アクション
15
15
  */
16
16
  const factory = require("../../../factory");
17
- const onEventChanged_1 = require("../../offer/onEventChanged");
17
+ // import { createAggregateScreeningEventIfNotExist } from '../../offer/onEventChanged';
18
18
  const factory_1 = require("../factory");
19
19
  /**
20
20
  * 予約確定後のアクション
@@ -57,14 +57,12 @@ function onReservationConfirmed(confirmedReservations) {
57
57
  // ひとつめの予約からReservationPackageの共有属性を取り出す
58
58
  const { bookingTime, issuedThrough, project, provider, reservationFor, reservationNumber, underName } = confirmedReservations[0];
59
59
  // migrate to agg(2024-10-29~)
60
- if (!settings.useAggregationOnAggService) {
61
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
62
- project,
63
- reservationFor: [{ id: reservationFor.id }],
64
- force: false,
65
- identifier: `onReservationConfirmed:${reservationNumber}`
66
- })({ task: repos.task });
67
- }
60
+ // await createAggregateScreeningEventIfNotExist({
61
+ // project,
62
+ // reservationFor: [{ id: reservationFor.id }],
63
+ // force: false,
64
+ // identifier: `onReservationConfirmed:${reservationNumber}`
65
+ // })({ task: repos.task });
68
66
  const now = new Date();
69
67
  const taskAttributes = [];
70
68
  const subReservations4inform = confirmedReservations.map((r) => {
@@ -15,7 +15,7 @@ exports.onReservationUsed = void 0;
15
15
  */
16
16
  const moment = require("moment");
17
17
  const factory = require("../../../factory");
18
- const onEventChanged_1 = require("../../offer/onEventChanged");
18
+ // import { createAggregateScreeningEventIfNotExist } from '../../offer/onEventChanged';
19
19
  const factory_1 = require("../factory");
20
20
  /**
21
21
  * 予約使用
@@ -76,46 +76,45 @@ function onReservationUsed(attendedReservation) {
76
76
  // dependent on project settings(2024-10-29~)
77
77
  // if (settings.useAggregateEntranceGateProjects.includes(attendedReservation.project.id)) {
78
78
  if (useAggregateEntranceGate) {
79
- if (!settings.useAggregationOnAggService) {
80
- // 使用アクション集計タスクを作成する(冗長な作成を避ける)
81
- const readyAggregateUseActionsTaskDoc = yield repos.task.taskModel.findOne({
82
- 'project.id': { $eq: attendedReservation.project.id },
83
- name: { $eq: factory.taskName.AggregateUseActionsOnEvent },
84
- status: { $eq: factory.taskStatus.Ready },
85
- 'data.id': { $exists: true, $eq: attendedReservation.reservationFor.id }
86
- }, { _id: 1 })
87
- .exec();
88
- if (readyAggregateUseActionsTaskDoc === null) {
89
- const aggregateUseActionsTask = {
90
- project: attendedReservation.project,
91
- name: factory.taskName.AggregateUseActionsOnEvent,
92
- status: factory.taskStatus.Ready,
93
- runsAt: now,
94
- remainingNumberOfTries: 3,
95
- numberOfTried: 0,
96
- executionResults: [],
97
- data: {
98
- typeOf: attendedReservation.reservationFor.typeOf,
99
- id: attendedReservation.reservationFor.id
100
- }
101
- };
102
- tasks.push(aggregateUseActionsTask);
103
- }
104
- }
79
+ // 使用アクション集計タスクを作成する(冗長な作成を避ける)
80
+ // const readyAggregateUseActionsTaskDoc = await repos.task.taskModel.findOne(
81
+ // {
82
+ // 'project.id': { $eq: attendedReservation.project.id },
83
+ // name: { $eq: factory.taskName.AggregateUseActionsOnEvent },
84
+ // status: { $eq: factory.taskStatus.Ready },
85
+ // 'data.id': { $exists: true, $eq: attendedReservation.reservationFor.id }
86
+ // },
87
+ // { _id: 1 }
88
+ // )
89
+ // .exec();
90
+ // if (readyAggregateUseActionsTaskDoc === null) {
91
+ // const aggregateUseActionsTask: factory.task.aggregateUseActionsOnEvent.IAttributes = {
92
+ // project: attendedReservation.project,
93
+ // name: factory.taskName.AggregateUseActionsOnEvent,
94
+ // status: factory.taskStatus.Ready,
95
+ // runsAt: now,
96
+ // remainingNumberOfTries: 3,
97
+ // numberOfTried: 0,
98
+ // executionResults: [],
99
+ // data: {
100
+ // typeOf: attendedReservation.reservationFor.typeOf,
101
+ // id: attendedReservation.reservationFor.id
102
+ // }
103
+ // };
104
+ // tasks.push(aggregateUseActionsTask);
105
+ // }
105
106
  }
106
107
  if (tasks.length > 0) {
107
108
  yield repos.task.saveMany(tasks, { emitImmediately: true });
108
109
  }
109
110
  // migrate to agg(2024-10-29~)
110
- if (!settings.useAggregationOnAggService) {
111
- // 冗長な作成を避ける
112
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
113
- project: attendedReservation.project,
114
- reservationFor: [{ id: attendedReservation.reservationFor.id }],
115
- force: false,
116
- identifier: `onReservationUsed:${attendedReservation.id}`
117
- })({ task: repos.task });
118
- }
111
+ // 冗長な作成を避ける
112
+ // await createAggregateScreeningEventIfNotExist({
113
+ // project: attendedReservation.project,
114
+ // reservationFor: [{ id: attendedReservation.reservationFor.id }],
115
+ // force: false,
116
+ // identifier: `onReservationUsed:${attendedReservation.id}`
117
+ // })({ task: repos.task });
119
118
  });
120
119
  }
121
120
  exports.onReservationUsed = onReservationUsed;
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.onReservationsCreated = void 0;
13
13
  const factory = require("../../../factory");
14
- const onEventChanged_1 = require("../../offer/onEventChanged");
14
+ // import { createAggregateScreeningEventIfNotExist } from '../../offer/onEventChanged';
15
15
  const factory_1 = require("../factory");
16
16
  /**
17
17
  * 予約作成時イベント
@@ -19,15 +19,13 @@ const factory_1 = require("../factory");
19
19
  function onReservationsCreated(params) {
20
20
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
21
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
- }
22
+ // 集計タスク
23
+ // await createAggregateScreeningEventIfNotExist({
24
+ // project: { id: params.project.id },
25
+ // reservationFor: [{ id: params.event.id }],
26
+ // force: false,
27
+ // identifier: `onReservationsCreated:${params.transaction.transactionNumber}`
28
+ // })({ task: repos.task });
31
29
  // inform(2024-10-25~)
32
30
  const informReservations = settings.onReservationStatusChanged.informReservation;
33
31
  const now = new Date();
@@ -27,11 +27,13 @@ interface IWebhookSettings {
27
27
  */
28
28
  headerIdentifier?: string;
29
29
  }
30
+ interface IOnEventChanged {
31
+ informEvent?: factory.project.IInformParams[];
32
+ informEvent2agg?: factory.project.IInformParams[];
33
+ }
30
34
  interface IOptions {
31
35
  onOrderStatusChanged: IOnOrderStatusChanged;
32
- onEventChanged: {
33
- informEvent?: factory.project.IInformParams[];
34
- };
36
+ onEventChanged: IOnEventChanged;
35
37
  onReservationStatusChanged: IOnReservationStatusChanged;
36
38
  onResourceUpdated: {
37
39
  informResource?: factory.project.IInformParams[];
@@ -77,7 +79,6 @@ interface IOptions {
77
79
  */
78
80
  minIntervalBetweenPayAndRefund: number;
79
81
  };
80
- useAggregationOnAggService?: boolean;
81
82
  useAssetTransactionSyncProcessing: boolean;
82
83
  useExperimentalFeature: boolean;
83
84
  notification: IWebhookSettings;
@@ -87,9 +88,7 @@ interface IOptions {
87
88
  */
88
89
  declare class Settings {
89
90
  readonly onOrderStatusChanged: IOnOrderStatusChanged;
90
- readonly onEventChanged: {
91
- informEvent?: factory.project.IInformParams[];
92
- };
91
+ readonly onEventChanged: IOnEventChanged;
93
92
  readonly onReservationStatusChanged: IOnReservationStatusChanged;
94
93
  readonly onResourceUpdated: {
95
94
  informResource?: factory.project.IInformParams[];
@@ -138,7 +137,6 @@ declare class Settings {
138
137
  */
139
138
  minIntervalBetweenPayAndRefund: number;
140
139
  };
141
- readonly useAggregationOnAggService: boolean;
142
140
  readonly useAssetTransactionSyncProcessing: boolean;
143
141
  readonly useExperimentalFeature: boolean;
144
142
  /**
@@ -12,7 +12,7 @@ class Settings {
12
12
  // useAggregateEntranceGateProjects,
13
13
  // useAggregateOfferProjects,
14
14
  // useOfferRateLimitProjects,
15
- abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAggregationOnAggService, useAssetTransactionSyncProcessing, useExperimentalFeature, notification } = options;
15
+ abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAssetTransactionSyncProcessing, useExperimentalFeature, notification } = options;
16
16
  this.onEventChanged = onEventChanged;
17
17
  this.onOrderStatusChanged = onOrderStatusChanged;
18
18
  this.onResourceUpdated = onResourceUpdated;
@@ -30,7 +30,6 @@ class Settings {
30
30
  this.coa = coa;
31
31
  this.gmo = gmo;
32
32
  this.movieticketReserve = movieticketReserve;
33
- this.useAggregationOnAggService = useAggregationOnAggService === true;
34
33
  this.useAssetTransactionSyncProcessing = useAssetTransactionSyncProcessing;
35
34
  this.useExperimentalFeature = useExperimentalFeature;
36
35
  this.notification = notification;
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": "4.388.0-alpha.9",
15
- "@cinerino/sdk": "10.16.0-alpha.3",
14
+ "@chevre/factory": "4.388.0-alpha.10",
15
+ "@cinerino/sdk": "10.16.0-alpha.4",
16
16
  "@motionpicture/coa-service": "9.5.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
18
18
  "@sendgrid/mail": "6.4.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.50"
111
+ "version": "22.5.0-alpha.52"
112
112
  }