@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,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  Object.defineProperty(exports, "__esModule", { value: true });
12
23
  exports.onReservationConfirmed = exports.onReservationConfirmedByAction = void 0;
13
24
  /**
@@ -21,7 +32,9 @@ const informReservations = settings_1.settings.onReservationStatusChanged.inform
21
32
  /**
22
33
  * 予約確定後のアクション
23
34
  */
24
- function onReservationConfirmedByAction(actionAttributes, confirmedReservation) {
35
+ function onReservationConfirmedByAction(actionAttributes
36
+ // confirmedReservation: IEventReservation
37
+ ) {
25
38
  return (repos) => __awaiter(this, void 0, void 0, function* () {
26
39
  const potentialActions = actionAttributes.potentialActions;
27
40
  const now = new Date();
@@ -45,35 +58,34 @@ function onReservationConfirmedByAction(actionAttributes, confirmedReservation)
45
58
  }
46
59
  }
47
60
  // 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
- }
61
+ // if (Array.isArray(informReservations)) {
62
+ // const reservation4inform: IReservation4informConfirmed = maskUnderName(confirmedReservation);
63
+ // taskAttributes.push(...informReservations.map<ITriggerWebhookTaskAttributes>((informReservation) => {
64
+ // const informUrl: string = String(informReservation.recipient?.url);
65
+ // const informReservationAttributes: InformReservationActionattributes = {
66
+ // agent: confirmedReservation.project,
67
+ // object: [reservation4inform],
68
+ // project: confirmedReservation.project,
69
+ // recipient: {
70
+ // id: '',
71
+ // name: informUrl,
72
+ // typeOf: factory.creativeWorkType.WebApplication,
73
+ // url: informUrl
74
+ // },
75
+ // typeOf: factory.actionType.InformAction
76
+ // };
77
+ // return {
78
+ // project: actionAttributes.project,
79
+ // name: factory.taskName.TriggerWebhook,
80
+ // status: factory.taskStatus.Ready,
81
+ // runsAt: now,
82
+ // remainingNumberOfTries: NUM_TRY_INFORM_RESERVATION,
83
+ // numberOfTried: 0,
84
+ // executionResults: [],
85
+ // data: informReservationAttributes
86
+ // };
87
+ // }));
88
+ // }
77
89
  // タスク保管
78
90
  if (taskAttributes.length > 0) {
79
91
  yield repos.task.saveMany(taskAttributes);
@@ -88,6 +100,49 @@ function onReservationConfirmed(confirmedReservations) {
88
100
  project: confirmedReservations[0].project,
89
101
  reservationFor: { id: confirmedReservations[0].reservationFor.id }
90
102
  })({ task: repos.task });
103
+ const now = new Date();
104
+ const taskAttributes = [];
105
+ // inform galobally
106
+ if (Array.isArray(informReservations)) {
107
+ taskAttributes.push(...informReservations.map((informReservation) => {
108
+ var _a, _b;
109
+ const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
110
+ // ReservationPackage通知に変更(2022-12-24~)
111
+ // const informObject: IInformObject = confirmedReservations.map(maskUnderName);
112
+ const informObject = [Object.assign({ project: confirmedReservations[0].project, reservationFor: confirmedReservations[0].reservationFor, reservationNumber: confirmedReservations[0].reservationNumber, reservationStatus: confirmedReservations[0].reservationStatus, subReservation: confirmedReservations.map((r) => {
113
+ const { broker, project, reservationFor, reservationNumber, reservationStatus, underName } = r, subReservation = __rest(r, ["broker", "project", "reservationFor", "reservationNumber", "reservationStatus", "underName"]);
114
+ return subReservation;
115
+ }), typeOf: factory.reservationType.ReservationPackage }, (typeof ((_b = confirmedReservations[0].underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
116
+ ? { underName: (0, factory_1.maskUnderName)(confirmedReservations[0]).underName }
117
+ : undefined)];
118
+ const informReservationAttributes = {
119
+ agent: confirmedReservations[0].project,
120
+ object: informObject,
121
+ project: confirmedReservations[0].project,
122
+ recipient: {
123
+ id: '',
124
+ name: informUrl,
125
+ typeOf: factory.creativeWorkType.WebApplication,
126
+ url: informUrl
127
+ },
128
+ typeOf: factory.actionType.InformAction
129
+ };
130
+ return {
131
+ project: confirmedReservations[0].project,
132
+ name: factory.taskName.TriggerWebhook,
133
+ status: factory.taskStatus.Ready,
134
+ runsAt: now,
135
+ remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
136
+ numberOfTried: 0,
137
+ executionResults: [],
138
+ data: informReservationAttributes
139
+ };
140
+ }));
141
+ }
142
+ // タスク保管
143
+ if (taskAttributes.length > 0) {
144
+ yield repos.task.saveMany(taskAttributes);
145
+ }
91
146
  }
92
147
  });
93
148
  }
