@chevre/domain 26.0.0-alpha.3 → 26.0.0-alpha.30

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 (189) hide show
  1. package/lib/chevre/eventEmitter/task.d.ts +8 -23
  2. package/lib/chevre/eventEmitter/task.js +2 -2
  3. package/lib/chevre/repo/acceptedOffer.d.ts +0 -7
  4. package/lib/chevre/repo/acceptedOffer.js +27 -27
  5. package/lib/chevre/repo/action/actionProcess.d.ts +1 -1
  6. package/lib/chevre/repo/action/inform.d.ts +45 -0
  7. package/lib/chevre/repo/action/inform.js +159 -0
  8. package/lib/chevre/repo/action/update.d.ts +56 -0
  9. package/lib/chevre/repo/action/update.js +173 -0
  10. package/lib/chevre/repo/action.d.ts +3 -19
  11. package/lib/chevre/repo/action.js +0 -298
  12. package/lib/chevre/repo/adminAssetTransaction.d.ts +126 -0
  13. package/lib/chevre/repo/adminAssetTransaction.js +491 -0
  14. package/lib/chevre/repo/adminAsyncAction.d.ts +2 -2
  15. package/lib/chevre/repo/adminScheduledTask.d.ts +1 -1
  16. package/lib/chevre/repo/adminTask.d.ts +25 -8
  17. package/lib/chevre/repo/adminTask.js +31 -32
  18. package/lib/chevre/repo/adminTransaction.d.ts +131 -0
  19. package/lib/chevre/repo/adminTransaction.js +237 -0
  20. package/lib/chevre/repo/aggregateAssetTransaction.d.ts +43 -0
  21. package/lib/chevre/repo/aggregateAssetTransaction.js +166 -0
  22. package/lib/chevre/repo/aggregateScheduledTask.d.ts +32 -0
  23. package/lib/chevre/repo/aggregateScheduledTask.js +136 -0
  24. package/lib/chevre/repo/aggregateTransaction.d.ts +39 -0
  25. package/lib/chevre/repo/aggregateTransaction.js +166 -0
  26. package/lib/chevre/repo/aggregation.d.ts +0 -8
  27. package/lib/chevre/repo/aggregation.js +0 -10
  28. package/lib/chevre/repo/assetTransaction.d.ts +10 -235
  29. package/lib/chevre/repo/assetTransaction.js +48 -636
  30. package/lib/chevre/repo/asyncAction.d.ts +2 -2
  31. package/lib/chevre/repo/authorization.d.ts +0 -6
  32. package/lib/chevre/repo/authorization.js +15 -27
  33. package/lib/chevre/repo/message.d.ts +0 -7
  34. package/lib/chevre/repo/message.js +0 -38
  35. package/lib/chevre/repo/mongoose/schemas/{ownershipInfo.d.ts → action/inform.d.ts} +5 -5
  36. package/lib/chevre/repo/mongoose/schemas/action/inform.js +81 -0
  37. package/lib/chevre/repo/mongoose/schemas/action/update.d.ts +12 -0
  38. package/lib/chevre/repo/mongoose/schemas/action/update.js +107 -0
  39. package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -1
  40. package/lib/chevre/repo/mongoose/schemas/action.js +8 -1
  41. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +7 -0
  42. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +8 -9
  43. package/lib/chevre/repo/mongoose/schemas/aggregation.js +8 -1
  44. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +95 -76
  45. package/lib/chevre/repo/mongoose/schemas/authorization.js +25 -18
  46. package/lib/chevre/repo/mongoose/schemas/event.js +7 -0
  47. package/lib/chevre/repo/mongoose/schemas/eventOffer.js +7 -0
  48. package/lib/chevre/repo/mongoose/schemas/message.js +8 -1
  49. package/lib/chevre/repo/mongoose/schemas/pendingReservation.js +11 -4
  50. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +1 -0
  51. package/lib/chevre/repo/mongoose/schemas/task.d.ts +2 -5
  52. package/lib/chevre/repo/mongoose/schemas/task.js +134 -118
  53. package/lib/chevre/repo/mongoose/schemas/ticket.js +8 -1
  54. package/lib/chevre/repo/orderInTransaction.d.ts +0 -3
  55. package/lib/chevre/repo/orderInTransaction.js +30 -22
  56. package/lib/chevre/repo/scheduledTask.d.ts +5 -2
  57. package/lib/chevre/repo/scheduledTask.js +3 -25
  58. package/lib/chevre/repo/task.d.ts +45 -171
  59. package/lib/chevre/repo/task.js +20 -475
  60. package/lib/chevre/repo/taskDelayed.d.ts +74 -0
  61. package/lib/chevre/repo/taskDelayed.js +195 -0
  62. package/lib/chevre/repo/taskRunning.d.ts +35 -0
  63. package/lib/chevre/repo/taskRunning.js +89 -0
  64. package/lib/chevre/repo/ticket.d.ts +0 -6
  65. package/lib/chevre/repo/ticket.js +0 -11
  66. package/lib/chevre/repo/transaction.d.ts +1 -187
  67. package/lib/chevre/repo/transaction.js +2 -383
  68. package/lib/chevre/repository.d.ts +35 -5
  69. package/lib/chevre/repository.js +79 -13
  70. package/lib/chevre/service/aggregation/system.d.ts +17 -9
  71. package/lib/chevre/service/aggregation/system.js +46 -4
  72. package/lib/chevre/service/assetTransaction/cancelReservation/start.js +10 -17
  73. package/lib/chevre/service/assetTransaction/refund.js +2 -2
  74. package/lib/chevre/service/asyncAction.d.ts +2 -2
  75. package/lib/chevre/service/asyncAction.js +1 -4
  76. package/lib/chevre/service/asyncActionHandler/onOperationFailed.d.ts +2 -2
  77. package/lib/chevre/service/asyncActionHandler/onOperationFailed.js +0 -2
  78. package/lib/chevre/service/asyncActionHandler.d.ts +4 -4
  79. package/lib/chevre/service/asyncActionHandler.js +11 -13
  80. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +4 -2
  81. package/lib/chevre/service/event/processUpdateMovieTheater.js +3 -3
  82. package/lib/chevre/service/event.d.ts +4 -2
  83. package/lib/chevre/service/event.js +3 -3
  84. package/lib/chevre/service/notification/triggerWebhook.d.ts +4 -2
  85. package/lib/chevre/service/notification/triggerWebhook.js +5 -16
  86. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -3
  87. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +0 -4
  88. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +19 -19
  89. package/lib/chevre/service/offer/onEventChanged.js +0 -2
  90. package/lib/chevre/service/order/confirmPayTransaction.js +4 -1
  91. package/lib/chevre/service/order/deleteOrder.js +0 -1
  92. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +1 -49
  93. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.js +2 -2
  94. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +2 -4
  95. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +2 -4
  96. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +4 -4
  97. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
  98. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +2 -2
  99. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +2 -2
  100. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +3 -5
  101. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +2 -2
  102. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
  103. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +5 -7
  104. package/lib/chevre/service/order/onOrderUpdated/factory.js +0 -3
  105. package/lib/chevre/service/order/returnOrder.d.ts +0 -2
  106. package/lib/chevre/service/order/returnOrder.js +8 -40
  107. package/lib/chevre/service/order/sendOrder.d.ts +0 -2
  108. package/lib/chevre/service/order/sendOrder.js +41 -55
  109. package/lib/chevre/service/payment/any/findAcceptAction.d.ts +0 -4
  110. package/lib/chevre/service/payment/any/findAcceptAction.js +19 -19
  111. package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +0 -4
  112. package/lib/chevre/service/payment/any/findAuthorizeAction.js +19 -19
  113. package/lib/chevre/service/payment/any/findCheckAction.d.ts +0 -4
  114. package/lib/chevre/service/payment/any/findCheckAction.js +19 -19
  115. package/lib/chevre/service/payment/any/processVoidPayTransaction.js +1 -1
  116. package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +0 -2
  117. package/lib/chevre/service/payment/any/publishPaymentUrl.js +2 -2
  118. package/lib/chevre/service/project.d.ts +0 -3
  119. package/lib/chevre/service/project.js +0 -1
  120. package/lib/chevre/service/reserve/cancelReservation.js +3 -3
  121. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  122. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  123. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -2
  124. package/lib/chevre/service/reserve/useReservation.js +1 -1
  125. package/lib/chevre/service/scheduledTask.d.ts +1 -4
  126. package/lib/chevre/service/scheduledTask.js +3 -10
  127. package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.js +1 -2
  128. package/lib/chevre/service/scheduledTaskHandler.js +0 -13
  129. package/lib/chevre/service/task/acceptCOAOffer.js +1 -14
  130. package/lib/chevre/service/task/authorizePayment.js +1 -7
  131. package/lib/chevre/service/task/checkMovieTicket.js +1 -7
  132. package/lib/chevre/service/task/confirmReserveTransaction.js +3 -1
  133. package/lib/chevre/service/task/deleteTransaction.js +8 -39
  134. package/lib/chevre/service/task/importEventsFromCOA.js +4 -2
  135. package/lib/chevre/service/task/onAuthorizationCreated.js +2 -2
  136. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +4 -2
  137. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +4 -4
  138. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +4 -2
  139. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +4 -4
  140. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +4 -2
  141. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +4 -4
  142. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +4 -2
  143. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +4 -4
  144. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +4 -2
  145. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +4 -4
  146. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +4 -2
  147. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +4 -4
  148. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +4 -2
  149. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +4 -4
  150. package/lib/chevre/service/task/onResourceDeleted.js +4 -3
  151. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +0 -1
  152. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +0 -1
  153. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +0 -1
  154. package/lib/chevre/service/task/onResourceUpdated.js +0 -8
  155. package/lib/chevre/service/task/publishPaymentUrl.js +2 -13
  156. package/lib/chevre/service/task/returnOrder.js +2 -5
  157. package/lib/chevre/service/task/returnPayTransaction.js +2 -2
  158. package/lib/chevre/service/task/sendOrder.js +2 -2
  159. package/lib/chevre/service/task/syncResourcesFromCOA.js +31 -23
  160. package/lib/chevre/service/task/triggerWebhook.js +4 -2
  161. package/lib/chevre/service/task/voidReserveTransaction.js +5 -8
  162. package/lib/chevre/service/task.d.ts +3 -22
  163. package/lib/chevre/service/task.js +8 -40
  164. package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +0 -1
  165. package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +3 -2
  166. package/lib/chevre/service/taskHandler/onOperationFailed.js +5 -16
  167. package/lib/chevre/service/taskHandler.d.ts +1 -2
  168. package/lib/chevre/service/taskHandler.js +7 -19
  169. package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +2 -2
  170. package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +2 -2
  171. package/lib/chevre/service/transaction/deleteTransaction.d.ts +6 -2
  172. package/lib/chevre/service/transaction/deleteTransaction.js +5 -5
  173. package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
  174. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +8 -4
  175. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +55 -103
  176. package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +2 -0
  177. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +14 -10
  178. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.d.ts +13 -3
  179. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +48 -51
  180. package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
  181. package/lib/chevre/service/transaction/returnOrder.js +15 -13
  182. package/lib/chevre/service/transaction.d.ts +2 -0
  183. package/lib/chevre/service/transaction.js +0 -2
  184. package/lib/chevre/service/validation/validateOrder.js +2 -2
  185. package/lib/chevre/taskSettings.d.ts +4 -4
  186. package/package.json +2 -2
  187. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +0 -227
  188. package/lib/chevre/repo/ownershipInfo.d.ts +0 -122
  189. package/lib/chevre/repo/ownershipInfo.js +0 -466
