@chevre/domain 26.0.0-alpha.0 → 26.0.0-alpha.10
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/adminAsyncAction.d.ts +19 -0
- package/lib/chevre/repo/adminAsyncAction.js +86 -0
- package/lib/chevre/repo/adminScheduledTask.d.ts +20 -0
- package/lib/chevre/repo/adminScheduledTask.js +95 -0
- package/lib/chevre/repo/aggregateScheduledTask.d.ts +32 -0
- package/lib/chevre/repo/aggregateScheduledTask.js +136 -0
- package/lib/chevre/repo/asyncAction.d.ts +3 -8
- package/lib/chevre/repo/asyncAction.js +0 -108
- package/lib/chevre/repo/asyncActionLegacy.d.ts +23 -0
- package/lib/chevre/repo/asyncActionLegacy.js +59 -0
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +2 -4
- package/lib/chevre/repo/scheduledTask.d.ts +1 -1
- package/lib/chevre/repo/scheduledTaskLegacy.d.ts +39 -0
- package/lib/chevre/repo/scheduledTaskLegacy.js +96 -0
- package/lib/chevre/repo/scheduledTaskMigration.d.ts +21 -0
- package/lib/chevre/repo/scheduledTaskMigration.js +70 -0
- package/lib/chevre/repo/task.d.ts +35 -68
- package/lib/chevre/repo/task.js +257 -177
- package/lib/chevre/repository.d.ts +25 -0
- package/lib/chevre/repository.js +57 -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/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/onOrderStatusChanged/onOrderInTransit.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +1 -1
- 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/reserve/confirmReservation.js +19 -26
- package/lib/chevre/service/reserve/factory.d.ts +0 -3
- package/lib/chevre/service/reserve/factory.js +0 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +4 -13
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +21 -61
- 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.d.ts +1 -20
- package/lib/chevre/service/task.js +0 -28
- package/lib/chevre/service/taskHandler.js +0 -34
- 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 +20 -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 +21 -13
- package/lib/chevre/service/transaction.d.ts +2 -0
- package/lib/chevre/service/transaction.js +0 -2
- package/package.json +2 -2
|
@@ -12,9 +12,7 @@ const debug = (0, debug_1.default)('chevre-domain:service:reserve:confirmReserva
|
|
|
12
12
|
* 予約を確定する
|
|
13
13
|
*/
|
|
14
14
|
function confirmReservation(params) {
|
|
15
|
-
return async (repos
|
|
16
|
-
// settings: Settings
|
|
17
|
-
) => {
|
|
15
|
+
return async (repos) => {
|
|
18
16
|
// await Promise.all(params.actionAttributesList.map(async (potentialReserveAction) => {
|
|
19
17
|
// const actionAttributes = await reserveIfNotYet(potentialReserveAction, { byTask: params.byTask })(repos);
|
|
20
18
|
// if (params.useOnReservationConfirmed) {
|
|
@@ -23,7 +21,8 @@ function confirmReservation(params) {
|
|
|
23
21
|
// }));
|
|
24
22
|
const { actionAttributes, reserveTransaction } = await reserveIfNotYet(params.potentialReserveAction, { byTask: params.byTask })(repos);
|
|
25
23
|
if (params.useOnReservationConfirmed) {
|
|
26
|
-
|
|
24
|
+
// onReservationConfirmedByActionは廃止(2026-08-01~)
|
|
25
|
+
// await onReservationConfirmedByAction(actionAttributes)({ task: repos.task });
|
|
27
26
|
}
|
|
28
27
|
if (params.useOnReservationConfirmed) {
|
|
29
28
|
let confirmedReservations = [];
|
|
@@ -38,38 +37,32 @@ function confirmReservation(params) {
|
|
|
38
37
|
// project all fields
|
|
39
38
|
// {}
|
|
40
39
|
);
|
|
41
|
-
// price,underName,ticketTypeは予約取引から補完する(2026-03-25~)
|
|
42
40
|
confirmedReservations = rawReservations.map((rawReservation) => {
|
|
43
|
-
const subReservationByTransaction = reserveTransaction.object.subReservation?.find((s) => s.id === rawReservation.id);
|
|
44
|
-
// 予約取引内にsubReservationは必ず存在するはず
|
|
45
|
-
if (subReservationByTransaction === undefined) {
|
|
46
|
-
|
|
47
|
-
}
|
|
41
|
+
// const subReservationByTransaction = reserveTransaction.object.subReservation?.find((s) => s.id === rawReservation.id);
|
|
42
|
+
// // 予約取引内にsubReservationは必ず存在するはず
|
|
43
|
+
// if (subReservationByTransaction === undefined) {
|
|
44
|
+
// throw new factory.errors.NotFound('reserveTransaction.object.subReservation');
|
|
45
|
+
// }
|
|
48
46
|
// 予約取引内にreservationForは必ず存在するはず
|
|
49
47
|
if (reserveTransaction.object.reservationFor === undefined) {
|
|
50
48
|
throw new factory_1.factory.errors.NotFound('reserveTransaction.object.reservationFor');
|
|
51
49
|
}
|
|
52
|
-
const priceByTransaction = subReservationByTransaction.price;
|
|
53
|
-
const underNameByTransaction = reserveTransaction.object.underName;
|
|
54
|
-
const ticketTypeByTransaction = subReservationByTransaction.reservedTicket.ticketType;
|
|
55
|
-
// console.log('creating confirmedReservation...', rawReservation, priceByTransaction, underNameByTransaction, ticketTypeByTransaction);
|
|
50
|
+
// const priceByTransaction = subReservationByTransaction.price;
|
|
51
|
+
// const underNameByTransaction = reserveTransaction.object.underName;
|
|
52
|
+
// const ticketTypeByTransaction = subReservationByTransaction.reservedTicket.ticketType;
|
|
56
53
|
return {
|
|
57
54
|
...rawReservation,
|
|
58
|
-
price: priceByTransaction,
|
|
59
|
-
underName: underNameByTransaction,
|
|
60
|
-
reservedTicket: {
|
|
61
|
-
...rawReservation.reservedTicket,
|
|
62
|
-
ticketType: ticketTypeByTransaction
|
|
63
|
-
},
|
|
64
55
|
reservationFor: reserveTransaction.object.reservationFor, // reservationForは予約取引から参照する(2026-04-05~)
|
|
65
|
-
|
|
56
|
+
// price,underName,ticketTypeは予約取引から補完していたが(2026-03-25~)、もう廃止(2026-08-01~)
|
|
57
|
+
// reservedTicket: {
|
|
58
|
+
// ...rawReservation.reservedTicket,
|
|
59
|
+
// ticketType: ticketTypeByTransaction
|
|
60
|
+
// },
|
|
61
|
+
// price: priceByTransaction,
|
|
62
|
+
// underName: underNameByTransaction,
|
|
63
|
+
// issuedThrough: reserveTransaction.object.issuedThrough // issuedThroughは予約取引から補完する(2026-05-08~)
|
|
66
64
|
};
|
|
67
65
|
});
|
|
68
|
-
confirmedReservations = confirmedReservations.map((r) => {
|
|
69
|
-
// // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
70
|
-
// delete (r as any)._id;
|
|
71
|
-
return r;
|
|
72
|
-
});
|
|
73
66
|
}
|
|
74
67
|
await (0, onReservationConfirmed_1.onReservationConfirmed)(confirmedReservations, actionAttributes)(repos);
|
|
75
68
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { factory } from '../../factory';
|
|
2
|
-
export declare function optimizeUnderName4inform(params: {
|
|
3
|
-
underName: Pick<factory.reservation.IUnderName, 'id' | 'typeOf'>;
|
|
4
|
-
}): factory.notification.reservation.IMaskedUnderName;
|
|
5
2
|
export type IPotentialInformReservationAction = factory.task.triggerWebhook.IPotentialInformReservationAction;
|
|
6
3
|
export declare const NUM_TRY_INFORM_RESERVATION = 10;
|
|
7
4
|
export interface IPotentialCancelAction extends factory.action.cancel.reservation.IAttributes {
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NUM_TRY_INFORM_RESERVATION = void 0;
|
|
4
|
-
exports.optimizeUnderName4inform = optimizeUnderName4inform;
|
|
5
4
|
exports.createCancelPendingReservationAction = createCancelPendingReservationAction;
|
|
6
5
|
const factory_1 = require("../../factory");
|
|
7
|
-
function optimizeUnderName4inform(params) {
|
|
8
|
-
return { id: params.underName.id, typeOf: params.underName.typeOf };
|
|
9
|
-
}
|
|
10
6
|
exports.NUM_TRY_INFORM_RESERVATION = 10;
|
|
11
7
|
function createCancelPendingReservationAction(params) {
|
|
12
8
|
const transaction = params.transaction;
|
|
@@ -5,21 +5,12 @@ import { factory } from '../../../factory';
|
|
|
5
5
|
import { AuthorizationRepo } from '../../../repo/authorization';
|
|
6
6
|
import type { SettingRepo } from '../../../repo/setting';
|
|
7
7
|
import type { TaskRepo } from '../../../repo/task';
|
|
8
|
-
export type IConfirmedReservation =
|
|
9
|
-
price?: factory.assetTransaction.reserve.IPrice;
|
|
10
|
-
underName?: Pick<factory.reservation.IUnderName, 'id' | 'typeOf'>;
|
|
11
|
-
reservedTicket: Omit<factory.assetTransaction.reserve.ISubReservationReservedTicket, 'ticketType'> & {
|
|
12
|
-
ticketType: factory.assetTransaction.reserve.ITicketType;
|
|
13
|
-
};
|
|
8
|
+
export type IConfirmedReservation = Pick<factory.reservation.eventReservation.IReservation, 'additionalProperty' | 'additionalTicketText' | 'bookingTime' | 'id' | 'modifiedTime' | 'project' | 'provider' | 'reservationNumber' | 'subReservation' | 'typeOf' | 'reservedTicket'> & {
|
|
14
9
|
reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
15
|
-
|
|
10
|
+
price?: never;
|
|
11
|
+
underName?: never;
|
|
12
|
+
issuedThrough?: never;
|
|
16
13
|
};
|
|
17
|
-
/**
|
|
18
|
-
* 予約確定後のアクション
|
|
19
|
-
*/
|
|
20
|
-
export declare function onReservationConfirmedByAction(actionAttributes: Pick<factory.action.reserve.IAttributes, 'potentialActions'>): (repos: {
|
|
21
|
-
task: TaskRepo;
|
|
22
|
-
}) => Promise<void>;
|
|
23
14
|
export declare function onReservationConfirmed(confirmedReservations: IConfirmedReservation[], reserveAction: Pick<factory.action.reserve.IAttributes, 'instrument'>): (repos: {
|
|
24
15
|
code: AuthorizationRepo;
|
|
25
16
|
setting: SettingRepo;
|
|
@@ -1,52 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onReservationConfirmedByAction = onReservationConfirmedByAction;
|
|
4
3
|
exports.onReservationConfirmed = onReservationConfirmed;
|
|
5
4
|
/**
|
|
6
5
|
* 予約確定時アクション
|
|
7
6
|
*/
|
|
8
7
|
const factory_1 = require("../../../factory");
|
|
9
8
|
const factory_2 = require("../factory");
|
|
10
|
-
/**
|
|
11
|
-
* 予約確定後のアクション
|
|
12
|
-
*/
|
|
13
|
-
function onReservationConfirmedByAction(actionAttributes) {
|
|
14
|
-
return async (repos) => {
|
|
15
|
-
const potentialActions = actionAttributes.potentialActions;
|
|
16
|
-
// const now = new Date();
|
|
17
|
-
const taskAttributes = [];
|
|
18
|
-
/* istanbul ignore else */
|
|
19
|
-
if (potentialActions !== undefined) {
|
|
20
|
-
// discontinue(2026-04-18~)
|
|
21
|
-
// if (Array.isArray(potentialActions.moneyTransfer)) {
|
|
22
|
-
// taskAttributes.push(...potentialActions.moneyTransfer.map((a) => {
|
|
23
|
-
// return {
|
|
24
|
-
// project: a.project,
|
|
25
|
-
// name: factory.taskName.MoneyTransfer as factory.taskName.MoneyTransfer,
|
|
26
|
-
// status: factory.taskStatus.Ready,
|
|
27
|
-
// runsAt: now,
|
|
28
|
-
// remainingNumberOfTries: 10,
|
|
29
|
-
// numberOfTried: 0,
|
|
30
|
-
// executionResults: [],
|
|
31
|
-
// data: a
|
|
32
|
-
// };
|
|
33
|
-
// }));
|
|
34
|
-
// }
|
|
35
|
-
}
|
|
36
|
-
// タスク保管
|
|
37
|
-
if (taskAttributes.length > 0) {
|
|
38
|
-
await repos.task.saveMany(taskAttributes);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
9
|
function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
43
|
-
return async (repos
|
|
44
|
-
// settings: Settings
|
|
45
|
-
) => {
|
|
10
|
+
return async (repos) => {
|
|
46
11
|
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onReservationStatusChanged']);
|
|
47
|
-
// const informReservations = settings.onReservationStatusChanged.informReservation;
|
|
48
12
|
const informReservations = setting?.onReservationStatusChanged?.informReservation;
|
|
49
|
-
const minimizeReservation = setting?.onReservationStatusChanged?.minimizeReservation === true;
|
|
50
13
|
let orderAsAbout;
|
|
51
14
|
if (Array.isArray(reserveAction.instrument)) {
|
|
52
15
|
for (const eachInstrument of reserveAction.instrument) {
|
|
@@ -58,8 +21,7 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
|
58
21
|
}
|
|
59
22
|
if (Array.isArray(confirmedReservations) && confirmedReservations.length > 0) {
|
|
60
23
|
// ひとつめの予約からReservationPackageの共有属性を取り出す
|
|
61
|
-
const { bookingTime,
|
|
62
|
-
// create AggregateScreeningEvent task -> migrate to agg(2024-10-29~)
|
|
24
|
+
const { bookingTime, project, provider, reservationFor, reservationNumber } = confirmedReservations[0];
|
|
63
25
|
const now = new Date();
|
|
64
26
|
const taskAttributes = [];
|
|
65
27
|
let onAuthorizationCreatedTask;
|
|
@@ -98,15 +60,13 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
|
98
60
|
}
|
|
99
61
|
}
|
|
100
62
|
const subReservations4inform = confirmedReservations.map((r) => {
|
|
101
|
-
const {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
reservedTicket4inform = reservedTicket; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
109
|
-
}
|
|
63
|
+
const {
|
|
64
|
+
// additionalProperty: _additionalProperty,
|
|
65
|
+
// price: _price,
|
|
66
|
+
// programMembershipUsed: _programMembershipUsed,
|
|
67
|
+
additionalTicketText, id, modifiedTime, reservedTicket, subReservation, typeOf } = r;
|
|
68
|
+
const { ticketType: _ticketType, ...reservedTicketWithNoTicketType } = reservedTicket;
|
|
69
|
+
const reservedTicket4inform = reservedTicketWithNoTicketType;
|
|
110
70
|
return {
|
|
111
71
|
id,
|
|
112
72
|
typeOf,
|
|
@@ -114,15 +74,15 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
|
114
74
|
...(typeof additionalTicketText === 'string') ? { additionalTicketText } : undefined,
|
|
115
75
|
...(modifiedTime instanceof Date) ? { modifiedTime } : undefined,
|
|
116
76
|
...(Array.isArray(subReservation)) ? { subReservation } : undefined,
|
|
117
|
-
...(!minimizeReservation && Array.isArray(additionalProperty)) ? { additionalProperty } : undefined, //
|
|
118
|
-
...(!minimizeReservation && price !== undefined) ? { price } : undefined, //
|
|
119
|
-
...(!minimizeReservation && programMembershipUsed !== undefined) ? { programMembershipUsed } : undefined, //
|
|
77
|
+
// ...(!minimizeReservation && Array.isArray(additionalProperty)) ? { additionalProperty } : undefined, // discontinue(2026-08-01~)
|
|
78
|
+
// ...(!minimizeReservation && price !== undefined) ? { price } : undefined, // discontinue(2026-08-01~)
|
|
79
|
+
// ...(!minimizeReservation && programMembershipUsed !== undefined) ? { programMembershipUsed } : undefined, // discontinue(2026-08-01~)
|
|
120
80
|
};
|
|
121
81
|
});
|
|
122
|
-
if (typeof issuedThrough.id !== 'string') {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
82
|
+
// if (typeof issuedThrough.id !== 'string') {
|
|
83
|
+
// // COA予約では予約アクションを想定していないので、興行idは必ず存在するはず
|
|
84
|
+
// throw new factory.errors.Internal('reservation.issuedThrough.id must be string');
|
|
85
|
+
// }
|
|
126
86
|
const informObject = {
|
|
127
87
|
bookingTime,
|
|
128
88
|
project,
|
|
@@ -132,10 +92,10 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
|
132
92
|
reservationStatus: factory_1.factory.reservationStatusType.ReservationConfirmed,
|
|
133
93
|
subReservation: subReservations4inform,
|
|
134
94
|
typeOf: factory_1.factory.reservationType.ReservationPackage,
|
|
135
|
-
...(!minimizeReservation) ? { issuedThrough } : undefined, //
|
|
136
|
-
...(!minimizeReservation && typeof underName?.typeOf === 'string')
|
|
137
|
-
|
|
138
|
-
|
|
95
|
+
// ...(!minimizeReservation) ? { issuedThrough } : undefined, // discontinue(2026-08-01~)
|
|
96
|
+
// ...(!minimizeReservation && typeof underName?.typeOf === 'string')
|
|
97
|
+
// ? { underName: optimizeUnderName4inform({ underName }) }
|
|
98
|
+
// : undefined // discontinue(2026-08-01~)
|
|
139
99
|
};
|
|
140
100
|
const informIdentifier = `${factory_1.factory.reservationType.ReservationPackage}:${informObject.reservationNumber}:${informObject.reservationStatus}`;
|
|
141
101
|
// inform galobally
|
|
@@ -177,7 +137,7 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
|
|
|
177
137
|
await repos.task.saveMany(taskAttributes);
|
|
178
138
|
}
|
|
179
139
|
if (onAuthorizationCreatedTask !== undefined) {
|
|
180
|
-
await repos.task.
|
|
140
|
+
await repos.task.runTaskByIdentifier(onAuthorizationCreatedTask);
|
|
181
141
|
}
|
|
182
142
|
}
|
|
183
143
|
};
|
|
@@ -60,7 +60,10 @@ function call(params) {
|
|
|
60
60
|
endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
|
|
61
61
|
auth: coaAuthClient
|
|
62
62
|
}, { timeout: (await settings.getByKey('coa')).timeoutReserve });
|
|
63
|
-
await EventAggregationService.importFromCOA(
|
|
63
|
+
await EventAggregationService.importFromCOA({
|
|
64
|
+
...params.data,
|
|
65
|
+
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project }
|
|
66
|
+
})({
|
|
64
67
|
event: new event_1.EventRepo(connection),
|
|
65
68
|
reserveService
|
|
66
69
|
});
|
|
@@ -67,7 +67,10 @@ function call(params) {
|
|
|
67
67
|
endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
|
|
68
68
|
auth: coaAuthClient
|
|
69
69
|
}, { timeout: (await settings.getByKey('coa')).timeoutMaster });
|
|
70
|
-
await EventService.importFromCOA(
|
|
70
|
+
await EventService.importFromCOA({
|
|
71
|
+
...params.data,
|
|
72
|
+
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project }
|
|
73
|
+
})({
|
|
71
74
|
action: new action_1.ActionRepo(connection),
|
|
72
75
|
categoryCode: new categoryCode_1.CategoryCodeRepo(connection),
|
|
73
76
|
creativeWork: new creativeWork_1.CreativeWorkRepo(connection),
|
|
@@ -65,22 +65,22 @@ function call(params) {
|
|
|
65
65
|
const settings = new integration_1.IntegrationSettingRepo({ connection });
|
|
66
66
|
const aggregateOfferRepo = new aggregateOffer_1.AggregateOfferRepo(connection);
|
|
67
67
|
const categoryCodeRepo = new categoryCode_1.CategoryCodeRepo(connection);
|
|
68
|
-
// const taskRepo = new TaskRepo(connection);
|
|
69
68
|
const masterService = new coa_service_1.COA.service.Master({
|
|
70
69
|
endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
|
|
71
70
|
auth: coaAuthClient
|
|
72
71
|
}, { timeout: (await settings.getByKey('coa')).timeoutMaster });
|
|
73
72
|
await OfferService.event.importFromCOA({
|
|
74
|
-
project: { id: params.
|
|
73
|
+
project: { id: params.project.id },
|
|
75
74
|
theaterCode: params.data.theaterCode,
|
|
76
75
|
paymentMethodType4membershipCoupon
|
|
77
76
|
})({
|
|
78
|
-
// categoryCode: categoryCodeRepo,
|
|
79
77
|
aggregateOffer: aggregateOfferRepo,
|
|
80
|
-
// task: taskRepo,
|
|
81
78
|
masterService
|
|
82
79
|
});
|
|
83
|
-
await OfferService.event.importCategoryCodesFromCOA(
|
|
80
|
+
await OfferService.event.importCategoryCodesFromCOA({
|
|
81
|
+
...params.data,
|
|
82
|
+
project: { id: params.project.id }
|
|
83
|
+
})({
|
|
84
84
|
categoryCode: categoryCodeRepo,
|
|
85
85
|
masterService
|
|
86
86
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { IExecuteSettings as IMinimumExecuteSettings, INextFunction, IReadyTask, IRunningTask } from '../eventEmitter/task';
|
|
2
|
-
import { factory } from '../factory';
|
|
3
2
|
import type { AggregationSettings } from '../taskSettings';
|
|
4
3
|
interface IExecuteSettings extends IMinimumExecuteSettings {
|
|
5
4
|
aggregationSettings?: AggregationSettings;
|
|
@@ -16,22 +15,4 @@ declare function executeById(params: (IReadyTask | IRunningTask) & {
|
|
|
16
15
|
name: string;
|
|
17
16
|
};
|
|
18
17
|
}, next?: INextFunction): IOperation<void>;
|
|
19
|
-
|
|
20
|
-
name: {
|
|
21
|
-
$eq: factory.taskName;
|
|
22
|
-
};
|
|
23
|
-
executor: {
|
|
24
|
-
/**
|
|
25
|
-
* タスク実行者名称
|
|
26
|
-
*/
|
|
27
|
-
name: string;
|
|
28
|
-
};
|
|
29
|
-
runsAt: {
|
|
30
|
-
$lt: Date;
|
|
31
|
-
};
|
|
32
|
-
sort: {
|
|
33
|
-
numberOfTried?: factory.sortType;
|
|
34
|
-
runsAt?: factory.sortType;
|
|
35
|
-
};
|
|
36
|
-
}): IOperation<void>;
|
|
37
|
-
export { executeById, executeOneIfExists };
|
|
18
|
+
export { executeById, };
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.executeById = executeById;
|
|
7
|
-
exports.executeOneIfExists = executeOneIfExists;
|
|
8
7
|
/**
|
|
9
8
|
* タスクサービス
|
|
10
9
|
*/
|
|
@@ -41,30 +40,3 @@ function executeById(params, next) {
|
|
|
41
40
|
}
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
|
-
function executeOneIfExists(params) {
|
|
45
|
-
return async (settings) => {
|
|
46
|
-
const taskRepo = new (await import('../repo/task.js')).TaskRepo(settings.connection);
|
|
47
|
-
// 未実行のタスクを取得
|
|
48
|
-
let task = null;
|
|
49
|
-
try {
|
|
50
|
-
task = await taskRepo.executeOneIfExists({
|
|
51
|
-
executor: { name: params.executor.name },
|
|
52
|
-
runsAt: { $lt: params.runsAt.$lt },
|
|
53
|
-
name: params.name,
|
|
54
|
-
sort: params.sort
|
|
55
|
-
});
|
|
56
|
-
debug('executable task found.', task, params.runsAt.$lt);
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
/* istanbul ignore next */
|
|
60
|
-
debug('executeOne error:', error);
|
|
61
|
-
}
|
|
62
|
-
// タスクがなければ終了
|
|
63
|
-
if (task !== null) {
|
|
64
|
-
await (0, taskHandler_1.executeTask)(task)(settings, {
|
|
65
|
-
executeById: false,
|
|
66
|
-
executeByName: (typeof params.name?.$eq === 'string')
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
@@ -44,40 +44,6 @@ function executeTask(task, next) {
|
|
|
44
44
|
const { call } = await exports.taskLoader.load(task.name); // testが書きづらいのでtaskLoader経由で呼ぶ
|
|
45
45
|
const callResult = await call(task)(settings, options);
|
|
46
46
|
// ICallableTaskOperationSimpleを廃止(2026-07-22~)
|
|
47
|
-
// let callResult: ICallResult | undefined;
|
|
48
|
-
// switch (task.name) {
|
|
49
|
-
// case factory.taskName.AcceptCOAOffer:
|
|
50
|
-
// case factory.taskName.AggregateOnSystem:
|
|
51
|
-
// case factory.taskName.AuthorizePayment:
|
|
52
|
-
// case factory.taskName.CancelPendingReservation:
|
|
53
|
-
// case factory.taskName.CheckMovieTicket:
|
|
54
|
-
// case factory.taskName.CheckResource:
|
|
55
|
-
// case factory.taskName.CreateAccountingReport:
|
|
56
|
-
// case factory.taskName.HandleNotification:
|
|
57
|
-
// case factory.taskName.ImportEventCapacitiesFromCOA:
|
|
58
|
-
// case factory.taskName.ImportEventsFromCOA:
|
|
59
|
-
// case factory.taskName.ImportOffersFromCOA:
|
|
60
|
-
// case factory.taskName.InvalidatePaymentUrl:
|
|
61
|
-
// case factory.taskName.OnAuthorizationCreated:
|
|
62
|
-
// case factory.taskName.OnResourceDeleted:
|
|
63
|
-
// case factory.taskName.Pay:
|
|
64
|
-
// case factory.taskName.PublishPaymentUrl:
|
|
65
|
-
// case factory.taskName.Refund:
|
|
66
|
-
// case factory.taskName.VoidPayTransaction:
|
|
67
|
-
// case factory.taskName.VoidReserveTransaction:
|
|
68
|
-
// case factory.taskName.ConfirmPayTransaction:
|
|
69
|
-
// case factory.taskName.ConfirmReserveTransaction:
|
|
70
|
-
// case factory.taskName.ReturnPayTransaction:
|
|
71
|
-
// case factory.taskName.ReturnReserveTransaction:
|
|
72
|
-
// case factory.taskName.SendEmailMessage:
|
|
73
|
-
// case factory.taskName.SyncResourcesFromCOA:
|
|
74
|
-
// case factory.taskName.TriggerWebhook:
|
|
75
|
-
// case factory.taskName.UseReservation:
|
|
76
|
-
// callResult = await (call as ICallableTaskOperation)(task)(settings, options);
|
|
77
|
-
// break;
|
|
78
|
-
// default:
|
|
79
|
-
// await (call as ICallableTaskOperationSimple)(task.data)(settings); // TODO discontinue
|
|
80
|
-
// }
|
|
81
47
|
const result = {
|
|
82
48
|
executedAt: now,
|
|
83
49
|
endDate: new Date(),
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { factory } from '../../../../factory';
|
|
2
2
|
import type { ISetting } from '../../../../repo/setting';
|
|
3
|
-
type IPlaceOrderPotentialTask = factory.task.IAttributes<factory.taskName.PlaceOrder> | factory.task.
|
|
3
|
+
type IPlaceOrderPotentialTask = factory.task.IAttributes<factory.taskName.PlaceOrder> | factory.task.IAttributes<factory.taskName.VoidPayTransaction> | factory.task.voidReserveTransaction.IAttributes;
|
|
4
4
|
/**
|
|
5
5
|
* 取引のタスクを作成する
|
|
6
|
+
* 取引削除タスクを分離(2026-08-02~)
|
|
6
7
|
*/
|
|
7
|
-
export declare function
|
|
8
|
+
export declare function createImmediateTasks(params: {
|
|
8
9
|
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'endDate' | 'id' | 'object' | 'project' | 'seller' | 'startDate' | 'status' | 'typeOf'>;
|
|
9
|
-
|
|
10
|
-
}
|
|
10
|
+
taskRunsAt: Date;
|
|
11
|
+
}): IPlaceOrderPotentialTask[];
|
|
12
|
+
export declare function createScheduledTasks(params: {
|
|
13
|
+
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'endDate' | 'id' | 'object' | 'project' | 'status' | 'typeOf'>;
|
|
14
|
+
}, setting: Pick<ISetting, 'storage'> | null): factory.task.deleteTransaction.IAttributes;
|
|
11
15
|
export {};
|
|
@@ -3,114 +3,19 @@ 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.createImmediateTasks = createImmediateTasks;
|
|
7
|
+
exports.createScheduledTasks = createScheduledTasks;
|
|
7
8
|
const moment_1 = __importDefault(require("moment"));
|
|
8
9
|
const factory_1 = require("../../../../factory");
|
|
9
10
|
/**
|
|
10
11
|
* 取引のタスクを作成する
|
|
12
|
+
* 取引削除タスクを分離(2026-08-02~)
|
|
11
13
|
*/
|
|
12
|
-
function
|
|
14
|
+
function createImmediateTasks(params) {
|
|
13
15
|
const taskAttributes = [];
|
|
14
16
|
const transaction = params.transaction;
|
|
15
|
-
const taskRunsAt = params.
|
|
17
|
+
const taskRunsAt = params.taskRunsAt;
|
|
16
18
|
// 取引通知は廃止(2026-06-29~)
|
|
17
|
-
// const informTransaction = setting?.onTransactionStatusChanged?.informTransaction;
|
|
18
|
-
// const transactionWebhookUrls = (Array.isArray(informTransaction)) ? informTransaction : [];
|
|
19
|
-
// const triggerWebhookTaskAttributes: factory.task.IAttributes<factory.taskName.TriggerWebhook>[] = [];
|
|
20
|
-
// transactionWebhookUrls.forEach(({ recipient }) => {
|
|
21
|
-
// if (typeof recipient?.url === 'string') {
|
|
22
|
-
// const informObject: factory.notification.transaction.IPlaceOrderAsNotification = {
|
|
23
|
-
// id: transaction.id,
|
|
24
|
-
// typeOf: transaction.typeOf,
|
|
25
|
-
// project: transaction.project,
|
|
26
|
-
// seller: transaction.seller,
|
|
27
|
-
// startDate: transaction.startDate,
|
|
28
|
-
// status: transaction.status,
|
|
29
|
-
// ...(transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined
|
|
30
|
-
// };
|
|
31
|
-
// const data: factory.task.triggerWebhook.IInformAnyResourceAction = {
|
|
32
|
-
// object: informObject,
|
|
33
|
-
// recipient: {
|
|
34
|
-
// id: (typeof recipient?.id === 'string') ? recipient.id : '',
|
|
35
|
-
// name: recipient?.name,
|
|
36
|
-
// typeOf: factory.creativeWorkType.WebApplication
|
|
37
|
-
// // url: recipient.url // discontinue(2025-02-13~)
|
|
38
|
-
// },
|
|
39
|
-
// target: {
|
|
40
|
-
// httpMethod: 'POST',
|
|
41
|
-
// encodingType: factory.encodingFormat.Application.json,
|
|
42
|
-
// typeOf: 'EntryPoint',
|
|
43
|
-
// urlTemplate: recipient.url
|
|
44
|
-
// }
|
|
45
|
-
// };
|
|
46
|
-
// triggerWebhookTaskAttributes.push({
|
|
47
|
-
// project: transaction.project,
|
|
48
|
-
// name: factory.taskName.TriggerWebhook,
|
|
49
|
-
// status: factory.taskStatus.Ready,
|
|
50
|
-
// runsAt: taskRunsAt,
|
|
51
|
-
// remainingNumberOfTries: 3,
|
|
52
|
-
// numberOfTried: 0,
|
|
53
|
-
// executionResults: [],
|
|
54
|
-
// data
|
|
55
|
-
// });
|
|
56
|
-
// }
|
|
57
|
-
// });
|
|
58
|
-
const confirmedStoragePeriodInDays = setting?.storage?.transactionConfirmedInDays;
|
|
59
|
-
const canceledStoragePeriodInDays = setting?.storage?.transactionCanceledInDays;
|
|
60
|
-
if (typeof confirmedStoragePeriodInDays !== 'number') {
|
|
61
|
-
throw new factory_1.factory.errors.NotFound('setting.storage.confirmedStoragePeriodInDays');
|
|
62
|
-
}
|
|
63
|
-
if (typeof canceledStoragePeriodInDays !== 'number') {
|
|
64
|
-
throw new factory_1.factory.errors.NotFound('setting.storage.canceledStoragePeriodInDays');
|
|
65
|
-
}
|
|
66
|
-
// 取引削除タスクを作成(取引ステータスによってrunsAtを調整)
|
|
67
|
-
// let deleteAt = moment(transaction.endDate)
|
|
68
|
-
// .add(settings.transaction.confirmedStoragePeriodInDays, 'days')
|
|
69
|
-
// .toDate();
|
|
70
|
-
let deleteAt = (0, moment_1.default)(transaction.endDate)
|
|
71
|
-
.add(confirmedStoragePeriodInDays, 'days')
|
|
72
|
-
.toDate();
|
|
73
|
-
switch (transaction.status) {
|
|
74
|
-
case factory_1.factory.transactionStatusType.Confirmed:
|
|
75
|
-
break;
|
|
76
|
-
case factory_1.factory.transactionStatusType.Canceled:
|
|
77
|
-
case factory_1.factory.transactionStatusType.Expired:
|
|
78
|
-
// deleteAt = moment(transaction.endDate)
|
|
79
|
-
// .add(settings.transaction.canceledStoragePeriodInDays, 'days')
|
|
80
|
-
// .toDate();
|
|
81
|
-
deleteAt = (0, moment_1.default)(transaction.endDate)
|
|
82
|
-
.add(canceledStoragePeriodInDays, 'days')
|
|
83
|
-
.toDate();
|
|
84
|
-
break;
|
|
85
|
-
default:
|
|
86
|
-
}
|
|
87
|
-
const deleteTransactionTask = {
|
|
88
|
-
project: transaction.project,
|
|
89
|
-
name: factory_1.factory.taskName.DeleteTransaction,
|
|
90
|
-
status: factory_1.factory.taskStatus.Ready,
|
|
91
|
-
runsAt: deleteAt,
|
|
92
|
-
remainingNumberOfTries: 3,
|
|
93
|
-
numberOfTried: 0,
|
|
94
|
-
executionResults: [],
|
|
95
|
-
data: {
|
|
96
|
-
object: {
|
|
97
|
-
specifyingMethod: factory_1.factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id,
|
|
98
|
-
id: transaction.id,
|
|
99
|
-
object: {
|
|
100
|
-
...(typeof transaction.object.confirmationNumber === 'string')
|
|
101
|
-
? { confirmationNumber: transaction.object.confirmationNumber }
|
|
102
|
-
: undefined,
|
|
103
|
-
...(typeof transaction.object.orderNumber === 'string')
|
|
104
|
-
? { orderNumber: transaction.object.orderNumber }
|
|
105
|
-
: undefined
|
|
106
|
-
},
|
|
107
|
-
// project: transaction.project,
|
|
108
|
-
// startDate: transaction.startDate,
|
|
109
|
-
typeOf: transaction.typeOf,
|
|
110
|
-
// ...(transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
19
|
// 確定取引にも興行オファー承認中止タスクを追加(2023-05-09~)
|
|
115
20
|
const voidReserveTaskAttributes = {
|
|
116
21
|
project: transaction.project,
|
|
@@ -121,7 +26,6 @@ function createTasks(params, setting) {
|
|
|
121
26
|
numberOfTried: 0,
|
|
122
27
|
executionResults: [],
|
|
123
28
|
data: {
|
|
124
|
-
// project: transaction.project, // discontinue(2025-03-12~)
|
|
125
29
|
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
126
30
|
}
|
|
127
31
|
};
|
|
@@ -135,11 +39,9 @@ function createTasks(params, setting) {
|
|
|
135
39
|
numberOfTried: 0,
|
|
136
40
|
executionResults: [],
|
|
137
41
|
data: {
|
|
138
|
-
// project: transaction.project, // discontinue(2025-03-12~)
|
|
139
42
|
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
140
43
|
}
|
|
141
44
|
};
|
|
142
|
-
taskAttributes.push(deleteTransactionTask);
|
|
143
45
|
switch (transaction.status) {
|
|
144
46
|
case factory_1.factory.transactionStatusType.Confirmed: {
|
|
145
47
|
taskAttributes.push(voidReserveTaskAttributes, voidPaymentTaskAttributes);
|
|
@@ -188,3 +90,53 @@ function createTasks(params, setting) {
|
|
|
188
90
|
}
|
|
189
91
|
return taskAttributes;
|
|
190
92
|
}
|
|
93
|
+
function createScheduledTasks(params, setting) {
|
|
94
|
+
const transaction = params.transaction;
|
|
95
|
+
const confirmedStoragePeriodInDays = setting?.storage?.transactionConfirmedInDays;
|
|
96
|
+
const canceledStoragePeriodInDays = setting?.storage?.transactionCanceledInDays;
|
|
97
|
+
if (typeof confirmedStoragePeriodInDays !== 'number') {
|
|
98
|
+
throw new factory_1.factory.errors.NotFound('setting.storage.confirmedStoragePeriodInDays');
|
|
99
|
+
}
|
|
100
|
+
if (typeof canceledStoragePeriodInDays !== 'number') {
|
|
101
|
+
throw new factory_1.factory.errors.NotFound('setting.storage.canceledStoragePeriodInDays');
|
|
102
|
+
}
|
|
103
|
+
// 取引削除タスクを作成(取引ステータスによってrunsAtを調整)
|
|
104
|
+
let deleteAt = (0, moment_1.default)(transaction.endDate)
|
|
105
|
+
.add(confirmedStoragePeriodInDays, 'days')
|
|
106
|
+
.toDate();
|
|
107
|
+
switch (transaction.status) {
|
|
108
|
+
case factory_1.factory.transactionStatusType.Confirmed:
|
|
109
|
+
break;
|
|
110
|
+
case factory_1.factory.transactionStatusType.Canceled:
|
|
111
|
+
case factory_1.factory.transactionStatusType.Expired:
|
|
112
|
+
deleteAt = (0, moment_1.default)(transaction.endDate)
|
|
113
|
+
.add(canceledStoragePeriodInDays, 'days')
|
|
114
|
+
.toDate();
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
project: transaction.project,
|
|
120
|
+
name: factory_1.factory.taskName.DeleteTransaction,
|
|
121
|
+
status: factory_1.factory.taskStatus.Ready,
|
|
122
|
+
runsAt: deleteAt,
|
|
123
|
+
remainingNumberOfTries: 3,
|
|
124
|
+
numberOfTried: 0,
|
|
125
|
+
executionResults: [],
|
|
126
|
+
data: {
|
|
127
|
+
object: {
|
|
128
|
+
specifyingMethod: factory_1.factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id,
|
|
129
|
+
id: transaction.id,
|
|
130
|
+
object: {
|
|
131
|
+
...(typeof transaction.object.confirmationNumber === 'string')
|
|
132
|
+
? { confirmationNumber: transaction.object.confirmationNumber }
|
|
133
|
+
: undefined,
|
|
134
|
+
...(typeof transaction.object.orderNumber === 'string')
|
|
135
|
+
? { orderNumber: transaction.object.orderNumber }
|
|
136
|
+
: undefined
|
|
137
|
+
},
|
|
138
|
+
typeOf: transaction.typeOf,
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|