@chevre/domain 20.1.0-alpha.35 → 20.1.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.
@@ -131,10 +131,10 @@ function createReservedTicket(params) {
131
131
  }
132
132
  const ticketType = createTicketType({ availableOffer: params.availableOffer });
133
133
  const issuedBy = createIssuedBy({ acceptedOffer: params.acceptedOffer, availableOffer: params.availableOffer });
134
- return Object.assign({ dateIssued: params.dateIssued, issuedBy, priceCurrency: factory.priceCurrency.JPY, ticketType, typeOf: 'Ticket', underName: {
135
- typeOf: params.transaction.agent.typeOf,
136
- name: params.transaction.agent.name
137
- } }, (ticketedSeat !== undefined)
134
+ return Object.assign({ dateIssued: params.dateIssued, issuedBy,
135
+ // 不要なので廃止(2022-12-19~)
136
+ // priceCurrency: factory.priceCurrency.JPY,
137
+ ticketType, typeOf: 'Ticket' }, (ticketedSeat !== undefined)
138
138
  ? { ticketedSeat: ticketedSeat }
139
139
  : {});
140
140
  }
@@ -344,7 +344,10 @@ function createAdditionalTicketText(params) {
344
344
  }
345
345
  exports.createAdditionalTicketText = createAdditionalTicketText;
