@chevre/domain 26.0.0 → 26.1.0-alpha.0

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 (51) hide show
  1. package/lib/chevre/repo/action/acceptCOAOffer.d.ts +8 -0
  2. package/lib/chevre/repo/action/acceptCOAOffer.js +17 -0
  3. package/lib/chevre/repo/action/acceptPay.d.ts +8 -0
  4. package/lib/chevre/repo/action/acceptPay.js +19 -2
  5. package/lib/chevre/repo/action/anyAction/actionProcess.d.ts +12 -21
  6. package/lib/chevre/repo/action/anyAction/actionProcess.js +4 -360
  7. package/lib/chevre/repo/action/anyAction/actionRecipe.d.ts +1 -1
  8. package/lib/chevre/repo/action/authorizeInvoice.js +1 -1
  9. package/lib/chevre/repo/action/authorizeOffer.js +1 -5
  10. package/lib/chevre/repo/action/authorizePaymentMethod.d.ts +8 -0
  11. package/lib/chevre/repo/action/authorizePaymentMethod.js +18 -1
  12. package/lib/chevre/repo/action/checkMovieTicket.d.ts +8 -0
  13. package/lib/chevre/repo/action/checkMovieTicket.js +17 -0
  14. package/lib/chevre/repo/action/dedicatedAction/dedicatedActionProcess.d.ts +46 -0
  15. package/lib/chevre/repo/action/dedicatedAction/dedicatedActionProcess.js +92 -0
  16. package/lib/chevre/repo/action/inform.d.ts +2 -1
  17. package/lib/chevre/repo/action/inform.js +14 -45
  18. package/lib/chevre/repo/action/pay.js +1 -1
  19. package/lib/chevre/repo/action/update.d.ts +8 -6
  20. package/lib/chevre/repo/action/update.js +14 -51
  21. package/lib/chevre/repo/action/use.d.ts +2 -1
  22. package/lib/chevre/repo/action/use.js +14 -45
  23. package/lib/chevre/repo/adminAction.d.ts +1 -1
  24. package/lib/chevre/repo/adminAction.js +27 -1
  25. package/lib/chevre/repo/factory/action/createMongoConditions.d.ts +4 -0
  26. package/lib/chevre/repo/factory/action/createMongoConditions.js +335 -0
  27. package/lib/chevre/repo/mongoose/schemas/action/abstractAction.d.ts +5 -0
  28. package/lib/chevre/repo/mongoose/schemas/action/abstractAction.js +2 -0
  29. package/lib/chevre/service/assetTransaction/pay/check.d.ts +3 -1
  30. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +1 -1
  31. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -1
  32. package/lib/chevre/service/assetTransaction/pay/start.d.ts +1 -1
  33. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +4 -5
  34. package/lib/chevre/service/payment/any/authorize.d.ts +1 -1
  35. package/lib/chevre/service/payment/any/findAcceptAction.js +4 -5
  36. package/lib/chevre/service/payment/any/findAuthorizeAction.js +4 -5
  37. package/lib/chevre/service/payment/any/findCheckAction.d.ts +3 -1
  38. package/lib/chevre/service/payment/any/findCheckAction.js +5 -6
  39. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +1 -1
  40. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +3 -1
  41. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +3 -3
  42. package/lib/chevre/service/payment/movieTicket/validation.d.ts +3 -1
  43. package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
  44. package/lib/chevre/service/task/acceptCOAOffer.js +4 -5
  45. package/lib/chevre/service/task/authorizePayment.js +5 -6
  46. package/lib/chevre/service/task/checkMovieTicket.js +7 -6
  47. package/lib/chevre/service/task/pay.js +3 -2
  48. package/lib/chevre/service/task/payment/payByTask.d.ts +3 -1
  49. package/lib/chevre/service/task/payment/payByTask.js +1 -1
  50. package/lib/chevre/service/task/publishPaymentUrl.js +4 -5
  51. package/package.json +1 -1
@@ -7,6 +7,14 @@ export type IAcceptCOAOfferAction = factory.action.accept.coaOffer.IAction;
7
7
  */
