@chevre/domain 22.5.0-alpha.35 → 22.5.0-alpha.37

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.
@@ -1,4 +1,5 @@
1
1
  import * as factory from '../../../factory';
2
+ import { Settings } from '../../../settings';
2
3
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
3
4
  import type { EventRepo } from '../../../repo/event';
4
5
  import type { EventSeriesRepo } from '../../../repo/eventSeries';
@@ -31,7 +32,7 @@ interface IStartOperationRepos {
31
32
  task: TaskRepo;
32
33
  assetTransaction: AssetTransactionRepo;
33
34
  }
34
- type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
35
+ type IStartOperation<T> = (repos: IStartOperationRepos, settings: Settings) => Promise<T>;
35
36
  type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
36
37
  type IStartParams = factory.assetTransaction.reserve.IStartParamsWithoutDetail & {
37
38
  /**
@@ -16,8 +16,8 @@ const factory = require("../../../factory");
16
16
  const pecorinoapi = require("../../../pecorinoapi");
17
17
  const OfferService = require("../../offer");
18
18
  const searchOffersByIds_1 = require("../../offer/event/searchOffersByIds");
19
- const onEventChanged_1 = require("../../offer/onEventChanged");
20
19
  const cancelReservation_1 = require("../../reserve/cancelReservation");
20
+ const onReservationsCreated_1 = require("../../reserve/potentialActions/onReservationsCreated");
21
21
  const createSubReservations_1 = require("./start/createSubReservations");
22
22
  const createPointAward_1 = require("./start/factory/createPointAward");
23
23
  const createStartParams_1 = require("./start/factory/createStartParams");
@@ -28,7 +28,7 @@ const ONE_MONTH_IN_DAYS = 31;
28
28
  * 取引開始
29
29
  */
30
30
  function start(params, options) {
31
- return (repos) => __awaiter(this, void 0, void 0, function* () {
31
+ return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
32
32
  var _a, _b;
33
33
  const now = new Date();
34
34
  const reservationNumber = params.transactionNumber;
@@ -70,7 +70,7 @@ function start(params, options) {
70
70
  stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd,
71
71
  // acceptedOffers4transactionObject,
72
72
  objectSubReservations
73
- })(repos);
73
+ })(repos, settings);
74
74
  return {
75
75
  transaction: { id },
76
76
  objectSubReservations,
@@ -154,7 +154,7 @@ function createObjectAttributes(params, options) {
154
154
  * 予約追加
155
155
  */
156
156
  function addReservations(params) {
157
- return (repos) => __awaiter(this, void 0, void 0, function* () {
157
+ return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
158
158
  const reservationNumber = params.transaction.transactionNumber;
159
159
  const { event, reservationFor, objectSubReservations } = params;
160
160
  let lockedOfferRateLimitKeys = [];
@@ -164,20 +164,6 @@ function addReservations(params) {
164
164
  reservationFor,
165
165
  reservationNumber
166
166
  })(repos);
167
- // start時保管へ移行(2024-07-06~)
168
- // // 上書きの必要なし(2024-07-01~)
169
- // // transaction = await repos.assetTransaction.addReservations({
170
- // await repos.assetTransaction.addReservations({
171
- // typeOf: factory.assetTransactionType.Reserve,
172
- // id: params.transaction.id,
173
- // object: {
174
- // acceptedOffer: acceptedOffers4transactionObject,
175
- // // issuedThroughを追加(2023-06-05~)
176
- // // issuedThrough, // start時保管へ移行(2024-07-01~)
177
- // // reservationFor, // start時保管へ移行(2024-07-01~)
178
- // subReservation: objectSubReservations
179
- // }
180
- // });
181
167
  }
182
168
  catch (error) {
183
169
  if (lockedOfferRateLimitKeys.length > 0) {
@@ -205,7 +191,13 @@ function addReservations(params) {
205
191
  stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd
206
192
  })(repos);
207
193
  // ストックホルダー処理(stockHolderで残席数を集計しているので必要)
208
- yield onReservationsCreated({ event, transaction: { transactionNumber: reservationNumber } })(repos);
194
+ yield (0, onReservationsCreated_1.onReservationsCreated)({
195
+ project: { id: event.project.id },
196
+ event: { id: event.id },
197
+ transaction: {
198
+ transactionNumber: reservationNumber
199
+ }
200
+ })(repos, settings);
209
201
  });
210
202
  }
211
203
  /**
@@ -540,11 +532,6 @@ function processLockSeats(params) {
540
532
  // .add(1, 'month')
541
533
  .add(params.stockHoldUntilDaysAfterEventEnd, 'days')
542
534
  .toDate();
543
- // holder:取引番号に対応(2023-06-05~)
544
- // let holder: string = params.transaction.id;
545
- // if (params.transaction.object?.useHoldStockByTransactionNumber === true) {
546
- // holder = params.transaction.transactionNumber;
547
- // }
548
535
  const holder = params.transaction.transactionNumber; // fix as transactionNumber(2024-07-02~)
549
536
  const hasTicketedSeat = ((_c = (_b = (_a = params.event.offers.itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) === null || _c === void 0 ? void 0 : _c.typeOf) === factory.placeType.Seat;
550
537
  const maximumAttendeeCapacity4event = (_d = params.event.location) === null || _d === void 0 ? void 0 : _d.maximumAttendeeCapacity;
@@ -574,17 +561,3 @@ function processLockSeats(params) {
574
561
  }
575
562
  });
576
563
  }
577
- /**
578
- * 予約作成時イベント
579
- */
580
- function onReservationsCreated(params) {
581
- return (repos) => __awaiter(this, void 0, void 0, function* () {
582
- // 集計タスク
583
- yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
584
- project: params.event.project,
585
- reservationFor: [{ id: params.event.id }],
586
- force: false,
587
- identifier: `onReservationsCreated:${params.transaction.transactionNumber}`
588
- })({ task: repos.task });
589
- });
590
- }
@@ -1,4 +1,5 @@
1
1
  import * as factory from '../../../../factory';
