@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,282 +1,18 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ActionRepo = void 0;
7
- const moment_1 = __importDefault(require("moment"));
8
4
  const factory_1 = require("../factory");
9
- // import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
10
5
  const actionProcess_1 = require("./action/actionProcess");
11
6
  /**
12
7
  * アクションリポジトリ
13
8
  */
14
9
  class ActionRepo extends actionProcess_1.ActionProcessRepo {
15
- // private readonly actionModel: IActionModel;
16
- // private readonly actionRecipeModel: IActionRecipeModel;
17
- // constructor(connection: Connection) {
18
- // this.actionModel = connection.model(modelName, createSchema());
19
- // this.actionRecipeModel = connection.model(recipeModelName, createRecipeSchema());
20
- // }
21
10
  /**
22
11
  * 汎用アクション検索
23
12
  */
24
13
  async findActionsByType(params, inclusion) {
25
14
  return (this.findAnyActions(params, inclusion));
26
15
  }
27
- // /**
28
- // * アクション開始
29
- // */
30
- // public async start<T extends factory.actionType>(
31
- // attributes: factory.action.IAttributes<T, any, any>,
32
- // options?: {
33
- // recipe?: IRecipeAsActionAttributes;
34
- // }
35
- // ): Promise<Pick<IAction<T>, 'id' | 'typeOf' | 'startDate'>> {
36
- // const startDate = new Date();
37
- // const creatingAction: Omit<factory.action.IAction<factory.action.IAttributes<T, any, any>>, 'id'> = {
38
- // ...attributes,
39
- // actionStatus: factory.actionStatusType.ActiveActionStatus,
40
- // startDate
41
- // };s
42
- // // reimplemnt with insertMany(2024-08-29~)
43
- // const result = await this.actionModel.insertMany(creatingAction, { rawResult: true });
44
- // const id = result.insertedIds?.[0]?.toHexString();
45
- // if (typeof id !== 'string') {
46
- // throw new factory.errors.Internal('action not saved');
47
- // }
48
- // // add recipe(2024-06-09~)
49
- // const savingRecipe = options?.recipe;
50
- // if (savingRecipe?.typeOf === 'Recipe') {
51
- // await this.upsertRecipe({ ...savingRecipe, recipeFor: { id, typeOf: creatingAction.typeOf } });
52
- // }
53
- // return { id, startDate, typeOf: creatingAction.typeOf };
54
- // }
55
- // public async completeWithVoid(params: {
56
- // typeOf: factory.actionType;
57
- // id: string;
58
- // result: any;
59
- // recipe?: IRecipeAsActionAttributes;
60
- // }): Promise<void> {
61
- // if (params.recipe?.typeOf === 'Recipe') {
62
- // await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
63
- // }
64
- // const doc = await this.actionModel.findOneAndUpdate(
65
- // {
66
- // _id: { $eq: params.id },
67
- // typeOf: { $eq: params.typeOf }
68
- // },
69
- // {
70
- // $set: {
71
- // actionStatus: factory.actionStatusType.CompletedActionStatus,
72
- // result: params.result,
73
- // endDate: new Date()
74
- // }
75
- // },
76
- // { new: false, projection: { _id: 1 } }
77
- // )
78
- // .lean<{ _id: ObjectId }>()
79
- // .exec();
80
- // if (doc === null) {
81
- // throw new factory.errors.NotFound(this.actionModel.modelName);
82
- // }
83
- // }
84
- // /**
85
- // * アクション取消
86
- // */
87
- // public async cancelWithVoid(params: {
88
- // typeOf: factory.actionType.AcceptAction | factory.actionType.AuthorizeAction; // 現時点でAcceptAction,AuthorizeActionのみ対応
89
- // id: string;
90
- // cancelAction?: Pick<ICancelActionAction, 'agent' | 'sameAs' | 'startTime'>;
91
- // }): Promise<void> {
92
- // const cancelDate = new Date();
93
- // const cancelAction: ICancelActionAction | undefined = (params.cancelAction !== undefined)
94
- // ? {
95
- // ...params.cancelAction,
96
- // endTime: cancelDate,
97
- // typeOf: factory.actionType.CancelAction
98
- // }
99
- // : undefined;
100
- // const doc = await this.actionModel.findOneAndUpdate(
101
- // {
102
- // _id: { $eq: params.id },
103
- // typeOf: { $eq: params.typeOf },
104
- // actionStatus: { $ne: factory.actionStatusType.CanceledActionStatus } // 冪等性確保(2024-05-26~)
105
- // },
106
- // {
107
- // $set: {
108
- // actionStatus: factory.actionStatusType.CanceledActionStatus,
109
- // ...(cancelAction !== undefined) ? { cancelAction } : undefined // cancelAction連携(2024-05-26~)
110
- // }
111
- // },
112
- // { new: false, projection: { _id: 1 } }
113
- // )
114
- // .lean<{ _id: ObjectId }>()
115
- // .exec();
116
- // if (doc === null) {
117
- // // 既にCanceledActionStatusであればok
118
- // const existingAction = <Pick<IAction<typeof params.typeOf>, 'actionStatus'>>
119
- // await this.findById({ id: params.id, typeOf: params.typeOf }, ['actionStatus'], []);
120
- // if (existingAction.actionStatus !== factory.actionStatusType.CanceledActionStatus) {
121
- // throw new factory.errors.NotFound(this.actionModel.modelName);
122
- // }
123
- // }
124
- // // endDateが存在しなければセット(2024-04-22~)
125
- // await this.actionModel.updateOne(
126
- // {
127
- // _id: { $eq: params.id },
128
- // endDate: { $exists: false }
129
- // },
130
- // { $set: { endDate: cancelDate } }
131
- // )
132
- // .exec();
133
- // }
134
- // /**
135
- // * アクション失敗
136
- // */
137
- // public async giveUp(params: {
138
- // typeOf: factory.actionType;
139
- // id: string;
140
- // error: Error | Error[];
141
- // recipe?: IRecipeAsActionAttributes;
142
- // }): Promise<void> {
143
- // const actionError: IActionError | IActionError[] = (Array.isArray(params.error))
144
- // ? params.error.map((e) => ({ ...e, message: e.message, name: e.name }))
145
- // : { ...params.error, message: params.error.message, name: params.error.name };
146
- // if (params.recipe?.typeOf === 'Recipe') {
147
- // await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
148
- // }
149
- // const doc = await this.actionModel.findOneAndUpdate(
150
- // {
151
- // typeOf: { $eq: params.typeOf },
152
- // _id: { $eq: params.id }
153
- // },
154
- // {
155
- // $set: {
156
- // actionStatus: factory.actionStatusType.FailedActionStatus,
157
- // error: actionError,
158
- // endDate: new Date()
159
- // }
160
- // },
161
- // { new: true, projection: { _id: 1 } }
162
- // )
163
- // .lean<{ _id: ObjectId }>()
164
- // .exec();
165
- // if (doc === null) {
166
- // throw new factory.errors.NotFound(this.actionModel.modelName);
167
- // }
168
- // }
169
- // /**
170
- // * アクション再開
171
- // */
172
- // public async reStart(params: {
173
- // typeOf: factory.actionType;
174
- // id: string;
175
- // recipe?: IRecipeAsActionAttributes;
176
- // }): Promise<void> {
177
- // const doc = await this.actionModel.findOneAndUpdate(
178
- // {
179
- // _id: { $eq: params.id },
180
- // typeOf: { $eq: params.typeOf },
181
- // actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
182
- // },
183
- // {
184
- // $set: {
185
- // actionStatus: factory.actionStatusType.ActiveActionStatus,
186
- // startDate: new Date()
187
- // },
188
- // $unset: { endDate: 1 }
189
- // },
190
- // { new: false, projection: { _id: 1 } }
191
- // )
192
- // .lean<{ _id: ObjectId }>()
193
- // .exec();
194
- // if (doc === null) {
195
- // throw new factory.errors.NotFound(this.actionModel.modelName);
196
- // }
197
- // // add recipe(2024-06-09~)
198
- // if (params.recipe?.typeOf === 'Recipe') {
199
- // await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
200
- // }
201
- // }
202
- // /**
203
- // * 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
204
- // */
205
- // public async giveUpStartDatePassedCertainPeriod(params: {
206
- // id?: { $eq?: string };
207
- // error: any;
208
- // startDate: { $lt: Date };
209
- // }): Promise<any> {
210
- // return this.actionModel.updateMany(
211
- // {
212
- // actionStatus: { $eq: factory.actionStatusType.ActiveActionStatus },
213
- // // 一定期間過ぎたもの
214
- // startDate: { $lt: params.startDate.$lt },
215
- // ...(typeof params.id?.$eq === 'string') ? { _id: { $eq: params.id.$eq } } : undefined
216
- // },
217
- // {
218
- // actionStatus: factory.actionStatusType.FailedActionStatus,
219
- // error: params.error,
220
- // endDate: new Date()
221
- // }
222
- // )
223
- // .exec();
224
- // }
225
- // public async findById<T extends factory.actionType>(
226
- // params: {
227
- // typeOf: T;
228
- // id: string;
229
- // },
230
- // inclusion?: IKeyOfProjection[],
231
- // exclusion?: IKeyOfProjection[]
232
- // ): Promise<IAction<T>> {
233
- // let positiveProjectionFields: IKeyOfProjection[] = AVAILABLE_PROJECT_FIELDS;
234
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
235
- // positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
236
- // } else {
237
- // if (Array.isArray(exclusion) && exclusion.length > 0) {
238
- // positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
239
- // }
240
- // }
241
- // const projection: ProjectionType<IAction<T>> = {
242
- // _id: 0,
243
- // id: { $toString: '$_id' },
244
- // ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
245
- // };
246
- // const doc = await this.actionModel.findOne(
247
- // {
248
- // typeOf: { $eq: params.typeOf },
249
- // _id: { $eq: params.id }
250
- // },
251
- // projection
252
- // )
253
- // .lean<IAction<T>>() // 2024-08-26~
254
- // .exec();
255
- // if (doc === null) {
256
- // throw new factory.errors.NotFound(this.actionModel.modelName);
257
- // }
258
- // return doc;
259
- // }
260
- // public async findPayAction(params: {
261
- // project: { id: string };
262
- // paymentMethodId: string;
263
- // actionStatus?: { $in?: factory.actionStatusType[] };
264
- // }): Promise<factory.action.trade.pay.IAction | undefined> {
265
- // const payActions = await this.findActionsByType<factory.actionType.PayAction>(
266
- // {
267
- // limit: 1,
268
- // page: 1,
269
- // actionStatus: (Array.isArray(params.actionStatus?.$in))
270
- // ? { $in: params.actionStatus?.$in }
271
- // : { $in: [factory.actionStatusType.CompletedActionStatus] },
272
- // project: { id: { $eq: params.project.id } },
273
- // typeOf: { $eq: factory.actionType.PayAction },
274
- // object: { paymentMethod: { paymentMethodId: { $eq: params.paymentMethodId } } }
275
- // },
276
- // []
277
- // ) as factory.action.trade.pay.IAction[];
278
- // return payActions.shift();
279
- // }
280
16
  /**
281
17
  * 取引に対するアクションを検索する
282
18
  */
@@ -374,40 +110,6 @@ class ActionRepo extends actionProcess_1.ActionProcessRepo {
374
110
  })
