@chevre/domain 20.1.0-alpha.4 → 20.1.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 (107) hide show
  1. package/example/src/chevre/deleteEvents.ts +9 -1
  2. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +157 -0
  3. package/example/src/chevre/migrateCreativeWorkAdditionalProperties.ts +116 -0
  4. package/example/src/chevre/migrateEventOffersSellerMakesOffer.ts +139 -0
  5. package/example/src/chevre/migrateEventProjectAttributes.ts +57 -0
  6. package/example/src/chevre/migratePlaceAdditionalProperties.ts +162 -0
  7. package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +64 -0
  8. package/example/src/chevre/searchEvents.ts +36 -16
  9. package/lib/chevre/repo/accountAction.d.ts +0 -18
  10. package/lib/chevre/repo/accountAction.js +402 -355
  11. package/lib/chevre/repo/accountTitle.d.ts +1 -0
  12. package/lib/chevre/repo/accountTitle.js +6 -1
  13. package/lib/chevre/repo/additionalProperty.d.ts +35 -0
  14. package/lib/chevre/repo/additionalProperty.js +205 -0
  15. package/lib/chevre/repo/categoryCode.d.ts +1 -0
  16. package/lib/chevre/repo/categoryCode.js +15 -1
  17. package/lib/chevre/repo/creativeWork.js +10 -1
  18. package/lib/chevre/repo/customer.d.ts +1 -0
  19. package/lib/chevre/repo/customer.js +5 -0
  20. package/lib/chevre/repo/event.d.ts +12 -4
  21. package/lib/chevre/repo/event.js +84 -48
  22. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -0
  23. package/lib/chevre/repo/merchantReturnPolicy.js +5 -0
  24. package/lib/chevre/repo/mongoose/model/additionalProperty.d.ts +7 -0
  25. package/lib/chevre/repo/mongoose/model/additionalProperty.js +81 -0
  26. package/lib/chevre/repo/mongoose/model/categoryCode.js +18 -2
  27. package/lib/chevre/repo/mongoose/model/creativeWork.js +6 -0
  28. package/lib/chevre/repo/mongoose/model/event.js +53 -0
  29. package/lib/chevre/repo/mongoose/model/offer.js +7 -1
  30. package/lib/chevre/repo/mongoose/model/offerCatalog.js +21 -2
  31. package/lib/chevre/repo/mongoose/model/ownershipInfo.js +3 -15
  32. package/lib/chevre/repo/mongoose/model/place.js +42 -0
  33. package/lib/chevre/repo/offer.js +10 -1
  34. package/lib/chevre/repo/offerCatalog.js +10 -10
  35. package/lib/chevre/repo/place.d.ts +1 -0
  36. package/lib/chevre/repo/place.js +54 -7
  37. package/lib/chevre/repo/reservation.d.ts +16 -2
  38. package/lib/chevre/repo/reservation.js +29 -1
  39. package/lib/chevre/repo/transaction.js +20 -5
  40. package/lib/chevre/repository.d.ts +6 -3
  41. package/lib/chevre/repository.js +10 -5
  42. package/lib/chevre/service/account.d.ts +0 -4
  43. package/lib/chevre/service/account.js +24 -22
  44. package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -2
  45. package/lib/chevre/service/accountTransaction/deposit.js +3 -3
  46. package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -2
  47. package/lib/chevre/service/accountTransaction/transfer.js +3 -3
  48. package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -2
  49. package/lib/chevre/service/accountTransaction/withdraw.js +3 -3
  50. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +9 -19
  51. package/lib/chevre/service/assetTransaction/reserve/factory.js +119 -115
  52. package/lib/chevre/service/assetTransaction/reserve.js +99 -89
  53. package/lib/chevre/service/delivery/factory.js +2 -1
  54. package/lib/chevre/service/event.js +20 -6
  55. package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
  56. package/lib/chevre/service/offer/event/authorize.js +65 -27
  57. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  58. package/lib/chevre/service/offer/event/factory.js +17 -12
  59. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +19 -9
  60. package/lib/chevre/service/offer/factory.js +7 -20
  61. package/lib/chevre/service/offer.js +6 -6
  62. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +4 -2
  63. package/lib/chevre/service/order/onOrderStatusChanged.js +3 -2
  64. package/lib/chevre/service/order/placeOrder.js +13 -5
  65. package/lib/chevre/service/order/returnOrder.js +2 -1
  66. package/lib/chevre/service/order/sendOrder.js +2 -1
  67. package/lib/chevre/service/reserve/cancelReservation.js +135 -84
  68. package/lib/chevre/service/reserve/confirmReservation.js +65 -33
  69. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
  70. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +67 -30
  71. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
  72. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -8
  73. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +6 -3
  74. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +9 -4
  75. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +2 -1
  76. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +2 -1
  77. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +2 -1
  78. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +4 -3
  79. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -1
  80. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +10 -6
  81. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -4
  82. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +3 -1
  83. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +3 -2
  84. package/lib/chevre/service/transaction/placeOrderInProgress.js +16 -2
  85. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +4 -5
  86. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +6 -3
  87. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +4 -6
  88. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +2 -1
  89. package/lib/chevre/service/transaction/returnOrder.js +10 -1
  90. package/lib/chevre/service/transaction.js +1 -14
  91. package/package.json +4 -4
  92. package/example/src/chevre/accountBlanceTest.ts +0 -24
  93. package/example/src/chevre/checkOffersAppliesToMovieTicket.ts +0 -56
  94. package/example/src/chevre/createSeats.ts +0 -59
  95. package/example/src/chevre/manageOwnedByOfOwnershipInfo.ts +0 -35
  96. package/example/src/chevre/migrateEventOffersItemOfferedName.ts +0 -82
  97. package/example/src/chevre/migrateMovieTicketChargePriceSpecs.ts +0 -92
  98. package/example/src/chevre/migrateSellerMakesOffers.ts +0 -84
  99. package/example/src/chevre/migrateTTTSOldEventId.ts +0 -68
  100. package/example/src/chevre/publishConfirmationNumber.ts +0 -30
  101. package/example/src/chevre/publishServiceOutputIdentifier.ts +0 -28
  102. package/example/src/chevre/publishTransactionNumber.ts +0 -28
  103. package/example/src/chevre/renameTransaction.ts +0 -22
  104. package/lib/chevre/service/task/accountMoneyTransfer.d.ts +0 -3
  105. package/lib/chevre/service/task/accountMoneyTransfer.js +0 -31
  106. package/lib/chevre/service/task/cancelAccountMoneyTransfer.d.ts +0 -3
  107. package/lib/chevre/service/task/cancelAccountMoneyTransfer.js +0 -33
