@chevre/domain 21.2.0-alpha.11 → 21.2.0-alpha.13
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/example/src/chevre/transaction/startExportTasks.ts +19 -0
- package/lib/chevre/repo/accountTransaction.d.ts +0 -10
- package/lib/chevre/repo/accountTransaction.js +0 -53
- package/lib/chevre/repo/assetTransaction.d.ts +2 -1
- package/lib/chevre/repo/assetTransaction.js +8 -9
- package/lib/chevre/repo/transaction.d.ts +2 -2
- package/lib/chevre/repo/transaction.js +10 -12
- package/lib/chevre/service/assetTransaction.d.ts +0 -2
- package/lib/chevre/service/assetTransaction.js +0 -1
- package/lib/chevre/service/transaction.d.ts +1 -0
- package/lib/chevre/service/transaction.js +1 -7
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
10
|
+
const result = await transactionRepo.startExportTasks({
|
|
11
|
+
typeOf: { $in: [chevre.factory.transactionType.PlaceOrder] },
|
|
12
|
+
status: chevre.factory.transactionStatusType.Confirmed
|
|
13
|
+
});
|
|
14
|
+
console.log(result);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
main()
|
|
18
|
+
.then(console.log)
|
|
19
|
+
.catch(console.error);
|
|
@@ -42,16 +42,6 @@ export declare class MongoRepository {
|
|
|
42
42
|
id?: string;
|
|
43
43
|
transactionNumber?: string;
|
|
44
44
|
}): Promise<factory.account.transaction.ITransaction<T>>;
|
|
45
|
-
/**
|
|
46
|
-
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
47
|
-
*/
|
|
48
|
-
/**
|
|
49
|
-
* タスクエクスポートリトライ
|
|
50
|
-
* TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
|
|
51
|
-
*/
|
|
52
|
-
/**
|
|
53
|
-
* タスクをエクスポート済に変更する
|
|
54
|
-
*/
|
|
55
45
|
/**
|
|
56
46
|
* 取引を期限切れにする
|
|
57
47
|
*/
|
|
@@ -221,59 +221,6 @@ class MongoRepository {
|
|
|
221
221
|
return doc.toObject();
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
-
/**
|
|
225
|
-
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
226
|
-
*/
|
|
227
|
-
// public async startExportTasks<T extends factory.account.transactionType>(
|
|
228
|
-
// status: factory.transactionStatusType
|
|
229
|
-
// ): Promise<factory.account.transaction.ITransaction<T> | null> {
|
|
230
|
-
// return this.transactionModel.findOneAndUpdate(
|
|
231
|
-
// {
|
|
232
|
-
// status: status,
|
|
233
|
-
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
234
|
-
// },
|
|
235
|
-
// { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting },
|
|
236
|
-
// { new: true }
|
|
237
|
-
// )
|
|
238
|
-
// .exec()
|
|
239
|
-
// // tslint:disable-next-line:no-null-keyword
|
|
240
|
-
// .then((doc) => (doc === null) ? null : doc.toObject());
|
|
241
|
-
// }
|
|
242
|
-
// tslint:disable-next-line:no-suspicious-comment
|
|
243
|
-
/**
|
|
244
|
-
* タスクエクスポートリトライ
|
|
245
|
-
* TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
|
|
246
|
-
*/
|
|
247
|
-
// public async reexportTasks(params: { intervalInMinutes: number }): Promise<void> {
|
|
248
|
-
// await this.transactionModel.updateMany(
|
|
249
|
-
// {
|
|
250
|
-
// tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
|
|
251
|
-
// updatedAt: {
|
|
252
|
-
// $lt: moment()
|
|
253
|
-
// .add(-params.intervalInMinutes, 'minutes')
|
|
254
|
-
// .toDate()
|
|
255
|
-
// }
|
|
256
|
-
// },
|
|
257
|
-
// {
|
|
258
|
-
// tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
259
|
-
// }
|
|
260
|
-
// )
|
|
261
|
-
// .exec();
|
|
262
|
-
// }
|
|
263
|
-
/**
|
|
264
|
-
* タスクをエクスポート済に変更する
|
|
265
|
-
*/
|
|
266
|
-
// public async setTasksExportedById(transactionId: string): Promise<void> {
|
|
267
|
-
// await this.transactionModel.findByIdAndUpdate(
|
|
268
|
-
// transactionId,
|
|
269
|
-
// {
|
|
270
|
-
// tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
271
|
-
// tasksExportedAt: moment()
|
|
272
|
-
// .toDate()
|
|
273
|
-
// }
|
|
274
|
-
// )
|
|
275
|
-
// .exec();
|
|
276
|
-
// }
|
|
277
224
|
/**
|
|
278
225
|
* 取引を期限切れにする
|
|
279
226
|
*/
|
|
@@ -100,7 +100,8 @@ export declare class MongoRepository {
|
|
|
100
100
|
$in: T[];
|
|
101
101
|
};
|
|
102
102
|
status: factory.transactionStatusType;
|
|
103
|
-
|
|
103
|
+
id?: string;
|
|
104
|
+
}): Promise<Pick<factory.assetTransaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
|
|
104
105
|
/**
|
|
105
106
|
* タスクエクスポートリトライ
|
|
106
107
|
* TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
|
|
@@ -353,15 +353,14 @@ class MongoRepository {
|
|
|
353
353
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
354
354
|
*/
|
|
355
355
|
startExportTasks(params) {
|
|
356
|
-
var _a, _b
|
|
356
|
+
var _a, _b;
|
|
357
357
|
return __awaiter(this, void 0, void 0, function* () {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
? { typeOf: { $in: (_c = params.typeOf) === null || _c === void 0 ? void 0 : _c.$in } } : undefined), { status: params.status, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }), { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting }, { new: true })
|
|
358
|
+
const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
|
|
359
|
+
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: params.status, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting }, { new: true })
|
|
360
|
+
.select({
|
|
361
|
+
_id: 1,
|
|
362
|
+
typeOf: 1
|
|
363
|
+
})
|
|
365
364
|
.exec()
|
|
366
365
|
// tslint:disable-next-line:no-null-keyword
|
|
367
366
|
.then((doc) => (doc === null) ? null : doc.toObject());
|
|
@@ -393,7 +392,7 @@ class MongoRepository {
|
|
|
393
392
|
*/
|
|
394
393
|
setTasksExportedById(params) {
|
|
395
394
|
return __awaiter(this, void 0, void 0, function* () {
|
|
396
|
-
yield this.transactionModel.
|
|
395
|
+
yield this.transactionModel.updateOne({ _id: { $eq: params.id } }, {
|
|
397
396
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
398
397
|
tasksExportedAt: moment()
|
|
399
398
|
.toDate()
|
|
@@ -88,7 +88,6 @@ export declare class MongoRepository {
|
|
|
88
88
|
id: string;
|
|
89
89
|
object?: {
|
|
90
90
|
name?: string;
|
|
91
|
-
dateOnTransactionStatusChangedEmitted?: Date;
|
|
92
91
|
};
|
|
93
92
|
}): Promise<void>;
|
|
94
93
|
/**
|
|
@@ -112,7 +111,8 @@ export declare class MongoRepository {
|
|
|
112
111
|
$in: T[];
|
|
113
112
|
};
|
|
114
113
|
status: factory.transactionStatusType;
|
|
115
|
-
|
|
114
|
+
id?: string;
|
|
115
|
+
}): Promise<Pick<factory.transaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
|
|
116
116
|
/**
|
|
117
117
|
* タスクエクスポートリトライ
|
|
118
118
|
* TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
|
|
@@ -384,16 +384,14 @@ class MongoRepository {
|
|
|
384
384
|
* 注文名称など
|
|
385
385
|
*/
|
|
386
386
|
updateObject(params) {
|
|
387
|
-
var _a
|
|
387
|
+
var _a;
|
|
388
388
|
return __awaiter(this, void 0, void 0, function* () {
|
|
389
389
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
390
390
|
_id: params.id,
|
|
391
391
|
typeOf: params.typeOf,
|
|
392
392
|
status: factory.transactionStatusType.InProgress
|
|
393
393
|
}, {
|
|
394
|
-
$set: Object.assign(
|
|
395
|
-
? { 'object.dateOnTransactionStatusChangedEmitted': params.object.dateOnTransactionStatusChangedEmitted }
|
|
396
|
-
: undefined)
|
|
394
|
+
$set: Object.assign({}, (typeof ((_a = params.object) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? { 'object.name': params.object.name } : undefined)
|
|
397
395
|
}, {
|
|
398
396
|
projection: { _id: 1 }
|
|
399
397
|
})
|
|
@@ -455,14 +453,14 @@ class MongoRepository {
|
|
|
455
453
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
456
454
|
*/
|
|
457
455
|
startExportTasks(params) {
|
|
456
|
+
var _a;
|
|
458
457
|
return __awaiter(this, void 0, void 0, function* () {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
? { typeOf: { $in: params.typeOf.$in } } : undefined), { status: params.status, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }), { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting }, { new: true })
|
|
458
|
+
const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
|
|
459
|
+
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: params.status, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting }, { new: true })
|
|
460
|
+
.select({
|
|
461
|
+
_id: 1,
|
|
462
|
+
typeOf: 1
|
|
463
|
+
})
|
|
466
464
|
.exec()
|
|
467
465
|
// tslint:disable-next-line:no-null-keyword
|
|
468
466
|
.then((doc) => (doc === null) ? null : doc.toObject());
|
|
@@ -494,7 +492,7 @@ class MongoRepository {
|
|
|
494
492
|
*/
|
|
495
493
|
setTasksExportedById(params) {
|
|
496
494
|
return __awaiter(this, void 0, void 0, function* () {
|
|
497
|
-
yield this.transactionModel.
|
|
495
|
+
yield this.transactionModel.updateOne({ _id: { $eq: params.id } }, {
|
|
498
496
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
499
497
|
tasksExportedAt: new Date()
|
|
500
498
|
})
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as factory from '../factory';
|
|
5
5
|
import { MongoRepository as AssetTransactionRepo } from '../repo/assetTransaction';
|
|
6
|
-
import { MongoRepository as ProjectRepo } from '../repo/project';
|
|
7
6
|
import { MongoRepository as TaskRepo } from '../repo/task';
|
|
8
7
|
import * as CancelReservationTransactionService from './assetTransaction/cancelReservation';
|
|
9
8
|
import * as MoneyTransferTransactionService from './assetTransaction/moneyTransfer';
|
|
@@ -30,7 +29,6 @@ export declare function exportTasks<T extends factory.assetTransactionType>(para
|
|
|
30
29
|
$in: T[];
|
|
31
30
|
};
|
|
32
31
|
}): (repos: {
|
|
33
|
-
project: ProjectRepo;
|
|
34
32
|
task: TaskRepo;
|
|
35
33
|
assetTransaction: AssetTransactionRepo;
|
|
36
34
|
}) => Promise<{
|
|
@@ -32,7 +32,6 @@ exports.reserve = ReserveTransactionService;
|
|
|
32
32
|
function exportTasks(params) {
|
|
33
33
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const transaction = yield repos.assetTransaction.startExportTasks({
|
|
35
|
-
// project: params.project,
|
|
36
35
|
typeOf: params.typeOf,
|
|
37
36
|
status: params.status
|
|
38
37
|
});
|
|
@@ -77,15 +77,10 @@ exports.updateAgent = updateAgent;
|
|
|
77
77
|
*/
|
|
78
78
|
function exportTasks(params) {
|
|
79
79
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const transaction = yield repos.transaction.startExportTasks({
|
|
81
|
-
project: params.project,
|
|
82
|
-
typeOf: params.typeOf,
|
|
83
|
-
status: params.status
|
|
84
|
-
});
|
|
80
|
+
const transaction = yield repos.transaction.startExportTasks(Object.assign({ project: params.project, typeOf: params.typeOf, status: params.status }, (typeof params.id === 'string') ? { id: params.id } : undefined));
|
|
85
81
|
if (transaction === null) {
|
|
86
82
|
return;
|
|
87
83
|
}
|
|
88
|
-
// let tasks: factory.task.ITask<factory.taskName>[] = [];
|
|
89
84
|
// 失敗してもここでは戻さない(RUNNINGのまま待機)
|
|
90
85
|
switch (transaction.typeOf) {
|
|
91
86
|
case factory.transactionType.MoneyTransfer:
|
|
@@ -109,7 +104,6 @@ function exportTasks(params) {
|
|
|
109
104
|
default:
|
|
110
105
|
}
|
|
111
106
|
yield repos.transaction.setTasksExportedById({ id: transaction.id });
|
|
112
|
-
// return tasks;
|
|
113
107
|
});
|
|
114
108
|
}
|
|
115
109
|
exports.exportTasks = exportTasks;
|
package/package.json
CHANGED