375
111
  .exec();
376
112
  }
377
- /**
378
- * 開始日時を一定期間過ぎたアクションを削除する
379
- */
380
- async deleteStartDatePassedCertainPeriod(params) {
381
- return this.actionModel.deleteMany({
382
- startDate: {
383
- $lt: params.$lt
384
- }
385
- })
386
- .exec();
387
- }
388
- /**
389
- * 終了日時を一定期間過ぎたアクションを削除する
390
- * 作成日時を一定期間過ぎたアクションレシピも削除する
391
- */
392
- async deleteEndDatePassedCertainPeriod(params) {
393
- const { $lt } = params;
394
- if ($lt instanceof Date) {
395
- const deleteActionsResult = await this.actionModel.deleteMany({
396
- // 終了日時を一定期間過ぎたもの
397
- endDate: { $exists: true, $lt }
398
- })
399
- .exec();
400
- // clean actionRecipes(2025-01-10~)
401
- const dateCreatedLt = (0, moment_1.default)($lt)
402
- .add(-1, 'day') // レシピ作成とアクション終了の時間差を考慮
403
- .toDate();
404
- const deleteActionRecipesResult = await this.actionRecipeModel.deleteMany({
405
- dateCreated: { $lt: dateCreatedLt }
406
- })
407
- .exec();
408
- return { deleteActionRecipesResult, deleteActionsResult };
409
- }
410
- }
411
113
  /**
412
114
  * 取引からアクションを削除する
413
115
  */
