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

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 (169) hide show
  1. package/example/src/chevre/createProject.ts +19 -0
  2. package/example/src/chevre/migrateDeleteTransactionTasks.ts +1 -1
  3. package/example/src/chevre/projectFields.ts +6 -7
  4. package/example/src/chevre/{projectEventFieldsById.ts → projectFieldsById.ts} +6 -11
  5. package/example/src/chevre/searchTransactions.ts +1 -1
  6. package/example/src/chevre/unsetUnnecessaryFields.ts +2 -15
  7. package/lib/chevre/repo/accountTitle.d.ts +9 -3
  8. package/lib/chevre/repo/accountingReport.d.ts +2 -15
  9. package/lib/chevre/repo/action.d.ts +55 -3
  10. package/lib/chevre/repo/aggregateReservation.d.ts +1 -14
  11. package/lib/chevre/repo/assetTransaction.d.ts +134 -7
  12. package/lib/chevre/repo/assetTransaction.js +2 -2
  13. package/lib/chevre/repo/categoryCode.d.ts +4 -0
  14. package/lib/chevre/repo/categoryCode.js +6 -0
  15. package/lib/chevre/repo/comment.d.ts +5 -1
  16. package/lib/chevre/repo/creativeWork.d.ts +14 -2
  17. package/lib/chevre/repo/customer.d.ts +5 -1
  18. package/lib/chevre/repo/customerType.d.ts +1 -1
  19. package/lib/chevre/repo/event.d.ts +49 -2
  20. package/lib/chevre/repo/member.d.ts +5 -1
  21. package/lib/chevre/repo/merchantReturnPolicy.d.ts +22 -2
  22. package/lib/chevre/repo/message.d.ts +1 -15
  23. package/lib/chevre/repo/mongoose/schemas/account.d.ts +8 -3
  24. package/lib/chevre/repo/mongoose/schemas/account.js +1 -1
  25. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +8 -3
  26. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +2 -2
  27. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +8 -3
  28. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
  29. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +22 -3
  30. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -1
  31. package/lib/chevre/repo/mongoose/schemas/action.d.ts +12 -3
  32. package/lib/chevre/repo/mongoose/schemas/action.js +1 -1
  33. package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +14 -3
  34. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +2 -5
  35. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +8 -3
  36. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +12 -12
  37. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +11 -3
  38. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +1 -1
  39. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +22 -3
  40. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +1 -1
  41. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +7 -3
  42. package/lib/chevre/repo/mongoose/schemas/aggregation.js +2 -1
  43. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +10 -3
  44. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +1 -1
  45. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +8 -3
  46. package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
  47. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +8 -3
  48. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -1
  49. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +8 -3
  50. package/lib/chevre/repo/mongoose/schemas/comments.js +1 -1
  51. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +10 -3
  52. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +2 -2
  53. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +8 -3
  54. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -1
  55. package/lib/chevre/repo/mongoose/schemas/customerType.d.ts +9 -3
  56. package/lib/chevre/repo/mongoose/schemas/customerType.js +1 -1
  57. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +8 -3
  58. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -1
  59. package/lib/chevre/repo/mongoose/schemas/event.d.ts +19 -3
  60. package/lib/chevre/repo/mongoose/schemas/event.js +1 -1
  61. package/lib/chevre/repo/mongoose/schemas/member.d.ts +8 -3
  62. package/lib/chevre/repo/mongoose/schemas/member.js +1 -1
  63. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +8 -3
  64. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -1
  65. package/lib/chevre/repo/mongoose/schemas/message.d.ts +23 -3
  66. package/lib/chevre/repo/mongoose/schemas/message.js +1 -1
  67. package/lib/chevre/repo/mongoose/schemas/note.d.ts +8 -3
  68. package/lib/chevre/repo/mongoose/schemas/note.js +1 -1
  69. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +12 -3
  70. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -1
  71. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +12 -3
  72. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +1 -1
  73. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +8 -3
  74. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +1 -1
  75. package/lib/chevre/repo/mongoose/schemas/order.d.ts +10 -3
  76. package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
  77. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +10 -3
  78. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -1
  79. package/lib/chevre/repo/mongoose/schemas/paymentService.d.ts +10 -3
  80. package/lib/chevre/repo/mongoose/schemas/paymentService.js +1 -1
  81. package/lib/chevre/repo/mongoose/schemas/place.d.ts +16 -3
  82. package/lib/chevre/repo/mongoose/schemas/place.js +1 -1
  83. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +11 -3
  84. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -1
  85. package/lib/chevre/repo/mongoose/schemas/product.d.ts +12 -3
  86. package/lib/chevre/repo/mongoose/schemas/product.js +1 -1
  87. package/lib/chevre/repo/mongoose/schemas/productModel.d.ts +30 -3
  88. package/lib/chevre/repo/mongoose/schemas/productModel.js +1 -1
  89. package/lib/chevre/repo/mongoose/schemas/project.d.ts +12 -3
  90. package/lib/chevre/repo/mongoose/schemas/project.js +3 -3
  91. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +12 -3
  92. package/lib/chevre/repo/mongoose/schemas/reservation.js +5 -5
  93. package/lib/chevre/repo/mongoose/schemas/role.d.ts +9 -3
  94. package/lib/chevre/repo/mongoose/schemas/role.js +1 -1
  95. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +8 -3
  96. package/lib/chevre/repo/mongoose/schemas/seller.js +1 -1
  97. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +8 -3
  98. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +1 -1
  99. package/lib/chevre/repo/mongoose/schemas/task.d.ts +8 -3
  100. package/lib/chevre/repo/mongoose/schemas/task.js +1 -1
  101. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +7 -3
  102. package/lib/chevre/repo/mongoose/schemas/telemetry.js +2 -1
  103. package/lib/chevre/repo/mongoose/schemas/ticket.d.ts +26 -3
  104. package/lib/chevre/repo/mongoose/schemas/ticket.js +1 -1
  105. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +8 -3
  106. package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -2
  107. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +8 -3
  108. package/lib/chevre/repo/mongoose/schemas/trip.js +3 -3
  109. package/lib/chevre/repo/offer.d.ts +13 -4
  110. package/lib/chevre/repo/offerCatalog.d.ts +15 -2
  111. package/lib/chevre/repo/order.d.ts +13 -1
  112. package/lib/chevre/repo/ownershipInfo.d.ts +13 -1
  113. package/lib/chevre/repo/place/movieTheater.d.ts +54 -2
  114. package/lib/chevre/repo/priceSpecification.d.ts +42 -1
  115. package/lib/chevre/repo/product.d.ts +6 -1
  116. package/lib/chevre/repo/productModel.d.ts +1 -22
  117. package/lib/chevre/repo/project.d.ts +21 -1
  118. package/lib/chevre/repo/project.js +2 -2
  119. package/lib/chevre/repo/reservation.d.ts +35 -3
  120. package/lib/chevre/repo/reservation.js +1 -1
  121. package/lib/chevre/repo/role.d.ts +2 -9
  122. package/lib/chevre/repo/role.js +20 -10
  123. package/lib/chevre/repo/seller.d.ts +54 -2
  124. package/lib/chevre/repo/task.d.ts +64 -3
  125. package/lib/chevre/repo/telemetry.d.ts +3 -2
  126. package/lib/chevre/repo/ticket.d.ts +2 -19
  127. package/lib/chevre/repo/transaction.d.ts +30 -14
  128. package/lib/chevre/repo/transaction.js +106 -77
  129. package/lib/chevre/service/assetTransaction/cancelReservation.d.ts +1 -1
  130. package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -3
  131. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +3 -2
  132. package/lib/chevre/service/offer/event/authorize.d.ts +1 -1
  133. package/lib/chevre/service/offer/event/authorize.js +1 -1
  134. package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
  135. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +1 -1
  136. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.d.ts +2 -2
  137. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.d.ts +3 -3
  138. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +2 -2
  139. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +4 -2
  140. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +1 -1
  141. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
  142. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +8 -5
  143. package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.d.ts +1 -1
  144. package/lib/chevre/service/offer/moneyTransfer/authorize.js +1 -1
  145. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
  146. package/lib/chevre/service/offer/product.js +2 -2
  147. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
  148. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  149. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  150. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  151. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  152. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +1 -1
  153. package/lib/chevre/service/order/returnOrder.js +1 -1
  154. package/lib/chevre/service/payment/any.js +5 -5
  155. package/lib/chevre/service/payment.d.ts +1 -1
  156. package/lib/chevre/service/report/telemetry.js +2 -2
  157. package/lib/chevre/service/task/onResourceUpdated.js +14 -2
  158. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  159. package/lib/chevre/service/transaction/deleteTransaction.js +2 -2
  160. package/lib/chevre/service/transaction/moneyTransfer.js +3 -3
  161. package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
  162. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
  163. package/lib/chevre/service/transaction/placeOrder/start.js +1 -1
  164. package/lib/chevre/service/transaction/returnOrder.js +2 -2
  165. package/lib/chevre/service/transaction.js +1 -1
  166. package/package.json +3 -3
  167. package/example/src/chevre/findTransactionById.ts +0 -23
  168. package/example/src/chevre/findTransactionInProgressById.ts +0 -23
  169. package/example/src/chevre/migrateTransactionObjectPaymentMethods.ts +0 -154
