@chevre/domain 24.0.0-alpha.26 → 24.0.0-alpha.28

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 (88) hide show
  1. package/lib/chevre/errorHandler.js +1 -1
  2. package/lib/chevre/repo/accountTitle.d.ts +7 -3
  3. package/lib/chevre/repo/action/acceptCOAOffer.js +0 -2
  4. package/lib/chevre/repo/action/acceptPay.d.ts +4 -0
  5. package/lib/chevre/repo/action/acceptPay.js +40 -52
  6. package/lib/chevre/repo/action/actionProcess.d.ts +31 -1
  7. package/lib/chevre/repo/action/actionProcess.js +499 -4
  8. package/lib/chevre/repo/action/authorizeInvoice.d.ts +14 -1
  9. package/lib/chevre/repo/action/authorizeInvoice.js +36 -0
  10. package/lib/chevre/repo/action/authorizePaymentMethod.js +9 -47
  11. package/lib/chevre/repo/action.d.ts +8 -8
  12. package/lib/chevre/repo/action.js +2 -510
  13. package/lib/chevre/repo/aggregateOffer.d.ts +7 -3
  14. package/lib/chevre/repo/assetTransaction.d.ts +48 -22
  15. package/lib/chevre/repo/categoryCode.d.ts +8 -3
  16. package/lib/chevre/repo/comment.d.ts +7 -3
  17. package/lib/chevre/repo/creativeWork.d.ts +8 -7
  18. package/lib/chevre/repo/customer.d.ts +8 -3
  19. package/lib/chevre/repo/event.d.ts +11 -23
  20. package/lib/chevre/repo/event.js +22 -23
  21. package/lib/chevre/repo/eventSeries.d.ts +10 -4
  22. package/lib/chevre/repo/identity.d.ts +12 -3
  23. package/lib/chevre/repo/identityProvider.d.ts +7 -18
  24. package/lib/chevre/repo/issuer.d.ts +8 -8
  25. package/lib/chevre/repo/member.d.ts +7 -3
  26. package/lib/chevre/repo/merchantReturnPolicy.d.ts +7 -3
  27. package/lib/chevre/repo/message.js +1 -1
  28. package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.d.ts +1 -1
  29. package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -1
  30. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +2 -2
  31. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +1 -1
  32. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +1 -1
  33. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +2 -2
  34. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +2 -2
  35. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +2 -2
  36. package/lib/chevre/repo/mongoose/schemas/customerType.d.ts +2 -2
  37. package/lib/chevre/repo/mongoose/schemas/eventOffer.d.ts +1 -1
  38. package/lib/chevre/repo/mongoose/schemas/identity.d.ts +1 -1
  39. package/lib/chevre/repo/mongoose/schemas/identityProvider.d.ts +1 -1
  40. package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +1 -1
  41. package/lib/chevre/repo/mongoose/schemas/member/global.d.ts +1 -1
  42. package/lib/chevre/repo/mongoose/schemas/message.d.ts +2 -2
  43. package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.d.ts +1 -1
  44. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +1 -1
  45. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +1 -1
  46. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +2 -2
  47. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +2 -2
  48. package/lib/chevre/repo/mongoose/schemas/paymentService.d.ts +1 -1
  49. package/lib/chevre/repo/mongoose/schemas/paymentServiceChannel.d.ts +1 -1
  50. package/lib/chevre/repo/mongoose/schemas/potentialAction.d.ts +1 -1
  51. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +3 -1
  52. package/lib/chevre/repo/mongoose/schemas/product.d.ts +1 -1
  53. package/lib/chevre/repo/mongoose/schemas/productModel.d.ts +1 -1
  54. package/lib/chevre/repo/mongoose/schemas/project.d.ts +1 -1
  55. package/lib/chevre/repo/mongoose/schemas/schedule.d.ts +1 -1
  56. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +1 -1
  57. package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.d.ts +1 -1
  58. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +1 -1
  59. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +1 -1
  60. package/lib/chevre/repo/mongoose/schemas/task.d.ts +1 -1
  61. package/lib/chevre/repo/mongoose/schemas/ticket.d.ts +1 -1
  62. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +5 -2
  63. package/lib/chevre/repo/mongoose/schemas/webSite.d.ts +1 -1
  64. package/lib/chevre/repo/movieTicketType.d.ts +2 -1
  65. package/lib/chevre/repo/offerCatalog.d.ts +8 -4
  66. package/lib/chevre/repo/order.d.ts +10 -4
  67. package/lib/chevre/repo/ownershipInfo.d.ts +8 -7
  68. package/lib/chevre/repo/paymentService.d.ts +8 -8
  69. package/lib/chevre/repo/place/movieTheater.d.ts +7 -3
  70. package/lib/chevre/repo/place/screeningRoom.d.ts +7 -3
  71. package/lib/chevre/repo/potentialAction.d.ts +7 -26
  72. package/lib/chevre/repo/priceSpecification.d.ts +47 -22
  73. package/lib/chevre/repo/priceSpecification.js +0 -6
  74. package/lib/chevre/repo/product.d.ts +7 -3
  75. package/lib/chevre/repo/project.d.ts +8 -11
  76. package/lib/chevre/repo/reservation.d.ts +18 -6
  77. package/lib/chevre/repo/reserveInterface.js +4 -4
  78. package/lib/chevre/repo/role.d.ts +39 -3
  79. package/lib/chevre/repo/schedule.js +1 -1
  80. package/lib/chevre/repo/seller.d.ts +7 -50
  81. package/lib/chevre/repo/task.d.ts +7 -67
  82. package/lib/chevre/repo/transaction.d.ts +103 -13
  83. package/lib/chevre/service/order/sendOrder.js +0 -1
  84. package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +9 -8
  85. package/lib/chevre/service/payment/creditCard/voidTransaction.js +15 -7
  86. package/lib/chevre/service/task/payment/voidPaymentByTask.d.ts +2 -0
  87. package/lib/chevre/service/task/voidPayment.js +2 -0
  88. package/package.json +3 -3
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ActionProcessRepo = exports.AVAILABLE_PROJECT_FIELDS = void 0;
27
27
  const factory = __importStar(require("../../factory"));
