@chevre/domain 21.2.0-alpha.19 → 21.2.0-alpha.20
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/task.d.ts +5 -2
- package/lib/chevre/repo/task.js +19 -15
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -5
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/assetTransaction/pay.js +1 -1
- package/lib/chevre/service/assetTransaction/refund.js +1 -1
- package/lib/chevre/service/assetTransaction/registerService.js +1 -2
- package/lib/chevre/service/assetTransaction/reserve.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -1
- package/lib/chevre/service/order/placeOrder.js +1 -1
- package/lib/chevre/service/order/returnOrder.js +1 -5
- package/lib/chevre/service/order/sendOrder.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -3
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/returnOrder.js +1 -5
- package/package.json +1 -1
|
@@ -17,6 +17,9 @@ interface IStatus {
|
|
|
17
17
|
export interface IAggregateTask {
|
|
18
18
|
statuses: IStatus[];
|
|
19
19
|
}
|
|
20
|
+
interface IOptionOnCreate {
|
|
21
|
+
emitImmediately: boolean;
|
|
22
|
+
}
|
|
20
23
|
/**
|
|
21
24
|
* タスクリポジトリ
|
|
22
25
|
*/
|
|
@@ -24,10 +27,10 @@ export declare class MongoRepository {
|
|
|
24
27
|
readonly taskModel: typeof Model;
|
|
25
28
|
constructor(connection: Connection);
|
|
26
29
|
static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): any[];
|
|
27
|
-
saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[]): Promise<{
|
|
30
|
+
saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[], options?: IOptionOnCreate): Promise<{
|
|
28
31
|
id: string;
|
|
29
32
|
}[]>;
|
|
30
|
-
createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook
|
|
33
|
+
createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook>, options: IOptionOnCreate): Promise<void>;
|
|
31
34
|
executeById(params: {
|
|
32
35
|
id: string;
|
|
33
36
|
}): Promise<factory.task.ITask<factory.taskName> | null>;
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -150,8 +150,9 @@ class MongoRepository {
|
|
|
150
150
|
}
|
|
151
151
|
return andConditions;
|
|
152
152
|
}
|
|
153
|
-
saveMany(taskAttributes) {
|
|
153
|
+
saveMany(taskAttributes, options) {
|
|
154
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const emitImmediately = (options === null || options === void 0 ? void 0 : options.emitImmediately) === true;
|
|
155
156
|
if (taskAttributes.length > 0) {
|
|
156
157
|
const result = yield this.taskModel.insertMany(taskAttributes, { ordered: false, rawResult: true });
|
|
157
158
|
if (result.insertedCount !== taskAttributes.length) {
|
|
@@ -161,18 +162,14 @@ class MongoRepository {
|
|
|
161
162
|
.map((objectId) => {
|
|
162
163
|
return { id: objectId.toHexString() };
|
|
163
164
|
});
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
if (emitImmediately) {
|
|
166
|
+
taskAttributes.forEach((savedTask) => {
|
|
167
|
+
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
168
|
+
name: savedTask.name,
|
|
169
|
+
status: factory.taskStatus.Ready
|
|
170
|
+
});
|
|
168
171
|
});
|
|
169
|
-
}
|
|
170
|
-
// savedTasks.forEach((savedTask) => {
|
|
171
|
-
// taskEventEmitter.emitTaskStatusChanged({
|
|
172
|
-
// id: savedTask.id,
|
|
173
|
-
// status: factory.taskStatus.Ready
|
|
174
|
-
// });
|
|
175
|
-
// });
|
|
172
|
+
}
|
|
176
173
|
// return result.ops;
|
|
177
174
|
return savedTasks;
|
|
178
175
|
}
|
|
@@ -181,9 +178,9 @@ class MongoRepository {
|
|
|
181
178
|
}
|
|
182
179
|
});
|
|
183
180
|
}
|
|
184
|
-
createInformTaskIfNotExist(params) {
|
|
181
|
+
createInformTaskIfNotExist(params, options) {
|
|
185
182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
yield this.taskModel.findOneAndUpdate({
|
|
183
|
+
const createdTask = yield this.taskModel.findOneAndUpdate({
|
|
187
184
|
'project.id': { $eq: params.project.id },
|
|
188
185
|
name: params.name,
|
|
189
186
|
'data.object.id': {
|
|
@@ -191,7 +188,15 @@ class MongoRepository {
|
|
|
191
188
|
$eq: String(params.data.object.id)
|
|
192
189
|
}
|
|
193
190
|
}, { $setOnInsert: params }, { new: true, upsert: true })
|
|
191
|
+
.select({ _id: 1 })
|
|
194
192
|
.exec();
|
|
193
|
+
if (options.emitImmediately) {
|
|
194
|
+
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
195
|
+
id: createdTask.id,
|
|
196
|
+
name: params.name,
|
|
197
|
+
status: factory.taskStatus.Ready
|
|
198
|
+
});
|
|
199
|
+
}
|
|
195
200
|
});
|
|
196
201
|
}
|
|
197
202
|
executeById(params) {
|
|
@@ -208,7 +213,6 @@ class MongoRepository {
|
|
|
208
213
|
numberOfTried: 1 // トライ回数増やす
|
|
209
214
|
}
|
|
210
215
|
}, { new: true })
|
|
211
|
-
// .sort(sortOrder4executionOfTasks)
|
|
212
216
|
.exec();
|
|
213
217
|
if (doc === null) {
|
|
214
218
|
// tslint:disable-next-line:no-null-keyword
|
|
@@ -13,13 +13,11 @@ exports.exportTasksById = exports.startAndConfirm = exports.confirm = exports.st
|
|
|
13
13
|
/**
|
|
14
14
|
* 予約取消取引サービス
|
|
15
15
|
*/
|
|
16
|
-
const createDebug = require("debug");
|
|
17
16
|
const moment = require("moment");
|
|
18
17
|
const mongoose = require("mongoose");
|
|
19
18
|
const factory = require("../../factory");
|
|
20
19
|
const settings_1 = require("../../settings");
|
|
21
20
|
const factory_1 = require("./cancelReservation/factory");
|
|
22
|
-
const debug = createDebug('chevre-domain:service');
|
|
23
21
|
function validateStartParams(params) {
|
|
24
22
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
25
23
|
var _a, _b;
|
|
@@ -235,9 +233,7 @@ function exportTasksById(params) {
|
|
|
235
233
|
default:
|
|
236
234
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
237
235
|
}
|
|
238
|
-
|
|
239
|
-
return repos.task.saveMany(taskAttributes);
|
|
240
|
-
// return Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
|
|
236
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
241
237
|
});
|
|
242
238
|
}
|
|
243
239
|
exports.exportTasksById = exportTasksById;
|
|
@@ -430,7 +430,7 @@ function exportTasksById(params) {
|
|
|
430
430
|
default:
|
|
431
431
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
432
432
|
}
|
|
433
|
-
return repos.task.saveMany(taskAttributes);
|
|
433
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
436
|
exports.exportTasksById = exportTasksById;
|
|
@@ -470,7 +470,7 @@ function exportTasksById(params) {
|
|
|
470
470
|
default:
|
|
471
471
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
472
472
|
}
|
|
473
|
-
return repos.task.saveMany(taskAttributes);
|
|
473
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
474
474
|
});
|
|
475
475
|
}
|
|
476
476
|
exports.exportTasksById = exportTasksById;
|
|
@@ -218,7 +218,7 @@ function exportTasksById(params) {
|
|
|
218
218
|
default:
|
|
219
219
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
220
220
|
}
|
|
221
|
-
return repos.task.saveMany(taskAttributes);
|
|
221
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
224
|
exports.exportTasksById = exportTasksById;
|
|
@@ -301,8 +301,7 @@ function exportTasksById(params) {
|
|
|
301
301
|
default:
|
|
302
302
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
303
303
|
}
|
|
304
|
-
return repos.task.saveMany(taskAttributes);
|
|
305
|
-
// return Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
|
|
304
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
306
305
|
});
|
|
307
306
|
}
|
|
308
307
|
exports.exportTasksById = exportTasksById;
|
|
@@ -860,7 +860,7 @@ function exportTasksById(params) {
|
|
|
860
860
|
default:
|
|
861
861
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
862
862
|
}
|
|
863
|
-
return repos.task.saveMany(taskAttributes);
|
|
863
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
864
864
|
});
|
|
865
865
|
}
|
|
866
866
|
exports.exportTasksById = exportTasksById;
|
|
@@ -204,10 +204,6 @@ function onReturn(returnActionAttributes) {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
// タスク保管
|
|
207
|
-
|
|
208
|
-
yield repos.task.saveMany(taskAttributes);
|
|
209
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
210
|
-
// return repos.task.save(taskAttribute);
|
|
211
|
-
// }));
|
|
207
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
212
208
|
});
|
|
213
209
|
}
|
|
@@ -576,9 +576,7 @@ function exportTasksById(params) {
|
|
|
576
576
|
transaction,
|
|
577
577
|
runsAt: taskRunsAt
|
|
578
578
|
});
|
|
579
|
-
|
|
580
|
-
yield repos.task.saveMany(taskAttributes);
|
|
581
|
-
// await Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
|
|
579
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
582
580
|
});
|
|
583
581
|
}
|
|
584
582
|
exports.exportTasksById = exportTasksById;
|
|
@@ -36,11 +36,7 @@ function exportTasksById(params) {
|
|
|
36
36
|
transaction,
|
|
37
37
|
runsAt: taskRunsAt
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
yield repos.task.saveMany(taskAttributes);
|
|
41
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
42
|
-
// await repos.task.save(taskAttribute);
|
|
43
|
-
// }));
|
|
39
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
44
40
|
});
|
|
45
41
|
}
|
|
46
42
|
exports.exportTasksById = exportTasksById;
|
|
@@ -384,11 +384,7 @@ function exportTasksById(params) {
|
|
|
384
384
|
transaction,
|
|
385
385
|
runsAt: taskRunsAt
|
|
386
386
|
});
|
|
387
|
-
|
|
388
|
-
yield repos.task.saveMany(taskAttributes);
|
|
389
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
390
|
-
// await repos.task.save(taskAttribute);
|
|
391
|
-
// }));
|
|
387
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
392
388
|
});
|
|
393
389
|
}
|
|
394
390
|
exports.exportTasksById = exportTasksById;
|
package/package.json
CHANGED