@@ -0,0 +1,126 @@
1
+ import type { Connection, FilterQuery } from 'mongoose';
2
+ import { IDocType } from './mongoose/schemas/assetTransaction';
3
+ import { factory } from '../factory';
4
+ type AvailableAssetTransactionType = factory.assetTransactionType.CancelReservation | factory.assetTransactionType.Pay | factory.assetTransactionType.Refund | factory.assetTransactionType.Reserve;
5
+ /**
6
+ * 資産取引管理リポジトリ
7
+ */
8
+ export declare class AdminAssetTransactionRepo {
9
+ private readonly transactionModel;
10
+ constructor(connection: Connection);
11
+ static CREATE_MONGO_CONDITIONS(params: factory.assetTransaction.ISearchConditions<factory.assetTransactionType>): FilterQuery<import("@chevre/factory/lib/chevre/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/chevre/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/chevre/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/chevre/assetTransaction/reserve").ITransaction>[];
12
+ countPotentiallyExportTasks(params: {
13
+ endDate: {
14
+ $lt: Date;
15
+ };
16
+ limit?: number;
17
+ }): Promise<{
18
+ count: number;
19
+ }>;
20
+ /**
21
+ * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
22
+ * PotentialActionStatusに変更する
23
+ * 2025-03-10~
24
+ */
25
+ reExportAction(params: {
26
+ startDate: {
27
+ $lt: Date;
28
+ };
29
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
30
+ /**
31
+ * add(2025-03-17~)
32
+ */
33
+ countPotentiallyExpired(params: {
34
+ expires: {
35
+ $lt: Date;
36
+ };
37
+ limit?: number;
38
+ }): Promise<{
39
+ count: number;
40
+ }>;
41
+ /**
42
+ * add(2025-03-12~)
43
+ */
44
+ makeOneExpiredIfExists(params: {
45
+ expires: {
46
+ $lt: Date;
47
+ };
48
+ }): Promise<Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'id' | 'typeOf'> | undefined>;
49
+ countAssetTransactions<T extends factory.assetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>): Promise<{
50
+ count: number;
51
+ }>;
52
+ /**
53
+ * 取引を検索する
54
+ */
55
+ findAssetTransactions<T extends AvailableAssetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>, inclusion?: string[], exclusion?: string[]): Promise<factory.assetTransaction.ITransaction<T>[]>;
56
+ getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & ((import("@chevre/factory/lib/chevre/assetTransaction/cancelReservation").IAttributes & {
57
+ id: string;
58
+ } & {
59
+ seller?: any;
60
+ } & {
61
+ _id: import("mongoose").Types.ObjectId;
62
+ } & {
63
+ __v: number;
64
+ }) | (import("@chevre/factory/lib/chevre/assetTransaction/pay").IAttributes & {
65
+ id: string;
66
+ } & {
67
+ seller?: any;
68
+ } & {
69
+ _id: import("mongoose").Types.ObjectId;
70
+ } & {
71
+ __v: number;
72
+ }) | (import("@chevre/factory/lib/chevre/assetTransaction/refund").IAttributes & {
73
+ id: string;
74
+ } & {
75
+ seller?: any;
76
+ } & {
77
+ _id: import("mongoose").Types.ObjectId;
78
+ } & {
79
+ __v: number;
80
+ }) | (import("@chevre/factory/lib/chevre/assetTransaction/reserve").IAttributes & {
81
+ id: string;
82
+ } & {
83
+ seller?: any;
84
+ } & {
85
+ _id: import("mongoose").Types.ObjectId;
86
+ } & {
87
+ __v: number;
88
+ })), import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & ((import("@chevre/factory/lib/chevre/assetTransaction/cancelReservation").IAttributes & {
89
+ id: string;
90
+ } & {
91
+ seller?: any;
92
+ } & {
93
+ _id: import("mongoose").Types.ObjectId;
94
+ } & {
95
+ __v: number;
96
+ }) | (import("@chevre/factory/lib/chevre/assetTransaction/pay").IAttributes & {
97
+ id: string;
98
+ } & {
99
+ seller?: any;
100
+ } & {
101
+ _id: import("mongoose").Types.ObjectId;
102
+ } & {
103
+ __v: number;
104
+ }) | (import("@chevre/factory/lib/chevre/assetTransaction/refund").IAttributes & {
105
+ id: string;
106
+ } & {
107
+ seller?: any;
108
+ } & {
109
+ _id: import("mongoose").Types.ObjectId;
110
+ } & {
111
+ __v: number;
112
+ }) | (import("@chevre/factory/lib/chevre/assetTransaction/reserve").IAttributes & {
113
+ id: string;
114
+ } & {
115
+ seller?: any;
116
+ } & {
117
+ _id: import("mongoose").Types.ObjectId;
118
+ } & {
119
+ __v: number;
120
+ }))) | null>;
121
+ unsetUnnecessaryFields(params: {
122
+ filter: any;
123
+ $unset: any;
124
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
125
+ }
126
+ export {};