@chevre/domain 24.0.0-alpha.77 → 24.0.0-alpha.79

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 (74) hide show
  1. package/lib/chevre/repo/action/actionProcess.d.ts +4 -4
  2. package/lib/chevre/repo/action/authorizeOffer.d.ts +2 -3
  3. package/lib/chevre/repo/action/authorizeOffer.js +2 -2
  4. package/lib/chevre/repo/action.d.ts +2 -2
  5. package/lib/chevre/repo/assetTransaction.d.ts +3 -51
  6. package/lib/chevre/repo/assetTransaction.js +51 -51
  7. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +1 -1
  8. package/lib/chevre/repo/product.d.ts +0 -10
  9. package/lib/chevre/repo/product.js +28 -22
  10. package/lib/chevre/repo/task.d.ts +1 -1
  11. package/lib/chevre/repository.d.ts +0 -5
  12. package/lib/chevre/repository.js +0 -11
  13. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
  14. package/lib/chevre/service/assetTransaction/pay/start/factory.js +7 -7
  15. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +18 -16
  16. package/lib/chevre/service/assetTransaction/refund.js +19 -17
  17. package/lib/chevre/service/assetTransaction/reserve/start.js +8 -8
  18. package/lib/chevre/service/assetTransaction.d.ts +0 -2
  19. package/lib/chevre/service/assetTransaction.js +8 -10
  20. package/lib/chevre/service/delivery/factory.js +13 -13
  21. package/lib/chevre/service/offer/any.d.ts +1 -1
  22. package/lib/chevre/service/offer/event/authorize.js +7 -32
  23. package/lib/chevre/service/offer/product.d.ts +0 -62
  24. package/lib/chevre/service/offer/product.js +0 -409
  25. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.d.ts +1 -1
  26. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +48 -43
  27. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +38 -37
  28. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  29. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  30. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +2 -96
  31. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  32. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
  33. package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +0 -1
  34. package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +3 -28
  35. package/lib/chevre/service/order/placeOrder/factory.js +5 -5
  36. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +1 -1
  37. package/lib/chevre/service/payment/factory.js +23 -23
  38. package/lib/chevre/service/product.js +16 -16
  39. package/lib/chevre/service/reserve/confirmReservation.js +19 -17
  40. package/lib/chevre/service/reserve/factory.d.ts +0 -6
  41. package/lib/chevre/service/reserve/factory.js +0 -59
  42. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +16 -15
  43. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +0 -1
  44. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +2 -2
  45. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +2 -2
  46. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +3 -3
  47. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +16 -12
  48. package/lib/chevre/service/transaction/placeOrder/confirm.js +21 -23
  49. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +0 -21
  50. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +4 -4
  51. package/lib/chevre/service/validation/validateOrder.js +11 -10
  52. package/package.json +2 -2
  53. package/lib/chevre/repo/action/authorizeProductOffer.d.ts +0 -26
  54. package/lib/chevre/repo/action/authorizeProductOffer.js +0 -32
  55. package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +0 -21
  56. package/lib/chevre/service/assetTransaction/registerService/factory.js +0 -171
  57. package/lib/chevre/service/assetTransaction/registerService/potentialActions.d.ts +0 -8
  58. package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +0 -148
  59. package/lib/chevre/service/assetTransaction/registerService.d.ts +0 -54
  60. package/lib/chevre/service/assetTransaction/registerService.js +0 -273
  61. package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.d.ts +0 -15
  62. package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.js +0 -44
  63. package/lib/chevre/service/delivery/product/factory.d.ts +0 -13
  64. package/lib/chevre/service/delivery/product/factory.js +0 -81
  65. package/lib/chevre/service/offer/product/factory.d.ts +0 -37
  66. package/lib/chevre/service/offer/product/factory.js +0 -208
  67. package/lib/chevre/service/task/confirmRegisterService.d.ts +0 -6
  68. package/lib/chevre/service/task/confirmRegisterService.js +0 -19
  69. package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +0 -17
  70. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +0 -116
  71. package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +0 -6
  72. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +0 -23
  73. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +0 -8
  74. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +0 -89
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validatePrice = validatePrice;
4
4
  const factory_1 = require("../../../../../factory");
