@chevre/domain 26.0.0-alpha.2 → 26.0.0-alpha.21
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/eventEmitter/task.d.ts +8 -23
- package/lib/chevre/eventEmitter/task.js +2 -2
- package/lib/chevre/repo/adminAsyncAction.d.ts +2 -2
- package/lib/chevre/repo/adminScheduledTask.d.ts +1 -1
- package/lib/chevre/repo/adminTask.d.ts +31 -8
- package/lib/chevre/repo/adminTask.js +41 -26
- package/lib/chevre/repo/aggregateScheduledTask.d.ts +32 -0
- package/lib/chevre/repo/aggregateScheduledTask.js +136 -0
- package/lib/chevre/repo/asyncAction.d.ts +2 -2
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +1 -0
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +2 -5
- package/lib/chevre/repo/mongoose/schemas/task.js +87 -96
- package/lib/chevre/repo/orderInTransaction.d.ts +0 -3
- package/lib/chevre/repo/orderInTransaction.js +30 -22
- package/lib/chevre/repo/scheduledTask.d.ts +5 -2
- package/lib/chevre/repo/scheduledTask.js +3 -25
- package/lib/chevre/repo/task.d.ts +25 -172
- package/lib/chevre/repo/task.js +19 -475
- package/lib/chevre/repo/taskDelayed.d.ts +74 -0
- package/lib/chevre/repo/taskDelayed.js +195 -0
- package/lib/chevre/repo/taskRunning.d.ts +35 -0
- package/lib/chevre/repo/taskRunning.js +89 -0
- package/lib/chevre/repository.d.ts +10 -0
- package/lib/chevre/repository.js +24 -2
- package/lib/chevre/service/aggregation/system.d.ts +10 -2
- package/lib/chevre/service/aggregation/system.js +42 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +5 -25
- package/lib/chevre/service/asyncAction.d.ts +2 -2
- package/lib/chevre/service/asyncAction.js +1 -4
- package/lib/chevre/service/asyncActionHandler/onOperationFailed.d.ts +2 -2
- package/lib/chevre/service/asyncActionHandler/onOperationFailed.js +0 -2
- package/lib/chevre/service/asyncActionHandler.d.ts +4 -4
- package/lib/chevre/service/asyncActionHandler.js +11 -13
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +0 -4
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +19 -19
- package/lib/chevre/service/order/confirmPayTransaction.js +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +4 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +0 -4
- package/lib/chevre/service/payment/any/findAcceptAction.js +19 -19
- package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +0 -4
- package/lib/chevre/service/payment/any/findAuthorizeAction.js +19 -19
- package/lib/chevre/service/payment/any/findCheckAction.d.ts +0 -4
- package/lib/chevre/service/payment/any/findCheckAction.js +19 -19
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +0 -2
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +2 -2
- package/lib/chevre/service/project.d.ts +0 -3
- package/lib/chevre/service/project.js +0 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -2
- package/lib/chevre/service/scheduledTask.d.ts +1 -4
- package/lib/chevre/service/scheduledTask.js +3 -10
- package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.js +1 -2
- package/lib/chevre/service/scheduledTaskHandler.js +0 -13
- 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/confirmReserveTransaction.js +3 -1
- package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +4 -1
- package/lib/chevre/service/task/importEventsFromCOA.js +4 -1
- package/lib/chevre/service/task/importOffersFromCOA.js +5 -5
- package/lib/chevre/service/task/publishPaymentUrl.js +2 -13
- 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 -22
- package/lib/chevre/service/task.js +8 -40
- package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +3 -2
- package/lib/chevre/service/taskHandler/onOperationFailed.js +5 -16
- package/lib/chevre/service/taskHandler.d.ts +1 -2
- package/lib/chevre/service/taskHandler.js +7 -53
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +8 -4
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +55 -103
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +2 -0
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +14 -10
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.d.ts +13 -3
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +48 -51
- package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
- package/lib/chevre/service/transaction/returnOrder.js +15 -13
- package/lib/chevre/service/transaction.d.ts +2 -0
- package/lib/chevre/service/transaction.js +0 -2
- package/lib/chevre/taskSettings.d.ts +4 -4
- package/package.json +2 -2
|
@@ -0,0 +1,195 @@
|
|
|
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.TaskDelayedRepo = 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 TaskDelayedRepo {
|
|
16
|
+
taskModel;
|
|
17
|
+
constructor(connection) {
|
|
18
|
+
this.taskModel = connection.model(task_2.modelName, (0, task_2.createSchema)());
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 潜在的に実行されるべきタスクをカウントする
|
|
22
|
+
* add(2025-03-16~)
|
|
23
|
+
*/
|
|
24
|
+
async countPotentiallyRunning(params) {
|
|
25
|
+
const { runsAt, limit, name } = params;
|
|
26
|
+
const nameEq = name?.$eq;
|
|
27
|
+
const nameIn = name?.$in;
|
|
28
|
+
if (!(runsAt.$lt instanceof Date)) {
|
|
29
|
+
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
30
|
+
}
|
|
31
|
+
const query = this.taskModel.countDocuments({
|
|
32
|
+
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
33
|
+
...(typeof nameEq === 'string' || Array.isArray(nameIn))
|
|
34
|
+
? {
|
|
35
|
+
name: {
|
|
36
|
+
...(typeof nameEq === 'string') ? { $eq: nameEq } : undefined,
|
|
37
|
+
...(Array.isArray(nameIn)) ? { $in: nameIn } : undefined
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
: undefined,
|
|
41
|
+
runsAt: { $lt: params.runsAt.$lt }
|
|
42
|
+
});
|
|
43
|
+
if (typeof limit === 'number' && limit >= 0) {
|
|
44
|
+
query.limit(limit);
|
|
45
|
+
}
|
|
46
|
+
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
47
|
+
.exec();
|
|
48
|
+
return { count };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更する
|
|
52
|
+
*/
|
|
53
|
+
async runDelayedTask(params) {
|
|
54
|
+
const { filter } = params;
|
|
55
|
+
const projection = {
|
|
56
|
+
_id: 0,
|
|
57
|
+
id: { $toString: '$_id' },
|
|
58
|
+
name: 1
|
|
59
|
+
};
|
|
60
|
+
return this.taskModel.findOneAndUpdate(filter, {
|
|
61
|
+
$set: {
|
|
62
|
+
status: factory_1.factory.taskStatus.Running, // 実行中に変更
|
|
63
|
+
lastTriedAt: new Date(),
|
|
64
|
+
executor: params.executor
|
|
65
|
+
},
|
|
66
|
+
$inc: {
|
|
67
|
+
remainingNumberOfTries: -1, // 残りトライ可能回数減らす
|
|
68
|
+
numberOfTried: 1 // トライ回数増やす
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
new: true,
|
|
72
|
+
projection,
|
|
73
|
+
sort: {
|
|
74
|
+
runsAt: factory_1.factory.sortType.Ascending // ソートはrunsAtで固定化(2026-08-07~)
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
78
|
+
.lean()
|
|
79
|
+
.exec();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更した上で、Runningイベントを発生させる
|
|
83
|
+
*/
|
|
84
|
+
async runDelayedTaskIfExistsByName(params) {
|
|
85
|
+
if (!(params.runsAt.$lt instanceof Date)) {
|
|
86
|
+
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
87
|
+
}
|
|
88
|
+
// インデックスについては、name指定であれば'executeOneByName'あるいは'runDelayedTaskByName'を想定
|
|
89
|
+
const filter = {
|
|
90
|
+
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
91
|
+
name: params.name,
|
|
92
|
+
runsAt: { $lt: params.runsAt.$lt }
|
|
93
|
+
};
|
|
94
|
+
const doc = await this.runDelayedTask({
|
|
95
|
+
filter,
|
|
96
|
+
executor: params.executor
|
|
97
|
+
});
|
|
98
|
+
if (doc === null) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const nameEq = params.name?.$eq;
|
|
102
|
+
let changedTask;
|
|
103
|
+
if (typeof nameEq === 'string') {
|
|
104
|
+
changedTask = {
|
|
105
|
+
id: doc.id,
|
|
106
|
+
status: factory_1.factory.taskStatus.Running,
|
|
107
|
+
name: nameEq
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
changedTask = {
|
|
112
|
+
id: doc.id,
|
|
113
|
+
status: factory_1.factory.taskStatus.Running
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask);
|
|
117
|
+
return doc;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更した上で、Runningイベントを発生させる
|
|
121
|
+
* 2026-08-06~
|
|
122
|
+
*/
|
|
123
|
+
async runDelayedTaskIfExists(params) {
|
|
124
|
+
if (!(params.runsAt.$lt instanceof Date)) {
|
|
125
|
+
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
126
|
+
}
|
|
127
|
+
// インデックスについては、name未指定であれば'executeOneByNameIfExists'を想定
|
|
128
|
+
const filter = {
|
|
129
|
+
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
130
|
+
runsAt: { $lt: params.runsAt.$lt }
|
|
131
|
+
};
|
|
132
|
+
const doc = await this.runDelayedTask({
|
|
133
|
+
filter,
|
|
134
|
+
executor: params.executor
|
|
135
|
+
});
|
|
136
|
+
if (doc === null) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const changedTask = {
|
|
140
|
+
id: doc.id,
|
|
141
|
+
status: factory_1.factory.taskStatus.Running
|
|
142
|
+
};
|
|
143
|
+
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask);
|
|
144
|
+
return doc;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Runningのまま一定期間超過し、かつ、remainingNumberOfTries>0のタスクをReadyに変更する
|
|
148
|
+
*/
|
|
149
|
+
async retryTasks(params) {
|
|
150
|
+
const lastTriedAtShoudBeLessThan = (0, moment_1.default)()
|
|
151
|
+
.add(-params.intervalInMinutes, 'minutes')
|
|
152
|
+
.toDate();
|
|
153
|
+
return this.taskModel.updateMany(
|
|
154
|
+
// name: 'retry'のindexと連動しているので、条件の順序などには注意すること
|
|
155
|
+
// @see schemas/task
|
|
156
|
+
{
|
|
157
|
+
status: { $eq: factory_1.factory.taskStatus.Running },
|
|
158
|
+
remainingNumberOfTries: { $gte: 1 },
|
|
159
|
+
lastTriedAt: {
|
|
160
|
+
$type: 'date',
|
|
161
|
+
$lt: lastTriedAtShoudBeLessThan
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
$set: {
|
|
165
|
+
status: factory_1.factory.taskStatus.Ready // 実行前に変更
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
.exec();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* $lte:0をReadyにする -> Readyにすれば自動的にAbortedになる
|
|
172
|
+
*/
|
|
173
|
+
async retryAbortingTasks(params) {
|
|
174
|
+
const lastTriedAtShoudBeLessThan = (0, moment_1.default)()
|
|
175
|
+
.add(-params.intervalInMinutes, 'minutes')
|
|
176
|
+
.toDate();
|
|
177
|
+
return this.taskModel.updateMany(
|
|
178
|
+
// name: 'retry'のindexと連動しているので、条件の順序などには注意すること
|
|
179
|
+
// @see schemas/task
|
|
180
|
+
{
|
|
181
|
+
status: { $eq: factory_1.factory.taskStatus.Running },
|
|
182
|
+
remainingNumberOfTries: { $lte: 0 },
|
|
183
|
+
lastTriedAt: {
|
|
184
|
+
$type: 'date',
|
|
185
|
+
$lt: lastTriedAtShoudBeLessThan
|
|
186
|
+
}
|
|
187
|
+
}, {
|
|
188
|
+
$set: {
|
|
189
|
+
status: factory_1.factory.taskStatus.Ready // 実行前に変更
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
.exec();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.TaskDelayedRepo = TaskDelayedRepo;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
import type { IExecutableTask } from '../taskSettings';
|
|
4
|
+
/**
|
|
5
|
+
* 実行中タスクリポジトリ
|
|
6
|
+
*/
|
|
7
|
+
export declare class TaskRunningRepo {
|
|
8
|
+
private readonly taskModel;
|
|
9
|
+
constructor(connection: Connection);
|
|
10
|
+
/**
|
|
11
|
+
* Ready -> remainingNumberOfTriesが1減る
|
|
12
|
+
* Running -> findOneするだけ
|
|
13
|
+
*/
|
|
14
|
+
executeOneById(params: {
|
|
15
|
+
id: string;
|
|
16
|
+
status: factory.taskStatus.Ready | factory.taskStatus.Running;
|
|
17
|
+
executor: {
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
expires?: never;
|
|
21
|
+
}): Promise<IExecutableTask<factory.taskName> | null>;
|
|
22
|
+
/**
|
|
23
|
+
* タスクIDから実行結果とステータスを保管する
|
|
24
|
+
* Abortedの場合、dateAbortedもセットする
|
|
25
|
+
*/
|
|
26
|
+
setExecutionResultAndStatus(params: {
|
|
27
|
+
/**
|
|
28
|
+
* タスクID
|
|
29
|
+
*/
|
|
30
|
+
id: string;
|
|
31
|
+
}, update: {
|
|
32
|
+
status: factory.taskStatus.Executed | factory.taskStatus.Running | factory.taskStatus.Aborted;
|
|
33
|
+
executionResult: factory.task.IExecutionResult;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskRunningRepo = void 0;
|
|
4
|
+
const factory_1 = require("../factory");
|
|
5
|
+
const settings_1 = require("../settings");
|
|
6
|
+
const task_1 = require("./mongoose/schemas/task");
|
|
7
|
+
const executableTaskProjection = {
|
|
8
|
+
_id: 0,
|
|
9
|
+
id: { $toString: '$_id' },
|
|
10
|
+
// 必要最低限にprojection(2024-04-23~)
|
|
11
|
+
data: 1,
|
|
12
|
+
name: 1,
|
|
13
|
+
status: 1,
|
|
14
|
+
numberOfTried: 1,
|
|
15
|
+
project: 1,
|
|
16
|
+
remainingNumberOfTries: 1,
|
|
17
|
+
runsAt: 1,
|
|
18
|
+
// expires: 1 // 非同期アクションは移行につきexpires廃止(2026-08-05~)
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 実行中タスクリポジトリ
|
|
22
|
+
*/
|
|
23
|
+
class TaskRunningRepo {
|
|
24
|
+
taskModel;
|
|
25
|
+
constructor(connection) {
|
|
26
|
+
this.taskModel = connection.model(task_1.modelName, (0, task_1.createSchema)());
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Ready -> remainingNumberOfTriesが1減る
|
|
30
|
+
* Running -> findOneするだけ
|
|
31
|
+
*/
|
|
32
|
+
async executeOneById(params) {
|
|
33
|
+
const now = new Date();
|
|
34
|
+
let doc;
|
|
35
|
+
if (params.status === factory_1.factory.taskStatus.Running) {
|
|
36
|
+
doc = await this.taskModel.findOne({
|
|
37
|
+
_id: { $eq: params.id },
|
|
38
|
+
status: { $eq: params.status },
|
|
39
|
+
runsAt: { $lt: now },
|
|
40
|
+
// ...(params.expires instanceof Date) ? { expires: { $gt: now } } : undefined // 非同期アクションは移行につきexpires廃止(2026-08-05~)
|
|
41
|
+
}, executableTaskProjection)
|
|
42
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
43
|
+
.lean()
|
|
44
|
+
.exec();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
doc = await this.taskModel.findOneAndUpdate({
|
|
48
|
+
_id: { $eq: params.id },
|
|
49
|
+
status: { $eq: params.status },
|
|
50
|
+
runsAt: { $lt: now },
|
|
51
|
+
// ...(params.expires instanceof Date) ? { expires: { $gt: now } } : undefined // 非同期アクションは移行につきexpires廃止(2026-08-05~)
|
|
52
|
+
}, {
|
|
53
|
+
$set: {
|
|
54
|
+
status: factory_1.factory.taskStatus.Running, // 実行中に変更
|
|
55
|
+
lastTriedAt: now,
|
|
56
|
+
executor: params.executor
|
|
57
|
+
},
|
|
58
|
+
$inc: {
|
|
59
|
+
remainingNumberOfTries: -1, // 残りトライ可能回数減らす
|
|
60
|
+
numberOfTried: 1 // トライ回数増やす
|
|
61
|
+
}
|
|
62
|
+
}, { new: true, projection: executableTaskProjection })
|
|
63
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
64
|
+
.lean() // lean(2024-09-26~)
|
|
65
|
+
.exec();
|
|
66
|
+
}
|
|
67
|
+
if (doc === null) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return doc;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* タスクIDから実行結果とステータスを保管する
|
|
74
|
+
* Abortedの場合、dateAbortedもセットする
|
|
75
|
+
*/
|
|
76
|
+
async setExecutionResultAndStatus(params, update) {
|
|
77
|
+
const { id } = params;
|
|
78
|
+
const { status, executionResult } = update;
|
|
79
|
+
await this.taskModel.updateOne({ _id: { $eq: id } }, {
|
|
80
|
+
$set: {
|
|
81
|
+
status,
|
|
82
|
+
...(status === factory_1.factory.taskStatus.Aborted) ? { dateAborted: executionResult.endDate } : undefined // 2025-08-04~
|
|
83
|
+
},
|
|
84
|
+
$push: { executionResults: executionResult }
|
|
85
|
+
})
|
|
86
|
+
.exec();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.TaskRunningRepo = TaskRunningRepo;
|
|
@@ -24,6 +24,7 @@ import type { AggregateActionRepo } from './repo/aggregateAction';
|
|
|
24
24
|
import type { AggregateOfferRepo } from './repo/aggregateOffer';
|
|
25
25
|
import type { AggregateOrderRepo } from './repo/aggregateOrder';
|
|
26
26
|
import type { AggregateReservationRepo } from './repo/aggregateReservation';
|
|
27
|
+
import type { AggregateScheduledTaskRepo } from './repo/aggregateScheduledTask';
|
|
27
28
|
import type { AggregateTaskRepo } from './repo/aggregateTask';
|
|
28
29
|
import type { AggregationRepo } from './repo/aggregation';
|
|
29
30
|
import type { AssetTransactionRepo } from './repo/assetTransaction';
|
|
@@ -92,6 +93,7 @@ import type { WaiterSettingRepo } from './repo/setting/waiter';
|
|
|
92
93
|
import type { StockHolderRepo } from './repo/stockHolder';
|
|
93
94
|
import type { ScheduledTaskRepo } from './repo/scheduledTask';
|
|
94
95
|
import type { TaskRepo } from './repo/task';
|
|
96
|
+
import type { TaskDelayedRepo } from './repo/taskDelayed';
|
|
95
97
|
import type { TicketRepo } from './repo/ticket';
|
|
96
98
|
import type { TransactionRepo } from './repo/transaction';
|
|
97
99
|
import type { PlaceOrderRepo } from './repo/transaction/placeOrder';
|
|
@@ -180,6 +182,10 @@ export type AggregateAction = AggregateActionRepo;
|
|
|
180
182
|
export declare namespace AggregateAction {
|
|
181
183
|
function createInstance(...params: ConstructorParameters<typeof AggregateActionRepo>): Promise<AggregateActionRepo>;
|
|
182
184
|
}
|
|
185
|
+
export type AggregateScheduledTask = AggregateScheduledTaskRepo;
|
|
186
|
+
export declare namespace AggregateScheduledTask {
|
|
187
|
+
function createInstance(...params: ConstructorParameters<typeof AggregateScheduledTaskRepo>): Promise<AggregateScheduledTaskRepo>;
|
|
188
|
+
}
|
|
183
189
|
export type AggregateTask = AggregateTaskRepo;
|
|
184
190
|
export declare namespace AggregateTask {
|
|
185
191
|
function createInstance(...params: ConstructorParameters<typeof AggregateTaskRepo>): Promise<AggregateTaskRepo>;
|
|
@@ -496,6 +502,10 @@ export type Task = TaskRepo;
|
|
|
496
502
|
export declare namespace Task {
|
|
497
503
|
function createInstance(...params: ConstructorParameters<typeof TaskRepo>): Promise<TaskRepo>;
|
|
498
504
|
}
|
|
505
|
+
export type TaskDelayed = TaskDelayedRepo;
|
|
506
|
+
export declare namespace TaskDelayed {
|
|
507
|
+
function createInstance(...params: ConstructorParameters<typeof TaskDelayedRepo>): Promise<TaskDelayedRepo>;
|
|
508
|
+
}
|
|
499
509
|
export type AsyncAction = AsyncActionRepo;
|
|
500
510
|
export declare namespace AsyncAction {
|
|
501
511
|
function createInstance(...params: ConstructorParameters<typeof AsyncActionRepo>): Promise<AsyncActionRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = void 0;
|
|
3
|
+
exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateTask = exports.AggregateScheduledTask = exports.AggregateAction = exports.AdminTask = exports.AdminScheduledTask = exports.AdminAsyncAction = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
|
|
4
|
+
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.TaskDelayed = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = void 0;
|
|
5
5
|
var AcceptedOffer;
|
|
6
6
|
(function (AcceptedOffer) {
|
|
7
7
|
let repo;
|
|
@@ -214,6 +214,17 @@ var AggregateAction;
|
|
|
214
214
|
}
|
|
215
215
|
AggregateAction.createInstance = createInstance;
|
|
216
216
|
})(AggregateAction || (exports.AggregateAction = AggregateAction = {}));
|
|
217
|
+
var AggregateScheduledTask;
|
|
218
|
+
(function (AggregateScheduledTask) {
|
|
219
|
+
let repo;
|
|
220
|
+
async function createInstance(...params) {
|
|
221
|
+
if (repo === undefined) {
|
|
222
|
+
repo = (await import('./repo/aggregateScheduledTask.js')).AggregateScheduledTaskRepo;
|
|
223
|
+
}
|
|
224
|
+
return new repo(...params);
|
|
225
|
+
}
|
|
226
|
+
AggregateScheduledTask.createInstance = createInstance;
|
|
227
|
+
})(AggregateScheduledTask || (exports.AggregateScheduledTask = AggregateScheduledTask = {}));
|
|
217
228
|
var AggregateTask;
|
|
218
229
|
(function (AggregateTask) {
|
|
219
230
|
let repo;
|
|
@@ -1044,6 +1055,17 @@ var Task;
|
|
|
1044
1055
|
}
|
|
1045
1056
|
Task.createInstance = createInstance;
|
|
1046
1057
|
})(Task || (exports.Task = Task = {}));
|
|
1058
|
+
var TaskDelayed;
|
|
1059
|
+
(function (TaskDelayed) {
|
|
1060
|
+
let repo;
|
|
1061
|
+
async function createInstance(...params) {
|
|
1062
|
+
if (repo === undefined) {
|
|
1063
|
+
repo = (await import('./repo/taskDelayed.js')).TaskDelayedRepo;
|
|
1064
|
+
}
|
|
1065
|
+
return new repo(...params);
|
|
1066
|
+
}
|
|
1067
|
+
TaskDelayed.createInstance = createInstance;
|
|
1068
|
+
})(TaskDelayed || (exports.TaskDelayed = TaskDelayed = {}));
|
|
1047
1069
|
var AsyncAction;
|
|
1048
1070
|
(function (AsyncAction) {
|
|
1049
1071
|
let repo;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AggregateActionRepo } from '../../repo/aggregateAction';
|
|
2
|
+
import type { AggregateScheduledTaskRepo } from '../../repo/aggregateScheduledTask';
|
|
2
3
|
import type { AggregateTaskRepo } from '../../repo/aggregateTask';
|
|
3
4
|
import { AggregationRepo } from '../../repo/aggregation';
|
|
4
5
|
import type { AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
@@ -10,7 +11,7 @@ interface IAggregateParams {
|
|
|
10
11
|
aggregateDate: Date;
|
|
11
12
|
aggregateDurationUnit: AggregateDurationUnit;
|
|
12
13
|
aggregationCount: number;
|
|
13
|
-
excludedProjectId?:
|
|
14
|
+
excludedProjectId?: never;
|
|
14
15
|
}
|
|
15
16
|
declare function aggregateEvent(params: IAggregateParams): (repos: {
|
|
16
17
|
agregation: AggregationRepo;
|
|
@@ -146,4 +147,11 @@ declare function aggregateTask(params: IAggregateParams): (repos: {
|
|
|
146
147
|
aggregationCount: number;
|
|
147
148
|
aggregateDuration: string;
|
|
148
149
|
}>;
|
|
149
|
-
|
|
150
|
+
declare function aggregateScheduledTask(params: IAggregateParams): (repos: {
|
|
151
|
+
agregation: AggregationRepo;
|
|
152
|
+
aggregateScheduledTask: AggregateScheduledTaskRepo;
|
|
153
|
+
}) => Promise<{
|
|
154
|
+
aggregationCount: number;
|
|
155
|
+
aggregateDuration: string;
|
|
156
|
+
}>;
|
|
157
|
+
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregateCancelReservationAction, aggregateCheckMovieTicketAction, aggregateEvent, aggregateOrder, aggregateOrderAction, aggregatePayMovieTicketAction, aggregatePayTransaction, aggregatePlaceOrder, aggregateReserveAction, aggregateReserveTransaction, aggregateTask, aggregateScheduledTask, aggregateUseAction };
|
|
@@ -17,6 +17,7 @@ exports.aggregatePlaceOrder = aggregatePlaceOrder;
|
|
|
17
17
|
exports.aggregateReserveAction = aggregateReserveAction;
|
|
18
18
|
exports.aggregateReserveTransaction = aggregateReserveTransaction;
|
|
19
19
|
exports.aggregateTask = aggregateTask;
|
|
20
|
+
exports.aggregateScheduledTask = aggregateScheduledTask;
|
|
20
21
|
exports.aggregateUseAction = aggregateUseAction;
|
|
21
22
|
const debug_1 = __importDefault(require("debug"));
|
|
22
23
|
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
@@ -692,3 +693,44 @@ function aggregateTask(params) {
|
|
|
692
693
|
return { aggregationCount: i, aggregateDuration };
|
|
693
694
|
};
|
|
694
695
|
}
|
|
696
|
+
function aggregateScheduledTask(params) {
|
|
697
|
+
return async (repos) => {
|
|
698
|
+
const { aggregateDate } = params;
|
|
699
|
+
if (!(aggregateDate instanceof Date)) {
|
|
700
|
+
throw new factory_1.factory.errors.Argument('aggregateDate', 'must be Date');
|
|
701
|
+
}
|
|
702
|
+
const aggregateDuration = moment_timezone_1.default.duration(1, params.aggregateDurationUnit)
|
|
703
|
+
.toISOString();
|
|
704
|
+
let i = -1;
|
|
705
|
+
while (i < params.aggregationCount) {
|
|
706
|
+
i += 1;
|
|
707
|
+
const runsFrom = (0, moment_timezone_1.default)(aggregateDate)
|
|
708
|
+
.utc()
|
|
709
|
+
// .tz('Asia/Tokyo')
|
|
710
|
+
.add(-i, params.aggregateDurationUnit)
|
|
711
|
+
.startOf(params.aggregateDurationUnit)
|
|
712
|
+
.toDate();
|
|
713
|
+
const runsThrough = (0, moment_timezone_1.default)(aggregateDate)
|
|
714
|
+
.utc()
|
|
715
|
+
// .tz('Asia/Tokyo')
|
|
716
|
+
.add(-i, params.aggregateDurationUnit)
|
|
717
|
+
.endOf(params.aggregateDurationUnit)
|
|
718
|
+
.toDate();
|
|
719
|
+
const aggregateResult = await repos.aggregateScheduledTask.aggregateScheduledTask({
|
|
720
|
+
// project: { id: { $ne: params.excludedProjectId } },
|
|
721
|
+
runsFrom,
|
|
722
|
+
runsThrough
|
|
723
|
+
});
|
|
724
|
+
await repos.agregation.saveAggregation({
|
|
725
|
+
typeOf: factory_1.factory.aggregation.AggregationType.AggregateScheduledTask,
|
|
726
|
+
project: { id: '*', typeOf: factory_1.factory.organizationType.Project },
|
|
727
|
+
aggregateDuration,
|
|
728
|
+
aggregateStart: runsFrom,
|
|
729
|
+
aggregateDate,
|
|
730
|
+
...aggregateResult
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
debug(i, 'aggregations saved');
|
|
734
|
+
return { aggregationCount: i, aggregateDuration };
|
|
735
|
+
};
|
|
736
|
+
}
|
|
@@ -9,7 +9,7 @@ function createStartParams(params) {
|
|
|
9
9
|
typeOf: factory_1.factory.organizationType.Corporation
|
|
10
10
|
};
|
|
11
11
|
// reservationFor,issuedThrough保管をaddReservationsから移行(2024-07-01~)
|
|
12
|
-
const reservationFor = createReservationFor(params.event
|
|
12
|
+
const reservationFor = createReservationFor(params.event);
|
|
13
13
|
const { issuedThrough } = createIssuedThrough({ reservationFor: params.event });
|
|
14
14
|
const reservationPackage = {
|
|
15
15
|
issuedThrough, // addReservationsから移行(2024-07-01~)
|
|
@@ -33,7 +33,7 @@ function createStartParams(params) {
|
|
|
33
33
|
instrument
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function createReservationFor(params
|
|
36
|
+
function createReservationFor(params) {
|
|
37
37
|
if (params.typeOf === factory_1.factory.eventType.ScreeningEvent) {
|
|
38
38
|
return {
|
|
39
39
|
endDate: params.endDate,
|
|
@@ -41,7 +41,7 @@ function createReservationFor(params, useOptimizeReservation) {
|
|
|
41
41
|
location: params.location,
|
|
42
42
|
name: params.name,
|
|
43
43
|
startDate: params.startDate,
|
|
44
|
-
superEvent: optimizeReservationSuperEvent(params
|
|
44
|
+
superEvent: optimizeReservationSuperEvent(params),
|
|
45
45
|
typeOf: params.typeOf,
|
|
46
46
|
...(params.doorTime instanceof Date)
|
|
47
47
|
? { doorTime: params.doorTime }
|
|
@@ -52,38 +52,18 @@ function createReservationFor(params, useOptimizeReservation) {
|
|
|
52
52
|
throw new factory_1.factory.errors.NotImplemented(`typeOf: ${params.typeOf}`);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function optimizeReservationSuperEvent(params
|
|
55
|
+
function optimizeReservationSuperEvent(params) {
|
|
56
56
|
const superEvent = params.superEvent;
|
|
57
57
|
return {
|
|
58
58
|
id: superEvent.id,
|
|
59
|
-
// kanaName: superEvent.kanaName, // 廃止(2024-01-26~)
|
|
60
59
|
location: superEvent.location,
|
|
61
60
|
name: superEvent.name,
|
|
62
|
-
soundFormat: superEvent.soundFormat,
|
|
61
|
+
// soundFormat: superEvent.soundFormat, // discontinue(2026-08-01~)
|
|
63
62
|
typeOf: superEvent.typeOf,
|
|
64
63
|
workPerformed: superEvent.workPerformed,
|
|
65
|
-
// 廃止(2024-01-26~)
|
|
66
|
-
// ...(superEvent.description !== undefined)
|
|
67
|
-
// ? { description: superEvent.description }
|
|
68
|
-
// : undefined,
|
|
69
64
|
...(superEvent.headline !== undefined)
|
|
70
65
|
? { headline: superEvent.headline }
|
|
71
66
|
: undefined,
|
|
72
|
-
// 最適化対応(2024-03-16~)
|
|
73
|
-
...(useOptimizeReservation)
|
|
74
|
-
? {}
|
|
75
|
-
: {
|
|
76
|
-
additionalProperty: (Array.isArray(superEvent.additionalProperty))
|
|
77
|
-
? superEvent.additionalProperty
|
|
78
|
-
: []
|
|
79
|
-
}
|
|
80
|
-
// videoFormatをデータとしても廃止(万が一に備えてUSE_DEPRECATED_VIDEO_FORMATで再設定可能)(2026-02-03~)
|
|
81
|
-
// ...(USE_DEPRECATED_VIDEO_FORMAT)
|
|
82
|
-
// ? {
|
|
83
|
-
// // 現時点で型廃止済だがデータとしては互換性維持(2026-01-15~)
|
|
84
|
-
// videoFormat: (<any>superEvent).videoFormat
|
|
85
|
-
// }
|
|
86
|
-
// : undefined
|
|
87
67
|
};
|
|
88
68
|
}
|
|
89
69
|
function createIssuedThrough(params) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IExecuteSettings as IMinimumExecuteSettings,
|
|
1
|
+
import type { IExecuteSettings as IMinimumExecuteSettings, IAsyncActionNextFunction } from '../eventEmitter/task';
|
|
2
2
|
type IExecuteSettings = IMinimumExecuteSettings;
|
|
3
3
|
type IOperation<T> = (settings: IExecuteSettings) => Promise<T>;
|
|
4
4
|
declare function executeAsyncActionById(params: {
|
|
@@ -12,5 +12,5 @@ declare function executeAsyncActionById(params: {
|
|
|
12
12
|
*/
|
|
13
13
|
name: string;
|
|
14
14
|
};
|
|
15
|
-
}, next
|
|
15
|
+
}, next: IAsyncActionNextFunction): IOperation<void>;
|
|
16
16
|
export { executeAsyncActionById };
|
|
@@ -27,10 +27,7 @@ function executeAsyncActionById(params, next) {
|
|
|
27
27
|
}
|
|
28
28
|
// タスクがなければ終了
|
|
29
29
|
if (task !== null) {
|
|
30
|
-
await (0, asyncActionHandler_1.executeAsyncAction)(task,
|
|
31
|
-
executeById: true,
|
|
32
|
-
executeByName: false
|
|
33
|
-
});
|
|
30
|
+
await (0, asyncActionHandler_1.executeAsyncAction)(task, next)(settings, {});
|
|
34
31
|
}
|
|
35
32
|
};
|
|
36
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ITaskAsNextFunctionParam } from '../../eventEmitter/task';
|
|
2
2
|
import type { AsyncActionRepo, IExecutableAsyncAction } from '../../repo/asyncAction';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行失敗時処理
|
|
@@ -10,6 +10,6 @@ declare function onOperationFailed(params: {
|
|
|
10
10
|
}): (repos: {
|
|
11
11
|
asyncAction: AsyncActionRepo;
|
|
12
12
|
}) => Promise<{
|
|
13
|
-
executedTask:
|
|
13
|
+
executedTask: ITaskAsNextFunctionParam;
|
|
14
14
|
}>;
|
|
15
15
|
export { onOperationFailed };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { IAsyncActionNextFunction } from '../eventEmitter/task';
|
|
2
|
+
import type { ICallableTaskOperation, IOperationExecute } from '../taskSettings';
|
|
3
3
|
import type { IExecutableAsyncAction } from '../repo/asyncAction';
|
|
4
4
|
export declare const taskLoader: {
|
|
5
5
|
load: (taskName: string) => Promise<{
|
|
@@ -9,5 +9,5 @@ export declare const taskLoader: {
|
|
|
9
9
|
/**
|
|
10
10
|
* 非同期アクションを実行する
|
|
11
11
|
*/
|
|
12
|
-
declare function executeAsyncAction(task: IExecutableAsyncAction, next
|
|
13
|
-
export {
|
|
12
|
+
declare function executeAsyncAction(task: IExecutableAsyncAction, next: IAsyncActionNextFunction): IOperationExecute<void>;
|
|
13
|
+
export { executeAsyncAction };
|