2
+ import { Settings } from '../../../../settings';
2
3
  import type { JWTCredentials } from '../../../../credentials/jwt';
3
4
  import type { ActionRepo } from '../../../../repo/action';
4
5
  import type { AssetTransactionRepo } from '../../../../repo/assetTransaction';
@@ -57,7 +58,7 @@ declare function processStartReserve4chevre(params: {
57
58
  task: TaskRepo;
58
59
  ticket: TicketRepo;
59
60
  assetTransaction: AssetTransactionRepo;
60
- }, credentials: {
61
+ }, settings: Settings, credentials: {
61
62
  jwt: JWTCredentials;
62
63
  }) => Promise<{
63
64
  acceptedOffers4result: IResultAcceptedOffer[];
@@ -15,7 +15,7 @@ const ReserveTransactionService = require("../../../assetTransaction/reserve");
15
15
  const factory_1 = require("./factory");
16
16
  const requestedProgramMembershipUsed2permit_1 = require("./processStartReserve4chevre/requestedProgramMembershipUsed2permit");
17
17
  function processStartReserve4chevre(params, options) {
18
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
18
+ return (repos, settings, credentials) => __awaiter(this, void 0, void 0, function* () {
19
19
  const { event, transaction, transactionNumber } = params;
20
20
  let acceptedOffers4result = [];
21
21
  // 予約取引開始
@@ -29,7 +29,7 @@ function processStartReserve4chevre(params, options) {
29
29
  // preSearchedEvent: event,
30
30
  preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateEvent: params.validateEvent, validateEventOfferPeriod: params.validateEventOfferPeriod, validateAppliesToMovieTicket: true,
31
31
  // useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber, // discontinue(2024-07-02~)
32
- stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd }), options)(repos);
32
+ stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd }), options)(repos, settings);
33
33
  // 予約取引結果から注文オファーを生成する
34
34
  acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
35
35
  issuedThrough: startReserveTransactionResult.issuedThrough,
@@ -1,4 +1,5 @@
1
1
  import * as factory from '../../../factory';
2
+ import { Settings } from '../../../settings';
2
3
  import type { JWTCredentials } from '../../../credentials/jwt';
3
4
  import type { ActionRepo } from '../../../repo/action';
4
5
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
@@ -46,7 +47,7 @@ interface IAuthorizeRepos {
46
47
  transaction: TransactionRepo;
47
48
  transactionNumber: TransactionNumberRepo;
48
49
  }