@@ -15,6 +15,23 @@ const transaction_1 = require("../eventEmitter/transaction");
15
15
  const factory = require("../factory");
16
16
  const settings_1 = require("../settings");
17
17
  const transaction_2 = require("./mongoose/schemas/transaction");
18
+ const AVAILABLE_PROJECT_FIELDS = [
19
+ 'project',
20
+ 'status',
21
+ 'typeOf',
22
+ 'agent',
23
+ 'recipient',
24
+ 'seller',
25
+ 'error',
26
+ 'result',
27
+ 'object',
28
+ 'expires',
29
+ 'startDate',
30
+ 'endDate',
31
+ 'tasksExportAction',
32
+ 'potentialActions',
33
+ 'instrument'
34
+ ];
18
35
  /**
19
36
  * 取引リポジトリ
20
37
  */
@@ -263,8 +280,6 @@ class TransactionRepo {
263
280
  throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
264
281
  }
265
282
  // reimplemnt with insertMany(2024-05-30~)
266
- // const transaction = await this.transactionModel.create<AnyKeys<factory.transaction.ITransaction<T>>>(creatingTransaction)
267
- // .then((doc: HydratedDocument<factory.transaction.ITransaction<T>>) => doc.toObject());
268
283
  const result = yield this.transactionModel.insertMany(creatingTransaction, { rawResult: true });
