@chevre/domain 26.0.0-alpha.12 → 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 +15 -3
- package/lib/chevre/repo/adminTask.js +26 -1
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +1 -2
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +1 -4
- package/lib/chevre/repo/mongoose/schemas/task.js +5 -1
- package/lib/chevre/repo/task.d.ts +4 -74
- package/lib/chevre/repo/task.js +11 -189
- 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 +4 -4
- package/lib/chevre/service/task.js +7 -7
- 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/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +11 -17
- package/lib/chevre/service/transaction/returnOrder.js +11 -17
- 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
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskDelayedRepo = void 0;
|
|
4
|
+
const task_1 = require("../eventEmitter/task");
|
|
5
|
+
const factory_1 = require("../factory");
|
|
6
|
+
const settings_1 = require("../settings");
|
|
7
|
+
const task_2 = require("./mongoose/schemas/task");
|
|
8
|
+
/**
|
|
9
|
+
* 遅延タスクリポジトリ
|
|
10
|
+
*/
|
|
11
|
+
class TaskDelayedRepo {
|
|
12
|
+
taskModel;
|
|
13
|
+
constructor(connection) {
|
|
14
|
+
this.taskModel = connection.model(task_2.modelName, (0, task_2.createSchema)());
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 潜在的に実行されるべきタスクをカウントする
|
|
18
|
+
* add(2025-03-16~)
|
|
19
|
+
*/
|
|
20
|
+
async countPotentiallyRunning(params) {
|
|
21
|
+
const { runsAt, limit, name } = params;
|
|
22
|
+
const nameEq = name?.$eq;
|
|
23
|
+
const nameIn = name?.$in;
|
|
24
|
+
if (!(runsAt.$lt instanceof Date)) {
|
|
25
|
+
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
26
|
+
}
|
|
27
|
+
const query = this.taskModel.countDocuments({
|
|
28
|
+
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
29
|
+
...(typeof nameEq === 'string' || Array.isArray(nameIn))
|
|
30
|
+
? {
|
|
31
|
+
name: {
|
|
32
|
+
...(typeof nameEq === 'string') ? { $eq: nameEq } : undefined,
|
|
33
|
+
...(Array.isArray(nameIn)) ? { $in: nameIn } : undefined
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
: undefined,
|
|
37
|
+
runsAt: { $lt: params.runsAt.$lt }
|
|
38
|
+
});
|
|
39
|
+
if (typeof limit === 'number' && limit >= 0) {
|
|
40
|
+
query.limit(limit);
|
|
41
|
+
}
|
|
42
|
+
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
43
|
+
.exec();
|
|
44
|
+
return { count };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更する
|
|
48
|
+
*/
|
|
49
|
+
async runDelayedTask(params) {
|
|
50
|
+
const { filter } = params;
|
|
51
|
+
const projection = {
|
|
52
|
+
_id: 0,
|
|
53
|
+
id: { $toString: '$_id' },
|
|
54
|
+
name: 1
|
|
55
|
+
};
|
|
56
|
+
return this.taskModel.findOneAndUpdate(filter, {
|
|
57
|
+
$set: {
|
|
58
|
+
status: factory_1.factory.taskStatus.Running, // 実行中に変更
|
|
59
|
+
lastTriedAt: new Date(),
|
|
60
|
+
executor: params.executor
|
|
61
|
+
},
|
|
62
|
+
$inc: {
|
|
63
|
+
remainingNumberOfTries: -1, // 残りトライ可能回数減らす
|
|
64
|
+
numberOfTried: 1 // トライ回数増やす
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
new: true,
|
|
68
|
+
projection,
|
|
69
|
+
...(typeof params.sort.numberOfTried === 'number' || typeof params.sort.runsAt === 'number')
|
|
70
|
+
? { sort: params.sort }
|
|
71
|
+
: undefined
|
|
72
|
+
})
|
|
73
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
74
|
+
.lean()
|
|
75
|
+
.exec();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更した上で、Runningイベントを発生させる
|
|
79
|
+
*/
|
|
80
|
+
async emitRunningIfExistsByName(params) {
|
|
81
|
+
if (!(params.runsAt.$lt instanceof Date)) {
|
|
82
|
+
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
83
|
+
}
|
|
84
|
+
// インデックス'executeOneByNameIfExists'を想定したfilter
|
|
85
|
+
const filter = {
|
|
86
|
+
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
87
|
+
name: params.name,
|
|
88
|
+
runsAt: { $lt: params.runsAt.$lt }
|
|
89
|
+
};
|
|
90
|
+
const doc = await this.runDelayedTask({
|
|
91
|
+
filter,
|
|
92
|
+
sort: params.sort,
|
|
93
|
+
executor: params.executor
|
|
94
|
+
});
|
|
95
|
+
if (doc === null) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const nameEq = params.name?.$eq;
|
|
99
|
+
let changedTask;
|
|
100
|
+
if (typeof nameEq === 'string') {
|
|
101
|
+
changedTask = {
|
|
102
|
+
id: doc.id,
|
|
103
|
+
status: factory_1.factory.taskStatus.Running,
|
|
104
|
+
name: nameEq
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
changedTask = {
|
|
109
|
+
id: doc.id,
|
|
110
|
+
status: factory_1.factory.taskStatus.Running
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask);
|
|
114
|
+
return doc;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更した上で、Runningイベントを発生させる
|
|
118
|
+
* taskNameで絞らない
|
|
119
|
+
* 2026-08-04~
|
|
120
|
+
*/
|
|
121
|
+
async emitRunningIfExistsNoName(params) {
|
|
122
|
+
if (!(params.runsAt.$lt instanceof Date)) {
|
|
123
|
+
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
124
|
+
}
|
|
125
|
+
// インデックス'executeOneByNameIfExists'を想定したfilter
|
|
126
|
+
const filter = {
|
|
127
|
+
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
128
|
+
runsAt: { $lt: params.runsAt.$lt }
|
|
129
|
+
};
|
|
130
|
+
const doc = await this.runDelayedTask({
|
|
131
|
+
filter,
|
|
132
|
+
sort: {
|
|
133
|
+
runsAt: factory_1.factory.sortType.Ascending // ソートはrunsAtのみにしてみる(2026-08-04~)
|
|
134
|
+
},
|
|
135
|
+
executor: params.executor
|
|
136
|
+
});
|
|
137
|
+
if (doc === null) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const changedTask = {
|
|
141
|
+
id: doc.id,
|
|
142
|
+
status: factory_1.factory.taskStatus.Running
|
|
143
|
+
};
|
|
144
|
+
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask);
|
|
145
|
+
return doc;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.TaskDelayedRepo = TaskDelayedRepo;
|
|
@@ -16,7 +16,6 @@ import type { CheckThingActionRepo } from './repo/action/checkThing';
|
|
|
16
16
|
import type { PayActionRepo } from './repo/action/pay';
|
|
17
17
|
import type { RefundActionRepo } from './repo/action/refund';
|
|
18
18
|
import type { AsyncActionRepo } from './repo/asyncAction';
|
|
19
|
-
import type { AsyncActionLegacyRepo } from './repo/asyncActionLegacy';
|
|
20
19
|
import type { AdditionalPropertyRepo } from './repo/additionalProperty';
|
|
21
20
|
import type { AdminAsyncActionRepo } from './repo/adminAsyncAction';
|
|
22
21
|
import type { AdminScheduledTaskRepo } from './repo/adminScheduledTask';
|
|
@@ -93,8 +92,8 @@ import type { RateLimitSettingRepo } from './repo/setting/rateLimit';
|
|
|
93
92
|
import type { WaiterSettingRepo } from './repo/setting/waiter';
|
|
94
93
|
import type { StockHolderRepo } from './repo/stockHolder';
|
|
95
94
|
import type { ScheduledTaskRepo } from './repo/scheduledTask';
|
|
96
|
-
import type { ScheduledTaskLegacyRepo } from './repo/scheduledTaskLegacy';
|
|
97
95
|
import type { TaskRepo } from './repo/task';
|
|
96
|
+
import type { TaskDelayedRepo } from './repo/taskDelayed';
|
|
98
97
|
import type { TicketRepo } from './repo/ticket';
|
|
99
98
|
import type { TransactionRepo } from './repo/transaction';
|
|
100
99
|
import type { PlaceOrderRepo } from './repo/transaction/placeOrder';
|
|
@@ -499,22 +498,18 @@ export type ScheduledTask = ScheduledTaskRepo;
|
|
|
499
498
|
export declare namespace ScheduledTask {
|
|
500
499
|
function createInstance(...params: ConstructorParameters<typeof ScheduledTaskRepo>): Promise<ScheduledTaskRepo>;
|
|
501
500
|
}
|
|
502
|
-
export type ScheduledTaskLegacy = ScheduledTaskLegacyRepo;
|
|
503
|
-
export declare namespace ScheduledTaskLegacy {
|
|
504
|
-
function createInstance(...params: ConstructorParameters<typeof ScheduledTaskLegacyRepo>): Promise<ScheduledTaskLegacyRepo>;
|
|
505
|
-
}
|
|
506
501
|
export type Task = TaskRepo;
|
|
507
502
|
export declare namespace Task {
|
|
508
503
|
function createInstance(...params: ConstructorParameters<typeof TaskRepo>): Promise<TaskRepo>;
|
|
509
504
|
}
|
|
505
|
+
export type TaskDelayed = TaskDelayedRepo;
|
|
506
|
+
export declare namespace TaskDelayed {
|
|
507
|
+
function createInstance(...params: ConstructorParameters<typeof TaskDelayedRepo>): Promise<TaskDelayedRepo>;
|
|
508
|
+
}
|
|
510
509
|
export type AsyncAction = AsyncActionRepo;
|
|
511
510
|
export declare namespace AsyncAction {
|
|
512
511
|
function createInstance(...params: ConstructorParameters<typeof AsyncActionRepo>): Promise<AsyncActionRepo>;
|
|
513
512
|
}
|
|
514
|
-
export type AsyncActionLegacy = AsyncActionLegacyRepo;
|
|
515
|
-
export declare namespace AsyncActionLegacy {
|
|
516
|
-
function createInstance(...params: ConstructorParameters<typeof AsyncActionLegacyRepo>): Promise<AsyncActionLegacyRepo>;
|
|
517
|
-
}
|
|
518
513
|
export type Ticket = TicketRepo;
|
|
519
514
|
export declare namespace Ticket {
|
|
520
515
|
function createInstance(...params: ConstructorParameters<typeof TicketRepo>): Promise<TicketRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
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.
|
|
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;
|
|
@@ -1044,17 +1044,6 @@ var ScheduledTask;
|
|
|
1044
1044
|
}
|
|
1045
1045
|
ScheduledTask.createInstance = createInstance;
|
|
1046
1046
|
})(ScheduledTask || (exports.ScheduledTask = ScheduledTask = {}));
|
|
1047
|
-
var ScheduledTaskLegacy;
|
|
1048
|
-
(function (ScheduledTaskLegacy) {
|
|
1049
|
-
let repo;
|
|
1050
|
-
async function createInstance(...params) {
|
|
1051
|
-
if (repo === undefined) {
|
|
1052
|
-
repo = (await import('./repo/scheduledTaskLegacy.js')).ScheduledTaskLegacyRepo;
|
|
1053
|
-
}
|
|
1054
|
-
return new repo(...params);
|
|
1055
|
-
}
|
|
1056
|
-
ScheduledTaskLegacy.createInstance = createInstance;
|
|
1057
|
-
})(ScheduledTaskLegacy || (exports.ScheduledTaskLegacy = ScheduledTaskLegacy = {}));
|
|
1058
1047
|
var Task;
|
|
1059
1048
|
(function (Task) {
|
|
1060
1049
|
let repo;
|
|
@@ -1066,28 +1055,28 @@ var Task;
|
|
|
1066
1055
|
}
|
|
1067
1056
|
Task.createInstance = createInstance;
|
|
1068
1057
|
})(Task || (exports.Task = Task = {}));
|
|
1069
|
-
var
|
|
1070
|
-
(function (
|
|
1058
|
+
var TaskDelayed;
|
|
1059
|
+
(function (TaskDelayed) {
|
|
1071
1060
|
let repo;
|
|
1072
1061
|
async function createInstance(...params) {
|
|
1073
1062
|
if (repo === undefined) {
|
|
1074
|
-
repo = (await import('./repo/
|
|
1063
|
+
repo = (await import('./repo/taskDelayed.js')).TaskDelayedRepo;
|
|
1075
1064
|
}
|
|
1076
1065
|
return new repo(...params);
|
|
1077
1066
|
}
|
|
1078
|
-
|
|
1079
|
-
})(
|
|
1080
|
-
var
|
|
1081
|
-
(function (
|
|
1067
|
+
TaskDelayed.createInstance = createInstance;
|
|
1068
|
+
})(TaskDelayed || (exports.TaskDelayed = TaskDelayed = {}));
|
|
1069
|
+
var AsyncAction;
|
|
1070
|
+
(function (AsyncAction) {
|
|
1082
1071
|
let repo;
|
|
1083
1072
|
async function createInstance(...params) {
|
|
1084
1073
|
if (repo === undefined) {
|
|
1085
|
-
repo = (await import('./repo/
|
|
1074
|
+
repo = (await import('./repo/asyncAction.js')).AsyncActionRepo;
|
|
1086
1075
|
}
|
|
1087
1076
|
return new repo(...params);
|
|
1088
1077
|
}
|
|
1089
|
-
|
|
1090
|
-
})(
|
|
1078
|
+
AsyncAction.createInstance = createInstance;
|
|
1079
|
+
})(AsyncAction || (exports.AsyncAction = AsyncAction = {}));
|
|
1091
1080
|
var Ticket;
|
|
1092
1081
|
(function (Ticket) {
|
|
1093
1082
|
let repo;
|
|
@@ -29,7 +29,7 @@ function executeAsyncActionById(params, next) {
|
|
|
29
29
|
if (task !== null) {
|
|
30
30
|
await (0, asyncActionHandler_1.executeAsyncAction)(task, (typeof next === 'function') ? next : undefined)(settings, {
|
|
31
31
|
executeById: true,
|
|
32
|
-
executeByName: false
|
|
32
|
+
// executeByName: false // discontinue(2026-08-05~)
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
};
|
|
@@ -33,7 +33,7 @@ function executeScheduledTaskById(params) {
|
|
|
33
33
|
if (task !== null) {
|
|
34
34
|
await (0, scheduledTaskHandler_1.executeScheduledTask)(task)(settings, {
|
|
35
35
|
executeById: true,
|
|
36
|
-
executeByName: false
|
|
36
|
+
// executeByName: false // discontinue(2026-08-05~)
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
};
|
|
@@ -7,9 +7,6 @@ const acceptCOAOffer_1 = require("../../repo/action/acceptCOAOffer");
|
|
|
7
7
|
const authorizeOffer_1 = require("../../repo/action/authorizeOffer");
|
|
8
8
|
const credentials_1 = require("../../repo/credentials");
|
|
9
9
|
const event_1 = require("../../repo/event");
|
|
10
|
-
// import { OrderInTransactionRepo } from '../../repo/orderInTransaction';
|
|
11
|
-
// import { OrderNumberRepo } from '../../repo/orderNumber';
|
|
12
|
-
// import { ProjectRepo } from '../../repo/project';
|
|
13
10
|
const reserveInterface_1 = require("../../repo/reserveInterface");
|
|
14
11
|
const integration_1 = require("../../repo/setting/integration");
|
|
15
12
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
@@ -19,14 +16,10 @@ let coaAuthClient;
|
|
|
19
16
|
* タスク実行関数
|
|
20
17
|
*/
|
|
21
18
|
function call(params) {
|
|
22
|
-
return async ({ connection, redisClient }
|
|
19
|
+
return async ({ connection, redisClient }) => {
|
|
23
20
|
if (redisClient === undefined) {
|
|
24
21
|
throw new factory_1.factory.errors.Argument('settings', 'redisClient required');
|
|
25
22
|
}
|
|
26
|
-
// 遅延実行(executeByName)には対応しない
|
|
27
|
-
if (!options.executeById) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
23
|
const settings = new integration_1.IntegrationSettingRepo({ connection });
|
|
31
24
|
const reserveInterfaceRepo = new reserveInterface_1.ReserveInterfaceRepo(connection);
|
|
32
25
|
const coaAPI = await reserveInterfaceRepo.findOne({ project: { id: { $eq: params.project.id } } });
|
|
@@ -57,7 +50,6 @@ function call(params) {
|
|
|
57
50
|
});
|
|
58
51
|
}
|
|
59
52
|
const actionRepo = new acceptCOAOffer_1.AcceptCOAOfferActionRepo(connection);
|
|
60
|
-
// const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
|
|
61
53
|
try {
|
|
62
54
|
const coaIntegrationSettings = await settings.getByKey('coa');
|
|
63
55
|
const reserveService = new coa_service_1.COA.service.Reserve({
|
|
@@ -86,8 +78,6 @@ function call(params) {
|
|
|
86
78
|
action: actionRepo,
|
|
87
79
|
authorizeOfferAction: new authorizeOffer_1.AuthorizeOfferActionRepo(connection),
|
|
88
80
|
event: new event_1.EventRepo(connection),
|
|
89
|
-
// orderNumber: new OrderNumberRepo({ connection }),
|
|
90
|
-
// project: new ProjectRepo(connection),
|
|
91
81
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
|
|
92
82
|
reserveService,
|
|
93
83
|
masterService
|
|
@@ -104,9 +94,6 @@ function call(params) {
|
|
|
104
94
|
})({
|
|
105
95
|
action: actionRepo,
|
|
106
96
|
event: new event_1.EventRepo(connection),
|
|
107
|
-
// orderInTransaction: new OrderInTransactionRepo(connection),
|
|
108
|
-
// orderNumber: new OrderNumberRepo({ connection }),
|
|
109
|
-
// project: new ProjectRepo(connection),
|
|
110
97
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
|
|
111
98
|
reserveService,
|
|
112
99
|
masterService
|
|
@@ -34,19 +34,13 @@ const any_1 = require("../payment/any");
|
|
|
34
34
|
* タスク実行関数
|
|
35
35
|
*/
|
|
36
36
|
function call(params) {
|
|
37
|
-
return async ({ connection, redisClient }
|
|
37
|
+
return async ({ connection, redisClient }) => {
|
|
38
38
|
if (redisClient === undefined) {
|
|
39
39
|
throw new factory_1.factory.errors.Argument('settings', 'redisClient required');
|
|
40
40
|
}
|
|
41
|
-
// 遅延実行(executeByName)には対応しない
|
|
42
|
-
if (!options.executeById) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
41
|
let callResult;
|
|
46
42
|
const settings = new integration_1.IntegrationSettingRepo({ connection });
|
|
47
|
-
// const actionRepo = new ActionRepo(connection);
|
|
48
43
|
const authorizePaymentMethodActionRepo = new authorizePaymentMethod_1.AuthorizePaymentMethodActionRepo(connection);
|
|
49
|
-
// const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
|
|
50
44
|
const paymentServiceId = params.data.object.issuedThrough.id;
|
|
51
45
|
const credentialsExpireInSeconds = (await settings.getByKey('movieticketReserve')).credentialsExpireInSeconds;
|
|
52
46
|
const useCredentialsRepo = typeof paymentServiceId === 'string' && paymentServiceId !== ''
|
|
@@ -9,23 +9,17 @@ const paymentService_1 = require("../../repo/paymentService");
|
|
|
9
9
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
10
10
|
const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
|
|
11
11
|
const integration_1 = require("../../repo/setting/integration");
|
|
12
|
-
// import { TransactionProcessRepo } from '../../repo/transactionProcess';
|
|
13
12
|
const pay_1 = require("../assetTransaction/pay");
|
|
14
13
|
/**
|
|
15
14
|
* タスク実行関数
|
|
16
15
|
*/
|
|
17
16
|
function call(params) {
|
|
18
|
-
return async ({ connection, redisClient }
|
|
17
|
+
return async ({ connection, redisClient }) => {
|
|
19
18
|
if (redisClient === undefined) {
|
|
20
19
|
throw new factory_1.factory.errors.Argument('settings', 'redisClient required');
|
|
21
20
|
}
|
|
22
|
-
// 遅延実行(executeByName)には対応しない
|
|
23
|
-
if (!options.executeById) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
21
|
const settings = new integration_1.IntegrationSettingRepo({ connection });
|
|
27
22
|
const actionRepo = new checkMovieTicket_1.CheckMovieTicketActionRepo(connection);
|
|
28
|
-
// const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
|
|
29
23
|
const paymentServiceId = params.data.object[0]?.id;
|
|
30
24
|
const credentialsExpireInSeconds = (await settings.getByKey('movieticketReserve')).credentialsExpireInSeconds;
|
|
31
25
|
const useCredentialsRepo = typeof paymentServiceId === 'string' && paymentServiceId !== ''
|
|
@@ -10,10 +10,8 @@ const event_1 = require("../../repo/event");
|
|
|
10
10
|
const eventSeries_1 = require("../../repo/eventSeries");
|
|
11
11
|
const issuer_1 = require("../../repo/issuer");
|
|
12
12
|
const orderInTransaction_1 = require("../../repo/orderInTransaction");
|
|
13
|
-
// import { OrderNumberRepo } from '../../repo/orderNumber';
|
|
14
13
|
const paymentService_1 = require("../../repo/paymentService");
|
|
15
14
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
16
|
-
// import { ProjectRepo } from '../../repo/project';
|
|
17
15
|
const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
|
|
18
16
|
const integration_1 = require("../../repo/setting/integration");
|
|
19
17
|
const ticket_1 = require("../../repo/ticket");
|
|
@@ -24,17 +22,12 @@ const any_1 = require("../payment/any");
|
|
|
24
22
|
* タスク実行関数
|
|
25
23
|
*/
|
|
26
24
|
function call(params) {
|
|
27
|
-
return async ({ connection, redisClient }
|
|
25
|
+
return async ({ connection, redisClient }) => {
|
|
28
26
|
if (redisClient === undefined) {
|
|
29
27
|
throw new factory_1.factory.errors.Argument('settings', 'redisClient required');
|
|
30
28
|
}
|
|
31
|
-
// 遅延実行(executeByName)には対応しない
|
|
32
|
-
if (!options.executeById) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
29
|
const settings = new integration_1.IntegrationSettingRepo({ connection });
|
|
36
30
|
const actionRepo = new acceptPay_1.AcceptPayActionRepo(connection);
|
|
37
|
-
// const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
|
|
38
31
|
try {
|
|
39
32
|
const { savePaymentMethodIdInTransaction: _savePaymentMethodIdInTransaction, project: _project, ...publishPaymentUrlParams } = params.data;
|
|
40
33
|
await (0, any_1.publishPaymentUrl)({
|
|
@@ -51,11 +44,9 @@ function call(params) {
|
|
|
51
44
|
eventSeries: new eventSeries_1.EventSeriesRepo(connection),
|
|
52
45
|
issuer: new issuer_1.IssuerRepo(connection),
|
|
53
46
|
orderInTransaction: new orderInTransaction_1.OrderInTransactionRepo(connection),
|
|
54
|
-
// orderNumber: new OrderNumberRepo({ connection }),
|
|
55
47
|
paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
|
|
56
48
|
paymentService: new paymentService_1.PaymentServiceRepo(connection),
|
|
57
49
|
paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
|
|
58
|
-
// project: new ProjectRepo(connection),
|
|
59
50
|
ticket: new ticket_1.TicketRepo(connection),
|
|
60
51
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
|
|
61
52
|
transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
|
|
@@ -24,14 +24,10 @@ let coaAuthClient;
|
|
|
24
24
|
* タスク実行関数
|
|
25
25
|
*/
|
|
26
26
|
function call(params) {
|
|
27
|
-
return async ({ connection, redisClient }
|
|
27
|
+
return async ({ connection, redisClient }) => {
|
|
28
28
|
if (redisClient === undefined) {
|
|
29
29
|
throw new factory_1.factory.errors.Argument('settings', 'redisClient required');
|
|
30
30
|
}
|
|
31
|
-
// 遅延実行(executeByName)には対応しない
|
|
32
|
-
if (!options.executeById) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
31
|
const settings = new integration_1.IntegrationSettingRepo({ connection });
|
|
36
32
|
const reserveInterfaceRepo = new reserveInterface_1.ReserveInterfaceRepo(connection);
|
|
37
33
|
const coaAPI = await reserveInterfaceRepo.findOne({ project: { id: { $eq: params.project.id } } });
|
|
@@ -16,7 +16,6 @@ const setting_1 = require("../../repo/setting");
|
|
|
16
16
|
const integration_1 = require("../../repo/setting/integration");
|
|
17
17
|
const stockHolder_1 = require("../../repo/stockHolder");
|
|
18
18
|
const task_1 = require("../../repo/task");
|
|
19
|
-
// import { TransactionRepo } from '../../repo/transaction';
|
|
20
19
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
21
20
|
let coaAuthClientCreated = false;
|
|
22
21
|
let coaAuthClient = new coa_service_1.COA.auth.RefreshToken({
|
|
@@ -28,16 +27,16 @@ let coaAuthClient = new coa_service_1.COA.auth.RefreshToken({
|
|
|
28
27
|
* タスク実行関数
|
|
29
28
|
*/
|
|
30
29
|
function call(params) {
|
|
31
|
-
return async ({ connection, redisClient }
|
|
30
|
+
return async ({ connection, redisClient }) => {
|
|
32
31
|
if (redisClient === undefined) {
|
|
33
32
|
throw new factory_1.factory.errors.Argument('settings', 'redisClient required');
|
|
34
33
|
}
|
|
35
34
|
const voidByActionId = typeof params.data.id === 'string';
|
|
36
35
|
if (voidByActionId) {
|
|
37
|
-
// 遅延実行(executeByName)には対応しない
|
|
38
|
-
if (!options.executeById) {
|
|
39
|
-
|
|
40
|
-
}
|
|
36
|
+
// // 遅延実行(executeByName)には対応しない
|
|
37
|
+
// if (!options.executeById) {
|
|
38
|
+
// return;
|
|
39
|
+
// }
|
|
41
40
|
}
|
|
42
41
|
if (!coaAuthClientCreated) {
|
|
43
42
|
const reserveInterfaceRepo = new reserveInterface_1.ReserveInterfaceRepo(connection);
|
|
@@ -53,7 +52,6 @@ function call(params) {
|
|
|
53
52
|
endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
|
|
54
53
|
auth: coaAuthClient
|
|
55
54
|
}, { timeout: (await settings.getByKey('coa')).timeoutReserve });
|
|
56
|
-
// const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
|
|
57
55
|
try {
|
|
58
56
|
await (0, voidTransaction_1.voidTransaction)({
|
|
59
57
|
...params.data,
|
|
@@ -71,7 +69,6 @@ function call(params) {
|
|
|
71
69
|
setting: new setting_1.SettingRepo(connection),
|
|
72
70
|
task: new task_1.TaskRepo(connection),
|
|
73
71
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
|
|
74
|
-
// transaction: new TransactionRepo(connection),
|
|
75
72
|
reserveService
|
|
76
73
|
}, settings);
|
|
77
74
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IExecuteSettings as IMinimumExecuteSettings,
|
|
1
|
+
import type { IExecuteSettings as IMinimumExecuteSettings, IReadyTask, IRunningTask } from '../eventEmitter/task';
|
|
2
2
|
import type { AggregationSettings } from '../taskSettings';
|
|
3
3
|
interface IExecuteSettings extends IMinimumExecuteSettings {
|
|
4
4
|
aggregationSettings?: AggregationSettings;
|
|
@@ -7,12 +7,12 @@ type IOperation<T> = (settings: IExecuteSettings) => Promise<T>;
|
|
|
7
7
|
/**
|
|
8
8
|
* タスク変更イベントを受けて実行する
|
|
9
9
|
*/
|
|
10
|
-
declare function
|
|
10
|
+
declare function executeTaskById(params: (Pick<IReadyTask, 'id' | 'status'> | Pick<IRunningTask, 'id' | 'status'>) & {
|
|
11
11
|
executor: {
|
|
12
12
|
/**
|
|
13
13
|
* タスク実行者名称
|
|
14
14
|
*/
|
|
15
15
|
name: string;
|
|
16
16
|
};
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
17
|
+
}): IOperation<void>;
|
|
18
|
+
export { executeTaskById };
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.executeTaskById = executeTaskById;
|
|
7
7
|
/**
|
|
8
8
|
* タスクサービス
|
|
9
9
|
*/
|
|
@@ -13,10 +13,10 @@ const debug = (0, debug_1.default)('chevre-domain:service:task');
|
|
|
13
13
|
/**
|
|
14
14
|
* タスク変更イベントを受けて実行する
|
|
15
15
|
*/
|
|
16
|
-
function
|
|
16
|
+
function executeTaskById(params) {
|
|
17
17
|
return async (settings) => {
|
|
18
18
|
const taskRepo = new (await import('../repo/task.js')).TaskRepo(settings.connection);
|
|
19
|
-
const { id, status, executor
|
|
19
|
+
const { id, status, executor } = params;
|
|
20
20
|
let task = null;
|
|
21
21
|
try {
|
|
22
22
|
// support status: Running(2025-03-05~)
|
|
@@ -24,18 +24,18 @@ function executeById(params, next) {
|
|
|
24
24
|
id,
|
|
25
25
|
status,
|
|
26
26
|
executor: { name: executor.name },
|
|
27
|
-
...(expires instanceof Date) ? { expires } : undefined
|
|
27
|
+
// ...(expires instanceof Date) ? { expires } : undefined // 非同期アクションは移行につきexpires廃止(2026-08-05~)
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
31
|
/* istanbul ignore next */
|
|
32
|
-
debug('service.task.
|
|
32
|
+
debug('service.task.executeTaskById error:', error);
|
|
33
33
|
}
|
|
34
34
|
// タスクがなければ終了
|
|
35
35
|
if (task !== null) {
|
|
36
|
-
await (0, taskHandler_1.executeTask)(task
|
|
36
|
+
await (0, taskHandler_1.executeTask)(task)(settings, {
|
|
37
37
|
executeById: true,
|
|
38
|
-
executeByName: false
|
|
38
|
+
// executeByName: false // discontinue(2026-08-05~)
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { INextFunction } from '../../eventEmitter/task';
|
|
2
1
|
import { factory } from '../../factory';
|
|
3
2
|
import type { SettingRepo } from '../../repo/setting';
|
|
4
3
|
import type { TaskRepo } from '../../repo/task';
|
|
@@ -10,7 +9,7 @@ declare function onOperationFailed(params: {
|
|
|
10
9
|
task: IExecutableTask<factory.taskName>;
|
|
11
10
|
now: Date;
|
|
12
11
|
error: any;
|
|
13
|
-
next?:
|
|
12
|
+
next?: never;
|
|
14
13
|
}): (repos: {
|
|
15
14
|
setting: SettingRepo;
|
|
16
15
|
task: TaskRepo;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.onOperationFailed = onOperationFailed;
|
|
4
|
+
// import type { INextFunction } from '../../eventEmitter/task';
|
|
4
5
|
const factory_1 = require("../../factory");
|
|
5
6
|
const informTaskIfNeeded_1 = require("./onOperationFailed/informTaskIfNeeded");
|
|
6
7
|
/**
|
|
@@ -9,7 +10,7 @@ const informTaskIfNeeded_1 = require("./onOperationFailed/informTaskIfNeeded");
|
|
|
9
10
|
function onOperationFailed(params) {
|
|
10
11
|
return async (repos) => {
|
|
11
12
|
let error = params.error;
|
|
12
|
-
const { task, now
|
|
13
|
+
const { task, now } = params;
|
|
13
14
|
if (error === null || typeof error !== 'object') {
|
|
14
15
|
error = { message: String(error) };
|
|
15
16
|
}
|
|
@@ -35,12 +36,12 @@ function onOperationFailed(params) {
|
|
|
35
36
|
// 失敗してもここではステータスを戻さない(Runningのまま待機)
|
|
36
37
|
await repos.task.setExecutionResultAndStatus({
|
|
37
38
|
id: task.id,
|
|
38
|
-
remainingNumberOfTries: task.remainingNumberOfTries,
|
|
39
|
-
name: task.name
|
|
39
|
+
// remainingNumberOfTries: task.remainingNumberOfTries,
|
|
40
|
+
// name: task.name
|
|
40
41
|
}, {
|
|
41
42
|
status: task.status,
|
|
42
43
|
executionResult: result
|
|
43
|
-
}
|
|
44
|
+
});
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
46
47
|
// 分析連携(2025-08-05~)
|
|
@@ -61,12 +62,12 @@ function onOperationFailed(params) {
|
|
|
61
62
|
};
|
|
62
63
|
await repos.task.setExecutionResultAndStatus({
|
|
63
64
|
id: task.id,
|
|
64
|
-
remainingNumberOfTries: task.remainingNumberOfTries,
|
|
65
|
-
name: task.name
|
|
65
|
+
// remainingNumberOfTries: task.remainingNumberOfTries,
|
|
66
|
+
// name: task.name
|
|
66
67
|
}, {
|
|
67
68
|
status: factory_1.factory.taskStatus.Aborted,
|
|
68
69
|
executionResult: result
|
|
69
|
-
}
|
|
70
|
+
});
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
73
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { INextFunction } from '../eventEmitter/task';
|
|
2
1
|
import { factory } from '../factory';
|
|
3
2
|
import type { ICallResult, ICallableTaskOperation, IExecutableTask, IExecutableTaskKeys, IOperationExecute } from '../taskSettings';
|
|
4
3
|
export declare const taskLoader: {
|
|
@@ -9,5 +8,5 @@ export declare const taskLoader: {
|
|
|
9
8
|
/**
|
|
10
9
|
* タスクを実行する
|
|
11
10
|
*/
|
|
12
|
-
declare function executeTask(task: IExecutableTask<factory.taskName
|
|
11
|
+
declare function executeTask(task: IExecutableTask<factory.taskName>): IOperationExecute<void>;
|
|
13
12
|
export { ICallableTaskOperation, ICallResult, IExecutableTaskKeys, IOperationExecute, executeTask };
|