@chevre/domain 25.2.0-alpha.54 → 25.2.0-alpha.56

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.
@@ -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' },
@@ -55,86 +48,6 @@ class TaskRepo {
55
48
  constructor(connection) {
56
49
  this.taskModel = connection.model(task_2.modelName, (0, task_2.createSchema)());
57
50
  }
58
- static CREATE_MONGO_CONDITIONS(params) {
59
- const andConditions = [];
60
- const idEq = params.id?.$eq;
61
- if (typeof idEq === 'string') {
62
- andConditions.push({ _id: { $eq: idEq } });
63
- }
64
- const projectIdEq = params.project?.id?.$eq;
65
- if (typeof projectIdEq === 'string') {
66
- andConditions.push({ 'project.id': { $eq: projectIdEq } });
67
- }
68
- if (typeof params.name === 'string') {
69
- andConditions.push({ name: { $eq: params.name } });
70
- }
71
- else {
72
- const nameIn = params.name?.$in;
73
- if (Array.isArray(nameIn)) {
74
- andConditions.push({ name: { $in: nameIn } });
75
- }
76
- const nameNin = params.name?.$nin;
77
- if (Array.isArray(nameNin)) {
78
- andConditions.push({ name: { $nin: nameNin } });
79
- }
80
- }
81
- const statusEq = params.status?.$eq;
82
- if (typeof statusEq === 'string') {
83
- andConditions.push({ status: { $eq: statusEq } });
84
- }
85
- if (Array.isArray(params.statuses)) {
86
- andConditions.push({ status: { $in: params.statuses } });
87
- }
88
- if (params.runsFrom instanceof Date) {
89
- andConditions.push({ runsAt: { $gte: params.runsFrom } });
90
- }
91
- if (params.runsThrough instanceof Date) {
92
- andConditions.push({ runsAt: { $lte: params.runsThrough } });
93
- }
94
- if (params.lastTriedFrom instanceof Date) {
95
- andConditions.push({ lastTriedAt: { $type: 'date', $gte: params.lastTriedFrom } });
96
- }
97
- if (params.lastTriedThrough instanceof Date) {
98
- andConditions.push({ lastTriedAt: { $type: 'date', $lte: params.lastTriedThrough } });
99
- }
100
- const dateAbortedGte = params.dateAborted?.$gte;
101
- if (dateAbortedGte instanceof Date) {
102
- andConditions.push({ dateAborted: { $type: 'date', $gte: dateAbortedGte } });
103
- }
104
- const dateAbortedLte = params.dateAborted?.$lte;
105
- if (dateAbortedLte instanceof Date) {
106
- andConditions.push({ dateAborted: { $type: 'date', $lte: dateAbortedLte } });
107
- }
108
- const objectIdEq = params.data?.object?.id?.$eq;
109
- if (typeof objectIdEq === 'string') {
110
- andConditions.push({ 'data.object.id': { $exists: true, $eq: objectIdEq } });
111
- }
112
- const objectOrderNumberEq = params.data?.object?.orderNumber?.$eq;
113
- if (typeof objectOrderNumberEq === 'string') {
114
- andConditions.push({ 'data.object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
115
- }
116
- const objectTransactionNumberEq = params.data?.object?.transactionNumber?.$eq;
117
- if (typeof objectTransactionNumberEq === 'string') {
118
- andConditions.push({ 'data.object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
119
- }
120
- const objectPurposeIdEq = params.data?.purpose?.id?.$eq;
121
- if (typeof objectPurposeIdEq === 'string') {
122
- andConditions.push({ 'data.purpose.id': { $exists: true, $eq: objectPurposeIdEq } });
123
- }
124
- const objectPurposeOrderNumberEq = params.data?.purpose?.orderNumber?.$eq;
125
- if (typeof objectPurposeOrderNumberEq === 'string') {
126
- andConditions.push({ 'data.purpose.orderNumber': { $exists: true, $eq: objectPurposeOrderNumberEq } });
127
- }
128
- const alternateNameRegex = params.alternateName?.$regex;
129
- if (typeof alternateNameRegex === 'string' && alternateNameRegex.length > 0) {
130
- andConditions.push({ alternateName: { $exists: true, $regex: new RegExp(alternateNameRegex) } });
131
- }
132
- const identifierRegex = params.identifier?.$regex;
133
- if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
134
- andConditions.push({ identifier: { $exists: true, $regex: new RegExp(identifierRegex) } });
135
- }
136
- return andConditions;
137
- }
138
51
  async runImmediately(
139
52
  // resolve uniqueness of identifier(2025-03-27~)
140
53
  params,
@@ -452,8 +365,7 @@ class TaskRepo {
452
365
  /**
453
366
  * 実行日時を一定期間過ぎたReadyタスクについて、Runningスタータスに変更した上で、Runningイベントを発生させる
454
367
  */
455
- async emitRunningIfExists(params, next // support next function(2025-08-02~)
456
- ) {
368
+ async emitRunningIfExists(params) {
457
369
  if (!(params.runsAt.$lt instanceof Date)) {
458
370
  throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
459
371
  }
@@ -471,15 +383,6 @@ class TaskRepo {
471
383
  ...(nameFilterBeforeRunsAt) ? { name: params.name } : undefined,
472
384
  runsAt: { $lt: params.runsAt.$lt },
473
385
  ...(!nameFilterBeforeRunsAt) ? { name: params.name } : undefined
474
- // ...(typeof nameEq === 'string' || Array.isArray(nameIn))
475
- // ? {
476
- // name: {
477
- // ...(typeof nameEq === 'string') ? { $eq: nameEq } : undefined,
478
- // // ...(Array.isArray(nameNin)) ? { $nin: nameNin } : undefined
479
- // ...(Array.isArray(nameIn)) ? { $in: nameIn } : undefined
480
- // }
481
- // }
482
- // : undefined
483
386
  };
484
387
  const doc = await this.taskModel.findOneAndUpdate(filter, {
485
388
  $set: {
@@ -518,7 +421,7 @@ class TaskRepo {
518
421
  status: factory_1.factory.taskStatus.Running
519
422
  };
520
423
  }
521
- task_1.taskEventEmitter.emitTaskStatusChanged(changedTask, (typeof next === 'function') ? next : undefined);
424
+ task_1.taskEventEmitter.emitTaskStatusChanged(changedTask);
522
425
  return doc;
523
426
  }
524
427
  /**
@@ -589,42 +492,6 @@ class TaskRepo {
589
492
  })
590
493
  .exec();
591
494
  }
592
- // public async abortOne(params: {
593
- // intervalInMinutes: number;
594
- // }): Promise<factory.task.ITask<factory.taskName> | null> {
595
- // const lastTriedAtShoudBeLessThan = moment()
596
- // .add(-params.intervalInMinutes, 'minutes')
597
- // .toDate();
598
- // const projection: ProjectionType<factory.task.ITask<factory.taskName>> = {
599
- // _id: 0,
600
- // id: { $toString: '$_id' },
601
- // ...Object.fromEntries<1>(AVAILABLE_PROJECT_FIELDS.map((key) => ([key, 1])))
602
- // };
603
- // const doc = await this.taskModel.findOneAndUpdate(
604
- // {
605
- // status: { $eq: factory.taskStatus.Running },
606
- // lastTriedAt: {
607
- // $type: 'date',
608
- // $lt: lastTriedAtShoudBeLessThan
609
- // },
610
- // remainingNumberOfTries: { $eq: 0 }
611
- // },
612
- // {
613
- // $set: {
614
- // status: factory.taskStatus.Aborted,
615
- // dateAborted: new Date()
616
- // }
617
- // },
618
- // { new: true, projection }
619
- // )
620
- // .lean<factory.task.ITask<factory.taskName>>() // lean(2024-09-26~)
621
- // .exec();
622
- // if (doc === null) {
623
- // // tslint:disable-next-line:no-null-keyword
624
- // return null;
625
- // }
626
- // return doc;
627
- // }
628
495
  async abortMany(params) {
629
496
  const lastTriedAtShoudBeLessThan = (0, moment_1.default)()
630
497
  .add(-params.intervalInMinutes, 'minutes')
@@ -668,47 +535,6 @@ class TaskRepo {
668
535
  task_1.taskEventEmitter.emitTaskStatusChanged(changedTask, next);
669
536
  }
670
537
  }
671
- async count(params) {
672
- const { limit } = params;
673
- const conditions = TaskRepo.CREATE_MONGO_CONDITIONS(params);
674
- const query = this.taskModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
675
- if (typeof limit === 'number' && limit >= 0) {
676
- query.limit(limit);
677
- }
678
- const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
679
- .exec();
680
- return { count };
681
- }
682
- /**
683
- * 検索する
684
- */
685
- async projectFields(params, inclusion) {
686
- const conditions = TaskRepo.CREATE_MONGO_CONDITIONS(params);
687
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
688
- if (Array.isArray(inclusion) && inclusion.length > 0) {
689
- positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
690
- }
691
- else {
692
- // no op
693
- }
694
- const projection = {
695
- _id: 0,
696
- id: { $toString: '$_id' },
697
- ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
698
- };
699
- const query = this.taskModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
700
- if (typeof params.limit === 'number' && params.limit > 0) {
701
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
702
- query.limit(params.limit)
703
- .skip(params.limit * (page - 1));
704
- }
705
- if (params.sort?.runsAt !== undefined) {
706
- query.sort({ runsAt: params.sort.runsAt });
707
- }
708
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
709
- .lean() // lean(2024-09-26~)
710
- .exec();
711
- }
712
538
  /**
713
539
  * タスクの状態を参照する
714
540
  * 非同期アクション移行が完了したら廃止する(2026-07-29~)
@@ -745,18 +571,6 @@ class TaskRepo {
745
571
  })
746
572
  .exec();
747
573
  }
748
- async deleteByName(params) {
749
- return this.taskModel.deleteMany({
750
- name: { $eq: params.name },
751
- ...(typeof params.status?.$eq === 'string') ? { status: { $eq: params.status.$eq } } : undefined,
752
- ...(params.runsAt?.$gte instanceof Date)
753
- ? {
754
- runsAt: { $gte: params.runsAt.$gte, $lte: params.runsAt.$lte }
755
- }
756
- : undefined
757
- })
758
- .exec();
759
- }
760
574
  /**
761
575
  * 不要なタスクを削除する
762
576
  */
@@ -790,135 +604,5 @@ class TaskRepo {
790
604
  .exec();
791
605
  return { count };
792
606
  }
793
- getCursor(conditions, projection) {
794
- return this.taskModel.find(conditions, projection)
795
- .sort({ runsAt: factory_1.factory.sortType.Ascending })
796
- .cursor();
797
- }
798
- async unsetUnnecessaryFields(params) {
799
- return this.taskModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
800
- .exec();
801
- }
802
- async aggregateTask(params) {
803
- const statuses = await Promise.all([
804
- factory_1.factory.taskStatus.Executed,
805
- factory_1.factory.taskStatus.Aborted
806
- ].map(async (taskStatus) => {
807
- const matchConditions = {
808
- runsAt: {
809
- $gte: params.runsFrom,
810
- $lte: params.runsThrough
811
- },
812
- status: { $eq: taskStatus },
813
- ...(typeof params.project?.id?.$ne === 'string')
814
- ? { 'project.id': { $ne: params.project.id.$ne } }
815
- : undefined
816
- };
817
- return this.agggregateByStatus({ matchConditions, status: taskStatus });
818
- }));
819
- return { statuses };
820
- }
821
- async agggregateByStatus(params) {
822
- const matchConditions = params.matchConditions;
823
- const taskStatus = params.status;
824
- const aggregate1 = this.taskModel.aggregate([
825
- {
826
- $match: matchConditions
827
- },
828
- {
829
- $project: {
830
- latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
831
- status: '$status',
832
- runsAt: '$runsAt',
833
- lastTriedAt: '$lastTriedAt'
834
- }
835
- },
836
- {
837
- $group: {
838
- _id: '$status',
839
- taskCount: { $sum: 1 },
840
- maxLatency: { $max: '$latency' },
841
- minLatency: { $min: '$latency' },
842
- avgLatency: { $avg: '$latency' }
843
- }
844
- },
845
- {
846
- $project: {
847
- _id: 0,
848
- taskCount: '$taskCount',
849
- avgLatency: '$avgLatency',
850
- maxLatency: '$maxLatency',
851
- minLatency: '$minLatency'
852
- }
853
- }
854
- ]);
855
- // const explainResult = await aggregate1.explain();
856
- // console.dir(explainResult, { depth: null });
857
- // return;
858
- const aggregations = await aggregate1.exec();
859
- const percents = [50, 95, 99];
860
- if (aggregations.length === 0) {
861
- return {
862
- status: taskStatus,
863
- aggregation: {
864
- taskCount: 0,
865
- avgLatency: 0,
866
- maxLatency: 0,
867
- minLatency: 0,
868
- percentilesLatency: percents.map((percent) => {
869
- return {
870
- name: String(percent),
871
- value: 0
872
- };
873
- })
874
- }
875
- };
876
- }
877
- const ranks4percentile = percents.map((percentile) => {
878
- return {
879
- percentile,
880
- rank: Math.floor(aggregations[0].taskCount * percentile / 100)
881
- };
882
- });
883
- const aggregate2 = this.taskModel.aggregate([
884
- {
885
- $match: matchConditions
886
- },
887
- {
888
- $project: {
889
- latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
890
- status: '$status',
891
- runsAt: '$runsAt',
892
- lastTriedAt: '$lastTriedAt'
893
- }
894
- },
895
- { $sort: { latency: 1 } },
896
- {
897
- $group: {
898
- _id: '$status',
899
- latencies: { $push: '$latency' }
900
- }
901
- },
902
- {
903
- $project: {
904
- _id: 0,
905
- percentilesLatency: ranks4percentile.map((rank) => {
906
- return {
907
- name: String(rank.percentile),
908
- value: { $arrayElemAt: ['$latencies', rank.rank] }
909
- };
910
- })
911
- }
912
- }
913
- ]);
914
- const aggregations2 = await aggregate2.exec();
915
- return {
916
- status: taskStatus,
917
- aggregation: {
918
- ...aggregations[0],
919
- ...aggregations2[0]
920
- }
921
- };
922
- }
923
607
  }
924
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';
@@ -86,6 +88,7 @@ import type { MemberSettingRepo } from './repo/setting/member';
86
88
  import type { RateLimitSettingRepo } from './repo/setting/rateLimit';
87
89
  import type { WaiterSettingRepo } from './repo/setting/waiter';
88
90
  import type { StockHolderRepo } from './repo/stockHolder';
91
+ import type { ScheduledTaskRepo } from './repo/scheduledTask';
89
92
  import type { TaskRepo } from './repo/task';
90
93
  import type { TicketRepo } from './repo/ticket';
91
94
  import type { TransactionRepo } from './repo/transaction';
@@ -159,10 +162,18 @@ export type AdditionalProperty = AdditionalPropertyRepo;
159
162
  export declare namespace AdditionalProperty {
160
163
  function createInstance(...params: ConstructorParameters<typeof AdditionalPropertyRepo>): Promise<AdditionalPropertyRepo>;
161
164
  }
165
+ export type AdminTask = AdminTaskRepo;
166
+ export declare namespace AdminTask {
167
+ function createInstance(...params: ConstructorParameters<typeof AdminTaskRepo>): Promise<AdminTaskRepo>;
168
+ }
162
169
  export type AggregateAction = AggregateActionRepo;
163
170
  export declare namespace AggregateAction {
164
171
  function createInstance(...params: ConstructorParameters<typeof AggregateActionRepo>): Promise<AggregateActionRepo>;
165
172
  }
173
+ export type AggregateTask = AggregateTaskRepo;
174
+ export declare namespace AggregateTask {
175
+ function createInstance(...params: ConstructorParameters<typeof AggregateTaskRepo>): Promise<AggregateTaskRepo>;
176
+ }
166
177
  export type AggregateOffer = AggregateOfferRepo;
167
178
  export declare namespace AggregateOffer {
168
179
  function createInstance(...params: ConstructorParameters<typeof AggregateOfferRepo>): Promise<AggregateOfferRepo>;
@@ -467,6 +478,10 @@ export type StockHolder = StockHolderRepo;
467
478
  export declare namespace StockHolder {
468
479
  function createInstance(...params: ConstructorParameters<typeof StockHolderRepo>): Promise<StockHolderRepo>;
469
480
  }
481
+ export type ScheduledTask = ScheduledTaskRepo;
482
+ export declare namespace ScheduledTask {
483
+ function createInstance(...params: ConstructorParameters<typeof ScheduledTaskRepo>): Promise<ScheduledTaskRepo>;
484
+ }
470
485
  export type Task = TaskRepo;
471
486
  export declare namespace Task {
472
487
  function createInstance(...params: ConstructorParameters<typeof TaskRepo>): Promise<TaskRepo>;
@@ -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.ScheduledTask = 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;
@@ -978,6 +1000,17 @@ var StockHolder;
978
1000
  }
979
1001
  StockHolder.createInstance = createInstance;
980
1002
  })(StockHolder || (exports.StockHolder = StockHolder = {}));
1003
+ var ScheduledTask;
1004
+ (function (ScheduledTask) {
1005
+ let repo;
1006
+ async function createInstance(...params) {
1007
+ if (repo === undefined) {
1008
+ repo = (await import('./repo/scheduledTask.js')).ScheduledTaskRepo;
1009
+ }
1010
+ return new repo(...params);
1011
+ }
1012
+ ScheduledTask.createInstance = createInstance;
1013
+ })(ScheduledTask || (exports.ScheduledTask = ScheduledTask = {}));
981
1014
  var Task;
982
1015
  (function (Task) {
983
1016
  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 },
@@ -1,6 +1,3 @@
1
- /**
2
- * 注文決済時処理
3
- */
4
1
  import type { TaskRepo } from '../../../repo/task';
5
2
  import { factory } from '../../../factory';
6
3
  declare function onOrderPaymentDue(params: {