@@ -8,6 +8,7 @@ const moment = require("moment");
8
8
  const factory = require("../../../factory");
9
9
  const accountTransactionIdentifier_1 = require("../../../factory/accountTransactionIdentifier");
10
10
  const price_1 = require("./factory/price");
11
+ const USE_RESERVATION_PACKAGE_AS_OBJECT = process.env.USE_RESERVATION_PACKAGE_AS_OBJECT === '1';
11
12
  function createStartParams(params) {
12
13
  var _a;
13
14
  const reservationNumber = params.reservationNumber;
@@ -60,21 +61,6 @@ function createPointAward(params) {
60
61
  return pointAward;
61
62
  }
62
63
  exports.createPointAward = createPointAward;
63
- // function createPointAwardPurposeIdentifier(params: {
64
- // assetTransaction: { typeOf: factory.assetTransactionType };
65
- // project: { id: string };
66
- // reservation: { id: string };
67
- // toLocation: { identifier: string };
68
- // }): string {
69
- // return util.format(
70
- // '%s:%s:%s:%s:%s',
71
- // params.project.id,
72
- // 'givePointAward',
73
- // params.assetTransaction.typeOf,
74
- // params.reservation.id,
75
- // params.toLocation.identifier
76
- // );
77
- // }
78
64
  function createReservedTicket(params) {
79
65
  var _a, _b, _c;
80
66
  let acceptedTicketedSeat;
@@ -131,10 +117,10 @@ function createReservedTicket(params) {
131
117
  }
132
118
  const ticketType = createTicketType({ availableOffer: params.availableOffer });
133
119
  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)
120
+ return Object.assign({ dateIssued: params.dateIssued, issuedBy,
121
+ // 不要なので廃止(2022-12-19~)
122
+ // priceCurrency: factory.priceCurrency.JPY,
123
+ ticketType, typeOf: 'Ticket' }, (ticketedSeat !== undefined)
138
124
  ? { ticketedSeat: ticketedSeat }
139
125
  : {});
140
126
  }
