@chevre/domain 20.1.0-alpha.5 → 20.1.0-alpha.50

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 (119) hide show
  1. package/example/src/chevre/deleteReservationTicketUnderNames.ts +20 -0
  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/example/src/chevre/transaction/callOrderMembershipServiceTask.ts +0 -4
  10. package/example/src/chevre/transaction/orderMembershipService.ts +0 -4
  11. package/lib/chevre/factory/reservedAgentIdentifireNames.d.ts +1 -0
  12. package/lib/chevre/factory/reservedAgentIdentifireNames.js +12 -0
  13. package/lib/chevre/repo/accountAction.d.ts +0 -18
  14. package/lib/chevre/repo/accountAction.js +402 -355
  15. package/lib/chevre/repo/accountTitle.d.ts +1 -0
  16. package/lib/chevre/repo/accountTitle.js +6 -1
  17. package/lib/chevre/repo/additionalProperty.d.ts +35 -0
  18. package/lib/chevre/repo/additionalProperty.js +205 -0
  19. package/lib/chevre/repo/categoryCode.d.ts +1 -0
  20. package/lib/chevre/repo/categoryCode.js +15 -1
  21. package/lib/chevre/repo/creativeWork.js +10 -1
  22. package/lib/chevre/repo/customer.d.ts +1 -0
  23. package/lib/chevre/repo/customer.js +5 -0
  24. package/lib/chevre/repo/event.d.ts +12 -4
  25. package/lib/chevre/repo/event.js +84 -48
  26. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -0
  27. package/lib/chevre/repo/merchantReturnPolicy.js +5 -0
  28. package/lib/chevre/repo/mongoose/model/additionalProperty.d.ts +7 -0
  29. package/lib/chevre/repo/mongoose/model/additionalProperty.js +81 -0
  30. package/lib/chevre/repo/mongoose/model/categoryCode.js +18 -2
  31. package/lib/chevre/repo/mongoose/model/creativeWork.js +6 -0
  32. package/lib/chevre/repo/mongoose/model/event.js +53 -0
  33. package/lib/chevre/repo/mongoose/model/offer.js +7 -1
  34. package/lib/chevre/repo/mongoose/model/offerCatalog.js +21 -2
  35. package/lib/chevre/repo/mongoose/model/ownershipInfo.js +3 -15
  36. package/lib/chevre/repo/mongoose/model/place.js +42 -0
  37. package/lib/chevre/repo/offer.js +10 -1
  38. package/lib/chevre/repo/offerCatalog.js +10 -10
  39. package/lib/chevre/repo/person.js +4 -1
  40. package/lib/chevre/repo/place.d.ts +1 -0
  41. package/lib/chevre/repo/place.js +54 -7
  42. package/lib/chevre/repo/reservation.d.ts +17 -2
  43. package/lib/chevre/repo/reservation.js +41 -1
  44. package/lib/chevre/repo/transaction.js +20 -5
  45. package/lib/chevre/repository.d.ts +6 -3
  46. package/lib/chevre/repository.js +10 -5
  47. package/lib/chevre/service/account.d.ts +0 -4
  48. package/lib/chevre/service/account.js +24 -22
  49. package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -2
  50. package/lib/chevre/service/accountTransaction/deposit.js +3 -3
  51. package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -2
  52. package/lib/chevre/service/accountTransaction/transfer.js +3 -3
  53. package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -2
  54. package/lib/chevre/service/accountTransaction/withdraw.js +3 -3
  55. package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +86 -42
  56. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +9 -19
  57. package/lib/chevre/service/assetTransaction/reserve/factory.js +119 -115
  58. package/lib/chevre/service/assetTransaction/reserve.js +41 -95
  59. package/lib/chevre/service/delivery/factory.js +2 -1
  60. package/lib/chevre/service/event.js +20 -6
  61. package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
  62. package/lib/chevre/service/offer/event/authorize.js +65 -27
  63. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  64. package/lib/chevre/service/offer/event/factory.js +17 -12
  65. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +19 -9
  66. package/lib/chevre/service/offer/factory.js +7 -20
  67. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +11 -3
  68. package/lib/chevre/service/order/onOrderStatusChanged.js +3 -2
  69. package/lib/chevre/service/order/placeOrder.js +13 -5
  70. package/lib/chevre/service/order/returnOrder.js +2 -1
  71. package/lib/chevre/service/order/sendOrder.js +2 -1
  72. package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -5
  73. package/lib/chevre/service/reserve/cancelReservation.js +260 -107
  74. package/lib/chevre/service/reserve/confirmReservation.js +65 -33
  75. package/lib/chevre/service/reserve/factory.d.ts +14 -2
  76. package/lib/chevre/service/reserve/factory.js +13 -6
  77. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
  78. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +85 -30
  79. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
  80. package/lib/chevre/service/transaction/orderProgramMembership.js +15 -31
  81. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -0
  82. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +20 -4
  83. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +9 -4
  84. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +2 -1
  85. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +2 -1
  86. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +2 -1
  87. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +2 -1
  88. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -1
  89. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +10 -6
  90. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -4
  91. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +3 -1
  92. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +3 -2
  93. package/lib/chevre/service/transaction/placeOrderInProgress.js +16 -2
  94. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +2 -1
  95. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +6 -3
  96. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +2 -1
  97. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +2 -1
  98. package/lib/chevre/service/transaction/returnOrder.js +10 -1
  99. package/lib/chevre/service/transaction.js +1 -14
  100. package/lib/chevre/service.d.ts +2 -0
  101. package/lib/chevre/service.js +2 -0
  102. package/package.json +4 -4
  103. package/example/src/chevre/accountBlanceTest.ts +0 -24
  104. package/example/src/chevre/checkOffersAppliesToMovieTicket.ts +0 -56
  105. package/example/src/chevre/createSeats.ts +0 -59
  106. package/example/src/chevre/deleteEvents.ts +0 -50
  107. package/example/src/chevre/manageOwnedByOfOwnershipInfo.ts +0 -35
  108. package/example/src/chevre/migrateEventOffersItemOfferedName.ts +0 -82
  109. package/example/src/chevre/migrateMovieTicketChargePriceSpecs.ts +0 -92
  110. package/example/src/chevre/migrateSellerMakesOffers.ts +0 -84
  111. package/example/src/chevre/migrateTTTSOldEventId.ts +0 -68
  112. package/example/src/chevre/publishConfirmationNumber.ts +0 -30
  113. package/example/src/chevre/publishServiceOutputIdentifier.ts +0 -28
  114. package/example/src/chevre/publishTransactionNumber.ts +0 -28
  115. package/example/src/chevre/renameTransaction.ts +0 -22
  116. package/lib/chevre/service/task/accountMoneyTransfer.d.ts +0 -3
  117. package/lib/chevre/service/task/accountMoneyTransfer.js +0 -31
  118. package/lib/chevre/service/task/cancelAccountMoneyTransfer.d.ts +0 -3
  119. 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