@@ -1,16 +1,17 @@
1
1
  import type { AggregateActionRepo } from '../../repo/aggregateAction';
2
+ import type { AggregateAssetTransactionRepo } from '../../repo/aggregateAssetTransaction';
3
+ import type { AggregateScheduledTaskRepo } from '../../repo/aggregateScheduledTask';
2
4
  import type { AggregateTaskRepo } from '../../repo/aggregateTask';
3
- import { AggregationRepo } from '../../repo/aggregation';
4
- import type { AssetTransactionRepo } from '../../repo/assetTransaction';
5
+ import type { AggregateTransactionRepo } from '../../repo/aggregateTransaction';
6
+ import type { AggregationRepo } from '../../repo/aggregation';
5
7
  import type { EventRepo } from '../../repo/event';
6
- import { OrderRepo } from '../../repo/order';
7
- import type { TransactionRepo } from '../../repo/transaction';
8
+ import type { OrderRepo } from '../../repo/order';
8
9
  type AggregateDurationUnit = 'days' | 'hours';
9
10
  interface IAggregateParams {
10
11
  aggregateDate: Date;
11
12
  aggregateDurationUnit: AggregateDurationUnit;
12
13
  aggregationCount: number;
13
- excludedProjectId?: string;
14
+ excludedProjectId?: never;
14
15
  }
