@chevre/domain 22.11.0-alpha.2 → 22.11.0-alpha.22

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 (148) hide show
  1. package/example/src/chevre/assetTransaction/processReserve.ts +0 -1
  2. package/example/src/chevre/notifyAbortedTasksByEmail.ts +1 -1
  3. package/example/src/chevre/orders/searchWithUnwoundAcceptedOffers.ts +73 -0
  4. package/example/src/chevre/reIndex.ts +1 -1
  5. package/example/src/chevre/roles/addAdminPermissionIfNotExists.ts +132 -0
  6. package/example/src/chevre/roles/addDefaultPermissionIfNotExists.ts +37 -0
  7. package/example/src/chevre/roles/addEventOfferPermissionIfNotExists.ts +27 -0
  8. package/example/src/chevre/roles/addPermissionIfNotExists.ts +39 -6
  9. package/example/src/chevre/roles/addProjectCreatorRole.ts +48 -0
  10. package/example/src/chevre/roles/assignGlobalRoles.ts +72 -0
  11. package/example/src/chevre/roles/findPermissions.ts +84 -0
  12. package/example/src/chevre/roles/findRoleNames.ts +117 -0
  13. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +38 -0
  14. package/example/src/chevre/roles/removePermissionFromAPIRoles.ts +46 -0
  15. package/example/src/chevre/roles/removePermissionIfExists.ts +39 -0
  16. package/example/src/chevre/settings/addSettings.ts +23 -17
  17. package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +11 -20
  18. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -5
  19. package/example/src/idaas/auth0/adminApplications.ts +183 -0
  20. package/example/src/idaas/auth0/getToken.ts +55 -0
  21. package/example/src/idaas/auth0/getTokenByPrivateKeyJWT.ts +84 -0
  22. package/example/src/regex.ts +31 -0
  23. package/lib/chevre/eventEmitter/task.d.ts +13 -4
  24. package/lib/chevre/index.d.ts +0 -2
  25. package/lib/chevre/index.js +0 -10
  26. package/lib/chevre/repo/acceptedOffer.d.ts +3 -1
  27. package/lib/chevre/repo/acceptedOffer.js +11 -3
  28. package/lib/chevre/repo/confirmationNumber.d.ts +0 -11
  29. package/lib/chevre/repo/confirmationNumber.js +15 -54
  30. package/lib/chevre/repo/identity.d.ts +11 -33
  31. package/lib/chevre/repo/identity.js +10 -15
  32. package/lib/chevre/repo/member.d.ts +22 -4
  33. package/lib/chevre/repo/member.js +81 -27
  34. package/lib/chevre/repo/mongoose/schemas/identity.d.ts +1 -1
  35. package/lib/chevre/repo/mongoose/schemas/member/global.d.ts +14 -0
  36. package/lib/chevre/repo/mongoose/schemas/member/global.js +82 -0
  37. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +11 -0
  38. package/lib/chevre/repo/mongoose/schemas/setting.js +1 -0
  39. package/lib/chevre/repo/mongoose/schemas/task.js +9 -0
  40. package/lib/chevre/repo/orderNumber.d.ts +0 -11
  41. package/lib/chevre/repo/orderNumber.js +13 -51
  42. package/lib/chevre/repo/role.d.ts +16 -4
  43. package/lib/chevre/repo/role.js +71 -32
  44. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -4
  45. package/lib/chevre/repo/serviceOutputIdentifier.js +13 -38
  46. package/lib/chevre/repo/setting.d.ts +5 -10
  47. package/lib/chevre/repo/setting.js +4 -7
  48. package/lib/chevre/repo/stockHolder.js +0 -11
  49. package/lib/chevre/repo/task.d.ts +38 -25
  50. package/lib/chevre/repo/task.js +114 -211
  51. package/lib/chevre/repo/transactionNumber.d.ts +0 -11
  52. package/lib/chevre/repo/transactionNumber.js +13 -51
  53. package/lib/chevre/repo/transactionNumberCounter.d.ts +0 -10
  54. package/lib/chevre/repo/transactionNumberCounter.js +34 -29
  55. package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
  56. package/lib/chevre/service/code.d.ts +5 -28
  57. package/lib/chevre/service/code.js +3 -79
  58. package/lib/chevre/service/iam.d.ts +17 -7
  59. package/lib/chevre/service/iam.js +26 -6
  60. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +15 -0
  61. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +38 -0
  62. package/lib/chevre/service/notification.d.ts +2 -1
  63. package/lib/chevre/service/notification.js +3 -1
  64. package/lib/chevre/service/task/acceptCOAOffer.d.ts +1 -1
  65. package/lib/chevre/service/task/acceptCOAOffer.js +6 -5
  66. package/lib/chevre/service/task/aggregateOffers.d.ts +1 -1
  67. package/lib/chevre/service/task/aggregateOnSystem.d.ts +4 -2
  68. package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +1 -1
  69. package/lib/chevre/service/task/authorizePayment.d.ts +1 -1
  70. package/lib/chevre/service/task/authorizePayment.js +7 -6
  71. package/lib/chevre/service/task/cancelMoneyTransfer.d.ts +1 -1
  72. package/lib/chevre/service/task/cancelPendingReservation.d.ts +1 -1
  73. package/lib/chevre/service/task/cancelReservation.d.ts +1 -1
  74. package/lib/chevre/service/task/checkMovieTicket.d.ts +1 -1
  75. package/lib/chevre/service/task/checkMovieTicket.js +4 -3
  76. package/lib/chevre/service/task/checkResource.d.ts +1 -1
  77. package/lib/chevre/service/task/confirmMoneyTransfer.d.ts +1 -1
  78. package/lib/chevre/service/task/confirmPayTransaction.d.ts +1 -1
  79. package/lib/chevre/service/task/confirmRegisterService.d.ts +1 -1
  80. package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
  81. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +1 -1
  82. package/lib/chevre/service/task/createAccountingReport.d.ts +1 -1
  83. package/lib/chevre/service/task/createEvent.d.ts +1 -1
  84. package/lib/chevre/service/task/deletePerson.d.ts +1 -1
  85. package/lib/chevre/service/task/deleteTransaction.d.ts +1 -1
  86. package/lib/chevre/service/task/givePointAward.d.ts +1 -1
  87. package/lib/chevre/service/task/givePointAward.js +1 -1
  88. package/lib/chevre/service/task/handleNotification.d.ts +4 -2
  89. package/lib/chevre/service/task/importEventCapacitiesFromCOA.d.ts +1 -1
  90. package/lib/chevre/service/task/importEventsFromCOA.d.ts +1 -1
  91. package/lib/chevre/service/task/importOffersFromCOA.d.ts +1 -1
  92. package/lib/chevre/service/task/invalidatePaymentUrl.d.ts +1 -1
  93. package/lib/chevre/service/task/moneyTransfer.d.ts +1 -1
  94. package/lib/chevre/service/task/moneyTransfer.js +1 -1
  95. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +1 -1
  96. package/lib/chevre/service/task/onAuthorizationCreated.d.ts +1 -1
  97. package/lib/chevre/service/task/onEventChanged.d.ts +1 -1
  98. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +1 -1
  99. package/lib/chevre/service/task/onResourceUpdated.d.ts +1 -1
  100. package/lib/chevre/service/task/pay.d.ts +1 -1
  101. package/lib/chevre/service/task/placeOrder.d.ts +1 -1
  102. package/lib/chevre/service/task/publishPaymentUrl.d.ts +1 -1
  103. package/lib/chevre/service/task/publishPaymentUrl.js +6 -7
  104. package/lib/chevre/service/task/refund.d.ts +1 -1
  105. package/lib/chevre/service/task/refund.js +1 -1
  106. package/lib/chevre/service/task/registerService.d.ts +1 -1
  107. package/lib/chevre/service/task/reserve.d.ts +1 -1
  108. package/lib/chevre/service/task/returnMoneyTransfer.d.ts +1 -1
  109. package/lib/chevre/service/task/returnMoneyTransfer.js +1 -1
  110. package/lib/chevre/service/task/returnOrder.d.ts +1 -1
  111. package/lib/chevre/service/task/returnPayTransaction.d.ts +1 -1
  112. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  113. package/lib/chevre/service/task/returnPointAward.d.ts +1 -1
  114. package/lib/chevre/service/task/returnPointAward.js +1 -1
  115. package/lib/chevre/service/task/returnReserveTransaction.d.ts +1 -1
  116. package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
  117. package/lib/chevre/service/task/sendEmailMessage.d.ts +1 -1
  118. package/lib/chevre/service/task/sendOrder.d.ts +1 -1
  119. package/lib/chevre/service/task/triggerWebhook.d.ts +1 -1
  120. package/lib/chevre/service/task/useReservation.d.ts +1 -1
  121. package/lib/chevre/service/task/voidMoneyTransferTransaction.d.ts +1 -1
  122. package/lib/chevre/service/task/voidPayTransaction.d.ts +1 -1
  123. package/lib/chevre/service/task/voidPayment.d.ts +1 -1
  124. package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +1 -1
  125. package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
  126. package/lib/chevre/service/task/voidReserveTransaction.js +4 -3
  127. package/lib/chevre/service/task.d.ts +1 -23
  128. package/lib/chevre/service/task.js +3 -110
  129. package/lib/chevre/service/taskHandler.d.ts +26 -0
  130. package/lib/chevre/service/taskHandler.js +139 -0
  131. package/lib/chevre/service/validation/validateOrder.js +55 -37
  132. package/lib/chevre/service.d.ts +0 -4
  133. package/lib/chevre/service.js +10 -14
  134. package/lib/chevre/settings/aggregation.d.ts +6 -1
  135. package/lib/chevre/settings/aggregation.js +2 -1
  136. package/package.json +5 -3
  137. package/example/src/chevre/adminAuth/adminIdentity.ts +0 -38
  138. package/example/src/chevre/findExecutableTask.ts +0 -50
  139. package/example/src/chevre/findSetting.ts +0 -79
  140. package/example/src/chevre/roles/addRoleMembers.ts +0 -75
  141. package/example/src/chevre/searchPermissions.ts +0 -46
  142. package/example/src/chevre/transactionNumber/publishConfimationNumber.ts +0 -37
  143. package/example/src/chevre/transactionNumber/publishOrderNumber.ts +0 -40
  144. package/example/src/chevre/transactionNumber/setUseMongo4confirmationNumberFrom.ts +0 -45
  145. package/example/src/chevre/transactionNumber/setUseMongo4orderNumberFrom.ts +0 -41
  146. package/example/src/chevre/transactionNumber/setUseMongo4transactionNumberFrom.ts +0 -41
  147. package/lib/chevre/adminAuth.d.ts +0 -2
  148. package/lib/chevre/adminAuth.js +0 -6