346
346
  function createReservationFor(params) {
347
- return Object.assign({ endDate: params.endDate, eventStatus: params.eventStatus, id: params.id, location: params.location, name: params.name,
347
+ return Object.assign({ endDate: params.endDate,
348
+ // 不要なので廃止(2022-12-19~)
349
+ // eventStatus: params.eventStatus,
350
+ id: params.id, location: params.location, name: params.name,
348
351
  // 不要なので廃止(2022-12-19~)
349
352
  // project: params.project,
350
353
  startDate: params.startDate,
@@ -400,9 +403,24 @@ function createReservation(params) {
400
403
  }
401
404
  : undefined;
402
405
  const issuedThrough = Object.assign(Object.assign({ typeOf: factory.product.ProductType.EventService }, (typeof (serviceTypeOfIssuedThrough === null || serviceTypeOfIssuedThrough === void 0 ? void 0 : serviceTypeOfIssuedThrough.typeOf) === 'string') ? { serviceType: serviceTypeOfIssuedThrough } : undefined), (typeof eventOffers.itemOffered.id === 'string') ? { id: eventOffers.itemOffered.id } : undefined);
403
- return Object.assign(Object.assign(Object.assign(Object.assign({ project: params.project, typeOf: factory.reservationType.EventReservation, id: params.id, issuedThrough, additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY,
404
- // reservationFor,
405
- reservationNumber: params.reservationNumber, reservationStatus: factory.reservationStatusType.ReservationPending, reservedTicket: params.reservedTicket, underName: params.agent, checkedIn: false, attended: false }, (typeof params.additionalTicketText === 'string') ? { additionalTicketText: params.additionalTicketText } : undefined), (Array.isArray(params.subReservation)) ? { subReservation: params.subReservation } : undefined), (typeof ((_b = params.broker) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { broker: params.broker } : undefined), (typeof ((_c = params.programMembershipUsed) === null || _c === void 0 ? void 0 : _c.identifier) === 'string')
406
+ return Object.assign(Object.assign(Object.assign(Object.assign({ project: params.project, typeOf: factory.reservationType.EventReservation, id: params.id, issuedThrough, additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY, reservationNumber: params.reservationNumber, reservationStatus: factory.reservationStatusType.ReservationPending, reservedTicket: params.reservedTicket,
407
+ // 最適化(2022-12-19~)
408
+ // underName: params.agent,
409
+ underName: {
410
+ typeOf: params.agent.typeOf,
411
+ name: params.agent.name
412
+ }, checkedIn: false, attended: false }, (typeof params.additionalTicketText === 'string') ? { additionalTicketText: params.additionalTicketText } : undefined), (Array.isArray(params.subReservation))
413
+ ? {
414
+ subReservation: params.subReservation.map((r) => {
415
+ return {
416
+ reservedTicket: {
417
+ ticketedSeat: r.reservedTicket.ticketedSeat,
418
+ typeOf: 'Ticket'
419
+ }
420
+ };
421
+ })
422
+ }
423
+ : undefined), (typeof ((_b = params.broker) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { broker: params.broker } : undefined), (typeof ((_c = params.programMembershipUsed) === null || _c === void 0 ? void 0 : _c.identifier) === 'string')
406
424
  ? { programMembershipUsed: params.programMembershipUsed }
407
425
  : undefined);
408
426
  }
@@ -438,7 +456,8 @@ function createPotentialActions(params) {
438
456
  if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
439
457
  const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
440
458
  eventReservation.underName = ordre2reservationUnderNameResult.underName;
441
- eventReservation.reservedTicket.underName = ordre2reservationUnderNameResult.underName;
459
+ // 不要なので廃止(2022-12-19~)
460
+ // eventReservation.reservedTicket.underName = ordre2reservationUnderNameResult.underName;
442
461
  eventReservation.reservedTicket.issuedBy = ordre2reservationUnderNameResult.issuedBy;
443
462
  }
444
463
  const acceptedOffer4reservation = (_b = transaction.object.acceptedOffer) === null || _b === void 0 ? void 0 : _b.find((o) => { var _a, _b; return ((_b = (_a = o.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.id) === reservation.id; });
@@ -225,7 +225,8 @@ function createReservation(params) {
225
225
  typeOf: event.typeOf,
226
226
  // 予約のreservationForは最適化されているので、additionalPropertyは存在しない
227
227
  // additionalProperty: itemOffered.reservationFor.additionalProperty,
228
- eventStatus: event.eventStatus,
228
+ // 不要なので廃止(2022-12-19~)
229
+ // eventStatus: event.eventStatus,
229
230
  id: event.id,
230
231
  location: event.location,
231
232
  name: event.name,
@@ -114,7 +114,10 @@ function responseBody2acceptedOffers4result(params) {
114
114
  .toDate()
115
115
  }
116
116
  : undefined), { endDate: moment(event.endDate)
117
- .toDate(), eventStatus: event.eventStatus, identifier: event.identifier, location: {
117
+ .toDate(),
118
+ // 不要なので廃止(2022-12-19~)
119
+ // eventStatus: event.eventStatus,
120
+ identifier: event.identifier, location: {
118
121
  // 不要なので廃止(2022-12-19~)
119
122
  // project: event.location.project,
120
123
  typeOf: event.location.typeOf,
@@ -10,49 +10,70 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.confirmReservation = void 0;
13
+ /**
14
+ * 予約サービス
15
+ */
16
+ const factory = require("../../factory");
13
17
  const onReservationConfirmed_1 = require("./potentialActions/onReservationConfirmed");
14
18
  /**
15
19
  * 予約を確定する
16
20
  */
17
21
  function confirmReservation(actionAttributesList) {
18
22
  return (repos) => __awaiter(this, void 0, void 0, function* () {
19
- const confirmedReservations = [];
20
- yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
21
- let reservation = actionAttributes.object;
22
- const action = yield repos.action.start(actionAttributes);
23
- try {
24
- // 予約を確定状態に変更する
25
- reservation = yield repos.reservation.confirm({
26
- // 更新属性をwhitelist化(2022-06-13~)
27
- // ...actionAttributes.object,
28
- id: reservation.id,
29
- previousReservationStatus: reservation.reservationStatus,
30
- underName: reservation.underName,
31
- reservedTicket: reservation.reservedTicket
32
- });
33
- // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
34
- delete reservation._id;
35
- confirmedReservations.push(reservation);
36
- }
37
- catch (error) {
38
- // actionにエラー結果を追加
23
+ let confirmedReservations = [];
24
+ if (actionAttributesList.length > 0) {
25
+ yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
26
+ const reservation = actionAttributes.object;
27
+ const action = yield repos.action.start(actionAttributes);
39
28
  try {
40
- const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
41
- yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
29
+ // 予約を確定状態に変更する
30
+ // reservation = await repos.reservation.confirm<factory.reservationType.EventReservation>({
31
+ yield repos.reservation.confirm({
32
+ // 更新属性をwhitelist化(2022-06-13~)
33
+ // ...actionAttributes.object,
34
+ id: reservation.id,
35
+ previousReservationStatus: reservation.reservationStatus,
36
+ underName: reservation.underName,
37
+ reservedTicket: reservation.reservedTicket
38
+ });
39
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
40
+ // delete (<any>reservation)._id;
41
+ // confirmedReservations.push(reservation);
42
42
  }
43
- catch (__) {
44
- // 失敗したら仕方ない
43
+ catch (error) {
44
+ // actionにエラー結果を追加
45
+ try {
46
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
47
+ yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
48
+ }
49
+ catch (__) {
50
+ // 失敗したら仕方ない
51
+ }
52
+ throw error;
45
53
  }
46
- throw error;
54
+ // アクション完了
55
+ const actionResult = {
56
+ confirmedReservationId: reservation.id
57
+ };
58
+ yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
59
+ yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes)({ task: repos.task });
60
+ })));
61
+ // 確定予約通知タスクを予約番号単位で作成する(2022-12-21~)
62
+ const reservationNumber = actionAttributesList[0].object.reservationNumber;
63
+ if (typeof reservationNumber === 'string' && reservationNumber.length > 0) {
64
+ // 最新のconfirmedReservationsを検索
65
+ confirmedReservations = yield repos.reservation.search({
66
+ reservationNumber: { $eq: reservationNumber },
67
+ typeOf: factory.reservationType.EventReservation
68
+ });
69
+ confirmedReservations = confirmedReservations.map((r) => {
70
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
71
+ delete r._id;
72
+ return r;
73
+ });
47
74
  }
48
- // アクション完了
49
- const actionResult = {
50
- confirmedReservationId: reservation.id
51
- };
52
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
53
- yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes, reservation)({ task: repos.task });
54
- })));
55
- yield (0, onReservationConfirmed_1.onReservationConfirmed)(confirmedReservations)({ task: repos.task });
75
+ yield (0, onReservationConfirmed_1.onReservationConfirmed)(confirmedReservations)({ task: repos.task });
76
+ }
56
77
  });
57
78
  }
58
79
  exports.confirmReservation = confirmReservation;
@@ -7,7 +7,7 @@ declare type IEventReservation = factory.reservation.IReservation<factory.reserv
7
7
  /**
8
8
  * 予約確定後のアクション
9
9
  */
10
- export declare function onReservationConfirmedByAction(actionAttributes: factory.action.reserve.IAttributes, confirmedReservation: IEventReservation): (repos: {
10
+ export declare function onReservationConfirmedByAction(actionAttributes: factory.action.reserve.IAttributes): (repos: {
11
11
  task: TaskRepo;
12
12
  }) => Promise<void>;
13
13
  export declare function onReservationConfirmed(confirmedReservations: IEventReservation[]): (repos: {
@@ -21,7 +21,9 @@ const informReservations = settings_1.settings.onReservationStatusChanged.inform
21
21
  /**
22
22
  * 予約確定後のアクション
23
23
  */
24
- function onReservationConfirmedByAction(actionAttributes, confirmedReservation) {
24
+ function onReservationConfirmedByAction(actionAttributes
25
+ // confirmedReservation: IEventReservation
26
+ ) {
25
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
26
28
  const potentialActions = actionAttributes.potentialActions;
27
29
  const now = new Date();
@@ -45,35 +47,34 @@ function onReservationConfirmedByAction(actionAttributes, confirmedReservation)
45
47
  }
46
48
  }
47
49
  // inform galobally
48
- if (Array.isArray(informReservations)) {
49
- const reservation4inform = (0, factory_1.maskUnderName)(confirmedReservation);
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
- agent: confirmedReservation.project,
55
- object: [reservation4inform],
56
- project: confirmedReservation.project,
57
- recipient: {
58
- id: '',
59
- name: informUrl,
60
- typeOf: factory.creativeWorkType.WebApplication,
61
- url: informUrl
62
- },
63
- typeOf: factory.actionType.InformAction
64
- };
65
- return {
66
- project: actionAttributes.project,
67
- name: factory.taskName.TriggerWebhook,
68
- status: factory.taskStatus.Ready,
69
- runsAt: now,
70
- remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
71
- numberOfTried: 0,
72
- executionResults: [],
73
- data: informReservationAttributes
74
- };
75
- }));
76
- }
50
+ // if (Array.isArray(informReservations)) {
51
+ // const reservation4inform: IReservation4informConfirmed = maskUnderName(confirmedReservation);
52
+ // taskAttributes.push(...informReservations.map<ITriggerWebhookTaskAttributes>((informReservation) => {
53
+ // const informUrl: string = String(informReservation.recipient?.url);
54
+ // const informReservationAttributes: InformReservationActionattributes = {
55
+ // agent: confirmedReservation.project,
56
+ // object: [reservation4inform],
57
+ // project: confirmedReservation.project,
58
+ // recipient: {
59
+ // id: '',
60
+ // name: informUrl,
61
+ // typeOf: factory.creativeWorkType.WebApplication,
62
+ // url: informUrl
63
+ // },
64
+ // typeOf: factory.actionType.InformAction
65
+ // };
66
+ // return {
67
+ // project: actionAttributes.project,
68
+ // name: factory.taskName.TriggerWebhook,
69
+ // status: factory.taskStatus.Ready,
70
+ // runsAt: now,
71
+ // remainingNumberOfTries: NUM_TRY_INFORM_RESERVATION,
72
+ // numberOfTried: 0,
73
+ // executionResults: [],
74
+ // data: informReservationAttributes
75
+ // };
76
+ // }));
77
+ // }
77
78
  // タスク保管
78
79
  if (taskAttributes.length > 0) {
79
80
  yield repos.task.saveMany(taskAttributes);
@@ -88,6 +89,42 @@ function onReservationConfirmed(confirmedReservations) {
88
89
  project: confirmedReservations[0].project,
89
90
  reservationFor: { id: confirmedReservations[0].reservationFor.id }
90
91
  })({ task: repos.task });
92
+ const now = new Date();
93
+ const taskAttributes = [];
94
+ // inform galobally
95
+ if (Array.isArray(informReservations)) {
96
+ taskAttributes.push(...informReservations.map((informReservation) => {
97
+ var _a;
98
+ const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
99
+ const informObject = confirmedReservations.map(factory_1.maskUnderName);
100
+ const informReservationAttributes = {
101
+ agent: confirmedReservations[0].project,
102
+ object: informObject,
103
+ project: confirmedReservations[0].project,
104
+ recipient: {
105
+ id: '',
106
+ name: informUrl,
107
+ typeOf: factory.creativeWorkType.WebApplication,
108
+ url: informUrl
109
+ },
110
+ typeOf: factory.actionType.InformAction
111
+ };
112
+ return {
113
+ project: confirmedReservations[0].project,
114
+ name: factory.taskName.TriggerWebhook,
115
+ status: factory.taskStatus.Ready,
116
+ runsAt: now,
117
+ remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
118
+ numberOfTried: 0,
119
+ executionResults: [],
120
+ data: informReservationAttributes
121
+ };
122
+ }));
123
+ }
124
+ // タスク保管
125
+ if (taskAttributes.length > 0) {
126
+ yield repos.task.saveMany(taskAttributes);
127
+ }
91
128
  }
92
129
  });
93
130
  }
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.280.0-alpha.7",
13
- "@cinerino/sdk": "3.135.0-alpha.3",
12
+ "@chevre/factory": "4.280.0-alpha.8",
13
+ "@cinerino/sdk": "3.135.0-alpha.4",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.1.0-alpha.35"
123
+ "version": "20.1.0-alpha.37"
124
124
  }