15
16
  declare function aggregateEvent(params: IAggregateParams): (repos: {
16
17
  agregation: AggregationRepo;
@@ -36,7 +37,7 @@ declare function aggregatePlaceOrder(params: IAggregateParams & {
36
37
  clientIds?: string[];
37
38
  }): (repos: {
38
39
  agregation: AggregationRepo;
39
- transaction: TransactionRepo;
40
+ aggregateTransaction: AggregateTransactionRepo;
40
41
  }) => Promise<{
41
42
  aggregationCount: number;
42
43
  aggregateDuration: string;
@@ -124,7 +125,7 @@ declare function aggregatePayMovieTicketAction(params: IAggregateParams): (repos
124
125
  }>;
125
126
  declare function aggregatePayTransaction(params: IAggregateParams): (repos: {
126
127
  agregation: AggregationRepo;
127
- assetTransaction: AssetTransactionRepo;
128
+ aggregateAssetTransaction: AggregateAssetTransactionRepo;
128
129
  }) => Promise<{
129
130
  aggregationCount: number;
130
131
  aggregateDuration: string;
@@ -134,7 +135,7 @@ declare function aggregatePayTransaction(params: IAggregateParams): (repos: {
134
135
  */
135
136
  declare function aggregateReserveTransaction(params: IAggregateParams): (repos: {
136
137
  agregation: AggregationRepo;
137
- assetTransaction: AssetTransactionRepo;
138
+ aggregateAssetTransaction: AggregateAssetTransactionRepo;
138
139
  }) => Promise<{
139
140
  aggregationCount: number;
140
141
  aggregateDuration: string;
@@ -146,4 +147,11 @@ declare function aggregateTask(params: IAggregateParams): (repos: {
146
147
  aggregationCount: number;
147
148
  aggregateDuration: string;
148
149
  }>;
149
- export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCancelReservationAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregateOrder, aggregateOrderAction, aggregatePayMovieTicketAction, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveAction, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
150
+ declare function aggregateScheduledTask(params: IAggregateParams): (repos: {
151
+ agregation: AggregationRepo;
152
+ aggregateScheduledTask: AggregateScheduledTaskRepo;
153
+ }) => Promise<{
154
+ aggregationCount: number;
155
+ aggregateDuration: string;
156
+ }>;
157
+ export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCancelReservationAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregateOrder, aggregateOrderAction, aggregatePayMovieTicketAction, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveAction, aggregateReserveTransaction, aggregateTask, aggregateScheduledTask, aggregateUseAction };
@@ -17,6 +17,7 @@ exports.aggregatePlaceOrder = aggregatePlaceOrder;
17
17
  exports.aggregateReserveAction = aggregateReserveAction;
18
18
  exports.aggregateReserveTransaction = aggregateReserveTransaction;
19
19
  exports.aggregateTask = aggregateTask;
20
+ exports.aggregateScheduledTask = aggregateScheduledTask;
20
21
  exports.aggregateUseAction = aggregateUseAction;
21
22
  const debug_1 = __importDefault(require("debug"));
22
23
  const moment_timezone_1 = __importDefault(require("moment-timezone"));
@@ -133,7 +134,7 @@ function aggregatePlaceOrder(params) {
133
134
  .add(-i, params.aggregateDurationUnit)
134
135
  .endOf(params.aggregateDurationUnit)
135
136
  .toDate();
136
- const aggregateResult = await repos.transaction.aggregatePlaceOrder({
137
+ const aggregateResult = await repos.aggregateTransaction.aggregatePlaceOrder({
137
138
  project: { id: { $ne: params.excludedProjectId } },
138
139
  startFrom,
139
140
  startThrough,
@@ -143,7 +144,7 @@ function aggregatePlaceOrder(params) {
143
144
  const aggregateResultsByClientId = [];
144
145
  if (Array.isArray(params.clientIds)) {
145
146
  for (const clientId of params.clientIds) {
146
- const aggregateResultByClientId = await repos.transaction.aggregatePlaceOrder({
147
+ const aggregateResultByClientId = await repos.aggregateTransaction.aggregatePlaceOrder({
147
148
  project: { id: { $ne: params.excludedProjectId } },
148
149
  startFrom,
149
150
  startThrough,
@@ -586,7 +587,7 @@ function aggregatePayTransaction(params) {
586
587
  .add(-i, params.aggregateDurationUnit)
587
588
  .endOf(params.aggregateDurationUnit)
588
589
  .toDate();
589
- const aggregateResult = await repos.assetTransaction.aggregateAssetTransaction({
590
+ const aggregateResult = await repos.aggregateAssetTransaction.aggregateAssetTransaction({
590
591
  project: { id: { $ne: params.excludedProjectId } },
591
592
  startFrom,
592
593
  startThrough,
@@ -631,7 +632,7 @@ function aggregateReserveTransaction(params) {
631
632
  .add(-i, params.aggregateDurationUnit)
632
633
  .endOf(params.aggregateDurationUnit)
633
634
  .toDate();
634
- const aggregateResult = await repos.assetTransaction.aggregateAssetTransaction({
635
+ const aggregateResult = await repos.aggregateAssetTransaction.aggregateAssetTransaction({
635
636
  project: { id: { $ne: params.excludedProjectId } },
636
637
  startFrom,
637
638
  startThrough,
@@ -692,3 +693,44 @@ function aggregateTask(params) {
692
693
  return { aggregationCount: i, aggregateDuration };
693
694
  };
694
695
  }
696
+ function aggregateScheduledTask(params) {
697
+ return async (repos) => {
698
+ const { aggregateDate } = params;
699
+ if (!(aggregateDate instanceof Date)) {
700
+ throw new factory_1.factory.errors.Argument('aggregateDate', 'must be Date');
701
+ }
702
+ const aggregateDuration = moment_timezone_1.default.duration(1, params.aggregateDurationUnit)
703
+ .toISOString();
704
+ let i = -1;
705
+ while (i < params.aggregationCount) {
706
+ i += 1;
707
+ const runsFrom = (0, moment_timezone_1.default)(aggregateDate)
708
+ .utc()
709
+ // .tz('Asia/Tokyo')
710
+ .add(-i, params.aggregateDurationUnit)
711
+ .startOf(params.aggregateDurationUnit)
712
+ .toDate();
713
+ const runsThrough = (0, moment_timezone_1.default)(aggregateDate)
714
+ .utc()
715
+ // .tz('Asia/Tokyo')
716
+ .add(-i, params.aggregateDurationUnit)
717
+ .endOf(params.aggregateDurationUnit)
718
+ .toDate();
719
+ const aggregateResult = await repos.aggregateScheduledTask.aggregateScheduledTask({
720
+ // project: { id: { $ne: params.excludedProjectId } },
721
+ runsFrom,
722
+ runsThrough
723
+ });
724
+ await repos.agregation.saveAggregation({
725
+ typeOf: factory_1.factory.aggregation.AggregationType.AggregateScheduledTask,
726
+ project: { id: '*', typeOf: factory_1.factory.organizationType.Project },
727
+ aggregateDuration,
728
+ aggregateStart: runsFrom,
729
+ aggregateDate,
730
+ ...aggregateResult
731
+ });
732
+ }
733
+ debug(i, 'aggregations saved');
734
+ return { aggregationCount: i, aggregateDuration };
735
+ };
736
+ }
@@ -11,30 +11,15 @@ function validateStartParams(params) {
11
11
  const sellerId = params.seller?.id;
12
12
  // 予約番号で取引存在確認
13
13
  if (typeof params.object.reservation?.reservationNumber === 'string') {
14
- const transactions = await repos.assetTransaction.search({
14
+ const transactions = await repos.assetTransaction.findAssetTransactionsByTypeOf({
15
15
  limit: 1,
16
16
  page: 1,
17
17
  typeOf: factory_1.factory.assetTransactionType.Reserve,
18
18
  object: {
19
- reservationNumber: { $eq: params.object.reservation.reservationNumber },
20
- // 販売者検証(2023-08-01~)
21
- ...(typeof sellerId === 'string') ? { provider: { id: { $eq: sellerId } } } : undefined
19
+ reservationNumber: { $eq: params.object.reservation.reservationNumber }
22
20
  }
23
21
  });
24
22
  reserveTransaction = transactions.shift();
25
- // ここでReservationConfirmedでない予約をスルーしても、
26
- // ReservationRepo.cancel()で冪等性を保証しているのでvalidation不要か(2022-05-12~)
27
- // 予約ステータス確認
28
- // const unconfirmedReservations = await repos.reservation.search({
29
- // limit: 1,
30
- // page: 1,
31
- // typeOf: factory.reservationType.EventReservation,
32
- // reservationNumber: { $eq: params.object.reservation.reservationNumber },
33
- // reservationStatus: { $ne: factory.reservationStatusType.ReservationConfirmed }
34
- // });
35
- // if (unconfirmedReservations.length > 0) {
36
- // throw new factory.errors.Argument('object.reservation.reservationNumber', `Reservation ${unconfirmedReservations[0].id} not confirmed`);
37
- // }
38
23
  }
39
24
  // 取引指定が確認できなければ、予約指定を確認
40
25
  if (reserveTransaction === undefined) {
@@ -59,6 +44,14 @@ function validateStartParams(params) {
59
44
  reservations = [reservation];
60
45
  }
61
46
  }
47
+ else {
48
+ // 販売者検証(2023-08-01~)
49
+ if (typeof sellerId === 'string') {
50
+ if (reserveTransaction.object.provider?.id !== sellerId) {
51
+ throw new factory_1.factory.errors.NotFound(factory_1.factory.reservationType.EventReservation);
52
+ }
53
+ }
54
+ }
62
55
  if (reserveTransaction === undefined && reservations === undefined) {
63
56
  throw new factory_1.factory.errors.Argument('object', 'Transaction or reservation must be specified');
64
57
  }
@@ -135,12 +135,12 @@ function confirm(params) {
135
135
  else {
136
136
  throw new factory_1.factory.errors.ArgumentNull('Transaction ID or Transaction Number');
137
137
  }
138
- const payTransaction = (await repos.assetTransaction.search({
138
+ const payTransaction = (await repos.assetTransaction.findAssetTransactionsByTypeOf({
139
139
  limit: 1,
140
140
  page: 1,
141
141
  typeOf: factory_1.factory.assetTransactionType.Pay,
142
142
  transactionNumber: { $eq: transaction.object.paymentMethodId }
143
- }, ['recipient'], [])).shift();
143
+ }, ['recipient'])).shift();
144
144
  if (payTransaction === undefined) {
145
145
  throw new factory_1.factory.errors.NotFound(factory_1.factory.assetTransactionType.Pay);
146
146
  }
@@ -1,4 +1,4 @@
1
- import type { IExecuteSettings as IMinimumExecuteSettings, INextFunction } from '../eventEmitter/task';
1
+ import type { IExecuteSettings as IMinimumExecuteSettings, IAsyncActionNextFunction } from '../eventEmitter/task';
2
2
  type IExecuteSettings = IMinimumExecuteSettings;
3
3
  type IOperation<T> = (settings: IExecuteSettings) => Promise<T>;
4
4
  declare function executeAsyncActionById(params: {
@@ -12,5 +12,5 @@ declare function executeAsyncActionById(params: {
12
12
  */
13
13
  name: string;
14
14
  };
15
- }, next?: INextFunction): IOperation<void>;
15
+ }, next: IAsyncActionNextFunction): IOperation<void>;
16
16
  export { executeAsyncActionById };
@@ -27,10 +27,7 @@ function executeAsyncActionById(params, next) {
27
27
  }
28
28
  // タスクがなければ終了
29
29
  if (task !== null) {
30
- await (0, asyncActionHandler_1.executeAsyncAction)(task, (typeof next === 'function') ? next : undefined)(settings, {
31
- executeById: true,
32
- executeByName: false
33
- });
30
+ await (0, asyncActionHandler_1.executeAsyncAction)(task, next)(settings, {});
34
31
  }
35
32
  };
36
33
  }
@@ -1,4 +1,4 @@
1
- import type { IExecutedTask } from '../../eventEmitter/task';
1
+ import type { ITaskAsNextFunctionParam } from '../../eventEmitter/task';
2
2
  import type { AsyncActionRepo, IExecutableAsyncAction } from '../../repo/asyncAction';
3
3
  /**
4
4
  * タスク実行失敗時処理
@@ -10,6 +10,6 @@ declare function onOperationFailed(params: {
10
10
  }): (repos: {
11
11
  asyncAction: AsyncActionRepo;
12
12
  }) => Promise<{
13
- executedTask: IExecutedTask;
13
+ executedTask: ITaskAsNextFunctionParam;
14
14
  }>;
15
15
  export { onOperationFailed };
@@ -32,10 +32,8 @@ function onOperationFailed(params) {
32
32
  });
33
33
  const executedTask = {
34
34
  id: task.id,
35
- remainingNumberOfTries: 0,
36
35
  name: task.name,
37
36
  status: factory_1.factory.taskStatus.Aborted,
38
- executionResult: result
39
37
  };
40
38
  return { executedTask };
41
39
  };
@@ -1,5 +1,5 @@
1
- import type { INextFunction } from '../eventEmitter/task';
2
- import type { ICallResult, ICallableTaskOperation, IExecutableTaskKeys, IOperationExecute } from '../taskSettings';
1
+ import type { IAsyncActionNextFunction } from '../eventEmitter/task';
2
+ import type { ICallableTaskOperation, IOperationExecute } from '../taskSettings';
3
3
  import type { IExecutableAsyncAction } from '../repo/asyncAction';
4
4
  export declare const taskLoader: {
5
5
  load: (taskName: string) => Promise<{
@@ -9,5 +9,5 @@ export declare const taskLoader: {
9
9
  /**
10
10
  * 非同期アクションを実行する
11
11
  */
12
- declare function executeAsyncAction(task: IExecutableAsyncAction, next?: INextFunction): IOperationExecute<void>;
13
- export { ICallableTaskOperation, ICallResult, IExecutableTaskKeys, IOperationExecute, executeAsyncAction };
12
+ declare function executeAsyncAction(task: IExecutableAsyncAction, next: IAsyncActionNextFunction): IOperationExecute<void>;
13
+ export { executeAsyncAction };
@@ -5,11 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.taskLoader = void 0;
7
7
  exports.executeAsyncAction = executeAsyncAction;
8
- const debug_1 = __importDefault(require("debug"));
9
8
  const moment_1 = __importDefault(require("moment"));
10
9
  const factory_1 = require("../factory");
11
10
  const onOperationFailed_1 = require("./asyncActionHandler/onOperationFailed");
12
- const debug = (0, debug_1.default)('chevre-domain:service:asyncActionHandler');
13
11
  exports.taskLoader = {
14
12
  load: (taskName) => {
15
13
  return import(`./task/${taskName}.js`);
@@ -20,10 +18,9 @@ exports.taskLoader = {
20
18
  */
21
19
  function executeAsyncAction(task, next) {
22
20
  const now = new Date();
23
- debug('executing an executableTask...', task, now);
24
21
  return async (settings, options) => {
25
22
  const asyncActionRepo = new (await import('../repo/asyncAction.js')).AsyncActionRepo(settings.connection);
26
- let executedTask;
23
+ let taskAsNextFunctionParam;
27
24
  try {
28
25
  // 期限検証(2024-04-23~)
29
26
  if (task.expires instanceof Date) {
@@ -57,32 +54,33 @@ function executeAsyncAction(task, next) {
57
54
  status: factory_1.factory.taskStatus.Executed,
58
55
  executionResult: result
59
56
  });
60
- executedTask = {
57
+ taskAsNextFunctionParam = {
61
58
  id: task.id,
62
- remainingNumberOfTries: 0, // one timeの前提なのでひとまず固定で0
63
59
  name: task.name,
64
60
  status: factory_1.factory.taskStatus.Executed,
65
- executionResult: result
66
61
  };
67
62
  }
68
63
  catch (error) {
69
64
  const onOperationFailedResult = await (0, onOperationFailed_1.onOperationFailed)({
70
65
  task, now, error,
71
66
  })({ asyncAction: asyncActionRepo });
72
- executedTask = onOperationFailedResult.executedTask;
67
+ taskAsNextFunctionParam = {
68
+ id: onOperationFailedResult.executedTask.id,
69
+ name: onOperationFailedResult.executedTask.name,
70
+ status: onOperationFailedResult.executedTask.status
71
+ };
72
+ ;
73
73
  }
74
74
  finally {
75
75
  if (typeof next === 'function') {
76
- if (executedTask === undefined) {
77
- executedTask = {
76
+ if (taskAsNextFunctionParam === undefined) {
77
+ taskAsNextFunctionParam = {
78
78
  id: task.id,
79
- remainingNumberOfTries: 0, // one timeの前提なのでひとまず固定で0
80
79
  name: task.name,
81
80
  status: factory_1.factory.taskStatus.Aborted,
82
- executionResult: {} // eslint-disable-line @typescript-eslint/no-explicit-any
83
81
  };
84
82
  }
85
- await next(executedTask)(settings);
83
+ await next(taskAsNextFunctionParam)(settings);
86
84
  }
87
85
  }
88
86
  };
@@ -1,5 +1,5 @@
1
1
  import type { COA } from '@motionpicture/coa-service';
2
- import type { ActionRepo } from '../../repo/action';
2
+ import type { UpdateActionRepo } from '../../repo/action/update';
3
3
  import type { CategoryCodeRepo } from '../../repo/categoryCode';
4
4
  import type { MovieTheaterRepo } from '../../repo/place/movieTheater';
5
5
  import type { ScreeningRoomRepo } from '../../repo/place/screeningRoom';
@@ -9,7 +9,9 @@ import { IImportFromCOAParams } from './factory';
9
9
  type IMovieTheater = Pick<factory.place.movieTheater.IPlace, 'id' | 'typeOf' | 'branchCode' | 'name' | 'kanaName'>;
10
10
  declare function processUpdateMovieTheater(params: IImportFromCOAParams): (repos: {
11
11
  masterService: COA.service.Master;
12
- action: ActionRepo;
12
+ actions: {
13
+ update: UpdateActionRepo;
14
+ };
13
15
  categoryCode: CategoryCodeRepo;
14
16
  movieTheater: MovieTheaterRepo;
15
17
  screeningRoom: ScreeningRoomRepo;
@@ -20,7 +20,7 @@ function processUpdateMovieTheater(params) {
20
20
  },
21
21
  targetCollection: { typeOf: factory_1.factory.placeType.MovieTheater }
22
22
  };
23
- const action = await repos.action.start(actionAttributes);
23
+ const action = await repos.actions.update.startUpdateAction(actionAttributes);
24
24
  let seller;
25
25
  let movieTheater;
26
26
  let screeningRooms;
@@ -66,7 +66,7 @@ function processUpdateMovieTheater(params) {
66
66
  }
67
67
  catch (error) {
68
68
  try {
69
- await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
69
+ await repos.actions.update.giveUpUpdateAction({ typeOf: action.typeOf, id: action.id, error });
70
70
  }
71
71
  catch (__) {
72
72
  // 失敗したら仕方ない
@@ -77,7 +77,7 @@ function processUpdateMovieTheater(params) {
77
77
  screeningRoomsCount: screeningRooms.length,
78
78
  ...(processTime !== undefined) ? { processTime } : undefined
79
79
  };
80
- await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
80
+ await repos.actions.update.completeUpdateAction({ typeOf: action.typeOf, id: action.id, result: actionResult });
81
81
  return { seller, movieTheater, screeningRooms };
82
82
  };
83
83
  }
@@ -2,7 +2,7 @@
2
2
  * マスターデータ同期サービス
3
3
  */
4
4
  import type { COA } from '@motionpicture/coa-service';
5
- import type { ActionRepo } from '../repo/action';
5
+ import type { UpdateActionRepo } from '../repo/action/update';
6
6
  import type { CategoryCodeRepo } from '../repo/categoryCode';
7
7
  import type { CreativeWorkRepo } from '../repo/creativeWork';
8
8
  import type { EventRepo } from '../repo/event';
@@ -17,7 +17,9 @@ import { saveScreeningEventSeries } from './event/saveScreeningEventSeries';
17
17
  * イベントをインポートする
18
18
  */
19
19
  declare function importFromCOA(params: IImportFromCOAParams): (repos: {
20
- action: ActionRepo;
20
+ actions: {
21
+ update: UpdateActionRepo;
22
+ };
21
23
  categoryCode: CategoryCodeRepo;
22
24
  creativeWork: CreativeWorkRepo;
23
25
  event: EventRepo;
@@ -70,7 +70,7 @@ function importFromCOA(params) {
70
70
  instrument,
71
71
  targetCollection: { typeOf: factory_1.factory.eventType.ScreeningEvent }
72
72
  };
73
- const action = await repos.action.start(actionAttributes);
73
+ const action = await repos.actions.update.startUpdateAction(actionAttributes);
74
74
  let savedScreeningEventsCount = 0;
75
75
  let savedScreeningEventSeriesCount = 0;
76
76
  let cancelledIds = [];
@@ -131,7 +131,7 @@ function importFromCOA(params) {
131
131
  }
132
132
  catch (error) {
133
133
  try {
134
- await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
134
+ await repos.actions.update.giveUpUpdateAction({ typeOf: action.typeOf, id: action.id, error });
135
135
  }
136
136
  catch (__) {
137
137
  // 失敗したら仕方ない
@@ -144,7 +144,7 @@ function importFromCOA(params) {
144
144
  savedScreeningEventSeriesCount,
145
145
  ...(processTime !== undefined) ? { processTime } : undefined
146
146
  };
147
- await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
147
+ await repos.actions.update.completeUpdateAction({ typeOf: action.typeOf, id: action.id, result: actionResult });
148
148
  };
149
149
  }
150
150
  function cancelDeletedEvents(params) {
@@ -1,9 +1,11 @@
1
1
  import { factory } from '../../factory';
2
- import type { ActionRepo } from '../../repo/action';
2
+ import type { InformActionRepo } from '../../repo/action/inform';
3
3
  import type { PotentialActionRepo } from '../../repo/potentialAction';
4
4
  import type { SettingRepo } from '../../repo/setting';
5
5
  interface ITriggerWebhookRepos {
6
- action: ActionRepo;
6
+ actions: {
7
+ inform: InformActionRepo;
8
+ };
7
9
  potentialAction: PotentialActionRepo;
8
10
  setting: SettingRepo;
9
11
  }
@@ -88,18 +88,7 @@ function createInformActionAttributes(params) {
88
88
  const { about, object, purpose, recipient, project, id, typeOf } = params;
89
89
  // redefine recipient(2025-02-15~)
90
90
  let informRecipient;
91
- // let informRecipient: factory.action.interact.inform.IRecipient | factory.action.interact.inform.IRecipientDeprecated = {
92
- // ...recipient
93
- // // url: target.urlTemplate // discontinue(2025-02-15~)
94
- // };
95
- if (recipient?.typeOf === factory_1.factory.organizationType.Corporation && typeof recipient.id === 'string') {
96
- informRecipient = {
97
- id: recipient.id,
98
- name: recipient.name,
99
- typeOf: recipient.typeOf
100
- };
101
- }
102
- else if (recipient?.typeOf === factory_1.factory.creativeWorkType.WebApplication) {
91
+ if (recipient?.typeOf === factory_1.factory.creativeWorkType.WebApplication) {
103
92
  informRecipient = {
104
93
  name: recipient.name,
105
94
  typeOf: recipient.typeOf
@@ -139,9 +128,9 @@ function createInformActionAttributes(params) {
139
128
  project: { id: project.id, typeOf: factory_1.factory.organizationType.Project },
140
129
  recipient: informRecipient,
141
130
  typeOf: factory_1.factory.actionType.InformAction,
131
+ target, // add(2025-02-06~)
142
132
  ...(typeof purpose?.typeOf === 'string') ? { purpose } : undefined,
143
133
  ...(typeof about?.typeOf === 'string') ? { about } : undefined, // add(2025-01-23~)
144
- ...(typeof target?.typeOf === 'string') ? { target } : undefined // add(2025-02-06~)
145
134
  };
146
135
  };
147
136
  }
@@ -159,7 +148,7 @@ function processInformAction(params, options) {
159
148
  const headerIdentifier = options?.triggerWebhook?.headerIdentifier;
160
149
  const { identifier } = params;
161
150
  const informActionAttributes = await createInformActionAttributes(params)(repos);
162
- const action = await repos.action.start(informActionAttributes);
151
+ const action = await repos.actions.inform.startInformAction(informActionAttributes);
163
152
  let result = {};
164
153
  try {
165
154
  const urlTemplate = informActionAttributes.target?.urlTemplate;
@@ -226,13 +215,13 @@ function processInformAction(params, options) {
226
215
  }
227
216
  catch (error) {
228
217
  try {
229
- await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
218
+ await repos.actions.inform.giveUpInformAction({ typeOf: action.typeOf, id: action.id, error });
230
219
  }
231
220
  catch (__) {
232
221
  // 失敗したら仕方ない
233
222
  }
234
223
  throw error;
235
224
  }
236
- await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
225
+ await repos.actions.inform.completeInformAction({ typeOf: action.typeOf, id: action.id, result: result });
237
226
  };
238
227
  }
@@ -2,15 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processVoidTransaction4chevre = processVoidTransaction4chevre;
4
4
  const factory_1 = require("../../../../factory");
5
- // import type { TransactionRepo } from '../../../../repo/transaction';
6
5
  const reserve_1 = require("../../../assetTransaction/reserve");
7
6
  function processVoidTransaction4chevre(params) {
8
7
  return async (repos, settings) => {
9
- // const transactionNumber = params.action.object.pendingTransaction?.transactionNumber;
10
8
  const transactionNumber = params.action.instrument.transactionNumber;
11
9
  if (typeof transactionNumber === 'string') {
12
10
  // 取引が存在すれば中止
13
- const assetTransactions = await repos.assetTransaction.search({
11
+ const assetTransactions = await repos.assetTransaction.findAssetTransactionsByTypeOf({
14
12
  limit: 1,
15
13
  page: 1,
16
14
  project: { id: { $eq: params.action.project.id } },
@@ -1,7 +1,6 @@
1
1
  import { factory } from '../../../factory';
2
2
  import type { AcceptCOAOfferActionRepo } from '../../../repo/action/acceptCOAOffer';
3
3
  import type { AsyncActionRepo } from '../../../repo/asyncAction';
4
- import type { TaskRepo } from '../../../repo/task';
5
4
  interface IFindAcceptActionResult {
6
5
  /**
7
6
  * アクションID
@@ -35,11 +34,8 @@ declare function findAcceptAction(params: {
35
34
  */
36
35
  id: string;
37
36
  };
38
- }, options: {
39
- useAsyncAction: boolean;
40
37
  }): (repos: {
41
38
  action: AcceptCOAOfferActionRepo;
42
39
  asyncAction: AsyncActionRepo;
43
- task: TaskRepo;
44
40
  }) => Promise<IFindAcceptActionResult>;
45
41
  export { findAcceptAction };
@@ -2,27 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findAcceptAction = findAcceptAction;
4
4
  const factory_1 = require("../../../factory");
5
- function findAcceptAction(params, options) {
5
+ function findAcceptAction(params) {
6
6
  return async (repos) => {
7
7
  // 非同期アクションに対応(2026-07-27~)
8
- const { useAsyncAction } = options;
9
- let task;
10
- if (useAsyncAction) {
11
- // まず非同期アクションを参照
12
- task = await repos.asyncAction.findAsyncActionById({
13
- id: { $eq: params.sameAs.id },
14
- project: { id: { $eq: params.project.id } },
15
- name: factory_1.factory.taskName.AcceptCOAOffer
16
- }, ['status', 'executionResults']);
17
- }
18
- // 非同期アクションが存在しなければタスクを参照
19
- if (task === undefined) {
20
- task = await repos.task.findTaskById({
21
- id: { $eq: params.sameAs.id },
22
- project: { id: { $eq: params.project.id } },
23
- name: factory_1.factory.taskName.AcceptCOAOffer
24
- }, ['status', 'executionResults']);
25
- }
8
+ // let task: Pick<factory.task.acceptCOAOffer.ITask, 'id' | 'status' | 'executionResults'> | undefined;
9
+ // まず非同期アクションを参照
10
+ const task = await repos.asyncAction.findAsyncActionById({
11
+ id: { $eq: params.sameAs.id },
12
+ project: { id: { $eq: params.project.id } },
13
+ name: factory_1.factory.taskName.AcceptCOAOffer
14
+ }, ['status', 'executionResults']);
15
+ // // 非同期アクションが存在しなければタスクを参照
16
+ // if (task === undefined) {
17
+ // task = await repos.task.findTaskById(
18
+ // {
19
+ // id: { $eq: params.sameAs.id },
20
+ // project: { id: { $eq: params.project.id } },
21
+ // name: factory.taskName.AcceptCOAOffer
22
+ // },
23
+ // ['status', 'executionResults']
24
+ // );
25
+ // }
26
26
  if (task === undefined) {
27
27
  throw new factory_1.factory.errors.NotFound(factory_1.factory.taskName.AcceptCOAOffer);
28
28
  }
@@ -203,7 +203,6 @@ function createInformTasks(params, setting) {
203
203
  const informActionAttributes = {
204
204
  object: event4inform,
205
205
  recipient: {
206
- id: '',
207
206
  name: String(informEvent.recipient?.name),
208
207
  typeOf: factory_1.factory.creativeWorkType.WebApplication
209
208
  // url: informUrl // discontinue(2025-02-13~)
@@ -257,7 +256,6 @@ function createInform2aggTasks(params, setting) {
257
256
  const informActionAttributes = {
258
257
  object: informObject,
259
258
  recipient: {
260
- id: '',
261
259
  name: String(informEvent.recipient?.name),
262
260
  typeOf: factory_1.factory.creativeWorkType.WebApplication
263
261
  // url: informUrl // discontinue(2025-02-13~)