@@ -148,9 +148,6 @@ function addReservations(params) {
148
148
  // 予約作成(insertManyで実装)
149
149
  yield repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
150
150
  // 予約作成後処理
151
- // await Promise.all(objectSubReservations.map(async (r) => {
152
- // await onReservationCreated(transaction, r)(repos);
153
- // }));
154
151
  yield onReservationsCreated({ event })(repos);
155
152
  return transaction;
156
153
  });
@@ -528,22 +525,6 @@ function processLockSeats(params) {
528
525
  }
529
526
  });
530
527
  }
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
528
  /**
548
529
  * 予約作成時イベント
549
530
  */
@@ -628,47 +609,31 @@ function cancel(params) {
628
609
  transactionNumber: params.transactionNumber
629
610
  });
630
611
  // 本来非同期でタスクが実行されるが、同期的に仮予約取消が実行されていないと、サービス利用側が困る可能性があるので、
631
- // 一応同期的にもcancelPendingReservationを実行しておく
612
+ // 同期的にもcancelPendingReservationを実行しておく
632
613
  try {
633
614
  const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
615
+ let cancelActionAttributes = [];
634
616
  if (pendingReservations.length > 0) {
635
617
  const reservationFor = transaction.object.reservationFor;
636
618
  if (reservationFor === undefined) {
637
619
  throw new factory.errors.NotFound('transaction.object.reservationFor');
638
620
  }
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 {
621
+ // ReservationPackageに対応(2022-12-23~)
622
+ const reservationPackage = {
623
+ typeOf: factory.reservationType.ReservationPackage,
624
+ reservationNumber: transaction.transactionNumber,
625
+ reservationFor: { typeOf: reservationFor.typeOf, id: reservationFor.id },
626
+ reservationStatus: pendingReservations[0].reservationStatus
627
+ };
628
+ cancelActionAttributes = [{
644
629
  project: transaction.project,
645
630
  typeOf: factory.actionType.CancelAction,
646
- purpose: {
647
- typeOf: transaction.typeOf,
648
- id: transaction.id
649
- },
650
- // プロジェクトに変更(2022-05-26~)
631
+ purpose: { typeOf: transaction.typeOf, id: transaction.id },
651
632
  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
- }
669
- };
670
- });
671
- yield (0, cancelReservation_1.cancelPendingReservation)(actionAttributes)(repos);
633
+ object: reservationPackage,
634
+ potentialActions: {}
635
+ }];
636
+ yield (0, cancelReservation_1.cancelPendingReservation)(cancelActionAttributes)(repos);
672
637
  }