@@ -72,7 +72,7 @@ function confirmReserveTransaction(params) {
72
72
  object = object;
73
73
  yield ReserveTransactionService.confirm({
74
74
  transactionNumber: object.transactionNumber,
75
- object: object.object,
75
+ // object: object.object,
76
76
  potentialActions: object.potentialActions
77
77
  })(repos);
78
78
  }
@@ -15,7 +15,6 @@ exports.orderProgramMembership = exports.ISS_PREFIX = void 0;
15
15
  */
16
16
  const GMO = require("@motionpicture/gmo-service");
17
17
  const createDebug = require("debug");
18
- const moment = require("moment-timezone");
19
18
  const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
20
19
  const OfferService = require("../offer");
21
20
  const AnyPaymentService = require("../payment/any");
@@ -32,34 +31,20 @@ exports.ISS_PREFIX = 'https://cognito-idp.ap-northeast-1.amazonaws.com/';
32
31
  */
33
32
  function orderProgramMembership(params, paymentMethodType) {
34
33
  return (repos) => __awaiter(this, void 0, void 0, function* () {
35
- // let iss = '';
36
- // if (Array.isArray(params.agent.identifier)) {
37
- // const issByAgent = params.agent.identifier?.find((p) => p.name === 'iss')?.value;
38
- // if (typeof issByAgent === 'string' && issByAgent.length > 0) {
39
- // iss = issByAgent.replace(ISS_PREFIX, '');
40
- // }
41
- // }
42
- var _a, _b, _c, _d, _e;
34
+ var _a, _b, _c;
43
35
  // ユーザー存在確認(管理者がマニュアルでユーザーを削除する可能性があるので)
44
36
  const customer = yield repos.person.findById({ userId: String(params.agent.id) });
45
- // issは必ずissからセットし直す
46
- let issByCustomer;
47
- if (Array.isArray(customer.identifier)) {
48
- issByCustomer = (_b = (_a = customer.identifier) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'iss')) === null || _b === void 0 ? void 0 : _b.value;
49
- }
50
- if (typeof issByCustomer === 'string' && issByCustomer.length > 0) {
51
- // iss = issByCustomer.replace(ISS_PREFIX, '');
52
- }
53
- else {
37
+ // issに依存するので存在確認
38
+ const issByCustomer = (_b = (_a = customer.identifier) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'iss')) === null || _b === void 0 ? void 0 : _b.value;
39
+ if (typeof issByCustomer !== 'string' || issByCustomer.length === 0) {
54
40
  throw new factory.errors.NotFound(`iss of customer ${customer.id}`);
55
41
  }
56
42
  const acceptedOffer = params.object;
57
- // hostingOrganizationへの依存排除 -> acceptedOffer.seller.idへ依存
58
- let sellerId = (_c = acceptedOffer.seller) === null || _c === void 0 ? void 0 : _c.id;
59
- if (typeof sellerId !== 'string') {
60
- // 互換性維持対応として↓
61
- sellerId = (_e = (_d = acceptedOffer.itemOffered) === null || _d === void 0 ? void 0 : _d.hostingOrganization) === null || _e === void 0 ? void 0 : _e.id;
62
- }
43
+ const sellerId = (_c = acceptedOffer.seller) === null || _c === void 0 ? void 0 : _c.id;
44
+ // if (typeof sellerId !== 'string') {
45
+ // // 互換性維持対応として↓
46
+ // sellerId = (<any>acceptedOffer.itemOffered)?.hostingOrganization?.id;
47
+ // }
63
48
  if (typeof sellerId !== 'string') {
64
49
  throw new factory.errors.NotFound('acceptedOffer seller ID undefined');
65
50
  }
@@ -120,16 +105,15 @@ function createStartPlaceOrderInProgressParams(params) {
120
105
  id: customer.id,
121
106
  identifier: customer.identifier,
122
107
  memberOf: customer.memberOf
123
- // ↓不要なので廃止(2022-05-26~)
124
- // paramsにadditionalPropertyの指定があれば反映する
125
- // ...(Array.isArray(params.agent.additionalProperty)) ? { additionalProperty: params.agent.additionalProperty } : []
126
108
  };
127
109
  return {
128
110
  project: { typeOf: factory.organizationType.Project, id: params.project.id },
129
- expires: moment()
130
- // tslint:disable-next-line:no-magic-numbers
131
- .add(5, 'minutes')
132
- .toDate(),
111
+ // expiresInSeconds指定に変更(2022-11-29~)
112
+ // expires: moment()
113
+ // // tslint:disable-next-line:no-magic-numbers
114
+ // .add(5, 'minutes')
115
+ // .toDate(),
116
+ expiresInSeconds: 300,
133
117
  agent,
134
118
  seller: { id: params.seller.id },
135
119
  object: {
@@ -1,4 +1,5 @@
1
1
  import * as factory from '../../../../factory';
2
+ export declare type IPlaceOrderTransactionAsInformObject = Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'id' | 'typeOf' | 'agent' | 'endDate' | 'expires' | 'project' | 'seller' | 'result' | 'startDate' | 'status'>;
2
3
  /**
3
4
  * 取引のタスクを作成する
4
5
  */
@@ -9,11 +9,24 @@ const settings_1 = require("../../../../settings");
9
9
  */
10
10
  // tslint:disable-next-line:max-func-body-length
11
11
  function createTasks(params) {
12
+ var _a;
12
13
  const taskAttributes = [];
13
14
  const transaction = params.transaction;
14
15
  const taskRunsAt = params.runsAt;
15
16
  const transactionWebhookUrls = (Array.isArray(settings_1.settings.transactionWebhookUrls)) ? settings_1.settings.transactionWebhookUrls : [];
16
17
  const triggerWebhookTaskAttributes = transactionWebhookUrls.map((webhookUrl) => {
18
+ const informObject = {
19
+ id: transaction.id,
20
+ typeOf: transaction.typeOf,
21
+ agent: transaction.agent,
22
+ endDate: transaction.endDate,
23
+ expires: transaction.expires,
24
+ project: transaction.project,
25
+ seller: transaction.seller,
26
+ result: transaction.result,
27
+ startDate: transaction.startDate,
28
+ status: transaction.status
29
+ };
17
30
  return {
18
31
  project: transaction.project,
19
32
  name: factory.taskName.TriggerWebhook,
@@ -24,8 +37,8 @@ function createTasks(params) {
24
37
  executionResults: [],
25
38
  data: {
26
39
  agent: transaction.project,
27
- // agent: transaction.seller,
28
- object: transaction,
40
+ // 通知内容最適化(2022-12-28~)
41
+ object: informObject,
29
42
  project: transaction.project,
30
43
  purpose: { typeOf: transaction.typeOf, id: transaction.id },
31
44
  recipient: {
@@ -72,6 +85,10 @@ function createTasks(params) {
72
85
  if (potentialActions === undefined) {
73
86
  throw new factory.errors.NotFound('Transaction PotentialActions');
74
87
  }
88
+ const orderFromTransaction = (_a = transaction.result) === null || _a === void 0 ? void 0 : _a.order;
89
+ if (orderFromTransaction === undefined) {
90
+ throw new factory.errors.NotFound('Transaction Result');
91
+ }
75
92
  const orderActionAttributes = potentialActions.order;
76
93
  const placeOrderTaskAttributes = {
77
94
  project: transaction.project,
@@ -81,9 +98,8 @@ function createTasks(params) {
81
98
  remainingNumberOfTries: 10,
82
99
  numberOfTried: 0,
83
100
  executionResults: [],
84
- // data: orderActionAttributes
85
101
  data: Object.assign({ project: orderActionAttributes.project, object: {
86
- confirmationNumber: orderActionAttributes.object.confirmationNumber,
102
+ confirmationNumber: orderFromTransaction.confirmationNumber,
87
103
  orderNumber: orderActionAttributes.object.orderNumber
88
104
  } }, (orderActionAttributes.potentialActions !== undefined)
89
105
  ? { potentialActions: orderActionAttributes.potentialActions }
@@ -10,7 +10,9 @@ function createStartParams(params, passport, seller, broker) {
10
10
  if (typeof seller.id !== 'string') {
11
11
  throw new factory.errors.NotFound('seller.id');
12
12
  }
13
- // 取引ファクトリーで新しい進行中取引オブジェクトを作成
13
+ if (typeof params.expiresInSeconds !== 'number') {
14
+ throw new factory.errors.ArgumentNull('expiresInSeconds');
15
+ }
14
16
  return {
15
17
  project: { typeOf: seller.project.typeOf, id: seller.project.id },
16
18
  typeOf: factory.transactionType.PlaceOrder,
@@ -19,11 +21,14 @@ function createStartParams(params, passport, seller, broker) {
19
21
  id: seller.id,
20
22
  name: seller.name,
21
23
  typeOf: seller.typeOf
22
- // ↓最適化(2022-05-24~)
23
- // ...{ project: seller.project }
24
24
  },
25
25
  object: transactionObject,
26
- expires: params.expires
26
+ // expires: params.expires,
27
+ expiresInSeconds: params.expiresInSeconds
28
+ // 販売者にexpires設定があれば適用
29
+ // ...(typeof makesOfferFromClient?.eligibleTransactionDuration?.maxValue === 'number')
30
+ // ? { expiresInSeconds: makesOfferFromClient.eligibleTransactionDuration.maxValue }
31
+ // : undefined
27
32
  };
28
33
  }
29
34
  exports.createStartParams = createStartParams;
@@ -48,7 +48,8 @@ function createGivePointAwardActions(params) {
48
48
  seller: params.order.seller,
49
49
  // mask
50
50
  customer: (0, order_1.createMaskedCustomer)(params.order),
51
- confirmationNumber: params.order.confirmationNumber,
51
+ // IOrderへ移行(2022-11-17~)
52
+ // confirmationNumber: params.order.confirmationNumber,
52
53
  orderNumber: params.order.orderNumber,
53
54
  price: params.order.price,
54
55
  priceCurrency: params.order.priceCurrency,
@@ -66,7 +66,8 @@ function createMoneyTransferActions(params) {
66
66
  seller: params.order.seller,
67
67
  // mask
68
68
  customer: (0, order_1.createMaskedCustomer)(params.order),
69
- confirmationNumber: params.order.confirmationNumber,
69
+ // IOrderへ移行(2022-11-17~)
70
+ // confirmationNumber: params.order.confirmationNumber,
70
71
  orderNumber: params.order.orderNumber,
71
72
  price: params.order.price,
72
73
  priceCurrency: params.order.priceCurrency,
@@ -51,7 +51,8 @@ function createRegisterServiceActions(params) {
51
51
  seller: params.order.seller,
52
52
  // mask
53
53
  customer: (0, order_1.createMaskedCustomer)(params.order),
54
- confirmationNumber: params.order.confirmationNumber,
54
+ // IOrderへ移行(2022-11-17~)
55
+ // confirmationNumber: params.order.confirmationNumber,
55
56
  orderNumber: params.order.orderNumber,
56
57
  price: params.order.price,
57
58
  priceCurrency: params.order.priceCurrency,
@@ -25,7 +25,8 @@ function createSendEmailMessageActions(params) {
25
25
  seller: params.order.seller,
26
26
  // mask
27
27
  customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
28
- confirmationNumber: params.order.confirmationNumber,
28
+ // IOrderへ移行(2022-11-17~)
29
+ // confirmationNumber: params.order.confirmationNumber,
29
30
  orderNumber: params.order.orderNumber,
30
31
  price: params.order.price,
31
32
  priceCurrency: params.order.priceCurrency,
@@ -41,7 +41,8 @@ function createPotentialActions(params) {
41
41
  seller: params.order.seller,
42
42
  // mask
43
43
  customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
44
- confirmationNumber: params.order.confirmationNumber,
44
+ // IOrderへ移行(2022-11-17~)
45
+ // confirmationNumber: params.order.confirmationNumber,
45
46
  orderNumber: params.order.orderNumber,
46
47
  price: params.order.price,
47
48
  priceCurrency: params.order.priceCurrency,
@@ -35,25 +35,29 @@ function createReservationAcceptedOffers(params) {
35
35
  }
36
36
  exports.createReservationAcceptedOffers = createReservationAcceptedOffers;
37
37
  function reservationOffers2orderedItem(params) {
38
- var _a, _b, _c, _d, _e;
38
+ var _a, _b, _c, _d;
39
39
  const reservationFor = params.reservationFor;
40
40
  const issuedThrough = params.issuedThrough;
41
41
  const reservationFor4orderedItem = {
42
42
  location: {
43
43
  branchCode: (_a = reservationFor.location) === null || _a === void 0 ? void 0 : _a.branchCode,
44
44
  name: (_b = reservationFor.location) === null || _b === void 0 ? void 0 : _b.name,
45
- project: (_c = reservationFor.location) === null || _c === void 0 ? void 0 : _c.project,
46
- typeOf: (_d = reservationFor.location) === null || _d === void 0 ? void 0 : _d.typeOf
45
+ // 不要なので廃止(2022-12-19~)
46
+ // project: reservationFor.location?.project,
47
+ typeOf: (_c = reservationFor.location) === null || _c === void 0 ? void 0 : _c.typeOf
47
48
  },
48
- project: reservationFor.project,
49
+ // 不要なので廃止(2022-12-19~)
50
+ // project: reservationFor.project,
49
51
  typeOf: reservationFor.typeOf,
50
52
  id: reservationFor.id,
51
53
  name: reservationFor.name,
52
54
  startDate: reservationFor.startDate,
53
55
  endDate: reservationFor.endDate
54
- // eventStatus: reservationFor.eventStatus
55
56
  };
56
- return Object.assign(Object.assign({ project: reservationFor.project, typeOf: issuedThrough.typeOf }, (typeof ((_e = issuedThrough.serviceType) === null || _e === void 0 ? void 0 : _e.typeOf) === 'string')
57
+ return Object.assign(Object.assign({
58
+ // 不要なので廃止(2022-12-19~)
59
+ // project: reservationFor.project,
60
+ typeOf: issuedThrough.typeOf }, (typeof ((_d = issuedThrough.serviceType) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
57
61
  ? { serviceType: issuedThrough.serviceType }
58
62
  : undefined), { serviceOutput: {
59
63
  typeOf: factory.reservationType.EventReservation,
@@ -34,13 +34,11 @@ function createSeller(params) {
34
34
  var _a;
35
35
  const seller = params.transaction.seller;
36
36
  return {
37
- project: { typeOf: params.transaction.project.typeOf, id: params.transaction.project.id },
37
+ // 最適化(2022-11-15~)
38
+ // project: { typeOf: params.transaction.project.typeOf, id: params.transaction.project.id },
38
39
  id: seller.id,
39
40
  name: (typeof seller.name === 'string') ? seller.name : String((_a = seller.name) === null || _a === void 0 ? void 0 : _a.ja),
40
41
  typeOf: seller.typeOf
41
- // ↓最適化(2022-05-20~)
42
- // ...(typeof seller.telephone === 'string') ? { telephone: seller.telephone } : undefined,
43
- // ...(typeof seller.url === 'string') ? { url: seller.url } : undefined
44
42
  };
45
43
  }
46
44
  function createCustomer(params) {
@@ -2,4 +2,6 @@ import * as factory from '../../../../factory';
2
2
  export declare function validateSeller(params: {
3
3
  seller: factory.seller.ISeller;
4
4
  clientUser?: factory.clientUser.IClientUser;
5
- }): void;
5
+ }): {
6
+ makesOfferFromClient: factory.seller.IMakesOffer;
7
+ };
@@ -8,12 +8,13 @@ function validateSeller(params) {
8
8
  if (typeof clientId !== 'string' || clientId.length === 0) {
9
9
  throw new factory.errors.ArgumentNull('client_id');
10
10
  }
11
- const makesOfferFromClient = (_b = params.seller.makesOffer) === null || _b === void 0 ? void 0 : _b.some((offer) => {
11
+ const makesOfferFromClient = (_b = params.seller.makesOffer) === null || _b === void 0 ? void 0 : _b.find((offer) => {
12
12
  var _a;
13
13
  return (_a = offer.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.some((availableApplication) => availableApplication.id === clientId);
14
14
  });
15
- if (makesOfferFromClient !== true) {
15
+ if (makesOfferFromClient === undefined) {
16
16
  throw new factory.errors.Argument('seller', 'makes no offers');
17
17
  }
18
+ return { makesOfferFromClient };
18
19
  }
19
20
  exports.validateSeller = validateSeller;
@@ -27,14 +27,28 @@ exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
27
27
  */
28
28
  function start(params) {
29
29
  return (repos) => __awaiter(this, void 0, void 0, function* () {
30
+ var _a;
30
31
  const seller = yield repos.seller.findById({ id: params.seller.id });
32
+ let makesOfferFromClient;
31
33
  // 販売者オファー検証(2022-10-14~)
32
34
  if (params.validateSeller === true) {
33
- (0, validateSeller_1.validateSeller)({ seller, clientUser: params.object.clientUser });
35
+ const validateSellerResult = (0, validateSeller_1.validateSeller)({ seller, clientUser: params.object.clientUser });
36
+ makesOfferFromClient = validateSellerResult.makesOfferFromClient;
34
37
  }
35
38
  const passport = yield (0, validation_2.validateWaiterPassport)(params);
39
+ // fix expiresInSeconds(2022-11-29~)
40
+ let expiresInSeconds;
41
+ if (typeof ((_a = makesOfferFromClient === null || makesOfferFromClient === void 0 ? void 0 : makesOfferFromClient.eligibleTransactionDuration) === null || _a === void 0 ? void 0 : _a.maxValue) === 'number') {
42
+ expiresInSeconds = makesOfferFromClient.eligibleTransactionDuration.maxValue;
43
+ }
44
+ else if (typeof params.expiresInSeconds === 'number') {
45
+ expiresInSeconds = params.expiresInSeconds;
46
+ }
47
+ else {
48
+ throw new factory.errors.ArgumentNull('expiresInSeconds');
49
+ }
36
50
  // 取引ファクトリーで新しい進行中取引オブジェクトを作成
37
- const startParams = (0, factory_1.createStartParams)(params, passport, seller, params.broker);
51
+ const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { expiresInSeconds }), passport, seller, params.broker);
38
52
  let transaction;
39
53
  try {
40
54
  transaction = yield repos.transaction.start(startParams);
@@ -23,7 +23,8 @@ function createReturnMoneyTransferActions(params) {
23
23
  seller: order.seller,
24
24
  // mask
25
25
  customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
26
- confirmationNumber: order.confirmationNumber,
26
+ // IOrderへ移行(2022-11-17~)
27
+ // confirmationNumber: order.confirmationNumber,
27
28
  orderNumber: order.orderNumber,
28
29
  price: order.price,
29
30
  priceCurrency: order.priceCurrency,
@@ -45,7 +45,8 @@ function createReturnPaymentMethodPotentialActions(params) {
45
45
  seller: order.seller,
46
46
  // mask
47
47
  customer: (0, order_1.createMaskedCustomer)(order),
48
- confirmationNumber: order.confirmationNumber,
48
+ // IOrderへ移行(2022-11-17~)
49
+ // confirmationNumber: order.confirmationNumber,
49
50
  orderNumber: order.orderNumber,
50
51
  price: order.price,
51
52
  priceCurrency: order.priceCurrency,
@@ -109,7 +110,8 @@ function createReturnPaymentMethodActions(params) {
109
110
  seller: order.seller,
110
111
  // mask
111
112
  customer: (0, order_1.createMaskedCustomer)(order),
112
- confirmationNumber: order.confirmationNumber,
113
+ // IOrderへ移行(2022-11-17~)
114
+ // confirmationNumber: order.confirmationNumber,
113
115
  orderNumber: order.orderNumber,
114
116
  price: order.price,
115
117
  priceCurrency: order.priceCurrency,
@@ -179,7 +181,8 @@ function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
179
181
  seller: order.seller,
180
182
  // mask
181
183
  customer: (0, order_1.createMaskedCustomer)(order),
182
- confirmationNumber: order.confirmationNumber,
184
+ // IOrderへ移行(2022-11-17~)
185
+ // confirmationNumber: order.confirmationNumber,
183
186
  orderNumber: order.orderNumber,
184
187
  price: order.price,
185
188
  priceCurrency: order.priceCurrency,
@@ -54,7 +54,8 @@ function createReturnPointAwardActions(params) {
54
54
  seller: order.seller,
55
55
  // mask
56
56
  customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id, name: maskedCustomer.name },
57
- confirmationNumber: order.confirmationNumber,
57
+ // IOrderへ移行(2022-11-17~)
58
+ // confirmationNumber: order.confirmationNumber,
58
59
  orderNumber: order.orderNumber,
59
60
  price: order.price,
60
61
  priceCurrency: order.priceCurrency,
@@ -23,7 +23,8 @@ function createSendEmailMessaegActionsOnReturn(params) {
23
23
  seller: order.seller,
24
24
  // mask
25
25
  customer: (0, order_1.createMaskedCustomer)(order),
26
- confirmationNumber: order.confirmationNumber,
26
+ // IOrderへ移行(2022-11-17~)
27
+ // confirmationNumber: order.confirmationNumber,
27
28
  orderNumber: order.orderNumber,
28
29
  price: order.price,
29
30
  priceCurrency: order.priceCurrency,
@@ -55,6 +55,14 @@ function start(params) {
55
55
  returnPolicy: appliedReturnPolicy,
56
56
  reason: params.object.reason
57
57
  };
58
+ // fix expiresInSeconds(2022-11-30~)
59
+ let expiresInSeconds;
60
+ if (typeof params.expiresInSeconds === 'number') {
61
+ expiresInSeconds = params.expiresInSeconds;
62
+ }
63
+ else {
64
+ throw new factory.errors.ArgumentNull('expiresInSeconds');
65
+ }
58
66
  const returnOrderAttributes = {
59
67
  project: params.project,
60
68
  typeOf: factory.transactionType.ReturnOrder,
@@ -65,7 +73,8 @@ function start(params) {
65
73
  name: seller.name
66
74
  },
67
75
  object: transactionObject,
68
- expires: params.expires
76
+ // expires: params.expires,
77
+ expiresInSeconds
69
78
  };
70
79
  let returnOrderTransaction;
71
80
  try {
@@ -53,26 +53,13 @@ function updateAgent(params) {
53
53
  const newAgent = {
54
54
  typeOf: transaction.agent.typeOf,
55
55
  id: transaction.agent.id
56
- // 不要なので廃止(2022-05-26~)
57
- // ...(Array.isArray(params.agent.additionalProperty)) ? { additionalProperty: params.agent.additionalProperty } : {},
58
- // ...(typeof params.agent.age === 'string') ? { age: params.agent.age } : {},
59
- // ...(typeof params.agent.address === 'string') ? { address: params.agent.address } : {},
60
- // ...(typeof params.agent.email === 'string') ? { email: params.agent.email } : {},
61
- // ...(typeof params.agent.familyName === 'string') ? { familyName: params.agent.familyName } : {},
62
- // ...(typeof params.agent.gender === 'string') ? { gender: params.agent.gender } : {},
63
- // ...(typeof params.agent.givenName === 'string') ? { givenName: params.agent.givenName } : {},
64
- // ...(typeof params.agent.name === 'string') ? { name: params.agent.name } : {},
65
- // ...(typeof formattedTelephone === 'string') ? { telephone: formattedTelephone } : {},
66
- // ...(typeof params.agent.url === 'string') ? { url: params.agent.url } : {}
67
56
  };
68
57
  // 注文取引の場合、object.customerにも適用
69
58
  let customer;
70
59
  if (transaction.typeOf === factory.transactionType.PlaceOrder) {
71
60
  // いったんtransaction.object.customer?.typeOfは取引開始時にセットされている前提
72
61
  if (typeof ((_a = transaction.object.customer) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
73
- customer = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: transaction.object.customer.typeOf, id: transaction.object.customer.id }, (transaction.object.customer.typeOf === factory.organizationType.Organization)
74
- ? { project: transaction.object.customer.project }
75
- : undefined), (Array.isArray(transaction.object.customer.identifier))
62
+ customer = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: transaction.object.customer.typeOf, id: transaction.object.customer.id }, (Array.isArray(transaction.object.customer.identifier))
76
63
  ? { identifier: transaction.object.customer.identifier }
77
64
  : undefined), (transaction.object.customer.typeOf === factory.personType.Person
78
65
  && typeof ((_b = transaction.object.customer.memberOf) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as AccountTransactionIdentifierFactory from './factory/accountTransactionIdentifier';
5
5
  import * as OrderFactory from './factory/order';
6
+ import * as ReservedAgentIdentifireNamesFactory from './factory/reservedAgentIdentifireNames';
6
7
  import * as AccountService from './service/account';
7
8
  import * as AccountTransactionService from './service/accountTransaction';
8
9
  import * as AggregationService from './service/aggregation';
@@ -46,4 +47,5 @@ export import util = UtilService;
46
47
  export declare namespace factory {
47
48
  export import accountTransactionIdentifier = AccountTransactionIdentifierFactory;
48
49
  export import order = OrderFactory;
50
+ export import reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
49
51
  }