@@ -1,3 +1,3 @@
1
- import type { IExecutableTaskKeys, IOperationExecute } from '../task';
1
+ import type { IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  export declare function call(params: Pick<factory.task.invalidatePaymentUrl.ITask, IExecutableTaskKeys>): IOperationExecute<void>;
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -25,7 +25,7 @@ function call(data) {
25
25
  }
26
26
  const actionRepo = new action_1.ActionRepo(connection);
27
27
  const productRepo = new product_1.ProductRepo(connection);
28
- const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ redisClient, connection });
28
+ const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ connection });
29
29
  yield MoneyTransferService.moneyTransfer(data)({
30
30
  action: actionRepo,
31
31
  product: productRepo,
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IExecutableTaskKeys, IOperationExecute } from '../task';
2
+ import type { IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -1,4 +1,4 @@
1
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,4 +1,4 @@
1
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -22,7 +22,7 @@ const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
22
22
  const ticket_1 = require("../../repo/ticket");
23
23
  const transaction_1 = require("../../repo/transaction");
24
24
  const transactionNumber_1 = require("../../repo/transactionNumber");
25
- const transactionProcess_1 = require("../../repo/transactionProcess");
25
+ // import { TransactionProcessRepo } from '../../repo/transactionProcess';
26
26
  const any_1 = require("../payment/any");
27
27
  /**
28
28
  * タスク実行関数
@@ -37,20 +37,20 @@ function call(params) {
37
37
  return;
38
38
  }
39
39
  const actionRepo = new action_1.ActionRepo(connection);
40
- const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
40
+ // const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
41
41
  try {
42
42
  yield (0, any_1.publishPaymentUrl)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
43
43
  action: actionRepo,
44
44
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
45
45
  authorization: new authorization_1.AuthorizationRepo(connection),
46
- orderNumber: new orderNumber_1.OrderNumberRepo({ redisClient, connection }),
46
+ orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
47
47
  paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
48
48
  paymentService: new paymentService_1.PaymentServiceRepo(connection),
49
49
  paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
50
50
  project: new project_1.ProjectRepo(connection),
51
51
  ticket: new ticket_1.TicketRepo(connection),
52
52
  transaction: new transaction_1.TransactionRepo(connection),
53
- transactionNumber: new transactionNumber_1.TransactionNumberRepo({ redisClient, connection })
53
+ transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
54
54
  }, settings);
55
55
  }
56
56
  catch (error) {
@@ -69,10 +69,9 @@ function call(params) {
69
69
  }
70
70
  }
71
71
  finally {
72
+ // taskRepo.runImmediatelyのnextパラメータでの解決へ移行したためここでの解除は不要(2025-07-12~)
72
73
  // 取引プロセスロック解除
73
- // if (params.data.options.useUnlockTransactionProcess) {
74
- yield transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
75
- // }
74
+ // await transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
76
75
  }
77
76
  });
78
77
  }
@@ -1,4 +1,4 @@
1
- import type { IExecutableTaskKeys, IOperationExecute } from '../task';
1
+ import type { IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -58,7 +58,7 @@ function call(params) {
58
58
  project: new project_1.ProjectRepo(connection),
59
59
  task: new task_1.TaskRepo(connection),
60
60
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
61
- transactionNumber: new transactionNumber_1.TransactionNumberRepo({ redisClient, connection })
61
+ transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
62
62
  }, settings);
63
63
  });
64
64
  }
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -29,7 +29,7 @@ function call(data) {
29
29
  const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
30
30
  const productRepo = new product_1.ProductRepo(connection);
31
31
  const projectRepo = new project_1.ProjectRepo(connection);
32
- const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ redisClient, connection });
32
+ const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ connection });
33
33
  yield (0, returnMoneyTransfer_1.returnMoneyTransfer)(data)({
34
34
  action: actionRepo,
35
35
  assetTransaction: assetTransactionRepo,
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,4 +1,4 @@
1
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -39,7 +39,7 @@ function call(params) {
39
39
  product: new product_1.ProductRepo(connection),
40
40
  task: new task_1.TaskRepo(connection),
41
41
  transaction: new transaction_1.TransactionRepo(connection),
42
- transactionNumber: new transactionNumber_1.TransactionNumberRepo({ redisClient, connection })
42
+ transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
43
43
  });
44
44
  });
45
45
  }
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -29,7 +29,7 @@ function call(data) {
29
29
  const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
30
30
  const productRepo = new product_1.ProductRepo(connection);
31
31
  const projectRepo = new project_1.ProjectRepo(connection);
32
- const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ redisClient, connection });
32
+ const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ connection });
33
33
  yield DeliveryService.returnPointAward(data)({
34
34
  action: actionRepo,
35
35
  assetTransaction: assetTransactionRepo,
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
2
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -55,7 +55,7 @@ function call(params) {
55
55
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
56
56
  project: new project_1.ProjectRepo(connection),
57
57
  reservation: new reservation_1.ReservationRepo(connection),
58
- transactionNumber: new transactionNumber_1.TransactionNumberRepo({ redisClient, connection }),
58
+ transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection }),
59
59
  reserveService
60
60
  });
61
61
  });
@@ -1,4 +1,4 @@
1
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,4 +1,4 @@
1
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,4 +1,4 @@
1
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,4 +1,4 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
2
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -23,7 +23,7 @@ const setting_1 = require("../../repo/setting");
23
23
  const stockHolder_1 = require("../../repo/stockHolder");
24
24
  const task_1 = require("../../repo/task");
25
25
  const transaction_1 = require("../../repo/transaction");
26
- const transactionProcess_1 = require("../../repo/transactionProcess");
26
+ // import { TransactionProcessRepo } from '../../repo/transactionProcess';
27
27
  let coaAuthClientCreated = false;
28
28
  let coaAuthClient = new COA.auth.RefreshToken({
29
29
  endpoint: '', // 使用されないので空文字でok
@@ -59,7 +59,7 @@ function call(params) {
59
59
  endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
60
60
  auth: coaAuthClient
61
61
  }, { timeout: settings.coa.timeout });
62
- const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
62
+ // const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
63
63
  try {
64
64
  yield (0, voidTransaction_1.voidTransaction)(Object.assign(Object.assign({}, params.data), { project: { id: params.project.id }, sameAs: { id: params.id } }))({
65
65
  action: new action_1.ActionRepo(connection),
@@ -80,7 +80,8 @@ function call(params) {
80
80
  finally {
81
81
  // アクションID指定であれば取引プロセスロック解除(2024-05-26~)
82
82
  if (voidByActionId) {
83
- yield transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
83
+ // taskRepo.runImmediatelyのnextパラメータでの解決へ移行したためここでの解除は不要(2025-07-12~)
84
+ // await transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
84
85
  }
85
86
  }
86
87
  });
@@ -1,7 +1,6 @@
1
1
  import { SendGridCredentials } from '../credentials/sendGrid';
2
2
  import type { IExecuteSettings as IMinimumExecuteSettings, INextFunction, IReadyTask, IRunningTask } from '../eventEmitter/task';
3
3
  import * as factory from '../factory';
4
- import type { IExecutableTask, IExecutableTaskKeys, TaskRepo } from '../repo/task';
5
4
  import { Settings } from '../settings';
6
5
  import { AggregationSettings } from '../settings/aggregation';
7
6
  interface ICredentialSettings {
@@ -12,14 +11,7 @@ interface IExecuteSettings extends IMinimumExecuteSettings {
12
11
  settings: Settings;
13
12
  aggregationSettings?: AggregationSettings;
14
13
  }
15
- interface IExecuteOptions {
16
- executeById: boolean;
17
- executeByName: boolean;
18
- }
19
14
  type IOperation<T> = (settings: IExecuteSettings) => Promise<T>;
20
- type IOperationExecute<T> = (settings: IExecuteSettings, options: IExecuteOptions) => Promise<T>;
21
- type ICallResult = void | Pick<factory.task.IExecutionResult, 'error'>;
22
- export type ICallableTaskOperation = (task: IExecutableTask<factory.taskName>) => IOperationExecute<ICallResult>;
23
15
  /**
24
16
  * タスク変更イベントを受けて実行する
25
17
  */
@@ -49,18 +41,4 @@ declare function executeOneIfExists(params: {
49
41
  $lt: Date;
50
42
  };
51
43
  }): IOperation<void>;
52
- /**
53
- * タスクを実行する
54
- */
55
- declare function execute(task: IExecutableTask<factory.taskName>, next?: INextFunction): IOperationExecute<void>;
56
- /**
57
- * add(2025-03-13~)
58
- */
59
- declare function notifyAbortedTasksByEmail(params: {
60
- dateAbortedGte: Date;
61
- }): (repos: {
62
- task: TaskRepo;
63
- }, settings: Pick<Settings, "abortedTasksWithoutReport">, credentials: {
64
- sendGrid: SendGridCredentials;
65
- }) => Promise<void>;
66
- export { ICallResult, IExecutableTaskKeys, IOperationExecute, executeById, executeOneIfExists, execute, notifyAbortedTasksByEmail };
44
+ export { executeById, executeOneIfExists };
@@ -11,15 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.executeById = executeById;
13
13
  exports.executeOneIfExists = executeOneIfExists;
14
- exports.execute = execute;
15
- exports.notifyAbortedTasksByEmail = notifyAbortedTasksByEmail;
16
14
  /**
17
15
  * タスクサービス
18
16
  */
19
17
  const createDebug = require("debug");
20
- const moment = require("moment");
21
- const factory = require("../factory");
22
- const factory_1 = require("./notification/factory");
18
+ const taskHandler_1 = require("./taskHandler");
23
19
  const debug = createDebug('chevre-domain:service:task');
24
20
  /**
25
21
  * タスク変更イベントを受けて実行する
@@ -42,7 +38,7 @@ function executeById(params, next) {
42
38
  }
43
39
  // タスクがなければ終了
44
40
  if (task !== null) {
45
- yield execute(task, (typeof next === 'function') ? next : undefined)(settings, {
41
+ yield (0, taskHandler_1.executeTask)(task, (typeof next === 'function') ? next : undefined)(settings, {
46
42
  executeById: true,
47
43
  executeByName: false
48
44
  });
@@ -70,113 +66,10 @@ function executeOneIfExists(params) {
70
66
  }
71
67
  // タスクがなければ終了
72
68
  if (task !== null) {
73
- yield execute(task)(settings, {
69
+ yield (0, taskHandler_1.executeTask)(task)(settings, {
74
70
  executeById: false,
75
71
  executeByName: (typeof ((_a = params.name) === null || _a === void 0 ? void 0 : _a.$eq) === 'string')
76
72
  });
77
73
  }
78
74
  });
79
75
  }
80
- /**
81
- * タスクを実行する
82
- */
83
- function execute(task, next) {
84
- const now = new Date();
85
- debug('executing an executableTask...', task, now);
86
- return (settings, options) => __awaiter(this, void 0, void 0, function* () {
87
- const taskRepo = new (yield Promise.resolve().then(() => require('../repo/task'))).TaskRepo(settings.connection);
88
- try {
89
- // 期限検証(2024-04-23~)
90
- if (task.expires instanceof Date) {
91
- const taskExpired = moment(now)
92
- .isAfter(task.expires);
93
- if (taskExpired) {
94
- throw new factory.errors.Internal(`task expired [expires:${task.expires}]`);
95
- }
96
- }
97
- // タスク名の関数が定義されていなければ、TypeErrorとなる
98
- let callResult;
99
- const { call } = yield Promise.resolve(`${`./task/${task.name}`}`).then(s => require(s));
100
- switch (task.name) {
101
- case factory.taskName.AcceptCOAOffer:
102
- case factory.taskName.AggregateOnSystem:
103
- case factory.taskName.AuthorizePayment:
104
- case factory.taskName.CancelPendingReservation:
105
- case factory.taskName.CheckMovieTicket:
106
- case factory.taskName.DeletePerson:
107
- case factory.taskName.HandleNotification:
108
- case factory.taskName.ImportEventCapacitiesFromCOA:
109
- case factory.taskName.ImportEventsFromCOA:
110
- case factory.taskName.ImportOffersFromCOA:
111
- case factory.taskName.InvalidatePaymentUrl:
112
- case factory.taskName.OnAuthorizationCreated:
113
- case factory.taskName.Pay:
114
- case factory.taskName.PublishPaymentUrl:
115
- case factory.taskName.Refund:
116
- case factory.taskName.VoidPayTransaction:
117
- case factory.taskName.VoidReserveTransaction:
118
- case factory.taskName.ConfirmReserveTransaction:
119
- case factory.taskName.ReturnPayTransaction:
120
- case factory.taskName.ReturnReserveTransaction:
121
- case factory.taskName.SendEmailMessage:
122
- case factory.taskName.TriggerWebhook:
123
- callResult = yield call(task)(settings, options);
124
- break;
125
- default:
126
- yield call(task.data)(settings);
127
- }
128
- const result = {
129
- executedAt: now,
130
- endDate: new Date(),
131
- // enable overwriting task.executionResults.error on Executed(2024-05-29~)
132
- error: ((callResult === null || callResult === void 0 ? void 0 : callResult.error) instanceof Error)
133
- ? Object.assign(Object.assign({}, callResult.error), { message: callResult.error.message }) : ''
134
- };
135
- yield taskRepo.pushExecutionResultById({
136
- id: task.id,
137
- status: factory.taskStatus.Executed
138
- }, result, (typeof next === 'function') ? next : undefined);
139
- }
140
- catch (error) {
141
- debug('service.task.execute throwed an error. task:', task.name, task.id, 'error:', error === null || error === void 0 ? void 0 : error.name, error === null || error === void 0 ? void 0 : error.message);
142
- if (typeof error !== 'object') {
143
- error = { message: String(error) };
144
- }
145
- // 実行結果追加
146
- const result = {
147
- executedAt: now,
148
- endDate: new Date(),
149
- error: Object.assign(Object.assign({}, error), { code: error.code, message: error.message, name: error.name, stack: error.stack })
150
- };
151
- // 失敗してもここではステータスを戻さない(Runningのまま待機)
152
- yield taskRepo.pushExecutionResultById({
153
- id: task.id,
154
- status: task.status
155
- }, result, (typeof next === 'function') ? next : undefined);
156
- }
157
- });
158
- }
159
- let notification;
160
- /**
161
- * add(2025-03-13~)
162
- */
163
- function notifyAbortedTasksByEmail(params) {
164
- return (repos, settings, credentials) => __awaiter(this, void 0, void 0, function* () {
165
- const { abortedTasksWithoutReport } = settings;
166
- const abortedTasks = yield repos.task.projectFields(Object.assign({ status: { $eq: factory.taskStatus.Aborted }, dateAborted: { $gte: params.dateAbortedGte } }, (abortedTasksWithoutReport.length > 0)
167
- ? { name: { $nin: abortedTasksWithoutReport } }
168
- : undefined), []);
169
- if (abortedTasks.length > 0) {
170
- if (notification === undefined) {
171
- notification = yield Promise.resolve().then(() => require('./notification'));
172
- }
173
- // 開発者へ報告
174
- const message = (0, factory_1.tasks2lineNotify)({ tasks: abortedTasks });
175
- const notifyResult = yield notification.notifyByEmail({
176
- subject: message.subject, content: message.content,
177
- logLevel: 'error'
178
- })({}, credentials);
179
- debug('notifyResult:', notifyResult);
180
- }
181
- });
182
- }
@@ -0,0 +1,26 @@
1
+ import { SendGridCredentials } from '../credentials/sendGrid';
2
+ import type { IExecuteSettings as IMinimumExecuteSettings, INextFunction } from '../eventEmitter/task';
3
+ import * as factory from '../factory';
4
+ import type { IExecutableTask, IExecutableTaskKeys } from '../repo/task';
5
+ import { Settings } from '../settings';
6
+ import { AggregationSettings } from '../settings/aggregation';
7
+ interface ICredentialSettings {
8
+ sendGrid: SendGridCredentials;
9
+ }
10
+ interface IExecuteSettings extends IMinimumExecuteSettings {
11
+ credentials: ICredentialSettings;
12
+ settings: Settings;
13
+ aggregationSettings?: AggregationSettings;
14
+ }
15
+ interface IExecuteOptions {
16
+ executeById: boolean;
17
+ executeByName: boolean;
18
+ }
19
+ type IOperationExecute<T> = (settings: IExecuteSettings, options: IExecuteOptions) => Promise<T>;
20
+ type ICallResult = void | Pick<factory.task.IExecutionResult, 'error'>;
21
+ type ICallableTaskOperation = (task: IExecutableTask<factory.taskName>) => IOperationExecute<ICallResult>;
22
+ /**
23
+ * タスクを実行する
24
+ */
25
+ declare function executeTask(task: IExecutableTask<factory.taskName>, next?: INextFunction): IOperationExecute<void>;
26
+ export { ICallableTaskOperation, ICallResult, IExecutableTaskKeys, IOperationExecute, executeTask };