673
638
  }
674
639
  catch (error) {
@@ -737,65 +702,46 @@ function exportTasksById(params) {
737
702
  case factory.transactionStatusType.Canceled:
738
703
  case factory.transactionStatusType.Expired:
739
704
  const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
705
+ let cancelActionAttributes = [];
740
706
  if (pendingReservations.length > 0) {
741
707
  const reservationFor = transaction.object.reservationFor;
742
708
  if (reservationFor === undefined) {
743
709
  throw new factory.errors.NotFound('transaction.object.reservationFor');
744
710
  }
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 {
711
+ // ReservationPackageに対応(2022-12-23~)
712
+ const reservationPackage = {
713
+ typeOf: factory.reservationType.ReservationPackage,
714
+ reservationNumber: transaction.transactionNumber,
715
+ reservationFor: { typeOf: reservationFor.typeOf, id: reservationFor.id },
716
+ reservationStatus: pendingReservations[0].reservationStatus
717
+ };
718
+ cancelActionAttributes = [{
750
719
  project: transaction.project,
751
720
  typeOf: factory.actionType.CancelAction,
752
- purpose: {
753
- typeOf: transaction.typeOf,
754
- id: transaction.id
755
- },
756
- // プロジェクトに変更(2022-05-26~)
721
+ purpose: { typeOf: transaction.typeOf, id: transaction.id },
757
722
  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
- }
775
- };
776
- });
777
- const cancelPendingReservationTasks = actionAttributes.map((a) => {
778
- return {
779
- project: transaction.project,
780
- name: factory.taskName.CancelPendingReservation,
781
- status: factory.taskStatus.Ready,
782
- runsAt: new Date(),
783
- remainingNumberOfTries: 10,
784
- numberOfTried: 0,
785
- executionResults: [],
786
- data: {
787
- actionAttributes: [a]
788
- }
789
- };
790
- });
791
- taskAttributes.push(...cancelPendingReservationTasks);
723
+ object: reservationPackage,
724
+ potentialActions: {}
725
+ }];
726
+ const cancelPendingReservationTask = {
727
+ project: transaction.project,
728
+ name: factory.taskName.CancelPendingReservation,
729
+ status: factory.taskStatus.Ready,
730
+ runsAt: new Date(),
731
+ remainingNumberOfTries: 10,
732
+ numberOfTried: 0,
733
+ executionResults: [],
734
+ data: {
735
+ actionAttributes: cancelActionAttributes
736
+ }
737
+ };
738
+ taskAttributes.push(cancelPendingReservationTask);
792
739
  }
793
740
  break;
794
741
  default:
795
742
  throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
796
743
  }
797
744
  return repos.task.saveMany(taskAttributes);
798
- // return Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
799
745
  });
800
746
  }
801
747
  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')
@@ -419,7 +419,8 @@ function createScreeningEventFromCOA(params) {
419
419
  .toDate();
420
420
  }
