@chevre/domain 25.2.0-alpha.53 → 25.2.0-alpha.55

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.
Files changed (31) hide show
  1. package/lib/chevre/repo/adminTask.d.ts +37 -0
  2. package/lib/chevre/repo/adminTask.js +163 -0
  3. package/lib/chevre/repo/aggregateTask.d.ts +38 -0
  4. package/lib/chevre/repo/aggregateTask.js +136 -0
  5. package/lib/chevre/repo/asyncAction.d.ts +3 -3
  6. package/lib/chevre/repo/mongoose/schemas/asyncAction.d.ts +3 -1
  7. package/lib/chevre/repo/mongoose/schemas/task.d.ts +6 -1
  8. package/lib/chevre/repo/task.d.ts +27 -65
  9. package/lib/chevre/repo/task.js +49 -333
  10. package/lib/chevre/repository.d.ts +10 -0
  11. package/lib/chevre/repository.js +24 -2
  12. package/lib/chevre/service/aggregation/system.d.ts +2 -2
  13. package/lib/chevre/service/aggregation/system.js +1 -1
  14. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +2 -2
  15. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +1 -1
  16. package/lib/chevre/service/offer/event/voidTransaction.d.ts +1 -1
  17. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +1 -1
  18. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +2 -4
  19. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  20. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  21. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +0 -3
  22. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +72 -43
  23. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  24. package/lib/chevre/service/payment/any/findAcceptAction.js +2 -4
  25. package/lib/chevre/service/payment/any/findAuthorizeAction.js +2 -4
  26. package/lib/chevre/service/payment/any/findCheckAction.js +2 -4
  27. package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
  28. package/lib/chevre/service/transaction/deleteTransaction.d.ts +1 -1
  29. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -1
  30. package/lib/chevre/taskSettings.d.ts +2 -1
  31. package/package.json +2 -2
@@ -10,13 +10,6 @@ const task_1 = require("../eventEmitter/task");
10
10
  const factory_1 = require("../factory");
11
11
  const settings_1 = require("../settings");
12
12
  const task_2 = require("./mongoose/schemas/task");
