@chevre/domain 21.32.0 → 21.33.0-alpha.1
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/searchAggregations.ts +45 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +1 -0
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +24 -2
- package/lib/chevre/service/task/acceptCOAOffer.d.ts +2 -2
- package/lib/chevre/service/task/authorizePayment.d.ts +2 -2
- package/lib/chevre/service/task/authorizePayment.js +11 -1
- package/lib/chevre/service/task/checkMovieTicket.d.ts +2 -2
- package/lib/chevre/service/task/publishPaymentUrl.d.ts +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.d.ts +2 -2
- package/lib/chevre/service/task.d.ts +2 -1
- package/lib/chevre/service/task.js +5 -4
- package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import { chevre } from '../../../lib/index';
|
|
3
|
+
|
|
4
|
+
import * as moment from 'moment';
|
|
5
|
+
import * as mongoose from 'mongoose';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
mongoose.Model.on('index', (...args) => {
|
|
10
|
+
console.error('******** index event emitted. ********\n', args);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
async function main() {
|
|
14
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
|
+
|
|
16
|
+
const now = new Date();
|
|
17
|
+
const limit = 100;
|
|
18
|
+
const page = 1;
|
|
19
|
+
const aggregationRepo = await chevre.repository.Aggregation.createInstance(mongoose.connection);
|
|
20
|
+
const aggregations = await aggregationRepo.aggregationModel.find(
|
|
21
|
+
{
|
|
22
|
+
typeOf: { $eq: 'AggregateAuthorizeEventServiceOfferAction' },
|
|
23
|
+
aggregateDuration: { $eq: 'P1D' },
|
|
24
|
+
aggregateStart: {
|
|
25
|
+
$gte: moment(now)
|
|
26
|
+
.add(-1, 'months')
|
|
27
|
+
.toDate(),
|
|
28
|
+
$lte: now
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
.limit(limit)
|
|
33
|
+
.skip(limit * (page - 1))
|
|
34
|
+
.sort({ aggregateStart: chevre.factory.sortType.Ascending })
|
|
35
|
+
.exec();
|
|
36
|
+
|
|
37
|
+
// console.log('aggregations:', aggregations);
|
|
38
|
+
console.log(aggregations.length, 'aggregations found');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main()
|
|
42
|
+
.then(() => {
|
|
43
|
+
console.log('success!');
|
|
44
|
+
})
|
|
45
|
+
.catch(console.error);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
|
|
2
2
|
declare const modelName = "Aggregation";
|
|
3
|
-
declare function createSchema(): Schema;
|
|
4
3
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
4
|
+
declare function createSchema(): Schema;
|
|
5
5
|
export { modelName, indexes, createSchema };
|
|
@@ -31,6 +31,25 @@ const schemaOptions = {
|
|
|
31
31
|
versionKey: false
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
+
const indexes = [
|
|
35
|
+
[
|
|
36
|
+
{ aggregateStart: 1 },
|
|
37
|
+
{ name: 'searchByAggregateStart' }
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
{ typeOf: 1, aggregateStart: 1 },
|
|
41
|
+
{ name: 'searchByTypeOf' }
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
{ 'project.id': 1, aggregateStart: 1 },
|
|
45
|
+
{ name: 'searchByProjectId' }
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
{ aggregateDuration: 1, aggregateStart: 1 },
|
|
49
|
+
{ name: 'searchByAggregateDuration' }
|
|
50
|
+
]
|
|
51
|
+
];
|
|
52
|
+
exports.indexes = indexes;
|
|
34
53
|
/**
|
|
35
54
|
* 集計スキーマ
|
|
36
55
|
*/
|
|
@@ -38,9 +57,12 @@ let schema;
|
|
|
38
57
|
function createSchema() {
|
|
39
58
|
if (schema === undefined) {
|
|
40
59
|
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
60
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
61
|
+
indexes.forEach((indexParams) => {
|
|
62
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
41
65
|
}
|
|
42
66
|
return schema;
|
|
43
67
|
}
|
|
44
68
|
exports.createSchema = createSchema;
|
|
45
|
-
const indexes = [];
|
|
46
|
-
exports.indexes = indexes;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
1
|
+
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(params: Pick<factory.task.acceptCOAOffer.ITask, IExecutableTaskKeys>): IOperationExecute<
|
|
6
|
+
export declare function call(params: Pick<factory.task.acceptCOAOffer.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
1
|
+
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(params: Pick<factory.task.authorizePayment.ITask, IExecutableTaskKeys>): IOperationExecute<
|
|
6
|
+
export declare function call(params: Pick<factory.task.authorizePayment.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -39,6 +39,7 @@ function call(params) {
|
|
|
39
39
|
if (!options.executeById) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
+
let callResult;
|
|
42
43
|
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
43
44
|
const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepository(settings.redisClient, { lockExpiresInSeconds: 120 });
|
|
44
45
|
try {
|
|
@@ -72,7 +73,13 @@ function call(params) {
|
|
|
72
73
|
throwsError = false;
|
|
73
74
|
}
|
|
74
75
|
if (throwsError) {
|
|
75
|
-
|
|
76
|
+
if (error instanceof Error) {
|
|
77
|
+
// throwせずにcallResultとして返す(2024-05-29~)
|
|
78
|
+
callResult = { error };
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
85
|
finally {
|
|
@@ -81,6 +88,9 @@ function call(params) {
|
|
|
81
88
|
yield transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
|
|
82
89
|
}
|
|
83
90
|
}
|
|
91
|
+
if (callResult !== undefined) {
|
|
92
|
+
return callResult;
|
|
93
|
+
}
|
|
84
94
|
});
|
|
85
95
|
}
|
|
86
96
|
exports.call = call;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
1
|
+
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(params: Pick<factory.task.checkMovieTicket.ITask, IExecutableTaskKeys>): IOperationExecute<
|
|
6
|
+
export declare function call(params: Pick<factory.task.checkMovieTicket.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
1
|
+
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(params: Pick<factory.task.publishPaymentUrl.ITask, IExecutableTaskKeys>): IOperationExecute<
|
|
6
|
+
export declare function call(params: Pick<factory.task.publishPaymentUrl.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
1
|
+
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(params: Pick<factory.task.ITask<factory.taskName.VoidReserveTransaction>, IExecutableTaskKeys>): IOperationExecute<
|
|
6
|
+
export declare function call(params: Pick<factory.task.ITask<factory.taskName.VoidReserveTransaction>, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -21,6 +21,7 @@ type TaskOperation<T> = (repos: {
|
|
|
21
21
|
}) => Promise<T>;
|
|
22
22
|
type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
23
23
|
type IOperationExecute<T> = (settings: IConnectionSettings, options: IExecuteOptions) => Promise<T>;
|
|
24
|
+
type ICallResult = void | Pick<factory.task.IExecutionResult, 'error'>;
|
|
24
25
|
declare function executeById(params: {
|
|
25
26
|
id: string;
|
|
26
27
|
executor?: {
|
|
@@ -53,4 +54,4 @@ declare function abort(params: {
|
|
|
53
54
|
declare function notifyAbortedTasks(params: {
|
|
54
55
|
dateAbortedGte: Date;
|
|
55
56
|
}): TaskOperation<void>;
|
|
56
|
-
export { IExecutableTaskKeys, IOperationExecute, executeById, executeByName, execute, abort, notifyAbortedTasks };
|
|
57
|
+
export { ICallResult, IExecutableTaskKeys, IOperationExecute, executeById, executeByName, execute, abort, notifyAbortedTasks };
|
|
@@ -17,7 +17,6 @@ const createDebug = require("debug");
|
|
|
17
17
|
const moment = require("moment");
|
|
18
18
|
const factory = require("../factory");
|
|
19
19
|
const factory_1 = require("./notification/factory");
|
|
20
|
-
// import { credentials } from '../credentials';
|
|
21
20
|
const settings_1 = require("../settings");
|
|
22
21
|
const debug = createDebug('chevre-domain:service:task');
|
|
23
22
|
const DEFAULT_EXECUTOR_NAME = `${process.env.GAE_APPLICATION}:${process.env.GAE_SERVICE}:jobs`;
|
|
@@ -102,6 +101,7 @@ function execute(task) {
|
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
// タスク名の関数が定義されていなければ、TypeErrorとなる
|
|
104
|
+
let callResult;
|
|
105
105
|
const { call } = yield Promise.resolve(`${`./task/${task.name}`}`).then(s => require(s));
|
|
106
106
|
switch (task.name) {
|
|
107
107
|
case factory.taskName.AcceptCOAOffer:
|
|
@@ -110,7 +110,7 @@ function execute(task) {
|
|
|
110
110
|
case factory.taskName.PublishPaymentUrl:
|
|
111
111
|
case factory.taskName.Refund:
|
|
112
112
|
case factory.taskName.VoidReserveTransaction:
|
|
113
|
-
yield call(task)(settings, options);
|
|
113
|
+
callResult = yield call(task)(settings, options);
|
|
114
114
|
break;
|
|
115
115
|
default:
|
|
116
116
|
yield call(task.data)(settings);
|
|
@@ -118,7 +118,9 @@ function execute(task) {
|
|
|
118
118
|
const result = {
|
|
119
119
|
executedAt: now,
|
|
120
120
|
endDate: new Date(),
|
|
121
|
-
error
|
|
121
|
+
// enable overwriting task.executionResults.error on Executed(2024-05-29~)
|
|
122
|
+
error: ((callResult === null || callResult === void 0 ? void 0 : callResult.error) instanceof Error)
|
|
123
|
+
? Object.assign(Object.assign({}, callResult.error), { message: callResult.error.message }) : ''
|
|
122
124
|
};
|
|
123
125
|
yield taskRepo.pushExecutionResultById(task.id, factory.taskStatus.Executed, result);
|
|
124
126
|
}
|
|
@@ -165,7 +167,6 @@ function abort(params) {
|
|
|
165
167
|
subject: message.subject, content: message.content,
|
|
166
168
|
logLevel: 'error'
|
|
167
169
|
})({
|
|
168
|
-
// accessToken: credentials.lineNotify.accessTokenAlert,
|
|
169
170
|
useFetchAPI: settings_1.USE_FETCH_API
|
|
170
171
|
});
|
|
171
172
|
}
|
|
@@ -325,7 +325,7 @@ function getReturnPolicyByProject(params) {
|
|
|
325
325
|
}
|
|
326
326
|
break;
|
|
327
327
|
case http_status_1.NOT_FOUND:
|
|
328
|
-
throw new factory.errors.Argument('
|
|
328
|
+
throw new factory.errors.Argument('', `custom return policy returned statusCode: ${res.status}`);
|
|
329
329
|
// break;
|
|
330
330
|
default:
|
|
331
331
|
// tslint:disable-next-line:no-console
|
package/package.json
CHANGED