421
421
  const offers = {
422
- project: { typeOf: params.project.typeOf, id: params.project.id },
422
+ // 不要なので廃止(2022-12-19~)
423
+ // project: { typeOf: params.project.typeOf, id: params.project.id },
423
424
  typeOf: factory.offerType.Offer,
424
425
  offeredThrough: {
425
426
  typeOf: 'WebAPI',
@@ -437,7 +438,8 @@ function createScreeningEventFromCOA(params) {
437
438
  eventStatus: factory.eventStatusType.EventScheduled,
438
439
  workPerformed: params.superEvent.workPerformed,
439
440
  location: {
440
- project: { typeOf: params.project.typeOf, id: params.project.id },
441
+ // 不要なので廃止(2022-12-19~)
442
+ // project: { typeOf: params.project.typeOf, id: params.project.id },
441
443
  typeOf: params.screenRoom.typeOf,
442
444
  branchCode: params.screenRoom.branchCode,
443
445
  name: params.screenRoom.name
@@ -475,7 +477,7 @@ function createScreeningEventAdditionalPropertyFromCOA(params) {
475
477
  return {
476
478
  coaInfo,
477
479
  additionalProperty: [
478
- { name: 'COA_ENDPOINT', value: credentials_1.credentials.coa.endpoint },
480
+ // { name: 'COA_ENDPOINT', value: credentials.coa.endpoint },
479
481
  { name: 'coaInfo', value: JSON.stringify(coaInfo) }
480
482
  ]
481
483
  };
@@ -529,7 +531,8 @@ function createScreeningEventSeriesFromCOA(params) {
529
531
  kanaName: params.filmFromCOA.titleNameKana,
530
532
  alternativeHeadline: params.filmFromCOA.titleNameShort,
531
533
  location: {
532
- project: { typeOf: params.project.typeOf, id: params.project.id },
534
+ // 不要なので廃止(2022-12-19~)
535
+ // project: { typeOf: params.project.typeOf, id: params.project.id },
533
536
  id: (params.movieTheater.id !== undefined) ? params.movieTheater.id : '',
534
537
  branchCode: params.movieTheater.branchCode,
535
538
  name: params.movieTheater.name,
@@ -544,7 +547,8 @@ function createScreeningEventSeriesFromCOA(params) {
544
547
  videoFormat: params.eizouKubuns.filter((kubun) => kubun.kubunCode === params.filmFromCOA.kbnEizou)[0],
545
548
  soundFormat: [],
546
549
  workPerformed: {
547
- project: { typeOf: params.project.typeOf, id: params.project.id },
550
+ // 不要なので廃止(2022-12-19~)
551
+ // project: { typeOf: params.project.typeOf, id: params.project.id },
548
552
  id: `${params.movieTheater.branchCode}-${params.filmFromCOA.titleCode}`,
549
553
  identifier: params.filmFromCOA.titleCode,
550
554
  // 多言語化(2022-07-26~)
@@ -579,7 +583,7 @@ function createScreeningEventSeriesAdditionalPropertyFromCOA(params) {
579
583
  return {
580
584
  coaInfo,
581
585
  additionalProperty: [
582
- { name: 'COA_ENDPOINT', value: credentials_1.credentials.coa.endpoint },
586
+ // { name: 'COA_ENDPOINT', value: credentials.coa.endpoint },
583
587
  { name: 'coaInfo', value: JSON.stringify(coaInfo) }
584
588
  ]
585
589
  };
@@ -648,6 +652,16 @@ function createMovieTheaterFromCOA(project, theaterFromCOA, screensFromCOA) {
648
652
  typeOf: 'QuantitativeValue',
649
653
  value: 1200,
650
654
  unitCode: factory.unitCode.Sec
655
+ },
656
+ availabilityStartsGraceTimeOnPOS: {
657
+ typeOf: 'QuantitativeValue',
658
+ value: -93,
659
+ unitCode: factory.unitCode.Day
660
+ },
661
+ availabilityEndsGraceTimeOnPOS: {
662
+ typeOf: 'QuantitativeValue',
663
+ value: 2678400,
664
+ unitCode: factory.unitCode.Sec
651
665
  }
652
666
  }
653
667
  };
@@ -49,11 +49,15 @@ export declare function authorize(params: {
49
49
  transaction: {
50
50
  id: string;
51
51
  };
52
+ validateEventOfferPeriod?: boolean;
52
53
  validateEvent?: boolean;
53
54
  /**
54
55
  * どの店舗に対して
55
56
  */
56
57
  store: {
58
+ /**
59
+ * 販売アプリケーションID
60
+ */
57
61
  id: string;
58
62
  };
59
63
  }): IAuthorizeOperation<IAuthorizeOfferAction>;