@chevre/domain 21.32.0-alpha.9 → 21.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/findCheckAction.ts +37 -0
- package/example/src/chevre/investigateCheckMovieTicketActions.ts +60 -0
- package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +36 -0
- package/example/src/chevre/transaction/acceptCOAOffer.ts +78 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +1 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +11 -5
- package/lib/chevre/errorHandler.d.ts +4 -0
- package/lib/chevre/errorHandler.js +33 -1
- package/lib/chevre/repo/action.d.ts +50 -7
- package/lib/chevre/repo/action.js +111 -11
- package/lib/chevre/repo/aggregation.d.ts +4 -0
- package/lib/chevre/repo/aggregation.js +6 -0
- package/lib/chevre/repo/confirmationNumber.d.ts +1 -1
- package/lib/chevre/repo/confirmationNumber.js +7 -7
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +3 -14
- package/lib/chevre/repo/mongoose/schemas/task.js +2 -12
- package/lib/chevre/repo/task.d.ts +4 -0
- package/lib/chevre/repo/task.js +6 -0
- package/lib/chevre/repository.d.ts +1 -1
- package/lib/chevre/repository.js +1 -1
- package/lib/chevre/service/code.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +1 -3
- package/lib/chevre/service/offer/event/authorize.js +7 -7
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +24 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +35 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.d.ts +9 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +130 -0
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +10 -3
- package/lib/chevre/service/offer/event/voidTransaction.js +77 -92
- package/lib/chevre/service/offer/event/{cancel.d.ts → voidTransactionByActionId.d.ts} +8 -22
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +85 -0
- package/lib/chevre/service/offer/event.d.ts +1 -2
- package/lib/chevre/service/offer/event.js +2 -3
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.d.ts +23 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +258 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.d.ts +15 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.js +20 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +33 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +182 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +1 -3
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +7 -7
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +3 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +5 -1
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +1 -3
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +7 -7
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +41 -0
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +66 -0
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +3 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +6 -1
- package/lib/chevre/service/payment/any.d.ts +8 -0
- package/lib/chevre/service/payment/any.js +36 -9
- package/lib/chevre/service/task/acceptCOAOffer.d.ts +6 -0
- package/lib/chevre/service/task/acceptCOAOffer.js +102 -0
- package/lib/chevre/service/task/authorizePayment.js +2 -0
- package/lib/chevre/service/task/voidReserveTransaction.d.ts +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +34 -13
- package/lib/chevre/service/task.js +2 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +1 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateAuthorizePaymentActions.ts +0 -75
- package/lib/chevre/service/offer/event/cancel.js +0 -57
|
@@ -19,25 +19,46 @@ const reservation_1 = require("../../repo/reservation");
|
|
|
19
19
|
const stockHolder_1 = require("../../repo/stockHolder");
|
|
20
20
|
const task_1 = require("../../repo/task");
|
|
21
21
|
const transaction_1 = require("../../repo/transaction");
|
|
22
|
-
const
|
|
22
|
+
const transactionProcess_1 = require("../../repo/transactionProcess");
|
|
23
|
+
const event_1 = require("../offer/event");
|
|
23
24
|
/**
|
|
24
25
|
* タスク実行関数
|
|
25
26
|
*/
|
|
26
|
-
function call(
|
|
27
|
-
|
|
27
|
+
function call(params) {
|
|
28
|
+
// export function call(data: factory.task.IData<factory.taskName.VoidReserveTransaction>): IOperationExecute<void> {
|
|
29
|
+
return (settings, options) => __awaiter(this, void 0, void 0, function* () {
|
|
28
30
|
if (settings.redisClient === undefined) {
|
|
29
31
|
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const voidByActionId = typeof params.data.id === 'string';
|
|
34
|
+
if (voidByActionId) {
|
|
35
|
+
// 遅延実行(executeByName)には対応しない
|
|
36
|
+
if (!options.executeById) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepository(settings.redisClient, { lockExpiresInSeconds: 120 });
|
|
41
|
+
try {
|
|
42
|
+
yield (0, event_1.voidTransaction)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
|
|
43
|
+
action: new action_1.MongoRepository(settings.connection),
|
|
44
|
+
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
45
|
+
stockHolder: new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection),
|
|
46
|
+
offerRateLimit: new offer_1.RedisRepository(settings.redisClient),
|
|
47
|
+
orderInTransaction: new orderInTransaction_1.MongoRepository(settings.connection),
|
|
48
|
+
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
49
|
+
task: new task_1.MongoRepository(settings.connection),
|
|
50
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
// アクションID指定であれば取引プロセスロック解除(2024-05-26~)
|
|
58
|
+
if (voidByActionId) {
|
|
59
|
+
yield transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
41
62
|
});
|
|
42
63
|
}
|
|
43
64
|
exports.call = call;
|
|
@@ -104,10 +104,12 @@ function execute(task) {
|
|
|
104
104
|
// タスク名の関数が定義されていなければ、TypeErrorとなる
|
|
105
105
|
const { call } = yield Promise.resolve(`${`./task/${task.name}`}`).then(s => require(s));
|
|
106
106
|
switch (task.name) {
|
|
107
|
+
case factory.taskName.AcceptCOAOffer:
|
|
107
108
|
case factory.taskName.AuthorizePayment:
|
|
108
109
|
case factory.taskName.CheckMovieTicket:
|
|
109
110
|
case factory.taskName.PublishPaymentUrl:
|
|
110
111
|
case factory.taskName.Refund:
|
|
112
|
+
case factory.taskName.VoidReserveTransaction:
|
|
111
113
|
yield call(task)(settings, options);
|
|
112
114
|
break;
|
|
113
115
|
default:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
2
2
|
import type { AuthorizationRepo } from '../../../repo/code';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
4
4
|
import type { MongoRepository as EmailMessageRepo } from '../../../repo/emailMessage';
|
|
5
5
|
import type { MessageRepo } from '../../../repo/message';
|
|
6
6
|
import type { MongoRepository as OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
|
|
2
2
|
import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
|
|
3
3
|
import * as factory from '../../../factory';
|
|
4
4
|
/**
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.371.0-alpha.
|
|
14
|
-
"@cinerino/sdk": "
|
|
13
|
+
"@chevre/factory": "4.371.0-alpha.6",
|
|
14
|
+
"@cinerino/sdk": "7.0.0-alpha.10",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.32.0
|
|
113
|
+
"version": "21.32.0"
|
|
114
114
|
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
14
|
-
|
|
15
|
-
const cursor = actionRepo.getCursor(
|
|
16
|
-
{
|
|
17
|
-
typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
|
|
18
|
-
'object.typeOf': { $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
|
|
19
|
-
startDate: {
|
|
20
|
-
$gte: moment()
|
|
21
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
22
|
-
.add(-180, 'days')
|
|
23
|
-
.toDate()
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
typeOf: 1,
|
|
28
|
-
project: 1,
|
|
29
|
-
instrument: 1,
|
|
30
|
-
startDate: 1,
|
|
31
|
-
object: 1
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
console.log('actions found');
|
|
35
|
-
|
|
36
|
-
let i = 0;
|
|
37
|
-
let updateCount = 0;
|
|
38
|
-
await cursor.eachAsync(async (doc) => {
|
|
39
|
-
i += 1;
|
|
40
|
-
const authorizeAction: Pick<
|
|
41
|
-
chevre.factory.action.authorize.paymentMethod.any.IAction,
|
|
42
|
-
'project' | 'typeOf' | 'instrument' | 'startDate' | 'object'
|
|
43
|
-
> = doc.toObject();
|
|
44
|
-
|
|
45
|
-
const alreadyMigrated =
|
|
46
|
-
authorizeAction.instrument.identifier === chevre.factory.action.authorize.paymentMethod.any.ServiceIdentifier.Chevre;
|
|
47
|
-
|
|
48
|
-
if (alreadyMigrated) {
|
|
49
|
-
console.log(
|
|
50
|
-
'already exist.',
|
|
51
|
-
authorizeAction.project.id,
|
|
52
|
-
authorizeAction.object.typeOf, authorizeAction.object.paymentMethodId, authorizeAction.startDate, i, updateCount
|
|
53
|
-
);
|
|
54
|
-
} else {
|
|
55
|
-
console.log(
|
|
56
|
-
'updating...',
|
|
57
|
-
authorizeAction.project.id,
|
|
58
|
-
authorizeAction.object.typeOf, authorizeAction.object.paymentMethodId, authorizeAction.startDate, i, updateCount
|
|
59
|
-
);
|
|
60
|
-
updateCount += 1;
|
|
61
|
-
console.log(
|
|
62
|
-
'updated.',
|
|
63
|
-
authorizeAction.project.id,
|
|
64
|
-
authorizeAction.object.typeOf, authorizeAction.object.paymentMethodId, authorizeAction.startDate, i, updateCount
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
console.log(i, 'actions checked');
|
|
70
|
-
console.log(updateCount, 'actions updated');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
main()
|
|
74
|
-
.then()
|
|
75
|
-
.catch(console.error);
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.cancel = void 0;
|
|
13
|
-
const factory = require("../../../factory");
|
|
14
|
-
const ReserveTransactionService = require("../../assetTransaction/reserve");
|
|
15
|
-
const any_1 = require("../any");
|
|
16
|
-
/**
|
|
17
|
-
* 興行オファー承認取消(apiから実行)
|
|
18
|
-
* 特定の承認アクションについて処理する
|
|
19
|
-
*/
|
|
20
|
-
function cancel(params) {
|
|
21
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
var _a;
|
|
23
|
-
const transaction = yield repos.transaction.findInProgressById({
|
|
24
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
25
|
-
id: params.transaction.id
|
|
26
|
-
});
|
|
27
|
-
if (transaction.agent.id !== params.agent.id) {
|
|
28
|
-
throw new factory.errors.Forbidden('Transaction not yours');
|
|
29
|
-
}
|
|
30
|
-
// MongoDBでcompleteステータスであるにも関わらず、Chevreでは削除されている、というのが最悪の状況
|
|
31
|
-
// それだけは回避するためにMongoDBを先に変更
|
|
32
|
-
yield repos.action.cancelWithVoid({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
33
|
-
const action = yield repos.action.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
34
|
-
switch (action.instrument.identifier) {
|
|
35
|
-
case factory.service.webAPI.Identifier.COA:
|
|
36
|
-
// 実質使用する予定なしなので廃止(2022-05-12~)
|
|
37
|
-
throw new factory.errors.NotImplemented(`booking service '${action.instrument.identifier}' not implemented`);
|
|
38
|
-
default:
|
|
39
|
-
// add orderInTransaction(2024-01-15~)
|
|
40
|
-
// USE_CREATE_ORDER_ON_OFFER_ACCEPTEDの場合、orderNumber発行済のはず
|
|
41
|
-
const orderNumberByTransaction = transaction.object.orderNumber;
|
|
42
|
-
if (typeof orderNumberByTransaction === 'string') {
|
|
43
|
-
yield (0, any_1.voidAcceptedOffer)({
|
|
44
|
-
// authorizeActions: [action],
|
|
45
|
-
authorizeActionsWithInstrument: [action],
|
|
46
|
-
orderNumber: orderNumberByTransaction
|
|
47
|
-
})(repos);
|
|
48
|
-
}
|
|
49
|
-
const transactionNumber = (_a = action.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.transactionNumber;
|
|
50
|
-
if (typeof transactionNumber === 'string') {
|
|
51
|
-
// すでに取消済であったとしても、すべて取消処理(actionStatusに関係なく)
|
|
52
|
-
yield ReserveTransactionService.cancel({ transactionNumber })(repos);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
exports.cancel = cancel;
|