269
284
  const id = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
270
285
  if (typeof id !== 'string') {
@@ -278,59 +293,73 @@ class TransactionRepo {
278
293
  /**
279
294
  * 特定取引検索
280
295
  */
281
- findById(params, inclusion // make required(2024-05-31~)
282
- // exclusion?: IKeyOfProjection<T>[] // discontinue(2024-06-17~)
296
+ projectFieldsById(params, inclusion // make required(2024-05-31~)
283
297
  ) {
284
298
  return __awaiter(this, void 0, void 0, function* () {
285
- let projection = {};
299
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
286
300
  if (Array.isArray(inclusion) && inclusion.length > 0) {
287
- inclusion.forEach((field) => {
288
- projection[field] = 1;
289
- });
301
+ positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(key));
290
302
  }
291
303
  else {
292
- projection = {
293
- __v: 0,
294
- createdAt: 0,
295
- updatedAt: 0
296
- };
297
- // if (Array.isArray(exclusion) && exclusion.length > 0) { // discontinue(2024-06-17~)
298
- // exclusion.forEach((field) => {
299
- // projection[field] = 0;
300
- // });
301
- // }
304
+ throw new factory.errors.NotImplemented('inclusion must be specified'); // 2024-08-26~
302
305
  }
306
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
307
+ // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
308
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
309
+ // inclusion.forEach((field) => {
310
+ // projection[field] = 1;
311
+ // });
312
+ // } else {
313
+ // projection = {
314
+ // __v: 0,
315
+ // createdAt: 0,
316
+ // updatedAt: 0
317
+ // };
318
+ // }
303
319
  const doc = yield this.transactionModel.findOne({
304
320
  _id: { $eq: params.id },
305
321
  typeOf: { $eq: params.typeOf }
306
- })
307
- .select(projection)
322
+ }, projection)
323
+ .lean() // 2024-08-26~
308
324
  .exec();
309
325
  if (doc === null) {
310
326
  throw new factory.errors.NotFound(this.transactionModel.modelName);
311
327
  }
312
- return doc.toObject();
328
+ return doc;
313
329
  });
314
330
  }
315
331
  /**
316
332
  * 進行中の取引を取得する
317
333
  */
