@chevre/domain 22.11.0-alpha.13 → 22.11.0-alpha.15
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/notifyAbortedTasksByEmail.ts +1 -1
- package/lib/chevre/eventEmitter/task.d.ts +3 -3
- package/lib/chevre/repo/seller.d.ts +4 -4
- package/lib/chevre/repo/task.d.ts +13 -22
- package/lib/chevre/repo/task.js +47 -132
- package/lib/chevre/service/task/aggregateOnSystem.d.ts +3 -1
- package/lib/chevre/service/task/handleNotification.d.ts +3 -1
- package/lib/chevre/service/taskHandler.js +4 -2
- package/package.json +3 -3
- package/example/src/chevre/findExecutableTask.ts +0 -50
|
@@ -30,7 +30,7 @@ async function main() {
|
|
|
30
30
|
]
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
const result = await (await chevre.service.
|
|
33
|
+
const result = await (await chevre.service.notification.createService()).notifyAbortedTasksByEmail({
|
|
34
34
|
dateAbortedGte: moment()
|
|
35
35
|
// tslint:disable-next-line:no-magic-numbers
|
|
36
36
|
.add(-10, 'days')
|
|
@@ -13,7 +13,7 @@ interface IExecuteSettings {
|
|
|
13
13
|
redisClient?: RedisClientType;
|
|
14
14
|
}
|
|
15
15
|
type IOperationExecute<T> = (settings: IExecuteSettings) => Promise<T>;
|
|
16
|
-
type INextFunction = (task: Pick<factory.task.ITask<factory.taskName>, 'id' | 'remainingNumberOfTries'>) => IOperationExecute<void>;
|
|
16
|
+
type INextFunction = (task: Pick<factory.task.ITask<factory.taskName>, 'id' | 'remainingNumberOfTries' | 'name' | 'status'>) => IOperationExecute<void>;
|
|
17
17
|
interface IReadyTask {
|
|
18
18
|
id: string;
|
|
19
19
|
name?: factory.taskName;
|
|
@@ -35,13 +35,13 @@ interface IRunningTask {
|
|
|
35
35
|
*/
|
|
36
36
|
interface IExecutedTask {
|
|
37
37
|
id: string;
|
|
38
|
-
status: factory.taskStatus;
|
|
38
|
+
status: factory.taskStatus.Executed | factory.taskStatus.Running;
|
|
39
39
|
executionResult: factory.task.IExecutionResult;
|
|
40
40
|
/**
|
|
41
41
|
* 実行されたタスクの残り試行回数
|
|
42
42
|
*/
|
|
43
43
|
remainingNumberOfTries: number;
|
|
44
|
-
name
|
|
44
|
+
name: factory.taskName;
|
|
45
45
|
expires?: never;
|
|
46
46
|
}
|
|
47
47
|
type IChangedTask = IReadyTask | IRunningTask | IExecutedTask;
|
|
@@ -77,8 +77,8 @@ export declare class SellerRepo {
|
|
|
77
77
|
}): Promise<void>;
|
|
78
78
|
getCursor(conditions: FilterQuery<factory.seller.ISeller>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, {
|
|
79
79
|
url?: string | undefined;
|
|
80
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
81
80
|
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
81
|
+
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
82
82
|
typeOf: factory.organizationType.Corporation;
|
|
83
83
|
location?: factory.organization.ILocation | undefined;
|
|
84
84
|
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
@@ -89,8 +89,8 @@ export declare class SellerRepo {
|
|
|
89
89
|
paymentAccepted?: factory.seller.IPaymentAccepted[] | undefined;
|
|
90
90
|
}> & {
|
|
91
91
|
url?: string | undefined;
|
|
92
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
93
92
|
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
93
|
+
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
94
94
|
typeOf: factory.organizationType.Corporation;
|
|
95
95
|
location?: factory.organization.ILocation | undefined;
|
|
96
96
|
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
@@ -103,8 +103,8 @@ export declare class SellerRepo {
|
|
|
103
103
|
_id: Types.ObjectId;
|
|
104
104
|
}, QueryOptions<import("mongoose").Document<unknown, {}, {
|
|
105
105
|
url?: string | undefined;
|
|
106
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
107
106
|
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
107
|
+
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
108
108
|
typeOf: factory.organizationType.Corporation;
|
|
109
109
|
location?: factory.organization.ILocation | undefined;
|
|
110
110
|
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
@@ -115,8 +115,8 @@ export declare class SellerRepo {
|
|
|
115
115
|
paymentAccepted?: factory.seller.IPaymentAccepted[] | undefined;
|
|
116
116
|
}> & {
|
|
117
117
|
url?: string | undefined;
|
|
118
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
119
118
|
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
119
|
+
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
120
120
|
typeOf: factory.organizationType.Corporation;
|
|
121
121
|
location?: factory.organization.ILocation | undefined;
|
|
122
122
|
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
@@ -23,7 +23,9 @@ interface IOptionOnCreate {
|
|
|
23
23
|
emitImmediately: boolean;
|
|
24
24
|
}
|
|
25
25
|
export type IExecutableTaskKeys = 'data' | 'id' | 'name' | 'status' | 'numberOfTried' | 'project' | 'remainingNumberOfTries' | 'runsAt' | 'expires';
|
|
26
|
-
export type IExecutableTask<T extends factory.taskName> = Pick<factory.task.ITask<T>, IExecutableTaskKeys
|
|
26
|
+
export type IExecutableTask<T extends factory.taskName> = Pick<factory.task.ITask<T>, IExecutableTaskKeys> & {
|
|
27
|
+
status: factory.taskStatus.Running;
|
|
28
|
+
};
|
|
27
29
|
type IKeyOfProjection = keyof factory.task.ITask<factory.taskName>;
|
|
28
30
|
type ICreatingTask = Pick<factory.task.IAttributes<factory.taskName>, 'data' | 'executionResults' | 'name' | 'numberOfTried' | 'project' | 'remainingNumberOfTries' | 'runsAt' | 'status' | 'identifier' | 'description'>;
|
|
29
31
|
/**
|
|
@@ -125,15 +127,6 @@ export declare class TaskRepo {
|
|
|
125
127
|
runsAt: factory.sortType;
|
|
126
128
|
};
|
|
127
129
|
}, next: INextFunction): Promise<Pick<factory.task.ITask<factory.taskName>, 'id' | 'name'> | null>;
|
|
128
|
-
findExecutableOne(params: {
|
|
129
|
-
name?: {
|
|
130
|
-
$eq?: factory.taskName;
|
|
131
|
-
$nin?: factory.taskName[];
|
|
132
|
-
};
|
|
133
|
-
runsAt: {
|
|
134
|
-
$lt: Date;
|
|
135
|
-
};
|
|
136
|
-
}): Promise<IExecutableTask<factory.taskName> | null>;
|
|
137
130
|
/**
|
|
138
131
|
* emit OnTaskStatusChanged on delayed tasks
|
|
139
132
|
*/
|
|
@@ -171,12 +164,10 @@ export declare class TaskRepo {
|
|
|
171
164
|
* タスクID
|
|
172
165
|
*/
|
|
173
166
|
id: string;
|
|
174
|
-
status: factory.taskStatus;
|
|
167
|
+
status: factory.taskStatus.Executed | factory.taskStatus.Running;
|
|
175
168
|
remainingNumberOfTries: number;
|
|
169
|
+
name: factory.taskName;
|
|
176
170
|
}, executionResult: factory.task.IExecutionResult, next?: INextFunction): Promise<void>;
|
|
177
|
-
/**
|
|
178
|
-
* 特定タスク検索
|
|
179
|
-
*/
|
|
180
171
|
count(params: factory.task.ISearchConditions): Promise<{
|
|
181
172
|
count: number;
|
|
182
173
|
}>;
|
|
@@ -218,12 +209,12 @@ export declare class TaskRepo {
|
|
|
218
209
|
}>;
|
|
219
210
|
getCursor(conditions: FilterQuery<factory.task.ITask<factory.taskName>>, projection: ProjectionType<factory.task.ITask<factory.taskName>>): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, {
|
|
220
211
|
remainingNumberOfTries: number;
|
|
212
|
+
name: factory.taskName;
|
|
213
|
+
status: factory.taskStatus;
|
|
221
214
|
alternateName?: string | undefined;
|
|
222
215
|
identifier?: string | undefined;
|
|
223
216
|
description?: string | undefined;
|
|
224
217
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
225
|
-
name: factory.taskName;
|
|
226
|
-
status: factory.taskStatus;
|
|
227
218
|
runsAt: Date;
|
|
228
219
|
lastTriedAt?: Date | undefined;
|
|
229
220
|
numberOfTried: number;
|
|
@@ -234,12 +225,12 @@ export declare class TaskRepo {
|
|
|
234
225
|
expires?: Date | undefined;
|
|
235
226
|
}> & {
|
|
236
227
|
remainingNumberOfTries: number;
|
|
228
|
+
name: factory.taskName;
|
|
229
|
+
status: factory.taskStatus;
|
|
237
230
|
alternateName?: string | undefined;
|
|
238
231
|
identifier?: string | undefined;
|
|
239
232
|
description?: string | undefined;
|
|
240
233
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
241
|
-
name: factory.taskName;
|
|
242
|
-
status: factory.taskStatus;
|
|
243
234
|
runsAt: Date;
|
|
244
235
|
lastTriedAt?: Date | undefined;
|
|
245
236
|
numberOfTried: number;
|
|
@@ -252,12 +243,12 @@ export declare class TaskRepo {
|
|
|
252
243
|
_id: import("mongoose").Types.ObjectId;
|
|
253
244
|
}, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, {
|
|
254
245
|
remainingNumberOfTries: number;
|
|
246
|
+
name: factory.taskName;
|
|
247
|
+
status: factory.taskStatus;
|
|
255
248
|
alternateName?: string | undefined;
|
|
256
249
|
identifier?: string | undefined;
|
|
257
250
|
description?: string | undefined;
|
|
258
251
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
259
|
-
name: factory.taskName;
|
|
260
|
-
status: factory.taskStatus;
|
|
261
252
|
runsAt: Date;
|
|
262
253
|
lastTriedAt?: Date | undefined;
|
|
263
254
|
numberOfTried: number;
|
|
@@ -268,12 +259,12 @@ export declare class TaskRepo {
|
|
|
268
259
|
expires?: Date | undefined;
|
|
269
260
|
}> & {
|
|
270
261
|
remainingNumberOfTries: number;
|
|
262
|
+
name: factory.taskName;
|
|
263
|
+
status: factory.taskStatus;
|
|
271
264
|
alternateName?: string | undefined;
|
|
272
265
|
identifier?: string | undefined;
|
|
273
266
|
description?: string | undefined;
|
|
274
267
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
275
|
-
name: factory.taskName;
|
|
276
|
-
status: factory.taskStatus;
|
|
277
268
|
runsAt: Date;
|
|
278
269
|
lastTriedAt?: Date | undefined;
|
|
279
270
|
numberOfTried: number;
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -242,48 +242,6 @@ class TaskRepo {
|
|
|
242
242
|
return { id, status };
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
-
// public async createIfNotExistByIdentifier(
|
|
246
|
-
// params: factory.task.IAttributes<factory.taskName> & {
|
|
247
|
-
// // resolve uniqueness of identifier(2025-03-27~)
|
|
248
|
-
// identifier: string;
|
|
249
|
-
// },
|
|
250
|
-
// options: IOptionOnCreate
|
|
251
|
-
// ): Promise<void> {
|
|
252
|
-
// if (typeof params.identifier !== 'string' || params.identifier.length === 0) {
|
|
253
|
-
// throw new factory.errors.ArgumentNull('identifier');
|
|
254
|
-
// }
|
|
255
|
-
// try {
|
|
256
|
-
// const createdTask = await this.taskModel.findOneAndUpdate(
|
|
257
|
-
// {
|
|
258
|
-
// 'project.id': { $eq: params.project.id },
|
|
259
|
-
// name: { $eq: params.name },
|
|
260
|
-
// identifier: { $exists: true, $eq: params.identifier }
|
|
261
|
-
// },
|
|
262
|
-
// { $setOnInsert: params },
|
|
263
|
-
// { new: true, upsert: true }
|
|
264
|
-
// )
|
|
265
|
-
// .select({ _id: 1 })
|
|
266
|
-
// .exec();
|
|
267
|
-
// if (options.emitImmediately) {
|
|
268
|
-
// taskEventEmitter.emitTaskStatusChanged({
|
|
269
|
-
// id: createdTask.id,
|
|
270
|
-
// name: params.name,
|
|
271
|
-
// status: factory.taskStatus.Ready
|
|
272
|
-
// });
|
|
273
|
-
// }
|
|
274
|
-
// } catch (error) {
|
|
275
|
-
// let throwsError = true;
|
|
276
|
-
// if (await isMongoError(error)) {
|
|
277
|
-
// // すでにidentifierが存在する場合ok
|
|
278
|
-
// if (error.code === MongoErrorCode.DuplicateKey) {
|
|
279
|
-
// throwsError = false;
|
|
280
|
-
// }
|
|
281
|
-
// }
|
|
282
|
-
// if (throwsError) {
|
|
283
|
-
// throw error;
|
|
284
|
-
// }
|
|
285
|
-
// }
|
|
286
|
-
// }
|
|
287
245
|
/**
|
|
288
246
|
* タスク識別子から冪等作成する
|
|
289
247
|
* reimplement createIfNotExistByIdentifier(2025-03-28~)
|
|
@@ -341,40 +299,6 @@ class TaskRepo {
|
|
|
341
299
|
}
|
|
342
300
|
});
|
|
343
301
|
}
|
|
344
|
-
// public async createInformTaskIfNotExist(
|
|
345
|
-
// // resolve uniqueness of identifier(2025-03-27~)
|
|
346
|
-
// params: Pick<
|
|
347
|
-
// factory.task.IAttributes<factory.taskName.TriggerWebhook>,
|
|
348
|
-
// 'data' | 'executionResults' | 'name' | 'numberOfTried' | 'project' | 'remainingNumberOfTries' | 'runsAt' | 'status'
|
|
349
|
-
// > & {
|
|
350
|
-
// data: factory.task.triggerWebhook.IInformAnyResourceAction & {
|
|
351
|
-
// object: factory.notification.person.IPersonAsNotification;
|
|
352
|
-
// };
|
|
353
|
-
// },
|
|
354
|
-
// options: IOptionOnCreate
|
|
355
|
-
// ): Promise<void> {
|
|
356
|
-
// const createdTask = await this.taskModel.findOneAndUpdate(
|
|
357
|
-
// {
|
|
358
|
-
// 'project.id': { $eq: params.project.id },
|
|
359
|
-
// name: params.name,
|
|
360
|
-
// 'data.object.id': {
|
|
361
|
-
// $exists: true,
|
|
362
|
-
// $eq: String(params.data.object.id)
|
|
363
|
-
// }
|
|
364
|
-
// },
|
|
365
|
-
// { $setOnInsert: params },
|
|
366
|
-
// { new: true, upsert: true }
|
|
367
|
-
// )
|
|
368
|
-
// .select({ _id: 1 })
|
|
369
|
-
// .exec();
|
|
370
|
-
// if (options.emitImmediately) {
|
|
371
|
-
// taskEventEmitter.emitTaskStatusChanged({
|
|
372
|
-
// id: createdTask.id,
|
|
373
|
-
// name: params.name,
|
|
374
|
-
// status: factory.taskStatus.Ready
|
|
375
|
-
// });
|
|
376
|
-
// }
|
|
377
|
-
// }
|
|
378
302
|
/**
|
|
379
303
|
* 取引削除タスク冪等作成
|
|
380
304
|
*/
|
|
@@ -599,36 +523,51 @@ class TaskRepo {
|
|
|
599
523
|
return doc;
|
|
600
524
|
});
|
|
601
525
|
}
|
|
602
|
-
findExecutableOne(params
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
526
|
+
// public async findExecutableOne(params: {
|
|
527
|
+
// name?: {
|
|
528
|
+
// $eq?: factory.taskName;
|
|
529
|
+
// $nin?: factory.taskName[];
|
|
530
|
+
// };
|
|
531
|
+
// runsAt: {
|
|
532
|
+
// $lt: Date;
|
|
533
|
+
// };
|
|
534
|
+
// }): Promise<IExecutableTask<factory.taskName> | null> {
|
|
535
|
+
// if (!(params.runsAt.$lt instanceof Date)) {
|
|
536
|
+
// throw new factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
537
|
+
// }
|
|
538
|
+
// const nameEq = params.name?.$eq;
|
|
539
|
+
// const nameNin = params.name?.$nin;
|
|
540
|
+
// const query = this.taskModel.findOne(
|
|
541
|
+
// {
|
|
542
|
+
// status: { $eq: factory.taskStatus.Ready },
|
|
543
|
+
// runsAt: { $lt: params.runsAt.$lt },
|
|
544
|
+
// ...(typeof nameEq === 'string' || Array.isArray(nameNin))
|
|
545
|
+
// ? {
|
|
546
|
+
// name: {
|
|
547
|
+
// ...(typeof nameEq === 'string') ? { $eq: nameEq } : undefined,
|
|
548
|
+
// ...(Array.isArray(nameNin)) ? { $nin: nameNin } : undefined
|
|
549
|
+
// }
|
|
550
|
+
// }
|
|
551
|
+
// : undefined
|
|
552
|
+
// },
|
|
553
|
+
// executableTaskProjection
|
|
554
|
+
// )
|
|
555
|
+
// .sort({
|
|
556
|
+
// runsAt: factory.sortType.Ascending
|
|
557
|
+
// });
|
|
558
|
+
// // .hint('executeOneByName');
|
|
559
|
+
// // const explainResult = await query.explain();
|
|
560
|
+
// // console.dir(explainResult, { depth: null });
|
|
561
|
+
// // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
|
|
562
|
+
// const doc = await query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
563
|
+
// .lean<IExecutableTask<factory.taskName>>()
|
|
564
|
+
// .exec();
|
|
565
|
+
// if (doc === null) {
|
|
566
|
+
// // tslint:disable-next-line:no-null-keyword
|
|
567
|
+
// return null;
|
|
568
|
+
// }
|
|
569
|
+
// return doc;
|
|
570
|
+
// }
|
|
632
571
|
// discontinue(2025-05-26~)
|
|
633
572
|
/**
|
|
634
573
|
* emit OnTaskStatusChanged on delayed tasks
|
|
@@ -804,7 +743,7 @@ class TaskRepo {
|
|
|
804
743
|
// support customr function(2025-05-25~)
|
|
805
744
|
next) {
|
|
806
745
|
return __awaiter(this, void 0, void 0, function* () {
|
|
807
|
-
const { id, status, remainingNumberOfTries } = params;
|
|
746
|
+
const { id, status, remainingNumberOfTries, name } = params;
|
|
808
747
|
yield this.taskModel.updateOne({ _id: { $eq: id } }, {
|
|
809
748
|
$set: { status },
|
|
810
749
|
$push: { executionResults: executionResult }
|
|
@@ -812,35 +751,11 @@ class TaskRepo {
|
|
|
812
751
|
.exec();
|
|
813
752
|
// emit event(2025-05-26~)
|
|
814
753
|
if (typeof next === 'function') {
|
|
815
|
-
const changedTask = { id, status, remainingNumberOfTries, executionResult };
|
|
754
|
+
const changedTask = { id, name, status, remainingNumberOfTries, executionResult };
|
|
816
755
|
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask, next);
|
|
817
756
|
}
|
|
818
757
|
});
|
|
819
758
|
}
|
|
820
|
-
/**
|
|
821
|
-
* 特定タスク検索
|
|
822
|
-
*/
|
|
823
|
-
// public async findById<T extends factory.taskName>(params: {
|
|
824
|
-
// name: T;
|
|
825
|
-
// id: string;
|
|
826
|
-
// }): Promise<factory.task.ITask<T>> {
|
|
827
|
-
// const doc = await this.taskModel.findOne(
|
|
828
|
-
// {
|
|
829
|
-
// name: { $eq: params.name },
|
|
830
|
-
// _id: { $eq: params.id }
|
|
831
|
-
// },
|
|
832
|
-
// {
|
|
833
|
-
// __v: 0,
|
|
834
|
-
// createdAt: 0,
|
|
835
|
-
// updatedAt: 0
|
|
836
|
-
// }
|
|
837
|
-
// )
|
|
838
|
-
// .exec();
|
|
839
|
-
// if (doc === null) {
|
|
840
|
-
// throw new factory.errors.NotFound('Task');
|
|
841
|
-
// }
|
|
842
|
-
// return doc.toObject();
|
|
843
|
-
// }
|
|
844
759
|
count(params) {
|
|
845
760
|
return __awaiter(this, void 0, void 0, function* () {
|
|
846
761
|
const { limit } = params;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
2
|
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
|
|
3
|
-
export declare function call(params: Pick<factory.task.aggregateOnSystem.ITask, IExecutableTaskKeys>
|
|
3
|
+
export declare function call(params: Pick<factory.task.aggregateOnSystem.ITask, IExecutableTaskKeys> & {
|
|
4
|
+
status: factory.taskStatus.Running;
|
|
5
|
+
}): IOperationExecute<ICallResult>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
2
|
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
|
|
3
|
-
export declare function call(params: Pick<factory.task.handleNotification.ITask, IExecutableTaskKeys>
|
|
3
|
+
export declare function call(params: Pick<factory.task.handleNotification.ITask, IExecutableTaskKeys> & {
|
|
4
|
+
status: factory.taskStatus.Running;
|
|
5
|
+
}): IOperationExecute<ICallResult>;
|
|
@@ -73,7 +73,8 @@ function executeTask(task, next) {
|
|
|
73
73
|
yield taskRepo.pushExecutionResultById({
|
|
74
74
|
id: task.id,
|
|
75
75
|
status: factory.taskStatus.Executed,
|
|
76
|
-
remainingNumberOfTries: task.remainingNumberOfTries
|
|
76
|
+
remainingNumberOfTries: task.remainingNumberOfTries,
|
|
77
|
+
name: task.name
|
|
77
78
|
}, result, (typeof next === 'function') ? next : undefined);
|
|
78
79
|
}
|
|
79
80
|
catch (error) {
|
|
@@ -91,7 +92,8 @@ function executeTask(task, next) {
|
|
|
91
92
|
yield taskRepo.pushExecutionResultById({
|
|
92
93
|
id: task.id,
|
|
93
94
|
status: task.status,
|
|
94
|
-
remainingNumberOfTries: task.remainingNumberOfTries
|
|
95
|
+
remainingNumberOfTries: task.remainingNumberOfTries,
|
|
96
|
+
name: task.name
|
|
95
97
|
}, result, (typeof next === 'function') ? next : undefined);
|
|
96
98
|
}
|
|
97
99
|
});
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.
|
|
15
|
-
"@cinerino/sdk": "11.
|
|
14
|
+
"@chevre/factory": "4.396.0-alpha.1",
|
|
15
|
+
"@cinerino/sdk": "11.1.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "22.11.0-alpha.
|
|
118
|
+
"version": "22.11.0-alpha.15"
|
|
119
119
|
}
|
|
@@ -1,50 +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
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
11
|
-
|
|
12
|
-
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
setInterval(
|
|
15
|
-
async () => {
|
|
16
|
-
const startTime = process.hrtime();
|
|
17
|
-
const task = await taskRepo.findExecutableOne({
|
|
18
|
-
name: {
|
|
19
|
-
$eq: chevre.factory.taskName.VoidReserveTransaction
|
|
20
|
-
// $nin: [
|
|
21
|
-
// chevre.factory.taskName.DeleteTransaction,
|
|
22
|
-
// chevre.factory.taskName.ImportEventCapacitiesFromCOA,
|
|
23
|
-
// chevre.factory.taskName.ImportEventsFromCOA,
|
|
24
|
-
// chevre.factory.taskName.AcceptCOAOffer,
|
|
25
|
-
// chevre.factory.taskName.CheckMovieTicket,
|
|
26
|
-
// chevre.factory.taskName.AuthorizePayment,
|
|
27
|
-
// chevre.factory.taskName.PublishPaymentUrl
|
|
28
|
-
// ]
|
|
29
|
-
},
|
|
30
|
-
runsAt: {
|
|
31
|
-
$lt: moment()
|
|
32
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
33
|
-
.add(-60, 'seconds')
|
|
34
|
-
.toDate()
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const diff = process.hrtime(startTime);
|
|
38
|
-
console.log(`took ${diff[0]} seconds and ${diff[1]} nanoseconds.`);
|
|
39
|
-
|
|
40
|
-
// tslint:disable-next-line:no-null-keyword
|
|
41
|
-
console.dir(task?.id, { depth: null });
|
|
42
|
-
},
|
|
43
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
44
|
-
1000
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
main()
|
|
49
|
-
.then()
|
|
50
|
-
.catch(console.error);
|