@chevre/domain 25.2.0-alpha.50 → 25.2.0-alpha.52
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/asyncAction.d.ts +6 -1
- package/lib/chevre/repo/asyncAction.js +59 -0
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +4 -0
- package/lib/chevre/service/payment/any/findAcceptAction.js +22 -9
- package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +4 -0
- package/lib/chevre/service/payment/any/findAuthorizeAction.js +22 -9
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
1
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import { factory } from '../factory';
|
|
3
3
|
import { IModel, IDocType } from './mongoose/schemas/asyncAction';
|
|
4
4
|
import type { IExecutableTask } from '../taskSettings';
|
|
@@ -7,12 +7,17 @@ type ISavingTask = Pick<factory.task.IAttributes<factory.taskName>, 'data' | 'ex
|
|
|
7
7
|
};
|
|
8
8
|
export type IExecutableAsyncAction = Pick<IExecutableTask<factory.taskName>, 'data' | 'expires' | 'id' | 'name' | 'project' | 'runsAt' | 'status'>;
|
|
9
9
|
type IKeyOfProjection = keyof factory.task.ITask<factory.taskName>;
|
|
10
|
+
type IFindParams = Pick<factory.task.ISearchConditions, 'id' | 'name' | 'project' | 'runsFrom' | 'runsThrough' | 'status' | 'limit' | 'page' | 'sort'>;
|
|
10
11
|
/**
|
|
11
12
|
* 非同期アクションリポジトリ
|
|
12
13
|
*/
|
|
13
14
|
export declare class AsyncActionRepo {
|
|
14
15
|
readonly asyncActionModel: IModel;
|
|
15
16
|
constructor(connection: Connection);
|
|
17
|
+
static CREATE_MONGO_CONDITIONS(params: Pick<IFindParams, 'id' | 'name' | 'project' | 'runsFrom' | 'runsThrough' | 'status'>): FilterQuery<import("@chevre/factory/lib/chevre/task").ITask | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/createAccountingReport").ITask | import("@chevre/factory/lib/chevre/task/deleteTransaction").ITask | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/chevre/task/onEventChanged").ITask | import("@chevre/factory/lib/chevre/task/onResourceDeleted").ITask | import("@chevre/factory/lib/chevre/task/onResourceUpdated").ITask | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/chevre/task/placeOrder").ITask | import("@chevre/factory/lib/chevre/task/returnOrder").ITask | import("@chevre/factory/lib/chevre/task/returnPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/sendEmailMessage").ITask | import("@chevre/factory/lib/chevre/task/sendOrder").ITask | import("@chevre/factory/lib/chevre/task/triggerWebhook").ITask | import("@chevre/factory/lib/chevre/task/useReservation").ITask | import("@chevre/factory/lib/chevre/task/voidPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/voidReserveTransaction").ITask>[];
|
|
18
|
+
findAsyncActions(params: IFindParams, inclusion: IKeyOfProjection[]): Promise<(IDocType & {
|
|
19
|
+
id: string;
|
|
20
|
+
})[]>;
|
|
16
21
|
/**
|
|
17
22
|
* Readyタスクをひとつ追加する
|
|
18
23
|
*/
|
|
@@ -35,6 +35,65 @@ class AsyncActionRepo {
|
|
|
35
35
|
constructor(connection) {
|
|
36
36
|
this.asyncActionModel = connection.model(asyncAction_1.modelName, (0, asyncAction_1.createSchema)());
|
|
37
37
|
}
|
|
38
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
39
|
+
const andConditions = [];
|
|
40
|
+
const idEq = params.id?.$eq;
|
|
41
|
+
if (typeof idEq === 'string') {
|
|
42
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
43
|
+
}
|
|
44
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
45
|
+
if (typeof projectIdEq === 'string') {
|
|
46
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
47
|
+
}
|
|
48
|
+
if (typeof params.name === 'string') {
|
|
49
|
+
andConditions.push({ name: { $eq: params.name } });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const nameIn = params.name?.$in;
|
|
53
|
+
if (Array.isArray(nameIn)) {
|
|
54
|
+
andConditions.push({ name: { $in: nameIn } });
|
|
55
|
+
}
|
|
56
|
+
const nameNin = params.name?.$nin;
|
|
57
|
+
if (Array.isArray(nameNin)) {
|
|
58
|
+
andConditions.push({ name: { $nin: nameNin } });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const statusEq = params.status?.$eq;
|
|
62
|
+
if (typeof statusEq === 'string') {
|
|
63
|
+
andConditions.push({ status: { $eq: statusEq } });
|
|
64
|
+
}
|
|
65
|
+
if (params.runsFrom instanceof Date) {
|
|
66
|
+
andConditions.push({ runsAt: { $gte: params.runsFrom } });
|
|
67
|
+
}
|
|
68
|
+
if (params.runsThrough instanceof Date) {
|
|
69
|
+
andConditions.push({ runsAt: { $lte: params.runsThrough } });
|
|
70
|
+
}
|
|
71
|
+
return andConditions;
|
|
72
|
+
}
|
|
73
|
+
async findAsyncActions(params, inclusion) {
|
|
74
|
+
const conditions = AsyncActionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
75
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
76
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
77
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
78
|
+
}
|
|
79
|
+
const projection = {
|
|
80
|
+
_id: 0,
|
|
81
|
+
id: { $toString: '$_id' },
|
|
82
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
83
|
+
};
|
|
84
|
+
const query = this.asyncActionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
85
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
86
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
87
|
+
query.limit(params.limit)
|
|
88
|
+
.skip(params.limit * (page - 1));
|
|
89
|
+
}
|
|
90
|
+
if (params.sort?.runsAt !== undefined) {
|
|
91
|
+
query.sort({ runsAt: params.sort.runsAt });
|
|
92
|
+
}
|
|
93
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
94
|
+
.lean()
|
|
95
|
+
.exec();
|
|
96
|
+
}
|
|
38
97
|
/**
|
|
39
98
|
* Readyタスクをひとつ追加する
|
|
40
99
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { factory } from '../../../factory';
|
|
2
2
|
import type { AcceptPayActionRepo } from '../../../repo/action/acceptPay';
|
|
3
|
+
import type { AsyncActionRepo } from '../../../repo/asyncAction';
|
|
3
4
|
import type { TaskRepo } from '../../../repo/task';
|
|
4
5
|
interface IFindAcceptActionResult {
|
|
5
6
|
/**
|
|
@@ -38,8 +39,11 @@ declare function findAcceptAction(params: {
|
|
|
38
39
|
*/
|
|
39
40
|
id: string;
|
|
40
41
|
};
|
|
42
|
+
}, options: {
|
|
43
|
+
useAsyncAction: boolean;
|
|
41
44
|
}): (repos: {
|
|
42
45
|
acceptPayAction: AcceptPayActionRepo;
|
|
46
|
+
asyncAction: AsyncActionRepo;
|
|
43
47
|
task: TaskRepo;
|
|
44
48
|
}) => Promise<IFindAcceptActionResult>;
|
|
45
49
|
export { findAcceptAction, };
|
|
@@ -2,16 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findAcceptAction = findAcceptAction;
|
|
4
4
|
const factory_1 = require("../../../factory");
|
|
5
|
-
function findAcceptAction(params) {
|
|
5
|
+
function findAcceptAction(params, options) {
|
|
6
6
|
return async (repos) => {
|
|
7
|
-
//
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
// 非同期アクションに対応(2026-07-28~)
|
|
8
|
+
const { useAsyncAction } = options;
|
|
9
|
+
let task;
|
|
10
|
+
if (useAsyncAction) {
|
|
11
|
+
// まず非同期アクションを参照
|
|
12
|
+
task = await repos.asyncAction.findAsyncActionById({
|
|
13
|
+
id: { $eq: params.sameAs.id },
|
|
14
|
+
project: { id: { $eq: params.project.id } },
|
|
15
|
+
name: factory_1.factory.taskName.PublishPaymentUrl
|
|
16
|
+
}, ['status', 'executionResults']);
|
|
17
|
+
}
|
|
18
|
+
// 非同期アクションが存在しなければタスクを参照
|
|
19
|
+
if (task === undefined) {
|
|
20
|
+
task = (await repos.task.projectFields({
|
|
21
|
+
limit: 1,
|
|
22
|
+
page: 1,
|
|
23
|
+
id: { $eq: params.sameAs.id },
|
|
24
|
+
project: { id: { $eq: params.project.id } },
|
|
25
|
+
name: factory_1.factory.taskName.PublishPaymentUrl
|
|
26
|
+
}, ['status', 'executionResults'])).shift();
|
|
27
|
+
}
|
|
15
28
|
if (task === undefined) {
|
|
16
29
|
throw new factory_1.factory.errors.NotFound(factory_1.factory.taskName.PublishPaymentUrl);
|
|
17
30
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { factory } from '../../../factory';
|
|
2
2
|
import type { AuthorizePaymentMethodActionRepo } from '../../../repo/action/authorizePaymentMethod';
|
|
3
|
+
import type { AsyncActionRepo } from '../../../repo/asyncAction';
|
|
3
4
|
import type { TaskRepo } from '../../../repo/task';
|
|
4
5
|
interface IFindAuthorizeActionResult {
|
|
5
6
|
/**
|
|
@@ -20,6 +21,7 @@ interface IFindAuthorizeActionResult {
|
|
|
20
21
|
}
|
|
21
22
|
interface IFindAuthorizeActionRepos {
|
|
22
23
|
authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
|
|
24
|
+
asyncAction: AsyncActionRepo;
|
|
23
25
|
task: TaskRepo;
|
|
24
26
|
}
|
|
25
27
|
declare function findAuthorizeAction(params: {
|
|
@@ -38,5 +40,7 @@ declare function findAuthorizeAction(params: {
|
|
|
38
40
|
*/
|
|
39
41
|
id: string;
|
|
40
42
|
};
|
|
43
|
+
}, options: {
|
|
44
|
+
useAsyncAction: boolean;
|
|
41
45
|
}): (repos: IFindAuthorizeActionRepos) => Promise<IFindAuthorizeActionResult>;
|
|
42
46
|
export { IFindAuthorizeActionRepos, findAuthorizeAction, };
|
|
@@ -2,16 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findAuthorizeAction = findAuthorizeAction;
|
|
4
4
|
const factory_1 = require("../../../factory");
|
|
5
|
-
function findAuthorizeAction(params) {
|
|
5
|
+
function findAuthorizeAction(params, options) {
|
|
6
6
|
return async (repos) => {
|
|
7
|
-
//
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
// 非同期アクションに対応(2026-07-28~)
|
|
8
|
+
const { useAsyncAction } = options;
|
|
9
|
+
let task;
|
|
10
|
+
if (useAsyncAction) {
|
|
11
|
+
// まず非同期アクションを参照
|
|
12
|
+
task = await repos.asyncAction.findAsyncActionById({
|
|
13
|
+
id: { $eq: params.sameAs.id },
|
|
14
|
+
project: { id: { $eq: params.project.id } },
|
|
15
|
+
name: factory_1.factory.taskName.AuthorizePayment
|
|
16
|
+
}, ['status', 'executionResults']);
|
|
17
|
+
}
|
|
18
|
+
// 非同期アクションが存在しなければタスクを参照
|
|
19
|
+
if (task === undefined) {
|
|
20
|
+
task = (await repos.task.projectFields({
|
|
21
|
+
limit: 1,
|
|
22
|
+
page: 1,
|
|
23
|
+
id: { $eq: params.sameAs.id },
|
|
24
|
+
project: { id: { $eq: params.project.id } },
|
|
25
|
+
name: factory_1.factory.taskName.AuthorizePayment
|
|
26
|
+
}, ['status', 'executionResults'])).shift();
|
|
27
|
+
}
|
|
15
28
|
if (task === undefined) {
|
|
16
29
|
throw new factory_1.factory.errors.NotFound(factory_1.factory.taskName.AuthorizePayment);
|
|
17
30
|
}
|
package/package.json
CHANGED