49
- type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, credentials: {
50
+ type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, settings: Settings, credentials: {
50
51
  jwt: JWTCredentials;
51
52
  }) => Promise<T>;
52
53
  type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
@@ -20,7 +20,7 @@ const searchOffersByIds_1 = require("./searchOffersByIds");
20
20
  * 興行オファー承認
21
21
  */
22
22
  function authorize(params, options) {
23
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
23
+ return (repos, settings, credentials) => __awaiter(this, void 0, void 0, function* () {
24
24
  var _a;
25
25
  const { noOfferSpecified, stockHoldUntilDaysAfterEventEnd } = options;
26
26
  const { transaction, event } = yield validateCreateRequest(params)(repos);
@@ -44,7 +44,7 @@ function authorize(params, options) {
44
44
  const processStartReserveResult = yield (0, processStartReserve4chevre_1.processStartReserve4chevre)(Object.assign({ acceptedOffers, event,
45
45
  transactionNumber, transaction, availableAtOrFrom: { id: params.store.id }, ticketOffers, unitPriceOffers, validateEvent: params.validateEvent === true, validateEventOfferPeriod: params.validateEventOfferPeriod === true,
46
46
  // useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber, // discontinue(2024-07-02~)
47
- stockHoldUntilDaysAfterEventEnd }, (typeof ((_a = params.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.object.broker } : undefined), options)(repos, credentials);
47
+ stockHoldUntilDaysAfterEventEnd }, (typeof ((_a = params.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.object.broker } : undefined), options)(repos, settings, credentials);
48
48
  acceptedOffers4result = processStartReserveResult.acceptedOffers4result;
49
49
  // add orderInTransaction(2024-01-15~)
50
50
  if (!noOfferSpecified) {
@@ -21,6 +21,9 @@ declare function createAggregateScreeningEventIfNotExist(params: {
21
21
  id: string;
22
22
  }[];
23
23
  force: boolean;
24
+ /**
25
+ * タスク識別子の中間に使用される識別子
26
+ */
24
27
  identifier: string;
25
28
  }): (repos: {
26
29
  task: TaskRepo;
@@ -21,9 +21,7 @@ function onEventChanged(params) {
21
21
  if (params.typeOf === factory.eventType.ScreeningEvent) {
22
22
  yield createAggregateScreeningEventIfNotExist({
23
23
  project: { id: params.project.id },
24
- reservationFor: params.id.map((id) => {
25
- return { id };
26
- }),
24
+ reservationFor: params.id.map((id) => ({ id })),
27
25
  // 新規作成の場合は強制的に集計
28
26
  force: params.isNew,
29
27
  identifier: `onEventChanged`
@@ -7,7 +7,7 @@ import { ReservationRepo } from '../../repo/reservation';
7
7
  import { StockHolderRepo } from '../../repo/stockHolder';
8
8
  import type { TaskRepo } from '../../repo/task';
9
9
  /**
10
- * 進行中の予約をキャンセルする
10
+ * 保留予約取消
11
11
  */
12
12
  declare function cancelPendingReservation(actionAttributes: factory.task.cancelPendingReservation.IData): (repos: {
13
13
  action: ActionRepo;
@@ -16,18 +16,24 @@ exports.processUnlockOfferRateLimit = exports.cancelReservation = exports.cancel
16
16
  const moment = require("moment");
17
17
  const factory = require("../../factory");
18
18
  const factory_1 = require("./factory");
19
+ const onPendingReservationCanceled_1 = require("./potentialActions/onPendingReservationCanceled");
19
20
  const onReservationCanceled_1 = require("./potentialActions/onReservationCanceled");
20
21
  /**
21
- * 進行中の予約をキャンセルする
22
+ * 保留予約取消
22
23
  */
23
24
  function cancelPendingReservation(actionAttributes) {
24
25
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
25
26
  var _a;
26
27
  const { reserveTransaction } = yield cancelPengindIfNotYet(actionAttributes)(repos);
27
- yield (0, onReservationCanceled_1.onReservationCanceled)([], // PendingReservationはドキュメントとして存在しないので空でok
28
- false, {
28
+ yield (0, onPendingReservationCanceled_1.onPendingReservationCanceled)(
29
+ // [], // PendingReservationはドキュメントとして存在しないので空でok
30
+ // false,
31
+ {
29
32
  project: { id: reserveTransaction.project.id },
30
- id: String((_a = reserveTransaction.object.reservationFor) === null || _a === void 0 ? void 0 : _a.id)
33
+ reservationFor: {
34
+ id: String((_a = reserveTransaction.object.reservationFor) === null || _a === void 0 ? void 0 : _a.id)
35
+ },
36
+ reservationNumber: reserveTransaction.object.reservationNumber
31
37
  })({ task: repos.task }, settings);
32
38
  });
33
39
  }
@@ -306,7 +312,9 @@ function cancelReservation(actionAttributesList) {
306
312
  });
307
313
  canceledReservations = [canceledReservation];
308
314
  }
309
- yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, true, {
315
+ yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations,
316
+ // true,
317
+ {
310
318
  project: { id: actionAttributes.project.id },
311
319
  id: canceledReservationForId
312
320
  })({ task: repos.task }, settings);
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 保留予約取消時アクション
3
+ */
4
+ import type { TaskRepo } from '../../../repo/task';
5
+ import { Settings } from '../../../settings';
6
+ export declare function onPendingReservationCanceled(params: {
7
+ project: {
8
+ id: string;
9
+ };
10
+ /**
11
+ * 集計対象イベント
12
+ */
13
+ reservationFor: {
14
+ id: string;
15
+ };
16
+ reservationNumber: string;
17
+ }): (repos: {
18
+ task: TaskRepo;
19
+ }, settings: Settings) => Promise<void>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.onPendingReservationCanceled = void 0;
13
+ const factory = require("../../../factory");
14
+ const onEventChanged_1 = require("../../offer/onEventChanged");
15
+ const factory_1 = require("../factory");
16
+ function onPendingReservationCanceled(params) {
17
+ return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
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 });
27
+ }
28
+ // inform(2024-10-25~)
29
+ if (settings.useExperimentalFeature) {
30
+ const informReservations = settings.onReservationStatusChanged.informReservation;
31
+ const now = new Date();
32
+ const taskAttributes = [];
33
+ const informObject = [{
34
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
35
+ reservationNumber,
36
+ reservationStatus: factory.reservationStatusType.ReservationCancelled,
37
+ typeOf: factory.reservationType.ReservationPackage
38
+ }];
39
+ const informIdentifier = `${factory.reservationType.ReservationPackage}:${informObject[0].reservationNumber}:${informObject[0].reservationStatus}`;
40
+ // inform galobally
41
+ if (Array.isArray(informReservations)) {
42
+ taskAttributes.push(...informReservations.map((informReservation) => {
43
+ var _a;
44
+ const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
45
+ const informReservationAttributes = {
46
+ object: informObject,
47
+ recipient: {
48
+ id: '',
49
+ name: informUrl,
50
+ typeOf: factory.creativeWorkType.WebApplication,
51
+ url: informUrl
52
+ },
53
+ identifier: informIdentifier
54
+ };
55
+ return {
56
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
57
+ name: factory.taskName.TriggerWebhook,
58
+ status: factory.taskStatus.Ready,
59
+ runsAt: now,
60
+ remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
61
+ numberOfTried: 0,
62
+ executionResults: [],
63
+ data: informReservationAttributes
64
+ };
65
+ }));
66
+ }
67
+ // タスク保管
68
+ if (taskAttributes.length > 0) {
69
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
70
+ }
71
+ }
72
+ });
73
+ }
74
+ exports.onPendingReservationCanceled = onPendingReservationCanceled;
@@ -11,10 +11,6 @@ export declare function onReservationCanceled(
11
11
  * ステータス変更された予約リスト
12
12
  */
13
13
  canceledReservations: ICanceledEventReservation[] | ICanceledBusReservation[],
14
- /**
15
- * 予約通知有無
16
- */
17
- useInformReservation: boolean,
18
14
  /**
19
15
  * 集計対象イベント
20
16
  */
@@ -22,10 +22,7 @@ function onReservationCanceled(
22
22
  * ステータス変更された予約リスト
23
23
  */
24
24
  canceledReservations,
25
- /**
26
- * 予約通知有無
27
- */
28
- useInformReservation,
25
+ // useInformReservation: boolean,
29
26
  /**
30
27
  * 集計対象イベント
31
28
  */
@@ -39,67 +36,65 @@ reservationFor) {
39
36
  const project = canceledReservations[0].project;
40
37
  const taskAttributes = [];
41
38
  // inform galobally
42
- if (useInformReservation) {
43
- const informTaskRunsAt = now;
44
- const reservations4inform = canceledReservations.map((r) => {
39
+ const informTaskRunsAt = now;
40
+ const reservations4inform = canceledReservations.map((r) => {
41
+ return {
42
+ typeOf: r.typeOf,
43
+ project: r.project,
44
+ id: r.id,
45
+ reservationStatus: factory.reservationStatusType.ReservationCancelled,
46
+ modifiedTime: r.modifiedTime
47
+ };
48
+ });
49
+ if (Array.isArray(informReservations)) {
50
+ taskAttributes.push(...informReservations.map((informReservation) => {
51
+ var _a;
52
+ const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
53
+ const informReservationAttributes = {
54
+ object: reservations4inform,
55
+ recipient: {
56
+ id: '',
57
+ name: informUrl,
58
+ typeOf: factory.creativeWorkType.WebApplication,
59
+ url: informUrl
60
+ }
61
+ };
62
+ return {
63
+ project,
64
+ name: factory.taskName.TriggerWebhook,
65
+ status: factory.taskStatus.Ready,
66
+ runsAt: informTaskRunsAt,
67
+ remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
68
+ numberOfTried: 0,
69
+ executionResults: [],
70
+ data: informReservationAttributes
71
+ };
72
+ }));
73
+ }
74
+ if (Array.isArray(informReservation2hub)) {
75
+ taskAttributes.push(...informReservation2hub.map((informReservation) => {
76
+ var _a;
77
+ const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
78
+ const informReservationAttributes = {
79
+ object: reservations4inform,
80
+ recipient: {
81
+ id: '',
82
+ name: informUrl,
83
+ typeOf: factory.creativeWorkType.WebApplication,
84
+ url: informUrl
85
+ }
86
+ };
45
87
  return {
46
- typeOf: r.typeOf,
47
- project: r.project,
48
- id: r.id,
49
- reservationStatus: factory.reservationStatusType.ReservationCancelled,
50
- modifiedTime: r.modifiedTime
88
+ project,
89
+ name: factory.taskName.TriggerWebhook,
90
+ status: factory.taskStatus.Ready,
91
+ runsAt: informTaskRunsAt,
92
+ remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
93
+ numberOfTried: 0,
94
+ executionResults: [],
95
+ data: informReservationAttributes
51
96
  };
52
- });
53
- if (Array.isArray(informReservations)) {
54
- taskAttributes.push(...informReservations.map((informReservation) => {
55
- var _a;
56
- const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
57
- const informReservationAttributes = {
58
- object: reservations4inform,
59
- recipient: {
60
- id: '',
61
- name: informUrl,
62
- typeOf: factory.creativeWorkType.WebApplication,
63
- url: informUrl
64
- }
65
- };
66
- return {
67
- project,
68
- name: factory.taskName.TriggerWebhook,
69
- status: factory.taskStatus.Ready,
70
- runsAt: informTaskRunsAt,
71
- remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
72
- numberOfTried: 0,
73
- executionResults: [],
74
- data: informReservationAttributes
75
- };
76
- }));
77
- }
78
- if (Array.isArray(informReservation2hub)) {
79
- taskAttributes.push(...informReservation2hub.map((informReservation) => {
80
- var _a;
81
- const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
82
- const informReservationAttributes = {
83
- object: reservations4inform,
84
- recipient: {
85
- id: '',
86
- name: informUrl,
87
- typeOf: factory.creativeWorkType.WebApplication,
88
- url: informUrl
89
- }
90
- };
91
- return {
92
- project,
93
- name: factory.taskName.TriggerWebhook,
94
- status: factory.taskStatus.Ready,
95
- runsAt: informTaskRunsAt,
96
- remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
97
- numberOfTried: 0,
98
- executionResults: [],
99
- data: informReservationAttributes
100
- };
101
- }));
102
- }
97
+ }));
103
98
  }
104
99
  // タスク保管
105
100
  if (taskAttributes.length > 0) {
@@ -1,6 +1,3 @@
1
- /**
2
- * 予約使用時アクション
3
- */
4
1
  import * as factory from '../../../factory';
5
2
  import type { IAttendedReservation } from '../../../repo/reservation';
6
3
  import type { TaskRepo } from '../../../repo/task';
@@ -13,6 +13,7 @@ exports.onReservationUsed = void 0;
13
13
  /**
14
14
  * 予約使用時アクション
15
15
  */
16
+ const moment = require("moment");
16
17
  const factory = require("../../../factory");
17
18
  const onEventChanged_1 = require("../../offer/onEventChanged");
18
19
  const factory_1 = require("../factory");
@@ -35,7 +36,9 @@ function onReservationUsed(attendedReservation) {
35
36
  modifiedTime: attendedReservation.modifiedTime,
36
37
  reservedTicket: { dateUsed: attendedReservation.reservedTicket.dateUsed }
37
38
  };
38
- const informIdentifier = `${attendedReservation.typeOf}:${reservation4inform.id}:attended:${attendedReservation.modifiedTime}`;
39
+ const modifiedTimeInMilliseconds = moment(attendedReservation.modifiedTime)
40
+ .valueOf();
41
+ const informIdentifier = `${attendedReservation.typeOf}:${reservation4inform.id}:attended:${modifiedTimeInMilliseconds}`;
39
42
  // inform galobally
40
43
  if (Array.isArray(informReservations)) {
41
44
  tasks.push(...informReservations.map((informReservation) => {
@@ -0,0 +1,18 @@
1
+ import type { TaskRepo } from '../../../repo/task';
2
+ import { Settings } from '../../../settings';
3
+ /**
4
+ * 予約作成時イベント
5
+ */
6
+ export declare function onReservationsCreated(params: {
7
+ event: {
8
+ id: string;
9
+ };
10
+ project: {
11
+ id: string;
12
+ };
13
+ transaction: {
14
+ transactionNumber: string;
15
+ };
16
+ }): (repos: {
17
+ task: TaskRepo;
18
+ }, settings: Settings) => Promise<void>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.onReservationsCreated = void 0;
13
+ const factory = require("../../../factory");
14
+ const onEventChanged_1 = require("../../offer/onEventChanged");
15
+ const factory_1 = require("../factory");
16
+ /**
17
+ * 予約作成時イベント
18
+ */
19
+ function onReservationsCreated(params) {
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 });
28
+ // inform(2024-10-25~)
29
+ if (settings.useExperimentalFeature) {
30
+ const informReservations = settings.onReservationStatusChanged.informReservation;
31
+ const now = new Date();
32
+ const taskAttributes = [];
33
+ const informObject = [{
34
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
35
+ reservationNumber: params.transaction.transactionNumber,
36
+ reservationStatus: factory.reservationStatusType.ReservationPending,
37
+ typeOf: factory.reservationType.ReservationPackage
38
+ }];
39
+ const informIdentifier = `${factory.reservationType.ReservationPackage}:${informObject[0].reservationNumber}:${informObject[0].reservationStatus}`;
40
+ // inform galobally
41
+ if (Array.isArray(informReservations)) {
42
+ taskAttributes.push(...informReservations.map((informReservation) => {
43
+ var _a;
44
+ const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
45
+ const informReservationAttributes = {
46
+ object: informObject,
47
+ recipient: {
48
+ id: '',
49
+ name: informUrl,
50
+ typeOf: factory.creativeWorkType.WebApplication,
51
+ url: informUrl
52
+ },
53
+ identifier: informIdentifier
54
+ };
55
+ return {
56
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
57
+ name: factory.taskName.TriggerWebhook,
58
+ status: factory.taskStatus.Ready,
59
+ runsAt: now,
60
+ remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
61
+ numberOfTried: 0,
62
+ executionResults: [],
63
+ data: informReservationAttributes
64
+ };
65
+ }));
66
+ }
67
+ // タスク保管
68
+ if (taskAttributes.length > 0) {
69
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
70
+ }
71
+ }
72
+ });
73
+ }
74
+ exports.onReservationsCreated = onReservationsCreated;
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.2",
14
+ "@chevre/factory": "4.388.0-alpha.3",
15
15
  "@cinerino/sdk": "10.15.0",
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.35"
111
+ "version": "22.5.0-alpha.37"
112
112
  }