@@ -145,10 +131,14 @@ exports.createReservedTicket = createReservedTicket;
145
131
  function createTicketType(params) {
146
132
  var _a;
147
133
  const availableOffer = params.availableOffer;
148
- return Object.assign(Object.assign(Object.assign(Object.assign({ description: availableOffer.description, id: availableOffer.id, identifier: availableOffer.identifier, name: availableOffer.name, priceCurrency: availableOffer.priceCurrency,
134
+ return Object.assign(Object.assign(Object.assign(Object.assign({ description: availableOffer.description, id: availableOffer.id, identifier: availableOffer.identifier, name: availableOffer.name,
135
+ // 不要なので廃止(2022-12-17~)
136
+ // priceCurrency: availableOffer.priceCurrency,
149
137
  // priceSpecificationを最適化(accounting不要)
150
138
  // accounting: { typeOf: "Accounting", … }
151
- project: availableOffer.project, typeOf: availableOffer.typeOf }, (Array.isArray(availableOffer.additionalProperty)) ? { additionalProperty: availableOffer.additionalProperty } : undefined), (typeof ((_a = availableOffer.category) === null || _a === void 0 ? void 0 : _a.codeValue) === 'string') ? { category: availableOffer.category } : undefined), (typeof availableOffer.color === 'string') ? { color: availableOffer.color } : undefined), (availableOffer.validRateLimit !== undefined) ? { validRateLimit: availableOffer.validRateLimit } : undefined);
139
+ // 不要なので廃止(2022-12-17~)
140
+ // project: availableOffer.project,
141
+ typeOf: availableOffer.typeOf }, (Array.isArray(availableOffer.additionalProperty)) ? { additionalProperty: availableOffer.additionalProperty } : undefined), (typeof ((_a = availableOffer.category) === null || _a === void 0 ? void 0 : _a.codeValue) === 'string') ? { category: availableOffer.category } : undefined), (typeof availableOffer.color === 'string') ? { color: availableOffer.color } : undefined), (availableOffer.validRateLimit !== undefined) ? { validRateLimit: availableOffer.validRateLimit } : undefined);
152
142
  }
153
143
  function createIssuedBy(params) {
154
144
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -340,9 +330,13 @@ function createAdditionalTicketText(params) {
340
330
  }
341
331
  exports.createAdditionalTicketText = createAdditionalTicketText;
342
332
  function createReservationFor(params) {
343
- return Object.assign({ endDate: params.endDate, eventStatus: params.eventStatus, id: params.id, location: params.location, name: params.name, project: params.project, startDate: params.startDate,
344
- // 最適化(2022-05-31~)
345
- superEvent: optimizeReservationSuperEvent(params), typeOf: params.typeOf }, (params.doorTime instanceof Date)
333
+ return Object.assign({ endDate: params.endDate,
334
+ // 不要なので廃止(2022-12-19~)
335
+ // eventStatus: params.eventStatus,
336
+ id: params.id, location: params.location, name: params.name,
337
+ // 不要なので廃止(2022-12-19~)
338
+ // project: params.project,
339
+ startDate: params.startDate, superEvent: optimizeReservationSuperEvent(params), typeOf: params.typeOf }, (params.doorTime instanceof Date)
346
340
  ? { doorTime: params.doorTime }
347
341
  : undefined);
348
342
  }
@@ -351,7 +345,10 @@ function optimizeReservationSuperEvent(params) {
351
345
  const superEvent = params.superEvent;
352
346
  return Object.assign(Object.assign({ additionalProperty: (Array.isArray(superEvent.additionalProperty))
353
347
  ? superEvent.additionalProperty
354
- : [], id: superEvent.id, kanaName: superEvent.kanaName, location: superEvent.location, name: superEvent.name, project: superEvent.project, soundFormat: superEvent.soundFormat, typeOf: superEvent.typeOf, videoFormat: superEvent.videoFormat, workPerformed: superEvent.workPerformed }, (superEvent.description !== undefined)
348
+ : [], id: superEvent.id, kanaName: superEvent.kanaName, location: superEvent.location, name: superEvent.name,
349
+ // 不要なので廃止(2022-12-19~)
350
+ // project: superEvent.project,
351
+ soundFormat: superEvent.soundFormat, typeOf: superEvent.typeOf, videoFormat: superEvent.videoFormat, workPerformed: superEvent.workPerformed }, (superEvent.description !== undefined)
355
352
  ? { description: superEvent.description }
356
353
  : undefined), (superEvent.headline !== undefined)
357
354
  ? { headline: superEvent.headline }
@@ -390,14 +387,31 @@ function createReservation(params) {
390
387
  }
391
388
  : undefined;
392
389
  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);
393
- 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,
394
- // reservationFor,
395
- 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')
390
+ 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,
391
+ // 最適化(2022-12-19~)
392
+ // underName: params.agent,
393
+ underName: {
394
+ typeOf: params.agent.typeOf,
395
+ name: params.agent.name
396
+ }, checkedIn: false, attended: false }, (typeof params.additionalTicketText === 'string') ? { additionalTicketText: params.additionalTicketText } : undefined), (Array.isArray(params.subReservation))
397
+ ? {
398
+ subReservation: params.subReservation.map((r) => {
399
+ return {
400
+ reservedTicket: {
401
+ ticketedSeat: r.reservedTicket.ticketedSeat,
402
+ typeOf: 'Ticket'
403
+ }
404
+ };
405
+ })
406
+ }
407
+ : 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')
396
408
  ? { programMembershipUsed: params.programMembershipUsed }
397
409
  : undefined);
398
410
  }
