@chevre/domain 21.32.0-alpha.1 → 21.32.0-alpha.3
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/findAuthorizePaymentAction.ts +34 -0
- package/lib/chevre/repo/action.d.ts +1 -1
- package/lib/chevre/repo/action.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -12
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repo/task.js +7 -1
- package/lib/chevre/service/payment/any.d.ts +38 -1
- package/lib/chevre/service/payment/any.js +54 -1
- package/lib/chevre/service/payment/movieTicket.js +6 -3
- package/lib/chevre/service/task/checkMovieTicket.d.ts +6 -0
- package/lib/chevre/service/task/checkMovieTicket.js +61 -0
- package/lib/chevre/service/task.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const result = await (await chevre.service.payment.any.createService()).findAuthorizeAction({
|
|
15
|
+
project: {
|
|
16
|
+
id: project.id
|
|
17
|
+
},
|
|
18
|
+
sameAs: {
|
|
19
|
+
id: '6649277cd22032e3e7b6d0fa'
|
|
20
|
+
},
|
|
21
|
+
purpose: {
|
|
22
|
+
id: '66492757d22032e3e7b6d013'
|
|
23
|
+
// id: '66492757d22032e3e7b63'
|
|
24
|
+
}
|
|
25
|
+
})({
|
|
26
|
+
action: actionRepo,
|
|
27
|
+
task: taskRepo
|
|
28
|
+
});
|
|
29
|
+
console.log('result:', result);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
main()
|
|
33
|
+
.then(console.log)
|
|
34
|
+
.catch(console.error);
|
|
@@ -174,7 +174,7 @@ export declare class MongoRepository {
|
|
|
174
174
|
$eq: string;
|
|
175
175
|
};
|
|
176
176
|
};
|
|
177
|
-
}): Promise<Pick<IAction<factory.actionType>, 'id' | 'actionStatus' | 'error'>[]>;
|
|
177
|
+
}): Promise<Pick<IAction<factory.actionType>, 'id' | 'actionStatus' | 'error' | 'purpose'>[]>;
|
|
178
178
|
deleteByProject(params: {
|
|
179
179
|
project: {
|
|
180
180
|
id: string;
|
|
@@ -684,7 +684,7 @@ class MongoRepository {
|
|
|
684
684
|
const query = this.actionModel.find(Object.assign({ 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq } }, (typeof ((_a = params.purpose) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
|
|
685
685
|
? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
|
|
686
686
|
: undefined))
|
|
687
|
-
.select({ _id: 1, actionStatus: 1, error: 1 })
|
|
687
|
+
.select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
|
|
688
688
|
.limit(1);
|
|
689
689
|
return query.exec()
|
|
690
690
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
@@ -38,10 +38,8 @@ const schemaOptions = {
|
|
|
38
38
|
writeConcern: writeConcern_1.writeConcern,
|
|
39
39
|
strict: true,
|
|
40
40
|
strictQuery: false,
|
|
41
|
-
timestamps:
|
|
42
|
-
|
|
43
|
-
updatedAt: 'updatedAt'
|
|
44
|
-
},
|
|
41
|
+
timestamps: false,
|
|
42
|
+
versionKey: false,
|
|
45
43
|
toJSON: {
|
|
46
44
|
getters: false,
|
|
47
45
|
virtuals: false,
|
|
@@ -56,14 +54,6 @@ const schemaOptions = {
|
|
|
56
54
|
}
|
|
57
55
|
};
|
|
58
56
|
const indexes = [
|
|
59
|
-
[
|
|
60
|
-
{ createdAt: 1 },
|
|
61
|
-
{ name: 'searchByCreatedAt' }
|
|
62
|
-
],
|
|
63
|
-
[
|
|
64
|
-
{ updatedAt: 1 },
|
|
65
|
-
{ name: 'searchByUpdatedAt' }
|
|
66
|
-
],
|
|
67
57
|
[
|
|
68
58
|
{ 'project.id': 1, startDate: -1 },
|
|
69
59
|
{
|
|
@@ -49,7 +49,7 @@ export type IExecutableTask<T extends factory.taskName> = Pick<factory.task.ITas
|
|
|
49
49
|
type IDelayedTask = Pick<factory.task.ITask<factory.taskName>, 'id' | 'name' | 'status'>;
|
|
50
50
|
type IKeyOfProjection = keyof factory.task.ITask<factory.taskName> | '_id';
|
|
51
51
|
type IProjection = {
|
|
52
|
-
[key in IKeyOfProjection]?: 0;
|
|
52
|
+
[key in IKeyOfProjection]?: 0 | 1;
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
55
|
* タスクリポジトリ
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -577,7 +577,13 @@ class MongoRepository {
|
|
|
577
577
|
var _a;
|
|
578
578
|
return __awaiter(this, void 0, void 0, function* () {
|
|
579
579
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
580
|
-
const
|
|
580
|
+
const positiveProjectionExists = (projection !== undefined && projection !== null)
|
|
581
|
+
? Object.values(projection)
|
|
582
|
+
.some((value) => value !== 0)
|
|
583
|
+
: false;
|
|
584
|
+
const query = this.taskModel.find((conditions.length > 0) ? { $and: conditions } : {}, (positiveProjectionExists)
|
|
585
|
+
? projection
|
|
586
|
+
: Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
|
|
581
587
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
582
588
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
583
589
|
query.limit(params.limit)
|
|
@@ -132,4 +132,41 @@ declare function authorize(params: {
|
|
|
132
132
|
*/
|
|
133
133
|
id: string;
|
|
134
134
|
}>;
|
|
135
|
-
|
|
135
|
+
interface IFindAuthorizeActionResult {
|
|
136
|
+
/**
|
|
137
|
+
* アクションID
|
|
138
|
+
*/
|
|
139
|
+
id?: string;
|
|
140
|
+
/**
|
|
141
|
+
* アクションスタータス
|
|
142
|
+
*/
|
|
143
|
+
actionStatus: factory.actionStatusType;
|
|
144
|
+
/**
|
|
145
|
+
* エラー
|
|
146
|
+
*/
|
|
147
|
+
error?: {
|
|
148
|
+
name?: string;
|
|
149
|
+
message?: string;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
declare function findAuthorizeAction(params: {
|
|
153
|
+
project: {
|
|
154
|
+
id: string;
|
|
155
|
+
};
|
|
156
|
+
sameAs: {
|
|
157
|
+
/**
|
|
158
|
+
* task ID
|
|
159
|
+
*/
|
|
160
|
+
id: string;
|
|
161
|
+
};
|
|
162
|
+
purpose: {
|
|
163
|
+
/**
|
|
164
|
+
* transaction ID
|
|
165
|
+
*/
|
|
166
|
+
id: string;
|
|
167
|
+
};
|
|
168
|
+
}): (repos: {
|
|
169
|
+
action: ActionRepo;
|
|
170
|
+
task: TaskRepo;
|
|
171
|
+
}) => Promise<IFindAuthorizeActionResult>;
|
|
172
|
+
export { onPaymentStatusChanged, authorize, findAuthorizeAction, invalidatePaymentUrl, voidPayTransaction, person2username, processVoidPayTransaction, publishPaymentUrl };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.publishPaymentUrl = exports.processVoidPayTransaction = exports.person2username = exports.voidPayTransaction = exports.invalidatePaymentUrl = exports.authorize = exports.onPaymentStatusChanged = void 0;
|
|
12
|
+
exports.publishPaymentUrl = exports.processVoidPayTransaction = exports.person2username = exports.voidPayTransaction = exports.invalidatePaymentUrl = exports.findAuthorizeAction = exports.authorize = exports.onPaymentStatusChanged = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* 汎用決済サービス
|
|
15
15
|
*/
|
|
@@ -464,3 +464,56 @@ function fixAccountIdIfPossible(params) {
|
|
|
464
464
|
return { accountId };
|
|
465
465
|
});
|
|
466
466
|
}
|
|
467
|
+
function findAuthorizeAction(params) {
|
|
468
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
469
|
+
var _a, _b;
|
|
470
|
+
// タスク検索
|
|
471
|
+
const task = (yield repos.task.search({
|
|
472
|
+
limit: 1,
|
|
473
|
+
page: 1,
|
|
474
|
+
id: { $eq: params.sameAs.id },
|
|
475
|
+
project: { id: { $eq: params.project.id } },
|
|
476
|
+
name: factory.taskName.AuthorizePayment
|
|
477
|
+
}, {
|
|
478
|
+
status: 1,
|
|
479
|
+
executionResults: 1
|
|
480
|
+
})).shift();
|
|
481
|
+
if (task === undefined) {
|
|
482
|
+
throw new factory.errors.NotFound(factory.taskName.AuthorizePayment);
|
|
483
|
+
}
|
|
484
|
+
const errorByTask = (_a = task.executionResults.shift()) === null || _a === void 0 ? void 0 : _a.error;
|
|
485
|
+
let defaultActionError;
|
|
486
|
+
if (typeof errorByTask === 'string') {
|
|
487
|
+
defaultActionError = { message: errorByTask };
|
|
488
|
+
}
|
|
489
|
+
else if (typeof (errorByTask === null || errorByTask === void 0 ? void 0 : errorByTask.message) === 'string') {
|
|
490
|
+
defaultActionError = { message: errorByTask.message, name: errorByTask.name };
|
|
491
|
+
}
|
|
492
|
+
let action = Object.assign({ actionStatus: factory.actionStatusType.PotentialActionStatus }, (defaultActionError !== undefined) ? { error: defaultActionError } : undefined);
|
|
493
|
+
switch (task.status) {
|
|
494
|
+
case factory.taskStatus.Ready:
|
|
495
|
+
break;
|
|
496
|
+
default:
|
|
497
|
+
// タスクがReadyでなければアクション検索
|
|
498
|
+
const authorizeAction = (yield repos.action.searchBySameAs({
|
|
499
|
+
sameAs: { id: { $eq: task.id } }
|
|
500
|
+
// purpose: { id: { $eq: String(params.purpose.id) } }
|
|
501
|
+
})).shift();
|
|
502
|
+
if (authorizeAction !== undefined) {
|
|
503
|
+
// purpose検証
|
|
504
|
+
if (((_b = authorizeAction.purpose) === null || _b === void 0 ? void 0 : _b.id) !== params.purpose.id) {
|
|
505
|
+
throw new factory.errors.NotFound('Action');
|
|
506
|
+
}
|
|
507
|
+
action = Object.assign({ id: authorizeAction.id, actionStatus: authorizeAction.actionStatus }, (authorizeAction.error !== undefined)
|
|
508
|
+
? {
|
|
509
|
+
error: (Array.isArray(authorizeAction.error))
|
|
510
|
+
? authorizeAction.error[0]
|
|
511
|
+
: authorizeAction.error
|
|
512
|
+
}
|
|
513
|
+
: undefined);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return action;
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
exports.findAuthorizeAction = findAuthorizeAction;
|
|
@@ -37,7 +37,7 @@ var MovieticketReserveRequestErrorMessage;
|
|
|
37
37
|
function checkMovieTicket(params) {
|
|
38
38
|
// tslint:disable-next-line:max-func-body-length
|
|
39
39
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
var _a, _b, _c, _d, _e;
|
|
40
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41
41
|
// 不要な属性がリクエストに含まれているのでmovieTicketsを最適化(2024-03-15~)
|
|
42
42
|
let movieTickets = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.movieTickets;
|
|
43
43
|
if (!Array.isArray(movieTickets)) {
|
|
@@ -62,7 +62,10 @@ function checkMovieTicket(params) {
|
|
|
62
62
|
});
|
|
63
63
|
const paymentMethodType = (_b = optimizedCheckObject[0]) === null || _b === void 0 ? void 0 : _b.paymentMethod.typeOf; // 決済方法区分
|
|
64
64
|
const paymentServiceId = (_c = optimizedCheckObject[0]) === null || _c === void 0 ? void 0 : _c.id;
|
|
65
|
-
const
|
|
65
|
+
const taskId = (_d = params.sameAs) === null || _d === void 0 ? void 0 : _d.id;
|
|
66
|
+
const actionAttributes = Object.assign(Object.assign({ project: params.project, typeOf: factory.actionType.CheckAction, agent: params.agent, object: optimizedCheckObject }, (typeof ((_e = params.purpose) === null || _e === void 0 ? void 0 : _e.typeOf) === 'string') ? { purpose: params.purpose } : undefined), (typeof taskId === 'string')
|
|
67
|
+
? { sameAs: { id: taskId, typeOf: 'Task' } } // タスク関連付け(2024-05-21~)
|
|
68
|
+
: undefined);
|
|
66
69
|
const action = yield repos.action.start(actionAttributes);
|
|
67
70
|
let checkResult;
|
|
68
71
|
try {
|
|
@@ -77,7 +80,7 @@ function checkMovieTicket(params) {
|
|
|
77
80
|
let screeningEvent;
|
|
78
81
|
// イベント取得属性最適化(2023-01-23~)
|
|
79
82
|
screeningEvent = yield repos.event.findMinimizedIndividualEventById({ id: eventIds[0] });
|
|
80
|
-
const sellerId = (
|
|
83
|
+
const sellerId = (_f = optimizedCheckObject[0]) === null || _f === void 0 ? void 0 : _f.seller.id;
|
|
81
84
|
const paymentAccepted = yield repos.paymentAccepted.isAcceptedBySeller({
|
|
82
85
|
seller: { id: sellerId },
|
|
83
86
|
codeValue: paymentMethodType
|
|
@@ -0,0 +1,61 @@
|
|
|
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.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const action_1 = require("../../repo/action");
|
|
15
|
+
const event_1 = require("../../repo/event");
|
|
16
|
+
const paymentService_1 = require("../../repo/paymentService");
|
|
17
|
+
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
18
|
+
const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
|
|
19
|
+
const pay_1 = require("../assetTransaction/pay");
|
|
20
|
+
/**
|
|
21
|
+
* タスク実行関数
|
|
22
|
+
*/
|
|
23
|
+
function call(params) {
|
|
24
|
+
return (settings, options) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
var _a;
|
|
26
|
+
if (settings.redisClient === undefined) {
|
|
27
|
+
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
28
|
+
}
|
|
29
|
+
// 遅延実行(executeByName)には対応しない
|
|
30
|
+
if (!options.executeById) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
34
|
+
try {
|
|
35
|
+
yield (0, pay_1.check)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id, typeOf: 'Task' } }))({
|
|
36
|
+
action: actionRepo,
|
|
37
|
+
event: new event_1.MongoRepository(settings.connection),
|
|
38
|
+
paymentAccepted: new sellerPaymentAccepted_1.MongoRepository(settings.connection),
|
|
39
|
+
paymentService: new paymentService_1.MongoRepository(settings.connection),
|
|
40
|
+
paymentServiceProvider: new paymentServiceProvider_1.MongoRepository(settings.connection)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
let throwsError = true;
|
|
45
|
+
// アクションが存在すればタスクを実行済扱いにする
|
|
46
|
+
const action = (yield actionRepo.searchBySameAs(Object.assign({ sameAs: { id: { $eq: params.id } } }, (typeof ((_a = params.data.purpose) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
47
|
+
? { purpose: { id: { $eq: params.data.purpose.id } } }
|
|
48
|
+
: undefined))).shift();
|
|
49
|
+
if (typeof (action === null || action === void 0 ? void 0 : action.id) === 'string') {
|
|
50
|
+
throwsError = false;
|
|
51
|
+
}
|
|
52
|
+
if (throwsError) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
// no op
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
exports.call = call;
|
|
@@ -105,6 +105,7 @@ function execute(task) {
|
|
|
105
105
|
const { call } = yield Promise.resolve(`${`./task/${task.name}`}`).then(s => require(s));
|
|
106
106
|
switch (task.name) {
|
|
107
107
|
case factory.taskName.AuthorizePayment:
|
|
108
|
+
case factory.taskName.CheckMovieTicket:
|
|
108
109
|
case factory.taskName.Refund:
|
|
109
110
|
yield call(task)(settings, options);
|
|
110
111
|
break;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
13
|
+
"@chevre/factory": "4.371.0-alpha.0",
|
|
14
14
|
"@cinerino/sdk": "6.1.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.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-alpha.
|
|
113
|
+
"version": "21.32.0-alpha.3"
|
|
114
114
|
}
|