@chevre/domain 22.2.0-alpha.2 → 22.2.0-alpha.21

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 (86) hide show
  1. package/example/src/chevre/findValidAuthorization.ts +1 -2
  2. package/example/src/chevre/playAroundTicket.ts +3 -2
  3. package/example/src/chevre/{projectReservationFields.ts → projectFields.ts} +10 -8
  4. package/example/src/chevre/{projectReservationFieldsById.ts → projectOwnershipInfoFieldsById.ts} +4 -4
  5. package/example/src/chevre/searchProjects.ts +9 -4
  6. package/example/src/chevre/searchSellersByAggregate.ts +3 -3
  7. package/example/src/chevre/unsetUnnecessaryFields.ts +4 -30
  8. package/lib/chevre/repo/authorization.d.ts +3 -1
  9. package/lib/chevre/repo/authorization.js +21 -10
  10. package/lib/chevre/repo/categoryCode.d.ts +14 -2
  11. package/lib/chevre/repo/categoryCode.js +41 -19
  12. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +1 -1
  13. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +21 -23
  14. package/lib/chevre/repo/mongoose/schemas/paymentService.js +12 -3
  15. package/lib/chevre/repo/mongoose/schemas/product.js +5 -12
  16. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +1 -1
  17. package/lib/chevre/repo/mongoose/schemas/seller.js +21 -23
  18. package/lib/chevre/repo/ownershipInfo.d.ts +10 -6
  19. package/lib/chevre/repo/ownershipInfo.js +75 -19
  20. package/lib/chevre/repo/paymentService.d.ts +2 -2
  21. package/lib/chevre/repo/paymentService.js +108 -58
  22. package/lib/chevre/repo/paymentServiceProvider.d.ts +1 -10
  23. package/lib/chevre/repo/product.d.ts +2 -2
  24. package/lib/chevre/repo/product.js +67 -33
  25. package/lib/chevre/repo/project.d.ts +4 -4
  26. package/lib/chevre/repo/project.js +69 -28
  27. package/lib/chevre/repo/seller.d.ts +10 -12
  28. package/lib/chevre/repo/seller.js +61 -27
  29. package/lib/chevre/repo/ticket.d.ts +3 -2
  30. package/lib/chevre/repo/ticket.js +23 -10
  31. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -1
  32. package/lib/chevre/service/aggregation/event/findEventOffers.js +1 -1
  33. package/lib/chevre/service/aggregation/project.js +1 -1
  34. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -2
  35. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  36. package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
  37. package/lib/chevre/service/assetTransaction/pay/factory.js +1 -1
  38. package/lib/chevre/service/assetTransaction/pay.js +3 -3
  39. package/lib/chevre/service/assetTransaction/refund/factory.d.ts +1 -1
  40. package/lib/chevre/service/assetTransaction/refund/factory.js +1 -1
  41. package/lib/chevre/service/assetTransaction/refund.js +3 -3
  42. package/lib/chevre/service/assetTransaction/registerService.js +4 -6
  43. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +26 -23
  44. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +4 -1
  45. package/lib/chevre/service/assetTransaction/reserve/start.js +1 -3
  46. package/lib/chevre/service/code.d.ts +0 -4
  47. package/lib/chevre/service/code.js +21 -17
  48. package/lib/chevre/service/event.js +3 -3
  49. package/lib/chevre/service/moneyTransfer.js +2 -4
  50. package/lib/chevre/service/notification.js +1 -1
  51. package/lib/chevre/service/offer/event/authorize/factory.js +34 -6
  52. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.d.ts +0 -2
  53. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +22 -22
  54. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +0 -2
  55. package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
  56. package/lib/chevre/service/offer/event/importFromCOA/factory.d.ts +3 -1
  57. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  58. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +4 -12
  59. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  60. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
  61. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -3
  62. package/lib/chevre/service/offer/product.d.ts +1 -1
  63. package/lib/chevre/service/offer/product.js +4 -6
  64. package/lib/chevre/service/order/sendOrder.js +9 -5
  65. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +1 -6
  66. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +26 -34
  67. package/lib/chevre/service/payment/any.d.ts +3 -3
  68. package/lib/chevre/service/payment/any.js +15 -7
  69. package/lib/chevre/service/payment/paymentCard.js +1 -3
  70. package/lib/chevre/service/report/ownershipInfo.d.ts +3 -1
  71. package/lib/chevre/service/task/authorizePayment.js +0 -2
  72. package/lib/chevre/service/task/onAuthorizationCreated.js +20 -16
  73. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +2 -2
  74. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  75. package/lib/chevre/service/task/onResourceUpdated.js +2 -2
  76. package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
  77. package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
  78. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +1 -1
  79. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +36 -2
  80. package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
  81. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +2 -2
  82. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +1 -1
  83. package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +2 -2
  84. package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
  85. package/package.json +3 -3
  86. package/example/src/chevre/searchProducts.ts +0 -28
@@ -13,6 +13,13 @@ exports.TicketRepo = void 0;
13
13
  const factory = require("../factory");