399
411
  exports.createReservation = createReservation;
412
+ // tslint:disable-next-line:max-func-body-length
400
413
  function createPotentialActions(params) {
414
+ var _a;
401
415
  const transaction = params.transaction;
402
416
  const reservationFor = transaction.object.reservationFor;
403
417
  if (reservationFor === undefined) {
@@ -405,113 +419,103 @@ function createPotentialActions(params) {
405
419
  }
406
420
  // 予約アクション属性作成
407
421
  const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
408
- const reserveActionAttributes = pendingReservations.map((reservation) => {
409
- var _a, _b;
410
- const eventReservation = Object.assign(Object.assign({}, reservation), { reservationFor });
411
- if (params.object !== undefined) {
412
- // 予約属性の指定があれば上書き
413
- const confirmingReservation = params.object.reservations.find((r) => r.id === eventReservation.id);
414
- if (confirmingReservation !== undefined) {
415
- // additionalTicketText指定を廃止(2022-05-23~)
416
- // if (typeof confirmingReservation.additionalTicketText === 'string') {
417
- // eventReservation.additionalTicketText = confirmingReservation.additionalTicketText;
418
- // }
419
- // additionalProperty指定を廃止(2022-05-23~)
420
- // 追加特性の指定があれば、元の追加特性にマージ
421
- // if (Array.isArray(confirmingReservation.additionalProperty)) {
422
- // eventReservation.additionalProperty = [
423
- // ...(Array.isArray(eventReservation.additionalProperty)) ? eventReservation.additionalProperty : [],
424
- // ...confirmingReservation.additionalProperty
425
- // ];
426
- // }
427
- if (confirmingReservation.underName !== undefined) {
428
- eventReservation.underName = confirmingReservation.underName;
429
- eventReservation.reservedTicket.underName = confirmingReservation.underName;
430
- }
431
- if (confirmingReservation.reservedTicket !== undefined) {
432
- // ticketToken指定を廃止(2022-05-23~)
433
- // if (typeof confirmingReservation.reservedTicket.ticketToken === 'string') {
434
- // eventReservation.reservedTicket.ticketToken = confirmingReservation.reservedTicket.ticketToken;
435
- // }
436
- if (confirmingReservation.reservedTicket.issuedBy !== undefined) {
437
- eventReservation.reservedTicket.issuedBy = confirmingReservation.reservedTicket.issuedBy;
438
- }
439
- // reservedTicket.underName指定を廃止(2022-05-23~)
440
- // if (confirmingReservation.reservedTicket.underName !== undefined) {
441
- // eventReservation.reservedTicket.underName = confirmingReservation.reservedTicket.underName;
442
- // }
443
- }
422
+ let reserveActionAttributes = [];
423
+ if (pendingReservations.length > 0) {
424
+ // ReservationPackageに対応(2022-12-22~)
425
+ if (USE_RESERVATION_PACKAGE_AS_OBJECT) {
426
+ let underName;
427
+ // purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
428
+ if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
429
+ const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
430
+ underName = ordre2reservationUnderNameResult.underName;
444
431
  }
432
+ const moneyTransferActions = [];
433
+ pendingReservations.forEach((reservation) => {
434
+ var _a;
435
+ const acceptedOffer4reservation = (_a = transaction.object.acceptedOffer) === null || _a === void 0 ? void 0 : _a.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; });
436
+ moneyTransferActions.push(...createMoneyTransferActions({
437
+ acceptedOffer: acceptedOffer4reservation,
438
+ reservation,
439
+ transaction: params.transaction,
440
+ underName
441
+ }));
442
+ });
443
+ const reservationPackage = Object.assign({ reservationFor, reservationNumber: pendingReservations[0].reservationNumber, reservationStatus: pendingReservations[0].reservationStatus, subReservation: pendingReservations, typeOf: factory.reservationType.ReservationPackage }, (typeof (underName === null || underName === void 0 ? void 0 : underName.typeOf) === 'string') ? { underName } : undefined);
444
+ reserveActionAttributes = [{
445
+ project: transaction.project,
446
+ typeOf: factory.actionType.ReserveAction,
447
+ // result: {},
448
+ object: reservationPackage,
449
+ agent: transaction.project,
450
+ potentialActions: {
451
+ moneyTransfer: moneyTransferActions
452
+ },
453
+ purpose: { typeOf: transaction.typeOf, id: transaction.id }
454
+ }];
445
455
  }
446
- // purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
447
- if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
448
- const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
449
- eventReservation.underName = ordre2reservationUnderNameResult.underName;
450
- eventReservation.reservedTicket.underName = ordre2reservationUnderNameResult.underName;
451
- eventReservation.reservedTicket.issuedBy = ordre2reservationUnderNameResult.issuedBy;
456
+ else {
457
+ reserveActionAttributes = pendingReservations.map((reservation) => {
458
+ var _a, _b;
459
+ const eventReservation = Object.assign(Object.assign({}, reservation), { reservationFor });
460
+ // purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
461
+ if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
462
+ const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
463
+ eventReservation.underName = ordre2reservationUnderNameResult.underName;
464
+ // 不要なので廃止(2022-12-19~)
465
+ // eventReservation.reservedTicket.underName = ordre2reservationUnderNameResult.underName;
466
+ // 不要なので廃止(2022-12-23~)
467
+ // eventReservation.reservedTicket.issuedBy = ordre2reservationUnderNameResult.issuedBy;
468
+ }
469
+ 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; });
470
+ const moneyTransfer = createMoneyTransferActions({
471
+ acceptedOffer: acceptedOffer4reservation,
472
+ reservation: eventReservation,
473
+ transaction: params.transaction,
474
+ underName: eventReservation.underName
475
+ });
476
+ return {
477
+ project: transaction.project,
478
+ typeOf: factory.actionType.ReserveAction,
479
+ // result: {},
480
+ object: eventReservation,
481
+ agent: transaction.project,
482
+ potentialActions: {
483
+ moneyTransfer: moneyTransfer
484
+ },
485
+ purpose: { typeOf: transaction.typeOf, id: transaction.id }
486
+ };
487
+ });
452
488
  }
453
- // const informReservationActions: factory.action.reserve.IInformReservation[] = [];
454
- 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; });
455
- const moneyTransfer = createMoneyTransferActions({
456
- acceptedOffer: acceptedOffer4reservation,
457
- reservation: eventReservation,
458
- transaction: params.transaction
459
- });
460
- return {
461
- project: transaction.project,
462
- typeOf: factory.actionType.ReserveAction,
463
- result: {},
464
- object: eventReservation,
465
- // プロジェクトに変更(2022-05-26~)
466
- agent: transaction.project,
467
- potentialActions: {
468
- moneyTransfer: moneyTransfer
469
- // informReservation: informReservationActions
470
- },
471
- purpose: {
472
- typeOf: transaction.typeOf,
473
- id: transaction.id
474
- }
475
- };
476
- });
489
+ }
477
490
  return {
478
491
  reserve: reserveActionAttributes
479
492
  };
