@chevre/domain 21.2.0-alpha.33 → 21.2.0-alpha.34
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.
- package/lib/chevre/repo/assetTransaction.js +13 -20
- package/lib/chevre/repo/transaction.js +10 -19
- package/lib/chevre/service/offer.js +1 -1
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/product.js +1 -5
- package/lib/chevre/service/reserve/cancelReservation.js +0 -2
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +18 -17
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +1 -5
- package/package.json +1 -1
|
@@ -248,7 +248,9 @@ class MongoRepository {
|
|
|
248
248
|
*/
|
|
249
249
|
start(params) {
|
|
250
250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined,
|
|
251
|
+
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportAction: {
|
|
252
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
253
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
|
|
252
254
|
.then((doc) => doc.toObject());
|
|
253
255
|
});
|
|
254
256
|
}
|
|
@@ -349,7 +351,9 @@ class MongoRepository {
|
|
|
349
351
|
*/
|
|
350
352
|
startAndConfirm(params) {
|
|
351
353
|
return __awaiter(this, void 0, void 0, function* () {
|
|
352
|
-
return this.transactionModel.create(Object.assign(Object.assign({ _id: params.id, typeOf: params.typeOf
|
|
354
|
+
return this.transactionModel.create(Object.assign(Object.assign({}, params), { _id: params.id, typeOf: params.typeOf, startDate: new Date(), status: factory.transactionStatusType.Confirmed, tasksExportAction: {
|
|
355
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
356
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }))
|
|
353
357
|
.then((doc) => doc.toObject());
|
|
354
358
|
});
|
|
355
359
|
}
|
|
@@ -367,10 +371,9 @@ class MongoRepository {
|
|
|
367
371
|
}
|
|
368
372
|
const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
|
|
369
373
|
return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof ((_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? { 'project.id': { $eq: params.project.id } } : undefined), (Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined), { status: { $eq: params.status }, tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported } }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), {
|
|
370
|
-
tasksExportAction:
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
},
|
|
374
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
|
|
375
|
+
'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
|
|
376
|
+
'tasksExportAction.startDate': new Date(),
|
|
374
377
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
|
|
375
378
|
}, { new: true })
|
|
376
379
|
.select({
|
|
@@ -410,6 +413,9 @@ class MongoRepository {
|
|
|
410
413
|
_id: { $eq: reexportingTransaction.id },
|
|
411
414
|
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
412
415
|
}, {
|
|
416
|
+
tasksExportAction: {
|
|
417
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
418
|
+
},
|
|
413
419
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
414
420
|
})
|
|
415
421
|
.exec();
|
|
@@ -420,20 +426,6 @@ class MongoRepository {
|
|
|
420
426
|
});
|
|
421
427
|
}
|
|
422
428
|
}
|
|
423
|
-
// await this.transactionModel.updateMany(
|
|
424
|
-
// {
|
|
425
|
-
// tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
|
|
426
|
-
// updatedAt: {
|
|
427
|
-
// $lt: moment()
|
|
428
|
-
// .add(-params.intervalInMinutes, 'minutes')
|
|
429
|
-
// .toDate()
|
|
430
|
-
// }
|
|
431
|
-
// },
|
|
432
|
-
// {
|
|
433
|
-
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
434
|
-
// }
|
|
435
|
-
// )
|
|
436
|
-
// .exec();
|
|
437
429
|
});
|
|
438
430
|
}
|
|
439
431
|
/**
|
|
@@ -489,6 +481,7 @@ class MongoRepository {
|
|
|
489
481
|
}, {
|
|
490
482
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
491
483
|
tasksExportedAt: endDate,
|
|
484
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
|
|
492
485
|
'tasksExportAction.endDate': endDate
|
|
493
486
|
})
|
|
494
487
|
.exec();
|
|
@@ -264,7 +264,9 @@ class MongoRepository {
|
|
|
264
264
|
else {
|
|
265
265
|
expires = params.expires;
|
|
266
266
|
}
|
|
267
|
-
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires,
|
|
267
|
+
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires, tasksExportAction: {
|
|
268
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
269
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
|
|
268
270
|
.then((doc) => doc.toObject());
|
|
269
271
|
});
|
|
270
272
|
}
|
|
@@ -478,10 +480,9 @@ class MongoRepository {
|
|
|
478
480
|
}
|
|
479
481
|
const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
|
|
480
482
|
return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.project !== undefined) ? { 'project.id': { $eq: params.project.id } } : undefined), (Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined), { status: { $eq: params.status }, tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported } }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), {
|
|
481
|
-
tasksExportAction:
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
},
|
|
483
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
|
|
484
|
+
'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
|
|
485
|
+
'tasksExportAction.startDate': new Date(),
|
|
485
486
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
|
|
486
487
|
}, { new: true })
|
|
487
488
|
.select({
|
|
@@ -521,6 +522,9 @@ class MongoRepository {
|
|
|
521
522
|
_id: { $eq: reexportingTransaction.id },
|
|
522
523
|
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
523
524
|
}, {
|
|
525
|
+
tasksExportAction: {
|
|
526
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
527
|
+
},
|
|
524
528
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
525
529
|
})
|
|
526
530
|
.exec();
|
|
@@ -531,20 +535,6 @@ class MongoRepository {
|
|
|
531
535
|
});
|
|
532
536
|
}
|
|
533
537
|
}
|
|
534
|
-
// await this.transactionModel.updateMany(
|
|
535
|
-
// {
|
|
536
|
-
// tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
|
|
537
|
-
// updatedAt: {
|
|
538
|
-
// $lt: moment()
|
|
539
|
-
// .add(-params.intervalInMinutes, 'minutes')
|
|
540
|
-
// .toDate()
|
|
541
|
-
// }
|
|
542
|
-
// },
|
|
543
|
-
// {
|
|
544
|
-
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
545
|
-
// }
|
|
546
|
-
// )
|
|
547
|
-
// .exec();
|
|
548
538
|
});
|
|
549
539
|
}
|
|
550
540
|
/**
|
|
@@ -600,6 +590,7 @@ class MongoRepository {
|
|
|
600
590
|
}, {
|
|
601
591
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
602
592
|
tasksExportedAt: endDate,
|
|
593
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
|
|
603
594
|
'tasksExportAction.endDate': endDate
|
|
604
595
|
})
|
|
605
596
|
.exec();
|
|
@@ -77,10 +77,6 @@ function onRegistered(actionAttributes, __) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
// タスク保管
|
|
80
|
-
|
|
81
|
-
yield repos.task.saveMany(taskAttributes);
|
|
82
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
83
|
-
// return repos.task.save(taskAttribute);
|
|
84
|
-
// }));
|
|
80
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
85
81
|
});
|
|
86
82
|
}
|
|
@@ -144,7 +144,6 @@ function cancelPendingReservation(actionAttributesList) {
|
|
|
144
144
|
// canceledReservationId: canceledReservation?.id
|
|
145
145
|
);
|
|
146
146
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
147
|
-
// await onReservationCanceledByAction(actionAttributes)({ task: repos.task });
|
|
148
147
|
if (actionObject.typeOf === factory.reservationType.ReservationPackage) {
|
|
149
148
|
// 最新のconfirmedReservationsを検索
|
|
150
149
|
canceledReservations = yield repos.reservation.search({
|
|
@@ -297,7 +296,6 @@ function cancelReservation(actionAttributesList) {
|
|
|
297
296
|
// canceledReservationId: canceledReservation?.id
|
|
298
297
|
);
|
|
299
298
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
300
|
-
// await onReservationCanceledByAction(actionAttributes)({ task: repos.task });
|
|
301
299
|
let canceledReservations = [];
|
|
302
300
|
if (actionAttributes.object.typeOf === factory.reservationType.ReservationPackage) {
|
|
303
301
|
const reservationNumber = actionAttributes.object.reservationNumber;
|
|
@@ -4,9 +4,6 @@ type IEventReservation = factory.reservation.IReservation<factory.reservationTyp
|
|
|
4
4
|
/**
|
|
5
5
|
* 予約取消後のアクション
|
|
6
6
|
*/
|
|
7
|
-
export declare function onReservationCanceledByAction(actionAttributes: factory.action.cancel.reservation.IAttributes): (repos: {
|
|
8
|
-
task: TaskRepo;
|
|
9
|
-
}) => Promise<void>;
|
|
10
7
|
export declare function onReservationCanceled(canceledReservations: IEventReservation[], useInformReservation: boolean): (repos: {
|
|
11
8
|
task: TaskRepo;
|
|
12
9
|
}) => Promise<void>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.onReservationCanceled =
|
|
12
|
+
exports.onReservationCanceled = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* 予約取消時アクション
|
|
15
15
|
*/
|
|
@@ -23,22 +23,23 @@ const INFORM_TASK_DELAY_IN_SECONDS = 30;
|
|
|
23
23
|
/**
|
|
24
24
|
* 予約取消後のアクション
|
|
25
25
|
*/
|
|
26
|
-
function onReservationCanceledByAction(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
26
|
+
// export function onReservationCanceledByAction(
|
|
27
|
+
// actionAttributes: factory.action.cancel.reservation.IAttributes
|
|
28
|
+
// ) {
|
|
29
|
+
// return async (repos: {
|
|
30
|
+
// task: TaskRepo;
|
|
31
|
+
// }) => {
|
|
32
|
+
// const potentialActions = actionAttributes.potentialActions;
|
|
33
|
+
// const taskAttributes: factory.task.IAttributes<factory.taskName>[] = [];
|
|
34
|
+
// if (potentialActions !== undefined) {
|
|
35
|
+
// // no op
|
|
36
|
+
// }
|
|
37
|
+
// // タスク保管
|
|
38
|
+
// if (taskAttributes.length > 0) {
|
|
39
|
+
// await repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
40
|
+
// }
|
|
41
|
+
// };
|
|
42
|
+
// }
|
|
42
43
|
function onReservationCanceled(canceledReservations, useInformReservation) {
|
|
43
44
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
44
45
|
if (Array.isArray(canceledReservations) && canceledReservations.length > 0) {
|
|
@@ -57,38 +57,9 @@ function onReservationConfirmedByAction(actionAttributes
|
|
|
57
57
|
}));
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
// inform galobally
|
|
61
|
-
// if (Array.isArray(informReservations)) {
|
|
62
|
-
// const reservation4inform: IReservation4informConfirmed = maskUnderName(confirmedReservation);
|
|
63
|
-
// taskAttributes.push(...informReservations.map<ITriggerWebhookTaskAttributes>((informReservation) => {
|
|
64
|
-
// const informUrl: string = String(informReservation.recipient?.url);
|
|
65
|
-
// const informReservationAttributes: InformReservationActionattributes = {
|
|
66
|
-
// agent: confirmedReservation.project,
|
|
67
|
-
// object: [reservation4inform],
|
|
68
|
-
// project: confirmedReservation.project,
|
|
69
|
-
// recipient: {
|
|
70
|
-
// id: '',
|
|
71
|
-
// name: informUrl,
|
|
72
|
-
// typeOf: factory.creativeWorkType.WebApplication,
|
|
73
|
-
// url: informUrl
|
|
74
|
-
// },
|
|
75
|
-
// typeOf: factory.actionType.InformAction
|
|
76
|
-
// };
|
|
77
|
-
// return {
|
|
78
|
-
// project: actionAttributes.project,
|
|
79
|
-
// name: factory.taskName.TriggerWebhook,
|
|
80
|
-
// status: factory.taskStatus.Ready,
|
|
81
|
-
// runsAt: now,
|
|
82
|
-
// remainingNumberOfTries: NUM_TRY_INFORM_RESERVATION,
|
|
83
|
-
// numberOfTried: 0,
|
|
84
|
-
// executionResults: [],
|
|
85
|
-
// data: informReservationAttributes
|
|
86
|
-
// };
|
|
87
|
-
// }));
|
|
88
|
-
// }
|
|
89
60
|
// タスク保管
|
|
90
61
|
if (taskAttributes.length > 0) {
|
|
91
|
-
yield repos.task.saveMany(taskAttributes);
|
|
62
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
92
63
|
}
|
|
93
64
|
});
|
|
94
65
|
}
|
|
@@ -142,7 +113,7 @@ function onReservationConfirmed(confirmedReservations) {
|
|
|
142
113
|
}
|
|
143
114
|
// タスク保管
|
|
144
115
|
if (taskAttributes.length > 0) {
|
|
145
|
-
yield repos.task.saveMany(taskAttributes);
|
|
116
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
146
117
|
}
|
|
147
118
|
}
|
|
148
119
|
});
|
|
@@ -95,7 +95,7 @@ function onRegistered(actionAttributes) {
|
|
|
95
95
|
taskAttributes.push(...orderProgramMembershipTasks);
|
|
96
96
|
}
|
|
97
97
|
// タスク保管
|
|
98
|
-
yield repos.task.saveMany(taskAttributes);
|
|
98
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
exports.onRegistered = onRegistered;
|
|
@@ -219,10 +219,6 @@ function onRefund(refundActionAttributes) {
|
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
// タスク保管
|
|
222
|
-
|
|
223
|
-
yield repos.task.saveMany(taskAttributes);
|
|
224
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
225
|
-
// return repos.task.save(taskAttribute);
|
|
226
|
-
// }));
|
|
222
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
227
223
|
});
|
|
228
224
|
}
|
package/package.json
CHANGED