5
- function validatePrice(authorizePaymentActions, authorizeEventServiceOfferActions, authorizeProductOfferActions) {
5
+ function validatePrice(authorizePaymentActions, authorizeEventServiceOfferActions) {
6
6
  let priceByAgent = 0;
7
7
  let priceBySeller = 0;
8
8
  // 決済承認を確認
@@ -19,7 +19,7 @@ function validatePrice(authorizePaymentActions, authorizeEventServiceOfferAction
19
19
  // 販売者が提供するアイテムの発生金額
20
20
  [
21
21
  ...authorizeEventServiceOfferActions,
22
- ...authorizeProductOfferActions
22
+ // ...authorizeProductOfferActions
23
23
  ].forEach(({ id, result }) => {
24
24
  const priceByAction = result?.price;
25
25
  if (typeof priceByAction === 'number' && priceByAction >= 0) {
@@ -1,11 +1,11 @@
1
1
  import { factory } from '../../../../factory';
2
2
  import { placeOrder as PlaceOrderFactory } from '../../../../factory/transaction';
3
- import { IAcceptPayAction, IAuthorizeEventServiceOffer, IAuthorizePaymentAction, IAuthorizeProductOffer, IPayTransaction } from './validation/factory';
4
- export { IAcceptPayAction, IAuthorizeEventServiceOffer, IAuthorizePaymentAction, IAuthorizeProductOffer, IPayTransaction };
3
+ import { IAcceptPayAction, IAuthorizeEventServiceOffer, IAuthorizePaymentAction, IPayTransaction } from './validation/factory';
4
+ export { IAcceptPayAction, IAuthorizeEventServiceOffer, IAuthorizePaymentAction, IPayTransaction };
5
5
  /**
6
6
  * 取引が確定可能な状態かどうかをチェックする
7
7
  */
8
- export declare function validateTransaction(transaction: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'object'>, acceptPayActions: IAcceptPayAction[], authorizePaymentActions: IAuthorizePaymentAction[], authorizeEventServiceOfferActions: Pick<IAuthorizeEventServiceOffer, 'id' | 'result'>[], authorizeProductOfferActions: Pick<IAuthorizeProductOffer, 'id' | 'result'>[], eventReservationAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IReservation>[], payTransactions: IPayTransaction[], customer: factory.order.ICustomer): void;
8
+ export declare function validateTransaction(transaction: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'object'>, acceptPayActions: IAcceptPayAction[], authorizePaymentActions: IAuthorizePaymentAction[], authorizeEventServiceOfferActions: Pick<IAuthorizeEventServiceOffer, 'id' | 'result'>[], eventReservationAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IReservation>[], payTransactions: IPayTransaction[], customer: factory.order.ICustomer): void;
9
9
  export type IOrderURLGenerator = (order: factory.order.IOrder) => string;
10
10
  /**
11
11
  * 注文オファー数検証
@@ -21,10 +21,12 @@ const debug = (0, debug_1.default)('chevre-domain:service:transaction');
21
21
  /**
22
22
  * 取引が確定可能な状態かどうかをチェックする
23
23
  */
24
- function validateTransaction(transaction, acceptPayActions, authorizePaymentActions, authorizeEventServiceOfferActions, authorizeProductOfferActions, eventReservationAcceptedOffers, payTransactions, customer) {
24
+ function validateTransaction(transaction, acceptPayActions, authorizePaymentActions, authorizeEventServiceOfferActions,
25
+ // authorizeProductOfferActions: Pick<IAuthorizeProductOffer, 'id' | 'result'>[],
26
+ eventReservationAcceptedOffers, payTransactions, customer) {
25
27
  // validateProfile(transaction);
26
28
  validateProfile({ customer });
27
- (0, validatePrice_1.validatePrice)(authorizePaymentActions, authorizeEventServiceOfferActions, authorizeProductOfferActions);
29
+ (0, validatePrice_1.validatePrice)(authorizePaymentActions, authorizeEventServiceOfferActions);
28
30
  // 請求のreferencesOrder検証(2025-11-23~)
29
31
  (0, validateInvoiceReferencesOrder_1.validateInvoiceReferencesOrder)(authorizePaymentActions, eventReservationAcceptedOffers);
30
32
  // 利用可能な通貨単位に対して取引検証
@@ -155,16 +157,18 @@ function validatePaymentUrl(transaction, acceptPayActions, authorizePaymentActio
155
157
  /**
156
158
  * JPY以外の通貨について取引を検証する
157
159
  */
158
- function validateMonetaryAmount(authorizePaymentActions, authorizeEventServiceOfferActions) {
159
- const authorizeMonetaryAmountActions = authorizePaymentActions.filter(({ result }) => {
160
- const resultAsInvoice = (Array.isArray(result))
161
- // ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
162
- ? result[0]
163
- : undefined;
164
- // JPY以外の通貨に対して承認可能なのはPaymentServiceType.PaymentCardのみ
165
- return resultAsInvoice?.issuedThrough.typeOf === factory_1.factory.service.paymentService.PaymentServiceType.PaymentCard
166
- && resultAsInvoice.totalPaymentDue?.currency !== factory_1.factory.priceCurrency.JPY;
167
- });
160
+ function validateMonetaryAmount(_authorizePaymentActions, authorizeEventServiceOfferActions) {
161
+ // PaymentCard決済を廃止したので、JPY以外の通貨に対しての承認はありえない(2026-04-18~)
162
+ const authorizeMonetaryAmountActions = [];
163
+ // const authorizeMonetaryAmountActions = authorizePaymentActions.filter(({ result }) => {
164
+ // const resultAsInvoice = (Array.isArray(result))
165
+ // // ? result.find(({ typeOf }) => typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
166
+ // ? result[0]
167
+ // : undefined;
168
+ // // JPY以外の通貨に対して承認可能なのはPaymentServiceType.PaymentCardのみ
169
+ // return resultAsInvoice?.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.PaymentCard
170
+ // && resultAsInvoice.totalPaymentDue?.currency !== factory.priceCurrency.JPY;
171
+ // });
168
172
  const requiredMonetaryAmountByCurrencyType = [];
169
173
  authorizeEventServiceOfferActions.forEach((a) => {
170
174
  const amount = a.result?.amount;
@@ -95,7 +95,9 @@ function confirm(params, options) {
95
95
  }
96
96
  const {
97
97
  // acceptedOffersFromAuthorizeAction, // discontinue(2024-06-17~)
98
- authorizePaymentActions, authorizeEventServiceOfferActions, authorizeProductOfferActions, serialNumbers } = dissolveAuthorizeActions(completedAuthorizeActions);
98
+ authorizePaymentActions, authorizeEventServiceOfferActions,
99
+ // authorizeProductOfferActions,
100
+ serialNumbers } = dissolveAuthorizeActions(completedAuthorizeActions);
99
101
  // orderInTransactionから検索する(2024-03-04~)
100
102
  const acceptedOffers = (await repos.orderInTransaction.findAcceptedOffersByOrderNumber({ orderNumber: { $eq: orderNumber } }))
101
103
  .filter(({ serialNumber }) => typeof serialNumber === 'string' && serialNumbers.includes(serialNumber));
@@ -118,7 +120,8 @@ function confirm(params, options) {
118
120
  ...params,
119
121
  orderNumber, transaction,
120
122
  acceptPayActions,
121
- authorizePaymentActions, authorizeEventServiceOfferActions, authorizeProductOfferActions,
123
+ authorizePaymentActions, authorizeEventServiceOfferActions,
124
+ // authorizeProductOfferActions,
122
125
  acceptedOffers, payTransactions, customer,
123
126
  ...(typeof code === 'string') ? { code } : undefined
124
127
  }, options);
@@ -217,20 +220,12 @@ function dissolveAuthorizeActions(completedAuthorizeActions) {
217
220
  // const acceptedOffersFromAuthorizeAction: IOrderAcceptedOffer[] = []; // discontinue(2024-06-17~)
218
221
  const authorizePaymentActions = [];
219
222
  const authorizeEventServiceOfferActions = [];
220
- const authorizeProductOfferActions = [];
223
+ // const authorizeProductOfferActions: IAuthorizeProductOffer[] = [];
221
224
  const serialNumbers = [];
222
225
  completedAuthorizeActions.forEach((a) => {
223
226
  let serialNumber;
224
227
  if (Array.isArray(a.object)) {
225
228
  throw new factory_1.factory.errors.NotImplemented('authorizeAction object as an array discontinued.'); // discontinue(2026-03-13~)
226
- // if (
227
- // a.object.length > 0
228
- // && a.object.every(({ typeOf }) => typeOf === factory.offerType.Offer)
229
- // && a.object.every(({ itemOffered }) => availableProductTypes.indexOf(itemOffered.typeOf) >= 0)
230
- // ) {
231
- // authorizeProductOfferActions.push(<IAuthorizeProductOffer>a);
232
- // serialNumber = (<IAuthorizeProductOffer>a).instrument.transactionNumber;
233
- // }
234
229
  }
235
230
  else {
236
231
  if (a.object.typeOf === factory_1.factory.action.authorize.offer.eventService.ObjectType.SeatReservation) {
@@ -241,10 +236,11 @@ function dissolveAuthorizeActions(completedAuthorizeActions) {
241
236
  }
242
237
  serialNumber = assetTransactionNumber;
243
238
  }
244
- else if (a.object.typeOf === factory_1.factory.action.authorize.offer.product.ObjectType.AggregateOffer
245
- && a.instrument?.typeOf === factory_1.factory.assetTransactionType.RegisterService) {
246
- authorizeProductOfferActions.push(a);
247
- serialNumber = a.instrument.transactionNumber;
239
+ else if (a.object.typeOf === 'AggregateOffer'
240
+ && a.instrument?.typeOf === 'RegisterService') {
241
+ throw new factory_1.factory.errors.NotImplemented('authorizeAction instrument as RegisterService discontinued.'); // discontinue(2026-03-13~)
242
+ // authorizeProductOfferActions.push((a as IAuthorizeProductOffer));
243
+ // serialNumber = a.instrument.transactionNumber;
248
244
  }
249
245
  else if (a.object.typeOf === factory_1.factory.action.authorize.paymentMethod.any.ResultType.Payment) {
250
246
  authorizePaymentActions.push(a);
@@ -258,7 +254,7 @@ function dissolveAuthorizeActions(completedAuthorizeActions) {
258
254
  return {
259
255
  authorizePaymentActions,
260
256
  authorizeEventServiceOfferActions,
261
- authorizeProductOfferActions,
257
+ // authorizeProductOfferActions,
262
258
  serialNumbers
263
259
  };
264
260
  }
@@ -288,7 +284,7 @@ function createReservationIdsResult(order, acceptedOffers) {
288
284
  function createResult(params, options) {
289
285
  const transaction = params.transaction;
290
286
  const eventReservationAcceptedOffers = [];
291
- const productAcceptedOffers = [];
287
+ // const productAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IPermit>[] = [];
292
288
  // const moneyTransferAcceptedOffers: factory.order.IAcceptedOffer<factory.order.IMoneyTransfer>[] = [];
293
289
  params.acceptedOffers.forEach((acceptedOffer) => {
294
290
  const itemOfferedTypeOf = acceptedOffer.itemOffered.typeOf;
@@ -296,19 +292,21 @@ function createResult(params, options) {
296
292
  case factory_1.factory.reservationType.EventReservation:
297
293
  eventReservationAcceptedOffers.push(acceptedOffer);
298
294
  break;
299
- case factory_1.factory.permit.PermitType.Permit:
300
- productAcceptedOffers.push(acceptedOffer);
301
- break;
295
+ // case factory.permit.PermitType.Permit:
296
+ // productAcceptedOffers.push((acceptedOffer as factory.order.IAcceptedOffer<factory.order.IPermit>));
297
+ // break;
302
298
  default:
303
299
  throw new factory_1.factory.errors.NotImplemented(`${itemOfferedTypeOf} not implemented`);
304
300
  }
305
301
  });
306
302
  // 取引の確定条件が全て整っているかどうか確認
307
- (0, validation_1.validateTransaction)(transaction, params.acceptPayActions, params.authorizePaymentActions, params.authorizeEventServiceOfferActions, params.authorizeProductOfferActions, eventReservationAcceptedOffers, params.payTransactions, params.customer);
303
+ (0, validation_1.validateTransaction)(transaction, params.acceptPayActions, params.authorizePaymentActions, params.authorizeEventServiceOfferActions,
304
+ // params.authorizeProductOfferActions,
305
+ eventReservationAcceptedOffers, params.payTransactions, params.customer);
308
306
  const { paymentMethods, price } = (0, factory_2.createPaymentMethods)({ authorizePaymentActions: params.authorizePaymentActions });
309
307
  const orderedItem = (0, orderedItem_1.acceptedOffers2orderedItem)({
310
308
  eventReservationAcceptedOffers,
311
- productAcceptedOffers,
309
+ // productAcceptedOffers,
312
310
  // moneyTransferAcceptedOffers
313
311
  });
314
312
  // 注文作成
@@ -348,7 +346,7 @@ function createResult(params, options) {
348
346
  const authorizeActions = [
349
347
  ...params.authorizePaymentActions.map(({ id }) => ({ id })),
350
348
  ...params.authorizeEventServiceOfferActions.map(({ id }) => ({ id })),
351
- ...params.authorizeProductOfferActions.map(({ id }) => ({ id }))
349
+ // ...params.authorizeProductOfferActions.map(({ id }) => ({ id }))
352
350
  ];
353
351
  let eventId;
354
352
  let reservationIds;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createTasks = createTasks;
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  const factory_1 = require("../../../../factory");
9
- // | factory.task.IAttributes<factory.taskName.VoidRegisterServiceTransaction>;
10
9
  /**
11
10
  * 取引のタスクを作成する
12
11
  */
@@ -192,26 +191,6 @@ function createTasks(params, setting
192
191
  else {
193
192
  taskAttributes.push(voidReserveTaskAttributes, voidPaymentTaskAttributes);
194
193
  }
195
- // eslint-disable-next-line no-warning-comments
196
- // TODO reimplement
197
- // temporarily discontinue VoidRegisterServiceTransaction VoidMoneyTransferTransaction(2025-02-25~)
198
- // const voidRegisterServiceTaskAttributes: factory.task.IAttributes<factory.taskName.VoidRegisterServiceTransaction> = {
199
- // project: transaction.project,
200
- // name: factory.taskName.VoidRegisterServiceTransaction,
201
- // status: factory.taskStatus.Ready,
202
- // runsAt: taskRunsAt,
203
- // remainingNumberOfTries: 10,
204
- // numberOfTried: 0,
205
- // executionResults: [],
206
- // data: {
207
- // project: transaction.project,
208
- // purpose: { typeOf: transaction.typeOf, id: transaction.id }
209
- // }
210
- // };
211
- // taskAttributes.push(
212
- // voidRegisterServiceTaskAttributes,
213
- // voidMoneyTransferTaskAttributes
214
- // );
215
194
  break;
216
195
  default:
217
196
  throw new factory_1.factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
@@ -4,7 +4,6 @@ exports.createPotentialActions = createPotentialActions;
4
4
  const factory_1 = require("../../../factory");
5
5
  // import { Settings } from '../../../settings';
6
6
  const returnPaymentMethod_1 = require("./potentialActions/returnPaymentMethod");
7
- const returnPointAward_1 = require("./potentialActions/returnPointAward");
8
7
  const sendEmailMessage_1 = require("./potentialActions/sendEmailMessage");
9
8
  async function createPotentialActions(params,
10
9
  // settings: Settings
@@ -24,8 +23,9 @@ setting) {
24
23
  ...(returnOrderActionParams !== undefined) ? { returnOrderActionParams } : undefined
25
24
  }, setting);
26
25
  emailMessages.push(...emailMessagesOnReturnInvoice);
27
- // ポイント特典の数だけ、返却アクションを作成
28
- const returnPointAwardActions = await (0, returnPointAward_1.createReturnPointAwardActions)({ ...params, order });
26
+ // discontinue(2026-04-18~)
27
+ // // ポイント特典の数だけ、返却アクションを作成
28
+ // const returnPointAwardActions = await createReturnPointAwardActions({ ...params, order });
29
29
  // 返品後のEメール送信アクション
30
30
  const { emailMessagesOnReturn, sendEmailMessaegActionsOnReturn } = await (0, sendEmailMessage_1.createSendEmailMessaegActionsOnReturn)({
31
31
  ...params,
@@ -35,7 +35,7 @@ setting) {
35
35
  emailMessages.push(...emailMessagesOnReturn);
36
36
  const potentialActionsOnReturnOrder = {
37
37
  returnPaymentMethod: returnPaymentMethodActions,
38
- returnPointAward: returnPointAwardActions,
38
+ // returnPointAward: returnPointAwardActions, // discontinue(2026-04-18~)
39
39
  sendEmailMessage: sendEmailMessaegActionsOnReturn
40
40
  };
41
41
  const returnOrderObject = {
@@ -8,7 +8,7 @@ exports.validateOrder = validateOrder;
8
8
  const moment_1 = __importDefault(require("moment"));
9
9
  const factory_1 = require("../../factory");
10
10
  const factory_2 = require("../offer/event/authorize/factory");
11
- const factory_3 = require("../offer/product/factory");
11
+ // import { acceptedOffers2amount as acceptedOffers2amount4product } from '../offer/product/factory';
12
12
  const validateMovieTicket_1 = require("../transaction/placeOrder/confirm/validation/validateMovieTicket");
13
13
  // const debug = createDebug('chevre-domain:service:validation');
14
14
  // type ICreatingCheckEventTask = Pick<
@@ -104,7 +104,8 @@ function validateOrder(params) {
104
104
  // 旧メンバーシップ&ペイメントカードを例外として除外(互換性維持対応をしていないため)
105
105
  if ((0, moment_1.default)(order.orderDate)
106
106
  .isAfter((0, moment_1.default)('2023-09-30T15:00:00Z'))
107
- || typeOf !== factory_1.factory.permit.PermitType.Permit) {
107
+ // || typeOf !== factory.permit.PermitType.Permit
108
+ ) {
108
109
  if (typeof serialNumber !== 'string' || serialNumber.length === 0) {
109
110
  throw new Error(`invalid acceptedOffer.serialNumber [${typeof serialNumber}]`);
110
111
  }
@@ -175,14 +176,14 @@ function validateOrder(params) {
175
176
  }
176
177
  break;
177
178
  }
178
- case factory_1.factory.permit.PermitType.Permit: {
179
- numOrderedItemExpected = acceptedOffers.length;
180
- const permitAcceptedOffers = acceptedOffers;
181
- priceExpected = (0, factory_3.acceptedOffers2amount)({
182
- acceptedOffers: permitAcceptedOffers
183
- });
184
- break;
185
- }
179
+ // case factory.permit.PermitType.Permit: {
180
+ // numOrderedItemExpected = acceptedOffers.length;
181
+ // const permitAcceptedOffers = acceptedOffers as factory.order.IAcceptedOffer<factory.order.IPermit>[];
182
+ // priceExpected = acceptedOffers2amount4product({
183
+ // acceptedOffers: permitAcceptedOffers
184
+ // });
185
+ // break;
186
+ // }
186
187
  // case factory.actionType.MoneyTransfer:
187
188
  // break;
188
189
  default:
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "7.0.0",
14
+ "@chevre/factory": "8.0.0-alpha.1",
15
15
  "@motionpicture/coa-service": "10.0.0",
16
16
  "@motionpicture/gmo-service": "6.0.0",
17
17
  "@sendgrid/client": "8.1.4",
@@ -91,5 +91,5 @@
91
91
  "postversion": "git push origin --tags",
92
92
  "prepublishOnly": "npm run clean && npm run build"
93
93
  },
94
- "version": "24.0.0-alpha.77"
94
+ "version": "24.0.0-alpha.79"
95
95
  }
@@ -1,26 +0,0 @@
1
- import { factory } from '../../factory';
2
- import { ActionProcessRepo } from './actionProcess';
3
- export type IAuthorizeProductOfferAction = factory.action.authorize.offer.product.IAction;
4
- /**
5
- * プロダクトオファー承認リポジトリ
6
- */
7
- export declare class AuthorizeProductOfferActionRepo extends ActionProcessRepo<IAuthorizeProductOfferAction, never> {
8
- /**
9
- * 取引に対するプロダクトオファー承認アクションを検索する
10
- */
11
- findAuthorizeProductOfferActionsByPurpose(params: {
12
- /**
13
- * 注文取引でフィルター
14
- */
15
- purpose: {
16
- typeOf: factory.transactionType;
17
- id: string;
18
- };
19
- /**
20
- * アクションステータスでフィルター
21
- */
22
- actionStatus?: {
23
- $eq?: factory.actionStatusType.CompletedActionStatus;
24
- };
25
- }): Promise<IAuthorizeProductOfferAction[]>;
26
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthorizeProductOfferActionRepo = void 0;
4
- const factory_1 = require("../../factory");
5
- // import { MONGO_MAX_TIME_MS } from '../settings';
6
- const availableProductTypes_1 = require("../../factory/availableProductTypes");
7
- const actionProcess_1 = require("./actionProcess");
8
- /**
9
- * プロダクトオファー承認リポジトリ
10
- */
11
- class AuthorizeProductOfferActionRepo extends actionProcess_1.ActionProcessRepo {
12
- /**
13
- * 取引に対するプロダクトオファー承認アクションを検索する
14
- */
15
- async findAuthorizeProductOfferActionsByPurpose(params) {
16
- const authorizeActions = await this.findAnyActionsByPurpose({
17
- ...params,
18
- typeOf: factory_1.factory.actionType.AuthorizeAction,
19
- object: {
20
- typeOf: { $eq: factory_1.factory.action.authorize.offer.eventService.ObjectType.AggregateOffer }
21
- }
22
- });
23
- return authorizeActions.filter((a) =>
24
- // Array.isArray(a.object)
25
- // && a.object.length > 0
26
- // // && a.object[0].typeOf === factory.offerType.Offer
27
- // && availableProductTypes.indexOf(a.object[0].itemOffered.typeOf) >= 0
28
- a.object.typeOf === factory_1.factory.action.authorize.offer.product.ObjectType.AggregateOffer
29
- && availableProductTypes_1.availableProductTypes.indexOf(a.object.itemOffered.typeOf) >= 0);
30
- }
31
- }
32
- exports.AuthorizeProductOfferActionRepo = AuthorizeProductOfferActionRepo;
@@ -1,21 +0,0 @@
1
- import { factory } from '../../../factory';
2
- export type IUnitPriceSpecification = factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.UnitPriceSpecification>;
3
- /**
4
- * ポイント特典を作成する
5
- */
6
- export declare function createPointAward(params: {
7
- acceptedOffer: factory.assetTransaction.registerService.IAcceptedOfferWithoutDetail;
8
- offer: factory.product.ITicketOffer;
9
- }): factory.action.transfer.moneyTransfer.IPointAward | undefined;
10
- /**
11
- * サービスアウトプットを作成する
12
- */
13
- export declare function createServiceOutput(params: {
14
- dateIssued: Date;
15
- product: Pick<factory.product.IProduct, 'id' | 'typeOf' | 'project' | 'serviceOutput' | 'serviceType'> & {
16
- id: string;
17
- };
18
- acceptedOffer: factory.assetTransaction.registerService.IAcceptedOfferWithoutDetail;
19
- offer: factory.product.ITicketOffer;
20
- transactionNumber: string;
21
- }): factory.assetTransaction.registerService.IServiceOutput;
@@ -1,171 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createPointAward = createPointAward;
7
- exports.createServiceOutput = createServiceOutput;
8
- const moment_1 = __importDefault(require("moment"));
9
- const factory_1 = require("../../../factory");
10
- /**
11
- * ポイント特典を作成する
12
- */
13
- function createPointAward(params) {
14
- let pointAward;
15
- const pointAwardAmount = params.offer.itemOffered?.pointAward?.amount;
16
- const pointAwardDescription = params.offer.itemOffered?.pointAward?.description;
17
- const pointAwardToLocation = params.acceptedOffer.itemOffered?.pointAward?.toLocation;
18
- const pointAwardRecipient = params.acceptedOffer.itemOffered?.pointAward?.recipient;
19
- const pointAwardPurposeIdentifier = params.acceptedOffer.itemOffered?.pointAward?.purpose?.identifier;
20
- // オファーのpointAward設定が適切にされていれば、指定されたtoLocationを反映する
21
- if (typeof pointAwardAmount?.value === 'number'
22
- && typeof pointAwardAmount?.currency === 'string'
23
- && typeof pointAwardToLocation?.identifier === 'string'
24
- && typeof pointAwardToLocation?.issuedThrough.id === 'string') {
25
- pointAward = {
26
- amount: pointAwardAmount,
27
- toLocation: {
28
- typeOf: factory_1.factory.permit.PermitType.Permit,
29
- identifier: pointAwardToLocation.identifier,
30
- issuedThrough: { id: pointAwardToLocation.issuedThrough.id }
31
- },
32
- typeOf: factory_1.factory.actionType.MoneyTransfer,
33
- ...(typeof pointAwardDescription === 'string') ? { description: pointAwardDescription } : undefined,
34
- ...(pointAwardRecipient !== undefined) ? { recipient: pointAwardRecipient } : undefined,
35
- ...(typeof pointAwardPurposeIdentifier === 'string') ? { purpose: { identifier: pointAwardPurposeIdentifier } } : undefined
36
- };
37
- }
38
- return pointAward;
39
- }
40
- /**
41
- * サービスアウトプットを作成する
42
- */
43
- function createServiceOutput(params) {
44
- const product = params.product;
45
- const acceptedOffer = params.acceptedOffer;
46
- const serviceOutputType = product.serviceOutput?.typeOf;
47
- if (typeof serviceOutputType !== 'string' || serviceOutputType.length === 0) {
48
- throw new factory_1.factory.errors.NotFound('Product serviceOutput type undefined');
49
- }
50
- const identifier = acceptedOffer.itemOffered?.serviceOutput?.identifier;
51
- if (typeof identifier !== 'string' || identifier.length === 0) {
52
- throw new factory_1.factory.errors.ArgumentNull('object.itemOffered.serviceOutput.identifier');
53
- }
54
- const accessCode = acceptedOffer.itemOffered?.serviceOutput?.accessCode;
55
- const name = acceptedOffer.itemOffered?.serviceOutput?.name;
56
- const additionalProperty = acceptedOffer.itemOffered?.serviceOutput?.additionalProperty;
57
- const issuedBy = acceptedOffer.itemOffered?.serviceOutput?.issuedBy;
58
- const { amount, depositAmount, paymentAmount } = createServiceOutputMonetaryAmount({ product, offer: params.offer });
59
- const validFor = offer2validFor({ offer: params.offer });
60
- // 決済口座
61
- let paymentAccount;
62
- switch (product.typeOf) {
63
- case factory_1.factory.product.ProductType.PaymentCard:
64
- if (typeof accessCode !== 'string' || accessCode.length === 0) {
65
- throw new factory_1.factory.errors.ArgumentNull('object.itemOffered.serviceOutput.accessCode');
66
- }
67
- paymentAccount = {
68
- // 廃止(2023-02-20~)
69
- // project: { typeOf: product.project.typeOf, id: product.project.id },
70
- // ひとまず固定
71
- // 口座は複数のプロダクトに結合する可能性もあり、どのように利用されるかは知らない。ただbalanceを管理するだけ。通貨は知っている。
72
- typeOf: factory_1.factory.accountType.Account,
73
- // ひとまずPermit識別子と口座番号は同一
74
- accountNumber: identifier
75
- // 廃止(2023-02-16~)
76
- // accountType: amount.currency
77
- };
78
- break;
79
- case factory_1.factory.product.ProductType.MembershipService:
80
- break;
81
- // case 'MoneyTransfer':
82
- default:
83
- throw new factory_1.factory.errors.NotImplemented(`Product type ${product.typeOf} not implemented`);
84
- }
85
- const issuedThrough = {
86
- // 廃止(2023-02-20~)
87
- // project: { typeOf: product.project.typeOf, id: product.project.id },
88
- typeOf: product.typeOf,
89
- id: product.id,
90
- ...(typeof product.serviceType?.typeOf === 'string') ? { serviceType: product.serviceType } : undefined
91
- };
92
- return {
93
- project: { typeOf: product.project.typeOf, id: product.project.id },
94
- identifier: identifier,
95
- issuedThrough,
96
- typeOf: serviceOutputType,
97
- dateIssued: params.dateIssued,
98
- ...(typeof accessCode === 'string') ? { accessCode } : undefined,
99
- ...(Array.isArray(additionalProperty)) ? { additionalProperty } : undefined,
100
- ...(typeof validFor === 'string') ? { validFor } : undefined,
101
- ...(name !== undefined) ? { name } : undefined,
102
- ...(amount !== undefined) ? { amount } : undefined,
103
- ...(depositAmount !== undefined) ? { depositAmount } : undefined,
104
- ...(paymentAmount !== undefined) ? { paymentAmount } : undefined,
105
- ...(paymentAccount !== undefined) ? { paymentAccount } : undefined,
106
- ...(issuedBy !== undefined) ? { issuedBy } : undefined
107
- };
108
- }
109
- function createServiceOutputMonetaryAmount(params) {
110
- const product = params.product;
111
- const currency = (typeof product.serviceOutput?.amount?.currency === 'string')
112
- ? product.serviceOutput?.amount.currency
113
- : factory_1.factory.priceCurrency.JPY;
114
- // 初期金額
115
- const amount = {
116
- ...product.serviceOutput?.amount,
117
- ...params.offer.itemOffered?.serviceOutput?.amount,
118
- currency,
119
- typeOf: 'MonetaryAmount'
120
- };
121
- // 入金設定
122
- const depositAmount = {
123
- // ...product.serviceOutput?.depositAmount,
124
- ...params.offer.itemOffered?.serviceOutput?.depositAmount,
125
- currency,
126
- typeOf: 'MonetaryAmount'
127
- };
128
- // 取引設定
129
- const paymentAmount = {
130
- // ...product.serviceOutput?.paymentAmount,
131
- ...params.offer.itemOffered?.serviceOutput?.paymentAmount,
132
- currency,
133
- typeOf: 'MonetaryAmount'
134
- };
135
- return { amount, depositAmount, paymentAmount };
136
- }
137
- function offer2validFor(params) {
138
- let validFor;
139
- // オファーからアウトプットの有効期間を決定
140
- const unitPriceSpec = params.offer.priceSpecification.priceComponent.find((c) => c.typeOf === factory_1.factory.priceSpecificationType.UnitPriceSpecification);
141
- if (unitPriceSpec === undefined) {
142
- throw new factory_1.factory.errors.NotFound(`UnitPriceSpecification for ${params.offer.id}`);
143
- }
144
- // unitPriceSpec.referenceQuantity.value: 'Infinity'に対応
145
- const referenceQuantityValue = unitPriceSpec.referenceQuantity.value;
146
- if (referenceQuantityValue === factory_1.factory.quantitativeValue.StringValue.Infinity) {
147
- // Infinityの場合validForはundefined
148
- }
149
- else if (typeof referenceQuantityValue === 'number') {
150
- switch (unitPriceSpec.referenceQuantity.unitCode) {
151
- case factory_1.factory.unitCode.Ann:
152
- validFor = moment_1.default.duration(referenceQuantityValue, 'years')
153
- .toISOString();
154
- break;
155
- case factory_1.factory.unitCode.Day:
156
- validFor = moment_1.default.duration(referenceQuantityValue, 'days')
157
- .toISOString();
158
- break;
159
- case factory_1.factory.unitCode.Sec:
160
- validFor = moment_1.default.duration(referenceQuantityValue, 'seconds')
161
- .toISOString();
162
- break;
163
- default:
164
- throw new factory_1.factory.errors.NotImplemented(`Reference quantity unit code '${unitPriceSpec.referenceQuantity.unitCode}' not implemented`);
165
- }
166
- }
167
- else {
168
- throw new factory_1.factory.errors.NotImplemented(`Reference quantity value '${referenceQuantityValue}' not implemented`);
169
- }
170
- return validFor;
171
- }
@@ -1,8 +0,0 @@
1
- import { factory } from '../../../factory';
2
- /**
3
- * 取引のポストアクションを作成する
4
- */
5
- export declare function createPotentialActions(params: {
6
- transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.RegisterService>;
7
- endDate?: Date;
8
- }): Promise<factory.assetTransaction.IPotentialActions<factory.assetTransactionType.RegisterService>>;