14
14
  const settings_1 = require("../settings");
15
15
  const ticket_1 = require("./mongoose/schemas/ticket");
16
+ const AVAILABLE_PROJECT_FIELDS = [
17
+ 'project',
18
+ 'typeOf',
19
+ 'ticketToken',
20
+ 'dateIssued',
21
+ 'issuedBy'
22
+ ];
16
23
  /**
17
24
  * チケットリポジトリ
18
25
  */
@@ -41,6 +48,7 @@ class TicketRepo {
41
48
  * 承認コードからチケットを発行する
42
49
  */
43
50
  issueByTicketToken(params) {
51
+ var _a, _b;
44
52
  return __awaiter(this, void 0, void 0, function* () {
45
53
  const { ticketToken, project, issuedBy } = params;
46
54
  const ticketIssuedBy = (typeof (issuedBy === null || issuedBy === void 0 ? void 0 : issuedBy.id) === 'string' && issuedBy.typeOf === factory.organizationType.Corporation)
@@ -53,19 +61,24 @@ class TicketRepo {
53
61
  ticketToken,
54
62
  typeOf: 'Ticket'
55
63
  };
56
- const doc = yield this.ticketModel.create(creatingTicket);
57
- return { id: doc.id };
64
+ const result = yield this.ticketModel.insertMany(creatingTicket, { rawResult: true });
65
+ const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
66
+ if (typeof insertedId !== 'string') {
67
+ throw new factory.errors.Internal(`ticket not saved unexpectedly. result:${JSON.stringify(result)}`);
68
+ }
69
+ return { id: insertedId };
58
70
  });
59
71
  }
60
- search(params) {
72
+ projectFields(params, inclusion) {
61
73
  var _a;
62
74
  return __awaiter(this, void 0, void 0, function* () {
63
75
  const conditions = TicketRepo.CREATE_MONGO_CONDITIONS(params);
64
- const query = this.ticketModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
65
- // __v: 0,
66
- // createdAt: 0,
67
- // updatedAt: 0
68
- });
76
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
77
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
78
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
79
+ }
80
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
81
+ const query = this.ticketModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
69
82
  if (typeof params.limit === 'number' && params.limit > 0) {
70
83
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
71
84
  query.limit(params.limit)
@@ -75,8 +88,8 @@ class TicketRepo {
75
88
  query.sort({ dateIssued: params.sort.dateIssued });
76
89
  }
77
90
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
78
- .exec()
79
- .then((docs) => docs.map((doc) => doc.toObject()));
91
+ .lean() // 2024-08-20~
92
+ .exec();
80
93
  });
81
94
  }
82
95
  }