28
- // import { MONGO_MAX_TIME_MS } from '../settings';
28
+ const settings_1 = require("../../settings");
29
29
  const action_1 = require("../mongoose/schemas/action");
30
30
  const actionRecipe_1 = require("../mongoose/schemas/actionRecipe");
31
31
  exports.AVAILABLE_PROJECT_FIELDS = [
@@ -65,6 +65,412 @@ class ActionProcessRepo {
65
65
  this.actionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
66
66
  this.actionRecipeModel = connection.model(actionRecipe_1.modelName, (0, actionRecipe_1.createSchema)());
67
67
  }
68
+ static CREATE_MONGO_CONDITIONS(params) {
69
+ const andConditions = [];
70
+ const idIn = params.id?.$in;
71
+ if (Array.isArray(idIn)) {
72
+ andConditions.push({ _id: { $in: idIn } });
73
+ }
74
+ const idNin = params.id?.$nin;
75
+ if (Array.isArray(idNin)) {
76
+ andConditions.push({ _id: { $nin: idNin } });
77
+ }
78
+ const projectIdEq = params.project?.id?.$eq;
79
+ if (typeof projectIdEq === 'string') {
80
+ andConditions.push({
81
+ 'project.id': {
82
+ $eq: projectIdEq
83
+ }
84
+ });
85
+ }
86
+ const agentTypeOfIn = params.agent?.typeOf?.$in;
87
+ if (Array.isArray(agentTypeOfIn)) {
88
+ andConditions.push({
89
+ 'agent.typeOf': {
90
+ $exists: true,
91
+ $in: agentTypeOfIn
92
+ }
93
+ });
94
+ }
95
+ const agentIdIn = params.agent?.id?.$in;
96
+ if (Array.isArray(agentIdIn)) {
97
+ andConditions.push({
98
+ 'agent.id': {
99
+ $exists: true,
100
+ $in: agentIdIn
101
+ }
102
+ });
103
+ }
104
+ const instrumentTransactionNumberEq = params.instrument?.transactionNumber?.$eq;
105
+ if (typeof instrumentTransactionNumberEq === 'string') {
106
+ andConditions.push({ 'instrument.transactionNumber': { $exists: true, $eq: instrumentTransactionNumberEq } });
107
+ }
108
+ const instrumentTypeOfEq = params.instrument?.typeOf?.$eq;
109
+ if (typeof instrumentTypeOfEq === 'string') {
110
+ andConditions.push({ 'instrument.typeOf': { $exists: true, $eq: instrumentTypeOfEq } });
111
+ }
112
+ const instrumentIdentifierEq = params.instrument?.identifier?.$eq;
113
+ if (typeof instrumentIdentifierEq === 'string') {
114
+ andConditions.push({ 'instrument.identifier': { $exists: true, $eq: instrumentIdentifierEq } });
115
+ }
116
+ const instrumentIdEq = params.instrument?.id?.$eq;
117
+ if (typeof instrumentIdEq === 'string') {
118
+ andConditions.push({ 'instrument.id': { $exists: true, $eq: instrumentIdEq } });
119
+ }
120
+ const instrumentOrderNumberEq = params.instrument?.orderNumber?.$eq;
121
+ if (typeof instrumentOrderNumberEq === 'string') {
122
+ andConditions.push({ 'instrument.orderNumber': { $exists: true, $eq: instrumentOrderNumberEq } });
123
+ }
124
+ const locationIdEq = params.location?.id?.$eq;
125
+ if (typeof locationIdEq === 'string') {
126
+ andConditions.push({
127
+ 'location.id': {
128
+ $exists: true,
129
+ $eq: locationIdEq
130
+ }
131
+ });
132
+ }
133
+ const locationIdentifierEq = params.location?.identifier?.$eq;
134
+ if (typeof locationIdentifierEq === 'string') {
135
+ andConditions.push({
136
+ 'location.identifier': {
137
+ $exists: true,
138
+ $eq: locationIdentifierEq
139
+ }
140
+ });
141
+ }
142
+ const objectMovieTicketsIdentifierEq = params.object?.movieTickets?.identifier?.$eq;
143
+ if (typeof objectMovieTicketsIdentifierEq === 'string') {
144
+ andConditions.push({
145
+ 'object.movieTickets.identifier': {
146
+ $exists: true,
147
+ $eq: objectMovieTicketsIdentifierEq
148
+ }
149
+ });
150
+ }
151
+ const objectMovieTicketsServiceOutputReservationForIdEq = params.object?.movieTickets?.serviceOutput?.reservationFor?.id?.$eq;
152
+ if (typeof objectMovieTicketsServiceOutputReservationForIdEq === 'string') {
153
+ andConditions.push({
154
+ 'object.movieTickets.serviceOutput.reservationFor.id': {
155
+ $exists: true,
156
+ $eq: objectMovieTicketsServiceOutputReservationForIdEq
157
+ }
158
+ });
159
+ }
160
+ const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
161
+ if (typeof objectPaymentMethodIdEq === 'string') {
162
+ andConditions.push({
163
+ 'object.paymentMethodId': {
164
+ $exists: true,
165
+ $eq: objectPaymentMethodIdEq
166
+ }
167
+ });
168
+ }
169
+ const objectObjectPaymentMethodIdEq = params.object?.object?.paymentMethodId?.$eq;
170
+ if (typeof objectObjectPaymentMethodIdEq === 'string') {
171
+ andConditions.push({
172
+ 'object.object.paymentMethodId': {
173
+ $exists: true,
174
+ $eq: objectObjectPaymentMethodIdEq
175
+ }
176
+ });
177
+ }
178
+ const objectReservationForIdEq = params.object?.reservationFor?.id?.$eq;
179
+ if (typeof objectReservationForIdEq === 'string') {
180
+ andConditions.push({
181
+ 'object.reservationFor.id': {
182
+ $exists: true,
183
+ $eq: objectReservationForIdEq
184
+ }
185
+ });
186
+ }
187
+ const objectReservationNumberEq = params.object?.reservationNumber?.$eq;
188
+ if (typeof objectReservationNumberEq === 'string') {
189
+ andConditions.push({
190
+ 'object.reservationNumber': {
191
+ $exists: true,
192
+ $eq: objectReservationNumberEq
193
+ }
194
+ });
195
+ }
196
+ const objectReservationNumberIn = params.object?.reservationNumber?.$in;
197
+ if (Array.isArray(objectReservationNumberIn)) {
198
+ andConditions.push({
199
+ 'object.reservationNumber': {
200
+ $exists: true,
201
+ $in: objectReservationNumberIn
202
+ }
203
+ });
204
+ }
205
+ const objectPaymentMethodAccountIdEq = params.object?.paymentMethod?.accountId?.$eq;
206
+ if (typeof objectPaymentMethodAccountIdEq === 'string') {
207
+ andConditions.push({
208
+ 'object.paymentMethod.accountId': {
209
+ $exists: true,
210
+ $eq: objectPaymentMethodAccountIdEq
211
+ }
212
+ });
213
+ }
214
+ const objectPaymentMethodPaymentMethodIdEq = params.object?.paymentMethod?.paymentMethodId?.$eq;
215
+ if (typeof objectPaymentMethodPaymentMethodIdEq === 'string') {
216
+ andConditions.push({
217
+ 'object.paymentMethod.paymentMethodId': {
218
+ $exists: true,
219
+ $eq: objectPaymentMethodPaymentMethodIdEq
220
+ }
221
+ });
222
+ }
223
+ const objectPaymentMethodPaymentMethodIdIn = params.object?.paymentMethod?.paymentMethodId?.$in;
224
+ if (Array.isArray(objectPaymentMethodPaymentMethodIdIn)) {
225
+ andConditions.push({
226
+ 'object.paymentMethod.paymentMethodId': {
227
+ $exists: true,
228
+ $in: objectPaymentMethodPaymentMethodIdIn
229
+ }
230
+ });
231
+ }
232
+ const objectPaymentMethodTypeOfEq = params.object?.paymentMethod?.typeOf?.$eq;
233
+ if (typeof objectPaymentMethodTypeOfEq === 'string') {
234
+ andConditions.push({
235
+ 'object.paymentMethod.typeOf': {
236
+ $exists: true,
237
+ $eq: objectPaymentMethodTypeOfEq
238
+ }
239
+ });
240
+ }
241
+ const objectTypeOfEq = params.object?.typeOf?.$eq;
242
+ if (typeof objectTypeOfEq === 'string') {
243
+ andConditions.push({
244
+ 'object.typeOf': {
245
+ $exists: true,
246
+ $eq: objectTypeOfEq
247
+ }
248
+ });
249
+ }
250
+ const objectTypeOfIn = params.object?.typeOf?.$in;
251
+ if (Array.isArray(objectTypeOfIn)) {
252
+ andConditions.push({
253
+ 'object.typeOf': {
254
+ $exists: true,
255
+ $in: objectTypeOfIn
256
+ }
257
+ });
258
+ }
259
+ const objectIdEq = params.object?.id?.$eq;
260
+ if (typeof objectIdEq === 'string') {
261
+ andConditions.push({
262
+ 'object.id': {
263
+ $exists: true,
264
+ $eq: objectIdEq
265
+ }
266
+ });
267
+ }
268
+ const objectIdIn = params.object?.id?.$in;
269
+ if (Array.isArray(objectIdIn)) {
270
+ andConditions.push({
271
+ 'object.id': {
272
+ $exists: true,
273
+ $in: objectIdIn
274
+ }
275
+ });
276
+ }
277
+ const objectOrderNumberIn = params.object?.orderNumber?.$in;
278
+ if (Array.isArray(objectOrderNumberIn)) {
279
+ andConditions.push({
280
+ 'object.orderNumber': {
281
+ $exists: true,
282
+ $in: objectOrderNumberIn
283
+ }
284
+ });
285
+ }
286
+ const objectEventIdIn = params.object?.event?.id?.$in;
287
+ if (Array.isArray(objectEventIdIn)) {
288
+ andConditions.push({
289
+ 'object.event.id': {
290
+ $exists: true,
291
+ $in: objectEventIdIn
292
+ }
293
+ });
294
+ }
295
+ // discontinue(2024-06-18~)
296
+ // const objectAcceptedOfferSeatNumberIn =
297
+ // params.object?.acceptedOffer?.itemOffered?.serviceOutput?.reservedTicket?.ticketedSeat?.seatNumber?.$in;
298
+ // if (Array.isArray(objectAcceptedOfferSeatNumberIn)) {
299
+ // andConditions.push({
300
+ // 'object.acceptedOffer.itemOffered.serviceOutput.reservedTicket.ticketedSeat.seatNumber': {
301
+ // $exists: true,
302
+ // $in: objectAcceptedOfferSeatNumberIn
303
+ // }
304
+ // });
305
+ // }
306
+ const objectTransactionNumberEq = params.object?.transactionNumber?.$eq;
307
+ if (typeof objectTransactionNumberEq === 'string') {
308
+ andConditions.push({ 'object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
309
+ }
310
+ if (typeof params.typeOf === 'string') {
311
+ andConditions.push({
312
+ typeOf: params.typeOf
313
+ });
314
+ }
315
+ else {
316
+ const typeOfEq = params.typeOf?.$eq;
317
+ if (typeof typeOfEq === 'string') {
318
+ andConditions.push({
319
+ typeOf: { $eq: typeOfEq }
320
+ });
321
+ }
322
+ }
323
+ const actionStatusIn = params.actionStatus?.$in;
324
+ if (Array.isArray(actionStatusIn)) {
325
+ andConditions.push({
326
+ actionStatus: { $in: actionStatusIn }
327
+ });
328
+ }
329
+ if (Array.isArray(params.actionStatusTypes)) {
330
+ andConditions.push({
331
+ actionStatus: { $in: params.actionStatusTypes }
332
+ });
333
+ }
334
+ const startDateGte = params.startFrom;
335
+ if (startDateGte instanceof Date) {
336
+ andConditions.push({
337
+ startDate: { $gte: startDateGte }
338
+ });
339
+ }
340
+ const startDateLte = params.startThrough;
341
+ if (startDateLte instanceof Date) {
342
+ andConditions.push({
343
+ startDate: { $lte: startDateLte }
344
+ });
345
+ }
346
+ const fromLocationTypeOfIn = params.fromLocation?.typeOf?.$in;
347
+ if (Array.isArray(fromLocationTypeOfIn)) {
348
+ andConditions.push({
349
+ 'fromLocation.typeOf': {
350
+ $exists: true,
351
+ $in: fromLocationTypeOfIn
352
+ }
353
+ });
354
+ }
355
+ const fromLocationAccountNumberIn = params.fromLocation?.accountNumber?.$in;
356
+ if (Array.isArray(fromLocationAccountNumberIn)) {
357
+ andConditions.push({
358
+ 'fromLocation.accountNumber': {
359
+ $exists: true,
360
+ $in: fromLocationAccountNumberIn
361
+ }
362
+ });
363
+ }
364
+ const fromLocationAccountTypeIn = params.fromLocation?.accountType?.$in;
365
+ if (Array.isArray(fromLocationAccountTypeIn)) {
366
+ andConditions.push({
367
+ 'fromLocation.accountType': {
368
+ $exists: true,
369
+ $in: fromLocationAccountTypeIn
370
+ }
371
+ });
372
+ }
373
+ const toLocationTypeOfIn = params.toLocation?.typeOf?.$in;
374
+ if (Array.isArray(toLocationTypeOfIn)) {
375
+ andConditions.push({
376
+ 'toLocation.typeOf': {
377
+ $exists: true,
378
+ $in: toLocationTypeOfIn
379
+ }
380
+ });
381
+ }
382
+ const toLocationAccountNumberIn = params.toLocation?.accountNumber?.$in;
383
+ if (Array.isArray(toLocationAccountNumberIn)) {
384
+ andConditions.push({
385
+ 'toLocation.accountNumber': {
386
+ $exists: true,
387
+ $in: toLocationAccountNumberIn
388
+ }
389
+ });
390
+ }
391
+ const toLocationAccountTypeIn = params.toLocation?.accountType?.$in;
392
+ if (Array.isArray(toLocationAccountTypeIn)) {
393
+ andConditions.push({
394
+ 'toLocation.accountType': {
395
+ $exists: true,
396
+ $in: toLocationAccountTypeIn
397
+ }
398
+ });
399
+ }
400
+ const purposeTypeOfIn = params.purpose?.typeOf?.$in;
401
+ if (Array.isArray(purposeTypeOfIn)) {
402
+ andConditions.push({
403
+ 'purpose.typeOf': {
404
+ $exists: true,
405
+ $in: purposeTypeOfIn
406
+ }
407
+ });
408
+ }
409
+ const purposeIdIn = params.purpose?.id?.$in;
410
+ if (Array.isArray(purposeIdIn)) {
411
+ andConditions.push({
412
+ 'purpose.id': {
413
+ $exists: true,
414
+ $in: purposeIdIn
415
+ }
416
+ });
417
+ }
418
+ const purposeOrderNumberIn = params.purpose?.orderNumber?.$in;
419
+ if (Array.isArray(purposeOrderNumberIn)) {
420
+ andConditions.push({
421
+ 'purpose.orderNumber': {
422
+ $exists: true,
423
+ $in: purposeOrderNumberIn
424
+ }
425
+ });
426
+ }
427
+ const resultTypeOfIn = params.result?.typeOf?.$in;
428
+ if (Array.isArray(resultTypeOfIn)) {
429
+ andConditions.push({
430
+ 'result.typeOf': {
431
+ $exists: true,
432
+ $in: resultTypeOfIn
433
+ }
434
+ });
435
+ }
436
+ const resultIdIn = params.result?.id?.$in;
437
+ if (Array.isArray(resultIdIn)) {
438
+ andConditions.push({
439
+ 'result.id': {
440
+ $exists: true,
441
+ $in: resultIdIn
442
+ }
443
+ });
444
+ }
445
+ const resultOrderNumberIn = params.result?.orderNumber?.$in;
446
+ if (Array.isArray(resultOrderNumberIn)) {
447
+ andConditions.push({
448
+ 'result.orderNumber': {
449
+ $exists: true,
450
+ $in: resultOrderNumberIn
451
+ }
452
+ });
453
+ }
454
+ const resultCodeIn = params.result?.code?.$in;
455
+ if (Array.isArray(resultCodeIn)) {
456
+ andConditions.push({
457
+ 'result.code': {
458
+ $exists: true,
459
+ $in: resultCodeIn
460
+ }
461
+ });
462
+ }
463
+ // sameAs(2024-04-23~)
464
+ const sameAsIdEq = params.sameAs?.id?.$eq;
465
+ if (typeof sameAsIdEq === 'string') {
466
+ andConditions.push({ 'sameAs.id': { $exists: true, $eq: sameAsIdEq } });
467
+ }
468
+ const aboutOrderNumberEq = params.about?.orderNumber?.$eq;
469
+ if (typeof aboutOrderNumberEq === 'string') {
470
+ andConditions.push({ 'about.orderNumber': { $exists: true, $eq: aboutOrderNumberEq } });
471
+ }
472
+ return andConditions;
473
+ }
68
474
  /**
69
475
  * アクション開始
70
476
  */
@@ -268,6 +674,95 @@ class ActionProcessRepo {
268
674
  }
269
675
  return doc;
270
676
  }
677
+ /**
678
+ * 汎用アクション検索
679
+ * 継承クラスから呼ぶ想定
680
+ */
681
+ async findAnyActions(params, inclusion) {
682
+ const conditions = ActionProcessRepo.CREATE_MONGO_CONDITIONS(params);
683
+ let positiveProjectionFields = exports.AVAILABLE_PROJECT_FIELDS;
684
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
685
+ positiveProjectionFields = inclusion.filter((key) => exports.AVAILABLE_PROJECT_FIELDS.includes(key));
686
+ }
687
+ const projection = {
688
+ _id: 0,
689
+ id: { $toString: '$_id' },
690
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
691
+ };
692
+ const query = this.actionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
693
+ if (typeof params.limit === 'number' && params.limit > 0) {
694
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
695
+ query.limit(params.limit)
696
+ .skip(params.limit * (page - 1));
697
+ }
698
+ /* istanbul ignore else */
699
+ if (params.sort?.startDate !== undefined) {
700
+ query.sort({ startDate: params.sort.startDate });
701
+ }
702
+ // const explainResult = await (<any>query).explain();
703
+ // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
704
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
705
+ .lean() // 2024-08-26~
706
+ .exec();
707
+ }
708
+ /**
709
+ * 取引に対する汎用アクション検索
710
+ * 継承クラスから呼ぶ想定
711
+ * 件数はlimitされない
712
+ */
713
+ async findAnyActionsByPurpose(params) {
714
+ const andConditions = [
715
+ { 'purpose.typeOf': { $exists: true, $eq: params.purpose.typeOf } },
716
+ { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
717
+ ];
718
+ const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
719
+ if (typeof objectPaymentMethodIdEq === 'string') {
720
+ andConditions.push({ 'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq } });
721
+ }
722
+ const objectTypeOfEq = params.object?.typeOf?.$eq;
723
+ if (typeof objectTypeOfEq === 'string') {
724
+ andConditions.push({ 'object.typeOf': { $exists: true, $eq: objectTypeOfEq } });
725
+ }
726
+ if (typeof params.typeOf === 'string') {
727
+ andConditions.push({ typeOf: { $eq: params.typeOf } });
728
+ }
729
+ const actionStatusEq = params.actionStatus?.$eq;
730
+ if (typeof actionStatusEq === 'string') {
731
+ andConditions.push({ actionStatus: { $eq: actionStatusEq } });
732
+ }
733
+ const positiveProjectionFields = [
734
+ 'project',
735
+ 'actionStatus',
736
+ 'typeOf',
737
+ 'description',
738
+ 'agent',
739
+ 'recipient',
740
+ 'result',
741
+ 'error',
742
+ 'object',
743
+ 'startDate',
744
+ 'endDate',
745
+ 'purpose',
746
+ 'potentialActions',
747
+ 'instrument',
748
+ 'location',
749
+ 'sameAs',
750
+ 'cancelAction',
751
+ 'identifier'
752
+ ];
753
+ const projection = {
754
+ _id: 0,
755
+ id: { $toString: '$_id' },
756
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
757
+ };
758
+ const query = this.actionModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
759
+ if (typeof params.sort?.startDate === 'number') {
760
+ query.sort({ startDate: params.sort.startDate });
761
+ }
762
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
763
+ .lean()
764
+ .exec();
765
+ }
271
766
  async upsertRecipe(savingRecipe) {
272
767
  const dateModified = new Date();
273
768
  const { typeOf, project, recipeCategory, recipeFor, step } = savingRecipe;
@@ -283,9 +778,9 @@ class ActionProcessRepo {
283
778
  $setOnInsert: setOnInsert,
284
779
  $set: setKeys
285
780
  };
286
- return this.actionRecipeModel.updateOne(filter, update, {
287
- upsert: true,
288
- includeResultMetadata: true
781
+ await this.actionRecipeModel.updateOne(filter, update, {
782
+ upsert: true
783
+ // includeResultMetadata: true
289
784
  })
290
785
  .exec();
291
786
  }
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import { IActionRecipe, ActionProcessRepo } from './actionProcess';
2
+ import { IKeyOfProjection, IActionRecipe, ActionProcessRepo } from './actionProcess';
3
3
  export type IAuthorizeInvoiceAction = factory.action.authorize.invoice.IAction & {
4
4
  /**
5
5
  * 実際存在しない属性だが、ActionProcessRepoのTActionに適合させるために補完
@@ -10,4 +10,17 @@ export type IAuthorizeInvoiceAction = factory.action.authorize.invoice.IAction &
10
10
  * インボイス承認リポジトリ
11
11
  */
12
12
  export declare class AuthorizeInvoiceActionRepo extends ActionProcessRepo<IAuthorizeInvoiceAction, IActionRecipe<factory.recipe.RecipeCategory.authorizeInvoice | factory.recipe.RecipeCategory.authorizeInvoice3ds>> {
13
+ /**
14
+ * 決済取引からインボイス承認アクションをひとつ参照する
15
+ */
16
+ findAuthorizeInvoiceActionsByPayTransaction(params: {
17
+ /**
18
+ * 決済方法ID
19
+ */
20
+ paymentMethodId: string;
21
+ /**
22
+ * 決済取引ID
23
+ */
24
+ payTransactionId: string;
25
+ }, inclusion: IKeyOfProjection[]): Promise<IAuthorizeInvoiceAction[]>;
13
26
  }
@@ -1,6 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.AuthorizeInvoiceActionRepo = void 0;
27
+ const factory = __importStar(require("../../factory"));
4
28
  // import { MONGO_MAX_TIME_MS } from '../settings';
5
29
  // import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
6
30
  // import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
@@ -9,5 +33,17 @@ const actionProcess_1 = require("./actionProcess");
9
33
  * インボイス承認リポジトリ
10
34
  */
11
35
  class AuthorizeInvoiceActionRepo extends actionProcess_1.ActionProcessRepo {
36
+ /**
37
+ * 決済取引からインボイス承認アクションをひとつ参照する
38
+ */
39
+ async findAuthorizeInvoiceActionsByPayTransaction(params, inclusion) {
40
+ return this.findAnyActions({
41
+ limit: 1, // ひとまず1でok
42
+ page: 1,
43
+ typeOf: { $eq: factory.actionType.AuthorizeAction },
44
+ object: { paymentMethodId: { $eq: params.paymentMethodId } },
45
+ sameAs: { id: { $eq: params.payTransactionId } } // sameAsが決済取引
46
+ }, inclusion);
47
+ }
12
48
  }
13
49
  exports.AuthorizeInvoiceActionRepo = AuthorizeInvoiceActionRepo;
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.AuthorizePaymentMethodActionRepo = void 0;
27
27
  const factory = __importStar(require("../../factory"));
28
- const settings_1 = require("../../settings");
28
+ // import { MONGO_MAX_TIME_MS } from '../../settings';
29
29
  // import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
30
30
  // import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
31
31
  const actionProcess_1 = require("./actionProcess");
@@ -37,52 +37,14 @@ class AuthorizePaymentMethodActionRepo extends actionProcess_1.ActionProcessRepo
37
37
  * 取引に対する決済承認アクションを検索する
38
38
  */
39
39
  async findAuthorizePaymentMethodActionsByPurpose(params) {
40
- const andConditions = [
41
- { typeOf: { $eq: factory.actionType.AuthorizeAction } },
42
- { 'purpose.typeOf': { $exists: true, $eq: params.purpose.typeOf } },
43
- { 'purpose.id': { $exists: true, $eq: params.purpose.id } },
44
- { 'object.typeOf': { $exists: true, $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } }
45
- ];
46
- const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
47
- if (typeof objectPaymentMethodIdEq === 'string') {
48
- andConditions.push({ 'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq } });
49
- }
50
- const actionStatusEq = params.actionStatus?.$eq;
51
- if (typeof actionStatusEq === 'string') {
52
- andConditions.push({ actionStatus: { $eq: actionStatusEq } });
53
- }
54
- const positiveProjectionFields = [
55
- 'project',
56
- 'actionStatus',
57
- 'typeOf',
58
- 'description',
59
- 'agent',
60
- 'recipient',
61
- 'result',
62
- 'error',
63
- 'object',
64
- 'startDate',
65
- 'endDate',
66
- 'purpose',
67
- 'potentialActions',
68
- 'instrument',
69
- 'location',
70
- 'sameAs',
71
- 'cancelAction',
72
- 'identifier'
73
- ];
74
- const projection = {
75
- _id: 0,
76
- id: { $toString: '$_id' },
77
- ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
78
- };
79
- const query = this.actionModel.find({ $and: andConditions }, projection);
80
- if (typeof params.sort?.startDate === 'number') {
81
- query.sort({ startDate: params.sort.startDate });
82
- }
83
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
84
- .lean()
85
- .exec();
40
+ return this.findAnyActionsByPurpose({
41
+ ...params,
42
+ typeOf: factory.actionType.AuthorizeAction,
43
+ object: {
44
+ ...params.object,
45
+ typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment }
46
+ }
47
+ });
86
48
  }
87
49
  }
88
50
  exports.AuthorizePaymentMethodActionRepo = AuthorizePaymentMethodActionRepo;