13
- /**
14
- * タスク実行時のソート条件
15
- */
16
- // const sortOrder4executionOfTasks: { [key in keyof factory.task.IAttributes<factory.taskName>]?: factory.sortType } = {
17
- // numberOfTried: factory.sortType.Ascending, // トライ回数の少なさ優先
18
- // runsAt: factory.sortType.Ascending // 実行予定日時の早さ優先
19
- // };
20
13
  const executableTaskProjection = {
21
14
  _id: 0,
22
15
  id: { $toString: '$_id' },
@@ -30,7 +23,6 @@ const executableTaskProjection = {
30
23
  runsAt: 1,
31
24
  expires: 1
32
25
  };
33
- // type IProjection = { [key in IKeyOfProjection]?: 0 | 1; };
34
26
  const AVAILABLE_PROJECT_FIELDS = [
35
27
  'alternateName',
36
28
  'identifier',
@@ -56,86 +48,6 @@ class TaskRepo {
56
48
  constructor(connection) {
57
49
  this.taskModel = connection.model(task_2.modelName, (0, task_2.createSchema)());
58
50
  }
59
- static CREATE_MONGO_CONDITIONS(params) {
60
- const andConditions = [];
61
- const idEq = params.id?.$eq;
62
- if (typeof idEq === 'string') {
63
- andConditions.push({ _id: { $eq: idEq } });
64
- }
65
- const projectIdEq = params.project?.id?.$eq;
66
- if (typeof projectIdEq === 'string') {
67
- andConditions.push({ 'project.id': { $eq: projectIdEq } });
68
- }
69
- if (typeof params.name === 'string') {
70
- andConditions.push({ name: { $eq: params.name } });
71
- }
72
- else {
73
- const nameIn = params.name?.$in;
74
- if (Array.isArray(nameIn)) {
75
- andConditions.push({ name: { $in: nameIn } });
76
- }
77
- const nameNin = params.name?.$nin;
78
- if (Array.isArray(nameNin)) {
79
- andConditions.push({ name: { $nin: nameNin } });
80
- }
81
- }
82
- const statusEq = params.status?.$eq;
83
- if (typeof statusEq === 'string') {
84
- andConditions.push({ status: { $eq: statusEq } });
85
- }
86
- if (Array.isArray(params.statuses)) {
87
- andConditions.push({ status: { $in: params.statuses } });
88
- }
89
- if (params.runsFrom instanceof Date) {
90
- andConditions.push({ runsAt: { $gte: params.runsFrom } });
91
- }
92
- if (params.runsThrough instanceof Date) {
93
- andConditions.push({ runsAt: { $lte: params.runsThrough } });
94
- }
95
- if (params.lastTriedFrom instanceof Date) {
96
- andConditions.push({ lastTriedAt: { $type: 'date', $gte: params.lastTriedFrom } });
97
- }
98
- if (params.lastTriedThrough instanceof Date) {
99
- andConditions.push({ lastTriedAt: { $type: 'date', $lte: params.lastTriedThrough } });
100
- }
101
- const dateAbortedGte = params.dateAborted?.$gte;
102
- if (dateAbortedGte instanceof Date) {
103
- andConditions.push({ dateAborted: { $type: 'date', $gte: dateAbortedGte } });
104
- }
105
- const dateAbortedLte = params.dateAborted?.$lte;
106
- if (dateAbortedLte instanceof Date) {
107
- andConditions.push({ dateAborted: { $type: 'date', $lte: dateAbortedLte } });
108
- }
109
- const objectIdEq = params.data?.object?.id?.$eq;
110
- if (typeof objectIdEq === 'string') {
111
- andConditions.push({ 'data.object.id': { $exists: true, $eq: objectIdEq } });
112
- }
113
- const objectOrderNumberEq = params.data?.object?.orderNumber?.$eq;
114
- if (typeof objectOrderNumberEq === 'string') {
115
- andConditions.push({ 'data.object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
116
- }
117
- const objectTransactionNumberEq = params.data?.object?.transactionNumber?.$eq;
118
- if (typeof objectTransactionNumberEq === 'string') {
119
- andConditions.push({ 'data.object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
120
- }
121
- const objectPurposeIdEq = params.data?.purpose?.id?.$eq;
122
- if (typeof objectPurposeIdEq === 'string') {
123
- andConditions.push({ 'data.purpose.id': { $exists: true, $eq: objectPurposeIdEq } });
124
- }
125
- const objectPurposeOrderNumberEq = params.data?.purpose?.orderNumber?.$eq;
126
- if (typeof objectPurposeOrderNumberEq === 'string') {
127
- andConditions.push({ 'data.purpose.orderNumber': { $exists: true, $eq: objectPurposeOrderNumberEq } });
128
- }
129
- const alternateNameRegex = params.alternateName?.$regex;
130
- if (typeof alternateNameRegex === 'string' && alternateNameRegex.length > 0) {
131
- andConditions.push({ alternateName: { $exists: true, $regex: new RegExp(alternateNameRegex) } });
132
- }
133
- const identifierRegex = params.identifier?.$regex;
134
- if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
135
- andConditions.push({ identifier: { $exists: true, $regex: new RegExp(identifierRegex) } });
136
- }
137
- return andConditions;
138
- }
139
51
  async runImmediately(
140
52
  // resolve uniqueness of identifier(2025-03-27~)
141
53
  params,
@@ -272,30 +184,39 @@ class TaskRepo {
272
184
  throw new factory_1.factory.errors.Internal(`falied in creating a task unexpectedly. ${params.alternateName}`);
273
185
  }
274
186
  }
275
- /**
276
- * 取引削除タスク冪等作成
277
- */
278
- async createDeleteTransactionTaskIfNotExist(
279
- // resolve uniqueness of identifier(2025-03-27~)
280
- params, options) {
281
- if (params.data.object.specifyingMethod !== factory_1.factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id) {
282
- throw new factory_1.factory.errors.NotImplemented(`only ${factory_1.factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id} implemented`);
283
- }
284
- const createdTask = await this.taskModel.findOneAndUpdate({
285
- 'project.id': { $eq: params.project.id },
286
- name: { $eq: params.name },
287
- 'data.object.id': { $exists: true, $eq: params.data.object.id }
288
- }, { $setOnInsert: params }, { new: true, upsert: true })
289
- .select({ _id: 1 })
290
- .exec();
291
- if (options.emitImmediately) {
292
- task_1.taskEventEmitter.emitTaskStatusChanged({
293
- id: createdTask.id,
294
- name: params.name,
295
- status: factory_1.factory.taskStatus.Ready
296
- });
297
- }
298
- }
187
+ // /**
188
+ // * 取引削除タスク冪等作成
189
+ // */
190
+ // public async createDeleteTransactionTaskIfNotExist(
191
+ // // resolve uniqueness of identifier(2025-03-27~)
192
+ // params: Pick<
193
+ // factory.task.IAttributes<factory.taskName.DeleteTransaction>,
194
+ // 'data' | 'executionResults' | 'name' | 'numberOfTried' | 'project' | 'remainingNumberOfTries' | 'runsAt' | 'status'
195
+ // >,
196
+ // options: IOptionOnCreate
197
+ // ): Promise<void> {
198
+ // if (params.data.object.specifyingMethod !== factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id) {
199
+ // throw new factory.errors.NotImplemented(`only ${factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id} implemented`);
200
+ // }
201
+ // const createdTask = await this.taskModel.findOneAndUpdate(
202
+ // {
203
+ // 'project.id': { $eq: params.project.id },
204
+ // name: { $eq: params.name },
205
+ // 'data.object.id': { $exists: true, $eq: params.data.object.id }
206
+ // },
207
+ // { $setOnInsert: params },
208
+ // { new: true, upsert: true }
209
+ // )
210
+ // .select({ _id: 1 })
211
+ // .exec();
212
+ // if (options.emitImmediately) {
213
+ // taskEventEmitter.emitTaskStatusChanged({
214
+ // id: createdTask.id,
215
+ // name: params.name,
216
+ // status: factory.taskStatus.Ready
217
+ // });
218
+ // }
219
+ // }
299
220
  async createOnAssetTransactionStatusChangedTaskIfNotExist(
300
221
  // resolve uniqueness of identifier(2025-03-27~)
301
222
  params, options) {
@@ -444,8 +365,7 @@ class TaskRepo {
444
365
  /**
445
366
  * 実行日時を一定期間過ぎたReadyタスクについて、Runningスタータスに変更した上で、Runningイベントを発生させる
446
367
  */
447
- async emitRunningIfExists(params, next // support next function(2025-08-02~)
448
- ) {
368
+ async emitRunningIfExists(params) {
449
369
  if (!(params.runsAt.$lt instanceof Date)) {
450
370
  throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
451
371
  }
@@ -463,15 +383,6 @@ class TaskRepo {
463
383
  ...(nameFilterBeforeRunsAt) ? { name: params.name } : undefined,
464
384
  runsAt: { $lt: params.runsAt.$lt },
465
385
  ...(!nameFilterBeforeRunsAt) ? { name: params.name } : undefined
466
- // ...(typeof nameEq === 'string' || Array.isArray(nameIn))
467
- // ? {
468
- // name: {
469
- // ...(typeof nameEq === 'string') ? { $eq: nameEq } : undefined,
470
- // // ...(Array.isArray(nameNin)) ? { $nin: nameNin } : undefined
471
- // ...(Array.isArray(nameIn)) ? { $in: nameIn } : undefined
472
- // }
473
- // }
474
- // : undefined
475
386
  };
476
387
  const doc = await this.taskModel.findOneAndUpdate(filter, {
477
388
  $set: {
@@ -510,7 +421,7 @@ class TaskRepo {
510
421
  status: factory_1.factory.taskStatus.Running
511
422
  };
512
423
  }
513
- task_1.taskEventEmitter.emitTaskStatusChanged(changedTask, (typeof next === 'function') ? next : undefined);
424
+ task_1.taskEventEmitter.emitTaskStatusChanged(changedTask);
514
425
  return doc;
515
426
  }
516
427
  /**
@@ -581,42 +492,6 @@ class TaskRepo {
581
492
  })
582
493
  .exec();
583
494
  }
584
- // public async abortOne(params: {
585
- // intervalInMinutes: number;
586
- // }): Promise<factory.task.ITask<factory.taskName> | null> {
587
- // const lastTriedAtShoudBeLessThan = moment()
588
- // .add(-params.intervalInMinutes, 'minutes')
589
- // .toDate();
590
- // const projection: ProjectionType<factory.task.ITask<factory.taskName>> = {
591
- // _id: 0,
592
- // id: { $toString: '$_id' },
593
- // ...Object.fromEntries<1>(AVAILABLE_PROJECT_FIELDS.map((key) => ([key, 1])))
594
- // };
595
- // const doc = await this.taskModel.findOneAndUpdate(
596
- // {
597
- // status: { $eq: factory.taskStatus.Running },
598
- // lastTriedAt: {
599
- // $type: 'date',
600
- // $lt: lastTriedAtShoudBeLessThan
601
- // },
602
- // remainingNumberOfTries: { $eq: 0 }
603
- // },
604
- // {
605
- // $set: {
606
- // status: factory.taskStatus.Aborted,
607
- // dateAborted: new Date()
608
- // }
609
- // },
610
- // { new: true, projection }
611
- // )
612
- // .lean<factory.task.ITask<factory.taskName>>() // lean(2024-09-26~)
613
- // .exec();
614
- // if (doc === null) {
615
- // // tslint:disable-next-line:no-null-keyword
616
- // return null;
617
- // }
618
- // return doc;
619
- // }
620
495
  async abortMany(params) {
621
496
  const lastTriedAtShoudBeLessThan = (0, moment_1.default)()
622
497
  .add(-params.intervalInMinutes, 'minutes')
@@ -660,28 +535,11 @@ class TaskRepo {
660
535
  task_1.taskEventEmitter.emitTaskStatusChanged(changedTask, next);
661
536
  }
662
537
  }
663
- async count(params) {
664
- const { limit } = params;
665
- const conditions = TaskRepo.CREATE_MONGO_CONDITIONS(params);
666
- const query = this.taskModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
667
- if (typeof limit === 'number' && limit >= 0) {
668
- query.limit(limit);
669
- }
670
- const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
671
- .exec();
672
- return { count };
673
- }
674
538
  /**
675
- * 検索する
539
+ * タスクの状態を参照する
540
+ * 非同期アクション移行が完了したら廃止する(2026-07-29~)
676
541
  */
677
- async projectFields(params,
678
- // projection?: IProjection
679
- inclusion) {
680
- const conditions = TaskRepo.CREATE_MONGO_CONDITIONS(params);
681
- // const positiveProjectionExists: boolean = (projection !== undefined && projection !== null)
682
- // ? Object.values(projection)
683
- // .some((value) => value !== 0)
684
- // : false;
542
+ async findTaskById(params, inclusion) {
685
543
  let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
686
544
  if (Array.isArray(inclusion) && inclusion.length > 0) {
687
545
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
@@ -694,18 +552,18 @@ class TaskRepo {
694
552
  id: { $toString: '$_id' },
695
553
  ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
696
554
  };
697
- const query = this.taskModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
698
- if (typeof params.limit === 'number' && params.limit > 0) {
699
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
700
- query.limit(params.limit)
701
- .skip(params.limit * (page - 1));
702
- }
703
- if (params.sort?.runsAt !== undefined) {
704
- query.sort({ runsAt: params.sort.runsAt });
705
- }
706
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
707
- .lean() // lean(2024-09-26~)
555
+ const query = this.taskModel.findOne({
556
+ _id: { $eq: params.id.$eq },
557
+ 'project.id': { $eq: params.project.id.$eq },
558
+ name: { $eq: params.name }
559
+ }, projection);
560
+ const doc = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
561
+ .lean()
708
562
  .exec();
563
+ if (doc === null) {
564
+ return;
565
+ }
566
+ return doc;
709
567
  }
710
568
  async deleteByProject(params) {
711
569
  await this.taskModel.deleteMany({
@@ -713,18 +571,6 @@ class TaskRepo {
713
571
  })
714
572
  .exec();
715
573
  }
716
- async deleteByName(params) {
717
- return this.taskModel.deleteMany({
718
- name: { $eq: params.name },
719
- ...(typeof params.status?.$eq === 'string') ? { status: { $eq: params.status.$eq } } : undefined,
720
- ...(params.runsAt?.$gte instanceof Date)
721
- ? {
722
- runsAt: { $gte: params.runsAt.$gte, $lte: params.runsAt.$lte }
723
- }
724
- : undefined
725
- })
726
- .exec();
727
- }
728
574
  /**
729
575
  * 不要なタスクを削除する
730
576
  */
@@ -758,135 +604,5 @@ class TaskRepo {
758
604
  .exec();
759
605
  return { count };
760
606
  }
761
- getCursor(conditions, projection) {
762
- return this.taskModel.find(conditions, projection)
763
- .sort({ runsAt: factory_1.factory.sortType.Ascending })
764
- .cursor();
765
- }
766
- async unsetUnnecessaryFields(params) {
767
- return this.taskModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
768
- .exec();
769
- }
770
- async aggregateTask(params) {
771
- const statuses = await Promise.all([
772
- factory_1.factory.taskStatus.Executed,
773
- factory_1.factory.taskStatus.Aborted
774
- ].map(async (taskStatus) => {
775
- const matchConditions = {
776
- runsAt: {
777
- $gte: params.runsFrom,
778
- $lte: params.runsThrough
779
- },
780
- status: { $eq: taskStatus },
781
- ...(typeof params.project?.id?.$ne === 'string')
782
- ? { 'project.id': { $ne: params.project.id.$ne } }
783
- : undefined
784
- };
785
- return this.agggregateByStatus({ matchConditions, status: taskStatus });
786
- }));
787
- return { statuses };
788
- }
789
- async agggregateByStatus(params) {
790
- const matchConditions = params.matchConditions;
791
- const taskStatus = params.status;
792
- const aggregate1 = this.taskModel.aggregate([
793
- {
794
- $match: matchConditions
795
- },
796
- {
797
- $project: {
798
- latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
799
- status: '$status',
800
- runsAt: '$runsAt',
801
- lastTriedAt: '$lastTriedAt'
802
- }
803
- },
804
- {
805
- $group: {
806
- _id: '$status',
807
- taskCount: { $sum: 1 },
808
- maxLatency: { $max: '$latency' },
809
- minLatency: { $min: '$latency' },
810
- avgLatency: { $avg: '$latency' }
811
- }
812
- },
813
- {
814
- $project: {
815
- _id: 0,
816
- taskCount: '$taskCount',
817
- avgLatency: '$avgLatency',
818
- maxLatency: '$maxLatency',
819
- minLatency: '$minLatency'
820
- }
821
- }
822
- ]);
823
- // const explainResult = await aggregate1.explain();
824
- // console.dir(explainResult, { depth: null });
825
- // return;
826
- const aggregations = await aggregate1.exec();
827
- const percents = [50, 95, 99];
828
- if (aggregations.length === 0) {
829
- return {
830
- status: taskStatus,
831
- aggregation: {
832
- taskCount: 0,
833
- avgLatency: 0,
834
- maxLatency: 0,
835
- minLatency: 0,
836
- percentilesLatency: percents.map((percent) => {
837
- return {
838
- name: String(percent),
839
- value: 0
840
- };
841
- })
842
- }
843
- };
844
- }
845
- const ranks4percentile = percents.map((percentile) => {
846
- return {
847
- percentile,
848
- rank: Math.floor(aggregations[0].taskCount * percentile / 100)
849
- };
850
- });
851
- const aggregate2 = this.taskModel.aggregate([
852
- {
853
- $match: matchConditions
854
- },
855
- {
856
- $project: {
857
- latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
858
- status: '$status',
859
- runsAt: '$runsAt',
860
- lastTriedAt: '$lastTriedAt'
861
- }
862
- },
863
- { $sort: { latency: 1 } },
864
- {
865
- $group: {
866
- _id: '$status',
867
- latencies: { $push: '$latency' }
868
- }
869
- },
870
- {
871
- $project: {
872
- _id: 0,
873
- percentilesLatency: ranks4percentile.map((rank) => {
874
- return {
875
- name: String(rank.percentile),
876
- value: { $arrayElemAt: ['$latencies', rank.rank] }
877
- };
878
- })
879
- }
880
- }
881
- ]);
882
- const aggregations2 = await aggregate2.exec();
883
- return {
884
- status: taskStatus,
885
- aggregation: {
886
- ...aggregations[0],
887
- ...aggregations2[0]
888
- }
889
- };
890
- }
891
607
  }
892
608
  exports.TaskRepo = TaskRepo;
@@ -17,10 +17,12 @@ import type { PayActionRepo } from './repo/action/pay';
17
17
  import type { RefundActionRepo } from './repo/action/refund';
18
18
  import type { AsyncActionRepo } from './repo/asyncAction';
19
19
  import type { AdditionalPropertyRepo } from './repo/additionalProperty';
20
+ import type { AdminTaskRepo } from './repo/adminTask';
20
21
  import type { AggregateActionRepo } from './repo/aggregateAction';
21
22
  import type { AggregateOfferRepo } from './repo/aggregateOffer';
22
23
  import type { AggregateOrderRepo } from './repo/aggregateOrder';
23
24
  import type { AggregateReservationRepo } from './repo/aggregateReservation';
25
+ import type { AggregateTaskRepo } from './repo/aggregateTask';
24
26
  import type { AggregationRepo } from './repo/aggregation';
25
27
  import type { AssetTransactionRepo } from './repo/assetTransaction';
26
28
  import type { ReserveTransactionRepo } from './repo/assetTransaction/reserve';
@@ -159,10 +161,18 @@ export type AdditionalProperty = AdditionalPropertyRepo;
159
161
  export declare namespace AdditionalProperty {
160
162
  function createInstance(...params: ConstructorParameters<typeof AdditionalPropertyRepo>): Promise<AdditionalPropertyRepo>;
161
163
  }
164
+ export type AdminTask = AdminTaskRepo;
165
+ export declare namespace AdminTask {
166
+ function createInstance(...params: ConstructorParameters<typeof AdminTaskRepo>): Promise<AdminTaskRepo>;
167
+ }
162
168
  export type AggregateAction = AggregateActionRepo;
163
169
  export declare namespace AggregateAction {
164
170
  function createInstance(...params: ConstructorParameters<typeof AggregateActionRepo>): Promise<AggregateActionRepo>;
165
171
  }
172
+ export type AggregateTask = AggregateTaskRepo;
173
+ export declare namespace AggregateTask {
174
+ function createInstance(...params: ConstructorParameters<typeof AggregateTaskRepo>): Promise<AggregateTaskRepo>;
175
+ }
166
176
  export type AggregateOffer = AggregateOfferRepo;
167
177
  export declare namespace AggregateOffer {
168
178
  function createInstance(...params: ConstructorParameters<typeof AggregateOfferRepo>): Promise<AggregateOfferRepo>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateAction = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
4
- exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = void 0;
3
+ exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateTask = exports.AggregateAction = exports.AdminTask = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
4
+ exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = void 0;
5
5
  var AcceptedOffer;
6
6
  (function (AcceptedOffer) {
7
7
  let repo;
@@ -170,6 +170,17 @@ var AdditionalProperty;
170
170
  }
171
171
  AdditionalProperty.createInstance = createInstance;
172
172
  })(AdditionalProperty || (exports.AdditionalProperty = AdditionalProperty = {}));
173
+ var AdminTask;
174
+ (function (AdminTask) {
175
+ let repo;
176
+ async function createInstance(...params) {
177
+ if (repo === undefined) {
178
+ repo = (await import('./repo/adminTask.js')).AdminTaskRepo;
179
+ }
180
+ return new repo(...params);
181
+ }
182
+ AdminTask.createInstance = createInstance;
183
+ })(AdminTask || (exports.AdminTask = AdminTask = {}));
173
184
  var AggregateAction;
174
185
  (function (AggregateAction) {
175
186
  let repo;
@@ -181,6 +192,17 @@ var AggregateAction;
181
192
  }
182
193
  AggregateAction.createInstance = createInstance;
183
194
  })(AggregateAction || (exports.AggregateAction = AggregateAction = {}));
195
+ var AggregateTask;
196
+ (function (AggregateTask) {
197
+ let repo;
198
+ async function createInstance(...params) {
199
+ if (repo === undefined) {
200
+ repo = (await import('./repo/aggregateTask.js')).AggregateTaskRepo;
201
+ }
202
+ return new repo(...params);
203
+ }
204
+ AggregateTask.createInstance = createInstance;
205
+ })(AggregateTask || (exports.AggregateTask = AggregateTask = {}));
184
206
  var AggregateOffer;
185
207
  (function (AggregateOffer) {
186
208
  let repo;
@@ -1,9 +1,9 @@
1
1
  import type { AggregateActionRepo } from '../../repo/aggregateAction';
2
+ import type { AggregateTaskRepo } from '../../repo/aggregateTask';
2
3
  import { AggregationRepo } from '../../repo/aggregation';
3
4
  import type { AssetTransactionRepo } from '../../repo/assetTransaction';
4
5
  import type { EventRepo } from '../../repo/event';
5
6
  import { OrderRepo } from '../../repo/order';
6
- import type { TaskRepo } from '../../repo/task';
7
7
  import type { TransactionRepo } from '../../repo/transaction';
8
8
  type AggregateDurationUnit = 'days' | 'hours';
9
9
  interface IAggregateParams {
@@ -141,7 +141,7 @@ declare function aggregateReserveTransaction(params: IAggregateParams): (repos:
141
141
  }>;
142
142
  declare function aggregateTask(params: IAggregateParams): (repos: {
143
143
  agregation: AggregationRepo;
144
- task: TaskRepo;
144
+ aggregateTask: AggregateTaskRepo;
145
145
  }) => Promise<{
146
146
  aggregationCount: number;
147
147
  aggregateDuration: string;
@@ -673,7 +673,7 @@ function aggregateTask(params) {
673
673
  .add(-i, params.aggregateDurationUnit)
674
674
  .endOf(params.aggregateDurationUnit)
675
675
  .toDate();
676
- const aggregateResult = await repos.task.aggregateTask({
676
+ const aggregateResult = await repos.aggregateTask.aggregateTask({
677
677
  project: { id: { $ne: params.excludedProjectId } },
678
678
  runsFrom,
679
679
  runsThrough
@@ -1,7 +1,7 @@
1
- import type { TaskRepo } from '../../repo/task';
1
+ import type { AdminTaskRepo } from '../../repo/adminTask';
2
2
  import type { IntegrationSettingRepo } from '../../repo/setting/integration';
3
3
  interface INotifyAbortedTasksRepos {
4
- task: TaskRepo;
4
+ adminTask: AdminTaskRepo;
5
5
  integrationSetting: IntegrationSettingRepo;
6
6
  }
7
7
  /**
@@ -16,7 +16,7 @@ const debug = (0, debug_1.default)('chevre-domain:service:notification');
16
16
  function notifyAbortedTasksByEmail(params) {
17
17
  return async (repos) => {
18
18
  const abortedTasksWithoutReport = await repos.integrationSetting.getByKey('abortedTasksWithoutReport');
19
- const abortedTasks = await repos.task.projectFields({
19
+ const abortedTasks = await repos.adminTask.findTasks({
20
20
  limit: params.limit,
21
21
  page: 1,
22
22
  status: { $eq: factory_1.factory.taskStatus.Aborted },
@@ -36,7 +36,7 @@ interface IVoidTransactionRepos {
36
36
  * 興行オファー承認取消(タスクから実行 or apiから実行))
37
37
  * 取引中の承認アクション全てについて処理する or 特定の承認アクションについて処理する
38
38
  */
39
- declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidReserveTransaction> & {
39
+ declare function voidTransaction(params: factory.task.voidReserveTransaction.IData & {
40
40
  project: {
41
41
  id: string;
42
42
  };
@@ -36,7 +36,7 @@ interface IVoidTransactionByActionIdRepos {
36
36
  * 興行オファー承認取消(apiから実行)
37
37
  * 特定の承認アクションについて処理する
38
38
  */
39
- declare function voidTransactionByActionId(params: factory.task.IData<factory.taskName.VoidReserveTransaction> & {
39
+ declare function voidTransactionByActionId(params: factory.task.voidReserveTransaction.IData & {
40
40
  project: {
41
41
  id: string;
42
42
  };
@@ -17,13 +17,11 @@ function findAcceptAction(params, options) {
17
17
  }
18
18
  // 非同期アクションが存在しなければタスクを参照
19
19
  if (task === undefined) {
20
- task = (await repos.task.projectFields({
21
- limit: 1,
22
- page: 1,
20
+ task = await repos.task.findTaskById({
23
21
  id: { $eq: params.sameAs.id },
24
22
  project: { id: { $eq: params.project.id } },
25
23
  name: factory_1.factory.taskName.AcceptCOAOffer
26
- }, ['status', 'executionResults'])).shift();
24
+ }, ['status', 'executionResults']);
27
25
  }
28
26
  if (task === undefined) {
29
27
  throw new factory_1.factory.errors.NotFound(factory_1.factory.taskName.AcceptCOAOffer);
@@ -7,5 +7,5 @@ import { factory } from '../../../../factory';
7
7
  */
8
8
  declare function createOnOrderCancelledTasksByTransaction(params: {
9
9
  transaction: Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf'>;
10
- }): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/chevre/task/onEventChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceDeleted").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/chevre/task/placeOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/chevre/task/sendOrder").IAttributes | import("@chevre/factory/lib/chevre/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/chevre/task/useReservation").IAttributes | import("@chevre/factory/lib/chevre/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/voidReserveTransaction").IAttributes)[];
10
+ }): (import("@chevre/factory/lib/chevre/task").ITaskAttributes | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/createAccountingReport").IAttributes | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/chevre/task/onEventChanged").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceDeleted").IAttributes | import("@chevre/factory/lib/chevre/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/chevre/task/placeOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnOrder").IAttributes | import("@chevre/factory/lib/chevre/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/chevre/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/chevre/task/sendOrder").IAttributes | import("@chevre/factory/lib/chevre/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/chevre/task/useReservation").IAttributes | import("@chevre/factory/lib/chevre/task/voidPayTransaction").IAttributes)[];
11
11
  export { createOnOrderCancelledTasksByTransaction };