@@ -165,7 +165,7 @@ function calculateOfferCount(params) {
165
165
  try {
166
166
  const eventOffers = params.event.offers;
167
167
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
168
- const eventService = (yield repos.product.searchProducts({
168
+ const eventService = (yield repos.product.projectFields({
169
169
  limit: 1,
170
170
  page: 1,
171
171
  id: { $eq: eventOffers.itemOffered.id }
@@ -23,7 +23,7 @@ function findEventOffers(params) {
23
23
  // 興行設定があれば興行のカタログを参照する
24
24
  const eventOffers = params.event.offers;
25
25
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
26
- const eventService = (yield repos.product.searchProducts({
26
+ const eventService = (yield repos.product.projectFields({
27
27
  limit: 1,
28
28
  page: 1,
29
29
  id: { $eq: eventOffers.itemOffered.id }
@@ -23,7 +23,7 @@ function aggregate(params) {
23
23
  // 集計対象プロジェクト検索
24
24
  const project = yield repos.project.findById({
25
25
  id: params.project.id,
26
- inclusion: ['_id', 'typeOf'],
26
+ inclusion: ['typeOf'],
27
27
  exclusion: []
28
28
  });
29
29
  // 予約集計
@@ -85,7 +85,7 @@ function start(params) {
85
85
  return (repos) => __awaiter(this, void 0, void 0, function* () {
86
86
  const project = yield repos.project.findById({
87
87
  id: params.project.id,
88
- inclusion: ['_id', 'typeOf'],
88
+ inclusion: ['typeOf'],
89
89
  exclusion: []
90
90
  });
91
91
  const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
@@ -141,7 +141,7 @@ function startAndConfirm(params) {
141
141
  return (repos) => __awaiter(this, void 0, void 0, function* () {
142
142
  const project = yield repos.project.findById({
143
143
  id: params.project.id,
144
- inclusion: ['_id', 'typeOf'],
144
+ inclusion: ['typeOf'],
145
145
  exclusion: []
146
146
  });
147
147
  const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
@@ -28,7 +28,7 @@ function start(params) {
28
28
  var _a;
29
29
  const issuedThroughId = fixIssuedThroughId(params);
30
30
  // location.issuedThroughIdからプロダクトをfixする
31
- const products = yield repos.product.searchProducts({
31
+ const products = yield repos.product.projectFields({
32
32
  limit: 1,
33
33
  page: 1,
34
34
  project: { id: { $eq: params.project.id } },
@@ -6,6 +6,6 @@ export declare function createStartParams(params: factory.assetTransaction.pay.I
6
6
  transactionNumber: string;
7
7
  paymentServiceType: factory.service.paymentService.PaymentServiceType;
8
8
  amount: number;
9
- paymentService?: factory.service.paymentService.IService | factory.product.IProduct;
9
+ paymentService?: Pick<factory.service.paymentService.IService, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'> | Pick<factory.product.IProduct, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'>;
10
10
  location?: factory.action.trade.pay.ILocation;
11
11
  }): factory.assetTransaction.IStartParams<factory.assetTransactionType.Pay>;
@@ -74,7 +74,7 @@ function createStartParams(params) {
74
74
  else if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.CreditCard) {
75
75
  const creditCardPaymentServiceOutput = (_l = params.paymentService) === null || _l === void 0 ? void 0 : _l.serviceOutput;
76
76
  const invoiceAsServiceOutput = (Array.isArray(creditCardPaymentServiceOutput))
77
- ? creditCardPaymentServiceOutput.find((output) => output.typeOf === 'Invoice')
77
+ ? creditCardPaymentServiceOutput.find((output) => (output === null || output === void 0 ? void 0 : output.typeOf) === 'Invoice')
78
78
  : creditCardPaymentServiceOutput;
79
79
  // カード通貨区分が存在すれば適用
80
80
  if ((invoiceAsServiceOutput === null || invoiceAsServiceOutput === void 0 ? void 0 : invoiceAsServiceOutput.typeOf) === 'Invoice') {
@@ -268,7 +268,7 @@ function fixPaymentService(params) {
268
268
  break;
269
269
  // PaymentCardの場合、プロダクト検索
270
270
  case factory.service.paymentService.PaymentServiceType.PaymentCard:
271
- paymentService = (yield repos.product.searchProducts({
271
+ paymentService = (yield repos.product.projectFields({
272
272
  limit: 1,
273
273
  page: 1,
274
274
  project: { id: { $eq: params.project.id } },
@@ -280,13 +280,13 @@ function fixPaymentService(params) {
280
280
  }
281
281
  break;
282
282
  default:
283
- paymentService = (yield repos.paymentService.searchPaymentServices({
283
+ paymentService = (yield repos.paymentService.projectFields({
284
284
  limit: 1,
285
285
  page: 1,
286
286
  project: { id: { $eq: params.project.id } },
287
287
  typeOf: { $eq: paymentServiceType },
288
288
  id: { $eq: getPaymentServiceId(params) }
289
- }, [], [])).shift();
289
+ }, ['availableChannel', 'serviceOutput', 'serviceType'], [])).shift();
290
290
  if (paymentService === undefined) {
291
291
  throw new factory.errors.NotFound('PaymentService');
292
292
  }
@@ -6,5 +6,5 @@ export declare function createStartParams(params: factory.assetTransaction.refun
6
6
  transactionNumber: string;
7
7
  paymentServiceType: factory.service.paymentService.PaymentServiceType;
8
8
  payAction: factory.action.trade.pay.IAction;
9
- paymentService?: factory.product.IProduct | factory.service.paymentService.IService;
9
+ paymentService?: factory.product.IProduct | Pick<factory.service.paymentService.IService, 'availableChannel' | 'id' | 'typeOf' | 'serviceOutput'>;
10
10
  }): factory.assetTransaction.IStartParams<factory.assetTransactionType.Refund>;
@@ -24,7 +24,7 @@ function createStartParams(params) {
24
24
  if (((_g = params.paymentService) === null || _g === void 0 ? void 0 : _g.typeOf) === factory.service.paymentService.PaymentServiceType.CreditCard) {
25
25
  // カード通貨区分の存在する決済サービスを考慮(2023-08-09~)
26
26
  const invoiceAsServiceOutput = (Array.isArray(params.paymentService.serviceOutput))
27
- ? params.paymentService.serviceOutput.find((output) => output.typeOf === 'Invoice')
27
+ ? params.paymentService.serviceOutput.find((output) => (output === null || output === void 0 ? void 0 : output.typeOf) === 'Invoice')
28
28
  : params.paymentService.serviceOutput;
29
29
  let paymentServiceOutputAmountCurrency;
30
30
  if ((invoiceAsServiceOutput === null || invoiceAsServiceOutput === void 0 ? void 0 : invoiceAsServiceOutput.typeOf) === 'Invoice') {
@@ -86,7 +86,7 @@ function fixPaymentService(params) {
86
86
  break;
87
87
  // PaymentCardの場合、プロダクト検索
88
88
  case factory.service.paymentService.PaymentServiceType.PaymentCard:
89
- paymentService = (yield repos.product.searchProducts({
89
+ paymentService = (yield repos.product.projectFields({
90
90
  limit: 1,
91
91
  page: 1,
92
92
  project: { id: { $eq: params.payAction.project.id } },
@@ -98,13 +98,13 @@ function fixPaymentService(params) {
98
98
  }
99
99
  break;
100
100
  default:
101
- paymentService = (yield repos.paymentService.searchPaymentServices({
101
+ paymentService = (yield repos.paymentService.projectFields({
102
102
  limit: 1,
103
103
  page: 1,
104
104
  project: { id: { $eq: params.payAction.project.id } },
105
105
  typeOf: { $eq: params.paymentServiceType },
106
106
  id: { $eq: paymentServiceId }
107
- }, [], [])).shift();
107
+ }, ['availableChannel', 'serviceOutput', 'typeOf'], [])).shift();
108
108
  if (paymentService === undefined) {
109
109
  throw new factory.errors.NotFound('PaymentService');
110
110
  }
@@ -27,7 +27,7 @@ function start(params) {
27
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
28
  const project = yield repos.project.findById({
29
29
  id: params.project.id,
30
- inclusion: ['_id', 'typeOf'],
30
+ inclusion: ['typeOf'],
31
31
  exclusion: []
32
32
  });
33
33
  // objectはオファー
@@ -44,8 +44,7 @@ function start(params) {
44
44
  throw new factory.errors.ArgumentNull('object.itemOffered.id');
45
45
  }
46
46
  // プロダクト確認
47
- // const product = await repos.product.findProductById({ id: productId }, [], []);
48
- const product = (yield repos.product.searchProducts({
47
+ const product = (yield repos.product.projectFields({
49
48
  limit: 1,
50
49
  page: 1,
51
50
  id: { $eq: productId }
@@ -138,12 +137,11 @@ function createTransactionObject(params) {
138
137
  function createPermitService(params) {
139
138
  return (repos) => __awaiter(this, void 0, void 0, function* () {
140
139
  var _a, _b, _c, _d, _e, _f, _g;
141
- // const product = await repos.product.findProductById({ id: params.issuedThrough.id }, [], []);
142
- const product = (yield repos.product.searchProducts({
140
+ const product = (yield repos.product.projectFields({
143
141
  limit: 1,
144
142
  page: 1,
145
143
  id: { $eq: params.issuedThrough.id }
146
- }, [], [])).shift();
144
+ }, ['availableChannel'], [])).shift();
147
145
  if (product === undefined) {
148
146
  throw new factory.errors.NotFound('Product');
149
147
  }
@@ -53,6 +53,7 @@ function createSubReservations(params) {
53
53
  });
54
54
  const programMembershipUsed = yield validateProgramMembershipUsed({
55
55
  acceptedOffer,
56
+ availableOffer: ticketType,
56
57
  project: { id: params.event.project.id }
57
58
  })(repos);
58
59
  // チケット作成
@@ -273,7 +274,7 @@ function validateAdvanceBookingRequirement(params) {
273
274
  function validateProgramMembershipUsed(params) {
274
275
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
275
276
  return (repos) => __awaiter(this, void 0, void 0, function* () {
276
- var _a, _b, _c, _d, _e, _f;
277
+ var _a, _b, _c, _d, _e, _f, _g, _h;
277
278
  const now = new Date();
278
279
  let programMembershipUsed;
279
280
  const requestedProgramMembershipUsed = (_b = (_a = params.acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed;
@@ -293,12 +294,12 @@ function validateProgramMembershipUsed(params) {
293
294
  if (typeof issuedThroughId !== 'string' || issuedThroughId === '') {
294
295
  throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
295
296
  }
296
- permitIssuedThrough = (yield repos.product.searchProducts({
297
+ permitIssuedThrough = (yield repos.product.projectFields({
297
298
  limit: 1,
298
299
  page: 1,
299
300
  id: { $eq: issuedThroughId },
300
301
  typeOf: { $eq: factory.product.ProductType.MembershipService }
301
- }, ['_id', 'typeOf', 'project', 'serviceType', 'serviceOutput'], [])).shift();
302
+ }, ['typeOf', 'project', 'serviceType', 'serviceOutput'], [])).shift();
302
303
  if (permitIssuedThrough === undefined) {
303
304
  throw new factory.errors.NotFound(factory.product.ProductType.MembershipService);
304
305
  }
@@ -308,12 +309,12 @@ function validateProgramMembershipUsed(params) {
308
309
  if (typeof issuedThroughId !== 'string' || issuedThroughId === '') {
309
310
  throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
310
311
  }
311
- permitIssuedThrough = (yield repos.paymentService.searchPaymentServices({
312
+ permitIssuedThrough = (yield repos.paymentService.projectFields({
312
313
  limit: 1,
313
314
  page: 1,
314
315
  id: { $eq: issuedThroughId },
315
316
  typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard }
316
- }, ['_id', 'typeOf', 'project', 'serviceType', 'serviceOutput'], [])).shift();
317
+ }, ['typeOf', 'project', 'serviceType', 'serviceOutput'], [])).shift();
317
318
  if (permitIssuedThrough === undefined) {
318
319
  throw new factory.errors.NotFound(factory.service.paymentService.PaymentServiceType.CreditCard);
319
320
  }
@@ -329,32 +330,36 @@ function validateProgramMembershipUsed(params) {
329
330
  }
330
331
  switch (permitIssuedThrough.typeOf) {
331
332
  case factory.service.paymentService.PaymentServiceType.FaceToFace:
332
- // 問答無用に受け入れる
333
- programMembershipUsed = {
334
- typeOf: factory.permit.PermitType.Permit,
335
- identifier: programMembershipUsedIdentifier,
336
- issuedThrough: {
337
- typeOf: permitIssuedThrough.typeOf
338
- }
339
- };
333
+ // 適用メンバーシップ条件有のオファーであれば、問答無用に受け入れる
334
+ const eligibleMembershipType = (_g = (_f = params.availableOffer.eligibleMembershipType) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.codeValue;
335
+ if (typeof eligibleMembershipType === 'string') {
336
+ programMembershipUsed = {
337
+ typeOf: factory.programMembership.ProgramMembershipType.ProgramMembership,
338
+ identifier: programMembershipUsedIdentifier,
339
+ issuedThrough: {
340
+ serviceType: { codeValue: eligibleMembershipType },
341
+ typeOf: permitIssuedThrough.typeOf
342
+ }
343
+ };
344
+ }
340
345
  break;
341
346
  // 発行サービスがCreditCardのケースに対応(2023-09-01~)
342
347
  case factory.service.paymentService.PaymentServiceType.CreditCard:
343
348
  // 決済サービスのserviceOutputにPermitが存在すれば、設定されたメンバーシップ区分のPermitをprogramMembershipUsedとして適用する
344
349
  let issuedThroughServiceType;
345
350
  if (Array.isArray(permitIssuedThrough.serviceOutput)) {
346
- const serviceOutputAsPermit = permitIssuedThrough.serviceOutput.find((output) => output.typeOf === factory.permit.PermitType.Permit);
351
+ const serviceOutputAsPermit = permitIssuedThrough.serviceOutput.find((output) => (output === null || output === void 0 ? void 0 : output.typeOf) === factory.permit.PermitType.Permit);
347
352
  if ((serviceOutputAsPermit === null || serviceOutputAsPermit === void 0 ? void 0 : serviceOutputAsPermit.typeOf) === factory.permit.PermitType.Permit) {
348
353
  issuedThroughServiceType = serviceOutputAsPermit.issuedThrough.serviceType;
349
354
  }
350
355
  }
351
- if ((issuedThroughServiceType === null || issuedThroughServiceType === void 0 ? void 0 : issuedThroughServiceType.typeOf) === 'CategoryCode') {
356
+ if (typeof (issuedThroughServiceType === null || issuedThroughServiceType === void 0 ? void 0 : issuedThroughServiceType.codeValue) === 'string') {
352
357
  programMembershipUsed = {
353
- typeOf: factory.permit.PermitType.Permit,
358
+ typeOf: factory.programMembership.ProgramMembershipType.ProgramMembership,
354
359
  identifier: programMembershipUsedIdentifier,
355
360
  issuedThrough: {
356
361
  id: permitIssuedThrough.id,
357
- serviceType: issuedThroughServiceType,
362
+ serviceType: { codeValue: issuedThroughServiceType.codeValue },
358
363
  typeOf: permitIssuedThrough.typeOf
359
364
  }
360
365
  };
@@ -383,13 +388,13 @@ function validateProgramMembershipUsed(params) {
383
388
  .isBefore(moment(now))) {
384
389
  throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'unavailable programMembership');
385
390
  }
386
- if (((_f = permitIssuedThrough.serviceType) === null || _f === void 0 ? void 0 : _f.typeOf) === 'CategoryCode') {
391
+ if (((_h = permitIssuedThrough.serviceType) === null || _h === void 0 ? void 0 : _h.typeOf) === 'CategoryCode') {
387
392
  programMembershipUsed = {
388
- typeOf: serviceOutput.typeOf,
393
+ typeOf: factory.programMembership.ProgramMembershipType.ProgramMembership,
389
394
  identifier: programMembershipUsedIdentifier,
390
395
  issuedThrough: {
391
396
  id: permitIssuedThrough.id,
392
- serviceType: permitIssuedThrough.serviceType,
397
+ serviceType: { codeValue: permitIssuedThrough.serviceType.codeValue },
393
398
  typeOf: permitIssuedThrough.typeOf
394
399
  }
395
400
  };
@@ -405,9 +410,7 @@ function validateProgramMembershipUsed(params) {
405
410
  function createPermitService(params) {
406
411
  return (repos) => __awaiter(this, void 0, void 0, function* () {
407
412
  var _a, _b, _c, _d, _e, _f, _g;
408
- // const product = <Pick<factory.product.IProduct, 'availableChannel'>>
409
- // await repos.product.findProductById({ id: params.issuedThrough.id }, ['availableChannel'], []);
410
- const product = (yield repos.product.searchProducts({
413
+ const product = (yield repos.product.projectFields({
411
414
  limit: 1,
412
415
  page: 1,
413
416
  id: { $eq: params.issuedThrough.id }
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateAppliesToMovieTicket = exports.createReservedTicket = exports.createReservation = exports.createAdditionalTicketText = exports.createAdditionalProperty = void 0;
4
+ const createDebug = require("debug");
4
5
  const moment = require("moment");
5
6
  const util = require("util");
6
7
  const factory = require("../../../../../factory");
7
8
  const price_1 = require("./price");
9
+ const debug = createDebug('chevre-domain:service:assetTransaction');
8
10
  function createTicketIdentifier(params) {
9
11
  var _a, _b, _c, _d;
10
12
  // チケット識別子の規定値を作成
@@ -193,11 +195,12 @@ function validateEligibleSubReservation(params) {
193
195
  }
194
196
  }
195
197
  function validateEligibleMembershipType(params) {
198
+ debug('validateEligibleMembershipType: validating...', JSON.stringify(params.programMembershipUsed), JSON.stringify(params.availableOffer.eligibleMembershipType));
196
199
  const programMembershipUsed = params.programMembershipUsed;
197
200
  // 使用メンバーシップがeligibleMembershipに含まれればよい
198
201
  const eligibleMembershipType = params.availableOffer.eligibleMembershipType;
199
202
  if (Array.isArray(eligibleMembershipType)) {
200
- if ((programMembershipUsed === null || programMembershipUsed === void 0 ? void 0 : programMembershipUsed.typeOf) !== factory.permit.PermitType.Permit) {
203
+ if ((programMembershipUsed === null || programMembershipUsed === void 0 ? void 0 : programMembershipUsed.typeOf) !== factory.programMembership.ProgramMembershipType.ProgramMembership) {
201
204
  throw new factory.errors.Argument('programMembershipUsed', 'programMembership required');
202
205
  }
203
206
  const { identifier, issuedThrough } = programMembershipUsed;
@@ -405,9 +405,7 @@ function getAcceptedSeatNumbersAndSeatSections(params) {
405
405
  function createPermitService(params) {
406
406
  return (repos) => __awaiter(this, void 0, void 0, function* () {
407
407
  var _a, _b, _c, _d, _e, _f, _g;
408
- // const product = <Pick<factory.product.IProduct, 'availableChannel'>>
409
- // await repos.product.findProductById({ id: params.issuedThrough.id }, ['availableChannel'], []);
410
- const product = (yield repos.product.searchProducts({
408
+ const product = (yield repos.product.projectFields({
411
409
  limit: 1,
412
410
  page: 1,
413
411
  id: { $eq: params.issuedThrough.id }
@@ -35,10 +35,6 @@ declare function getToken(params: {
35
35
  * jtw.payload.aud
36
36
  */
37
37
  audience: string;
38
- /**
39
- * payload.jtiを使用するかどうか
40
- */
41
- useJti: boolean;
42
38
  }): (repos: {
43
39
  authorization: AuthorizationRepo;
44
40
  ticket: TicketRepo;
@@ -39,22 +39,26 @@ function getToken(params) {
39
39
  if (typeof params.issuer !== 'string' || params.issuer.length === 0) {
40
40
  throw new factory.errors.ArgumentNull('issuer');
41
41
  }
42
- let subject = authorization.id;
43
- let typ = `${credentials.jwt.payloadTypPrefix}:${authorization.typeOf}`;
42
+ let subject;
43
+ let typ;
44
44
  let jti;
45
- if (params.useJti) {
46
- const { id } = yield repos.ticket.issueByTicketToken(Object.assign({ project: { id: params.project.id }, ticketToken: params.code }, (typeof ((_a = authorization.issuedBy) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { issuedBy: authorization.issuedBy } : undefined));
47
- jti = id;
48
- // ロール承認の場合、subjectはメンバーID,typはメンバータイプ
49
- if (authorization.object.typeOf === factory.iam.RoleType.OrganizationRole) {
50
- subject = authorization.object.member.id;
51
- typ = `${credentials.jwt.payloadTypPrefix}:${authorization.object.member.typeOf}`;
52
- }
53
- else {
54
- // useJtiの場合、subject,typはagent(2024-05-09~)
55
- subject = params.agent.id;
56
- typ = `${credentials.jwt.payloadTypPrefix}:${params.agent.typeOf}`;
57
- }
45
+ // let subject: string = authorization.id;
46
+ // let typ: string = `${credentials.jwt.payloadTypPrefix}:${authorization.typeOf}`;
47
+ // jti必須化(2024-08-22~)
48
+ // let jti: string | undefined;
49
+ // if (params.useJti) {
50
+ // }
51
+ const { id } = yield repos.ticket.issueByTicketToken(Object.assign({ project: { id: params.project.id }, ticketToken: params.code }, (typeof ((_a = authorization.issuedBy) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { issuedBy: authorization.issuedBy } : undefined));
52
+ jti = id;
53
+ // ロール承認の場合、subjectはメンバーID,typはメンバータイプ
54
+ if (authorization.object.typeOf === factory.iam.RoleType.OrganizationRole) {
55
+ subject = authorization.object.member.id;
56
+ typ = `${credentials.jwt.payloadTypPrefix}:${authorization.object.member.typeOf}`;
57
+ }
58
+ else {
59
+ // useJtiの場合、subject,typはagent(2024-05-09~)
60
+ subject = params.agent.id;
61
+ typ = `${credentials.jwt.payloadTypPrefix}:${params.agent.typeOf}`;
58
62
  }
59
63
  const payload = {
60
64
  // sub: authorization.id, // 拡張(2024-05-01~)
@@ -110,12 +114,12 @@ function payload2authorizeObject(params) {
110
114
  // }
111
115
  if (typeof payload.jti === 'string') {
112
116
  // jtiに対応(2024-05-08~)
113
- const ticket = (yield repos.ticket.search({
117
+ const ticket = (yield repos.ticket.projectFields({
114
118
  limit: 1,
115
119
  page: 1,
116
120
  project: { id: { $eq: params.project.id } },
117
121
  id: { $eq: payload.jti }
118
- })).shift();
122
+ }, ['ticketToken'])).shift();
119
123
  if (ticket === undefined) {
120
124
  throw new factory.errors.NotFound('Ticket');
121
125
  }
@@ -162,12 +162,12 @@ function processUpdateMovieTheater(params) {
162
162
  let processTime;
163
163
  try {
164
164
  // 同ブランチコードの販売者を検索する
165
- const sellersWithSameBranchCode = yield repos.seller.search({
165
+ const sellersWithSameBranchCode = yield repos.seller.projectFields({
166
166
  limit: 1,
167
167
  page: 1,
168
168
  project: { id: { $eq: params.project.id } },
169
169
  branchCode: { $eq: params.locationBranchCode }
170
- }, ['_id'], []);
170
+ }, ['id'], []);
171
171
  const sellerWithSameBranchCode = sellersWithSameBranchCode.shift();
172
172
  if (typeof (sellerWithSameBranchCode === null || sellerWithSameBranchCode === void 0 ? void 0 : sellerWithSameBranchCode.id) !== 'string') {
173
173
  throw new factory.errors.NotFound('Seller', `Seller with branchCode '${params.locationBranchCode}' not found`);
@@ -236,7 +236,7 @@ function saveScreeningEventSeries(params) {
236
236
  kubunClass: '043'
237
237
  });
238
238
  debug('kubunNames found.');
239
- const availablePaymentMethodTypes = yield repos.categoryCode.search({
239
+ const availablePaymentMethodTypes = yield repos.categoryCode.projectFields({
240
240
  project: { id: { $eq: params.project.id } },
241
241
  inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
242
242
  }, ['additionalProperty', 'codeValue'], []);
@@ -24,7 +24,7 @@ function authorize(params) {
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
25
  const project = yield repos.project.findById({
26
26
  id: params.project.id,
27
- inclusion: ['_id', 'settings', 'typeOf'],
27
+ inclusion: ['settings', 'typeOf'],
28
28
  exclusion: []
29
29
  });
30
30
  const transaction = yield repos.assetTransaction.findById({
@@ -329,9 +329,7 @@ function getIssuedThroughIdByAction(params) {
329
329
  function createPermitServiceCredentials(params) {
330
330
  return (repos) => __awaiter(this, void 0, void 0, function* () {
331
331
  var _a, _b, _c, _d, _e, _f, _g;
332
- // const paymentCardService = <Pick<factory.product.IProduct, 'availableChannel'>>
333
- // await repos.product.findProductById({ id: params.issuedThrough.id }, ['availableChannel'], []);
334
- const paymentCardService = (yield repos.product.searchProducts({
332
+ const paymentCardService = (yield repos.product.projectFields({
335
333
  limit: 1,
336
334
  page: 1,
337
335
  id: { $eq: params.issuedThrough.id },
@@ -30,7 +30,7 @@ function sendEmailMessage(params) {
30
30
  var _a, _b, _c, _d, _e;
31
31
  const project = yield repos.project.findById({
32
32
  id: params.project.id,
33
- inclusion: ['_id', 'settings'],
33
+ inclusion: ['settings'],
34
34
  exclusion: []
35
35
  });
36
36
  const action = yield repos.action.start(createSendEmailMessageActionAttributes(params));
@@ -137,15 +137,45 @@ function acceptedOffers2amount(params) {
137
137
  return amount;
138
138
  }
139
139
  exports.acceptedOffers2amount = acceptedOffers2amount;
140
+ function acceptedOffers2programMembershipUsed(params) {
141
+ const programMembershipUsed = [];
142
+ const permitIdentifiers = [];
143
+ params.acceptedOffers.forEach(({ itemOffered }) => {
144
+ var _a;
145
+ if (((_a = itemOffered.programMembershipUsed) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.programMembership.ProgramMembershipType.ProgramMembership) {
146
+ // メンバーシップコードに対してユニークに集計
147
+ if (!permitIdentifiers.includes(itemOffered.programMembershipUsed.identifier)) {
148
+ permitIdentifiers.push(itemOffered.programMembershipUsed.identifier);
149
+ const issuedThroughTypeOf = itemOffered.programMembershipUsed.issuedThrough.typeOf;
150
+ if (issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
151
+ programMembershipUsed.push({
152
+ typeOf: factory.permit.PermitType.Permit,
153
+ identifier: itemOffered.programMembershipUsed.identifier,
154
+ issuedThrough: { typeOf: issuedThroughTypeOf }
155
+ });
156
+ }
157
+ else {
158
+ programMembershipUsed.push({
159
+ typeOf: factory.permit.PermitType.Permit,
160
+ identifier: itemOffered.programMembershipUsed.identifier,
161
+ issuedThrough: { typeOf: issuedThroughTypeOf, id: itemOffered.programMembershipUsed.issuedThrough.id }
162
+ });
163
+ }
164
+ }
165
+ }
166
+ });
167
+ return programMembershipUsed;
168
+ }
140
169
  function acceptedOffers2authorizeResult(params) {
141
170
  const { acceptedOffers, acceptedOffers4result, noOfferSpecified, ticketOffers } = params;
142
- // const priceCurrency = acceptedOffers[0]?.priceSpecification?.priceCurrency;
143
171
  const priceCurrency = factory.priceCurrency.JPY; // fix(2024-07-03~)
144
172
  // redefine as typeOf: AggregateOffer(2024-06-18~)
145
173
  let offers;
146
174
  let price;
175
+ let programMembershipUsed = [];
147
176
  if (!noOfferSpecified) {
148
177
  price = acceptedOffers2amount({ acceptedOffers: acceptedOffers4result }); // オファー指定の場合のみ金額計算(2023-11-27~)
178
+ programMembershipUsed = acceptedOffers2programMembershipUsed({ acceptedOffers: acceptedOffers4result });
149
179
  // オファーIDごとに集計
150
180
  const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
151
181
  offers = offerIds.map((offerId) => {
@@ -153,10 +183,6 @@ function acceptedOffers2authorizeResult(params) {
153
183
  if (acceptedOffer === undefined) {
154
184
  throw new factory.errors.Internal(`acceptedOffer not found [id:${offerId}]`);
155
185
  }
156
- // const acceptedOffer = acceptedOffers.find(({ id }) => id === offerId);
157
- // if (acceptedOffer === undefined) {
158
- // throw new factory.errors.Internal(`acceptedOffer not found [id:${offerId}]`);
159
- // }
160
186
  const amountOfThisGood = acceptedOffers.filter(({ id }) => id === offerId).length;
161
187
  const { acceptedPaymentMethod, priceSpecification } = acceptedOffer;
162
188
  const unitPriceSpec = priceSpecification.priceComponent.find((spec) => spec.typeOf === factory.priceSpecificationType.UnitPriceSpecification
@@ -169,7 +195,9 @@ function acceptedOffers2authorizeResult(params) {
169
195
  return Object.assign({ id: offerId, includesObject: { amountOfThisGood }, typeOf: factory.offerType.Offer, priceSpecification: Object.assign(Object.assign({}, (eligibleQuantity !== undefined) ? { eligibleQuantity } : undefined), (eligibleTransactionVolume !== undefined) ? { eligibleTransactionVolume } : undefined) }, (acceptedPaymentMethod !== undefined) ? { acceptedPaymentMethod } : undefined);
170
196
  });
171
197
  }
172
- return Object.assign(Object.assign({ typeOf: factory.offerType.AggregateOffer, priceCurrency, amount: [] }, (typeof price === 'number') ? { price } : undefined), (Array.isArray(offers)) ? { offers } : undefined);
198
+ return Object.assign(Object.assign({ typeOf: factory.offerType.AggregateOffer, priceCurrency, amount: [], itemOffered: {
199
+ serviceOutput: { programMembershipUsed } // add programMembershipUsed required(2024-08-15~)
200
+ } }, (typeof price === 'number') ? { price } : undefined), (Array.isArray(offers)) ? { offers } : undefined);
173
201
  }
174
202
  exports.acceptedOffers2authorizeResult = acceptedOffers2authorizeResult;
175
203
  function responseBody2acceptedOffers4result(params) {
@@ -2,7 +2,6 @@ import * as factory from '../../../../../factory';
2
2
  import type { JWTCredentials } from '../../../../../credentials/jwt';
3
3
  import type { ActionRepo } from '../../../../../repo/action';
4
4
  import type { AuthorizationRepo } from '../../../../../repo/authorization';
5
- import type { OwnershipInfoRepo } from '../../../../../repo/ownershipInfo';
6
5
  import type { TicketRepo } from '../../../../../repo/ticket';
7
6
  /**
8
7
  * チケット化された適用メンバーシップをPermitに変換する
@@ -18,7 +17,6 @@ declare function requestedProgramMembershipUsed2permit(params: {
18
17
  }): (repos: {
19
18
  action: ActionRepo;
20
19
  authorization: AuthorizationRepo;
21
- ownershipInfo: OwnershipInfoRepo;
22
20
  ticket: TicketRepo;
23
21
  }, credentials: {
24
22
  jwt: JWTCredentials;