@chevre/domain 26.0.0-alpha.13 → 26.0.0-alpha.14
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/adminTask.d.ts +12 -0
- package/lib/chevre/repo/adminTask.js +24 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +4 -0
- package/lib/chevre/repo/task.d.ts +1 -71
- package/lib/chevre/repo/task.js +8 -186
- package/lib/chevre/repo/taskDelayed.d.ts +67 -0
- package/lib/chevre/repo/taskDelayed.js +148 -0
- package/lib/chevre/repository.d.ts +5 -10
- package/lib/chevre/repository.js +11 -22
- package/lib/chevre/service/asyncAction.js +1 -1
- package/lib/chevre/service/scheduledTask.js +1 -1
- package/lib/chevre/service/task/acceptCOAOffer.js +1 -14
- package/lib/chevre/service/task/authorizePayment.js +1 -7
- package/lib/chevre/service/task/checkMovieTicket.js +1 -7
- package/lib/chevre/service/task/publishPaymentUrl.js +1 -10
- package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -5
- package/lib/chevre/service/task/voidReserveTransaction.js +5 -8
- package/lib/chevre/service/task.d.ts +3 -3
- package/lib/chevre/service/task.js +3 -3
- package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +1 -2
- package/lib/chevre/service/taskHandler/onOperationFailed.js +8 -7
- package/lib/chevre/service/taskHandler.d.ts +1 -2
- package/lib/chevre/service/taskHandler.js +6 -5
- package/lib/chevre/taskSettings.d.ts +4 -2
- package/package.json +1 -1
- package/lib/chevre/repo/asyncActionLegacy.d.ts +0 -23
- package/lib/chevre/repo/asyncActionLegacy.js +0 -59
- package/lib/chevre/repo/scheduledTaskLegacy.d.ts +0 -39
- package/lib/chevre/repo/scheduledTaskLegacy.js +0 -96
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ScheduledTaskLegacyRepo = void 0;
|
|
7
|
-
const moment_1 = __importDefault(require("moment"));
|
|
8
|
-
const task_1 = require("../eventEmitter/task");
|
|
9
|
-
const factory_1 = require("../factory");
|
|
10
|
-
const settings_1 = require("../settings");
|
|
11
|
-
const task_2 = require("./mongoose/schemas/task");
|
|
12
|
-
/**
|
|
13
|
-
* 旧予定タスクリポジトリ
|
|
14
|
-
*/
|
|
15
|
-
class ScheduledTaskLegacyRepo {
|
|
16
|
-
taskModel;
|
|
17
|
-
constructor(connection) {
|
|
18
|
-
this.taskModel = connection.model(task_2.modelName, (0, task_2.createSchema)());
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* $eq:0をAbortedにする(特定のタスクのみ)(これらは中止されてもhubへ通知しない)
|
|
22
|
-
*/
|
|
23
|
-
async abortLegacyTasks(params) {
|
|
24
|
-
const lastTriedAtShoudBeLessThan = (0, moment_1.default)()
|
|
25
|
-
.add(-params.intervalInMinutes, 'minutes')
|
|
26
|
-
.toDate();
|
|
27
|
-
return this.taskModel.updateMany({
|
|
28
|
-
status: { $eq: factory_1.factory.taskStatus.Running },
|
|
29
|
-
lastTriedAt: {
|
|
30
|
-
$type: 'date',
|
|
31
|
-
$lt: lastTriedAtShoudBeLessThan
|
|
32
|
-
},
|
|
33
|
-
remainingNumberOfTries: { $eq: 0 },
|
|
34
|
-
name: { $in: params.name.$in }
|
|
35
|
-
}, {
|
|
36
|
-
$set: {
|
|
37
|
-
status: factory_1.factory.taskStatus.Aborted,
|
|
38
|
-
dateAborted: new Date()
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
.exec();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更した上で、Runningイベントを発生させる
|
|
45
|
-
*/
|
|
46
|
-
async emitRunningIfExistsLegacy(params
|
|
47
|
-
// next?: INextFunction // 現時点でタスク遅延実行ではnext指定なし(2026-07-30)
|
|
48
|
-
) {
|
|
49
|
-
if (!(params.runsAt.$lt instanceof Date)) {
|
|
50
|
-
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
51
|
-
}
|
|
52
|
-
const projection = {
|
|
53
|
-
_id: 0,
|
|
54
|
-
id: { $toString: '$_id' },
|
|
55
|
-
name: 1
|
|
56
|
-
};
|
|
57
|
-
const nameEq = params.name?.$eq;
|
|
58
|
-
// インデックス'executeOneByNameIfExists'を想定したfilter
|
|
59
|
-
const filter = {
|
|
60
|
-
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
61
|
-
runsAt: { $lt: params.runsAt.$lt },
|
|
62
|
-
name: params.name
|
|
63
|
-
};
|
|
64
|
-
const doc = await this.taskModel.findOneAndUpdate(filter, {
|
|
65
|
-
$set: {
|
|
66
|
-
status: factory_1.factory.taskStatus.Running, // 実行中に変更
|
|
67
|
-
lastTriedAt: new Date(),
|
|
68
|
-
executor: params.executor
|
|
69
|
-
},
|
|
70
|
-
$inc: {
|
|
71
|
-
remainingNumberOfTries: -1, // 残りトライ可能回数減らす
|
|
72
|
-
numberOfTried: 1 // トライ回数増やす
|
|
73
|
-
}
|
|
74
|
-
}, {
|
|
75
|
-
new: true,
|
|
76
|
-
projection,
|
|
77
|
-
...(typeof params.sort.numberOfTried === 'number' || typeof params.sort.runsAt === 'number')
|
|
78
|
-
? { sort: params.sort }
|
|
79
|
-
: undefined
|
|
80
|
-
})
|
|
81
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
82
|
-
.lean()
|
|
83
|
-
.exec();
|
|
84
|
-
if (doc === null) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
const changedTask = {
|
|
88
|
-
id: doc.id,
|
|
89
|
-
status: factory_1.factory.taskStatus.Running,
|
|
90
|
-
name: nameEq
|
|
91
|
-
};
|
|
92
|
-
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask);
|
|
93
|
-
return doc;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.ScheduledTaskLegacyRepo = ScheduledTaskLegacyRepo;
|