480
493
  }
481
494
  exports.createPotentialActions = createPotentialActions;
482
495
  function createReservationUnderNameIdentifier(params) {
483
- const order = params.order;
484
- const customer = order.customer;
485
496
  // 予約のunderName.identifierを決定する
486
497
  return [
487
- { name: 'orderNumber', value: order.orderNumber },
488
- // 不要なので廃止(2022-05-24~)
489
- // { name: 'transaction', value: params.transaction.id },
490
- // ↓legacy-reservationの印刷アウトプットで使用(2022-02-09廃止)
491
- // { name: 'paymentMethod', value: paymentMethodNames },
492
- ...(Array.isArray(customer.identifier)) ? customer.identifier : []
498
+ { name: 'orderNumber', value: params.order.orderNumber },
499
+ ...(Array.isArray(params.order.customer.identifier)) ? params.order.customer.identifier : []
493
500
  ];
494
501
  }
495
502
  function createReservationUnderName(params) {
496
- // 予約のunderName.identifierを決定する
497
- const defaultUnderNameIdentifiers = createReservationUnderNameIdentifier({ order: params.order });
498
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ identifier: defaultUnderNameIdentifiers, name: String(params.order.customer.name), typeOf: params.order.customer.typeOf }, (typeof params.order.customer.address === 'string') ? { address: params.order.customer.address } : undefined), (typeof params.order.customer.age === 'string') ? { age: params.order.customer.age } : undefined), (typeof params.order.customer.email === 'string') ? { email: params.order.customer.email } : undefined), (typeof params.order.customer.familyName === 'string') ? { familyName: params.order.customer.familyName } : undefined), (typeof params.order.customer.gender === 'string') ? { gender: params.order.customer.gender } : undefined), (typeof params.order.customer.givenName === 'string') ? { givenName: params.order.customer.givenName } : undefined), (typeof params.order.customer.id === 'string') ? { id: params.order.customer.id } : undefined), (typeof params.order.customer.telephone === 'string') ? { telephone: params.order.customer.telephone } : undefined), (typeof params.order.customer.url === 'string') ? { url: params.order.customer.url } : undefined);
503
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ identifier: createReservationUnderNameIdentifier({ order: params.order }), name: String(params.order.customer.name), typeOf: params.order.customer.typeOf }, (typeof params.order.customer.address === 'string') ? { address: params.order.customer.address } : undefined), (typeof params.order.customer.age === 'string') ? { age: params.order.customer.age } : undefined), (typeof params.order.customer.email === 'string') ? { email: params.order.customer.email } : undefined), (typeof params.order.customer.familyName === 'string') ? { familyName: params.order.customer.familyName } : undefined), (typeof params.order.customer.gender === 'string') ? { gender: params.order.customer.gender } : undefined), (typeof params.order.customer.givenName === 'string') ? { givenName: params.order.customer.givenName } : undefined), (typeof params.order.customer.id === 'string') ? { id: params.order.customer.id } : undefined), (typeof params.order.customer.telephone === 'string') ? { telephone: params.order.customer.telephone } : undefined), (typeof params.order.customer.url === 'string') ? { url: params.order.customer.url } : undefined);
499
504
  }