8
8
  export declare class AcceptCOAOfferActionRepo extends ActionProcessRepo<IAcceptCOAOfferAction, IActionRecipe<factory.recipe.RecipeCategory.acceptCOAOffer>> {
9
9
  constructor(connection: Connection);
10
+ findActionBySameAs(params: {
11
+ sameAs: {
12
+ id: string;
13
+ };
14
+ purpose?: {
15
+ id: string;
16
+ };
17
+ }): Promise<Pick<import("@chevre/factory/lib/chevre/action/accept/coaOffer").IAction, "error" | "id" | "purpose" | "actionStatus"> | null>;
10
18
  /**
11
19
  * 完了済の採用アクションを参照する
12
20
  */
@@ -14,6 +14,23 @@ class AcceptCOAOfferActionRepo extends actionProcess_1.ActionProcessRepo {
14
14
  recipeExpireAfterSeconds: EXPIRE_AFTER_SECONDS
15
15
  });
16
16
  }
17
+ async findActionBySameAs(params) {
18
+ return this.actionModel.findOne({
19
+ typeOf: { $eq: factory_1.factory.actionType.AcceptAction }, // 1taskから複数actionが発生する可能性があるので、typeOf指定が必須
20
+ 'sameAs.id': { $exists: true, $eq: params.sameAs.id },
21
+ ...(typeof params.purpose?.id === 'string')
22
+ ? { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
23
+ : undefined
24
+ }, {
25
+ _id: 0,
26
+ id: { $toString: '$_id' },
27
+ actionStatus: 1,
28
+ error: 1,
29
+ purpose: 1
30
+ })
31
+ .lean()
32
+ .exec();
33
+ }
17
34
  /**
18
35
  * 完了済の採用アクションを参照する
19
36
  */
@@ -7,6 +7,14 @@ export type IAcceptPayAction = factory.action.accept.pay.IAction;
7
7
  */
8
8
  export declare class AcceptPayActionRepo extends ActionProcessRepo<IAcceptPayAction, IActionRecipe<factory.recipe.RecipeCategory.publishPaymentUrl>> {
9
9
  constructor(connection: Connection);
10
+ findActionBySameAs(params: {
11
+ sameAs: {
12
+ id: string;
13
+ };
14
+ purpose?: {
15
+ id: string;
16
+ };
17
+ }): Promise<Pick<import("@chevre/factory/lib/chevre/action/accept/pay").IAction, "error" | "id" | "purpose" | "actionStatus"> | null>;
10
18
  /**
11
19
  * 注文取引から検索する
12
20
  * 件数はlimitされない
@@ -14,13 +14,30 @@ class AcceptPayActionRepo extends actionProcess_1.ActionProcessRepo {
14
14
  recipeExpireAfterSeconds: EXPIRE_AFTER_SECONDS
15
15
  });
16
16
  }
17
+ async findActionBySameAs(params) {
18
+ return this.actionModel.findOne({
19
+ typeOf: { $eq: factory_1.factory.actionType.AcceptAction }, // 1taskから複数actionが発生する可能性があるので、typeOf指定が必須
20
+ 'sameAs.id': { $exists: true, $eq: params.sameAs.id },
21
+ ...(typeof params.purpose?.id === 'string')
22
+ ? { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
23
+ : undefined
24
+ }, {
25
+ _id: 0,
26
+ id: { $toString: '$_id' },
27
+ actionStatus: 1,
28
+ error: 1,
29
+ purpose: 1
30
+ })
31
+ .lean()
32
+ .exec();
33
+ }
17
34
  /**
18
35
  * 注文取引から検索する
19
36
  * 件数はlimitされない
20
37
  */
21
38
  async findAcceptActionsByPurpose(params, inclusion) {
22
39
  const { actionStatus, limit, page } = params;
23
- return this.findAnyActions({
40
+ return this.findAnyActionsLegacy({
24
41
  project: { id: { $eq: params.project.id } },
25
42
  typeOf: { $eq: factory_1.factory.actionType.AcceptAction }, // 採用アクション
26
43
  purpose: { id: { $in: [params.purpose.id] } },
@@ -38,7 +55,7 @@ class AcceptPayActionRepo extends actionProcess_1.ActionProcessRepo {
38
55
  * 決済取引番号から完了済の決済採用アクションを参照する
39
56
  */
40
57
  async findCompletedAcceptActionsByTransactionNumber(params, inclusion) {
41
- return this.findAnyActions({
58
+ return this.findAnyActionsLegacy({
42
59
  limit: 1, // ひとまず1つだけでよい
43
60
  page: 1,
44
61
  project: { id: { $eq: params.project.id } },
@@ -1,4 +1,4 @@
1
- import { Connection, FilterQuery } from 'mongoose';
1
+ import { Connection } from 'mongoose';
2
2
  import { factory } from '../../../factory';
3
3
  import { IModel as IActionModel, IDocType } from '../../mongoose/schemas/action';
4
4
  import { ActionRecipeRepo, IActionRecipe, IRecipeAsActionAttributes } from './actionRecipe';
@@ -33,7 +33,6 @@ export declare class ActionProcessRepo<TAction extends IAction<factory.actionTyp
33
33
  protected constructor(params: {
34
34
  connection: Connection;
35
35
  }, options: IOptions);
36
- static CREATE_MONGO_CONDITIONS(params: factory.action.ISearchConditions): FilterQuery<IDocType>[];
37
36
  /**
38
37
  * アクション開始
39
38
  */
@@ -68,30 +67,22 @@ export declare class ActionProcessRepo<TAction extends IAction<factory.actionTyp
68
67
  typeOf: TAction['typeOf'];
69
68
  id: string;
70
69
  }, inclusion?: IKeyOfProjection[], exclusion?: IKeyOfProjection[]): Promise<TAction>;
71
- searchBySameAs(params: {
72
- sameAs: {
73
- id: {
74
- $eq: string;
75
- };
76
- };
77
- purpose?: {
78
- id: {
79
- $eq: string;
80
- };
81
- };
82
- /**
83
- * 1taskから複数actionが発生する可能性があるので、typeOf指定が必須
84
- */
85
- typeOf: {
86
- $eq: TAction['typeOf'];
87
- };
88
- }): Promise<Pick<TAction, 'id' | 'actionStatus' | 'error' | 'purpose'>[]>;
89
70
  private findActionStatusById;
90
71
  /**
91
72
  * 汎用アクション検索
92
73
  * 継承クラスから呼ぶ想定
93
74
  */
94
- protected findAnyActions(params: factory.action.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<TAction[]>;
75
+ protected findAnyActionsLegacy(params: Pick<factory.action.ISearchConditions, 'limit' | 'page' | 'project' | 'id' | 'actionStatus' | 'typeOf' | 'object' | 'purpose' | 'sameAs'> & {
76
+ sort?: never;
77
+ actionStatusTypes?: never;
78
+ agent?: never;
79
+ about?: never;
80
+ instrument?: never;
81
+ location?: never;
82
+ startFrom?: never;
83
+ startThrough?: never;
84
+ result?: never;
85
+ }, inclusion: IKeyOfProjection[]): Promise<TAction[]>;
95
86
  /**
96
87
  * 取引に対する汎用アクション検索
97
88
  * 継承クラスから呼ぶ想定
@@ -5,6 +5,7 @@ const factory_1 = require("../../../factory");
5
5
  const settings_1 = require("../../../settings");
6
6
  const action_1 = require("../../mongoose/schemas/action");
7
7
  const unknown2actionError_1 = require("../unknown2actionError");
8
+ const createMongoConditions_1 = require("../../factory/action/createMongoConditions");
8
9
  const actionRecipe_1 = require("./actionRecipe");
9
10
  exports.AVAILABLE_PROJECT_FIELDS = [
10
11
  'project',
@@ -41,338 +42,6 @@ class ActionProcessRepo extends actionRecipe_1.ActionRecipeRepo {
41
42
  this.actionModel = params.connection.model(action_1.modelName, (0, action_1.createSchema)());
42
43
  this.options = options;
43
44
  }
44
- static CREATE_MONGO_CONDITIONS(params) {
45
- const andConditions = [];
46
- const idIn = params.id?.$in;
47
- if (Array.isArray(idIn)) {
48
- andConditions.push({ _id: { $in: idIn } });
49
- }
50
- const idNin = params.id?.$nin;
51
- if (Array.isArray(idNin)) {
52
- andConditions.push({ _id: { $nin: idNin } });
53
- }
54
- const projectIdEq = params.project?.id?.$eq;
55
- if (typeof projectIdEq === 'string') {
56
- andConditions.push({
57
- 'project.id': {
58
- $eq: projectIdEq
59
- }
60
- });
61
- }
62
- const agentTypeOfIn = params.agent?.typeOf?.$in;
63
- if (Array.isArray(agentTypeOfIn)) {
64
- andConditions.push({
65
- 'agent.typeOf': {
66
- $exists: true,
67
- $in: agentTypeOfIn
68
- }
69
- });
70
- }
71
- const agentIdIn = params.agent?.id?.$in;
72
- if (Array.isArray(agentIdIn)) {
73
- andConditions.push({
74
- 'agent.id': {
75
- $exists: true,
76
- $in: agentIdIn
77
- }
78
- });
79
- }
80
- const instrumentTransactionNumberEq = params.instrument?.transactionNumber?.$eq;
81
- if (typeof instrumentTransactionNumberEq === 'string') {
82
- andConditions.push({ 'instrument.transactionNumber': { $exists: true, $eq: instrumentTransactionNumberEq } });
83
- }
84
- const instrumentTypeOfEq = params.instrument?.typeOf?.$eq;
85
- if (typeof instrumentTypeOfEq === 'string') {
86
- andConditions.push({ 'instrument.typeOf': { $exists: true, $eq: instrumentTypeOfEq } });
87
- }
88
- const instrumentIdentifierEq = params.instrument?.identifier?.$eq;
89
- if (typeof instrumentIdentifierEq === 'string') {
90
- andConditions.push({ 'instrument.identifier': { $exists: true, $eq: instrumentIdentifierEq } });
91
- }
92
- const instrumentIdEq = params.instrument?.id?.$eq;
93
- if (typeof instrumentIdEq === 'string') {
94
- andConditions.push({ 'instrument.id': { $exists: true, $eq: instrumentIdEq } });
95
- }
96
- const instrumentOrderNumberEq = params.instrument?.orderNumber?.$eq;
97
- if (typeof instrumentOrderNumberEq === 'string') {
98
- andConditions.push({ 'instrument.orderNumber': { $exists: true, $eq: instrumentOrderNumberEq } });
99
- }
100
- const locationIdEq = params.location?.id?.$eq;
101
- if (typeof locationIdEq === 'string') {
102
- andConditions.push({
103
- 'location.id': {
104
- $exists: true,
105
- $eq: locationIdEq
106
- }
107
- });
108
- }
109
- const locationIdentifierEq = params.location?.identifier?.$eq;
110
- if (typeof locationIdentifierEq === 'string') {
111
- andConditions.push({
112
- 'location.identifier': {
113
- $exists: true,
114
- $eq: locationIdentifierEq
115
- }
116
- });
117
- }
118
- const objectMovieTicketsIdentifierEq = params.object?.movieTickets?.identifier?.$eq;
119
- if (typeof objectMovieTicketsIdentifierEq === 'string') {
120
- andConditions.push({
121
- 'object.movieTickets.identifier': {
122
- $exists: true,
123
- $eq: objectMovieTicketsIdentifierEq
124
- }
125
- });
126
- }
127
- const objectMovieTicketsServiceOutputReservationForIdEq = params.object?.movieTickets?.serviceOutput?.reservationFor?.id?.$eq;
128
- if (typeof objectMovieTicketsServiceOutputReservationForIdEq === 'string') {
129
- andConditions.push({
130
- 'object.movieTickets.serviceOutput.reservationFor.id': {
131
- $exists: true,
132
- $eq: objectMovieTicketsServiceOutputReservationForIdEq
133
- }
134
- });
135
- }
136
- const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
137
- if (typeof objectPaymentMethodIdEq === 'string') {
138
- andConditions.push({
139
- 'object.paymentMethodId': {
140
- $exists: true,
141
- $eq: objectPaymentMethodIdEq
142
- }
143
- });
144
- }
145
- const objectObjectPaymentMethodIdEq = params.object?.object?.paymentMethodId?.$eq;
146
- if (typeof objectObjectPaymentMethodIdEq === 'string') {
147
- andConditions.push({
148
- 'object.object.paymentMethodId': {
149
- $exists: true,
150
- $eq: objectObjectPaymentMethodIdEq
151
- }
152
- });
153
- }
154
- const objectReservationForIdEq = params.object?.reservationFor?.id?.$eq;
155
- if (typeof objectReservationForIdEq === 'string') {
156
- andConditions.push({
157
- 'object.reservationFor.id': {
158
- $exists: true,
159
- $eq: objectReservationForIdEq
160
- }
161
- });
162
- }
163
- const objectReservationNumberEq = params.object?.reservationNumber?.$eq;
164
- if (typeof objectReservationNumberEq === 'string') {
165
- andConditions.push({
166
- 'object.reservationNumber': {
167
- $exists: true,
168
- $eq: objectReservationNumberEq
169
- }
170
- });
171
- }
172
- const objectReservationNumberIn = params.object?.reservationNumber?.$in;
173
- if (Array.isArray(objectReservationNumberIn)) {
174
- andConditions.push({
175
- 'object.reservationNumber': {
176
- $exists: true,
177
- $in: objectReservationNumberIn
178
- }
179
- });
180
- }
181
- const objectPaymentMethodAccountIdEq = params.object?.paymentMethod?.accountId?.$eq;
182
- if (typeof objectPaymentMethodAccountIdEq === 'string') {
183
- andConditions.push({
184
- 'object.paymentMethod.accountId': {
185
- $exists: true,
186
- $eq: objectPaymentMethodAccountIdEq
187
- }
188
- });
189
- }
190
- const objectPaymentMethodPaymentMethodIdEq = params.object?.paymentMethod?.paymentMethodId?.$eq;
191
- if (typeof objectPaymentMethodPaymentMethodIdEq === 'string') {
192
- andConditions.push({
193
- 'object.paymentMethod.paymentMethodId': {
194
- $exists: true,
195
- $eq: objectPaymentMethodPaymentMethodIdEq
196
- }
197
- });
198
- }
199
- const objectPaymentMethodPaymentMethodIdIn = params.object?.paymentMethod?.paymentMethodId?.$in;
200
- if (Array.isArray(objectPaymentMethodPaymentMethodIdIn)) {
201
- andConditions.push({
202
- 'object.paymentMethod.paymentMethodId': {
203
- $exists: true,
204
- $in: objectPaymentMethodPaymentMethodIdIn
205
- }
206
- });
207
- }
208
- const objectPaymentMethodTypeOfEq = params.object?.paymentMethod?.typeOf?.$eq;
209
- if (typeof objectPaymentMethodTypeOfEq === 'string') {
210
- andConditions.push({
211
- 'object.paymentMethod.typeOf': {
212
- $exists: true,
213
- $eq: objectPaymentMethodTypeOfEq
214
- }
215
- });
216
- }
217
- const objectTypeOfEq = params.object?.typeOf?.$eq;
218
- if (typeof objectTypeOfEq === 'string') {
219
- andConditions.push({
220
- 'object.typeOf': {
221
- $exists: true,
222
- $eq: objectTypeOfEq
223
- }
224
- });
225
- }
226
- const objectTypeOfIn = params.object?.typeOf?.$in;
227
- if (Array.isArray(objectTypeOfIn)) {
228
- andConditions.push({
229
- 'object.typeOf': {
230
- $exists: true,
231
- $in: objectTypeOfIn
232
- }
233
- });
234
- }
235
- const objectIdEq = params.object?.id?.$eq;
236
- if (typeof objectIdEq === 'string') {
237
- andConditions.push({
238
- 'object.id': {
239
- $exists: true,
240
- $eq: objectIdEq
241
- }
242
- });
243
- }
244
- const objectIdIn = params.object?.id?.$in;
245
- if (Array.isArray(objectIdIn)) {
246
- andConditions.push({
247
- 'object.id': {
248
- $exists: true,
249
- $in: objectIdIn
250
- }
251
- });
252
- }
253
- const objectOrderNumberIn = params.object?.orderNumber?.$in;
254
- if (Array.isArray(objectOrderNumberIn)) {
255
- andConditions.push({
256
- 'object.orderNumber': {
257
- $exists: true,
258
- $in: objectOrderNumberIn
259
- }
260
- });
261
- }
262
- const objectTransactionNumberEq = params.object?.transactionNumber?.$eq;
263
- if (typeof objectTransactionNumberEq === 'string') {
264
- andConditions.push({ 'object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
265
- }
266
- if (typeof params.typeOf === 'string') {
267
- andConditions.push({
268
- typeOf: params.typeOf
269
- });
270
- }
271
- else {
272
- const typeOfEq = params.typeOf?.$eq;
273
- if (typeof typeOfEq === 'string') {
274
- andConditions.push({
275
- typeOf: { $eq: typeOfEq }
276
- });
277
- }
278
- }
279
- const actionStatusIn = params.actionStatus?.$in;
280
- if (Array.isArray(actionStatusIn)) {
281
- andConditions.push({
282
- actionStatus: { $in: actionStatusIn }
283
- });
284
- }
285
- if (Array.isArray(params.actionStatusTypes)) {
286
- andConditions.push({
287
- actionStatus: { $in: params.actionStatusTypes }
288
- });
289
- }
290
- const startDateGte = params.startFrom;
291
- if (startDateGte instanceof Date) {
292
- andConditions.push({
293
- startDate: { $gte: startDateGte }
294
- });
295
- }
296
- const startDateLte = params.startThrough;
297
- if (startDateLte instanceof Date) {
298
- andConditions.push({
299
- startDate: { $lte: startDateLte }
300
- });
301
- }
302
- const purposeTypeOfIn = params.purpose?.typeOf?.$in;
303
- if (Array.isArray(purposeTypeOfIn)) {
304
- andConditions.push({
305
- 'purpose.typeOf': {
306
- $exists: true,
307
- $in: purposeTypeOfIn
308
- }
309
- });
310
- }
311
- const purposeIdIn = params.purpose?.id?.$in;
312
- if (Array.isArray(purposeIdIn)) {
313
- andConditions.push({
314
- 'purpose.id': {
315
- $exists: true,
316
- $in: purposeIdIn
317
- }
318
- });
319
- }
320
- const purposeOrderNumberIn = params.purpose?.orderNumber?.$in;
321
- if (Array.isArray(purposeOrderNumberIn)) {
322
- andConditions.push({
323
- 'purpose.orderNumber': {
324
- $exists: true,
325
- $in: purposeOrderNumberIn
326
- }
327
- });
328
- }
329
- const resultTypeOfIn = params.result?.typeOf?.$in;
330
- if (Array.isArray(resultTypeOfIn)) {
331
- andConditions.push({
332
- 'result.typeOf': {
333
- $exists: true,
334
- $in: resultTypeOfIn
335
- }
336
- });
337
- }
338
- const resultIdIn = params.result?.id?.$in;
339
- if (Array.isArray(resultIdIn)) {
340
- andConditions.push({
341
- 'result.id': {
342
- $exists: true,
343
- $in: resultIdIn
344
- }
345
- });
346
- }
347
- const resultOrderNumberIn = params.result?.orderNumber?.$in;
348
- if (Array.isArray(resultOrderNumberIn)) {
349
- andConditions.push({
350
- 'result.orderNumber': {
351
- $exists: true,
352
- $in: resultOrderNumberIn
353
- }
354
- });
355
- }
356
- const resultCodeIn = params.result?.code?.$in;
357
- if (Array.isArray(resultCodeIn)) {
358
- andConditions.push({
359
- 'result.code': {
360
- $exists: true,
361
- $in: resultCodeIn
362
- }
363
- });
364
- }
365
- // sameAs(2024-04-23~)
366
- const sameAsIdEq = params.sameAs?.id?.$eq;
367
- if (typeof sameAsIdEq === 'string') {
368
- andConditions.push({ 'sameAs.id': { $exists: true, $eq: sameAsIdEq } });
369
- }
370
- const aboutOrderNumberEq = params.about?.orderNumber?.$eq;
371
- if (typeof aboutOrderNumberEq === 'string') {
372
- andConditions.push({ 'about.orderNumber': { $exists: true, $eq: aboutOrderNumberEq } });
373
- }
374
- return andConditions;
375
- }
376
45
  /**
377
46
  * アクション開始
378
47
  */
@@ -478,7 +147,7 @@ class ActionProcessRepo extends actionRecipe_1.ActionRecipeRepo {
478
147
  error: actionError,
479
148
  endDate
480
149
  }
481
- }, { new: true, projection: { _id: 1 } })
150
+ }, { new: false, projection: { _id: 1 } })
482
151
  .lean()
483
152
  .exec();
484
153
  if (doc === null) {
@@ -511,27 +180,6 @@ class ActionProcessRepo extends actionRecipe_1.ActionRecipeRepo {
511
180
  }
512
181
  return doc;
513
182
  }
514
- async searchBySameAs(params) {
515
- const projection = {
516
- _id: 0,
517
- id: { $toString: '$_id' },
518
- actionStatus: 1,
519
- error: 1,
520
- purpose: 1
521
- };
522
- const query = this.actionModel.find({
523
- typeOf: { $eq: params.typeOf.$eq },
524
- 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq },
525
- ...(typeof params.purpose?.id.$eq === 'string')
526
- ? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
527
- : undefined
528
- }, projection)
529
- // .select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
530
- .limit(1);
531
- return query
532
- .lean() // 2024-08-26~
533
- .exec();
534
- }
535
183
  async findActionStatusById(params) {
536
184
  const projection = {
537
185
  _id: 0,
@@ -553,8 +201,8 @@ class ActionProcessRepo extends actionRecipe_1.ActionRecipeRepo {
553
201
  * 汎用アクション検索
554
202
  * 継承クラスから呼ぶ想定
555
203
  */
556
- async findAnyActions(params, inclusion) {
557
- const conditions = ActionProcessRepo.CREATE_MONGO_CONDITIONS(params);
204
+ async findAnyActionsLegacy(params, inclusion) {
205
+ const conditions = (0, createMongoConditions_1.createMongoConditions)(params);
558
206
  let positiveProjectionFields = exports.AVAILABLE_PROJECT_FIELDS;
559
207
  if (Array.isArray(inclusion) && inclusion.length > 0) {
560
208
  positiveProjectionFields = inclusion.filter((key) => exports.AVAILABLE_PROJECT_FIELDS.includes(key));
@@ -570,10 +218,6 @@ class ActionProcessRepo extends actionRecipe_1.ActionRecipeRepo {
570
218
  query.limit(params.limit)
571
219
  .skip(params.limit * (page - 1));
572
220
  }
573
- /* istanbul ignore else */
574
- if (params.sort?.startDate !== undefined) {
575
- query.sort({ startDate: params.sort.startDate });
576
- }
577
221
  // const explainResult = await (<any>query).explain();
578
222
  // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
579
223
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
@@ -32,6 +32,6 @@ export declare class ActionRecipeRepo<TActionRecipe extends IActionRecipe<factor
32
32
  id: string;
33
33
  };
34
34
  }): Promise<Pick<IActionRecipe<T>, 'step' | 'recipeCategory'> | null>;
35
- upsertRecipe(savingRecipe: Pick<IRecipeAsDocument, 'project' | 'recipeCategory' | 'recipeFor' | 'step' | 'typeOf'>): Promise<void>;
35
+ protected upsertRecipe(savingRecipe: Pick<IRecipeAsDocument, 'project' | 'recipeCategory' | 'recipeFor' | 'step' | 'typeOf'>): Promise<void>;
36
36
  }
37
37
  export {};
@@ -17,7 +17,7 @@ class AuthorizeInvoiceActionRepo extends actionProcess_1.ActionProcessRepo {
17
17
  * 決済取引からインボイス承認アクションをひとつ参照する
18
18
  */
19
19
  async findAuthorizeInvoiceActionsByPayTransaction(params, inclusion) {
20
- return this.findAnyActions({
20
+ return this.findAnyActionsLegacy({
21
21
  limit: 1, // ひとまず1でok
22
22
  page: 1,
23
23
  typeOf: { $eq: factory_1.factory.actionType.AuthorizeAction },
@@ -17,7 +17,7 @@ class AuthorizeOfferActionRepo extends actionProcess_1.ActionProcessRepo {
17
17
  if (!Array.isArray(params.ids)) {
18
18
  throw new factory_1.factory.errors.Argument('ids', 'must be Array');
19
19
  }
20
- return this.findAnyActions({
20
+ return this.findAnyActionsLegacy({
21
21
  typeOf: factory_1.factory.actionType.AuthorizeAction,
22
22
  purpose: {
23
23
  typeOf: { $in: [factory_1.factory.transactionType.PlaceOrder] },
@@ -89,10 +89,6 @@ class AuthorizeOfferActionRepo extends actionProcess_1.ActionProcessRepo {
89
89
  if (doc === null) {
90
90
  throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
91
91
  }
92
- // // add recipe(2024-06-09~)
93
- // if (params.recipe?.typeOf === 'Recipe') {
94
- // await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
95
- // }
96
92
  }
97
93
  async reCompleteAuthorizeEventOfferAction(params) {
98
94
  return this.actionModel.findOneAndUpdate({
@@ -8,6 +8,14 @@ export type IActionRecipe = never;
8
8
  */
9
9
  export declare class AuthorizePaymentMethodActionRepo extends ActionProcessRepo<IAuthorizePaymentMethodAction, IActionRecipe> {
10
10
  constructor(connection: Connection);
11
+ findActionBySameAs(params: {
12
+ sameAs: {
13
+ id: string;
14
+ };
15
+ purpose?: {
16
+ id: string;
17
+ };
18
+ }): Promise<Pick<import("@chevre/factory/lib/chevre/action/authorize/paymentMethod/any").IAction, "error" | "id" | "purpose" | "actionStatus"> | null>;
11
19
  /**
12
20
  * 取引に対する決済承認アクションを検索する
13
21
  */
@@ -13,6 +13,23 @@ class AuthorizePaymentMethodActionRepo extends actionProcess_1.ActionProcessRepo
13
13
  recipeExpireAfterSeconds: actionProcess_1.RECIPE_DEFAULT_EXPIRE_AFTER_SECONDS
14
14
  });
15
15
  }
16
+ async findActionBySameAs(params) {
17
+ return this.actionModel.findOne({
18
+ typeOf: { $eq: factory_1.factory.actionType.AuthorizeAction }, // 1taskから複数actionが発生する可能性があるので、typeOf指定が必須
19
+ 'sameAs.id': { $exists: true, $eq: params.sameAs.id },
20
+ ...(typeof params.purpose?.id === 'string')
21
+ ? { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
22
+ : undefined
23
+ }, {
24
+ _id: 0,
25
+ id: { $toString: '$_id' },
26
+ actionStatus: 1,
27
+ error: 1,
28
+ purpose: 1
29
+ })
30
+ .lean()
31
+ .exec();
32
+ }
16
33
  /**
17
34
  * 取引に対する決済承認アクションを検索する
18
35
  */
@@ -30,7 +47,7 @@ class AuthorizePaymentMethodActionRepo extends actionProcess_1.ActionProcessRepo
30
47
  if (!Array.isArray(params.ids)) {
31
48
  throw new factory_1.factory.errors.Argument('ids', 'must be Array');
32
49
  }
33
- return this.findAnyActions({
50
+ return this.findAnyActionsLegacy({
34
51
  typeOf: factory_1.factory.actionType.AuthorizeAction,
35
52
  purpose: {
36
53
  typeOf: { $in: [factory_1.factory.transactionType.PlaceOrder] },
@@ -62,6 +62,14 @@ export type ICheckMovieTicketAction = factory.action.check.paymentMethod.movieTi
62
62
  */
63
63
  export declare class CheckMovieTicketActionRepo extends ActionProcessRepo<ICheckMovieTicketAction, IActionRecipe<factory.recipe.RecipeCategory.checkMovieTicket>> {
64
64
  constructor(connection: Connection);
65
+ findActionBySameAs(params: {
66
+ sameAs: {
67
+ id: string;
68
+ };
69
+ purpose?: {
70
+ id: string;
71
+ };
72
+ }): Promise<Pick<import("@chevre/factory/lib/chevre/action/check/paymentMethod/movieTicket").IAction, "error" | "id" | "purpose" | "actionStatus"> | null>;
65
73
  /**
66
74
  * アクションIDからレシピのafterMediaを参照する
67
75
  */