318
- findInProgressById(params, inclusion // make required(2024-05-29~)
334
+ projectFieldsInProgressById(params, inclusion // make required(2024-05-29~)
319
335
  ) {
320
336
  return __awaiter(this, void 0, void 0, function* () {
321
- let projection = {};
337
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
322
338
  if (Array.isArray(inclusion) && inclusion.length > 0) {
323
- inclusion.forEach((field) => {
324
- projection[field] = 1;
325
- });
339
+ positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(key));
326
340
  }
327
341
  else {
328
- // minimize(2024-05-29~)
329
- projection = Object.assign({ __v: 0, createdAt: 0, updatedAt: 0, tasksExportAction: 0 }, {
330
- tasksExportedAt: 0,
331
- tasksExportationStatus: 0
332
- });
342
+ throw new factory.errors.NotImplemented('inclusion must be specified'); // 2024-08-26~
333
343
  }
344
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
345
+ // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: ProjectionElementType } = {};
346
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
347
+ // inclusion.forEach((field) => {
348
+ // projection[field] = 1;
349
+ // });
350
+ // } else {
351
+ // // minimize(2024-05-29~)
352
+ // projection = {
353
+ // __v: 0,
354
+ // createdAt: 0,
355
+ // updatedAt: 0,
356
+ // tasksExportAction: 0,
357
+ // ...{
358
+ // tasksExportedAt: 0,
359
+ // tasksExportationStatus: 0
360
+ // }
361
+ // };
362
+ // }
334
363
  const filter = {
335
364
  _id: { $eq: params.id },
336
365
  typeOf: { $eq: params.typeOf },
@@ -339,11 +368,12 @@ class TransactionRepo {
339
368
  expires: { $gt: new Date() }
340
369
  };
341
370
  const doc = yield this.transactionModel.findOne(filter, projection)
371
+ .lean() // 2024-08-26~
342
372
  .exec();
343
373
  if (doc === null) {
344
374
  throw new factory.errors.NotFound(this.transactionModel.modelName);
345
375
  }
346
- return doc.toObject();
376
+ return doc;
347
377
  });
348
378
  }
349
379
  /**
@@ -356,11 +386,12 @@ class TransactionRepo {
356
386
  typeOf: { $eq: factory.transactionType.PlaceOrder },
357
387
  status: { $eq: factory.transactionStatusType.InProgress }
358
388
  }, { 'object.paymentMethods': 1 })
389
+ .lean() // 2024-08-26~
359
390
  .exec();
360
391
  if (doc === null) {
361
392
  throw new factory.errors.NotFound(this.transactionModel.modelName);
362
393
  }
363
- return doc.toObject().object.paymentMethods;
394
+ return doc.object.paymentMethods;
364
395
  });
365
396
  }
366
397
  /**
@@ -373,11 +404,12 @@ class TransactionRepo {
373
404
  typeOf: { $eq: factory.transactionType.PlaceOrder },
374
405
  status: { $eq: factory.transactionStatusType.InProgress }
375
406
  }, { 'object.orderNumber': 1 })
407
+ .lean() // 2024-08-26~
376
408
  .exec();
377
409
  if (doc === null) {
378
410
  throw new factory.errors.NotFound(this.transactionModel.modelName);
379
411
  }
380
- return doc.toObject().object.orderNumber;
412
+ return doc.object.orderNumber;
381
413
  });
382
414
  }
383
415
  /**
@@ -390,11 +422,12 @@ class TransactionRepo {
390
422
  typeOf: { $eq: factory.transactionType.PlaceOrder },
391
423
  status: { $in: params.status.$in }
392
424
  }, { 'object.confirmationNumber': 1 })
425
+ .lean() // 2024-08-26~
393
426
  .exec();
394
427
  if (doc === null) {
395
428
  throw new factory.errors.NotFound(this.transactionModel.modelName);
396
429
  }
397
- return doc.toObject().object.confirmationNumber;
430
+ return doc.object.confirmationNumber;
398
431
  });
399
432
  }
400
433
  /**
@@ -412,6 +445,7 @@ class TransactionRepo {
412
445
  }, {
413
446
  projection: { _id: 1 }
414
447
  })
448
+ .lean()
415
449
  .exec();
416
450
  if (doc === null) {
417
451
  throw new factory.errors.NotFound(this.transactionModel.modelName);
@@ -434,6 +468,7 @@ class TransactionRepo {
434
468
  }, {
435
469
  projection: { _id: 1 }
436
470
  })
471
+ .lean()
437
472
  .exec();
438
473
  if (doc === null) {
439
474
  throw new factory.errors.NotFound(this.transactionModel.modelName);
@@ -456,6 +491,7 @@ class TransactionRepo {
456
491
  }, {
457
492
  projection: { _id: 1 }
458
493
  })
494
+ .lean()
459
495
  .exec();
460
496
  if (doc === null) {
461
497
  throw new factory.errors.NotFound(this.transactionModel.modelName);
@@ -481,10 +517,11 @@ class TransactionRepo {
481
517
  new: true,
482
518
  projection: { _id: 1 }
483
519
  })
520
+ .lean()
484
521
  .exec();
485
522
  // NotFoundであれば取引状態確認
486
523
  if (doc === null) {
487
- const { status } = yield this.findById({ typeOf: params.typeOf, id: params.id }, ['status']);
524
+ const { status } = yield this.projectFieldsById({ typeOf: params.typeOf, id: params.id }, ['status']);
488
525
  if (status === factory.transactionStatusType.Confirmed) {
489
526
  // すでに確定済の場合スルー
490
527
  }
@@ -529,14 +566,19 @@ class TransactionRepo {
529
566
  'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
530
567
  'tasksExportAction.startDate': new Date()
531
568
  // tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting // discontinue(2024-06-20~)
532
- }, { new: true })
533
- .select({
534
- _id: 1,
535
- typeOf: 1
569
+ }, {
570
+ new: true,
571
+ projection: {
572
+ // _id: 1,
573
+ _id: 0,
574
+ id: { $toString: '$_id' },
575
+ typeOf: 1
576
+ }
536
577
  })
578
+ .lean() // 2024-08-26~
537
579
  .exec()
538
580
  // tslint:disable-next-line:no-null-keyword
539
- .then((doc) => (doc === null) ? null : doc.toObject());
581
+ .then((doc) => (doc === null) ? null : doc);
540
582
  });
541
583
  }
542
584
  reexportTasksByExportAction(params) {
@@ -697,10 +739,11 @@ class TransactionRepo {
697
739
  new: true,
698
740
  projection: { _id: 1 }
699
741
  })
742
+ .lean()
700
743
  .exec();
701
744
  // NotFoundであれば取引状態確認
702
745
  if (doc === null) {
703
- const { status } = yield this.findById(params, ['status']);
746
+ const { status } = yield this.projectFieldsById(params, ['status']);
704
747
  if (status === factory.transactionStatusType.Canceled) {
705
748
  // すでに中止済の場合スルー
706
749
  }
@@ -732,28 +775,28 @@ class TransactionRepo {
732
775
  /**
733
776
  * 取引を検索する
734
777
  */
735
- search(params) {
778
+ projectFields(params) {
736
779
  var _a;
737
780
  return __awaiter(this, void 0, void 0, function* () {
781
+ const { inclusion } = params;
738
782
  const conditions = TransactionRepo.CREATE_MONGO_CONDITIONS(params);
739
- let projection = {};
740
- if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
741
- params.inclusion.forEach((field) => {
742
- projection[field] = 1;
743
- });
744
- }
745
- else {
746
- projection = {
747
- __v: 0,
748
- createdAt: 0,
749
- updatedAt: 0
750
- };
751
- // if (Array.isArray(params.exclusion) && params.exclusion.length > 0) { // discontinue(2024-06-17~)
752
- // params.exclusion.forEach((field) => {
753
- // projection[field] = 0;
754
- // });
755
- // }
783
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
784
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
785
+ positiveProjectionFields = positiveProjectionFields.filter((key) => inclusion.includes(key));
756
786
  }
787
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
788
+ // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
789
+ // if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
790
+ // params.inclusion.forEach((field) => {
791
+ // projection[field] = 1;
792
+ // });
793
+ // } else {
794
+ // projection = {
795
+ // __v: 0,
796
+ // createdAt: 0,
797
+ // updatedAt: 0
798
+ // };
799
+ // }
757
800
  const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
758
801
  .select(projection);
759
802
  if (typeof params.limit === 'number' && params.limit > 0) {
@@ -769,8 +812,8 @@ class TransactionRepo {
769
812
  // const explainResult = await (<any>query).explain();
770
813
  // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
771
814
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
772
- .exec()
773
- .then((docs) => docs.map((doc) => doc.toObject()));
815
+ .lean() // 2024-08-26~
816
+ .exec();
774
817
  });
775
818
  }
776
819
  /**
@@ -785,21 +828,7 @@ class TransactionRepo {
785
828
  // new: true,
786
829
  projection: { _id: 1 }
787
830
  })
788
- .exec()
789
- .then((doc) => {
790
- if (doc === null) {
791
- throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
792
- }
793
- });
794
- });
795
- }
796
- findByIdAndUpdate4migrate(params) {
797
- return __awaiter(this, void 0, void 0, function* () {
798
- yield this.transactionModel.findOneAndUpdate({
799
- _id: { $eq: params.id }
800
- }, params.update, {
801
- projection: { _id: 1 }
802
- })
831
+ .lean()
803
832
  .exec()
804
833
  .then((doc) => {
805
834
  if (doc === null) {
@@ -34,7 +34,7 @@ export declare function startAndConfirm(params: factory.assetTransaction.cancelR
34
34
  seller: {
35
35
  id?: string;
36
36
  };
37
- }): IStartOperation<factory.assetTransaction.cancelReservation.ITransaction>;
37
+ }): IStartOperation<Pick<factory.assetTransaction.cancelReservation.ITransaction, 'id'>>;
38
38
  /**
39
39
  * 取引タスク出力
40
40
  */
@@ -4,7 +4,7 @@ declare function createReserveTransactionStartParams(params: {
4
4
  project: {
5
5
  id: string;
6
6
  };
7
- acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4chevre[];
7
+ acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer[];
8
8
  event: {
9
9
  id: string;
10
10
  };
@@ -26,13 +26,13 @@ declare function acceptedOffers2amount(params: {
26
26
  acceptedOffers: IResultAcceptedOffer[];
27
27
  }): number;
28
28
  declare function acceptedOffers2authorizeResult(params: {
29
- acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4chevre[];
29
+ acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer[];
30
30
  acceptedOffers4result: IResultAcceptedOffer[];
31
31
  noOfferSpecified: boolean;
32
32
  ticketOffers: factory.product.ITicketOffer[];
33
33
  }): factory.action.authorize.offer.eventService.IResult;
34
34
  type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
35
- type IResultAcceptedOffer = factory.action.authorize.offer.eventService.IResultAcceptedOffer;
35
+ export type IResultAcceptedOffer = factory.order.IAcceptedOffer<factory.order.IReservation>;
36
36
  declare function responseBody2acceptedOffers4result(params: {
37
37
  issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
38
38
  reservationFor: factory.assetTransaction.reserve.IReservationFor;
@@ -17,8 +17,9 @@ import type { OfferRateLimitRepo } from '../../../../repo/rateLimit/offer';
17
17
  import type { StockHolderRepo } from '../../../../repo/stockHolder';
18
18
  import type { TaskRepo } from '../../../../repo/task';
19
19
  import type { TicketRepo } from '../../../../repo/ticket';
20
+ import { IResultAcceptedOffer } from './factory';
20
21
  declare function processStartReserve4chevre(params: {
21
- acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4chevre[];
22
+ acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer[];
22
23
  event: Pick<IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>, 'id'>;
23
24
  broker?: factory.reservation.IBroker<factory.reservationType>;
24
25
  transactionNumber: string;
@@ -57,6 +58,6 @@ declare function processStartReserve4chevre(params: {
57
58
  }, credentials: {
58
59
  jwt: JWTCredentials;
59
60
  }) => Promise<{
60
- acceptedOffers4result: factory.action.authorize.offer.eventService.IResultAcceptedOffer[];
61
+ acceptedOffers4result: IResultAcceptedOffer[];
61
62
  }>;
62
63
  export { processStartReserve4chevre };
@@ -48,7 +48,7 @@ type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, credentials: {
48
48
  jwt: JWTCredentials;
49
49
  }) => Promise<T>;
50
50
  type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
51
- type IObjectWithoutDetail = factory.action.authorize.offer.eventService.IObjectWithoutDetail<factory.service.webAPI.Identifier.Chevre>;
51
+ type IObjectWithoutDetail = factory.action.authorize.offer.eventService.IObjectWithoutDetail;
52
52
  interface IAuthorizeOptions {
53
53
  /**
54
54
  * オファーID指定なしに座席をおさえる場合true
@@ -74,7 +74,7 @@ exports.authorize = authorize;
74
74
  function validateCreateRequest(params) {
75
75
  return (repos) => __awaiter(this, void 0, void 0, function* () {
76
76
  var _a, _b;
77
- const transaction = yield repos.transaction.findInProgressById({
77
+ const transaction = yield repos.transaction.projectFieldsInProgressById({
78
78
  typeOf: factory.transactionType.PlaceOrder,
79
79
  id: params.transaction.id
80
80
  }, ['agent', 'expires', 'project', 'seller', 'typeOf', 'instrument']);
@@ -29,7 +29,7 @@ function voidTransaction(params) {
29
29
  return;
30
30
  }
31
31
  const cancelAction = Object.assign({ startTime: new Date(), agent: { id: params.project.id, typeOf: factory.organizationType.Project } }, (typeof ((_a = params.sameAs) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined);
32
- const transaction = yield repos.transaction.findById({ typeOf: params.purpose.typeOf, id: params.purpose.id }, ['typeOf', 'status', 'object']);
32
+ const transaction = yield repos.transaction.projectFieldsById({ typeOf: params.purpose.typeOf, id: params.purpose.id }, ['typeOf', 'status', 'object']);
33
33
  // 興行オファー承認アクション検索
34
34
  let authorizeActions = yield repos.action.searchByPurpose({
35
35
  typeOf: factory.actionType.AuthorizeAction,
@@ -102,7 +102,7 @@ function cancelAcceptActions(params) {
102
102
  return (repos) => __awaiter(this, void 0, void 0, function* () {
103
103
  var _a, _b, _c;
104
104
  const cancelAction = Object.assign({ startTime: new Date(), agent: { id: params.project.id, typeOf: factory.organizationType.Project } }, (typeof ((_a = params.sameAs) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined);
105
- const transaction = yield repos.transaction.findById({
105
+ const transaction = yield repos.transaction.projectFieldsById({
106
106
  typeOf: params.purpose.typeOf,
107
107
  id: params.purpose.id
108
108
  }, ['typeOf', 'status']);
@@ -25,7 +25,7 @@ function voidTransactionByActionId(params) {
25
25
  throw new factory.errors.ArgumentNull('id');
26
26
  }
27
27
  const cancelAction = Object.assign({ startTime: new Date(), agent: { id: params.project.id, typeOf: factory.organizationType.Project } }, (typeof ((_a = params.sameAs) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined);
28
- const transaction = yield repos.transaction.findInProgressById({
28
+ const transaction = yield repos.transaction.projectFieldsInProgressById({
29
29
  typeOf: factory.transactionType.PlaceOrder,
30
30
  id: params.purpose.id
31
31
  }, ['typeOf']);
@@ -10,12 +10,12 @@ export interface IAppliesToSurfrock {
10
10
  };
11
11
  }
12
12
  export declare function createAcceptedOffersWithoutDetails(params: {
13
- object: factory.action.authorize.offer.eventService.IObjectWithoutDetail<WebAPIIdentifier.COA>;
13
+ object: factory.action.accept.coaOffer.IObjectWithoutDetail4COA;
14
14
  coaInfo: Pick<factory.event.screeningEvent.ICOAInfo, 'dateJouei' | 'screenCode' | 'theaterCode' | 'timeBegin' | 'timeEnd' | 'titleBranchNum' | 'titleCode'>;
15
15
  }): (repos: {
16
16
  reserveService: COA.service.Reserve;
17
17
  }) => Promise<IAcceptedOfferWithoutDetail[]>;
18
- type IAcceptedOfferBeforeAuthorize4COA = factory.action.authorize.offer.eventService.IAcceptedOfferBeforeAuthorize4COA;
18
+ type IAcceptedOfferBeforeAuthorize4COA = factory.action.accept.coaOffer.IAcceptedOfferBeforeAuthorize4COA;
19
19
  export declare function validateOffers(coaInfo: Pick<factory.event.screeningEvent.ICOAInfo, 'dateJouei' | 'screenCode' | 'theaterCode' | 'timeBegin' | 'timeEnd' | 'titleBranchNum' | 'titleCode'>, offers: IAcceptedOfferWithoutDetail[], appliesToSurfrock: IAppliesToSurfrock, flgMember: COA.factory.reserve.FlgMember): (repos: {
20
20
  reserveService: COA.service.Reserve;
21
21
  masterService: COA.service.Master;
@@ -1,14 +1,14 @@
1
1
  import * as factory from '../../../../factory';
2
- type IAcceptedOfferWithoutDetail = factory.action.authorize.offer.eventService.IAcceptedOfferWithoutDetail<factory.service.webAPI.Identifier.COA> & {
2
+ type IAcceptedOfferWithoutDetail = factory.action.accept.coaOffer.IAcceptedOfferWithoutDetail4COA & {
3
3
  additionalProperty?: factory.propertyValue.IPropertyValue<string>[];
4
- ticketInfo: factory.action.authorize.offer.eventService.ICOATicketInfo & {
4
+ ticketInfo: factory.action.accept.coaOffer.ICOATicketInfo & {
5
5
  spseatAdd1: number;
6
6
  spseatAdd2: number;
7
7
  spseatKbn: string;
8
8
  };
9
9
  };
10
10
  declare function createUpdTmpReserveSeatArgs(params: {
11
- object: factory.action.authorize.offer.eventService.IObjectWithoutDetail<factory.service.webAPI.Identifier.COA>;
11
+ object: factory.action.accept.coaOffer.IObjectWithoutDetail4COA;
12
12
  coaInfo: Pick<factory.event.screeningEvent.ICOAInfo, 'dateJouei' | 'screenCode' | 'theaterCode' | 'timeBegin' | 'timeEnd' | 'titleBranchNum' | 'titleCode'>;
13
13
  }): factory.action.accept.coaOffer.IUpdTmpReserveSeatArgs;
14
14
  declare function processUpdTmpReserveSeatResult2recipe(params: {
@@ -42,7 +42,7 @@ function acceptOffer(params) {
42
42
  if (typeof params.sameAs.id !== 'string' || params.sameAs.id === '') {
43
43
  throw new factory.errors.ArgumentNull('sameAs.id');
44
44
  }
45
- const transaction = yield repos.transaction.findInProgressById({
45
+ const transaction = yield repos.transaction.projectFieldsInProgressById({
46
46
  typeOf: factory.transactionType.PlaceOrder,
47
47
  id: params.purpose.id
48
48
  }, ['project', 'agent', 'typeOf']);
@@ -121,7 +121,7 @@ function reAcceptOffer(params) {
121
121
  if (typeof ((_a = params.potentialActions) === null || _a === void 0 ? void 0 : _a.id) !== 'string' || params.potentialActions.id === '') {
122
122
  throw new factory.errors.ArgumentNull('potentialActions.id');
123
123
  }
124
- const transaction = yield repos.transaction.findInProgressById({
124
+ const transaction = yield repos.transaction.projectFieldsInProgressById({
125
125
  typeOf: factory.transactionType.PlaceOrder,
126
126
  id: params.purpose.id
127
127
  }, ['project', 'agent', 'typeOf']);
@@ -6,8 +6,10 @@ import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
6
6
  import type { OrderNumberRepo } from '../../../repo/orderNumber';
7
7
  import type { ProjectRepo } from '../../../repo/project';
8
8
  import type { TransactionRepo } from '../../../repo/transaction';
9
+ import { IRequestBody, IResponseBody } from './factory';
9
10
  import { IAcceptedOfferBeforeAuthorize4COA } from './validateAcceptedOffers';
10
11
  import * as factory from '../../../factory';
12
+ export { IRequestBody, IResponseBody };
11
13
  export import WebAPIIdentifier = factory.service.webAPI.Identifier;
12
14
  export type IAuthorizeActionResult = factory.action.authorize.offer.eventService.IResult;
13
15
  export interface IAuthorizeRepos {
@@ -51,8 +53,8 @@ export declare function authorize(params: {
51
53
  id: string;
52
54
  };
53
55
  result: {
54
- requestBody: factory.action.authorize.offer.eventService.IRequestBody<WebAPIIdentifier.COA>;
55
- responseBody: factory.action.authorize.offer.eventService.IResponseBody<WebAPIIdentifier.COA>;
56
+ requestBody: IRequestBody;
57
+ responseBody: IResponseBody;
56
58
  };
57
59
  options: {};
58
60
  }): IAuthorizeOperation<IAuthorizeOfferAction>;
@@ -23,7 +23,7 @@ function authorize(params) {
23
23
  // tslint:disable-next-line:max-func-body-length
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
25
  var _a;
26
- const transaction = yield repos.transaction.findInProgressById({
26
+ const transaction = yield repos.transaction.projectFieldsInProgressById({
27
27
  typeOf: factory.transactionType.PlaceOrder,
28
28
  id: params.transaction.id
29
29
  }, ['agent', 'project', 'seller', 'typeOf', 'instrument']);
@@ -23,7 +23,7 @@ function changeOffers(params) {
23
23
  // tslint:disable-next-line:max-func-body-length
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
25
  var _a, _b, _c, _d;
26
- const transaction = yield repos.transaction.findInProgressById({
26
+ const transaction = yield repos.transaction.projectFieldsInProgressById({
27
27
  typeOf: factory.transactionType.PlaceOrder,
28
28
  id: params.transaction.id
29
29
  }, ['typeOf', 'agent', 'project', 'seller']);
@@ -1,12 +1,15 @@
1
+ import type * as COAService from '@motionpicture/coa-service';
1
2
  import * as factory from '../../../factory';
2
3
  import { IMinimizedIndividualEvent } from '../../../factory/event';
3
4
  export import WebAPIIdentifier = factory.service.webAPI.Identifier;
4
- export type IAcceptedOffer4COA = factory.action.authorize.offer.eventService.IAcceptedOffer4COA;
5
+ export type IAcceptedOffer4COA = factory.action.accept.coaOffer.IAcceptedOffer4COA;
6
+ export type IRequestBody = COAService.factory.reserve.IUpdTmpReserveSeatArgs;
7
+ export type IResponseBody = COAService.factory.reserve.IUpdTmpReserveSeatResult;
5
8
  export declare function createAuthorizeSeatReservationActionAttributes(params: {
6
9
  acceptAction: {
7
10
  id: string;
8
11
  };
9
- acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4COA[];
12
+ acceptedOffers: factory.action.accept.coaOffer.IAcceptedOffer4COA[];
10
13
  event: {
11
14
  id: string;
12
15
  typeOf: factory.eventType.ScreeningEvent;
@@ -21,13 +24,13 @@ export declare function offers2resultPrice(offers: IAcceptedOffer4COA[]): {
21
24
  price: number;
22
25
  eligibleMonetaryAmount: factory.offer.IEligibleMonetaryAmount[];
23
26
  };
24
- type IResultAcceptedOffer = factory.action.authorize.offer.eventService.IResultAcceptedOffer;
27
+ type IResultAcceptedOffer = factory.order.IAcceptedOffer<factory.order.IReservation>;
25
28
  /**
26
29
  * COA仮予約結果から注文アイテムを生成する
27
30
  */
28
31
  export declare function responseBody2acceptedOffers4result(params: {
29
- responseBody: factory.action.authorize.offer.eventService.IResponseBody<factory.service.webAPI.Identifier.COA>;
30
- acceptedOffer: factory.action.authorize.offer.eventService.IAcceptedOffer4COA[];
32
+ responseBody: IResponseBody;
33
+ acceptedOffer: factory.action.accept.coaOffer.IAcceptedOffer4COA[];
31
34
  event: Pick<IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>, 'coaInfo' | 'doorTime' | 'endDate' | 'id' | 'location' | 'startDate' | 'superEvent' | 'typeOf' | 'identifier' | 'name'>;
32
35
  seller: Pick<factory.transaction.placeOrder.ISeller, 'typeOf' | 'name'>;
33
36
  bookingTime: Date;
@@ -1,7 +1,7 @@
1
1
  import * as factory from '../../../factory';
2
2
  import type { OfferRepo } from '../../../repo/offer';
3
3
  import { IAcceptedOffer4COA } from './factory';
4
- export type IAcceptedOfferBeforeAuthorize4COA = factory.action.authorize.offer.eventService.IAcceptedOfferBeforeAuthorize4COA;
4
+ export type IAcceptedOfferBeforeAuthorize4COA = factory.action.accept.coaOffer.IAcceptedOfferBeforeAuthorize4COA;
5
5
  /**
6
6
  * 受け入れらたオファーの内容を検証
7
7
  */
@@ -16,7 +16,7 @@ const MoneyTransferAssetTransactionService = require("../../assetTransaction/mon
16
16
  const any_1 = require("../any");
17
17
  function authorize(params) {
18
18
  return (repos) => __awaiter(this, void 0, void 0, function* () {
19
- const transaction = yield repos.transaction.findInProgressById({
19
+ const transaction = yield repos.transaction.projectFieldsInProgressById({
20
20
  typeOf: params.purpose.typeOf,
21
21
  id: params.purpose.id
22
22
  }, ['seller', 'project', 'agent', 'typeOf']);
@@ -16,7 +16,7 @@ function voidTransaction(params) {
16
16
  return (repos) => __awaiter(this, void 0, void 0, function* () {
17
17
  let transaction;
18
18
  if (params.agent !== undefined && params.agent !== null && typeof params.agent.id === 'string') {
19
- transaction = (yield repos.transaction.findInProgressById({
19
+ transaction = (yield repos.transaction.projectFieldsInProgressById({
20
20
  typeOf: params.purpose.typeOf,
21
21
  id: params.purpose.id
22
22
  }, ['typeOf']));
@@ -89,7 +89,7 @@ function authorize(params) {
89
89
  // tslint:disable-next-line:max-func-body-length
90
90
  return (repos) => __awaiter(this, void 0, void 0, function* () {
91
91
  const now = new Date();
92
- const transaction = yield repos.transaction.findInProgressById({
92
+ const transaction = yield repos.transaction.projectFieldsInProgressById({
93
93
  typeOf: factory.transactionType.PlaceOrder,
94
94
  id: params.transaction.id
95
95
  }, ['agent', 'project', 'seller', 'typeOf', 'expires']);
@@ -189,7 +189,7 @@ function fixProductAndOffers(params) {
189
189
  function voidTransaction(params) {
190
190
  return (repos) => __awaiter(this, void 0, void 0, function* () {
191
191
  var _a;
192
- const transaction = yield repos.transaction.findById({
192
+ const transaction = yield repos.transaction.projectFieldsById({
193
193
  typeOf: params.purpose.typeOf,
194
194
  id: params.purpose.id
195
195
  }, ['agent', 'status', 'typeOf']);
@@ -13,7 +13,7 @@ exports.findPlaceOrderTransaction = void 0;
13
13
  const factory = require("../../factory");
14
14
  function findPlaceOrderTransaction(params) {
15
15
  return (repos) => __awaiter(this, void 0, void 0, function* () {
16
- const placeOrderTransactions = yield repos.transaction.search({
16
+ const placeOrderTransactions = yield repos.transaction.projectFields({
17
17
  limit: 1,
18
18
  page: 1,
19
19
  project: { id: { $eq: params.project.id } },