500
505
  /**
501
506
  * 注文者情報を予約者情報へ変換する
502
507
  */
503
508
  function ordre2reservationUnderName(params) {
504
509
  return {
505
- issuedBy: {
506
- typeOf: params.order.seller.typeOf,
507
- name: params.order.seller.name
508
- },
510
+ // issuedBy: {
511
+ // typeOf: params.order.seller.typeOf,
512
+ // name: params.order.seller.name
513
+ // },
509
514
  underName: createReservationUnderName({ order: params.order })
510
515
  };
511
516
  }
512
517
  function createMoneyTransferActions(params) {
513
518
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
514
- // return [];
515
519
  const pointAward = (_b = (_a = params.acceptedOffer) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.pointAward;
516
520
  const moneyTransfer = [];
517
521
  // ポイント特典があれば適用
@@ -534,13 +538,13 @@ function createMoneyTransferActions(params) {
534
538
  issuedThrough: { id: String((_k = (_j = pointAward.toLocation) === null || _j === void 0 ? void 0 : _j.issuedThrough) === null || _k === void 0 ? void 0 : _k.id) }
535
539
  };
536
540
  const recipient = {
537
- typeOf: (typeof ((_l = params.reservation.underName) === null || _l === void 0 ? void 0 : _l.typeOf) === 'string')
538
- ? (_m = params.reservation.underName) === null || _m === void 0 ? void 0 : _m.typeOf
541
+ typeOf: (typeof ((_l = params.underName) === null || _l === void 0 ? void 0 : _l.typeOf) === 'string')
542
+ ? (_m = params.underName) === null || _m === void 0 ? void 0 : _m.typeOf
539
543
  : factory.personType.Person,
540
- id: (typeof ((_o = params.reservation.underName) === null || _o === void 0 ? void 0 : _o.id) === 'string')
541
- ? (_p = params.reservation.underName) === null || _p === void 0 ? void 0 : _p.id
544
+ id: (typeof ((_o = params.underName) === null || _o === void 0 ? void 0 : _o.id) === 'string')
545
+ ? (_p = params.underName) === null || _p === void 0 ? void 0 : _p.id
542
546
  : '',
543
- name: String((_q = params.reservation.underName) === null || _q === void 0 ? void 0 : _q.name)
547
+ name: String((_q = params.underName) === null || _q === void 0 ? void 0 : _q.name)
544
548
  };
545
549
  moneyTransfer.push(Object.assign(Object.assign({ project: params.transaction.project, typeOf: factory.actionType.MoneyTransfer, agent: params.transaction.project, recipient, object: {
546
550
  typeOf: factory.account.transactionType.Deposit
@@ -20,6 +20,7 @@ const OfferService = require("../offer");
20
20
  const cancelReservation_1 = require("../reserve/cancelReservation");
21
21
  const settings_1 = require("../../settings");
22
22
  const factory_1 = require("./reserve/factory");
23
+ const USE_RESERVATION_PACKAGE_AS_OBJECT = process.env.USE_RESERVATION_PACKAGE_AS_OBJECT === '1';
23
24
  /**
24
25
  * 取引開始
25
26
  */
@@ -148,9 +149,6 @@ function addReservations(params) {
148
149
  // 予約作成(insertManyで実装)
149
150
  yield repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
150
151
  // 予約作成後処理
151
- // await Promise.all(objectSubReservations.map(async (r) => {
152
- // await onReservationCreated(transaction, r)(repos);
153
- // }));
154
152
  yield onReservationsCreated({ event })(repos);
155
153
  return transaction;
156
154
  });
@@ -528,22 +526,6 @@ function processLockSeats(params) {
528
526
  }
529
527
  });
530
528
  }
531
- /**
532
- * 予約作成時イベント
533
- */
534
- // function onReservationCreated(
535
- // __1: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>,
536
- // __2: IObjectSubReservation
537
- // ) {
538
- // return async (repos: {
539
- // task: TaskRepo;
540
- // }) => {
541
- // // const now = new Date();
542
- // const taskAttributes: factory.task.IAttributes<factory.taskName>[] = [];
543
- // // タスク保管
544
- // await repos.task.saveMany(taskAttributes);
545
- // };
546
- // }
547
529
  /**
548
530
  * 予約作成時イベント
549
531
  */
@@ -628,47 +610,55 @@ function cancel(params) {
628
610
  transactionNumber: params.transactionNumber
629
611
  });
630
612
  // 本来非同期でタスクが実行されるが、同期的に仮予約取消が実行されていないと、サービス利用側が困る可能性があるので、
631
- // 一応同期的にもcancelPendingReservationを実行しておく
613
+ // 同期的にもcancelPendingReservationを実行しておく
632
614
  try {
633
615
  const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
616
+ let cancelActionAttributes = [];
634
617
  if (pendingReservations.length > 0) {
635
618
  const reservationFor = transaction.object.reservationFor;
636
619
  if (reservationFor === undefined) {
637
620
  throw new factory.errors.NotFound('transaction.object.reservationFor');
638
621
  }
639
- const actionAttributes = pendingReservations.map((reservation) => {
640
- var _a;
641
- const eventReservation = Object.assign(Object.assign({}, reservation), { reservationFor });
642
- // const informReservationActions: factory.action.reserve.IInformReservation[] = [];
643
- return {
644
- project: transaction.project,
645
- typeOf: factory.actionType.CancelAction,
646
- purpose: {
647
- typeOf: transaction.typeOf,
648
- id: transaction.id
649
- },
650
- // プロジェクトに変更(2022-05-26~)
651
- agent: transaction.project,
652
- // 最適化(2022-06-06~)
653
- object: {
654
- typeOf: eventReservation.typeOf,
655
- id: eventReservation.id,
656
- issuedThrough: {
657
- typeOf: (_a = eventReservation.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf
658
- },
659
- reservationFor: {
660
- typeOf: eventReservation.reservationFor.typeOf,
661
- id: eventReservation.reservationFor.id
662
- },
663
- reservationNumber: eventReservation.reservationNumber,
664
- reservationStatus: eventReservation.reservationStatus
665
- },
666
- potentialActions: {
667
- // informReservation: informReservationActions
668
- }
622
+ // ReservationPackageに対応(2022-12-23~)
623
+ if (USE_RESERVATION_PACKAGE_AS_OBJECT) {
624
+ const reservationPackage = {
625
+ typeOf: factory.reservationType.ReservationPackage,
626
+ reservationNumber: transaction.transactionNumber,
627
+ reservationFor: { typeOf: reservationFor.typeOf, id: reservationFor.id },
628
+ reservationStatus: pendingReservations[0].reservationStatus
669
629
  };
670
- });
671
- yield (0, cancelReservation_1.cancelPendingReservation)(actionAttributes)(repos);
630
+ cancelActionAttributes = [{
631
+ project: transaction.project,
632
+ typeOf: factory.actionType.CancelAction,
633
+ purpose: { typeOf: transaction.typeOf, id: transaction.id },
634
+ agent: transaction.project,
635
+ object: reservationPackage,
636
+ potentialActions: {}
637
+ }];
638
+ }
639
+ else {
640
+ cancelActionAttributes = pendingReservations.map((reservation) => {
641
+ var _a;
642
+ return {
643
+ project: transaction.project,
644
+ typeOf: factory.actionType.CancelAction,
645
+ purpose: { typeOf: transaction.typeOf, id: transaction.id },
646
+ agent: transaction.project,
647
+ object: {
648
+ typeOf: reservation.typeOf,
649
+ id: reservation.id,
650
+ issuedThrough: {
651
+ typeOf: (_a = reservation.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf
652
+ },
653
+ reservationFor: { typeOf: reservationFor.typeOf, id: reservationFor.id },
654
+ reservationNumber: reservation.reservationNumber,
655
+ reservationStatus: reservation.reservationStatus
656
+ },
657
+ potentialActions: {}
658
+ };
659
+ });
660
+ }
661
+ yield (0, cancelReservation_1.cancelPendingReservation)(cancelActionAttributes)(repos);
672
662
  }
673
663
  }
674
664
  catch (error) {
@@ -737,45 +727,29 @@ function exportTasksById(params) {
737
727
  case factory.transactionStatusType.Canceled:
738
728
  case factory.transactionStatusType.Expired:
739
729
  const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
730
+ let cancelActionAttributes = [];
740
731
  if (pendingReservations.length > 0) {
741
732
  const reservationFor = transaction.object.reservationFor;
742
733
  if (reservationFor === undefined) {
743
734
  throw new factory.errors.NotFound('transaction.object.reservationFor');
744
735
  }
745
- const actionAttributes = pendingReservations.map((reservation) => {
746
- var _a;
747
- const eventReservation = Object.assign(Object.assign({}, reservation), { reservationFor });
748
- // const informReservationActions: factory.action.reserve.IInformReservation[] = [];
749
- return {
750
- project: transaction.project,
751
- typeOf: factory.actionType.CancelAction,
752
- purpose: {
753
- typeOf: transaction.typeOf,
754
- id: transaction.id
755
- },
756
- // プロジェクトに変更(2022-05-26~)
757
- agent: transaction.project,
758
- // 最適化(2022-06-06~)
759
- object: {
760
- typeOf: eventReservation.typeOf,
761
- id: eventReservation.id,
762
- issuedThrough: {
763
- typeOf: (_a = eventReservation.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf
764
- },
765
- reservationFor: {
766
- typeOf: eventReservation.reservationFor.typeOf,
767
- id: eventReservation.reservationFor.id
768
- },
769
- reservationNumber: eventReservation.reservationNumber,
770
- reservationStatus: eventReservation.reservationStatus
771
- },
772
- potentialActions: {
773
- // informReservation: informReservationActions
774
- }
736
+ // ReservationPackageに対応(2022-12-23~)
737
+ if (USE_RESERVATION_PACKAGE_AS_OBJECT) {
738
+ const reservationPackage = {
739
+ typeOf: factory.reservationType.ReservationPackage,
740
+ reservationNumber: transaction.transactionNumber,
741
+ reservationFor: { typeOf: reservationFor.typeOf, id: reservationFor.id },
742
+ reservationStatus: pendingReservations[0].reservationStatus
775
743
  };
776
- });
777
- const cancelPendingReservationTasks = actionAttributes.map((a) => {
778
- return {
744
+ cancelActionAttributes = [{
745
+ project: transaction.project,
746
+ typeOf: factory.actionType.CancelAction,
747
+ purpose: { typeOf: transaction.typeOf, id: transaction.id },
748
+ agent: transaction.project,
749
+ object: reservationPackage,
750
+ potentialActions: {}
751
+ }];
752
+ const cancelPendingReservationTask = {
779
753
  project: transaction.project,
780
754
  name: factory.taskName.CancelPendingReservation,
781
755
  status: factory.taskStatus.Ready,
@@ -784,18 +758,54 @@ function exportTasksById(params) {
784
758
  numberOfTried: 0,
785
759
  executionResults: [],
786
760
  data: {
787
- actionAttributes: [a]
761
+ actionAttributes: cancelActionAttributes
788
762
  }
789
763
  };
790
- });
791
- taskAttributes.push(...cancelPendingReservationTasks);
764
+ taskAttributes.push(cancelPendingReservationTask);
765
+ }
766
+ else {
767
+ cancelActionAttributes = pendingReservations.map((reservation) => {
768
+ var _a;
769
+ return {
770
+ project: transaction.project,
771
+ typeOf: factory.actionType.CancelAction,
772
+ purpose: { typeOf: transaction.typeOf, id: transaction.id },
773
+ agent: transaction.project,
774
+ object: {
775
+ typeOf: reservation.typeOf,
776
+ id: reservation.id,
777
+ issuedThrough: {
778
+ typeOf: (_a = reservation.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf
779
+ },
780
+ reservationFor: { typeOf: reservationFor.typeOf, id: reservationFor.id },
781
+ reservationNumber: reservation.reservationNumber,
782
+ reservationStatus: reservation.reservationStatus
783
+ },
784
+ potentialActions: {}
785
+ };
786
+ });
787
+ const cancelPendingReservationTasks = cancelActionAttributes.map((a) => {
788
+ return {
789
+ project: transaction.project,
790
+ name: factory.taskName.CancelPendingReservation,
791
+ status: factory.taskStatus.Ready,
792
+ runsAt: new Date(),
793
+ remainingNumberOfTries: 10,
794
+ numberOfTried: 0,
795
+ executionResults: [],
796
+ data: {
797
+ actionAttributes: [a]
798
+ }
799
+ };
800
+ });
801
+ taskAttributes.push(...cancelPendingReservationTasks);
802
+ }
792
803
  }
793
804
  break;
794
805
  default:
795
806
  throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
796
807
  }
797
808
  return repos.task.saveMany(taskAttributes);
798
- // return Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
799
809
  });
800
810
  }
801
811
  exports.exportTasksById = exportTasksById;
@@ -63,7 +63,8 @@ function createAcquiredFrom(params) {
63
63
  // 最低限の情報に絞る
64
64
  const seller = params.order.seller;
65
65
  return {
66
- project: { typeOf: params.order.project.typeOf, id: params.order.project.id },
66
+ // 最適化(2022-11-15~)
67
+ // project: { typeOf: params.order.project.typeOf, id: params.order.project.id },
67
68
  id: seller.id,
68
69
  typeOf: seller.typeOf,
69
70
  name: (typeof seller.name === 'string')